From c3b41a2aa6bdbb9b29f265078f39805a0f7865fc Mon Sep 17 00:00:00 2001 From: Chris Apers Date: Sun, 26 Feb 2006 16:30:21 +0000 Subject: Move launcher files to a new folder svn-id: r20928 --- backends/PalmOS/Src/app.cpp | 374 ------------------- backends/PalmOS/Src/games.cpp | 518 --------------------------- backends/PalmOS/Src/games.h | 197 ---------- backends/PalmOS/Src/launch.cpp | 526 --------------------------- backends/PalmOS/Src/launcher/app.cpp | 374 +++++++++++++++++++ backends/PalmOS/Src/launcher/games.cpp | 518 +++++++++++++++++++++++++++ backends/PalmOS/Src/launcher/games.h | 197 ++++++++++ backends/PalmOS/Src/launcher/launch.cpp | 526 +++++++++++++++++++++++++++ backends/PalmOS/Src/launcher/skin.cpp | 611 ++++++++++++++++++++++++++++++++ backends/PalmOS/Src/launcher/skin.h | 130 +++++++ backends/PalmOS/Src/launcher/start.cpp | 366 +++++++++++++++++++ backends/PalmOS/Src/launcher/start.h | 96 +++++ backends/PalmOS/Src/skin.cpp | 611 -------------------------------- backends/PalmOS/Src/skin.h | 130 ------- backends/PalmOS/Src/start.cpp | 366 ------------------- backends/PalmOS/Src/start.h | 96 ----- 16 files changed, 2818 insertions(+), 2818 deletions(-) delete mode 100644 backends/PalmOS/Src/app.cpp delete mode 100644 backends/PalmOS/Src/games.cpp delete mode 100644 backends/PalmOS/Src/games.h delete mode 100644 backends/PalmOS/Src/launch.cpp create mode 100644 backends/PalmOS/Src/launcher/app.cpp create mode 100644 backends/PalmOS/Src/launcher/games.cpp create mode 100644 backends/PalmOS/Src/launcher/games.h create mode 100644 backends/PalmOS/Src/launcher/launch.cpp create mode 100644 backends/PalmOS/Src/launcher/skin.cpp create mode 100644 backends/PalmOS/Src/launcher/skin.h create mode 100644 backends/PalmOS/Src/launcher/start.cpp create mode 100644 backends/PalmOS/Src/launcher/start.h delete mode 100644 backends/PalmOS/Src/skin.cpp delete mode 100644 backends/PalmOS/Src/skin.h delete mode 100644 backends/PalmOS/Src/start.cpp delete mode 100644 backends/PalmOS/Src/start.h (limited to 'backends') diff --git a/backends/PalmOS/Src/app.cpp b/backends/PalmOS/Src/app.cpp deleted file mode 100644 index 784ad935c2..0000000000 --- a/backends/PalmOS/Src/app.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/* 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 -#include - -#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/PalmOS/Src/games.cpp b/backends/PalmOS/Src/games.cpp deleted file mode 100644 index 737cb4983c..0000000000 --- a/backends/PalmOS/Src/games.cpp +++ /dev/null @@ -1,518 +0,0 @@ -/* 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 -#include -#include - -#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_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 (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++; - - // ----- - 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 = 0; // 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/PalmOS/Src/games.h b/backends/PalmOS/Src/games.h deleted file mode 100644 index 99d8d5ef03..0000000000 --- a/backends/PalmOS/Src/games.h +++ /dev/null @@ -1,197 +0,0 @@ -/* 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,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_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" }, - { "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/PalmOS/Src/launch.cpp b/backends/PalmOS/Src/launch.cpp deleted file mode 100644 index 282b9ae8e9..0000000000 --- a/backends/PalmOS/Src/launch.cpp +++ /dev/null @@ -1,526 +0,0 @@ -/* 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 -#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) { - switch (gameInfoP->musicInfo.sound.drvMusic) { - case 0: // NULL - ArgsAdd(&argvP[argc], "-e", "null", &argc); - break; - - case 1: // AdLib - ArgsAdd(&argvP[argc], "-e", "adlib", &argc); - break; - - case 2: // FM Towns - ArgsAdd(&argvP[argc], "-e", "towns", &argc); - break; - - case 3: // IBM PCjr - ArgsAdd(&argvP[argc], "-e", "pcjr", &argc); - break; - - case 4: // built-in MIDI - 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", "null", &argc); // error, no music driver - break; - - case 5: // PC Speaker - ArgsAdd(&argvP[argc], "-e", "pcspk", &argc); - break; - } - - // 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; - - // 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/PalmOS/Src/launcher/app.cpp b/backends/PalmOS/Src/launcher/app.cpp new file mode 100644 index 0000000000..784ad935c2 --- /dev/null +++ b/backends/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 +#include + +#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/PalmOS/Src/launcher/games.cpp b/backends/PalmOS/Src/launcher/games.cpp new file mode 100644 index 0000000000..737cb4983c --- /dev/null +++ b/backends/PalmOS/Src/launcher/games.cpp @@ -0,0 +1,518 @@ +/* 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 +#include +#include + +#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_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 (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++; + + // ----- + 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 = 0; // 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/PalmOS/Src/launcher/games.h b/backends/PalmOS/Src/launcher/games.h new file mode 100644 index 0000000000..99d8d5ef03 --- /dev/null +++ b/backends/PalmOS/Src/launcher/games.h @@ -0,0 +1,197 @@ +/* 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,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_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" }, + { "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/PalmOS/Src/launcher/launch.cpp b/backends/PalmOS/Src/launcher/launch.cpp new file mode 100644 index 0000000000..282b9ae8e9 --- /dev/null +++ b/backends/PalmOS/Src/launcher/launch.cpp @@ -0,0 +1,526 @@ +/* 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 +#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) { + switch (gameInfoP->musicInfo.sound.drvMusic) { + case 0: // NULL + ArgsAdd(&argvP[argc], "-e", "null", &argc); + break; + + case 1: // AdLib + ArgsAdd(&argvP[argc], "-e", "adlib", &argc); + break; + + case 2: // FM Towns + ArgsAdd(&argvP[argc], "-e", "towns", &argc); + break; + + case 3: // IBM PCjr + ArgsAdd(&argvP[argc], "-e", "pcjr", &argc); + break; + + case 4: // built-in MIDI + 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", "null", &argc); // error, no music driver + break; + + case 5: // PC Speaker + ArgsAdd(&argvP[argc], "-e", "pcspk", &argc); + break; + } + + // 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; + + // 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/PalmOS/Src/launcher/skin.cpp b/backends/PalmOS/Src/launcher/skin.cpp new file mode 100644 index 0000000000..f38fe88d46 --- /dev/null +++ b/backends/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 +#include +#include + +#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(©); + 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, ©); + 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/PalmOS/Src/launcher/skin.h b/backends/PalmOS/Src/launcher/skin.h new file mode 100644 index 0000000000..2047532fd8 --- /dev/null +++ b/backends/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/PalmOS/Src/launcher/start.cpp b/backends/PalmOS/Src/launcher/start.cpp new file mode 100644 index 0000000000..076c24d6c2 --- /dev/null +++ b/backends/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 +#include + +#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/PalmOS/Src/launcher/start.h b/backends/PalmOS/Src/launcher/start.h new file mode 100644 index 0000000000..4d3afade59 --- /dev/null +++ b/backends/PalmOS/Src/launcher/start.h @@ -0,0 +1,96 @@ +/* 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; + + 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 diff --git a/backends/PalmOS/Src/skin.cpp b/backends/PalmOS/Src/skin.cpp deleted file mode 100644 index f38fe88d46..0000000000 --- a/backends/PalmOS/Src/skin.cpp +++ /dev/null @@ -1,611 +0,0 @@ -/* 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 -#include -#include - -#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(©); - 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, ©); - 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/PalmOS/Src/skin.h b/backends/PalmOS/Src/skin.h deleted file mode 100644 index 2047532fd8..0000000000 --- a/backends/PalmOS/Src/skin.h +++ /dev/null @@ -1,130 +0,0 @@ -/* 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/PalmOS/Src/start.cpp b/backends/PalmOS/Src/start.cpp deleted file mode 100644 index 076c24d6c2..0000000000 --- a/backends/PalmOS/Src/start.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/* 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 -#include - -#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/PalmOS/Src/start.h b/backends/PalmOS/Src/start.h deleted file mode 100644 index 4d3afade59..0000000000 --- a/backends/PalmOS/Src/start.h +++ /dev/null @@ -1,96 +0,0 @@ -/* 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; - - 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 -- cgit v1.2.3