diff options
Diffstat (limited to 'backends')
97 files changed, 822 insertions, 2381 deletions
diff --git a/backends/base-backend.cpp b/backends/base-backend.cpp index 40e702495a..8d22ab732d 100644 --- a/backends/base-backend.cpp +++ b/backends/base-backend.cpp @@ -24,8 +24,16 @@ */ #include "backends/base-backend.h" + +#ifndef DISABLE_DEFAULT_EVENT_MANAGER #include "backends/events/default/default-events.h" +#endif + +#ifndef DISABLE_DEFAULT_AUDIOCD_MANAGER #include "backends/audiocd/default/default-audiocd.h" +#endif + + #include "gui/message.h" void BaseBackend::displayMessageOnOSD(const char *msg) { @@ -34,16 +42,20 @@ void BaseBackend::displayMessageOnOSD(const char *msg) { dialog.runModal(); } +void BaseBackend::initBackend() { + // Init Event manager +#ifndef DISABLE_DEFAULT_EVENT_MANAGER + if (!_eventManager) + _eventManager = new DefaultEventManager(getDefaultEventSource()); +#endif -static Common::EventManager *s_eventManager = 0; + // Init audio CD manager +#ifndef DISABLE_DEFAULT_AUDIOCD_MANAGER + if (!_audiocdManager) + _audiocdManager = new DefaultAudioCDManager(); +#endif -Common::EventManager *BaseBackend::getEventManager() { - // FIXME/TODO: Eventually this method should be turned into an abstract one, - // to force backends to implement this conciously (even if they - // end up returning the default event manager anyway). - if (!s_eventManager) - s_eventManager = new DefaultEventManager(this); - return s_eventManager; + OSystem::initBackend(); } void BaseBackend::fillScreen(uint32 col) { @@ -52,49 +64,3 @@ void BaseBackend::fillScreen(uint32 col) { memset(screen->pixels, col, screen->h * screen->pitch); unlockScreen(); } - - -/* - FIXME: Maybe we should push the default config file loading/saving code below - out to all the backends? -*/ - - -#if defined(POSIX) -#define DEFAULT_CONFIG_FILE ".scummvmrc" -#endif - -#if !defined(POSIX) -#define DEFAULT_CONFIG_FILE "scummvm.ini" -#endif - -BaseBackend::BaseBackend() { - _audiocdManager = 0; -} - -BaseBackend::~BaseBackend() { - delete _audiocdManager; -} - -Common::SeekableReadStream *BaseBackend::createConfigReadStream() { - Common::FSNode file(DEFAULT_CONFIG_FILE); - return file.createReadStream(); -} - -Common::WriteStream *BaseBackend::createConfigWriteStream() { -#ifdef __DC__ - return 0; -#else - Common::FSNode file(DEFAULT_CONFIG_FILE); - return file.createWriteStream(); -#endif -} - -AudioCDManager *BaseBackend::getAudioCDManager() { - if (!_audiocdManager) - _audiocdManager = new DefaultAudioCDManager(); - return _audiocdManager; -} - -void BaseBackend::resetGraphicsScale() { -} diff --git a/backends/base-backend.h b/backends/base-backend.h index 864c11544a..c797e831a8 100644 --- a/backends/base-backend.h +++ b/backends/base-backend.h @@ -24,26 +24,22 @@ #define BACKENDS_BASE_BACKEND_H #include "common/system.h" -#include "backends/events/default/default-events.h" +#include "common/events.h" -class BaseBackend : public OSystem, Common::EventSource { +class BaseBackend : public OSystem { +protected: + virtual Common::EventSource *getDefaultEventSource() = 0; public: - BaseBackend(); - ~BaseBackend(); + virtual void initBackend(); - virtual Common::EventManager *getEventManager(); virtual void displayMessageOnOSD(const char *msg); virtual void fillScreen(uint32 col); +}; - virtual Common::SeekableReadStream *createConfigReadStream(); - virtual Common::WriteStream *createConfigWriteStream(); - - virtual AudioCDManager *getAudioCDManager(); - - virtual void resetGraphicsScale(); - +class EventsBaseBackend : public BaseBackend, Common::EventSource { protected: - AudioCDManager *_audiocdManager; + virtual Common::EventSource *getDefaultEventSource() { return this; } +public: }; diff --git a/backends/events/gp2xsdl/gp2xsdl-events.cpp b/backends/events/gp2xsdl/gp2xsdl-events.cpp deleted file mode 100644 index 86d4de384f..0000000000 --- a/backends/events/gp2xsdl/gp2xsdl-events.cpp +++ /dev/null @@ -1,463 +0,0 @@ -/* 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. - * - */ - -#include "common/scummsys.h" - -#if defined(GP2X_OLD) - -#include "backends/events/gp2xsdl/gp2xsdl-events.h" -#include "backends/platform/gp2x/gp2x-hw.h" -#include "backends/graphics/gp2xsdl/gp2xsdl-graphics.h" - -#include "backends/platform/sdl/sdl.h" - -// FIXME move joystick defines out and replace with confile file options -// we should really allow users to map any key to a joystick button using the keymapper. -#define JOY_DEADZONE 2200 - -#define JOY_XAXIS 0 -#define JOY_YAXIS 1 - -/* Quick default button states for modifiers. */ -int BUTTON_STATE_L = false; - -enum { - /* DPAD/Stick */ - BUTTON_UP = 0, - BUTTON_UPLEFT = 1, - BUTTON_LEFT = 2, - BUTTON_DOWNLEFT = 3, - BUTTON_DOWN = 4, - BUTTON_DOWNRIGHT = 5, - BUTTON_RIGHT = 6, - BUTTON_UPRIGHT = 7, - /* Joystick Buttons */ - BUTTON_MENU = 8, // Start on F100 GP2X - BUTTON_SELECT = 9, - BUTTON_L = 10, - BUTTON_R = 11, - BUTTON_A = 12, - BUTTON_B = 13, - BUTTON_X = 14, - BUTTON_Y = 15, - BUTTON_VOLUP = 16, - BUTTON_VOLDOWN = 17, - BUTTON_CLICK = 18 -}; - -enum { - /* Unused Joystick Buttons on the GP2X */ - BUTTON_HOME = 51, - BUTTON_HOLD = 52, - BUTTON_HELP = 53, - BUTTON_HELP2 = 54 -}; - -enum { - /* Touchscreen TapMode */ - TAPMODE_LEFT = 0, - TAPMODE_RIGHT = 1, - TAPMODE_HOVER = 2 -}; - -GP2XSdlEventSource::GP2XSdlEventSource() - : _buttonStateL(false){ -} - -void GP2XSdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) { - event.kbd.flags = 0; - - if (mod & KMOD_SHIFT) - event.kbd.flags |= Common::KBD_SHIFT; - if (mod & KMOD_ALT) - event.kbd.flags |= Common::KBD_ALT; - if (mod & KMOD_CTRL) - event.kbd.flags |= Common::KBD_CTRL; - - // Sticky flags - if (mod & KMOD_NUM) - event.kbd.flags |= Common::KBD_NUM; - if (mod & KMOD_CAPS) - event.kbd.flags |= Common::KBD_CAPS; -} - -void GP2XSdlEventSource::moveStick() { - bool stickBtn[32]; - - memcpy(stickBtn, _stickBtn, sizeof(stickBtn)); - - if ((stickBtn[0])||(stickBtn[2])||(stickBtn[4])||(stickBtn[6])) - stickBtn[1] = stickBtn[3] = stickBtn[5] = stickBtn[7] = 0; - - if ((stickBtn[1])||(stickBtn[2])||(stickBtn[3])) { - if (_km.x_down_count!=2) { - _km.x_vel = -1; - _km.x_down_count = 1; - } else - _km.x_vel = -4; - } else if ((stickBtn[5])||(stickBtn[6])||(stickBtn[7])) { - if (_km.x_down_count!=2) { - _km.x_vel = 1; - _km.x_down_count = 1; - } else - _km.x_vel = 4; - } else { - _km.x_vel = 0; - _km.x_down_count = 0; - } - - if ((stickBtn[0])||(stickBtn[1])||(stickBtn[7])) { - if (_km.y_down_count!=2) { - _km.y_vel = -1; - _km.y_down_count = 1; - } else - _km.y_vel = -4; - } else if ((stickBtn[3])||(stickBtn[4])||(stickBtn[5])) { - if (_km.y_down_count!=2) { - _km.y_vel = 1; - _km.y_down_count = 1; - } else - _km.y_vel = 4; - } else { - _km.y_vel = 0; - _km.y_down_count = 0; - } -} - -/* GP2X Input mappings. -Single Button - -Movement: - -GP2X_BUTTON_UP Cursor Up -GP2X_BUTTON_DOWN Cursor Down -GP2X_BUTTON_LEFT Cursor Left -GP2X_BUTTON_RIGHT Cursor Right - -GP2X_BUTTON_UPLEFT Cursor Up Left -GP2X_BUTTON_UPRIGHT Cursor Up Right -GP2X_BUTTON_DOWNLEFT Cursor Down Left -GP2X_BUTTON_DOWNRIGHT Cursor Down Right - -Button Emulation: - -GP2X_BUTTON_CLICK Left Mouse Click (GP2X only) -GP2X_BUTTON_A . (Period) -GP2X_BUTTON_B Left Mouse Click -GP2X_BUTTON_Y Space Bar -GP2X_BUTTON_X Right Mouse Click -GP2X_BUTTON_L Combo Modifier (Left Trigger) -GP2X_BUTTON_R Return (Right Trigger) -GP2X_BUTTON_MENU F5 (Game Menu) -GP2X_BUTTON_SELECT Escape -GP2X_BUTTON_VOLUP /dev/mixer Global Volume Up -GP2X_BUTTON_VOLDOWN /dev/mixer Global Volume Down - -Combos: - -GP2X_BUTTON_VOLUP & GP2X_BUTTON_VOLDOWN 0 (For Monkey 2 CP) or Virtual Keyboard if enabled -GP2X_BUTTON_L & GP2X_BUTTON_SELECT Common::EVENT_QUIT (Calls Sync() to make sure SD is flushed) -GP2X_BUTTON_L & GP2X_BUTTON_MENU Common::EVENT_MAINMENU (ScummVM Global Main Menu) -GP2X_BUTTON_L & GP2X_BUTTON_A Common::EVENT_PREDICTIVE_DIALOG for predictive text entry box (AGI games) -GP2X_BUTTON_L & GP2X_BUTTON_Y Toggles setZoomOnMouse() for larger then 320*240 games to scale to the point + raduis. (GP2X only) -*/ - -bool GP2XSdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) { - SDLModToOSystemKeyFlags(SDL_GetModState(), event); - - if (remapKey(ev, event)) - return true; - - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; - event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); - - return true; -} - -bool GP2XSdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { - - _stickBtn[ev.jbutton.button] = 1; - event.kbd.flags = 0; - - switch (ev.jbutton.button) { - case BUTTON_UP: - case BUTTON_UPLEFT: - case BUTTON_LEFT: - case BUTTON_DOWNLEFT: - case BUTTON_DOWN: - case BUTTON_DOWNRIGHT: - case BUTTON_RIGHT: - case BUTTON_UPRIGHT: - moveStick(); - event.type = Common::EVENT_MOUSEMOVE; - fillMouseEvent(event, _km.x, _km.y); - break; - case BUTTON_B: - case BUTTON_CLICK: - if (BUTTON_STATE_L == true) { - ((GP2XSdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->toggleZoomOnMouse(); - fillMouseEvent(event, _km.x, _km.y); - } else { - event.type = Common::EVENT_LBUTTONDOWN; - fillMouseEvent(event, _km.x, _km.y); - } - break; - case BUTTON_X: - event.type = Common::EVENT_RBUTTONDOWN; - fillMouseEvent(event, _km.x, _km.y); - break; - case BUTTON_L: - BUTTON_STATE_L = true; - break; - case BUTTON_R: - event.type = Common::EVENT_KEYDOWN; - if (BUTTON_STATE_L == true) { -#ifdef ENABLE_VKEYBD - event.kbd.keycode = Common::KEYCODE_F7; - event.kbd.ascii = mapKey(SDLK_F7, ev.key.keysym.mod, 0); -#else - event.kbd.keycode = Common::KEYCODE_0; - event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0); -#endif - } else { - event.kbd.keycode = Common::KEYCODE_RETURN; - event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0); - } - break; - case BUTTON_SELECT: - case BUTTON_HOME: - event.type = Common::EVENT_KEYDOWN; - if (BUTTON_STATE_L == true) { - event.type = Common::EVENT_QUIT; - } else { - event.kbd.keycode = Common::KEYCODE_ESCAPE; - event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0); - } - break; - case BUTTON_A: - event.type = Common::EVENT_KEYDOWN; - if (BUTTON_STATE_L == true) { - event.type = Common::EVENT_PREDICTIVE_DIALOG; - } else { - event.kbd.keycode = Common::KEYCODE_PERIOD; - event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0); - } - break; - case BUTTON_Y: - event.type = Common::EVENT_KEYDOWN; - if (BUTTON_STATE_L == true) { - GPH::ToggleTapMode(); - if (GPH::tapmodeLevel == TAPMODE_LEFT) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Left Click"); - } else if (GPH::tapmodeLevel == TAPMODE_RIGHT) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Right Click"); - } else if (GPH::tapmodeLevel == TAPMODE_HOVER) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Hover (No Click)"); - } - } else { - event.kbd.keycode = Common::KEYCODE_SPACE; - event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0); - } - break; - case BUTTON_MENU: - case BUTTON_HELP: - event.type = Common::EVENT_KEYDOWN; - if (BUTTON_STATE_L == true) { - event.type = Common::EVENT_MAINMENU; - } else { - event.kbd.keycode = Common::KEYCODE_F5; - event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0); - } - break; - case BUTTON_VOLUP: - GP2X_HW::mixerMoveVolume(2); - if (GP2X_HW::volumeLevel == 100) { - g_system->displayMessageOnOSD("Maximum Volume"); - } else { - g_system->displayMessageOnOSD("Increasing Volume"); - } - break; - - case BUTTON_VOLDOWN: - GP2X_HW::mixerMoveVolume(1); - if (GP2X_HW::volumeLevel == 0) { - g_system->displayMessageOnOSD("Minimal Volume"); - } else { - g_system->displayMessageOnOSD("Decreasing Volume"); - } - break; - case BUTTON_HOLD: - event.type = Common::EVENT_QUIT; - break; - case BUTTON_HELP2: - GPH::ToggleTapMode(); - if (GPH::tapmodeLevel == TAPMODE_LEFT) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Left Click"); - } else if (GPH::tapmodeLevel == TAPMODE_RIGHT) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Right Click"); - } else if (GPH::tapmodeLevel == TAPMODE_HOVER) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Hover (No Click)"); - } - break; - } - return true; -} - -bool GP2XSdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { - _stickBtn[ev.jbutton.button] = 0; - event.kbd.flags = 0; - - switch (ev.jbutton.button) { - case BUTTON_UP: - case BUTTON_UPLEFT: - case BUTTON_LEFT: - case BUTTON_DOWNLEFT: - case BUTTON_DOWN: - case BUTTON_DOWNRIGHT: - case BUTTON_RIGHT: - case BUTTON_UPRIGHT: - moveStick(); - event.type = Common::EVENT_MOUSEMOVE; - fillMouseEvent(event, _km.x, _km.y); - break; - case BUTTON_B: - case BUTTON_CLICK: - if (BUTTON_STATE_L == true) { - break; - } else { - event.type = Common::EVENT_LBUTTONUP; - fillMouseEvent(event, _km.x, _km.y); - } - break; - case BUTTON_X: - event.type = Common::EVENT_RBUTTONUP; - fillMouseEvent(event, _km.x, _km.y); - break; - case BUTTON_L: - BUTTON_STATE_L = false; - break; - case BUTTON_SELECT: - case BUTTON_HOME: - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_ESCAPE; - event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0); - break; - case BUTTON_A: - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_PERIOD; - event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0); - break; - case BUTTON_Y: - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_SPACE; - event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0); - break; - case BUTTON_MENU: - case BUTTON_HELP: - event.type = Common::EVENT_KEYUP; - if (BUTTON_STATE_L == true) { - event.type = Common::EVENT_MAINMENU; - } else { - event.kbd.keycode = Common::KEYCODE_F5; - event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0); - } - break; - case BUTTON_R: - event.type = Common::EVENT_KEYUP; - if (BUTTON_STATE_L == true) { -#ifdef ENABLE_VKEYBD - event.kbd.keycode = Common::KEYCODE_F7; - event.kbd.ascii = mapKey(SDLK_F7, ev.key.keysym.mod, 0); -#else - event.kbd.keycode = Common::KEYCODE_0; - event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0); -#endif - } else { - event.kbd.keycode = Common::KEYCODE_RETURN; - event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0); - } - break; - case BUTTON_VOLUP: - break; - case BUTTON_VOLDOWN: - break; - case BUTTON_HOLD: - break; - case BUTTON_HELP2: - break; - } - return true; -} - -bool GP2XSdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) { - int axis = ev.jaxis.value; - if ( axis > JOY_DEADZONE) { - axis -= JOY_DEADZONE; - event.type = Common::EVENT_MOUSEMOVE; - } else if ( axis < -JOY_DEADZONE ) { - axis += JOY_DEADZONE; - event.type = Common::EVENT_MOUSEMOVE; - } else - axis = 0; - - if ( ev.jaxis.axis == JOY_XAXIS) { -#ifdef JOY_ANALOG - _km.x_vel = axis/2000; - _km.x_down_count = 0; -#else - if (axis != 0) { - _km.x_vel = (axis > 0) ? 1:-1; - _km.x_down_count = 1; - } else { - _km.x_vel = 0; - _km.x_down_count = 0; - } -#endif - - } else if (ev.jaxis.axis == JOY_YAXIS) { -#ifndef JOY_INVERT_Y - axis = -axis; -#endif -#ifdef JOY_ANALOG - _km.y_vel = -axis / 2000; - _km.y_down_count = 0; -#else - if (axis != 0) { - _km.y_vel = (-axis > 0) ? 1: -1; - _km.y_down_count = 1; - } else { - _km.y_vel = 0; - _km.y_down_count = 0; - } -#endif - } - - fillMouseEvent(event, _km.x, _km.y); - return true; -} - -bool GP2XSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { - return false; -} - -#endif diff --git a/backends/events/gp2xsdl/gp2xsdl-events.h b/backends/events/gp2xsdl/gp2xsdl-events.h deleted file mode 100644 index 0d74c1bcac..0000000000 --- a/backends/events/gp2xsdl/gp2xsdl-events.h +++ /dev/null @@ -1,56 +0,0 @@ -/* 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. - * - */ - -#if !defined(BACKEND_EVENTS_SDL_GP2X_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER) -#define BACKEND_EVENTS_SDL_GP2X_H - -#include "backends/events/sdl/sdl-events.h" - -/** - * SDL events manager for GP2X - */ -class GP2XSdlEventSource : public SdlEventSource { -public: - GP2XSdlEventSource(); - -protected: - bool _stickBtn[32]; - - /** Button state for L button modifier */ - bool _buttonStateL; - - /** - * Handles the stick movement - */ - void moveStick(); - - virtual bool handleKeyDown(SDL_Event &ev, Common::Event &event); - virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event); - virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event); - virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event); - - virtual void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event); - - virtual bool remapKey(SDL_Event &ev, Common::Event &event); -}; - -#endif diff --git a/backends/events/gph/gph-events.cpp b/backends/events/gph/gph-events.cpp index d2b3483f84..b461f85fbb 100644 --- a/backends/events/gph/gph-events.cpp +++ b/backends/events/gph/gph-events.cpp @@ -34,6 +34,7 @@ #include "common/util.h" #include "common/events.h" +#include "common/translation.h" #define JOY_DEADZONE 2200 @@ -186,7 +187,6 @@ GPHEventSource::GPHEventSource() // } //} - void GPHEventSource::moveStick() { bool stickBtn[32]; @@ -363,11 +363,11 @@ bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { if (BUTTON_STATE_L == true) { GPH::ToggleTapMode(); if (GPH::tapmodeLevel == TAPMODE_LEFT) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Left Click"); + g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Left Click")); } else if (GPH::tapmodeLevel == TAPMODE_RIGHT) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Right Click"); + g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Right Click")); } else if (GPH::tapmodeLevel == TAPMODE_HOVER) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Hover (No Click)"); + g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (No Click)")); } } else { event.kbd.keycode = Common::KEYCODE_SPACE; @@ -387,17 +387,17 @@ bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { case BUTTON_VOLUP: WIZ_HW::mixerMoveVolume(2); if (WIZ_HW::volumeLevel == 100) { - g_system->displayMessageOnOSD("Maximum Volume"); + g_system->displayMessageOnOSD(_("Maximum Volume")); } else { - g_system->displayMessageOnOSD("Increasing Volume"); + g_system->displayMessageOnOSD(_("Increasing Volume")); } break; case BUTTON_VOLDOWN: WIZ_HW::mixerMoveVolume(1); if (WIZ_HW::volumeLevel == 0) { - g_system->displayMessageOnOSD("Minimal Volume"); + g_system->displayMessageOnOSD(_("Minimal Volume")); } else { - g_system->displayMessageOnOSD("Decreasing Volume"); + g_system->displayMessageOnOSD(_("Decreasing Volume")); } break; case BUTTON_HOLD: @@ -406,11 +406,11 @@ bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { case BUTTON_HELP2: GPH::ToggleTapMode(); if (GPH::tapmodeLevel == TAPMODE_LEFT) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Left Click"); + g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Left Click")); } else if (GPH::tapmodeLevel == TAPMODE_RIGHT) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Right Click"); + g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Right Click")); } else if (GPH::tapmodeLevel == TAPMODE_HOVER) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Hover (No Click)"); + g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (No Click)")); } break; } diff --git a/backends/events/openpandora/op-events.cpp b/backends/events/openpandora/op-events.cpp index 381cbf89e9..72bc56c95d 100644 --- a/backends/events/openpandora/op-events.cpp +++ b/backends/events/openpandora/op-events.cpp @@ -24,7 +24,6 @@ /* * OpenPandora: Device Specific Event Handling. - * */ #if defined(OPENPANDORA) @@ -34,6 +33,10 @@ #include "backends/platform/openpandora/op-sdl.h" #include "backends/platform/openpandora/op-options.h" +#include "common/translation.h" +#include "common/util.h" +#include "common/events.h" + /* Quick default button states for modifiers. */ int BUTTON_STATE_L = false; @@ -48,6 +51,68 @@ OPEventSource::OPEventSource() : _buttonStateL(false){ } +/* Custom handleMouseButtonDown/handleMouseButtonUp to deal with 'Tap Mode' for the touchscreen */ + +bool OPEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) { + if (ev.button.button == SDL_BUTTON_LEFT){ + if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */ + event.type = Common::EVENT_RBUTTONDOWN; + else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */ + event.type = Common::EVENT_LBUTTONDOWN; + else if (OP::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */ + event.type = Common::EVENT_RBUTTONDOWN; + else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ + event.type = Common::EVENT_MOUSEMOVE; + else + event.type = Common::EVENT_LBUTTONDOWN; /* For normal mice etc. */ + } + else if (ev.button.button == SDL_BUTTON_RIGHT) + event.type = Common::EVENT_RBUTTONDOWN; +#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN) + else if (ev.button.button == SDL_BUTTON_WHEELUP) + event.type = Common::EVENT_WHEELUP; + else if (ev.button.button == SDL_BUTTON_WHEELDOWN) + event.type = Common::EVENT_WHEELDOWN; +#endif +#if defined(SDL_BUTTON_MIDDLE) + else if (ev.button.button == SDL_BUTTON_MIDDLE) + event.type = Common::EVENT_MBUTTONDOWN; +#endif + else + return false; + + fillMouseEvent(event, ev.button.x, ev.button.y); + + return true; +} + +bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { + if (ev.button.button == SDL_BUTTON_LEFT){ + if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */ + event.type = Common::EVENT_RBUTTONUP; + else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */ + event.type = Common::EVENT_LBUTTONUP; + else if (OP::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */ + event.type = Common::EVENT_RBUTTONUP; + else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ + event.type = Common::EVENT_MOUSEMOVE; + else + event.type = Common::EVENT_LBUTTONUP; /* For normal mice etc. */ + } + else if (ev.button.button == SDL_BUTTON_RIGHT) + event.type = Common::EVENT_RBUTTONUP; +#if defined(SDL_BUTTON_MIDDLE) + else if (ev.button.button == SDL_BUTTON_MIDDLE) + event.type = Common::EVENT_MBUTTONUP; +#endif + else + return false; + + fillMouseEvent(event, ev.button.x, ev.button.y); + + return true; +} + /* On the OpenPandora by default the ABXY and L/R Trigger buttons are returned by SDL as (A): SDLK_HOME (B): SDLK_END (X): SDLK_PAGEDOWN (Y): SDLK_PAGEUP (L): SDLK_RSHIFT (R): SDLK_RCTRL */ @@ -73,11 +138,11 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { case SDLK_PAGEUP: OP::ToggleTapMode(); if (OP::tapmodeLevel == TAPMODE_LEFT) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Left Click"); + g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Left Click")); } else if (OP::tapmodeLevel == TAPMODE_RIGHT) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Right Click"); + g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Right Click")); } else if (OP::tapmodeLevel == TAPMODE_HOVER) { - g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Hover (No Click)"); + g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (No Click)")); } break; case SDLK_RSHIFT: @@ -122,65 +187,4 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { return false; } -/* Custom handleMouseButtonDown/handleMouseButtonUp to deal with 'Tap Mode' for the touchscreen */ - -bool OPEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) { - if (ev.button.button == SDL_BUTTON_LEFT){ - if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */ - event.type = Common::EVENT_RBUTTONDOWN; - else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */ - event.type = Common::EVENT_LBUTTONDOWN; - else if (OP::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */ - event.type = Common::EVENT_RBUTTONDOWN; - else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ - event.type = Common::EVENT_MOUSEMOVE; - else - event.type = Common::EVENT_LBUTTONDOWN; /* For normal mice etc. */ - } - else if (ev.button.button == SDL_BUTTON_RIGHT) - event.type = Common::EVENT_RBUTTONDOWN; -#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN) - else if (ev.button.button == SDL_BUTTON_WHEELUP) - event.type = Common::EVENT_WHEELUP; - else if (ev.button.button == SDL_BUTTON_WHEELDOWN) - event.type = Common::EVENT_WHEELDOWN; -#endif -#if defined(SDL_BUTTON_MIDDLE) - else if (ev.button.button == SDL_BUTTON_MIDDLE) - event.type = Common::EVENT_MBUTTONDOWN; -#endif - else - return false; - - fillMouseEvent(event, ev.button.x, ev.button.y); - - return true; -} - -bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { - if (ev.button.button == SDL_BUTTON_LEFT){ - if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */ - event.type = Common::EVENT_RBUTTONUP; - else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */ - event.type = Common::EVENT_LBUTTONUP; - else if (OP::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */ - event.type = Common::EVENT_RBUTTONUP; - else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ - event.type = Common::EVENT_MOUSEMOVE; - else - event.type = Common::EVENT_LBUTTONUP; /* For normal mice etc. */ - } - else if (ev.button.button == SDL_BUTTON_RIGHT) - event.type = Common::EVENT_RBUTTONUP; -#if defined(SDL_BUTTON_MIDDLE) - else if (ev.button.button == SDL_BUTTON_MIDDLE) - event.type = Common::EVENT_MBUTTONUP; -#endif - else - return false; - - fillMouseEvent(event, ev.button.x, ev.button.y); - - return true; -} #endif diff --git a/backends/events/openpandora/op-events.h b/backends/events/openpandora/op-events.h index 9aa637992a..25f79e68d7 100644 --- a/backends/events/openpandora/op-events.h +++ b/backends/events/openpandora/op-events.h @@ -28,17 +28,22 @@ /** * Events manager for the OpenPandora. */ + class OPEventSource : public SdlEventSource { public: OPEventSource(); protected: - /** Button state for L button modifier */ + + /** + * Button state for L button modifier + */ bool _buttonStateL; - bool remapKey(SDL_Event &ev, Common::Event &event); + bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event); bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event); + bool remapKey(SDL_Event &ev, Common::Event &event); }; #endif /* BACKEND_EVENTS_OP_H */ diff --git a/backends/events/wincesdl/wincesdl-events.cpp b/backends/events/wincesdl/wincesdl-events.cpp index f15a416b76..4fab47a58e 100644 --- a/backends/events/wincesdl/wincesdl-events.cpp +++ b/backends/events/wincesdl/wincesdl-events.cpp @@ -35,7 +35,7 @@ WINCESdlEventSource::WINCESdlEventSource() : _tapTime(0), _closeClick(false), _rbutton(false), - _freeLook(false), _graphicsMan(0) { + _graphicsMan(0) { } void WINCESdlEventSource::init(WINCESdlGraphicsManager *graphicsMan) { @@ -64,6 +64,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) { ev.type = SDL_NOEVENT; DWORD currentTime; bool keyEvent = false; + bool freeLookActive = _graphicsMan->getFreeLookState(); int deltaX, deltaY; memset(&event, 0, sizeof(Common::Event)); @@ -199,7 +200,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) { } } - if (_freeLook && !_closeClick) { + if (freeLookActive && !_closeClick) { _rbutton = false; _tapTime = 0; _tapX = event.mouse.x; @@ -241,7 +242,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) { fillMouseEvent(event, ev.button.x, ev.button.y); - if (_freeLook && !_closeClick) { + if (freeLookActive && !_closeClick) { _tapX = event.mouse.x; _tapY = event.mouse.y; event.type = Common::EVENT_MOUSEMOVE; @@ -322,8 +323,4 @@ int WINCESdlEventSource::mapKeyCE(SDLKey key, SDLMod mod, Uint16 unicode, bool u return key; } -void WINCESdlEventSource::swap_freeLook() { - _freeLook = !_freeLook; -} - #endif /* _WIN32_WCE */ diff --git a/backends/events/wincesdl/wincesdl-events.h b/backends/events/wincesdl/wincesdl-events.h index 734cc899c0..deeee6196c 100644 --- a/backends/events/wincesdl/wincesdl-events.h +++ b/backends/events/wincesdl/wincesdl-events.h @@ -45,8 +45,6 @@ public: // Overloaded from SDL backend (mouse and new scaler handling) void fillMouseEvent(Common::Event &event, int x, int y); - void swap_freeLook(); - protected: private: @@ -61,8 +59,6 @@ private: bool _closeClick; // flag when taps are spatially close together bool _rbutton; // double tap -> right button simulation - bool _freeLook; // freeLook mode (do not send mouse button events) - }; #endif diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp index 6c11ddc605..e3f282df05 100644 --- a/backends/fs/ds/ds-fs.cpp +++ b/backends/fs/ds/ds-fs.cpp @@ -602,35 +602,11 @@ size_t std_fread(void *ptr, size_t size, size_t numItems, FILE *handle) { } size_t std_fwrite(const void *ptr, size_t size, size_t numItems, FILE *handle) { - if ((handle == stdin)) - return 0; - - if ((handle == stderr) || (handle == stdout)) { -#ifndef DISABLE_TEXT_CONSOLE - nocashMessage((char *) ptr); -// consolePrintf((char *) ptr); -#endif - return size; - } - //consolePrintf("fwrite size=%d\n", size * numItems); if (DS::isGBAMPAvailable()) { FAT_fwrite(ptr, size, numItems, (FAT_FILE *) handle); return numItems; - - int length = size * numItems; - int pos = 0; - - while (pos < length) { - int amount = length > 512? 512: length; - - FAT_fwrite(((char *) (ptr)) + pos, 1, amount, (FAT_FILE *) handle); - length -= amount; - pos += amount; - } - - return numItems; } return 0; diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/fs/posix/posix-fs-factory.cpp index ccff8a8b42..829355be84 100644 --- a/backends/fs/posix/posix-fs-factory.cpp +++ b/backends/fs/posix/posix-fs-factory.cpp @@ -26,6 +26,7 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_time_h #define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h #define FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_exit //Needed for IRIX's unistd.h #include "backends/fs/posix/posix-fs-factory.h" #include "backends/fs/posix/posix-fs.h" diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 08a7601c17..0b94c37b16 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -27,6 +27,7 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h #define FORBIDDEN_SYMBOL_EXCEPTION_mkdir #define FORBIDDEN_SYMBOL_EXCEPTION_getenv +#define FORBIDDEN_SYMBOL_EXCEPTION_exit //Needed for IRIX's unistd.h #include "backends/fs/posix/posix-fs.h" #include "backends/fs/stdiostream.h" diff --git a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp index 6690244fb7..8a141e97a5 100644 --- a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp +++ b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp @@ -468,7 +468,7 @@ bool DINGUXSdlGraphicsManager::loadGFXMode() { bool DINGUXSdlGraphicsManager::hasFeature(OSystem::Feature f) { return (f == OSystem::kFeatureAspectRatioCorrection) || - (f == OSystem::kFeatureCursorHasPalette); + (f == OSystem::kFeatureCursorPalette); } void DINGUXSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { diff --git a/backends/graphics/gp2xsdl/gp2xsdl-graphics.cpp b/backends/graphics/gp2xsdl/gp2xsdl-graphics.cpp deleted file mode 100644 index 6e5a35a1b1..0000000000 --- a/backends/graphics/gp2xsdl/gp2xsdl-graphics.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* 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. - * - */ - -#include "common/scummsys.h" - -#if defined(GP2X_OLD) - -#include "backends/graphics/gp2xsdl/gp2xsdl-graphics.h" -#include "graphics/scaler/aspect.h" -#include <SDL_gp2x.h> - -static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { - {"Fullscreen", "1x", GFX_NORMAL}, - {0, 0, 0} -}; - -GP2XSdlGraphicsManager::GP2XSdlGraphicsManager(SdlEventSource *sdlEventSource) - : SdlGraphicsManager(sdlEventSource), _adjustZoomOnMouse(false) { -} - -const OSystem::GraphicsMode *GP2XSdlGraphicsManager::getSupportedGraphicsModes() const { - return s_supportedGraphicsModes; -} - -int GP2XSdlGraphicsManager::getDefaultGraphicsMode() const { - return GFX_NORMAL; -} - - -bool GP2XSdlGraphicsManager::hasFeature(OSystem::Feature f) { - if (f == OSystem::kFeatureIconifyWindow) - return false; - - return SdlGraphicsManager::hasFeature(f); -} - -void GP2XSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { - if (f != OSystem::kFeatureIconifyWindow) - SdlGraphicsManager::setFeatureState(f, enable); -} - -void GP2XSdlGraphicsManager::drawMouse() { - if (!_mouseVisible || !_mouseSurface) { - _mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0; - return; - } - - SDL_Rect zoomdst; - SDL_Rect dst; - int scale; - int hotX, hotY; - int tmpScreenWidth, tmpScreenHeight; - - // Temp vars to ensure we zoom to the LCD resolution or greater. - tmpScreenWidth = _videoMode.screenWidth; - tmpScreenHeight = _videoMode.screenHeight; - - if (_videoMode.screenHeight <= 240) { - tmpScreenHeight = 240; - } - - if (_videoMode.screenWidth <= 320) { - tmpScreenWidth = 320; - } - - dst.x = _mouseCurState.x; - dst.y = _mouseCurState.y; - - if (!_overlayVisible) { - scale = _videoMode.scaleFactor; - dst.w = _mouseCurState.vW; - dst.h = _mouseCurState.vH; - hotX = _mouseCurState.vHotX; - hotY = _mouseCurState.vHotY; - } else { - scale = 1; - dst.w = _mouseCurState.rW; - dst.h = _mouseCurState.rH; - hotX = _mouseCurState.rHotX; - hotY = _mouseCurState.rHotY; - } - - // The mouse is undrawn using virtual coordinates, i.e. they may be - // scaled and aspect-ratio corrected. - - _mouseBackup.x = dst.x - hotX; - _mouseBackup.y = dst.y - hotY; - _mouseBackup.w = dst.w; - _mouseBackup.h = dst.h; - - // We draw the pre-scaled cursor image, so now we need to adjust for - // scaling, shake position and aspect ratio correction manually. - - if (!_overlayVisible) { - dst.y += _currentShakePos; - } - - if (_videoMode.aspectRatioCorrection && !_overlayVisible) - dst.y = real2Aspect(dst.y); - - dst.x = scale * dst.x - _mouseCurState.rHotX; - dst.y = scale * dst.y - _mouseCurState.rHotY; - dst.w = _mouseCurState.rW; - dst.h = _mouseCurState.rH; - - // Hacking about with the zoom around mouse pointer stuff. - if (_adjustZoomOnMouse){ - - zoomdst.w = (tmpScreenWidth / 2); - zoomdst.h = (tmpScreenHeight / 2); - - // Create a zoomed rect centered on the mouse pointer. - // Will pan 1/4 of the screen. - - if (dst.x > ((tmpScreenWidth / 4) * 3)) { - zoomdst.x = (tmpScreenWidth / 2); - } else { - zoomdst.x = (dst.x - (tmpScreenWidth / 4)); - if (zoomdst.x < 0) { - zoomdst.x = 0; - } - } - - if (dst.y > ((tmpScreenHeight / 4) * 3)) { - zoomdst.y = (tmpScreenHeight / 2); - } else { - zoomdst.y = (dst.y - (tmpScreenHeight / 4)); - if (zoomdst.y < 0) { - zoomdst.y = 0; - } - } - SDL_GP2X_Display(&zoomdst); - } else { - - // Make sure we are looking at the whole screen otherwise. - - zoomdst.x = 0; - zoomdst.y = 0; - zoomdst.w = (tmpScreenWidth); - zoomdst.h = (tmpScreenHeight); - - SDL_GP2X_Display(&zoomdst); - }; - - // Note that SDL_BlitSurface() and addDirtyRect() will both perform any - // clipping necessary - - if (SDL_BlitSurface(_mouseSurface, NULL, _hwscreen, &dst) != 0) - error("SDL_BlitSurface failed: %s", SDL_GetError()); - - // The screen will be updated using real surface coordinates, i.e. - // they will not be scaled or aspect-ratio corrected. - - addDirtyRect(dst.x, dst.y, dst.w, dst.h, true); -} - -void GP2XSdlGraphicsManager::toggleZoomOnMouse() { - _adjustZoomOnMouse = !_adjustZoomOnMouse; -} - -#endif diff --git a/backends/graphics/gp2xsdl/gp2xsdl-graphics.h b/backends/graphics/gp2xsdl/gp2xsdl-graphics.h deleted file mode 100644 index 341b913acd..0000000000 --- a/backends/graphics/gp2xsdl/gp2xsdl-graphics.h +++ /dev/null @@ -1,46 +0,0 @@ -/* 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. - * - */ - -#ifndef BACKENDS_GRAPHICS_SDL_GP2X_H -#define BACKENDS_GRAPHICS_SDL_GP2X_H - -#include "backends/graphics/sdl/sdl-graphics.h" - -class GP2XSdlGraphicsManager : public SdlGraphicsManager { -public: - GP2XSdlGraphicsManager(SdlEventSource *sdlEventSource); - - virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const; - virtual int getDefaultGraphicsMode() const; - virtual void drawMouse(); - - virtual bool hasFeature(OSystem::Feature f); - virtual void setFeatureState(OSystem::Feature f, bool enable); - - // Toggles zoom adjust on mouse - void toggleZoomOnMouse(); - -protected: - bool _adjustZoomOnMouse; -}; - -#endif diff --git a/backends/graphics/gph/gph-graphics.cpp b/backends/graphics/gph/gph-graphics.cpp index b407bf1faf..eb748f2fc2 100644 --- a/backends/graphics/gph/gph-graphics.cpp +++ b/backends/graphics/gph/gph-graphics.cpp @@ -35,8 +35,8 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { {0, 0, 0} }; -GPHGraphicsManager::GPHGraphicsManager(SdlEventSource *boss) - : SdlGraphicsManager(boss) { +GPHGraphicsManager::GPHGraphicsManager(SdlEventSource *sdlEventSource) + : SdlGraphicsManager(sdlEventSource) { } const OSystem::GraphicsMode *GPHGraphicsManager::getSupportedGraphicsModes() const { @@ -110,21 +110,43 @@ void GPHGraphicsManager::setGraphicsModeIntern() { blitCursor(); } -void GPHGraphicsManager::initSize(uint w, uint h) { +void GPHGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) { assert(_transactionMode == kTransactionActive); +#ifdef USE_RGB_COLOR + // Avoid redundant format changes + Graphics::PixelFormat newFormat; + if (!format) + newFormat = Graphics::PixelFormat::createFormatCLUT8(); + else + newFormat = *format; + + assert(newFormat.bytesPerPixel > 0); + + if (newFormat != _videoMode.format) { + _videoMode.format = newFormat; + _transactionDetails.formatChanged = true; + _screenFormat = newFormat; + } +#endif + + // Avoid redundant res changes if ((int)w == _videoMode.screenWidth && (int)h == _videoMode.screenHeight) return; _videoMode.screenWidth = w; _videoMode.screenHeight = h; + if (w > 320 || h > 240){ setGraphicsMode(GFX_HALF); setGraphicsModeIntern(); _sdlEventSource->toggleMouseGrab(); } + _videoMode.overlayWidth = 320; + _videoMode.overlayHeight = 240; + _transactionDetails.sizeChanged = true; } @@ -433,26 +455,65 @@ void GPHGraphicsManager::hideOverlay() { } -bool GPHGraphicsManager::loadGFXMode() { - - /* Forcefully disable aspect ratio correction for games - that start with a native 240px height resolution - This corrects games with non-standard resolutions - such as MM Nes (256x240). - */ +//bool GPHGraphicsManager::loadGFXMode() { + + +// _videoMode.overlayWidth = 320; +// _videoMode.overlayHeight = 240; +// _videoMode.fullscreen = true; +// +// /* Forcefully disable aspect ratio correction for games +// that start with a native 240px height resolution +// This corrects games with non-standard resolutions +// such as MM Nes (256x240). +// */ +// if(_videoMode.screenHeight == 240) { +// _videoMode.aspectRatioCorrection = false; +// } + +// debug("Game ScreenMode = %d*%d", _videoMode.screenWidth, _videoMode.screenHeight); +// if (_videoMode.screenWidth > 320 || _videoMode.screenHeight > 240) { +// _videoMode.aspectRatioCorrection = false; +// setGraphicsMode(GFX_HALF); +// debug("GraphicsMode set to HALF"); +// } else { +// setGraphicsMode(GFX_NORMAL); +// debug("GraphicsMode set to NORMAL"); +// } + + +// if ((_videoMode.mode == GFX_HALF) && !_overlayVisible) { +// //_videoMode.overlayWidth = _videoMode.screenWidth / 2; +// //_videoMode.overlayHeight = _videoMode.screenHeight / 2; +// _videoMode.overlayWidth = 320; +// _videoMode.overlayHeight = 240; +// _videoMode.fullscreen = true; +// } else { +// +// _videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor; +// _videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor; +// +// if (_videoMode.aspectRatioCorrection) +// _videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight); +// +// //_videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor; +// //_videoMode.hardwareHeight = effectiveScreenHeight(); +// _videoMode.hardwareWidth = 320; +// _videoMode.hardwareHeight = 240; +// +// } + +// return SdlGraphicsManager::loadGFXMode(); +//} - if(_videoMode.screenHeight == 240) { - _videoMode.aspectRatioCorrection = false; - } - - debug("Game ScreenMode = %d*%d", _videoMode.screenWidth, _videoMode.screenHeight); +bool GPHGraphicsManager::loadGFXMode() { if (_videoMode.screenWidth > 320 || _videoMode.screenHeight > 240) { _videoMode.aspectRatioCorrection = false; setGraphicsMode(GFX_HALF); - debug("GraphicsMode set to HALF"); +// printf("GFX_HALF\n"); } else { setGraphicsMode(GFX_NORMAL); - debug("GraphicsMode set to NORMAL"); +// printf("GFX_NORMAL\n"); } if ((_videoMode.mode == GFX_HALF) && !_overlayVisible) { @@ -476,7 +537,7 @@ bool GPHGraphicsManager::loadGFXMode() { bool GPHGraphicsManager::hasFeature(OSystem::Feature f) { return (f == OSystem::kFeatureAspectRatioCorrection) || - (f == OSystem::kFeatureCursorHasPalette); + (f == OSystem::kFeatureCursorPalette); } void GPHGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { diff --git a/backends/graphics/gph/gph-graphics.h b/backends/graphics/gph/gph-graphics.h index 6ba2b344a6..fc3dc5730d 100644 --- a/backends/graphics/gph/gph-graphics.h +++ b/backends/graphics/gph/gph-graphics.h @@ -24,7 +24,7 @@ #define BACKENDS_GRAPHICS_GPH_H #include "backends/graphics/sdl/sdl-graphics.h" -#include "graphics/scaler/aspect.h" // for aspect2Real +#include "graphics/scaler/aspect.h" // for aspect2Real #include "graphics/scaler/downscaler.h" enum { @@ -40,7 +40,7 @@ public: bool getFeatureState(OSystem::Feature f); int getDefaultGraphicsMode() const; - void initSize(uint w, uint h); + void initSize(uint w, uint h, const Graphics::PixelFormat *format = NULL); const OSystem::GraphicsMode *getSupportedGraphicsModes() const; bool setGraphicsMode(const char *name); bool setGraphicsMode(int mode); diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index 4e681eb155..20924ed581 100644 --- a/backends/graphics/graphics.h +++ b/backends/graphics/graphics.h @@ -82,7 +82,6 @@ public: virtual void warpMouse(int x, int y) = 0; virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) = 0; virtual void setCursorPalette(const byte *colors, uint start, uint num) = 0; - virtual void disableCursorPalette(bool disable) = 0; virtual void displayMessageOnOSD(const char *msg) {} }; diff --git a/backends/graphics/null/null-graphics.h b/backends/graphics/null/null-graphics.h index 673d59814e..28b24f6aca 100644 --- a/backends/graphics/null/null-graphics.h +++ b/backends/graphics/null/null-graphics.h @@ -79,7 +79,6 @@ public: void warpMouse(int x, int y) {} void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) {} void setCursorPalette(const byte *colors, uint start, uint num) {} - void disableCursorPalette(bool disable) {} }; #endif diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 32c0fbca6f..c0551de386 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -91,7 +91,7 @@ void OpenGLGraphicsManager::initEventObserver() { bool OpenGLGraphicsManager::hasFeature(OSystem::Feature f) { return (f == OSystem::kFeatureAspectRatioCorrection) || - (f == OSystem::kFeatureCursorHasPalette); + (f == OSystem::kFeatureCursorPalette); } void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { @@ -105,6 +105,11 @@ void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { _transactionDetails.needRefresh = true; break; + case OSystem::kFeatureCursorPalette: + _cursorPaletteDisabled = !enable; + _cursorNeedsRedraw = true; + break; + default: break; } @@ -118,6 +123,9 @@ bool OpenGLGraphicsManager::getFeatureState(OSystem::Feature f) { case OSystem::kFeatureAspectRatioCorrection: return _videoMode.aspectRatioCorrection; + case OSystem::kFeatureCursorPalette: + return !_cursorPaletteDisabled; + default: return false; } @@ -642,11 +650,6 @@ void OpenGLGraphicsManager::setCursorPalette(const byte *colors, uint start, uin _cursorNeedsRedraw = true; } -void OpenGLGraphicsManager::disableCursorPalette(bool disable) { - _cursorPaletteDisabled = disable; - _cursorNeedsRedraw = true; -} - // // Misc // @@ -1382,7 +1385,7 @@ const char *OpenGLGraphicsManager::getCurrentModeName() { #ifdef USE_OSD void OpenGLGraphicsManager::updateOSD() { // The font we are going to use: - const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kOSDFont); + const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont); if (_osdSurface.w != _osdTexture->getWidth() || _osdSurface.h != _osdTexture->getHeight()) _osdSurface.create(_osdTexture->getWidth(), _osdTexture->getHeight(), _overlayFormat); diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index daba7748bc..463715aad8 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -107,7 +107,6 @@ public: virtual void warpMouse(int x, int y); virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool disable); virtual void displayMessageOnOSD(const char *msg); diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 3f9ffc9f3e..87457c3c08 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -28,6 +28,7 @@ #include "backends/platform/sdl/sdl.h" #include "common/config-manager.h" #include "common/textconsole.h" +#include "common/translation.h" OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager() : @@ -394,7 +395,8 @@ void OpenGLSdlGraphicsManager::displayModeChangedMsg() { const int scaleFactor = getScale(); char buffer[128]; - sprintf(buffer, "Current display mode: %s\n%d x %d -> %d x %d", + sprintf(buffer, "%s: %s\n%d x %d -> %d x %d", + _("Current display mode"), newModeName, _videoMode.screenWidth * scaleFactor, _videoMode.screenHeight * scaleFactor, @@ -406,7 +408,8 @@ void OpenGLSdlGraphicsManager::displayModeChangedMsg() { void OpenGLSdlGraphicsManager::displayScaleChangedMsg() { char buffer[128]; const int scaleFactor = getScale(); - sprintf(buffer, "Current scale: x%d\n%d x %d -> %d x %d", + sprintf(buffer, "%s: x%d\n%d x %d -> %d x %d", + _("Current scale"), scaleFactor, _videoMode.screenWidth, _videoMode.screenHeight, _videoMode.overlayWidth, _videoMode.overlayHeight @@ -449,11 +452,13 @@ void OpenGLSdlGraphicsManager::toggleFullScreen(int loop) { #ifdef USE_OSD char buffer[128]; if (getFullscreenMode()) - sprintf(buffer, "Fullscreen mode\n%d x %d", + sprintf(buffer, "%s\n%d x %d", + _("Fullscreen mode"), _hwscreen->w, _hwscreen->h ); else - sprintf(buffer, "Windowed mode\n%d x %d", + sprintf(buffer, "%s\n%d x %d", + _("Windowed mode"), _hwscreen->w, _hwscreen->h ); displayMessageOnOSD(buffer); @@ -508,11 +513,13 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { #ifdef USE_OSD char buffer[128]; if (getFeatureState(OSystem::kFeatureAspectRatioCorrection)) - sprintf(buffer, "Enabled aspect ratio correction\n%d x %d -> %d x %d", + sprintf(buffer, "%s\n%d x %d -> %d x %d", + _("Enabled aspect ratio correction"), _videoMode.screenWidth, _videoMode.screenHeight, _hwscreen->w, _hwscreen->h); else - sprintf(buffer, "Disabled aspect ratio correction\n%d x %d -> %d x %d", + sprintf(buffer, "%s\n%d x %d -> %d x %d", + _("Disabled aspect ratio correction"), _videoMode.screenWidth, _videoMode.screenHeight, _hwscreen->w, _hwscreen->h); displayMessageOnOSD(buffer); @@ -532,9 +539,9 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { // modes we use, we might want to consider a better way of // displaying information to the user. if (getAntialiasingState()) - displayMessageOnOSD("Active filter mode: Linear"); + displayMessageOnOSD(_("Active filter mode: Linear")); else - displayMessageOnOSD("Active filter mode: Nearest"); + displayMessageOnOSD(_("Active filter mode: Nearest")); #endif return true; } diff --git a/backends/graphics/openpandora/op-graphics.cpp b/backends/graphics/openpandora/op-graphics.cpp index 20ee5dfc36..c8617635a5 100644 --- a/backends/graphics/openpandora/op-graphics.cpp +++ b/backends/graphics/openpandora/op-graphics.cpp @@ -26,15 +26,13 @@ #include "backends/graphics/openpandora/op-graphics.h" #include "backends/events/openpandora/op-events.h" -#include "backends/platform/openpandora/op-sdl.h" -#include "common/mutex.h" -#include "common/util.h" - +//#include "backends/platform/openpandora/op-sdl.h" #include "graphics/scaler/aspect.h" -#include "graphics/surface.h" +#include "common/mutex.h" +#include "common/textconsole.h" -OPGraphicsManager::OPGraphicsManager(SdlEventSource *boss) - : SdlGraphicsManager(boss) { +OPGraphicsManager::OPGraphicsManager(SdlEventSource *sdlEventSource) + : SdlGraphicsManager(sdlEventSource) { } bool OPGraphicsManager::loadGFXMode() { diff --git a/backends/graphics/openpandora/op-graphics.h b/backends/graphics/openpandora/op-graphics.h index b0d4298620..4bb89ca1e6 100644 --- a/backends/graphics/openpandora/op-graphics.h +++ b/backends/graphics/openpandora/op-graphics.h @@ -33,30 +33,30 @@ enum { class OPGraphicsManager : public SdlGraphicsManager { public: - OPGraphicsManager(SdlEventSource *boss); - - bool hasFeature(OSystem::Feature f); - void setFeatureState(OSystem::Feature f, bool enable); - bool getFeatureState(OSystem::Feature f); - int getDefaultGraphicsMode() const; - - void initSize(uint w, uint h); - const OSystem::GraphicsMode *getSupportedGraphicsModes() const; - bool setGraphicsMode(const char *name); - bool setGraphicsMode(int mode); - void setGraphicsModeIntern(); - void internUpdateScreen(); - void showOverlay(); - void hideOverlay(); + OPGraphicsManager(SdlEventSource *sdlEventSource); + +// bool hasFeature(OSystem::Feature f); +// void setFeatureState(OSystem::Feature f, bool enable); +// bool getFeatureState(OSystem::Feature f); +// int getDefaultGraphicsMode() const; + +// void initSize(uint w, uint h, const Graphics::PixelFormat *format = NULL); +// const OSystem::GraphicsMode *getSupportedGraphicsModes() const; +// bool setGraphicsMode(const char *name); +// bool setGraphicsMode(int mode); +// void setGraphicsModeIntern(); +// void internUpdateScreen(); +// void showOverlay(); +// void hideOverlay(); bool loadGFXMode(); - void drawMouse(); - void undrawMouse(); - virtual void warpMouse(int x, int y); +// void drawMouse(); +// void undrawMouse(); +// virtual void warpMouse(int x, int y); - SdlGraphicsManager::MousePos *getMouseCurState(); - SdlGraphicsManager::VideoState *getVideoMode(); +// SdlGraphicsManager::MousePos *getMouseCurState(); +// SdlGraphicsManager::VideoState *getVideoMode(); - virtual void adjustMouseEvent(const Common::Event &event); +// virtual void adjustMouseEvent(const Common::Event &event); }; #endif /* BACKENDS_GRAPHICS_OP_H */ diff --git a/backends/graphics/samsungtvsdl/samsungtvsdl-graphics.cpp b/backends/graphics/samsungtvsdl/samsungtvsdl-graphics.cpp index 18629d949a..f6832978a8 100644 --- a/backends/graphics/samsungtvsdl/samsungtvsdl-graphics.cpp +++ b/backends/graphics/samsungtvsdl/samsungtvsdl-graphics.cpp @@ -35,7 +35,7 @@ SamsungTVSdlGraphicsManager::SamsungTVSdlGraphicsManager(SdlEventSource *sdlEven bool SamsungTVSdlGraphicsManager::hasFeature(OSystem::Feature f) { return (f == OSystem::kFeatureAspectRatioCorrection) || - (f == OSystem::kFeatureCursorHasPalette); + (f == OSystem::kFeatureCursorPalette); } void SamsungTVSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index 7a5b777032..9063f55744 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -223,7 +223,7 @@ bool SdlGraphicsManager::hasFeature(OSystem::Feature f) { return (f == OSystem::kFeatureFullscreenMode) || (f == OSystem::kFeatureAspectRatioCorrection) || - (f == OSystem::kFeatureCursorHasPalette) || + (f == OSystem::kFeatureCursorPalette) || (f == OSystem::kFeatureIconifyWindow); } @@ -235,6 +235,10 @@ void SdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { case OSystem::kFeatureAspectRatioCorrection: setAspectRatioCorrection(enable); break; + case OSystem::kFeatureCursorPalette: + _cursorPaletteDisabled = !enable; + blitCursor(); + break; case OSystem::kFeatureIconifyWindow: if (enable) SDL_WM_IconifyWindow(); @@ -245,13 +249,15 @@ void SdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { } bool SdlGraphicsManager::getFeatureState(OSystem::Feature f) { - assert (_transactionMode == kTransactionNone); + assert(_transactionMode == kTransactionNone); switch (f) { case OSystem::kFeatureFullscreenMode: return _videoMode.fullscreen; case OSystem::kFeatureAspectRatioCorrection: return _videoMode.aspectRatioCorrection; + case OSystem::kFeatureCursorPalette: + return !_cursorPaletteDisabled; default: return false; } @@ -1458,11 +1464,6 @@ void SdlGraphicsManager::setCursorPalette(const byte *colors, uint start, uint n blitCursor(); } -void SdlGraphicsManager::disableCursorPalette(bool disable) { - _cursorPaletteDisabled = disable; - blitCursor(); -} - void SdlGraphicsManager::setShakePos(int shake_pos) { assert (_transactionMode == kTransactionNone); @@ -2059,7 +2060,7 @@ void SdlGraphicsManager::displayMessageOnOSD(const char *msg) { _osdSurface->format->Bshift, _osdSurface->format->Ashift); // The font we are going to use: - const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kOSDFont); + const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont); // Clear everything with the "transparent" color, i.e. the colorkey SDL_FillRect(_osdSurface, 0, kOSDColorKey); @@ -2132,12 +2133,14 @@ bool SdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) { #ifdef USE_OSD char buffer[128]; if (_videoMode.aspectRatioCorrection) - sprintf(buffer, "Enabled aspect ratio correction\n%d x %d -> %d x %d", + sprintf(buffer, "%s\n%d x %d -> %d x %d", + _("Enabled aspect ratio correction"), _videoMode.screenWidth, _videoMode.screenHeight, _hwscreen->w, _hwscreen->h ); else - sprintf(buffer, "Disabled aspect ratio correction\n%d x %d -> %d x %d", + sprintf(buffer, "%s\n%d x %d -> %d x %d", + _("Disabled aspect ratio correction"), _videoMode.screenWidth, _videoMode.screenHeight, _hwscreen->w, _hwscreen->h ); @@ -2191,7 +2194,8 @@ bool SdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) { } if (newScalerName) { char buffer[128]; - sprintf(buffer, "Active graphics filter: %s\n%d x %d -> %d x %d", + sprintf(buffer, "%s %s\n%d x %d -> %d x %d", + _("Active graphics filter:"), newScalerName, _videoMode.screenWidth, _videoMode.screenHeight, _hwscreen->w, _hwscreen->h @@ -2245,9 +2249,9 @@ void SdlGraphicsManager::toggleFullScreen() { endGFXTransaction(); #ifdef USE_OSD if (_videoMode.fullscreen) - displayMessageOnOSD("Fullscreen mode"); + displayMessageOnOSD(_("Fullscreen mode")); else - displayMessageOnOSD("Windowed mode"); + displayMessageOnOSD(_("Windowed mode")); #endif } diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h index 86e52a0bf6..9627ab23a3 100644 --- a/backends/graphics/sdl/sdl-graphics.h +++ b/backends/graphics/sdl/sdl-graphics.h @@ -132,7 +132,6 @@ public: virtual void warpMouse(int x, int y); virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool disable); #ifdef USE_OSD virtual void displayMessageOnOSD(const char *msg); diff --git a/backends/graphics/symbiansdl/symbiansdl-graphics.cpp b/backends/graphics/symbiansdl/symbiansdl-graphics.cpp index 4d656cd7cd..a88c8a8ffe 100644 --- a/backends/graphics/symbiansdl/symbiansdl-graphics.cpp +++ b/backends/graphics/symbiansdl/symbiansdl-graphics.cpp @@ -54,7 +54,7 @@ bool SymbianSdlGraphicsManager::hasFeature(OSystem::Feature f) { switch (f) { case OSystem::kFeatureFullscreenMode: case OSystem::kFeatureAspectRatioCorrection: - case OSystem::kFeatureCursorHasPalette: + case OSystem::kFeatureCursorPalette: #ifdef USE_VIBRA_SE_PXXX case OSystem::kFeatureVibration: #endif diff --git a/backends/graphics/wincesdl/wincesdl-graphics.cpp b/backends/graphics/wincesdl/wincesdl-graphics.cpp index 80b04ca56d..8ba7b5821d 100644 --- a/backends/graphics/wincesdl/wincesdl-graphics.cpp +++ b/backends/graphics/wincesdl/wincesdl-graphics.cpp @@ -49,8 +49,8 @@ WINCESdlGraphicsManager::WINCESdlGraphicsManager(SdlEventSource *sdlEventSource) _panelVisible(true), _saveActiveToolbar(NAME_MAIN_PANEL), _panelStateForced(false), _canBeAspectScaled(false), _scalersChanged(false), _saveToolbarState(false), _mouseBackupOld(NULL), _mouseBackupDim(0), _mouseBackupToolbar(NULL), - _usesEmulatedMouse(false), _forceHideMouse(false), _hasfocus(true), - _zoomUp(false), _zoomDown(false) { + _usesEmulatedMouse(false), _forceHideMouse(false), _freeLook(false), + _hasfocus(true), _zoomUp(false), _zoomDown(false) { memset(&_mouseCurState, 0, sizeof(_mouseCurState)); if (_isSmartphone) { _mouseCurState.x = 20; @@ -444,7 +444,6 @@ void WINCESdlGraphicsManager::update_game_settings() { // Skip panel->add(NAME_ITEM_SKIP, new CEGUI::ItemAction(ITEM_SKIP, POCKET_ACTION_SKIP)); // sound -//__XXX__ panel->add(NAME_ITEM_SOUND, new CEGUI::ItemSwitch(ITEM_SOUND_OFF, ITEM_SOUND_ON, &_soundMaster)); panel->add(NAME_ITEM_SOUND, new CEGUI::ItemSwitch(ITEM_SOUND_OFF, ITEM_SOUND_ON, &OSystem_WINCE3::_soundMaster)); // bind keys @@ -1627,6 +1626,14 @@ void WINCESdlGraphicsManager::create_toolbar() { _toolbarHandler.setVisible(false); } +void WINCESdlGraphicsManager::swap_freeLook() { + _freeLook = !_freeLook; +} + +bool WINCESdlGraphicsManager::getFreeLookState() { + return _freeLook; +} + WINCESdlGraphicsManager::zoneDesc WINCESdlGraphicsManager::_zones[TOTAL_ZONES] = { { 0, 0, 320, 145 }, { 0, 145, 150, 55 }, diff --git a/backends/graphics/wincesdl/wincesdl-graphics.h b/backends/graphics/wincesdl/wincesdl-graphics.h index b3a8d66f51..2727bc0d27 100644 --- a/backends/graphics/wincesdl/wincesdl-graphics.h +++ b/backends/graphics/wincesdl/wincesdl-graphics.h @@ -56,6 +56,8 @@ public: void unloadGFXMode(); bool hotswapGFXMode(); + void update_game_settings(); + // Overloaded from SDL backend (toolbar handling) void drawMouse(); // Overloaded from SDL backend (new scaler handling) @@ -88,7 +90,8 @@ public: void swap_zoom_up(); void swap_zoom_down(); void swap_mouse_visibility(); - + void swap_freeLook(); + bool getFreeLookState(); //#ifdef WIN32_PLATFORM_WFSP void move_cursor_up(); @@ -96,7 +99,6 @@ public: void move_cursor_left(); void move_cursor_right(); - void retrieve_mouse_location(int &x, int &y); void switch_zone(); void add_right_click(bool pushed); @@ -106,6 +108,11 @@ public: void smartphone_rotate_display(); //#endif + bool hasPocketPCResolution(); + bool hasDesktopResolution(); + bool hasSquareQVGAResolution(); + bool hasWideResolution() const; + bool _panelInitialized; // only initialize the toolbar once bool _noDoubleTapRMB; // disable double tap -> rmb click @@ -122,11 +129,6 @@ public: bool _hasfocus; // scummvm has the top window - bool hasPocketPCResolution(); - bool hasDesktopResolution(); - bool hasSquareQVGAResolution(); - bool hasWideResolution() const; - MousePos _mouseCurState; bool _zoomUp; // zooming up mode @@ -158,8 +160,8 @@ protected: private: bool update_scalers(); - void update_game_settings(); void drawToolbarMouse(SDL_Surface *surf, bool draw); + void retrieve_mouse_location(int &x, int &y); void create_toolbar(); bool _panelVisible; // panel visibility @@ -186,6 +188,7 @@ private: uint16 _mouseBackupDim; bool _forceHideMouse; // force invisible mouse cursor + bool _freeLook; // freeLook mode (do not send mouse button events) // Smartphone specific variables void loadDeviceConfigurationElement(Common::String element, int &value, int defaultValue); diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index c5f147ffe1..525170d685 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -24,44 +24,25 @@ #include "backends/modular-backend.h" -#include "backends/fs/fs-factory.h" -#include "backends/audiocd/audiocd.h" #include "backends/graphics/graphics.h" #include "backends/mutex/mutex.h" #include "audio/mixer.h" -#include "common/events.h" -#include "gui/message.h" #include "graphics/pixelformat.h" ModularBackend::ModularBackend() : - _fsFactory(0), - _eventManager(0), - _savefileManager(0), - _timerManager(0), _mutexManager(0), _graphicsManager(0), - _mixer(0), - _audiocdManager(0) { + _mixer(0) { } ModularBackend::~ModularBackend() { - delete _fsFactory; - _fsFactory = 0; delete _graphicsManager; _graphicsManager = 0; - delete _eventManager; - _eventManager = 0; delete _mixer; _mixer = 0; - delete _audiocdManager; - _audiocdManager = 0; - delete _savefileManager; - _savefileManager = 0; - delete _timerManager; - _timerManager = 0; delete _mutexManager; _mutexManager = 0; } @@ -222,20 +203,6 @@ void ModularBackend::setCursorPalette(const byte *colors, uint start, uint num) _graphicsManager->setCursorPalette(colors, start, num); } -void ModularBackend::disableCursorPalette(bool disable) { - _graphicsManager->disableCursorPalette(disable); -} - -Common::TimerManager *ModularBackend::getTimerManager() { - assert(_timerManager); - return _timerManager; -} - -Common::EventManager *ModularBackend::getEventManager() { - assert(_eventManager); - return _eventManager; -} - OSystem::MutexRef ModularBackend::createMutex() { assert(_mutexManager); return _mutexManager->createMutex(); @@ -261,25 +228,10 @@ Audio::Mixer *ModularBackend::getMixer() { return (Audio::Mixer *)_mixer; } -AudioCDManager *ModularBackend::getAudioCDManager() { - assert(_audiocdManager); - return _audiocdManager; -} - void ModularBackend::displayMessageOnOSD(const char *msg) { _graphicsManager->displayMessageOnOSD(msg); } -Common::SaveFileManager *ModularBackend::getSavefileManager() { - assert(_savefileManager); - return _savefileManager; -} - -FilesystemFactory *ModularBackend::getFilesystemFactory() { - assert(_fsFactory); - return _fsFactory; -} - void ModularBackend::quit() { exit(0); } diff --git a/backends/modular-backend.h b/backends/modular-backend.h index e46fbfdd21..3593130bf5 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -23,9 +23,7 @@ #ifndef BACKENDS_MODULAR_BACKEND_H #define BACKENDS_MODULAR_BACKEND_H -#include "common/system.h" -#include "common/timer.h" -#include "common/savefile.h" +#include "backends/base-backend.h" class GraphicsManager; class MutexManager; @@ -39,8 +37,6 @@ class MutexManager; * A backend derivated from this class, will need to implement * these functions on its own: * OSystem::pollEvent() - * OSystem::createConfigReadStream() - * OSystem::createConfigWriteStream() * OSystem::getMillis() * OSystem::delayMillis() * OSystem::getTimeAndDate() @@ -48,7 +44,7 @@ class MutexManager; * And, it should also initialize all the managers variables * declared in this class, or override their related functions. */ -class ModularBackend : public OSystem { +class ModularBackend : public BaseBackend { public: ModularBackend(); virtual ~ModularBackend(); @@ -106,15 +102,12 @@ public: virtual void warpMouse(int x, int y); virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool disable); //@} /** @name Events and Time */ //@{ - virtual Common::TimerManager *getTimerManager(); - virtual Common::EventManager *getEventManager(); virtual Common::HardwareKeySet *getHardwareKeySet() { return 0; } //@} @@ -136,18 +129,9 @@ public: //@} - /** @name Audio CD */ - //@{ - - virtual AudioCDManager *getAudioCDManager(); - - //@} - /** @name Miscellaneous */ //@{ - virtual Common::SaveFileManager *getSavefileManager(); - virtual FilesystemFactory *getFilesystemFactory(); virtual void quit(); virtual void displayMessageOnOSD(const char *msg); @@ -157,14 +141,9 @@ protected: /** @name Managers variables */ //@{ - FilesystemFactory *_fsFactory; - Common::EventManager *_eventManager; - Common::SaveFileManager *_savefileManager; - Common::TimerManager *_timerManager; MutexManager *_mutexManager; GraphicsManager *_graphicsManager; Audio::Mixer *_mixer; - AudioCDManager *_audiocdManager; //@} }; diff --git a/backends/module.mk b/backends/module.mk index 27058bef88..d1feae4317 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -118,14 +118,6 @@ MODULE_OBJS += \ graphics/gph/gph-graphics.o endif -# TODO/FIXME: The gp2xsdl files are only compiled if GP2X_OLD is defined, -# which currently is never the case (unless the user manually requests it). -# ifeq ($(BACKEND),gp2x) -# MODULE_OBJS += \ -# events/gp2xsdl/gp2xsdl-events.o \ -# graphics/gp2xsdl/gp2xsdl-graphics.o -# endif - ifeq ($(BACKEND),linuxmoto) MODULE_OBJS += \ events/linuxmotosdl/linuxmotosdl-events.o \ diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index eeeddb4c77..90660cf82c 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -132,10 +132,7 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) : _show_mouse(false), _show_overlay(false), _enable_zoning(false), - _savefile(0), _mixer(0), - _timer(0), - _fsFactory(new POSIXFilesystemFactory()), _shake_offset(0), _event_queue_lock(createMutex()), _touch_pt_down(), @@ -149,6 +146,9 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) : _dpad_scale(4), _fingersDown(0), _trackball_scale(2) { + + _fsFactory = new POSIXFilesystemFactory(); + Common::String mf = getSystemProperty("ro.product.manufacturer"); LOGI("Running on: [%s] [%s] [%s] [%s] [%s] SDK:%s ABI:%s", @@ -170,17 +170,17 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) : OSystem_Android::~OSystem_Android() { ENTER(); - delete _savefile; - delete _timer; delete _mixer; + _mixer = 0; delete _fsFactory; + _fsFactory = 0; deleteMutex(_event_queue_lock); } void *OSystem_Android::timerThreadFunc(void *arg) { OSystem_Android *system = (OSystem_Android *)arg; - DefaultTimerManager *timer = (DefaultTimerManager *)(system->_timer); + DefaultTimerManager *timer = (DefaultTimerManager *)(system->_timerManager); // renice this thread to boost the audio thread if (setpriority(PRIO_PROCESS, 0, 19) < 0) @@ -359,8 +359,8 @@ void OSystem_Android::initBackend() { // BUG: "transient" ConfMan settings get nuked by the options // screen. Passing the savepath in this way makes it stick // (via ConfMan.registerDefault) - _savefile = new DefaultSaveFileManager(ConfMan.get("savepath")); - _timer = new DefaultTimerManager(); + _savefileManager = new DefaultSaveFileManager(ConfMan.get("savepath")); + _timerManager = new DefaultTimerManager(); gettimeofday(&_startTime, 0); @@ -388,6 +388,8 @@ void OSystem_Android::initBackend() { warning("couldn't renice the main thread"); JNI::setReadyForEvents(true); + + EventsBaseBackend::initBackend(); } void OSystem_Android::addPluginDirectories(Common::FSList &dirs) const { @@ -399,7 +401,7 @@ void OSystem_Android::addPluginDirectories(Common::FSList &dirs) const { bool OSystem_Android::hasFeature(Feature f) { return (f == kFeatureFullscreenMode || f == kFeatureAspectRatioCorrection || - f == kFeatureCursorHasPalette || + f == kFeatureCursorPalette || f == kFeatureVirtualKeyboard || f == kFeatureOverlaySupportsAlpha); } @@ -420,6 +422,11 @@ void OSystem_Android::setFeatureState(Feature f, bool enable) { _virtkeybd_on = enable; showVirtualKeyboard(enable); break; + case kFeatureCursorPalette: + _use_mouse_palette = !enable; + if (!enable) + disableCursorPalette(); + break; default: break; } @@ -433,6 +440,8 @@ bool OSystem_Android::getFeatureState(Feature f) { return _ar_correction; case kFeatureVirtualKeyboard: return _virtkeybd_on; + case kFeatureCursorPalette: + return _use_mouse_palette; default: return false; } @@ -526,21 +535,11 @@ void OSystem_Android::showVirtualKeyboard(bool enable) { JNI::showVirtualKeyboard(enable); } -Common::SaveFileManager *OSystem_Android::getSavefileManager() { - assert(_savefile); - return _savefile; -} - Audio::Mixer *OSystem_Android::getMixer() { assert(_mixer); return _mixer; } -Common::TimerManager *OSystem_Android::getTimerManager() { - assert(_timer); - return _timer; -} - void OSystem_Android::getTimeAndDate(TimeDate &td) const { struct tm tm; const time_t curTime = time(0); @@ -554,10 +553,6 @@ void OSystem_Android::getTimeAndDate(TimeDate &td) const { td.tm_year = tm.tm_year; } -FilesystemFactory *OSystem_Android::getFilesystemFactory() { - return _fsFactory; -} - void OSystem_Android::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { ENTER(""); @@ -568,6 +563,10 @@ void OSystem_Android::addSysArchivesToSearchSet(Common::SearchSet &s, void OSystem_Android::logMessage(LogMessageType::Type type, const char *message) { switch (type) { + case LogMessageType::kInfo: + __android_log_write(ANDROID_LOG_INFO, android_log_tag, message); + break; + case LogMessageType::kDebug: __android_log_write(ANDROID_LOG_DEBUG, android_log_tag, message); break; diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index 752a31a4db..c2ada2ab77 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -103,7 +103,7 @@ protected: }; #endif -class OSystem_Android : public BaseBackend, public PaletteManager { +class OSystem_Android : public EventsBaseBackend, public PaletteManager { private: // passed from the dark side int _audio_sample_rate; @@ -152,10 +152,7 @@ private: bool _enable_zoning; bool _virtkeybd_on; - Common::SaveFileManager *_savefile; Audio::MixerImpl *_mixer; - Common::TimerManager *_timer; - FilesystemFactory *_fsFactory; timeval _startTime; Common::String getSystemProperty(const char *name) const; @@ -237,6 +234,7 @@ private: void clipMouse(Common::Point &p); void scaleMouse(Common::Point &p, int x, int y, bool deductDrawRect = true); void updateEventScale(); + void disableCursorPalette(); protected: // PaletteManager API @@ -272,7 +270,6 @@ public: int cursorTargetScale, const Graphics::PixelFormat *format); virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool disable); virtual bool pollEvent(Common::Event &event); virtual uint32 getMillis(); @@ -289,11 +286,8 @@ public: virtual void displayMessageOnOSD(const char *msg); virtual void showVirtualKeyboard(bool enable); - virtual Common::SaveFileManager *getSavefileManager(); virtual Audio::Mixer *getMixer(); virtual void getTimeAndDate(TimeDate &t) const; - virtual Common::TimerManager *getTimerManager(); - virtual FilesystemFactory *getFilesystemFactory(); virtual void logMessage(LogMessageType::Type type, const char *message); virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp index 89e918a34e..b8a9e74437 100644 --- a/backends/platform/android/gfx.cpp +++ b/backends/platform/android/gfx.cpp @@ -801,12 +801,10 @@ void OSystem_Android::setCursorPalette(const byte *colors, _use_mouse_palette = true; } -void OSystem_Android::disableCursorPalette(bool disable) { - ENTER("%d", disable); - +void OSystem_Android::disableCursorPalette() { // when disabling the cursor palette, and we're running a clut8 game, // it expects the game palette to be used for the cursor - if (disable && _game_texture->hasPalette()) { + if (_game_texture->hasPalette()) { const byte *src = _game_texture->palette_const(); byte *dst = _mouse_texture_palette->palette(); @@ -825,8 +823,6 @@ void OSystem_Android::disableCursorPalette(bool disable) { byte *p = _mouse_texture_palette->palette() + _mouse_keycolor * 2; WRITE_UINT16(p, READ_UINT16(p) & ~1); } - - _use_mouse_palette = !disable; } #endif diff --git a/backends/platform/dc/dc-fs.cpp b/backends/platform/dc/dc-fs.cpp index 16547456c3..ac709f62b9 100644 --- a/backends/platform/dc/dc-fs.cpp +++ b/backends/platform/dc/dc-fs.cpp @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include "dc.h" #include "backends/fs/abstract-fs.h" diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index e31b817d7c..bde50daa2d 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -70,7 +70,7 @@ class DCCDManager : public DefaultAudioCDManager { void updateCD(); }; -class OSystem_Dreamcast : private DCHardware, public BaseBackend, public PaletteManager, public FilesystemFactory +class OSystem_Dreamcast : private DCHardware, public EventsBaseBackend, public PaletteManager, public FilesystemFactory #ifdef DYNAMIC_MODULES , public FilePluginProvider #endif @@ -145,9 +145,6 @@ public: // Replace the specified range of cursor the palette with new colors. void setCursorPalette(const byte *colors, uint start, uint num); - // Disable or enable cursor palette. - void disableCursorPalette(bool disable); - // Shaking is used in SCUMM. Set current shake position. void setShakePos(int shake_pos); @@ -164,8 +161,6 @@ public: // Returns true if an event was retrieved. bool pollEvent(Common::Event &event); - AudioCDManager *getAudioCDManager() { return _cdManager; } - // Quit void quit(); @@ -190,26 +185,20 @@ public: void setWindowCaption(const char *caption); // Modulatized backend - Common::SaveFileManager *getSavefileManager() { return _savefile; } Audio::Mixer *getMixer() { return _mixer; } - Common::TimerManager *getTimerManager() { return _timer; } // Extra SoftKbd support void mouseToSoftKbd(int x, int y, int &rx, int &ry) const; // Filesystem - FilesystemFactory *getFilesystemFactory() { return this; } AbstractFSNode *makeRootFileNode() const; AbstractFSNode *makeCurrentDirectoryFileNode() const; AbstractFSNode *makeFileNodePath(const Common::String &path) const; private: - Common::SaveFileManager *_savefile; Audio::MixerImpl *_mixer; - DefaultTimerManager *_timer; SoftKeyboard _softkbd; - DCCDManager *_cdManager; int _ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_old_x, _ms_old_y; int _ms_hotspot_x, _ms_hotspot_y, _ms_visible, _devpoll, _last_screen_refresh; diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp index dfce176e90..3faf0185ad 100644 --- a/backends/platform/dc/dcmain.cpp +++ b/backends/platform/dc/dcmain.cpp @@ -20,10 +20,7 @@ * */ -// Allow use of stuff in <time.h> -#define FORBIDDEN_SYMBOL_EXCEPTION_time_h - -#define FORBIDDEN_SYMBOL_EXCEPTION_printf +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include <common/scummsys.h> #include <engines/engine.h> @@ -44,26 +41,29 @@ const char *gGameName; OSystem_Dreamcast::OSystem_Dreamcast() : _devpoll(0), screen(NULL), mouse(NULL), overlay(NULL), _softkbd(this), - _ms_buf(NULL), _timer(NULL), _mixer(NULL), _savefile(NULL), + _ms_buf(NULL), _mixer(NULL), _current_shake_pos(0), _aspect_stretch(false), _softkbd_on(false), _softkbd_motion(0), _enable_cursor_palette(false), _screenFormat(0) { memset(screen_tx, 0, sizeof(screen_tx)); memset(mouse_tx, 0, sizeof(mouse_tx)); memset(ovl_tx, 0, sizeof(ovl_tx)); + _fsFactory = this; } void OSystem_Dreamcast::initBackend() { ConfMan.setInt("autosave_period", 0); - _savefile = createSavefileManager(); - _timer = new DefaultTimerManager(); + _savefileManager = createSavefileManager(); + _timerManager = new DefaultTimerManager(); uint sampleRate = initSound(); _mixer = new Audio::MixerImpl(this, sampleRate); _mixer->setReady(true); - _cdManager = new DCCDManager(); + _audiocdManager = new DCCDManager(); + + EventsBaseBackend::initBackend(); } @@ -163,7 +163,7 @@ bool OSystem_Dreamcast::hasFeature(Feature f) case kFeatureAspectRatioCorrection: case kFeatureVirtualKeyboard: case kFeatureOverlaySupportsAlpha: - case kFeatureCursorHasPalette: + case kFeatureCursorPalette: return true; default: return false; @@ -181,6 +181,9 @@ void OSystem_Dreamcast::setFeatureState(Feature f, bool enable) case kFeatureVirtualKeyboard: _softkbd_on = enable; break; + case kFeatureCursorPalette: + _enable_cursor_palette = enable; + break; default: break; } @@ -193,6 +196,8 @@ bool OSystem_Dreamcast::getFeatureState(Feature f) return _aspect_stretch; case kFeatureVirtualKeyboard: return _softkbd_on; + case kFeatureCursorPalette: + return _enable_cursor_palette; default: return false; } diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index 56eef870c0..a11e329df3 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -171,11 +171,6 @@ void OSystem_Dreamcast::setCursorPalette(const byte *colors, uint start, uint nu _enable_cursor_palette = true; } -void OSystem_Dreamcast::disableCursorPalette(bool disable) -{ - _enable_cursor_palette = !disable; -} - void OSystem_Dreamcast::grabPalette(byte *colors, uint start, uint num) { const unsigned short *src = palette + start; diff --git a/backends/platform/dc/input.cpp b/backends/platform/dc/input.cpp index 7054ad196e..3759eec6df 100644 --- a/backends/platform/dc/input.cpp +++ b/backends/platform/dc/input.cpp @@ -192,8 +192,8 @@ bool OSystem_Dreamcast::pollEvent(Common::Event &event) { unsigned int t = Timer(); - if (_timer != NULL) - _timer->handler(); + if (_timerManager != NULL) + ((DefaultTimerManager *)_timerManager)->handler(); if (((int)(t-_devpoll))<0) return false; diff --git a/backends/platform/dc/time.cpp b/backends/platform/dc/time.cpp index c343852321..8cc3a71e8d 100644 --- a/backends/platform/dc/time.cpp +++ b/backends/platform/dc/time.cpp @@ -48,8 +48,8 @@ void OSystem_Dreamcast::delayMillis(uint msecs) unsigned int t, start = Timer(); int time = (((unsigned int)msecs)*3125U)>>6; while (((int)((t = Timer())-start))<time) { - if (_timer != NULL) - _timer->handler(); + if (_timerManager != NULL) + ((DefaultTimerManager *)_timerManager)->handler(); checkSound(); } getMillis(); diff --git a/backends/platform/dc/vmsave.cpp b/backends/platform/dc/vmsave.cpp index f18f69efa6..e06dd7fa43 100644 --- a/backends/platform/dc/vmsave.cpp +++ b/backends/platform/dc/vmsave.cpp @@ -20,10 +20,7 @@ * */ -// Allow use of stuff in <time.h> -#define FORBIDDEN_SYMBOL_EXCEPTION_time_h - -#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include <common/scummsys.h> #include "engines/engine.h" diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index 462990cb32..b157a3a87a 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -41,6 +41,9 @@ #include "touchkeyboard.h" #include "backends/fs/ds/ds-fs-factory.h" +#include "backends/audiocd/default/default-audiocd.h" +#include "backends/timer/default/default-timer.h" + #ifdef ENABLE_AGI #include "wordcompletion.h" #endif @@ -79,7 +82,7 @@ OSystem_DS *OSystem_DS::_instance = NULL; OSystem_DS::OSystem_DS() - : eventNum(0), lastPenFrame(0), queuePos(0), _mixer(NULL), _timer(NULL), _frameBufferExists(false), + : eventNum(0), lastPenFrame(0), queuePos(0), _mixer(NULL), _frameBufferExists(false), _disableCursorPalette(true), _graphicsEnable(true), _gammaValue(0) { // eventNum = 0; @@ -87,13 +90,17 @@ OSystem_DS::OSystem_DS() // queuePos = 0; _instance = this; // _mixer = NULL; - // _timer = NULL; //_frameBufferExists = false; } OSystem_DS::~OSystem_DS() { delete _mixer; - delete _timer; + _mixer = 0; + + // If _savefileManager is not 0, then it points to the OSystem_DS + // member variable mpSaveManager. Hence we set _savefileManager to + // 0, to prevent the OSystem destructor from trying to delete it. + _savefileManager = 0; } int OSystem_DS::timerHandler(int t) { @@ -106,7 +113,11 @@ void OSystem_DS::initBackend() { ConfMan.setInt("autosave_period", 0); ConfMan.setBool("FM_medium_quality", true); - _timer = new DefaultTimerManager(); + if (DS::isGBAMPAvailable()) { + _savefileManager = &mpSaveManager; + } + + _timerManager = new DefaultTimerManager(); DS::setTimerCallback(&OSystem_DS::timerHandler, 10); if (ConfMan.hasKey("22khzaudio", "ds") && ConfMan.getBool("22khzaudio", "ds")) { @@ -118,21 +129,32 @@ void OSystem_DS::initBackend() { _mixer = new Audio::MixerImpl(this, DS::getSoundFrequency()); _mixer->setReady(true); - OSystem::initBackend(); + /* TODO/FIXME: The NDS should use a custom AudioCD manager instance! + if (!_audiocdManager) + _audiocdManager = new DSAudioCDManager(); + */ + + EventsBaseBackend::initBackend(); } bool OSystem_DS::hasFeature(Feature f) { - return (f == kFeatureVirtualKeyboard) || (f == kFeatureCursorHasPalette); + return (f == kFeatureVirtualKeyboard) || (f == kFeatureCursorPalette); } void OSystem_DS::setFeatureState(Feature f, bool enable) { if (f == kFeatureVirtualKeyboard) DS::setKeyboardIcon(enable); + else if (f == kFeatureCursorPalette) { + _disableCursorPalette = !enable; + refreshCursor(); + } } bool OSystem_DS::getFeatureState(Feature f) { if (f == kFeatureVirtualKeyboard) return DS::getKeyboardIcon(); + if (f == kFeatureCursorPalette) + return !_disableCursorPalette; return false; } @@ -734,14 +756,6 @@ void OSystem_DS::quit() { swiSoftReset();*/ } -Common::SaveFileManager *OSystem_DS::getSavefileManager() { - if (DS::isGBAMPAvailable()) { - return &mpSaveManager; - } - return NULL; -} - - Graphics::Surface *OSystem_DS::createTempFrameBuffer() { // Ensure we copy using 16 bit quantities due to limitation of VRAM addressing @@ -840,16 +854,15 @@ void OSystem_DS::setCharactersEntered(int count) { DS::setCharactersEntered(count); } -Common::SeekableReadStream *OSystem_DS::createConfigReadStream() { - Common::FSNode file(DEFAULT_CONFIG_FILE); -// consolePrintf("R %s", DEFAULT_CONFIG_FILE); - return file.createReadStream(); +Common::String OSystem_DS::getDefaultConfigFileName() { + return DEFAULT_CONFIG_FILE; } -Common::WriteStream *OSystem_DS::createConfigWriteStream() { - Common::FSNode file(DEFAULT_CONFIG_FILE); -// consolePrintf("W %s", DEFAULT_CONFIG_FILE); - return file.createWriteStream(); +void OSystem_DS::logMessage(LogMessageType::Type type, const char *message) { +#ifndef DISABLE_TEXT_CONSOLE + nocashMessage((char *)message); +// consolePrintf((char *)message); +#endif } u16 OSystem_DS::applyGamma(u16 color) { diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index 4ab2e36322..b1222a152d 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.h +++ b/backends/platform/ds/arm9/source/osystem_ds.h @@ -29,13 +29,12 @@ #include "nds.h" #include "gbampsave.h" #include "backends/saves/default/default-saves.h" -#include "backends/timer/default/default-timer.h" #include "audio/mixer_intern.h" #include "graphics/surface.h" #include "graphics/colormasks.h" #include "graphics/palette.h" -class OSystem_DS : public BaseBackend, public PaletteManager { +class OSystem_DS : public EventsBaseBackend, public PaletteManager { protected: int eventNum; @@ -46,7 +45,6 @@ protected: GBAMPSaveFileManager mpSaveManager; Audio::MixerImpl *_mixer; - DefaultTimerManager *_timer; Graphics::Surface _framebuffer; bool _frameBufferExists; bool _graphicsEnable; @@ -140,8 +138,6 @@ public: virtual void quit(); - virtual Common::SaveFileManager *getSavefileManager(); - void addEvent(const Common::Event& e); bool isEventQueueEmpty() const { return queuePos == 0; } @@ -159,7 +155,6 @@ public: virtual Audio::Mixer *getMixer() { return _mixer; } Audio::MixerImpl *getMixerImpl() { return _mixer; } - virtual Common::TimerManager *getTimerManager() { return _timer; } static int timerHandler(int t); @@ -172,14 +167,13 @@ public: virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool dis) { _disableCursorPalette = dis; refreshCursor(); } - - FilesystemFactory *getFilesystemFactory(); + virtual FilesystemFactory *getFilesystemFactory(); void refreshCursor(); - Common::WriteStream *createConfigWriteStream(); - Common::SeekableReadStream *createConfigReadStream(); + virtual Common::String getDefaultConfigFileName(); + + virtual void logMessage(LogMessageType::Type type, const char *message); u16 applyGamma(u16 color); void setGammaValue(int gamma) { _gammaValue = gamma; } diff --git a/backends/platform/gp2x/build/clean.sh b/backends/platform/gp2x/build/clean.sh deleted file mode 100755 index 0979f6c7d6..0000000000 --- a/backends/platform/gp2x/build/clean.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -echo Quick script to make building all the time less painful. - -# Set the paths up here to support the build. - -export PATH=/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/bin:$PATH -export PATH=/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin:$PATH -export CXX=arm-open2x-linux-g++ -export CC=arm-open2x-linux-gcc -export CXXFLAGS=-march=armv4t -export LDFLAGS=-static - -cd ../../../.. - -echo Cleaning ScummVM for GP2X. -make clean diff --git a/backends/platform/gp2x/gp2x-common.h b/backends/platform/gp2x/gp2x-common.h deleted file mode 100644 index 7efdd7164c..0000000000 --- a/backends/platform/gp2x/gp2x-common.h +++ /dev/null @@ -1,49 +0,0 @@ -/* 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. - * - */ - -#ifndef PLATFORM_SDL_GP2X_H -#define PLATFORM_SDL_GP2X_H - -#include "backends/base-backend.h" -#include "backends/platform/sdl/sdl.h" -#include "backends/platform/sdl/posix/posix.h" -#include "backends/graphics/gp2xsdl/gp2xsdl-graphics.h" -#include "backends/events/gp2xsdl/gp2xsdl-events.h" - -#ifndef PATH_MAX - #define PATH_MAX 255 -#endif - -class OSystem_GP2X : public OSystem_POSIX { -public: - OSystem_GP2X() {} - - void initBackend(); - void quit(); - void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); - void initSDL(); - -protected: - -}; - -#endif diff --git a/backends/platform/gp2x/gp2x-hw.cpp b/backends/platform/gp2x/gp2x-hw.cpp deleted file mode 100644 index 074c668b5f..0000000000 --- a/backends/platform/gp2x/gp2x-hw.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* 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. - * - */ - -/* - * GP2X: Hardware Stuff. - * Thanks to Rlyeh, Snaff, Squidge, Hermes, PS2Reality and RobBrown - * for there help with us all getting to grips with this. - * - */ - -// Disable symbol overrides so that we can use system headers. -#define FORBIDDEN_SYMBOL_ALLOW_ALL - -#include "gp2x-common.h" - -#include "gp2x-hw.h" -#include "gp2x-mem.h" - -// Linux includes to let us goof about with the system in a 'standard' way. -#include <fcntl.h> -#include <pthread.h> -#include <signal.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <sys/mman.h> -#include <sys/ioctl.h> -#include <sys/soundcard.h> -#include <sys/time.h> -#include <unistd.h> - -extern "C" { -static unsigned long gp2x_dev[8]={0,0,0,0,0,0,0,0};//, gp2x_ticks_per_second; -} - -namespace GP2X_HW { - -enum { - VOLUME_NOCHG = 0, - VOLUME_DOWN = 1, - VOLUME_UP = 2, - VOLUME_CHANGE_RATE = 8, - VOLUME_MIN = 0, - VOLUME_INITIAL = 60, - VOLUME_MAX = 100 -}; - -int volumeLevel = VOLUME_INITIAL; - -/* system registers */ -static struct -{ - unsigned short SYSCLKENREG,SYSCSETREG,FPLLVSETREG,DUALINT920,DUALINT940,DUALCTRL940; -} -system_reg; - -static unsigned short dispclockdiv; - -static volatile unsigned short *MEM_REG; - -#define SYS_CLK_FREQ 7372800 - -void deviceInit() { - // Open devices - if (!gp2x_dev[0]) gp2x_dev[0] = open("/dev/mixer", O_RDWR); - if (!gp2x_dev[1]) gp2x_dev[1] = open("/dev/batt", O_RDONLY); - if (!gp2x_dev[2]) gp2x_dev[2] = open("/dev/mem", O_RDWR); -} - -void deviceDeinit() { - // Close devices - { - int i; - for (i=0;i<8;i++) - { - if (gp2x_dev[i]) - { - close(gp2x_dev[i]); - } - } - } - - MEM_REG[0x91c>>1] = system_reg.SYSCSETREG; - MEM_REG[0x910>>1] = system_reg.FPLLVSETREG; - MEM_REG[0x3B40>>1] = system_reg.DUALINT920; - MEM_REG[0x3B42>>1] = system_reg.DUALINT940; - MEM_REG[0x3B48>>1] = system_reg.DUALCTRL940; - MEM_REG[0x904>>1] = system_reg.SYSCLKENREG; - MEM_REG[0x924>>1] = dispclockdiv; - - unpatchMMU(); -} - -void mixerMoveVolume(int direction) { - if (volumeLevel <= 10) { - if (direction == VOLUME_UP) volumeLevel += VOLUME_CHANGE_RATE/2; - if (direction == VOLUME_DOWN) volumeLevel -= VOLUME_CHANGE_RATE/2; - } else { - if(direction == VOLUME_UP) volumeLevel += VOLUME_CHANGE_RATE; - if(direction == VOLUME_DOWN) volumeLevel -= VOLUME_CHANGE_RATE; - } - - if (volumeLevel < VOLUME_MIN) volumeLevel = VOLUME_MIN; - if (volumeLevel > VOLUME_MAX) volumeLevel = VOLUME_MAX; - - unsigned long soundDev = open("/dev/mixer", O_RDWR); - - if(soundDev) { - int vol = ((volumeLevel << 8) | volumeLevel); - ioctl(soundDev, SOUND_MIXER_WRITE_PCM, &vol); - close(soundDev); - } -} - -void setCpuspeed(unsigned int mhz) -{ - set_FCLK(mhz); - set_DCLK_Div(0); - set_920_Div(0); -} - -int getBattLevel() { - int devbatt; - unsigned short currentval=0; - devbatt = open("/dev/batt", O_RDONLY); - read (devbatt, ¤tval, 2); - close (devbatt); - return (currentval); -} - -void set_display_clock_div(unsigned div) -{ - div=((div & 63) | 64)<<8; - MEM_REG[0x924>>1]=(MEM_REG[0x924>>1] & ~(255<<8)) | div; -} - - -void set_FCLK(unsigned MHZ) -{ - unsigned v; - unsigned mdiv,pdiv=3,scale=0; - MHZ*=1000000; - mdiv=(MHZ*pdiv)/SYS_CLK_FREQ; - mdiv=((mdiv-8)<<8) & 0xff00; - pdiv=((pdiv-2)<<2) & 0xfc; - scale&=3; - v=mdiv | pdiv | scale; - MEM_REG[0x910>>1]=v; -} - - -void set_920_Div(unsigned short div) -{ - unsigned short v; - v = MEM_REG[0x91c>>1] & (~0x3); - MEM_REG[0x91c>>1] = (div & 0x7) | v; -} - - -void set_DCLK_Div( unsigned short div ) -{ - unsigned short v; - v = (unsigned short)( MEM_REG[0x91c>>1] & (~(0x7 << 6)) ); - MEM_REG[0x91c>>1] = ((div & 0x7) << 6) | v; -} - - -void Disable_940(void) -{ - MEM_REG[0x3B42>>1]; - MEM_REG[0x3B42>>1]=0; - MEM_REG[0x3B46>>1]=0xffff; - MEM_REG[0x3B48>>1]|= (1 << 7); - MEM_REG[0x904>>1]&=0xfffe; -} - -void gp2x_video_wait_vsync(void) -{ - MEM_REG[0x2846>>1]=(MEM_REG[0x2846>>1] | 0x20) & ~2; - while (!(MEM_REG[0x2846>>1] & 2)); -} - -} /* namespace GP2X_HW */ - -namespace GPH { - -enum { - /* Touchscreen TapMode */ - TAPMODE_LEFT = 0, - TAPMODE_RIGHT = 1, - TAPMODE_HOVER = 2 -}; - -int tapmodeLevel = TAPMODE_LEFT; - -void ToggleTapMode() { - if (tapmodeLevel == TAPMODE_LEFT) { - tapmodeLevel = TAPMODE_RIGHT; - } else if (tapmodeLevel == TAPMODE_RIGHT) { - tapmodeLevel = TAPMODE_HOVER; - } else if (tapmodeLevel == TAPMODE_HOVER) { - tapmodeLevel = TAPMODE_LEFT; - } else { - tapmodeLevel = TAPMODE_LEFT; - } -} - - -} /* namespace GPH */ diff --git a/backends/platform/gp2x/gp2x-hw.h b/backends/platform/gp2x/gp2x-hw.h deleted file mode 100644 index 3c66400124..0000000000 --- a/backends/platform/gp2x/gp2x-hw.h +++ /dev/null @@ -1,62 +0,0 @@ -/* 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. - * - */ - -/* - * GP2X: Hardware Stuff. - * - */ - -#ifndef GP2X_HW_H -#define GP2X_HW_H - -namespace GP2X_HW { - -#define GP2X_MAXVOL 100 // Highest level permitted by GP2X's mixer -#define SYS_CLK_FREQ 7372800 // Clock Frequency - -extern int volumeLevel; - -extern void deviceInit(); -extern void deviceDeinit(); -extern void mixerMoveVolume(int); -extern void setCpuspeed(unsigned int cpuspeed); -extern int getBattLevel(); - -extern void save_system_regs(void); /* save some registers */ -extern void set_display_clock_div(unsigned div); -extern void set_FCLK(unsigned MHZ); /* adjust the clock frequency (in Mhz units) */ -extern void set_920_Div(unsigned short div); /* 0 to 7 divider (freq=FCLK/(1+div)) */ -extern void set_DCLK_Div(unsigned short div); /* 0 to 7 divider (freq=FCLK/(1+div)) */ -extern void Disable_940(void); /* 940t down */ -extern void gp2x_video_wait_vsync(void); - -} /* namespace GP2X_HW */ - -namespace GPH { - -extern int tapmodeLevel; - -extern void ToggleTapMode(); - -} /* namespace GPH */ - -#endif //GP2X_HW_H diff --git a/backends/platform/gp2x/gp2x-main.cpp b/backends/platform/gp2x/gp2x-main.cpp deleted file mode 100644 index f1ee5ed5f3..0000000000 --- a/backends/platform/gp2x/gp2x-main.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* 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. - * - */ - -#include "backends/platform/gp2x/gp2x-common.h" -#include "backends/plugins/sdl/sdl-provider.h" -#include "base/main.h" - -#if defined(GP2X) -int main(int argc, char *argv[]) { - - // Create our OSystem instance - g_system = new OSystem_GP2X(); - assert(g_system); - - // Pre initialize the backend - ((OSystem_GP2X *)g_system)->init(); - -#ifdef DYNAMIC_MODULES - PluginManager::instance().addPluginProvider(new SDLPluginProvider()); -#endif - - // Invoke the actual ScummVM main entry point: - int res = scummvm_main(argc, argv); - - // Free OSystem - delete (OSystem_GP2X *)g_system; - - return res; -} - -#endif diff --git a/backends/platform/gp2x/gp2x-mem.cpp b/backends/platform/gp2x/gp2x-mem.cpp deleted file mode 100644 index 8d22bf8130..0000000000 --- a/backends/platform/gp2x/gp2x-mem.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* 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. - * - */ - -/* - * GP2X: Memory tweaking stuff. - * - */ - -// Disable symbol overrides so that we can use system headers. -#define FORBIDDEN_SYMBOL_ALLOW_ALL - -#include <stdio.h> -#include <signal.h> -#include <setjmp.h> -#include <stdlib.h> -#include <fcntl.h> -#include <sys/mman.h> -#include <unistd.h> -#include <string.h> - -#include "backends/platform/gp2x/gp2x-mem.h" - -extern "C" { -static volatile unsigned short *gp2x_memregs; -} - -void SetClock (unsigned c) { - unsigned v; - unsigned mdiv,pdiv=3,scale=0; - - // Set ARM920t clock - c *= 1000000; - mdiv = (c*pdiv) / SYS_CLK_FREQ; - mdiv = ((mdiv-8)<<8) & 0xff00; - pdiv = ((pdiv-2)<<2) & 0xfc; - scale &= 3; - v = mdiv | pdiv | scale; - gp2x_memregs[0x910>>1] = v; -} - -void patchMMU (void) { - //volatile unsigned int *secbuf = (unsigned int *)malloc (204800); - - printf ("Reconfiguring cached memory regions...\n"); - - //hackpgtable(); - //printf ("Sucess...\n"); - - system("/sbin/rmmod mmuhack"); - system("/sbin/insmod -f mmuhack.o"); - - int mmufd = open("/dev/mmuhack", O_RDWR); - - if(mmufd < 0) { - printf ("Upper memory uncached (attempt failed, access to upper memory will be slower)...\n"); - } else { - printf ("Upper memory cached...\n"); - close(mmufd); - } -} - -void unpatchMMU (void) { - printf ("Restoreing cached memory regions...\n"); - system("/sbin/rmmod mmuhack"); -} diff --git a/backends/platform/gp2x/gp2x-mem.h b/backends/platform/gp2x/gp2x-mem.h deleted file mode 100644 index b2cd00a587..0000000000 --- a/backends/platform/gp2x/gp2x-mem.h +++ /dev/null @@ -1,51 +0,0 @@ -/* 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. - * - */ - -/* - * GP2X: Memory Stuff. - * - */ - -#ifndef GP2X_MEM_H -#define GP2X_MEM_H - -#ifdef __cplusplus -extern "C" { -#endif - -// Use Squidge's MMU patch rather then myown (his is neater). -// The effect if not that great but cacheing the upper RAM is no bad thing (tm) ;). - -//extern void InitRam (void); -//extern void CloseRam (void); -// Set ARM920t clock frequency -extern void SetClock (unsigned c); -extern void patchMMU (void); -extern void unpatchMMU (void); - -#define SYS_CLK_FREQ 7372800 - -#ifdef __cplusplus - } -#endif - -#endif //GP2X_MEM_H diff --git a/backends/platform/gp2x/gp2x.cpp b/backends/platform/gp2x/gp2x.cpp deleted file mode 100644 index 0e28a6b738..0000000000 --- a/backends/platform/gp2x/gp2x.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* 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. - * - */ - -/* - * GP2X: Main backend. - * - */ - -// Disable symbol overrides so that we can use system headers. -#define FORBIDDEN_SYMBOL_ALLOW_ALL - -#include "backends/platform/sdl/sdl-sys.h" -#include "backends/platform/gp2x/gp2x-common.h" -#include "backends/platform/gp2x/gp2x-hw.h" -#include "backends/platform/gp2x/gp2x-mem.h" - -#include "backends/saves/default/default-saves.h" - -#include "common/config-manager.h" -#include "common/debug.h" - -// Disable for normal serial logging. -#define DUMP_STDOUT - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <limits.h> -#include <errno.h> -#include <sys/stat.h> - -void OSystem_GP2X::initBackend() { - // Setup default save path to be workingdir/saves - char savePath[PATH_MAX + 1]; - char workDirName[PATH_MAX + 1]; - - if (getcwd(workDirName, PATH_MAX) == NULL) { - error("Could not obtain current working directory"); - } else { - printf("Current working directory: %s\n", workDirName); - } - - strcpy(savePath, workDirName); - strcat(savePath, "/saves"); - printf("Current save directory: %s\n", savePath); - struct stat sb; - if (stat(savePath, &sb) == -1) - if (errno == ENOENT) // Create the dir if it does not exist - if (mkdir(savePath, 0755) != 0) - warning("mkdir for '%s' failed", savePath); - - ConfMan.registerDefault("savepath", savePath); - - #ifdef DUMP_STDOUT - // The GP2X has a serial console but most users do not use this so we - // output all our STDOUT and STDERR to files for debug purposes. - char STDOUT_FILE[PATH_MAX + 1]; - char STDERR_FILE[PATH_MAX + 1]; - - strcpy(STDOUT_FILE, workDirName); - strcpy(STDERR_FILE, workDirName); - strcat(STDOUT_FILE, "/scummvm.stdout.txt"); - strcat(STDERR_FILE, "/scummvm.stderr.txt"); - - /* Flush the output in case anything is queued */ - fclose(stdout); - fclose(stderr); - - /* Redirect standard input and standard output */ - FILE *newfp = freopen(STDOUT_FILE, "w", stdout); - if (newfp == NULL) { - #if !defined(stdout) - stdout = fopen(STDOUT_FILE, "w"); - #else - newfp = fopen(STDOUT_FILE, "w"); - if (newfp) { - *stdout = *newfp; - } - #endif - } - - newfp = freopen(STDERR_FILE, "w", stderr); - if (newfp == NULL) { - #if !defined(stderr) - stderr = fopen(STDERR_FILE, "w"); - #else - newfp = fopen(STDERR_FILE, "w"); - if (newfp) { - *stderr = *newfp; - } - #endif - } - - setbuf(stderr, NULL); - printf("%s\n", "Debug: STDOUT and STDERR redirected to text files."); - #endif /* DUMP_STDOUT */ - - // Setup other defaults. - ConfMan.registerDefault("aspect_ratio", true); - - /* Up default volume values as we use a seperate system level volume anyway. */ - ConfMan.registerDefault("music_volume", 192); - ConfMan.registerDefault("sfx_volume", 192); - ConfMan.registerDefault("speech_volume", 192); - ConfMan.registerDefault("autosave_period", 3 * 60); // Trigger autosave every 3 minutes - On low batts 4 mins is about your warning time. - - ConfMan.setBool("FM_low_quality", true); - - /* Initialize any GP2X specific stuff we may want (Batt Status, scaler etc.) */ - GP2X_HW::deviceInit(); - - /* Set Default hardware mixer volume to a preset level (VOLUME_INITIAL). This is done to 'reset' volume level if set by other apps. */ - GP2X_HW::mixerMoveVolume(0); - - // Create the events manager - if (_eventSource == 0) - _eventSource = new GP2XSdlEventSource(); - - // Create the graphics manager - if (_graphicsManager == 0) - _graphicsManager = new GP2XSdlGraphicsManager(_eventSource); - - /* Pass to POSIX method to do the heavy lifting */ - OSystem_POSIX::initBackend(); -} - -void OSystem_GP2X::initSDL() { - // Check if SDL has not been initialized - if (!_initedSDL) { - uint32 sdlFlags = SDL_INIT_EVENTTHREAD; - if (ConfMan.hasKey("disable_sdl_parachute")) - sdlFlags |= SDL_INIT_NOPARACHUTE; - - // Initialize SDL (SDL Subsystems are initiliazed in the corresponding sdl managers) - if (SDL_Init(sdlFlags) == -1) - error("Could not initialize SDL: %s", SDL_GetError()); - - // Enable unicode support if possible - SDL_EnableUNICODE(1); - - _initedSDL = true; - } -} - -void OSystem_GP2X::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { - /* Setup default extra data paths for engine data files and plugins */ - char workDirName[PATH_MAX + 1]; - - if (getcwd(workDirName, PATH_MAX) == NULL) { - error("Error: Could not obtain current working directory"); - } - - Common::FSNode workdirNode(workDirName); - if (workdirNode.exists() && workdirNode.isDirectory()) { - s.add("__GP2X_WORKDIR__", new Common::FSDirectory(workDirName), priority); - } - - char enginedataPath[PATH_MAX+1]; - - strcpy(enginedataPath, workDirName); - strcat(enginedataPath, "/engine-data"); - - Common::FSNode engineNode(enginedataPath); - if (engineNode.exists() && engineNode.isDirectory()) { - s.add("__GP2X_ENGDATA__", new Common::FSDirectory(enginedataPath), priority); - } - - char pluginsPath[PATH_MAX+1]; - - strcpy(pluginsPath, workDirName); - strcat(pluginsPath, "/plugins"); - - Common::FSNode pluginsNode(pluginsPath); - if (pluginsNode.exists() && pluginsNode.isDirectory()) { - s.add("__GP2X_PLUGINS__", new Common::FSDirectory(pluginsPath), priority); - } -} - -void OSystem_GP2X::quit() { - GP2X_HW::deviceDeinit(); - - #ifdef DUMP_STDOUT - printf("%s\n", "Debug: STDOUT and STDERR text files closed."); - fclose(stdout); - fclose(stderr); - #endif /* DUMP_STDOUT */ - - OSystem_POSIX::quit(); -} diff --git a/backends/platform/gp2x/module.mk b/backends/platform/gp2x/module.mk deleted file mode 100644 index 4846f162cb..0000000000 --- a/backends/platform/gp2x/module.mk +++ /dev/null @@ -1,15 +0,0 @@ -MODULE := backends/platform/gp2x - -MODULE_OBJS := \ - gp2x-hw.o \ - gp2x-main.o \ - gp2x-mem.o \ - gp2x.o - -# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS. -MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) -OBJS := $(MODULE_OBJS) $(OBJS) -MODULE_DIRS += $(sort $(dir $(MODULE_OBJS))) - -# Hack to ensure the SDL backend is built so we can use OSystem_SDL. --include $(srcdir)/backends/platform/sdl/module.mk diff --git a/backends/platform/gph/build/gp2x-config.sh b/backends/platform/gph/build/gp2x-config.sh index f474c4d0d4..a9b28b2fd0 100644 --- a/backends/platform/gph/build/gp2x-config.sh +++ b/backends/platform/gph/build/gp2x-config.sh @@ -23,8 +23,9 @@ cd ../../../.. --enable-tremor --with-tremor-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 \ --enable-zlib --with-zlib-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 \ --enable-mad --with-mad-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 \ - --enable-vkeybd --enable-plugins --default-dynamic -# --disable-release --enable-debug + --enable-vkeybd + # --enable-plugins --default-dynamic +# --disable-release --enable-debug echo Generating config for GP2X complete. Check for errors. diff --git a/backends/platform/gph/devices/gp2x/scummvm.gpe b/backends/platform/gph/devices/gp2x/scummvm.gpe index e8983aa2ce..51a49f7560 100644 --- a/backends/platform/gph/devices/gp2x/scummvm.gpe +++ b/backends/platform/gph/devices/gp2x/scummvm.gpe @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Remount SD with forced Sync, does this really work? mount -o sync,remount /dev/mmcsd/disc0/part1 /mnt/sd/ @@ -8,7 +8,7 @@ mount -o sync,remount /dev/mmcsd/disc0/part1 /mnt/sd/ export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH # Run ScummVM, important this bit. -./scummvm.gph +./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc # Sync the SD card to check that everything is written. sync diff --git a/backends/platform/gph/gph-backend.cpp b/backends/platform/gph/gph-backend.cpp index cb52da441d..ae3466b836 100644 --- a/backends/platform/gph/gph-backend.cpp +++ b/backends/platform/gph/gph-backend.cpp @@ -56,8 +56,15 @@ /* Dump console info to files. */ #define DUMP_STDOUT +OSystem_GPH::OSystem_GPH() + : + OSystem_POSIX() { +} + void OSystem_GPH::initBackend() { + assert(!_inited); + // Create the events manager if (_eventSource == 0) _eventSource = new GPHEventSource(); @@ -81,7 +88,7 @@ void OSystem_GPH::initBackend() { char workDirName[PATH_MAX+1]; if (getcwd(workDirName, PATH_MAX) == NULL) { - error("Could not obtain current working directory"); + error("Could not obtain current working directory."); } else { printf("Current working directory: %s\n", workDirName); } @@ -155,7 +162,8 @@ void OSystem_GPH::initBackend() { /* Trigger autosave every 4 minutes - On low batts 5 mins is about your warning time. */ ConfMan.registerDefault("autosave_period", 4 * 60); - /* Make sure that aspect ratio correction is enabled on the 1st run to stop users asking me what the 'wasted space' is ;-). */ + /* Make sure that aspect ratio correction is enabled on the 1st run to stop + users asking me what the 'wasted space' at the bottom is ;-). */ ConfMan.registerDefault("aspect_ratio", true); /* Make sure SDL knows that we have a joystick we want to use. */ @@ -164,10 +172,10 @@ void OSystem_GPH::initBackend() { /* Now setup any device specific user options (Left handed mode, that sort of thing). */ // GPH::setOptions(); - printf("%s\n", "Passing to OSystem::SDL initBackend."); - /* Pass to POSIX method to do the heavy lifting */ OSystem_POSIX::initBackend(); + + _inited = true; } void OSystem_GPH::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { @@ -176,7 +184,7 @@ void OSystem_GPH::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) char workDirName[PATH_MAX+1]; if (getcwd(workDirName, PATH_MAX) == NULL) { - error("Error: Could not obtain current working directory"); + error("Error: Could not obtain current working directory."); } Common::FSNode workdirNode(workDirName); @@ -215,5 +223,5 @@ void OSystem_GPH::quit() { fclose(stderr); #endif /* DUMP_STDOUT */ - OSystem_SDL::quit(); + OSystem_POSIX::quit(); } diff --git a/backends/platform/gph/gph-main.cpp b/backends/platform/gph/gph-main.cpp index f91ec8f478..1a8c6686ca 100644 --- a/backends/platform/gph/gph-main.cpp +++ b/backends/platform/gph/gph-main.cpp @@ -21,7 +21,7 @@ */ #include "backends/platform/gph/gph-sdl.h" -#include "backends/plugins/sdl/sdl-provider.h" +#include "backends/plugins/posix/posix-provider.h" #include "base/main.h" #if defined(GPH_DEVICE) @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) { ((OSystem_GPH *)g_system)->init(); #ifdef DYNAMIC_MODULES - PluginManager::instance().addPluginProvider(new SDLPluginProvider()); + PluginManager::instance().addPluginProvider(new POSIXPluginProvider()); #endif // Invoke the actual ScummVM main entry point: diff --git a/backends/platform/gph/gph-sdl.h b/backends/platform/gph/gph-sdl.h index 68a641eed7..8b943f98f3 100644 --- a/backends/platform/gph/gph-sdl.h +++ b/backends/platform/gph/gph-sdl.h @@ -28,8 +28,8 @@ #include "backends/base-backend.h" #include "backends/platform/sdl/sdl.h" #include "backends/platform/sdl/posix/posix.h" -#include "backends/graphics/gph/gph-graphics.h" #include "backends/events/gph/gph-events.h" +#include "backends/graphics/gph/gph-graphics.h" #define __GP2XWIZ__ @@ -39,6 +39,8 @@ class OSystem_GPH : public OSystem_POSIX { public: + OSystem_GPH(); + /* Platform Setup Stuff */ void addSysArchivesToSearchSet(Common::SearchSet &s, int priority); void initBackend(); diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 8e0ffc19cb..223f025978 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -67,6 +67,7 @@ - (void)updateMainSurface; - (void)updateOverlaySurface; - (void)updateMouseSurface; +- (void)clearColorBuffer; -(void)updateMouseCursor; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 006603df64..04d25cebf8 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -85,6 +85,8 @@ void iPhone_setMouseCursor(short* buffer, int width, int height) { void iPhone_enableOverlay(int state) { _overlayIsEnabled = state; + + [sharedInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; } int iPhone_getScreenHeight() { @@ -478,12 +480,7 @@ bool getLocalMouseCoords(CGPoint *point) { glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - // The color buffer is triple-buffered, so we clear it multiple times right away to avid doing any glClears later. - int clearCount = 5; - while (clearCount-- > 0) { - glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); - [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; - } + [self clearColorBuffer]; if (_keyboardView != nil) { [_keyboardView removeFromSuperview]; @@ -535,6 +532,15 @@ bool getLocalMouseCoords(CGPoint *point) { } } +- (void)clearColorBuffer { + // The color buffer is triple-buffered, so we clear it multiple times right away to avid doing any glClears later. + int clearCount = 5; + while (clearCount-- > 0) { + glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); + [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; + } +} + - (id)getEvent { if (_events == nil || [_events count] == 0) { return nil; diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 12317ad935..9325ed50bf 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -53,7 +53,7 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL; void *OSystem_IPHONE::s_soundParam = NULL; OSystem_IPHONE::OSystem_IPHONE() : - _savefile(NULL), _mixer(NULL), _timer(NULL), _offscreen(NULL), + _mixer(NULL), _offscreen(NULL), _overlayVisible(false), _fullscreen(NULL), _mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), _secondaryTapped(false), _lastSecondaryTap(0), @@ -72,10 +72,7 @@ OSystem_IPHONE::OSystem_IPHONE() : OSystem_IPHONE::~OSystem_IPHONE() { AudioQueueDispose(s_AudioQueue.queue, true); - delete _fsFactory; - delete _savefile; delete _mixer; - delete _timer; delete _offscreen; delete _fullscreen; } @@ -88,12 +85,12 @@ int OSystem_IPHONE::timerHandler(int t) { void OSystem_IPHONE::initBackend() { #ifdef IPHONE_OFFICIAL - _savefile = new DefaultSaveFileManager(iPhone_getDocumentsDir()); + _savefileManager = new DefaultSaveFileManager(iPhone_getDocumentsDir()); #else - _savefile = new DefaultSaveFileManager(SCUMMVM_SAVE_PATH); + _savefileManager = new DefaultSaveFileManager(SCUMMVM_SAVE_PATH); #endif - _timer = new DefaultTimerManager(); + _timerManager = new DefaultTimerManager(); gettimeofday(&_startTime, NULL); @@ -101,7 +98,7 @@ void OSystem_IPHONE::initBackend() { setTimerCallback(&OSystem_IPHONE::timerHandler, 10); - OSystem::initBackend(); + EventsBaseBackend::initBackend(); } bool OSystem_IPHONE::hasFeature(Feature f) { @@ -210,48 +207,25 @@ void OSystem_IPHONE::getTimeAndDate(TimeDate &td) const { td.tm_year = t.tm_year; } -Common::SaveFileManager *OSystem_IPHONE::getSavefileManager() { - assert(_savefile); - return _savefile; -} - Audio::Mixer *OSystem_IPHONE::getMixer() { assert(_mixer); return _mixer; } -Common::TimerManager *OSystem_IPHONE::getTimerManager() { - assert(_timer); - return _timer; -} - OSystem *OSystem_IPHONE_create() { return new OSystem_IPHONE(); } -Common::SeekableReadStream *OSystem_IPHONE::createConfigReadStream() { +Common::String OSystem_IPHONE::getDefaultConfigFileName() { #ifdef IPHONE_OFFICIAL - char buf[256]; - strncpy(buf, iPhone_getDocumentsDir(), 256); - strncat(buf, "/Preferences", 256 - strlen(buf) ); - Common::FSNode file(buf); + Common::String path = iPhone_getDocumentsDir(); + path += "/Preferences"; + return path; #else - Common::FSNode file(SCUMMVM_PREFS_PATH); + return SCUMMVM_PREFS_PATH; #endif - return file.createReadStream(); } -Common::WriteStream *OSystem_IPHONE::createConfigWriteStream() { -#ifdef IPHONE_OFFICIAL - char buf[256]; - strncpy(buf, iPhone_getDocumentsDir(), 256); - strncat(buf, "/Preferences", 256 - strlen(buf) ); - Common::FSNode file(buf); -#else - Common::FSNode file(SCUMMVM_PREFS_PATH); -#endif - return file.createWriteStream(); -} void OSystem_IPHONE::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { // Get URL of the Resource directory of the .app bundle diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 1ff87967a1..14325f8090 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -49,7 +49,7 @@ typedef struct AQCallbackStruct { AudioStreamBasicDescription dataFormat; } AQCallbackStruct; -class OSystem_IPHONE : public BaseBackend, public PaletteManager { +class OSystem_IPHONE : public EventsBaseBackend, public PaletteManager { protected: static const OSystem::GraphicsMode s_supportedGraphicsModes[]; @@ -57,9 +57,7 @@ protected: static SoundProc s_soundCallback; static void *s_soundParam; - Common::SaveFileManager *_savefile; Audio::MixerImpl *_mixer; - Common::TimerManager *_timer; Graphics::Surface _framebuffer; byte *_offscreen; @@ -110,7 +108,6 @@ protected: bool _fullScreenIsDirty; bool _fullScreenOverlayIsDirty; int _screenChangeCount; - FilesystemFactory *_fsFactory; public: @@ -173,19 +170,15 @@ public: virtual int getScreenChangeID() const { return _screenChangeCount; } virtual void quit(); - FilesystemFactory *getFilesystemFactory() { return _fsFactory; } virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); virtual void getTimeAndDate(TimeDate &t) const; - virtual Common::SaveFileManager *getSavefileManager(); virtual Audio::Mixer *getMixer(); - virtual Common::TimerManager *getTimerManager(); void startSoundsystem(); void stopSoundsystem(); - virtual Common::SeekableReadStream *createConfigReadStream(); - virtual Common::WriteStream *createConfigWriteStream(); + virtual Common::String getDefaultConfigFileName(); protected: void internUpdateScreen(); diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index 263cbd2bcc..fa425b108a 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -349,6 +349,7 @@ void OSystem_IPHONE::showOverlay() { //printf("showOverlay()\n"); _overlayVisible = true; dirtyFullOverlayScreen(); + updateScreen(); iPhone_enableOverlay(true); } @@ -368,7 +369,7 @@ void OSystem_IPHONE::clearOverlay() { void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { //printf("grabOverlay()\n"); - int h = _screenHeight; + int h = _overlayHeight; OverlayColor *src = _overlayBuffer; do { diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h index 8c0b34ce32..dfa8f58cce 100644 --- a/backends/platform/n64/osys_n64.h +++ b/backends/platform/n64/osys_n64.h @@ -27,8 +27,6 @@ #include "common/config-manager.h" #include "backends/base-backend.h" -#include "backends/saves/default/default-saves.h" -#include "backends/timer/default/default-timer.h" #include "base/main.h" @@ -73,12 +71,9 @@ enum GraphicModeID { OVERS_MPAL_340X240 }; -class OSystem_N64 : public BaseBackend, public PaletteManager { +class OSystem_N64 : public EventsBaseBackend, public PaletteManager { protected: - Common::SaveFileManager *_savefile; Audio::MixerImpl *_mixer; - Common::TimerManager *_timer; - FilesystemFactory *_fsFactory; struct display_context * _dc; // Display context for N64 on screen buffer switching @@ -189,7 +184,6 @@ public: virtual void warpMouse(int x, int y); virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool disable); virtual bool pollEvent(Common::Event &event); virtual uint32 getMillis(); @@ -202,12 +196,9 @@ public: virtual void quit(); - virtual Common::SaveFileManager *getSavefileManager(); virtual Audio::Mixer *getMixer(); virtual void getTimeAndDate(TimeDate &t) const; - virtual Common::TimerManager *getTimerManager(); virtual void setTimerCallback(TimerProc callback, int interval); - FilesystemFactory *getFilesystemFactory(); void rebuildOffscreenGameBuffer(void); void rebuildOffscreenMouseBuffer(void); diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp index 094bb839d3..69e8da3526 100644 --- a/backends/platform/n64/osys_n64_base.cpp +++ b/backends/platform/n64/osys_n64_base.cpp @@ -30,6 +30,8 @@ #include "pakfs_save_manager.h" #include "framfs_save_manager.h" #include "backends/fs/n64/n64-fs-factory.h" +#include "backends/saves/default/default-saves.h" +#include "backends/timer/default/default-timer.h" typedef unsigned long long uint64; @@ -137,9 +139,7 @@ OSystem_N64::OSystem_N64() { _mouseMaxX = _overlayWidth; _mouseMaxY = _overlayHeight; - _savefile = 0; _mixer = 0; - _timer = 0; _dirtyOffscreen = false; @@ -154,10 +154,7 @@ OSystem_N64::OSystem_N64() { } OSystem_N64::~OSystem_N64() { - delete _savefile; delete _mixer; - delete _timer; - delete _fsFactory; } void OSystem_N64::initBackend() { @@ -170,7 +167,7 @@ void OSystem_N64::initBackend() { if (FRAM_Detect()) { // Use FlashRAM initFramFS(); - _savefile = new FRAMSaveManager(); + _savefileManager = new FRAMSaveManager(); } else { // Use PakFS // Init Controller Pak initPakFs(); @@ -185,28 +182,36 @@ void OSystem_N64::initBackend() { } } - _savefile = new PAKSaveManager(); + _savefileManager = new PAKSaveManager(); } - _timer = new DefaultTimerManager(); + _timerManager = new DefaultTimerManager(); setTimerCallback(&timer_handler, 10); setupMixer(); - OSystem::initBackend(); - + EventsBaseBackend::initBackend(); } bool OSystem_N64::hasFeature(Feature f) { - return (f == kFeatureCursorHasPalette); + return (f == kFeatureCursorPalette); } void OSystem_N64::setFeatureState(Feature f, bool enable) { - return; + if (f == kFeatureCursorPalette) { + _cursorPaletteDisabled = !enable; + + // Rebuild cursor hicolor buffer + rebuildOffscreenMouseBuffer(); + + _dirtyOffscreen = true; + } } bool OSystem_N64::getFeatureState(Feature f) { + if (f == kFeatureCursorPalette) + return !_cursorPaletteDisabled; return false; } @@ -437,15 +442,6 @@ void OSystem_N64::setCursorPalette(const byte *colors, uint start, uint num) { _dirtyOffscreen = true; } -void OSystem_N64::disableCursorPalette(bool disable) { - _cursorPaletteDisabled = disable; - - // Rebuild cursor hicolor buffer - rebuildOffscreenMouseBuffer(); - - _dirtyOffscreen = true; -} - void OSystem_N64::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { //Clip the coordinates if (x < 0) { @@ -852,21 +848,11 @@ void OSystem_N64::quit() { return; } -Common::SaveFileManager *OSystem_N64::getSavefileManager() { - assert(_savefile); - return _savefile; -} - Audio::Mixer *OSystem_N64::getMixer() { assert(_mixer); return _mixer; } -Common::TimerManager *OSystem_N64::getTimerManager() { - assert(_timer); - return _timer; -} - void OSystem_N64::getTimeAndDate(TimeDate &t) const { // No RTC inside the N64, read mips timer to simulate // passing of time, not a perfect solution, but can't think @@ -884,10 +870,6 @@ void OSystem_N64::getTimeAndDate(TimeDate &t) const { return; } -FilesystemFactory *OSystem_N64::getFilesystemFactory() { - return _fsFactory; -} - void OSystem_N64::setTimerCallback(TimerProc callback, int interval) { assert (interval > 0); diff --git a/backends/platform/n64/osys_n64_utilities.cpp b/backends/platform/n64/osys_n64_utilities.cpp index 8d9f0471d3..0622e6423d 100644 --- a/backends/platform/n64/osys_n64_utilities.cpp +++ b/backends/platform/n64/osys_n64_utilities.cpp @@ -21,6 +21,7 @@ */ #include "osys_n64.h" +#include "backends/timer/default/default-timer.h" void checkTimers(void) { OSystem_N64 *osys = (OSystem_N64 *)g_system; diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp index b9e901bb5a..106cde1699 100644 --- a/backends/platform/null/null.cpp +++ b/backends/platform/null/null.cpp @@ -52,9 +52,6 @@ public: virtual uint32 getMillis(); virtual void delayMillis(uint msecs); virtual void getTimeAndDate(TimeDate &t) const {} - - virtual Common::SeekableReadStream *createConfigReadStream(); - virtual Common::WriteStream *createConfigWriteStream(); }; OSystem_NULL::OSystem_NULL() { @@ -73,12 +70,11 @@ OSystem_NULL::~OSystem_NULL() { } void OSystem_NULL::initBackend() { - _mutexManager = (MutexManager *)new NullMutexManager(); + _mutexManager = new NullMutexManager(); _timerManager = new DefaultTimerManager(); _eventManager = new DefaultEventManager(this); _savefileManager = new DefaultSaveFileManager(); - _graphicsManager = (GraphicsManager *)new NullGraphicsManager(); - _audiocdManager = (AudioCDManager *)new DefaultAudioCDManager(); + _graphicsManager = new NullGraphicsManager(); _mixer = new Audio::MixerImpl(this, 22050); ((Audio::MixerImpl *)_mixer)->setReady(false); @@ -87,7 +83,7 @@ void OSystem_NULL::initBackend() { // this way; they need to be hooked into the system somehow to // be functional. Of course, can't do that in a NULL backend :). - OSystem::initBackend(); + ModularBackend::initBackend(); } bool OSystem_NULL::pollEvent(Common::Event &event) { @@ -101,18 +97,6 @@ uint32 OSystem_NULL::getMillis() { void OSystem_NULL::delayMillis(uint msecs) { } -#define DEFAULT_CONFIG_FILE "scummvm.ini" - -Common::SeekableReadStream *OSystem_NULL::createConfigReadStream() { - Common::FSNode file(DEFAULT_CONFIG_FILE); - return file.createReadStream(); -} - -Common::WriteStream *OSystem_NULL::createConfigWriteStream() { - Common::FSNode file(DEFAULT_CONFIG_FILE); - return file.createWriteStream(); -} - OSystem *OSystem_NULL_create() { return new OSystem_NULL(); } diff --git a/backends/platform/openpandora/op-backend.cpp b/backends/platform/openpandora/op-backend.cpp index 4c29636e40..5231e9790d 100644 --- a/backends/platform/openpandora/op-backend.cpp +++ b/backends/platform/openpandora/op-backend.cpp @@ -20,13 +20,16 @@ * */ +#if defined(OPENPANDORA) + // Disable symbol overrides so that we can use system headers. #define FORBIDDEN_SYMBOL_ALLOW_ALL -#include "backends/platform/openpandora/op-sdl.h" -#include "base/main.h" +#include "backends/platform/sdl/sdl-sys.h" #include "backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h" +#include "backends/platform/openpandora/op-sdl.h" +#include "backends/plugins/posix/posix-provider.h" #include "backends/saves/default/default-saves.h" #include "backends/timer/default/default-timer.h" @@ -35,6 +38,7 @@ #include "common/debug.h" #include "common/events.h" #include "common/file.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/mixer_intern.h" @@ -52,15 +56,29 @@ static SDL_Cursor *hiddenCursor; -static Uint32 timer_handler(Uint32 interval, void *param) { - ((DefaultTimerManager *)param)->handler(); - return interval; +OSystem_OP::OSystem_OP() + : + OSystem_POSIX() { } +//static Uint32 timer_handler(Uint32 interval, void *param) { +// ((DefaultTimerManager *)param)->handler(); +// return interval; +//} + void OSystem_OP::initBackend() { assert(!_inited); + // Create the events manager + if (_eventSource == 0) + _eventSource = new OPEventSource(); + + // Create the graphics manager + if (_graphicsManager == 0) { + _graphicsManager = new OPGraphicsManager(_eventSource); + } + // int joystick_num = ConfMan.getInt("joystick_num"); // uint32 sdlFlags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER; // @@ -76,12 +94,12 @@ void OSystem_OP::initBackend() { // // Create the mixer manager - if (_mixer == 0) { - _mixerManager = new DoubleBufferSDLMixerManager(); +// if (_mixer == 0) { +// _mixerManager = new DoubleBufferSDLMixerManager(); // Setup and start mixer - _mixerManager->init(); - } +// _mixerManager->init(); +// } /* Setup default save path to be workingdir/saves */ @@ -103,7 +121,7 @@ void OSystem_OP::initBackend() { if (mkdir(savePath, 0755) != 0) warning("mkdir for '%s' failed!", savePath); -// _savefileManager = new DefaultSaveFileManager(savePath); + _savefileManager = new DefaultSaveFileManager(savePath); #ifdef DUMP_STDOUT // The OpenPandora has a serial console on the EXT connection but most users do not use this so we @@ -161,24 +179,14 @@ void OSystem_OP::initBackend() { /* Make sure SDL knows that we have a joystick we want to use. */ ConfMan.setInt("joystick_num", 0); - // Create the events manager - if (_eventSource == 0) - _eventSource = new OPEventSource(); - - // Create the graphics manager - if (_graphicsManager == 0) - _graphicsManager = new OPGraphicsManager(_eventSource); - // _graphicsMutex = createMutex(); - // Invoke parent implementation of this method + /* Pass to POSIX method to do the heavy lifting */ OSystem_POSIX::initBackend(); _inited = true; } - - // enable joystick // if (joystick_num > -1 && SDL_NumJoysticks() > 0) { // printf("Using joystick: %s\n", SDL_JoystickName(0)); @@ -239,13 +247,14 @@ void OSystem_OP::initSDL() { // _videoMode.fullscreen = true; _initedSDL = true; + +// OSystem_POSIX::initSDL(); } } void OSystem_OP::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { /* Setup default extra data paths for engine data files and plugins */ - char workDirName[PATH_MAX+1]; if (getcwd(workDirName, PATH_MAX) == NULL) { @@ -276,3 +285,5 @@ void OSystem_OP::quit() { OSystem_POSIX::quit(); } + +#endif diff --git a/backends/platform/openpandora/op-main.cpp b/backends/platform/openpandora/op-main.cpp index ab777fec8f..bb359e7204 100644 --- a/backends/platform/openpandora/op-main.cpp +++ b/backends/platform/openpandora/op-main.cpp @@ -20,10 +20,8 @@ * */ - -#include "backends/platform/sdl/sdl-sys.h" #include "backends/platform/openpandora/op-sdl.h" -#include "backends/plugins/posix/posix-provider.h" +#include "backends/plugins/sdl/sdl-provider.h" #include "base/main.h" #if defined(OPENPANDORA) @@ -35,10 +33,10 @@ int main(int argc, char *argv[]) { assert(g_system); // Pre initialize the backend - //((OSystem_OP *)g_system)->init(); + ((OSystem_OP *)g_system)->init(); #ifdef DYNAMIC_MODULES - PluginManager::instance().addPluginProvider(new POSIXPluginProvider()); + PluginManager::instance().addPluginProvider(new SDLPluginProvider()); #endif // Invoke the actual ScummVM main entry point: diff --git a/backends/platform/openpandora/op-sdl.h b/backends/platform/openpandora/op-sdl.h index 9d92472b17..d493c3957c 100644 --- a/backends/platform/openpandora/op-sdl.h +++ b/backends/platform/openpandora/op-sdl.h @@ -26,12 +26,12 @@ #if defined(OPENPANDORA) #include "backends/base-backend.h" -#include "backends/platform/sdl/sdl.h" +#include "backends/platform/sdl/sdl-sys.h" #include "backends/platform/sdl/posix/posix.h" #include "backends/events/openpandora/op-events.h" #include "backends/graphics/openpandora/op-graphics.h" -#define __OPENPANDORA__ +//#define MIXER_DOUBLE_BUFFERING 1 #ifndef PATH_MAX #define PATH_MAX 255 @@ -39,16 +39,22 @@ class OSystem_OP : public OSystem_POSIX { public: - OSystem_OP() {} + OSystem_OP(); /* Platform Setup Stuff */ void addSysArchivesToSearchSet(Common::SearchSet &s, int priority); void initBackend(); - void initSDL(); void quit(); protected: - + bool _inited; + bool _initedSDL; + + /** + * Initialse the SDL library + * with an OpenPandora workaround. + */ + virtual void initSDL(); }; #endif #endif //OP_SDL_H diff --git a/backends/platform/ps2/fileio.cpp b/backends/platform/ps2/fileio.cpp index 038cccd9dd..ef01f3a693 100644 --- a/backends/platform/ps2/fileio.cpp +++ b/backends/platform/ps2/fileio.cpp @@ -535,23 +535,3 @@ size_t ps2_fwrite(const void *buf, size_t r, size_t n, FILE *stream) { assert(r != 0); return ((Ps2File*)stream)->write(buf, r * n) / r; } - -int ps2_fputs(const char *s, FILE *stream) { - int len = strlen(s); - - if (stream == stderr || stream == stdout) { - printf("%s", s); - sioprintf("%s", s); - return len; - } - - if (ps2_fwrite(s, 1, len, stream) == (size_t)len) - return len; - else - return EOF; -} - -int ps2_fflush(FILE *stream) { - // printf("fflush not implemented\n"); - return 0; -} diff --git a/backends/platform/ps2/fileio.h b/backends/platform/ps2/fileio.h index 3fdee5f1dc..afa2ca1f24 100644 --- a/backends/platform/ps2/fileio.h +++ b/backends/platform/ps2/fileio.h @@ -115,10 +115,8 @@ public: // TODO: Get rid of the following, instead use PS2FileStream directly. FILE *ps2_fopen(const char *fname, const char *mode); int ps2_fclose(FILE *stream); -int ps2_fflush(FILE *stream); size_t ps2_fread(void *buf, size_t r, size_t n, FILE *stream); size_t ps2_fwrite(const void *buf, size_t r, size_t n, FILE *stream); -int ps2_fputs(const char *s, FILE *stream); #endif // __PS2FILE_IO__ diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index 210454c9aa..d3acd06089 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -33,36 +33,41 @@ #include <assert.h> #include <iopcontrol.h> #include <iopheap.h> -#include "common/scummsys.h" -#include "engines/engine.h" -#include "backends/platform/ps2/systemps2.h" -#include "backends/platform/ps2/Gs2dScreen.h" -#include "backends/platform/ps2/ps2input.h" -#include "backends/platform/ps2/irxboot.h" + #include <sjpcm.h> #include <libhdd.h> -#include "backends/platform/ps2/savefilemgr.h" -#include "common/file.h" -#include "backends/platform/ps2/sysdefs.h" -#include "backends/platform/ps2/fileio.h" #include <libmc.h> #include <libpad.h> -#include "backends/platform/ps2/cd.h" #include <fileXio_rpc.h> -#include "backends/platform/ps2/asyncfio.h" #include "eecodyvdfs.h" -#include "graphics/surface.h" -#include "graphics/font.h" -#include "backends/timer/default/default-timer.h" -#include "audio/mixer_intern.h" + +#include "common/config-manager.h" #include "common/events.h" +#include "common/file.h" +#include "common/scummsys.h" + +#include "backends/platform/ps2/asyncfio.h" +#include "backends/platform/ps2/cd.h" +#include "backends/platform/ps2/fileio.h" +#include "backends/platform/ps2/Gs2dScreen.h" +#include "backends/platform/ps2/irxboot.h" #include "backends/platform/ps2/ps2debug.h" -#include "backends/fs/ps2/ps2-fs-factory.h" +#include "backends/platform/ps2/ps2input.h" +#include "backends/platform/ps2/savefilemgr.h" +#include "backends/platform/ps2/sysdefs.h" +#include "backends/platform/ps2/systemps2.h" +#include "backends/fs/ps2/ps2-fs-factory.h" #include "backends/plugins/ps2/ps2-provider.h" -#include "backends/saves/default/default-saves.h" -#include "common/config-manager.h" +#include "backends/timer/default/default-timer.h" + +#include "audio/mixer_intern.h" + +#include "engines/engine.h" + +#include "graphics/font.h" +#include "graphics/surface.h" #include "icon.h" #include "ps2temp.h" @@ -342,13 +347,14 @@ OSystem_PS2::OSystem_PS2(const char *elfPath) { void OSystem_PS2::init(void) { sioprintf("Timer...\n"); - _scummTimerManager = new DefaultTimerManager(); + _timerManager = new DefaultTimerManager(); _scummMixer = new Audio::MixerImpl(this, 48000); _scummMixer->setReady(true); + initTimer(); sioprintf("Starting SavefileManager\n"); - _saveManager = new Ps2SaveFileManager(this, _screen); + _savefileManager = new Ps2SaveFileManager(this, _screen); sioprintf("Initializing ps2Input\n"); _input = new Ps2Input(this, _useMouse, _useKbd); @@ -423,7 +429,7 @@ void OSystem_PS2::initTimer(void) { void OSystem_PS2::timerThreadCallback(void) { while (!_systemQuit) { WaitSema(g_TimerThreadSema); - _scummTimerManager->handler(); + ((DefaultTimerManager *)_timerManager)->handler(); } ExitThread(); } @@ -593,22 +599,10 @@ void OSystem_PS2::delayMillis(uint msecs) { } } -Common::TimerManager *OSystem_PS2::getTimerManager() { - return _scummTimerManager; -} -/* -Common::EventManager *OSystem_PS2::getEventManager() { - return getEventManager(); -} -*/ Audio::Mixer *OSystem_PS2::getMixer() { return _scummMixer; } -Common::SaveFileManager *OSystem_PS2::getSavefileManager(void) { - return _saveManager; -} - FilesystemFactory *OSystem_PS2::getFilesystemFactory() { return &Ps2FilesystemFactory::instance(); } @@ -767,7 +761,7 @@ void OSystem_PS2::msgPrintf(int millis, const char *format, ...) { void OSystem_PS2::powerOffCallback(void) { sioprintf("powerOffCallback\n"); - // _saveManager->quit(); // romeo + // _savefileManager->quit(); // romeo if (_useHdd) { sioprintf("umount\n"); fio.umount("pfs0:"); @@ -807,7 +801,7 @@ void OSystem_PS2::quit(void) { DisableIntc(INT_TIMER0); RemoveIntcHandler(INT_TIMER0, _intrId); - // _saveManager->quit(); // romeo + // _savefileManager->quit(); // romeo _screen->quit(); padEnd(); // stop pad library @@ -976,12 +970,11 @@ void OSystem_PS2::makeConfigPath() { _configFile = strdup(path); } -Common::SeekableReadStream *OSystem_PS2::createConfigReadStream() { - Common::FSNode file(_configFile); - return file.createReadStream(); +Common::String OSystem_PS2::getDefaultConfigFileName() { + return _configFile; } -Common::WriteStream *OSystem_PS2::createConfigWriteStream() { - Common::FSNode file(_configFile); - return file.createWriteStream(); +void OSystem_PS2::logMessage(LogMessageType::Type type, const char *message) { + printf("%s", message); + sioprintf("%s", message); } diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h index b21a56c184..35ceaf829e 100644 --- a/backends/platform/ps2/systemps2.h +++ b/backends/platform/ps2/systemps2.h @@ -27,12 +27,8 @@ #include "backends/base-backend.h" #include "graphics/palette.h" -class DefaultTimerManager; -class DefaultSaveFileManager; - class Gs2dScreen; class Ps2Input; -class Ps2SaveFileManager; // class Ps2FilesystemFactory; struct IrxReference; @@ -44,15 +40,11 @@ struct Ps2Mutex { int count; }; -namespace Common { -class TimerManager; -}; - namespace Audio { class MixerImpl; }; -class OSystem_PS2 : public BaseBackend, public PaletteManager { +class OSystem_PS2 : public EventsBaseBackend, public PaletteManager { public: OSystem_PS2(const char *elfPath); virtual ~OSystem_PS2(void); @@ -93,8 +85,6 @@ public: virtual uint32 getMillis(); virtual void delayMillis(uint msecs); - virtual Common::TimerManager *getTimerManager(); -// virtual Common::EventManager *getEventManager(); virtual bool pollEvent(Common::Event &event); virtual Audio::Mixer *getMixer(); @@ -112,11 +102,11 @@ public: virtual void quit(); - virtual Common::SeekableReadStream *createConfigReadStream(); - virtual Common::WriteStream *createConfigWriteStream(); + virtual Common::String getDefaultConfigFileName(); + + virtual void logMessage(LogMessageType::Type type, const char *message); virtual Graphics::PixelFormat getOverlayFormat() const; - virtual Common::SaveFileManager *getSavefileManager(); virtual FilesystemFactory *getFilesystemFactory(); virtual void getTimeAndDate(TimeDate &t) const; @@ -144,15 +134,11 @@ private: void initTimer(void); void readRtcTime(void); - DefaultTimerManager *_scummTimerManager; Audio::MixerImpl *_scummMixer; bool _mouseVisible; bool _useMouse, _useKbd, _useHdd, _usbMassLoaded, _useNet; - Ps2SaveFileManager *_saveManager; - // DefaultSaveFileManager *_saveManager; - Gs2dScreen *_screen; Ps2Input *_input; uint16 _oldMouseX, _oldMouseY; diff --git a/backends/platform/psp/cursor.h b/backends/platform/psp/cursor.h index 9c24d001fb..f79968243b 100644 --- a/backends/platform/psp/cursor.h +++ b/backends/platform/psp/cursor.h @@ -53,6 +53,7 @@ public: Buffer &buffer() { return _buffer; } void setCursorPalette(const byte *colors, uint start, uint num); void enableCursorPalette(bool enable); + bool isCursorPaletteEnabled() const { return _useCursorPalette; } void setLimits(uint32 width, uint32 height); void setXY(int x, int y); int32 getX() const { return _x; } diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 3db743eff3..01124b420e 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -89,9 +89,9 @@ void OSystem_PSP::initBackend() { _imageViewer.setInputHandler(&_inputHandler); _imageViewer.setDisplayManager(&_displayManager); - _savefile = new PSPSaveFileManager; + _savefileManager = new PSPSaveFileManager; - _timer = new DefaultTimerManager(); + _timerManager = new DefaultTimerManager(); PSP_DEBUG_PRINT("calling keyboard.load()\n"); _keyboard.load(); // Load virtual keyboard files into memory @@ -100,7 +100,7 @@ void OSystem_PSP::initBackend() { setupMixer(); - OSystem::initBackend(); + EventsBaseBackend::initBackend(); } // Let's us know an engine @@ -110,13 +110,20 @@ void OSystem_PSP::engineDone() { } bool OSystem_PSP::hasFeature(Feature f) { - return (f == kFeatureOverlaySupportsAlpha || f == kFeatureCursorHasPalette); + return (f == kFeatureOverlaySupportsAlpha || f == kFeatureCursorPalette); } void OSystem_PSP::setFeatureState(Feature f, bool enable) { + if (f == kFeatureCursorPalette) { + _pendingUpdate = false; + _cursor.enableCursorPalette(enable); + } } bool OSystem_PSP::getFeatureState(Feature f) { + if (f == kFeatureCursorPalette) { + return _cursor.isCursorPaletteEnabled(); + } return false; } @@ -198,12 +205,6 @@ void OSystem_PSP::setCursorPalette(const byte *colors, uint start, uint num) { _cursor.clearKeyColor(); // Do we need this? } -void OSystem_PSP::disableCursorPalette(bool disable) { - DEBUG_ENTER_FUNC(); - _pendingUpdate = false; - _cursor.enableCursorPalette(!disable); -} - void OSystem_PSP::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { DEBUG_ENTER_FUNC(); _displayManager.waitUntilRenderFinished(); @@ -421,7 +422,7 @@ void OSystem_PSP::quit() { } void OSystem_PSP::logMessage(LogMessageType::Type type, const char *message) { - BaseBackend::logMessage(type, message); + EventsBaseBackend::logMessage(type, message); if (type == LogMessageType::kError) PspDebugTrace(false, "%s", message); // write to file @@ -438,14 +439,6 @@ void OSystem_PSP::getTimeAndDate(TimeDate &td) const { td.tm_year = t.tm_year; } -#define PSP_CONFIG_FILE "ms0:/scummvm.ini" - -Common::SeekableReadStream *OSystem_PSP::createConfigReadStream() { - Common::FSNode file(PSP_CONFIG_FILE); - return file.createReadStream(); -} - -Common::WriteStream *OSystem_PSP::createConfigWriteStream() { - Common::FSNode file(PSP_CONFIG_FILE); - return file.createWriteStream(); +Common::String OSystem_PSP::getDefaultConfigFileName() { + return "ms0:/scummvm.ini"; } diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index 00eec3da90..e6b445e232 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -42,12 +42,10 @@ #include "backends/timer/psp/timer.h" #include "backends/platform/psp/thread.h" -class OSystem_PSP : public BaseBackend, public PaletteManager { +class OSystem_PSP : public EventsBaseBackend, public PaletteManager { private: - Common::SaveFileManager *_savefile; Audio::MixerImpl *_mixer; - Common::TimerManager *_timer; bool _pendingUpdate; // save an update we couldn't perform uint32 _pendingUpdateCounter; // prevent checking for pending update too often, in a cheap way @@ -63,7 +61,7 @@ private: ImageViewer _imageViewer; public: - OSystem_PSP() : _savefile(0), _mixer(0), _timer(0), _pendingUpdate(false), _pendingUpdateCounter(0) {} + OSystem_PSP() : _mixer(0), _pendingUpdate(false), _pendingUpdateCounter(0) {} ~OSystem_PSP(); static OSystem *instance(); @@ -99,7 +97,6 @@ protected: void grabPalette(byte *colors, uint start, uint num); public: void setCursorPalette(const byte *colors, uint start, uint num); - void disableCursorPalette(bool disable); // Screen related void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); @@ -134,7 +131,6 @@ public: // Timer typedef int (*TimerProc)(int interval); void setTimerCallback(TimerProc callback, int interval); - Common::TimerManager *getTimerManager() { return _timer; } // Mutex MutexRef createMutex(void); @@ -148,7 +144,6 @@ public: Audio::Mixer *getMixer() { return _mixer; } // Misc - Common::SaveFileManager *getSavefileManager() { return _savefile; } FilesystemFactory *getFilesystemFactory() { return &PSPFilesystemFactory::instance(); } void getTimeAndDate(TimeDate &t) const; virtual void engineDone(); @@ -157,9 +152,7 @@ public: void logMessage(LogMessageType::Type type, const char *message); - Common::SeekableReadStream *createConfigReadStream(); - Common::WriteStream *createConfigWriteStream(); - + virtual Common::String getDefaultConfigFileName(); }; #endif /* OSYS_PSP_H */ diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 0ef16d9a6e..9b11eb2c09 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -33,7 +33,9 @@ #include "common/archive.h" #include "common/fs.h" -#include "CoreFoundation/CoreFoundation.h" +#include "ApplicationServices/ApplicationServices.h" // for LSOpenFSRef +#include "CoreFoundation/CoreFoundation.h" // for CF* stuff +#include "CoreServices/CoreServices.h" // for FSPathMakeRef OSystem_MacOSX::OSystem_MacOSX() : @@ -75,4 +77,27 @@ void OSystem_MacOSX::setupIcon() { // Don't set icon on OS X, as we use a nicer external icon there. } +bool OSystem_MacOSX::hasFeature(Feature f) { + if (f == kFeatureDisplayLogFile) + return true; + return OSystem_POSIX::hasFeature(f); +} + +bool OSystem_MacOSX::displayLogFile() { + // Use LaunchServices to open the log file, if possible. + + if (_logFilePath.empty()) + return false; + + FSRef ref; + OSStatus err; + + err = FSPathMakeRef((const UInt8 *)_logFilePath.c_str(), &ref, NULL); + if (err == noErr) { + err = LSOpenFSRef(&ref, NULL); + } + + return err != noErr; +} + #endif diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h index 6d78427522..86c70297ec 100644 --- a/backends/platform/sdl/macosx/macosx.h +++ b/backends/platform/sdl/macosx/macosx.h @@ -29,6 +29,10 @@ class OSystem_MacOSX : public OSystem_POSIX { public: OSystem_MacOSX(); + virtual bool hasFeature(Feature f); + + virtual bool displayLogFile(); + virtual void initBackend(); virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); virtual void setupIcon(); diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 21ad7b9e35..d757186134 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -22,6 +22,8 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_getenv #define FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_exit +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h #define FORBIDDEN_SYMBOL_EXCEPTION_time_h //On IRIX, sys/stat.h includes sys/time.h #include "common/scummsys.h" @@ -34,6 +36,8 @@ #include <errno.h> #include <sys/stat.h> +#include <sys/wait.h> +#include <unistd.h> OSystem_POSIX::OSystem_POSIX(Common::String baseConfigName) @@ -58,6 +62,12 @@ void OSystem_POSIX::initBackend() { OSystem_SDL::initBackend(); } +bool OSystem_POSIX::hasFeature(Feature f) { + if (f == kFeatureDisplayLogFile) + return true; + return OSystem_SDL::hasFeature(f); +} + Common::String OSystem_POSIX::getDefaultConfigFileName() { char configFile[MAXPATHLEN]; @@ -73,6 +83,10 @@ Common::String OSystem_POSIX::getDefaultConfigFileName() { } Common::WriteStream *OSystem_POSIX::createLogFile() { + // Start out by resetting _logFilePath, so that in case + // of a failure, we know that no log file is open. + _logFilePath.clear(); + const char *home = getenv("HOME"); if (home == NULL) return 0; @@ -128,7 +142,62 @@ Common::WriteStream *OSystem_POSIX::createLogFile() { logFile += "/scummvm.log"; Common::FSNode file(logFile); - return file.createWriteStream(); + Common::WriteStream *stream = file.createWriteStream(); + if (stream) + _logFilePath = logFile; + return stream; } +bool OSystem_POSIX::displayLogFile() { + if (_logFilePath.empty()) + return false; + + // FIXME: This may not work perfectly when in fullscreen mode. + // On my system it drops from fullscreen without ScummVM noticing, + // so the next Alt-Enter does nothing, going from windowed to windowed. + // (wjp, 20110604) + + pid_t pid = fork(); + if (pid < 0) { + // failed to fork + return false; + } else if (pid == 0) { + + // Try xdg-open first + execlp("xdg-open", "xdg-open", _logFilePath.c_str(), (char*)0); + + // If we're here, that clearly failed. + + // TODO: We may also want to try detecting the case where + // xdg-open is successfully executed but returns an error code. + + // Try xterm+less next + + execlp("xterm", "xterm", "-e", "less", _logFilePath.c_str(), (char*)0); + + // TODO: If less does not exist we could fall back to 'more'. + // However, we'll have to use 'xterm -hold' for that to prevent the + // terminal from closing immediately (for short log files) or + // unexpectedly. + + exit(127); + } + + int status; + // Wait for viewer to close. + // (But note that xdg-open may have spawned a viewer in the background.) + + // FIXME: We probably want the viewer to always open in the background. + // This may require installing a SIGCHLD handler. + pid = waitpid(pid, &status, 0); + + if (pid < 0) { + // Probably nothing sensible to do in this error situation + return false; + } + + return WIFEXITED(status) && WEXITSTATUS(status) == 0; +} + + #endif diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h index 0a4f38e2c4..59909a958f 100644 --- a/backends/platform/sdl/posix/posix.h +++ b/backends/platform/sdl/posix/posix.h @@ -31,14 +31,31 @@ public: OSystem_POSIX(Common::String baseConfigName = ".scummvmrc"); virtual ~OSystem_POSIX() {} + virtual bool hasFeature(Feature f); + + virtual bool displayLogFile(); + virtual void init(); virtual void initBackend(); protected: - // Base string for creating the default path and filename - // for the configuration file + /** + * Base string for creating the default path and filename for the + * configuration file. This allows the Mac OS X subclass to override + * the config file path and name. + */ Common::String _baseConfigName; + /** + * The path of the currently open log file, if any. + * + * @note This is currently a string and not an FSNode for simplicity; + * e.g. we don't need to include fs.h here, and currently the + * only use of this value is to use it to open the log file in an + * editor; for that, we need it only as a string anyway. + */ + Common::String _logFilePath; + virtual Common::String getDefaultConfigFileName(); virtual Common::WriteStream *createLogFile(); diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index a3fb719ca4..afc6c850d9 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -20,8 +20,7 @@ * */ -#define FORBIDDEN_SYMBOL_EXCEPTION_time_h -#define FORBIDDEN_SYMBOL_EXCEPTION_exit +#define FORBIDDEN_SYMBOL_ALLOW_ALL #ifdef WIN32 #define WIN32_LEAN_AND_MEAN @@ -206,6 +205,8 @@ void OSystem_SDL::initBackend() { setupIcon(); _inited = true; + + ModularBackend::initBackend(); } void OSystem_SDL::initSDL() { @@ -244,20 +245,6 @@ void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) } -Common::String OSystem_SDL::getDefaultConfigFileName() { - return "scummvm.ini"; -} - -Common::SeekableReadStream *OSystem_SDL::createConfigReadStream() { - Common::FSNode file(getDefaultConfigFileName()); - return file.createReadStream(); -} - -Common::WriteStream *OSystem_SDL::createConfigWriteStream() { - Common::FSNode file(getDefaultConfigFileName()); - return file.createWriteStream(); -} - void OSystem_SDL::setWindowCaption(const char *caption) { Common::String cap; byte c; diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index e9e9bc5696..9c08752054 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -65,8 +65,6 @@ public: virtual void setWindowCaption(const char *caption); virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); - virtual Common::SeekableReadStream *createConfigReadStream(); - virtual Common::WriteStream *createConfigWriteStream(); virtual uint32 getMillis(); virtual void delayMillis(uint msecs); virtual void getTimeAndDate(TimeDate &td) const; @@ -93,6 +91,8 @@ protected: */ SdlEventSource *_eventSource; + virtual Common::EventSource *getDefaultEventSource() { return _eventSource; } + /** * Initialze the SDL library. */ @@ -103,12 +103,6 @@ protected: */ virtual void setupIcon(); - /** - * Get the file path where the user configuration - * of ScummVM will be saved. - */ - virtual Common::String getDefaultConfigFileName(); - // Logging virtual Common::WriteStream *createLogFile() { return 0; } Backends::Log::Log *_logger; diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 93b76f4188..5b14be4417 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -32,6 +32,7 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> #undef ARRAYSIZE // winnt.h defines ARRAYSIZE, but we want our own one... +#include <shellapi.h> #include "backends/platform/sdl/win32/win32.h" #include "backends/fs/windows/windows-fs-factory.h" @@ -87,6 +88,49 @@ void OSystem_Win32::init() { OSystem_SDL::init(); } + +bool OSystem_Win32::hasFeature(Feature f) { + if (f == kFeatureDisplayLogFile) + return true; + + return OSystem_SDL::hasFeature(f); +} + +bool OSystem_Win32::displayLogFile() { + if (_logFilePath.empty()) + return false; + + // Try opening the log file with the default text editor + // log files should be registered as "txtfile" by default and thus open in the default text editor + HINSTANCE shellExec = ShellExecute(NULL, NULL, _logFilePath.c_str(), NULL, NULL, SW_SHOWNORMAL); + if ((intptr_t)shellExec > 32) + return true; + + // ShellExecute with the default verb failed, try the "Open with..." dialog + PROCESS_INFORMATION processInformation; + STARTUPINFO startupInfo; + memset(&processInformation, 0, sizeof(processInformation)); + memset(&startupInfo, 0, sizeof(startupInfo)); + startupInfo.cb = sizeof(startupInfo); + + char cmdLine[MAX_PATH * 2]; // CreateProcess may change the contents of cmdLine + sprintf(cmdLine, "rundll32 shell32.dll,OpenAs_RunDLL %s", _logFilePath.c_str()); + BOOL result = CreateProcess(NULL, + cmdLine, + NULL, + NULL, + FALSE, + NORMAL_PRIORITY_CLASS, + NULL, + NULL, + &startupInfo, + &processInformation); + if (result) + return true; + + return false; +} + Common::String OSystem_Win32::getDefaultConfigFileName() { char configFile[MAXPATHLEN]; @@ -136,6 +180,10 @@ Common::String OSystem_Win32::getDefaultConfigFileName() { } Common::WriteStream *OSystem_Win32::createLogFile() { + // Start out by resetting _logFilePath, so that in case + // of a failure, we know that no log file is open. + _logFilePath.clear(); + char logFile[MAXPATHLEN]; OSVERSIONINFO win32OsVersion; @@ -163,7 +211,11 @@ Common::WriteStream *OSystem_Win32::createLogFile() { strcat(logFile, "\\scummvm.log"); Common::FSNode file(logFile); - return file.createWriteStream(); + Common::WriteStream *stream = file.createWriteStream(); + if (stream) + _logFilePath= logFile; + + return stream; } else { return 0; } diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h index 268449eeff..ef7b6af3f1 100644 --- a/backends/platform/sdl/win32/win32.h +++ b/backends/platform/sdl/win32/win32.h @@ -30,7 +30,22 @@ public: virtual void init(); virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); + + virtual bool hasFeature(Feature f); + + virtual bool displayLogFile(); + protected: + /** + * The path of the currently open log file, if any. + * + * @note This is currently a string and not an FSNode for simplicity; + * e.g. we don't need to include fs.h here, and currently the + * only use of this value is to use it to open the log file in an + * editor; for that, we need it only as a string anyway. + */ + Common::String _logFilePath; + virtual Common::String getDefaultConfigFileName(); virtual Common::WriteStream *createLogFile(); }; diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp index 401b19b0e1..c6b23783b8 100644 --- a/backends/platform/wii/osystem.cpp +++ b/backends/platform/wii/osystem.cpp @@ -34,6 +34,8 @@ #include "common/config-manager.h" #include "common/textconsole.h" #include "backends/fs/wii/wii-fs-factory.h" +#include "backends/saves/default/default-saves.h" +#include "backends/timer/default/default-timer.h" #include "osystem.h" #include "options.h" @@ -96,20 +98,12 @@ OSystem_Wii::OSystem_Wii() : _padSensitivity(16), _padAcceleration(4), - _savefile(NULL), - _mixer(NULL), - _timer(NULL) { + _mixer(NULL) { } OSystem_Wii::~OSystem_Wii() { - delete _savefile; - _savefile = NULL; - delete _mixer; _mixer = NULL; - - delete _timer; - _timer = NULL; } void OSystem_Wii::initBackend() { @@ -143,14 +137,14 @@ void OSystem_Wii::initBackend() { if (!getcwd(buf, MAXPATHLEN)) strcpy(buf, "/"); - _savefile = new DefaultSaveFileManager(buf); - _timer = new DefaultTimerManager(); + _savefileManager = new DefaultSaveFileManager(buf); + _timerManager = new DefaultTimerManager(); initGfx(); initSfx(); initEvents(); - OSystem::initBackend(); + EventsBaseBackend::initBackend(); } void OSystem_Wii::quit() { @@ -175,7 +169,7 @@ void OSystem_Wii::engineDone() { bool OSystem_Wii::hasFeature(Feature f) { return (f == kFeatureFullscreenMode) || (f == kFeatureAspectRatioCorrection) || - (f == kFeatureCursorHasPalette) || + (f == kFeatureCursorPalette) || (f == kFeatureOverlaySupportsAlpha); } @@ -188,6 +182,13 @@ void OSystem_Wii::setFeatureState(Feature f, bool enable) { case kFeatureAspectRatioCorrection: _arCorrection = enable; break; + case kFeatureCursorPalette: + _cursorPaletteDisabled = !enable; + if (_texMouse.palette && !enable) { + memcpy(_texMouse.palette, _cursorPalette, 256 * 2); + _cursorPaletteDirty = true; + } + break; default: break; } @@ -199,6 +200,8 @@ bool OSystem_Wii::getFeatureState(Feature f) { return _fullscreen; case kFeatureAspectRatioCorrection: return _arCorrection; + case kFeatureCursorPalette: + return !_cursorPaletteDisabled; default: return false; } @@ -252,21 +255,11 @@ 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(); } @@ -368,7 +361,7 @@ Common::String OSystem_Wii::getSystemLanguage() const { } else { // This will only happen when new languages are added to the API. warning("WII: Unknown system language: %d", langID); - return BaseBackend::getSystemLanguage(); + return EventsBaseBackend::getSystemLanguage(); } } #endif // !GAMECUBE diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h index 0db5f92fff..6863a6840e 100644 --- a/backends/platform/wii/osystem.h +++ b/backends/platform/wii/osystem.h @@ -32,8 +32,6 @@ #include "common/rect.h" #include "common/events.h" #include "backends/base-backend.h" -#include "backends/saves/default/default-saves.h" -#include "backends/timer/default/default-timer.h" #include "graphics/colormasks.h" #include "graphics/palette.h" #include "graphics/surface.h" @@ -54,7 +52,7 @@ extern void wii_memstats(void); } #endif -class OSystem_Wii : public BaseBackend, public PaletteManager { +class OSystem_Wii : public EventsBaseBackend, public PaletteManager { private: s64 _startup_time; @@ -130,9 +128,7 @@ private: void showOptionsDialog(); protected: - Common::SaveFileManager *_savefile; Audio::MixerImpl *_mixer; - DefaultTimerManager *_timer; public: enum { @@ -171,7 +167,6 @@ protected: virtual void grabPalette(byte *colors, uint start, uint num); public: virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool disable); virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); virtual void updateScreen(); @@ -212,9 +207,7 @@ public: virtual void setWindowCaption(const char *caption); - virtual Common::SaveFileManager *getSavefileManager(); virtual Audio::Mixer *getMixer(); - virtual Common::TimerManager *getTimerManager(); virtual FilesystemFactory *getFilesystemFactory(); virtual void getTimeAndDate(TimeDate &t) const; diff --git a/backends/platform/wii/osystem_events.cpp b/backends/platform/wii/osystem_events.cpp index 8e51bbc673..389d3823e7 100644 --- a/backends/platform/wii/osystem_events.cpp +++ b/backends/platform/wii/osystem_events.cpp @@ -35,6 +35,7 @@ #endif #include "common/config-manager.h" +#include "backends/timer/default/default-timer.h" #define TIMER_THREAD_STACKSIZE (1024 * 32) #define TIMER_THREAD_PRIO 64 diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index b44c1270f5..859e3a1395 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -394,15 +394,6 @@ void OSystem_Wii::setCursorPalette(const byte *colors, uint start, uint num) { _cursorPaletteDirty = true; } -void OSystem_Wii::disableCursorPalette(bool disable) { - _cursorPaletteDisabled = disable; - - if (_texMouse.palette && disable) { - memcpy(_texMouse.palette, _cursorPalette, 256 * 2); - _cursorPaletteDirty = true; - } -} - void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { assert(x >= 0 && x < _gameWidth); diff --git a/backends/platform/wince/CEActionsPocket.cpp b/backends/platform/wince/CEActionsPocket.cpp index f2c461fcf9..a4786d330d 100644 --- a/backends/platform/wince/CEActionsPocket.cpp +++ b/backends/platform/wince/CEActionsPocket.cpp @@ -233,15 +233,15 @@ CEActionsPocket::~CEActionsPocket() { bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) { static bool keydialogrunning = false, quitdialog = false; + _graphicsMan = ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager()); + if (!pushed) { switch (action) { case POCKET_ACTION_RIGHTCLICK: - //_CESystem->add_right_click(false); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_right_click(false); + _graphicsMan->add_right_click(false); return true; case POCKET_ACTION_LEFTCLICK: - //_CESystem->add_left_click(false); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_left_click(false); + _graphicsMan->add_left_click(false); return true; case POCKET_ACTION_PAUSE: case POCKET_ACTION_SAVE: @@ -249,7 +249,6 @@ bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) { case POCKET_ACTION_MULTI: EventsBuffer::simulateKey(&_key_action[action], false); return true; - } return false; } @@ -271,55 +270,43 @@ bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) { EventsBuffer::simulateKey(&_key_action[action], true); return true; case POCKET_ACTION_KEYBOARD: - //_CESystem->swap_panel(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_panel(); + _graphicsMan->swap_panel(); return true; case POCKET_ACTION_HIDE: - //_CESystem->swap_panel_visibility(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_panel_visibility(); + _graphicsMan->swap_panel_visibility(); return true; case POCKET_ACTION_SOUND: _CESystem->swap_sound_master(); return true; case POCKET_ACTION_RIGHTCLICK: - //_CESystem->add_right_click(true); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_right_click(true); + _graphicsMan->add_right_click(true); return true; case POCKET_ACTION_CURSOR: - //_CESystem->swap_mouse_visibility(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_mouse_visibility(); + _graphicsMan->swap_mouse_visibility(); return true; case POCKET_ACTION_FREELOOK: - //_CESystem->swap_freeLook(); - ((WINCESdlEventSource *)((OSystem_SDL *)g_system)->getEventManager())->swap_freeLook(); + _graphicsMan->swap_freeLook(); return true; case POCKET_ACTION_ZOOM_UP: - //_CESystem->swap_zoom_up(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_zoom_up(); + _graphicsMan->swap_zoom_up(); return true; case POCKET_ACTION_ZOOM_DOWN: - //_CESystem->swap_zoom_down(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_zoom_down(); + _graphicsMan->swap_zoom_down(); return true; case POCKET_ACTION_LEFTCLICK: - //_CESystem->add_left_click(true); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_left_click(true); + _graphicsMan->add_left_click(true); return true; case POCKET_ACTION_UP: - //_CESystem->move_cursor_up(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_up(); + _graphicsMan->move_cursor_up(); return true; case POCKET_ACTION_DOWN: - //_CESystem->move_cursor_down(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_down(); + _graphicsMan->move_cursor_down(); return true; case POCKET_ACTION_LEFT: - //_CESystem->move_cursor_left(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_left(); + _graphicsMan->move_cursor_left(); return true; case POCKET_ACTION_RIGHT: - //_CESystem->move_cursor_right(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_right(); + _graphicsMan->move_cursor_right(); return true; case POCKET_ACTION_QUIT: if (!quitdialog) { diff --git a/backends/platform/wince/CEActionsPocket.h b/backends/platform/wince/CEActionsPocket.h index fd97c0b1df..e1f52b6b88 100644 --- a/backends/platform/wince/CEActionsPocket.h +++ b/backends/platform/wince/CEActionsPocket.h @@ -28,6 +28,7 @@ #include "common/str.h" #include "gui/Key.h" #include "gui/Actions.h" +#include "backends/graphics/wincesdl/wincesdl-graphics.h" #define POCKET_ACTION_VERSION 5 @@ -80,6 +81,7 @@ public: ~CEActionsPocket(); private: CEActionsPocket(const Common::String &gameid); + WINCESdlGraphicsManager *_graphicsMan; bool _right_click_needed; bool _hide_toolbar_needed; bool _zoom_needed; diff --git a/backends/platform/wince/CEActionsSmartphone.cpp b/backends/platform/wince/CEActionsSmartphone.cpp index fdd52cfc26..b12dadabb6 100644 --- a/backends/platform/wince/CEActionsSmartphone.cpp +++ b/backends/platform/wince/CEActionsSmartphone.cpp @@ -199,15 +199,15 @@ CEActionsSmartphone::~CEActionsSmartphone() { bool CEActionsSmartphone::perform(GUI::ActionType action, bool pushed) { static bool keydialogrunning = false, quitdialog = false; + _graphicsMan = ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager()); + if (!pushed) { switch (action) { case SMARTPHONE_ACTION_RIGHTCLICK: - //_CESystem->add_right_click(false); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_right_click(false); + _graphicsMan->add_right_click(false); return true; case SMARTPHONE_ACTION_LEFTCLICK: - //_CESystem->add_left_click(false); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_left_click(false); + _graphicsMan->add_left_click(false); return true; case SMARTPHONE_ACTION_SAVE: case SMARTPHONE_ACTION_SKIP: @@ -234,32 +234,25 @@ bool CEActionsSmartphone::perform(GUI::ActionType action, bool pushed) { EventsBuffer::simulateKey(&_key_action[action], true); return true; case SMARTPHONE_ACTION_RIGHTCLICK: - //_CESystem->add_right_click(true); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_right_click(true); + _graphicsMan->add_right_click(true); return true; case SMARTPHONE_ACTION_LEFTCLICK: - //_CESystem->add_left_click(true); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_left_click(true); + _graphicsMan->add_left_click(true); return true; case SMARTPHONE_ACTION_UP: - //_CESystem->move_cursor_up(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_up(); + _graphicsMan->move_cursor_up(); return true; case SMARTPHONE_ACTION_DOWN: - //_CESystem->move_cursor_down(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_down(); + _graphicsMan->move_cursor_down(); return true; case SMARTPHONE_ACTION_LEFT: - //_CESystem->move_cursor_left(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_left(); + _graphicsMan->move_cursor_left(); return true; case SMARTPHONE_ACTION_RIGHT: - //_CESystem->move_cursor_right(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_right(); + _graphicsMan->move_cursor_right(); return true; case SMARTPHONE_ACTION_ZONE: - //_CESystem->switch_zone(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->switch_zone(); + _graphicsMan->switch_zone(); return true; case SMARTPHONE_ACTION_BINDKEYS: if (!keydialogrunning) { @@ -271,12 +264,10 @@ bool CEActionsSmartphone::perform(GUI::ActionType action, bool pushed) { } return true; case SMARTPHONE_ACTION_KEYBOARD: - //_CESystem->swap_smartphone_keyboard(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_smartphone_keyboard(); + _graphicsMan->swap_smartphone_keyboard(); return true; case SMARTPHONE_ACTION_ROTATE: - //_CESystem->smartphone_rotate_display(); - ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->smartphone_rotate_display(); + _graphicsMan->smartphone_rotate_display(); return true; case SMARTPHONE_ACTION_QUIT: if (!quitdialog) { diff --git a/backends/platform/wince/CEActionsSmartphone.h b/backends/platform/wince/CEActionsSmartphone.h index 5535ce1350..3da46d3923 100644 --- a/backends/platform/wince/CEActionsSmartphone.h +++ b/backends/platform/wince/CEActionsSmartphone.h @@ -28,6 +28,7 @@ #include "common/str.h" #include "gui/Key.h" #include "gui/Actions.h" +#include "backends/graphics/wincesdl/wincesdl-graphics.h" #define SMARTPHONE_ACTION_VERSION 5 @@ -68,6 +69,7 @@ public: ~CEActionsSmartphone(); private: CEActionsSmartphone(); + WINCESdlGraphicsManager *_graphicsMan; bool _right_click_needed; OSystem_WINCE3 *_CESystem; }; diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index a53bc41667..3ab9dc8aa4 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -379,10 +379,17 @@ void OSystem_WINCE3::initBackend() { ((WINCESdlEventSource *)_eventSource)->init((WINCESdlGraphicsManager *)_graphicsManager); + + // FIXME: This timer manager is *not accesible* from the outside. + // Instead the timer manager setup by OSystem_SDL is visible on the outside. + // Since the WinCE backend actually seems to work, my guess is that + // SDL_AddTimer works after all and the following code is redundant. + // However it may be, this must be resolved one way or another. + // Create the timer. CE SDL does not support multiple timers (SDL_AddTimer). // We work around this by using the SetTimer function, since we only use // one timer in scummvm (for the time being) - _timer = _int_timer = new DefaultTimerManager(); + _int_timer = new DefaultTimerManager(); //_timerID = NULL; // OSystem_SDL will call removetimer with this, it's ok SDL_SetTimer(10, &timer_handler_wrapper); @@ -443,14 +450,9 @@ OSystem_WINCE3::OSystem_WINCE3() : OSystem_SDL(), } OSystem_WINCE3::~OSystem_WINCE3() { - delete _fsFactory; delete _mixer; } -FilesystemFactory *OSystem_WINCE3::getFilesystemFactory() { - return _fsFactory; -} - void OSystem_WINCE3::swap_sound_master() { _soundMaster = !_soundMaster; @@ -464,7 +466,7 @@ void OSystem_WINCE3::swap_sound_master() { void OSystem_WINCE3::engineInit() { check_mappings(); // called here to initialize virtual keys handling - //update_game_settings(); + ((WINCESdlGraphicsManager *)_graphicsManager)->update_game_settings(); // finalize mixer init _mixerManager->init(); } diff --git a/backends/platform/wince/wince-sdl.h b/backends/platform/wince/wince-sdl.h index a1e46081f9..adb63eb936 100644 --- a/backends/platform/wince/wince-sdl.h +++ b/backends/platform/wince/wince-sdl.h @@ -58,7 +58,6 @@ public: void getTimeAndDate(TimeDate &t) const; virtual Common::String getDefaultConfigFileName(); - virtual FilesystemFactory *getFilesystemFactory(); void swap_sound_master(); @@ -73,8 +72,6 @@ public: protected: void initSDL(); Audio::MixerImpl *_mixer; - DefaultTimerManager *_timer; - FilesystemFactory *_fsFactory; private: void check_mappings(); diff --git a/backends/vkeybd/virtual-keyboard-parser.cpp b/backends/vkeybd/virtual-keyboard-parser.cpp index e2b35132dc..5e4ce11fe4 100644 --- a/backends/vkeybd/virtual-keyboard-parser.cpp +++ b/backends/vkeybd/virtual-keyboard-parser.cpp @@ -59,8 +59,7 @@ bool VirtualKeyboardParser::closedKeyCallback(ParserNode *node) { return parserError("Initial mode of keyboard pack not defined"); } else if (node->name.equalsIgnoreCase("mode")) { if (!_layoutParsed) { - return parserError("'%s' layout missing from '%s' mode", - _mode->resolution.c_str(), _mode->name.c_str()); + return parserError("'" + _mode->resolution + "' layout missing from '" + _mode->name + "' mode"); } } return true; @@ -105,7 +104,7 @@ bool VirtualKeyboardParser::parserCallback_mode(ParserNode *node) { if (_parseMode == kParseFull) { // if full parse then add new mode to keyboard if (_keyboard->_modes.contains(name)) - return parserError("Mode '%s' has already been defined", name.c_str()); + return parserError("Mode '" + name + "' has already been defined"); VirtualKeyboard::Mode mode; mode.name = name; @@ -177,7 +176,7 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) { String name = node->values["name"]; if (_mode->events.contains(name)) - return parserError("Event '%s' has already been defined", name.c_str()); + return parserError("Event '" + name + "' has already been defined"); VirtualKeyboard::VKEvent *evt = new VirtualKeyboard::VKEvent(); evt->name = name; @@ -235,7 +234,7 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) { evt->type = VirtualKeyboard::kVKEventMoveRight; } else { delete evt; - return parserError("Event type '%s' not known", type.c_str()); + return parserError("Event type '" + type + "' not known"); } _mode->events[name] = evt; @@ -257,7 +256,7 @@ bool VirtualKeyboardParser::parserCallback_layout(ParserNode *node) { SeekableReadStream *file = _keyboard->_fileArchive->createReadStreamForMember(_mode->bitmapName); if (!file) - return parserError("Bitmap '%s' not found", _mode->bitmapName.c_str()); + return parserError("Bitmap '" + _mode->bitmapName + "' not found"); const Graphics::PixelFormat format = g_system->getOverlayFormat(); @@ -265,7 +264,7 @@ bool VirtualKeyboardParser::parserCallback_layout(ParserNode *node) { delete file; if (!_mode->image) - return parserError("Error loading bitmap '%s'", _mode->bitmapName.c_str()); + return parserError("Error loading bitmap '" + _mode->bitmapName + "'"); int r, g, b; if (node->values.contains("transparent_color")) { @@ -313,7 +312,7 @@ bool VirtualKeyboardParser::parserCallback_area(ParserNode *node) { Polygon *poly = _mode->imageMap.createArea(target); return parsePolygon(*poly, coords); } - return parserError("Area shape '%s' not known", shape.c_str()); + return parserError("Area shape '" + shape + "' not known"); } byte VirtualKeyboardParser::parseFlags(const String& flags) { |