diff options
author | Max Horn | 2006-07-06 21:44:48 +0000 |
---|---|---|
committer | Max Horn | 2006-07-06 21:44:48 +0000 |
commit | 1d8d9f5510dc5f574e926bd6fadb9d20337daede (patch) | |
tree | 5cdcf6c8a233159776be9d90f3f39885222f65eb /backends/platform/PalmOS/Src/native | |
parent | 9269ebe9f5a281f452594f1e8108e31c88a398fb (diff) | |
download | scummvm-rg350-1d8d9f5510dc5f574e926bd6fadb9d20337daede.tar.gz scummvm-rg350-1d8d9f5510dc5f574e926bd6fadb9d20337daede.tar.bz2 scummvm-rg350-1d8d9f5510dc5f574e926bd6fadb9d20337daede.zip |
Moving remaining platform/backends code, as previously threatened
svn-id: r23380
Diffstat (limited to 'backends/platform/PalmOS/Src/native')
-rw-r--r-- | backends/platform/PalmOS/Src/native/oscalls.cpp | 47 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/native/oscalls.h | 40 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/native/pace.h | 102 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/native/pnoARM.c | 80 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/native/pnoStartup.c | 27 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/native/zodiacARM.cpp | 146 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/native/zodiacStartup.cpp | 173 |
7 files changed, 615 insertions, 0 deletions
diff --git a/backends/platform/PalmOS/Src/native/oscalls.cpp b/backends/platform/PalmOS/Src/native/oscalls.cpp new file mode 100644 index 0000000000..4520d81c20 --- /dev/null +++ b/backends/platform/PalmOS/Src/native/oscalls.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend + * + * 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. + * + * $URL$ + * $Id$ + * + */ + +#include <PenInputMgr.h> +#include "pace.h" + +GlobalsType global; + + +PACE_CLASS_WRAPPER(Err) + StatShow_68k(void) { + PACE_PIN_EXEC_NP(pinStatShow, Err) +} + +PACE_CLASS_WRAPPER(Err) + StatHide_68k(void) { + PACE_PIN_EXEC_NP(pinStatHide, Err) +} + +PACE_CLASS_WRAPPER(Err) + PINSetInputAreaState_68k(UInt16 state) { + PACE_PARAMS_INIT() + PACE_PARAMS_ADD16(state) + PACE_PARAMS_END() + PACE_PIN_EXEC(pinPINSetInputAreaState, Err) +} diff --git a/backends/platform/PalmOS/Src/native/oscalls.h b/backends/platform/PalmOS/Src/native/oscalls.h new file mode 100644 index 0000000000..ae8f989337 --- /dev/null +++ b/backends/platform/PalmOS/Src/native/oscalls.h @@ -0,0 +1,40 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend + * + * 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. + * + * $URL$ + * $Id$ + * + */ + +#ifndef _OSCALLS_H_ +#define _OSCALLS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +Err StatShow_68k(); +Err StatHide_68k(); +Err PINSetInputAreaState_68k(UInt16 state); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/backends/platform/PalmOS/Src/native/pace.h b/backends/platform/PalmOS/Src/native/pace.h new file mode 100644 index 0000000000..a617e8a274 --- /dev/null +++ b/backends/platform/PalmOS/Src/native/pace.h @@ -0,0 +1,102 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend + * + * 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. + * + * $URL$ + * $Id$ + * + */ + +#ifndef PACE_H +#define PACE_H + +#include <PceNativeCall.h> +//#include "endianutils.h" + +// local definition of the emulation state structure +typedef struct { + UInt32 instr; + UInt32 regData[8]; + UInt32 regAddress[8]; + UInt32 regPC; +} EmulStateType; + +typedef struct { + EmulStateType *emulStateP; + Call68KFuncType *call68KFuncP; +} GlobalsType; + +extern GlobalsType global; + +// TODO : check this, already defined in ARMlet_Runtime +//extern EmulStateType *g_emulStateP; +//extern Call68KFuncType *g_call68KFuncP; +#define g_emulStateP global.emulStateP +#define g_call68KFuncP global.call68KFuncP + + +#ifdef __cplusplus +# define PACE_CLASS_WRAPPER(rv) extern "C" rv +#else +# define PACE_CLASS_WRAPPER(rv) rv +#endif +#define PACE_CALLBACK_PTR g_call68KFuncP +#define PACE_EMULSTATE g_emulStateP + +#define ALIGN_4BYTE(addr) (((UInt32)(addr) + 3) & 0xFFFFFFFC) + +/****** TAKEN FROM PACEInteface.cpp (ARMlet_Runtime) ******/ +// local definition of the emulation state structure + +#define PACE_PARAMS_INIT() \ + UInt8 params[] = { + +#define PACE_PARAMS_ADD8(param) \ + (UInt8)(param), \ + 0, + +#define PACE_PARAMS_ADD16(param) \ + (UInt8)((UInt16)(param) >> 8), \ + (UInt8)(param), + +#define PACE_PARAMS_ADD32(param) \ + (UInt8)((UInt32)(param) >> 24), \ + (UInt8)((UInt32)(param) >> 16), \ + (UInt8)((UInt32)(param) >> 8), \ + (UInt8)(param), + +#define PACE_PARAMS_END() \ + }; + +// PIN +#define PACE_PIN_EXEC_NP(pinTrap, returnType) \ + PACE_EMULSTATE->regData[2] = pinTrap; \ + return ((returnType)((PACE_CALLBACK_PTR)( \ + static_cast<void *>(PACE_EMULSTATE), \ + PceNativeTrapNo(sysTrapPinsDispatch), \ + NULL, 0))); + +#define PACE_PIN_EXEC(pinTrap, returnType) \ + PACE_EMULSTATE->regData[2] = pinTrap; \ + return ((returnType)((PACE_CALLBACK_PTR)( \ + static_cast<void *>(PACE_EMULSTATE), \ + PceNativeTrapNo(sysTrapPinsDispatch), \ + ¶ms, \ + sizeof(params)))); + +#endif
\ No newline at end of file diff --git a/backends/platform/PalmOS/Src/native/pnoARM.c b/backends/platform/PalmOS/Src/native/pnoARM.c new file mode 100644 index 0000000000..6c7954fcb5 --- /dev/null +++ b/backends/platform/PalmOS/Src/native/pnoARM.c @@ -0,0 +1,80 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend + * + * 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. + * + * $URL$ + * $Id$ + * + */ + +#ifdef COMPILE_OS5 + +//#include <tapwave.h> +#include <PalmOS.h> +#include <stdlib.h> +#include "pace.h" + +// Linker still looks for ARMlet_Main as entry point, but the +// "ARMlet" name is now officially discouraged. Compare an +// contrast to "PilotMain" for 68K applications. +#define PNO_Main ARMlet_Main + +#ifdef COMPILE_ZODIAC + const void* twEmulState; + Call68KFuncType* twCall68KFunc; +#endif +struct TwGlue* twGlue; + +unsigned long PNO_Main(const void *emulStateP, void *userData68KP, Call68KFuncType *call68KFuncP) { +#ifdef COMPILE_ZODIAC + twEmulState = emulStateP; + twCall68KFunc = call68KFuncP; +#else + global.emulStateP = (EmulStateType *)emulStateP; + global.call68KFuncP = call68KFuncP; +#endif + twGlue = (struct TwGlue*) userData68KP; + return PilotMain(sysAppLaunchCmdNormalLaunch, userData68KP, 0); +} + + // + // The following functions provide malloc/free support to Metrowerks + // Standard Library (MSL). This feature requires the MSL library be + // built with _MSL_OS_DIRECT_MALLOC enabled. + // +void* +__sys_alloc(UInt32 size) +{ + void * ptr = malloc(size); + ErrFatalDisplayIf(ptr == NULL, "out of memory"); + return ptr; +} + +void +__sys_free(void* ptr) +{ + (void) MemPtrFree(ptr); +} + +UInt32 +__sys_pointer_size(void* ptr) +{ + return (UInt32) MemPtrSize(ptr); +} + +#endif diff --git a/backends/platform/PalmOS/Src/native/pnoStartup.c b/backends/platform/PalmOS/Src/native/pnoStartup.c new file mode 100644 index 0000000000..dcfb56d002 --- /dev/null +++ b/backends/platform/PalmOS/Src/native/pnoStartup.c @@ -0,0 +1,27 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend + * + * 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. + * + * $URL$ + * $Id$ + * + */ + +#ifdef COMPILE_OS5 +# include "(Source)/ARMlet_Startup.c" +#endif diff --git a/backends/platform/PalmOS/Src/native/zodiacARM.cpp b/backends/platform/PalmOS/Src/native/zodiacARM.cpp new file mode 100644 index 0000000000..9b0db9122d --- /dev/null +++ b/backends/platform/PalmOS/Src/native/zodiacARM.cpp @@ -0,0 +1,146 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend + * + * 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. + * + * $URL$ + * $Id$ + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "globals.h" +#include "extend.h" +#include "args.h" +#include "palmdefs.h" + +#include "rumble.h" + + +#include <AdnDebugMgr.h> +//#define DEBUG_ARM + +#include "stdafx.h" +#include "base/main.h" +#include "be_zodiac.h" +#include "be_os5ex.h" + +GlobalsDataType g_vars; +GlobalsDataPtr gVars = &g_vars; +UInt32 g_stackSize; + +static void palm_main(int argc, char **argvP) { +#ifdef COMPILE_OS5 + if (gVars->advancedMode) + g_system = new OSystem_PalmOS5Ex(); + else + g_system = new OSystem_PalmOS5(); +#elif defined(COMPILE_ZODIAC) + g_system = new OSystem_PalmZodiac(); +#else + #error "No target defined." +#endif + + assert(g_system); + + scummvm_main(argc, argvP); + + g_system->quit(); // TODO: Consider removing / replacing this! +} + +static void Go() { + void *tmp; + char **argvP; + int argc; + +#ifdef DEBUG_ARM +// Tell the debugger we want to enable full debugging + UInt32 flags = AdnDebugEnableGet(); + flags |= kAdnEnableMasterSwitch | kAdnEnableFullDebugging; + AdnDebugEnableSet(flags); +// Tell the debugger where our code lives in memory: + AdnDebugNativeRegister(sysFileTApplication, appFileCreator, 'ARMC', 1); +#endif + + // get global struct + FtrGet(appFileCreator, ftrVars, (UInt32 *)&tmp); + MemMove(gVars, tmp, sizeof(GlobalsDataType)); + + // init STDIO + StdioSetCacheSize(0); + StdioInit(gVars->VFS.volRefNum, "/PALM/Programs/ScummVM/scumm.log"); + if (gVars->indicator.showLED) + StdioSetLedProc(DrawStatus); + StdioSetCacheSize(gVars->VFS.cacheSize); + gUnistdCWD = SCUMMVM_SAVEPATH; + + // get args + FtrGet(appFileCreator, ftrArgsData, (UInt32 *)&argvP); + FtrGet(appFileCreator, ftrArgsCount, (UInt32 *)&argc); + + // init system + WinSetDrawWindow(WinGetDisplayWindow()); + if (HWR_INIT(INIT_VIBRATOR)) gVars->vibrator = RumbleInit(); + + // run ... + DO_EXIT ( palm_main(argc, argvP); ) + + // release + if (HWR_INIT(INIT_VIBRATOR)) RumbleRelease(); + StdioRelease(); + +#ifdef DEBUG_ARM + AdnDebugNativeUnregister(); +#endif +} + +/* Stack size */ + +Int8 *g_newStack, *g_newStackPos; +void *g_oldStack; + +static asm void *StkSwap(void *newStack ,void *dummy) { + mov r1, r13 + mov r13, r0 + mov r0, r1 + bx lr +} + +extern UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { + if (cmd == sysAppLaunchCmdNormalLaunch) { + FtrGet(appFileCreator, ftrStack, &g_stackSize); + if (!g_stackSize) + g_stackSize = 32 * 1024; + + g_newStack = (Int8 *)malloc(g_stackSize + 8); + g_newStackPos = (g_newStack + g_stackSize); + g_newStackPos -= ((UInt32)g_newStackPos & 7); + + g_oldStack = StkSwap(g_newStackPos, 0); + + Go(); + + StkSwap(g_oldStack, 0); + free(g_newStack); + } + + return 0; +} + diff --git a/backends/platform/PalmOS/Src/native/zodiacStartup.cpp b/backends/platform/PalmOS/Src/native/zodiacStartup.cpp new file mode 100644 index 0000000000..64ac89ab5b --- /dev/null +++ b/backends/platform/PalmOS/Src/native/zodiacStartup.cpp @@ -0,0 +1,173 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001-2006 The ScummVM project + * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend + * + * 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. + * + * $URL$ + * $Id$ + * + */ + +#ifdef COMPILE_ZODIAC + +#include <TapWave.h> + +#ifndef __PALMOS_ARMLET__ +#error "__PALMOS_ARMLET__ is not defined!!!" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This variable holds the Tapwave Native Application interface + * dispatch table. General ARM API calls will go through this table. + */ +struct TwGlue* twGlue; +const void* twEmulState; +Call68KFuncType* twCall68KFunc; + +#ifdef __MWERKS__ + +#if __PALMOS_ARMLET__ < 0x120 +#error "You must use CodeWarrior for Palm OS 9.3 or later!!!" +#endif + + +UInt32 __ARMlet_Startup__(const void*, void*, Call68KFuncType*); + +/* + * These symbols aren't real, but are linker-generated symbols that + * mark the start and end of the various data sections. + */ +extern long __DataStart__[]; +extern long __RODataStart__[]; +extern long __BSSStart__[]; +extern long __BSSEnd__[]; +extern long __CodeRelocStart__[]; +extern long __CodeRelocEnd__[]; +extern long __DataRelocStart__[]; +extern long __DataRelocEnd__[]; + +/* + * This function performs relocation for Tapwave Native Application. + */ +static void relocate(void) +{ + // this symbol points to the very beginning of current application + long base = (long) __ARMlet_Startup__; + long *cur, *end; + + // handle code-to-data relocation + cur = __CodeRelocStart__; + end = __CodeRelocEnd__; + for (; cur < end; cur++) { + *(long*)(base + *cur) += base; + } + + // handle data-to-data relocation + cur = __DataRelocStart__; + end = __DataRelocEnd__; + for (; cur < end; cur++) { + *(long*)(base + *cur) += base; + } +} + +/* + * The following functions provide malloc/free support to Metrowerks + * Standard Library (MSL). This feature requires the MSL library be + * built with _MSL_OS_DIRECT_MALLOC enabled. + */ +void* +__sys_alloc(size_t size) +{ + void * ptr = MemPtrNew(size); + ErrFatalDisplayIf(ptr == NULL, "out of memory"); + return ptr; +} + +void +__sys_free(void* ptr) +{ + (void) MemPtrFree(ptr); +} + +size_t +__sys_pointer_size(void* ptr) +{ + return (size_t) MemPtrSize(ptr); +} + +/* + * This is the real entrypoint for Tapwave Native Application. It + * depends on various CodeWarrior 9.2 compiler/linker/runtime features. + */ +static SYSTEM_CALLBACK UInt32 +Startup(const void *emulStateP, void *userData68KP, Call68KFuncType *call68KFuncP) +{ + if (emulStateP) { + twEmulState = emulStateP; + twCall68KFunc = call68KFuncP; + // COMMENT: normal pace native object launch + return PilotMain(sysAppLaunchCmdNormalLaunch, userData68KP, 0); + } else { + // Setup TNA interface dispatch table + twGlue = (struct TwGlue*) userData68KP; + + // OPTIONAL: relocate data segment + relocate(); + + // OPTIONAL: initialize the floating-point library + // _fp_init(); + + return 0; + } +} + +#pragma PIC off +asm UInt32 +__ARMlet_Startup__(const void *emulStateP, void *userData68KP, Call68KFuncType *call68KFuncP) +{ + b Startup // 0 forwarding call + nop // 4 + nop // 8 + nop // 12 + nop // 16 + nop // 20 + nop // 24 + dcd 'TWNA' // 28 Tapwave Native Application + dcd 1 // 32 version 1 + dcd 'cdwr' // 36 make this section the same as the __ARMlet_Startup__ + dcd __DataStart__ // 40 used by CodeWarrior 9.2 + dcd __RODataStart__ // 44 + dcd __BSSStart__ // 48 + dcd __BSSEnd__ // 52 + dcd __CodeRelocStart__ // 56 + dcd __CodeRelocEnd__ // 60 + dcd __DataRelocStart__ // 64 + dcd __DataRelocEnd__ // 68 +} +#pragma PIC reset + +#endif // __MWERKS__ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif |