aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/PalmOS/Src/launcher
diff options
context:
space:
mode:
authorMax Horn2006-07-06 21:44:48 +0000
committerMax Horn2006-07-06 21:44:48 +0000
commit1d8d9f5510dc5f574e926bd6fadb9d20337daede (patch)
tree5cdcf6c8a233159776be9d90f3f39885222f65eb /backends/platform/PalmOS/Src/launcher
parent9269ebe9f5a281f452594f1e8108e31c88a398fb (diff)
downloadscummvm-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/launcher')
-rw-r--r--backends/platform/PalmOS/Src/launcher/app.cpp374
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/formCards.cpp378
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/formCards.h32
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/formEditGame.cpp611
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/formEditGame.h38
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/formMisc.cpp272
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/formSkins.cpp267
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/formUtil.cpp60
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/formUtil.h21
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/forminfo.cpp146
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/formmain.cpp363
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/formmusic.cpp387
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/forms.h22
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/formtabs.cpp242
-rw-r--r--backends/platform/PalmOS/Src/launcher/forms/formtabs.h24
-rw-r--r--backends/platform/PalmOS/Src/launcher/games.cpp530
-rw-r--r--backends/platform/PalmOS/Src/launcher/games.h201
-rw-r--r--backends/platform/PalmOS/Src/launcher/launch.cpp517
-rw-r--r--backends/platform/PalmOS/Src/launcher/skin.cpp611
-rw-r--r--backends/platform/PalmOS/Src/launcher/skin.h130
-rw-r--r--backends/platform/PalmOS/Src/launcher/start.cpp366
-rw-r--r--backends/platform/PalmOS/Src/launcher/start.h97
22 files changed, 5689 insertions, 0 deletions
diff --git a/backends/platform/PalmOS/Src/launcher/app.cpp b/backends/platform/PalmOS/Src/launcher/app.cpp
new file mode 100644
index 0000000000..784ad935c2
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/app.cpp
@@ -0,0 +1,374 @@
+/* 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 <PalmOS.h>
+#include <SonyClie.h>
+
+#include "StarterRsc.h"
+#include "palmdefs.h"
+#include "start.h"
+#include "globals.h"
+#include "rumble.h"
+
+#include "mathlib.h"
+#include "formCards.h"
+#include "games.h"
+#include "extend.h"
+
+#include "modules.h"
+#include "init_mathlib.h"
+#include "init_sony.h"
+#include "init_palmos.h"
+#include "init_stuffs.h"
+
+/***********************************************************************
+ *
+ * FUNCTION: AppStart
+ *
+ * DESCRIPTION: Get the current application's preferences.
+ *
+ * PARAMETERS: nothing
+ *
+ * RETURNED: Err value 0 if nothing went wrong
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+static Err AppStartCheckHRmode()
+{
+ Err e = errNone;
+ UInt32 depth = (OPTIONS_TST(kOptMode16Bit) && OPTIONS_TST(kOptDeviceOS5)) ? 16 : 8;
+
+ // try to init Sony HR mode then Palm HR mode
+ gVars->HRrefNum = SonyHRInit(depth);
+
+ if (gVars->HRrefNum == sysInvalidRefNum) {
+ if (e = PalmHRInit(depth))
+ FrmCustomAlert(FrmErrorAlert,"Your device doesn't seem to support Hi-Res or 256color mode.",0,0);
+ } else {
+ OPTIONS_SET(kOptDeviceClie);
+ }
+
+ return e;
+}
+
+static void AppStopHRMode() {
+ if (gVars->HRrefNum != sysInvalidRefNum)
+ SonyHRRelease(gVars->HRrefNum);
+ else
+ PalmHRRelease();
+}
+
+static Err AppStartCheckNotify() {
+ UInt32 romVersion;
+ Err err;
+
+ err = FtrGet(sysFtrCreator, sysFtrNumNotifyMgrVersion, &romVersion);
+ if (!err) {
+ UInt16 cardNo;
+ LocalID dbID;
+
+ err = SysCurAppDatabase(&cardNo, &dbID);
+ if (!err) {
+ SysNotifyRegister(cardNo, dbID, sysNotifyVolumeMountedEvent, NULL, sysNotifyNormalPriority, NULL);
+ SysNotifyRegister(cardNo, dbID, sysNotifyVolumeUnmountedEvent, NULL, sysNotifyNormalPriority, NULL);
+ SysNotifyRegister(cardNo, dbID, sonySysNotifyMsaEnforceOpenEvent, NULL, sysNotifyNormalPriority, NULL);
+ SysNotifyRegister(cardNo, dbID, sysNotifyDisplayResizedEvent, NULL, sysNotifyNormalPriority, NULL);
+ }
+ }
+
+ return err;
+}
+
+static Err AppStartLoadSkin() {
+ Err err = errNone;
+
+ // if skin defined, check if the db still exists
+ if (gPrefs->skin.dbID) {
+ UInt32 type, creator;
+
+ // check if the DB still exists
+ DmSearchStateType state;
+ UInt16 cardNo;
+ LocalID dbID;
+ Boolean found = false;
+ err = DmGetNextDatabaseByTypeCreator(true, &state, 'skin', appFileCreator, false, &cardNo, &dbID);
+ while (!err && dbID && !found) {
+ found = (cardNo == gPrefs->skin.cardNo && dbID == gPrefs->skin.dbID);
+ err = DmGetNextDatabaseByTypeCreator(false, &state, 'skin', appFileCreator, false, &cardNo, &dbID);
+ }
+
+ if (found) {
+ // remember to check version for next revision of the skin
+ err = DmDatabaseInfo (gPrefs->skin.cardNo, gPrefs->skin.dbID, gPrefs->skin.nameP, 0, 0, 0, 0, 0, 0, 0,0, &type, &creator);
+ if (!err)
+ if (type != 'skin' || creator != appFileCreator)
+ err = dmErrInvalidParam;
+ }
+
+ if (!found || err)
+ MemSet(&(gPrefs->skin),sizeof(SkinInfoType),0);
+ }
+
+ // No skin ? try to get the first one
+ if (!gPrefs->skin.dbID) {
+ DmSearchStateType stateInfo;
+
+ err = DmGetNextDatabaseByTypeCreator(true, &stateInfo, 'skin', appFileCreator, false, &gPrefs->skin.cardNo, &gPrefs->skin.dbID);
+ if (!err)
+ err = DmDatabaseInfo (gPrefs->skin.cardNo, gPrefs->skin.dbID, gPrefs->skin.nameP, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ }
+
+ return err;
+}
+
+static Err AppStartCheckMathLib() {
+ Err e = MathlibInit();
+
+ switch (e) {
+ case errNone:
+ break;
+ case sysErrLibNotFound:
+ FrmCustomAlert(FrmErrorAlert,"Can't find MathLib !",0,0);
+ break;
+ default:
+ FrmCustomAlert(FrmErrorAlert,"Can't open MathLib !",0,0);
+ break;
+ }
+
+ return e;
+}
+
+static void AppStopMathLib() {
+ MathlibRelease();
+}
+
+static void AppStartCheckScreenSize() {
+ Coord sw, sh, fw, fh;
+ UInt8 mode;
+
+ OPTIONS_RST(kOptCollapsible);
+ OPTIONS_RST(kOptModeWide);
+ OPTIONS_RST(kOptModeLandscape);
+
+ // we are on a sony device
+ if (OPTIONS_TST(kOptDeviceClie)) {
+ mode = SonyScreenSize(gVars->HRrefNum, &sw, &sh, &fw, &fh);
+ if (mode) {
+ OPTIONS_SET(kOptModeWide);
+ OPTIONS_SET((mode == SONY_LANDSCAPE) ? kOptModeLandscape : kOptNone);
+ }
+ } else {
+ mode = PalmScreenSize(&sw, &sh, &fw, &fh);
+ if (mode) {
+ OPTIONS_SET(kOptCollapsible);
+ OPTIONS_SET(kOptModeWide);
+ OPTIONS_SET((mode == PALM_LANDSCAPE) ? kOptModeLandscape : kOptNone);
+ }
+ }
+
+ gVars->screenWidth = sw;
+ gVars->screenHeight = sh;
+
+ gVars->screenFullWidth = fw;
+ gVars->screenFullHeight = fh;
+}
+
+#define max(id,value) gVars->memory[id] = (gVars->memory[id] < value ? value : gVars->memory[id])
+#define min(id,value) gVars->memory[id] = (gVars->memory[id] > value ? value : gVars->memory[id])
+#define threshold 700
+
+static void AppStartSetMemory() {
+ UInt32 mem, def;
+ PalmGetMemory(0,0,0,&mem);
+ def = (mem > threshold) ? (mem - threshold) * 1024 : 0;
+ gVars->startupMemory = mem;
+
+ // default values
+ gVars->memory[kMemScummOldCostGames] = (mem >= 550 + threshold) ? 550000 : def;
+ gVars->memory[kMemScummNewCostGames] = (mem >= 2500 + threshold) ? 2500000 : def;
+ gVars->memory[kMemSimon1Games] = (mem >= 1000 + threshold) ? 1000000 : def;
+ gVars->memory[kMemSimon2Games] = (mem >= 2000 + threshold) ? 2000000 : def;
+
+ // set min required values
+ max(kMemScummOldCostGames, 450000);
+ max(kMemScummNewCostGames, 450000);
+ max(kMemSimon1Games, 500000);
+ max(kMemSimon2Games, 500000);
+
+ // set max required values
+ min(kMemScummOldCostGames, 550000);
+ min(kMemScummNewCostGames, 2500000);
+ min(kMemSimon1Games, 1000000);
+ min(kMemSimon2Games, 2000000);
+
+}
+
+#undef threshold
+#undef min
+#undef max
+
+Err AppStart(void) {
+ UInt16 dataSize, checkSize = 0;
+ Err error;
+
+#ifndef _DEBUG_ENGINE
+ // delete old databases
+ ModDelete();
+#endif
+
+ // allocate global variables space
+ dataSize = sizeof(GlobalsDataType);
+ gVars = (GlobalsDataType *)MemPtrNew(dataSize);
+ MemSet(gVars, dataSize, 0);
+
+ gVars->indicator.on = 255;
+ gVars->indicator.off = 0;
+ gVars->HRrefNum = sysInvalidRefNum;
+ gVars->VFS.volRefNum = vfsInvalidVolRef;
+ gVars->slkRefNum = sysInvalidRefNum;
+ gVars->options = kOptNone;
+
+ // set memory required by the differents engines
+ AppStartSetMemory();
+ StuffsGetFeatures();
+
+ // allocate prefs space
+ dataSize = sizeof(GlobalsPreferenceType);
+ gPrefs = (GlobalsPreferenceType *)MemPtrNew(dataSize);
+ MemSet(gPrefs, dataSize, 0);
+
+ // Read the saved preferences / saved-state information.
+ if (PrefGetAppPreferences(appFileCreator, appPrefID, NULL, &checkSize, true) == noPreferenceFound || checkSize != dataSize) {
+ // reset all elements
+ MemSet(gPrefs, dataSize, 0);
+
+ gPrefs->card.volRefNum = vfsInvalidVolRef;
+ gPrefs->card.cacheSize = 4096;
+ gPrefs->card.useCache = true;
+ gPrefs->card.showLED = true;
+
+ gPrefs->autoOff = true;
+ gPrefs->vibrator = RumbleExists();
+ gPrefs->debug = false;
+ gPrefs->exitLauncher = true;
+ gPrefs->stdPalette = OPTIONS_TST(kOptDeviceOS5);
+ gPrefs->stylusClick = true;
+
+ } else {
+ PrefGetAppPreferences(appFileCreator, appPrefID, gPrefs, &dataSize, true);
+ }
+
+ if (!OPTIONS_TST(kOptDeviceARM)) {
+ error = AppStartCheckMathLib();
+ if (error) return (error);
+ }
+
+ error = AppStartCheckHRmode();
+ if (error) return (error);
+
+ bDirectMode = (AppStartLoadSkin() != errNone);
+
+ // if volref previously defined, check if it's a valid one
+ if (gPrefs->card.volRefNum != vfsInvalidVolRef) {
+ VolumeInfoType volInfo;
+ Err err = VFSVolumeInfo(gPrefs->card.volRefNum, &volInfo);
+ if (err)
+ gPrefs->card.volRefNum = parseCards();
+ }
+ else
+ gPrefs->card.volRefNum = parseCards();
+ if (gPrefs->card.volRefNum != vfsInvalidVolRef)
+ CardSlotCreateDirs();
+
+ // open games database
+ error = GamOpenDatabase();
+ if (error) return (error);
+ GamImportDatabase();
+
+ AppStartCheckScreenSize();
+ AppStartCheckNotify(); // not fatal error if not avalaible
+
+ return error;
+}
+
+/***********************************************************************
+ *
+ * FUNCTION: AppStop
+ *
+ * DESCRIPTION: Save the current state of the application.
+ *
+ * PARAMETERS: nothing
+ *
+ * RETURNED: nothing
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+static Err AppStopCheckNotify()
+{
+ UInt32 romVersion;
+ Err err;
+
+ err = FtrGet(sysFtrCreator, sysFtrNumNotifyMgrVersion, &romVersion);
+ if (!err) {
+ UInt16 cardNo;
+ LocalID dbID;
+
+ err = SysCurAppDatabase(&cardNo, &dbID);
+ if (!err) {
+ SysNotifyUnregister(cardNo, dbID, sysNotifyVolumeUnmountedEvent, sysNotifyNormalPriority);
+ SysNotifyUnregister(cardNo, dbID, sysNotifyVolumeMountedEvent, sysNotifyNormalPriority);
+ // sonySysNotifyMsaEnforceOpenEvent
+ SysNotifyUnregister(cardNo, dbID, sysNotifyDisplayResizedEvent, sysNotifyNormalPriority);
+ }
+ }
+
+ return err;
+}
+
+void AppStop(void) {
+ // Close all the open forms.
+ FrmCloseAllForms();
+ WinEraseWindow();
+ WinPalette(winPaletteSetToDefault, 0, 256, NULL);
+
+ // Close and move Game list database
+ GamCloseDatabase(false);
+
+ // Write the saved preferences / saved-state information. This data
+ // will saved during a HotSync backup.
+ SavePrefs();
+
+ // stop all
+ AppStopCheckNotify();
+ if (!OPTIONS_TST(kOptDeviceARM))
+ AppStopMathLib();
+ AppStopHRMode();
+
+ if (!bLaunched)
+ MemPtrFree(gVars);
+}
diff --git a/backends/platform/PalmOS/Src/launcher/forms/formCards.cpp b/backends/platform/PalmOS/Src/launcher/forms/formCards.cpp
new file mode 100644
index 0000000000..1c22ea647a
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/formCards.cpp
@@ -0,0 +1,378 @@
+/* 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 <PalmOS.h>
+#include <VFSMgr.h>
+#include <PmPalmOSNVFS.h>
+
+#include "start.h"
+#include "formTabs.h"
+#include "forms.h"
+#include "globals.h"
+
+typedef struct {
+ UInt16 volRefNum;
+ Char nameP[expCardInfoStringMaxLen+1];
+
+} CardInfoType;
+
+static TabType *myTabP;
+static UInt16 lastTab = 0;
+
+static void CardSlotFormExit(Boolean bSave);
+
+static void CardSlotFreeList() {
+ MemHandle cards = NULL;
+ MemHandle items = NULL;
+
+ if (itemsText && itemsList) {
+ cards = MemPtrRecoverHandle(itemsList);
+ items = MemPtrRecoverHandle(itemsText);
+
+ itemsText = NULL;
+ itemsList = NULL;
+ }
+ itemsType = ITEM_TYPE_UNKNOWN;
+
+ if (items && cards) {
+ MemHandleUnlock(items);
+ MemHandleUnlock(cards);
+ MemHandleFree(items);
+ MemHandleFree(cards);
+ }
+}
+
+static UInt16 CardSlotFillList(Boolean getRefNum = false) {
+ Err err;
+ UInt16 index;
+ UInt16 volRefNum;
+ UInt32 volIterator = vfsIteratorStart|vfsIncludePrivateVolumes;
+ UInt8 counter = 0;
+ UInt32 other = 1;
+
+ MemHandle items = NULL;
+ MemHandle cards = NULL;
+ CardInfoType *cardsInfo;
+
+ // retreive card infos
+ while (volIterator != vfsIteratorStop) {
+ err = VFSVolumeEnumerate(&volRefNum, &volIterator);
+
+ if (!err) {
+ Char labelP[expCardInfoStringMaxLen+1];
+ MemSet(labelP, expCardInfoStringMaxLen+1, 0);
+ err = VFSVolumeGetLabel(volRefNum, labelP, expCardInfoStringMaxLen+1);
+
+ if (err || StrLen(labelP) == 0) { // if no label try to retreive card type
+ VolumeInfoType volInfo;
+ err = VFSVolumeInfo(volRefNum, &volInfo);
+
+ if (!err) {
+ ExpCardInfoType info;
+ err = ExpCardInfo(volInfo.slotRefNum, &info);
+ StrCopy(labelP, info.deviceClassStr);
+ }
+
+ if (err) // if err default name
+ StrPrintF(labelP,"Other Card %ld", other++);
+ }
+
+ if (!cards)
+ cards = MemHandleNew(sizeof(CardInfoType));
+ else
+ MemHandleResize(cards, MemHandleSize(cards) + sizeof(CardInfoType));
+
+ cardsInfo = (CardInfoType *)MemHandleLock(cards);
+ cardsInfo[counter].volRefNum = volRefNum;
+ StrCopy(cardsInfo[counter].nameP, labelP);
+ MemHandleUnlock(cards);
+ counter++;
+ }
+ }
+
+ if (counter > 0) {
+ // set the list items ...
+ if (!getRefNum) {
+ for (index = 0; index < counter; index++) {
+ if (!items)
+ items = MemHandleNew(sizeof(Char *));
+ else
+ MemHandleResize(items, MemHandleSize(items) + sizeof(Char *));
+
+ itemsText = (Char **)MemHandleLock(items);
+ itemsText[index] = cardsInfo[index].nameP;
+ MemHandleUnlock(items);
+ }
+
+ // save globals
+ itemsText = (Char **)MemHandleLock(items);
+ itemsList = (void *)MemHandleLock(cards);
+ itemsType = ITEM_TYPE_CARD;
+
+ // ... or just return a default volRefNum
+ } else {
+ UInt16 volRefNum;
+
+ cardsInfo = (CardInfoType *)MemHandleLock(cards);
+ volRefNum = cardsInfo[0].volRefNum; // return the first volref
+ MemHandleUnlock(cards);
+ MemHandleFree(cards);
+
+ return volRefNum;
+ }
+
+ // no card found ? free old list in any or return invalid volref
+ } else {
+ if (!getRefNum)
+ CardSlotFreeList();
+ else
+ return vfsInvalidVolRef;
+ }
+
+ return counter;
+}
+
+static void ConfigTabInit(Boolean update = false) {
+ ListPtr listP;
+
+ UInt16 index;
+ Int16 selected = -1;
+
+ UInt16 counter = CardSlotFillList();
+ listP = (ListType *)GetObjectPtr(TabCardConfigSlotList);
+
+ // itemsText can be NULL if counter = 0
+ LstSetListChoices (listP, itemsText, counter);
+ if (counter > 0) {
+ CardInfoType *cardsInfo = (CardInfoType *)itemsList;
+
+ for (index = 0; index < counter; index++) {
+ if (cardsInfo[index].volRefNum == gPrefs->card.volRefNum) {
+ selected = index;
+ break;
+ }
+ }
+
+ LstSetSelection(listP, selected);
+ }
+
+ if (!update) {
+ FieldType *fld1P;
+ Char *cacheP;
+ MemHandle cacheH;
+
+ fld1P = (FieldType *)GetObjectPtr(TabCardConfigCacheSizeField);
+ cacheH = MemHandleNew(FldGetMaxChars(fld1P)+1);
+ cacheP = (Char *)MemHandleLock(cacheH);
+ StrIToA(cacheP, gPrefs->card.cacheSize / 1024);
+ MemHandleUnlock(cacheH);
+
+ FldSetTextHandle(fld1P, cacheH);
+ CtlSetValue((ControlType *)GetObjectPtr(TabCardConfigCacheCheckbox), gPrefs->card.useCache);
+ CtlSetValue((ControlType *)GetObjectPtr(TabCardConfigLedCheckbox), gPrefs->card.showLED);
+ // update ? redraw the list
+ } else {
+ WinScreenLock(winLockCopy);
+ LstDrawList(listP);
+ WinScreenUnlock();
+ }
+}
+
+static UInt16 ConfigTabSave() {
+ ControlType *cckP[2];
+ FieldType *fld1P;
+ ListPtr listP;
+ FormPtr frmP;
+ UInt16 updateCode = frmRedrawUpdateMS;
+
+ cckP[0] = (ControlType *)GetObjectPtr(TabCardConfigCacheCheckbox);
+ cckP[1] = (ControlType *)GetObjectPtr(TabCardConfigLedCheckbox);
+
+ gPrefs->card.useCache = CtlGetValue(cckP[0]);
+ gPrefs->card.showLED = CtlGetValue(cckP[1]);
+
+ fld1P = (FieldType *)GetObjectPtr(TabCardConfigCacheSizeField);
+ frmP = FrmGetActiveForm();
+ if (FldGetTextLength(fld1P) == 0 && CtlGetValue(cckP[0]) == 1) {
+ TabSetActive(frmP, myTabP, 0);
+ FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabCardConfigCacheSizeField));
+ FrmCustomAlert(FrmWarnAlert,"You must specified a cache size.",0,0);
+ return 0;
+ }
+ gPrefs->card.cacheSize = StrAToI(FldGetTextPtr(fld1P)) * 1024;
+
+ Int16 selected;
+ CardInfoType *cardsInfo = (CardInfoType *)itemsList;
+
+ listP = (ListType *)GetObjectPtr(TabCardConfigSlotList);
+ selected = LstGetSelection(listP);
+ if (selected == -1) {
+ gPrefs->card.volRefNum = vfsInvalidVolRef;
+ } else if (gPrefs->card.volRefNum != cardsInfo[selected].volRefNum) {
+ updateCode = frmRedrawUpdateMSImport;
+ gPrefs->card.volRefNum = cardsInfo[selected].volRefNum;
+ }
+
+ CardSlotCreateDirs();
+ CardSlotFreeList();
+
+ return updateCode;
+}
+
+static void GameListTabInit() {
+ CtlSetValue((ControlType *)GetObjectPtr(TabCardGameListMoveCheckbox), gPrefs->card.moveDB);
+ CtlSetValue((ControlType *)GetObjectPtr(TabCardGameListDeleteCheckbox), gPrefs->card.deleteDB);
+ CtlSetValue((ControlType *)GetObjectPtr(TabCardGameListConfirmCheckbox), gPrefs->card.confirmMoveDB);
+}
+
+static void GameListTabSave() {
+ ControlType *cckP[3];
+
+ cckP[0] = (ControlType *)GetObjectPtr(TabCardGameListMoveCheckbox);
+ cckP[1] = (ControlType *)GetObjectPtr(TabCardGameListDeleteCheckbox);
+ cckP[2] = (ControlType *)GetObjectPtr(TabCardGameListConfirmCheckbox);
+
+ gPrefs->card.moveDB = CtlGetValue(cckP[0]);
+ gPrefs->card.deleteDB = CtlGetValue(cckP[1]);
+ gPrefs->card.confirmMoveDB = CtlGetValue(cckP[2]);
+}
+
+static void GameListTabDraw() {
+ ControlType *cck1P;
+ FormPtr frmP = FrmGetActiveForm();
+
+ cck1P = (ControlType *)GetObjectPtr(TabCardGameListMoveCheckbox);
+ if (CtlGetValue(cck1P)) {
+ FrmShowObject(frmP, FrmGetObjectIndex (frmP, TabCardGameListDeleteCheckbox));
+ FrmShowObject(frmP, FrmGetObjectIndex (frmP, TabCardGameListConfirmCheckbox));
+ } else {
+ FrmHideObject(frmP, FrmGetObjectIndex (frmP, TabCardGameListDeleteCheckbox));
+ FrmHideObject(frmP, FrmGetObjectIndex (frmP, TabCardGameListConfirmCheckbox));
+ }
+}
+
+static void CardSlotFormInit() {
+ TabType *tabP;
+ FormType *frmP = FrmGetActiveForm();
+
+ tabP = TabNewTabs(2);
+ TabAddContent(&frmP, tabP, "Cards", TabCardConfigForm);
+ TabAddContent(&frmP, tabP, "Game List", TabCardGameListForm, GameListTabDraw);
+
+ ConfigTabInit();
+ GameListTabInit();
+
+ FrmDrawForm(frmP);
+ TabSetActive(frmP, tabP, lastTab);
+
+ myTabP = tabP;
+}
+
+static void CardSlotFormSave() {
+ UInt16 updateCode;
+ updateCode = ConfigTabSave();
+ if (!updateCode) return;
+ GameListTabSave();
+ CardSlotCreateDirs();
+
+ TabDeleteTabs(myTabP);
+ FrmReturnToMain(updateCode);
+}
+
+static void CardSlotFormCancel() {
+ CardSlotFreeList();
+ TabDeleteTabs(myTabP);
+ FrmReturnToMain();
+}
+
+Boolean CardSlotFormHandleEvent(EventPtr eventP) {
+ FormPtr frmP = FrmGetActiveForm();
+ Boolean handled = false;
+
+ switch (eventP->eType) {
+ case frmOpenEvent:
+ CardSlotFormInit();
+ handled = true;
+ break;
+
+ case frmCloseEvent:
+ CardSlotFormCancel();
+ handled = true;
+ break;
+
+ case ctlSelectEvent:
+ switch (eventP->data.ctlSelect.controlID)
+ {
+ case (CardSlotForm + 1) :
+ case (CardSlotForm + 2) :
+ lastTab = (eventP->data.ctlSelect.controlID - CardSlotForm - 1);
+ TabSetActive(frmP, myTabP, lastTab);
+ break;
+
+ case CardSlotOkButton:
+ CardSlotFormSave();
+ break;
+
+ case CardSlotCancelButton:
+ CardSlotFormCancel();
+ break;
+
+ case TabCardGameListMoveCheckbox:
+ GameListTabDraw();
+ break;
+ }
+ handled = true;
+ break;
+
+ default:
+ break;
+ }
+
+ return handled;
+}
+
+void CardSlotCreateDirs() {
+ if (gPrefs->card.volRefNum != vfsInvalidVolRef) {
+ VFSDirCreate(gPrefs->card.volRefNum, "/PALM");
+ VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs");
+ VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs/ScummVM");
+ VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs/ScummVM/Games");
+ VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs/ScummVM/Saved");
+ VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs/ScummVM/Audio");
+ VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs/ScummVM/Mods");
+ }
+}
+
+void CardSlotFormUpdate() {
+ if (itemsType == ITEM_TYPE_CARD) {
+ CardSlotFreeList();
+ ConfigTabInit(true);
+ }
+}
+
+UInt16 parseCards() {
+ UInt16 volRefNum = CardSlotFillList(true);
+ CardSlotFreeList();
+ return volRefNum;
+}
diff --git a/backends/platform/PalmOS/Src/launcher/forms/formCards.h b/backends/platform/PalmOS/Src/launcher/forms/formCards.h
new file mode 100644
index 0000000000..956ef86340
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/formCards.h
@@ -0,0 +1,32 @@
+/* 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 __FORMCARDS_H__
+#define __FORMCARDS_H__
+
+UInt16 parseCards();
+void CardSlotFormUpdate();
+void CardSlotCreateDirs();
+
+#endif
diff --git a/backends/platform/PalmOS/Src/launcher/forms/formEditGame.cpp b/backends/platform/PalmOS/Src/launcher/forms/formEditGame.cpp
new file mode 100644
index 0000000000..42953ad15e
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/formEditGame.cpp
@@ -0,0 +1,611 @@
+/* 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 <PalmOS.h>
+#include <VFSMgr.h>
+#include <FileBrowserLibCommon.h>
+#include <FileBrowserLib68K.h>
+
+#include "formTabs.h"
+#include "forms.h"
+
+#include "start.h"
+#include "games.h"
+#include "skin.h"
+
+#define errBadParam 0x1000
+
+static TabType *myTabP;
+static UInt16 lastTab = 0;
+
+UInt8 gFormEditMode;
+
+static void GameTabInit(GameInfoType *gameInfoP) {
+ FieldType *fld1P, *fld2P, *fld3P;
+ Char *nameP, *pathP, *gameP;
+ MemHandle nameH, pathH, gameH;
+ ListType *list1P;
+
+ list1P = (ListType *)GetObjectPtr(TabGameInfoEngineList);
+
+ itemsText = (Char **)MemPtrNew(ENGINE_COUNT * sizeof(Char *));
+ for (int i = 0; i < ENGINE_COUNT; i++)
+ itemsText[i] = (Char *)engines[i].nameP;
+ LstSetListChoices(list1P, itemsText, ENGINE_COUNT);
+
+ fld1P = (FieldType *)GetObjectPtr(TabGameInfoEntryNameField);
+ fld2P = (FieldType *)GetObjectPtr(TabGameInfoPathField);
+ fld3P = (FieldType *)GetObjectPtr(TabGameInfoGameField);
+
+ nameH = MemHandleNew(FldGetMaxChars(fld1P)+1);
+ pathH = MemHandleNew(FldGetMaxChars(fld2P)+1);
+ gameH = MemHandleNew(FldGetMaxChars(fld3P)+1);
+
+ nameP = (Char *)MemHandleLock(nameH);
+ pathP = (Char *)MemHandleLock(pathH);
+ gameP = (Char *)MemHandleLock(gameH);
+
+ if (gameInfoP) {
+ LstSetSelection(list1P, gameInfoP->engine);
+ LstSetTopItem(list1P, gameInfoP->engine);
+ StrCopy(nameP, gameInfoP->nameP);
+ StrCopy(pathP, gameInfoP->pathP);
+ StrCopy(gameP, gameInfoP->gameP);
+ } else {
+ LstSetSelection(list1P, 0);
+ MemSet(nameP,MemHandleSize(nameH),0);
+ MemSet(pathP,MemHandleSize(pathH),0);
+ MemSet(gameP,MemHandleSize(gameH),0);
+ }
+
+ CtlSetLabel((ControlType *)GetObjectPtr(TabGameInfoEnginePopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+
+ MemHandleUnlock(nameH);
+ MemHandleUnlock(pathH);
+ MemHandleUnlock(gameH);
+
+ FldSetTextHandle(fld1P, nameH);
+ FldSetTextHandle(fld2P, pathH);
+ FldSetTextHandle(fld3P, gameH);
+}
+
+static Err GameTabSave(GameInfoType *gameInfoP) {
+ FieldType *fld1P, *fld2P, *fld3P;
+ ListType *list1P;
+
+ FormType *frmP = FrmGetActiveForm();
+ list1P = (ListType *)GetObjectPtr(TabGameInfoEngineList);
+
+ fld1P = (FieldType *)GetObjectPtr(TabGameInfoEntryNameField);
+ fld2P = (FieldType *)GetObjectPtr(TabGameInfoPathField);
+ fld3P = (FieldType *)GetObjectPtr(TabGameInfoGameField);
+
+ FldTrimText(fld1P);
+ FldTrimText(fld2P);
+ FldTrimText(fld3P);
+
+ // test case
+ if (!gameInfoP) {
+ if (FldGetTextLength(fld1P) == 0) {
+ FrmCustomAlert(FrmWarnAlert,"You must specify an entry name.",0,0);
+ TabSetActive(frmP, myTabP, 0);
+ FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabGameInfoEntryNameField));
+ return errBadParam;
+
+ } else if (FldGetTextLength(fld2P) == 0) {
+ FrmCustomAlert(FrmWarnAlert,"You must specify a path.",0,0);
+ TabSetActive(frmP, myTabP, 0);
+ FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabGameInfoPathField));
+ return errBadParam;
+
+ } else if (FldGetTextLength(fld3P) == 0) {
+ FrmCustomAlert(FrmWarnAlert,"You must specify a game.",0,0);
+ TabSetActive(frmP, myTabP, 0);
+ FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabGameInfoGameField));
+ return errBadParam;
+ }
+
+ } else {
+ gameInfoP->engine = LstGetSelection(list1P);
+ StrCopy(gameInfoP->nameP, FldGetTextPtr(fld1P));
+ StrCopy(gameInfoP->pathP, FldGetTextPtr(fld2P));
+ StrCopy(gameInfoP->gameP, FldGetTextPtr(fld3P));
+
+ if (gameInfoP->pathP[StrLen(gameInfoP->pathP)-1] != '/')
+ StrCat(gameInfoP->pathP, "/");
+
+ MemPtrFree(itemsText);
+ itemsText = NULL;
+ }
+
+ return errNone;
+}
+
+static void DisplayInit(GameInfoType *gameInfoP) {
+ ListType *list1P, *list2P;
+
+ list1P = (ListType *)GetObjectPtr(TabGameDisplayGfxListList);
+ list2P = (ListType *)GetObjectPtr(TabGameDisplayRenderList);
+
+ if (gameInfoP) {
+ LstSetSelection(list1P, gameInfoP->gfxMode);
+ LstSetSelection(list2P, gameInfoP->renderMode);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameDisplayFilterCheckbox), gameInfoP->filter);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameDisplayFullscreenCheckbox), gameInfoP->fullscreen);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameDisplayAspectRatioCheckbox), gameInfoP->aspectRatio);
+
+ } else {
+ LstSetSelection(list1P, 0);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameDisplayFilterCheckbox), 0);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameDisplayFullscreenCheckbox), 0);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameDisplayAspectRatioCheckbox), 0);
+ }
+
+ CtlSetLabel((ControlType *)GetObjectPtr(TabGameDisplayGfxPopupPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+ CtlSetLabel((ControlType *)GetObjectPtr(TabGameDisplayRenderPopTrigger), LstGetSelectionText(list2P, LstGetSelection(list2P)));
+}
+
+static Err DisplaySave(GameInfoType *gameInfoP) {
+ ListType *list1P, *list2P;
+ ControlType *cck6P, *cck7P, *cck8P;
+
+ FormType *frmP = FrmGetActiveForm();
+
+ list1P = (ListType *)GetObjectPtr(TabGameDisplayGfxListList);
+ list2P = (ListType *)GetObjectPtr(TabGameDisplayRenderList);
+ cck6P = (ControlType *)GetObjectPtr(TabGameDisplayFilterCheckbox);
+ cck7P = (ControlType *)GetObjectPtr(TabGameDisplayFullscreenCheckbox);
+ cck8P = (ControlType *)GetObjectPtr(TabGameDisplayAspectRatioCheckbox);
+
+ if (!gameInfoP) {
+ } else {
+ gameInfoP->gfxMode = LstGetSelection(list1P);
+ gameInfoP->renderMode = LstGetSelection(list2P);
+ gameInfoP->filter = CtlGetValue(cck6P);
+ gameInfoP->fullscreen = CtlGetValue(cck7P);
+ gameInfoP->aspectRatio = CtlGetValue(cck8P);
+ }
+
+ return errNone;
+}
+
+static void OptionsInit(GameInfoType *gameInfoP) {
+ ListType *list2P, *list3P;
+ FieldType *fld4P, *fld5P, *fld6P;
+ Char *loadP, *roomP, *talkP;
+ MemHandle loadH, roomH, talkH;
+
+ list2P = (ListType *)GetObjectPtr(TabGameOptionsLanguageList);
+ list3P = (ListType *)GetObjectPtr(TabGameOptionsPlatformList);
+
+ fld4P = (FieldType *)GetObjectPtr(TabGameOptionsLoadSlotField);
+ fld5P = (FieldType *)GetObjectPtr(TabGameOptionsStartRoomField);
+ fld6P = (FieldType *)GetObjectPtr(TabGameOptionsTalkSpeedField);
+
+ loadH = MemHandleNew(FldGetMaxChars(fld4P)+1);
+ roomH = MemHandleNew(FldGetMaxChars(fld5P)+1);
+ talkH = MemHandleNew(FldGetMaxChars(fld6P)+1);
+
+ loadP = (Char *)MemHandleLock(loadH);
+ roomP = (Char *)MemHandleLock(roomH);
+ talkP = (Char *)MemHandleLock(talkH);
+
+ if (gameInfoP) {
+ LstSetSelection(list2P, gameInfoP->language);
+ LstSetTopItem(list2P, gameInfoP->language);
+ LstSetSelection(list3P, gameInfoP->platform);
+ LstSetTopItem(list3P, gameInfoP->platform);
+
+ StrIToA(loadP, gameInfoP->loadSlot);
+ StrIToA(roomP, gameInfoP->bootValue);
+ StrIToA(talkP, gameInfoP->talkValue);
+
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameOptionsLoadSlotCheckbox), gameInfoP->autoLoad);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameOptionsStartRoomCheckbox), gameInfoP->bootParam);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameOptionsAmigaCheckbox), gameInfoP->setPlatform);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameOptionsSubtitlesCheckbox), gameInfoP->subtitles);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameOptionsTalkSpeedCheckbox), gameInfoP->talkSpeed);
+
+ } else {
+ LstSetSelection(list2P, 0);
+ LstSetSelection(list3P, 0);
+
+ StrIToA(loadP, 0);
+ StrIToA(roomP, 0);
+ StrIToA(talkP, 60);
+
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameOptionsLoadSlotCheckbox), 0);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameOptionsStartRoomCheckbox), 0);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameOptionsAmigaCheckbox), 0);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameOptionsSubtitlesCheckbox), 1);
+ CtlSetValue((ControlType *)GetObjectPtr(TabGameOptionsTalkSpeedCheckbox), 0);
+ }
+
+ MemHandleUnlock(loadH);
+ MemHandleUnlock(roomH);
+ MemHandleUnlock(talkH);
+
+ FldSetTextHandle(fld4P, loadH);
+ FldSetTextHandle(fld5P, roomH);
+ FldSetTextHandle(fld6P, talkH);
+
+ CtlSetLabel((ControlType *)GetObjectPtr(TabGameOptionsLanguagePopTrigger), LstGetSelectionText(list2P, LstGetSelection(list2P)));
+ CtlSetLabel((ControlType *)GetObjectPtr(TabGameOptionsPlatformPopTrigger), LstGetSelectionText(list3P, LstGetSelection(list3P)));
+}
+
+static Err OptionsSave(GameInfoType *gameInfoP) {
+ FieldType *fld4P, *fld5P, *fld6P;
+ ControlType *cck1P, *cck2P, *cck3P, *cck4P, *cck5P;
+ ListType *list2P, *list3P;
+
+ FormType *frmP = FrmGetActiveForm();
+
+ list2P = (ListType *)GetObjectPtr(TabGameOptionsLanguageList);
+ list3P = (ListType *)GetObjectPtr(TabGameOptionsPlatformList);
+
+ fld4P = (FieldType *)GetObjectPtr(TabGameOptionsLoadSlotField);
+ fld5P = (FieldType *)GetObjectPtr(TabGameOptionsStartRoomField);
+ fld6P = (FieldType *)GetObjectPtr(TabGameOptionsTalkSpeedField);
+
+ cck1P = (ControlType *)GetObjectPtr(TabGameOptionsLoadSlotCheckbox);
+ cck2P = (ControlType *)GetObjectPtr(TabGameOptionsStartRoomCheckbox);
+ cck3P = (ControlType *)GetObjectPtr(TabGameOptionsAmigaCheckbox);
+ cck4P = (ControlType *)GetObjectPtr(TabGameOptionsSubtitlesCheckbox);
+ cck5P = (ControlType *)GetObjectPtr(TabGameOptionsTalkSpeedCheckbox);
+
+ if (!gameInfoP) {
+ if (FldGetTextLength(fld5P) == 0 && CtlGetValue(cck2P) == 1) {
+ FrmCustomAlert(FrmWarnAlert,"You must specify a room number.",0,0);
+ TabSetActive(frmP, myTabP, 2);
+ FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabGameOptionsStartRoomField));
+ return errBadParam;
+
+ } else if (FldGetTextLength(fld6P) == 0 && CtlGetValue(cck5P) == 1) {
+ FrmCustomAlert(FrmWarnAlert,"You must specify a talk speed.",0,0);
+ TabSetActive(frmP, myTabP, 2);
+ FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabGameOptionsTalkSpeedField));
+ return errBadParam;
+ }
+ } else {
+ gameInfoP->language = LstGetSelection(list2P);
+ gameInfoP->platform = LstGetSelection(list3P);
+
+ gameInfoP->autoLoad = CtlGetValue(cck1P);
+ gameInfoP->bootParam = CtlGetValue(cck2P);
+ gameInfoP->setPlatform = CtlGetValue(cck3P);
+ gameInfoP->subtitles = (CtlGetValue(cck4P));
+ gameInfoP->talkSpeed = CtlGetValue(cck5P);
+
+ gameInfoP->loadSlot = StrAToI(FldGetTextPtr(fld4P));
+ gameInfoP->bootValue = StrAToI(FldGetTextPtr(fld5P));
+ gameInfoP->talkValue = StrAToI(FldGetTextPtr(fld6P));
+ }
+
+ return errNone;
+}
+
+static void GameManInit(UInt16 index) {
+ TabType *tabP;
+ FormType *frmP = FrmGetActiveForm();
+ UInt16 active = lastTab;
+
+ tabP = TabNewTabs(3);
+ TabAddContent(&frmP, tabP, "Game", TabGameInfoForm);
+ TabAddContent(&frmP, tabP, "Display", TabGameDisplayForm);
+ TabAddContent(&frmP, tabP, "Options", TabGameOptionsForm);
+
+ UInt16 refNum;
+ if (SysLibFind(kFileBrowserLibName, &refNum))
+ FrmRemoveObject(&frmP, FrmGetObjectIndex(frmP, TabGameInfoBrowsePushButton));
+
+ if (index != dmMaxRecordIndex) {
+ MemHandle recordH = NULL;
+ GameInfoType *gameInfoP;
+
+ recordH = DmQueryRecord(gameDB, index);
+ gameInfoP = (GameInfoType *)MemHandleLock(recordH);
+
+ GameTabInit(gameInfoP);
+ DisplayInit(gameInfoP);
+ OptionsInit(gameInfoP);
+
+ MemHandleUnlock(recordH);
+ CtlSetUsable((ControlType *)GetObjectPtr(GameEditDeleteButton),true);
+ } else {
+ active = 0; // new game ? start with first tab
+ GameTabInit(0);
+ DisplayInit(0);
+ OptionsInit(0);
+ CtlSetUsable((ControlType *)GetObjectPtr(GameEditDeleteButton),false);
+ }
+
+ FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabGameInfoEntryNameField));
+ FrmDrawForm(frmP);
+ TabSetActive(frmP, tabP, active);
+
+ myTabP = tabP;
+}
+
+static void GameManSave(UInt16 index) {
+ MemHandle recordH;
+ GameInfoType *gameInfoP, newGameInfo;
+
+ if (GameTabSave(0) == errBadParam) return;
+ if (DisplaySave(0) == errBadParam) return;
+ if (OptionsSave(0) == errBadParam) return;
+
+ if (index != dmMaxRecordIndex) {
+ recordH = DmGetRecord(gameDB, index);
+ gameInfoP = (GameInfoType *)MemHandleLock(recordH);
+ MemMove(&newGameInfo, gameInfoP, sizeof(GameInfoType));
+
+ } else {
+ index = dmMaxRecordIndex;
+ GamUnselect();
+ recordH = DmNewRecord(gameDB, &index, sizeof(GameInfoType));
+ gameInfoP = (GameInfoType *)MemHandleLock(recordH);
+
+ MemSet(&newGameInfo, sizeof(GameInfoType), 0);
+ newGameInfo.version = curItemVersion;
+ newGameInfo.icnID = 0xFFFF;
+ newGameInfo.selected = true;
+
+ // default sound data
+ newGameInfo.musicInfo.volume.palm = 50;
+ newGameInfo.musicInfo.volume.music = 192;
+ newGameInfo.musicInfo.volume.sfx = 192;
+ newGameInfo.musicInfo.volume.speech = 192;
+ newGameInfo.musicInfo.volume.audiocd = 50;
+
+ newGameInfo.musicInfo.sound.tempo = 100;
+ newGameInfo.musicInfo.sound.defaultTrackLength = 10;
+ newGameInfo.musicInfo.sound.firstTrack = 1;
+ }
+
+ GameTabSave(&newGameInfo);
+ DisplaySave(&newGameInfo);
+ OptionsSave(&newGameInfo);
+
+ DmWrite(gameInfoP, 0, &newGameInfo, sizeof(GameInfoType));
+
+ MemHandleUnlock(recordH);
+ DmReleaseRecord (gameDB, index, 0);
+ GamSortList();
+ // update list position
+ {
+ RectangleType rArea;
+ UInt16 posIndex, maxView;
+
+ // get the sorted index
+ index = GamGetSelected();
+ // if new item is out of the list bounds, change current list pos
+ SknGetListBounds(&rArea, NULL);
+ maxView = rArea.extent.y / sknInfoListItemSize;
+ posIndex = gPrefs->listPosition;
+
+ // if out of the current list position
+ if (!(index >= posIndex && index < (posIndex + maxView)))
+ gPrefs->listPosition = index; // this value is corrected in SknUpdateList if needed
+ }
+
+ TabDeleteTabs(myTabP);
+ FrmReturnToMain();
+ SknUpdateList();
+}
+
+/***********************************************************************
+ *
+ * FUNCTION: EditGameFormSave
+ * FUNCTION: EditGameFormInit
+ * FUNCTION: EditGameFormHandleEvent
+ *
+ * DESCRIPTION:
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+void EditGameFormDelete(Boolean direct) {
+ UInt16 index = GamGetSelected();
+
+ if (index == dmMaxRecordIndex) {
+ FrmCustomAlert(FrmWarnAlert, "Select an entry first.",0,0);
+ return;
+
+ } else if (FrmCustomAlert(FrmConfirmAlert, "Do you really want to delete this entry ?", 0, 0) == FrmConfirmYes) {
+ DmRemoveRecord(gameDB, index);
+ if (!direct) {
+ TabDeleteTabs(myTabP);
+ FrmReturnToMain();
+ }
+ GamSortList();
+ SknUpdateList();
+ }
+}
+
+static void EditGameCancel() {
+ if (itemsText) {
+ MemPtrFree(itemsText);
+ itemsText = NULL;
+ }
+ TabDeleteTabs(myTabP);
+ FrmReturnToMain();
+}
+
+static void EditGameBowser() {
+ UInt16 refNum;
+ Err e;
+
+ ControlPtr butP = (ControlType *)GetObjectPtr(TabGameInfoBrowsePushButton);
+ CtlSetValue(butP, 0);
+
+ e = SysLibFind (kFileBrowserLibName, &refNum);
+ if (!e) {
+ e = FileBrowserLibOpen (refNum);
+ if (!e) {
+ UInt16 volRefNum = gPrefs->card.volRefNum;
+ Char *textP, *pathP = (Char *)MemPtrNew(kFileBrowserLibPathBufferSize);
+ pathP[0] = chrNull;
+
+ if (FileBrowserLibShowOpenDialog(refNum, &volRefNum, pathP, 0, 0, 0, "Game Data Path", kFileBrowserLibFlagNoFiles)) {
+ FieldPtr fldP;
+ MemHandle textH;
+ Int16 offset, copySize, maxSize;
+
+ fldP = (FieldType *)GetObjectPtr(TabGameInfoPathField);
+ maxSize = FldGetMaxChars(fldP);
+ textH = FldGetTextHandle(fldP);
+
+ FldSetTextHandle(fldP, NULL);
+ textP = (Char *)MemHandleLock(textH);
+ offset = 0;
+ copySize = StrLen(pathP);
+
+ if (StrNCaselessCompare(pathP, "/Palm/Programs/ScummVM/Games/", 29) == 0) {
+ if (StrLen(pathP) == 29) {
+ copySize = 1;
+ pathP[0] = '.';
+ } else {
+ copySize -= 29;
+ offset = 29;
+ }
+ }
+
+ if (copySize > maxSize)
+ copySize = maxSize;
+ StrNCopy(textP, pathP + offset, copySize);
+
+ MemHandleUnlock(textH);
+ FldSetTextHandle(fldP, textH);
+ FldDrawField(fldP);
+ FldGrabFocus(fldP);
+ }
+
+ MemPtrFree(pathP);
+ FileBrowserLibClose(refNum);
+ }
+ }
+}
+
+Boolean EditGameFormHandleEvent(EventPtr eventP) {
+ FormPtr frmP = FrmGetActiveForm();
+ Boolean handled = false;
+
+ switch (eventP->eType) {
+ case frmCloseEvent:
+ EditGameCancel();
+ handled = true;
+ break;
+
+ case frmOpenEvent:
+ switch (gFormEditMode) {
+ case edtModeAdd:
+ GameManInit(dmMaxRecordIndex);
+ break;
+ case edtModeEdit:
+ case edtModeParams:
+ default :
+ GameManInit(GamGetSelected());
+ break;
+ }
+ handled = true;
+ break;
+
+ case keyDownEvent:
+ switch (eventP->data.keyDown.chr) {
+ case chrLineFeed:
+ case chrCarriageReturn:
+ return true;
+ }
+ break;
+
+ case ctlSelectEvent:
+ switch (eventP->data.ctlSelect.controlID)
+ {
+ case (GameEditForm + 1) :
+ case (GameEditForm + 2) :
+ case (GameEditForm + 3) :
+ lastTab = (eventP->data.ctlSelect.controlID - GameEditForm - 1);
+ TabSetActive(frmP, myTabP, lastTab);
+ break;
+
+ case GameEditOKButton:
+ switch (gFormEditMode) {
+ case edtModeAdd:
+ GameManSave(dmMaxRecordIndex);
+ break;
+ case edtModeEdit:
+ case edtModeParams:
+ default :
+ GameManSave(GamGetSelected());
+ break;
+ }
+ break;
+
+ case GameEditCancelButton:
+ EditGameCancel();
+ break;
+
+ case GameEditDeleteButton:
+ EditGameFormDelete(false);
+ break;
+
+ case TabGameInfoBrowsePushButton:
+ EditGameBowser();
+ break;
+
+ case TabGameInfoEnginePopTrigger:
+ FrmList(eventP, TabGameInfoEngineList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabGameInfoEngineList));
+ break;
+
+ case TabGameDisplayGfxPopupPopTrigger:
+ FrmList(eventP, TabGameDisplayGfxListList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabGameDisplayGfxListList));
+ break;
+
+ case TabGameDisplayRenderPopTrigger:
+ FrmList(eventP, TabGameDisplayRenderList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabGameDisplayRenderList));
+ break;
+
+ case TabGameOptionsLanguagePopTrigger:
+ FrmList(eventP, TabGameOptionsLanguageList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabGameOptionsLanguageList));
+ break;
+
+ case TabGameOptionsPlatformPopTrigger:
+ FrmList(eventP, TabGameOptionsPlatformList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabGameOptionsPlatformList));
+ break;
+ }
+ handled = true;
+ break;
+
+ default:
+ break;
+ }
+
+ return handled;
+}
diff --git a/backends/platform/PalmOS/Src/launcher/forms/formEditGame.h b/backends/platform/PalmOS/Src/launcher/forms/formEditGame.h
new file mode 100644
index 0000000000..2e76e7ebb5
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/formEditGame.h
@@ -0,0 +1,38 @@
+/* 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 __FORMEDITGAME_H__
+#define __FORMEDITGAME_H__
+
+// edit game mode
+enum {
+ edtModeAdd,
+ edtModeEdit,
+ edtModeParams
+};
+
+extern UInt8 gFormEditMode;
+void EditGameFormDelete(Boolean direct);
+
+#endif
diff --git a/backends/platform/PalmOS/Src/launcher/forms/formMisc.cpp b/backends/platform/PalmOS/Src/launcher/forms/formMisc.cpp
new file mode 100644
index 0000000000..9b4009294c
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/formMisc.cpp
@@ -0,0 +1,272 @@
+/* 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 <PalmOS.h>
+
+#include "start.h"
+#include "formTabs.h"
+#include "forms.h"
+#include "globals.h"
+
+static TabType *myTabP;
+static UInt16 lastTab = 0;
+
+static Boolean ScummVMTabSave() {
+ FieldType *fld1P, *fld2P;
+ ControlType *cckP[11];
+ FormPtr frmP;
+
+ fld1P = (FieldType *)GetObjectPtr(TabMiscScummVMDebugLevelField);
+ fld2P = (FieldType *)GetObjectPtr(TabMiscScummVMAutosaveField);
+
+ cckP[0] = (ControlType *)GetObjectPtr(TabMiscScummVMAutosaveCheckbox);
+ cckP[3] = (ControlType *)GetObjectPtr(TabMiscScummVMDebugCheckbox);
+ cckP[6] = (ControlType *)GetObjectPtr(TabMiscScummVMDemoCheckbox);
+ cckP[9] = (ControlType *)GetObjectPtr(TabMiscScummVMCopyProtectionCheckbox);
+ cckP[10]= (ControlType *)GetObjectPtr(TabMiscScummVMAltIntroCheckbox);
+
+ frmP = FrmGetActiveForm();
+ if (FldGetTextLength(fld1P) == 0 && CtlGetValue(cckP[3]) == 1) {
+ TabSetActive(frmP, myTabP, 1);
+ FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabMiscScummVMDebugLevelField));
+ FrmCustomAlert(FrmWarnAlert,"You must specify a debug level.",0,0);
+ return false;
+
+ } else if (FldGetTextLength(fld2P) == 0 && CtlGetValue(cckP[0]) == 1) {
+ TabSetActive(frmP, myTabP, 1);
+ FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabMiscScummVMAutosaveField));
+ FrmCustomAlert(FrmWarnAlert,"You must specify a period.",0,0);
+ return false;
+ }
+
+ gPrefs->autoSave = CtlGetValue(cckP[0]);
+ gPrefs->debug = CtlGetValue(cckP[3]);
+ gPrefs->demoMode = CtlGetValue(cckP[6]);
+ gPrefs->copyProtection = CtlGetValue(cckP[9]);
+ gPrefs->altIntro = CtlGetValue(cckP[10]);
+
+ gPrefs->debugLevel = StrAToI(FldGetTextPtr(fld1P));
+ gPrefs->autoSavePeriod = StrAToI(FldGetTextPtr(fld2P));
+
+ return true;
+}
+
+static void PalmOSTabSave() {
+ ControlType *cckP[11];
+
+ if (OPTIONS_TST(kOptDeviceARM) && !OPTIONS_TST(kOptDeviceZodiac)) {
+ cckP[3]= (ControlType *)GetObjectPtr(TabMiscPalmOSAdvancedCheckbox);
+ gPrefs->advancedMode = CtlGetValue(cckP[3]);
+ }
+
+ if (!OPTIONS_TST(kOptDeviceARM)) {
+ cckP[2] = (ControlType *)GetObjectPtr(TabMiscPalmOSStdPaletteCheckbox);
+ gPrefs->stdPalette = CtlGetValue(cckP[2]);
+ }
+
+ cckP[0] = (ControlType *)GetObjectPtr(TabMiscPalmOSVibratorCheckbox);
+ cckP[1] = (ControlType *)GetObjectPtr(TabMiscPalmOSNoAutoOffCheckbox);
+ cckP[4] = (ControlType *)GetObjectPtr(TabMiscPalmOSLargerStackCheckbox);
+ cckP[5] = (ControlType *)GetObjectPtr(TabMiscPalmOSExitLauncherCheckbox);
+ cckP[6] = (ControlType *)GetObjectPtr(TabMiscPalmOSStylusClickCheckbox);
+ cckP[7] = (ControlType *)GetObjectPtr(TabMiscPalmOSArrowCheckbox);
+
+ gPrefs->vibrator = CtlGetValue(cckP[0]);
+ gPrefs->autoOff = !CtlGetValue(cckP[1]);
+ gPrefs->setStack = CtlGetValue(cckP[4]);
+ gPrefs->exitLauncher = CtlGetValue(cckP[5]);
+ gPrefs->stylusClick = !CtlGetValue(cckP[6]);
+ gPrefs->arrowKeys = CtlGetValue(cckP[7]);
+}
+
+static void ExtsTabSave() {
+ ControlType *cckP[2];
+
+ if (OPTIONS_TST(kOptLightspeedAPI)) {
+ ListType *list1P = (ListType *)GetObjectPtr(TabMiscExtsLightspeedList);
+ cckP[0] = (ControlType *)GetObjectPtr(TabMiscExtsLightspeedCheckbox);
+
+ gPrefs->lightspeed.enable = CtlGetValue(cckP[0]);
+ gPrefs->lightspeed.mode = LstGetSelection(list1P);
+ }
+ if (OPTIONS_TST(kOptGoLcdAPI)) {
+ cckP[1] = (ControlType *)GetObjectPtr(TabMiscExtsGolcdCheckbox);
+ gPrefs->goLCD = CtlGetValue(cckP[1]);
+ }
+}
+
+static void ScummVMTabInit() {
+ FieldType *fld1P, *fld2P;
+ Char *levelP, *periodP;
+ MemHandle levelH, periodH;
+
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscScummVMAutosaveCheckbox), gPrefs->autoSave);
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscScummVMDebugCheckbox), gPrefs->debug);
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscScummVMDemoCheckbox), gPrefs->demoMode);
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscScummVMCopyProtectionCheckbox), gPrefs->copyProtection);
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscScummVMAltIntroCheckbox), gPrefs->altIntro);
+
+ fld1P = (FieldType *)GetObjectPtr(TabMiscScummVMDebugLevelField);
+ fld2P = (FieldType *)GetObjectPtr(TabMiscScummVMAutosaveField);
+
+ levelH = MemHandleNew(FldGetMaxChars(fld1P)+1);
+ levelP = (Char *)MemHandleLock(levelH);
+ StrIToA(levelP, gPrefs->debugLevel);
+ MemHandleUnlock(levelH);
+
+ periodH = MemHandleNew(FldGetMaxChars(fld2P)+1);
+ periodP = (Char *)MemHandleLock(periodH);
+ StrIToA(periodP, gPrefs->autoSavePeriod);
+ MemHandleUnlock(periodH);
+
+ FldSetTextHandle(fld1P, levelH);
+ FldSetTextHandle(fld2P, periodH);
+}
+
+static void PalmOSTabInit() {
+ if (OPTIONS_TST(kOptDeviceARM) && !OPTIONS_TST(kOptDeviceZodiac))
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscPalmOSAdvancedCheckbox), gPrefs->advancedMode);
+
+ if (!OPTIONS_TST(kOptDeviceARM))
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscPalmOSStdPaletteCheckbox), gPrefs->stdPalette);
+
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscPalmOSExitLauncherCheckbox), gPrefs->exitLauncher);
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscPalmOSLargerStackCheckbox), gPrefs->setStack);
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscPalmOSVibratorCheckbox), gPrefs->vibrator);
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscPalmOSNoAutoOffCheckbox), !gPrefs->autoOff);
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscPalmOSStylusClickCheckbox), !gPrefs->stylusClick);
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscPalmOSArrowCheckbox), gPrefs->arrowKeys);
+}
+
+static void ExtsTabInit() {
+ if (OPTIONS_TST(kOptLightspeedAPI)) {
+ ListType *list1P = (ListType *)GetObjectPtr(TabMiscExtsLightspeedList);
+ LstSetSelection(list1P, gPrefs->lightspeed.mode);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabMiscExtsLightspeedPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscExtsLightspeedCheckbox), gPrefs->lightspeed.enable);
+ }
+
+ if (OPTIONS_TST(kOptGoLcdAPI))
+ CtlSetValue((ControlType *)GetObjectPtr(TabMiscExtsGolcdCheckbox), gPrefs->goLCD);
+}
+
+static void MiscFormSave() {
+ if (!ScummVMTabSave()) return;
+ PalmOSTabSave();
+ ExtsTabSave();
+
+ TabDeleteTabs(myTabP);
+ FrmReturnToMain();
+}
+
+static void MiscFormInit() {
+ TabType *tabP;
+ FormType *frmP = FrmGetActiveForm();
+ UInt8 extsCnt = 2;
+
+ tabP = TabNewTabs(3);
+ TabAddContent(&frmP, tabP, "PalmOS", TabMiscPalmOSForm);
+ TabAddContent(&frmP, tabP, "ScummVM", TabMiscScummVMForm);
+ TabAddContent(&frmP, tabP, "More ...", TabMiscExtsForm);
+
+ if (!OPTIONS_TST(kOptDeviceARM) || OPTIONS_TST(kOptDeviceZodiac))
+ FrmRemoveObject(&frmP, FrmGetObjectIndex(frmP, TabMiscPalmOSAdvancedCheckbox));
+
+ if (OPTIONS_TST(kOptDeviceARM))
+ FrmRemoveObject(&frmP, FrmGetObjectIndex(frmP, TabMiscPalmOSStdPaletteCheckbox));
+
+ if (!OPTIONS_TST(kOptGoLcdAPI)) {
+ FrmRemoveObject(&frmP, FrmGetObjectIndex(frmP, TabMiscExtsGolcdCheckbox));
+ // move lightspeed
+ TabMoveUpObject(frmP, TabMiscExtsLightspeedCheckbox, 12);
+ TabMoveUpObject(frmP, TabMiscExtsLightspeedPopTrigger, 12);
+ TabMoveUpObject(frmP, TabMiscExtsLightspeedList, 12);
+ TabMoveUpObject(frmP, TabMiscExtsNothingLabel, 12);
+ extsCnt--;
+ }
+
+ if (!OPTIONS_TST(kOptLightspeedAPI)) {
+ FrmRemoveObject(&frmP, FrmGetObjectIndex(frmP, TabMiscExtsLightspeedCheckbox));
+// FrmRemoveObject(&frmP, FrmGetObjectIndex(frmP, TabMiscExtsLightspeedList)); // cannot remove this ?
+ FrmRemoveObject(&frmP, FrmGetObjectIndex(frmP, TabMiscExtsLightspeedPopTrigger));
+ TabMoveUpObject(frmP, TabMiscExtsNothingLabel, 12);
+ extsCnt--;
+ }
+
+ if (extsCnt)
+ FrmRemoveObject(&frmP, FrmGetObjectIndex(frmP, TabMiscExtsNothingLabel));
+
+ PalmOSTabInit();
+ ScummVMTabInit();
+ ExtsTabInit();
+
+ FrmDrawForm(frmP);
+ TabSetActive(frmP, tabP, lastTab);
+
+ myTabP = tabP;
+}
+
+Boolean MiscFormHandleEvent(EventPtr eventP) {
+ FormPtr frmP = FrmGetActiveForm();
+ Boolean handled = false;
+
+ switch (eventP->eType) {
+ case frmOpenEvent:
+ MiscFormInit();
+ handled = true;
+ break;
+
+ case ctlSelectEvent:
+ switch (eventP->data.ctlSelect.controlID)
+ {
+ case (MiscForm + 1) :
+ case (MiscForm + 2) :
+ case (MiscForm + 3) :
+ lastTab = (eventP->data.ctlSelect.controlID - MiscForm - 1);
+ TabSetActive(frmP, myTabP, lastTab);
+ break;
+
+ case TabMiscExtsLightspeedPopTrigger:
+ FrmList(eventP, TabMiscExtsLightspeedList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabMiscExtsLightspeedList));
+ break;
+
+ case MiscOKButton:
+ MiscFormSave();
+ break;
+
+ case MiscCancelButton:
+ TabDeleteTabs(myTabP);
+ FrmReturnToMain();
+ break;
+ }
+ handled = true;
+ break;
+
+ default:
+ break;
+ }
+
+ return handled;
+}
diff --git a/backends/platform/PalmOS/Src/launcher/forms/formSkins.cpp b/backends/platform/PalmOS/Src/launcher/forms/formSkins.cpp
new file mode 100644
index 0000000000..b4c1e222d0
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/formSkins.cpp
@@ -0,0 +1,267 @@
+#include <PalmOS.h>
+
+#include "palmdefs.h"
+#include "start.h"
+#include "forms.h"
+#include "skin.h"
+#include "globals.h"
+
+static Int16 SkinsFormCompare(SkinInfoType *a, SkinInfoType *b, SortRecordInfoPtr, SortRecordInfoPtr, MemHandle) {
+ return StrCompare(a->nameP, b->nameP);
+}
+
+static void SkinsFormInit(Boolean bDraw) {
+ MemHandle skins = NULL;
+ SkinInfoType *skinsInfo;
+ UInt16 numSkins = 0;
+
+ FormPtr frmP;
+ ListType *listP;
+ MemHandle items = NULL;
+ ControlType *cck1P;
+ DmSearchStateType stateInfo;
+ UInt16 cardNo;
+ LocalID dbID;
+
+ Err errInfo;
+ Char nameP[32];
+
+ itemsText = NULL;
+
+ // parse and save skins
+ Err err = DmGetNextDatabaseByTypeCreator(true, &stateInfo, 'skin', appFileCreator, false, &cardNo, &dbID);
+ while (!err && dbID) {
+ errInfo = DmDatabaseInfo (cardNo, dbID, nameP, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ if (!errInfo)
+ {
+ if (!skins)
+ skins = MemHandleNew(sizeof(SkinInfoType));
+ else
+ MemHandleResize(skins, MemHandleSize(skins) + sizeof(SkinInfoType));
+
+ skinsInfo = (SkinInfoType *)MemHandleLock(skins);
+ StrCopy(skinsInfo[numSkins].nameP, nameP);
+ skinsInfo[numSkins].cardNo = cardNo;
+ skinsInfo[numSkins].dbID = dbID;
+ MemHandleUnlock(skins);
+ numSkins++;
+ }
+ err = DmGetNextDatabaseByTypeCreator(false, &stateInfo, 'skin', appFileCreator, false, &cardNo, &dbID);
+ }
+
+ Int16 selected = -1;
+
+ cck1P = (ControlType *)GetObjectPtr(SkinsSoundClickCheckbox);
+ CtlSetValue(cck1P, gPrefs->soundClick);
+
+ listP = (ListType *)GetObjectPtr(SkinsSkinList);
+ skinsInfo = (SkinInfoType *)MemHandleLock(skins);
+ SysQSort(skinsInfo, numSkins, sizeof(SkinInfoType), (CmpFuncPtr)SkinsFormCompare, 0);
+
+ // create itemsText (TODO: create a custom draw function)
+ for (UInt16 index=0; index < numSkins; index++)
+ {
+ if (!items)
+ items = MemHandleNew(sizeof(Char *));
+ else
+ MemHandleResize(items, MemHandleSize(items) + sizeof(Char *));
+
+ itemsText = (Char **)MemHandleLock(items);
+ itemsText[index] = skinsInfo[index].nameP;
+ MemHandleUnlock(items);
+
+ if ( gPrefs->skin.cardNo == skinsInfo[index].cardNo &&
+ gPrefs->skin.dbID == skinsInfo[index].dbID &&
+ StrCompare(gPrefs->skin.nameP, skinsInfo[index].nameP) == 0)
+ selected = index;
+ }
+ // save globals and set list
+ itemsText = (Char **)MemHandleLock(items);
+ itemsList = (void *)skinsInfo;
+ itemsType = ITEM_TYPE_SKIN;
+
+ LstSetListChoices (listP, itemsText, numSkins);
+ LstSetSelection(listP, selected);
+
+ // bDraw = true -> draw whole from
+ // bDraw = false -> redraw list
+ if (bDraw) {
+ frmP = FrmGetActiveForm();
+ FrmDrawForm(frmP);
+ } else {
+ WinScreenLock(winLockCopy);
+ LstDrawList(listP);
+ WinScreenUnlock();
+// LstSetSelection(listP, 0);
+ }
+}
+
+static void SkinsFormExit(Boolean bSave) {
+ MemHandle skins;
+ MemHandle items;
+ SkinInfoType *skinsInfo;
+
+ ListType *listP;
+ Int16 selected;
+
+ listP = (ListType *)GetObjectPtr(SkinsSkinList);
+ selected = LstGetSelection(listP);
+
+ if (bSave && selected == -1) { // may never occured...
+ FrmCustomAlert(FrmWarnAlert, "You didn't select a skin.", 0, 0);
+ return;
+ }
+
+ skinsInfo = (SkinInfoType *)itemsList;
+ skins = MemPtrRecoverHandle(skinsInfo);
+ items = MemPtrRecoverHandle(itemsText);
+
+ itemsText = NULL;
+ itemsList = NULL;
+ itemsType = ITEM_TYPE_UNKNOWN;
+
+ if (bSave) {
+ ControlType *cck1P;
+
+ StrCopy(gPrefs->skin.nameP, skinsInfo[selected].nameP);
+ gPrefs->skin.cardNo = skinsInfo[selected].cardNo;
+ gPrefs->skin.dbID = skinsInfo[selected].dbID;
+
+/* DmOpenRef skinDB = SknOpenSkin();
+ UInt32 depth = SknGetDepth(skinDB);
+ SknCloseSkin(skinDB);
+
+ if (depth != 8 && depth != 16) depth = 8;
+
+ if (depth == 16 && !OPTIONS_TST(kOptMode16Bit)) {
+ FrmCustomAlert(FrmInfoAlert, "You can only use 8bit skin on your device.", 0, 0);
+ gPrefs->skin.cardNo = cardNo;
+ gPrefs->skin.dbID = dbID;
+ }
+*/
+ cck1P = (ControlType *)GetObjectPtr(SkinsSoundClickCheckbox);
+ gPrefs->soundClick = CtlGetValue(cck1P);
+ }
+
+ FrmReturnToMain();
+
+ MemHandleUnlock(items);
+ MemHandleUnlock(skins);
+ MemHandleFree(items);
+ MemHandleFree(skins);
+
+ if (bSave)
+ SknApplySkin();
+}
+
+static void SkinsFormBeam() {
+ SkinInfoType *skinsInfo;
+
+ ListType *listP;
+ Int16 selected;
+ Err err;
+
+ listP = (ListType *)GetObjectPtr(SkinsSkinList);
+ selected = LstGetSelection(listP);
+
+ if (selected == -1) { // may never occured...
+ FrmCustomAlert(FrmWarnAlert, "You didn't select a skin.", 0, 0);
+ return;
+ }
+
+ skinsInfo = (SkinInfoType *)itemsList;
+ err = SendDatabase(0, skinsInfo[selected].dbID, "skin.pdb", "\nScummVM Skin");
+
+// if (err)
+// FrmCustomAlert(FrmErrorAlert, "Unable to beam this skin.",0,0);
+}
+
+static void SkinsFormDelete() {
+ MemHandle skins;
+ MemHandle items;
+ SkinInfoType *skinsInfo;
+
+ ListType *listP;
+ Int16 selected;
+
+ listP = (ListType *)GetObjectPtr(SkinsSkinList);
+ selected = LstGetSelection(listP);
+
+ if (selected == -1) { // may never occured...
+ FrmCustomAlert(FrmInfoAlert, "You didn't select a skin.", 0, 0);
+ return;
+ }
+
+ skinsInfo = (SkinInfoType *)itemsList;
+ skins = MemPtrRecoverHandle(skinsInfo);
+ items = MemPtrRecoverHandle(itemsText);
+
+ if ( gPrefs->skin.cardNo == skinsInfo[selected].cardNo &&
+ gPrefs->skin.dbID == skinsInfo[selected].dbID &&
+ StrCompare(gPrefs->skin.nameP, skinsInfo[selected].nameP) == 0) {
+ FrmCustomAlert(FrmInfoAlert, "You cannot delete the active skin.",0,0);
+ return;
+
+ } else {
+ Err err = DmDeleteDatabase(0, skinsInfo[selected].dbID);
+ if (!err) {
+
+ itemsText = NULL;
+ itemsList = NULL;
+ itemsType = ITEM_TYPE_UNKNOWN;
+
+ MemHandleUnlock(items);
+ MemHandleUnlock(skins);
+ MemHandleFree(items);
+ MemHandleFree(skins);
+
+ SkinsFormInit(false);
+ } else {
+ FrmCustomAlert(FrmErrorAlert, "Skin deletion failed.",0,0);
+ }
+ }
+
+}
+Boolean SkinsFormHandleEvent(EventPtr eventP) {
+ Boolean handled = false;
+
+ switch (eventP->eType) {
+
+ case frmOpenEvent:
+ SkinsFormInit(true);
+ handled = true;
+ break;
+
+ case frmCloseEvent:
+ SkinsFormExit(false);
+ handled = true;
+ break;
+
+ case ctlSelectEvent:
+ switch (eventP->data.ctlSelect.controlID)
+ {
+ case SkinsOKButton:
+ SkinsFormExit(true);
+ break;
+
+ case SkinsCancelButton:
+ SkinsFormExit(false);
+ break;
+
+ case SkinsBeamButton:
+ SkinsFormBeam();
+ break;
+
+ case SkinsDeleteButton:
+ SkinsFormDelete();
+ break;
+ }
+ handled = true;
+ break;
+
+ default:
+ break;
+ }
+
+ return handled;
+}
diff --git a/backends/platform/PalmOS/Src/launcher/forms/formUtil.cpp b/backends/platform/PalmOS/Src/launcher/forms/formUtil.cpp
new file mode 100644
index 0000000000..6d1d55e6e2
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/formUtil.cpp
@@ -0,0 +1,60 @@
+#include <PalmOS.h>
+#include <TxtGlue.h>
+
+#include "forms.h"
+
+Char **itemsText = NULL;
+void *itemsList = NULL;
+Char itemsType = ITEM_TYPE_UNKNOWN;
+
+void FrmReturnToMain(UInt16 updateCode) {
+ // if there is a form loaded, prevent crash on OS5
+ if (FrmGetFirstForm()) {
+ FrmUpdateForm(MainForm, updateCode);
+ FrmReturnToForm(MainForm);
+ }
+}
+
+void FldTrimText(FieldPtr fldP) {
+ MemHandle tmpH;
+ Char *tmpP;
+
+ tmpH = FldGetTextHandle(fldP);
+ FldSetTextHandle(fldP, NULL);
+ tmpP = (Char *)MemHandleLock(tmpH);
+ TxtGlueStripSpaces(tmpP, true, true);
+ MemHandleUnlock(tmpH);
+ FldSetTextHandle(fldP, tmpH);
+}
+
+/***********************************************************************
+ *
+ * FUNCTION: GetObjectPtr
+ *
+ * DESCRIPTION: This routine returns a pointer to an object in the current
+ * form.
+ *
+ * PARAMETERS: formId - id of the form to display
+ *
+ * RETURNED: void *
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+void * GetObjectPtr(UInt16 objectID) {
+ FormPtr frmP;
+
+ frmP = FrmGetActiveForm();
+ return FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID));
+}
+
+void FrmList(EventPtr eventP, UInt16 objectID) {
+ ListType *listP;
+ UInt16 listItem;
+
+ listP = (ListType *)GetObjectPtr(objectID);
+ listItem = LstPopupList(listP);
+ CtlSetLabel(eventP->data.ctlSelect.pControl, LstGetSelectionText(listP, LstGetSelection(listP)));
+}
+
diff --git a/backends/platform/PalmOS/Src/launcher/forms/formUtil.h b/backends/platform/PalmOS/Src/launcher/forms/formUtil.h
new file mode 100644
index 0000000000..90cf1ff37a
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/formUtil.h
@@ -0,0 +1,21 @@
+#ifndef __FORMUTIL_H__
+#define __FORMUTIL_H__
+
+#define frmRedrawUpdateMS (frmRedrawUpdateCode + 1)
+#define frmRedrawUpdateMSImport (frmRedrawUpdateCode + 2)
+
+// form list draw
+#define ITEM_TYPE_UNKNOWN 'U'
+#define ITEM_TYPE_CARD 'C'
+#define ITEM_TYPE_SKIN 'S'
+
+extern Char **itemsText;
+extern void *itemsList;
+extern Char itemsType;
+
+void FrmReturnToMain(UInt16 updateCode = frmRedrawUpdateMS);
+void * GetObjectPtr(UInt16 objectID);
+void FldTrimText(FieldPtr fldP);
+void FrmList(EventPtr eventP, UInt16 objectID);
+
+#endif
diff --git a/backends/platform/PalmOS/Src/launcher/forms/forminfo.cpp b/backends/platform/PalmOS/Src/launcher/forms/forminfo.cpp
new file mode 100644
index 0000000000..74622d8f14
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/forminfo.cpp
@@ -0,0 +1,146 @@
+#include <PalmOS.h>
+
+#include "start.h"
+#include "formTabs.h"
+#include "forms.h"
+
+#include "base/version.h"
+#include "globals.h"
+#include "init_palmos.h"
+
+/***********************************************************************
+ *
+ * FUNCTION: MiscOptionsFormSave
+ * FUNCTION: MiscOptionsFormInit
+ * FUNCTION: MiscOptionsFormHandleEvent
+ *
+ * DESCRIPTION: Misc. Options form functions
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+static TabType *myTabP;
+static UInt16 lastTab = 0;
+
+static UInt32 GetStackSize() {
+ MemPtr startPP, endPP;
+ SysGetStackInfo(&startPP, &endPP);
+
+ return ((Char *)endPP - (Char *)startPP) / 1024L;
+}
+
+static void VersionTabDraw() {
+ WinDrawChars(gScummVMVersion, StrLen(gScummVMVersion), 47, 12 + 30);
+ WinDrawChars(gScummVMBuildDate, StrLen(gScummVMBuildDate), 47, 24 + 30);
+}
+
+static void SystemTabDraw() {
+ Coord x;
+ UInt32 dm, sm, df, sf, stack;
+ Char num[10];
+
+ PalmGetMemory(&sm, &dm, &sf, 0);
+ stack = GetStackSize();
+ df = gVars->startupMemory;
+
+ WinSetTextColor(UIColorGetTableEntryIndex(UIObjectForeground));
+ FntSetFont(stdFont);
+
+ StrIToA(num, dm);
+ x = 147 - FntCharsWidth(num, StrLen(num)) + 5;
+ WinDrawChars(num, StrLen(num), x, 12 + 30);
+
+ StrIToA(num, sm);
+ x = 147 - FntCharsWidth(num, StrLen(num)) + 5;
+ WinDrawChars(num, StrLen(num), x, 24 + 30);
+
+ StrIToA(num, stack);
+ x = 147 - FntCharsWidth(num, StrLen(num)) + 5;
+ WinDrawChars(num, StrLen(num), x, 36 + 30);
+
+ StrIToA(num, df);
+ x = 107 - FntCharsWidth(num, StrLen(num)) + 5;
+ WinDrawChars(num, StrLen(num), x, 12 + 30);
+
+ StrIToA(num, sf);
+ x = 107 - FntCharsWidth(num, StrLen(num)) + 5;
+ WinDrawChars(num, StrLen(num), x, 24 + 30);
+
+ StrCopy(num,"-");
+ x = 107 - FntCharsWidth(num, StrLen(num)) + 5;
+ WinDrawChars(num, StrLen(num), x, 36 + 30);
+}
+
+static void InfoFormSave() {
+ TabDeleteTabs(myTabP);
+ FrmReturnToMain();
+}
+
+static void AboutTabDraw() {
+ MemHandle hTemp;
+ BitmapPtr bmpTemp;
+
+ hTemp = DmGetResource (bitmapRsc, 1200);
+ if (hTemp) {
+ bmpTemp = (BitmapType *)MemHandleLock(hTemp);
+ WinDrawBitmap(bmpTemp,3,44);
+ MemPtrUnlock(bmpTemp);
+ DmReleaseResource(hTemp);
+ }
+}
+
+static void InfoFormInit() {
+ TabType *tabP;
+ FormType *frmP = FrmGetActiveForm();
+
+ tabP = TabNewTabs(3);
+ TabAddContent(&frmP, tabP, "About", TabInfoAboutForm, AboutTabDraw);
+ TabAddContent(&frmP, tabP, "Version", TabInfoVersionForm, VersionTabDraw);
+ TabAddContent(&frmP, tabP, "Memory", TabInfoSystemForm, SystemTabDraw);
+
+ lastTab = 0;
+ FrmDrawForm(frmP);
+ TabSetActive(frmP, tabP, lastTab);
+
+ myTabP = tabP;
+}
+
+Boolean InfoFormHandleEvent(EventPtr eventP) {
+ FormPtr frmP = FrmGetActiveForm();
+ Boolean handled = false;
+
+ switch (eventP->eType) {
+ case frmOpenEvent:
+ InfoFormInit();
+ handled = true;
+ break;
+
+ case frmCloseEvent:
+ InfoFormSave();
+ handled = true;
+ break;
+
+ case ctlSelectEvent:
+ switch (eventP->data.ctlSelect.controlID)
+ {
+ case (InfoForm + 1) :
+ case (InfoForm + 2) :
+ case (InfoForm + 3) :
+ lastTab = (eventP->data.ctlSelect.controlID - InfoForm - 1);
+ TabSetActive(frmP, myTabP, lastTab);
+ break;
+
+ case InfoOKButton:
+ InfoFormSave();
+ break;
+ }
+ handled = true;
+ break;
+
+ default:
+ break;
+ }
+
+ return handled;
+}
diff --git a/backends/platform/PalmOS/Src/launcher/forms/formmain.cpp b/backends/platform/PalmOS/Src/launcher/forms/formmain.cpp
new file mode 100644
index 0000000000..1709b4c7a2
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/formmain.cpp
@@ -0,0 +1,363 @@
+/* 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 <PalmOS.h>
+
+#include "StarterRsc.h"
+#include "start.h"
+#include "skin.h"
+#include "games.h"
+#include "scumm_globals.h"
+#include "globals.h"
+
+#include "common/stdafx.h"
+#include "base/version.h"
+
+#include "formEditGame.h"
+#include "formUtil.h"
+
+static UInt16 sknLastOn = skinButtonNone;
+
+static Err BeamMe() {
+ UInt16 cardNo;
+ LocalID dbID;
+ Err err;
+
+ err = SysCurAppDatabase(&cardNo, &dbID);
+ if (dbID)
+ err = SendDatabase(0, dbID, "ScummVM.prc", "\nPlay your favorite LucasArts games");
+ else
+ err = DmGetLastErr();
+
+ return err;
+}
+
+/***********************************************************************
+ *
+ * FUNCTION: MainFormInit
+ *
+ * DESCRIPTION: This routine initializes the MainForm form.
+ *
+ * PARAMETERS: frm - pointer to the MainForm form.
+ *
+ * RETURNED: nothing
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+static void MainFormInit()
+{
+ SknApplySkin();
+}
+
+/***********************************************************************
+ *
+ * FUNCTION: MainFormDoCommand
+ *
+ * DESCRIPTION: This routine performs the menu command specified.
+ *
+ * PARAMETERS: command - menu item id
+ *
+ * RETURNED: nothing
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+
+static Boolean MainFormDoCommand(UInt16 command)
+{
+ Boolean handled = false;
+
+ switch (command) {
+ case MainGamesMemoryCard:
+ FrmPopupForm(CardSlotForm);
+ handled = true;
+ break;
+
+ case MainGamesNew:
+ gFormEditMode = edtModeAdd;
+ FrmPopupForm(GameEditForm);
+ handled = true;
+ break;
+
+ case MainGamesEdit:
+ gFormEditMode = edtModeEdit;
+ FrmPopupForm(GameEditForm);
+ handled = true;
+ break;
+
+ case MainGamesDelete:
+ EditGameFormDelete(true);
+ handled = true;
+ break;
+
+ case MainOptionsBeam:
+ BeamMe();
+ //if (BeamMe())
+ //FrmCustomAlert(FrmErrorAlert,"Unable to beam ScummVM for PalmOS.",0,0);
+ handled = true;
+ break;
+
+ case MainOptionsAbout:
+ FrmPopupForm(InfoForm);
+ handled = true;
+ break;
+
+ case MainGamesMusicSound:
+ FrmPopupForm(MusicForm);
+ handled = true;
+ break;
+
+ case MainOptionsSkins:
+ FrmPopupForm(SkinsForm);
+ handled = true;
+ break;
+
+ case MainOptionsMisc:
+ FrmPopupForm(MiscForm);
+ handled = true;
+ break;
+ }
+
+ MenuEraseStatus(0);
+ return handled;
+}
+
+/***********************************************************************
+ *
+ * FUNCTION: MainFormHandleEvent
+ *
+ * DESCRIPTION: This routine is the event handler for the
+ * "MainForm" of this application.
+ *
+ * PARAMETERS: eventP - a pointer to an EventType structure
+ *
+ * RETURNED: true if the event has handle and should not be passed
+ * to a higher level handler.
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+
+static Boolean PenDownRepeat() {
+ Coord x,y;
+ Boolean penDown, handled = false;
+ EvtGetPen(&x, &y, &penDown);
+
+ if (penDown && sknLastOn) {
+ RectangleType r;
+ DmOpenRef skinDBP;
+
+ skinDBP = SknOpenSkin();
+ SknGetObjectBounds(skinDBP, sknLastOn, &r);
+
+ if (RctPtInRectangle(x*2, y*2, &r)) {
+ if (SknGetState(skinDBP, sknLastOn) != sknStateSelected) {
+ SknSetState(skinDBP, sknLastOn, sknStateSelected);
+ SknShowObject(skinDBP, sknLastOn);
+ }
+
+ switch (sknLastOn) {
+ case skinSliderUpArrow:
+ case skinSliderDownArrow:
+ handled = SknProcessArrowAction(sknLastOn);
+ break;
+ }
+
+ } else {
+ if (SknGetState(skinDBP, sknLastOn) != sknStateNormal) {
+ SknSetState(skinDBP, sknLastOn, sknStateNormal);
+ SknShowObject(skinDBP, sknLastOn);
+ }
+ }
+
+ SknCloseSkin(skinDBP);
+ }
+
+ return handled;
+}
+
+
+Boolean MainFormHandleEvent(EventPtr eventP)
+{
+ Boolean handled = false;
+ FormPtr frmP;
+ Coord x,y;
+ DmOpenRef skinDBP;
+
+ switch (eventP->eType) {
+ case frmUpdateEvent:
+ {
+ RectangleType r;
+ UInt16 idx;
+ IndexedColorType bgColor = UIColorGetTableEntryIndex(UIFormFill);
+ frmP = FrmGetFormPtr(MainForm);
+
+ if (gPrefs->card.volRefNum != vfsInvalidVolRef)
+ idx = FrmGetObjectIndex (frmP, MainMSBitMap);
+ else
+ idx = FrmGetObjectIndex (frmP, MainMSNoneBitMap);
+
+ WinSetDrawMode(winPaint);
+ WinSetBackColor(bgColor);
+ FrmGetObjectBounds(frmP, idx, &r);
+ WinEraseRectangle(&r, 0);
+ FrmShowObject(frmP, idx);
+
+ if (eventP->data.frmUpdate.updateCode == frmRedrawUpdateMSImport) {
+ GamImportDatabase();
+ SknUpdateList();
+ }
+ handled = true;
+ break;
+ }
+ case menuEvent:
+ handled = MainFormDoCommand(eventP->data.menu.itemID);
+ break;
+
+ case frmOpenEvent:
+ MainFormInit();
+ handled = true;
+ break;
+
+ case ctlSelectEvent:
+ switch (eventP->data.ctlSelect.controlID)
+ {
+ case MainCardsButton:
+ //gPrefs->card.volRefNum = parseCards(true);
+ FrmPopupForm(CardSlotForm);
+ break;
+
+ case MainAboutButton:
+ FrmPopupForm(InfoForm);
+ break;
+
+// case MainListTypeSelTrigger:
+// FrmList(eventP, MainListTypeList);
+// break;
+ }
+ handled = true;
+ break;
+
+ case penUpEvent:
+ x = eventP->screenX;
+ y = eventP->screenY;
+ lastIndex = dmMaxRecordIndex; // enable select/unselect list item
+
+ if (sknLastOn != skinButtonNone) {
+ RectangleType r;
+ skinDBP = SknOpenSkin();
+ SknGetObjectBounds(skinDBP, sknLastOn, &r);
+ SknSetState(skinDBP, sknLastOn, sknStateNormal);
+ SknShowObject(skinDBP, sknLastOn);
+ SknCloseSkin(skinDBP);
+
+ if (RctPtInRectangle(x*2, y*2, &r)) {
+ switch (sknLastOn) {
+ case skinButtonGameAdd:
+ gFormEditMode = edtModeAdd;
+ FrmPopupForm(GameEditForm);
+ handled = true;
+ break;
+
+ case skinButtonGameAudio:
+ FrmPopupForm(MusicForm);
+ handled = true;
+ break;
+
+ case skinButtonGameEdit:
+ case skinButtonGameParams:
+ gFormEditMode = edtModeParams;
+ FrmPopupForm(GameEditForm);
+ handled = true;
+ break;
+
+ case skinButtonGameStart:
+ if (gPrefs->card.volRefNum == vfsInvalidVolRef)
+ FrmCustomAlert(FrmWarnAlert,"Please select/insert a memory card.", 0, 0);
+ else
+ bStartScumm = true;
+ handled = true;
+ break;
+
+ case skinButtonGameDelete:
+ EditGameFormDelete(true);
+ break;
+ }
+ }
+ sknLastOn = skinButtonNone;
+ }
+ break;
+
+ case penDownEvent:
+ case penMoveEvent:
+ if (sknLastOn == skinButtonNone) {
+ x = eventP->screenX;
+ y = eventP->screenY;
+ skinDBP = SknOpenSkin();
+
+ switch (sknLastOn = SknCheckClick(skinDBP, x,y)) {
+ case skinButtonNone:
+ break;
+ case skinSliderUpArrow:
+ case skinSliderDownArrow:
+ case skinButtonGameAdd:
+ case skinButtonGameEdit:
+ case skinButtonGameParams:
+ case skinButtonGameStart:
+ case skinButtonGameDelete:
+ case skinButtonGameAudio:
+ SknSetState(skinDBP, sknLastOn, sknStateSelected);
+ SknShowObject(skinDBP, sknLastOn);
+ if (gPrefs->soundClick)
+ SndPlaySystemSound(sndClick);
+ handled = true;
+ break;
+ default:
+ FrmCustomAlert(FrmWarnAlert,"Unknown button !",0,0);
+ }
+ SknCloseSkin(skinDBP);
+ SknSelect(x, y);
+ }
+ break;
+
+ case keyDownEvent:
+ if ( (eventP->data.keyDown.chr >= 'a' && eventP->data.keyDown.chr <= 'z') ||
+ (eventP->data.keyDown.chr >= 'A' && eventP->data.keyDown.chr <= 'Z')) {
+ if (GamJumpTo(eventP->data.keyDown.chr)) {
+ SknUpdateList();
+ handled = true;
+ }
+ }
+ break;
+
+ default:
+ handled = PenDownRepeat();
+ }
+
+ return handled;
+}
diff --git a/backends/platform/PalmOS/Src/launcher/forms/formmusic.cpp b/backends/platform/PalmOS/Src/launcher/forms/formmusic.cpp
new file mode 100644
index 0000000000..9b4b5355a7
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/formmusic.cpp
@@ -0,0 +1,387 @@
+/* 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 <PalmOS.h>
+
+#include "start.h"
+#include "formTabs.h"
+#include "forms.h"
+#include "games.h"
+
+#include "globals.h"
+
+static TabType *myTabP;
+static UInt16 lastTab = 0;
+
+static GameInfoType *gameInfoP = NULL;
+
+// Music
+static Boolean MusicTabSave() {
+ ControlType *cck1P, *cck2P;
+ ListType *list1P, *list2P, *list3P;
+ FieldType *fld1P;
+ UInt16 tempo;
+ FormPtr frmP;
+
+ frmP = FrmGetActiveForm();
+
+ cck1P = (ControlType *)GetObjectPtr(TabMusicMusicCheckbox);
+ cck2P = (ControlType *)GetObjectPtr(TabMusicMultiMidiCheckbox);
+
+ list1P = (ListType *)GetObjectPtr(TabMusicDriverList);
+ list2P = (ListType *)GetObjectPtr(TabMusicRateList);
+ list3P = (ListType *)GetObjectPtr(TabMusicQualityList);
+
+ fld1P = (FieldType *)GetObjectPtr(TabMusicTempoField);
+
+ tempo = StrAToI(FldGetTextPtr(fld1P));
+ if (tempo < 50 || tempo > 200) {
+ TabSetActive(frmP, myTabP, 0);
+ FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabMusicTempoField));
+ FrmCustomAlert(FrmErrorAlert, "Invalid tempo value (50...200)", 0, 0);
+ return false;
+ }
+
+ gameInfoP->musicInfo.sound.music = CtlGetValue(cck1P);
+ gameInfoP->musicInfo.sound.multiMidi = CtlGetValue(cck2P);
+
+ gameInfoP->musicInfo.sound.drvMusic = LstGetSelection(list1P);
+ gameInfoP->musicInfo.sound.rate = LstGetSelection(list2P);
+ gameInfoP->fmQuality = LstGetSelection(list3P);
+ gameInfoP->musicInfo.sound.tempo = tempo;
+
+ return true;
+}
+
+static void MusicTabInit() {
+ ControlType *cck1P, *cck2P;
+ ListType *list1P, *list2P, *list3P;
+ FieldType *fld1P;
+ MemHandle tempoH;
+ Char *tempoP;
+
+ cck1P = (ControlType *)GetObjectPtr(TabMusicMusicCheckbox);
+ cck2P = (ControlType *)GetObjectPtr(TabMusicMultiMidiCheckbox);
+
+ list1P = (ListType *)GetObjectPtr(TabMusicDriverList);
+ list2P = (ListType *)GetObjectPtr(TabMusicRateList);
+ list3P = (ListType *)GetObjectPtr(TabMusicQualityList);
+
+ fld1P = (FieldType *)GetObjectPtr(TabMusicTempoField);
+
+ CtlSetValue(cck1P, gameInfoP->musicInfo.sound.music);
+ CtlSetValue(cck2P, gameInfoP->musicInfo.sound.multiMidi);
+
+ if (gameInfoP->musicInfo.sound.drvMusic > 5)
+ gameInfoP->musicInfo.sound.drvMusic = 0;
+
+
+ LstSetSelection(list1P, gameInfoP->musicInfo.sound.drvMusic);
+ LstSetTopItem(list1P, gameInfoP->musicInfo.sound.drvMusic);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabMusicDriverPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+
+ LstSetSelection(list2P, gameInfoP->musicInfo.sound.rate);
+ LstSetTopItem(list2P, gameInfoP->musicInfo.sound.rate);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabMusicRatePopTrigger), LstGetSelectionText(list2P, LstGetSelection(list2P)));
+
+ LstSetSelection(list3P, gameInfoP->fmQuality);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabMusicQualityPopTrigger), LstGetSelectionText(list3P, LstGetSelection(list3P)));
+
+ tempoH = MemHandleNew(FldGetMaxChars(fld1P)+1);
+ tempoP = (Char *)MemHandleLock(tempoH);
+ StrIToA(tempoP, gameInfoP->musicInfo.sound.tempo);
+ MemHandleUnlock(tempoH);
+ FldSetTextHandle(fld1P, tempoH);
+}
+
+// Audio CD
+static Boolean AudioCDTabSave() {
+ ControlType *cck3P;
+ FieldType *fld2P, *fld3P;
+ ListType *list1P, *list2P;
+ UInt16 firstTrack;
+ FormPtr frmP;
+
+ frmP = FrmGetActiveForm();
+
+ cck3P = (ControlType *)GetObjectPtr(TabAudioCDMP3Checkbox);
+ fld2P = (FieldType *)GetObjectPtr(TabAudioCDLengthSecsField);
+ fld3P = (FieldType *)GetObjectPtr(TabAudioCDFirstTrackField);
+ list1P = (ListType *)GetObjectPtr(TabAudioCDDriverList);
+ list2P = (ListType *)GetObjectPtr(TabAudioCDFormatList);
+
+ firstTrack = StrAToI(FldGetTextPtr(fld3P));
+ if (firstTrack < 1 || firstTrack > 999) {
+ TabSetActive(frmP, myTabP, 2);
+ FrmSetFocus(frmP, FrmGetObjectIndex(frmP, TabAudioCDFirstTrackField));
+ FrmCustomAlert(FrmErrorAlert, "Invalid track value (1...999)", 0, 0);
+ return false;
+ }
+
+ gameInfoP->musicInfo.sound.CD = CtlGetValue(cck3P);
+
+ gameInfoP->musicInfo.sound.drvCD = LstGetSelection(list1P);
+ gameInfoP->musicInfo.sound.frtCD = LstGetSelection(list2P);
+
+ gameInfoP->musicInfo.sound.defaultTrackLength = StrAToI(FldGetTextPtr(fld2P));
+ gameInfoP->musicInfo.sound.firstTrack = firstTrack;
+
+ return true;
+}
+
+static void AudioCDTabInit() {
+ ControlType *cck3P;
+ FieldType *fld2P, *fld3P;
+ ListType *list1P, *list2P;
+ MemHandle lengthH, firstTrackH;
+ Char *lengthP, *firstTrackP;
+
+ cck3P = (ControlType *)GetObjectPtr(TabAudioCDMP3Checkbox);
+ fld2P = (FieldType *)GetObjectPtr(TabAudioCDLengthSecsField);
+ fld3P = (FieldType *)GetObjectPtr(TabAudioCDFirstTrackField);
+ list1P = (ListType *)GetObjectPtr(TabAudioCDDriverList);
+ list2P = (ListType *)GetObjectPtr(TabAudioCDFormatList);
+
+ LstSetSelection(list1P, gameInfoP->musicInfo.sound.drvCD);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDDriverPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+
+ LstSetSelection(list2P, gameInfoP->musicInfo.sound.frtCD);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDFormatPopTrigger), LstGetSelectionText(list2P, LstGetSelection(list2P)));
+
+ CtlSetValue(cck3P, gameInfoP->musicInfo.sound.CD);
+
+ lengthH = MemHandleNew(FldGetMaxChars(fld2P)+1);
+ lengthP = (Char *)MemHandleLock(lengthH);
+ StrIToA(lengthP, gameInfoP->musicInfo.sound.defaultTrackLength);
+ MemHandleUnlock(lengthH);
+ FldSetTextHandle(fld2P, lengthH);
+
+ firstTrackH = MemHandleNew(FldGetMaxChars(fld3P)+1);
+ firstTrackP = (Char *)MemHandleLock(firstTrackH);
+ StrIToA(firstTrackP, gameInfoP->musicInfo.sound.firstTrack);
+ MemHandleUnlock(firstTrackH);
+ FldSetTextHandle(fld3P, firstTrackH);
+}
+
+// Volume
+static void VolumeTabSave() {
+ SliderControlType *slid1P, *slid2P, *slid3P, *slid4P, *slid5P;
+
+ slid1P = (SliderControlType *)GetObjectPtr(TabVolumePalmSliderControl);
+ slid2P = (SliderControlType *)GetObjectPtr(TabVolumeMusicSliderControl);
+ slid3P = (SliderControlType *)GetObjectPtr(TabVolumeSfxSliderControl);
+ slid4P = (SliderControlType *)GetObjectPtr(TabVolumeSpeechSliderControl);
+ slid5P = (SliderControlType *)GetObjectPtr(TabVolumeAudioCDSliderControl);
+
+ CtlGetSliderValues ((ControlType *)slid1P, 0, 0, 0, &gameInfoP->musicInfo.volume.palm);
+ CtlGetSliderValues ((ControlType *)slid2P, 0, 0, 0, &gameInfoP->musicInfo.volume.music);
+ CtlGetSliderValues ((ControlType *)slid3P, 0, 0, 0, &gameInfoP->musicInfo.volume.sfx);
+ CtlGetSliderValues ((ControlType *)slid4P, 0, 0, 0, &gameInfoP->musicInfo.volume.speech);
+ CtlGetSliderValues ((ControlType *)slid5P, 0, 0, 0, &gameInfoP->musicInfo.volume.audiocd);
+}
+
+static void VolumeTabInit() {
+ SliderControlType *slid1P, *slid2P, *slid3P, *slid4P, *slid5P;
+ UInt16 value;
+
+ slid1P = (SliderControlType *)GetObjectPtr(TabVolumePalmSliderControl);
+ slid2P = (SliderControlType *)GetObjectPtr(TabVolumeMusicSliderControl);
+ slid3P = (SliderControlType *)GetObjectPtr(TabVolumeSfxSliderControl);
+ slid4P = (SliderControlType *)GetObjectPtr(TabVolumeSpeechSliderControl);
+ slid5P = (SliderControlType *)GetObjectPtr(TabVolumeAudioCDSliderControl);
+
+ value = gameInfoP->musicInfo.volume.palm;
+ CtlSetSliderValues ((ControlType *)slid1P, 0, 0, 0, &value);
+ value = gameInfoP->musicInfo.volume.music;
+ CtlSetSliderValues ((ControlType *)slid2P, 0, 0, 0, &value);
+ value = gameInfoP->musicInfo.volume.sfx;
+ CtlSetSliderValues ((ControlType *)slid3P, 0, 0, 0, &value);
+ value = gameInfoP->musicInfo.volume.speech;
+ CtlSetSliderValues ((ControlType *)slid4P, 0, 0, 0, &value);
+ value = gameInfoP->musicInfo.volume.audiocd;
+ CtlSetSliderValues ((ControlType *)slid5P, 0, 0, 0, &value);
+}
+
+static void MusicFormSave(UInt16 index) {
+ if (index != dmMaxRecordIndex) {
+ MemHandle recordH;
+ GameInfoType *ogameInfoP;
+
+ if (!MusicTabSave()) return;
+ if (!AudioCDTabSave()) return;
+ VolumeTabSave();
+
+ recordH = DmGetRecord(gameDB, index);
+ ogameInfoP = (GameInfoType *)MemHandleLock(recordH);
+ DmWrite(ogameInfoP, 0, gameInfoP, sizeof(GameInfoType));
+ MemHandleUnlock(recordH);
+ DmReleaseRecord (gameDB, index, 0);
+ }
+
+ MemPtrFree(gameInfoP);
+ gameInfoP = NULL;
+
+ TabDeleteTabs(myTabP);
+ FrmReturnToMain();
+}
+static void MusicFormInit(UInt16 index) {
+ TabType *tabP;
+ FormType *frmP = FrmGetActiveForm();
+
+ if (index != dmMaxRecordIndex) {
+ MemHandle recordH = NULL;
+ GameInfoType *ogameInfoP;
+
+ recordH = DmQueryRecord(gameDB, index);
+ ogameInfoP = (GameInfoType *)MemHandleLock(recordH);
+
+ if (!ogameInfoP) {
+ FrmCustomAlert(FrmErrorAlert, "An error occured.",0,0);
+ return;
+ }
+
+ gameInfoP = (GameInfoType *)MemPtrNew(sizeof(GameInfoType));
+ MemMove(gameInfoP, ogameInfoP, sizeof(GameInfoType));
+ MemHandleUnlock(recordH);
+
+ } else {
+ FrmCustomAlert(FrmWarnAlert, "Select an entry first.",0,0);
+ FrmReturnToMain();
+ return;
+ }
+
+ tabP = TabNewTabs(3);
+ TabAddContent(&frmP, tabP, "Sound", TabMusicForm);
+ TabAddContent(&frmP, tabP, "Volume", TabVolumeForm);
+ TabAddContent(&frmP, tabP, "Audio CD", TabAudioCDForm);
+
+ MusicTabInit();
+ AudioCDTabInit();
+ VolumeTabInit();
+
+ FrmDrawForm(frmP);
+ TabSetActive(frmP, tabP, lastTab);
+
+ myTabP = tabP;
+}
+
+Boolean MusicFormHandleEvent(EventPtr eventP) {
+ FormPtr frmP = FrmGetActiveForm();
+ Boolean handled = false;
+
+ switch (eventP->eType) {
+ case frmOpenEvent:
+ MusicFormInit(GamGetSelected());
+ handled = true;
+ break;
+
+ case frmCloseEvent:
+ MusicFormSave(dmMaxRecordIndex);
+ handled = true;
+ break;
+
+ case ctlSelectEvent:
+ switch (eventP->data.ctlSelect.controlID)
+ {
+ case (MusicForm + 1) :
+ case (MusicForm + 2) :
+ case (MusicForm + 3) :
+ lastTab = (eventP->data.ctlSelect.controlID - MusicForm - 1);
+ TabSetActive(frmP, myTabP, lastTab);
+ break;
+
+ case TabMusicDriverPopTrigger:
+ FrmList(eventP, TabMusicDriverList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabMusicDriverList));
+
+ if (!OPTIONS_TST(kOptDeviceZodiac) && !OPTIONS_TST(kOptSonyPa1LibAPI)) {
+ ListType *list1P = (ListType *)GetObjectPtr(TabMusicDriverList);
+
+ if (LstGetSelection(list1P) == 4) {
+ FrmCustomAlert(FrmInfoAlert, "There is no built-in MIDI support on your device.", 0, 0);
+ LstSetSelection(list1P, 0);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabMusicDriverPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+ }
+ }
+ break;
+
+ case TabMusicQualityPopTrigger:
+ FrmList(eventP, TabMusicQualityList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabMusicQualityList));
+ break;
+
+ case TabMusicRatePopTrigger:
+ FrmList(eventP, TabMusicRateList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabMusicRateList));
+
+ if (!OPTIONS_TST(kOptPalmSoundAPI)) {
+ ListType *list1P = (ListType *)GetObjectPtr(TabMusicRateList);
+
+ if (LstGetSelection(list1P) != 0) {
+ FrmCustomAlert(FrmInfoAlert, "You cannot use this rate on your device.", 0, 0);
+ LstSetSelection(list1P, 0);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabMusicRatePopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+ }
+ }
+ break;
+
+ case TabAudioCDFormatPopTrigger:
+ FrmList(eventP, TabAudioCDFormatList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabAudioCDFormatList));
+
+ if (LstGetSelection((ListPtr)GetObjectPtr(TabAudioCDDriverList)) == 1) {
+ ListType *list1P = (ListType *)GetObjectPtr(TabAudioCDFormatList);
+ LstSetSelection(list1P, 0);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDFormatPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+ }
+ break;
+
+ case TabAudioCDDriverPopTrigger:
+ FrmList(eventP, TabAudioCDDriverList);
+ FrmHideObject(frmP, FrmGetObjectIndex(frmP, TabAudioCDDriverList));
+
+ if (LstGetSelection((ListPtr)GetObjectPtr(TabAudioCDDriverList)) == 1) {
+ ListType *list1P = (ListType *)GetObjectPtr(TabAudioCDFormatList);
+ LstSetSelection(list1P, 0);
+ CtlSetLabel((ControlType *)GetObjectPtr(TabAudioCDFormatPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P)));
+ }
+ break;
+
+ case MusicOKButton:
+ MusicFormSave(GamGetSelected());
+ break;
+
+ case MusicCancelButton:
+ MusicFormSave(dmMaxRecordIndex);
+ break;
+ }
+ handled = true;
+ break;
+
+ default:
+ break;
+ }
+
+ return handled;
+}
diff --git a/backends/platform/PalmOS/Src/launcher/forms/forms.h b/backends/platform/PalmOS/Src/launcher/forms/forms.h
new file mode 100644
index 0000000000..0bdfd356c7
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/forms.h
@@ -0,0 +1,22 @@
+#ifndef __FORMS_H__
+#define __FORMS_H__
+
+#include "StarterRsc.h"
+#include "formUtil.h"
+
+#include "formEditGame.h"
+#include "formCards.h"
+
+
+#define HANDLER(x) Boolean x##FormHandleEvent(EventPtr eventP);
+
+HANDLER(Main)
+HANDLER(EditGame)
+HANDLER(SystemInfo)
+HANDLER(Misc)
+HANDLER(CardSlot)
+HANDLER(Skins)
+HANDLER(Music)
+HANDLER(Info)
+
+#endif
diff --git a/backends/platform/PalmOS/Src/launcher/forms/formtabs.cpp b/backends/platform/PalmOS/Src/launcher/forms/formtabs.cpp
new file mode 100644
index 0000000000..0dd3427c1a
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/formtabs.cpp
@@ -0,0 +1,242 @@
+#include <PalmOS.h>
+#include <CtlGlue.h>
+#include <FrmGlue.h>
+#include <LstGlue.h>
+
+#include "globals.h"
+#include "formTabs.h"
+
+TabType *TabNewTabs(UInt16 cnt) {
+ TabType *newP = new TabType;
+
+ newP->count = 0;
+ newP->width = 0;
+ newP->tabs = new TabDataType[cnt];
+
+ return newP;
+}
+
+void TabMoveUpObject(FormType *frmP, UInt16 objID, Coord amount) {
+ Coord x, y;
+ FrmGetObjectPosition(frmP, FrmGetObjectIndex(frmP, objID), &x, &y);
+ FrmSetObjectPosition(frmP, FrmGetObjectIndex(frmP, objID), x, y - amount);
+}
+
+void TabDeleteTabs(TabType *tabP) {
+ UInt16 cnt, num;
+ num = MemPtrSize(tabP->tabs) / sizeof(TabDataType);
+
+ for (cnt = 0; cnt < num; cnt++)
+ FrmDeleteForm(tabP->tabs[cnt].srcP);
+
+ delete tabP->tabs;
+ delete tabP;
+}
+
+Err TabAddContent(FormType **frmP, TabType *tabP, const Char *nameP, UInt16 rscID, TabProc *drawFunc) {
+ FormType *srcP;
+ UInt16 cnt;
+ void *objP, **dstP;
+ UInt16 objNum;
+ Coord x, y, w, h;
+ UInt16 id;
+ RectangleType r;
+
+ dstP = (void **)frmP;
+ srcP = FrmInitForm(rscID);
+
+ objNum = FrmGetNumberOfObjects(srcP);
+
+ // save tab data
+
+ // it's required to keep to source forms active
+ // while the tab form is not close for list data ptr (items text)
+ // TODO : fix this !
+ tabP->tabs[tabP->count].srcP = srcP;
+ tabP->tabs[tabP->count].first = FrmGetObjectId(srcP, 0);
+ tabP->tabs[tabP->count].last = FrmGetObjectId(srcP, objNum - 1);
+ tabP->tabs[tabP->count].drawFunc= drawFunc;
+ tabP->count++;
+ tabP->active = tabP->count;
+
+ // create tab
+ FntSetFont(stdFont);
+ x = 4 + tabP->width;
+ y = 16;
+ w = FntCharsWidth(nameP, StrLen(nameP)) + 6;
+ h = 12;
+ ControlType *addP = CtlNewControl(dstP, (FrmGetFormId(*frmP) + tabP->count), buttonCtl, nameP, x, y, w, h, stdFont, 0, true);
+ CtlGlueSetFrameStyle(addP, noButtonFrame);
+ tabP->width += w + 3;
+
+ // create tab content
+ for (cnt = 0; cnt < objNum; cnt++) {
+ objP = FrmGetObjectPtr(srcP, cnt);
+ id = FrmGetObjectId(srcP, cnt);
+ FrmGetObjectBounds(srcP, cnt, &r);
+ x = r.topLeft.x - 2;
+ y = r.topLeft.y + 30;
+ w = r.extent.x;
+ h = r.extent.y;
+
+ FrmSetObjectPosition(srcP, cnt, x, y);
+
+ switch (FrmGetObjectType(srcP, cnt)) {
+ case frmListObj: {
+ // HOWTO : to auto link the list to a popup trigger the listID must be popupID + 1 if popup id
+ // desn't exist the triggerID will be 0 and the list will be shown, but take care to not define
+ // ListID - 1 object if you want to show the list.
+ ListType *newP;
+ Char **itemsP = LstGlueGetItemsText((ListType *)objP);
+ FontID font = LstGlueGetFont((ListType *)objP);
+ UInt16 visible = LstGetVisibleItems((ListType *)objP);
+ UInt16 items = LstGetNumberOfItems((ListType *)objP);
+ UInt16 trigger = id - 1;
+ trigger = (FrmGetObjectIndex((FormType *)*dstP, trigger) != frmInvalidObjectId) ? trigger : 0;
+
+ LstNewList(dstP, id, x, y, w, h, font, visible, trigger);
+ newP = (ListType *)FrmGetObjectPtr((FormType *)*dstP, FrmGetObjectIndex((FormType *)*dstP, id));
+ LstSetListChoices(newP, itemsP, items);
+ FrmHideObject((FormType *)*dstP, FrmGetObjectIndex((FormType *)*dstP, id));
+ break;
+ }
+ case frmFieldObj: {
+ FieldAttrType attr;
+ FontID font = FldGetFont((FieldType *)objP);
+ UInt16 maxChars = FldGetMaxChars((FieldType *)objP);
+ FldGetAttributes((FieldType *)objP, &attr);
+ FldNewField(dstP, id, x, y, w, h, font, maxChars, attr.editable, attr.underlined, attr.singleLine, attr.dynamicSize, (JustificationType)attr.justification, attr.autoShift, attr.hasScrollBar, attr.numeric);
+ FrmHideObject((FormType *)*dstP, FrmGetObjectIndex((FormType *)*dstP, id));
+ break;
+ }
+ case frmControlObj: {
+ const Char *textP = CtlGetLabel((ControlType *)objP);
+ ControlStyleType style = CtlGlueGetControlStyle((ControlType *)objP);
+ FontID font = CtlGlueGetFont((ControlType *)objP);
+ ControlType *newP = CtlNewControl(dstP, id, style, textP, x, y, w, h, font, 0, true);
+ FrmHideObject((FormType *)*dstP, FrmGetObjectIndex((FormType *)*dstP, id));
+ switch (style) {
+ case sliderCtl:
+ {
+ UInt16 min, max, page, val;
+ CtlGetSliderValues((ControlType *)objP, &min, &max, &page, &val);
+ CtlSetSliderValues(newP, &min, &max, &page, &val);
+ break;
+ }
+ }
+ break;
+ }
+ case frmLabelObj: {
+ const Char *textP = FrmGetLabel(srcP, id);
+ FontID font = FrmGlueGetLabelFont(srcP, id);
+ FrmNewLabel((FormType **)dstP, id, textP, x, y, font);
+ FrmHideObject((FormType *)*dstP, FrmGetObjectIndex((FormType *)*dstP, id));
+ break;
+ }
+
+ case frmBitmapObj: {
+/* UInt16 family = id + 1;
+ FrmNewBitmap((FormType **)dstP, id, id, x, y);
+ //FrmHideObject((FormType *)*dstP, FrmGetObjectIndex((FormType *)*dstP, id));
+*/ break;
+ }
+ }
+ }
+
+ frmP = (FormType **)dstP; // save new form ptr
+ return errNone;
+}
+
+void TabSetActive(FormType *frmP, TabType *tabP, UInt16 num) {
+ UInt16 cnt, idx;
+ RectangleType r;
+ TabDataPtr dataP;
+
+ if (tabP->active == num)
+ return;
+
+ dataP = &tabP->tabs[tabP->active];
+
+ // hide active tab objects
+ if (tabP->active != tabP->count) {
+ for (cnt = dataP->first; cnt <= dataP->last; cnt++) {
+ if ((idx = FrmGetObjectIndex(frmP, cnt)) != frmInvalidObjectId)
+ FrmHideObject(frmP, idx);
+ }
+ }
+
+ // save active tab
+ tabP->active = num;
+ dataP = &tabP->tabs[num];
+
+ // draw tab limit
+ WinSetForeColor(UIColorGetTableEntryIndex(UIFormFill));
+ WinDrawLine(1, 14, 154,14);
+ WinDrawLine(1, 15, 154,15);
+ RctSetRectangle(&r, 1, 30, 154, 100);
+ WinDrawRectangle(&r, 0);
+ WinSetForeColor(UIColorGetTableEntryIndex(UIObjectFrame));
+ WinDrawLine(1, 28, 154,28);
+
+ // set tabs size
+ for (cnt = 0; cnt < tabP->count; cnt++) {
+ idx = FrmGetObjectIndex (frmP, (FrmGetFormId(frmP) + cnt + 1));
+
+ if (idx != frmInvalidObjectId) {
+ FrmGetObjectBounds(frmP, idx, &r);
+ r.topLeft.y = (num == cnt) ? 17 : 17;
+ r.extent.y = (num == cnt) ? 12 : 11;
+ FrmSetObjectBounds(frmP, idx, &r);
+
+ if (num == cnt) {
+ RGBColorType yellow = {0,255,192,0};
+
+ UInt8 line = /*(UIColorGetTableEntryIndex(UIFormFill) == UIColorGetTableEntryIndex(UIFieldTextHighlightBackground)) ?
+ WinRGBToIndex(&yellow) :*/
+ UIColorGetTableEntryIndex(UIFieldTextHighlightBackground);
+
+ r.topLeft.y -= 1;
+ WinSetForeColor(UIColorGetTableEntryIndex(UIObjectFrame));
+ WinDrawRectangleFrame(simpleFrame, &r);
+ WinSetForeColor(line);
+ WinDrawLine(r.topLeft.x, r.topLeft.y, r.topLeft.x + r.extent.x - 1, r.topLeft.y);
+ FrmShowObject(frmP, idx);
+
+ } else {
+ UInt8 frame = UIColorGetTableEntryIndex(UIObjectFrame);
+ RGBColorType light;
+ WinIndexToRGB(frame, &light);
+ light.r = (255 - light.r) > 72 ? light.r + 72 : 255;
+ light.g = (255 - light.g) > 72 ? light.g + 72 : 255;
+ light.b = (255 - light.b) > 72 ? light.b + 72 : 255;
+
+ WinSetForeColor(WinRGBToIndex(&light));
+ WinDrawRectangleFrame(simpleFrame, &r);
+ WinSetForeColor(frame);
+ WinDrawLine(r.topLeft.x - 1, r.topLeft.y + r.extent.y, r.topLeft.x + r.extent.x, r.topLeft.y + r.extent.y);
+ }
+
+ // round corner
+ WinSetForeColor(UIColorGetTableEntryIndex(UIFormFill));
+ if (OPTIONS_TST(kOptModeHiDensity)) {
+ WinSetCoordinateSystem(kCoordinatesNative);
+ WinDrawPixel((r.topLeft.x - 1) * 2, (r.topLeft.y - 1) * 2);
+ WinDrawPixel((r.topLeft.x + r.extent.x) * 2 + 1, (r.topLeft.y - 1) * 2);
+ WinSetCoordinateSystem(kCoordinatesStandard);
+
+ } else {
+ // TODO
+ }
+ }
+ }
+
+ // show objects
+ for (cnt = dataP->first; cnt <= dataP->last; cnt++) {
+ if ((idx = FrmGetObjectIndex(frmP, cnt)) != frmInvalidObjectId)
+ FrmShowObject(frmP, idx);
+ }
+
+ // post draw function
+ if (dataP->drawFunc)
+ (dataP->drawFunc)();
+}
diff --git a/backends/platform/PalmOS/Src/launcher/forms/formtabs.h b/backends/platform/PalmOS/Src/launcher/forms/formtabs.h
new file mode 100644
index 0000000000..5371485bf1
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/forms/formtabs.h
@@ -0,0 +1,24 @@
+#ifndef __FORMTABS_H__
+#define __FORMTABS_H__
+
+typedef void (TabProc)();
+
+typedef struct {
+ FormPtr srcP;
+ UInt16 first;
+ UInt16 last;
+ TabProc *drawFunc;
+} TabDataType, *TabDataPtr;
+
+typedef struct {
+ UInt16 count, active;
+ Coord width;
+ TabDataPtr tabs;
+} TabType, *TabPtr;
+
+TabType *TabNewTabs (UInt16 cnt);
+void TabDeleteTabs (TabType *tabP);
+Err TabAddContent (FormType **frmP, TabType *tabP, const Char *nameP, UInt16 rscID, TabProc *drawFunc = 0);
+void TabSetActive (FormType *frmP, TabType *tabP, UInt16 num);
+void TabMoveUpObject (FormType *frmP, UInt16 objID, Coord amount);
+#endif
diff --git a/backends/platform/PalmOS/Src/launcher/games.cpp b/backends/platform/PalmOS/Src/launcher/games.cpp
new file mode 100644
index 0000000000..166aae6aa4
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/games.cpp
@@ -0,0 +1,530 @@
+/* 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 <PalmOS.h>
+#include <VFSMgr.h>
+#include <ctype.h>
+
+#include "globals.h"
+#include "palmdefs.h"
+#include "start.h"
+#include "games.h"
+#include "skin.h"
+
+#include "extend.h"
+#include "StarterRsc.h"
+
+DmOpenRef gameDB = NULL;
+
+static Err GamUpdateList() {
+ if (gameDB) {
+ UInt16 numRecs = DmNumRecords(gameDB);
+
+ if (numRecs > 0) {
+ MemHandle tmpH;
+ UInt32 version, size;
+ UInt32 *versionP;
+
+ // get record size and version
+ tmpH = DmQueryRecord(gameDB, 0);
+ size = MemHandleSize(tmpH);
+ versionP = (UInt32 *)MemHandleLock(tmpH);
+ version = *versionP;
+ MemHandleUnlock(tmpH);
+
+ // check record
+ if (version != curItemVersion || size != sizeof(GameInfoType)) {
+ UInt16 index;
+ GameInfoType gitCur;
+ void *tmpP;
+ FormPtr ofmP, frmP;
+
+ // show dialog
+ ofmP = FrmGetActiveForm();
+ frmP = FrmInitForm(ConvertForm);
+ FrmSetActiveForm(frmP);
+ FrmDrawForm(frmP);
+ SysTaskDelay(1 * SysTicksPerSecond());
+
+ MemSet(&gitCur, sizeof(GameInfoType), 0);
+
+ if (version == itemVersion_354 ||
+ version == itemVersion_353 ||
+ version == itemVersion_352 ||
+ version == itemVersion_351 ||
+ version == itemVersion_350 ||
+ version == itemVersion_340 ||
+ version == itemVersion_330 ||
+ version == itemVersion_320 ||
+ version == itemVersion_310 ||
+ version == itemVersion_300 ||
+ version == itemVersion_270 ||
+ version == itemVersion_260 ||
+ version == itemVersion_250) {
+ for (index = 0; index < numRecs; index++) {
+ // get old data
+ tmpH = DmQueryRecord(gameDB, index);
+ tmpP = MemHandleLock(tmpH);
+ MemMove(&gitCur, tmpP, MemHandleSize(tmpH));
+ MemHandleUnlock(tmpH);
+
+ // new format
+ gitCur.version = curItemVersion;
+
+ if (version < itemVersion_300) {
+ gitCur.musicInfo.volume.palm = 50;
+ gitCur.musicInfo.volume.music = 192;
+ gitCur.musicInfo.volume.sfx = 192;
+ gitCur.musicInfo.volume.speech = 192;
+ gitCur.musicInfo.volume.audiocd = 50;
+
+ gitCur.musicInfo.sound.tempo = 100;
+ gitCur.musicInfo.sound.defaultTrackLength = 10;
+ gitCur.musicInfo.sound.firstTrack = 1;
+ }
+
+ if (version < itemVersion_310)
+ gitCur.engine = 0;
+
+ if (version < itemVersion_320)
+ gitCur.renderMode = 0;
+
+ if (version <= itemVersion_330) {
+ gitCur.fmQuality = 0;
+ gitCur.gfxMode = (gitCur.gfxMode == 3 ? 1 : 0); // v3.4 only 2 modes
+
+ if (gitCur.engine == 0) gitCur.engine = 8;
+ else if (gitCur.engine == 1) gitCur.engine = 7;
+ else if (gitCur.engine == 2) gitCur.engine = 3;
+ else if (gitCur.engine == 3) gitCur.engine = 1;
+ else if (gitCur.engine == 4) gitCur.engine = 0;
+ else if (gitCur.engine == 5) gitCur.engine = 6;
+ else if (gitCur.engine == 6) gitCur.engine = 4;
+ else if (gitCur.engine == 7) gitCur.engine = 5;
+ else if (gitCur.engine == 8) gitCur.engine = 2;
+
+ if (gitCur.renderMode == 1) gitCur.renderMode = 4;
+ else if (gitCur.renderMode == 2) gitCur.renderMode = 5;
+ else if (gitCur.renderMode == 3) gitCur.renderMode = 2;
+ else if (gitCur.renderMode == 4) gitCur.renderMode = 3;
+ else if (gitCur.renderMode == 5) gitCur.renderMode = 1;
+
+ if (gitCur.platform == 2) gitCur.platform = 6;
+ else if (gitCur.platform == 5) gitCur.platform = 8;
+ else if (gitCur.platform == 6) gitCur.platform = 2;
+
+ if (gitCur.language == 1) gitCur.language = 4;
+ else if (gitCur.language == 2) gitCur.language = 6;
+ else if (gitCur.language == 3) gitCur.language = 5;
+ else if (gitCur.language == 4) gitCur.language = 8;
+ else if (gitCur.language == 5) gitCur.language = 11;
+ else if (gitCur.language == 6) gitCur.language = 13;
+ else if (gitCur.language == 7) gitCur.language = 9;
+ else if (gitCur.language == 8) gitCur.language = 1;
+ else if (gitCur.language == 9) gitCur.language = 10;
+ else if (gitCur.language == 10) gitCur.language = 7;
+ else if (gitCur.language == 11) gitCur.language = 12;
+ else if (gitCur.language == 12) gitCur.language = 2;
+ else if (gitCur.language == 13) gitCur.language = 3;
+
+ if (gitCur.musicInfo.sound.drvMusic == 1) gitCur.musicInfo.sound.drvMusic = 4;
+ else if (gitCur.musicInfo.sound.drvMusic == 2) gitCur.musicInfo.sound.drvMusic = 5;
+ else if (gitCur.musicInfo.sound.drvMusic == 4) gitCur.musicInfo.sound.drvMusic = 2;
+ else if (gitCur.musicInfo.sound.drvMusic == 5) gitCur.musicInfo.sound.drvMusic = 1;
+ }
+
+ if (version <= itemVersion_340) {
+ gitCur.platform++;
+
+ if (gitCur.language == 3)
+ gitCur.language = 0;
+ else if (gitCur.language >= 11)
+ gitCur.language++;
+ }
+
+ if (version <= itemVersion_350)
+ if (gitCur.platform >= 9)
+ gitCur.platform++;
+
+ if (version <= itemVersion_351) {
+ if (gitCur.engine >= ENGINE_LURE) // newly added engine
+ gitCur.engine++;
+
+ if (gitCur.engine == ENGINE_SCUMM) // reorder
+ gitCur.engine = ENGINE_SIMON;
+ else if (gitCur.engine == ENGINE_SIMON)
+ gitCur.engine = ENGINE_SCUMM;
+ }
+
+ if (version <= itemVersion_352) {
+ if (gitCur.engine >= ENGINE_CINE) // newly added engine
+ gitCur.engine++;
+
+ gitCur.platform++;
+ }
+
+ if (version <= itemVersion_353)
+ gitCur.musicInfo.sound.drvMusic++;
+
+ if (version <= itemVersion_354)
+ if (gitCur.engine >= ENGINE_AGI) // newly added engine
+ gitCur.engine++;
+
+ if (gitCur.musicInfo.volume.palm > 100)
+ gitCur.musicInfo.volume.palm = 50;
+
+ // simply resize the old record
+ tmpH = DmResizeRecord(gameDB, index, sizeof(GameInfoType)); // TODO : check error on resize tmpH==NULL
+ tmpP = MemHandleLock(tmpH);
+ DmWrite(tmpP, 0, &gitCur, sizeof(GameInfoType));
+ MemPtrUnlock(tmpP);
+ }
+
+ } else if (version == itemVersion_200) {
+ // need conversion from V2 -> V3.5.2
+ GameInfoTypeV2 git0;
+
+ for (index = 0; index < numRecs; index++) {
+
+ // get old data
+ tmpH = DmQueryRecord(gameDB, index);
+ tmpP = MemHandleLock(tmpH);
+ MemMove(&git0, tmpP, sizeof(GameInfoTypeV2));
+ MemHandleUnlock(tmpH);
+
+ // convert to new format
+ gitCur.version = curItemVersion;
+ gitCur.icnID = 0xFFFF;
+ gitCur.selected = git0.selected;
+ StrCopy(gitCur.nameP, git0.nameP);
+ StrCopy(gitCur.pathP, git0.pathP);
+ StrCopy(gitCur.gameP, git0.gameP);
+ gitCur.gfxMode = (git0.gfxMode == 3 ? 1 : 0); // v3.4 only 2 modes
+
+ gitCur.autoLoad = git0.autoLoad;
+ gitCur.bootParam = git0.bootParam;
+ gitCur.setPlatform = git0.setPlatform;
+ gitCur.subtitles = git0.subtitles;
+ gitCur.talkSpeed = git0.talkSpeed;
+
+ gitCur.loadSlot = git0.loadSlot;
+ gitCur.bootValue = git0.bootValue;
+ gitCur.talkValue = git0.talkValue;
+ gitCur.platform = git0.platform;
+ gitCur.language = git0.language;
+
+ gitCur.musicInfo.volume.palm = 50;
+ gitCur.musicInfo.volume.music = 192;
+ gitCur.musicInfo.volume.sfx = 192;
+ gitCur.musicInfo.volume.speech = 192;
+ gitCur.musicInfo.volume.audiocd = 50;
+
+ gitCur.musicInfo.sound.tempo = 100;
+ gitCur.musicInfo.sound.defaultTrackLength = 10;
+ gitCur.musicInfo.sound.firstTrack = 1;
+
+ // to V3.4
+ if (gitCur.platform == 2) gitCur.platform = 6;
+ else if (gitCur.platform == 5) gitCur.platform = 8;
+ else if (gitCur.platform == 6) gitCur.platform = 2;
+
+ if (gitCur.language == 1) gitCur.language = 4;
+ else if (gitCur.language == 2) gitCur.language = 6;
+ else if (gitCur.language == 3) gitCur.language = 5;
+ else if (gitCur.language == 4) gitCur.language = 8;
+ else if (gitCur.language == 5) gitCur.language = 11;
+ else if (gitCur.language == 6) gitCur.language = 13;
+ else if (gitCur.language == 7) gitCur.language = 9;
+ else if (gitCur.language == 8) gitCur.language = 1;
+ else if (gitCur.language == 9) gitCur.language = 10;
+ else if (gitCur.language == 10) gitCur.language = 7;
+ else if (gitCur.language == 11) gitCur.language = 12;
+ else if (gitCur.language == 12) gitCur.language = 2;
+ else if (gitCur.language == 13) gitCur.language = 3;
+
+ if (gitCur.musicInfo.sound.drvMusic == 1) gitCur.musicInfo.sound.drvMusic = 4;
+ else if (gitCur.musicInfo.sound.drvMusic == 2) gitCur.musicInfo.sound.drvMusic = 5;
+ else if (gitCur.musicInfo.sound.drvMusic == 4) gitCur.musicInfo.sound.drvMusic = 2;
+ else if (gitCur.musicInfo.sound.drvMusic == 5) gitCur.musicInfo.sound.drvMusic = 1;
+
+ // to V3.5
+ gitCur.platform++;
+
+ if (gitCur.language == 3)
+ gitCur.language = 0;
+ else if (gitCur.language >= 11)
+ gitCur.language++;
+
+ // to V3.5.1
+ if (gitCur.platform >= 9)
+ gitCur.platform++;
+
+ //to V3.5.3
+ gitCur.musicInfo.sound.drvMusic++;
+
+ // -----
+ gitCur.engine = ENGINE_SCUMM;
+
+ tmpH = DmResizeRecord(gameDB, index, sizeof(GameInfoType)); // TODO : check error on resize tmpH==NULL
+ tmpP = MemHandleLock(tmpH);
+ DmWrite(tmpP, 0, &gitCur, sizeof(GameInfoType));
+ MemPtrUnlock(tmpP);
+ }
+ } else {
+ // need conversion from V0 -> V3.5.2
+ GameInfoTypeV0 git0;
+
+ for (index = 0; index < numRecs; index++) {
+
+ // get old data
+ tmpH = DmQueryRecord(gameDB, index);
+ tmpP = MemHandleLock(tmpH);
+ MemMove(&git0, tmpP, sizeof(GameInfoTypeV0));
+ MemHandleUnlock(tmpH);
+
+ // convert to new format
+ gitCur.version = curItemVersion;
+ gitCur.icnID = 0xFFFF;
+ gitCur.selected = git0.selected;
+ StrCopy(gitCur.nameP, git0.nameP);
+ StrCopy(gitCur.pathP, git0.pathP);
+ StrCopy(gitCur.gameP, git0.gameP);
+ gitCur.gfxMode = (git0.gfxMode == 3 ? 1 : 0); // v3.4 only 2 modes
+
+ gitCur.autoLoad = git0.autoLoad;
+ gitCur.bootParam = git0.bootParam;
+ gitCur.setPlatform = git0.amiga; // amiga become platform amiga/atari-st/machintosh
+ gitCur.platform = 1;
+ gitCur.subtitles = git0.subtitles;
+ gitCur.talkSpeed = git0.talkSpeed;
+
+ gitCur.loadSlot = git0.loadSlot;
+ gitCur.bootValue = git0.bootValue;
+ gitCur.talkValue = git0.talkValue;
+ gitCur.platform = 2; // default to amiga
+ gitCur.language = git0.language;
+
+ gitCur.musicInfo.volume.palm = 50;
+ gitCur.musicInfo.volume.music = 192;
+ gitCur.musicInfo.volume.sfx = 192;
+ gitCur.musicInfo.volume.speech = 192;
+ gitCur.musicInfo.volume.audiocd = 50;
+
+ gitCur.musicInfo.sound.tempo = 100;
+ gitCur.musicInfo.sound.defaultTrackLength = 10;
+ gitCur.musicInfo.sound.firstTrack = 1;
+
+ gitCur.engine = ENGINE_SCUMM;
+
+ tmpH = DmResizeRecord(gameDB, index, sizeof(GameInfoType)); // TODO : check error on resize tmpH==NULL
+ tmpP = MemHandleLock(tmpH);
+ DmWrite(tmpP, 0, &gitCur, sizeof(GameInfoType));
+ MemPtrUnlock(tmpP);
+ }
+ }
+
+ FrmEraseForm(frmP);
+ FrmDeleteForm(frmP);
+ if (ofmP)
+ FrmSetActiveForm(ofmP);
+ }
+ }
+ }
+
+ return errNone;
+}
+
+Err GamOpenDatabase() {
+ Err err = errNone;
+
+ gameDB = DmOpenDatabaseByTypeCreator( 'DATA', appFileCreator, dmModeReadWrite);
+
+ if (!gameDB) {
+ err = DmCreateDatabase(0, "ScummVM-Data", appFileCreator, 'DATA', false);
+ if (!err) {
+ gameDB = DmOpenDatabaseByTypeCreator( 'DATA', appFileCreator, dmModeReadWrite);
+
+ if (!gameDB)
+ err = DmGetLastErr();
+ }
+ }
+
+ if (err)
+ FrmCustomAlert(FrmErrorAlert,"Cannot open/create games list DB !",0,0);
+ else
+ err = GamUpdateList();
+
+ return err;
+}
+
+void GamImportDatabase() {
+ if (gPrefs->card.volRefNum != vfsInvalidVolRef && gPrefs->card.moveDB) {
+ FileRef file;
+ Err e;
+
+ e = VFSFileOpen(gPrefs->card.volRefNum, "/Palm/Programs/ScummVM/listdata.pdb", vfsModeRead, &file);
+ if (!e) {
+ UInt16 oCardNo, nCardNo;
+ LocalID oDbID, nDbID;
+
+ VFSFileClose(file);
+ if (gPrefs->card.confirmMoveDB)
+ if (FrmCustomAlert(FrmConfirmAlert, "Do you want to import games database from memory card ?", 0, 0) == FrmConfirmNo) {
+ // prevent to replace the file on memory card
+ gPrefs->card.moveDB = false;
+ return;
+ }
+
+ // get current db info and rename it
+ DmOpenDatabaseInfo(gameDB, &oDbID, 0, 0, &oCardNo, 0);
+ GamCloseDatabase(true);
+ e = DmDeleteDatabase(oCardNo, oDbID);
+
+ if (!e)
+ if (e = VFSImportDatabaseFromFile(gPrefs->card.volRefNum, "/Palm/Programs/ScummVM/listdata.pdb", &nCardNo, &nDbID))
+ FrmCustomAlert(FrmErrorAlert, "Failed to import games database from memory card.", 0, 0);
+
+ GamOpenDatabase();
+ }
+ }
+}
+
+void GamCloseDatabase(Boolean ignoreCardParams) {
+ if (gameDB) {
+ LocalID dbID;
+ UInt16 cardNo;
+
+ DmOpenDatabaseInfo(gameDB, &dbID, 0, 0, &cardNo, 0);
+ DmCloseDatabase(gameDB);
+
+ if (!ignoreCardParams) {
+ if (gPrefs->card.moveDB && gPrefs->card.volRefNum != vfsInvalidVolRef) {
+ VFSFileRename(gPrefs->card.volRefNum, "/Palm/Programs/ScummVM/listdata.pdb", "listdata-old.pdb");
+ Err e = VFSExportDatabaseToFile(gPrefs->card.volRefNum, "/Palm/Programs/ScummVM/listdata.pdb", cardNo, dbID);
+ if (!e) {
+ VFSFileDelete(gPrefs->card.volRefNum, "/Palm/Programs/ScummVM/listdata-old.pdb");
+ if (gPrefs->card.deleteDB)
+ DmDeleteDatabase(cardNo, dbID);
+ } else {
+ VFSFileRename(gPrefs->card.volRefNum, "/Palm/Programs/ScummVM/listdata-old.pdb", "listdata.pdb");
+ }
+ }
+ }
+ }
+ gameDB = NULL;
+}
+
+static Int16 GamCompare(GameInfoType *a, GameInfoType *b, SortRecordInfoPtr, SortRecordInfoPtr, MemHandle) {
+ return StrCaselessCompare(a->nameP, b->nameP);
+}
+
+Err GamSortList() {
+ return DmQuickSort (gameDB, (DmComparF *)GamCompare, 0);
+}
+
+void GamUnselect() {
+ GameInfoType *game;
+
+ MemHandle recordH;
+ UInt16 index;
+
+ index = GamGetSelected();
+
+ if (index != dmMaxRecordIndex) {
+ Boolean newValue;
+
+ recordH = DmGetRecord(gameDB, index);
+ game = (GameInfoType *)MemHandleLock(recordH);
+
+ newValue = false;
+ DmWrite(game, OffsetOf(GameInfoType,selected), &newValue, sizeof(Boolean));
+
+ MemHandleUnlock(recordH);
+ DmReleaseRecord (gameDB, index, 0);
+ }
+}
+
+UInt16 GamGetSelected() {
+ MemHandle record;
+ GameInfoType *game;
+ Boolean selected;
+ UInt16 index = DmNumRecords(gameDB)-1;
+
+ while (index != (UInt16)-1) {
+ record = DmQueryRecord(gameDB, index);
+ game = (GameInfoType *)MemHandleLock(record);
+ selected = game->selected;
+ MemHandleUnlock(record);
+
+ if (selected)
+ return index;
+
+ index--;
+ }
+
+ return dmMaxRecordIndex;
+}
+
+Boolean GamJumpTo(Char letter) {
+ MemHandle record;
+ GameInfoType *game;
+ Boolean found = false;
+ UInt16 index = 0;
+ UInt16 maxIndex = DmNumRecords(gameDB);
+ UInt16 active = GamGetSelected();
+
+ while (index < maxIndex) {
+ record = DmGetRecord(gameDB, index);
+ game = (GameInfoType *)MemHandleLock(record);
+
+ if (tolower(game->nameP[0]) == tolower(letter)) {
+ found = true;
+
+ if (index != active) {
+ RectangleType rArea;
+ UInt16 maxView;
+ Boolean newValue = true;
+
+ SknGetListBounds(&rArea, NULL);
+ maxView = rArea.extent.y / sknInfoListItemSize;
+
+ GamUnselect();
+ DmWrite(game, OffsetOf(GameInfoType,selected), &newValue, sizeof(Boolean));
+
+ if (index < gPrefs->listPosition || index >= (gPrefs->listPosition + maxView))
+ gPrefs->listPosition = index;
+ }
+ }
+
+ MemHandleUnlock(record);
+ DmReleaseRecord (gameDB, index, 0);
+
+ index++;
+
+ if (found)
+ return found;
+ }
+
+ return found;
+}
diff --git a/backends/platform/PalmOS/Src/launcher/games.h b/backends/platform/PalmOS/Src/launcher/games.h
new file mode 100644
index 0000000000..bb005e66fb
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/games.h
@@ -0,0 +1,201 @@
+/* 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 __GAMES_H__
+#define __GAMES_H__
+
+#define curItemVersion sysMakeROMVersion(3,5,5,0,0) // Added : AGI engine
+
+
+#define itemVersion_354 sysMakeROMVersion(3,5,4,0,0) // Added : Default/Auto music driver
+#define itemVersion_353 sysMakeROMVersion(3,5,3,0,0) // Added : CinE engine and 3DO platform
+#define itemVersion_352 sysMakeROMVersion(3,5,2,0,0) // Added : Lure engine
+#define itemVersion_351 sysMakeROMVersion(3,5,1,0,0) // Added : Sega CD platform
+#define itemVersion_350 sysMakeROMVersion(3,5,0,0,0)
+#define itemVersion_340 sysMakeROMVersion(3,4,0,0,0)
+#define itemVersion_330 sysMakeROMVersion(3,3,0,0,0)
+#define itemVersion_320 sysMakeROMVersion(3,2,0,0,0)
+#define itemVersion_310 sysMakeROMVersion(3,1,0,0,0)
+#define itemVersion_300 sysMakeROMVersion(3,0,0,0,0)
+#define itemVersion_270 sysMakeROMVersion(2,7,0,0,0)
+#define itemVersion_260 sysMakeROMVersion(2,6,0,0,0)
+#define itemVersion_250 sysMakeROMVersion(2,5,0,0,0)
+#define itemVersion_200 sysMakeROMVersion(2,0,0,0,0)
+
+// old config structs
+typedef struct {
+ UInt32 version;
+ UInt16 icnID; // icon to display on the list
+ Boolean selected;
+
+ Char nameP[50]; // game name to display in list
+ Char pathP[150]; // path to the game files
+ Char gameP[10]; // scumm name of the game
+ UInt16 gfxMode;
+
+ Boolean autoLoad;
+ UInt16 loadSlot;
+ Boolean bootParam;
+ UInt16 bootValue;
+ Boolean amiga;
+ Boolean subtitles;
+ Boolean talkSpeed;
+ UInt16 talkValue;
+ UInt8 language;
+
+} GameInfoTypeV0;
+
+typedef struct {
+ UInt32 version;
+ UInt16 icnID; // icon to display on the list
+ Boolean selected;
+
+ Char nameP[50]; // game name to display in list
+ Char pathP[150]; // path to the game files
+ Char gameP[10]; // scumm name of the game
+ UInt16 gfxMode;
+
+ Boolean autoLoad;
+ Boolean bootParam;
+ Boolean setPlatform;
+ Boolean subtitles;
+ Boolean talkSpeed;
+
+ UInt16 loadSlot;
+ UInt16 bootValue;
+ UInt16 talkValue;
+ UInt8 platform;
+ UInt8 language;
+
+} GameInfoTypeV2;
+
+
+// Current config
+typedef struct {
+ struct {
+ UInt16 palm;
+ UInt16 music;
+ UInt16 sfx; // TODO : remove
+ UInt16 speech;
+ UInt16 audiocd;
+ } volume;
+
+ struct {
+ // midi
+ Boolean multiMidi;
+ Boolean music; // TODO : rename this, it is enable audio option
+ UInt8 drvMusic;
+ UInt8 tempo;
+ // sound FX
+ Boolean sfx; // TODO : remove this
+ UInt8 rate;
+ // CD audio
+ Boolean CD;
+ UInt8 drvCD, frtCD;
+ UInt16 defaultTrackLength;
+ UInt16 firstTrack;
+ } sound;
+} MusicInfoType;
+
+typedef struct {
+ UInt32 version;
+ UInt16 icnID; // icon to display on the list
+ Boolean selected;
+
+ Char nameP[50]; // game name to display in list
+ Char pathP[150]; // path to the game files
+ Char gameP[15]; // scumm name of the game
+ UInt16 gfxMode;
+
+ Boolean autoLoad;
+ Boolean bootParam;
+ Boolean setPlatform;
+ Boolean subtitles;
+ Boolean talkSpeed;
+
+ UInt16 loadSlot;
+ UInt16 bootValue;
+ UInt16 talkValue;
+ UInt8 platform;
+ UInt8 language; // |- v2.5
+
+ Boolean filter; // v2.6
+ Boolean fullscreen; // |
+ Boolean aspectRatio; // |- v2.7
+
+ MusicInfoType musicInfo;// v3.0
+
+ UInt8 engine; // |- v3.1
+ UInt8 renderMode; // |- v3.2
+// Boolean use16Bit; // |- v3.3 // removed
+ UInt8 fmQuality; // |- v3.4 // replace use16Bit
+} GameInfoType;
+
+enum {
+ ENGINE_SKY = 0,
+ ENGINE_SWORD1,
+ ENGINE_SWORD2,
+ ENGINE_CINE,
+ ENGINE_QUEEN,
+ ENGINE_LURE,
+ ENGINE_GOB,
+ ENGINE_KYRA,
+ ENGINE_SAGA,
+ ENGINE_SCUMM,
+ ENGINE_AGI,
+ ENGINE_SIMON,
+ ENGINE_COUNT
+};
+
+static const struct {
+ const char *fileP;
+ const char *nameP;
+} engines[] = {
+ { "sky", "Beneath a Steel Sky" },
+ { "sword1", "Broken Sword 1" },
+ { "sword2", "Broken Sword 2" },
+ { "cine", "Delphine Cinematique v1.0" },
+ { "queen", "Flight of the Amazon Queen" },
+ { "lure", "Lure of the Tempress" },
+ { "gob", "Gobliiins" },
+ { "kyra", "Kyrandia" },
+ { "saga", "SAGA Engine" },
+ { "scumm", "Scumm Games" },
+ { "agi", "Sierra AGI" },
+ { "simon", "Simon the Sorcerer" },
+};
+
+
+// protos
+Err GamOpenDatabase ();
+void GamImportDatabase ();
+void GamCloseDatabase (Boolean ignoreCardParams);
+Err GamSortList ();
+UInt16 GamGetSelected ();
+void GamUnselect ();
+Boolean GamJumpTo (Char letter);
+
+extern DmOpenRef gameDB;
+
+#endif
diff --git a/backends/platform/PalmOS/Src/launcher/launch.cpp b/backends/platform/PalmOS/Src/launcher/launch.cpp
new file mode 100644
index 0000000000..c57738bb5f
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/launch.cpp
@@ -0,0 +1,517 @@
+/* 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 <PalmOS.h>
+#include "StarterRsc.h"
+
+#include "games.h"
+#include "start.h"
+#include "rumble.h"
+#include "extend.h"
+#include "globals.h"
+#include "features.h"
+#include "formUtil.h"
+#include "formCards.h"
+#include "palmdefs.h"
+
+#include "init_palmos.h"
+#include "init_stuffs.h"
+
+#include "modules.h"
+#include "args.h"
+
+
+#define BUILD_ERROR(m) \
+ { StrCopy(msg, m); \
+ StrCat(msg, "\n\nPlease check that all required files are installed on your card, and you have enough free storage memory."); \
+ goto onError; }
+
+#define BUILD_FILE(h,m) \
+ StrCopy(filename, "/Palm/Programs/ScummVM/Mods/"); \
+ StrCat(filename, h); \
+ StrCat(filename, m);
+
+#define CHECK_FILE(m) \
+ e = VFSFileOpen(volRefNum, filename, vfsModeRead, &file); \
+ if (e) \
+ BUILD_ERROR(m) \
+ else \
+ VFSFileClose(file);
+
+#define IMPRT_FILE(m) \
+ e = VFSImportDatabaseFromFile(volRefNum, filename, &cardNo, &dbID); \
+ if (e) \
+ BUILD_ERROR(m)
+
+#define DELET_FILE(f) \
+ del_dbID = DmFindDatabase(0, f); \
+ if (del_dbID) \
+ DmDeleteDatabase(0, del_dbID);
+
+void ModDelete() {
+ LocalID del_dbID;
+
+ DELET_FILE("Glbs::Common");
+ DELET_FILE("Glbs::Engine");
+ DELET_FILE("ScummVM-Engine");
+}
+
+static void ModSetStack(UInt32 newSize, UInt16 cardNo, LocalID dbID) {
+ DmOpenRef dbRef = DmOpenDatabase(cardNo, dbID, dmModeReadWrite);
+
+ if (dbRef) {
+ MemHandle pref = DmGetResource('pref',0);
+ UInt32 size = 0;
+
+ if (pref) {
+ SysAppPrefsType *data = (SysAppPrefsType *)MemHandleLock(pref);
+ size = data->stackSize;
+
+ if (newSize) {
+ SysAppPrefsType newData;
+ MemMove(&newData, data, sizeof(SysAppPrefsType));
+ newData.stackSize = newSize;
+ DmWrite(data, 0, &newData, sizeof(SysAppPrefsType));
+ }
+
+ MemPtrUnlock(data);
+ DmReleaseResource(pref);
+ }
+
+ DmCloseDatabase(dbRef);
+ }
+}
+
+static Err ModImport(UInt16 volRefNum, UInt8 engine, Boolean *armP) {
+#ifndef _DEBUG_ENGINE
+ char filename[256];
+ UInt16 cardNo;
+ LocalID dbID;
+ UInt32 result;
+ FileRef file;
+#endif
+ char msg[256];
+ FormPtr ofmP, frmP;
+ Err e = errNone;
+
+ ofmP = FrmGetActiveForm();
+ frmP = FrmInitForm(ImportForm);
+ FrmSetActiveForm(frmP);
+ FrmDrawForm(frmP);
+
+ // In debug mode, the engine files are directly uploaded to the simulator
+#ifndef _DEBUG_ENGINE
+ // engine file ?
+ BUILD_FILE(engines[engine].fileP, ".engine");
+ CHECK_FILE("ScummVM engine file was not found !");
+ IMPRT_FILE("Cannot import engine file !");
+
+ // need more files ?
+ dbID = DmFindDatabase(0, "ScummVM-Engine"); // be sure to have the correct dbID
+ e = SysAppLaunch(cardNo, dbID, 0, sysAppLaunchCustomEngineGetInfo, 0, &result);
+ *armP = ((result & GET_MODEARM) == GET_MODEARM);
+
+ // common file ?
+ if (!e && (result & GET_DATACOMMON)) {
+ BUILD_FILE("common", ".data");
+ CHECK_FILE("Common data file was not found !");
+ IMPRT_FILE("Cannot import common data file !");
+ }
+ // data file ?
+ if (!e && (result & GET_DATAENGINE)) {
+ BUILD_FILE(engines[engine].fileP, ".data");
+ CHECK_FILE("Engine data file was not found !");
+ IMPRT_FILE("Cannot import engine data file !");
+ }
+#endif
+ // if error, cleanup
+ if (e) ModDelete();
+
+onError:
+ FrmEraseForm(frmP);
+ FrmDeleteForm(frmP);
+ if (e) {
+ if (ofmP) FrmSetActiveForm(ofmP);
+ FrmCustomAlert(FrmErrorAlert, msg, 0, 0);
+ }
+
+ return e;
+}
+
+#undef DELET_FILE
+#undef CHECK_FILE
+#undef BUILD_FILE
+
+Boolean StartScummVM() {
+ Char **argvP;
+ UInt8 lightspeed, argc = 0;
+ UInt32 stackSize;
+ Boolean toLauncher, direct, isARM;
+ UInt8 engine;
+ Char num[6];
+
+ UInt16 index = GamGetSelected();
+
+ argvP = ArgsInit();
+ direct = false;
+
+ // start command line (exec name)
+ ArgsAdd(&argvP[argc], "-", NULL, &argc);
+
+ // no game selected
+ if (index == dmMaxRecordIndex) {
+ ListPtr listP;
+ UInt16 whichButton;
+
+ // init form
+ FormPtr frmP = FrmInitForm(EngineForm);
+ listP = (ListType *)FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, EngineListList));
+ itemsText = (Char **)MemPtrNew(ENGINE_COUNT * sizeof(Char *));
+
+ for (int i = 0; i < ENGINE_COUNT; i++)
+ itemsText[i] = (Char *)engines[i].nameP;
+
+ LstSetListChoices (listP, itemsText, ENGINE_COUNT);
+ LstSetSelection(listP, 0);
+
+ whichButton = FrmDoDialog(frmP);
+ engine = LstGetSelection(listP);
+
+ FrmDeleteForm(frmP);
+ MemPtrFree(itemsText);
+ itemsText = NULL;
+
+ if (whichButton == EngineCancelButton) {
+ if (bDirectMode) {
+ // and force exit if nothing selected
+ EventType event;
+ event.eType = keyDownEvent;
+ event.data.keyDown.chr = vchrLaunch;
+ event.data.keyDown.modifiers = commandKeyMask;
+ EvtAddUniqueEventToQueue(&event, 0, true);
+ }
+ // free args
+ ArgsFree(argvP);
+ return false;
+ }
+
+ // default values
+ if (bDirectMode)
+ gPrefs->card.volRefNum = parseCards(); // always use the first removable card available (?)
+ gVars->filter = true;
+ gVars->palmVolume = 50;
+ gVars->fmQuality = FM_QUALITY_INI;
+ direct = true;
+
+ // somthing selected
+ } else {
+ Char pathP[256];
+ MemHandle recordH;
+ GameInfoType *gameInfoP;
+
+ recordH = DmQueryRecord(gameDB,index);
+ gameInfoP = (GameInfoType *)MemHandleLock(recordH);
+ engine = gameInfoP->engine;
+
+ // build path
+ StrCopy(pathP,"/Palm/Programs/ScummVM/Games/");
+ if (gameInfoP->pathP[0] == '/')
+ StrCopy(pathP, gameInfoP->pathP);
+ else if (!(gameInfoP->pathP[0] == '.' && StrLen(gameInfoP->pathP) == 1))
+ StrCat(pathP, gameInfoP->pathP);
+
+ // path
+ ArgsAdd(&argvP[argc], "-p", pathP, &argc);
+
+ // language
+ if (gameInfoP->language > 0) {
+ const Char *lang = "zh\0cz\0gb\0en\0fr\0de\0hb\0it\0jp\0kr\0pl\0pt\0ru\0es\0se\0";
+ ArgsAdd(&argvP[argc], "-q", (lang + (gameInfoP->language - 1) * 3), &argc);
+ }
+
+ // fullscreen ?
+ if (gameInfoP->fullscreen)
+ ArgsAdd(&argvP[argc], "-f", NULL, &argc);
+
+ // aspect-ratio ?
+ ArgsAdd(&argvP[argc], (gameInfoP->aspectRatio ? "--aspect-ratio" : "--no-aspect-ratio"), NULL, &argc);
+
+ // gfx mode
+ gVars->filter = gameInfoP->filter;
+
+ switch (gameInfoP->renderMode) {
+ case 1:
+ ArgsAdd(&argvP[argc], "--render-mode=", "amiga", &argc);
+ break;
+ case 2:
+ ArgsAdd(&argvP[argc], "--render-mode=", "cga", &argc);
+ break;
+ case 3:
+ ArgsAdd(&argvP[argc], "--render-mode=", "ega", &argc);
+ break;
+ case 4:
+ ArgsAdd(&argvP[argc], "--render-mode=", "hercAmber", &argc);
+ break;
+ case 5:
+ ArgsAdd(&argvP[argc], "--render-mode=", "hercGreen", &argc);
+ break;
+ }
+
+ switch (gameInfoP->gfxMode) {
+ case 1:
+ ArgsAdd(&argvP[argc], "-g", "wide", &argc);
+ break;
+ default:
+ ArgsAdd(&argvP[argc], "-g", "1x", &argc);
+ break;
+ }
+
+ // load state
+ if (gameInfoP->autoLoad) {
+ StrIToA(num, gameInfoP->loadSlot);
+ ArgsAdd(&argvP[argc], "-x", num, &argc);
+ }
+ // boot script parameter
+ if (gameInfoP->bootParam) {
+ StrIToA(num, gameInfoP->bootValue);
+ ArgsAdd(&argvP[argc], "-b", num, &argc);
+ }
+ // not a PC version
+ if (gameInfoP->setPlatform) {
+ static const char *platform[] = {
+ "3do",
+ "acorn",
+ "amiga",
+ "atari",
+ "c64",
+ "pc",
+ "fmtowns",
+ "linux",
+ "mac",
+ "nes",
+ "segacd",
+ "windows"
+ };
+ ArgsAdd(&argvP[argc], "--platform=", platform[gameInfoP->platform], &argc);
+ }
+
+ // subtitles
+ if (gameInfoP->subtitles)
+ ArgsAdd(&argvP[argc], "-n", NULL, &argc);
+
+ // multi midi ?
+ if (gameInfoP->musicInfo.sound.multiMidi)
+ ArgsAdd(&argvP[argc], "--multi-midi", NULL, &argc);
+
+ if (engine == ENGINE_SCUMM) {
+ // music tempo
+ StrIToA(num, gameInfoP->musicInfo.sound.tempo);
+ ArgsAdd(&argvP[argc], "--tempo=", num, &argc);
+ }
+
+ // talk speed
+ if (gameInfoP->talkSpeed) {
+ StrIToA(num, gameInfoP->talkValue);
+ ArgsAdd(&argvP[argc], "--talkspeed=", num, &argc);
+ }
+
+ // music driver
+ if (gameInfoP->musicInfo.sound.music) {
+ static char *drv[] = {
+ "auto",
+ "null",
+ "adlib",
+ "towns",
+ "pcjr",
+ "native",
+ "pcspk"
+ };
+
+ if (StrCompare(drv[gameInfoP->musicInfo.sound.drvMusic], "native") == 0) {
+ if (OPTIONS_TST(kOptDeviceZodiac))
+ ArgsAdd(&argvP[argc], "-e", "zodiac", &argc); // Tapwave Zodiac
+ else if (OPTIONS_TST(kOptSonyPa1LibAPI))
+ ArgsAdd(&argvP[argc], "-e", "ypa1", &argc); // Pa1Lib devices
+ else
+ ArgsAdd(&argvP[argc], "-e", "auto", &argc); // no driver, switch to auto
+ } else {
+ ArgsAdd(&argvP[argc], "-e", drv[gameInfoP->musicInfo.sound.drvMusic], &argc);
+ }
+
+ // output rate
+ UInt32 rates[] = {4000, 8000, 11025, 22050, 44100};
+ StrIToA(num, rates[gameInfoP->musicInfo.sound.rate]);
+ ArgsAdd(&argvP[argc], "--output-rate=", num, &argc);
+
+ // FM quality
+ gVars->fmQuality = gameInfoP->fmQuality;
+
+ } else {
+ ArgsAdd(&argvP[argc], "-e", "null", &argc);
+ }
+
+ // volume control
+ StrIToA(num, gameInfoP->musicInfo.volume.sfx);
+ ArgsAdd(&argvP[argc], "-s", num, &argc);
+ StrIToA(num, gameInfoP->musicInfo.volume.music);
+ ArgsAdd(&argvP[argc], "-m", num, &argc);
+ StrIToA(num, gameInfoP->musicInfo.volume.speech);
+ ArgsAdd(&argvP[argc], "-r", num, &argc);
+
+ // game name
+ ArgsAdd(&argvP[argc], gameInfoP->gameP, NULL, &argc);
+
+ // others globals data
+ gVars->CD.enable = gameInfoP->musicInfo.sound.CD;
+ gVars->CD.driver = gameInfoP->musicInfo.sound.drvCD;
+ gVars->CD.format = gameInfoP->musicInfo.sound.frtCD;
+ gVars->CD.volume = gameInfoP->musicInfo.volume.audiocd;
+ gVars->CD.defaultTrackLength = gameInfoP->musicInfo.sound.defaultTrackLength;
+ gVars->CD.firstTrack = gameInfoP->musicInfo.sound.firstTrack;
+ gVars->palmVolume = gameInfoP->musicInfo.sound.music ? gameInfoP->musicInfo.volume.palm : 0;
+
+ MemHandleUnlock(recordH);
+ } // end no game / game selected
+
+ // common command line options
+
+ // debug level
+ if (gPrefs->debug) {
+ StrIToA(num, gPrefs->debugLevel);
+ ArgsAdd(&argvP[argc], "-d", num, &argc);
+ }
+
+ if (engine == ENGINE_QUEEN || engine == ENGINE_SKY) {
+ // alternative intro ?
+ if (gPrefs->altIntro)
+ ArgsAdd(&argvP[argc], "--alt-intro", NULL, &argc);
+ }
+
+ if (engine == ENGINE_SCUMM) {
+ // demo mode ?
+ if (gPrefs->demoMode)
+ ArgsAdd(&argvP[argc], "--demo-mode", NULL, &argc);
+ }
+
+ // copy protection ?
+ if (gPrefs->copyProtection)
+ ArgsAdd(&argvP[argc], "--copy-protection", NULL, &argc);
+
+ // exceed max args ?
+ if (argc > MAX_ARG)
+ FrmCustomAlert(FrmErrorAlert, "Too many parameters.",0,0);
+
+ // set some common options
+ stackSize = (gPrefs->setStack ? STACK_LARGER : STACK_DEFAULT);
+ lightspeed= (gPrefs->lightspeed.enable ? gPrefs->lightspeed.mode : 255);
+ toLauncher= (gPrefs->exitLauncher);
+
+ // gVars values
+ // (gVars->HRrefNum defined in checkHRmode on Clié)
+ gVars->VFS.volRefNum = gPrefs->card.volRefNum;
+ gVars->vibrator = gPrefs->vibrator;
+ gVars->stdPalette = gPrefs->stdPalette;
+ gVars->VFS.cacheSize = (gPrefs->card.useCache ? gPrefs->card.cacheSize : 0);
+ gVars->indicator.showLED= gPrefs->card.showLED;
+ gVars->stylusClick = gPrefs->stylusClick;
+ gVars->autoSave = (gPrefs->autoSave ? gPrefs->autoSavePeriod : -1);
+ gVars->advancedMode = gPrefs->advancedMode;
+ gVars->arrowKeys = gPrefs->arrowKeys;
+
+ // user params
+ HWR_RSTALL();
+
+ if (gPrefs->goLCD)
+ HWR_SET(INIT_GOLCD);
+ else
+ OPTIONS_RST(kOptGoLcdAPI);
+
+ if (!gPrefs->autoOff)
+ HWR_SET(INIT_AUTOOFF);
+
+ if (gVars->vibrator)
+ HWR_SET(INIT_VIBRATOR);
+/* ????
+ if ( musicDriver == 1 ||
+ musicDriver == 3 ||
+ musicDriver == 4 ||
+ musicDriver == sysInvalidRefNum) {
+ HWR_SET(INIT_PA1LIB);
+ }
+*/
+ if (ModImport(gVars->VFS.volRefNum, engine, &isARM) != errNone) {
+ if (bDirectMode) {
+ // and force exit if nothing selected
+ EventType event;
+ event.eType = keyDownEvent;
+ event.data.keyDown.chr = vchrLaunch;
+ event.data.keyDown.modifiers = commandKeyMask;
+ EvtAddUniqueEventToQueue(&event, 0, true);
+ }
+ ArgsFree(argvP);
+ return false;
+ }
+
+ // reset mode if screen rotation occured (DIA only)
+ if (!direct && OPTIONS_TST(kOptCollapsible)) {
+ UInt8 mode = PalmScreenSize(0,0, &(gVars->screenFullWidth), &(gVars->screenFullHeight));
+ OPTIONS_RST(kOptModeLandscape);
+ OPTIONS_SET((mode == PALM_LANDSCAPE) ? kOptModeLandscape : kOptNone);
+ }
+
+ // free and save globals pref memory
+ GamCloseDatabase(false);
+ FrmCloseAllForms();
+ SavePrefs();
+
+ {
+ UInt16 cardNo;
+ UInt32 dbID;
+
+ LaunchParamType *cmdPBP = (LaunchParamType *)MemPtrNew(sizeof(LaunchParamType));
+
+ MemPtrSetOwner(cmdPBP, 0);
+ MemPtrSetOwner(gVars, 0);
+ ArgsSetOwner(argvP, 0);
+
+ cardNo = 0;
+ dbID = DmFindDatabase(0, "ScummVM-Engine");
+
+ if (isARM)
+ FtrSet(appFileCreator, ftrStack , (stackSize * 4));
+ else
+ ModSetStack(stackSize, cardNo, dbID);
+
+ cmdPBP->args.argc = argc;
+ cmdPBP->args.argv = argvP;
+ cmdPBP->gVars = gVars;
+ cmdPBP->lightspeed = lightspeed;
+ cmdPBP->exitLauncher = toLauncher;
+
+ SysUIAppSwitch(cardNo, dbID, sysAppLaunchCmdNormalLaunch, cmdPBP);
+ bLaunched = true;
+ }
+
+ return false;
+}
diff --git a/backends/platform/PalmOS/Src/launcher/skin.cpp b/backends/platform/PalmOS/Src/launcher/skin.cpp
new file mode 100644
index 0000000000..f38fe88d46
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/skin.cpp
@@ -0,0 +1,611 @@
+/* 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 <PalmOS.h>
+#include <PalmOSGlue.h>
+#include <SonyClie.h>
+
+#include "start.h"
+#include "games.h"
+#include "globals.h"
+#include "skin.h"
+#include "StarterRsc.h"
+
+UInt16 lastIndex = dmMaxRecordIndex; // last select index in the list to prevent flash
+static WinHandle winLockH = NULL;
+
+MemPtr SknScreenLock(WinLockInitType initMode) {
+ Err e;
+ RectangleType r;
+
+ WinGetBounds(WinGetDisplayWindow(), &r);
+ winLockH = WinCreateOffscreenWindow(r.extent.x, r.extent.y, nativeFormat, &e);
+ WinSetDrawWindow(winLockH);
+
+ if (initMode == winLockCopy)
+ WinCopyRectangle(WinGetDisplayWindow(), winLockH, &r, 0, 0, winPaint);
+
+ return BmpGetBits(WinGetBitmap(winLockH));
+}
+
+void SknScreenUnlock() {
+ RectangleType r;
+
+ WinGetBounds(winLockH, &r);
+ WinCopyRectangle(winLockH, WinGetDisplayWindow(), &r, 0, 0, winPaint);
+ WinSetDrawWindow(WinGetDisplayWindow());
+ WinDeleteWindow(winLockH, false);
+ winLockH = NULL;
+}
+
+static void SknGetListColors(DmOpenRef skinDBP, UInt8 *text, UInt8 *selected, UInt8 *background) {
+ UInt16 colIndex;
+ MemHandle colH;
+ UInt8 *colTemp;
+
+ // default
+ *text = UIColorGetTableEntryIndex (UIMenuForeground);
+ *selected = UIColorGetTableEntryIndex (UIMenuSelectedForeground);
+ *background = UIColorGetTableEntryIndex (UIMenuSelectedFill);
+
+ if (skinDBP) {
+ colIndex = DmFindResource (skinDBP, sknColorsRsc, skinColors, NULL);
+
+ if (colIndex != (UInt16)-1) {
+ colH = DmGetResourceIndex(skinDBP, colIndex);
+
+ if (colH) {
+ colTemp = (UInt8 *)MemHandleLock(colH);
+
+ *text = colTemp[0];
+ *selected = colTemp[1];
+ *background = colTemp[2];
+
+ MemPtrUnlock(colTemp);
+ DmReleaseResource(colH);
+ }
+ }
+ }
+}
+
+static void SknCopyBits(DmOpenRef skinDBP, DmResID bitmapID, const RectangleType *srcRect, Coord destX, Coord destY) {
+ MemHandle hTemp;
+ BitmapPtr bmpTemp;
+ UInt16 index;
+
+ Coord cx, cy, cw, ch, bw, bh;
+ RectangleType copy, old;
+
+ if (skinDBP) {
+ // find the bitmap
+ index = DmFindResource (skinDBP, bitmapRsc, bitmapID, NULL);
+
+ if (index != (UInt16)-1) {
+ hTemp = DmGetResourceIndex(skinDBP,index);
+
+ if (hTemp) {
+ bmpTemp = (BitmapType *)MemHandleLock(hTemp);
+ BmpGlueGetDimensions(bmpTemp, &bw, &bh, 0);
+
+ if (!srcRect) {
+ cx = 0;
+ cy = 0;
+ cw = bw;
+ ch = bh;
+ } else {
+ cx = srcRect->topLeft.x;
+ cy = srcRect->topLeft.y;
+ cw = srcRect->extent.x;
+ ch = srcRect->extent.y;
+ }
+
+ if (ch) {
+ WinGetClip(&old);
+ if (OPTIONS_TST(kOptModeHiDensity)) {
+ Err e;
+ BitmapTypeV3 *bmp2P;
+
+ // create an uncompressed version of the bitmap
+ WinHandle win = WinCreateOffscreenWindow(bw, bh, screenFormat, &e);
+ WinHandle old = WinGetDrawWindow();
+ WinSetDrawWindow(win);
+ WinDrawBitmap(bmpTemp, 0, 0);
+ WinSetDrawWindow(old);
+
+ bmp2P = BmpCreateBitmapV3(WinGetBitmap(win), kDensityDouble, BmpGetBits(WinGetBitmap(win)), NULL);
+
+ copy.topLeft.x = destX / 2;
+ copy.topLeft.y = destY / 2;
+ copy.extent.x = cw / 2;
+ copy.extent.y = ch / 2;
+
+ WinSetClip(&copy);
+ WinDrawBitmap((BitmapPtr)bmp2P, (destX - cx) / 2, (destY - cy) / 2);
+ BmpDelete((BitmapPtr)bmp2P);
+ WinDeleteWindow(win, false);
+
+ } else {
+ copy.topLeft.x = destX;
+ copy.topLeft.y = destY;
+ copy.extent.x = cw;
+ copy.extent.y = ch;
+
+ HRWinSetClip(gVars->HRrefNum, &copy);
+ HRWinDrawBitmap(gVars->HRrefNum, bmpTemp, destX - cx, destY - cy);
+ }
+ WinSetClip(&old);
+ }
+
+ MemPtrUnlock(bmpTemp);
+ DmReleaseResource(hTemp);
+ }
+ }
+ }
+}
+
+void SknApplySkin() {
+ DmOpenRef skinDBP;
+ RectangleType r;
+ FormPtr frmP = FrmGetActiveForm();
+
+ // draw skin
+ FrmDrawForm(frmP);
+ SknScreenLock(winLockCopy);
+
+ skinDBP = SknOpenSkin();
+
+ if (gPrefs->card.volRefNum != vfsInvalidVolRef)
+ FrmShowObject(frmP, FrmGetObjectIndex (frmP, MainMSBitMap));
+ else
+ FrmShowObject(frmP, FrmGetObjectIndex (frmP, MainMSNoneBitMap));
+
+ WinSetForeColor(255);
+ WinSetDrawMode(winPaint);
+ WinDrawLine (0, 14, 159, 14);
+ WinDrawLine (0, 13, 159, 13);
+
+ SknGetObjectBounds(skinDBP, skinBackgroundImageTop, &r);
+ SknCopyBits(skinDBP, skinBackgroundImageTop, 0, r.topLeft.x, r.topLeft.y);
+ SknGetObjectBounds(skinDBP, skinBackgroundImageBottom, &r);
+ SknCopyBits(skinDBP, skinBackgroundImageBottom, 0, r.topLeft.x, r.topLeft.y);
+
+ for (UInt16 resID = 1100; resID <= 7000; resID += 100) {
+ SknSetState(skinDBP, resID, sknStateNormal);
+ SknShowObject(skinDBP, resID);
+ }
+
+ SknCloseSkin(skinDBP);
+ SknScreenUnlock();
+ SknUpdateList();
+}
+
+void SknGetObjectBounds(DmOpenRef skinDBP, DmResID resID, RectangleType *rP) {
+
+ UInt16 bmpIndex, strIndex;
+ MemHandle hBmp, hStr;
+ BitmapType *bmpTemp;
+ UInt8 *strTemp;
+
+ RctSetRectangle(rP, 0, 0, 0, 0);
+
+ if (skinDBP) {
+ bmpIndex = DmFindResource (skinDBP, bitmapRsc, resID, NULL);
+
+ if (bmpIndex != (UInt16)-1) { // if bmp exists
+ strIndex = DmFindResource (skinDBP, sknPosRsc, resID, NULL);
+
+ if (strIndex != (UInt16)-1) { // if params exist
+ hBmp = DmGetResourceIndex(skinDBP,bmpIndex);
+
+ if (hBmp) {
+ hStr = DmGetResourceIndex(skinDBP,strIndex);
+
+ if (hStr) {
+ // buttons : state|x|y|w/h slider|draw mode|x1/y1 keep|x2/y2 keep slider
+ // list (160mode) : state|x|y|w|h|
+ bmpTemp = (BitmapType *)MemHandleLock(hBmp);
+ strTemp = (UInt8 *)MemHandleLock(hStr);
+
+ BmpGlueGetDimensions(bmpTemp, &(rP->extent.x), &(rP->extent.y), 0);
+ rP->topLeft.x = strTemp[sknInfoPosX] * 2;
+ rP->topLeft.y = strTemp[sknInfoPosY] * 2;
+
+ MemPtrUnlock(strTemp);
+ DmReleaseResource(hStr);
+ }
+
+ MemPtrUnlock(bmpTemp);
+ DmReleaseResource(hBmp);
+ }
+ }
+ }
+ }
+}
+
+DmOpenRef SknOpenSkin() {
+ return DmOpenDatabase(gPrefs->skin.cardNo, gPrefs->skin.dbID, dmModeReadOnly);
+}
+
+void SknCloseSkin(DmOpenRef skinDBP) {
+ if (skinDBP)
+ DmCloseDatabase(skinDBP);
+}
+
+UInt8 SknSetState(DmOpenRef skinDBP, DmResID resID, UInt8 newState) {
+
+ UInt16 index;
+ MemHandle hStr;
+ UInt8 *strTemp;
+ UInt8 oldState = 0;
+
+ if (skinDBP) {
+ index = DmFindResource (skinDBP, sknPosRsc, resID, NULL);
+
+ if (index != (UInt16)-1) {
+ hStr = DmGetResourceIndex(skinDBP, index);
+
+ if (hStr) {
+ strTemp = (UInt8 *)MemHandleLock(hStr);
+ oldState = strTemp[sknInfoState];
+
+ if (oldState != newState) {
+ DmWrite(strTemp, 0, &newState, 1);
+ }
+
+ MemPtrUnlock(strTemp);
+ DmReleaseResource(hStr);
+ }
+ }
+ }
+
+ return oldState;
+}
+
+UInt8 SknGetDepth(DmOpenRef skinDBP) {
+ UInt16 index;
+ MemHandle hStr;
+ UInt8 *strTemp;
+ UInt8 depth = 8;
+
+ if (skinDBP) {
+ index = DmFindResource (skinDBP, sknDepthRsc, skinDepth, NULL);
+
+ if (index != (UInt16)-1) {
+ hStr = DmGetResourceIndex(skinDBP, index);
+
+ if (hStr) {
+ strTemp = (UInt8 *)MemHandleLock(hStr);
+ depth = *strTemp;
+ MemPtrUnlock(strTemp);
+ DmReleaseResource(hStr);
+ }
+ }
+ }
+
+ return depth;
+}
+
+UInt8 SknGetState(DmOpenRef skinDBP, DmResID resID) {
+ UInt16 index;
+ MemHandle hStr;
+ UInt8 *strTemp;
+ UInt8 oldState = sknStateDisabled;
+
+ if (skinDBP) {
+ index = DmFindResource (skinDBP, sknPosRsc, resID, NULL);
+
+ if (index != (UInt16)-1) {
+ hStr = DmGetResourceIndex(skinDBP, index);
+
+ if (hStr) {
+ strTemp = (UInt8 *)MemHandleLock(hStr);
+ oldState = strTemp[sknInfoState];
+ MemPtrUnlock(strTemp);
+ DmReleaseResource(hStr);
+ }
+ }
+ }
+
+ return oldState;
+}
+
+void SknShowObject(DmOpenRef skinDBP, DmResID resID) {
+ RectangleType r;
+ UInt8 state = SknGetState(skinDBP, resID);
+ SknGetObjectBounds(skinDBP, resID, &r);
+ SknCopyBits(skinDBP, resID + state, NULL, r.topLeft.x, r.topLeft.y);
+}
+
+void SknGetListBounds(RectangleType *rAreaP, RectangleType *rArea2xP) {
+ DmOpenRef skinDBP;
+ UInt16 strIndex;
+ MemHandle hStr;
+ UInt8 *strTemp;
+ UInt16 x,y,w,h;
+
+ skinDBP = DmOpenDatabase(gPrefs->skin.cardNo, gPrefs->skin.dbID, dmModeReadOnly);
+ if (skinDBP) {
+ strIndex = DmFindResource (skinDBP, sknPosRsc, skinList, NULL);
+
+ if (strIndex != 0xFFFF) { // if params exist
+ hStr = DmGetResourceIndex(skinDBP,strIndex);
+ if (hStr) {
+ strTemp = (UInt8 *)MemHandleLock(hStr);
+
+ x = strTemp[sknInfoPosX];
+ y = strTemp[sknInfoPosY];
+ w = strTemp[sknInfoListWidth];
+ h = strTemp[sknInfoListSize] * sknInfoListItemSize;
+
+ if (rAreaP)
+ RctSetRectangle(rAreaP ,x, y, w, h);
+ if (rArea2xP)
+ RctSetRectangle(rArea2xP, x+x, y+y, w+w, h+h);
+
+ MemHandleUnlock(hStr);
+ DmReleaseResource(hStr);
+ }
+ }
+
+ DmCloseDatabase(skinDBP);
+ }
+}
+
+static void SknRedrawTools(DmOpenRef skinDBP) {
+ if (GamGetSelected() == dmMaxRecordIndex) {
+ if (SknGetState(skinDBP, skinButtonGameDelete) == sknStateNormal) {
+ SknSetState(skinDBP, skinButtonGameDelete,sknStateDisabled);
+ SknShowObject(skinDBP, skinButtonGameDelete);
+ }
+ if (SknGetState(skinDBP, skinButtonGameEdit) == sknStateNormal) {
+ SknSetState(skinDBP, skinButtonGameEdit,sknStateDisabled);
+ SknShowObject(skinDBP, skinButtonGameEdit);
+ }
+ if (SknGetState(skinDBP, skinButtonGameAudio) == sknStateNormal) {
+ SknSetState(skinDBP, skinButtonGameAudio,sknStateDisabled);
+ SknShowObject(skinDBP, skinButtonGameAudio);
+ }
+
+ } else {
+ if (SknGetState(skinDBP, skinButtonGameDelete) == sknStateDisabled) {
+ SknSetState(skinDBP, skinButtonGameDelete,sknStateNormal);
+ SknShowObject(skinDBP, skinButtonGameDelete);
+ }
+ if (SknGetState(skinDBP, skinButtonGameEdit) == sknStateDisabled) {
+ SknSetState(skinDBP, skinButtonGameEdit,sknStateNormal);
+ SknShowObject(skinDBP, skinButtonGameEdit);
+ }
+ if (SknGetState(skinDBP, skinButtonGameAudio) == sknStateDisabled) {
+ SknSetState(skinDBP, skinButtonGameAudio,sknStateNormal);
+ SknShowObject(skinDBP, skinButtonGameAudio);
+ }
+ }
+}
+
+static void SknRedrawSlider(DmOpenRef skinDBP, UInt16 index, UInt16 maxIndex, UInt16 perPage) {
+ if (maxIndex <= perPage) {
+ if (SknGetState(skinDBP,skinSliderUpArrow) != sknStateDisabled) {
+ SknSetState(skinDBP,skinSliderUpArrow,sknStateDisabled);
+ SknShowObject(skinDBP,skinSliderUpArrow);
+ }
+ if (SknGetState(skinDBP,skinSliderDownArrow) != sknStateDisabled) {
+ SknSetState(skinDBP,skinSliderDownArrow,sknStateDisabled);
+ SknShowObject(skinDBP,skinSliderDownArrow);
+ }
+
+ } else {
+ if (SknGetState(skinDBP,skinSliderUpArrow) == sknStateDisabled) {
+ SknSetState(skinDBP,skinSliderUpArrow,sknStateNormal);
+ SknShowObject(skinDBP,skinSliderUpArrow);
+ }
+ if (SknGetState(skinDBP,skinSliderDownArrow) == sknStateDisabled) {
+ SknSetState(skinDBP,skinSliderDownArrow,sknStateNormal);
+ SknShowObject(skinDBP,skinSliderDownArrow);
+ }
+ }
+}
+
+void SknUpdateList() {
+ MemHandle record;
+ Int32 index, maxIndex, maxView;
+ GameInfoType *game;
+ RectangleType rArea, rField, rCopy, rArea2x;
+ DmOpenRef skinDBP;
+
+ UInt8 txtColor, norColor, selColor, bkgColor;
+ UInt16 x,y;
+
+ SknScreenLock(winLockCopy);
+
+ SknGetListBounds(&rArea, &rArea2x);
+ skinDBP = SknOpenSkin();
+ // set default bg
+ WinSetForeColor(UIColorGetTableEntryIndex (UIFormFill));
+ WinDrawRectangle(&rArea,0);
+ // copy top bg
+ SknGetObjectBounds(skinDBP, skinBackgroundImageTop, &rField);
+ RctGetIntersection(&rArea2x, &rField, &rCopy);
+ x = rCopy.topLeft.x;
+ y = rCopy.topLeft.y;
+ rCopy.topLeft.x -= rField.topLeft.x;
+ rCopy.topLeft.y -= rField.topLeft.y;
+ SknCopyBits(skinDBP, skinBackgroundImageTop, &rCopy, x, y);
+ // copy bottom bg
+ SknGetObjectBounds(skinDBP, skinBackgroundImageBottom, &rField);
+ RctGetIntersection(&rArea2x, &rField, &rCopy);
+ x = rCopy.topLeft.x;
+ y = rCopy.topLeft.y;
+ rCopy.topLeft.x -= rField.topLeft.x;
+ rCopy.topLeft.y -= rField.topLeft.y;
+ SknCopyBits(skinDBP, skinBackgroundImageBottom, &rCopy, x, y);
+
+ FntSetFont(stdFont);
+
+ index = gPrefs->listPosition;
+ maxIndex = DmNumRecords(gameDB);
+ maxView = rArea.extent.y / sknInfoListItemSize;
+
+ if (index > 0 && (index + maxView) > maxIndex)
+ index -= (index + maxView) - maxIndex;
+
+ if (index < 0)
+ index = 0;
+
+ gPrefs->listPosition = index;
+
+ SknRedrawSlider(skinDBP, index, maxIndex, maxView);
+ SknRedrawTools(skinDBP);
+ SknGetListColors(skinDBP, &norColor, &selColor, &bkgColor);
+
+ SknCloseSkin(skinDBP);
+
+ while (index < (gPrefs->listPosition + maxView) && index < maxIndex) {
+ record = DmQueryRecord(gameDB, index);
+ game = (GameInfoType *)MemHandleLock(record);
+
+ // text box
+ RctSetRectangle(&rField, rArea.topLeft.x, (rArea.topLeft.y + sknInfoListItemSize * (index - gPrefs->listPosition)), rArea.extent.x, sknInfoListItemSize);
+ WinSetClip(&rField);
+
+ if (game->selected) {
+ WinSetDrawMode(winPaint);
+ WinSetForeColor(bkgColor);
+ WinDrawRectangle(&rField,0);
+ txtColor = selColor;
+ }
+ else
+ txtColor = norColor;
+
+ // clipping
+ rField.topLeft.x += 2;
+ rField.extent.x -= 4;
+ WinSetClip(&rField);
+ // draw text mask
+ WinSetTextColor(255);
+ WinSetDrawMode(winMask);
+ WinPaintChars(game->nameP, StrLen(game->nameP), rField.topLeft.x, rField.topLeft.y);
+ // draw text
+ if (txtColor) {
+ WinSetTextColor(txtColor);
+ WinSetDrawMode(winOverlay);
+ WinPaintChars(game->nameP, StrLen(game->nameP), rField.topLeft.x, rField.topLeft.y);
+ }
+
+ MemHandleUnlock(record);
+ index++;
+ }
+
+ RctSetRectangle(&rArea,0,0,160,160);
+ WinSetClip(&rArea);
+ SknScreenUnlock();
+}
+
+UInt16 SknCheckClick(DmOpenRef skinDBP, Coord mx, Coord my) {
+ UInt16 resID;
+ RectangleType r;
+
+ mx *= 2;
+ my *= 2;
+
+ if (skinDBP) {
+ for (resID = 1100; resID <= 7000; resID += 100) {
+ if (SknGetState(skinDBP, resID) != sknStateDisabled) {
+ SknGetObjectBounds(skinDBP, resID, &r);
+ if (RctPtInRectangle(mx, my, &r)) {
+ return resID;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+void SknSelect(Coord x, Coord y) {
+ RectangleType rArea;
+ SknGetListBounds(&rArea,0);
+
+ if (RctPtInRectangle(x, y, &rArea)) {
+ UInt16 index;
+ MemHandle record;
+ GameInfoType *game;
+ UInt16 oldIndex;
+
+ index = (y - rArea.topLeft.y) / sknInfoListItemSize + gPrefs->listPosition;
+
+ if (index == lastIndex)
+ return;
+
+ if (index < DmNumRecords(gameDB)) {
+ Boolean newValue;
+
+ oldIndex = GamGetSelected();
+
+ if (oldIndex != index && oldIndex != dmMaxRecordIndex)
+ GamUnselect();
+
+ record = DmGetRecord(gameDB, index);
+ game = (GameInfoType *)MemHandleLock(record);
+
+ newValue = !game->selected;
+ DmWrite(game, OffsetOf(GameInfoType,selected), &newValue, sizeof(Boolean));
+
+ MemHandleUnlock(record);
+ DmReleaseRecord (gameDB, index, 0);
+
+ lastIndex = index;
+ SknUpdateList();
+ }
+ }
+}
+
+Boolean SknProcessArrowAction(UInt16 button) {
+ Boolean handled = false;
+
+ switch (button) {
+ case skinSliderUpArrow:
+ if (gPrefs->listPosition > 0) {
+ gPrefs->listPosition--;
+ SknUpdateList();
+ }
+ handled = true;
+ break;
+
+ case skinSliderDownArrow:
+ RectangleType rArea;
+ UInt16 maxView;
+
+ SknGetListBounds(&rArea, 0);
+ maxView = rArea.extent.y / sknInfoListItemSize;
+
+ if (gPrefs->listPosition < DmNumRecords(gameDB)-maxView) {
+ gPrefs->listPosition++;
+ SknUpdateList();
+ }
+ handled = true;
+ break;
+ }
+
+ return handled;
+}
diff --git a/backends/platform/PalmOS/Src/launcher/skin.h b/backends/platform/PalmOS/Src/launcher/skin.h
new file mode 100644
index 0000000000..2047532fd8
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/skin.h
@@ -0,0 +1,130 @@
+/* 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 __SKIN_H__
+#define __SKIN_H__
+
+// skin
+#define sknInfoState 0
+#define sknInfoPosX 1
+#define sknInfoPosY 2
+
+#define sknInfoMaxWOrH 3
+#define sknInfoDrawMode 4
+#define sknInfoKeepXOrY1 5
+#define sknInfoKeepXOrY2 7
+
+#define sknInfoListWidth sknInfoMaxWOrH
+#define sknInfoListHeight sknInfoDrawMode
+#define sknInfoListSize sknInfoListHeight
+#define sknInfoListItemSize 12
+
+#define sknPosRsc 'sPos'
+#define sknColorsRsc 'sCol'
+#define sknDepthRsc 'sDep'
+
+#define sknStateNormal 0
+#define sknStateSelected 10
+#define sknStateDisabled 20
+
+#define sknSelectedState(bmp) (bmp + sknStateSelected)
+#define sknDisabledState(bmp) (bmp + sknStateDisabled)
+
+// skin elements
+#define skinList 500
+#define skinColors 600
+#define skinDepth 700
+
+#define skinButtonNone 0
+
+#define skinSliderUpArrow 2000
+#define skinSliderDownArrow 2100
+
+#define skinButtonGameParams 3000
+#define skinButtonGameAdd 3100
+#define skinButtonGameEdit 3200
+#define skinButtonGameAudio 3300
+#define skinButtonGameDelete 4000
+#define skinButtonGameStart 7000
+
+#define skinBackgroundImageTop 1000
+#define skinBackgroundImageBottom 1010
+///
+
+
+#define skinToolsBackground 1100
+
+#define skinListUpArrowNormal 1500
+#define skinListUpArrowOver 1510
+#define skinListUpArrowDisabled 1540
+
+#define skinListDownArrowNormal 1800
+#define skinListDownArrowOver 1810
+#define skinListDownArrowDisabled 1840
+
+#define skinButtonGameInfoNormal 2000
+#define skinButtonGameInfoOver 2010
+#define skinButtonGameInfoDisabled 2040
+
+#define skinButtonGameParamNormal 3000
+#define skinButtonGameParamOver 3010
+
+#define skinButtonGameDeleteNormal 4000
+#define skinButtonGameDeleteOver 4010
+#define skinButtonGameDeleteDisabled 4040
+
+#define skinButtonVibratorNormal 5000
+#define skinButtonVibratorOver 5010
+#define skinButtonVibratorSelected 5020
+#define skinButtonVibratorSelectedOver 5030
+#define skinButtonVibratorDisabled 5040
+
+
+#define skinButtonSleepNormal 6000
+#define skinButtonSleepOver 6010
+#define skinButtonSleepSelected 6020
+#define skinButtonSleepSelectedOver 9030
+
+#define skinButtonPlayNormal 7000
+#define skinButtonPlayOver 7010
+#define skinButtonPlayDisabled 7040
+
+// protos
+void SknApplySkin();
+void SknGetObjectBounds(DmOpenRef skinDBP, DmResID resID, RectangleType *rP);
+DmOpenRef SknOpenSkin();
+void SknCloseSkin(DmOpenRef skinDBP);
+UInt8 SknSetState(DmOpenRef skinDBP, DmResID resID, UInt8 newState);
+void SknShowObject(DmOpenRef skinDBP, DmResID resID);
+UInt8 SknGetState(DmOpenRef skinDBP, DmResID resID);
+void SknUpdateList();
+void SknGetListBounds(RectangleType *rAreaP, RectangleType *rArea2xP);
+UInt16 SknCheckClick(DmOpenRef skinDBP, Coord mx, Coord my);
+void SknSelect(Coord x, Coord y);
+Boolean SknProcessArrowAction(UInt16 button);
+UInt8 SknGetDepth(DmOpenRef skinDBP);
+
+extern UInt16 lastIndex;
+
+#endif
diff --git a/backends/platform/PalmOS/Src/launcher/start.cpp b/backends/platform/PalmOS/Src/launcher/start.cpp
new file mode 100644
index 0000000000..076c24d6c2
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/start.cpp
@@ -0,0 +1,366 @@
+/* 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 <PalmOS.h>
+#include <SonyClie.h>
+
+#include "palmdefs.h"
+#include "start.h"
+#include "games.h"
+#include "globals.h"
+#include "modules.h"
+#include "skin.h"
+
+#include "forms.h"
+
+/***********************************************************************
+ *
+ * Global variables
+ *
+ ***********************************************************************/
+GlobalsPreferencePtr gPrefs;
+GlobalsDataPtr gVars;
+
+Boolean bDirectMode = false;
+Boolean bStartScumm = false;
+Boolean bLaunched = false;
+
+/***********************************************************************
+ *
+ * Internal Constants
+ *
+ ***********************************************************************/
+
+// Define the minimum OS version we support (3.5 for now).
+#define kOurMinVersion sysMakeROMVersion(3,5,0,sysROMStageRelease,0)
+#define kPalmOS10Version sysMakeROMVersion(1,0,0,sysROMStageRelease,0)
+
+/***********************************************************************
+ *
+ * Internal Functions
+ *
+ ***********************************************************************/
+
+// Callback for ExgDBWrite to send data with Exchange Manager
+static Err WriteDBData(const void* dataP, UInt32* sizeP, void* userDataP) {
+ Err err;
+ *sizeP = ExgSend((ExgSocketPtr)userDataP, (void*)dataP, *sizeP, &err);
+ return err;
+}
+
+Err SendDatabase (UInt16 cardNo, LocalID dbID, Char *nameP, Char *descriptionP) {
+ ExgSocketType exgSocket;
+ Err err;
+
+ // Create exgSocket structure
+ MemSet(&exgSocket, sizeof(exgSocket), 0);
+ exgSocket.description = descriptionP;
+ exgSocket.name = nameP;
+
+ // Start an exchange put operation
+ err = ExgPut(&exgSocket);
+ if (!err) {
+ err = ExgDBWrite(WriteDBData, &exgSocket, NULL, dbID, cardNo);
+ err = ExgDisconnect(&exgSocket, err);
+ }
+
+ return err;
+}
+
+
+/***********************************************************************
+ *
+ * FUNCTION: RomVersionCompatible
+ *
+ * DESCRIPTION: This routine checks that a ROM version is meet your
+ * minimum requirement.
+ *
+ * PARAMETERS: requiredVersion - minimum rom version required
+ * (see sysFtrNumROMVersion in SystemMgr.h
+ * for format)
+ * launchFlags - flags that indicate if the application
+ * UI is initialized.
+ *
+ * RETURNED: error code or zero if rom is compatible
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags) {
+ UInt32 romVersion;
+
+ // See if we're on in minimum required version of the ROM or later.
+ FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
+ if (romVersion < requiredVersion) {
+ if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) ==
+ (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) {
+
+ FrmAlert (RomIncompatibleAlert);
+
+ // Palm OS 1.0 will continuously relaunch this app unless we switch to
+ // another safe one.
+ if (romVersion <= kPalmOS10Version)
+ AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
+
+ }
+ return sysErrRomIncompatible;
+ }
+
+ return errNone;
+}
+
+///////////////////////////////////////////////////////////////////////
+
+
+void SavePrefs() {
+ if (gPrefs) {
+ PrefSetAppPreferences(appFileCreator, appPrefID, appPrefVersionNum, gPrefs, sizeof (GlobalsPreferenceType), true);
+ MemPtrFree(gPrefs);
+ gPrefs = NULL;
+ }
+}
+
+/***********************************************************************
+ *
+ * FUNCTION: AppHandleEvent
+ *
+ * DESCRIPTION: This routine loads form resources and set the event
+ * handler for the form loaded.
+ *
+ * PARAMETERS: event - a pointer to an EventType structure
+ *
+ * RETURNED: true if the event has handle and should not be passed
+ * to a higher level handler.
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+static Boolean AppHandleEvent(EventPtr eventP) {
+ UInt16 formId;
+ FormPtr frmP;
+
+ if (eventP->eType == frmLoadEvent) {
+ // Load the form resource.
+ formId = eventP->data.frmLoad.formID;
+ frmP = FrmInitForm(formId);
+ FrmSetActiveForm(frmP);
+
+ // Set the event handler for the form. The handler of the currently
+ // active form is called by FrmHandleEvent each time is receives an
+ // event.
+ switch (formId) {
+ case MainForm:
+ FrmSetEventHandler(frmP, MainFormHandleEvent);
+ break;
+
+ case SkinsForm:
+ FrmSetEventHandler(frmP, SkinsFormHandleEvent);
+ break;
+
+ case GameEditForm:
+ FrmSetEventHandler(frmP, EditGameFormHandleEvent);
+ break;
+
+ case MiscForm:
+ FrmSetEventHandler(frmP, MiscFormHandleEvent);
+ break;
+
+ case CardSlotForm:
+ FrmSetEventHandler(frmP, CardSlotFormHandleEvent);
+ break;
+
+ case MusicForm:
+ FrmSetEventHandler(frmP, MusicFormHandleEvent);
+ break;
+
+ case InfoForm:
+ FrmSetEventHandler(frmP, InfoFormHandleEvent);
+ break;
+
+ default:
+// ErrFatalDisplay("Invalid Form Load Event");
+ break;
+ }
+ return true;
+ }
+
+ return false;
+}
+
+/***********************************************************************
+ *
+ * FUNCTION: AppEventLoop
+ *
+ * DESCRIPTION: This routine is the event loop for the application.
+ *
+ * PARAMETERS: nothing
+ *
+ * RETURNED: nothing
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+static void AppEventLoop(void) {
+ UInt16 error;
+ EventType event;
+
+ do {
+ EvtGetEvent(&event, evtNoWait);
+
+ if(bStartScumm)
+ bStartScumm = StartScummVM();
+
+ if (! SysHandleEvent(&event))
+ if (! MenuHandleEvent(0, &event, &error))
+ if (! AppHandleEvent(&event))
+ FrmDispatchEvent(&event);
+
+ } while (event.eType != appStopEvent);
+}
+
+/***********************************************************************
+ *
+ * FUNCTION: ScummVMPalmMain
+ *
+ * DESCRIPTION: This is the main entry point for the application.
+ *
+ * PARAMETERS: cmd - word value specifying the launch code.
+ * cmdPB - pointer to a structure that is associated with the launch code.
+ * launchFlags - word value providing extra information about the launch.
+ *
+ * RETURNED: Result of launch
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+static void AppLaunchCmdNotify(UInt16 LaunchFlags, SysNotifyParamType * pData) {
+ switch (pData->notifyType) {
+ case sysNotifyVolumeMountedEvent:
+ pData->handled = true; // don't switch
+
+ if (gPrefs) { // gPrefs exists ? so we are in the palm selector
+ CardSlotFormUpdate(); // redraw card list if needed
+
+ if (gPrefs->card.volRefNum == vfsInvalidVolRef) {
+ VFSAnyMountParamType *notifyDetailsP = (VFSAnyMountParamType *)pData->notifyDetailsP;
+ gPrefs->card.volRefNum = notifyDetailsP->volRefNum;
+
+ if (FrmGetFormPtr(MainForm) == FrmGetActiveForm())
+ if (gPrefs->card.volRefNum != vfsInvalidVolRef) {
+ CardSlotCreateDirs();
+ FrmUpdateForm(MainForm, frmRedrawUpdateMSImport);
+ }
+ }
+ }
+ break;
+
+ case sysNotifyVolumeUnmountedEvent:
+ if (gPrefs) {
+ CardSlotFormUpdate();
+
+ if (gPrefs->card.volRefNum == (UInt16)pData->notifyDetailsP) {
+ gPrefs->card.volRefNum = vfsInvalidVolRef;
+
+ if (FrmGetFormPtr(MainForm) == FrmGetActiveForm())
+ FrmUpdateForm(MainForm, frmRedrawUpdateMS);
+ }
+ }
+ break;
+
+ case sysNotifyDisplayResizedEvent:
+ if (gVars)
+ if (FrmGetFormPtr(MainForm) == FrmGetActiveForm())
+ SknApplySkin();
+ break;
+
+ case sonySysNotifyMsaEnforceOpenEvent:
+ // what am i supposed to do here ???
+ break;
+ }
+}
+
+static UInt32 ScummVMPalmMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) {
+ Err error;
+
+ error = RomVersionCompatible (kOurMinVersion, launchFlags);
+ if (error) return (error);
+
+ switch (cmd) {
+ case sysAppLaunchCmdNotify:
+ AppLaunchCmdNotify(launchFlags, (SysNotifyParamType *) cmdPBP);
+ break;
+
+ case sysAppLaunchCustomEngineDelete:
+#ifndef _DEBUG_ENGINE
+ ModDelete();
+#endif
+ break;
+
+ case sysAppLaunchCmdNormalLaunch:
+ error = AppStart();
+ if (error)
+ goto end;
+
+ if (!bDirectMode) {
+ FrmGotoForm(MainForm);
+ }else {
+ GamUnselect();
+ bStartScumm = true;
+ }
+
+ AppEventLoop();
+end:
+ AppStop();
+ break;
+
+ default:
+ break;
+
+ }
+ return error;
+}
+
+/***********************************************************************
+ *
+ * FUNCTION: PilotMain
+ *
+ * DESCRIPTION: This is the main entry point for the application.
+ *
+ * PARAMETERS: cmd - word value specifying the launch code.
+ * cmdPB - pointer to a structure that is associated with the launch code.
+ * launchFlags - word value providing extra information about the launch.
+ * RETURNED: Result of launch
+ *
+ * REVISION HISTORY:
+ *
+ *
+ ***********************************************************************/
+
+UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) {
+ return ScummVMPalmMain(cmd, cmdPBP, launchFlags);
+}
diff --git a/backends/platform/PalmOS/Src/launcher/start.h b/backends/platform/PalmOS/Src/launcher/start.h
new file mode 100644
index 0000000000..a30414a54f
--- /dev/null
+++ b/backends/platform/PalmOS/Src/launcher/start.h
@@ -0,0 +1,97 @@
+/* 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 __START_H__
+#define __START_H__
+
+typedef struct {
+ Char nameP[32];
+ UInt16 cardNo;
+ LocalID dbID;
+} SkinInfoType, *SkinInfoPtr;
+
+typedef struct {
+
+ //skin params
+ SkinInfoType skin; // card where is located the skin
+ Boolean soundClick;
+
+ Boolean vibrator;
+ Boolean autoOff;
+ Boolean setStack;
+ Boolean exitLauncher;
+ Boolean goLCD;
+ Boolean stylusClick;
+ Boolean arrowKeys;
+
+ UInt16 listPosition;
+ UInt16 autoSavePeriod;
+
+ struct {
+ UInt16 volRefNum;
+ UInt32 cacheSize;
+ Boolean useCache;
+ Boolean showLED;
+ Boolean moveDB;
+ Boolean deleteDB;
+ Boolean confirmMoveDB;
+ } card;
+
+ Boolean debug;
+ UInt16 debugLevel;
+ Boolean stdPalette;
+ Boolean demoMode;
+ Boolean copyProtection;
+ Boolean oldarm;// TODO : free slot...
+ Boolean altIntro;
+ Boolean autoSave;
+ Boolean advancedMode;
+
+ struct {
+ Boolean enable;
+ UInt8 mode;
+ } lightspeed;
+
+} GlobalsPreferenceType, *GlobalsPreferencePtr;
+
+extern GlobalsPreferencePtr gPrefs;
+
+extern Boolean bDirectMode;
+extern Boolean bStartScumm;
+extern Boolean bLaunched;
+
+#define appPrefID 0x00
+#define appVersionNum 0x01
+#define appPrefVersionNum 0x02
+
+#define STACK_DEFAULT 8192
+#define STACK_LARGER 16384
+#define STACK_GET 0
+
+Err AppStart(void);
+void AppStop(void);
+Boolean StartScummVM();
+void SavePrefs();
+Err SendDatabase (UInt16 cardNo, LocalID dbID, Char *nameP, Char *descriptionP);
+#endif