diff options
| author | David Corrales | 2007-07-08 16:58:54 +0000 |
|---|---|---|
| committer | David Corrales | 2007-07-08 16:58:54 +0000 |
| commit | 9bfe5d53540af7dc9bf0214202f4e35b272320ea (patch) | |
| tree | 69dcaf6f735e9fd0913a3e2f163852d4b9af87e3 /engines/agos | |
| parent | 256e4d9521b79160d1f9ed670656097a96dc5a34 (diff) | |
| parent | 17da12ca07a1f18f3fe1ef5b0c2c0cd9fd8359b4 (diff) | |
| download | scummvm-rg350-9bfe5d53540af7dc9bf0214202f4e35b272320ea.tar.gz scummvm-rg350-9bfe5d53540af7dc9bf0214202f4e35b272320ea.tar.bz2 scummvm-rg350-9bfe5d53540af7dc9bf0214202f4e35b272320ea.zip | |
Merged the FSNode branch with trunk r27681:27969
svn-id: r27970
Diffstat (limited to 'engines/agos')
| -rw-r--r-- | engines/agos/agos.cpp | 18 | ||||
| -rw-r--r-- | engines/agos/agos.h | 10 | ||||
| -rw-r--r-- | engines/agos/animation.cpp | 7 | ||||
| -rw-r--r-- | engines/agos/contain.cpp | 16 | ||||
| -rw-r--r-- | engines/agos/debugger.cpp | 2 | ||||
| -rw-r--r-- | engines/agos/detection_tables.h | 2 | ||||
| -rw-r--r-- | engines/agos/event.cpp | 5 | ||||
| -rw-r--r-- | engines/agos/input.cpp | 62 | ||||
| -rw-r--r-- | engines/agos/intern.h | 14 | ||||
| -rw-r--r-- | engines/agos/items.cpp | 28 | ||||
| -rw-r--r-- | engines/agos/menus.cpp | 4 | ||||
| -rw-r--r-- | engines/agos/oracle.cpp | 18 | ||||
| -rw-r--r-- | engines/agos/res.cpp | 54 | ||||
| -rw-r--r-- | engines/agos/rooms.cpp | 22 | ||||
| -rw-r--r-- | engines/agos/saveload.cpp | 54 | ||||
| -rw-r--r-- | engines/agos/script.cpp | 16 | ||||
| -rw-r--r-- | engines/agos/script_e1.cpp | 24 | ||||
| -rw-r--r-- | engines/agos/script_e2.cpp | 38 | ||||
| -rw-r--r-- | engines/agos/script_ff.cpp | 2 | ||||
| -rw-r--r-- | engines/agos/script_s1.cpp | 26 | ||||
| -rw-r--r-- | engines/agos/script_s2.cpp | 2 | ||||
| -rw-r--r-- | engines/agos/script_ww.cpp | 9 | ||||
| -rw-r--r-- | engines/agos/string.cpp | 10 | ||||
| -rw-r--r-- | engines/agos/vga.cpp | 53 | ||||
| -rw-r--r-- | engines/agos/vga.h | 16 |
25 files changed, 267 insertions, 245 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index c98257f028..ae7f692c3f 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -110,8 +110,6 @@ AGOSEngine::AGOSEngine(OSystem *syst) _debugger = 0; - _keyPressed = 0; - _gameFile = 0; _opcode = 0; @@ -746,10 +744,12 @@ void AGOSEngine_Simon2::setupGame() { _tableIndexBase = 1580 / 4; _textIndexBase = 1500 / 4; _numVideoOpcodes = 75; -#ifndef PALMOS_68K - _vgaMemSize = 2000000; -#else +#if defined(__DS__) + _vgaMemSize = 1300000; +#elif defined(PALMOS_68K) _vgaMemSize = gVars->memory[kMemSimon2Games]; +#else + _vgaMemSize = 2000000; #endif _itemMemSize = 20000; _tableMemSize = 100000; @@ -958,8 +958,8 @@ GUI::Debugger *AGOSEngine::getDebugger() { } void AGOSEngine::pause() { - _keyPressed = 1; - _pause = 1; + _keyPressed.reset(); + _pause = true; bool ambient_status = _ambientPaused; bool music_status = _musicPaused; @@ -969,8 +969,8 @@ void AGOSEngine::pause() { while (_pause) { delay(1); - if (_keyPressed == 'p') - _pause = 0; + if (_keyPressed.keycode == Common::KEYCODE_p) + _pause = false; } _midi.pause(music_status); diff --git a/engines/agos/agos.h b/engines/agos/agos.h index e487c38cc7..d233d0bfeb 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -28,6 +28,7 @@ #include "engines/engine.h" +#include "common/keyboard.h" #include "common/rect.h" #include "common/util.h" @@ -216,7 +217,7 @@ protected: const GameSpecificSettings *gss; - byte _keyPressed; + Common::KeyState _keyPressed; Common::File *_gameFile; @@ -875,8 +876,8 @@ public: void vc36_setWindowImage(); void vc38_ifVarNotZero(); void vc39_setVar(); - void vc40(); - void vc41(); + void vc40_scrollRight(); + void vc41_scrollLeft(); void vc42_delayIfNotEQ(); // Video Script Opcodes, Elvira 1 @@ -1316,7 +1317,9 @@ public: void oe2_moveDirn(); void oe2_doClass(); void oe2_pObj(); + void oe2_isCalled(); void oe2_loadGame(); + void oe2_menu(); void oe2_drawItem(); void oe2_doTable(); void oe2_pauseGame(); @@ -1410,7 +1413,6 @@ public: void oww_setLongText(); void oww_printLongText(); void oww_whereTo(); - void oww_menu(); void oww_textMenu(); void oww_pauseGame(); void oww_boxMessage(); diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp index 8748cff54e..8d5238259d 100644 --- a/engines/agos/animation.cpp +++ b/engines/agos/animation.cpp @@ -130,8 +130,11 @@ void MoviePlayer::play() { return; } - if (!_fd) { - return; + if (_omniTVFile) { + // Clear any paused OmniTV video + _mixer->stopHandle(_omniTVSound); + delete _omniTVFile; + _omniTVFile = 0; } _leftButtonDown = false; diff --git a/engines/agos/contain.cpp b/engines/agos/contain.cpp index b5ca344905..891ac36d30 100644 --- a/engines/agos/contain.cpp +++ b/engines/agos/contain.cpp @@ -34,8 +34,8 @@ int AGOSEngine::canPlace(Item *x, Item *y) { Item *z = derefItem(x->parent); if (getGameType() == GType_ELVIRA1) { - SubPlayer *p = (SubPlayer *)findChildOfType(y, 3); - SubContainer *c = (SubContainer *)findChildOfType(y, 7); + SubPlayer *p = (SubPlayer *)findChildOfType(y, kPlayerType); + SubContainer *c = (SubContainer *)findChildOfType(y, kContainerType); int cap = 0; int wt; @@ -59,7 +59,7 @@ int AGOSEngine::canPlace(Item *x, Item *y) { return -2; /* Too heavy */ } } else { - SubObject *o = (SubObject *)findChildOfType(y, 2); + SubObject *o = (SubObject *)findChildOfType(y, kObjectType); int ct; int cap = 0; @@ -120,11 +120,11 @@ int AGOSEngine::sizeRec(Item *x, int d) { } int AGOSEngine::sizeOfRec(Item *i, int d) { - SubObject *o = (SubObject *)findChildOfType(i, 2); + SubObject *o = (SubObject *)findChildOfType(i, kObjectType); if (getGameType() == GType_ELVIRA1) { - SubPlayer *p = (SubPlayer *)findChildOfType(i, 3); - SubContainer *c = (SubContainer *)findChildOfType(i, 7); + SubPlayer *p = (SubPlayer *)findChildOfType(i, kPlayerType); + SubContainer *c = (SubContainer *)findChildOfType(i, kContainerType); if ((c) && (c->flags & 1)) { if (o) @@ -174,10 +174,10 @@ int AGOSEngine::weightRec(Item *x, int d) { } int AGOSEngine::weightOf(Item *x) { - SubObject *o = (SubObject *)findChildOfType(x, 2); + SubObject *o = (SubObject *)findChildOfType(x, kObjectType); if (getGameType() == GType_ELVIRA1) { - SubPlayer *p = (SubPlayer *)findChildOfType(x, 3); + SubPlayer *p = (SubPlayer *)findChildOfType(x, kPlayerType); if (o) return o->objectWeight; if (p) diff --git a/engines/agos/debugger.cpp b/engines/agos/debugger.cpp index ce50460621..3fc5a1f967 100644 --- a/engines/agos/debugger.cpp +++ b/engines/agos/debugger.cpp @@ -174,7 +174,7 @@ bool Debugger::Cmd_SetObjectFlag(int argc, const char **argv) { prop = atoi(argv[2]); if (obj >= 1 && obj < _vm->_itemArraySize) { - SubObject *o = (SubObject *)_vm->findChildOfType(_vm->derefItem(obj), 2); + SubObject *o = (SubObject *)_vm->findChildOfType(_vm->derefItem(obj), kObjectType); if (o != NULL) { if (o->objectFlags & (1 << prop) && prop < 16) { uint offs = _vm->getOffsetOfChild2Param(o, 1 << prop); diff --git a/engines/agos/detection_tables.h b/engines/agos/detection_tables.h index cb6123dc54..5efcaa3b86 100644 --- a/engines/agos/detection_tables.h +++ b/engines/agos/detection_tables.h @@ -426,7 +426,7 @@ static const AGOSGameDescription gameDescriptions[] = { { "gamepc", GAME_BASEFILE, "4bf28ab00f5324fd938e632595742382", -1}, { "icon.dat", GAME_ICONFILE, "83a7278bff55c82fbb3aef92981866c9", -1}, { "menus.dat", GAME_MENUFILE, "a2fdc88a77c8bdffec6b36cbeda4d955", -1}, - { "start", GAME_RESTFILE, "4d380a35ba941d03ee5084c71d20055b", -1}, + { "start", GAME_RESTFILE, "016107aced82d0cc5d758a9fba716270", -1}, { "stripped.txt", GAME_STRFILE, "c3a8f644551a27c8a2fec0f8070b46b7", -1}, { "tbllist", GAME_TBLFILE, "8252660df0edbdbc3e6377e155bbd0c5", -1}, { NULL, 0, NULL, 0} diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp index 32329f34d9..5c673de700 100644 --- a/engines/agos/event.cpp +++ b/engines/agos/event.cpp @@ -500,10 +500,7 @@ void AGOSEngine::delay(uint amount) { } // Make sure backspace works right (this fixes a small issue on OS X) - if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) - _keyPressed = 8; - else - _keyPressed = (byte)event.kbd.ascii; + _keyPressed = event.kbd; break; case Common::EVENT_MOUSEMOVE: break; diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp index ef0791dc10..0f1c234b79 100644 --- a/engines/agos/input.cpp +++ b/engines/agos/input.cpp @@ -195,7 +195,8 @@ void AGOSEngine::waitForInput() { _dragAccept = 1; for (;;) { - if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) && _keyPressed == 35) + if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) && + _keyPressed.keycode == Common::KEYCODE_HASH) displayBoxStars(); if (processSpecialKeys()) { if ((getGameType() == GType_PP && getGameId() != GID_DIMP) || @@ -238,7 +239,6 @@ void AGOSEngine::waitForInput() { _dragMode = 0; _dragCount = 0; _dragEnd = 0; - continue; } } while (!_dragEnd); @@ -472,39 +472,39 @@ bool AGOSEngine::processSpecialKeys() { } } - switch (_keyPressed) { - case 17: // Up + switch (_keyPressed.keycode) { + case Common::KEYCODE_UP: if (getGameType() == GType_PP) _verbHitArea = 302; else if (getGameType() == GType_WW) _verbHitArea = 239; verbCode = true; break; - case 18: // Down + case Common::KEYCODE_DOWN: if (getGameType() == GType_PP) _verbHitArea = 304; else if (getGameType() == GType_WW) _verbHitArea = 241; verbCode = true; break; - case 19: // Right + case Common::KEYCODE_RIGHT: if (getGameType() == GType_PP) _verbHitArea = 303; else if (getGameType() == GType_WW) _verbHitArea = 240; verbCode = true; break; - case 20: // Left + case Common::KEYCODE_LEFT: if (getGameType() == GType_PP) _verbHitArea = 301; else if (getGameType() == GType_WW) _verbHitArea = 242; verbCode = true; break; - case 27: // escape + case Common::KEYCODE_ESCAPE: _exitCutscene = true; break; - case 59: // F1 + case Common::KEYCODE_F1: if (getGameType() == GType_SIMON2) { vcWriteVar(5, 50); vcWriteVar(86, 0); @@ -513,7 +513,7 @@ bool AGOSEngine::processSpecialKeys() { vcWriteVar(86, 0); } break; - case 60: // F2 + case Common::KEYCODE_F2: if (getGameType() == GType_SIMON2) { vcWriteVar(5, 75); vcWriteVar(86, 1); @@ -522,7 +522,7 @@ bool AGOSEngine::processSpecialKeys() { vcWriteVar(86, 1); } break; - case 61: // F3 + case Common::KEYCODE_F3: if (getGameType() == GType_SIMON2) { vcWriteVar(5, 125); vcWriteVar(86, 2); @@ -531,19 +531,19 @@ bool AGOSEngine::processSpecialKeys() { vcWriteVar(86, 2); } break; - case 63: // F5 + case Common::KEYCODE_F5: if (getGameType() == GType_SIMON2 || getGameType() == GType_FF) _exitCutscene = true; break; - case 65: // F7 + case Common::KEYCODE_F7: if (getGameType() == GType_FF && getBitFlag(76)) _variableArray[254] = 70; break; - case 67: // F9 + case Common::KEYCODE_F9: if (getGameType() == GType_FF) setBitFlag(73, !getBitFlag(73)); break; - case 37: // F12 + case Common::KEYCODE_F12: if (getGameType() == GType_PP && getGameId() != GID_DIMP) { if (!getBitFlag(110)) { setBitFlag(107, !getBitFlag(107)); @@ -551,73 +551,77 @@ bool AGOSEngine::processSpecialKeys() { } } break; - case 'p': + case Common::KEYCODE_p: pause(); break; - case 't': + case Common::KEYCODE_t: if (getGameType() == GType_FF || (getGameType() == GType_SIMON2 && (getFeatures() & GF_TALKIE)) || ((getFeatures() & GF_TALKIE) && _language != Common::EN_ANY && _language != Common::DE_DEU)) { if (_speech) _subtitles ^= 1; } break; - case 'v': + case Common::KEYCODE_v: if (getGameType() == GType_FF || (getGameType() == GType_SIMON2 && (getFeatures() & GF_TALKIE))) { if (_subtitles) _speech ^= 1; } - case '+': + case Common::KEYCODE_PLUS: + case Common::KEYCODE_KP_PLUS: if (_midiEnabled) { _midi.setVolume(_midi.getVolume() + 16); } _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) + 16); break; - case '-': + case Common::KEYCODE_MINUS: + case Common::KEYCODE_KP_MINUS: if (_midiEnabled) { _midi.setVolume(_midi.getVolume() - 16); } _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) - 16); break; - case 'm': + case Common::KEYCODE_m: _musicPaused ^= 1; if (_midiEnabled) { _midi.pause(_musicPaused); } _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, (_musicPaused) ? 0 : ConfMan.getInt("music_volume")); break; - case 's': + case Common::KEYCODE_s: if (getGameId() == GID_SIMON1DOS) { _midi._enable_sfx ^= 1; } else { _sound->effectsPause(_effectsPaused ^= 1); } break; - case 'b': + case Common::KEYCODE_b: _sound->ambientPause(_ambientPaused ^= 1); break; - case 'r': + case Common::KEYCODE_r: if (_debugMode) _startMainScript ^= 1; break; - case 'o': + case Common::KEYCODE_o: if (_debugMode) _continousMainScript ^= 1; break; - case 'a': + case Common::KEYCODE_a: if (_debugMode) _startVgaScript ^= 1; break; - case 'g': + case Common::KEYCODE_g: if (_debugMode) _continousVgaScript ^= 1; break; - case 'd': + case Common::KEYCODE_d: if (_debugMode) _dumpImages ^=1; break; + default: + break; } - _keyPressed = 0; + _keyPressed.reset(); return verbCode; } diff --git a/engines/agos/intern.h b/engines/agos/intern.h index a863dc7c0f..44d38fbeed 100644 --- a/engines/agos/intern.h +++ b/engines/agos/intern.h @@ -28,6 +28,20 @@ namespace AGOS { +enum ChildType { + kRoomType = 1, + kObjectType = 2, + kPlayerType = 3, + kGenExitType = 4, // Elvira 1 specific + kSuperRoomType = 4, // Elvira 2 specific + + kContainerType = 7, + kChainType = 8, + kUserFlagType = 9, + + kInheritType = 255 +}; + struct Child { Child *next; uint16 type; diff --git a/engines/agos/items.cpp b/engines/agos/items.cpp index a911bee5a5..9a46b6e8ac 100644 --- a/engines/agos/items.cpp +++ b/engines/agos/items.cpp @@ -66,7 +66,7 @@ bool AGOSEngine::hasIcon(Item *item) { if (getGameType() == GType_ELVIRA1) { return (getUserFlag(item, 7) != 0); } else { - SubObject *child = (SubObject *)findChildOfType(item, 2); + SubObject *child = (SubObject *)findChildOfType(item, kObjectType); return (child && (child->objectFlags & kOFIcon) != 0); } } @@ -75,7 +75,7 @@ uint AGOSEngine::itemGetIconNumber(Item *item) { if (getGameType() == GType_ELVIRA1) { return getUserFlag(item, 7); } else { - SubObject *child = (SubObject *)findChildOfType(item, 2); + SubObject *child = (SubObject *)findChildOfType(item, kObjectType); uint offs; if (child == NULL || !(child->objectFlags & kOFIcon)) @@ -97,7 +97,7 @@ void AGOSEngine::createPlayer() { _currentPlayer->adjective = -1; _currentPlayer->noun = 10000; - p = (SubPlayer *)allocateChildBlock(_currentPlayer, 3, sizeof(SubPlayer)); + p = (SubPlayer *)allocateChildBlock(_currentPlayer, kPlayerType, sizeof(SubPlayer)); if (p == NULL) error("createPlayer: player create failure"); @@ -135,14 +135,14 @@ Child *AGOSEngine::findChildOfType(Item *i, uint type) { int AGOSEngine::getUserFlag(Item *item, int a) { SubUserFlag *subUserFlag; - subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) return 0; if (a < 0 || a > 7) return 0; - return subUserFlag->userFlags[a]; + return subUserFlag->userFlags[a]; } int AGOSEngine::getUserFlag1(Item *item, int a) { @@ -151,7 +151,7 @@ int AGOSEngine::getUserFlag1(Item *item, int a) { if (item == NULL || item == _dummyItem2 || item == _dummyItem3) return -1; - subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) return 0; @@ -164,9 +164,9 @@ int AGOSEngine::getUserFlag1(Item *item, int a) { void AGOSEngine::setUserFlag(Item *item, int a, int b) { SubUserFlag *subUserFlag; - subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) { - subUserFlag = (SubUserFlag *) allocateChildBlock(item, 9, sizeof(SubUserFlag)); + subUserFlag = (SubUserFlag *)allocateChildBlock(item, kUserFlagType, sizeof(SubUserFlag)); } if (a < 0 || a > 7) @@ -178,7 +178,7 @@ void AGOSEngine::setUserFlag(Item *item, int a, int b) { int AGOSEngine::getUserItem(Item *item, int n) { SubUserFlag *subUserFlag; - subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) return 0; @@ -191,9 +191,9 @@ int AGOSEngine::getUserItem(Item *item, int n) { void AGOSEngine::setUserItem(Item *item, int n, int m) { SubUserFlag *subUserFlag; - subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) { - subUserFlag = (SubUserFlag *) allocateChildBlock(item, 9, sizeof(SubUserFlag)); + subUserFlag = (SubUserFlag *)allocateChildBlock(item, kUserFlagType, sizeof(SubUserFlag)); } if (n == 0) @@ -201,15 +201,15 @@ void AGOSEngine::setUserItem(Item *item, int n, int m) { } bool AGOSEngine::isRoom(Item *item) { - return findChildOfType(item, 1) != NULL; + return findChildOfType(item, kRoomType) != NULL; } bool AGOSEngine::isObject(Item *item) { - return findChildOfType(item, 2) != NULL; + return findChildOfType(item, kObjectType) != NULL; } bool AGOSEngine::isPlayer(Item *item) { - return findChildOfType(item, 3) != NULL; + return findChildOfType(item, kPlayerType) != NULL; } uint AGOSEngine::getOffsetOfChild2Param(SubObject *child, uint prop) { diff --git a/engines/agos/menus.cpp b/engines/agos/menus.cpp index 6dd1a356d8..81df34c311 100644 --- a/engines/agos/menus.cpp +++ b/engines/agos/menus.cpp @@ -199,7 +199,7 @@ uint AGOSEngine::menuFor_e2(Item *item) { if (item == NULL || item == _dummyItem2 || item == _dummyItem3) return 0xFFFF; - SubObject *subObject = (SubObject *)findChildOfType(item, 2); + SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); if (subObject != NULL && subObject->objectFlags & kOFMenu) { uint offs = getOffsetOfChild2Param(subObject, kOFMenu); return subObject->objectFlagValue[offs]; @@ -216,7 +216,7 @@ uint AGOSEngine::menuFor_ww(Item *item, uint id) { if (item == NULL || item == _dummyItem2 || item == _dummyItem3) return _agosMenu; - SubObject *subObject = (SubObject *)findChildOfType(item, 2); + SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); if (subObject != NULL && subObject->objectFlags & kOFMenu) { uint offs = getOffsetOfChild2Param(subObject, kOFMenu); return subObject->objectFlagValue[offs]; diff --git a/engines/agos/oracle.cpp b/engines/agos/oracle.cpp index 787596a966..c7ad0ee8b7 100644 --- a/engines/agos/oracle.cpp +++ b/engines/agos/oracle.cpp @@ -464,37 +464,37 @@ void AGOSEngine_Feeble::saveUserGame(int slot) { windowPutChar(window, 0x7f); for (;;) { - _keyPressed = 0; + _keyPressed.reset(); delay(1); - if (_keyPressed == 0 || _keyPressed >= 127) + if (_keyPressed.ascii == 0 || _keyPressed.ascii >= 127) continue; window->textColumn -= getFeebleFontSize(127); name[len] = 0; windowBackSpace(_windowArray[3]); - if (_keyPressed == 27) { - _variableArray[55] = _keyPressed; + if (_keyPressed.keycode == Common::KEYCODE_ESCAPE) { + _variableArray[55] = 27; break; } - if (_keyPressed == 10 || _keyPressed == 13) { + if (_keyPressed.keycode == Common::KEYCODE_KP_ENTER || _keyPressed.keycode == Common::KEYCODE_RETURN) { if (!saveGame(readVariable(55), name)) _variableArray[55] = (int16)0xFFFF; else _variableArray[55] = 0; break; } - if (_keyPressed == 8 && len != 0) { + if (_keyPressed.keycode == Common::KEYCODE_BACKSPACE && len != 0) { len--; byte chr = name[len]; window->textColumn -= getFeebleFontSize(chr); name[len] = 0; windowBackSpace(_windowArray[3]); } - if (_keyPressed >= 32 && window->textColumn + 26 <= window->width) { - name[len++] = _keyPressed; - windowPutChar(_windowArray[3], _keyPressed); + if (_keyPressed.ascii >= 32 && window->textColumn + 26 <= window->width) { + name[len++] = _keyPressed.ascii; + windowPutChar(_windowArray[3], _keyPressed.ascii); } windowPutChar(window, 0x7f); diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp index 394c4956ae..4898cc9a45 100644 --- a/engines/agos/res.cpp +++ b/engines/agos/res.cpp @@ -350,13 +350,13 @@ void AGOSEngine::readItemFromGamePc(Common::SeekableReadStream *in, Item *item) } void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, uint type) { - if (type == 1) { - SubRoom *subRoom = (SubRoom *)allocateChildBlock(item, 1, sizeof(SubRoom)); + if (type == kRoomType) { + SubRoom *subRoom = (SubRoom *)allocateChildBlock(item, kRoomType, sizeof(SubRoom)); subRoom->roomShort = in->readUint32BE(); subRoom->roomLong = in->readUint32BE(); subRoom->flags = in->readUint16BE(); - } else if (type == 2) { - SubObject *subObject = (SubObject *)allocateChildBlock(item, 2, sizeof(SubObject)); + } else if (type == kObjectType) { + SubObject *subObject = (SubObject *)allocateChildBlock(item, kObjectType, sizeof(SubObject)); in->readUint32BE(); in->readUint32BE(); in->readUint32BE(); @@ -364,8 +364,8 @@ void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, ui subObject->objectSize = in->readUint16BE(); subObject->objectWeight = in->readUint16BE(); subObject->objectFlags = in->readUint16BE(); - } else if (type == 4) { - SubGenExit *genExit = (SubGenExit *)allocateChildBlock(item, 4, sizeof(SubGenExit)); + } else if (type == kGenExitType) { + SubGenExit *genExit = (SubGenExit *)allocateChildBlock(item, kGenExitType, sizeof(SubGenExit)); genExit->dest[0] = (uint16)fileReadItemID(in); genExit->dest[1] = (uint16)fileReadItemID(in); genExit->dest[2] = (uint16)fileReadItemID(in); @@ -378,14 +378,14 @@ void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, ui fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); - } else if (type == 7) { - SubContainer *container = (SubContainer *)allocateChildBlock(item, 7, sizeof(SubContainer)); + } else if (type == kContainerType) { + SubContainer *container = (SubContainer *)allocateChildBlock(item, kContainerType, sizeof(SubContainer)); container->volume = in->readUint16BE(); container->flags = in->readUint16BE(); - } else if (type == 8) { - SubChain *chain = (SubChain *)allocateChildBlock(item, 8, sizeof(SubChain)); + } else if (type == kChainType) { + SubChain *chain = (SubChain *)allocateChildBlock(item, kChainType, sizeof(SubChain)); chain->chChained = (uint16)fileReadItemID(in); - } else if (type == 9) { + } else if (type == kUserFlagType) { setUserFlag(item, 0, in->readUint16BE()); setUserFlag(item, 1, in->readUint16BE()); setUserFlag(item, 2, in->readUint16BE()); @@ -394,13 +394,13 @@ void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, ui setUserFlag(item, 5, in->readUint16BE()); setUserFlag(item, 6, in->readUint16BE()); setUserFlag(item, 7, in->readUint16BE()); - SubUserFlag *subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + SubUserFlag *subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); subUserFlag->userItems[0] = (uint16)fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); - } else if (type == 255) { - SubInherit *inherit = (SubInherit *)allocateChildBlock(item, 255, sizeof(SubInherit)); + } else if (type == kInheritType) { + SubInherit *inherit = (SubInherit *)allocateChildBlock(item, kInheritType, sizeof(SubInherit)); inherit->inMaster = (uint16)fileReadItemID(in); } else { error("readItemChildren: invalid type %d", type); @@ -408,7 +408,7 @@ void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, ui } void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item *item, uint type) { - if (type == 1) { + if (type == kRoomType) { uint fr1 = in->readUint16BE(); uint fr2 = in->readUint16BE(); uint i, size; @@ -420,14 +420,14 @@ void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item * if (j & 3) size += sizeof(subRoom->roomExit[0]); - subRoom = (SubRoom *)allocateChildBlock(item, 1, size); + subRoom = (SubRoom *)allocateChildBlock(item, kRoomType, size); subRoom->subroutine_id = fr1; subRoom->roomExitStates = fr2; for (i = k = 0, j = fr2; i != 6; i++, j >>= 2) if (j & 3) subRoom->roomExit[k++] = (uint16)fileReadItemID(in); - } else if (type == 2) { + } else if (type == kObjectType) { uint32 fr = in->readUint32BE(); uint i, k, size; SubObject *subObject; @@ -437,7 +437,7 @@ void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item * if (fr & (1 << i)) size += sizeof(subObject->objectFlagValue[0]); - subObject = (SubObject *)allocateChildBlock(item, 2, size); + subObject = (SubObject *)allocateChildBlock(item, kObjectType, size); subObject->objectFlags = fr; k = 0; @@ -450,7 +450,7 @@ void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item * if (getGameType() != GType_ELVIRA2) subObject->objectName = (uint16)in->readUint32BE(); - } else if (type == 4) { + } else if (type == kSuperRoomType) { assert(getGameType() == GType_ELVIRA2); uint i, j, k, size; @@ -467,7 +467,7 @@ void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item * for (i = 0; i != j; i++) size += sizeof(subSuperRoom->roomExitStates[0]); - subSuperRoom = (SubSuperRoom *)allocateChildBlock(item, 4, size); + subSuperRoom = (SubSuperRoom *)allocateChildBlock(item, kSuperRoomType, size); subSuperRoom->subroutine_id = id; subSuperRoom->roomX = x; subSuperRoom->roomY = y; @@ -475,20 +475,20 @@ void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item * for (i = k = 0; i != j; i++) subSuperRoom->roomExitStates[k++] = in->readUint16BE(); - } else if (type == 7) { - SubContainer *container = (SubContainer *)allocateChildBlock(item, 7, sizeof(SubContainer)); + } else if (type == kContainerType) { + SubContainer *container = (SubContainer *)allocateChildBlock(item, kContainerType, sizeof(SubContainer)); container->volume = in->readUint16BE(); container->flags = in->readUint16BE(); - } else if (type == 8) { - SubChain *chain = (SubChain *)allocateChildBlock(item, 8, sizeof(SubChain)); + } else if (type == kChainType) { + SubChain *chain = (SubChain *)allocateChildBlock(item, kChainType, sizeof(SubChain)); chain->chChained = (uint16)fileReadItemID(in); - } else if (type == 9) { + } else if (type == kUserFlagType) { setUserFlag(item, 0, in->readUint16BE()); setUserFlag(item, 1, in->readUint16BE()); setUserFlag(item, 2, in->readUint16BE()); setUserFlag(item, 3, in->readUint16BE()); - } else if (type == 255) { - SubInherit *inherit = (SubInherit *)allocateChildBlock(item, 255, sizeof(SubInherit)); + } else if (type == kInheritType) { + SubInherit *inherit = (SubInherit *)allocateChildBlock(item, kInheritType, sizeof(SubInherit)); inherit->inMaster = (uint16)fileReadItemID(in); } else { error("readItemChildren: invalid type %d", type); diff --git a/engines/agos/rooms.cpp b/engines/agos/rooms.cpp index af1bd0fe93..5e612080df 100644 --- a/engines/agos/rooms.cpp +++ b/engines/agos/rooms.cpp @@ -49,7 +49,7 @@ uint16 AGOSEngine::getDoorState(Item *item, uint16 d) { uint16 mask = 3; uint16 n; - SubRoom *subRoom = (SubRoom *)findChildOfType(item, 1); + SubRoom *subRoom = (SubRoom *)findChildOfType(item, kRoomType); if (subRoom == NULL) return 0; @@ -66,7 +66,7 @@ uint16 AGOSEngine::getExitOf(Item *item, uint16 d) { uint16 x; uint16 y = 0; - subRoom = (SubRoom *)findChildOfType(item, 1); + subRoom = (SubRoom *)findChildOfType(item, kRoomType); if (subRoom == NULL) return 0; x = d; @@ -93,7 +93,7 @@ void AGOSEngine::setDoorState(Item *i, uint16 d, uint16 n) { uint16 d1; uint16 y = 0; - r = (SubRoom *)findChildOfType(i, 1); + r = (SubRoom *)findChildOfType(i, kRoomType); if (r == NULL) return; d1 = d; @@ -107,7 +107,7 @@ void AGOSEngine::setDoorState(Item *i, uint16 d, uint16 n) { j = derefItem(r->roomExit[d1]); if (j == NULL) return; - r1 = (SubRoom *)findChildOfType(j, 1); + r1 = (SubRoom *)findChildOfType(j, kRoomType); if (r1 == NULL) return; d = getBackExit(d); @@ -130,7 +130,7 @@ Item *AGOSEngine::getDoorOf(Item *i, uint16 d) { SubGenExit *g; Item *x; - g = (SubGenExit *)findChildOfType(i, 4); + g = (SubGenExit *)findChildOfType(i, kGenExitType); if (g == NULL) return 0; @@ -146,7 +146,7 @@ Item *AGOSEngine::getExitOf_e1(Item *item, uint16 d) { SubGenExit *g; Item *x; - g = (SubGenExit *)findChildOfType(item, 4); + g = (SubGenExit *)findChildOfType(item, kGenExitType); if (g == NULL) return 0; @@ -192,10 +192,10 @@ void AGOSEngine_Elvira2::moveDirn(Item *i, uint x) { return; p = derefItem(i->parent); - if (findChildOfType(p, 4)) { + if (findChildOfType(p, kSuperRoomType)) { n = getExitState(p, _superRoomNumber,x); if (n == 1) { - sr = (SubSuperRoom *)findChildOfType(p, 4); + sr = (SubSuperRoom *)findChildOfType(p, kSuperRoomType); switch (x) { case 0: a = -(sr->roomX); break; case 1: a = 1; break; @@ -319,7 +319,7 @@ uint16 AGOSEngine_Elvira2::getExitState(Item *i, uint16 x, uint16 d) { uint16 mask = 3; uint16 n; - sr = (SubSuperRoom *)findChildOfType(i, 4); + sr = (SubSuperRoom *)findChildOfType(i, kSuperRoomType); if (sr == NULL) return 0; @@ -331,7 +331,7 @@ uint16 AGOSEngine_Elvira2::getExitState(Item *i, uint16 x, uint16 d) { } void AGOSEngine_Elvira2::setExitState(Item *i, uint16 n, uint16 d, uint16 s) { - SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, 4); + SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, kSuperRoomType); if (sr) changeExitStates(sr, n, d, s); } @@ -339,7 +339,7 @@ void AGOSEngine_Elvira2::setExitState(Item *i, uint16 n, uint16 d, uint16 s) { void AGOSEngine_Elvira2::setSRExit(Item *i, int n, int d, uint16 s) { uint16 mask = 3; - SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, 4); + SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, kSuperRoomType); if (sr) { n--; d <<= 1; diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp index eb2266550a..32b767073a 100644 --- a/engines/agos/saveload.cpp +++ b/engines/agos/saveload.cpp @@ -257,12 +257,12 @@ restart: for (;;) { windowPutChar(window, 128); - _keyPressed = 0; + _keyPressed.reset(); for (;;) { delay(10); - if (_keyPressed && _keyPressed < 128) { - i = _keyPressed; + if (_keyPressed.ascii && _keyPressed.ascii < 128) { + i = _keyPressed.ascii; break; } } @@ -490,16 +490,16 @@ int AGOSEngine_Elvira2::userGameGetKey(bool *b, char *buf, uint maxChar) { HitArea *ha; *b = true; - _keyPressed = 0; + _keyPressed.reset(); for (;;) { _lastHitArea = NULL; _lastHitArea3 = NULL; do { - if (_saveLoadEdit && _keyPressed && _keyPressed < maxChar) { + if (_saveLoadEdit && _keyPressed.ascii && _keyPressed.ascii < maxChar) { *b = false; - return _keyPressed; + return _keyPressed.ascii; } delay(10); } while (_lastHitArea3 == 0); @@ -759,16 +759,16 @@ int AGOSEngine_Simon1::userGameGetKey(bool *b, char *buf, uint maxChar) { listSaveGames(buf); } - _keyPressed = 0; + _keyPressed.reset(); for (;;) { _lastHitArea = NULL; _lastHitArea3 = NULL; do { - if (_saveLoadEdit && _keyPressed && _keyPressed < maxChar) { + if (_saveLoadEdit && _keyPressed.ascii && _keyPressed.ascii < maxChar) { *b = false; - return _keyPressed; + return _keyPressed.ascii; } delay(10); } while (_lastHitArea3 == 0); @@ -999,13 +999,13 @@ bool AGOSEngine::loadGame(const char *filename, bool restartMode) { item->state = f->readUint16BE(); item->classFlags = f->readUint16BE(); - SubObject *o = (SubObject *)findChildOfType(item, 2); + SubObject *o = (SubObject *)findChildOfType(item, kObjectType); if (o) { o->objectSize = f->readUint16BE(); o->objectWeight = f->readUint16BE(); } - SubPlayer *p = (SubPlayer *)findChildOfType(item, 3); + SubPlayer *p = (SubPlayer *)findChildOfType(item, kPlayerType); if (p) { p->score = f->readUint32BE(); p->level = f->readUint16BE(); @@ -1014,7 +1014,7 @@ bool AGOSEngine::loadGame(const char *filename, bool restartMode) { p->strength = f->readUint16BE(); } - SubUserFlag *u = (SubUserFlag *) findChildOfType(item, 9); + SubUserFlag *u = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (u) { for (i = 0; i != 8; i++) { u->userFlags[i] = f->readUint16BE(); @@ -1083,13 +1083,13 @@ bool AGOSEngine::saveGame(uint slot, const char *caption) { f->writeUint16BE(item->state); f->writeUint16BE(item->classFlags); - SubObject *o = (SubObject *)findChildOfType(item, 2); + SubObject *o = (SubObject *)findChildOfType(item, kObjectType); if (o) { f->writeUint16BE(o->objectSize); f->writeUint16BE(o->objectWeight); } - SubPlayer *p = (SubPlayer *)findChildOfType(item, 3); + SubPlayer *p = (SubPlayer *)findChildOfType(item, kPlayerType); if (p) { f->writeUint32BE(p->score); f->writeUint16BE(p->level); @@ -1098,7 +1098,7 @@ bool AGOSEngine::saveGame(uint slot, const char *caption) { f->writeUint16BE(p->strength); } - SubUserFlag *u = (SubUserFlag *) findChildOfType(item, 9); + SubUserFlag *u = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (u) { for (i = 0; i != 8; i++) { f->writeUint16BE(u->userFlags[i]); @@ -1204,19 +1204,19 @@ bool AGOSEngine_Elvira2::loadGame(const char *filename, bool restartMode) { item->state = f->readUint16BE(); item->classFlags = f->readUint16BE(); - SubRoom *r = (SubRoom *)findChildOfType(item, 1); + SubRoom *r = (SubRoom *)findChildOfType(item, kRoomType); if (r) { r->roomExitStates = f->readUint16BE(); } - SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(item, 4); + SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(item, kSuperRoomType); if (sr) { uint16 n = sr->roomX * sr->roomY * sr->roomZ; for (i = j = 0; i != n; i++) sr->roomExitStates[j++] = f->readUint16BE(); } - SubObject *o = (SubObject *)findChildOfType(item, 2); + SubObject *o = (SubObject *)findChildOfType(item, kObjectType); if (o) { o->objectFlags = f->readUint32BE(); i = o->objectFlags & 1; @@ -1228,7 +1228,7 @@ bool AGOSEngine_Elvira2::loadGame(const char *filename, bool restartMode) { } } - SubUserFlag *u = (SubUserFlag *) findChildOfType(item, 9); + SubUserFlag *u = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (u) { for (i = 0; i != 4; i++) { u->userFlags[i] = f->readUint16BE(); @@ -1283,9 +1283,12 @@ bool AGOSEngine_Elvira2::saveGame(uint slot, const char *caption) { Common::OutSaveFile *f; uint item_index, num_item, i, j; TimeEvent *te; - uint32 curTime = 0; uint32 gsc = _gameStoppedClock; + uint32 curTime = 0; + if (getGameType() != GType_SIMON1 && getGameType() != GType_SIMON2) + curTime = time(NULL); + _lockWord |= 0x100; f = _saveFileMan->openForSaving(genSaveName(slot)); @@ -1299,7 +1302,6 @@ bool AGOSEngine_Elvira2::saveGame(uint slot, const char *caption) { // No caption } else if (getGameType() == GType_FF) { f->write(caption, 100); - curTime = time(NULL); } else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { f->write(caption, 18); } else { @@ -1308,7 +1310,7 @@ bool AGOSEngine_Elvira2::saveGame(uint slot, const char *caption) { f->writeUint32BE(_itemArrayInited - 1); f->writeUint32BE(0xFFFFFFFF); - f->writeUint32BE(0); + f->writeUint32BE(curTime); f->writeUint32BE(0); i = 0; @@ -1345,19 +1347,19 @@ bool AGOSEngine_Elvira2::saveGame(uint slot, const char *caption) { f->writeUint16BE(item->state); f->writeUint16BE(item->classFlags); - SubRoom *r = (SubRoom *)findChildOfType(item, 1); + SubRoom *r = (SubRoom *)findChildOfType(item, kRoomType); if (r) { f->writeUint16BE(r->roomExitStates); } - SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(item, 4); + SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(item, kSuperRoomType); if (sr) { uint16 n = sr->roomX * sr->roomY * sr->roomZ; for (i = j = 0; i != n; i++) f->writeUint16BE(sr->roomExitStates[j++]); } - SubObject *o = (SubObject *)findChildOfType(item, 2); + SubObject *o = (SubObject *)findChildOfType(item, kObjectType); if (o) { f->writeUint32BE(o->objectFlags); i = o->objectFlags & 1; @@ -1369,7 +1371,7 @@ bool AGOSEngine_Elvira2::saveGame(uint slot, const char *caption) { } } - SubUserFlag *u = (SubUserFlag *)findChildOfType(item, 9); + SubUserFlag *u = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (u) { for (i = 0; i != 4; i++) { f->writeUint16BE(u->userFlags[i]); diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index c5cf6c5872..ace0b9d50f 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -206,7 +206,7 @@ void AGOSEngine::o_state() { void AGOSEngine::o_oflag() { // 28: item has prop - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); uint num = getVarOrByte(); setScriptCondition(subObject != NULL && (subObject->objectFlags & (1 << num)) != 0); } @@ -326,7 +326,7 @@ void AGOSEngine::o_goto() { void AGOSEngine::o_oset() { // 56: set child2 fr bit - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); int value = getVarOrByte(); if (subObject != NULL && value >= 16) subObject->objectFlags |= (1 << value); @@ -334,7 +334,7 @@ void AGOSEngine::o_oset() { void AGOSEngine::o_oclear() { // 57: clear child2 fr bit - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); int value = getVarOrByte(); if (subObject != NULL && value >= 16) subObject->objectFlags &= ~(1 << value); @@ -426,7 +426,7 @@ void AGOSEngine::o_if2() { void AGOSEngine::o_isCalled() { // 79: childstruct fr2 is - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); uint stringId = getNextStringID(); setScriptCondition((subObject != NULL) && subObject->objectName == stringId); } @@ -753,7 +753,7 @@ void AGOSEngine::o_setAdjNoun() { void AGOSEngine::o_saveUserGame() { // 132: save user game if (getGameId() == GID_SIMON1CD32) { - // The Amiga CD32 version of Simon the Sorcerer 1uses a single slot + // The Amiga CD32 version of Simon the Sorcerer 1 uses a single slot if (!saveGame(0, "Default Saved Game")) { vc33_setMouseOn(); fileError(_windowArray[5], true); @@ -799,7 +799,7 @@ void AGOSEngine::o_freezeZones() { freezeBottom(); if (!_copyProtection && !(getFeatures() & GF_TALKIE)) { - if ((getGameType() == GType_SIMON1 && _subroutine == 2924) || + if ((getGameType() == GType_SIMON1 && _subroutine == 2924) || (getGameType() == GType_SIMON2 && _subroutine == 1322)) { _variableArray[134] = 3; _variableArray[135] = 3; @@ -985,10 +985,10 @@ Child *nextSub(Child *sub, int16 key) { } void AGOSEngine::synchChain(Item *i) { - SubChain *c = (SubChain *)findChildOfType(i, 8); + SubChain *c = (SubChain *)findChildOfType(i, kChainType); while (c) { setItemState(derefItem(c->chChained), i->state); - c = (SubChain *)nextSub((Child *)c, 8); + c = (SubChain *)nextSub((Child *)c, kChainType); } } diff --git a/engines/agos/script_e1.cpp b/engines/agos/script_e1.cpp index b003a7262f..5a1d7d104b 100644 --- a/engines/agos/script_e1.cpp +++ b/engines/agos/script_e1.cpp @@ -419,7 +419,7 @@ void AGOSEngine_Elvira1::oe1_notPresent() { void AGOSEngine_Elvira1::oe1_worn() { // 4: worn Item *item = getNextItemPtr(); - SubObject *subObject = (SubObject *)findChildOfType(item, 2); + SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); if (item->parent != getItem1ID() || subObject == NULL) setScriptCondition(false); @@ -430,7 +430,7 @@ void AGOSEngine_Elvira1::oe1_worn() { void AGOSEngine_Elvira1::oe1_notWorn() { // 5: not worn Item *item = getNextItemPtr(); - SubObject *subObject = (SubObject *)findChildOfType(item, 2); + SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); if (item->parent != getItem1ID() || subObject == NULL) setScriptCondition(false); @@ -532,7 +532,7 @@ void AGOSEngine_Elvira1::oe1_moveDirn() { void AGOSEngine_Elvira1::oe1_score() { // 90: score - SubPlayer *p = (SubPlayer *) findChildOfType(me(), 3); + SubPlayer *p = (SubPlayer *)findChildOfType(me(), kPlayerType); showMessageFormat("Your score is %ld.\n", p->score); } @@ -542,9 +542,9 @@ void AGOSEngine_Elvira1::oe1_look() { if (i == NULL) return; - SubRoom *r = (SubRoom *)findChildOfType(i, 1); - SubObject *o = (SubObject *)findChildOfType(i, 2); - SubPlayer *p = (SubPlayer *)findChildOfType(i, 3); + SubRoom *r = (SubRoom *)findChildOfType(i, kRoomType); + SubObject *o = (SubObject *)findChildOfType(i, kObjectType); + SubPlayer *p = (SubPlayer *)findChildOfType(i, kPlayerType); if (p == NULL) return; @@ -594,7 +594,7 @@ void AGOSEngine_Elvira1::oe1_doClass() { void AGOSEngine_Elvira1::oe1_pObj() { // 112: print object - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); getVarOrWord(); if (subObject != NULL) @@ -624,7 +624,7 @@ void AGOSEngine_Elvira1::oe1_isCalled() { void AGOSEngine_Elvira1::oe1_cFlag() { // 162: check container flag - SubContainer *c = (SubContainer *)findChildOfType(getNextItemPtr(), 7); + SubContainer *c = (SubContainer *)findChildOfType(getNextItemPtr(), kContainerType); uint bit = getVarOrWord(); if (c == NULL) @@ -678,7 +678,7 @@ void AGOSEngine_Elvira1::oe1_doorExit() { int16 f = getVarOrWord(); int16 ct = 0; - c = (SubChain *)findChildOfType(d, 8); + c = (SubChain *)findChildOfType(d, kChainType); if (c) a = derefItem(c->chChained); while (ct < 6) { @@ -986,7 +986,7 @@ void AGOSEngine_Elvira1::oe1_printMonsterHit() { } int16 AGOSEngine::levelOf(Item *item) { - SubPlayer *p = (SubPlayer *) findChildOfType(item, 3); + SubPlayer *p = (SubPlayer *)findChildOfType(item, kPlayerType); if (p == NULL) return 0; @@ -998,7 +998,7 @@ int16 AGOSEngine::moreText(Item *i) { i = derefItem(i->next); while (i) { - o = (SubObject *)findChildOfType(i, 2); + o = (SubObject *)findChildOfType(i, kObjectType); if ((o) && (o->objectFlags & 1)) goto l1; if (i != me()) @@ -1014,7 +1014,7 @@ void AGOSEngine::lobjFunc(Item *i, const char *f) { SubObject *o; while (i) { - o = (SubObject *)findChildOfType(i, 2); + o = (SubObject *)findChildOfType(i, kObjectType); if ((o) && (o->objectFlags & 1)) goto l1; if (i == me()) diff --git a/engines/agos/script_e2.cpp b/engines/agos/script_e2.cpp index 00f0848ed9..77df3feecb 100644 --- a/engines/agos/script_e2.cpp +++ b/engines/agos/script_e2.cpp @@ -132,7 +132,7 @@ void AGOSEngine_Elvira2::setupOpcodes() { OPCODE(o_when), OPCODE(o_if1), OPCODE(o_if2), - OPCODE(oe1_isCalled), + OPCODE(oe2_isCalled), /* 80 */ OPCODE(o_is), OPCODE(o_invalid), @@ -165,7 +165,7 @@ void AGOSEngine_Elvira2::setupOpcodes() { OPCODE(o_cls), /* 104 */ OPCODE(o_closeWindow), - OPCODE(o_invalid), + OPCODE(oe2_menu), OPCODE(o_invalid), OPCODE(o_addBox), /* 108 */ @@ -309,12 +309,19 @@ void AGOSEngine_Elvira2::oe2_doClass() { void AGOSEngine_Elvira2::oe2_pObj() { // 73: print object - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (subObject != NULL && subObject->objectFlags & kOFText) showMessageFormat("%s\n", (const char *)getStringPtrByID(subObject->objectFlagValue[0])); // Difference } +void AGOSEngine_Elvira2::oe2_isCalled() { + // 79: childstruct fr2 is + Item *i = getNextItemPtr(); + uint stringId = getNextStringID(); + setScriptCondition(i->itemName == stringId); +} + void AGOSEngine_Elvira2::oe2_loadGame() { // 89: load game uint16 stringId = getNextStringID(); @@ -326,6 +333,11 @@ void AGOSEngine_Elvira2::oe2_loadGame() { } } +void AGOSEngine_Elvira2::oe2_menu() { + // 105: set agos menu + _agosMenu = getVarOrByte(); +} + void AGOSEngine_Elvira2::oe2_drawItem() { // 113: draw item Item *i = getNextItemPtr(); @@ -341,7 +353,7 @@ void AGOSEngine_Elvira2::oe2_doTable() { // 143: start item sub Item *i = getNextItemPtr(); - SubRoom *r = (SubRoom *)findChildOfType(i, 1); + SubRoom *r = (SubRoom *)findChildOfType(i, kRoomType); if (r != NULL) { Subroutine *sub = getSubroutineByID(r->subroutine_id); if (sub) { @@ -351,7 +363,7 @@ void AGOSEngine_Elvira2::oe2_doTable() { } if (getGameType() == GType_ELVIRA2) { - SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, 4); + SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, kSuperRoomType); if (sr != NULL) { Subroutine *sub = getSubroutineByID(sr->subroutine_id); if (sub) { @@ -478,7 +490,7 @@ void AGOSEngine_Elvira2::oe2_bNotZero() { void AGOSEngine_Elvira2::oe2_getOValue() { // 157: get item int prop Item *item = getNextItemPtr(); - SubObject *subObject = (SubObject *)findChildOfType(item, 2); + SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); uint prop = getVarOrByte(); if (subObject != NULL && subObject->objectFlags & (1 << prop) && prop < 16) { @@ -492,7 +504,7 @@ void AGOSEngine_Elvira2::oe2_getOValue() { void AGOSEngine_Elvira2::oe2_setOValue() { // 158: set item prop Item *item = getNextItemPtr(); - SubObject *subObject = (SubObject *)findChildOfType(item, 2); + SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); uint prop = getVarOrByte(); int value = getVarOrWord(); @@ -640,6 +652,16 @@ void AGOSEngine_Elvira2::oe2_isAdjNoun() { // 179: item unk1 unk2 is Item *item = getNextItemPtr(); int16 a = getNextWord(), b = getNextWord(); + + if (getGameType() == GType_ELVIRA2) { + // WORKAROUND: A NULL item can occur when interacting with Wine Bottles + if (item == NULL) { + warning("Please report where exactly this occurs in Elvira 2"); + setScriptCondition(false); + return; + } + } + setScriptCondition(item->adjective == a && item->noun == b); } @@ -707,7 +729,7 @@ void AGOSEngine_Elvira2::printStats() { if (val > 9999) val = 9999; writeChar(window, 30, y, 6, val / 100); - writeChar(window, 32, y, 2, val / 10); + writeChar(window, 32, y, 2, val % 100); mouseOn(); } diff --git a/engines/agos/script_ff.cpp b/engines/agos/script_ff.cpp index c3e6dc5192..8b7af31a66 100644 --- a/engines/agos/script_ff.cpp +++ b/engines/agos/script_ff.cpp @@ -528,7 +528,7 @@ void AGOSEngine_Feeble::off_screenTextPObj() { TextLocation *tl = NULL; char buf[256]; - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (subObject != NULL && subObject->objectFlags & kOFText) { string_ptr = (const char *)getStringPtrByID(subObject->objectFlagValue[0]); tl = getTextLocation(vgaSpriteId); diff --git a/engines/agos/script_s1.cpp b/engines/agos/script_s1.cpp index 93b907e688..1a4f956b8b 100644 --- a/engines/agos/script_s1.cpp +++ b/engines/agos/script_s1.cpp @@ -311,29 +311,29 @@ void AGOSEngine_Simon1::os1_pauseGame() { _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true); // If all else fails, use English as fallback. - byte keyYes = 'y'; - byte keyNo = 'n'; + Common::KeyCode keyYes = Common::KEYCODE_y; + Common::KeyCode keyNo = Common::KEYCODE_n; switch (_language) { case Common::RU_RUS: break; case Common::PL_POL: - keyYes = 't'; + keyYes = Common::KEYCODE_t; break; case Common::HB_ISR: - keyYes = 'f'; + keyYes = Common::KEYCODE_f; break; case Common::ES_ESP: - keyYes = 's'; + keyYes = Common::KEYCODE_s; break; case Common::IT_ITA: - keyYes = 's'; + keyYes = Common::KEYCODE_s; break; case Common::FR_FRA: - keyYes = 'o'; + keyYes = Common::KEYCODE_o; break; case Common::DE_DEU: - keyYes = 'j'; + keyYes = Common::KEYCODE_j; break; default: break; @@ -343,17 +343,17 @@ void AGOSEngine_Simon1::os1_pauseGame() { delay(1); #ifdef _WIN32_WCE if (isSmartphone()) { - if (_keyPressed) { - if (_keyPressed == 13) + if (_keyPressed.keycode) { + if (_keyPressed.keycode == Common::KEYCODE_RETURN) shutdown(); else break; } } #endif - if (_keyPressed == keyYes || _keyPressed == (keyYes - 32)) + if (_keyPressed.keycode == keyYes) shutdown(); - else if (_keyPressed == keyNo || _keyPressed == (keyNo - 32)) + else if (_keyPressed.keycode == keyNo) break; } @@ -419,7 +419,7 @@ void AGOSEngine_Simon1::os1_screenTextPObj() { uint vgaSpriteId = getVarOrByte(); uint color = getVarOrByte(); - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (getFeatures() & GF_TALKIE) { if (subObject != NULL && subObject->objectFlags & kOFVoice) { uint offs = getOffsetOfChild2Param(subObject, kOFVoice); diff --git a/engines/agos/script_s2.cpp b/engines/agos/script_s2.cpp index dfc1200d7c..00addce396 100644 --- a/engines/agos/script_s2.cpp +++ b/engines/agos/script_s2.cpp @@ -355,7 +355,7 @@ void AGOSEngine_Simon2::os2_screenTextPObj() { uint vgaSpriteId = getVarOrByte(); uint color = getVarOrByte(); - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (getFeatures() & GF_TALKIE) { if (subObject != NULL && subObject->objectFlags & kOFVoice) { uint speechId = subObject->objectFlagValue[getOffsetOfChild2Param(subObject, kOFVoice)]; diff --git a/engines/agos/script_ww.cpp b/engines/agos/script_ww.cpp index 377b49ae3f..fc472fd3c3 100644 --- a/engines/agos/script_ww.cpp +++ b/engines/agos/script_ww.cpp @@ -167,7 +167,7 @@ void AGOSEngine_Waxworks::setupOpcodes() { OPCODE(o_cls), /* 104 */ OPCODE(o_closeWindow), - OPCODE(oww_menu), + OPCODE(oe2_menu), OPCODE(oww_textMenu), OPCODE(o_addBox), /* 108 */ @@ -355,11 +355,6 @@ void AGOSEngine_Waxworks::oww_whereTo() { _objectItem = derefItem(getExitOf(i, d)); } -void AGOSEngine_Waxworks::oww_menu() { - // 105: set agos menu - _agosMenu = getVarOrByte(); -} - void AGOSEngine_Waxworks::oww_textMenu() { // 106: set text menu byte slot = getVarOrByte(); @@ -419,7 +414,7 @@ void AGOSEngine_Waxworks::oww_printBox() { void AGOSEngine_Waxworks::oww_boxPObj() { // 188: print object name to box - SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (subObject != NULL && subObject->objectFlags & kOFText) boxTextMsg((const char *)getStringPtrByID(subObject->objectFlagValue[0])); diff --git a/engines/agos/string.cpp b/engines/agos/string.cpp index 483f101889..521a3ab6ea 100644 --- a/engines/agos/string.cpp +++ b/engines/agos/string.cpp @@ -274,7 +274,7 @@ bool AGOSEngine::printNameOf(Item *item, uint x, uint y) { if (item == 0 || item == _dummyItem2 || item == _dummyItem3) return false; - subObject = (SubObject *)findChildOfType(item, 2); + subObject = (SubObject *)findChildOfType(item, kObjectType); if (subObject == NULL) return false; @@ -370,10 +370,12 @@ void AGOSEngine::printScreenText(uint vgaSpriteId, uint color, const char *strin if (y < 2) y = 2; - if (getGameType() == GType_SIMON1) - animate(windowNum, 2, 199 + vgaSpriteId, x, y, 12); - else + if (getGameType() == GType_SIMON1) { + uint16 id = 199 + vgaSpriteId; + animate(windowNum, id / 100, id, x, y, 12); + } else { animate(windowNum, 2, vgaSpriteId, x, y, 12); + } } // The Feeble Files specific diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp index 2b8f6d3a09..38c401a80d 100644 --- a/engines/agos/vga.cpp +++ b/engines/agos/vga.cpp @@ -70,8 +70,8 @@ void AGOSEngine::setupVideoOpcodes(VgaOpcodeProc *op) { op[36] = &AGOSEngine::vc36_setWindowImage; op[38] = &AGOSEngine::vc38_ifVarNotZero; op[39] = &AGOSEngine::vc39_setVar; - op[40] = &AGOSEngine::vc40; - op[41] = &AGOSEngine::vc41; + op[40] = &AGOSEngine::vc40_scrollRight; + op[41] = &AGOSEngine::vc41_scrollLeft; op[42] = &AGOSEngine::vc42_delayIfNotEQ; op[43] = &AGOSEngine::vc43_ifBitSet; op[44] = &AGOSEngine::vc44_ifBitClear; @@ -124,8 +124,8 @@ void AGOSEngine_Elvira1::setupVideoOpcodes(VgaOpcodeProc *op) { op[41] = &AGOSEngine::vc37_pokePalette; op[51] = &AGOSEngine::vc38_ifVarNotZero; op[52] = &AGOSEngine::vc39_setVar; - op[53] = &AGOSEngine::vc40; - op[54] = &AGOSEngine::vc41; + op[53] = &AGOSEngine::vc40_scrollRight; + op[54] = &AGOSEngine::vc41_scrollLeft; op[56] = &AGOSEngine::vc42_delayIfNotEQ; } @@ -1257,57 +1257,38 @@ void AGOSEngine::vc39_setVar() { vcWriteVar(var, value); } -void AGOSEngine::vc40() { +void AGOSEngine::vc40_scrollRight() { uint16 var = vcReadNextWord(); int16 value = vcReadVar(var) + vcReadNextWord(); if (getGameType() == GType_SIMON2 && var == 15 && !getBitFlag(80)) { - int16 tmp; - if (_scrollCount != 0) { - if (_scrollCount >= 0) - goto no_scroll; + if ((_scrollCount < 0) || (_scrollCount == 0 && _scrollFlag == 0)) { _scrollCount = 0; - } else { - if (_scrollFlag != 0) - goto no_scroll; - } - - if (value - _scrollX >= 30) { - _scrollCount = 20; - tmp = _scrollXMax - _scrollX; - if (tmp < 20) - _scrollCount = tmp; - addVgaEvent(6, SCROLL_EVENT, NULL, 0, 0); + if (value - _scrollX >= 30) { + _scrollCount = MIN(20, _scrollXMax - _scrollX); + addVgaEvent(6, SCROLL_EVENT, NULL, 0, 0); + } } } -no_scroll:; vcWriteVar(var, value); } -void AGOSEngine::vc41() { +void AGOSEngine::vc41_scrollLeft() { uint16 var = vcReadNextWord(); int16 value = vcReadVar(var) - vcReadNextWord(); if (getGameType() == GType_SIMON2 && var == 15 && !getBitFlag(80)) { - if (_scrollCount != 0) { - if (_scrollCount < 0) - goto no_scroll; - _scrollCount = 0; - } else { - if (_scrollFlag != 0) - goto no_scroll; - } - if ((uint16)(value - _scrollX) < 11) { - _scrollCount = -20; - if (_scrollX < 20) - _scrollCount = -_scrollX; - addVgaEvent(6, SCROLL_EVENT, NULL, 0, 0); + if ((_scrollCount > 0) || (_scrollCount == 0 && _scrollFlag == 0)) { + _scrollCount = 0; + if ((uint16)(value - _scrollX) < 11) { + _scrollCount = -MIN(20, (int)_scrollX); + addVgaEvent(6, SCROLL_EVENT, NULL, 0, 0); + } } } -no_scroll:; vcWriteVar(var, value); } diff --git a/engines/agos/vga.h b/engines/agos/vga.h index 37c5d37106..1994f59f7f 100644 --- a/engines/agos/vga.h +++ b/engines/agos/vga.h @@ -40,20 +40,20 @@ struct VgaFileHeader2_Feeble { uint16 x_4; uint16 animationTable; uint16 x_5; -}; +} PACKED_STRUCT; struct ImageHeader_Feeble { uint16 id; uint16 x_1; uint16 scriptOffs; uint16 x_2; -}; +} PACKED_STRUCT; struct AnimationHeader_Feeble { uint16 scriptOffs; uint16 x_2; uint16 id; -}; +} PACKED_STRUCT; // Simon 1/2 struct ImageHeader_Simon { @@ -61,13 +61,13 @@ struct ImageHeader_Simon { uint16 color; uint16 x_2; uint16 scriptOffs; -}; +} PACKED_STRUCT; struct AnimationHeader_Simon { uint16 id; uint16 x_2; uint16 scriptOffs; -}; +} PACKED_STRUCT; // Elvira 1/2 and Waxworks @@ -76,14 +76,14 @@ struct ImageHeader_WW { uint16 color; uint16 x_2; uint16 scriptOffs; -}; +} PACKED_STRUCT; struct AnimationHeader_WW { uint16 id; uint16 x_1; uint16 x_2; uint16 scriptOffs; -}; +} PACKED_STRUCT; // Common struct VgaFileHeader2_Common { @@ -96,7 +96,7 @@ struct VgaFileHeader2_Common { uint16 x_4; uint16 animationTable; uint16 x_5; -}; +} PACKED_STRUCT; #include "common/pack-end.h" // END STRUCT PACKING |
