command line parameter support

svn-id: r3414
This commit is contained in:
Ludvig Strigeus 2001-10-09 19:02:28 +00:00
parent 3c2f425cc1
commit 907f51287c
5 changed files with 93 additions and 43 deletions

14
scumm.h
View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.4 2001/10/09 19:02:28 strigeus
* command line parameter support
*
* Revision 1.3 2001/10/09 18:35:02 strigeus
* fixed object parent bug
* fixed some signed/unsigned comparisons
@ -779,9 +782,6 @@ struct Scumm {
void initThings();
void initVideoMode();
void initKbdAndMouse();
void detectSound();
void initRandSeeds();
uint getRandomNumber(uint max);
@ -863,7 +863,7 @@ struct Scumm {
void decodeCostData(Actor *a, int frame, uint mask);
void scummInit();
void scummMain();
void scummMain(int argc, char **argv);
void runScript(int script, int a, int b, int16 *lvarptr);
void stopScriptNr(int script);
@ -1220,6 +1220,10 @@ struct Scumm {
void addToBoxMatrix(byte b);
PathVertex *addPathVertex();
void *addToBoxVertexHeap(int size);
void parseCommandLine(int argc, char **argv);
void showHelpAndExit();
};
void waitForTimer(Scumm *s);
@ -1231,5 +1235,5 @@ void NORETURN CDECL error(const char *s, ...);
void CDECL warning(const char *s, ...);
void CDECL debug(int level, const char *s, ...);
void checkHeap();
void initGraphics(Scumm *s);
void updateScreen(Scumm *s);

View File

@ -17,6 +17,9 @@
*
* Change Log:
* $Log$
* Revision 1.3 2001/10/09 19:02:28 strigeus
* command line parameter support
*
* Revision 1.2 2001/10/09 18:35:02 strigeus
* fixed object parent bug
* fixed some signed/unsigned comparisons
@ -45,22 +48,9 @@ void Scumm::initThings() {
allocResTypeData(14, MKID('NONE'),10,"boxes", 0);
readIndexFile(2);
initVideoMode();
initKbdAndMouse();
detectSound();
initRandSeeds();
}
void Scumm::initVideoMode() {
}
void Scumm::initKbdAndMouse() {
}
void Scumm::detectSound() {
}
void Scumm::initRandSeeds() {
_randSeed1 = 0xA943DE35;
@ -203,7 +193,7 @@ void Scumm::checkRange(int max, int min, int no, const char *str) {
}
}
void Scumm::scummMain() {
void Scumm::scummMain(int argc, char **argv) {
int tmr, i;
Actor *a;
@ -214,10 +204,14 @@ void Scumm::scummMain() {
_fileHandle = NULL;
_bootParam = 29;
_bootParam = 0;
_debugMode = 1;
initThings();
parseCommandLine(argc, argv);
initGraphics(this);
initThings();
scummInit();
vm.vars[VAR_VERSION] = 21;
@ -334,6 +328,41 @@ void Scumm::scummMain() {
} while (1);
}
void Scumm::parseCommandLine(int argc, char **argv) {
int i;
char *s;
/* Parse the arguments */
for (i=1; i < argc; i++) {
s = argv[i];
if (s && s[0]=='-') {
s++;
while (*s) {
switch(tolower(*s)) {
case 'b':
_bootParam = atoi(s+1);
goto NextArg;
default:
goto ShowHelpAndExit;
}
s++;
}
NextArg:;
} else {
ShowHelpAndExit:;
printf(
"ScummVM - Scumm Interpreter\n"
"Syntax:\n"
"\tscummvm [-b<num>]\n"
"Flags:\n"
"\tb<num> - start in that room\n");
exit(1);
}
}
}
void Scumm::startScene(int room, Actor *a, int objectNr) {
int i;
Actor *at;

37
sdl.cpp
View File

@ -17,14 +17,15 @@
*
* Change Log:
* $Log$
* Revision 1.3 2001/10/09 19:02:28 strigeus
* command line parameter support
*
* Revision 1.2 2001/10/09 17:38:20 strigeus
* Autodetection of endianness.
*
* Revision 1.1.1.1 2001/10/09 14:30:13 strigeus
*
* initial revision
*
*
*/
#define NEED_SDL_HEADERS
@ -187,13 +188,21 @@ void updateScreen(Scumm *s) {
numDirtyRects = 0;
}
#undef main
int main(int argc, char* argv[]) {
void initGraphics(Scumm *s) {
if (SDL_Init(SDL_INIT_VIDEO)==-1) {
printf("Could not initialize SDL: %s.\n", SDL_GetError());
return -1;
error("Could not initialize SDL: %s.\n", SDL_GetError());
exit(1);
}
/* Clean up on exit */
atexit(SDL_Quit);
#if !defined(SCALEUP_2x2)
screen = SDL_SetVideoMode(320, 200, 8, SDL_SWSURFACE);
#else
screen = SDL_SetVideoMode(640, 400, 8, SDL_SWSURFACE);
#endif
printf("%d %d, %d %d, %d %d %d, %d %d %d %d %d\n",
sizeof(int8), sizeof(uint8),
sizeof(int16), sizeof(uint16),
@ -204,16 +213,12 @@ int main(int argc, char* argv[]) {
&((CodeHeader*)0)->unk4
);
/* Clean up on exit */
atexit(SDL_Quit);
#if !defined(SCALEUP_2x2)
screen = SDL_SetVideoMode(320, 200, 8, SDL_SWSURFACE);
#else
screen = SDL_SetVideoMode(640, 400, 8, SDL_SWSURFACE);
#endif
}
#undef main
int main(int argc, char* argv[]) {
scumm._videoMode = 0x13;
scumm.scummMain();
scumm.scummMain(argc, argv);
return 0;
}

View File

@ -17,8 +17,12 @@
*
* Change Log:
* $Log$
* Revision 1.1 2001/10/09 14:30:13 strigeus
* Initial revision
* Revision 1.2 2001/10/09 19:02:28 strigeus
* command line parameter support
*
* Revision 1.1.1.1 2001/10/09 14:30:13 strigeus
*
* initial revision
*
*
*/
@ -54,7 +58,7 @@ void Scumm::checkExecVerbs() {
runInputScript(4, _mouseButStat, 1);
} else if (_mouseButStat&0xC000) {
byte code = _mouseButStat&0x8000 ? 1 : 2;
if (virtscr[0].topline <= mouse.y || virtscr[0].topline + virtscr[0].height > mouse.y) {
if (mouse.y >= virtscr[0].topline && mouse.y < virtscr[0].topline + virtscr[0].height) {
over = checkMouseOver(mouse.x, mouse.y);
if (over != 0) {
runInputScript(1,verbs[over].verbid,code);

View File

@ -17,8 +17,12 @@
*
* Change Log:
* $Log$
* Revision 1.1 2001/10/09 14:30:13 strigeus
* Initial revision
* Revision 1.2 2001/10/09 19:02:28 strigeus
* command line parameter support
*
* Revision 1.1.1.1 2001/10/09 14:30:13 strigeus
*
* initial revision
*
*
*/
@ -772,6 +776,10 @@ void waitForTimer(Scumm *s) {
wm->handleMessage();
}
void initGraphics(Scumm *s) {
}
#undef main
int main(int argc, char* argv[]) {
scumm._videoMode = 0x13;
@ -780,7 +788,7 @@ int main(int argc, char* argv[]) {
wm->_vgabuf = (byte*)calloc(320,200);
wm->_scumm = &scumm;
scumm.scummMain();
scumm.scummMain(argc, argv);
return 0;
}