diff options
author | Chris Apers | 2004-11-09 10:45:47 +0000 |
---|---|---|
committer | Chris Apers | 2004-11-09 10:45:47 +0000 |
commit | 618971dd2fbee8b075b7c888f3abdff8aba47897 (patch) | |
tree | 50350983581f5ba727b372d6dca7b611dcef3994 /backends/PalmOS/Src | |
parent | 463544099832fd8af37b813afc7c3fffc96e78aa (diff) | |
download | scummvm-rg350-618971dd2fbee8b075b7c888f3abdff8aba47897.tar.gz scummvm-rg350-618971dd2fbee8b075b7c888f3abdff8aba47897.tar.bz2 scummvm-rg350-618971dd2fbee8b075b7c888f3abdff8aba47897.zip |
Gathered common functions into new source files
svn-id: r15743
Diffstat (limited to 'backends/PalmOS/Src')
-rw-r--r-- | backends/PalmOS/Src/args.cpp | 69 | ||||
-rw-r--r-- | backends/PalmOS/Src/args.h | 11 | ||||
-rw-r--r-- | backends/PalmOS/Src/init_arm.cpp | 57 | ||||
-rw-r--r-- | backends/PalmOS/Src/init_arm.h | 16 | ||||
-rw-r--r-- | backends/PalmOS/Src/init_mathlib.cpp | 30 | ||||
-rw-r--r-- | backends/PalmOS/Src/init_mathlib.h | 7 | ||||
-rw-r--r-- | backends/PalmOS/Src/init_pa1lib.cpp | 32 | ||||
-rw-r--r-- | backends/PalmOS/Src/init_pa1lib.h | 22 | ||||
-rw-r--r-- | backends/PalmOS/Src/init_palmos.cpp | 44 | ||||
-rw-r--r-- | backends/PalmOS/Src/init_palmos.h | 10 | ||||
-rw-r--r-- | backends/PalmOS/Src/init_sony.cpp | 91 | ||||
-rw-r--r-- | backends/PalmOS/Src/init_sony.h | 10 |
12 files changed, 399 insertions, 0 deletions
diff --git a/backends/PalmOS/Src/args.cpp b/backends/PalmOS/Src/args.cpp new file mode 100644 index 0000000000..5441485067 --- /dev/null +++ b/backends/PalmOS/Src/args.cpp @@ -0,0 +1,69 @@ +#include <PalmOS.h> +#include "args.h" + +Char **ArgsInit() { + MemHandle argvH = MemHandleNew(MAX_ARG * sizeof(Char *)); + Char **argvP = (Char **)MemHandleLock(argvH); + + for(UInt8 count = 0; count < MAX_ARG; count++) + argvP[count] = NULL; + + return argvP; +} + +void ArgsAdd(Char **argvP, const Char *argP, const Char *parmP, UInt8 *countArgP) { + if (argP) { + MemHandle newArg; + UInt16 len2 = 0; + UInt16 len1 = StrLen(argP); + + if (len1 > 0) { + if (parmP) + len2 = StrLen(parmP); + + (*countArgP)++; + newArg = MemHandleNew(len1 + len2 + 1); // +1 = NULL CHAR + *argvP = (Char *)MemHandleLock(newArg); + StrCopy(*argvP, argP); + + if (parmP) + StrCat(*argvP, parmP); + } + } +} + +void ArgsFree(Char **argvP) { + if (!argvP) + return; + + MemHandle oldH; + + for(UInt8 count = 0; count < MAX_ARG; count++) + if (argvP[count]) { + oldH = MemPtrRecoverHandle(argvP[count]); + MemHandleUnlock(oldH); + MemHandleFree(oldH); + } + + oldH = MemPtrRecoverHandle(argvP); + MemHandleUnlock(oldH); + MemHandleFree(oldH); +} + +void ArgsSetOwner(Char **argvP, UInt16 owner) { + if (!argvP) + return; + + MemHandle oldH; + + for(UInt8 count = 0; count < MAX_ARG; count++) + if (argvP[count]) { + oldH = MemPtrRecoverHandle(argvP[count]); + MemHandleSetOwner(oldH, owner); +// MemPtrSetOwner(argvP[count], 0); + } + + oldH = MemPtrRecoverHandle(argvP); + MemHandleSetOwner(oldH, owner); +// MemPtrSetOwner(argvP, 0); +} diff --git a/backends/PalmOS/Src/args.h b/backends/PalmOS/Src/args.h new file mode 100644 index 0000000000..b6b81adafd --- /dev/null +++ b/backends/PalmOS/Src/args.h @@ -0,0 +1,11 @@ +#ifndef ARGS_H +#define ARGS_H + +#define MAX_ARG 25 + +Char **ArgsInit(); +void ArgsAdd(Char **argvP, const Char *argP, const Char *parmP, UInt8 *countArgP); +void ArgsFree(Char **argvP); +void ArgsSetOwner(Char **argvP, UInt16 owner); + +#endif
\ No newline at end of file diff --git a/backends/PalmOS/Src/init_arm.cpp b/backends/PalmOS/Src/init_arm.cpp new file mode 100644 index 0000000000..ca98b21a40 --- /dev/null +++ b/backends/PalmOS/Src/init_arm.cpp @@ -0,0 +1,57 @@ +#include <PalmOS.h> +#include "globals.h" +#include "init_arm.h" + +void ARMInit() { + // init global ARM only + MemSet(gVars->arm, sizeof(gVars->arm), 0); + ARM(PNO_COPYRECT ).pnoPtr = _PnoInit(RSC_COPYRECT, &ARM(PNO_COPYRECT).pnoDesc); + ARM(PNO_COSTUMEPROC3).pnoPtr = _PceInit(RSC_COSTUMEPROC3); + ARM(PNO_DRAWSTRIP ).pnoPtr = _PceInit(RSC_DRAWSTRIP); + ARM(PNO_BLIT ).pnoPtr = _PnoInit(RSC_BLIT, &ARM(PNO_BLIT).pnoDesc); +} + +void ARMRelease() { + _PnoFree(&ARM(PNO_BLIT ).pnoDesc, ARM(PNO_BLIT).pnoPtr); + _PceFree(ARM(PNO_DRAWSTRIP ).pnoPtr); + _PceFree(ARM(PNO_COSTUMEPROC3 ).pnoPtr); + _PnoFree(&ARM(PNO_COPYRECT ).pnoDesc, ARM(PNO_COPYRECT).pnoPtr); +} + +MemPtr _PceInit(DmResID resID) { + MemHandle armH = DmGetResource('ARMC', resID); + NativeFuncType *armP = (NativeFuncType *)MemHandleLock(armH); + + return armP; +} + +UInt32 _PceCall(void *armP, void *userDataP) { + return PceNativeCall((NativeFuncType *)armP, userDataP); +} + +void _PceFree(void *armP) { + MemHandle armH = MemPtrRecoverHandle(armP); + + MemPtrUnlock(armP); + DmReleaseResource(armH); +} + +MemPtr _PnoInit(DmResID resID, PnoDescriptor *pnoP) { + MemHandle armH = DmGetResource('ARMC', resID); + MemPtr armP = MemHandleLock(armH); + PnoLoad(pnoP, armP); + + return armP; +} + +UInt32 _PnoCall(PnoDescriptor *pnoP, void *userDataP) { + return PnoCall(pnoP, userDataP); +} + +void _PnoFree(PnoDescriptor *pnoP, MemPtr armP) { + MemHandle armH = MemPtrRecoverHandle(armP); + + PnoUnload(pnoP); + MemPtrUnlock(armP); + DmReleaseResource(armH); +}
\ No newline at end of file diff --git a/backends/PalmOS/Src/init_arm.h b/backends/PalmOS/Src/init_arm.h new file mode 100644 index 0000000000..04ffbfc52d --- /dev/null +++ b/backends/PalmOS/Src/init_arm.h @@ -0,0 +1,16 @@ +#ifndef INIT_ARM_H +#define INIT_ARM_H + +void ARMInit(); +void ARMRelease(); + +// calls +MemPtr _PceInit(DmResID resID); +UInt32 _PceCall(void *armP, void *userDataP); +void _PceFree(void *armP); + +MemPtr _PnoInit(DmResID resID, PnoDescriptor *pnoP); +UInt32 _PnoCall(PnoDescriptor *pnoP, void *userDataP); +void _PnoFree(PnoDescriptor *pnoP, MemPtr armP); + +#endif
\ No newline at end of file diff --git a/backends/PalmOS/Src/init_mathlib.cpp b/backends/PalmOS/Src/init_mathlib.cpp new file mode 100644 index 0000000000..6fd4931236 --- /dev/null +++ b/backends/PalmOS/Src/init_mathlib.cpp @@ -0,0 +1,30 @@ +#include <PalmOS.h> +#include "enginersc.h" + +#include "globals.h" +#include "init_mathlib.h" +#include "mathlib.h" + +Err MathlibInit() { + Err e; + + if ((e = SysLibFind(MathLibName, &MathLibRef))) + if (e == sysErrLibNotFound) // couldn't find lib + e = SysLibLoad(LibType, MathLibCreator, &MathLibRef); + + if (e) return sysErrLibNotFound; + + e = MathLibOpen(MathLibRef, MathLibVersion); + return e; +} + +void MathlibRelease() { + UInt16 useCount; + + if (MathLibRef != sysInvalidRefNum) { + MathLibClose(MathLibRef, &useCount); + + if (!useCount) + SysLibRemove(MathLibRef); + } +}
\ No newline at end of file diff --git a/backends/PalmOS/Src/init_mathlib.h b/backends/PalmOS/Src/init_mathlib.h new file mode 100644 index 0000000000..1901e1330d --- /dev/null +++ b/backends/PalmOS/Src/init_mathlib.h @@ -0,0 +1,7 @@ +#ifndef INIT_MATHLIB_H +#define INIT_MATHLIB_H + +Err MathlibInit(); +void MathlibRelease(); + +#endif diff --git a/backends/PalmOS/Src/init_pa1lib.cpp b/backends/PalmOS/Src/init_pa1lib.cpp new file mode 100644 index 0000000000..bae109264f --- /dev/null +++ b/backends/PalmOS/Src/init_pa1lib.cpp @@ -0,0 +1,32 @@ +#include <PalmOS.h> +#include <Sonyclie.h> + +#include "pa1lib.h" +#include "init_pa1lib.h" + +void *sndStateOnFuncP = NULL; +void *sndStateOffFuncP = NULL; + +#define SndStateOn(a,b,c) if (sndStateOnFuncP)((sndStateOnType)(sndStateOnFuncP))(a, b, c); +#define SndStateOff(a) if (sndStateOffFuncP)((sndStateOffType)(sndStateOffFuncP))(a); + +void Pa1libInit() { + Pa1Lib_Open(); + + // Doesn't work on T4xx and T6xx series ? + FtrGet(sonySysFtrCreatorSystem, sonySysFtrNumSystemAOutSndStateOnHandlerP, (UInt32*) &sndStateOnFuncP); + FtrGet(sonySysFtrCreatorSystem, sonySysFtrNumSystemAOutSndStateOffHandlerP, (UInt32*) &sndStateOffFuncP); + + SndStateOn(aOutSndKindSp, 31, 31); + SndStateOn(aOutSndKindHp, 31, 31); + + Pa1Lib_devHpVolume(31, 31); + Pa1Lib_devSpVolume(31); +} + +void Pa1libRelease() { + SndStateOff(aOutSndKindSp); + SndStateOff(aOutSndKindHp); + + Pa1Lib_Close(); +}
\ No newline at end of file diff --git a/backends/PalmOS/Src/init_pa1lib.h b/backends/PalmOS/Src/init_pa1lib.h new file mode 100644 index 0000000000..c3ac12b05a --- /dev/null +++ b/backends/PalmOS/Src/init_pa1lib.h @@ -0,0 +1,22 @@ +#ifndef INIT_PA1LIB_H +#define INIT_PA1LIB_H + +// need to move this on a .h file +#define sonySysFileCSystem 'SsYs' /* Sony overall System */ +#define sonySysFtrCreatorSystem sonySysFileCSystem + +#define sonySysFtrNumSystemBase 10000 +#define sonySysFtrNumSystemAOutSndStateOnHandlerP (sonySysFtrNumSystemBase + 4) +#define sonySysFtrNumSystemAOutSndStateOffHandlerP (sonySysFtrNumSystemBase + 5) + +typedef void (*sndStateOnType) (UInt8 /* kind */, UInt8 /* L volume 0-31 */, UInt8 /* R volume 0-31 */); +typedef void (*sndStateOffType) (UInt8 /* kind */); + +/* kind */ +#define aOutSndKindSp (0) /* Speaker volume */ +#define aOutSndKindHp (2) /* HeadPhone volume */ + +void Pa1libInit(); +void Pa1libRelease(); + +#endif
\ No newline at end of file diff --git a/backends/PalmOS/Src/init_palmos.cpp b/backends/PalmOS/Src/init_palmos.cpp new file mode 100644 index 0000000000..8bfcb08627 --- /dev/null +++ b/backends/PalmOS/Src/init_palmos.cpp @@ -0,0 +1,44 @@ +#include <PalmOS.h> + +#include "globals.h" +#include "init_palmos.h" + +static UInt16 autoOffDelay; + +void PalmInit(UInt8 init) { + // set screen depth + UInt32 depth = 8; + WinScreenMode(winScreenModeSet, NULL, NULL, &depth, NULL); + + if (init & INIT_AUTOOFF) { + autoOffDelay = SysSetAutoOffTime(0); + EvtResetAutoOffTimer(); + } + +} + +void PalmRelease(UInt8 init) { + SysSetAutoOffTime(autoOffDelay); + EvtResetAutoOffTimer(); +} + +Err PalmHRInit(UInt32 depth) { + Err e; + UInt32 width = 320; + UInt32 height = 320; + Boolean color = true; + + e = WinScreenMode (winScreenModeSet, &width, &height, &depth, &color); + + if (!e) { + UInt32 attr; + WinScreenGetAttribute(winScreenDensity, &attr); + e = (attr != kDensityDouble); + } + + return e; +} + +void PalmHRRelease() { + // should i do something here ? +}
\ No newline at end of file diff --git a/backends/PalmOS/Src/init_palmos.h b/backends/PalmOS/Src/init_palmos.h new file mode 100644 index 0000000000..135dfcabcb --- /dev/null +++ b/backends/PalmOS/Src/init_palmos.h @@ -0,0 +1,10 @@ +#ifndef INIT_PALMOS_H +#define INIT_PALMOS_H + +void PalmInit(UInt8 init); +void PalmRelease(UInt8 init); + +Err PalmHRInit(UInt32 depth); +void PalmHRRelease(); + +#endif
\ No newline at end of file diff --git a/backends/PalmOS/Src/init_sony.cpp b/backends/PalmOS/Src/init_sony.cpp new file mode 100644 index 0000000000..bdf83e2cf1 --- /dev/null +++ b/backends/PalmOS/Src/init_sony.cpp @@ -0,0 +1,91 @@ +#include <PalmOS.h> +#include <SonyClie.h> +#include "init_sony.h" + +UInt16 SilkInit(UInt32 *retVersion) { + SonySysFtrSysInfoP sonySysFtrSysInfoP; + UInt32 version; + UInt16 slkRefNum; + Err e; + + // Sony HiRes+ + if (!(e = FtrGet(sonySysFtrCreator, sonySysFtrNumSysInfoP, (UInt32*)&sonySysFtrSysInfoP))) { + if (sonySysFtrSysInfoP->libr & sonySysFtrSysInfoLibrSilk) { + + if ((e = SysLibFind(sonySysLibNameSilk, &slkRefNum))) + if (e == sysErrLibNotFound) + e = SysLibLoad(sonySysFileTSilkLib, sonySysFileCSilkLib, &slkRefNum); + + if (!e) { + e = FtrGet(sonySysFtrCreator, sonySysFtrNumVskVersion, &version); + if (e) { + // v1 = NR + e = SilkLibOpen(slkRefNum); + if(!e) version = vskVersionNum1; + + } else { + // v2 = NX/NZ + // v3 = UX... + e = VskOpen(slkRefNum); + } + } + } else + e = sysErrLibNotFound; + } + + if (e) { + version = 0; + slkRefNum = sysInvalidRefNum; + } + + *retVersion = version; + return slkRefNum; +} + +void SilkRelease(UInt16 slkRefNum) { + if (slkRefNum != sysInvalidRefNum) + SilkLibClose(slkRefNum); +} + +UInt16 SonyHRInit(UInt32 depth) { + SonySysFtrSysInfoP sonySysFtrSysInfoP; + Err e; + UInt16 HRrefNum; + + // test if sonyHR is present + if (!(e = FtrGet(sonySysFtrCreator, sonySysFtrNumSysInfoP, (UInt32*)&sonySysFtrSysInfoP))) { + if (sonySysFtrSysInfoP->libr & sonySysFtrSysInfoLibrHR) { // HR available + + if ((e = SysLibFind(sonySysLibNameHR, &HRrefNum))) + if (e == sysErrLibNotFound) // can't find lib + e = SysLibLoad( 'libr', sonySysFileCHRLib, &HRrefNum); + + // Now we can use HR lib. Executes Open library. + if (!e) e = HROpen(HRrefNum); + } + } + + if (e) HRrefNum = sysInvalidRefNum; + + if (HRrefNum != sysInvalidRefNum) { + UInt32 width = hrWidth; + UInt32 height = hrHeight; + Boolean color = true; + + e = HRWinScreenMode(HRrefNum, winScreenModeSet, &width, &height, &depth, &color); + // error ? release and return an invalid reference number + if (e) { + SonyHRRelease(HRrefNum); + HRrefNum = sysInvalidRefNum; + } + } + + return HRrefNum; +} + +void SonyHRRelease(UInt16 HRrefNum) { + if (HRrefNum != sysInvalidRefNum) { + HRClose(HRrefNum); + //SysLibRemove(gVars->HRrefNum); // never call this !! + } +} diff --git a/backends/PalmOS/Src/init_sony.h b/backends/PalmOS/Src/init_sony.h new file mode 100644 index 0000000000..e85352e339 --- /dev/null +++ b/backends/PalmOS/Src/init_sony.h @@ -0,0 +1,10 @@ +#ifndef INIT_SONY_H +#define INIT_SONY_H + +UInt16 SilkInit(UInt32 *retVersion); +void SilkRelease(UInt16 slkRefNum); + +UInt16 SonyHRInit(UInt32 depth); +void SonyHRRelease(UInt16 HRrefNum); + +#endif
\ No newline at end of file |