diff options
author | Travis Howell | 2006-09-19 11:59:13 +0000 |
---|---|---|
committer | Travis Howell | 2006-09-19 11:59:13 +0000 |
commit | ab2cb0b30ad15c2cd33c82989461bdcf44644bd2 (patch) | |
tree | d8209b59ea5b444d2a7b7694c8b1cd13449d4ee3 /engines/simon/subroutine.cpp | |
parent | fd85c13d8f5a8c58e056fe51658a5b83da323053 (diff) | |
download | scummvm-rg350-ab2cb0b30ad15c2cd33c82989461bdcf44644bd2.tar.gz scummvm-rg350-ab2cb0b30ad15c2cd33c82989461bdcf44644bd2.tar.bz2 scummvm-rg350-ab2cb0b30ad15c2cd33c82989461bdcf44644bd2.zip |
Expand Simon engine
svn-id: r23939
Diffstat (limited to 'engines/simon/subroutine.cpp')
-rw-r--r-- | engines/simon/subroutine.cpp | 80 |
1 files changed, 73 insertions, 7 deletions
diff --git a/engines/simon/subroutine.cpp b/engines/simon/subroutine.cpp index 3587fa4a0b..2b9ed04432 100644 --- a/engines/simon/subroutine.cpp +++ b/engines/simon/subroutine.cpp @@ -40,11 +40,18 @@ Subroutine *SimonEngine::getSubroutineByID(uint subroutine_id) { return cur; } - loadTablesIntoMem(subroutine_id); + if (loadXTablesIntoMem(subroutine_id)) { + for (cur = _subroutineList; cur; cur = cur->next) { + if (cur->id == subroutine_id) + return cur; + } + } - for (cur = _subroutineList; cur; cur = cur->next) { - if (cur->id == subroutine_id) - return cur; + if (loadTablesIntoMem(subroutine_id)) { + for (cur = _subroutineList; cur; cur = cur->next) { + if (cur->id == subroutine_id) + return cur; + } } if (subroutine_id != 160) @@ -99,7 +106,7 @@ File *SimonEngine::openTablesFile_gme(const char *filename) { return _gameFile; } -void SimonEngine::loadTablesIntoMem(uint subr_id) { +bool SimonEngine::loadTablesIntoMem(uint subr_id) { byte *p; int i; uint min_num, max_num; @@ -108,7 +115,7 @@ void SimonEngine::loadTablesIntoMem(uint subr_id) { p = _tblList; if (p == NULL) - return; + return 0; while (*p) { for (i = 0; *p; p++, i++) @@ -151,12 +158,71 @@ void SimonEngine::loadTablesIntoMem(uint subr_id) { if (_tablesHeapCurPos > _tablesHeapSize) error("loadTablesIntoMem: Out of table memory"); - return; + return 1; } } } debug(1,"loadTablesIntoMem: didn't find %d", subr_id); + return 0; +} + +bool SimonEngine::loadXTablesIntoMem(uint subr_id) { + if (getGameType() != GType_WW) + return 0; + + byte *p; + int i; + uint min_num, max_num; + char filename[30]; + File *in; + + p = _xtblList; + if (p == NULL) + return 0; + + while (*p) { + for (i = 0; *p; p++, i++) + filename[i] = *p; + filename[i] = 0; + p++; + + for (;;) { + min_num = (p[0] * 256) | p[1]; + p += 2; + + if (min_num == 0) + break; + + max_num = (p[0] * 256) | p[1]; + p += 2; + + if (subr_id >= min_num && subr_id <= max_num) { + _subroutineList = _xsubroutineListOrg; + _tablesHeapPtr = _xtablesHeapPtrOrg; + _tablesHeapCurPos = _xtablesHeapCurPosOrg; + _stringIdLocalMin = 1; + _stringIdLocalMax = 0; + + in = openTablesFile(filename); + readSubroutineBlock(in); + closeTablesFile(in); + + alignTableMem(); + + _subroutineListOrg = _subroutineList; + _tablesHeapPtrOrg = _tablesHeapPtr; + _tablesHeapCurPosOrg = _tablesHeapCurPos; + _tablesheapPtrNew = _tablesHeapPtr; + _tablesHeapCurPosNew = _tablesHeapCurPos; + + return 1; + } + } + } + + debug(1,"loadXTablesIntoMem: didn't find %d", subr_id); + return 0; } void SimonEngine::closeTablesFile(File *in) { |