diff options
author | Chris Apers | 2004-11-09 10:50:30 +0000 |
---|---|---|
committer | Chris Apers | 2004-11-09 10:50:30 +0000 |
commit | 923e53724c3116982d4a41b11a5157bee9900db5 (patch) | |
tree | ed6a86c325d567e28b48cef7c2ac988831c8e088 /backends/PalmOS | |
parent | 58557e6457acc1804ae66c06cfcaf8cbe8610537 (diff) | |
download | scummvm-rg350-923e53724c3116982d4a41b11a5157bee9900db5.tar.gz scummvm-rg350-923e53724c3116982d4a41b11a5157bee9900db5.tar.bz2 scummvm-rg350-923e53724c3116982d4a41b11a5157bee9900db5.zip |
New module code
svn-id: r15745
Diffstat (limited to 'backends/PalmOS')
-rw-r--r-- | backends/PalmOS/Src/modules.cpp | 134 | ||||
-rw-r--r-- | backends/PalmOS/Src/modules.h | 22 |
2 files changed, 156 insertions, 0 deletions
diff --git a/backends/PalmOS/Src/modules.cpp b/backends/PalmOS/Src/modules.cpp new file mode 100644 index 0000000000..9b8600a7e9 --- /dev/null +++ b/backends/PalmOS/Src/modules.cpp @@ -0,0 +1,134 @@ +#include <PalmOS.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "palmdefs.h" +#include "args.h" +#include "globals.h" +#include "modules.h" +#include "extend.h" +#include "features.h" + +#include "rumble.h" +#include "init_mathlib.h" +#include "init_pa1lib.h" +#include "init_arm.h" +#include "init_palmos.h" +#include "init_sony.h" + +#ifndef DISABLE_LIGHTSPEED +#include "lightspeed_public.h" +#endif + +GlobalsDataPtr gVars; + +void run(int argc, char *argv[]) { + + MathlibInit(); + gVars->HRrefNum = SonyHRInit(8); + if (gVars->HRrefNum == sysInvalidRefNum) + PalmHRInit(8); + gVars->slkRefNum= SilkInit(&(gVars->slkVersion)); + + // create file for printf, warnings, etc... + StdioInit(gVars->volRefNum, "/PALM/Programs/ScummVM/scumm.log", DrawStatus); + gUnistdCWD = SCUMMVM_SAVEPATH; + + // init hardware + if (HWR_INIT(INIT_PA1LIB)) Pa1libInit(); + if (HWR_INIT(INIT_VIBRATOR)) gVars->vibrator = RumbleInit(); + if (HWR_INIT(INIT_ARM)) ARMInit(); + PalmInit(HWR_GET()); + + if (!gVars->vibrator) + HWR_RST(INIT_VIBRATOR); + + GlbOpen(); + + DO_EXIT( main(argc, argv); ) + + // be sure to release features memory + FREE_FTR(ftrBufferOverlay) + FREE_FTR(ftrBufferBackup) + FREE_FTR(ftrBufferHotSwap) + + GlbClose(); + + PalmRelease(HWR_GET()); + if (HWR_INIT(INIT_ARM)) ARMRelease(); + if (HWR_INIT(INIT_VIBRATOR)) RumbleRelease(); + if (HWR_INIT(INIT_PA1LIB)) Pa1libRelease(); + + // close log file + StdioRelease(); + + PalmHRRelease(); + SonyHRRelease(gVars->HRrefNum); + SilkRelease(gVars->slkRefNum); + MathlibRelease(); + + MemPtrFree(gVars); + WinPalette(winPaletteSetToDefault, 0, 256, NULL); +// ArgsFree(argvP); // called in main(...) +} + +static UInt32 ModulesPalmMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + switch (cmd) + { + case sysAppLaunchCmdNormalLaunch: + { + if (cmdPBP) { + Char **argvP; + UInt16 cardNo; + LocalID dbID; + + LaunchParamType *lp = (LaunchParamType *)cmdPBP; + + gVars = lp->gVars; + argvP = lp->args.argv; + +#ifndef DISABLE_LIGHTSPEED + switch (lp->lightspeed) { + case 0: + LS_SetCPUSpeedHigh(); + break; + case 1: + LS_SetCPUSpeedNormal(); + break; + case 2: + LS_SetCPUSpeedLow(); + break; + } +#endif + // MemPtrSetOwner(gVars, ownerID); + // ArgsSetOwner(argvP, ownerID); // will be freed by main(...) + // MemPtrFree(lp); // will be freed by the system on exit + + run(lp->args.argc, argvP); + + cardNo = 0; + dbID = DmFindDatabase(0, "ScummVM"); + if (dbID) { + if (lp->exitLauncher) + SysUIAppSwitch(cardNo, dbID, sysAppLaunchCustomDeleteEngine,0); + else + SysUIAppSwitch(cardNo, dbID, sysAppLaunchCmdNormalLaunch,0); + } + } + break; + } + + default: + break; + + } + + return 0; +} + +UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + return ModulesPalmMain(cmd, cmdPBP, launchFlags); +} diff --git a/backends/PalmOS/Src/modules.h b/backends/PalmOS/Src/modules.h new file mode 100644 index 0000000000..da89b7353b --- /dev/null +++ b/backends/PalmOS/Src/modules.h @@ -0,0 +1,22 @@ +#ifndef MODULES_H +#define MODULES_H + +#include "globals.h" + +#define sysAppLaunchCode_SVMRunEngine (sysAppLaunchCmdCustomBase + 0) + +void ModDelete(); + +typedef struct { + UInt8 lightspeed; + Boolean exitLauncher; + + struct { + UInt8 argc; + Char **argv; + } args; + + GlobalsDataPtr gVars; +} LaunchParamType; + +#endif |