2008-06-04 20:28:20 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2009-09-18 18:56:16 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <ogc/mutex.h>
|
|
|
|
#include <ogc/lwp_watchdog.h>
|
|
|
|
|
2008-08-11 22:43:00 +00:00
|
|
|
#include "common/config-manager.h"
|
2009-08-30 17:01:03 +00:00
|
|
|
#include "backends/fs/wii/wii-fs-factory.h"
|
2008-08-11 22:43:00 +00:00
|
|
|
|
|
|
|
#include "osystem.h"
|
2009-09-05 17:53:55 +00:00
|
|
|
#include "options.h"
|
2008-06-04 20:28:20 +00:00
|
|
|
|
|
|
|
OSystem_Wii::OSystem_Wii() :
|
|
|
|
_startup_time(0),
|
|
|
|
|
2009-08-30 17:01:03 +00:00
|
|
|
_cursorScale(1),
|
2008-06-04 20:28:20 +00:00
|
|
|
_cursorPaletteDisabled(true),
|
2009-08-30 17:01:03 +00:00
|
|
|
_cursorPalette(NULL),
|
|
|
|
_cursorPaletteDirty(false),
|
2008-06-04 20:28:20 +00:00
|
|
|
|
2009-08-30 17:01:03 +00:00
|
|
|
_gameRunning(false),
|
2008-06-04 20:28:20 +00:00
|
|
|
_gameWidth(0),
|
|
|
|
_gameHeight(0),
|
|
|
|
_gamePixels(NULL),
|
2009-08-30 17:01:03 +00:00
|
|
|
_gameDirty(false),
|
2008-06-04 20:28:20 +00:00
|
|
|
|
2009-08-30 17:01:03 +00:00
|
|
|
_overlayVisible(true),
|
2008-06-04 20:28:20 +00:00
|
|
|
_overlayWidth(0),
|
|
|
|
_overlayHeight(0),
|
|
|
|
_overlaySize(0),
|
|
|
|
_overlayPixels(NULL),
|
2009-08-30 17:01:03 +00:00
|
|
|
_overlayDirty(false),
|
2008-06-04 20:28:20 +00:00
|
|
|
|
|
|
|
_lastScreenUpdate(0),
|
|
|
|
_currentWidth(0),
|
|
|
|
_currentHeight(0),
|
2009-08-30 17:01:03 +00:00
|
|
|
_currentXScale(1),
|
|
|
|
_currentYScale(1),
|
2008-06-04 20:28:20 +00:00
|
|
|
|
2009-08-30 17:01:03 +00:00
|
|
|
_configGraphicsMode(0),
|
|
|
|
_actualGraphicsMode(0),
|
2009-09-03 17:52:38 +00:00
|
|
|
_bilinearFilter(false),
|
2009-08-22 08:49:23 +00:00
|
|
|
#ifdef USE_RGB_COLOR
|
2009-08-30 17:01:03 +00:00
|
|
|
_pfRGB565(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)),
|
|
|
|
_pfRGB3444(Graphics::PixelFormat(2, 4, 4, 4, 3, 8, 4, 0, 12)),
|
|
|
|
_pfGame(Graphics::PixelFormat::createFormatCLUT8()),
|
|
|
|
_pfGameTexture(Graphics::PixelFormat::createFormatCLUT8()),
|
|
|
|
_pfCursor(Graphics::PixelFormat::createFormatCLUT8()),
|
2009-08-22 08:49:23 +00:00
|
|
|
#endif
|
2008-08-11 22:43:00 +00:00
|
|
|
|
2009-09-01 19:33:47 +00:00
|
|
|
_optionsDlgActive(false),
|
2009-09-18 18:56:16 +00:00
|
|
|
_consoleVisible(false),
|
2008-08-11 22:43:00 +00:00
|
|
|
_fullscreen(false),
|
2009-08-30 17:01:03 +00:00
|
|
|
_arCorrection(false),
|
2008-06-04 20:28:20 +00:00
|
|
|
|
|
|
|
_mouseVisible(false),
|
|
|
|
_mouseX(0),
|
|
|
|
_mouseY(0),
|
|
|
|
_mouseHotspotX(0),
|
|
|
|
_mouseHotspotY(0),
|
|
|
|
_mouseKeyColor(0),
|
|
|
|
|
2009-02-15 15:28:05 +00:00
|
|
|
_kbd_active(false),
|
|
|
|
|
2008-06-07 15:37:17 +00:00
|
|
|
_event_quit(false),
|
|
|
|
|
2009-08-30 17:01:03 +00:00
|
|
|
_lastPadCheck(0),
|
2009-09-20 12:53:32 +00:00
|
|
|
_padSensitivity(16),
|
|
|
|
_padAcceleration(4),
|
2009-08-30 17:01:03 +00:00
|
|
|
|
2008-06-04 20:28:20 +00:00
|
|
|
_savefile(NULL),
|
|
|
|
_mixer(NULL),
|
|
|
|
_timer(NULL) {
|
|
|
|
}
|
|
|
|
|
|
|
|
OSystem_Wii::~OSystem_Wii() {
|
2009-08-30 17:01:03 +00:00
|
|
|
delete _savefile;
|
|
|
|
_savefile = NULL;
|
2008-06-04 20:28:20 +00:00
|
|
|
|
2009-08-30 17:01:03 +00:00
|
|
|
delete _mixer;
|
|
|
|
_mixer = NULL;
|
2008-06-04 20:28:20 +00:00
|
|
|
|
2009-08-30 17:01:03 +00:00
|
|
|
delete _timer;
|
|
|
|
_timer = NULL;
|
2008-06-04 20:28:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_Wii::initBackend() {
|
|
|
|
_startup_time = gettime();
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2009-09-05 17:53:55 +00:00
|
|
|
ConfMan.registerDefault("fullscreen", true);
|
|
|
|
ConfMan.registerDefault("aspect_ratio", true);
|
|
|
|
ConfMan.registerDefault("wii_video_default_underscan_x", 16);
|
|
|
|
ConfMan.registerDefault("wii_video_default_underscan_y", 16);
|
|
|
|
ConfMan.registerDefault("wii_video_ds_underscan_x", 16);
|
|
|
|
ConfMan.registerDefault("wii_video_ds_underscan_y", 16);
|
2009-09-20 12:53:32 +00:00
|
|
|
ConfMan.registerDefault("wii_pad_sensitivity", 48);
|
|
|
|
ConfMan.registerDefault("wii_pad_acceleration", 5);
|
2009-09-05 17:53:55 +00:00
|
|
|
ConfMan.registerDefault("wii_smb_server", "");
|
|
|
|
ConfMan.registerDefault("wii_smb_share", "");
|
|
|
|
ConfMan.registerDefault("wii_smb_username", "");
|
|
|
|
ConfMan.registerDefault("wii_smb_password", "");
|
|
|
|
|
|
|
|
WiiFilesystemFactory &fsf = WiiFilesystemFactory::instance();
|
|
|
|
|
|
|
|
#ifdef USE_WII_SMB
|
|
|
|
fsf.setSMBLoginData(ConfMan.get("wii_smb_server"),
|
|
|
|
ConfMan.get("wii_smb_share"),
|
|
|
|
ConfMan.get("wii_smb_username"),
|
|
|
|
ConfMan.get("wii_smb_password"));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
fsf.asyncInit();
|
|
|
|
|
2008-08-09 18:37:18 +00:00
|
|
|
char buf[MAXPATHLEN];
|
|
|
|
if (!getcwd(buf, MAXPATHLEN))
|
|
|
|
strcpy(buf, "/");
|
2008-06-04 20:28:20 +00:00
|
|
|
|
2008-08-09 18:37:18 +00:00
|
|
|
_savefile = new DefaultSaveFileManager(buf);
|
2008-07-06 12:04:19 +00:00
|
|
|
_mixer = new Audio::MixerImpl(this);
|
2008-06-04 20:28:20 +00:00
|
|
|
_timer = new DefaultTimerManager();
|
|
|
|
|
|
|
|
initGfx();
|
|
|
|
initSfx();
|
|
|
|
initEvents();
|
|
|
|
|
|
|
|
OSystem::initBackend();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_Wii::quit() {
|
|
|
|
deinitEvents();
|
|
|
|
deinitSfx();
|
|
|
|
deinitGfx();
|
2009-01-19 23:57:49 +00:00
|
|
|
|
2009-09-05 17:53:55 +00:00
|
|
|
WiiFilesystemFactory::instance().asyncDeinit();
|
2008-06-04 20:28:20 +00:00
|
|
|
}
|
|
|
|
|
2009-08-30 17:01:03 +00:00
|
|
|
void OSystem_Wii::engineInit() {
|
|
|
|
_gameRunning = true;
|
2009-09-05 17:53:55 +00:00
|
|
|
WiiFilesystemFactory::instance().umountUnused(ConfMan.get("path"));
|
2009-08-30 17:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_Wii::engineDone() {
|
|
|
|
_gameRunning = false;
|
2009-09-03 17:52:38 +00:00
|
|
|
switchVideoMode(gmStandard);
|
2009-08-30 17:01:03 +00:00
|
|
|
gfx_set_ar(4.0 / 3.0);
|
|
|
|
}
|
|
|
|
|
2008-06-04 20:28:20 +00:00
|
|
|
bool OSystem_Wii::hasFeature(Feature f) {
|
2008-08-11 22:43:00 +00:00
|
|
|
return (f == kFeatureFullscreenMode) ||
|
2009-08-30 17:01:03 +00:00
|
|
|
(f == kFeatureAspectRatioCorrection) ||
|
|
|
|
(f == kFeatureCursorHasPalette) ||
|
|
|
|
(f == kFeatureOverlaySupportsAlpha);
|
2008-06-04 20:28:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_Wii::setFeatureState(Feature f, bool enable) {
|
2008-08-11 22:43:00 +00:00
|
|
|
switch (f) {
|
|
|
|
case kFeatureFullscreenMode:
|
|
|
|
_fullscreen = enable;
|
2009-08-30 17:01:03 +00:00
|
|
|
gfx_set_pillarboxing(!enable);
|
|
|
|
break;
|
|
|
|
case kFeatureAspectRatioCorrection:
|
|
|
|
_arCorrection = enable;
|
2008-08-11 22:43:00 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-06-04 20:28:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_Wii::getFeatureState(Feature f) {
|
2008-08-11 22:43:00 +00:00
|
|
|
switch (f) {
|
|
|
|
case kFeatureFullscreenMode:
|
|
|
|
return _fullscreen;
|
2009-08-30 17:01:03 +00:00
|
|
|
case kFeatureAspectRatioCorrection:
|
|
|
|
return _arCorrection;
|
2008-08-11 22:43:00 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2008-06-04 20:28:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32 OSystem_Wii::getMillis() {
|
|
|
|
return ticks_to_millisecs(diff_ticks(_startup_time, gettime()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_Wii::delayMillis(uint msecs) {
|
|
|
|
usleep(msecs * 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
OSystem::MutexRef OSystem_Wii::createMutex() {
|
|
|
|
mutex_t *mutex = (mutex_t *) malloc(sizeof(mutex_t));
|
2009-01-02 17:58:54 +00:00
|
|
|
s32 res = LWP_MutexInit(mutex, true);
|
2008-06-04 20:28:20 +00:00
|
|
|
|
|
|
|
if (res) {
|
|
|
|
printf("ERROR creating mutex\n");
|
|
|
|
delete mutex;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (MutexRef) mutex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_Wii::lockMutex(MutexRef mutex) {
|
|
|
|
s32 res = LWP_MutexLock(*(mutex_t *) mutex);
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
printf("ERROR locking mutex %p (%d)\n", mutex, res);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_Wii::unlockMutex(MutexRef mutex) {
|
|
|
|
s32 res = LWP_MutexUnlock(*(mutex_t *) mutex);
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
printf("ERROR unlocking mutex %p (%d)\n", mutex, res);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_Wii::deleteMutex(MutexRef mutex) {
|
|
|
|
s32 res = LWP_MutexDestroy(*(mutex_t *) mutex);
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
printf("ERROR destroying mutex %p (%d)\n", mutex, res);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_Wii::setWindowCaption(const char *caption) {
|
|
|
|
printf("window caption: %s\n", caption);
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::SaveFileManager *OSystem_Wii::getSavefileManager() {
|
|
|
|
assert(_savefile);
|
|
|
|
return _savefile;
|
|
|
|
}
|
|
|
|
|
|
|
|
Audio::Mixer *OSystem_Wii::getMixer() {
|
|
|
|
assert(_mixer);
|
|
|
|
return _mixer;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::TimerManager *OSystem_Wii::getTimerManager() {
|
|
|
|
assert(_timer);
|
|
|
|
return _timer;
|
|
|
|
}
|
|
|
|
|
|
|
|
FilesystemFactory *OSystem_Wii::getFilesystemFactory() {
|
|
|
|
return &WiiFilesystemFactory::instance();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_Wii::getTimeAndDate(struct tm &t) const {
|
|
|
|
time_t curTime = time(0);
|
|
|
|
t = *localtime(&curTime);
|
|
|
|
}
|
|
|
|
|
2009-09-05 17:53:55 +00:00
|
|
|
void OSystem_Wii::showOptionsDialog() {
|
|
|
|
if (_optionsDlgActive)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool ds = (_actualGraphicsMode == gmDoubleStrike) ||
|
|
|
|
(_actualGraphicsMode == gmDoubleStrikeFiltered);
|
|
|
|
|
|
|
|
_optionsDlgActive = true;
|
|
|
|
WiiOptionsDialog dlg(ds);
|
|
|
|
dlg.runModal();
|
|
|
|
_optionsDlgActive = false;
|
2009-09-20 12:53:32 +00:00
|
|
|
|
|
|
|
_padSensitivity = 64 - ConfMan.getInt("wii_pad_sensitivity");
|
|
|
|
_padAcceleration = 9 - ConfMan.getInt("wii_pad_acceleration");
|
2009-09-05 17:53:55 +00:00
|
|
|
}
|
|
|
|
|