diff options
author | James Brown | 2002-03-16 18:03:28 +0000 |
---|---|---|
committer | James Brown | 2002-03-16 18:03:28 +0000 |
commit | 1d97edb2f9a1ab7cc8209fff7e8a7c76e47bbf8e (patch) | |
tree | c878965ac5196c41f7d0f7e0d21fea647ada75f5 | |
parent | c650f028aacc59e15bddd984e64e5bf6fac0ba4a (diff) | |
download | scummvm-rg350-1d97edb2f9a1ab7cc8209fff7e8a7c76e47bbf8e.tar.gz scummvm-rg350-1d97edb2f9a1ab7cc8209fff7e8a7c76e47bbf8e.tar.bz2 scummvm-rg350-1d97edb2f9a1ab7cc8209fff7e8a7c76e47bbf8e.zip |
Update to my latest local tree. Various stuff - and a fixme hack by khalek to stop loom intro crashing.
svn-id: r3765
-rw-r--r-- | gui.cpp | 28 | ||||
-rw-r--r-- | gui.h | 49 | ||||
-rw-r--r-- | resource.cpp | 30 | ||||
-rw-r--r-- | script.cpp | 27 | ||||
-rw-r--r-- | scumm.h | 12 | ||||
-rw-r--r-- | scummvm.cpp | 8 |
6 files changed, 103 insertions, 51 deletions
@@ -660,26 +660,32 @@ void Gui::getSavegameNames(int start) { } } -const char *Gui::queryString(int string, int id) { +const char *Gui::queryString(int stringno, int id) { static char namebuf[64]; - if (!_s->_gameId) - return "blah!"; - + char *result; + int string; if (id>=20 && id<=28) { sprintf(namebuf, "%2d. %s", id-20+_slotIndex, game_names[id-20]); return namebuf; } - if (string == 0) + if (stringno == 0) return NULL; - if (_s->_features&GF_AFTER_V6) { - string = _s->_vars[string_map_table_v6[string-1]]; - } else { - string = string_map_table_v5[string-1]; - } + if (_s->_features&GF_AFTER_V6) + string = _s->_vars[string_map_table_v6[stringno-1].num]; + else + string = string_map_table_v5[stringno-1].num; - return (char*)_s->getStringAddress(string); + result = (char*)_s->getStringAddress(string); + + if (!result) // Gracelessly degrade to english :) + if (_s->_features&GF_AFTER_V6) + return string_map_table_v6[stringno-1].string; + else + return string_map_table_v5[stringno-1].string; + + return result; } void Gui::showCaret(bool show) { @@ -1,6 +1,11 @@ #if !defined(gui_h) #define gui_h +struct ResString { + int num; + char string[80]; +}; + enum { GUI_NONE = 0, GUI_RESTEXT = 1, @@ -43,30 +48,30 @@ static const char* string_map_table_custom[] = { "Options" //17 }; -static const byte string_map_table_v6[] = { - 117, /* How may I serve you? */ - 109, /* Select a game to LOAD */ - 108, /* Name your SAVE game */ - 96, /* Save */ - 97, /* Load */ - 98, /* Play */ - 99, /* Cancel */ - 100, /* Quit */ - 101, /* Ok */ - 93 /* Game paused */ +static ResString string_map_table_v6[] = { + {117, "How may I serve you?"}, + {109, "Select a game to LOAD"}, + {108, "Name your SAVE game"}, + {96, "Save"}, + {97, "Load"}, + {98, "Play"}, + {99, "Cancel"}, + {100, "Quit"}, + {101, "Ok"}, + {93, "Game paused"}, }; -static const byte string_map_table_v5[] = { - 0, /* How may I serve you? */ - 20, /* Select a game to LOAD */ - 19, /* Name your SAVE game */ - 7, /* Save */ - 8, /* Load */ - 9, /* Play */ - 10, /* Cancel */ - 11, /* Quit */ - 12, /* Ok */ - 4 /* Game paused */ +static ResString string_map_table_v5[] = { + {0, "How may I serve you?"}, + {20, "Select a game to LOAD"}, + {19, "Name your SAVE game"}, + {7, "Save"}, + {8, "Load"}, + {9, "Play"}, + {10, "Cancel"}, + {11, "Quit"}, + {12, "Ok"}, + {4, "Game paused"} }; struct GuiWidget { diff --git a/resource.cpp b/resource.cpp index 304e8c87ab..8899e4ddb1 100644 --- a/resource.cpp +++ b/resource.cpp @@ -515,12 +515,13 @@ void Scumm::allocResTypeData(int id, uint32 tag, int num, const char *name, int } void Scumm::loadCharset(int no) { - int i; + int i, line = 0; byte *ptr; - + debug(9, "loadCharset(%d)",no); - if(_features & GF_EXTERNAL_CHARSET) { - uint32 size; + if(_features & GF_EXTERNAL_CHARSET) { + uint32 size; + checkRange(4 ,0 ,no , "Loading illegal charset %d"); openRoom(-1); if( _features & GF_SMALL_NAMES) @@ -543,6 +544,17 @@ void Scumm::loadCharset(int no) { for (i=0; i<15; i++) { _charsetData[no][i+1] = ptr[i+14]; } + printf("byte *font[] = {"); + while(*ptr) { + line++; + printf("%d,", ptr[i]); + if (line > 80) { + printf("\n"); + line = 0; + } + ptr++; + } + printf("};\n"); } void Scumm::nukeCharset(int i) { @@ -726,13 +738,15 @@ byte *Scumm::getResourceAddress(int type, int idx) { CHECK_HEAP validateResource("getResourceAddress", type, idx); - + if (!res.address[type]) + return NULL; + if (res.mode[type] && !res.address[type][idx]) { ensureResourceLoaded(type, idx); } - ptr=(byte*)res.address[type][idx]; - if (!ptr) + + if (!(ptr = (byte*)res.address[type][idx])) return NULL; setResourceCounter(type, idx, 1); @@ -790,7 +804,7 @@ byte *Scumm::createResource(int type, int idx, uint32 size) { void Scumm::validateResource(const char *str, int type, int idx) { if (type<rtFirst || type>rtLast || (uint)idx >= (uint)res.num[type]) { - error("%s Illegal Glob type %d num %d", str, type, idx); + warning("%s Illegal Glob type %d num %d", str, type, idx); } } diff --git a/script.cpp b/script.cpp index 9d5a8b2ef8..dae762e0cb 100644 --- a/script.cpp +++ b/script.cpp @@ -22,6 +22,7 @@ #include "stdafx.h" #include "scumm.h" +/* Start executing script 'script' with parameters 'a' and 'b' */ void Scumm::runScript(int script, int a, int b, int16 *lvarptr) { byte *scriptPtr; uint32 scriptOffs; @@ -65,6 +66,7 @@ void Scumm::runScript(int script, int a, int b, int16 *lvarptr) { runScriptNested(slot); } +/* Stop script 'script' */ void Scumm::stopScriptNr(int script) { ScriptSlot *ss; NestedScript *nest; @@ -83,7 +85,7 @@ void Scumm::stopScriptNr(int script) { if (ss->cutsceneOverride) error("Script %d stopped with active cutscene/override", script); ss->number = 0; - ss->status = 0; + ss->status = ssDead; if (_currentScript == i) _currentScript = 0xFF; } @@ -103,6 +105,7 @@ void Scumm::stopScriptNr(int script) { } while(nest++,--num); } +/* Stop an object script 'script'*/ void Scumm::stopObjectScript(int script) { ScriptSlot *ss; NestedScript *nest; @@ -119,7 +122,7 @@ void Scumm::stopObjectScript(int script) { if (ss->cutsceneOverride) error("Object %d stopped with active cutscene/override", script); ss->number = 0; - ss->status = 0; + ss->status = ssDead; if (_currentScript == i) _currentScript = 0xFF; } @@ -142,6 +145,7 @@ void Scumm::stopObjectScript(int script) { } while(nest++,--num); } +/* Return a free script slot */ int Scumm::getScriptSlot() { ScriptSlot *ss; int i; @@ -154,6 +158,7 @@ int Scumm::getScriptSlot() { error("Too many scripts running, %d max", NUM_SCRIPT_SLOT); } +/* Run script 'script' nested - eg, within the parent script.*/ void Scumm::runScriptNested(int script) { NestedScript *nest; ScriptSlot *slot; @@ -205,6 +210,7 @@ void Scumm::updateScriptPtr() { vm.slot[_currentScript].offs = _scriptPointer - _scriptOrgPointer; } +/* Get the code pointer to a script */ void Scumm::getScriptBaseAddress() { ScriptSlot *ss; int idx; @@ -248,6 +254,7 @@ void Scumm::getScriptEntryPoint() { _scriptPointer = _scriptOrgPointer + vm.slot[_currentScript].offs; } +/* Execute a script - Read opcode, and execute it from the table */ void Scumm::executeScript() { OpcodeProc op; while (_currentScript != 0xFF) { @@ -438,7 +445,11 @@ void Scumm::stopObjectCode() { * stopObjectScript(ss->number); */ } else { if (ss->cutsceneOverride) - error("Script %d ending with active cutscene/override", ss->number); + // FIXME: Loom workaround, fix properly :) - khalek + if ((_gameId == GID_LOOM256) && (ss->number==44)) + this->exitCutscene(); + else + error("Script %d ending with active cutscene/override", ss->number); } ss->number = 0; ss->status = 0; @@ -470,7 +481,7 @@ void Scumm::freezeScripts(int flag) { int i; for(i=1; i<NUM_SCRIPT_SLOT; i++) { - if (_currentScript!=i && vm.slot[i].status!=0 && (vm.slot[i].unk1==0 || flag>=0x80)) { + if (_currentScript!=i && vm.slot[i].status!=ssDead && (vm.slot[i].unk1==0 || flag>=0x80)) { vm.slot[i].status |= 0x80; vm.slot[i].freezeCount++; } @@ -509,7 +520,7 @@ void Scumm::runAllScripts() { _currentScript = 0xFF; for(_curExecScript = 0; _curExecScript<NUM_SCRIPT_SLOT; _curExecScript++) { - if (vm.slot[_curExecScript].status == 2 && + if (vm.slot[_curExecScript].status == ssRunning && vm.slot[_curExecScript].didexec == 0) { _currentScript = (char)_curExecScript; getScriptBaseAddress(); @@ -524,7 +535,7 @@ void Scumm::runExitScript() { runScript(_vars[VAR_EXIT_SCRIPT], 0, 0, 0); if (_EXCD_offs) { int slot = getScriptSlot(); - vm.slot[slot].status = 2; + vm.slot[slot].status = ssRunning; vm.slot[slot].number = 10001; vm.slot[slot].where = WIO_ROOM; vm.slot[slot].offs = _EXCD_offs; @@ -542,7 +553,7 @@ void Scumm::runEntryScript() { runScript(_vars[VAR_ENTRY_SCRIPT], 0, 0, 0); if (_ENCD_offs) { int slot = getScriptSlot(); - vm.slot[slot].status = 2; + vm.slot[slot].status = ssRunning; vm.slot[slot].number = 10002; vm.slot[slot].where = WIO_ROOM; vm.slot[slot].offs = _ENCD_offs; @@ -670,7 +681,7 @@ void Scumm::runVerbCode(int object, int entry, int a, int b, int16 *vars) { vm.slot[slot].number = object; vm.slot[slot].offs = obcd + offs; - vm.slot[slot].status = 2; + vm.slot[slot].status = ssRunning; vm.slot[slot].where = where; vm.slot[slot].unk1 = a; vm.slot[slot].unk2 = b; @@ -53,12 +53,20 @@ enum { KEY_SET_OPTIONS = 3456 // WinCE }; +/* Sound output type - MIDI */ enum { MIDI_NULL = 0, MIDI_WINDOWS = 1, MIDI_TIMIDITY = 2, MIDI_SEQ = 3, - MIDI_QTMUSIC = 4 + MIDI_QTMUSIC = 4, +}; + +/* Script status type (slot.status) */ +enum { + ssDead = 0, + ssPaused = 1, + ssRunning = 2 }; const uint16 many_direction_tab[18] = { @@ -2283,6 +2291,8 @@ struct Serializer { bool isSaving() { return _saveOrLoad; } + + bool Serializer::checkEOFLoadStream(); }; diff --git a/scummvm.cpp b/scummvm.cpp index 021bff95f0..61bdbdea31 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -286,11 +286,16 @@ void Scumm::scummMain(int argc, char **argv) { int Scumm::scummLoop(int delta) { + + #ifndef _WIN32_WCE + if (_debugger) _debugger->on_frame(); + + #endif _vars[VAR_TMR_1] += delta; @@ -584,6 +589,7 @@ static const VersionSettings version_settings[] = { /* Scumm version 5 */ {"loomcd", "Loom (256 color CD version)", GID_LOOM256, 5, 1, 42, GF_SMALL_HEADER|GF_USE_KEY|GF_AUDIOTRACKS}, {"monkey", "Monkey Island 1", GID_MONKEY, 5, 2, 2, GF_USE_KEY|GF_AUDIOTRACKS}, + {"monkey1", "Monkey Island 1 (alt)", GID_MONKEY, 5, 2, 2, GF_USE_KEY|GF_AUDIOTRACKS}, {"monkey2", "Monkey Island 2: LeChuck's revenge", GID_MONKEY2, 5, 2, 2, GF_USE_KEY}, {"atlantis", "Indiana Jones 4 and the Fate of Atlantis", GID_INDY4, 5, 5, 0, GF_USE_KEY}, {"playfate", "Indiana Jones 4 and the Fate of Atlantis (Demo)", GID_INDY4, 5, 5, 0, GF_USE_KEY}, @@ -689,7 +695,7 @@ void Scumm::startScene(int room, Actor *a, int objectNr) { _currentRoom = room; _vars[VAR_ROOM] = room; - + printf("startscene with room 0x%x", room); if (room >= 0x80) _roomResource = _resourceMapper[room&0x7F]; else |