diff options
author | Eugene Sandulenko | 2005-12-03 14:34:45 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2005-12-03 14:34:45 +0000 |
commit | 71e21f0fdf996348afe256b51305c5cd5fba8e8a (patch) | |
tree | 690ae0770cc59a53d24e5ae1b5c35a1219018c6e /backends | |
parent | 3a9bd3c18cacbd9b1d49107c6db609c7982940d6 (diff) | |
download | scummvm-rg350-71e21f0fdf996348afe256b51305c5cd5fba8e8a.tar.gz scummvm-rg350-71e21f0fdf996348afe256b51305c5cd5fba8e8a.tar.bz2 scummvm-rg350-71e21f0fdf996348afe256b51305c5cd5fba8e8a.zip |
Fix code formatting to be compliant with our rules.
It may happen that I broke something since I have no means to compile it.
Also I changed EScummVM -> ScummVM is several places.
svn-id: r19734
Diffstat (limited to 'backends')
-rw-r--r-- | backends/epoc/ScummApp.cpp | 7 | ||||
-rw-r--r-- | backends/epoc/ScummApp.h | 2 | ||||
-rw-r--r-- | backends/epoc/SymbianActions.cpp | 29 | ||||
-rw-r--r-- | backends/epoc/SymbianActions.h | 1 | ||||
-rw-r--r-- | backends/epoc/SymbianOS.cpp | 175 | ||||
-rw-r--r-- | backends/epoc/SymbianOS.h | 50 | ||||
-rw-r--r-- | backends/epoc/build/S60/ScummVMApp.cpp | 70 | ||||
-rw-r--r-- | backends/epoc/build/S60/ScummVMApp.h | 19 | ||||
-rw-r--r-- | backends/epoc/build/S80/ScummVMApp.cpp | 80 | ||||
-rw-r--r-- | backends/epoc/build/S80/ScummVMApp.h | 23 | ||||
-rw-r--r-- | backends/epoc/build/S90/ScummVMApp.cpp | 77 | ||||
-rw-r--r-- | backends/epoc/build/S90/ScummVMApp.h | 23 | ||||
-rw-r--r-- | backends/epoc/portdefs.h | 33 |
13 files changed, 311 insertions, 278 deletions
diff --git a/backends/epoc/ScummApp.cpp b/backends/epoc/ScummApp.cpp index d4207b5959..ce40c26ae6 100644 --- a/backends/epoc/ScummApp.cpp +++ b/backends/epoc/ScummApp.cpp @@ -21,9 +21,10 @@ * $Header$ */ -#include "ScummApp.h" +#include "backends/epoc/ScummApp.h" + +#include "backends/epoc/ScummVM.hrh" -#include "ScummVM.hrh" #ifdef __WINS__ extern "C" int _chkstk(int /*a*/) { return 1; @@ -32,7 +33,7 @@ extern "C" int _chkstk(int /*a*/) { #ifdef EPOC_AS_APP // this function is called by Symbian to deliver the new CApaApplication object -EXPORT_C CApaApplication* NewApplication() { +EXPORT_C CApaApplication *NewApplication() { // Return pointer to newly created CQMApp return (new CScummApp); } diff --git a/backends/epoc/ScummApp.h b/backends/epoc/ScummApp.h index 07fa1609a7..385f0ada1d 100644 --- a/backends/epoc/ScummApp.h +++ b/backends/epoc/ScummApp.h @@ -31,7 +31,7 @@ #include "ECompXL.h" #endif -class CScummApp:public CSDLApp { +class CScummApp : public CSDLApp { public: CScummApp(); ~CScummApp(); diff --git a/backends/epoc/SymbianActions.cpp b/backends/epoc/SymbianActions.cpp index 35a2c95c0d..ee1a6984ee 100644 --- a/backends/epoc/SymbianActions.cpp +++ b/backends/epoc/SymbianActions.cpp @@ -19,8 +19,8 @@ * */ -#include "stdafx.h" -#include "SymbianActions.h" +#include "common/stdafx.h" +#include "backends/epoc/SymbianActions.h" #include "gui/message.h" #include "scumm/scumm.h" @@ -83,11 +83,10 @@ int SymbianActions::version() { } SymbianActions::SymbianActions(GameDetector &detector) : - Actions(detector) -{ + Actions(detector) { int i; - for (i=0; i<ACTION_LAST; i++) { + for (i = 0; i < ACTION_LAST; i++) { _action_mapping[i] = ACTIONS_DEFAULT[i]; _action_enabled[i] = false; } @@ -136,17 +135,13 @@ void SymbianActions::initInstanceGame() { // Save if (is_simon || is_gob) _action_enabled[ACTION_SAVE] = false; - else - if (is_queen) { + else if (is_queen) { _action_enabled[ACTION_SAVE] = true; _key_action[ACTION_SAVE].setAscii(SDLK_F1); // F1 key for FOTAQ or F5??!? - } - else - if (is_sky) { + } else if (is_sky) { _action_enabled[ACTION_SAVE] = true; _key_action[ACTION_SAVE].setAscii(63); - } - else { + } else { _action_enabled[ACTION_SAVE] = true; _key_action[ACTION_SAVE].setAscii(SDLK_F5); // F5 key } @@ -161,13 +156,13 @@ void SymbianActions::initInstanceGame() { // FT Cheat _action_enabled[ACTION_FT_CHEAT] = true; _key_action[ACTION_FT_CHEAT].setAscii(86); // shift-V + // Skip text - _action_enabled[ACTION_SKIP_TEXT]=true; + _action_enabled[ACTION_SKIP_TEXT] = true; if (is_queen) { - _key_action[ACTION_SKIP_TEXT].setAscii(SDLK_SPACE); - } - else { - _key_action[ACTION_SKIP_TEXT].setAscii(SDLK_PERIOD); + _key_action[ACTION_SKIP_TEXT].setAscii(SDLK_SPACE); + } else { + _key_action[ACTION_SKIP_TEXT].setAscii(SDLK_PERIOD); } // Pause diff --git a/backends/epoc/SymbianActions.h b/backends/epoc/SymbianActions.h index 414a2e8654..74a307c1d7 100644 --- a/backends/epoc/SymbianActions.h +++ b/backends/epoc/SymbianActions.h @@ -67,6 +67,7 @@ public: int version(); ~SymbianActions(); + private: SymbianActions(GameDetector &detector); bool _right_click_needed; diff --git a/backends/epoc/SymbianOS.cpp b/backends/epoc/SymbianOS.cpp index 7e5227fc34..06c148a65d 100644 --- a/backends/epoc/SymbianOS.cpp +++ b/backends/epoc/SymbianOS.cpp @@ -21,11 +21,12 @@ * $Header$ */ -#include "SymbianOS.h" -#include "SymbianActions.h" -#include "Actions.h" -#include "Key.h" -#include "gui\message.h" +#include "backends/epoc/SymbianOS.h" +#include "backends/epoc/SymbianActions.h" +#include "gui/Actions.h" +#include "gui/Key.h" +#include "gui/message.h" + static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { {"1x", "Fullscreen", GFX_NORMAL}, {0, 0, 0} @@ -36,7 +37,7 @@ OSystem *OSystem_SymbianOS_create() { } -#include "config-manager.h" +#include "common/config-manager.h" extern Common::ConfigManager *g_config; @@ -45,16 +46,18 @@ OSystem_SDL_Symbian::zoneDesc OSystem_SDL_Symbian::_zones[TOTAL_ZONES] = { { 0, 145, 150, 55 }, { 150, 145, 170, 55 } }; -OSystem_SDL_Symbian::OSystem_SDL_Symbian() :_channels(0),_stereo_mix_buffer(0) -{ + +OSystem_SDL_Symbian::OSystem_SDL_Symbian() : _channels(0), _stereo_mix_buffer(0) { ConfMan.set("FM_high_quality", false); ConfMan.set("FM_medium_quality", true); - ConfMan.set("joystick_num",0); // Symbian OS should have joystick_num set to 0 in the ini file , but uiq devices might refuse opening the joystick + ConfMan.set("joystick_num" ,0); // Symbian OS should have joystick_num set to 0 in the ini file , but uiq devices might refuse opening the joystick ConfMan.flushToDisk(); + // Initialize global key mapping for Smartphones - GUI::Actions* actions = GUI::Actions::Instance(); + GUI::Actions *actions = GUI::Actions::Instance(); actions->initInstanceMain(this); actions->loadMapping(); + initZones(); } @@ -149,9 +152,8 @@ bool OSystem_SDL_Symbian::setSoundCallback(SoundProc proc, void *param) { _channels = obtained.channels; // Need to create mixbuffer for stereo mix to downmix - if(_channels != 2) - { - _stereo_mix_buffer = new byte [obtained.size*2];//*2 for stereo values + if(_channels != 2) { + _stereo_mix_buffer = new byte [obtained.size * 2]; // *2 for stereo values } SDL_PauseAudio(0); @@ -162,7 +164,7 @@ bool OSystem_SDL_Symbian::setSoundCallback(SoundProc proc, void *param) { * The mixer callback function, passed on to OSystem::setSoundCallback(). * This simply calls the mix() method. */ -void OSystem_SDL_Symbian::symbianMixCallback(void *s, byte *samples, int len){ +void OSystem_SDL_Symbian::symbianMixCallback(void *s, byte *samples, int len) { static_cast <OSystem_SDL_Symbian*>(s)->symbianMix(samples,len); } @@ -170,24 +172,20 @@ void OSystem_SDL_Symbian::symbianMixCallback(void *s, byte *samples, int len){ /** * Actual mixing implementation */ -void OSystem_SDL_Symbian::symbianMix(byte *samples, int len){ - - +void OSystem_SDL_Symbian::symbianMix(byte *samples, int len) { // If not stereo then we need to downmix - if(_channels != 2){ - _sound_proc(_sound_proc_param,_stereo_mix_buffer,len*2); - int16* bitmixDst=(int16*)samples; - int16* bitmixSrc=(int16*)_stereo_mix_buffer; + if (_channels != 2) { + _sound_proc(_sound_proc_param, _stereo_mix_buffer, len * 2); + int16 *bitmixDst = (int16 *)samples; + int16 *bitmixSrc = (int16 *)_stereo_mix_buffer; - for(int loop=len/2;loop>=0;loop--){ - *bitmixDst=(*bitmixSrc+*(bitmixSrc+1))>>1; + for (int loop = len / 2; loop >= 0; loop --) { + *bitmixDst = (*bitmixSrc + *(bitmixSrc + 1)) >> 1; bitmixDst++; - bitmixSrc+=2; + bitmixSrc += 2; } - } - else - _sound_proc(_sound_proc_param,samples,len); - + } else + _sound_proc(_sound_proc_param, samples, len); } /** @@ -196,85 +194,84 @@ void OSystem_SDL_Symbian::symbianMix(byte *samples, int len){ * @param ScumVM event to modify if special result is requested * @return true if Event has a valid return status */ -bool OSystem_SDL_Symbian::remapKey(SDL_Event &ev,Event &event) -{ - if(!GUI::Actions::Instance()->mappingActive() && ev.key.keysym.sym>SDLK_UNKNOWN) - for(TInt loop=0;loop<GUI::ACTION_LAST;loop++){ - if(GUI::Actions::Instance()->getMapping(loop) ==ev.key.keysym.sym && - GUI::Actions::Instance()->isEnabled(loop)){ - // Create proper event instead - switch(loop) - { +bool OSystem_SDL_Symbian::remapKey(SDL_Event &ev, Event &event) { + if (GUI::Actions::Instance()->mappingActive() || ev.key.keysym.sym <= SDLK_UNKNOWN) + return false; + + for (TInt loop = 0; loop < GUI::ACTION_LAST; loop++) { + if (GUI::Actions::Instance()->getMapping(loop) == ev.key.keysym.sym && + GUI::Actions::Instance()->isEnabled(loop)) { + // Create proper event instead + switch(loop) { case GUI::ACTION_UP: - if(ev.type == SDL_KEYDOWN) - { - _km.y_vel = -1; - _km.y_down_count = 1; - } - else - { + if (ev.type == SDL_KEYDOWN) { + _km.y_vel = -1; + _km.y_down_count = 1; + } else { _km.y_vel = 0; _km.y_down_count = 0; } event.type = EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); + return true; + case GUI::ACTION_DOWN: - if(ev.type == SDL_KEYDOWN) - { - _km.y_vel = 1; - _km.y_down_count = 1; - } - else - { + if(ev.type == SDL_KEYDOWN) { + _km.y_vel = 1; + _km.y_down_count = 1; + } else { _km.y_vel = 0; _km.y_down_count = 0; } event.type = EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); + return true; + case GUI::ACTION_LEFT: - if(ev.type == SDL_KEYDOWN) - { - _km.x_vel = -1; + if(ev.type == SDL_KEYDOWN) { + _km.x_vel = -1; _km.x_down_count = 1; - } - else - { + } else { _km.x_vel = 0; _km.x_down_count = 0; } event.type = EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); + return true; + case GUI::ACTION_RIGHT: - if(ev.type == SDL_KEYDOWN) - { - _km.x_vel = 1; + if(ev.type == SDL_KEYDOWN) { + _km.x_vel = 1; _km.x_down_count = 1; - } - else - { + } else { _km.x_vel = 0; _km.x_down_count = 0; } event.type = EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); + return true; + case GUI::ACTION_LEFTCLICK: - event.type = ev.type == SDL_KEYDOWN?EVENT_LBUTTONDOWN:EVENT_LBUTTONUP; + event.type = (ev.type == SDL_KEYDOWN ? EVENT_LBUTTONDOWN : EVENT_LBUTTONUP); fillMouseEvent(event, _km.x, _km.y); + return true; + case GUI::ACTION_RIGHTCLICK: - event.type = ev.type == SDL_KEYDOWN?EVENT_RBUTTONDOWN:EVENT_RBUTTONUP; + event.type = (ev.type == SDL_KEYDOWN ? EVENT_RBUTTONDOWN : EVENT_RBUTTONUP); fillMouseEvent(event, _km.x, _km.y); + return true; + case GUI::ACTION_ZONE: - if(ev.type == SDL_KEYDOWN) - { + if(ev.type == SDL_KEYDOWN) { int i; - for (i=0; i<TOTAL_ZONES; i++) + for (i=0; i < TOTAL_ZONES; i++) if (_km.x >= _zones[i].x && _km.y >= _zones[i].y && _km.x <= _zones[i].x + _zones[i].width && _km.y <= _zones[i].y + _zones[i].height ) { @@ -286,31 +283,38 @@ bool OSystem_SDL_Symbian::remapKey(SDL_Event &ev,Event &event) if (_currentZone >= TOTAL_ZONES) _currentZone = 0; event.type = EVENT_MOUSEMOVE; - fillMouseEvent(event, _mouseXZone[_currentZone],_mouseYZone[_currentZone]); - SDL_WarpMouse(event.mouse.x,event.mouse.y); + fillMouseEvent(event, _mouseXZone[_currentZone], _mouseYZone[_currentZone]); + SDL_WarpMouse(event.mouse.x, event.mouse.y); } + return true; + case GUI::ACTION_SAVE: case GUI::ACTION_SKIP: case GUI::ACTION_FT_CHEAT: case GUI::ACTION_SKIP_TEXT: case GUI::ACTION_PAUSE: { - GUI::Key& key = GUI::Actions::Instance()->getKeyAction(loop); - ev.key.keysym.sym =(SDLKey) key.ascii(); + GUI::Key &key = GUI::Actions::Instance()->getKeyAction(loop); + ev.key.keysym.sym = (SDLKey)key.ascii(); ev.key.keysym.scancode= key.keycode(); - ev.key.keysym.mod =(SDLMod) key.flags(); + ev.key.keysym.mod = (SDLMod)key.flags(); + return false; } - case GUI::ACTION_QUIT:{ - GUI::MessageDialog alert("Do you want to quit ?", "Yes", "No"); - if (alert.runModal() == GUI::kMessageOK) - quit(); - return true; + + case GUI::ACTION_QUIT: + { + GUI::MessageDialog alert("Do you want to quit ?", "Yes", "No"); + if (alert.runModal() == GUI::kMessageOK) + quit(); + + return true; + } } } } - } + return false; } @@ -327,13 +331,14 @@ void OSystem_SDL_Symbian::check_mappings() { } void OSystem_SDL_Symbian::initZones() { - int i; + int i; - _currentZone = 0; - for (i=0; i<TOTAL_ZONES; i++) { - _mouseXZone[i] = (_zones[i].x + (_zones[i].width / 2)); - _mouseYZone[i] = (_zones[i].y + (_zones[i].height / 2)); - } + _currentZone = 0; + + for (i = 0; i < TOTAL_ZONES; i++) { + _mouseXZone[i] = (_zones[i].x + (_zones[i].width / 2)); + _mouseYZone[i] = (_zones[i].y + (_zones[i].height / 2)); + } } /* diff --git a/backends/epoc/SymbianOS.h b/backends/epoc/SymbianOS.h index eadef5c9ae..b0fd426292 100644 --- a/backends/epoc/SymbianOS.h +++ b/backends/epoc/SymbianOS.h @@ -24,7 +24,7 @@ #ifndef SDLSYMBIANH #define SDLSYMBIANH -#include "sdl-common.h" +#include "backends/sdl/sdl-common.h" #define TOTAL_ZONES 3 @@ -32,42 +32,44 @@ class OSystem_SDL_Symbian : public OSystem_SDL { public: OSystem_SDL_Symbian(); ~OSystem_SDL_Symbian(); + int getDefaultGraphicsMode() const; const OSystem::GraphicsMode *getSupportedGraphicsModes() const; bool setGraphicsMode(const char *name); // Set function that generates samples - /** - * This function is overridden by the symbian port in order to provide MONO audio - * downmix is done by supplying our own audiocallback - */ + // + // This function is overridden by the symbian port in order to provide MONO audio + // downmix is done by supplying our own audiocallback + // virtual bool setSoundCallback(SoundProc proc, void *param); // overloaded by CE backend + protected: - /** - * The mixer callback function, passed on to OSystem::setSoundCallback(). - * This simply calls the mix() method. - * and then does downmixing for symbian if needed - */ + // + // The mixer callback function, passed on to OSystem::setSoundCallback(). + // This simply calls the mix() method. + // and then does downmixing for symbian if needed + // static void symbianMixCallback(void *s, byte *samples, int len); - /** - * Actual mixing implementation - */ + // + // Actual mixing implementation + // void symbianMix(byte *samples, int len); - /** - * This is an implementation by the remapKey function - * @param SDL_Event to remap - * @param ScumVM event to modify if special result is requested - * @return true if Event has a valid return status - */ - bool remapKey(SDL_Event &ev,Event &event); + // + // This is an implementation by the remapKey function + // @param SDL_Event to remap + // @param ScumVM event to modify if special result is requested + // @return true if Event has a valid return status + // + bool remapKey(SDL_Event &ev, Event &event); void setWindowCaption(const char *caption); - /** - * Used to intialized special game mappings - */ + // + // Used to intialized special game mappings + // void check_mappings(); void initZones(); @@ -77,7 +79,7 @@ protected: SoundProc _sound_proc; void *_sound_proc_param; - byte* _stereo_mix_buffer; + byte *_stereo_mix_buffer; // Used to handle joystick navi zones int _mouseXZone[TOTAL_ZONES]; diff --git a/backends/epoc/build/S60/ScummVMApp.cpp b/backends/epoc/build/S60/ScummVMApp.cpp index c5c365d2a8..638721e661 100644 --- a/backends/epoc/build/S60/ScummVMApp.cpp +++ b/backends/epoc/build/S60/ScummVMApp.cpp @@ -21,13 +21,13 @@ * $Header$ */ -#include "ScummVMapp.h" +#include "backends/epoc/build/S60/ScummVMapp.h" #include <escummvms60.rsg> #include <apgcli.h> #include <eikdll.h> -EXPORT_C CApaApplication* NewApplication() { - return (new CScummVM); +EXPORT_C CApaApplication *NewApplication() { + return (new CScummVM); } CScummVM::CScummVM() { @@ -36,28 +36,26 @@ CScummVM::CScummVM() { CScummVM::~CScummVM() { } -CApaDocument* CScummVM::CreateDocumentL() -{ - return new (ELeave) CScummVMDoc(*this); +CApaDocument *CScummVM::CreateDocumentL() { + return new (ELeave)CScummVMDoc(*this); } -TUid CScummVM::AppDllUid() const -{ +TUid CScummVM::AppDllUid() const { return TUid::Uid(0x101f9b57); } -CScummVMDoc::CScummVMDoc(CEikApplication& aApp):CAknDocument(aApp) { +CScummVMDoc::CScummVMDoc(CEikApplication &aApp) : CAknDocument(aApp) { } CScummVMDoc::~CScummVMDoc() { } -CEikAppUi* CScummVMDoc::CreateAppUiL() { - return new (ELeave) CScummVMUi; +CEikAppUi *CScummVMDoc::CreateAppUiL() { + return new (ELeave)CScummVMUi; } void CScummVMUi::HandleForegroundEventL(TBool aForeground) { - if(aForeground) { + if (aForeground) { BringUpEmulatorL(); } } @@ -80,33 +78,38 @@ void CScummVMUi::ConstructL() { TBuf<128> startFile; startFile = iEikonEnv->EikAppUi()->Application()->AppFullName(); TParse parser; - parser.Set(startFile,NULL,NULL); + parser.Set(startFile, NULL, NULL); startFile = parser.DriveAndPath(); #ifndef __WINS__ - startFile.Append( _L("EScummVM.exe")); + startFile.Append( _L("ScummVM.exe")); #else - startFile.Append( _L("EScummVM.dll")); + startFile.Append( _L("ScummVM.dll")); #endif - CApaCommandLine* cmdLine=CApaCommandLine::NewLC(startFile); + CApaCommandLine *cmdLine = CApaCommandLine::NewLC(startFile); RApaLsSession lsSession; + lsSession.Connect(); CleanupClosePushL(lsSession); - lsSession.StartApp(*cmdLine,iThreadId); - CleanupStack::PopAndDestroy();//close lsSession + lsSession.StartApp(*cmdLine, iThreadId); + CleanupStack::PopAndDestroy(); //close lsSession CleanupStack::PopAndDestroy(cmdLine); - User::After(500000);// Let the application start + + User::After(500000); // Let the application start TApaTaskList taskList(iEikonEnv->WsSession()); + TApaTask myTask=taskList.FindApp(TUid::Uid(0x101f9b57)); myTask.SendToBackground(); + TApaTask exeTask=taskList.FindByPos(0); iExeWgId=exeTask.WgId(); if(iExeWgId == myTask.WgId()) { // Should n't be the same Exit(); } - if(iThreadWatch.Open(iThreadId)==KErrNone) { + + if(iThreadWatch.Open(iThreadId) == KErrNone) { iWatcher = new (ELeave)CScummWatcher; iWatcher->iAppUi=this; iThreadWatch.Logon(iWatcher->iStatus); @@ -131,34 +134,33 @@ void CScummWatcher::RunL() { void CScummVMUi::BringUpEmulatorL() { RThread thread; - if(thread.Open(iThreadId)==KErrNone) { + + if (thread.Open(iThreadId) == KErrNone) { thread.Close(); TApaTask apaTask(iEikonEnv->WsSession()); apaTask.SetWgId(iExeWgId); apaTask.BringToForeground(); - } - else - { - iExeWgId=-1; + } else { + iExeWgId = -1; } } void CScummVMUi::HandleCommandL(TInt aCommand) { switch(aCommand) { case EEikCmdExit: - { - RThread thread; - if(thread.Open(iThreadId)==KErrNone) { - thread.Terminate(0); - thread.Close(); + RThread thread; + + if(thread.Open(iThreadId) == KErrNone) { + thread.Terminate(0); + thread.Close(); + } + Exit(); } - Exit(); - } - break; + break; } } -GLDEF_C TInt E32Dll(TDllReason) { +GLDEF_C TInt E32Dll(TDllReason) { return KErrNone; } diff --git a/backends/epoc/build/S60/ScummVMApp.h b/backends/epoc/build/S60/ScummVMApp.h index 8d16e47073..8cb622cac6 100644 --- a/backends/epoc/build/S60/ScummVMApp.h +++ b/backends/epoc/build/S60/ScummVMApp.h @@ -36,7 +36,8 @@ class CScummVM:public CEikApplication { public: CScummVM(); ~CScummVM(); - CApaDocument* CreateDocumentL(); + + CApaDocument *CreateDocumentL(); TUid AppDllUid() const; }; @@ -45,35 +46,39 @@ public: class CScummVMDoc:public CAknDocument { public: + CScummVMDoc(CEikApplication &aApplicaiton); ~CScummVMDoc(); - CEikAppUi* CreateAppUiL(); + + CEikAppUi *CreateAppUiL(); void ConstructL(); - CScummVMDoc(CEikApplication& aApplicaiton); }; #include <aknappui.h> class CScummVMUi; -class CScummWatcher:public CActive { +class CScummWatcher : public CActive { public: CScummWatcher(); ~CScummWatcher(); + void DoCancel(); void RunL(); - CScummVMUi* iAppUi; + CScummVMUi *iAppUi; }; -class CScummVMUi:public CAknAppUi { +class CScummVMUi : public CAknAppUi { public: CScummVMUi(); ~CScummVMUi(); + void ConstructL(); void HandleCommandL(TInt aCommand); void HandleForegroundEventL(TBool aForeground); void BringUpEmulatorL(); + private: TThreadId iThreadId; TInt iExeWgId; RThread iThreadWatch; - CScummWatcher* iWatcher; + CScummWatcher *iWatcher; }; #endif diff --git a/backends/epoc/build/S80/ScummVMApp.cpp b/backends/epoc/build/S80/ScummVMApp.cpp index 69165ea3ca..15db5fea12 100644 --- a/backends/epoc/build/S80/ScummVMApp.cpp +++ b/backends/epoc/build/S80/ScummVMApp.cpp @@ -21,13 +21,14 @@ * $Header$ */ -#include "ScummVMapp.h" +#include "backends/epoc/build/S80/ScummVMapp.h" #include <escummvms80.rsg> #include <apgcli.h> #include <eikdll.h> #include <apgtask.h> -EXPORT_C CApaApplication* NewApplication() { - return (new CScummVM); + +EXPORT_C CApaApplication *NewApplication() { + return (new CScummVM); } CScummVM::CScummVM() { @@ -36,24 +37,22 @@ CScummVM::CScummVM() { CScummVM::~CScummVM() { } -CApaDocument* CScummVM::CreateDocumentL() -{ - return new (ELeave) CScummVMDoc(*this); +CApaDocument *CScummVM::CreateDocumentL() { + return new (ELeave)CScummVMDoc(*this); } -TUid CScummVM::AppDllUid() const -{ +TUid CScummVM::AppDllUid() const { return TUid::Uid(0x101f9b57); } -CScummVMDoc::CScummVMDoc(CEikApplication& aApp):CEikDocument(aApp) { +CScummVMDoc::CScummVMDoc(CEikApplication &aApp) : CEikDocument(aApp) { } CScummVMDoc::~CScummVMDoc() { } -CEikAppUi* CScummVMDoc::CreateAppUiL() { - return new (ELeave) CScummVMUi; +CEikAppUi *CScummVMDoc::CreateAppUiL() { + return new (ELeave)CScummVMUi; } void CScummVMUi::HandleForegroundEventL(TBool aForeground) { @@ -84,37 +83,45 @@ void CScummVMUi::ConstructL() { startFile = parser.DriveAndPath(); #ifndef __WINS__ - startFile.Append( _L("EScummVM.exe")); + startFile.Append( _L("ScummVM.exe")); #else - startFile.Append( _L("EScummVM.dll")); + startFile.Append( _L("ScummVM.dll")); #endif - CApaCommandLine* cmdLine=CApaCommandLine::NewLC(startFile); + CApaCommandLine *cmdLine = CApaCommandLine::NewLC(startFile); RApaLsSession lsSession; + lsSession.Connect(); CleanupClosePushL(lsSession); - lsSession.StartApp(*cmdLine,iThreadId); - CleanupStack::PopAndDestroy();//close lsSession + lsSession.StartApp(*cmdLine, iThreadId); + + CleanupStack::PopAndDestroy(); // close lsSession CleanupStack::PopAndDestroy(cmdLine); - User::After(500000);// Let the application start + + User::After(500000); // Let the application start + TApaTaskList taskList(iEikonEnv->WsSession()); - TApaTask myTask=taskList.FindApp(TUid::Uid(0x101f9b57)); + + TApaTask myTask = taskList.FindApp(TUid::Uid(0x101f9b57)); myTask.SendToBackground(); - TApaTask exeTask=taskList.FindByPos(0); - iExeWgId=exeTask.WgId(); + + TApaTask exeTask = taskList.FindByPos(0); + + iExeWgId = exeTask.WgId(); exeTask.BringToForeground(); + if(iExeWgId == myTask.WgId()) { // Should n't be the same Exit(); } - if(iThreadWatch.Open(iThreadId)==KErrNone) { + if(iThreadWatch.Open(iThreadId) == KErrNone) { iWatcher = new (ELeave)CScummWatcher; - iWatcher->iAppUi=this; + iWatcher->iAppUi = this; iThreadWatch.Logon(iWatcher->iStatus); } } -CScummWatcher::CScummWatcher():CActive(EPriorityStandard) { +CScummWatcher::CScummWatcher() : CActive(EPriorityStandard) { CActiveScheduler::Add(this); - iStatus=KRequestPending; + iStatus = KRequestPending; SetActive(); } @@ -130,34 +137,31 @@ void CScummWatcher::RunL() { void CScummVMUi::BringUpEmulatorL() { RThread thread; - if(thread.Open(iThreadId)==KErrNone) { + if(thread.Open(iThreadId) == KErrNone) { thread.Close(); TApaTask apaTask(iEikonEnv->WsSession()); apaTask.SetWgId(iExeWgId); apaTask.BringToForeground(); - } - else - { - iExeWgId=-1; + } else { + iExeWgId = -1; } } void CScummVMUi::HandleCommandL(TInt aCommand) { switch(aCommand) { case EEikCmdExit: - { - RThread thread; - if(thread.Open(iThreadId)==KErrNone) { - thread.Terminate(0); - thread.Close(); + RThread thread; + if(thread.Open(iThreadId) == KErrNone) { + thread.Terminate(0); + thread.Close(); + } + Exit(); } - Exit(); - } - break; + break; } } -GLDEF_C TInt E32Dll(TDllReason) { +GLDEF_C TInt E32Dll(TDllReason) { return KErrNone; } diff --git a/backends/epoc/build/S80/ScummVMApp.h b/backends/epoc/build/S80/ScummVMApp.h index 18e4506650..e297d75e9d 100644 --- a/backends/epoc/build/S80/ScummVMApp.h +++ b/backends/epoc/build/S80/ScummVMApp.h @@ -31,48 +31,53 @@ #include <coeview.h> #include <eikappui.h> -class CScummVM:public CEikApplication { +class CScummVM : public CEikApplication { public: CScummVM(); ~CScummVM(); - CApaDocument* CreateDocumentL(); + + CApaDocument *CreateDocumentL(); TUid AppDllUid() const; }; #include <eikdoc.h> -class CScummVMDoc:public CEikDocument { +class CScummVMDoc : public CEikDocument { public: + CScummVMDoc(CEikApplication &aApplicaiton); ~CScummVMDoc(); - CEikAppUi* CreateAppUiL(); + + CEikAppUi *CreateAppUiL(); void ConstructL(); - CScummVMDoc(CEikApplication& aApplicaiton); }; #include <eikappui.h> class CScummVMUi; -class CScummWatcher:public CActive { +class CScummWatcher : public CActive { public: CScummWatcher(); ~CScummWatcher(); + void DoCancel(); void RunL(); - CScummVMUi* iAppUi; + CScummVMUi *iAppUi; }; -class CScummVMUi:public CEikAppUi { +class CScummVMUi : public CEikAppUi { public: CScummVMUi(); ~CScummVMUi(); + void ConstructL(); void HandleCommandL(TInt aCommand); void HandleForegroundEventL(TBool aForeground); void BringUpEmulatorL(); + private: TThreadId iThreadId; TInt iExeWgId; RThread iThreadWatch; - CScummWatcher* iWatcher; + CScummWatcher *iWatcher; }; #endif diff --git a/backends/epoc/build/S90/ScummVMApp.cpp b/backends/epoc/build/S90/ScummVMApp.cpp index 17804b2efb..1a2c89a4f6 100644 --- a/backends/epoc/build/S90/ScummVMApp.cpp +++ b/backends/epoc/build/S90/ScummVMApp.cpp @@ -21,13 +21,14 @@ * $Header$ */ -#include "ScummVMapp.h" +#include "backends/epoc/build/S90/ScummVMapp.h" #include <escummvms90.rsg> #include <apgcli.h> #include <eikdll.h> #include <apgtask.h> -EXPORT_C CApaApplication* NewApplication() { - return (new CScummVM); + +EXPORT_C CApaApplication *NewApplication() { + return (new CScummVM); } CScummVM::CScummVM() { @@ -36,24 +37,22 @@ CScummVM::CScummVM() { CScummVM::~CScummVM() { } -CApaDocument* CScummVM::CreateDocumentL() -{ - return new (ELeave) CScummVMDoc(*this); +CApaDocument *CScummVM::CreateDocumentL() { + return new (ELeave)CScummVMDoc(*this); } -TUid CScummVM::AppDllUid() const -{ +TUid CScummVM::AppDllUid() const { return TUid::Uid(0x101f9b57); } -CScummVMDoc::CScummVMDoc(CEikApplication& aApp):CEikDocument(aApp) { +CScummVMDoc::CScummVMDoc(CEikApplication &aApp) : CEikDocument(aApp) { } CScummVMDoc::~CScummVMDoc() { } -CEikAppUi* CScummVMDoc::CreateAppUiL() { - return new (ELeave) CScummVMUi; +CEikAppUi *CScummVMDoc::CreateAppUiL() { + return new (ELeave)CScummVMUi; } void CScummVMUi::HandleForegroundEventL(TBool aForeground) { @@ -70,6 +69,7 @@ CScummVMUi::~CScummVMUi() { iThreadWatch.LogonCancel(iWatcher->iStatus); iWatcher->Cancel(); } + delete iWatcher; iThreadWatch.Close(); @@ -84,37 +84,46 @@ void CScummVMUi::ConstructL() { startFile = parser.DriveAndPath(); #ifndef __WINS__ - startFile.Append( _L("EScummVM.exe")); + startFile.Append( _L("ScummVM.exe")); #else - startFile.Append( _L("EScummVM.dll")); + startFile.Append( _L("ScummVM.dll")); #endif - CApaCommandLine* cmdLine=CApaCommandLine::NewLC(startFile); + CApaCommandLine *cmdLine = CApaCommandLine::NewLC(startFile); RApaLsSession lsSession; + lsSession.Connect(); CleanupClosePushL(lsSession); - lsSession.StartApp(*cmdLine,iThreadId); + lsSession.StartApp(*cmdLine, iThreadId); + CleanupStack::PopAndDestroy();//close lsSession CleanupStack::PopAndDestroy(cmdLine); + User::After(500000);// Let the application start + TApaTaskList taskList(iEikonEnv->WsSession()); - TApaTask myTask=taskList.FindApp(TUid::Uid(0x101f9b57)); + + TApaTask myTask = taskList.FindApp(TUid::Uid(0x101f9b57)); myTask.SendToBackground(); - TApaTask exeTask=taskList.FindByPos(0); + + TApaTask exeTask = taskList.FindByPos(0); + iExeWgId=exeTask.WgId(); exeTask.BringToForeground(); + if(iExeWgId == myTask.WgId()) { // Should n't be the same Exit(); } - if(iThreadWatch.Open(iThreadId)==KErrNone) { + if(iThreadWatch.Open(iThreadId) == KErrNone) { iWatcher = new (ELeave)CScummWatcher; - iWatcher->iAppUi=this; + iWatcher->iAppUi = this; iThreadWatch.Logon(iWatcher->iStatus); } } -CScummWatcher::CScummWatcher():CActive(EPriorityStandard) { +CScummWatcher::CScummWatcher() : CActive(EPriorityStandard) { CActiveScheduler::Add(this); - iStatus=KRequestPending; + + iStatus = KRequestPending; SetActive(); } @@ -130,34 +139,32 @@ void CScummWatcher::RunL() { void CScummVMUi::BringUpEmulatorL() { RThread thread; - if(thread.Open(iThreadId)==KErrNone) { + + if(thread.Open(iThreadId) == KErrNone) { thread.Close(); TApaTask apaTask(iEikonEnv->WsSession()); apaTask.SetWgId(iExeWgId); apaTask.BringToForeground(); - } - else - { - iExeWgId=-1; + } else { + iExeWgId = -1; } } void CScummVMUi::HandleCommandL(TInt aCommand) { switch(aCommand) { case EEikCmdExit: - { - RThread thread; - if(thread.Open(iThreadId)==KErrNone) { - thread.Terminate(0); - thread.Close(); + RThread thread; + if(thread.Open(iThreadId) == KErrNone) { + thread.Terminate(0); + thread.Close(); + } + Exit(); } - Exit(); - } - break; + break; } } -GLDEF_C TInt E32Dll(TDllReason) { +GLDEF_C TInt E32Dll(TDllReason) { return KErrNone; } diff --git a/backends/epoc/build/S90/ScummVMApp.h b/backends/epoc/build/S90/ScummVMApp.h index 18e4506650..e297d75e9d 100644 --- a/backends/epoc/build/S90/ScummVMApp.h +++ b/backends/epoc/build/S90/ScummVMApp.h @@ -31,48 +31,53 @@ #include <coeview.h> #include <eikappui.h> -class CScummVM:public CEikApplication { +class CScummVM : public CEikApplication { public: CScummVM(); ~CScummVM(); - CApaDocument* CreateDocumentL(); + + CApaDocument *CreateDocumentL(); TUid AppDllUid() const; }; #include <eikdoc.h> -class CScummVMDoc:public CEikDocument { +class CScummVMDoc : public CEikDocument { public: + CScummVMDoc(CEikApplication &aApplicaiton); ~CScummVMDoc(); - CEikAppUi* CreateAppUiL(); + + CEikAppUi *CreateAppUiL(); void ConstructL(); - CScummVMDoc(CEikApplication& aApplicaiton); }; #include <eikappui.h> class CScummVMUi; -class CScummWatcher:public CActive { +class CScummWatcher : public CActive { public: CScummWatcher(); ~CScummWatcher(); + void DoCancel(); void RunL(); - CScummVMUi* iAppUi; + CScummVMUi *iAppUi; }; -class CScummVMUi:public CEikAppUi { +class CScummVMUi : public CEikAppUi { public: CScummVMUi(); ~CScummVMUi(); + void ConstructL(); void HandleCommandL(TInt aCommand); void HandleForegroundEventL(TBool aForeground); void BringUpEmulatorL(); + private: TThreadId iThreadId; TInt iExeWgId; RThread iThreadWatch; - CScummWatcher* iWatcher; + CScummWatcher *iWatcher; }; #endif diff --git a/backends/epoc/portdefs.h b/backends/epoc/portdefs.h index 863e62fbee..846a916508 100644 --- a/backends/epoc/portdefs.h +++ b/backends/epoc/portdefs.h @@ -35,43 +35,44 @@ // the place in Symbian FS where scummvm.ini & std***.txt are saved -#define SYMBIAN32_DOC_DIR "C:\\documents\\EScummVM\\" // includes final \\! +#define SYMBIAN32_DOC_DIR "C:\\documents\\ScummVM\\" // includes final \\! #define DISABLE_SCALERS // we only need 1x // hack in some tricks to work around not having these fcns for Symbian // and we _really_ don't wanna link with any other windows LIBC library! #ifdef __GCC32__ - #define snprintf(buf,len,args...) sprintf(buf,args) - #define vsnprintf snprintf +#define snprintf(buf,len,args...) sprintf(buf, args) +#define vsnprintf snprintf #else // WINS - // let's just blatantly ignore this for now and just get it to work :P but does n't work from the debug function - int inline scumm_snprintf (char *str, unsigned long /*n*/, char const *fmt, ...) - { - va_list args; - va_start(args, fmt); - vsprintf(str, fmt, args); - va_end(args); - return strlen(str); - } +// let's just blatantly ignore this for now and just get it to work :P but does n't work from the debug function +int inline scumm_snprintf (char *str, unsigned long /*n*/, char const *fmt, ...) { + va_list args; + va_start(args, fmt); + vsprintf(str, fmt, args); + va_end(args); - #define snprintf scumm_snprintf - #define vsnprintf scumm_snprintf + return strlen(str); +} + +#define snprintf scumm_snprintf +#define vsnprintf scumm_snprintf #endif // somehow nobody has this function... -#define hypot(a, b) sqrt((a)*(a) + (b)*(b)) +#define hypot(a, b) sqrt((a) * (a) + (b) * (b)) // Symbian bsearch implementation is flawed void inline *scumm_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) { size_t i; - for (i=0; i<nmemb; i++) + for (i = 0; i < nmemb; i++) if (compar(key, (void*)((size_t)base + size * i)) == 0) return (void*)((size_t)base + size * i); + return NULL; } #define bsearch scumm_bsearch |