diff options
Diffstat (limited to 'backends/platform')
77 files changed, 787 insertions, 1209 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index a67ee51b4d..17c7d4f9cb 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); @@ -389,7 +389,7 @@ void OSystem_Android::initBackend() { JNI::setReadyForEvents(true); - BaseBackend::initBackend(); + EventsBaseBackend::initBackend(); } void OSystem_Android::addPluginDirectories(Common::FSList &dirs) const { @@ -423,7 +423,7 @@ void OSystem_Android::setFeatureState(Feature f, bool enable) { showVirtualKeyboard(enable); break; case kFeatureCursorPalette: - _use_mouse_palette = !enable; + _use_mouse_palette = enable; if (!enable) disableCursorPalette(); break; @@ -535,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); @@ -563,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(""); diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index b70fdb7c30..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; @@ -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/jni.cpp b/backends/platform/android/jni.cpp index c4daf24e16..e3b4ef7401 100644 --- a/backends/platform/android/jni.cpp +++ b/backends/platform/android/jni.cpp @@ -22,8 +22,9 @@ #if defined(__ANDROID__) -// Allow use of stuff in <time.h> +// Allow use of stuff in <time.h> and abort() #define FORBIDDEN_SYMBOL_EXCEPTION_time_h +#define FORBIDDEN_SYMBOL_EXCEPTION_abort // Disable printf override in common/forbidden.h to avoid // clashes with log.h from the Android SDK. diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index c7659e8292..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 @@ -185,24 +185,19 @@ 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; int _ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_old_x, _ms_old_y; diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp index 47bfb0c15d..06738a687d 100644 --- a/backends/platform/dc/dcmain.cpp +++ b/backends/platform/dc/dcmain.cpp @@ -41,20 +41,21 @@ 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); @@ -62,7 +63,7 @@ void OSystem_Dreamcast::initBackend() _audiocdManager = new DCCDManager(); - BaseBackend::initBackend(); + EventsBaseBackend::initBackend(); } @@ -233,7 +234,7 @@ void OSystem_Dreamcast::logMessage(LogMessageType::Type type, const char *messag namespace DC_Flash { static int syscall_info_flash(int sect, int *info) { - return (*(int (**)(int, void*, int, int))0x8c0000b8)(sect,info,0,0); + return (*(int (**)(int, void*, int, int))0x8c0000b8)(sect,info,0,0); } static int syscall_read_flash(int offs, void *buf, int cnt) @@ -254,24 +255,24 @@ namespace DC_Flash { } return (unsigned short)~n; } - + static int flash_read_sector(int partition, int sec, unsigned char *dst) { int s, r, n, b, bmb, got=0; int info[2]; char buf[64]; char bm[64]; - + if((r = syscall_info_flash(partition, info))<0) return r; - + if((r = syscall_read_flash(info[0], buf, 64))<0) return r; - + if(memcmp(buf, "KATANA_FLASH", 12) || buf[16] != partition || buf[17] != 0) return -2; - + n = (info[1]>>6)-1-((info[1] + 0x7fff)>>15); bmb = n+1; for(b = 0; b < n; b++) { 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/plugins.cpp b/backends/platform/dc/plugins.cpp index fff3c147ec..2942a4f155 100644 --- a/backends/platform/dc/plugins.cpp +++ b/backends/platform/dc/plugins.cpp @@ -51,7 +51,7 @@ static void drawPluginProgress(const Common::String &filename) ta_begin_frame(); draw_solid_quad(80.0, 270.0, 560.0, 300.0, 0xff808080, 0xff808080, 0xff808080, 0xff808080); - draw_solid_quad(85.0, 275.0, 555.0, 295.0, + draw_solid_quad(85.0, 275.0, 555.0, 295.0, 0xff202020, 0xff202020, 0xff202020, 0xff202020); draw_solid_quad(85.0, 275.0, 85.0+470.0*ffree, 295.0, fcol, fcol, fcol, fcol); 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/dingux/dingux.cpp b/backends/platform/dingux/dingux.cpp index 1af53aeae1..674c2ea780 100644 --- a/backends/platform/dingux/dingux.cpp +++ b/backends/platform/dingux/dingux.cpp @@ -33,7 +33,7 @@ void OSystem_SDL_Dingux::initBackend() { // Create the graphics manager if (_graphicsManager == 0) { - _graphicsManager = new DINGUXSdlGraphicsManager(_eventSource); + _graphicsManager = new DINGUXSdlGraphicsManager(_eventSource); } // Call parent implementation of this method diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp index db9b1c2609..03729c5e6e 100644 --- a/backends/platform/ds/arm9/source/gbampsave.cpp +++ b/backends/platform/ds/arm9/source/gbampsave.cpp @@ -52,7 +52,7 @@ Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &f fileSpec += filename; // consolePrintf("Opening the file: %s\n", fileSpec.c_str()); - + Common::WriteStream *stream = DS::DSFileStream::makeFromPath(fileSpec, true); // Use a write buffer stream = Common::wrapBufferedWriteStream(stream, SAVE_BUFFER_SIZE); @@ -66,7 +66,7 @@ Common::InSaveFile *GBAMPSaveFileManager::openForLoading(const Common::String &f fileSpec += filename; // consolePrintf("Opening the file: %s\n", fileSpec.c_str()); - + return DS::DSFileStream::makeFromPath(fileSpec, false); } diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index eab9fd6a33..b157a3a87a 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -42,6 +42,7 @@ #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" @@ -81,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; @@ -89,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) { @@ -108,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")) { @@ -125,7 +134,7 @@ void OSystem_DS::initBackend() { _audiocdManager = new DSAudioCDManager(); */ - BaseBackend::initBackend(); + EventsBaseBackend::initBackend(); } bool OSystem_DS::hasFeature(Feature f) { @@ -747,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 diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index 1e032ba2cf..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); 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-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-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/osys_events.cpp b/backends/platform/iphone/osys_events.cpp index 6e2a4b7e1e..1ab1db0f27 100644 --- a/backends/platform/iphone/osys_events.cpp +++ b/backends/platform/iphone/osys_events.cpp @@ -335,9 +335,9 @@ bool OSystem_IPHONE::handleEvent_mouseSecondDragged(Common::Event &event, int x, const char *dialogMsg; if (_mouseClickAndDragEnabled) { _touchpadModeEnabled = false; - dialogMsg = "Mouse-click-and-drag mode enabled."; + dialogMsg = _("Mouse-click-and-drag mode enabled."); } else - dialogMsg = "Mouse-click-and-drag mode disabled."; + dialogMsg = _("Mouse-click-and-drag mode disabled."); GUI::TimedMessageDialog dialog(dialogMsg, 1500); dialog.runModal(); return false; diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 9007f006f8..4bc567c39d 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); - BaseBackend::initBackend(); + EventsBaseBackend::initBackend(); } bool OSystem_IPHONE::hasFeature(Feature f) { @@ -210,21 +207,11 @@ 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(); } @@ -255,6 +242,18 @@ void OSystem_IPHONE::addSysArchivesToSearchSet(Common::SearchSet &s, int priorit } } +void OSystem_IPHONE::logMessage(LogMessageType::Type type, const char *message) { + FILE *output = 0; + + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) + output = stdout; + else + output = stderr; + + fputs(message, output); + fflush(output); +} + void iphone_main(int argc, char *argv[]) { //OSystem_IPHONE::migrateApp(); diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 36b4b7356b..37896cceeb 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,18 @@ 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::String getDefaultConfigFileName(); + virtual void logMessage(LogMessageType::Type type, const char *message); + protected: void internUpdateScreen(); void dirtyFullScreen(); diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h index f22b221ccc..354f25a1cf 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 @@ -112,7 +107,7 @@ protected: // FIXME: This must be left as "int" for now, to fix the sign-comparison problem // there is a little more work involved than an int->uint change int _cursorWidth, _cursorHeight; - + int _cursorKeycolor; uint16 _overlayHeight, _overlayWidth; @@ -201,12 +196,10 @@ 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(); + virtual void logMessage(LogMessageType::Type type, const char *message); 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 62fe145bcc..4bc3780fe2 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,16 +182,16 @@ void OSystem_N64::initBackend() { } } - _savefile = new PAKSaveManager(); + _savefileManager = new PAKSaveManager(); } - _timer = new DefaultTimerManager(); + _timerManager = new DefaultTimerManager(); setTimerCallback(&timer_handler, 10); setupMixer(); - BaseBackend::initBackend(); + EventsBaseBackend::initBackend(); } bool OSystem_N64::hasFeature(Feature f) { @@ -851,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 @@ -883,8 +870,16 @@ void OSystem_N64::getTimeAndDate(TimeDate &t) const { return; } -FilesystemFactory *OSystem_N64::getFilesystemFactory() { - return _fsFactory; +void OSystem_N64::logMessage(LogMessageType::Type type, const char *message) { + FILE *output = 0; + + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) + output = stdout; + else + output = stderr; + + fputs(message, output); + fflush(output); } void OSystem_N64::setTimerCallback(TimerProc callback, int interval) { diff --git a/backends/platform/n64/osys_n64_events.cpp b/backends/platform/n64/osys_n64_events.cpp index 2645cfea2a..62f11aef64 100644 --- a/backends/platform/n64/osys_n64_events.cpp +++ b/backends/platform/n64/osys_n64_events.cpp @@ -162,7 +162,7 @@ bool OSystem_N64::pollEvent(Common::Event &event) { uint16 newButtons = 0; if (_controllerPort >= 0) newButtons = _ctrlData.c[_controllerPort].buttons; // Read from controller - + uint16 newMouseButtons = 0; if (_mousePort >= 0) newMouseButtons = _ctrlData.c[_mousePort].buttons; 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 106cde1699..4690a67c55 100644 --- a/backends/platform/null/null.cpp +++ b/backends/platform/null/null.cpp @@ -52,6 +52,8 @@ public: virtual uint32 getMillis(); virtual void delayMillis(uint msecs); virtual void getTimeAndDate(TimeDate &t) const {} + + virtual void logMessage(LogMessageType::Type type, const char *message); }; OSystem_NULL::OSystem_NULL() { @@ -97,6 +99,18 @@ uint32 OSystem_NULL::getMillis() { void OSystem_NULL::delayMillis(uint msecs) { } +void OSystem_NULL::logMessage(LogMessageType::Type type, const char *message) { + FILE *output = 0; + + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) + output = stdout; + else + output = stderr; + + fputs(message, output); + fflush(output); +} + 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/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index 728a67fbad..d3acd06089 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -60,7 +60,6 @@ #include "backends/fs/ps2/ps2-fs-factory.h" #include "backends/plugins/ps2/ps2-provider.h" -#include "backends/saves/default/default-saves.h" #include "backends/timer/default/default-timer.h" #include "audio/mixer_intern.h" @@ -348,14 +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); @@ -430,7 +429,7 @@ void OSystem_PS2::initTimer(void) { void OSystem_PS2::timerThreadCallback(void) { while (!_systemQuit) { WaitSema(g_TimerThreadSema); - _scummTimerManager->handler(); + ((DefaultTimerManager *)_timerManager)->handler(); } ExitThread(); } @@ -600,18 +599,10 @@ void OSystem_PS2::delayMillis(uint msecs) { } } -Common::TimerManager *OSystem_PS2::getTimerManager() { - return _scummTimerManager; -} - Audio::Mixer *OSystem_PS2::getMixer() { return _scummMixer; } -Common::SaveFileManager *OSystem_PS2::getSavefileManager(void) { - return _saveManager; -} - FilesystemFactory *OSystem_PS2::getFilesystemFactory() { return &Ps2FilesystemFactory::instance(); } @@ -770,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:"); @@ -810,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 diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h index cc9c489827..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,7 +85,6 @@ public: virtual uint32 getMillis(); virtual void delayMillis(uint msecs); - virtual Common::TimerManager *getTimerManager(); virtual bool pollEvent(Common::Event &event); virtual Audio::Mixer *getMixer(); @@ -116,7 +107,6 @@ public: 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.cpp b/backends/platform/psp/cursor.cpp index 18a61f3df4..b295507de1 100644 --- a/backends/platform/psp/cursor.cpp +++ b/backends/platform/psp/cursor.cpp @@ -324,18 +324,18 @@ inline void Cursor::setRendererModePalettized(bool palettized) { _renderer.setAlphaReverse(false); _renderer.setColorTest(false); } else { // 16 bits, no palette - // Color test is an easy way for the hardware to make our keycolor + // Color test is an easy way for the hardware to make our keycolor // transparent. - _renderer.setColorTest(true); - + _renderer.setColorTest(true); + // Alpha blending is not strictly required, but makes the cursor look // much better _renderer.setAlphaBlending(true); - + // Pixel formats without alpha (5650) are considered to have their alpha set. // Since pixel formats with alpha don't have their alpha bits set, we reverse // the alpha format for them so that 0 alpha is 1. - if (_buffer.getPixelFormat() != PSPPixelFormat::Type_5650) + if (_buffer.getPixelFormat() != PSPPixelFormat::Type_5650) _renderer.setAlphaReverse(true); else _renderer.setAlphaReverse(false); diff --git a/backends/platform/psp/display_client.cpp b/backends/platform/psp/display_client.cpp index 14b96d9cae..bc29166895 100644 --- a/backends/platform/psp/display_client.cpp +++ b/backends/platform/psp/display_client.cpp @@ -389,31 +389,31 @@ void Buffer::copyToArray(byte *dst, int pitch) { void Buffer::setSize(uint32 width, uint32 height, HowToSize textureOrSource/*=kSizeByTextureSize*/) { DEBUG_ENTER_FUNC(); - + // We can size the buffer either by texture size (multiple of 2^n) or source size. // At higher sizes, increasing the texture size to 2^n is a waste of space. At these sizes kSizeBySourceSize should be used. - + _sourceSize.width = width; _sourceSize.height = height; _textureSize.width = scaleUpToPowerOfTwo(width); // can only scale up to 512 _textureSize.height = scaleUpToPowerOfTwo(height); - + if (textureOrSource == kSizeByTextureSize) { _width = _textureSize.width; _height = _textureSize.height; } else { // sizeBySourceSize _width = _sourceSize.width; _height = _sourceSize.height; - - // adjust allocated width to be divisible by 32. + + // adjust allocated width to be divisible by 32. // The GU can only handle multiples of 16 bytes. A 4 bit image x 32 will give us 16 bytes // We don't necessarily know the depth of the pixels here. So just make it divisible by 32. uint32 checkDiv = _width & 31; if (checkDiv) _width += 32 - checkDiv; } - + PSP_DEBUG_PRINT("width[%u], height[%u], texW[%u], texH[%u], sourceW[%d], sourceH[%d] %s\n", _width, _height, _textureSize.width, _textureSize.height, _sourceSize.width, _sourceSize.height, textureOrSource ? "size by source" : "size by texture"); } @@ -558,10 +558,10 @@ void GuRenderer::render() { // Loop over patches of 512x512 pixel textures and draw them for (uint32 j = 0; j < _buffer->getSourceHeight(); j += 512) { _textureLoadOffset.y = j; - + for (uint32 i = 0; i < _buffer->getSourceWidth(); i += 512) { _textureLoadOffset.x = i; - + guLoadTexture(); Vertex *vertices = guGetVertices(); fillVertices(vertices); @@ -573,8 +573,8 @@ void GuRenderer::render() { inline void GuRenderer::guProgramDrawBehavior() { DEBUG_ENTER_FUNC(); - PSP_DEBUG_PRINT("blending[%s] colorTest[%s] reverseAlpha[%s] keyColor[%u]\n", - _blending ? "on" : "off", _colorTest ? "on" : "off", + PSP_DEBUG_PRINT("blending[%s] colorTest[%s] reverseAlpha[%s] keyColor[%u]\n", + _blending ? "on" : "off", _colorTest ? "on" : "off", _alphaReverse ? "on" : "off", _keyColor); if (_blending) { @@ -591,7 +591,7 @@ inline void GuRenderer::guProgramDrawBehavior() { if (_colorTest) { sceGuEnable(GU_COLOR_TEST); sceGuColorFunc(GU_NOTEQUAL, // show only colors not equal to this color - _keyColor, + _keyColor, 0x00ffffff); // match everything but alpha } else sceGuDisable(GU_COLOR_TEST); @@ -663,10 +663,10 @@ inline void GuRenderer::guLoadTexture() { byte *startPoint = _buffer->getPixels(); if (_textureLoadOffset.x) startPoint += _buffer->_pixelFormat.pixelsToBytes(_textureLoadOffset.x); - if (_textureLoadOffset.y) + if (_textureLoadOffset.y) startPoint += _buffer->getWidthInBytes() * _textureLoadOffset.y; - - sceGuTexImage(0, + + sceGuTexImage(0, _buffer->getTextureWidth(), // texture width (must be power of 2) _buffer->getTextureHeight(), // texture height (must be power of 2) _buffer->getWidth(), // width of a line of the image (to get to the next line) @@ -698,7 +698,7 @@ void GuRenderer::fillVertices(Vertex *vertices) { // These coordinates describe an area within the texture. ie. we already loaded a square of texture, // now the coordinates within it are 0 to the edge of the area of the texture we want to draw float textureStartX = textureFix + _offsetInBuffer.x; - float textureStartY = textureFix + _offsetInBuffer.y; + float textureStartY = textureFix + _offsetInBuffer.y; int textureLeftX = _drawSize.width - _textureLoadOffset.x; if (textureLeftX > 512) @@ -720,7 +720,7 @@ void GuRenderer::fillVertices(Vertex *vertices) { float imageStartY = gapY + scaledOffsetOnScreenY + (scaleSourceToOutput(false, stretch(false, _textureLoadOffset.y))); float imageEndX, imageEndY; - + imageEndX = imageStartX + scaleSourceToOutput(true, stretch(true, textureLeftX)); imageEndY = imageStartY + scaleSourceToOutput(false, stretch(false, textureLeftY)); diff --git a/backends/platform/psp/display_client.h b/backends/platform/psp/display_client.h index f190658a26..e384bfb82b 100644 --- a/backends/platform/psp/display_client.h +++ b/backends/platform/psp/display_client.h @@ -171,12 +171,12 @@ protected: class GuRenderer { public: // Constructors - GuRenderer() : _useGlobalScaler(false), _buffer(0), _palette(0), - _blending(false), _alphaReverse(false), _colorTest(false), + GuRenderer() : _useGlobalScaler(false), _buffer(0), _palette(0), + _blending(false), _alphaReverse(false), _colorTest(false), _keyColor(0), _fullScreen(false), _stretch(false), _stretchX(1.0f), _stretchY(1.0f) {} - GuRenderer(Buffer *buffer, Palette *palette) : - _useGlobalScaler(false), _buffer(buffer), _palette(palette), - _blending(false), _alphaReverse(false), _colorTest(false), + GuRenderer(Buffer *buffer, Palette *palette) : + _useGlobalScaler(false), _buffer(buffer), _palette(palette), + _blending(false), _alphaReverse(false), _colorTest(false), _keyColor(0), _fullScreen(false), _stretch(false), _stretchX(1.0f), _stretchY(1.0f) {} static void setDisplayManager(DisplayManager *dm) { _displayManager = dm; } // Called by the Display Manager diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp index 899b79727f..e945dca4a8 100644 --- a/backends/platform/psp/display_manager.cpp +++ b/backends/platform/psp/display_manager.cpp @@ -299,7 +299,7 @@ void DisplayManager::init() { #endif // Init overlay since we never change the size - _overlay->deallocate(); + _overlay->deallocate(); _overlay->setBytesPerPixel(sizeof(OverlayColor)); _overlay->setSize(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); _overlay->allocate(); @@ -432,13 +432,13 @@ bool DisplayManager::renderAll() { _screen->render(); _screen->setClean(); // clean out dirty bit - + if (_imageViewer->isVisible()) _imageViewer->render(); _imageViewer->setClean(); if (_overlay->isVisible()) - _overlay->render(); + _overlay->render(); _overlay->setClean(); if (_cursor->isVisible()) @@ -448,7 +448,7 @@ bool DisplayManager::renderAll() { if (_keyboard->isVisible()) _keyboard->render(); _keyboard->setClean(); - + _masterGuRenderer.guPostRender(); return true; // rendered successfully diff --git a/backends/platform/psp/display_manager.h b/backends/platform/psp/display_manager.h index 5176bee3fe..38c43d60a3 100644 --- a/backends/platform/psp/display_manager.h +++ b/backends/platform/psp/display_manager.h @@ -72,7 +72,7 @@ private: */ class MasterGuRenderer : public PspThreadable { public: - MasterGuRenderer() : _lastRenderTime(0), _renderFinished(true), + MasterGuRenderer() : _lastRenderTime(0), _renderFinished(true), _renderSema(1, 1), _callbackId(-1) {} void guInit(); void guPreRender(); @@ -108,7 +108,7 @@ public: KEEP_ASPECT_RATIO, STRETCHED_FULL_SCREEN }; - DisplayManager() : _screen(0), _cursor(0), _overlay(0), _keyboard(0), + DisplayManager() : _screen(0), _cursor(0), _overlay(0), _keyboard(0), _imageViewer(0), _lastUpdateTime(0), _graphicsMode(0) {} ~DisplayManager(); @@ -127,7 +127,7 @@ public: void setOverlay(Overlay *overlay) { _overlay = overlay; } void setKeyboard(PSPKeyboard *keyboard) { _keyboard = keyboard; } void setImageViewer(ImageViewer *imageViewer) { _imageViewer = imageViewer; } - + void setSizeAndPixelFormat(uint width, uint height, const Graphics::PixelFormat *format); // Getters diff --git a/backends/platform/psp/dummy.cpp b/backends/platform/psp/dummy.cpp index 86ab30b3e2..748ac8cbf3 100644 --- a/backends/platform/psp/dummy.cpp +++ b/backends/platform/psp/dummy.cpp @@ -26,31 +26,31 @@ #include <stdio.h> #include <png.h> #include <sys/socket.h> - + //void userWriteFn(png_structp png_ptr, png_bytep data, png_size_t length) { //} //void userFlushFn(png_structp png_ptr) { //} - + // Dummy functions are pulled in so that we don't need to build the plugins with certain libs - + int dummyFunc() { // For Broken Sword 2.5 volatile int i; i = clock(); rename("dummyA", "dummyB"); - + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_set_write_fn(png_ptr, NULL, NULL, NULL); png_infop info_ptr; png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); png_destroy_write_struct(&png_ptr, &info_ptr); - + // For lua's usage of libc: very heavy usage so it pulls in sockets? setsockopt(0, 0, 0, NULL, 0); getsockopt(0, 0, 0, NULL, NULL); - + return i; }
\ No newline at end of file diff --git a/backends/platform/psp/image_viewer.cpp b/backends/platform/psp/image_viewer.cpp index 97d582b63a..1ed7698bc8 100644 --- a/backends/platform/psp/image_viewer.cpp +++ b/backends/platform/psp/image_viewer.cpp @@ -34,45 +34,45 @@ #include "backends/platform/psp/input.h" #include "backends/platform/psp/display_manager.h" #include "backends/platform/psp/display_client.h" -#include "backends/platform/psp/image_viewer.h" -#include "backends/platform/psp/png_loader.h" +#include "backends/platform/psp/image_viewer.h" +#include "backends/platform/psp/png_loader.h" #include "backends/platform/psp/thread.h" static const char *imageName = "psp_image"; #define PSP_SCREEN_HEIGHT 272 #define PSP_SCREEN_WIDTH 480 - + bool ImageViewer::load(int imageNum) { if (_init) unload(); - + // build string char number[8]; sprintf(number, "%d", imageNum); - Common::String imageNameStr(imageName); + Common::String imageNameStr(imageName); Common::String specificImageName = imageNameStr + Common::String(number) + Common::String(".png"); - + // search for image file if (!SearchMan.hasFile(specificImageName)) { PSP_ERROR("file %s not found\n", specificImageName.c_str()); return false; } - + Common::ScopedPtr<Common::SeekableReadStream> file(SearchMan.createReadStreamForMember(specificImageName)); - + _buffer = new Buffer(); _palette = new Palette(); _renderer = new GuRenderer(); - + assert(_buffer); assert(_palette); assert(_renderer); - + // Load a PNG into our buffer and palette. Size it by the actual size of the image PngLoader image(file, *_buffer, *_palette, Buffer::kSizeBySourceSize); - + PngLoader::Status status = image.allocate(); // allocate the buffers for the file - + char error[100]; if (status == PngLoader::BAD_FILE) { sprintf(error, "Cannot display %s. Not a proper PNG file", specificImageName.c_str()); @@ -89,29 +89,29 @@ bool ImageViewer::load(int imageNum) { if (!image.load()) { sprintf(error, "Cannot display %s. Not a proper PNG file", specificImageName.c_str()); GUI::TimedMessageDialog dialog(error, 4000); - dialog.runModal(); + dialog.runModal(); return false; } - + setConstantRendererOptions(); setFullScreenImageParams(); // prepare renderer for full screen view - + _imageNum = imageNum; // now we can say we displayed this image _init = true; - + return true; } void ImageViewer::setConstantRendererOptions() { _renderer->setBuffer(_buffer); _renderer->setPalette(_palette); - + _renderer->setAlphaBlending(false); _renderer->setColorTest(false); _renderer->setUseGlobalScaler(false); _renderer->setStretch(true); _renderer->setOffsetInBuffer(0, 0); - _renderer->setDrawWholeBuffer(); + _renderer->setDrawWholeBuffer(); } void ImageViewer::unload() { @@ -130,32 +130,32 @@ void ImageViewer::resetOnEngineDone() { void ImageViewer::setVisible(bool visible) { DEBUG_ENTER_FUNC(); - + if (_visible == visible) return; - + // from here on, we're making the loader visible if (visible && g_engine) { // we can only run the image viewer when there's an engine g_engine->pauseEngine(true); - + load(_imageNum ? _imageNum : 1); // load the 1st image or the current } if (visible && _init) { // we managed to load _visible = true; setViewerButtons(true); - + { // so dialog goes out of scope, destroying all allocations GUI::TimedMessageDialog dialog("Image Viewer", 1000); dialog.runModal(); } - + runLoop(); // only listen to viewer events } else { // we were asked to make invisible or failed to load _visible = false; unload(); setViewerButtons(false); - + if (g_engine && g_engine->isPaused()) g_engine->pauseEngine(false); } @@ -175,7 +175,7 @@ void ImageViewer::runLoop() { void ImageViewer::setViewerButtons(bool active) { _inputHandler->setImageViewerMode(active); -} +} void ImageViewer::loadNextImage() { if (!load(_imageNum+1)) { // try to load the next image @@ -190,21 +190,21 @@ void ImageViewer::loadLastImage() { if (!load(_imageNum-1)) if (!load(_imageNum)) setVisible(false); // we can't even show the old image so hide - } + } setDirty(); } void ImageViewer::setFullScreenImageParams() { // we try to fit the image fullscreen at least in one dimension uint32 width = _buffer->getSourceWidth(); - uint32 height = _buffer->getSourceHeight(); + uint32 height = _buffer->getSourceHeight(); _centerX = PSP_SCREEN_WIDTH / 2.0f; _centerY = PSP_SCREEN_HEIGHT / 2.0f; - + // see if we fit width wise if (PSP_SCREEN_HEIGHT >= (int)((height * PSP_SCREEN_WIDTH) / (float)width)) { - setZoom(PSP_SCREEN_WIDTH / (float)width); + setZoom(PSP_SCREEN_WIDTH / (float)width); } else { setZoom(PSP_SCREEN_HEIGHT / (float)height); } @@ -233,32 +233,32 @@ void ImageViewer::render() { break; } _renderer->render(); - } + } } void ImageViewer::modifyZoom(bool up) { float factor = _zoomFactor; - if (up) + if (up) factor += 0.1f; else // down factor -= 0.1f; - - setZoom(factor); + + setZoom(factor); } -void ImageViewer::setZoom(float value) { +void ImageViewer::setZoom(float value) { if (value <= 0.0f) // don't want 0 or negative zoom return; _zoomFactor = value; - _renderer->setStretchXY(value, value); + _renderer->setStretchXY(value, value); setOffsetParams(); } void ImageViewer::moveImageX(float val) { float newVal = _centerX + val; - - if (newVal - (_visibleWidth / 2) > PSP_SCREEN_WIDTH - 4 || newVal + (_visibleWidth / 2) < 4) + + if (newVal - (_visibleWidth / 2) > PSP_SCREEN_WIDTH - 4 || newVal + (_visibleWidth / 2) < 4) return; _centerX = newVal; setOffsetParams(); @@ -266,22 +266,22 @@ void ImageViewer::moveImageX(float val) { void ImageViewer::moveImageY(float val) { float newVal = _centerY + val; - - if (newVal - (_visibleHeight / 2) > PSP_SCREEN_HEIGHT - 4 || newVal + (_visibleHeight / 2) < 4) + + if (newVal - (_visibleHeight / 2) > PSP_SCREEN_HEIGHT - 4 || newVal + (_visibleHeight / 2) < 4) return; _centerY = newVal; setOffsetParams(); } -// Set the renderer with the proper offset on the screen +// Set the renderer with the proper offset on the screen // void ImageViewer::setOffsetParams() { _visibleWidth = _zoomFactor * _buffer->getSourceWidth(); - _visibleHeight = _zoomFactor * _buffer->getSourceHeight(); - + _visibleHeight = _zoomFactor * _buffer->getSourceHeight(); + int offsetX = _centerX - (int)(_visibleWidth * 0.5f); int offsetY = _centerY - (int)(_visibleHeight * 0.5f); - + _renderer->setOffsetOnScreen(offsetX, offsetY); setDirty(); } @@ -290,8 +290,8 @@ void ImageViewer::setOffsetParams() { // void ImageViewer::handleEvent(uint32 event) { DEBUG_ENTER_FUNC(); - - switch (event) { + + switch (event) { case EVENT_HIDE: setVisible(false); break; diff --git a/backends/platform/psp/image_viewer.h b/backends/platform/psp/image_viewer.h index 4c3eaf7b4a..ad188536a3 100644 --- a/backends/platform/psp/image_viewer.h +++ b/backends/platform/psp/image_viewer.h @@ -54,10 +54,10 @@ private: float _visibleHeight, _visibleWidth; float _centerX, _centerY; Event _movement; - + InputHandler *_inputHandler; DisplayManager *_displayManager; - + void setFullScreenImageParams(); void loadNextImage(); void loadLastImage(); @@ -66,19 +66,19 @@ private: void moveImageX(float val); void moveImageY(float val); bool load(int imageNum); - void unload(); + void unload(); void runLoop(); // to get total pausing we have to do our own loop - + void setZoom(float value); void setOffsetParams(); void modifyZoom(bool up); // up or down void setVisible(bool visible); - + public: - ImageViewer() : _buffer(0), _palette(0), _visible(false), - _dirty(false), _init(false), _imageNum(0), - _zoomFactor(0.0f), _visibleHeight(0.0f), _visibleWidth(0.0f), + ImageViewer() : _buffer(0), _palette(0), _visible(false), + _dirty(false), _init(false), _imageNum(0), + _zoomFactor(0.0f), _visibleHeight(0.0f), _visibleWidth(0.0f), _centerX(0.0f), _centerY(0.0f), _movement(EVENT_MOVE_STOP), _inputHandler(0), _displayManager(0) {} ~ImageViewer() { unload(); } // deallocate images @@ -88,15 +88,15 @@ public: bool isDirty() { return _dirty; } void setDirty() { _dirty = true; } void setClean() { if (!_visible) // otherwise we want to keep rendering - _dirty = false; - } + _dirty = false; + } void resetOnEngineDone(); - + void handleEvent(uint32 event); - + // pointer setters - void setInputHandler(InputHandler *inputHandler) { _inputHandler = inputHandler; } + void setInputHandler(InputHandler *inputHandler) { _inputHandler = inputHandler; } void setDisplayManager(DisplayManager *displayManager) { _displayManager = displayManager; } }; -#endif /* PSP_IMAGE_VIEWER_H */
\ No newline at end of file +#endif /* PSP_IMAGE_VIEWER_H */
\ No newline at end of file diff --git a/backends/platform/psp/input.cpp b/backends/platform/psp/input.cpp index 17f8954e3b..a9ad441b4d 100644 --- a/backends/platform/psp/input.cpp +++ b/backends/platform/psp/input.cpp @@ -198,7 +198,7 @@ bool ButtonPad::getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData & uint32 curButtonState = PSP_ALL_BUTTONS & pad.Buttons; // we only care about these if (_combosEnabled) - modifyButtonsForCombos(pad); // change buttons for combos + modifyButtonsForCombos(pad); // change buttons for combos return getEventFromButtonState(event, pspEvent, curButtonState); } @@ -460,7 +460,7 @@ bool InputHandler::handlePspEvent(Common::Event &event, PspEvent &pspEvent) { /*case PSP_EVENT_CHANGE_SPEED: handleSpeedChange(pspEvent.data); break;*/ - case PSP_EVENT_IMAGE_VIEWER: + case PSP_EVENT_IMAGE_VIEWER: _imageViewer->handleEvent(pspEvent.data); break; case PSP_EVENT_IMAGE_VIEWER_SET_BUTTONS: @@ -530,7 +530,7 @@ void InputHandler::setImageViewerMode(bool active) { _nub.init(); _buttonPad.enableCombos(true); // re-enable combos _buttonPad.initButtons(); - } + } } void InputHandler::setButtonsForImageViewer() { @@ -538,32 +538,32 @@ void InputHandler::setButtonsForImageViewer() { // Dpad _buttonPad.clearButtons(); - _buttonPad.getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_ZOOM_IN, + _buttonPad.getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_ZOOM_IN, + PSP_EVENT_NONE, false); + _buttonPad.getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_ZOOM_OUT, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_ZOOM_OUT, + _buttonPad.getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_LAST_IMAGE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_LAST_IMAGE, + _buttonPad.getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_NEXT_IMAGE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_NEXT_IMAGE, - PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_LTRIGGER, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, + _buttonPad.getButton(ButtonPad::BTN_LTRIGGER, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_RTRIGGER, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, + _buttonPad.getButton(ButtonPad::BTN_RTRIGGER, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_START, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, + _buttonPad.getButton(ButtonPad::BTN_START, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_SELECT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, + _buttonPad.getButton(ButtonPad::BTN_SELECT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, PSP_EVENT_NONE, false); //Nub _nub.getPad().clearButtons(); - _nub.getPad().getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_UP, + _nub.getPad().getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_UP, PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); - _nub.getPad().getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_DOWN, + _nub.getPad().getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_DOWN, PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); - _nub.getPad().getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_LEFT, + _nub.getPad().getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_LEFT, PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); - _nub.getPad().getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_RIGHT, + _nub.getPad().getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_RIGHT, PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); } diff --git a/backends/platform/psp/input.h b/backends/platform/psp/input.h index 8315a3766c..ef2e1b84a4 100644 --- a/backends/platform/psp/input.h +++ b/backends/platform/psp/input.h @@ -122,16 +122,16 @@ public: ButtonPad(); void initButtons(); // set the buttons to the mode that's selected void clearButtons(); // empty the buttons of all events - + bool getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad); bool getEventFromButtonState(Common::Event &event, PspEvent &pspEvent, uint32 buttonState); - + void setShifted(ShiftMode shifted) { _shifted = shifted; } void setPadMode(PspPadMode mode) { _padMode = mode; } bool isButtonDown() { return _prevButtonState; } - + void enableCombos(bool value) { _combosEnabled = value; } - Button &getButton(ButtonType type, ShiftMode mode) { return _button[type][mode]; } + Button &getButton(ButtonType type, ShiftMode mode) { return _button[type][mode]; } }; class Nub { @@ -140,17 +140,17 @@ private: ShiftMode _shifted; bool _dpadMode; - + ButtonPad _buttonPad; // private buttonpad for dpad mode - + int32 modifyNubAxisMotion(int32 input); void translateToDpadState(int dpadX, int dpadY, uint32 &buttonState); // convert nub data to dpad data public: Nub() : _shifted(UNSHIFTED), _dpadMode(false) { } - void init() { _buttonPad.initButtons(); } + void init() { _buttonPad.initButtons(); } void setCursor(Cursor *cursor) { _cursor = cursor; } - + // setters void setDpadMode(bool active) { _dpadMode = active; } void setShifted(ShiftMode shifted) { _shifted = shifted; } @@ -163,7 +163,7 @@ public: class InputHandler { public: - InputHandler() : _keyboard(0), _cursor(0), _imageViewer(0), _padMode(PAD_MODE_NORMAL), + InputHandler() : _keyboard(0), _cursor(0), _imageViewer(0), _padMode(PAD_MODE_NORMAL), _lastPadCheckTime(0) {} // pointer setters void setKeyboard(PSPKeyboard *keyboard) { _keyboard = keyboard; } @@ -175,7 +175,7 @@ public: void setImageViewerMode(bool active); private: - Nub _nub; + Nub _nub; ButtonPad _buttonPad; // Pointers to relevant other classes diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 4408cbf481..5fa5110684 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -20,8 +20,7 @@ * */ -// Allow use of stuff in <time.h> -#define FORBIDDEN_SYMBOL_EXCEPTION_time_h +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include <pspuser.h> #include <pspgu.h> @@ -84,14 +83,14 @@ void OSystem_PSP::initBackend() { _inputHandler.setKeyboard(&_keyboard); _inputHandler.setImageViewer(&_imageViewer); _inputHandler.init(); - + // Set pointers for image viewer _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 +99,7 @@ void OSystem_PSP::initBackend() { setupMixer(); - BaseBackend::initBackend(); + EventsBaseBackend::initBackend(); } // Let's us know an engine @@ -422,7 +421,15 @@ void OSystem_PSP::quit() { } void OSystem_PSP::logMessage(LogMessageType::Type type, const char *message) { - BaseBackend::logMessage(type, message); + FILE *output = 0; + + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) + output = stdout; + else + output = stderr; + + fputs(message, output); + fflush(output); if (type == LogMessageType::kError) PspDebugTrace(false, "%s", message); // write to file diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index 4f1d6f2fa7..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(); @@ -133,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); @@ -147,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(); diff --git a/backends/platform/psp/png_loader.cpp b/backends/platform/psp/png_loader.cpp index 2f4857569e..16377539c8 100644 --- a/backends/platform/psp/png_loader.cpp +++ b/backends/platform/psp/png_loader.cpp @@ -36,7 +36,7 @@ PngLoader::Status PngLoader::allocate() { DEBUG_ENTER_FUNC(); - + if (!findImageDimensions()) { PSP_ERROR("failed to get image dimensions\n"); return BAD_FILE; @@ -45,7 +45,7 @@ PngLoader::Status PngLoader::allocate() { _buffer->setSize(_width, _height, _sizeBy); uint32 bitsPerPixel = _bitDepth * _channels; - + if (_paletteSize) { // 8 or 4-bit image if (bitsPerPixel == 4) { _buffer->setPixelFormat(PSPPixelFormat::Type_Palette_4bit); @@ -130,7 +130,7 @@ bool PngLoader::basicImageLoad() { png_get_IHDR(_pngPtr, _infoPtr, (png_uint_32 *)&_width, (png_uint_32 *)&_height, &_bitDepth, &_colorType, &interlaceType, int_p_NULL, int_p_NULL); _channels = png_get_channels(_pngPtr, _infoPtr); - + if (_colorType & PNG_COLOR_MASK_PALETTE) _paletteSize = _infoPtr->num_palette; @@ -141,7 +141,7 @@ bool PngLoader::basicImageLoad() { bool PngLoader::findImageDimensions() { DEBUG_ENTER_FUNC(); - bool status = basicImageLoad(); + bool status = basicImageLoad(); PSP_DEBUG_PRINT("width[%d], height[%d], paletteSize[%d], bitDepth[%d], channels[%d], rowBytes[%d]\n", _width, _height, _paletteSize, _bitDepth, _channels, _infoPtr->rowbytes); png_destroy_read_struct(&_pngPtr, &_infoPtr, png_infopp_NULL); @@ -157,7 +157,7 @@ bool PngLoader::loadImageIntoBuffer() { if (!basicImageLoad()) { png_destroy_read_struct(&_pngPtr, &_infoPtr, png_infopp_NULL); return false; - } + } png_set_strip_16(_pngPtr); // Strip off 16 bit channels in case they occur if (_paletteSize) { @@ -178,16 +178,16 @@ bool PngLoader::loadImageIntoBuffer() { } uint32 rowBytes = png_get_rowbytes(_pngPtr, _infoPtr); - - // there seems to be a bug in libpng where it doesn't increase the rowbytes or the + + // there seems to be a bug in libpng where it doesn't increase the rowbytes or the // channel even after we add the alpha channel if (_channels == 3 && (rowBytes / _width) == 3) { _channels = 4; - rowBytes = _width * _channels; - } - + rowBytes = _width * _channels; + } + PSP_DEBUG_PRINT("rowBytes[%d], channels[%d]\n", rowBytes, _channels); - + unsigned char *line = (unsigned char*) malloc(rowBytes); if (!line) { png_destroy_read_struct(&_pngPtr, png_infopp_NULL, png_infopp_NULL); diff --git a/backends/platform/psp/png_loader.h b/backends/platform/psp/png_loader.h index 616a79405e..0ff9d8a65d 100644 --- a/backends/platform/psp/png_loader.h +++ b/backends/platform/psp/png_loader.h @@ -61,7 +61,7 @@ public: Buffer::HowToSize sizeBy = Buffer::kSizeByTextureSize) : _file(file), _buffer(&buffer), _palette(&palette), _width(0), _height(0), _paletteSize(0), - _bitDepth(0), _sizeBy(sizeBy), _pngPtr(0), + _bitDepth(0), _sizeBy(sizeBy), _pngPtr(0), _infoPtr(0), _colorType(0), _channels(0) {} PngLoader::Status allocate(); diff --git a/backends/platform/psp/trace.cpp b/backends/platform/psp/trace.cpp index 373e00415b..b799b4e870 100644 --- a/backends/platform/psp/trace.cpp +++ b/backends/platform/psp/trace.cpp @@ -75,38 +75,38 @@ void PspDebugTrace(bool alsoToScreen, const char *format, ...) { #define GET_RET(retAddr) \ asm volatile ("move %0,$ra\n\t" \ : "=&r" (retAddr) : ) - + #define GET_SP(stackPtr) \ asm volatile ("move %0,$sp\n\t" \ : "=&r" (stackPtr) : ) // Function to retrieve a backtrace for the MIPS processor -// This is not trivial since the MIPS doesn't use a frame pointer. +// This is not trivial since the MIPS doesn't use a frame pointer. // Takes the number of levels wanted above the calling function (included) and an array of void * -// +// void mipsBacktrace(uint32 levels, void **addresses) { - // get the current return address + // get the current return address register byte *retAddr; register byte *stackPointer; - GET_RET(retAddr); + GET_RET(retAddr); GET_SP(stackPointer); char string[100]; - + if (!levels) return; - + memset(addresses, 0, sizeof(void *) * levels); - + uint32 curLevel = 0; - + const uint32 SP_SUBTRACT = 0x27bd8000; // The instruction to subtract from the SP looks like this const uint32 SP_SUB_HIGH_MASK = 0xffff8000; // The mask to check for the subtract SP instruction const uint32 SP_SUB_LOW_MASK = 0x0000ffff; // The mask that gives us how much was subtracted - + // make sure we go out of the stack of this current level // we already have the return address for this level from the register if (curLevel < levels) { - void *thisFunc = (void *)mipsBacktrace; + void *thisFunc = (void *)mipsBacktrace; for (uint32 *seekPtr = (uint32 *)thisFunc; ; seekPtr++) { if ((*seekPtr & SP_SUB_HIGH_MASK) == SP_SUBTRACT) { // we found the $sp subtraction at the beginning of the function @@ -120,10 +120,10 @@ void mipsBacktrace(uint32 levels, void **addresses) { fputs(string, stderr); } break; - } - } + } + } } - + // keep scanning while more levels are requested while (curLevel < levels) { // now scan backwards from the return address to find the size of the stack @@ -139,13 +139,13 @@ void mipsBacktrace(uint32 levels, void **addresses) { sprintf(string, "invalid retAddr %p\n", retAddr); fputs(string, stderr); return; - } + } //sprintf(string, "retAddr[%p]\n", retAddr); //fputs(string, stderr); addresses[curLevel++] = retAddr; break; - } - } + } + } } -} +} diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 9b11eb2c09..817f61e864 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -74,7 +74,7 @@ void OSystem_MacOSX::addSysArchivesToSearchSet(Common::SearchSet &s, int priorit } void OSystem_MacOSX::setupIcon() { - // Don't set icon on OS X, as we use a nicer external icon there. + // Don't set icon on OS X, as we use a nicer external icon there. } bool OSystem_MacOSX::hasFeature(Feature f) { diff --git a/backends/platform/sdl/main.cpp b/backends/platform/sdl/main.cpp index 1992bdd3f2..3947d010c4 100644 --- a/backends/platform/sdl/main.cpp +++ b/backends/platform/sdl/main.cpp @@ -34,6 +34,7 @@ !defined(CAANOO) && \ !defined(LINUXMOTO) && \ !defined(SAMSUNGTV) && \ + !defined(PLAYSTATION3) && \ !defined(OPENPANDORA) #include "backends/platform/sdl/sdl.h" diff --git a/backends/platform/sdl/module.mk b/backends/platform/sdl/module.mk index efc5168d5b..e67bf859d6 100644 --- a/backends/platform/sdl/module.mk +++ b/backends/platform/sdl/module.mk @@ -29,6 +29,12 @@ MODULE_OBJS += \ amigaos/amigaos.o endif +ifdef PLAYSTATION3 +MODULE_OBJS += \ + ps3/ps3-main.o \ + ps3/ps3.o +endif + # We don't use rules.mk but rather manually update OBJS and MODULE_DIRS. MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) OBJS := $(MODULE_OBJS) $(OBJS) diff --git a/backends/platform/sdl/posix/posix-main.cpp b/backends/platform/sdl/posix/posix-main.cpp index f78e001398..3bf7a5138a 100644 --- a/backends/platform/sdl/posix/posix-main.cpp +++ b/backends/platform/sdl/posix/posix-main.cpp @@ -22,7 +22,7 @@ #include "common/scummsys.h" -#if defined(POSIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) +#if defined(POSIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) && !defined(PLAYSTATION3) #include "backends/platform/sdl/posix/posix.h" #include "backends/plugins/sdl/sdl-provider.h" diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index d757186134..05c779a4e0 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -33,6 +33,7 @@ #include "backends/platform/sdl/posix/posix.h" #include "backends/saves/posix/posix-saves.h" #include "backends/fs/posix/posix-fs-factory.h" +#include "backends/taskbar/unity/unity-taskbar.h" #include <errno.h> #include <sys/stat.h> @@ -49,6 +50,11 @@ void OSystem_POSIX::init() { // Initialze File System Factory _fsFactory = new POSIXFilesystemFactory(); +#if defined(USE_TASKBAR) && defined(USE_TASKBAR_UNITY) + // Initialize taskbar manager + _taskbarManager = new UnityTaskbarManager(); +#endif + // Invoke parent implementation of this method OSystem_SDL::init(); } @@ -60,6 +66,11 @@ void OSystem_POSIX::initBackend() { // Invoke parent implementation of this method OSystem_SDL::initBackend(); + +#if defined(USE_TASKBAR) && defined(USE_TASKBAR_UNITY) + // Register the taskbar manager as an event source (this is necessary for the glib event loop to be run) + _eventManager->getEventDispatcher()->registerSource((UnityTaskbarManager *)_taskbarManager, false); +#endif } bool OSystem_POSIX::hasFeature(Feature f) { diff --git a/backends/platform/gp2x/gp2x-main.cpp b/backends/platform/sdl/ps3/ps3-main.cpp index f1ee5ed5f3..ba548a3749 100644 --- a/backends/platform/gp2x/gp2x-main.cpp +++ b/backends/platform/sdl/ps3/ps3-main.cpp @@ -20,19 +20,20 @@ * */ -#include "backends/platform/gp2x/gp2x-common.h" +#include "common/scummsys.h" + +#include "backends/platform/sdl/ps3/ps3.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(); + g_system = new OSystem_PS3(); assert(g_system); // Pre initialize the backend - ((OSystem_GP2X *)g_system)->init(); + ((OSystem_PS3 *)g_system)->init(); #ifdef DYNAMIC_MODULES PluginManager::instance().addPluginProvider(new SDLPluginProvider()); @@ -42,9 +43,7 @@ int main(int argc, char *argv[]) { int res = scummvm_main(argc, argv); // Free OSystem - delete (OSystem_GP2X *)g_system; + delete (OSystem_PS3 *)g_system; return res; } - -#endif diff --git a/backends/platform/sdl/ps3/ps3.cpp b/backends/platform/sdl/ps3/ps3.cpp new file mode 100644 index 0000000000..16722ccdb7 --- /dev/null +++ b/backends/platform/sdl/ps3/ps3.cpp @@ -0,0 +1,94 @@ +/* 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. + * + */ + +#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_time_h //On IRIX, sys/stat.h includes sys/time.h +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h + +#include "common/scummsys.h" +#include "common/config-manager.h" +#include "backends/platform/sdl/ps3/ps3.h" +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" +#include "backends/saves/default/default-saves.h" +#include "backends/fs/ps3/ps3-fs-factory.h" +#include "backends/events/ps3sdl/ps3sdl-events.h" +#include "backends/mixer/sdl13/sdl13-mixer.h" + +#include <dirent.h> +#include <sys/stat.h> + +int access(const char *pathname, int mode) { + struct stat sb; + + if (stat(pathname, &sb) == -1) { + return -1; + } + + return 0; +} + +OSystem_PS3::OSystem_PS3(Common::String baseConfigName) + : _baseConfigName(baseConfigName) { +} + +void OSystem_PS3::init() { + // Initialze File System Factory + _fsFactory = new PS3FilesystemFactory(); + + // Invoke parent implementation of this method + OSystem_SDL::init(); +} + +void OSystem_PS3::initBackend() { + ConfMan.set("joystick_num", 0); + ConfMan.set("vkeybdpath", PREFIX "/data"); + ConfMan.registerDefault("fullscreen", true); + ConfMan.registerDefault("aspect_ratio", true); + + // Create the savefile manager + if (_savefileManager == 0) + _savefileManager = new DefaultSaveFileManager(PREFIX "/saves"); + + // Create the mixer manager + if (_mixer == 0) { + _mixerManager = new Sdl13MixerManager(); + + // Setup and start mixer + _mixerManager->init(); + } + + // Event source + if (_eventSource == 0) + _eventSource = new PS3SdlEventSource(); + + // Invoke parent implementation of this method + OSystem_SDL::initBackend(); +} + +Common::String OSystem_PS3::getDefaultConfigFileName() { + return PREFIX "/" + _baseConfigName; +} + +Common::WriteStream *OSystem_PS3::createLogFile() { + Common::FSNode file(PREFIX "/scummvm.log"); + return file.createWriteStream(); +} diff --git a/backends/platform/gp2x/gp2x-common.h b/backends/platform/sdl/ps3/ps3.h index 7efdd7164c..daed7599a9 100644 --- a/backends/platform/gp2x/gp2x-common.h +++ b/backends/platform/sdl/ps3/ps3.h @@ -20,30 +20,28 @@ * */ -#ifndef PLATFORM_SDL_GP2X_H -#define PLATFORM_SDL_GP2X_H +#ifndef PLATFORM_SDL_PS3_H +#define PLATFORM_SDL_PS3_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 { +class OSystem_PS3 : public OSystem_SDL { public: - OSystem_GP2X() {} + // Let the subclasses be able to change _baseConfigName in the constructor + OSystem_PS3(Common::String baseConfigName = "scummvm.ini"); + virtual ~OSystem_PS3() {} - void initBackend(); - void quit(); - void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); - void initSDL(); + virtual void init(); + virtual void initBackend(); protected: + // Base string for creating the default path and filename + // for the configuration file + Common::String _baseConfigName; + + virtual Common::String getDefaultConfigFileName(); + virtual Common::WriteStream *createLogFile(); }; #endif diff --git a/backends/platform/sdl/sdl-sys.h b/backends/platform/sdl/sdl-sys.h index 77515ff4e5..ca3c586e03 100644 --- a/backends/platform/sdl/sdl-sys.h +++ b/backends/platform/sdl/sdl-sys.h @@ -27,7 +27,7 @@ // fashion, even on the Symbian port. // Moreover, it contains a workaround for the fact that SDL_rwops.h uses // a FILE pointer in one place, which conflicts with common/forbidden.h. - +// The SDL 1.3 headers also include strings.h #include "common/scummsys.h" @@ -39,6 +39,16 @@ typedef struct { int FAKE; } FAKE_FILE; #define FILE FAKE_FILE #endif +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strcasecmp) +#undef strcasecmp +#define strcasecmp FAKE_strcasecmp +#endif + +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strncasecmp) +#undef strncasecmp +#define strncasecmp FAKE_strncasecmp +#endif + #if defined(__SYMBIAN32__) #include <esdl\SDL.h> #else @@ -47,8 +57,19 @@ typedef struct { int FAKE; } FAKE_FILE; // Finally forbid FILE again (if it was forbidden to start with) #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_FILE) -#undef FILE +#undef FILE #define FILE FORBIDDEN_SYMBOL_REPLACEMENT #endif +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strcasecmp) +#undef strcasecmp +#define strcasecmp FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strncasecmp) +#undef strncasecmp +#define strncasecmp FORBIDDEN_SYMBOL_REPLACEMENT +#endif + + #endif diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index afc6c850d9..d05cca4d1f 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -31,14 +31,22 @@ #include "backends/platform/sdl/sdl.h" #include "common/config-manager.h" #include "common/EventRecorder.h" +#include "common/taskbar.h" #include "common/textconsole.h" #include "backends/saves/default/default-saves.h" + +// Audio CD support was removed with SDL 1.3 +#if SDL_VERSION_ATLEAST(1, 3, 0) +#include "backends/audiocd/default/default-audiocd.h" +#else #include "backends/audiocd/sdl/sdl-audiocd.h" +#endif + #include "backends/events/sdl/sdl-events.h" #include "backends/mutex/sdl/sdl-mutex.h" #include "backends/timer/sdl/sdl-timer.h" -#include "backends/graphics/sdl/sdl-graphics.h" +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" #ifdef USE_OPENGL #include "backends/graphics/openglsdl/openglsdl-graphics.h" #endif @@ -125,6 +133,11 @@ void OSystem_SDL::init() { if (_timerManager == 0) _timerManager = new SdlTimerManager(); +#if defined(USE_TASKBAR) + if (_taskbarManager == 0) + _taskbarManager = new Common::TaskbarManager(); +#endif + #ifdef USE_OPENGL // Setup a list with both SDL and OpenGL graphics modes setupGraphicsModes(); @@ -167,27 +180,11 @@ void OSystem_SDL::initBackend() { } #endif if (_graphicsManager == 0) { - _graphicsManager = new SdlGraphicsManager(_eventSource); + _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); graphicsManagerType = 0; } } - // Creates the backend managers, if they don't exist yet (we check - // for this to allow subclasses to provide their own). - if (_eventManager == 0) - _eventManager = new DefaultEventManager(_eventSource); - - // We have to initialize the graphics manager before the event manager - // so the virtual keyboard can be initialized, but we have to add the - // graphics manager as an event observer after initializing the event - // manager. - if (graphicsManagerType == 0) - ((SdlGraphicsManager *)_graphicsManager)->initEventObserver(); -#ifdef USE_OPENGL - else if (graphicsManagerType == 1) - ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); -#endif - if (_savefileManager == 0) _savefileManager = new DefaultSaveFileManager(); @@ -198,8 +195,15 @@ void OSystem_SDL::initBackend() { _mixerManager->init(); } - if (_audiocdManager == 0) + if (_audiocdManager == 0) { + // Audio CD support was removed with SDL 1.3 +#if SDL_VERSION_ATLEAST(1, 3, 0) + _audiocdManager = new DefaultAudioCDManager(); +#else _audiocdManager = new SdlAudioCDManager(); +#endif + + } // Setup a custom program icon. setupIcon(); @@ -207,7 +211,34 @@ void OSystem_SDL::initBackend() { _inited = true; ModularBackend::initBackend(); + + // We have to initialize the graphics manager before the event manager + // so the virtual keyboard can be initialized, but we have to add the + // graphics manager as an event observer after initializing the event + // manager. + if (graphicsManagerType == 0) + ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); +#ifdef USE_OPENGL + else if (graphicsManagerType == 1) + ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); +#endif + +} + +#if defined(USE_TASKBAR) +void OSystem_SDL::engineInit() { + // Add the started engine to the list of recent tasks + _taskbarManager->addRecent(ConfMan.getActiveDomainName(), ConfMan.get("description")); + + // Set the overlay icon the current running engine + _taskbarManager->setOverlayIcon(ConfMan.getActiveDomainName(), ConfMan.get("description")); +} + +void OSystem_SDL::engineDone() { + // Remove overlay icon + _taskbarManager->setOverlayIcon("", ""); } +#endif void OSystem_SDL::initSDL() { // Check if SDL has not been initialized @@ -275,10 +306,22 @@ void OSystem_SDL::fatalError() { void OSystem_SDL::logMessage(LogMessageType::Type type, const char *message) { - ModularBackend::logMessage(type, message); + // First log to stdout/stderr + FILE *output = 0; + + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) + output = stdout; + else + output = stderr; + + fputs(message, output); + fflush(output); + + // Then log into file (via the logger) if (_logger) _logger->print(message); + // Finally, some Windows / WinCE specific logging code. #if defined( USE_WINDBG ) #if defined( _WIN32_WCE ) TCHAR buf_unicode[1024]; @@ -301,7 +344,7 @@ void OSystem_SDL::logMessage(LogMessageType::Type type, const char *message) { } Common::String OSystem_SDL::getSystemLanguage() const { -#ifdef USE_DETECTLANG +#if defined(USE_DETECTLANG) && !defined(_WIN32_WCE) #ifdef WIN32 // We can not use "setlocale" (at least not for MSVC builds), since it // will return locales like: "English_USA.1252", thus we need a special @@ -368,7 +411,7 @@ void OSystem_SDL::setupIcon() { if (sscanf(scummvm_icon[0], "%d %d %d %d", &w, &h, &ncols, &nbytes) != 4) { warning("Wrong format of scummvm_icon[0] (%s)", scummvm_icon[0]); - + return; } if ((w > 512) || (h > 512) || (ncols > 255) || (nbytes > 1)) { @@ -384,6 +427,7 @@ void OSystem_SDL::setupIcon() { for (i = 0; i < ncols; i++) { unsigned char code; char color[32]; + memset(color, 0, sizeof(color)); unsigned int col; if (sscanf(scummvm_icon[1 + i], "%c c %s", &code, color) != 2) { warning("Wrong format of scummvm_icon[%d] (%s)", 1 + i, scummvm_icon[1 + i]); @@ -472,7 +516,7 @@ bool OSystem_SDL::setGraphicsMode(int mode) { // Check if mode is from SDL or OpenGL if (mode < _sdlModesCount) { - srcMode = SdlGraphicsManager::supportedGraphicsModes(); + srcMode = SurfaceSdlGraphicsManager::supportedGraphicsModes(); i = 0; } else { srcMode = OpenGLSdlGraphicsManager::supportedGraphicsModes(); @@ -487,8 +531,8 @@ bool OSystem_SDL::setGraphicsMode(int mode) { if (_graphicsMode >= _sdlModesCount && mode < _sdlModesCount) { debug(1, "switching to plain SDL graphics"); delete _graphicsManager; - _graphicsManager = new SdlGraphicsManager(_eventSource); - ((SdlGraphicsManager *)_graphicsManager)->initEventObserver(); + _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); + ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); _graphicsManager->beginGFXTransaction(); } else if (_graphicsMode < _sdlModesCount && mode >= _sdlModesCount) { debug(1, "switching to OpenGL graphics"); @@ -514,7 +558,7 @@ int OSystem_SDL::getGraphicsMode() const { } void OSystem_SDL::setupGraphicsModes() { - const OSystem::GraphicsMode *sdlGraphicsModes = SdlGraphicsManager::supportedGraphicsModes(); + const OSystem::GraphicsMode *sdlGraphicsModes = SurfaceSdlGraphicsManager::supportedGraphicsModes(); const OSystem::GraphicsMode *openglGraphicsModes = OpenGLSdlGraphicsManager::supportedGraphicsModes(); _sdlModesCount = 0; _glModesCount = 0; diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 917fac5558..395b2b3aac 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -30,7 +30,7 @@ #include "backends/events/sdl/sdl-events.h" #include "backends/log/log.h" -/** +/** * Base OSystem class for all SDL ports. */ class OSystem_SDL : public ModularBackend { @@ -38,7 +38,7 @@ public: OSystem_SDL(); virtual ~OSystem_SDL(); - /** + /** * Pre-initialize backend. It should be called after * instantiating the backend. Early needed managers are * created here. @@ -54,6 +54,10 @@ public: // Override functions from ModularBackend and OSystem virtual void initBackend(); +#if defined(USE_TASKBAR) + virtual void engineInit(); + virtual void engineDone(); +#endif virtual Common::HardwareKeySet *getHardwareKeySet(); virtual void quit(); virtual void fatalError(); @@ -91,6 +95,8 @@ protected: */ SdlEventSource *_eventSource; + virtual Common::EventSource *getDefaultEventSource() { return _eventSource; } + /** * Initialze the SDL library. */ diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 5b14be4417..420ed2465b 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -34,8 +34,11 @@ #undef ARRAYSIZE // winnt.h defines ARRAYSIZE, but we want our own one... #include <shellapi.h> +#include <SDL_syswm.h> // For setting the icon + #include "backends/platform/sdl/win32/win32.h" #include "backends/fs/windows/windows-fs-factory.h" +#include "backends/taskbar/win32/win32-taskbar.h" #include "common/memstream.h" @@ -81,9 +84,14 @@ void OSystem_Win32::init() { } #endif - // Initialze File System Factory + // Initialize File System Factory _fsFactory = new WindowsFilesystemFactory(); +#if defined(USE_TASKBAR) + // Initialize taskbar manager + _taskbarManager = new Win32TaskbarManager(); +#endif + // Invoke parent implementation of this method OSystem_SDL::init(); } @@ -131,6 +139,28 @@ bool OSystem_Win32::displayLogFile() { return false; } +void OSystem_Win32::setupIcon() { + HMODULE handle = GetModuleHandle(NULL); + HICON ico = LoadIcon(handle, MAKEINTRESOURCE(1001 /* IDI_ICON */)); + if (ico) { + SDL_SysWMinfo wminfo; + SDL_VERSION(&wminfo.version); + if (SDL_GetWMInfo(&wminfo)) { + // Replace the handle to the icon associated with the window class by our custom icon + SetClassLongPtr(wminfo.window, GCLP_HICON, (ULONG_PTR)ico); + + // Since there wasn't any default icon, we can't use the return value from SetClassLong + // to check for errors (it would be 0 in both cases: error or no previous value for the + // icon handle). Instead we check for the last-error code value. + if (GetLastError() == ERROR_SUCCESS) + return; + } + } + + // If no icon has been set, fallback to default path + OSystem_SDL::setupIcon(); +} + Common::String OSystem_Win32::getDefaultConfigFileName() { char configFile[MAXPATHLEN]; @@ -149,18 +179,31 @@ Common::String OSystem_Win32::getDefaultConfigFileName() { error("Unable to access user profile directory"); strcat(configFile, "\\Application Data"); - CreateDirectory(configFile, NULL); + + // If the directory already exists (as it should in most cases), + // we don't want to fail, but we need to stop on other errors (such as ERROR_PATH_NOT_FOUND) + if (!CreateDirectory(configFile, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) + error("Cannot create Application data folder"); + } } strcat(configFile, "\\ScummVM"); - CreateDirectory(configFile, NULL); + if (!CreateDirectory(configFile, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) + error("Cannot create ScummVM application data folder"); + } + strcat(configFile, "\\" DEFAULT_CONFIG_FILE); FILE *tmp = NULL; if ((tmp = fopen(configFile, "r")) == NULL) { // Check windows directory char oldConfigFile[MAXPATHLEN]; - GetWindowsDirectory(oldConfigFile, MAXPATHLEN); + uint ret = GetWindowsDirectory(oldConfigFile, MAXPATHLEN); + if (ret == 0 || ret > MAXPATHLEN) + error("Cannot retrieve the path of the Windows directory"); + strcat(oldConfigFile, "\\" DEFAULT_CONFIG_FILE); if ((tmp = fopen(oldConfigFile, "r"))) { strcpy(configFile, oldConfigFile); @@ -172,7 +215,10 @@ Common::String OSystem_Win32::getDefaultConfigFileName() { } } else { // Check windows directory - GetWindowsDirectory(configFile, MAXPATHLEN); + uint ret = GetWindowsDirectory(configFile, MAXPATHLEN); + if (ret == 0 || ret > MAXPATHLEN) + error("Cannot retrieve the path of the Windows directory"); + strcat(configFile, "\\" DEFAULT_CONFIG_FILE); } @@ -300,7 +346,7 @@ Common::SeekableReadStream *Win32ResourceArchive::createReadStreamForMember(cons } // End of anonymous namespace void OSystem_Win32::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { - s.add("Win32Res", new Win32ResourceArchive()); + s.add("Win32Res", new Win32ResourceArchive(), priority); OSystem_SDL::addSysArchivesToSearchSet(s, priority); } diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h index ef7b6af3f1..cc2fc51d36 100644 --- a/backends/platform/sdl/win32/win32.h +++ b/backends/platform/sdl/win32/win32.h @@ -46,6 +46,7 @@ protected: */ Common::String _logFilePath; + virtual void setupIcon(); virtual Common::String getDefaultConfigFileName(); virtual Common::WriteStream *createLogFile(); }; diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index 9cccc81d19..b1bd976f9e 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -57,7 +57,7 @@ char *GetExecutablePath() { OSystem_SDL_Symbian::OSystem_SDL_Symbian() : _RFs(0) { - + } void OSystem_SDL_Symbian::init() { @@ -171,7 +171,7 @@ Common::String OSystem_SDL_Symbian::getDefaultConfigFileName() { } void OSystem_SDL_Symbian::setupIcon() { - // Don't for Symbian: it uses the EScummVM.aif file for the icon. + // Don't for Symbian: it uses the EScummVM.aif file for the icon. } RFs& OSystem_SDL_Symbian::FsSession() { diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp index c16578d9b3..258a782cc4 100644 --- a/backends/platform/wii/osystem.cpp +++ b/backends/platform/wii/osystem.cpp @@ -19,11 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// Allow use of stuff in <time.h> -#define FORBIDDEN_SYMBOL_EXCEPTION_time_h - -#define FORBIDDEN_SYMBOL_EXCEPTION_printf -#define FORBIDDEN_SYMBOL_EXCEPTION_getcwd +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include <unistd.h> @@ -34,6 +30,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 +94,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 +133,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(); - BaseBackend::initBackend(); + EventsBaseBackend::initBackend(); } void OSystem_Wii::quit() { @@ -261,21 +251,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(); } @@ -307,6 +287,18 @@ void OSystem_Wii::showOptionsDialog() { _padAcceleration = 9 - ConfMan.getInt("wii_pad_acceleration"); } +void OSystem_Wii::logMessage(LogMessageType::Type type, const char *message) { + FILE *output = 0; + + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) + output = stdout; + else + output = stderr; + + fputs(message, output); + fflush(output); +} + #ifndef GAMECUBE Common::String OSystem_Wii::getSystemLanguage() const { const char *wiiCountries[] = { @@ -377,7 +369,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 981b25f69c..64197f913a 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 { @@ -211,12 +207,12 @@ 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; + virtual void logMessage(LogMessageType::Type type, const char *message); + #ifndef GAMECUBE virtual Common::String getSystemLanguage() const; #endif // GAMECUBE 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 859e3a1395..443e738a4a 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -20,6 +20,7 @@ */ #define FORBIDDEN_SYMBOL_EXCEPTION_printf +#define FORBIDDEN_SYMBOL_EXCEPTION_abort #include <malloc.h> diff --git a/backends/platform/wince/CEActionsPocket.cpp b/backends/platform/wince/CEActionsPocket.cpp index f2c461fcf9..194f855e98 100644 --- a/backends/platform/wince/CEActionsPocket.cpp +++ b/backends/platform/wince/CEActionsPocket.cpp @@ -137,6 +137,7 @@ void CEActionsPocket::initInstanceGame() { bool is_tinsel = (gameid == "tinsel"); bool is_cruise = (gameid == "cruise"); bool is_made = (gameid == "made"); + bool is_sci = (gameid == "sci"); GUI_Actions::initInstanceGame(); @@ -219,7 +220,7 @@ void CEActionsPocket::initInstanceGame() { // Key bind method _action_enabled[POCKET_ACTION_BINDKEYS] = true; // Disable double-tap right-click for convenience - if (is_tinsel || is_cruise) + if (is_tinsel || is_cruise || is_sci) if (!ConfMan.hasKey("no_doubletap_rightclick")) { ConfMan.setBool("no_doubletap_rightclick", true); ConfMan.flushToDisk(); @@ -233,15 +234,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 +250,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 +271,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..c6456d3eb5 100644 --- a/backends/platform/wince/CEActionsSmartphone.cpp +++ b/backends/platform/wince/CEActionsSmartphone.cpp @@ -128,6 +128,7 @@ void CEActionsSmartphone::initInstanceGame() { bool is_tinsel = (gameid == "tinsel"); bool is_cruise = (gameid == "cruise"); bool is_made = (gameid == "made"); + bool is_sci = (gameid == "sci"); GUI_Actions::initInstanceGame(); @@ -185,7 +186,7 @@ void CEActionsSmartphone::initInstanceGame() { // Bind keys _action_enabled[SMARTPHONE_ACTION_BINDKEYS] = true; // Disable double-tap right-click for convenience - if (is_tinsel || is_cruise) + if (is_tinsel || is_cruise || is_sci) if (!ConfMan.hasKey("no_doubletap_rightclick")) { ConfMan.setBool("no_doubletap_rightclick", true); ConfMan.flushToDisk(); @@ -199,15 +200,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 +235,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 +265,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/CELauncherDialog.cpp b/backends/platform/wince/CELauncherDialog.cpp index 9c832dd585..dd6076e0af 100644 --- a/backends/platform/wince/CELauncherDialog.cpp +++ b/backends/platform/wince/CELauncherDialog.cpp @@ -24,6 +24,7 @@ #define FORBIDDEN_SYMBOL_ALLOW_ALL #include "backends/platform/wince/wince-sdl.h" +#include "backends/graphics/wincesdl/wincesdl-graphics.h" #include "CELauncherDialog.h" @@ -34,6 +35,7 @@ #include "gui/browser.h" #include "gui/message.h" #include "gui/ThemeEval.h" +#include "gui/widgets/list.h" #include "common/config-manager.h" @@ -63,9 +65,13 @@ public: }; CELauncherDialog::CELauncherDialog() : GUI::LauncherDialog() { + ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->reset_panel(); } void CELauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { + if ((cmd == 'STRT') || (cmd == kListItemActivatedCmd) || (cmd == kListItemDoubleClickedCmd)) { + ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->init_panel(); + } LauncherDialog::handleCommand(sender, cmd, data); if (cmd == 'ABOU') { CEAboutDialog about; diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index a53bc41667..ec222c6fc1 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -353,9 +353,9 @@ void drawError(char *error) { } // ******************************************************************************************** -static DefaultTimerManager *_int_timer = NULL; static Uint32 timer_handler_wrapper(Uint32 interval) { - _int_timer->handler(); + DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager(); + tm->handler(); return interval; } @@ -379,14 +379,15 @@ void OSystem_WINCE3::initBackend() { ((WINCESdlEventSource *)_eventSource)->init((WINCESdlGraphicsManager *)_graphicsManager); - // Create the timer. CE SDL does not support multiple timers (SDL_AddTimer). + // Create the timer (but remove the timer manager from the SDL backend first). + // 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(); - //_timerID = NULL; // OSystem_SDL will call removetimer with this, it's ok + delete _timerManager; + _timerManager = new DefaultTimerManager(); SDL_SetTimer(10, &timer_handler_wrapper); - // Chain init + // Call parent implementation of this method OSystem_SDL::initBackend(); // Initialize global key mapping @@ -397,9 +398,6 @@ void OSystem_WINCE3::initBackend() { GUI_Actions::Instance()->saveMapping(); // write defaults } - // Call parent implementation of this method - //OSystem_SDL::initBackend(); - _inited = true; } @@ -443,14 +441,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 +457,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(); } @@ -576,6 +569,73 @@ void OSystem_WINCE3::getTimeAndDate(TimeDate &t) const { t.tm_sec = systime.wSecond; } +Common::String OSystem_WINCE3::getSystemLanguage() const { +#ifdef USE_DETECTLANG + // We can not use "setlocale" (at least not for MSVC builds), since it + // will return locales like: "English_USA.1252", thus we need a special + // way to determine the locale string for Win32. + char langName[9]; + char ctryName[9]; + TCHAR langNameW[32]; + TCHAR ctryNameW[32]; + int i = 0; + bool localeFound = false; + Common::String localeName; + + // Really not nice, but the only way to map Windows CE language/country codes to posix NLS names, + // because Windows CE doesn't support LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME, + // according to this: http://msdn.microsoft.com/en-us/library/aa912934.aspx + // + // See http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx for a translation table + // This table has to be updated manually when new translations are added + const char *posixMappingTable[][3] = { + {"CAT", "ESP", "ca_ES"}, + {"CSY", "CZE", "cs_CZ"}, + {"DAN", "DNK", "da_DA"}, + {"DEU", "DEU", "de_DE"}, + {"ESN", "ESP", "es_ES"}, + {"ESP", "ESP", "es_ES"}, + {"FRA", "FRA", "fr_FR"}, + {"HUN", "HUN", "hu_HU"}, + {"ITA", "ITA", "it_IT"}, + {"NOR", "NOR", "nb_NO"}, + {"NON", "NOR", "nn_NO"}, + {"PLK", "POL", "pl_PL"}, + {"PTB", "BRA", "pt_BR"}, + {"RUS", "RUS", "ru_RU"}, + {"SVE", "SWE", "se_SE"}, + {"UKR", "UKR", "uk_UA"}, + {NULL, NULL, NULL} + }; + + if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, langNameW, sizeof(langNameW)) != 0 && + GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, ctryNameW, sizeof(ctryNameW)) != 0) { + WideCharToMultiByte(CP_ACP, 0, langNameW, -1, langName, (wcslen(langNameW) + 1), NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, ctryNameW, -1, ctryName, (wcslen(ctryNameW) + 1), NULL, NULL); + + debug(1, "Trying to find posix locale name for %s_%s", langName, ctryName); + while (posixMappingTable[i][0] && !localeFound) { + if ( (!strcmp(posixMappingTable[i][0], langName) || !strcmp(posixMappingTable[i][0], "*")) && + (!strcmp(posixMappingTable[i][1], ctryName) || !strcmp(posixMappingTable[i][0], "*")) ) { + localeFound = true; + localeName = posixMappingTable[i][2]; + } + i++; + } + if (!localeFound) warning("No posix locale name found for %s_%s", langName, ctryName); + } + + if (localeFound) { + debug(1, "Found posix locale name: %s", localeName.c_str()); + return localeName; + } else { + return ModularBackend::getSystemLanguage(); + } +#else // USE_DETECTLANG + return ModularBackend::getSystemLanguage(); +#endif // USE_DETECTLANG +} + int OSystem_WINCE3::_platformScreenWidth; int OSystem_WINCE3::_platformScreenHeight; bool OSystem_WINCE3::_isOzone; diff --git a/backends/platform/wince/wince-sdl.h b/backends/platform/wince/wince-sdl.h index a1e46081f9..481956c19a 100644 --- a/backends/platform/wince/wince-sdl.h +++ b/backends/platform/wince/wince-sdl.h @@ -53,12 +53,13 @@ public: // Overloaded from SDL backend void quit(); + virtual Common::String getSystemLanguage() const; + // Overloaded from OSystem void engineInit(); void getTimeAndDate(TimeDate &t) const; virtual Common::String getDefaultConfigFileName(); - virtual FilesystemFactory *getFilesystemFactory(); void swap_sound_master(); @@ -73,8 +74,6 @@ public: protected: void initSDL(); Audio::MixerImpl *_mixer; - DefaultTimerManager *_timer; - FilesystemFactory *_fsFactory; private: void check_mappings(); |