2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2006-02-12 20:13:08 +00:00
|
|
|
*
|
|
|
|
* 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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-11-03 16:14:58 +00:00
|
|
|
#include <PalmOS.h>
|
2007-01-14 17:05:43 +00:00
|
|
|
#include <PmPalmOSNVFS.h>
|
2003-11-03 16:14:58 +00:00
|
|
|
#include "StarterRsc.h"
|
2004-05-25 13:18:11 +00:00
|
|
|
|
2003-11-03 16:14:58 +00:00
|
|
|
#include "games.h"
|
|
|
|
#include "start.h"
|
2004-09-12 13:24:06 +00:00
|
|
|
#include "rumble.h"
|
2004-05-25 13:18:11 +00:00
|
|
|
#include "globals.h"
|
2004-09-12 13:24:06 +00:00
|
|
|
#include "features.h"
|
2004-11-09 11:54:16 +00:00
|
|
|
#include "formUtil.h"
|
2006-02-12 20:13:08 +00:00
|
|
|
#include "formCards.h"
|
|
|
|
#include "palmdefs.h"
|
|
|
|
|
|
|
|
#include "init_palmos.h"
|
|
|
|
#include "init_stuffs.h"
|
2004-05-25 13:18:11 +00:00
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
#include "modules.h"
|
|
|
|
#include "args.h"
|
2003-11-03 16:14:58 +00:00
|
|
|
|
|
|
|
|
2006-02-12 20:13:08 +00:00
|
|
|
#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; }
|
2004-11-09 11:54:16 +00:00
|
|
|
|
|
|
|
#define BUILD_FILE(h,m) \
|
|
|
|
StrCopy(filename, "/Palm/Programs/ScummVM/Mods/"); \
|
|
|
|
StrCat(filename, h); \
|
|
|
|
StrCat(filename, m);
|
|
|
|
|
2007-01-14 17:05:43 +00:00
|
|
|
#define FIND_FILE() \
|
|
|
|
if (*volRefNum == vfsInvalidVolRef) \
|
|
|
|
*volRefNum = ModFind(filename);
|
|
|
|
|
|
|
|
|
2006-02-12 20:13:08 +00:00
|
|
|
#define CHECK_FILE(m) \
|
2007-01-14 17:05:43 +00:00
|
|
|
e = VFSFileOpen(*volRefNum, filename, vfsModeRead, &file); \
|
2004-11-09 11:54:16 +00:00
|
|
|
if (e) \
|
2006-02-12 20:13:08 +00:00
|
|
|
BUILD_ERROR(m) \
|
2004-11-09 11:54:16 +00:00
|
|
|
else \
|
2006-02-12 20:13:08 +00:00
|
|
|
VFSFileClose(file);
|
|
|
|
|
|
|
|
#define IMPRT_FILE(m) \
|
2007-01-14 17:05:43 +00:00
|
|
|
e = VFSImportDatabaseFromFile(*volRefNum, filename, &cardNo, &dbID); \
|
2006-02-12 20:13:08 +00:00
|
|
|
if (e) \
|
|
|
|
BUILD_ERROR(m)
|
2004-11-09 11:54:16 +00:00
|
|
|
|
|
|
|
#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");
|
2004-12-20 17:20:37 +00:00
|
|
|
DELET_FILE("Glbs::Engine");
|
2004-11-09 11:54:16 +00:00
|
|
|
DELET_FILE("ScummVM-Engine");
|
|
|
|
}
|
2003-11-03 16:14:58 +00:00
|
|
|
|
2007-01-14 17:05:43 +00:00
|
|
|
UInt16 ModFind(const Char *f) {
|
|
|
|
Err e;
|
|
|
|
UInt16 volRefNum;
|
|
|
|
FileRef r;
|
|
|
|
UInt32 volIterator = vfsIteratorStart|vfsIncludePrivateVolumes;
|
|
|
|
while (volIterator != vfsIteratorStop) {
|
|
|
|
e = VFSVolumeEnumerate(&volRefNum, &volIterator);
|
|
|
|
|
|
|
|
if (!e) e = VFSFileOpen(volRefNum, f, vfsModeRead, &r);
|
|
|
|
if (!e) e = VFSFileClose(r);
|
|
|
|
if (!e) break;
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-01-14 17:05:43 +00:00
|
|
|
return volRefNum;
|
|
|
|
}
|
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
static void ModSetStack(UInt32 newSize, UInt16 cardNo, LocalID dbID) {
|
|
|
|
DmOpenRef dbRef = DmOpenDatabase(cardNo, dbID, dmModeReadWrite);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
if (dbRef) {
|
|
|
|
MemHandle pref = DmGetResource('pref',0);
|
|
|
|
UInt32 size = 0;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
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);
|
2003-11-03 16:14:58 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
DmCloseDatabase(dbRef);
|
2003-11-03 16:14:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-14 17:05:43 +00:00
|
|
|
static Err ModImport(UInt16 *volRefNum, UInt8 engine, Boolean *armP) {
|
2006-02-12 20:13:08 +00:00
|
|
|
#ifndef _DEBUG_ENGINE
|
2004-11-09 11:54:16 +00:00
|
|
|
char filename[256];
|
2006-02-12 20:13:08 +00:00
|
|
|
UInt16 cardNo;
|
|
|
|
LocalID dbID;
|
|
|
|
UInt32 result;
|
2004-11-09 11:54:16 +00:00
|
|
|
FileRef file;
|
2006-02-12 20:13:08 +00:00
|
|
|
#endif
|
|
|
|
char msg[256];
|
2004-11-09 11:54:16 +00:00
|
|
|
FormPtr ofmP, frmP;
|
2004-12-20 17:20:37 +00:00
|
|
|
Err e = errNone;
|
2004-11-09 11:54:16 +00:00
|
|
|
|
|
|
|
ofmP = FrmGetActiveForm();
|
|
|
|
frmP = FrmInitForm(ImportForm);
|
|
|
|
FrmSetActiveForm(frmP);
|
|
|
|
FrmDrawForm(frmP);
|
|
|
|
|
2004-12-20 17:20:37 +00:00
|
|
|
// In debug mode, the engine files are directly uploaded to the simulator
|
2006-02-12 20:13:08 +00:00
|
|
|
#ifndef _DEBUG_ENGINE
|
|
|
|
// engine file ?
|
|
|
|
BUILD_FILE(engines[engine].fileP, ".engine");
|
2007-01-14 17:05:43 +00:00
|
|
|
FIND_FILE ();
|
2006-02-12 20:13:08 +00:00
|
|
|
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);
|
|
|
|
|
2007-01-14 17:05:43 +00:00
|
|
|
/* ARM ONLY FOR NOW, NOT REQUIRED
|
2006-02-12 20:13:08 +00:00
|
|
|
// 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 !");
|
|
|
|
}
|
2007-01-14 17:05:43 +00:00
|
|
|
*/
|
2004-12-20 17:20:37 +00:00
|
|
|
#endif
|
2004-11-09 11:54:16 +00:00
|
|
|
// if error, cleanup
|
|
|
|
if (e) ModDelete();
|
|
|
|
|
|
|
|
onError:
|
|
|
|
FrmEraseForm(frmP);
|
|
|
|
FrmDeleteForm(frmP);
|
2006-02-12 20:13:08 +00:00
|
|
|
if (e) {
|
|
|
|
if (ofmP) FrmSetActiveForm(ofmP);
|
|
|
|
FrmCustomAlert(FrmErrorAlert, msg, 0, 0);
|
|
|
|
}
|
2004-11-09 11:54:16 +00:00
|
|
|
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef DELET_FILE
|
|
|
|
#undef CHECK_FILE
|
|
|
|
#undef BUILD_FILE
|
|
|
|
|
2007-05-01 14:50:55 +00:00
|
|
|
Boolean StartScummVM(Int16 engine) {
|
2004-11-09 11:54:16 +00:00
|
|
|
Char **argvP;
|
|
|
|
UInt8 lightspeed, argc = 0;
|
|
|
|
UInt32 stackSize;
|
2006-02-12 20:13:08 +00:00
|
|
|
Boolean toLauncher, direct, isARM;
|
2006-02-25 20:54:01 +00:00
|
|
|
Char num[6];
|
2003-11-03 16:14:58 +00:00
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
argvP = ArgsInit();
|
2006-02-12 20:13:08 +00:00
|
|
|
direct = false;
|
2004-11-09 11:54:16 +00:00
|
|
|
|
2006-02-12 20:13:08 +00:00
|
|
|
// start command line (exec name)
|
|
|
|
ArgsAdd(&argvP[argc], "-", NULL, &argc);
|
2007-12-09 11:26:01 +00:00
|
|
|
// standard path
|
|
|
|
ArgsAdd(&argvP[argc], "--themepath=", "/PALM/Programs/ScummVM/Themes", &argc);
|
2006-02-12 20:13:08 +00:00
|
|
|
|
2007-05-01 14:50:55 +00:00
|
|
|
UInt16 index = GamGetSelected();
|
2006-02-12 20:13:08 +00:00
|
|
|
// no game selected
|
2004-11-09 11:54:16 +00:00
|
|
|
if (index == dmMaxRecordIndex) {
|
2007-05-01 14:50:55 +00:00
|
|
|
if (engine == NO_ENGINE) {
|
2006-02-12 20:13:08 +00:00
|
|
|
// free args
|
|
|
|
ArgsFree(argvP);
|
2004-11-09 11:54:16 +00:00
|
|
|
return false;
|
2006-02-12 20:13:08 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-02-12 20:13:08 +00:00
|
|
|
// default values
|
|
|
|
if (bDirectMode)
|
|
|
|
gPrefs->card.volRefNum = parseCards(); // always use the first removable card available (?)
|
2007-05-01 14:50:55 +00:00
|
|
|
|
2006-02-12 20:13:08 +00:00
|
|
|
gVars->filter = true;
|
|
|
|
gVars->palmVolume = 50;
|
|
|
|
gVars->fmQuality = FM_QUALITY_INI;
|
|
|
|
direct = true;
|
2003-11-03 16:14:58 +00:00
|
|
|
|
2006-02-12 20:13:08 +00:00
|
|
|
// somthing selected
|
2004-11-09 11:54:16 +00:00
|
|
|
} else {
|
2003-11-03 16:14:58 +00:00
|
|
|
Char pathP[256];
|
|
|
|
MemHandle recordH;
|
|
|
|
GameInfoType *gameInfoP;
|
|
|
|
|
|
|
|
recordH = DmQueryRecord(gameDB,index);
|
|
|
|
gameInfoP = (GameInfoType *)MemHandleLock(recordH);
|
2004-11-09 11:54:16 +00:00
|
|
|
engine = gameInfoP->engine;
|
2003-11-03 16:14:58 +00:00
|
|
|
|
|
|
|
// build path
|
|
|
|
StrCopy(pathP,"/Palm/Programs/ScummVM/Games/");
|
|
|
|
if (gameInfoP->pathP[0] == '/')
|
2006-02-12 20:13:08 +00:00
|
|
|
StrCopy(pathP, gameInfoP->pathP);
|
|
|
|
else if (!(gameInfoP->pathP[0] == '.' && StrLen(gameInfoP->pathP) == 1))
|
|
|
|
StrCat(pathP, gameInfoP->pathP);
|
2003-11-03 16:14:58 +00:00
|
|
|
|
|
|
|
// path
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-p", pathP, &argc);
|
2003-11-03 16:14:58 +00:00
|
|
|
|
|
|
|
// language
|
|
|
|
if (gameInfoP->language > 0) {
|
2006-02-12 20:13:08 +00:00
|
|
|
const Char *lang = "zh\0cz\0gb\0en\0fr\0de\0hb\0it\0jp\0kr\0pl\0pt\0ru\0es\0se\0";
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-q", (lang + (gameInfoP->language - 1) * 3), &argc);
|
2003-11-03 16:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// fullscreen ?
|
2004-09-12 13:24:06 +00:00
|
|
|
if (gameInfoP->fullscreen)
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-f", NULL, &argc);
|
2004-01-20 14:10:23 +00:00
|
|
|
|
|
|
|
// aspect-ratio ?
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], (gameInfoP->aspectRatio ? "--aspect-ratio" : "--no-aspect-ratio"), NULL, &argc);
|
2003-11-03 16:14:58 +00:00
|
|
|
|
|
|
|
// gfx mode
|
2004-09-12 13:24:06 +00:00
|
|
|
gVars->filter = gameInfoP->filter;
|
|
|
|
|
2006-02-12 20:13:08 +00:00
|
|
|
switch (gameInfoP->renderMode) {
|
2003-11-03 16:14:58 +00:00
|
|
|
case 1:
|
2006-02-12 20:13:08 +00:00
|
|
|
ArgsAdd(&argvP[argc], "--render-mode=", "amiga", &argc);
|
2003-11-03 16:14:58 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2006-02-12 20:13:08 +00:00
|
|
|
ArgsAdd(&argvP[argc], "--render-mode=", "cga", &argc);
|
2003-11-03 16:14:58 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2006-02-12 20:13:08 +00:00
|
|
|
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;
|
2008-01-27 19:47:41 +00:00
|
|
|
}
|
2006-02-12 20:13:08 +00:00
|
|
|
|
|
|
|
switch (gameInfoP->gfxMode) {
|
|
|
|
case 1:
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-g", "wide", &argc);
|
2003-11-03 16:14:58 +00:00
|
|
|
break;
|
|
|
|
default:
|
2006-02-15 21:14:17 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-g", "1x", &argc);
|
2003-11-03 16:14:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// load state
|
|
|
|
if (gameInfoP->autoLoad) {
|
|
|
|
StrIToA(num, gameInfoP->loadSlot);
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-x", num, &argc);
|
2003-11-03 16:14:58 +00:00
|
|
|
}
|
|
|
|
// boot script parameter
|
|
|
|
if (gameInfoP->bootParam) {
|
|
|
|
StrIToA(num, gameInfoP->bootValue);
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-b", num, &argc);
|
2003-11-03 16:14:58 +00:00
|
|
|
}
|
|
|
|
// not a PC version
|
|
|
|
if (gameInfoP->setPlatform) {
|
2006-02-12 20:13:08 +00:00
|
|
|
static const char *platform[] = {
|
2006-02-25 20:54:01 +00:00
|
|
|
"3do",
|
2006-02-12 20:13:08 +00:00
|
|
|
"acorn",
|
|
|
|
"amiga",
|
2007-01-14 17:05:43 +00:00
|
|
|
"2gs",
|
2006-02-12 20:13:08 +00:00
|
|
|
"atari",
|
|
|
|
"c64",
|
|
|
|
"pc",
|
|
|
|
"fmtowns",
|
|
|
|
"linux",
|
|
|
|
"mac",
|
|
|
|
"nes",
|
|
|
|
"segacd",
|
|
|
|
"windows"
|
|
|
|
};
|
2008-01-27 19:47:41 +00:00
|
|
|
ArgsAdd(&argvP[argc], "--platform=", platform[gameInfoP->platform], &argc);
|
2003-11-03 16:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// subtitles
|
2004-10-11 14:01:38 +00:00
|
|
|
if (gameInfoP->subtitles)
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-n", NULL, &argc);
|
2004-09-12 13:24:06 +00:00
|
|
|
|
2003-11-03 16:14:58 +00:00
|
|
|
// multi midi ?
|
2004-09-12 13:24:06 +00:00
|
|
|
if (gameInfoP->musicInfo.sound.multiMidi)
|
2004-11-09 11:54:16 +00:00
|
|
|
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);
|
2006-02-12 20:13:08 +00:00
|
|
|
}
|
|
|
|
|
2006-02-25 20:54:01 +00:00
|
|
|
// talk speed
|
|
|
|
if (gameInfoP->talkSpeed) {
|
|
|
|
StrIToA(num, gameInfoP->talkValue);
|
|
|
|
ArgsAdd(&argvP[argc], "--talkspeed=", num, &argc);
|
2004-11-09 11:54:16 +00:00
|
|
|
}
|
2003-11-03 16:14:58 +00:00
|
|
|
|
|
|
|
// music driver
|
2006-02-25 20:54:01 +00:00
|
|
|
if (gameInfoP->musicInfo.sound.music) {
|
2006-04-11 18:04:09 +00:00
|
|
|
static char *drv[] = {
|
|
|
|
"auto",
|
|
|
|
"null",
|
|
|
|
"adlib",
|
|
|
|
"towns",
|
|
|
|
"pcjr",
|
|
|
|
"native",
|
|
|
|
"pcspk"
|
|
|
|
};
|
|
|
|
|
|
|
|
if (StrCompare(drv[gameInfoP->musicInfo.sound.drvMusic], "native") == 0) {
|
|
|
|
if (OPTIONS_TST(kOptDeviceZodiac))
|
|
|
|
ArgsAdd(&argvP[argc], "-e", "zodiac", &argc); // Tapwave Zodiac
|
|
|
|
else if (OPTIONS_TST(kOptSonyPa1LibAPI))
|
|
|
|
ArgsAdd(&argvP[argc], "-e", "ypa1", &argc); // Pa1Lib devices
|
|
|
|
else
|
|
|
|
ArgsAdd(&argvP[argc], "-e", "auto", &argc); // no driver, switch to auto
|
|
|
|
} else {
|
2008-01-27 19:47:41 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-e", drv[gameInfoP->musicInfo.sound.drvMusic], &argc);
|
2006-04-11 18:04:09 +00:00
|
|
|
}
|
2006-02-25 20:54:01 +00:00
|
|
|
|
|
|
|
// 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 {
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-e", "null", &argc);
|
2006-02-25 20:54:01 +00:00
|
|
|
}
|
2003-11-03 16:14:58 +00:00
|
|
|
|
|
|
|
// volume control
|
2004-09-12 13:24:06 +00:00
|
|
|
StrIToA(num, gameInfoP->musicInfo.volume.sfx);
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-s", num, &argc);
|
2004-09-12 13:24:06 +00:00
|
|
|
StrIToA(num, gameInfoP->musicInfo.volume.music);
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-m", num, &argc);
|
2004-09-12 13:24:06 +00:00
|
|
|
StrIToA(num, gameInfoP->musicInfo.volume.speech);
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], "-r", num, &argc);
|
2003-11-03 16:14:58 +00:00
|
|
|
|
|
|
|
// game name
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsAdd(&argvP[argc], gameInfoP->gameP, NULL, &argc);
|
2003-11-03 16:14:58 +00:00
|
|
|
|
2006-02-25 20:54:01 +00:00
|
|
|
gVars->palmVolume = gameInfoP->musicInfo.sound.music ? gameInfoP->musicInfo.volume.palm : 0;
|
2004-09-12 13:24:06 +00:00
|
|
|
|
2003-11-03 16:14:58 +00:00
|
|
|
MemHandleUnlock(recordH);
|
2006-02-12 20:13:08 +00:00
|
|
|
} // end no game / game selected
|
|
|
|
|
|
|
|
// common command line options
|
2003-11-03 16:14:58 +00:00
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
// debug level
|
|
|
|
if (gPrefs->debug) {
|
|
|
|
StrIToA(num, gPrefs->debugLevel);
|
|
|
|
ArgsAdd(&argvP[argc], "-d", num, &argc);
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-20 17:20:37 +00:00
|
|
|
if (engine == ENGINE_QUEEN || engine == ENGINE_SKY) {
|
2004-11-09 11:54:16 +00:00
|
|
|
// alternative intro ?
|
|
|
|
if (gPrefs->altIntro)
|
|
|
|
ArgsAdd(&argvP[argc], "--alt-intro", NULL, &argc);
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-02-12 20:13:08 +00:00
|
|
|
if (engine == ENGINE_SCUMM) {
|
2004-11-09 11:54:16 +00:00
|
|
|
// demo mode ?
|
|
|
|
if (gPrefs->demoMode)
|
|
|
|
ArgsAdd(&argvP[argc], "--demo-mode", NULL, &argc);
|
|
|
|
}
|
|
|
|
|
2006-02-25 20:54:01 +00:00
|
|
|
// copy protection ?
|
|
|
|
if (gPrefs->copyProtection)
|
|
|
|
ArgsAdd(&argvP[argc], "--copy-protection", NULL, &argc);
|
|
|
|
|
2006-02-12 20:13:08 +00:00
|
|
|
// exceed max args ?
|
2004-12-20 17:20:37 +00:00
|
|
|
if (argc > MAX_ARG)
|
|
|
|
FrmCustomAlert(FrmErrorAlert, "Too many parameters.",0,0);
|
2004-01-20 14:10:23 +00:00
|
|
|
|
2006-02-12 20:13:08 +00:00
|
|
|
// set some common options
|
2004-11-09 11:54:16 +00:00
|
|
|
stackSize = (gPrefs->setStack ? STACK_LARGER : STACK_DEFAULT);
|
|
|
|
lightspeed= (gPrefs->lightspeed.enable ? gPrefs->lightspeed.mode : 255);
|
|
|
|
toLauncher= (gPrefs->exitLauncher);
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
// gVars values
|
2007-07-01 12:47:07 +00:00
|
|
|
// (gVars->HRrefNum defined in checkHRmode on Clie)
|
2007-05-01 10:20:48 +00:00
|
|
|
#ifndef _DEBUG_ENGINE
|
2007-01-14 17:05:43 +00:00
|
|
|
gVars->VFS.volRefNum = (gPrefs->card.autoDetect ? vfsInvalidVolRef : gPrefs->card.volRefNum);
|
2007-05-01 10:20:48 +00:00
|
|
|
#else
|
|
|
|
gVars->VFS.volRefNum = gPrefs->card.volRefNum;
|
|
|
|
#endif
|
2006-02-12 20:13:08 +00:00
|
|
|
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;
|
2006-06-05 19:17:30 +00:00
|
|
|
gVars->arrowKeys = gPrefs->arrowKeys;
|
2003-11-03 16:14:58 +00:00
|
|
|
|
2004-05-25 13:18:11 +00:00
|
|
|
// user params
|
2004-11-09 11:54:16 +00:00
|
|
|
HWR_RSTALL();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-02-12 20:13:08 +00:00
|
|
|
if (gPrefs->goLCD)
|
|
|
|
HWR_SET(INIT_GOLCD);
|
|
|
|
else
|
|
|
|
OPTIONS_RST(kOptGoLcdAPI);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
if (!gPrefs->autoOff)
|
|
|
|
HWR_SET(INIT_AUTOOFF);
|
|
|
|
|
2003-11-03 16:14:58 +00:00
|
|
|
if (gVars->vibrator)
|
2004-11-09 11:54:16 +00:00
|
|
|
HWR_SET(INIT_VIBRATOR);
|
2006-02-25 20:54:01 +00:00
|
|
|
/* ????
|
2004-11-09 11:54:16 +00:00
|
|
|
if ( musicDriver == 1 ||
|
|
|
|
musicDriver == 3 ||
|
|
|
|
musicDriver == 4 ||
|
|
|
|
musicDriver == sysInvalidRefNum) {
|
|
|
|
HWR_SET(INIT_PA1LIB);
|
|
|
|
}
|
2006-02-25 20:54:01 +00:00
|
|
|
*/
|
2007-01-14 17:05:43 +00:00
|
|
|
if (ModImport(&gVars->VFS.volRefNum, engine, &isARM) != errNone) {
|
2006-02-12 20:13:08 +00:00
|
|
|
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);
|
|
|
|
}
|
2004-11-09 11:54:16 +00:00
|
|
|
ArgsFree(argvP);
|
|
|
|
return false;
|
2003-11-03 16:14:58 +00:00
|
|
|
}
|
|
|
|
|
2010-06-15 12:33:20 +00:00
|
|
|
// reset mode if screen rotation occurred (DIA only)
|
2006-02-12 20:13:08 +00:00
|
|
|
if (!direct && OPTIONS_TST(kOptCollapsible)) {
|
|
|
|
UInt8 mode = PalmScreenSize(0,0, &(gVars->screenFullWidth), &(gVars->screenFullHeight));
|
|
|
|
OPTIONS_RST(kOptModeLandscape);
|
|
|
|
OPTIONS_SET((mode == PALM_LANDSCAPE) ? kOptModeLandscape : kOptNone);
|
|
|
|
}
|
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
// free and save globals pref memory
|
|
|
|
GamCloseDatabase(false);
|
|
|
|
FrmCloseAllForms();
|
|
|
|
SavePrefs();
|
|
|
|
|
2004-09-12 13:24:06 +00:00
|
|
|
{
|
2004-11-09 11:54:16 +00:00
|
|
|
UInt16 cardNo;
|
|
|
|
UInt32 dbID;
|
2004-09-12 13:24:06 +00:00
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
LaunchParamType *cmdPBP = (LaunchParamType *)MemPtrNew(sizeof(LaunchParamType));
|
2003-11-03 16:14:58 +00:00
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
MemPtrSetOwner(cmdPBP, 0);
|
|
|
|
MemPtrSetOwner(gVars, 0);
|
|
|
|
ArgsSetOwner(argvP, 0);
|
2003-11-03 16:14:58 +00:00
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
cardNo = 0;
|
|
|
|
dbID = DmFindDatabase(0, "ScummVM-Engine");
|
2006-02-12 20:13:08 +00:00
|
|
|
|
|
|
|
if (isARM)
|
|
|
|
FtrSet(appFileCreator, ftrStack , (stackSize * 4));
|
|
|
|
else
|
|
|
|
ModSetStack(stackSize, cardNo, dbID);
|
2003-11-03 16:14:58 +00:00
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
cmdPBP->args.argc = argc;
|
|
|
|
cmdPBP->args.argv = argvP;
|
|
|
|
cmdPBP->gVars = gVars;
|
|
|
|
cmdPBP->lightspeed = lightspeed;
|
|
|
|
cmdPBP->exitLauncher = toLauncher;
|
2003-11-03 16:14:58 +00:00
|
|
|
|
2004-11-09 11:54:16 +00:00
|
|
|
SysUIAppSwitch(cardNo, dbID, sysAppLaunchCmdNormalLaunch, cmdPBP);
|
|
|
|
bLaunched = true;
|
2003-11-03 16:14:58 +00:00
|
|
|
}
|
2004-09-12 13:24:06 +00:00
|
|
|
|
2003-11-03 16:14:58 +00:00
|
|
|
return false;
|
|
|
|
}
|