diff options
152 files changed, 8616 insertions, 3668 deletions
@@ -7,15 +7,37 @@ For a more comprehensive changelog of the latest experimental code, see: General: - Updated MT-32 emulation code to version 1.3.0. + - Switched from our custom JPEG decoder to libjpeg-turbo, which + is faster and can handle all kinds of exotic JPEG images :) + - Switched from our custom PNG decoder to libpng, which + is faster and can handle all kinds of exotic PNG images :) + (NOTE: The change to libpng was done in version 1.6.0, but + it was not added to the NEWS file). Gob: - - Improved video quality in Urban Runner + - Improved video quality in Urban Runner. + + SCI: + - Added support for the more detailed RAVE lip syncing data in the + Windows version of King's Quest 6. Portraits should now be much + more expressive when talking. + - Added support for simultaneous speech and subtitles in the CD + versions of Laura Bow 2 and King's Quest 6 (toggled via the + ScummVM audio options). + - Fixed music fading. + - Fixed several script bugs in Camelot, Crazy Nick's, Hoyle 3, + QFG1VGA, KQ5, KQ6, LB2, LSL2, LSL5, Pharkas, PQ1VGA, SQ4, SQ5. + - Improved the MIDI parser so that music event processing is done + more properly. Broken Sword 1: - - Added back support for MPEG-2 videos + - Added back support for MPEG-2 videos. Broken Sword 2: - - Added back support for MPEG-2 videos + - Added back support for MPEG-2 videos. + + Tinsel: + - Discworld 1 and 2 no longer crash on big-endian systems. 1.6.0 (2013-05-31) New Games: @@ -33,7 +33,8 @@ Table of Contents: * 3.17 Winnie the Pooh notes * 3.18 Troll's Tale notes * 3.19 Dragon History notes - * 3.20 Known Problems + * 3.20 Simultaneous speech and subtitles in Sierra SCI games + * 3.21 Known Problems 4.0) Supported Platforms 5.0) Running ScummVM * 5.1 Command Line Options @@ -815,7 +816,55 @@ All game files and the walkthrough can be downloaded from http://www.ucw.cz/draci-historie/index-en.html -3.20) Known Problems: +3.20) Simultaneous speech and subtitles in Sierra SCI games: +----- ------------------------------------------------------ +Certain CD versions of Sierra SCI games had both speech and text +resources. Some have an option to toggle between the two, but there are +some cases where there wasn't any option to enable both simultaneously. +In ScummVM, it is possible to enjoy a combined mode, where both speech +and text are shown at the same time. This mode can be toggled in the +ScummVM audio options, but each game has different behavior in-game +regarding speech and text toggling. + +The CD games where speech and subtitles can be shown simultaneously +are: + EcoQuest 1 CD + Freddy Pharkas CD + King's Quest 6 CD + Laura Bow 2 CD + Leisure Suit Larry 6 CD + Space Quest 4 CD + +EcoQuest 1 CD: + Speech and text can be toggled via the game's "Mode" option in the + options dialog, or via ScummVM's audio options. + +Freddy Pharkas CD: + There is no in-game option to toggle speech and text. Only ScummVM's + audio options can be used to toggle this feature. Note that some + spoken dialog is missing from the game texts. + +King's Quest 6 CD: + Speech and text can be toggled via the "Mode" button in the options + dialog (with an extra "Dual" setting added in ScummVM), or via + ScummVM's audio options. + +Laura Bow 2 CD: + Speech and text can be toggled via the "Mode" button in the options + dialog (with an extra "Dual" setting added in ScummVM), or via + ScummVM's audio options. + +Leisure Suit Larry 6 CD: + Either speech only or speech and text can be selected. There is no + in-game option to toggle text only. Only ScummVM's audio options can + be used to enable the text only mode. + +Space Quest 4 CD: + Speech and text can be toggled via the "Display Mode" button in the + options dialog, or via ScummVM's audio options. + + +3.21) Known Problems: ----- --------------- This release has the following known problems. There is no need to report them, although patches to fix them are welcome. If you discover a diff --git a/engines/agos/detection_tables.h b/engines/agos/detection_tables.h index 70757865f5..329af75d0c 100644 --- a/engines/agos/detection_tables.h +++ b/engines/agos/detection_tables.h @@ -1091,6 +1091,30 @@ static const AGOSGameDescription gameDescriptions[] = { GF_32COLOR | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_OLD_BUNDLE | GF_PLANAR }, + // Simon the Sorcerer 1 - German Amiga OCS Floppy + { + { + "simon1", + "OCS Floppy", + + { + { "gameamiga", GAME_BASEFILE, "634c82b7a0b760214fd71add328c7a00", 39493}, + { "icon.pkd", GAME_ICONFILE, "565ef7a98dcc21ef526a2bb10b6f42ed", 18979}, + { "stripped.txt", GAME_STRFILE, "f5fc67db3b8c5283cda51c43b98a74f8", 243}, + { "tbllist", GAME_TBLFILE, "f9d5bf2ce09f82289c791c3ca26e1e4b", 696}, + { NULL, 0, NULL, 0} + }, + Common::DE_DEU, + Common::kPlatformAmiga, + ADGF_NO_FLAGS, + GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI) + }, + + GType_SIMON1, + GID_SIMON1, + GF_32COLOR | GF_CRUNCHED | GF_OLD_BUNDLE | GF_PLANAR + }, + // Simon the Sorcerer 1 - English Amiga AGA Floppy { { diff --git a/engines/avalanche/dialogs.cpp b/engines/avalanche/dialogs.cpp index 271c0b8288..c68ad4b002 100644 --- a/engines/avalanche/dialogs.cpp +++ b/engines/avalanche/dialogs.cpp @@ -318,7 +318,7 @@ void Dialogs::scrollModeMusic() { || (event.kbd.keycode == Common::KEYCODE_u) || (event.kbd.keycode == Common::KEYCODE_i) || (event.kbd.keycode == Common::KEYCODE_o) || (event.kbd.keycode == Common::KEYCODE_p) || (event.kbd.keycode == Common::KEYCODE_LEFTBRACKET) || (event.kbd.keycode == Common::KEYCODE_RIGHTBRACKET))) { - byte value; + byte value = 0; switch (event.kbd.keycode) { case Common::KEYCODE_q: value = 0; diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index 841512847f..4b8d667fbf 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -451,6 +451,51 @@ void GraphicManager::drawDebugLines() { } } +void GraphicManager::drawFilledRectangle(Common::Rect rect, Color color) { + _surface.fillRect(rect, color); +} + +void GraphicManager::drawRectangle(Common::Rect rect, Color color) { + _surface.frameRect(rect, color); +} + +void GraphicManager::nimLoad() { + Common::File file; + Common::String filename = "nim.avd"; + + if (!file.open(filename)) + error("AVALANCHE: Scrolls: File not found: %s", filename.c_str()); + + file.seek(41); + + _nimStone = loadPictureSign(file, 7, 23); + for (int i = 0; i < 3; i++) + _nimInitials[i] = loadPictureSign(file, 7, 23); + _nimLogo = loadPictureSign(file, 30, 37); + + file.close(); +} + +void GraphicManager::nimDrawStone(int x, int y) { + drawPicture(_surface, _nimStone, x, y); +} + +void GraphicManager::nimDrawInitials() { + for (int i = 0; i < 3; i++) + drawPicture(_surface, _nimInitials[i], 0, 75 + i * 35); +} + +void GraphicManager::nimDrawLogo() { + drawPicture(_surface, _nimLogo, 392, 5); +} + +void GraphicManager::nimFree() { + _nimStone.free(); + for (int i = 0; i < 3; i++) + _nimInitials[i].free(); + _nimLogo.free(); +} + /** * This function mimics Pascal's getimage(). */ @@ -503,6 +548,31 @@ Graphics::Surface GraphicManager::loadPictureRaw(Common::File &file, uint16 widt return picture; } +Graphics::Surface GraphicManager::loadPictureSign(Common::File &file, int xl, int yl) { + // I know it looks very similar to the other loadPicture methods, but in truth it's the combination of the two. + uint16 width = xl * 8; + uint16 height = yl; + + Graphics::Surface picture; // We make a Surface object for the picture itself. + picture.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); + + // Produce the picture. We read it in row-by-row, and every row has 4 planes. + for (int yy = 0; yy < height; yy++) { + for (int8 plane = 0; plane < 4; plane++) { // The planes are in the "right" order. + for (uint16 xx = 0; xx < width; xx += 8) { + byte pixel = file.readByte(); + for (int bit = 0; bit < 8; bit++) { + byte pixelBit = (pixel >> bit) & 1; + if (pixelBit != 0) + *(byte *)picture.getBasePtr(xx + 7 - bit, yy) += (pixelBit << plane); + } + } + } + } + + return picture; +} + void GraphicManager::clearAlso() { _magics.fillRect(Common::Rect(0, 0, 640, 200), 0); _magics.frameRect(Common::Rect(0, 45, 640, 161), 15); @@ -603,28 +673,10 @@ void GraphicManager::drawSign(Common::String fn, int16 xl, int16 yl, int16 y) { if (!file.open(filename)) error("AVALANCHE: Scrolls: File not found: %s", filename.c_str()); - // I know it looks very similar to the loadPicture methods, but in truth it's the combination of the two. - uint16 width = xl * 8; - uint16 height = yl; - Graphics::Surface sign; // We make a Surface object for the picture itself. - sign.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); - - // Produce the picture. We read it in row-by-row, and every row has 4 planes. - for (int yy = 0; yy < height; yy++) { - for (int8 plane = 0; plane < 4; plane++) { // The planes are in the "right" order. - for (uint16 xx = 0; xx < width; xx += 8) { - byte pixel = file.readByte(); - for (int bit = 0; bit < 8; bit++) { - byte pixelBit = (pixel >> bit) & 1; - if (pixelBit != 0) - *(byte *)sign.getBasePtr(xx + 7 - bit, yy) += (pixelBit << plane); - } - } - } - } - - drawPicture(_scrolls, sign, kScreenWidth / 2 - width / 2, y); + sign = loadPictureSign(file, xl, yl); + uint16 width = xl * 8; + drawPicture(_scrolls, sign, kScreenWidth / 2 - width / 2, y); // x coord: center the picture. file.close(); } diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index 4af6d4e8db..0de23612a7 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -77,18 +77,25 @@ public: void drawChar(byte ander, int x, int y, Color color); void drawDebugLines(); + // For the mini-game "Nim". + void drawFilledRectangle(Common::Rect rect, Color color); + void drawRectangle(Common::Rect rect, Color color); + void nimLoad(); + void nimDrawStone(int x, int y); + void nimDrawInitials(); + void nimDrawLogo(); + void nimFree(); + void clearAlso(); void clearTextBar(); void setAlsoLine(int x1, int y1, int x2, int y2, Color color); byte getAlsoColor(int x1, int y1, int x2, int y2); byte getScreenColor(Common::Point pos); - // The caller has to .free() the returned Surfaces!!! - // Further information about these two: http://www.shikadi.net/moddingwiki/Raw_EGA_data + // Further information about this: http://www.shikadi.net/moddingwiki/Raw_EGA_data Graphics::Surface loadPictureRaw(Common::File &file, uint16 width, uint16 height); void drawSprite(AnimationType *sprite, byte picnum, int16 x, int16 y); - void drawPicture(Graphics::Surface &target, const Graphics::Surface picture, uint16 destX, uint16 destY); void drawThinkPic(Common::String filename, int id); void drawToolbar(); void drawCursor(byte pos); @@ -125,12 +132,23 @@ private: Graphics::Surface _screen; // Only used in refreshScreen() to make it more optimized. (No recreation of it at every call of the function.) Graphics::Surface _scrolls; Graphics::Surface _surface; + + // For the mini-game "Nim". + Graphics::Surface _nimStone; + Graphics::Surface _nimInitials[3]; + Graphics::Surface _nimLogo; + byte _egaPalette[64][3]; AvalancheEngine *_vm; + // Further information about these two: http://www.shikadi.net/moddingwiki/Raw_EGA_data Graphics::Surface loadPictureGraphic(Common::File &file); // Reads Graphic-planar EGA data. + Graphics::Surface loadPictureSign(Common::File &file, int xl, int yl); // Reads a tricky type of picture used for the "game over"/"about" scrolls and in the mini-game Nim. + void drawText(Graphics::Surface &surface, const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color); + void drawPicture(Graphics::Surface &target, const Graphics::Surface picture, uint16 destX, uint16 destY); + // Taken from Free Pascal's Procedure InternalEllipseDefault. Used to replace Pascal's procedure arc. // Returns the end point of the arc. (Needed in Clock.) // TODO: Make it more accurate later. diff --git a/engines/avalanche/nim.cpp b/engines/avalanche/nim.cpp index a2572f1fa5..e4897a6d49 100644 --- a/engines/avalanche/nim.cpp +++ b/engines/avalanche/nim.cpp @@ -35,11 +35,26 @@ const char * const Nim::kNames[2] = {"Avalot", "Dogfood"}; Nim::Nim(AvalancheEngine *vm) { _vm = vm; - _playedNim = 0; + resetVariables(); } void Nim::resetVariables() { _playedNim = 0; + _turns = 0; + _dogfoodsTurn = false; + _stonesLeft = 0; + _clicked = false; + _row = 0; + _number = 0; + _squeak = false; + _lmo = false; + + for (int i = 0; i < 3; i++) { + _old[i] = 0; + _stones[i] = 0; + _inAp[i] = 0; + _r[i] = 0; + } } void Nim::synchronize(Common::Serializer &sz) { @@ -62,21 +77,25 @@ void Nim::playNim() { _vm->_dialogs->displayScrollChain('Q', 3); _playedNim++; - _vm->fadeOut(); - + _vm->_graphics->saveScreen(); + _vm->fadeOut(); CursorMan.showMouse(false); setup(); board(); - CursorMan.showMouse(true); + //CursorMan.showMouse(true); do { + startMove(); if (_dogfoodsTurn) dogFood(); - else + else { + CursorMan.showMouse(true); takeSome(); + CursorMan.showMouse(false); + } _stones[_row] -= _number; showChanges(); } while (_stonesLeft != 0); @@ -84,13 +103,10 @@ void Nim::playNim() { endOfGame(); // Winning sequence is A1, B3, B1, C1, C1, btw. _vm->fadeOut(); - CursorMan.showMouse(false); - _vm->_graphics->restoreScreen(); _vm->_graphics->removeBackup(); - - CursorMan.showMouse(true); _vm->fadeIn(); + CursorMan.showMouse(true); if (_dogfoodsTurn) { // Dogfood won - as usual. @@ -117,61 +133,443 @@ void Nim::playNim() { } } -void Nim::chalk(int x,int y, Common::String z) { - warning("STUB: Nim::chalk()"); +void Nim::chalk(int x, int y, Common::String text) { + const Color greys[] = { kColorBlack, kColorDarkgray, kColorLightgray, kColorWhite }; + + for (int i = 0; i < 4; i++) { + _vm->_graphics->drawNormalText(text, _vm->_font, 8, x - i, y, greys[i]); + _vm->_graphics->refreshScreen(); + int freq = i * 100 * text.size(); + if (freq == 0) + _vm->_system->delayMillis(3); + else + _vm->_sound->playNote(freq, 3); + _vm->_system->delayMillis(30); + } } void Nim::setup() { - warning("STUB: Nim::setup()"); -} - -void Nim::plotStone(byte x,byte y) { - warning("STUB: Nim::plotStone()"); + _vm->fadeIn(); + _vm->_graphics->nimLoad(); + + _vm->_graphics->drawFilledRectangle(Common::Rect(0, 0, 640, 200), kColorBlack); + // Upper left rectangle. + _vm->_graphics->drawRectangle(Common::Rect(10, 5, 381, 71), kColorRed); + _vm->_graphics->drawFilledRectangle(Common::Rect(11, 6, 380, 70), kColorBrown); + // Bottom right rectangle. + _vm->_graphics->drawRectangle(Common::Rect(394, 50, 635, 198), kColorRed); + _vm->_graphics->drawFilledRectangle(Common::Rect(395, 51, 634, 197), kColorBrown); + + _vm->_graphics->nimDrawLogo(); + _vm->_graphics->nimDrawInitials(); + + _vm->_graphics->drawNormalText("SCOREBOARD:", _vm->_font, 8, 475, 45, kColorWhite); + _vm->_graphics->drawNormalText("Turn:", _vm->_font, 8, 420, 55, kColorYellow); + _vm->_graphics->drawNormalText("Player:", _vm->_font, 8, 490, 55, kColorYellow); + _vm->_graphics->drawNormalText("Move:", _vm->_font, 8, 570, 55, kColorYellow); + + chalk(27, 7, "Take pieces away with:"); + chalk(77, 17, "1) the mouse (click leftmost)"); + chalk(53, 27, "or 2) the keyboard:"); + chalk(220, 27, Common::String(24) + '/' + 25 + ": choose row,"); + chalk(164, 37, Common::String("+/- or ") + 27 + '/' + 26 + ": more/fewer,"); + chalk(204, 47, "Enter: take stones."); + + _vm->_graphics->refreshScreen(); + + for (int i = 0; i < 3; i++) + _stones[i] = i + 3; + _stonesLeft = 12; + + _turns = 0; + _dogfoodsTurn = true; + + _row = 0; + _number = 1; + for (int i = 0; i < 3; i++) + _old[i] = 0; } void Nim::board() { - warning("STUB: Nim::board()"); + _vm->_graphics->drawFilledRectangle(Common::Rect(57, 72, 393, 200), kColorBlack); + for (int i = 0; i < 3; i++) + for (int j = 0; j < _stones[i]; j++) + _vm->_graphics->nimDrawStone(64 + j * 8 * 8, 75 + i * 35); + // It's practically the body of the Pascal function "plotstone()", reimplemented. + // It's the only place where we use it, so there's no reason to keep it separated as a function. + _vm->_graphics->refreshScreen(); } void Nim::startMove() { - warning("STUB: Nim::startMove()"); + _turns++; + Common::String turnsStr = Common::String::format("%d", _turns); + int y = 55 + _turns * 10; + _dogfoodsTurn = !_dogfoodsTurn; + chalk(433, y, turnsStr); + chalk(493, y, kNames[_dogfoodsTurn]); + for (int i = 0; i < 3; i++) + _old[i] = _stones[i]; } void Nim::showChanges() { - warning("STUB: Nim::showChanges()"); + chalk(573, 55 + _turns * 10, Common::String('A' + _row) + Common::String('0' + _number)); + board(); + _stonesLeft -= _number; } void Nim::blip() { - warning("STUB: Nim::blip()"); + _vm->_sound->playNote(1771, 3); } -void Nim::checkMouse() { - warning("STUB: Nim::checkMouse()"); +void Nim::findNextUp() { + while (_stones[_row] == 0) { + _row--; + if (_row < 0) + _row = 2; + } + + if (_number > _stones[_row]) + _number = _stones[_row]; +} + +void Nim::findNextDown() { + while (_stones[_row] == 0) { + _row++; + if (_row > 2) + _row = 0; + } + + if (_number > _stones[_row]) + _number = _stones[_row]; } -void Nim::less() { - warning("STUB: Nim::less()"); +bool Nim::checkInput() { + while (!_vm->shouldQuit()) { + _vm->_graphics->refreshScreen(); + Common::Event event; + while (_vm->getEvent(event)) { + if (event.type == Common::EVENT_LBUTTONUP) { + Common::Point cursorPos = _vm->getMousePos(); + + int8 newRow = (cursorPos.y / 2 - 38) / 35 - 1; + if ((newRow < 0) || (newRow > 2)) { + blip(); + return false; + } + + int8 newNum = _stones[newRow] - ((cursorPos.x - 64) / 64); + if ((newNum < 1) || (newNum > _stones[newRow])) { + blip(); + return false; + } + + _number = newNum; + _row = newRow; + + return true; + } else if (event.type == Common::EVENT_KEYDOWN) { + switch (event.kbd.keycode) { + case Common::KEYCODE_LEFT: + case Common::KEYCODE_KP_PLUS: + if (_stones[_row] > _number) + _number++; + return false; + case Common::KEYCODE_RIGHT: + case Common::KEYCODE_KP_MINUS: + if (_number > 1) + _number--; + return false; + case Common::KEYCODE_1: + _number = 1; + return false; + case Common::KEYCODE_2: + if (_stones[_row] >= 2) + _number = 2; + return false; + case Common::KEYCODE_3: + if (_stones[_row] >= 3) + _number = 3; + else + _number = _stones[_row]; + return false; + case Common::KEYCODE_4: + if (_stones[_row] >= 4) + _number = 4; + else + _number = _stones[_row]; + return false; + case Common::KEYCODE_5: + if (_stones[_row] == 5) + _number = 5; + else + _number = _stones[_row]; + return false; + case Common::KEYCODE_HOME: + _number = _stones[_row]; + return false; + case Common::KEYCODE_END: + _number = 1; + return false; + case Common::KEYCODE_UP: + _row--; + if (_row < 0) + _row = 2; + findNextUp(); + return false; + case Common::KEYCODE_DOWN: + _row++; + if (_row > 2) + _row = 0; + findNextDown(); + return false; + case Common::KEYCODE_a: + if (_stones[0] != 0) { + _row = 0; + if (_number > _stones[_row]) + _number = _stones[_row]; + } + return false; + case Common::KEYCODE_b: + if (_stones[1] != 0) { + _row = 1; + if (_number > _stones[_row]) + _number = _stones[_row]; + } + return false; + case Common::KEYCODE_c: + if (_stones[2] != 0) { + _row = 2; + if (_number > _stones[_row]) + _number = _stones[_row]; + } + return false; + case Common::KEYCODE_PAGEUP: + _row = 0; + findNextDown(); + return false; + case Common::KEYCODE_PAGEDOWN: + _row = 2; + findNextUp(); + return false; + case Common::KEYCODE_RETURN: + return true; + default: + break; + } + } + } + } + return false; } void Nim::takeSome() { - warning("STUB: Nim::takeSome()"); + _number = 1; + + do { + byte sr; + do { + sr = _stones[_row]; + if (sr == 0) { + if (_row == 2) + _row = 0; + else + _row++; + _number = 1; + } + } while (sr == 0); + + if (_number > sr) + _number = sr; + + int x1 = 63 + (_stones[_row] - _number) * 64; + int y1 = 38 + 35 * (_row + 1); + int x2 = 54 + _stones[_row] * 64; + int y2 = 63 + 35 * (_row + 1); + _vm->_graphics->drawRectangle(Common::Rect(x1, y1, x2, y2), kColorBlue); // Draw the selection rectangle. + _vm->_graphics->refreshScreen(); + + bool confirm = false; + do { + confirm = checkInput(); + + if (!confirm) { + _vm->_graphics->drawRectangle(Common::Rect(x1, y1, x2, y2), kColorBlack); // Erase the previous selection. + x1 = 63 + (_stones[_row] - _number) * 64; + y1 = 38 + 35 * (_row + 1); + x2 = 54 + _stones[_row] * 64; + y2 = 63 + 35 * (_row + 1); + _vm->_graphics->drawRectangle(Common::Rect(x1, y1, x2, y2), kColorBlue); // Draw the new one. + _vm->_graphics->refreshScreen(); + } + } while (!confirm); + + return; + + } while (true); } void Nim::endOfGame() { - warning("STUB: Nim::endOfGame()"); -} + chalk(595, 55 + _turns * 10, "Wins!"); + _vm->_graphics->drawNormalText("- - - Press any key... - - -", _vm->_font, 8, 100, 190, kColorWhite); + + Common::Event event; + bool escape = false; + while (!_vm->shouldQuit() && !escape) { + _vm->_graphics->refreshScreen(); + while (_vm->getEvent(event)) { + if ((event.type == Common::EVENT_LBUTTONUP) || (event.type == Common::EVENT_KEYDOWN)) { + escape = true; + break; + } + } + } -void Nim::dogFood() { - warning("STUB: Nim::dogFood()"); + _vm->_graphics->nimFree(); } bool Nim::find(byte x) { - warning("STUB: Nim::find()"); - return true; + bool ret = false; + for (int i = 0; i < 3; i++) { + if (_stones[i] == x) { + ret = true; + _inAp[i] = true; + } + } + return ret; +} + +void Nim::findAp(byte start, byte stepSize) { + byte thisOne = 0; + byte matches = 0; + + for (int i = 0; i < 3; i++) + _inAp[i] = 0; // Blank 'em all! + + for (int i = 0; i < 3; i++) { + if (find(start + i * stepSize)) + matches++; + else + thisOne = i; + } + + // Now... Matches must be 0, 1, 2, or 3. + // 0 / 1 mean there are no A.P.s here, so we'll keep looking, + // 2 means there is a potential A.P.that we can create (ideal!), and + // 3 means that we're already in an A.P. (Trouble!) + + byte ooo = 0; // Odd one out. + + switch (matches) { + case 2: + for (int i = 0; i < 3; i++) { // Find which one didn't fit the A.P. + if (!_inAp[i]) + ooo = i; + } + + if (_stones[ooo] > (start + thisOne * stepSize)) { // Check if it's possible! + // Create an A.P. + _row = ooo; // Already calculated. + // Start + thisone * stepsize will give the amount we SHOULD have here. + _number = _stones[_row] - (start + thisOne * stepSize); + _lmo = true; + return; + } + break; + case 3: // We're actually IN an A.P! Trouble! Oooh dear. + // Take 1 from the largest pile. + _row = _r[2]; + _number = 1; + _lmo = true; + return; + default: + break; + } } -void Nim::findAp(byte start,byte stepsize) { - warning("STUB: Nim::findAp()"); +void Nim::dogFood() { + _lmo = false; + byte live = 0; + byte sr[3]; + + for (int i = 0; i < 3; i++) { + if (_stones[i] > 0) { + _r[live] = i; + sr[live] = _stones[i]; + live++; + } + } + + switch (live) { + case 1: // Only one is free - so take 'em all! + _row = _r[0]; + _number = _stones[_r[0]]; + return; + case 2: // Two are free - make them equal! + if (sr[0] > sr[1]) { // T > b + _row = _r[0]; + _number = sr[0] - sr[1]; + } + else if (sr[0] < sr[1]) { // B > t + _row = _r[1]; + _number = sr[1] - sr[0]; + } + else { // B = t... oh no, we've lost! + _row = _r[0]; + _number = 1; + } + return; + case 3: { + // Ho hum... this'll be difficult! + // There are three possible courses of action when we have 3 lines left: + // 1) Look for 2 equal lines, then take the odd one out. + // 2) Look for A.P.s, and capitalise on them. + // 3) Go any old where. + const byte other[3][2] = { { 2, 3 }, { 1, 3 }, { 1, 2 } }; + + for (int i = 0; i < 3; i++) { // Look for 2 equal lines. + if (_stones[other[i][0]] == _stones[other[i][1]]) { + _row = i; // This row. + _number = _stones[i]; // All of 'em. + return; + } + } + + bool sorted; + do { + sorted = true; + for (int i = 0; i < 2; i++) { + if (sr[i] > sr[i + 1]) { + byte temp = sr[i + 1]; + sr[i + 1] = sr[i]; + sr[i] = temp; + + temp = _r[i + 1]; + _r[i + 1] = _r[i]; + _r[i] = temp; + + sorted = false; + } + } + } while (!sorted); + + // Now we look for A.P.s... + for (int i = 1; i <= 3; i++) { + findAp(i, 1); // There are 3 "1"s. + if (_lmo) + return; // Cut - out. + } + findAp(1, 2); // Only "2" possible. + if (_lmo) + return; + + // A.P.search must have failed - use the default move. + _row = _r[2]; + _number = 1; + return; + } + default: + break; + } } } // End of namespace Avalanche diff --git a/engines/avalanche/nim.h b/engines/avalanche/nim.h index a76afcfe22..7e5f55e69f 100644 --- a/engines/avalanche/nim.h +++ b/engines/avalanche/nim.h @@ -44,31 +44,34 @@ private: byte _old[3]; byte _stones[3]; - byte _stonePic[4][23][7]; // Picture of Nimstone. byte _turns; bool _dogfoodsTurn; byte _stonesLeft; bool _clicked; - byte _row; + int8 _row; byte _number; bool _squeak; - int8 _mNum, _mRow; byte _playedNim; // How many times you've played Nim. - void chalk(int x,int y, Common::String z); + // Inner variables for dogFood(), find() and findAp(). + bool _inAp[3]; + bool _lmo; // Let Me Out! + byte _r[3]; + + void chalk(int x, int y, Common::String text); void setup(); - void plotStone(byte x,byte y); void board(); void startMove(); void showChanges(); void blip(); - void checkMouse(); - void less(); + void findNextUp(); // Inner function for checkInput(). + void findNextDown(); // Same as above. + bool checkInput(); // It returns TRUE if the player confirmed his selection of stones either by pressing RETURN or by clicking on a stone. void takeSome(); void endOfGame(); - void dogFood(); - bool find(byte x); - void findAp(byte start,byte stepsize); + bool find(byte x); // This gives TRUE if there's a pile with x stones in. + void findAp(byte start, byte stepSize); + void dogFood(); // AI procedure to play the game. }; } // End of namespace Avalanche diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp index 609d5e86aa..c08cb43a47 100644 --- a/engines/cge/fileio.cpp +++ b/engines/cge/fileio.cpp @@ -70,7 +70,7 @@ ResourceManager::ResourceManager() { _catFile = new Common::File(); _catFile->open(kCatName); - if ((!_datFile) || (!_catFile)) + if (!_datFile->isOpen() || !_catFile->isOpen()) error("Unable to open data files"); for (int i = 0; i < kBtLevel; i++) { diff --git a/engines/fullpipe/behavior.cpp b/engines/fullpipe/behavior.cpp index c27f1082f5..abea906d9b 100644 --- a/engines/fullpipe/behavior.cpp +++ b/engines/fullpipe/behavior.cpp @@ -132,7 +132,7 @@ void BehaviorManager::updateBehavior(BehaviorInfo *behaviorInfo, BehaviorEntry * mq->sendNextCommand(); bhi->_flags &= 0xFFFFFFFD; - } else if (behaviorInfo->_counter >= bhi->_delay && bhi->_percent && g_fullpipe->_rnd->getRandomNumber(32767) <= entry->_items[i]->_percent) { + } else if (behaviorInfo->_counter >= bhi->_delay && bhi->_percent && g_fp->_rnd->getRandomNumber(32767) <= entry->_items[i]->_percent) { MessageQueue *mq = new MessageQueue(bhi->_messageQueue, 0, 1); mq->sendNextCommand(); @@ -149,7 +149,7 @@ void BehaviorManager::updateStaticAniBehavior(StaticANIObject *ani, int delay, B MessageQueue *mq = 0; if (bhe->_flags & 1) { - uint rnd = g_fullpipe->_rnd->getRandomNumber(32767); + uint rnd = g_fp->_rnd->getRandomNumber(32767); uint runPercent = 0; for (int i = 0; i < bhe->_itemsCount; i++) { if (!(bhe->_items[i]->_flags & 1) && bhe->_items[i]->_percent) { @@ -164,7 +164,7 @@ void BehaviorManager::updateStaticAniBehavior(StaticANIObject *ani, int delay, B for (int i = 0; i < bhe->_itemsCount; i++) { if (!(bhe->_items[i]->_flags & 1) && delay >= bhe->_items[i]->_delay) { if (bhe->_items[i]->_percent) { - if (g_fullpipe->_rnd->getRandomNumber(32767) <= bhe->_items[i]->_percent) { + if (g_fp->_rnd->getRandomNumber(32767) <= bhe->_items[i]->_percent) { mq = new MessageQueue(bhe->_items[i]->_messageQueue, 0, 1); break; } @@ -198,6 +198,12 @@ void BehaviorManager::setFlagByStaticAniObject(StaticANIObject *ani, int flag) { } } +BehaviorEntryInfo *BehaviorManager::getBehaviorEntryInfoByMessageQueueDataId(StaticANIObject *ani, int id1, int id2) { + warning("STUB: getBehaviorEntryInfoByMessageQueueDataId()"); + + return 0; +} + void BehaviorInfo::clear() { _ani = 0; _staticsId = 0; @@ -246,11 +252,11 @@ void BehaviorInfo::initObjectBehavior(GameVar *var, Scene *sc, StaticANIObject * if (strcmp(var->_value.stringValue, "ROOT")) break; - GameVar *v1 = g_fullpipe->getGameLoaderGameVar()->getSubVarByName("BEHAVIOR")->getSubVarByName(ani->getName()); + GameVar *v1 = g_fp->getGameLoaderGameVar()->getSubVarByName("BEHAVIOR")->getSubVarByName(ani->getName()); if (v1 == var) return; - sc = g_fullpipe->accessScene(ani->_sceneId); + sc = g_fp->accessScene(ani->_sceneId); clear(); var = v1; _itemsCount = var->getSubVarsCount(); diff --git a/engines/fullpipe/behavior.h b/engines/fullpipe/behavior.h index 1ac0b5bbfe..90bb38dc9b 100644 --- a/engines/fullpipe/behavior.h +++ b/engines/fullpipe/behavior.h @@ -81,6 +81,8 @@ class BehaviorManager : public CObject { bool setBehaviorEnabled(StaticANIObject *obj, int aniId, int quId, int flag); void setFlagByStaticAniObject(StaticANIObject *ani, int flag); + + BehaviorEntryInfo *getBehaviorEntryInfoByMessageQueueDataId(StaticANIObject *ani, int id1, int id2); }; } // End of namespace Fullpipe diff --git a/engines/fullpipe/console.cpp b/engines/fullpipe/console.cpp index 587f3dc6e6..06235d3eab 100644 --- a/engines/fullpipe/console.cpp +++ b/engines/fullpipe/console.cpp @@ -20,12 +20,29 @@ * */ +#include "fullpipe/constants.h" #include "fullpipe/fullpipe.h" +#include "fullpipe/gameloader.h" +#include "fullpipe/scene.h" namespace Fullpipe { -Console::Console(FullpipeEngine *vm) : GUI::Debugger() { - _vm = vm; +Console::Console(FullpipeEngine *vm) : GUI::Debugger(), _vm(vm) { + DCmd_Register("scene", WRAP_METHOD(Console, Cmd_Scene)); +} + +bool Console::Cmd_Scene(int argc, const char **argv) { + if (argc != 2) { + int sceneTag = _vm->_currentScene->_sceneId; + DebugPrintf("Current scene: %d (scene tag: %d)\n", _vm->getSceneFromTag(sceneTag), sceneTag); + DebugPrintf("Use %s <scene> to change the current scene\n", argv[0]); + return true; + } else { + int scene = _vm->convertScene(atoi(argv[1])); + _vm->_gameLoader->loadScene(scene); + _vm->_gameLoader->gotoScene(scene, TrubaLeft); + return false; + } } } // End of namespace Fullpipe diff --git a/engines/fullpipe/console.h b/engines/fullpipe/console.h index 9c03081b2b..af2b5114ac 100644 --- a/engines/fullpipe/console.h +++ b/engines/fullpipe/console.h @@ -33,6 +33,8 @@ public: private: FullpipeEngine *_vm; + + bool Cmd_Scene(int argc, const char **argv); }; } // End of namespace Fullpipe diff --git a/engines/fullpipe/constants.h b/engines/fullpipe/constants.h index 1a59cce787..e2dff762ea 100644 --- a/engines/fullpipe/constants.h +++ b/engines/fullpipe/constants.h @@ -25,14 +25,24 @@ namespace Fullpipe { +#define ANI_BALLDROP 2685 +#define ANI_BATUTA 737 #define ANI_BIGBALL 4923 +#define ANI_BIGLUK 909 #define ANI_BOOT_1 4231 #define ANI_BUTTON 598 +#define ANI_BUTTON_6 2988 #define ANI_CLOCK 588 +#define ANI_CLOCK_8 2989 +#define ANI_CORNERSITTER 71 #define ANI_DOMINO_3 2732 #define ANI_DADAYASHIK 306 #define ANI_EGGEATER 334 +#define ANI_EGGIE 4929 +#define ANI_GUM 978 #define ANI_HAND 601 +#define ANI_HANDLE 622 +#define ANI_HOOLIGAN 808 #define ANI_IN1MAN 5110 #define ANI_INV_COIN 875 #define ANI_INV_EGGAPL 1564 @@ -40,17 +50,28 @@ namespace Fullpipe { #define ANI_INV_EGGCOIN 1567 #define ANI_INV_EGGDOM 1561 #define ANI_INV_EGGGLS 1573 +#define ANI_INV_HANDLE 893 #define ANI_INV_MAP 5321 #define ANI_KOZAWKA 495 #define ANI_LIFTBUTTON 2751 +#define ANI_LUKE 803 +#define ANI_MAMASHA 656 #define ANI_MAMASHA_4 660 #define ANI_MAN 322 +#define ANI_NADUVATEL 944 +#define ANI_NEWBALL 1073 +#define ANI_OTMOROZ 419 +#define ANI_PACHKA 975 +#define ANI_PACHKA2 3008 #define ANI_PLANK 501 +#define ANI_PLUSMINUS 2938 #define ANI_SC2_BOX 1020 #define ANI_SC4_BOOT 1035 #define ANI_SC4_COIN 690 +#define ANI_SC7_BOX 791 #define ANI_SPEAKER_4 3275 #define ANI_SPRING 542 +#define ANI_VMYATS 764 #define MSG_CLICKBOTTLE 569 #define MSG_CLICKBUTTON 609 #define MSG_CLICKPLANK 549 @@ -96,46 +117,131 @@ namespace Fullpipe { #define MSG_SC4_KOZAWFALL 2858 #define MSG_SC4_MANFROMBOTTLE 2854 #define MSG_SC4_MANTOBOTTLE 2852 +#define MSG_SC5_BGRSOUNDOFF 5315 +#define MSG_SC5_BGRSOUNDON 5314 +#define MSG_SC5_HANDLEDOWN 916 +#define MSG_SC5_HANDLEUP 915 +#define MSG_SC5_HIDEHANDLE 917 +#define MSG_SC5_MAKEMANFLIGHT 1136 +#define MSG_SC5_MAKEOTMFEEDBACK 1169 +#define MSG_SC5_SHOWHANDLE 918 +#define MSG_SC5_TESTLUK 914 +#define MSG_SC6_BTNPUSH 1017 +#define MSG_SC6_ENABLEDROPS 687 +#define MSG_SC6_INSTHANDLE 1012 +#define MSG_SC6_JUMPBK 2900 +#define MSG_SC6_JUMPFW 2901 +#define MSG_SC6_RESTORESCROLL 2906 +#define MSG_SC6_SHOWNEXTBALL 790 +#define MSG_SC6_STARTDROPS 2897 +#define MSG_SC6_TAKEBALL 682 +#define MSG_SC6_TESTNUMBALLS 2904 +#define MSG_SC6_UTRUBACLICK 1105 +#define MSG_SC7_CLOSELUKE 822 +#define MSG_SC7_HIDEBOX 817 +#define MSG_SC7_HIDELUKE 821 +#define MSG_SC7_OPENLUKE 823 +#define MSG_SC7_PULL 2943 +#define MSG_SC7_SHOWBOX 816 +#define MSG_SC8_ARCADENOW 1044 +#define MSG_SC8_ENTERUP 3037 +#define MSG_SC8_GETHIMUP 789 +#define MSG_SC8_HIDELADDER_D 1107 +#define MSG_SC8_RESUMEFLIGHT 784 +#define MSG_SC8_STANDUP 2976 +#define MSG_SC10_CLICKGUM 992 +#define MSG_SC10_HIDEGUM 993 +#define MSG_SC10_LADDERTOBACK 3002 +#define MSG_SC10_LADDERTOFORE 3004 +#define MSG_SC10_SHOWGUM 994 #define MSG_GOTOLADDER 618 #define MSG_SHAKEBOTTLE 584 #define MSG_SHOOTKOZAW 557 #define MSG_SHOWCOIN 1033 +#define MSG_SPINHANDLE 2398 +#define MSG_STARTARCADE 781 #define MSG_STARTHAND 612 #define MSG_TAKEBOTTLE 614 #define MSG_TAKEKOZAW 611 #define MSG_TESTPLANK 538 #define MSG_UPDATEBOTTLE 613 +#define MV_BLK_CLOSE 911 +#define MV_BLK_OPEN 910 +#define MV_CLK8_GO 2990 +#define MV_CST_CLOSELUKE 807 #define MV_EGTR_FATASK 5332 #define MV_IN1MAN_SLEEP 5111 -#define MV_KZW_JUMP 558 -#define MV_KZW_JUMPROTATE 561 -#define MV_KZW_TOHOLERV 537 -#define MV_KZW_WALKPLANK 500 #define MV_BDG_OPEN 1379 #define MV_BTN_CLICK 599 #define MV_CLK_GO 589 #define MV_HND_POINT 602 +#define MV_KZW_GOR 564 +#define MV_KZW_JUMP 558 +#define MV_KZW_JUMPROTATE 561 +#define MV_KZW_TOHOLERV 537 +#define MV_KZW_WALKPLANK 500 +#define MV_KZW_JUMPHIT 2857 +#define MV_KZW_JUMPOUT 586 +#define MV_KZW_RAISEHEAD 577 +#define MV_KZW_STANDUP 563 +#define MV_KZW_TURN 562 +#define MV_MAN_FROMLADDER 493 +#define MV_MAN_FROMLADDERUP 1522 #define MV_MAN_GOD 481 #define MV_MAN_GOLADDER 451 #define MV_MAN_GOLADDER2 2844 #define MV_MAN_GOU 460 #define MV_MAN_JUMPONPLANK 551 #define MV_MAN_LOOKLADDER 520 +#define MV_MAN_LOOKLADDERRV 556 #define MV_MAN_LOOKUP 4773 #define MV_MAN_PLANKTOLADDER 553 #define MV_MAN_STARTLADDER 452 #define MV_MAN_STARTLADDER2 2842 +#define MV_MAN_STARTLADDERD 457 #define MV_MAN_STOPLADDER 454 #define MV_MAN_STOPLADDER2 2845 #define MV_MAN_TOLADDER 448 +#define MV_MAN_TOLADDERD 1524 #define MV_MAN_TOLADDER2 2841 #define MV_MAN_TURN_LU 486 #define MV_MAN_TURN_SUD 1089 +#define MV_MAN6_TAKEBALL 2691 +#define MV_MAN6_THROWBALL 2692 +#define MV_MAN8_BADLUCK 783 +#define MV_MAN8_DRYGDOWN 770 +#define MV_MAN8_DRYGUP 768 +#define MV_MAN8_HANDSDOWN 772 +#define MV_MAN8_HANDSUP 777 +#define MV_MAN8_JUMP 775 +#define MV_MAN8_JUMPOFF 2969 +#define MV_MAN8_SITDOWN 2968 +#define MV_MANHDL_HANDLEDOWN 630 +#define MV_MANHDL_HANDLEUP 631 +#define MV_MOM_CYCLEBK 3012 +#define MV_MOM_JUMPBK 662 +#define MV_MOM_JUMPFW 661 +#define MV_MOM_STARTBK 3010 +#define MV_MOM_STOPBK 3013 +#define MV_MOM_TAKE1 2885 +#define MV_MOM_TAKE2 2886 +#define MV_MOM_TAKE3 2887 +#define MV_MOM_TAKE4 2888 +#define MV_MOM_TAKE5 2889 +#define MV_NDV_BLOW2 2855 +#define MV_NDV_DENIES 952 +#define MV_NDV_DENY_NOGUM 3022 +#define MV_OTM_BOXHANDLEDOWN 626 +#define MV_OTM_BOXHANDLEUP 627 +#define MV_OTM_HANDLEDOWN 620 +#define MV_OTM_HANDLEUP 621 #define MV_PNK_WEIGHTLEFT 541 #define MV_PNK_WEIGHTRIGHT 502 #define MV_SC4_COIN_default 1029 +#define MV_SC7_BOX_default 792 #define MV_SPK4_PLAY 3276 #define MV_SPR_LOWER 543 +#define MV_VMT_DEF 765 #define PIC_CMN_EVAL 3468 #define PIC_CSR_DEFAULT 4891 #define PIC_CSR_DEFAULT_INV 4892 @@ -173,6 +279,7 @@ namespace Fullpipe { #define PIC_IN1_PIPETITLE 5167 #define PIC_INV_MENU 991 #define PIC_MAP_A13 5275 +#define PIC_MAP_P03 5279 #define PIC_MAP_S01 5223 #define PIC_SC1_KUCHKA 1321 #define PIC_SC1_LADDER 1091 @@ -189,9 +296,19 @@ namespace Fullpipe { #define PIC_SC4_LRTRUBA 616 #define PIC_SC4_MASK 585 #define PIC_SC4_PLANK 5183 +#define PIC_SC6_LADDER 1104 +#define PIC_SC8_ARCADENOW 1043 +#define PIC_SC8_LADDER 754 +#define PIC_SC8_LADDER_D 755 +#define PIC_SC8_LADDERD 1106 +#define PIC_SC10_DTRUBA 974 +#define PIC_SC10_LADDER 995 #define PIC_SCD_SEL 734 #define QU_BALL_WALKL 4920 #define QU_BALL_WALKR 4919 +#define QU_CST_CLOSELUKE 820 +#define QU_EGG6_GOL 4936 +#define QU_EGG6_GOR 4935 #define QU_EGTR_MD2_SHOW 4698 #define QU_EGTR_MD1_SHOW 4697 #define QU_EGTR_SLIMSHOW 4883 @@ -204,11 +321,33 @@ namespace Fullpipe { #define QU_INTR_GETUPMAN 5136 #define QU_INTR_STARTINTRO 5133 #define QU_KOZAW_WALK 505 +#define QU_MOM_JUMPBK 671 +#define QU_MOM_JUMPFW 670 +#define QU_MOM_PUTBALL 2903 +#define QU_MOM_SITDOWN 685 +#define QU_MOM_STANDUP 2899 +#define QU_MOM_TOLIFT 2902 #define QU_PNK_CLICK 550 #define QU_SC3_ENTERLIFT 2779 #define QU_SC3_EXITLIFT 2808 +#define QU_SC6_FALLHANDLE 2995 #define QU_SC4_GOCLOCK 595 #define QU_SC4_MANFROMBOTTLE 2851 +#define QU_SC4_MANTOBOTTLE 2850 +#define QU_SC5_MANBUMP 1167 +#define QU_SC5_MANFLY 1168 +#define QU_SC6_DROPS 2898 +#define QU_SC6_DROPS3 2955 +#define QU_SC6_ENTERLIFT 1054 +#define QU_SC6_EXITLIFT 1055 +#define QU_SC6_FALLBALL 2690 +#define QU_SC6_SHOWHANDLE 1689 +#define QU_SC6_SHOWNEXTBALL 2689 +#define QU_SC8_FINISH 788 +#define QU_SC8_STANDUP 2975 +#define QU_SC10_ENTERLIFT 1067 +#define QU_SC10_EXITLIFT 2809 +#define QU_SC10_TAKEGUM 3026 #define SC_1 301 #define SC_10 653 #define SC_11 654 @@ -264,17 +403,35 @@ namespace Fullpipe { #define SND_4_010 3125 #define SND_4_012 3127 #define SND_4_033 4990 +#define SND_5_026 5316 +#define SND_8_014 3624 #define SND_CMN_031 3516 #define SND_CMN_070 5199 #define SND_INTR_019 5220 +#define ST_BLK_CLOSED 912 +#define ST_BLK_OPEN 913 +#define ST_BTT_CHESHET 746 +#define ST_BTT_NOSPOON 739 +#define ST_BTT_SLEEPS 748 +#define ST_BTT_SPOON 741 #define ST_CLK_CLOSED 590 +#define ST_CST_HANDLELESS 794 #define ST_DYAS_LIES 318 #define ST_EGTR_MID1 2863 #define ST_EGTR_MID2 2869 #define ST_EGTR_SLIM 336 +#define ST_HGN_LOOK 811 +#define ST_HGN_LUKE 810 +#define ST_HDL_BROKEN 3342 +#define ST_HDL_DOWN 625 +#define ST_HDL_PLUGGED 2397 +#define ST_HDL_UP 624 #define ST_HND_EMPTY 603 #define ST_IN1MAN_SLEEP 5112 #define ST_KZW_EMPTY 498 +#define ST_KZW_JUMPOUT 587 +#define ST_KZW_RIGHT 559 +#define ST_KZW_SIT 560 #define ST_LBN_0N 2832 #define ST_LBN_0P 2833 #define ST_LBN_1N 2753 @@ -295,22 +452,71 @@ namespace Fullpipe { #define ST_LBN_8P 2775 #define ST_LBN_9N 2777 #define ST_LBN_9P 2778 +#define ST_LUK_CLOSED 805 +#define ST_LUK_OPEN 806 #define ST_MAN_GOLADDER 450 #define ST_MAN_GOLADDER2 2843 #define ST_MAN_EMPTY 476 #define ST_MAN_LADDERDOWN 521 +#define ST_MAN_LOOKPLANK 555 #define ST_MAN_ONPLANK 552 #define ST_MAN_RIGHT 325 #define ST_MAN_SIT 1164 #define ST_MAN_STANDLADDER 453 #define ST_MAN_UP 449 +#define ST_MAN6_BALL 2688 +#define ST_MAN8_FLYDOWN 771 +#define ST_MAN8_FLYUP 769 +#define ST_MAN8_HANDSUP 773 +#define ST_MAN8_STAND 774 +#define ST_MOM_SITS 659 +#define ST_MOM_STANDS 658 +#define ST_NBL_NORM 1076 +#define ST_NDV_SIT 946 +#define ST_OTM_BOX_LEFT 429 +#define ST_OTM_GLS_LEFT 421 +#define ST_OTM_VNT_LEFT 434 +#define ST_PMS_MINUS 2942 +#define ST_PMS_PLUS 2941 #define ST_PNK_WEIGHTLEFT 503 +#define ST_PNK_WEIGHTRIGHT 504 #define ST_SPR_UP 544 +#define ST_VMT_MIN 766 #define TrubaDown 697 #define TrubaLeft 474 #define TrubaRight 696 #define TrubaUp 680 #define rMV_MAN_LOOKUP 4775 +#define rMV_KZW_GOR 566 + +// Scene 11 +#define ANI_BOOTS_11 2704 +#define ANI_KACHELI 1094 +#define ANI_MAN11 1108 +#define ANI_SWINGER 1113 +#define PIC_SC11_HINT 5170 +#define ST_KCH_STATIC 1122 +#define ST_SWR_SIT 1147 +#define ST_SWR_SITBALD 1153 +#define ST_SWR_STAND3 3014 + +// Scene 15 +#define ANI_BOOT_15 4779 +#define ANI_GRANDMA_ASS 1265 +#define MSG_SC15_ASSDRYG 4755 +#define MSG_SC15_LADDERTOBACK 3259 +#define MSG_SC15_PULL 2940 +#define MSG_SC15_STOPCHANTING 4753 +#define PIC_SC15_DTRUBA 1263 +#define PIC_SC15_LADDER 3253 +#define PIC_SC15_LTRUBA 1261 +#define QU_SC15_ENTERLIFT 2811 +#define QU_SC15_EXITLIFT 2812 +#define SND_15_001 3798 +#define SND_15_006 3808 +#define SND_15_011 4754 +#define ST_GMS_BOOT 1270 +#define ST_GMS_BOOTLESS2 3316 } // End of namespace Fullpipe diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp index 970af423ae..a0348a9407 100644 --- a/engines/fullpipe/fullpipe.cpp +++ b/engines/fullpipe/fullpipe.cpp @@ -33,14 +33,14 @@ #include "fullpipe/behavior.h" #include "fullpipe/modal.h" #include "fullpipe/input.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/floaters.h" -#include "fullpipe/motion.h" #include "fullpipe/console.h" namespace Fullpipe { -FullpipeEngine *g_fullpipe = 0; +FullpipeEngine *g_fp = 0; Vars *g_vars = 0; FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { @@ -148,9 +148,16 @@ FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) _objectAtCursor = 0; _objectIdAtCursor = 0; + _arcadeOverlay = 0; + _arcadeOverlayHelper = 0; + _arcadeOverlayX = 0; + _arcadeOverlayY = 0; + _arcadeOverlayMidX = 0; + _arcadeOverlayMidY = 0; + _isSaveAllowed = true; - g_fullpipe = this; + g_fp = this; g_vars = new Vars; } diff --git a/engines/fullpipe/fullpipe.h b/engines/fullpipe/fullpipe.h index eb502cbadf..5e4389af7b 100644 --- a/engines/fullpipe/fullpipe.h +++ b/engines/fullpipe/fullpipe.h @@ -63,6 +63,7 @@ struct MessageHandler; struct MovTable; class MGM; class NGIArchive; +class PictureObject; class Scene; class SoundList; class StaticANIObject; @@ -148,9 +149,11 @@ public: void stopAllSounds(); void toggleMute(); void playSound(int id, int flag); + void playTrack(GameVar *sceneVar, const char *name, bool delayed); void startSceneTrack(); void stopSoundStream2(); void stopAllSoundStreams(); + void stopAllSoundInstances(int id); int _sfxVolume; @@ -235,6 +238,7 @@ public: Scene *accessScene(int sceneId); void setSceneMusicParameters(GameVar *var); int convertScene(int scene); + int getSceneFromTag(int tag); NGIArchive *_currArchive; @@ -242,9 +246,18 @@ public: void openHelp(); void openMainMenu(); + PictureObject *_arcadeOverlay; + PictureObject *_arcadeOverlayHelper; + int _arcadeOverlayX; + int _arcadeOverlayY; + int _arcadeOverlayMidX; + int _arcadeOverlayMidY; + void initArcadeKeys(const char *varname); void processArcade(ExCommand *ex); void winArcade(); + void setArcadeOverlay(int picId); + int drawArcadeOverlay(int adjust); void getAllInventory(); @@ -268,7 +281,7 @@ public: }; -extern FullpipeEngine *g_fullpipe; +extern FullpipeEngine *g_fp; extern Vars *g_vars; } // End of namespace Fullpipe diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp index e130337001..57c1b23f66 100644 --- a/engines/fullpipe/gameloader.cpp +++ b/engines/fullpipe/gameloader.cpp @@ -32,19 +32,19 @@ namespace Fullpipe { Inventory2 *getGameLoaderInventory() { - return &g_fullpipe->_gameLoader->_inventory; + return &g_fp->_gameLoader->_inventory; } MctlCompound *getSc2MctlCompoundBySceneId(int16 sceneId) { - for (uint i = 0; i < g_fullpipe->_gameLoader->_sc2array.size(); i++) - if (g_fullpipe->_gameLoader->_sc2array[i]._sceneId == sceneId) - return (MctlCompound *)g_fullpipe->_gameLoader->_sc2array[i]._motionController; + for (uint i = 0; i < g_fp->_gameLoader->_sc2array.size(); i++) + if (g_fp->_gameLoader->_sc2array[i]._sceneId == sceneId) + return (MctlCompound *)g_fp->_gameLoader->_sc2array[i]._motionController; return 0; } InteractionController *getGameLoaderInteractionController() { - return g_fullpipe->_gameLoader->_interactionController; + return g_fp->_gameLoader->_interactionController; } GameLoader::GameLoader() { @@ -68,10 +68,10 @@ GameLoader::GameLoader() { _preloadEntranceId = 0; _updateCounter = 0; - g_fullpipe->_msgX = 0; - g_fullpipe->_msgY = 0; - g_fullpipe->_msgObjectId2 = 0; - g_fullpipe->_msgId = 0; + g_fp->_msgX = 0; + g_fp->_msgY = 0; + g_fp->_msgObjectId2 = 0; + g_fp->_msgId = 0; } GameLoader::~GameLoader() { @@ -91,10 +91,10 @@ bool GameLoader::load(MfcArchive &file) { _gameProject->load(file); - g_fullpipe->_gameProject = _gameProject; + g_fp->_gameProject = _gameProject; - if (g_fullpipe->_gameProjectVersion < 12) { - error("Old gameProjectVersion: %d", g_fullpipe->_gameProjectVersion); + if (g_fp->_gameProjectVersion < 12) { + error("Old gameProjectVersion: %d", g_fp->_gameProjectVersion); } _gameName = file.readPascalString(); @@ -167,7 +167,7 @@ bool GameLoader::gotoScene(int sceneId, int entranceId) { return false; if (_sc2array[sc2idx]._entranceDataCount < 1) { - g_fullpipe->_currentScene = st->_scene; + g_fp->_currentScene = st->_scene; return true; } @@ -186,20 +186,20 @@ bool GameLoader::gotoScene(int sceneId, int entranceId) { if (sg || (sg = _gameVar->getSubVarByName("OBJSTATES")->addSubVarAsInt("SAVEGAME", 0)) != 0) sg->setSubVarAsInt("Entrance", entranceId); - if (!g_fullpipe->sceneSwitcher(_sc2array[sc2idx]._entranceData[entranceIdx])) + if (!g_fp->sceneSwitcher(_sc2array[sc2idx]._entranceData[entranceIdx])) return false; - g_fullpipe->_msgObjectId2 = 0; - g_fullpipe->_msgY = -1; - g_fullpipe->_msgX = -1; + g_fp->_msgObjectId2 = 0; + g_fp->_msgY = -1; + g_fp->_msgX = -1; - g_fullpipe->_currentScene = st->_scene; + g_fp->_currentScene = st->_scene; - MessageQueue *mq1 = g_fullpipe->_currentScene->getMessageQueueById(_sc2array[sc2idx]._entranceData[entranceIdx]->_messageQueueId); + MessageQueue *mq1 = g_fp->_currentScene->getMessageQueueById(_sc2array[sc2idx]._entranceData[entranceIdx]->_messageQueueId); if (mq1) { MessageQueue *mq = new MessageQueue(mq1, 0, 0); - StaticANIObject *stobj = g_fullpipe->_currentScene->getStaticANIObject1ById(_field_FA, -1); + StaticANIObject *stobj = g_fp->_currentScene->getStaticANIObject1ById(_field_FA, -1); if (stobj) { stobj->_flags &= 0x100; @@ -220,7 +220,7 @@ bool GameLoader::gotoScene(int sceneId, int entranceId) { return false; } } else { - StaticANIObject *stobj = g_fullpipe->_currentScene->getStaticANIObject1ById(_field_FA, -1); + StaticANIObject *stobj = g_fp->_currentScene->getStaticANIObject1ById(_field_FA, -1); if (stobj) stobj->_flags &= 0xfeff; } @@ -262,8 +262,8 @@ bool GameLoader::preloadScene(int sceneId, int entranceId) { return false; } - if (g_fullpipe->_currentScene && g_fullpipe->_currentScene->_sceneId == sceneId) - g_fullpipe->_currentScene = 0; + if (g_fp->_currentScene && g_fp->_currentScene->_sceneId == sceneId) + g_fp->_currentScene = 0; saveScenePicAniInfos(sceneId); clearGlobalMessageQueueList1(); @@ -358,7 +358,7 @@ void GameLoader::applyPicAniInfos(Scene *sc, PicAniInfo **picAniInfo, int picAni if (!(picAniInfo[i]->type & 1)) continue; - Scene *scNew = g_fullpipe->accessScene(picAniInfo[i]->sceneId); + Scene *scNew = g_fp->accessScene(picAniInfo[i]->sceneId); if (!scNew) continue; @@ -386,8 +386,8 @@ void GameLoader::saveScenePicAniInfos(int sceneId) { } void GameLoader::updateSystems(int counterdiff) { - if (g_fullpipe->_currentScene) { - g_fullpipe->_currentScene->update(counterdiff); + if (g_fp->_currentScene) { + g_fp->_currentScene->update(counterdiff); _exCommand._messageKind = 17; _updateCounter++; @@ -510,4 +510,8 @@ InputController *FullpipeEngine::getGameLoaderInputController() { return 0; } +MotionController *getCurrSceneSc2MotionController() { + return getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId); +} + } // End of namespace Fullpipe diff --git a/engines/fullpipe/gameloader.h b/engines/fullpipe/gameloader.h index 4f5462671d..074537500c 100644 --- a/engines/fullpipe/gameloader.h +++ b/engines/fullpipe/gameloader.h @@ -111,6 +111,7 @@ class GameLoader : public CObject { Inventory2 *getGameLoaderInventory(); InteractionController *getGameLoaderInteractionController(); MctlCompound *getSc2MctlCompoundBySceneId(int16 sceneId); +MotionController *getCurrSceneSc2MotionController(); } // End of namespace Fullpipe diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index d54f7591b4..8b2aca4bdb 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -100,11 +100,11 @@ bool Background::load(MfcArchive &file) { addPictureObject(pct); } - assert(g_fullpipe->_gameProjectVersion >= 4); + assert(g_fp->_gameProjectVersion >= 4); _bigPictureArray1Count = file.readUint32LE(); - assert(g_fullpipe->_gameProjectVersion >= 5); + assert(g_fp->_gameProjectVersion >= 5); _bigPictureArray2Count = file.readUint32LE(); @@ -313,7 +313,7 @@ bool GameObject::load(MfcArchive &file) { _oy = file.readUint32LE(); _priority = file.readUint16LE(); - if (g_fullpipe->_gameProjectVersion >= 11) { + if (g_fp->_gameProjectVersion >= 11) { _field_8 = file.readUint32LE(); } @@ -494,7 +494,7 @@ bool Picture::load(MfcArchive &file) { _y = file.readUint32LE(); _field_44 = file.readUint16LE(); - assert(g_fullpipe->_gameProjectVersion >= 2); + assert(g_fp->_gameProjectVersion >= 2); _width = file.readUint32LE(); _height = file.readUint32LE(); @@ -508,7 +508,7 @@ bool Picture::load(MfcArchive &file) { setAOIDs(); } - assert (g_fullpipe->_gameProjectVersion >= 12); + assert (g_fp->_gameProjectVersion >= 12); _alpha = file.readUint32LE() & 0xff; @@ -527,8 +527,8 @@ bool Picture::load(MfcArchive &file) { } void Picture::setAOIDs() { - int w = (g_fullpipe->_pictureScale + _width - 1) / g_fullpipe->_pictureScale; - int h = (g_fullpipe->_pictureScale + _height - 1) / g_fullpipe->_pictureScale; + int w = (g_fp->_pictureScale + _width - 1) / g_fp->_pictureScale; + int h = (g_fp->_pictureScale + _height - 1) / g_fp->_pictureScale; _memoryObject2->_rows = (byte **)malloc(w * sizeof(int *)); @@ -618,7 +618,7 @@ void Picture::draw(int x, int y, int style, int angle) { if (!pal) { //warning("Picture:draw: using global palette"); - pal = g_fullpipe->_globalPalette; + pal = g_fp->_globalPalette; } Common::Point point; @@ -650,7 +650,7 @@ void Picture::drawRotated(int x, int y, int angle) { } void Picture::displayPicture() { - if (!g_fullpipe->_gameContinue) + if (!g_fp->_gameContinue) return; getData(); @@ -659,22 +659,22 @@ void Picture::displayPicture() { if (!_dataSize) return; - g_fullpipe->_backgroundSurface.fillRect(Common::Rect(0, 0, 800, 600), 0); - g_fullpipe->_system->copyRectToScreen(g_fullpipe->_backgroundSurface.getBasePtr(0, 0), g_fullpipe->_backgroundSurface.pitch, 0, 0, 800, 600); + g_fp->_backgroundSurface.fillRect(Common::Rect(0, 0, 800, 600), 0); + g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface.getBasePtr(0, 0), g_fp->_backgroundSurface.pitch, 0, 0, 800, 600); draw(0, 0, 0, 0); - g_fullpipe->updateEvents(); - g_fullpipe->_system->delayMillis(10); - g_fullpipe->_system->updateScreen(); + g_fp->updateEvents(); + g_fp->_system->delayMillis(10); + g_fp->_system->updateScreen(); - while (g_fullpipe->_gameContinue) { - g_fullpipe->updateEvents(); - g_fullpipe->_system->delayMillis(10); - g_fullpipe->_system->updateScreen(); + while (g_fp->_gameContinue) { + g_fp->updateEvents(); + g_fp->_system->delayMillis(10); + g_fp->_system->updateScreen(); - if (g_fullpipe->_keyState == ' ') { - g_fullpipe->_keyState = Common::KEYCODE_INVALID; + if (g_fp->_keyState == ' ') { + g_fp->_keyState = Common::KEYCODE_INVALID; break; } } @@ -722,7 +722,7 @@ bool Picture::isPixelHitAtPos(int x, int y) { } int Picture::getPixelAtPos(int x, int y) { - return getPixelAtPosEx(x / g_fullpipe->_pictureScale, y / g_fullpipe->_pictureScale); + return getPixelAtPosEx(x / g_fp->_pictureScale, y / g_fp->_pictureScale); return false; } @@ -731,8 +731,8 @@ int Picture::getPixelAtPosEx(int x, int y) { if (x < 0 || y < 0) return 0; - if (x < (g_fullpipe->_pictureScale + _width - 1) / g_fullpipe->_pictureScale && - y < (g_fullpipe->_pictureScale + _height - 1) / g_fullpipe->_pictureScale && + if (x < (g_fp->_pictureScale + _width - 1) / g_fp->_pictureScale && + y < (g_fp->_pictureScale + _height - 1) / g_fp->_pictureScale && _memoryObject2 != 0 && _memoryObject2->_rows != 0) return _memoryObject2->_rows[x][2 * y]; @@ -785,8 +785,8 @@ bool Bitmap::isPixelAtHitPosRB(int x, int y) { void Bitmap::putDib(int x, int y, int32 *palette) { debug(7, "Bitmap::putDib(%d, %d)", x, y); - _x = x - g_fullpipe->_sceneRect.left; - _y = y - g_fullpipe->_sceneRect.top; + _x = x - g_fp->_sceneRect.left; + _y = y - g_fp->_sceneRect.top; if (_type == MKTAG('R', 'B', '\0', '\0')) putDibRB(palette); @@ -807,7 +807,7 @@ bool Bitmap::putDibRB(int32 *palette, int pX, int pY) { uint16 *srcPtr; if (!palette && pX == -1) { - warning("Bitmap::putDibRB(): Both global and local palettes are empty"); + debug(2, "Bitmap::putDibRB(): Both global and local palettes are empty"); return false; } @@ -879,7 +879,7 @@ bool Bitmap::putDibRB(int32 *palette, int pX, int pY) { if (y <= endy) { if (pX == -1) { int bgcolor = palette[(pixel >> 8) & 0xff]; - curDestPtr = (uint16 *)g_fullpipe->_backgroundSurface.getBasePtr(start1, y); + curDestPtr = (uint16 *)g_fp->_backgroundSurface.getBasePtr(start1, y); colorFill(curDestPtr, fillLen, bgcolor); } else { if (y == pY && pX >= start1 && pX < start1 + fillLen) @@ -910,7 +910,7 @@ bool Bitmap::putDibRB(int32 *palette, int pX, int pY) { if (y <= endy) { if (pX == -1) { - curDestPtr = (uint16 *)g_fullpipe->_backgroundSurface.getBasePtr(start1, y); + curDestPtr = (uint16 *)g_fp->_backgroundSurface.getBasePtr(start1, y); paletteFill(curDestPtr, (byte *)srcPtr2, fillLen, (int32 *)palette); } else { if (y == pY && pX >= start1 && pX < start1 + fillLen) @@ -922,7 +922,7 @@ bool Bitmap::putDibRB(int32 *palette, int pX, int pY) { } if (pX == -1) - g_fullpipe->_system->copyRectToScreen(g_fullpipe->_backgroundSurface.getBasePtr(startx, starty), g_fullpipe->_backgroundSurface.pitch, startx, starty, endx + 1 - startx, endy + 1 - starty); + g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface.getBasePtr(startx, starty), g_fp->_backgroundSurface.pitch, startx, starty, endx + 1 - startx, endy + 1 - starty); return false; } @@ -973,17 +973,17 @@ void Bitmap::putDibCB(int32 *palette) { if (_flags & 0x1000000) { for (int y = starty; y < endy; srcPtr -= pitch, y++) { - curDestPtr = (uint16 *)g_fullpipe->_backgroundSurface.getBasePtr(startx, y); + curDestPtr = (uint16 *)g_fp->_backgroundSurface.getBasePtr(startx, y); copierKeyColor(curDestPtr, srcPtr, endx - startx + 1, _flags & 0xff, (int32 *)palette, cb05_format); } } else { for (int y = starty; y <= endy; srcPtr -= pitch, y++) { - curDestPtr = (uint16 *)g_fullpipe->_backgroundSurface.getBasePtr(startx, y); + curDestPtr = (uint16 *)g_fp->_backgroundSurface.getBasePtr(startx, y); copier(curDestPtr, srcPtr, endx - startx + 1, (int32 *)palette, cb05_format); } } - g_fullpipe->_system->copyRectToScreen(g_fullpipe->_backgroundSurface.getBasePtr(startx, starty), g_fullpipe->_backgroundSurface.pitch, startx, starty, endx + 1 - startx, endy + 1 - starty); + g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface.getBasePtr(startx, starty), g_fp->_backgroundSurface.pitch, startx, starty, endx + 1 - startx, endy + 1 - starty); } void Bitmap::colorFill(uint16 *dest, int len, int32 color) { @@ -1178,6 +1178,34 @@ bool BigPicture::load(MfcArchive &file) { return true; } +void BigPicture::draw(int x, int y, int style, int angle) { + if (!_bitmap) + init(); + + if (_bitmap) { + _bitmap->_flags &= 0xFEFFFFFF; + + int nx = _x; + int ny = _y; + + if (x != -1) + nx = x; + + if (y != -1) + ny = y; + + if (_alpha < 0xFF) { + //vrtSetAlphaBlendMode(g_vrtDrawHandle, 1, v9); + } + + _bitmap->putDib(nx, ny, 0); + + if (_alpha < 0xFF) { + //vrtSetAlphaBlendMode(g_vrtDrawHandle, 0, 255); + } + } +} + Shadows::Shadows() { _staticAniObjectId = 0; _movementId = 0; @@ -1194,7 +1222,7 @@ bool Shadows::load(MfcArchive &file) { } void Shadows::init() { - Scene *scene = g_fullpipe->accessScene(_sceneId); + Scene *scene = g_fp->accessScene(_sceneId); StaticANIObject *st; Movement *mov; diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h index 9d5c45de0b..72495bfe0b 100644 --- a/engines/fullpipe/gfx.h +++ b/engines/fullpipe/gfx.h @@ -94,7 +94,7 @@ class Picture : public MemoryObject { void init(); void getDibInfo(); Bitmap *getPixelData(); - void draw(int x, int y, int style, int angle); + virtual void draw(int x, int y, int style, int angle); void drawRotated(int x, int y, int angle); byte getAlpha() { return (byte)_alpha; } @@ -116,6 +116,7 @@ class BigPicture : public Picture { public: BigPicture() {} virtual bool load(MfcArchive &file); + virtual void draw(int x, int y, int style, int angle); }; class GameObject : public CObject { diff --git a/engines/fullpipe/init.cpp b/engines/fullpipe/init.cpp index eb109e11ec..4cf5fbef61 100644 --- a/engines/fullpipe/init.cpp +++ b/engines/fullpipe/init.cpp @@ -45,22 +45,22 @@ void FullpipeEngine::initObjectStates() { setSwallowedEggsState(); setObjectState(sO_WeirdWacko, getObjectEnumState(sO_WeirdWacko, sO_InGlasses)); - setObjectState(sO_TumyTrampie, getObjectEnumState(sO_TumyTrampie, sO_Drinking)); + setObjectState(sO_TummyTrampie, getObjectEnumState(sO_TummyTrampie, sO_IsDrinking)); setObjectState(sO_StairsUp_8, getObjectEnumState(sO_StairsUp_8, sO_NotBroken)); setObjectState(sO_HareTheNooksiter, getObjectEnumState(sO_HareTheNooksiter, sO_WithHandle)); setObjectState(sO_Elephantine, getObjectEnumState(sO_Elephantine, sO_WithBoot)); setObjectState(sO_Fly_12, 0); - setObjectState(sO_ClockAxis, getObjectEnumState(sO_ClockAxis, sO_NotAvailable)); + setObjectState(sO_ClockAxis, getObjectEnumState(sO_ClockAxis, sO_IsNotAvailable)); setObjectState(sO_ClockHandle, getObjectEnumState(sO_ClockHandle, sO_In_7)); - setObjectState(sO_BigMumsy, getObjectEnumState(sO_BigMumsy, sO_Sleeping)); + setObjectState(sO_BigMumsy, getObjectEnumState(sO_BigMumsy, sO_IsSleeping)); setObjectState(sO_CoinSlot_1, getObjectEnumState(sO_CoinSlot_1, sO_Empty)); setObjectState(sO_FriesPit, getObjectEnumState(sO_FriesPit, sO_WithApple)); setObjectState(sO_Jug, getObjectEnumState(sO_Jug, sO_Blocked)); setObjectState(sO_RightStairs_9, getObjectEnumState(sO_RightStairs_9, sO_IsClosed)); setObjectState(sO_Pipe_9, getObjectEnumState(sO_Pipe_9, sO_WithJug)); setObjectState(sO_Inflater, getObjectEnumState(sO_Inflater, sO_WithGum)); - setObjectState(sO_Swingie, getObjectEnumState(sO_Swingie, sO_Swinging)); - setObjectState(sO_DudeJumped, getObjectEnumState(sO_DudeJumped, sO_No)); + setObjectState(sO_Swingie, getObjectEnumState(sO_Swingie, sO_IsSwinging)); + setObjectState(sO_DudeHasJumped, getObjectEnumState(sO_DudeHasJumped, sO_No)); setObjectState(sO_Bridge, getObjectEnumState(sO_Bridge, sO_Convoluted)); setObjectState(sO_Guardian, getObjectEnumState(sO_Guardian, sO_OnRight)); setObjectState(sO_Grandma, getObjectEnumState(sO_Grandma, sO_In_14)); @@ -73,7 +73,7 @@ void FullpipeEngine::initObjectStates() { setObjectState(sO_RightPipe_17, getObjectEnumState(sO_RightPipe_17, sO_IsClosed)); setObjectState(sO_Fly_17, 1); setObjectState(sO_DudeSwinged, 0); - setObjectState(sO_Girl, getObjectEnumState(sO_Girl, sO_Swinging)); + setObjectState(sO_Girl, getObjectEnumState(sO_Girl, sO_IsSwinging)); setObjectState(sO_Sugar, getObjectEnumState(sO_Sugar, sO_Present)); setObjectState(sO_Janitors, getObjectEnumState(sO_Janitors, sO_Together)); setObjectState(sO_Bag_22, getObjectEnumState(sO_Bag_22, sO_NotFallen)); diff --git a/engines/fullpipe/input.cpp b/engines/fullpipe/input.cpp index e98920c78a..5294c4b4ea 100644 --- a/engines/fullpipe/input.cpp +++ b/engines/fullpipe/input.cpp @@ -34,7 +34,7 @@ namespace Fullpipe { InputController::InputController() { - g_fullpipe->_inputController = this; + g_fp->_inputController = this; _flag = 0; _cursorHandle = 0; @@ -55,16 +55,16 @@ InputController::InputController() { InputController::~InputController() { removeMessageHandler(126, -1); - g_fullpipe->_inputController = 0; + g_fp->_inputController = 0; } void InputController::setInputDisabled(bool state) { _flag = state; - g_fullpipe->_inputDisabled = state; + g_fp->_inputDisabled = state; } void setInputDisabled(bool state) { - g_fullpipe->_inputController->setInputDisabled(state); + g_fp->_inputController->setInputDisabled(state); } void InputController::addCursor(CursorInfo *cursor) { @@ -93,8 +93,8 @@ void InputController::drawCursor(int x, int y) { if (_cursorIndex == -1) return; - _cursorBounds.left = g_fullpipe->_sceneRect.left + x - _cursorsArray[_cursorIndex]->hotspotX; - _cursorBounds.top = g_fullpipe->_sceneRect.top + y - _cursorsArray[_cursorIndex]->hotspotY; + _cursorBounds.left = g_fp->_sceneRect.left + x - _cursorsArray[_cursorIndex]->hotspotX; + _cursorBounds.top = g_fp->_sceneRect.top + y - _cursorsArray[_cursorIndex]->hotspotY; _cursorBounds.right = _cursorBounds.left + _cursorsArray[_cursorIndex]->width; _cursorBounds.bottom = _cursorBounds.top + _cursorsArray[_cursorIndex]->height; @@ -274,4 +274,70 @@ void FullpipeEngine::updateCursorCommon() { _cursorId = PIC_CSR_DEFAULT; } +void FullpipeEngine::initArcadeKeys(const char *varname) { + GameVar *var = getGameLoaderGameVar()->getSubVarByName(varname)->getSubVarByName("KEYPOS"); + + if (!var) + return; + + int cnt = var->getSubVarsCount(); + + for (int i = 0; i < cnt; i++) { + Common::Point *point = new Common::Point; + + GameVar *sub = var->getSubVarByIndex(i); + + point->x = sub->getSubVarAsInt("X"); + point->y = sub->getSubVarAsInt("Y"); + + _arcadeKeys.push_back(point); + } +} + +void FullpipeEngine::setArcadeOverlay(int picId) { + Common::Point point; + Common::Point point2; + + _arcadeOverlayX = 800; + _arcadeOverlayY = 545; + + _arcadeOverlayHelper = accessScene(SC_INV)->getPictureObjectById(PIC_CSR_HELPERBGR, 0); + _arcadeOverlay = accessScene(SC_INV)->getPictureObjectById(picId, 0); + + _arcadeOverlay->getDimensions(&point); + _arcadeOverlayHelper->getDimensions(&point2); + + _arcadeOverlayMidX = (point2.x - point.x) / 2; + _arcadeOverlayMidY = abs(point2.y - point.y) / 2; +} + +int FullpipeEngine::drawArcadeOverlay(int adjust) { + _arcadeOverlayHelper->drawAt(_sceneRect.left + _arcadeOverlayX, _sceneRect.top + _arcadeOverlayY); + _arcadeOverlay->drawAt(_sceneRect.left + _arcadeOverlayX + _arcadeOverlayMidX, _sceneRect.top + _arcadeOverlayY + _arcadeOverlayMidY); + + if (adjust) { + if (_arcadeOverlayX > 745) { + _arcadeOverlayX -= 15; + + if (_arcadeOverlayX < 745) + _arcadeOverlayX = 745; + } + + return 1; + } + + if (_arcadeOverlayX >= 800) { + return 0; + } else { + _arcadeOverlayX += 15; + + if (_arcadeOverlayX <= 800) + return 1; + + _arcadeOverlayX = 800; + } + + return 1; +} + } // End of namespace Fullpipe diff --git a/engines/fullpipe/interaction.cpp b/engines/fullpipe/interaction.cpp index cd9aad5b22..9d92638328 100644 --- a/engines/fullpipe/interaction.cpp +++ b/engines/fullpipe/interaction.cpp @@ -36,8 +36,8 @@ int handleObjectInteraction(StaticANIObject *subject, GameObject *object, int in bool canInteractAny(GameObject *obj1, GameObject *obj2, int invId) { int sceneId = 0; - if (g_fullpipe->_currentScene) - sceneId = g_fullpipe->_currentScene->_sceneId; + if (g_fp->_currentScene) + sceneId = g_fp->_currentScene->_sceneId; InteractionController *intC = getGameLoaderInteractionController(); for (ObList::iterator i = intC->_interactions.begin(); i != intC->_interactions.end(); ++i) { @@ -137,7 +137,7 @@ bool InteractionController::handleInteraction(StaticANIObject *subj, GameObject obj->setPicAniInfo(&aniInfo); if (abs(xpos - subj->_ox) > 1 || abs(ypos - subj->_oy) > 1) { - mq = getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->doWalkTo(subj, xpos, ypos, 1, cinter->_staticsId2); + mq = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->doWalkTo(subj, xpos, ypos, 1, cinter->_staticsId2); if (mq) { dur = mq->calcDuration(subj); delete mq; @@ -305,7 +305,7 @@ LABEL_38: if (abs(xpos - subj->_ox) > 1 || abs(ypos - subj->_oy) > 1 || (inter->_staticsId2 != 0 && (subj->_statics == 0 || subj->_statics->_staticsId != inter->_staticsId2))) { - mq = getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->method34(subj, xpos, ypos, 1, inter->_staticsId2); + mq = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->method34(subj, xpos, ypos, 1, inter->_staticsId2); if (!mq) return false; @@ -444,7 +444,7 @@ bool Interaction::load(MfcArchive &file) { } bool Interaction::canInteract(GameObject *obj1, GameObject *obj2, int invId) { - if (_sceneId > 0 && g_fullpipe->_currentScene && g_fullpipe->_currentScene->_sceneId != _sceneId) + if (_sceneId > 0 && g_fp->_currentScene && g_fp->_currentScene->_sceneId != _sceneId) return false; if (_flags & 0x20000) @@ -476,20 +476,20 @@ bool Interaction::canInteract(GameObject *obj1, GameObject *obj2, int invId) { if (_objectState1) { if (_flags & 0x10) { - if ((g_fullpipe->getObjectState(obj1->getName()) & _objectState1) == 0) + if ((g_fp->getObjectState(obj1->getName()) & _objectState1) == 0) return false; } else { - if (g_fullpipe->getObjectState(obj1->getName()) != _objectState1) + if (g_fp->getObjectState(obj1->getName()) != _objectState1) return false; } } if (_objectState2) { if (_flags & 0x10) { - if ((g_fullpipe->getObjectState(obj2->getName()) & _objectState2) == 0) + if ((g_fp->getObjectState(obj2->getName()) & _objectState2) == 0) return false; } else { - if (g_fullpipe->getObjectState(obj2->getName()) != _objectState2) + if (g_fp->getObjectState(obj2->getName()) != _objectState2) return false; } } diff --git a/engines/fullpipe/inventory.cpp b/engines/fullpipe/inventory.cpp index 18ef3c4d97..3e22f8526d 100644 --- a/engines/fullpipe/inventory.cpp +++ b/engines/fullpipe/inventory.cpp @@ -161,7 +161,7 @@ int Inventory2::getItemFlags(int itemId) { } void Inventory2::rebuildItemRects() { - _scene = g_fullpipe->accessScene(_sceneId); + _scene = g_fp->accessScene(_sceneId); if (!_scene) return; @@ -226,11 +226,11 @@ void Inventory2::draw() { if (!_scene) return; - int oldScLeft = g_fullpipe->_sceneRect.left; - int oldScTop = g_fullpipe->_sceneRect.top; + int oldScLeft = g_fp->_sceneRect.left; + int oldScTop = g_fp->_sceneRect.top; - g_fullpipe->_sceneRect.top = -_topOffset; - g_fullpipe->_sceneRect.left = 0; + g_fp->_sceneRect.top = -_topOffset; + g_fp->_sceneRect.left = 0; _picture->draw(-1, -1, 0, 0); @@ -290,8 +290,8 @@ LABEL_25: reset: - g_fullpipe->_sceneRect.top = oldScTop; - g_fullpipe->_sceneRect.left = oldScLeft; + g_fp->_sceneRect.top = oldScTop; + g_fp->_sceneRect.left = oldScLeft; } @@ -365,7 +365,7 @@ int Inventory2::selectItem(int itemId) { int idx = getInventoryPoolItemIndexById(itemId); Picture *pic = _scene->getPictureObjectById(_itemsPool[idx]->pictureObjectId1, 0)->_picture; - g_fullpipe->getGameLoaderInputController()->setCursorItemPicture(pic); + g_fp->getGameLoaderInputController()->setCursorItemPicture(pic); } return _selectedId; @@ -382,7 +382,7 @@ bool Inventory2::unselectItem(bool flag) { _inventoryIcons[i]->isSelected = false; } - g_fullpipe->getGameLoaderInputController()->setCursorItemPicture(0); + g_fp->getGameLoaderInputController()->setCursorItemPicture(0); return true; } diff --git a/engines/fullpipe/lift.cpp b/engines/fullpipe/lift.cpp index 1d6d986977..ca23d8223a 100644 --- a/engines/fullpipe/lift.cpp +++ b/engines/fullpipe/lift.cpp @@ -67,7 +67,7 @@ int FullpipeEngine::lift_getButtonIdP(int objid) { } void FullpipeEngine::lift_setButton(const char *name, int state) { - GameVar *var = g_fullpipe->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName(sO_LiftButtons); + GameVar *var = g_fp->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName(sO_LiftButtons); if (var) var->setSubVarAsInt(name, state); diff --git a/engines/fullpipe/messagehandlers.cpp b/engines/fullpipe/messagehandlers.cpp index fc57109f07..a9872a5a23 100644 --- a/engines/fullpipe/messagehandlers.cpp +++ b/engines/fullpipe/messagehandlers.cpp @@ -55,7 +55,7 @@ int global_messageHandler1(ExCommand *cmd) { cmd->_messageNum = MV_MAN_STOPLADDER2; } - if (g_fullpipe->_inputDisabled) { + if (g_fp->_inputDisabled) { if (cmd->_messageKind == 17) { switch (cmd->_messageNum) { case 29: @@ -71,25 +71,25 @@ int global_messageHandler1(ExCommand *cmd) { } else if (cmd->_messageKind == 17) { switch (cmd->_messageNum) { case MSG_MANSHADOWSON: - g_fullpipe->_aniMan->_shadowsOn = 1; + g_fp->_aniMan->_shadowsOn = 1; break; case MSG_HMRKICK_STUCCO: global_messageHandler_KickStucco(); break; case MSG_MANSHADOWSOFF: - g_fullpipe->_aniMan->_shadowsOn = 0; + g_fp->_aniMan->_shadowsOn = 0; break; case MSG_DISABLESAVES: - g_fullpipe->disableSaves(cmd); + g_fp->disableSaves(cmd); break; case MSG_ENABLESAVES: - g_fullpipe->enableSaves(); + g_fp->enableSaves(); break; case MSG_HMRKICK_METAL: global_messageHandler_KickMetal(); break; case 29: // left mouse - if (g_fullpipe->_inventoryScene) { + if (g_fp->_inventoryScene) { if (getGameLoaderInventory()->handleLeftClick(cmd)) cmd->_messageKind = 0; } @@ -101,22 +101,22 @@ int global_messageHandler1(ExCommand *cmd) { } break; case 36: // keydown - g_fullpipe->defHandleKeyDown(cmd->_keyCode); + g_fp->defHandleKeyDown(cmd->_keyCode); switch (cmd->_keyCode) { case '\x1B': // ESC - if (g_fullpipe->_currentScene) { + if (g_fp->_currentScene) { getGameLoaderInventory()->unselectItem(0); - g_fullpipe->openMainMenu(); + g_fp->openMainMenu(); cmd->_messageKind = 0; } break; case 't': - g_fullpipe->stopAllSounds(); + g_fp->stopAllSounds(); cmd->_messageKind = 0; break; case 'u': - g_fullpipe->toggleMute(); + g_fp->toggleMute(); cmd->_messageKind = 0; break; case ' ': @@ -130,13 +130,13 @@ int global_messageHandler1(ExCommand *cmd) { } break; case '\t': - if (g_fullpipe->_flgCanOpenMap) - g_fullpipe->openMap(); + if (g_fp->_flgCanOpenMap) + g_fp->openMap(); cmd->_messageKind = 0; break; case 'p': - if (g_fullpipe->_flgCanOpenMap) - g_fullpipe->openHelp(); + if (g_fp->_flgCanOpenMap) + g_fp->openHelp(); cmd->_messageKind = 0; break; default: @@ -144,47 +144,47 @@ int global_messageHandler1(ExCommand *cmd) { } break; case 33: - if (!g_fullpipe->_inventoryScene) + if (!g_fp->_inventoryScene) break; int invItem; - if (g_fullpipe->_updateFlag && (invItem = g_fullpipe->_inventory->getHoveredItem(&g_fullpipe->_mouseScreenPos))) { - g_fullpipe->_cursorId = PIC_CSR_ITN; - if (!g_fullpipe->_currSelectedInventoryItemId && !g_fullpipe->_aniMan->_movement && - !(g_fullpipe->_aniMan->_flags & 0x100) && g_fullpipe->_aniMan->isIdle()) { - int st = g_fullpipe->_aniMan->_statics->_staticsId; + if (g_fp->_updateFlag && (invItem = g_fp->_inventory->getHoveredItem(&g_fp->_mouseScreenPos))) { + g_fp->_cursorId = PIC_CSR_ITN; + if (!g_fp->_currSelectedInventoryItemId && !g_fp->_aniMan->_movement && + !(g_fp->_aniMan->_flags & 0x100) && g_fp->_aniMan->isIdle()) { + int st = g_fp->_aniMan->_statics->_staticsId; ExCommand *newex = 0; if (st == ST_MAN_RIGHT) { - newex = new ExCommand(g_fullpipe->_aniMan->_id, 1, rMV_MAN_LOOKUP, 0, 0, 0, 1, 0, 0, 0); + newex = new ExCommand(g_fp->_aniMan->_id, 1, rMV_MAN_LOOKUP, 0, 0, 0, 1, 0, 0, 0); } else if (st == (0x4000 | ST_MAN_RIGHT)) { - newex = new ExCommand(g_fullpipe->_aniMan->_id, 1, MV_MAN_LOOKUP, 0, 0, 0, 1, 0, 0, 0); + newex = new ExCommand(g_fp->_aniMan->_id, 1, MV_MAN_LOOKUP, 0, 0, 0, 1, 0, 0, 0); } if (newex) { - newex->_keyCode = g_fullpipe->_aniMan->_okeyCode; + newex->_keyCode = g_fp->_aniMan->_okeyCode; newex->_excFlags |= 3; newex->postMessage(); } } - if (g_fullpipe->_currSelectedInventoryItemId != invItem) - g_fullpipe->playSound(SND_CMN_070, 0); + if (g_fp->_currSelectedInventoryItemId != invItem) + g_fp->playSound(SND_CMN_070, 0); - g_fullpipe->_currSelectedInventoryItemId = invItem; - g_fullpipe->setCursor(g_fullpipe->_cursorId); + g_fp->_currSelectedInventoryItemId = invItem; + g_fp->setCursor(g_fp->_cursorId); break; } - if (g_fullpipe->_updateCursorCallback) - g_fullpipe->_updateCursorCallback(); + if (g_fp->_updateCursorCallback) + g_fp->_updateCursorCallback(); - g_fullpipe->_currSelectedInventoryItemId = 0; - g_fullpipe->setCursor(g_fullpipe->_cursorId); + g_fp->_currSelectedInventoryItemId = 0; + g_fp->setCursor(g_fp->_cursorId); break; case 65: // open map - if (cmd->_field_2C == 11 && cmd->_field_14 == ANI_INV_MAP && g_fullpipe->_flgCanOpenMap) - g_fullpipe->openMap(); + if (cmd->_field_2C == 11 && cmd->_field_14 == ANI_INV_MAP && g_fp->_flgCanOpenMap) + g_fp->openMap(); break; default: break; @@ -228,13 +228,13 @@ int global_messageHandler2(ExCommand *cmd) { break; case 28: - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (ani) ani->_priority = cmd->_field_14; break; case 25: - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (ani) { if (cmd->_field_14) { ani->setFlags40(true); @@ -247,7 +247,7 @@ int global_messageHandler2(ExCommand *cmd) { break; case 26: - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (ani) { Movement *mov = ani->_movement; if (mov) @@ -258,7 +258,7 @@ int global_messageHandler2(ExCommand *cmd) { default: #if 0 // We never put anything into _defMsgArray - while (::iterator it = g_fullpipe->_defMsgArray.begin(); it != g_fullpipe->_defMsgArray.end(); ++it) + while (::iterator it = g_fp->_defMsgArray.begin(); it != g_fp->_defMsgArray.end(); ++it) if (((ExCommand *)*it)->_field_24 == _messageNum) { ((ExCommand *)*it)->firef34(v13); res = 1; @@ -267,11 +267,11 @@ int global_messageHandler2(ExCommand *cmd) { //debug_msg(_messageNum); - if (!g_fullpipe->_soundEnabled || cmd->_messageNum != 33 || g_fullpipe->_currSoundListCount <= 0) + if (!g_fp->_soundEnabled || cmd->_messageNum != 33 || g_fp->_currSoundListCount <= 0) return res; - for (int snd = 0; snd < g_fullpipe->_currSoundListCount; snd++) { - SoundList *s = g_fullpipe->_currSoundList1[snd]; + for (int snd = 0; snd < g_fp->_currSoundListCount; snd++) { + SoundList *s = g_fp->_currSoundList1[snd]; int ms = s->getCount(); for (int i = 0; i < ms; i++) { s->getSoundByIndex(i)->setPanAndVolumeByStaticAni(); @@ -292,7 +292,7 @@ int global_messageHandler3(ExCommand *cmd) { case 31: case 32: case 36: - if (g_fullpipe->_inputDisabled) + if (g_fp->_inputDisabled) cmd->_messageKind = 0; break; default: @@ -306,41 +306,41 @@ int global_messageHandler3(ExCommand *cmd) { case 17: switch (cmd->_messageNum) { case 61: - return g_fullpipe->_gameLoader->preloadScene(cmd->_parentId, cmd->_keyCode); + return g_fp->_gameLoader->preloadScene(cmd->_parentId, cmd->_keyCode); case 62: - return g_fullpipe->_gameLoader->gotoScene(cmd->_parentId, cmd->_keyCode); + return g_fp->_gameLoader->gotoScene(cmd->_parentId, cmd->_keyCode); case 64: - if (g_fullpipe->_currentScene && g_fullpipe->_msgObjectId2 - && (!(cmd->_keyCode & 4) || g_fullpipe->_msgObjectId2 != cmd->_field_14 || g_fullpipe->_msgId != cmd->_field_20)) { - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(g_fullpipe->_msgObjectId2, g_fullpipe->_msgId); + if (g_fp->_currentScene && g_fp->_msgObjectId2 + && (!(cmd->_keyCode & 4) || g_fp->_msgObjectId2 != cmd->_field_14 || g_fp->_msgId != cmd->_field_20)) { + ani = g_fp->_currentScene->getStaticANIObject1ById(g_fp->_msgObjectId2, g_fp->_msgId); if (ani) { ani->_flags &= 0xFF7F; ani->_flags &= 0xFEFF; ani->deleteFromGlobalMessageQueue(); } } - g_fullpipe->_msgX = 0; - g_fullpipe->_msgY = 0; - g_fullpipe->_msgObjectId2 = 0; - g_fullpipe->_msgId = 0; + g_fp->_msgX = 0; + g_fp->_msgY = 0; + g_fp->_msgObjectId2 = 0; + g_fp->_msgId = 0; if ((cmd->_keyCode & 1) || (cmd->_keyCode & 2)) { - g_fullpipe->_msgX = cmd->_x; - g_fullpipe->_msgY = cmd->_y; + g_fp->_msgX = cmd->_x; + g_fp->_msgY = cmd->_y; } if (cmd->_keyCode & 4) { - g_fullpipe->_msgObjectId2 = cmd->_field_14; - g_fullpipe->_msgId = cmd->_field_20; + g_fp->_msgObjectId2 = cmd->_field_14; + g_fp->_msgId = cmd->_field_20; } return result; case 29: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) return result; - if (g_fullpipe->_gameLoader->_interactionController->_flag24) { - ani = g_fullpipe->_currentScene->getStaticANIObjectAtPos(cmd->_sceneClickX, cmd->_sceneClickY); - ani2 = g_fullpipe->_currentScene->getStaticANIObject1ById(g_fullpipe->_gameLoader->_field_FA, -1); + if (g_fp->_gameLoader->_interactionController->_flag24) { + ani = g_fp->_currentScene->getStaticANIObjectAtPos(cmd->_sceneClickX, cmd->_sceneClickY); + ani2 = g_fp->_currentScene->getStaticANIObject1ById(g_fp->_gameLoader->_field_FA, -1); if (ani) { - if (g_fullpipe->_msgObjectId2 == ani->_id && g_fullpipe->_msgId == ani->_okeyCode) { + if (g_fp->_msgObjectId2 == ani->_id && g_fp->_msgId == ani->_okeyCode) { cmd->_messageKind = 0; return result; } @@ -349,10 +349,10 @@ int global_messageHandler3(ExCommand *cmd) { return 1; } } else { - int id = g_fullpipe->_currentScene->getPictureObjectIdAtPos(cmd->_sceneClickX, cmd->_sceneClickY); - PictureObject *pic = g_fullpipe->_currentScene->getPictureObjectById(id, 0); + int id = g_fp->_currentScene->getPictureObjectIdAtPos(cmd->_sceneClickX, cmd->_sceneClickY); + PictureObject *pic = g_fp->_currentScene->getPictureObjectById(id, 0); if (pic) { - if (g_fullpipe->_msgObjectId2 == pic->_id && g_fullpipe->_msgId == pic->_okeyCode) { + if (g_fp->_msgObjectId2 == pic->_id && g_fp->_msgId == pic->_okeyCode) { cmd->_messageKind = 0; return result; } @@ -364,13 +364,13 @@ int global_messageHandler3(ExCommand *cmd) { } } } - if (getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->_isEnabled && cmd->_keyCode <= 0) { - if (g_fullpipe->_msgX != cmd->_sceneClickX || g_fullpipe->_msgY != cmd->_sceneClickY) { - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(g_fullpipe->_gameLoader->_field_FA, -1); + if (getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->_isEnabled && cmd->_keyCode <= 0) { + if (g_fp->_msgX != cmd->_sceneClickX || g_fp->_msgY != cmd->_sceneClickY) { + ani = g_fp->_currentScene->getStaticANIObject1ById(g_fp->_gameLoader->_field_FA, -1); if (!ani || (ani->isIdle() && !(ani->_flags & 0x80) && !(ani->_flags & 0x100))) { - result = startWalkTo(g_fullpipe->_gameLoader->_field_FA, -1, cmd->_sceneClickX, cmd->_sceneClickY, 0); + result = startWalkTo(g_fp->_gameLoader->_field_FA, -1, cmd->_sceneClickX, cmd->_sceneClickY, 0); if (result) { - ExCommand *ex = new ExCommand(g_fullpipe->_gameLoader->_field_FA, 17, 64, 0, 0, 0, 1, 0, 0, 0); + ExCommand *ex = new ExCommand(g_fp->_gameLoader->_field_FA, 17, 64, 0, 0, 0, 1, 0, 0, 0); ex->_keyCode = 1; ex->_excFlags |= 3; @@ -388,7 +388,7 @@ int global_messageHandler3(ExCommand *cmd) { return result; } case 58: - g_fullpipe->setCursor(cmd->_keyCode); + g_fp->setCursor(cmd->_keyCode); return result; case 59: setInputDisabled(1); @@ -398,7 +398,7 @@ int global_messageHandler3(ExCommand *cmd) { return result; case 56: if (cmd->_field_2C) { - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (ani) { getGameLoaderInventory()->addItem2(ani); result = 1; @@ -412,13 +412,13 @@ int global_messageHandler3(ExCommand *cmd) { case 57: if (cmd->_field_2C) { if (!cmd->_field_20) { - getGameLoaderInventory()->removeItem2(g_fullpipe->_currentScene, cmd->_parentId, cmd->_x, cmd->_y, cmd->_field_14); + getGameLoaderInventory()->removeItem2(g_fp->_currentScene, cmd->_parentId, cmd->_x, cmd->_y, cmd->_field_14); getGameLoaderInventory()->rebuildItemRects(); return 1; } - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(g_fullpipe->_gameLoader->_field_FA, -1); + ani = g_fp->_currentScene->getStaticANIObject1ById(g_fp->_gameLoader->_field_FA, -1); if (ani) { - getGameLoaderInventory()->removeItem2(g_fullpipe->_currentScene, cmd->_parentId, ani->_ox + cmd->_x, ani->_oy + cmd->_y, ani->_priority + cmd->_field_14); + getGameLoaderInventory()->removeItem2(g_fp->_currentScene, cmd->_parentId, ani->_ox + cmd->_x, ani->_oy + cmd->_y, ani->_priority + cmd->_field_14); getGameLoaderInventory()->rebuildItemRects(); return 1; } @@ -428,13 +428,13 @@ int global_messageHandler3(ExCommand *cmd) { getGameLoaderInventory()->rebuildItemRects(); return 1; case 55: - if (g_fullpipe->_currentScene) { + if (g_fp->_currentScene) { GameObject *obj; if (cmd->_field_14) - obj = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_x, cmd->_y); + obj = g_fp->_currentScene->getStaticANIObject1ById(cmd->_x, cmd->_y); else - obj = g_fullpipe->_currentScene->getPictureObjectById(cmd->_x, cmd->_y); - handleObjectInteraction(g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode), obj, cmd->_field_20); + obj = g_fp->_currentScene->getPictureObjectById(cmd->_x, cmd->_y); + handleObjectInteraction(g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode), obj, cmd->_field_20); result = 1; } return result; @@ -448,7 +448,7 @@ int global_messageHandler3(ExCommand *cmd) { if (cmd->_objtype == kObjTypeObjstateCommand) { ObjstateCommand *c = (ObjstateCommand *)cmd; result = 1; - g_fullpipe->setObjectState(c->_objCommandName, c->_value); + g_fp->setObjectState(c->_objCommandName, c->_value); } return result; default: @@ -461,7 +461,7 @@ int global_messageHandler4(ExCommand *cmd) { switch (cmd->_messageKind) { case 18: { - MessageQueue *mq = new MessageQueue(g_fullpipe->_currentScene->getMessageQueueById(cmd->_messageNum), cmd->_parId, 0); + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(cmd->_messageNum), cmd->_parId, 0); if (cmd->_excFlags & 1) mq->_flag1 = 1; @@ -472,10 +472,10 @@ int global_messageHandler4(ExCommand *cmd) { break; } case 2: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -483,10 +483,10 @@ int global_messageHandler4(ExCommand *cmd) { break; case 1: { - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -502,10 +502,10 @@ int global_messageHandler4(ExCommand *cmd) { break; } case 8: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -513,10 +513,10 @@ int global_messageHandler4(ExCommand *cmd) { break; case 20: { - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -534,10 +534,10 @@ int global_messageHandler4(ExCommand *cmd) { break; } case 21: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -548,17 +548,17 @@ int global_messageHandler4(ExCommand *cmd) { // Nop in original break; case 3: - g_fullpipe->_currentScene->_y = cmd->_messageNum - cmd->_messageNum % g_fullpipe->_scrollSpeed; + g_fp->_currentScene->_y = cmd->_messageNum - cmd->_messageNum % g_fp->_scrollSpeed; break; case 4: - g_fullpipe->_currentScene->_x = cmd->_messageNum - cmd->_messageNum % g_fullpipe->_scrollSpeed; + g_fp->_currentScene->_x = cmd->_messageNum - cmd->_messageNum % g_fp->_scrollSpeed; break; case 19: { - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -573,10 +573,10 @@ int global_messageHandler4(ExCommand *cmd) { break; } case 22: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -585,10 +585,10 @@ int global_messageHandler4(ExCommand *cmd) { break; case 6: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -596,18 +596,18 @@ int global_messageHandler4(ExCommand *cmd) { break; case 27: - if (!g_fullpipe->_currentScene || g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode) == 0) { - ani = g_fullpipe->accessScene(cmd->_field_20)->getStaticANIObject1ById(cmd->_parentId, -1); + if (!g_fp->_currentScene || g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode) == 0) { + ani = g_fp->accessScene(cmd->_field_20)->getStaticANIObject1ById(cmd->_parentId, -1); if (ani) { ani = new StaticANIObject(ani); - g_fullpipe->_currentScene->addStaticANIObject(ani, 1); + g_fp->_currentScene->addStaticANIObject(ani, 1); } } // fall through case 5: - if (g_fullpipe->_currentScene) - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + if (g_fp->_currentScene) + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -619,10 +619,10 @@ int global_messageHandler4(ExCommand *cmd) { break; case 10: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -633,34 +633,34 @@ int global_messageHandler4(ExCommand *cmd) { break; case 7: { - if (!g_fullpipe->_currentScene->_picObjList.size()) + if (!g_fp->_currentScene->_picObjList.size()) break; - int offX = g_fullpipe->_scrollSpeed * (cmd->_x / g_fullpipe->_scrollSpeed); - int offY = g_fullpipe->_scrollSpeed * (cmd->_y / g_fullpipe->_scrollSpeed); + int offX = g_fp->_scrollSpeed * (cmd->_x / g_fp->_scrollSpeed); + int offY = g_fp->_scrollSpeed * (cmd->_y / g_fp->_scrollSpeed); if (cmd->_messageNum) { - g_fullpipe->_currentScene->_x = offX - g_fullpipe->_sceneRect.left; - g_fullpipe->_currentScene->_y = offY - g_fullpipe->_sceneRect.top; + g_fp->_currentScene->_x = offX - g_fp->_sceneRect.left; + g_fp->_currentScene->_y = offY - g_fp->_sceneRect.top; if (cmd->_field_24) { - g_fullpipe->_currentScene->_messageQueueId = cmd->_parId; + g_fp->_currentScene->_messageQueueId = cmd->_parId; } } else { - g_fullpipe->_sceneRect.moveTo(offX, offY); + g_fp->_sceneRect.moveTo(offX, offY); - g_fullpipe->_currentScene->_x = 0; - g_fullpipe->_currentScene->_y = 0; + g_fp->_currentScene->_x = 0; + g_fp->_currentScene->_y = 0; - g_fullpipe->_currentScene->updateScrolling2(); + g_fp->_currentScene->updateScrolling2(); } break; } case 34: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -690,15 +690,15 @@ int MovGraph_messageHandler(ExCommand *cmd) { if (cmd->_messageNum != 33) return 0; - StaticANIObject *ani = g_fullpipe->_currentScene->getStaticANIObject1ById(g_fullpipe->_gameLoader->_field_FA, -1); + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(g_fp->_gameLoader->_field_FA, -1); - if (!getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)) + if (!getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)) return 0; - if (getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->_objtype != kObjTypeMovGraph || !ani) + if (getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->_objtype != kObjTypeMovGraph || !ani) return 0; - MovGraph *gr = (MovGraph *)getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId); + MovGraph *gr = (MovGraph *)getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId); MovGraphLink *link = 0; double mindistance = 1.0e10; diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp index 8ed99fce15..8ca416bb9e 100644 --- a/engines/fullpipe/messages.cpp +++ b/engines/fullpipe/messages.cpp @@ -73,7 +73,7 @@ bool ExCommand::load(MfcArchive &file) { _field_3C = 0; - if (g_fullpipe->_gameProjectVersion >= 12) { + if (g_fp->_gameProjectVersion >= 12) { _excFlags = file.readUint32LE(); _parId = file.readUint32LE(); } @@ -83,12 +83,12 @@ bool ExCommand::load(MfcArchive &file) { bool ExCommand::handleMessage() { int cnt = 0; - for (MessageHandler *m = g_fullpipe->_messageHandlers; m; m = m->nextItem) + for (MessageHandler *m = g_fp->_messageHandlers; m; m = m->nextItem) cnt += m->callback(this); if (_messageKind == 17 || (_excFlags & 1)) { if (_parId) { - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(_parId); if (mq) mq->update(); } @@ -101,18 +101,18 @@ bool ExCommand::handleMessage() { } void ExCommand::sendMessage() { - g_fullpipe->_exCommandList.push_back(this); + g_fp->_exCommandList.push_back(this); processMessages(); } void ExCommand::postMessage() { - g_fullpipe->_exCommandList.push_back(this); + g_fp->_exCommandList.push_back(this); } void ExCommand::handle() { - if (g_fullpipe->_modalObject) { - g_fullpipe->_modalObject->handleMessage(this); + if (g_fp->_modalObject) { + g_fp->_modalObject->handleMessage(this); delete this; } else { @@ -205,7 +205,7 @@ MessageQueue::MessageQueue(int dataId) { _field_14 = 0; _parId = 0; _dataId = dataId; - _id = g_fullpipe->_globalMessageQueueList->compact(); + _id = g_fp->_globalMessageQueueList->compact(); _isFinished = 0; _flags = 0; _queueName = 0; @@ -231,11 +231,11 @@ MessageQueue::MessageQueue(MessageQueue *src, int parId, int field_38) { else _parId = src->_parId; - _id = g_fullpipe->_globalMessageQueueList->compact(); + _id = g_fp->_globalMessageQueueList->compact(); _dataId = src->_dataId; _flags = src->_flags; - g_fullpipe->_globalMessageQueueList->addMessageQueue(this); + g_fp->_globalMessageQueueList->addMessageQueue(this); _isFinished = 0; _flag1 = 0; @@ -255,7 +255,7 @@ MessageQueue::~MessageQueue() { delete _field_14; if (_flags & 2) { - g_fullpipe->_globalMessageQueueList->removeQueueById(_id); + g_fp->_globalMessageQueueList->removeQueueById(_id); } finish(); @@ -270,7 +270,7 @@ bool MessageQueue::load(MfcArchive &file) { int count = file.readUint16LE(); - assert(g_fullpipe->_gameProjectVersion >= 12); + assert(g_fp->_gameProjectVersion >= 12); _queueName = file.readPascalString(); @@ -291,7 +291,7 @@ bool MessageQueue::load(MfcArchive &file) { bool MessageQueue::chain(StaticANIObject *ani) { if (checkGlobalExCommandList1() && checkGlobalExCommandList2()) { if (!(getFlags() & 2)) { - g_fullpipe->_globalMessageQueueList->addMessageQueue(this); + g_fp->_globalMessageQueueList->addMessageQueue(this); _flags |= 2; } if (ani) { @@ -331,7 +331,7 @@ void MessageQueue::addExCommandToEnd(ExCommand *ex) { } ExCommand *MessageQueue::getExCommandByIndex(uint idx) { - if (idx > getCount()) + if (idx >= getCount()) return 0; Common::List<ExCommand *>::iterator it = _exCommands.begin(); @@ -345,7 +345,7 @@ ExCommand *MessageQueue::getExCommandByIndex(uint idx) { } void MessageQueue::deleteExCommandByIndex(uint idx, bool doFree) { - if (idx > getCount()) + if (idx >= getCount()) return; Common::List<ExCommand *>::iterator it = _exCommands.begin(); @@ -398,7 +398,7 @@ bool MessageQueue::checkGlobalExCommandList1() { if (ex->_messageKind != 1 && ex->_messageKind != 20 && ex->_messageKind != 5 && ex->_messageKind != 27) continue; - for (Common::List<ExCommand *>::iterator it = g_fullpipe->_exCommandList.begin(); it != g_fullpipe->_exCommandList.end(); it++) { + for (Common::List<ExCommand *>::iterator it = g_fp->_exCommandList.begin(); it != g_fp->_exCommandList.end(); it++) { ex1 = *it; if (ex1->_messageKind != 1 && ex1->_messageKind != 20 && ex1->_messageKind != 5 && ex1->_messageKind != 27) @@ -407,7 +407,7 @@ bool MessageQueue::checkGlobalExCommandList1() { if (ex1->_keyCode != ex->_keyCode && ex1->_keyCode != -1 && ex->_keyCode != -1) continue; - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(ex1->_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(ex1->_parId); if (mq) { if (mq->getFlags() & 1) @@ -427,7 +427,7 @@ bool MessageQueue::checkGlobalExCommandList2() { if (ex->_messageKind != 1 && ex->_messageKind != 20 && ex->_messageKind != 5 && ex->_messageKind != 27) continue; - for (Common::List<ExCommand *>::iterator it = g_fullpipe->_exCommandList.begin(); it != g_fullpipe->_exCommandList.end();) { + for (Common::List<ExCommand *>::iterator it = g_fp->_exCommandList.begin(); it != g_fp->_exCommandList.end();) { ex1 = *it; if (ex1->_messageKind != 1 && ex1->_messageKind != 20 && ex1->_messageKind != 5 && ex1->_messageKind != 27) { @@ -440,7 +440,7 @@ bool MessageQueue::checkGlobalExCommandList2() { continue; } - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(ex1->_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(ex1->_parId); if (mq) { if (mq->getFlags() & 1) @@ -449,7 +449,7 @@ bool MessageQueue::checkGlobalExCommandList2() { delete mq; } - it = g_fullpipe->_exCommandList.erase(it); + it = g_fp->_exCommandList.erase(it); if (ex1->_excFlags & 2) { delete ex1; @@ -463,7 +463,7 @@ void MessageQueue::finish() { if (!_parId) return; - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(_parId); _parId = 0; @@ -573,7 +573,7 @@ int GlobalMessageQueueList::compact() { disableQueueById(_storage[i]->_id); remove_at(i); } else { - if (_storage[i]->_id < size() + 2) + if ((uint)_storage[i]->_id < size() + 2) useList[_storage[i]->_id] = 1; i++; } @@ -602,8 +602,8 @@ void clearGlobalMessageQueueList1() { } bool removeMessageHandler(int16 id, int pos) { - if (g_fullpipe->_messageHandlers) { - MessageHandler *curItem = g_fullpipe->_messageHandlers; + if (g_fp->_messageHandlers) { + MessageHandler *curItem = g_fp->_messageHandlers; MessageHandler *prevItem = 0; int curPos = 0; @@ -637,13 +637,13 @@ void addMessageHandler(int (*callback)(ExCommand *), int16 id) { if (getMessageHandlerById(id)) return; - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; if (!curItem) return; int index = 0; - for (MessageHandler *i = g_fullpipe->_messageHandlers->nextItem; i; i = i->nextItem) { + for (MessageHandler *i = g_fp->_messageHandlers->nextItem; i; i = i->nextItem) { curItem = i; index++; } @@ -655,7 +655,7 @@ void addMessageHandler(int (*callback)(ExCommand *), int16 id) { } MessageHandler *getMessageHandlerById(int16 id) { - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; if (!curItem) return 0; @@ -685,7 +685,7 @@ bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExComm msg->callback = callback; msg->index = 0; - g_fullpipe->_messageHandlers = msg; + g_fp->_messageHandlers = msg; } return true; @@ -693,7 +693,7 @@ bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExComm int getMessageHandlersCount() { int result; - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; for (result = 0; curItem; result++) curItem = curItem->nextItem; @@ -706,7 +706,7 @@ bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id) return false; if (index) { - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; for (int i = index - 1; i > 0; i--) if (curItem) @@ -724,13 +724,13 @@ bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id) } else { MessageHandler *newItem = new MessageHandler; - newItem->nextItem = g_fullpipe->_messageHandlers; + newItem->nextItem = g_fp->_messageHandlers; newItem->id = id; newItem->callback = callback; newItem->index = 0; - updateMessageHandlerIndex(g_fullpipe->_messageHandlers, 1); - g_fullpipe->_messageHandlers = newItem; + updateMessageHandlerIndex(g_fp->_messageHandlers, 1); + g_fp->_messageHandlers = newItem; return true; } @@ -740,7 +740,7 @@ bool insertMessageHandler(int (*callback)(ExCommand *), int index, int16 id) { if (getMessageHandlerById(id)) return false; - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; for (int i = index; i > 0; i--) if (curItem) @@ -757,7 +757,7 @@ void clearMessageHandlers() { MessageHandler *curItem; MessageHandler *nextItem; - curItem = g_fullpipe->_messageHandlers; + curItem = g_fp->_messageHandlers; if (curItem) { do { nextItem = curItem->nextItem; @@ -767,32 +767,32 @@ void clearMessageHandlers() { curItem = nextItem; } while (nextItem); - g_fullpipe->_messageHandlers = 0; + g_fp->_messageHandlers = 0; } } void processMessages() { - if (!g_fullpipe->_isProcessingMessages) { - g_fullpipe->_isProcessingMessages = true; + if (!g_fp->_isProcessingMessages) { + g_fp->_isProcessingMessages = true; - while (g_fullpipe->_exCommandList.size()) { - ExCommand *ex = g_fullpipe->_exCommandList.front(); - g_fullpipe->_exCommandList.pop_front(); + while (g_fp->_exCommandList.size()) { + ExCommand *ex = g_fp->_exCommandList.front(); + g_fp->_exCommandList.pop_front(); ex->handleMessage(); } - g_fullpipe->_isProcessingMessages = false; + g_fp->_isProcessingMessages = false; } } void updateGlobalMessageQueue(int id, int objid) { - MessageQueue *m = g_fullpipe->_globalMessageQueueList->getMessageQueueById(id); + MessageQueue *m = g_fp->_globalMessageQueueList->getMessageQueueById(id); if (m) { m->update(); } } bool chainQueue(int queueId, int flags) { - MessageQueue *mq = g_fullpipe->_currentScene->getMessageQueueById(queueId); + MessageQueue *mq = g_fp->_currentScene->getMessageQueueById(queueId); if (!mq) return false; @@ -810,6 +810,25 @@ bool chainQueue(int queueId, int flags) { return true; } +bool chainObjQueue(StaticANIObject *obj, int queueId, int flags) { + MessageQueue *mq = g_fp->_currentScene->getMessageQueueById(queueId); + + if (!mq) + return false; + + MessageQueue *nmq = new MessageQueue(mq, 0, 0); + + nmq->_flags |= flags; + + if (!nmq->chain(obj)) { + delete nmq; + + return false; + } + + return true; +} + void postExCommand(int parentId, int keyCode, int x, int y, int f20, int f14) { ExCommand *ex = new ExCommand(parentId, 17, 64, 0, 0, 0, 1, 0, 0, 0); diff --git a/engines/fullpipe/messages.h b/engines/fullpipe/messages.h index ca61dad007..44245bcf19 100644 --- a/engines/fullpipe/messages.h +++ b/engines/fullpipe/messages.h @@ -178,6 +178,7 @@ void updateGlobalMessageQueue(int id, int objid); void clearGlobalMessageQueueList1(); bool chainQueue(int queueId, int flags); +bool chainObjQueue(StaticANIObject *obj, int queueId, int flags); void postExCommand(int parentId, int keyCode, int x, int y, int f20, int f16); } // End of namespace Fullpipe diff --git a/engines/fullpipe/modal.cpp b/engines/fullpipe/modal.cpp index f766be3eac..516d761aa2 100644 --- a/engines/fullpipe/modal.cpp +++ b/engines/fullpipe/modal.cpp @@ -24,6 +24,7 @@ #include "fullpipe/modal.h" #include "fullpipe/messages.h" #include "fullpipe/constants.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/gameloader.h" @@ -40,17 +41,17 @@ ModalIntro::ModalIntro() { _introFlags = 33; _countDown = 150; - PictureObject *pict = g_fullpipe->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0); + PictureObject *pict = g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0); pict->setFlags(pict->_flags & 0xFFFB); } g_vars->sceneIntro_skipIntro = false; - _sfxVolume = g_fullpipe->_sfxVolume; + _sfxVolume = g_fp->_sfxVolume; } ModalIntro::~ModalIntro() { - g_fullpipe->stopAllSounds(); - g_fullpipe->_sfxVolume = _sfxVolume; + g_fp->stopAllSounds(); + g_fp->_sfxVolume = _sfxVolume; } bool ModalIntro::handleMessage(ExCommand *message) { @@ -84,7 +85,7 @@ bool ModalIntro::init(int counterdiff) { } if (_introFlags & 0x10) - g_fullpipe->_gameLoader->updateSystems(42); + g_fp->_gameLoader->updateSystems(42); _introFlags |= 2; @@ -94,7 +95,7 @@ bool ModalIntro::init(int counterdiff) { if (_introFlags & 4) { ModalVideoPlayer *player = new ModalVideoPlayer(); - g_fullpipe->_modalObject = player; + g_fp->_modalObject = player; player->_parentObj = this; player->play("intro.avi"); @@ -118,7 +119,7 @@ bool ModalIntro::init(int counterdiff) { if (_introFlags & 0x40) { ModalVideoPlayer *player = new ModalVideoPlayer(); - g_fullpipe->_modalObject = player; + g_fp->_modalObject = player; player->_parentObj = this; player->play("intro2.avi"); @@ -151,7 +152,7 @@ bool ModalIntro::init(int counterdiff) { _countDown = 150; _introFlags = (_introFlags & 0xf7) | 0x21; - g_fullpipe->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0)->_flags &= 0xfffb; + g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0)->_flags &= 0xfffb; } if (!(_introFlags & 0x20)) { @@ -159,12 +160,12 @@ bool ModalIntro::init(int counterdiff) { if (!_stillRunning) { _introFlags |= 1; - g_fullpipe->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0)->_flags &= 0xfffb; - g_fullpipe->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_GAMETITLE, 0)->_flags &= 0xfffb; + g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0)->_flags &= 0xfffb; + g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_GAMETITLE, 0)->_flags &= 0xfffb; chainQueue(QU_INTR_STARTINTRO, 1); } - g_fullpipe->_gameLoader->updateSystems(42); + g_fp->_gameLoader->updateSystems(42); } return true; } @@ -180,7 +181,7 @@ bool ModalIntro::init(int counterdiff) { _introFlags = (_introFlags & 0xdf) | 0x10; - g_fullpipe->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_GAMETITLE, 0)->_flags &= 0xfffb; + g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_GAMETITLE, 0)->_flags &= 0xfffb; _stillRunning = 0; } @@ -189,14 +190,14 @@ bool ModalIntro::init(int counterdiff) { } void ModalIntro::update() { - if (g_fullpipe->_currentScene) { + if (g_fp->_currentScene) { if (_introFlags & 1) { //sceneFade(virt, g_currentScene, 1); _stillRunning = 255; _introFlags &= 0xfe; if (_introFlags & 0x20) - g_fullpipe->playSound(SND_INTR_019, 0); + g_fp->playSound(SND_INTR_019, 0); } else if (_introFlags & 2) { if (g_vars->sceneIntro_needBlackout) { //vrtRectangle(*(_DWORD *)virt, 0, 0, 0, 800, 600); @@ -209,18 +210,18 @@ void ModalIntro::update() { _introFlags &= 0xfd; } } else if (_stillRunning) { - g_fullpipe->_currentScene->draw(); + g_fp->_currentScene->draw(); } } } void ModalIntro::finish() { - g_fullpipe->_gameLoader->unloadScene(SC_INTRO2); - g_fullpipe->_currentScene = g_fullpipe->accessScene(SC_INTRO1); - g_fullpipe->_gameLoader->preloadScene(SC_INTRO1, TrubaDown); + g_fp->_gameLoader->unloadScene(SC_INTRO2); + g_fp->_currentScene = g_fp->accessScene(SC_INTRO1); + g_fp->_gameLoader->preloadScene(SC_INTRO1, TrubaDown); - if (g_fullpipe->_currentScene) - g_fullpipe->_gameLoader->updateSystems(42); + if (g_fp->_currentScene) + g_fp->_gameLoader->updateSystems(42); } void ModalVideoPlayer::play(const char *fname) { diff --git a/engines/fullpipe/module.mk b/engines/fullpipe/module.mk index bd948b7ab4..6f8fbe2c71 100644 --- a/engines/fullpipe/module.mk +++ b/engines/fullpipe/module.mk @@ -28,6 +28,14 @@ MODULE_OBJS = \ scenes/scene02.o \ scenes/scene03.o \ scenes/scene04.o \ + scenes/scene05.o \ + scenes/scene06.o \ + scenes/scene07.o \ + scenes/scene08.o \ + scenes/scene10.o \ + scenes/scene11.o \ + scenes/scene12.o \ + scenes/scene15.o \ scenes/sceneDbg.o \ scenes/sceneIntro.o diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index fbe2768486..45ff4ae5f0 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -42,6 +42,16 @@ bool MotionController::load(MfcArchive &file) { return true; } +void MotionController::enableLinks(const char *linkName, bool enable) { + warning("STUB: MotionController::enableLinks()"); +} + +MovGraphLink *MotionController::getLinkByName(const char *name) { + warning("STUB: MotionController::getLinkByName()"); + + return 0; +} + bool MctlCompound::load(MfcArchive &file) { debug(5, "MctlCompound::load()"); @@ -185,9 +195,14 @@ MessageQueue *MctlCompound::doWalkTo(StaticANIObject *subj, int xpos, int ypos, return mq; } +MctlCompoundArrayItem::~MctlCompoundArrayItem() { + delete _movGraphReactObj; + delete _motionControllerObj; +} + MctlLadder::MctlLadder() { - _ladder_field_18 = 0; - _objId = 0; + _width = 0; + _ladderX = 0; _height = 0; _ladderY = 0; _ladder_field_14 = 0; @@ -243,7 +258,7 @@ int MctlLadder::findObjectPos(StaticANIObject *obj) { } bool MctlLadder::initMovement(StaticANIObject *ani, MctlLadderMovement *movement) { - GameVar *v = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(ani->getName()); + GameVar *v = g_fp->getGameLoaderGameVar()->getSubVarByName(ani->getName()); if (!v) return false; @@ -298,7 +313,12 @@ void MctlLadder::freeItems() { } MessageQueue *MctlLadder::method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { - warning("STUB: MctlLadder::method34()"); + MessageQueue *mq = doWalkTo(subj, xpos, ypos, fuzzyMatch, staticsId); + + if (mq) { + if (mq->chain(subj)) + return mq; + } return 0; } @@ -309,12 +329,61 @@ MessageQueue *MctlLadder::doWalkTo(StaticANIObject *subj, int xpos, int ypos, in return 0; } +MessageQueue *MctlLadder::controllerWalkTo(StaticANIObject *ani, int off) { + return doWalkTo(ani, _ladderX + off * _width, _ladderY + off * _height, 1, 0); +} + MctlConnectionPoint *MctlCompound::findClosestConnectionPoint(int ox, int oy, int destIndex, int connectionX, int connectionY, int sourceIndex, int *minDistancePtr) { warning("STUB: MctlCompound::findClosestConnectionPoint()"); return 0; } +void MctlCompound::replaceNodeX(int from, int to) { + warning("STUB: MctlCompound::replaceNodeX()"); +} + +MctlConnectionPoint::MctlConnectionPoint() { + _connectionX = 0; + _connectionY = 0; + _field_C = 0; + _field_10 = 0; + _field_14 = 0; + _field_16 = 0; + _messageQueueObj = 0; + _motionControllerObj = 0; +} + +MctlConnectionPoint::~MctlConnectionPoint() { + delete _messageQueueObj; +} + +MovInfo1::MovInfo1(MovInfo1 *src) { + field_0 = src->field_0; + pt1 = src->pt1; + pt2 = src->pt2; + distance1 = src->distance1; + distance2 = src->distance2; + subIndex = src->subIndex; + item1Index = src->item1Index; + items = src->items; + itemsCount = src->itemsCount; + flags = src->flags; +} + +void MovInfo1::clear() { + field_0 = 0; + pt1.x = pt1.y = 0; + pt2.x = pt2.y = 0; + distance1 = 0; + distance2 = 0; + subIndex = 0; + item1Index = 0; + items.clear(); + itemsCount = 0; + flags = 0; +} + bool MctlCompoundArray::load(MfcArchive &file) { debug(5, "MctlCompoundArray::load()"); @@ -404,10 +473,9 @@ int MovGraph::method28() { return 0; } -int MovGraph::method2C() { - warning("STUB: MovGraph::method2C()"); - - return 0; +int MovGraph::method2C(StaticANIObject *obj, int x, int y) { + obj->setOXY(x, y); + return method3C(obj, 1); } MessageQueue *MovGraph::method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { @@ -422,7 +490,7 @@ int MovGraph::changeCallback() { return 0; } -int MovGraph::method3C() { +int MovGraph::method3C(StaticANIObject *ani, int flag) { warning("STUB: MovGraph::method3C()"); return 0; @@ -475,8 +543,8 @@ double MovGraph::calcDistance(Common::Point *point, MovGraphLink *link, int fuzz return -1.0; } } else { - point->x = n1x + (dist2x * distm / link->_distance); - point->y = n1y + (dist2y * distm / link->_distance); + point->x = (int)(n1x + (dist2x * distm / link->_distance)); + point->y = (int)(n1y + (dist2y * distm / link->_distance)); } return res; @@ -529,7 +597,7 @@ bool MovGraph2::initDirections(StaticANIObject *obj, MovGraph2Item *item) { item->_obj = obj; item->_objectId = obj->_id; - GameVar *var = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(obj->_objectName); + GameVar *var = g_fp->getGameLoaderGameVar()->getSubVarByName(obj->_objectName); if (!var) return false; @@ -782,15 +850,13 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL } MessageQueue *MovGraph2::buildMovInfo1MessageQueue(MovInfo1 *movInfo) { - MovInfo1 movinfo; - - memcpy(&movinfo, movInfo, sizeof(movinfo)); + MovInfo1 movinfo(movInfo); int curX = movInfo->pt1.x; int curY = movInfo->pt1.y; int curDistance = movInfo->distance1; - MessageQueue *mq = new MessageQueue(g_fullpipe->_globalMessageQueueList->compact()); + MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); for (int i = 0; i < movInfo->itemsCount - 1; i++) { if (movInfo->items[i + 1]->subIndex != 10) { @@ -1026,7 +1092,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int } if (obj->_ox == xpos && obj->_oy == ypos) { - g_fullpipe->_globalMessageQueueList->compact(); + g_fp->_globalMessageQueueList->compact(); MessageQueue *mq = new MessageQueue(); @@ -1103,7 +1169,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int if (minPath < 0.0 || ((linkInfoSource.node != linkInfoDest.node || !linkInfoSource.node) && !tempLinkList.size())) return 0; - memset(&movInfo1, 0, sizeof(movInfo1)); + movInfo1.clear(); movInfo1.subIndex = idxsub; movInfo1.pt1.x = obj->_ox; @@ -1134,7 +1200,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int double dst1 = sqrt((double)((ypos - nod->_y) * (ypos - nod->_y) + (xpos - nod->_x) * (xpos - nod->_x))); int dst = linkInfoDest.link->_movGraphNode2->_distance - nod->_distance; - movInfo1.distance2 = nod->_distance + (dst1 * (double)dst / linkInfoDest.link->_distance); + movInfo1.distance2 = (int)(nod->_distance + (dst1 * (double)dst / linkInfoDest.link->_distance)); calcDistance(&movInfo1.pt2, linkInfoDest.link, 1); @@ -1160,7 +1226,6 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int if (_items2[idx]->_subItems[idxsub]._staticsId1 != obj->_statics->_staticsId) movInfo1.flags |= 2; - // FIXME: This somehow corrupts the heap (reported by MSVC) buildMovInfo1SubItems(&movInfo1, &tempLinkList, &linkInfoSource, &linkInfoDest); MessageQueue *mq = buildMovInfo1MessageQueue(&movInfo1); @@ -1492,7 +1557,7 @@ void MGM::rebuildTables(int objId) { _items[idx]->movements1.clear(); _items[idx]->movements2.clear(); - StaticANIObject *obj = g_fullpipe->_currentScene->getStaticANIObject1ById(objId, -1); + StaticANIObject *obj = g_fp->_currentScene->getStaticANIObject1ById(objId, -1); if (!obj) return; @@ -1528,9 +1593,13 @@ void MGM::updateAnimStatics(StaticANIObject *ani, int staticsId) { ani->queueMessageQueue(0); ani->_movement->gotoLastFrame(); ani->_statics = ani->_movement->_staticsObj2; + + int x = ani->_movement->_ox; + int y = ani->_movement->_oy; + ani->_movement = 0; - ani->setOXY(ani->_movement->_ox, ani->_movement->_oy); + ani->setOXY(x, y); } if (ani->_statics) { @@ -1544,12 +1613,66 @@ void MGM::updateAnimStatics(StaticANIObject *ani, int staticsId) { } } -Common::Point *MGM::getPoint(Common::Point *point, int aniId, int staticsId1, int staticsId2) { - warning("STUB: MGM::getPoint()"); +Common::Point *MGM::getPoint(Common::Point *point, int objectId, int staticsId1, int staticsId2) { + int idx = getItemIndexById(objectId); + + if (idx == -1) { + point->x = -1; + point->y = -1; + } else { + int st1idx = getStaticsIndexById(idx, staticsId1); + int st2idx = getStaticsIndexById(idx, staticsId2); + + if (st1idx == st2idx) { + point->x = 0; + point->y = 0; + } else { + int subidx = st1idx + st2idx * _items[idx]->statics.size(); + + if (!_items[idx]->subItems[subidx]->movement) { + clearMovements2(idx); + recalcOffsets(idx, st1idx, st2idx, false, true); + + if (!_items[idx]->subItems[subidx]->movement) { + clearMovements2(idx); + recalcOffsets(idx, st1idx, st2idx, true, false); + } + } + + MGMSubItem *sub = _items[idx]->subItems[subidx]; + + if (sub->movement) { + point->x = sub->x; + point->y = sub->y; + } else { + point->x = 0; + point->y = 0; + } + } + } return point; } +int MGM::getStaticsIndexById(int idx, int16 id) { + for (uint i = 0; i < _items[idx]->statics.size(); i++) { + if (_items[idx]->statics[i]->_staticsId == id) + return i; + } + + return 0; +} + +void MGM::clearMovements2(int idx) { + _items[idx]->movements2.clear(); +} + +int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) { + warning("STUB: MGM::recalcOffsets()"); + + return 0; +} + MovGraphLink::MovGraphLink() { _distance = 0; _angle = 0; @@ -1712,15 +1835,15 @@ bool MovGraphReact::pointInRegion(int x, int y) { double xinters; Common::Point p, p1, p2; - p.x = (double)x; - p.y = (double)y; + p.x = x; + p.y = y; - p1.x = (double)_points[0]->x; - p1.y = (double)_points[0]->y; + p1.x = _points[0]->x; + p1.y = _points[0]->y; for (int i = 1; i <= _pointCount; i++) { - p2.x = (double)_points[i % _pointCount]->x; - p2.y = (double)_points[i % _pointCount]->y; + p2.x = _points[i % _pointCount]->x; + p2.y = _points[i % _pointCount]->y; if (p.y > MIN(p1.y, p2.y)) { if (p.y <= MAX(p1.y, p2.y)) { @@ -1745,10 +1868,10 @@ bool MovGraphReact::pointInRegion(int x, int y) { } int startWalkTo(int objId, int objKey, int x, int y, int a5) { - MctlCompound *mc = getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId); + MctlCompound *mc = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId); if (mc) - return (mc->method34(g_fullpipe->_currentScene->getStaticANIObject1ById(objId, objKey), x, y, a5, 0) != 0); + return (mc->method34(g_fp->_currentScene->getStaticANIObject1ById(objId, objKey), x, y, a5, 0) != 0); return 0; } diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h index b49fea55bc..24f047d76b 100644 --- a/engines/fullpipe/motion.h +++ b/engines/fullpipe/motion.h @@ -28,6 +28,7 @@ namespace Fullpipe { class Statics; class Movement; class MctlConnectionPoint; +class MovGraphLink; int startWalkTo(int objId, int objKey, int x, int y, int a5); int doSomeAnimation(int objId, int objKey, int a3); @@ -50,15 +51,18 @@ public: virtual int removeObject(StaticANIObject *obj) { return 0; } virtual void freeItems() {} virtual int method28() { return 0; } - virtual int method2C() { return 0; } + virtual int method2C(StaticANIObject *obj, int x, int y) { return 0; } virtual int method30() { return 0; } virtual MessageQueue *method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { return 0; } virtual int changeCallback() { return 0; } - virtual int method3C() { return 0; } + virtual int method3C(StaticANIObject *ani, int flag) { return 0; } virtual int method40() { return 0; } virtual int method44() { return 0; } virtual int method48() { return -1; } virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { return 0; } + + void enableLinks(const char *linkName, bool enable); + MovGraphLink *getLinkByName(const char *name); }; class MovGraphReact : public CObject { @@ -76,9 +80,7 @@ public: }; class MctlCompoundArrayItem : public CObject { - friend class MctlCompound; - -protected: +public: MotionController *_motionControllerObj; MovGraphReact *_movGraphReactObj; Common::Array<MctlConnectionPoint *> _connectionPoints; @@ -88,6 +90,7 @@ protected: public: MctlCompoundArrayItem() : _movGraphReactObj(0), _motionControllerObj(0), _field_20(0), _field_24(0), _field_28(0) {} + ~MctlCompoundArrayItem(); }; class MctlCompoundArray : public Common::Array<MctlCompoundArrayItem *>, public CObject { @@ -96,9 +99,9 @@ class MctlCompoundArray : public Common::Array<MctlCompoundArrayItem *>, public }; class MctlCompound : public MotionController { +public: MctlCompoundArray _motionControllers; - public: MctlCompound() { _objtype = kObjTypeMctlCompound; } virtual bool load(MfcArchive &file); @@ -111,10 +114,11 @@ class MctlCompound : public MotionController { void initMovGraph2(); MctlConnectionPoint *findClosestConnectionPoint(int ox, int oy, int destIndex, int connectionX, int connectionY, int sourceIndex, int *minDistancePtr); + void replaceNodeX(int from, int to); }; struct MGMSubItem { - int movement; + Movement *movement; int staticsIndex; int field_8; int field_C; @@ -146,6 +150,8 @@ struct MGMInfo { int x2; int y2; int flags; + + MGMInfo() { memset(this, 0, sizeof(MGMInfo)); } }; class MGM : public CObject { @@ -161,6 +167,9 @@ public: MessageQueue *genMovement(MGMInfo *mgminfo); void updateAnimStatics(StaticANIObject *ani, int staticsId); Common::Point *getPoint(Common::Point *point, int aniId, int staticsId1, int staticsId2); + int getStaticsIndexById(int idx, int16 id); + void clearMovements2(int idx); + int recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop); }; struct MctlLadderMovementVars { @@ -181,10 +190,10 @@ struct MctlLadderMovement { class MctlLadder : public MotionController { public: - int _objId; + int _ladderX; int _ladderY; int _ladder_field_14; - int _ladder_field_18; + int _width; int _height; int _ladder_field_20; int _ladder_field_24; @@ -202,6 +211,8 @@ public: virtual MessageQueue *method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); + MessageQueue *controllerWalkTo(StaticANIObject *ani, int off); + private: int findObjectPos(StaticANIObject *obj); bool initMovement(StaticANIObject *ani, MctlLadderMovement *movement); @@ -309,10 +320,10 @@ public: virtual int removeObject(StaticANIObject *obj); virtual void freeItems(); virtual int method28(); - virtual int method2C(); + virtual int method2C(StaticANIObject *obj, int x, int y); virtual MessageQueue *method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); virtual int changeCallback(); - virtual int method3C(); + virtual int method3C(StaticANIObject *ani, int flag); virtual int method44(); virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); virtual int method50(); @@ -362,6 +373,10 @@ struct MovInfo1 { Common::Array<MovInfo1Sub *> items; int itemsCount; int flags; + + MovInfo1() { clear(); } + MovInfo1(MovInfo1 *src); + void clear(); }; struct MovGraph2Item { // 744 @@ -411,6 +426,9 @@ public: int16 _field_16; MessageQueue *_messageQueueObj; int _motionControllerObj; + + MctlConnectionPoint(); + ~MctlConnectionPoint(); }; } // End of namespace Fullpipe diff --git a/engines/fullpipe/ngiarchive.cpp b/engines/fullpipe/ngiarchive.cpp index 5d895c17a0..132f4758d3 100644 --- a/engines/fullpipe/ngiarchive.cpp +++ b/engines/fullpipe/ngiarchive.cpp @@ -91,7 +91,7 @@ NGIArchive::NGIArchive(const Common::String &filename) : _ngiFilename(filename) free(fat); - g_fullpipe->_currArchive = this; + g_fp->_currArchive = this; debug(0, "NGIArchive::NGIArchive(%s): Located %d files", filename.c_str(), _headers.size()); } @@ -103,7 +103,7 @@ NGIArchive::~NGIArchive() { delete it->_value; } - g_fullpipe->_currArchive = 0; + g_fp->_currArchive = 0; } bool NGIArchive::hasFile(const Common::String &name) const { diff --git a/engines/fullpipe/objectnames.h b/engines/fullpipe/objectnames.h index b8696ec672..87442d990a 100644 --- a/engines/fullpipe/objectnames.h +++ b/engines/fullpipe/objectnames.h @@ -30,7 +30,7 @@ namespace Fullpipe { #define sO_Grandma "\xc1\xe0\xe1\xf3\xeb\xff" // "Бабуля" #define sO_Jar_4 "\xc1\xe0\xed\xea\xe0_4" // "Банка_4" #define sO_Pool "\xc1\xe0\xf1\xf1\xe5\xe9\xed" // "Бассейн" -#define sO_TumyTrampie "\xc1\xe0\xf2\xf3\xf2\xe0" // "Батута" +#define sO_TummyTrampie "\xc1\xe0\xf2\xf3\xf2\xe0" // "Батута" #define sO_WithoutBoot "\xc1\xe5\xe7 \xe1\xee\xf2\xe8\xed\xea\xe0" // "Без ботинка" #define sO_WithoutJug "\xc1\xe5\xe7 \xe3\xee\xf0\xf8\xea\xee\xe2" // "Без горшков" #define sO_WithoutCarpet "\xc1\xe5\xe7 \xea\xee\xe2\xf0\xe8\xea\xe0" // "Без коврика" @@ -48,6 +48,10 @@ namespace Fullpipe { #define sO_InSock "\xc2 \xed\xee\xf1\xea\xe5" // "В носке" #define sO_InGlasses "\xc2 \xee\xf7\xea\xe0\xf5" // "В очках" #define sO_In_14 "\xc2_14" // "В_14" +#define sO_In_15 "\xc2_15" // "В_15" +#define sO_In_15_1 "\xc2_15_1" // "В_15_1" +#define sO_In_15_2 "\xc2_15_2" // "В_15_2" +#define sO_In_15_3 "\xc2_15_3" // "В_15_3" #define sO_In_32_Lies "\xc2_32 \xeb\xe5\xe6\xe8\xf2" // "В_32 лежит" #define sO_In_32_Stands "\xc2_32 \xf2\xee\xf0\xf7\xe8\xf2" // "В_32 торчит" #define sO_In_33 "\xc2_33" // "В_33" @@ -78,11 +82,11 @@ namespace Fullpipe { #define sO_Grandpa "\xc4\xe5\xe4\xf3\xf8\xea\xe0" // "Дедушка" #define sO_Plank_25 "\xc4\xee\xf1\xea\xe0_25" // "Доска_25" #define sO_Plank_34 "\xc4\xee\xf1\xea\xe0_34" // "Доска_34" -#define sO_DudeJumped "\xc4\xff\xe4\xff \xef\xf0\xfb\xe3\xe0\xeb" // "Дядя прыгал" +#define sO_DudeHasJumped "\xc4\xff\xe4\xff \xef\xf0\xfb\xe3\xe0\xeb" // "Дядя прыгал" #define sO_Dude "\xc4\xff\xe4\xff" // "Дядя" #define sO_GuvTheDrawer "\xc4\xff\xe4\xff-\xff\xf9\xe8\xea" // "Дядя-ящик" #define sO_DudeSwinged "\xc4\xff\xe4\xff_\xea\xe0\xf2\xe0\xeb\xf1\xff" // "Дядя_катался" -#define sO_Eats "\xc5\xf1\xf2" // "Ест" +#define sO_IsEating "\xc5\xf1\xf2" // "Ест" #define sO_Present "\xc5\xf1\xf2\xfc" // "Есть" #define sO_CloseThing1 "\xc7\xe0\xea\xf0\xfb\xe2\xe0\xe5\xec\xee\xe5 1" // "Закрываемое 1" #define sO_CloseThing2 "\xc7\xe0\xea\xf0\xfb\xe2\xe0\xe5\xec\xee\xe5 2" // "Закрываемое 2" @@ -94,11 +98,11 @@ namespace Fullpipe { #define sO_HalfFull "\xc7\xe0\xef\xee\xeb\xed\xe5\xed \xed\xe0\xef\xee\xeb\xee\xe2\xe8\xed\xf3" // "Заполнен наполовину" #define sO_Full "\xc7\xe0\xef\xee\xeb\xed\xe5\xed \xf6\xe5\xeb\xe8\xea\xee\xec" // "Заполнен целиком" #define sO_MirroredTo "\xc7\xe5\xf0\xea\xe0\xeb\xfc\xed\xe0\xff \xea" // "Зеркальная к" -#define sO_Playing "\xc8\xe3\xf0\xe0\xe5\xf2" // "Играет" +#define sO_IsPlaying "\xc8\xe3\xf0\xe0\xe5\xf2" // "Играет" #define sO_Tub "\xca\xe0\xe4\xea\xe0" // "Кадка" #define sO_Cactus "\xca\xe0\xea\xf2\xf3\xf1" // "Кактус" -#define sO_SwingingWithBoot "\xca\xe0\xf2\xe0\xe5\xf2\xf1\xff \xf1 \xe1\xee\xf2\xe8\xed\xea\xee\xec" // "Катается с ботинком" -#define sO_Swinging "\xca\xe0\xf2\xe0\xe5\xf2\xf1\xff" // "Катается" +#define sO_IsSwingingWithBoot "\xca\xe0\xf2\xe0\xe5\xf2\xf1\xff \xf1 \xe1\xee\xf2\xe8\xed\xea\xee\xec" // "Катается с ботинком" +#define sO_IsSwinging "\xca\xe0\xf2\xe0\xe5\xf2\xf1\xff" // "Катается" #define sO_Swingie "\xca\xe0\xf7\xe5\xeb\xe5\xed\xff" // "Качеленя" #define sO_LiftButtons "\xca\xed\xee\xef\xea\xe8 \xeb\xe8\xf4\xf2\xe0" // "Кнопки лифта" #define sO_Carpet_35 "\xca\xee\xe2\xf0\xe8\xea_35" // "Коврик_35" @@ -135,7 +139,7 @@ namespace Fullpipe { #define sO_NotGrown "\xcd\xe5 \xe2\xfb\xf0\xee\xf1" // "Не вырос" #define sO_DidNotCrackEgg "\xcd\xe5 \xea\xee\xeb\xee\xeb \xff\xe9\xf6\xee" // "Не колол яйцо" #define sO_NotFallen "\xcd\xe5 \xef\xe0\xe4\xe0\xeb" // "Не падал" -#define sO_NotAvailable "\xcd\xe5\xe4\xee\xf1\xf2\xf3\xef\xed\xe0" // "Недоступна" +#define sO_IsNotAvailable "\xcd\xe5\xe4\xee\xf1\xf2\xf3\xef\xed\xe0" // "Недоступна" #define sO_CannotTake "\xcd\xe5\xeb\xfc\xe7\xff \xe2\xe7\xff\xf2\xfc" // "Нельзя взять" #define sO_No "\xcd\xe5\xf2" // "Нет" #define sO_LowerHatch_23 "\xcd\xe8\xe6\xed\xe8\xe9 \xeb\xfe\xea_23" // "Нижний люк_23" @@ -168,8 +172,8 @@ namespace Fullpipe { #define sO_Empty "\xcf\xf3\xf1\xf2" // "Пуст" #define sO_EmptyShe "\xcf\xf3\xf1\xf2\xe0\xff" // "Пустая" #define sO_WayToPipe "\xcf\xf3\xf2\xfc \xea \xf2\xf0\xf3\xe1\xe5" // "Путь к трубе" -#define sO_Drinking "\xcf\xfc\xe5\xf2" // "Пьет" -#define sO_BrokenInPieces "\xd0\xe0\xe7\xe1\xe8\xf2\xe0" // "Разбита" +#define sO_IsDrinking "\xcf\xfc\xe5\xf2" // "Пьет" +#define sO_Broken "\xd0\xe0\xe7\xe1\xe8\xf2\xe0" // "Разбита" #define sO_Unblocked "\xd0\xe0\xe7\xe1\xeb\xee\xea\xe8\xf0\xee\xe2\xe0\xed" // "Разблокирован" #define sO_Unfolded "\xd0\xe0\xe7\xe2\xe5\xf0\xed\xf3\xf2" // "Развернут" #define sO_Jawcrucnher "\xd0\xee\xf2\xee\xf5\xf0\xf3\xf1" // "Ротохрус" @@ -197,16 +201,16 @@ namespace Fullpipe { #define sO_Sugar "\xd1\xe0\xf5\xe0\xf0\xee\xea" // "Сахарок" #define sO_Convoluted "\xd1\xe2\xe5\xf0\xed\xf3\xf2" // "Свернут" #define sO_IsFree "\xd1\xe2\xee\xe1\xee\xe4\xed\xe0" // "Свободна" -#define sO_Sitting "\xd1\xe8\xe4\xe8\xf2" // "Сидит" +#define sO_IsSitting "\xd1\xe8\xe4\xe8\xf2" // "Сидит" #define sO_Laughing "\xd1\xec\xe5\xe5\xf2\xf1\xff" // "Смеется" #define sO_WithEveryone "\xd1\xee \xe2\xf1\xe5\xec\xe8" // "Со всеми" #define sO_WithMop "\xd1\xee \xf8\xe2\xe0\xe1\xf0\xee\xe9" // "Со шваброй" #define sO_WithHose "\xd1\xee \xf8\xeb\xe0\xed\xe3\xee\xec" // "Со шлангом" #define sO_WithBrush "\xd1\xee \xf9\xe5\xf2\xea\xee\xe9" // "Со щеткой" -#define sO_Sleeping "\xd1\xef\xe8\xf2" // "Спит" +#define sO_IsSleeping "\xd1\xef\xe8\xf2" // "Спит" #define sO_OnRight "\xd1\xef\xf0\xe0\xe2\xe0" // "Справа" -#define sO_StandsInBoots "\xd1\xf2\xee\xe8\xf2 \xe2 \xe1\xee\xf2\xe8\xed\xea\xe0\xf5" // "Стоит в ботинках" -#define sO_StandsInCorner "\xd1\xf2\xee\xe8\xf2 \xe2 \xf3\xe3\xeb\xf3" // "Стоит в углу" +#define sO_IsStandingInBoots "\xd1\xf2\xee\xe8\xf2 \xe2 \xe1\xee\xf2\xe8\xed\xea\xe0\xf5" // "Стоит в ботинках" +#define sO_IsStandingInCorner "\xd1\xf2\xee\xe8\xf2 \xe2 \xf3\xe3\xeb\xf3" // "Стоит в углу" #define sO_Guardian "\xd1\xf2\xee\xf0\xee\xe6" // "Сторож" #define sO_Guard_1 "\xd1\xf2\xf0\xe0\xe6 1" // "Страж 1" #define sO_Gurad_2 "\xd1\xf2\xf0\xe0\xe6 2" // "Страж 2" @@ -222,11 +226,11 @@ namespace Fullpipe { #define sO_NearPipe "\xd3 \xf2\xf0\xf3\xe1\xfb" // "У трубы" #define sO_Janitors "\xd3\xe1\xee\xf0\xf9\xe8\xea\xe8" // "Уборщики" #define sO_Janitress "\xd3\xe1\xee\xf0\xf9\xe8\xf6\xe0" // "Уборщица" -#define sO_Gone "\xd3\xe5\xf5\xe0\xeb\xe0" // "Уехала" +#define sO_IsGone "\xd3\xe5\xf5\xe0\xeb\xe0" // "Уехала" #define sO_FallenOnce "\xd3\xef\xe0\xeb \xf0\xe0\xe7" // "Упал раз" #define sO_FallenBrush "\xd3\xef\xe0\xeb\xe0 \xf9\xe5\xf2\xea\xe0" // "Упала щетка" #define sO_NotBroken "\xd6\xe5\xeb\xe0" // "Цела" -#define sO_ScratchingBelly "\xd7\xe5\xf8\xe5\xf2 \xef\xf3\xe7\xee" // "Чешет пузо" +#define sO_IsScratchingBelly "\xd7\xe5\xf8\xe5\xf2 \xef\xf3\xe7\xee" // "Чешет пузо" #define sO_Level0 "\xdd\xf2\xe0\xe6 0" // "Этаж 0" #define sO_Level1 "\xdd\xf2\xe0\xe6 1" // "Этаж 1" #define sO_Level2 "\xdd\xf2\xe0\xe6 2" // "Этаж 2" diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp index a5a286cfcb..558a90978a 100644 --- a/engines/fullpipe/scene.cpp +++ b/engines/fullpipe/scene.cpp @@ -114,7 +114,7 @@ void SceneTag::loadScene() { delete file; - g_fullpipe->_currArchive = 0; + g_fp->_currArchive = 0; free(fname); free(archname); @@ -146,7 +146,7 @@ bool Scene::load(MfcArchive &file) { int aniNum = file.readUint16LE(); char *aniname = genFileName(0, aniNum, "ani"); - Common::SeekableReadStream *f = g_fullpipe->_currArchive->createReadStreamForMember(aniname); + Common::SeekableReadStream *f = g_fp->_currArchive->createReadStreamForMember(aniname); StaticANIObject *ani = new StaticANIObject(); @@ -168,7 +168,7 @@ bool Scene::load(MfcArchive &file) { int qNum = file.readUint16LE(); char *qname = genFileName(0, qNum, "qu"); - Common::SeekableReadStream *f = g_fullpipe->_currArchive->createReadStreamForMember(qname); + Common::SeekableReadStream *f = g_fp->_currArchive->createReadStreamForMember(qname); MfcArchive archive(f); archive.readUint16LE(); // Skip 2 bytes @@ -191,7 +191,7 @@ bool Scene::load(MfcArchive &file) { assert(0); } - _libHandle = g_fullpipe->_currArchive; + _libHandle = g_fp->_currArchive; if (_picObjList.size() > 0 && _bgname && strlen(_bgname) > 1) { char fname[260]; @@ -216,10 +216,10 @@ bool Scene::load(MfcArchive &file) { char *slsname = genFileName(0, _sceneId, "sls"); - if (g_fullpipe->_soundEnabled) { + if (g_fp->_soundEnabled) { _soundList = new SoundList(); - if (g_fullpipe->_flgSoundList) { + if (g_fp->_flgSoundList) { char *nlname = genFileName(17, _sceneId, "nl"); _soundList->loadFile(slsname, nlname); @@ -249,7 +249,7 @@ void Scene::init() { _x = 0; _y = 0; - g_fullpipe->_sceneRect.moveTo(0, 0); + g_fp->_sceneRect.moveTo(0, 0); for (uint i = 0; i < _picObjList.size(); i++) ((PictureObject *)_picObjList[i])->clearFlags(); @@ -398,7 +398,7 @@ void Scene::preloadMovements(GameVar *var) { } void Scene::initObjectCursors(const char *varname) { - GameVar *cursorsVar = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(varname)->getSubVarByName("CURSORS"); + GameVar *cursorsVar = g_fp->getGameLoaderGameVar()->getSubVarByName(varname)->getSubVarByName("CURSORS"); if (!cursorsVar || !cursorsVar->_subVars) return; @@ -417,10 +417,10 @@ void Scene::initObjectCursors(const char *varname) { } } - g_fullpipe->_minCursorId = minId; - g_fullpipe->_maxCursorId = maxId; + g_fp->_minCursorId = minId; + g_fp->_maxCursorId = maxId; - g_fullpipe->_objectIdCursors.resize(maxId - minId + 1); + g_fp->_objectIdCursors.resize(maxId - minId + 1); for (GameVar *sub = cursorsVar->_subVars; sub; sub = sub->_nextVarObj) { GameObject *obj = getPictureObjectByName(sub->_varName, -1); @@ -431,7 +431,7 @@ void Scene::initObjectCursors(const char *varname) { PictureObject *pic = getGameLoaderInventory()->getScene()->getPictureObjectByName(sub->_value.stringValue, -1); if (obj && pic) - g_fullpipe->_objectIdCursors[obj->_id - minId] = pic->_id; + g_fp->_objectIdCursors[obj->_id - minId] = pic->_id; } } @@ -451,7 +451,7 @@ void Scene::draw() { updateScrolling(); // Clean previous stuff - g_fullpipe->_backgroundSurface.fillRect(Common::Rect(0, 0, 800, 600), 0); + g_fp->_backgroundSurface.fillRect(Common::Rect(0, 0, 800, 600), 0); drawContent(60000, 0, true); @@ -474,7 +474,7 @@ void Scene::draw() { void Scene::updateScrolling() { if (_messageQueueId && !_x && !_y) { - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(_messageQueueId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(_messageQueueId); if (mq) mq->update(); @@ -487,31 +487,31 @@ void Scene::updateScrolling() { int offsetY = 0; if (_x < 0) { - if (!g_fullpipe->_sceneRect.left && !(((PictureObject *)_picObjList[0])->_flags & 2)) + if (!g_fp->_sceneRect.left && !(((PictureObject *)_picObjList[0])->_flags & 2)) _x = 0; - if (_x <= -g_fullpipe->_scrollSpeed) { - offsetX = -g_fullpipe->_scrollSpeed; - _x += g_fullpipe->_scrollSpeed; + if (_x <= -g_fp->_scrollSpeed) { + offsetX = -g_fp->_scrollSpeed; + _x += g_fp->_scrollSpeed; } - } else if (_x >= g_fullpipe->_scrollSpeed) { - offsetX = g_fullpipe->_scrollSpeed; - _x -= g_fullpipe->_scrollSpeed; + } else if (_x >= g_fp->_scrollSpeed) { + offsetX = g_fp->_scrollSpeed; + _x -= g_fp->_scrollSpeed; } else { _x = 0; } if (_y > 0) { - offsetY = g_fullpipe->_scrollSpeed; - _y -= g_fullpipe->_scrollSpeed; + offsetY = g_fp->_scrollSpeed; + _y -= g_fp->_scrollSpeed; } if (_y < 0) { - offsetY -= g_fullpipe->_scrollSpeed; - _y += g_fullpipe->_scrollSpeed; + offsetY -= g_fp->_scrollSpeed; + _y += g_fp->_scrollSpeed; } - g_fullpipe->_sceneRect.translate(offsetX, offsetY); + g_fp->_sceneRect.translate(offsetX, offsetY); } updateScrolling2(); @@ -527,19 +527,19 @@ void Scene::updateScrolling2() { int flags = ((PictureObject *)_picObjList[0])->_flags; - if (g_fullpipe->_sceneRect.left < 0 && !(flags & 2)) - offsetX = -g_fullpipe->_sceneRect.left; + if (g_fp->_sceneRect.left < 0 && !(flags & 2)) + offsetX = -g_fp->_sceneRect.left; - if (g_fullpipe->_sceneRect.top < 0 && !(flags & 0x20)) - offsetY = -g_fullpipe->_sceneRect.top; + if (g_fp->_sceneRect.top < 0 && !(flags & 0x20)) + offsetY = -g_fp->_sceneRect.top; - if (g_fullpipe->_sceneRect.right > point.x - 1 && g_fullpipe->_sceneRect.left > 0 && !(flags & 2)) - offsetX = point.x - g_fullpipe->_sceneRect.right - 1; + if (g_fp->_sceneRect.right > point.x - 1 && g_fp->_sceneRect.left > 0 && !(flags & 2)) + offsetX = point.x - g_fp->_sceneRect.right - 1; - if (g_fullpipe->_sceneRect.bottom > point.y - 1 && g_fullpipe->_sceneRect.top > 0 && !(flags & 0x20)) - offsetY = point.y - g_fullpipe->_sceneRect.bottom - 1; + if (g_fp->_sceneRect.bottom > point.y - 1 && g_fp->_sceneRect.top > 0 && !(flags & 0x20)) + offsetY = point.y - g_fp->_sceneRect.bottom - 1; - g_fullpipe->_sceneRect.translate(offsetX, offsetY); + g_fp->_sceneRect.translate(offsetX, offsetY); } } @@ -602,7 +602,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { return; if (_palette) { - g_fullpipe->_globalPalette = _palette->_data; + g_fp->_globalPalette = _palette->_data; } debug(8, "Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg); @@ -635,7 +635,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { debug(8, "w2: %d h2:%d", point.x, point.y); - int bgStX = g_fullpipe->_sceneRect.left % point.x; + int bgStX = g_fp->_sceneRect.left % point.x; if (bgStX < 0) bgStX += point.x; @@ -643,7 +643,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { int bgNumX = bgStX / width; int bgOffsetX = bgStX % width; - int bgStY = g_fullpipe->_sceneRect.top % point.y; + int bgStY = g_fp->_sceneRect.top % point.y; if (bgStY < 0) bgStY += point.y; @@ -651,12 +651,12 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { int bgNumY = bgStY / height; int bgOffsetY = bgStY % height; - int bgPosX = g_fullpipe->_sceneRect.left - bgOffsetX; + int bgPosX = g_fp->_sceneRect.left - bgOffsetX; - if (bgPosX < g_fullpipe->_sceneRect.right - 1) { + if (bgPosX < g_fp->_sceneRect.right - 1) { while (1) { int v25 = bgNumY; - for (int y = g_fullpipe->_sceneRect.top - bgOffsetY; y < g_fullpipe->_sceneRect.bottom - 1;) { + for (int y = g_fp->_sceneRect.top - bgOffsetY; y < g_fp->_sceneRect.bottom - 1;) { BigPicture *v27 = _bigPictureArray[bgNumX][v25]; v27->draw(bgPosX, y, 0, 0); y += v27->getDimensions(&point)->y; @@ -678,7 +678,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { break; bgNumX = 0; } - if (oldx >= g_fullpipe->_sceneRect.right - 1) + if (oldx >= g_fp->_sceneRect.right - 1) break; } } @@ -703,22 +703,22 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { int height = point.y; if (obj->_flags & 8) { - while (objX > g_fullpipe->_sceneRect.right) { + while (objX > g_fp->_sceneRect.right) { objX -= width; obj->setOXY(objX, objY); } - for (int j = width + objX; width + objX < g_fullpipe->_sceneRect.left; j = width + objX) { + for (int j = width + objX; width + objX < g_fp->_sceneRect.left; j = width + objX) { objX = j; obj->setOXY(j, objY); } } if (obj->_flags & 0x10) { - while (objY > g_fullpipe->_sceneRect.bottom) { + while (objY > g_fp->_sceneRect.bottom) { objY -= height; obj->setOXY(objX, objY); } - for (int j = objY + height; objY + height < g_fullpipe->_sceneRect.top; j = objY + height) { + for (int j = objY + height; objY + height < g_fp->_sceneRect.top; j = objY + height) { objY = j; obj->setOXY(objX, j); } @@ -727,12 +727,12 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { obj->draw(); if (obj->_flags & 2) { - if (objX > g_fullpipe->_sceneRect.left) { + if (objX > g_fp->_sceneRect.left) { obj->setOXY(objX - width, objY); obj->draw(); obj->setOXY(objX, objY); } - if (width + objX < g_fullpipe->_sceneRect.right) { + if (width + objX < g_fp->_sceneRect.right) { obj->setOXY(width + objX, objY); obj->draw(); obj->setOXY(objX, objY); @@ -740,12 +740,12 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { } if (obj->_flags & 0x20) { - if (objY > g_fullpipe->_sceneRect.top) { + if (objY > g_fp->_sceneRect.top) { obj->setOXY(objX, objY - height); obj->draw(); obj->setOXY(objX, objY); } - if (height + objY < g_fullpipe->_sceneRect.bottom) { + if (height + objY < g_fp->_sceneRect.bottom) { obj->setOXY(objX, height + objY); obj->draw(); obj->setOXY(objX, objY); diff --git a/engines/fullpipe/scenes.cpp b/engines/fullpipe/scenes.cpp index 37d1250ae0..96d9cba54f 100644 --- a/engines/fullpipe/scenes.cpp +++ b/engines/fullpipe/scenes.cpp @@ -80,29 +80,120 @@ Vars::Vars() { scene04_dudePosX = 0; scene04_dudePosY = 0; - scene04_var02 = 0; - scene04_var04 = 0; + scene04_bottleIsTaken = false; + scene04_kozyawkaOnLadder = false; scene04_walkingKozyawka = 0; scene04_bottleWeight = 0; - scene04_var07 = 0; - scene04_var08 = 0; - scene04_var09 = 0; - scene04_var10 = 0; - scene04_var11 = 0; - scene04_var12 = 0; - scene04_var13 = 0; - scene04_var14 = 0; - scene04_var15 = 0; + scene04_var07 = false; + scene04_ladderClickable = false; + scene04_handIsDown = false; + scene04_dudeInBottle = false; + scene04_kozHeadRaised = false; + scene04_bottleIsDropped = false; + scene04_bigBallIn = false; + scene04_bigBallCounter = 0; + scene04_bigBallFromLeft = false; scene04_speakerVariant = 0; scene04_speakerPhase = 0; - scene04_var18 = 0; - scene04_var19 = 0; - scene04_var20 = 0; - scene04_var24 = 0; - scene04_var25 = 0; + scene04_clockCanGo = false; + scene04_objectIsTaken = false; + scene04_springOffset = 0; + scene04_lastKozyawka = 0; + scene04_springDelay = 0; scene04_bottleY = 0; scene04_ladderOffset = 0; + scene05_handle = 0; + scene05_wacko = 0; + scene05_bigHatch = 0; + scene05_wackoTicker = 0; + scene05_handleFlipper = 0; + scene05_floatersTicker = 0; + + scene06_manX = 0; + scene06_manY = 0; + scene06_ballX = 0; + scene06_ballY = 0; + scene06_mumsy = 0; + scene06_someBall = 0; + scene06_invHandle = 0; + scene06_liftButton = 0; + scene06_ballDrop = 0; + scene06_arcadeEnabled = false; + scene06_aimingBall = false; + scene06_currentBall = 0; + scene06_ballInHands = 0; + scene06_flyingBall = 0; + scene06_numBallsGiven = 0; + scene06_mumsyNumBalls = 0; + scene06_eggieTimeout = 0; + scene06_eggieDirection = true; + scene06_mumsyGotBall = 0; + scene06_ballDeltaX = 0; + scene06_ballDeltaY = 0; + scene06_sceneClickX = 0; + scene06_sceneClickY = 0; + scene06_mumsyPos = 0; + scene06_mumsyJumpBk = 0; + scene06_mumsyJumpFw = 0; + scene06_mumsyJumpBkPercent = 0; + scene06_mumsyJumpFwPercent = 0; + + scene07_lukeAnim = 0; + scene07_lukePercent = 0; + scene07_plusMinus = 0; + + scene08_batuta = 0; + scene08_vmyats = 0; + scene08_clock = 0; + scene08_inAir = false; + scene08_flyingUp = false; + scene08_onBelly = false; + scene08_stairsOffset = -37; + scene08_snoringCountdown = -1; + scene08_inArcade = false; + scene08_stairsVisible = true; + scene08_manOffsetY = 0; + + scene10_gum = 0; + scene10_packet = 0; + scene10_packet2 = 0; + scene10_inflater = 0; + scene10_ladder = 0; + scene10_hasGum = 0; + + scene11_swingie = 0; + scene11_boots = 0; + scene11_dudeOnSwing = 0; + scene11_hint = 0; + scene11_var02 = 0; + scene11_var03 = 0; + scene11_var04 = 0; + scene11_var05 = 0; + scene11_var06 = 0; + scene11_var07 = 0; + scene11_var08 = 1.0; + scene11_var09 = 1.0; + scene11_var10 = 1.0; + scene11_var11 = 1.0; + scene11_var12 = 0.0; + scene11_var13 = 0; + scene11_var14 = 0; + scene11_var15 = 0; + scene11_var16 = 0; + scene11_var17 = 0; + scene11_var18 = 0; + scene11_var19 = 0; + scene11_var20 = 0; + + scene12_fly = 0; + scene12_flyCountdown = 0; + + scene15_chantingCountdown = 0; + scene15_plusminus = 0; + scene15_ladder = 0; + scene15_boot = 0; + selector = 0; } @@ -123,6 +214,15 @@ int FullpipeEngine::convertScene(int scene) { return scenes[scene - 1]; } +int FullpipeEngine::getSceneFromTag(int tag) { + for (int i = 0; i < ARRAYSIZE(scenes); i++) { + if (scenes[i] == tag) + return i + 1; + } + + return 1; +} + bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { GameVar *sceneVar; Common::Point sceneDim; @@ -265,7 +365,6 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _updateCursorCallback = scene04_updateCursor; break; -#if 0 case SC_5: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_5"); scene->preloadMovements(sceneVar); @@ -284,7 +383,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _behaviorManager->initBehavior(scene, sceneVar); scene->initObjectCursors("SC_6"); setSceneMusicParameters(sceneVar); - sub_415300(); + scene06_initMumsy(); insertMessageHandler(sceneHandler06, 2, 2); _updateCursorCallback = scene06_updateCursor; break; @@ -307,11 +406,12 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _behaviorManager->initBehavior(scene, sceneVar); scene->initObjectCursors("SC_8"); setSceneMusicParameters(sceneVar); - sub_416890(); + scene08_setupMusic(); addMessageHandler(sceneHandler08, 2); _updateCursorCallback = scene08_updateCursor; break; +#if 0 case SC_9: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_9"); scene->preloadMovements(sceneVar); @@ -322,6 +422,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { insertMessageHandler(sceneHandler09, 2, 2); _updateCursorCallback = scene09_updateCursor; break; +#endif case SC_10: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_10"); @@ -334,6 +435,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _updateCursorCallback = scene10_updateCursor; break; +#if 0 case SC_11: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_11"); scene->preloadMovements(sceneVar); @@ -342,9 +444,10 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { scene->initObjectCursors("SC_11"); setSceneMusicParameters(sceneVar); insertMessageHandler(sceneHandler11, 2, 2); - scene11_sub_41A980(); + scene11_setupMusic(); _updateCursorCallback = scene11_updateCursor; break; +#endif case SC_12: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_12"); @@ -357,6 +460,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _updateCursorCallback = defaultUpdateCursor; break; +#if 0 case SC_13: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_13"); scene->preloadMovements(sceneVar); @@ -379,6 +483,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { scene14_sub_41D2B0(); _updateCursorCallback = scene14_updateCursor; break; +#endif case SC_15: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_15"); @@ -391,6 +496,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _updateCursorCallback = scene15_updateCursor; break; +#if 0 case SC_16: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_16"); scene->preloadMovements(sceneVar); @@ -695,6 +801,8 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { default: _behaviorManager->initBehavior(0, 0); + + error("Unknown scene %d", entrance->_sceneId); break; } @@ -702,29 +810,9 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { } int defaultUpdateCursor() { - g_fullpipe->updateCursorCommon(); - - return g_fullpipe->_cursorId; -} - -void FullpipeEngine::initArcadeKeys(const char *varname) { - GameVar *var = getGameLoaderGameVar()->getSubVarByName(varname)->getSubVarByName("KEYPOS"); - - if (!var) - return; + g_fp->updateCursorCommon(); - int cnt = var->getSubVarsCount(); - - for (int i = 0; i < cnt; i++) { - Common::Point *point = new Common::Point; - - GameVar *sub = var->getSubVarByIndex(i); - - point->x = sub->getSubVarAsInt("X"); - point->y = sub->getSubVarAsInt("Y"); - - _arcadeKeys.push_back(point); - } + return g_fp->_cursorId; } void FullpipeEngine::processArcade(ExCommand *ex) { diff --git a/engines/fullpipe/scenes.h b/engines/fullpipe/scenes.h index 38f685e82a..270c2038b0 100644 --- a/engines/fullpipe/scenes.h +++ b/engines/fullpipe/scenes.h @@ -25,8 +25,10 @@ namespace Fullpipe { +struct BehaviorEntryInfo; class StaticANIObject; - class MctlLadder; +class MctlLadder; +class MGM; int defaultUpdateCursor(); @@ -50,6 +52,33 @@ int scene04_updateCursor(); void scene04_initScene(Scene *sc); int sceneHandler04(ExCommand *cmd); +void scene05_initScene(Scene *sc); +int sceneHandler05(ExCommand *cmd); + +void scene06_initScene(Scene *sc); +void scene06_initMumsy(); +int sceneHandler06(ExCommand *cmd); +int scene06_updateCursor(); + +void scene07_initScene(Scene *sc); +int sceneHandler07(ExCommand *cmd); + +void scene08_initScene(Scene *sc); +void scene08_setupMusic(); +int sceneHandler08(ExCommand *cmd); +int scene08_updateCursor(); + +void scene10_initScene(Scene *sc); +int sceneHandler10(ExCommand *cmd); +int scene10_updateCursor(); + +void scene12_initScene(Scene *sc); +int sceneHandler12(ExCommand *ex); + +int scene15_updateCursor(); +void scene15_initScene(Scene *sc); +int sceneHandler15(ExCommand *cmd); + void sceneDbgMenu_initScene(Scene *sc); int sceneHandlerDbgMenu(ExCommand *cmd); @@ -113,23 +142,116 @@ public: int scene04_speakerVariant; int scene04_speakerPhase; - int scene04_var02; - int scene04_var04; + bool scene04_bottleIsTaken; + bool scene04_kozyawkaOnLadder; int scene04_bottleWeight; - int scene04_var07; - int scene04_var08; - int scene04_var09; - int scene04_var10; - int scene04_var11; - int scene04_var12; - int scene04_var13; - int scene04_var14; - int scene04_var15; - int scene04_var18; - int scene04_var19; - int scene04_var20; - StaticANIObject *scene04_var24; - int scene04_var25; + bool scene04_var07; + bool scene04_ladderClickable; + bool scene04_handIsDown; + bool scene04_dudeInBottle; + bool scene04_kozHeadRaised; + bool scene04_bottleIsDropped; + bool scene04_bigBallIn; + int scene04_bigBallCounter; + bool scene04_bigBallFromLeft; + bool scene04_clockCanGo; + bool scene04_objectIsTaken; + int scene04_springOffset; + StaticANIObject *scene04_lastKozyawka; + int scene04_springDelay; + + StaticANIObject *scene05_handle; + StaticANIObject *scene05_wacko; + StaticANIObject *scene05_bigHatch; + int scene05_wackoTicker; + int scene05_handleFlipper; + int scene05_floatersTicker; + + StaticANIObject *scene06_mumsy; + int scene06_manX; + int scene06_manY; + int scene06_ballX; + int scene06_ballY; + StaticANIObject *scene06_someBall; + StaticANIObject *scene06_invHandle; + StaticANIObject *scene06_liftButton; + StaticANIObject *scene06_ballDrop; + bool scene06_arcadeEnabled; + bool scene06_aimingBall; + StaticANIObject *scene06_currentBall; + StaticANIObject *scene06_ballInHands; + StaticANIObject *scene06_flyingBall; + Common::Array<StaticANIObject *> scene06_balls; + int scene06_numBallsGiven; + int scene06_mumsyNumBalls; + int scene06_eggieTimeout; + int scene06_eggieDirection; + int scene06_mumsyGotBall; + int scene06_ballDeltaX; + int scene06_ballDeltaY; + int scene06_sceneClickX; + int scene06_sceneClickY; + int scene06_mumsyPos; + BehaviorEntryInfo *scene06_mumsyJumpBk; + BehaviorEntryInfo *scene06_mumsyJumpFw; + int scene06_mumsyJumpBkPercent; + int scene06_mumsyJumpFwPercent; + + BehaviorEntryInfo *scene07_lukeAnim; + int scene07_lukePercent; + StaticANIObject *scene07_plusMinus; + + StaticANIObject *scene08_batuta; + StaticANIObject *scene08_vmyats; + StaticANIObject *scene08_clock; + bool scene08_inAir; + bool scene08_flyingUp; + int scene08_onBelly; + int scene08_stairsOffset; + int scene08_snoringCountdown; + bool scene08_inArcade; + bool scene08_stairsVisible; + int scene08_manOffsetY; + + StaticANIObject *scene10_gum; + StaticANIObject *scene10_packet; + StaticANIObject *scene10_packet2; + StaticANIObject *scene10_inflater; + PictureObject *scene10_ladder; + int scene10_hasGum; + + StaticANIObject *scene11_swingie; + StaticANIObject *scene11_boots; + StaticANIObject *scene11_dudeOnSwing; + PictureObject *scene11_hint; + MGM scene11_var01; + int scene11_var02; + int scene11_var03; + int scene11_var04; + int scene11_var05; + int scene11_var06; + int scene11_var07; + double scene11_var08; + double scene11_var09; + double scene11_var10; + double scene11_var11; + double scene11_var12; + int scene11_var13; + int scene11_var14; + int scene11_var15; + int scene11_var16; + int scene11_var17; + int scene11_var18; + int scene11_var19; + int scene11_var20; + + int scene12_fly; + int scene12_flyCountdown; + + int scene15_chantingCountdown; + StaticANIObject *scene15_plusminus; + PictureObject *scene15_ladder; + StaticANIObject *scene15_boot; PictureObject *selector; }; diff --git a/engines/fullpipe/scenes/scene01.cpp b/engines/fullpipe/scenes/scene01.cpp index 4181bbffe3..6c8f26d209 100644 --- a/engines/fullpipe/scenes/scene01.cpp +++ b/engines/fullpipe/scenes/scene01.cpp @@ -26,6 +26,7 @@ #include "fullpipe/constants.h" #include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/statics.h" @@ -36,7 +37,7 @@ namespace Fullpipe { void scene01_fixEntrance() { - GameVar *var = g_fullpipe->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME"); + GameVar *var = g_fp->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME"); if (var->getSubVarAsInt("Entrance") == TrubaLeft) var->setSubVarAsInt("Entrance", TrubaRight); } @@ -48,7 +49,7 @@ void scene01_initScene(Scene *sc, int entrance) { g_vars->scene01_picSc01Osk2 = sc->getPictureObjectById(PIC_SC1_OSK2, 0); g_vars->scene01_picSc01Osk2->_flags &= 0xFFFB; - if (g_fullpipe->getObjectState(sO_EggCracker) == g_fullpipe->getObjectEnumState(sO_EggCracker, sO_DidNotCrackEgg)) { + if (g_fp->getObjectState(sO_EggCracker) == g_fp->getObjectEnumState(sO_EggCracker, sO_DidNotCrackEgg)) { PictureObject *pic = sc->getPictureObjectById(PIC_SC1_KUCHKA, 0); if (pic) pic->_flags &= 0xFFFB; @@ -60,7 +61,7 @@ void scene01_initScene(Scene *sc, int entrance) { bootAnim->_flags &= ~0x04; } - g_fullpipe->lift_setButton(sO_Level2, ST_LBN_2N); + g_fp->lift_setButton(sO_Level2, ST_LBN_2N); } int sceneHandler01(ExCommand *cmd) { @@ -71,7 +72,7 @@ int sceneHandler01(ExCommand *cmd) { if (cmd->_messageNum > MSG_SC1_SHOWOSK) { if (cmd->_messageNum == MSG_SC1_UTRUBACLICK) - handleObjectInteraction(g_fullpipe->_aniMan, g_fullpipe->_currentScene->getPictureObjectById(PIC_SC1_LADDER, 0), 0); + handleObjectInteraction(g_fp->_aniMan, g_fp->_currentScene->getPictureObjectById(PIC_SC1_LADDER, 0), 0); return 0; } @@ -97,19 +98,19 @@ int sceneHandler01(ExCommand *cmd) { return 0; } - if (g_fullpipe->_aniMan2) { - if (g_fullpipe->_aniMan2->_ox < g_fullpipe->_sceneRect.left + 200) { - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan2->_ox - g_fullpipe->_sceneRect.left - 300; + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) { + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; } - if (g_fullpipe->_aniMan2->_ox > g_fullpipe->_sceneRect.right - 200) - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan2->_ox - g_fullpipe->_sceneRect.right + 300; + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; res = 1; } - g_fullpipe->_behaviorManager->updateBehaviors(); + g_fp->_behaviorManager->updateBehaviors(); - g_fullpipe->startSceneTrack(); + g_fp->startSceneTrack(); return res; } diff --git a/engines/fullpipe/scenes/scene02.cpp b/engines/fullpipe/scenes/scene02.cpp index dd01af4c4b..95cf1df7dd 100644 --- a/engines/fullpipe/scenes/scene02.cpp +++ b/engines/fullpipe/scenes/scene02.cpp @@ -26,6 +26,7 @@ #include "fullpipe/constants.h" #include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/statics.h" @@ -39,12 +40,12 @@ namespace Fullpipe { void scene02_initScene(Scene *sc) { g_vars->scene02_guvTheDrawer = sc->getStaticANIObject1ById(ANI_DADAYASHIK, -1); - if (g_fullpipe->getObjectState(sO_GuvTheDrawer) == g_fullpipe->getObjectEnumState(sO_GuvTheDrawer, sO_Sleeping)) { - Scene *s = g_fullpipe->_currentScene; + if (g_fp->getObjectState(sO_GuvTheDrawer) == g_fp->getObjectEnumState(sO_GuvTheDrawer, sO_IsSleeping)) { + Scene *s = g_fp->_currentScene; - g_fullpipe->_currentScene = sc; + g_fp->_currentScene = sc; g_vars->scene02_guvTheDrawer->changeStatics2(ST_DYAS_LIES); - g_fullpipe->_currentScene = s; + g_fp->_currentScene = s; } g_vars->scene02_boxDelay = 0; @@ -55,23 +56,23 @@ void scene02_initScene(Scene *sc) { g_vars->scene02_boxOpen = false; } else { g_vars->scene02_boxOpen = true; - g_vars->scene02_boxDelay = 100 * g_fullpipe->_rnd->getRandomNumber(32767) + 150; + g_vars->scene02_boxDelay = 100 * g_fp->_rnd->getRandomNumber(32767) + 150; } - g_fullpipe->_floaters->init(g_fullpipe->_gameLoader->_gameVar->getSubVarByName("SC_2")); + g_fp->_floaters->init(g_fp->_gameLoader->_gameVar->getSubVarByName("SC_2")); } void sceneHandler02_ladderClick() { - handleObjectInteraction(g_fullpipe->_aniMan2, g_fullpipe->_currentScene->getPictureObjectById(PIC_SC2_DTRUBA, 0), 0); + handleObjectInteraction(g_fp->_aniMan2, g_fp->_currentScene->getPictureObjectById(PIC_SC2_DTRUBA, 0), 0); } void sceneHandler02_showLadder() { - g_fullpipe->_currentScene->getPictureObjectById(PIC_SC2_LADDER, 0)->_flags |= 4; + g_fp->_currentScene->getPictureObjectById(PIC_SC2_LADDER, 0)->_flags |= 4; } void sceneHandler02_hideLadder() { - g_fullpipe->_currentScene->getPictureObjectById(PIC_SC2_LADDER, 0)->_flags &= 0xfffb; - g_fullpipe->_aniMan2->_priority = 25; + g_fp->_currentScene->getPictureObjectById(PIC_SC2_LADDER, 0)->_flags &= 0xfffb; + g_fp->_aniMan2->_priority = 25; } int sceneHandler02(ExCommand *ex) { @@ -90,7 +91,7 @@ int sceneHandler02(ExCommand *ex) { return 0; case MSG_SC2_PUTMANUP: - g_fullpipe->_aniMan2->_priority = 0; + g_fp->_aniMan2->_priority = 0; return 0; case MSG_SC2_HIDELADDER: @@ -98,12 +99,12 @@ int sceneHandler02(ExCommand *ex) { return 0; case 33: - if (g_fullpipe->_aniMan2) { - if (g_fullpipe->_aniMan2->_ox < g_fullpipe->_sceneRect.left + 200) - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan2->_ox - g_fullpipe->_sceneRect.left - 300; + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; - if (g_fullpipe->_aniMan2->_ox > g_fullpipe->_sceneRect.right - 200) - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan2->_ox - g_fullpipe->_sceneRect.right + 300; + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; res = 1; } @@ -111,24 +112,24 @@ int sceneHandler02(ExCommand *ex) { if (g_vars->scene02_boxOpen) { if (g_vars->scene02_boxDelay >= 1) { --g_vars->scene02_boxDelay; - } else if (g_fullpipe->_floaters->_array2.size() >= 1) { - if (g_fullpipe->_floaters->_array2[0]->val5 == -50) { - g_fullpipe->_floaters->stopAll(); + } else if (g_fp->_floaters->_array2.size() >= 1) { + if (g_fp->_floaters->_array2[0]->val5 == -50) { + g_fp->_floaters->stopAll(); g_vars->scene02_boxOpen = false; - g_vars->scene02_boxDelay = 100 * g_fullpipe->_rnd->getRandomNumber(32767) + 150; + g_vars->scene02_boxDelay = 100 * g_fp->_rnd->getRandomNumber(32767) + 150; } else { - g_fullpipe->_floaters->_array2[0]->val3 = -50; + g_fp->_floaters->_array2[0]->val3 = -50; } } else { - g_fullpipe->_floaters->genFlies(g_fullpipe->_currentScene, g_fullpipe->_rnd->getRandomNumber(700) + 100, -50, 0, 0); - g_vars->scene02_boxDelay = 500 * g_fullpipe->_rnd->getRandomNumber(32767) + 1000; + g_fp->_floaters->genFlies(g_fp->_currentScene, g_fp->_rnd->getRandomNumber(700) + 100, -50, 0, 0); + g_vars->scene02_boxDelay = 500 * g_fp->_rnd->getRandomNumber(32767) + 1000; } } - g_fullpipe->_floaters->update(); - g_fullpipe->_behaviorManager->updateBehaviors(); + g_fp->_floaters->update(); + g_fp->_behaviorManager->updateBehaviors(); - g_fullpipe->startSceneTrack(); + g_fp->startSceneTrack(); } return res; diff --git a/engines/fullpipe/scenes/scene03.cpp b/engines/fullpipe/scenes/scene03.cpp index 1bfd8b8fcc..40e70e2ea5 100644 --- a/engines/fullpipe/scenes/scene03.cpp +++ b/engines/fullpipe/scenes/scene03.cpp @@ -26,6 +26,7 @@ #include "fullpipe/constants.h" #include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/statics.h" @@ -50,34 +51,34 @@ void scene03_initScene(Scene *sc) { g_vars->scene03_eggeater = sc->getStaticANIObject1ById(ANI_EGGEATER, -1); g_vars->scene03_domino = sc->getStaticANIObject1ById(ANI_DOMINO_3, -1); - GameVar *v = g_fullpipe->_gameLoader->_gameVar->getSubVarByName("OBJSTATES")->getSubVarByName(sO_GulpedEggs); + GameVar *v = g_fp->_gameLoader->_gameVar->getSubVarByName("OBJSTATES")->getSubVarByName(sO_GulpedEggs); g_vars->swallowedEgg1 = v->getSubVarByName(sO_Egg1); g_vars->swallowedEgg2 = v->getSubVarByName(sO_Egg2); g_vars->swallowedEgg3 = v->getSubVarByName(sO_Egg3); - g_fullpipe->lift_setButton(sO_Level2, ST_LBN_2N); + g_fp->lift_setButton(sO_Level2, ST_LBN_2N); - g_fullpipe->lift_sub5(sc, QU_SC3_ENTERLIFT, QU_SC3_EXITLIFT); + g_fp->lift_sub5(sc, QU_SC3_ENTERLIFT, QU_SC3_EXITLIFT); } void scene03_setEaterState() { - if (g_fullpipe->getObjectState(sO_EggGulperGaveCoin) == g_fullpipe->getObjectEnumState(sO_EggGulperGaveCoin, sO_Yes)) { - g_fullpipe->_behaviorManager->setBehaviorEnabled(g_vars->scene03_eggeater, ST_EGTR_SLIM, QU_EGTR_SLIMSHOW, 0); - g_fullpipe->_behaviorManager->setBehaviorEnabled(g_vars->scene03_eggeater, ST_EGTR_MID1, QU_EGTR_MD1_SHOW, 0); - g_fullpipe->_behaviorManager->setBehaviorEnabled(g_vars->scene03_eggeater, ST_EGTR_MID2, QU_EGTR_MD2_SHOW, 0); + if (g_fp->getObjectState(sO_EggGulperGaveCoin) == g_fp->getObjectEnumState(sO_EggGulperGaveCoin, sO_Yes)) { + g_fp->_behaviorManager->setBehaviorEnabled(g_vars->scene03_eggeater, ST_EGTR_SLIM, QU_EGTR_SLIMSHOW, 0); + g_fp->_behaviorManager->setBehaviorEnabled(g_vars->scene03_eggeater, ST_EGTR_MID1, QU_EGTR_MD1_SHOW, 0); + g_fp->_behaviorManager->setBehaviorEnabled(g_vars->scene03_eggeater, ST_EGTR_MID2, QU_EGTR_MD2_SHOW, 0); } } int scene03_updateCursor() { - g_fullpipe->updateCursorCommon(); + g_fp->updateCursorCommon(); - if (g_fullpipe->_cursorId == PIC_CSR_DEFAULT && g_fullpipe->_objectIdAtCursor == PIC_SC3_DOMIN && g_vars->scene03_domino) { + if (g_fp->_cursorId == PIC_CSR_DEFAULT && g_fp->_objectIdAtCursor == PIC_SC3_DOMIN && g_vars->scene03_domino) { if (g_vars->scene03_domino->_flags & 4) - g_fullpipe->_cursorId = PIC_CSR_ITN; + g_fp->_cursorId = PIC_CSR_ITN; } - return g_fullpipe->_cursorId; + return g_fp->_cursorId; } void sceneHandler03_eaterFat() { @@ -94,7 +95,7 @@ void sceneHandler03_swallowEgg(int item) { } else if (!g_vars->swallowedEgg3->_value.intValue) { g_vars->swallowedEgg3->_value.intValue = item; - g_fullpipe->setObjectState(sO_EggGulperGaveCoin, g_fullpipe->getObjectEnumState(sO_EggGulperGaveCoin, sO_Yes)); + g_fp->setObjectState(sO_EggGulperGaveCoin, g_fp->getObjectEnumState(sO_EggGulperGaveCoin, sO_Yes)); scene03_setEaterState(); } @@ -112,7 +113,7 @@ int sceneHandler03_swallowedEgg1State() { } void sceneHandler03_giveCoin(ExCommand *ex) { - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(ex->_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(ex->_parId); if (mq && mq->getCount() > 0) { ExCommand *ex0 = mq->getExCommandByIndex(0); @@ -136,7 +137,7 @@ void sceneHandler03_giveCoin(ExCommand *ex) { } void sceneHandler03_goLadder() { - handleObjectInteraction(g_fullpipe->_aniMan, g_fullpipe->_currentScene->getPictureObjectById(PIC_SC3_LADDER, 0), 0); + handleObjectInteraction(g_fp->_aniMan, g_fp->_currentScene->getPictureObjectById(PIC_SC3_LADDER, 0), 0); } void sceneHandler03_pushEggStack() { @@ -158,7 +159,7 @@ void sceneHandler03_releaseEgg() { } void sceneHandler03_takeEgg(ExCommand *ex) { - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(ex->_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(ex->_parId); if (mq && mq->getCount() > 0) { ExCommand *ex0 = mq->getExCommandByIndex(0); @@ -179,7 +180,7 @@ void sceneHandler03_takeEgg(ExCommand *ex) { if (ex1->_objtype == kObjTypeObjstateCommand) { ObjstateCommand *com = (ObjstateCommand *)ex1; - com->_value = g_fullpipe->getObjectEnumState(sO_EggGulper, sO_WantsNothing); + com->_value = g_fp->getObjectEnumState(sO_EggGulper, sO_WantsNothing); } } } @@ -194,11 +195,11 @@ int sceneHandler03(ExCommand *ex) { switch (ex->_messageNum) { case MSG_LIFT_EXITLIFT: - g_fullpipe->lift_exitSeq(ex); + g_fp->lift_exitSeq(ex); break; case MSG_LIFT_CLOSEDOOR: - g_fullpipe->lift_closedoorSeq(); + g_fp->lift_closedoorSeq(); break; case MSG_SC3_ONTAKECOIN: @@ -206,7 +207,7 @@ int sceneHandler03(ExCommand *ex) { break; case MSG_LIFT_STARTEXITQUEUE: - g_fullpipe->lift_startExitQueue(); + g_fp->lift_startExitQueue(); break; case MSG_SC3_RELEASEEGG: @@ -214,7 +215,7 @@ int sceneHandler03(ExCommand *ex) { break; case MSG_LIFT_CLICKBUTTON: - g_fullpipe->lift_animation3(); + g_fp->lift_animation3(); break; case MSG_SC3_HIDEDOMINO: @@ -226,7 +227,7 @@ int sceneHandler03(ExCommand *ex) { break; case MSG_LIFT_GO: - g_fullpipe->lift_goAnimation(); + g_fp->lift_goAnimation(); break; case MSG_SC3_UTRUBACLICK: @@ -238,25 +239,25 @@ int sceneHandler03(ExCommand *ex) { break; case 64: - g_fullpipe->lift_sub05(ex); + g_fp->lift_sub05(ex); break; case 29: { - StaticANIObject *ani = g_fullpipe->_currentScene->getStaticANIObjectAtPos(ex->_sceneClickX, ex->_sceneClickY); + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObjectAtPos(ex->_sceneClickX, ex->_sceneClickY); if (ani && ani->_id == ANI_LIFTBUTTON) { - g_fullpipe->lift_sub1(ani); + g_fp->lift_sub1(ani); ex->_messageKind = 0; return 0; } - if (g_fullpipe->_currentScene->getPictureObjectIdAtPos(ex->_sceneClickX, ex->_sceneClickY) == PIC_SC3_DOMIN) { + if (g_fp->_currentScene->getPictureObjectIdAtPos(ex->_sceneClickX, ex->_sceneClickY) == PIC_SC3_DOMIN) { if (g_vars->scene03_domino) if (g_vars->scene03_domino->_flags & 4) - if (g_fullpipe->_aniMan->isIdle()) - if (!(g_fullpipe->_aniMan->_flags & 0x100) && g_fullpipe->_msgObjectId2 != g_vars->scene03_domino->_id) { - handleObjectInteraction(g_fullpipe->_aniMan, g_vars->scene03_domino, ex->_keyCode); + if (g_fp->_aniMan->isIdle()) + if (!(g_fp->_aniMan->_flags & 0x100) && g_fp->_msgObjectId2 != g_vars->scene03_domino->_id) { + handleObjectInteraction(g_fp->_aniMan, g_vars->scene03_domino, ex->_keyCode); ex->_messageKind = 0; return 0; @@ -270,19 +271,19 @@ int sceneHandler03(ExCommand *ex) { { int res = 0; - if (g_fullpipe->_aniMan2) { - if (g_fullpipe->_aniMan2->_ox < g_fullpipe->_sceneRect.left + 200) - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan2->_ox - g_fullpipe->_sceneRect.left - 300; + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; - if (g_fullpipe->_aniMan2->_ox > g_fullpipe->_sceneRect.right - 200) - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan2->_ox - g_fullpipe->_sceneRect.right + 300; + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; res = 1; } - g_fullpipe->_behaviorManager->updateBehaviors(); + g_fp->_behaviorManager->updateBehaviors(); - g_fullpipe->startSceneTrack(); + g_fp->startSceneTrack(); return res; } diff --git a/engines/fullpipe/scenes/scene04.cpp b/engines/fullpipe/scenes/scene04.cpp index 07ac109477..fa9f4ceef0 100644 --- a/engines/fullpipe/scenes/scene04.cpp +++ b/engines/fullpipe/scenes/scene04.cpp @@ -26,14 +26,14 @@ #include "fullpipe/constants.h" #include "fullpipe/utils.h" #include "fullpipe/gfx.h" -#include "fullpipe/scenes.h" #include "fullpipe/messages.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" #include "fullpipe/statics.h" #include "fullpipe/scene.h" #include "fullpipe/interaction.h" #include "fullpipe/gameloader.h" #include "fullpipe/behavior.h" -#include "fullpipe/motion.h" namespace Fullpipe { @@ -52,7 +52,7 @@ void scene04_speakerCallback(int *phase) { if (scene04_speakerPhases[g_vars->scene04_speakerPhase + 6 * g_vars->scene04_speakerVariant] < 0) { g_vars->scene04_speakerPhase = 0; - g_vars->scene04_speakerVariant = g_fullpipe->_rnd->getRandomNumber(2); + g_vars->scene04_speakerVariant = g_fp->_rnd->getRandomNumber(2); } } else { ++g_vars->scene04_speakerPhase; @@ -113,7 +113,7 @@ void scene04_initScene(Scene *sc) { if (plank) plank->_flags |= 8; - if (g_fullpipe->getObjectState(sO_Jar_4) == g_fullpipe->getObjectEnumState(sO_Jar_4, sO_UpsideDown)) { + if (g_fp->getObjectState(sO_Jar_4) == g_fp->getObjectEnumState(sO_Jar_4, sO_UpsideDown)) { g_vars->scene04_bottleObjList.clear(); g_vars->scene04_kozyawkiObjList.clear(); @@ -121,8 +121,8 @@ void scene04_initScene(Scene *sc) { sc->getPictureObjectById(PIC_SC4_MASK, 0)->_flags &= 0xfffb; sc->getStaticANIObject1ById(ANI_SPRING, 0)->_flags &= 0xfffb; - g_vars->scene04_var18 = 0; - g_vars->scene04_var19 = 0; + g_vars->scene04_clockCanGo = false; + g_vars->scene04_objectIsTaken = false; } else { StaticANIObject *spring = sc->getStaticANIObject1ById(ANI_SPRING, -1); @@ -156,33 +156,33 @@ void scene04_initScene(Scene *sc) { } sc->getPictureObjectById(PIC_SC4_BOTTLE2, 0)->_flags &= 0xfffb; - g_vars->scene04_var18 = 1; - g_vars->scene04_var19 = 1; + g_vars->scene04_clockCanGo = true; + g_vars->scene04_objectIsTaken = true; } - g_vars->scene04_var02 = 0; + g_vars->scene04_bottleIsTaken = false; g_vars->scene04_soundPlaying = false; - g_vars->scene04_var04 = 0; + g_vars->scene04_kozyawkaOnLadder = false; g_vars->scene04_walkingKozyawka = 0; g_vars->scene04_bottleWeight = 2; g_vars->scene04_dynamicPhaseIndex = 0; g_vars->scene04_kozyawkiAni.clear(); - g_fullpipe->setObjectState(sO_LowerPipe, g_fullpipe->getObjectEnumState(sO_LowerPipe, sO_IsClosed)); + g_fp->setObjectState(sO_LowerPipe, g_fp->getObjectEnumState(sO_LowerPipe, sO_IsClosed)); - g_vars->scene04_var07 = 0; - g_vars->scene04_var08 = 0; - g_vars->scene04_coinPut = 0; - g_vars->scene04_var09 = 0; - g_vars->scene04_var10 = 0; - g_vars->scene04_var11 = 0; - g_vars->scene04_var12 = 0; - g_vars->scene04_var13 = 1; - g_vars->scene04_var14 = 0; - g_vars->scene04_var15 = 1; + g_vars->scene04_var07 = false; + g_vars->scene04_ladderClickable = false; + g_vars->scene04_coinPut = false; + g_vars->scene04_handIsDown = false; + g_vars->scene04_dudeInBottle = false; + g_vars->scene04_kozHeadRaised = false; + g_vars->scene04_bottleIsDropped = false; + g_vars->scene04_bigBallIn = true; + g_vars->scene04_bigBallCounter = 0; + g_vars->scene04_bigBallFromLeft = true; - if (g_fullpipe->getObjectState(sO_BigMumsy) != g_fullpipe->getObjectEnumState(sO_BigMumsy, sO_Gone)) + if (g_fp->getObjectState(sO_BigMumsy) != g_fp->getObjectEnumState(sO_BigMumsy, sO_IsGone)) g_vars->scene04_mamasha->hide(); g_vars->scene04_speaker = sc->getStaticANIObject1ById(ANI_SPEAKER_4, -1); @@ -192,12 +192,12 @@ void scene04_initScene(Scene *sc) { g_vars->scene04_speakerVariant = 0; g_vars->scene04_speakerPhase = 0; - g_fullpipe->initArcadeKeys("SC_4"); + g_fp->initArcadeKeys("SC_4"); } bool sceneHandler04_friesAreWalking() { - if (g_vars->scene04_dudeOnLadder && g_fullpipe->_aniMan->isIdle() && !(g_fullpipe->_aniMan->_flags & 0x100)) { - int col = g_vars->scene04_ladder->collisionDetection(g_fullpipe->_aniMan); + if (g_vars->scene04_dudeOnLadder && g_fp->_aniMan->isIdle() && !(g_fp->_aniMan->_flags & 0x100)) { + int col = g_vars->scene04_ladder->collisionDetection(g_fp->_aniMan); if (col >= 3 && col <= 6 ) { Movement *koz; @@ -214,59 +214,59 @@ bool sceneHandler04_friesAreWalking() { } int scene04_updateCursor() { - g_fullpipe->updateCursorCommon(); + g_fp->updateCursorCommon(); - if (g_fullpipe->_objectIdAtCursor == PIC_SC4_LRTRUBA) { - if (!g_vars->scene04_var19) { - g_fullpipe->_cursorId = PIC_CSR_DEFAULT; + if (g_fp->_objectIdAtCursor == PIC_SC4_LRTRUBA) { + if (!g_vars->scene04_objectIsTaken) { + g_fp->_cursorId = PIC_CSR_DEFAULT; - return g_fullpipe->_cursorId; + return g_fp->_cursorId; } - } else if (g_fullpipe->_objectIdAtCursor == ANI_PLANK || g_fullpipe->_objectIdAtCursor == PIC_SC4_PLANK) { - if (g_fullpipe->_objectIdAtCursor == ANI_PLANK && g_fullpipe->_cursorId != PIC_CSR_ITN) - return g_fullpipe->_cursorId; + } else if (g_fp->_objectIdAtCursor == ANI_PLANK || g_fp->_objectIdAtCursor == PIC_SC4_PLANK) { + if (g_fp->_objectIdAtCursor == ANI_PLANK && g_fp->_cursorId != PIC_CSR_ITN) + return g_fp->_cursorId; - if (g_fullpipe->_objectIdAtCursor == ANI_PLANK || (g_fullpipe->_objectIdAtCursor == PIC_SC4_PLANK && g_fullpipe->_cursorId == PIC_CSR_DEFAULT)) { + if (g_fp->_objectIdAtCursor == ANI_PLANK || (g_fp->_objectIdAtCursor == PIC_SC4_PLANK && g_fp->_cursorId == PIC_CSR_DEFAULT)) { if (sceneHandler04_friesAreWalking()) { - g_fullpipe->_cursorId = PIC_CSR_ARCADE1; - return g_fullpipe->_cursorId; + g_fp->_cursorId = PIC_CSR_ARCADE1; + return g_fp->_cursorId; } if (g_vars->scene04_soundPlaying) { - g_fullpipe->_cursorId = PIC_CSR_DEFAULT; - return g_fullpipe->_cursorId; + g_fp->_cursorId = PIC_CSR_DEFAULT; + return g_fp->_cursorId; } } } - if (g_fullpipe->_objectIdAtCursor == PIC_CSR_ITN && g_fullpipe->_objectIdAtCursor == PIC_SC4_DOWNTRUBA) - g_fullpipe->_cursorId = PIC_CSR_GOD; + if (g_fp->_objectIdAtCursor == PIC_CSR_ITN && g_fp->_objectIdAtCursor == PIC_SC4_DOWNTRUBA) + g_fp->_cursorId = PIC_CSR_GOD; - return g_fullpipe->_cursorId; + return g_fp->_cursorId; } void sceneHandler04_checkBigBallClick() { - StaticANIObject *ball = g_fullpipe->_currentScene->getStaticANIObject1ById(ANI_BIGBALL, -1); + StaticANIObject *ball = g_fp->_currentScene->getStaticANIObject1ById(ANI_BIGBALL, -1); if (ball) for (uint i = 0; i < ball->_movements.size(); i++) ((Movement *)ball->_movements[i])->_counterMax = 73; - g_vars->scene04_var13 = 1; + g_vars->scene04_bigBallIn = true; } void sceneHandler04_clickBottle() { - if (!g_vars->scene04_var02) - g_vars->scene04_var20 += 5; + if (!g_vars->scene04_bottleIsTaken) + g_vars->scene04_springOffset += 5; } void sceneHandler04_clickButton() { - StaticANIObject *but = g_fullpipe->_currentScene->getStaticANIObject1ById(ANI_BUTTON, -1); + StaticANIObject *but = g_fp->_currentScene->getStaticANIObject1ById(ANI_BUTTON, -1); if (but) { if (!g_vars->scene04_clock->_movement || (g_vars->scene04_clock->_movement->_id == MV_CLK_GO && g_vars->scene04_clock->_movement->_currDynamicPhaseIndex > 3 && g_vars->scene04_clock->_movement->_currDynamicPhaseIndex < 105)) { - if (!g_vars->scene04_hand->_movement && !g_vars->scene04_var02) { + if (!g_vars->scene04_hand->_movement && !g_vars->scene04_bottleIsTaken) { but->startAnim(MV_BTN_CLICK, 0, -1); g_vars->scene04_hand->startAnim(MV_HND_POINT, 0, -1); } @@ -275,22 +275,22 @@ void sceneHandler04_clickButton() { } void sceneHandler04_downLadder(int x, int y) { - g_vars->scene04_ladder->method34(g_fullpipe->_aniMan, x + g_vars->scene04_ladder->_ladder_field_20, y + g_vars->scene04_ladder->_ladder_field_24, 0, 0); + g_vars->scene04_ladder->method34(g_fp->_aniMan, x + g_vars->scene04_ladder->_ladder_field_20, y + g_vars->scene04_ladder->_ladder_field_24, 0, 0); } void sceneHandler04_walkClimbLadder(ExCommand *ex) { - MessageQueue *mq = new MessageQueue(g_fullpipe->_globalMessageQueueList->compact()); + MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); ExCommand *ex1 = new ExCommand(ANI_MAN, 1, MV_MAN_TOLADDER, 0, 0, 0, 1, 0, 0, 0); - ex1->_keyCode = g_fullpipe->_aniMan->_okeyCode; + ex1->_keyCode = g_fp->_aniMan->_okeyCode; ex1->_excFlags |= 2; mq->addExCommandToEnd(ex1); ExCommand *ex2 = new ExCommand(ANI_MAN, 1, MV_MAN_STOPLADDER, 0, 0, 0, 1, 0, 0, 0); - ex2->_keyCode = g_fullpipe->_aniMan->_okeyCode; + ex2->_keyCode = g_fp->_aniMan->_okeyCode; ex2->_excFlags |= 2; mq->addExCommandToEnd(ex2); @@ -313,15 +313,15 @@ void sceneHandler04_walkClimbLadder(ExCommand *ex) { g_vars->scene04_dudeOnLadder = 1; g_vars->scene04_ladder = new MctlLadder; - g_vars->scene04_ladder->_objId = MV_MAN_TURN_SUD; + g_vars->scene04_ladder->_ladderX = 1089; g_vars->scene04_ladder->_ladderY = 406; g_vars->scene04_ladder->_ladder_field_14 = 12; - g_vars->scene04_ladder->_ladder_field_18 = 0; + g_vars->scene04_ladder->_width = 0; g_vars->scene04_ladder->_height = -40; g_vars->scene04_ladder->_ladder_field_20 = 0; g_vars->scene04_ladder->_ladder_field_24 = -60; - g_vars->scene04_ladder->addObject(g_fullpipe->_aniMan); + g_vars->scene04_ladder->addObject(g_fp->_aniMan); if (g_vars->scene04_soundPlaying) { g_vars->scene04_ladder->_movements.front()->movVars->varUpStart = MV_MAN_STARTLADDER2; @@ -335,19 +335,19 @@ void sceneHandler04_walkClimbLadder(ExCommand *ex) { g_vars->scene04_ladder->_movements.front()->staticIds[2] = ST_MAN_GOLADDER; } - g_fullpipe->_aniMan->_priority = 12; + g_fp->_aniMan->_priority = 12; - getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->clearEnabled(); + getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->clearEnabled(); getGameLoaderInteractionController()->disableFlag24(); } void sceneHandler04_clickLadder() { - g_vars->scene04_dudePosX = g_fullpipe->_aniMan->_ox; - g_vars->scene04_dudePosY = g_fullpipe->_aniMan->_oy; + g_vars->scene04_dudePosX = g_fp->_aniMan->_ox; + g_vars->scene04_dudePosY = g_fp->_aniMan->_oy; if (g_vars->scene04_dudeOnLadder) { - if (!g_fullpipe->_aniMan->isIdle() || (g_fullpipe->_aniMan->_flags & 0x100)) { - g_vars->scene04_var08 = 1; + if (!g_fp->_aniMan->isIdle() || (g_fp->_aniMan->_flags & 0x100)) { + g_vars->scene04_ladderClickable = true; } else { int h3 = 3 * g_vars->scene04_ladder->_height; int half = abs(g_vars->scene04_ladder->_height) / 2; @@ -363,19 +363,19 @@ void sceneHandler04_clickLadder() { sceneHandler04_downLadder(g_vars->scene04_sceneClickX, g_vars->scene04_sceneClickY); - g_vars->scene04_var08 = 0; + g_vars->scene04_ladderClickable = false; } } else { - if (g_fullpipe->_aniMan->isIdle() && !(g_fullpipe->_aniMan->_flags & 0x100)) { + if (g_fp->_aniMan->isIdle() && !(g_fp->_aniMan->_flags & 0x100)) { if (abs(1095 - g_vars->scene04_dudePosX) > 1 || abs(434 - g_vars->scene04_dudePosY) > 1) { - MessageQueue *mq = getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->method34(g_fullpipe->_aniMan, 1095, 434, 1, ST_MAN_UP); + MessageQueue *mq = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->method34(g_fp->_aniMan, 1095, 434, 1, ST_MAN_UP); if (mq) { ExCommand *ex = new ExCommand(0, 17, MSG_SC4_CLICKLADDER, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags = 3; mq->addExCommandToEnd(ex); - postExCommand(g_fullpipe->_aniMan->_id, 2, 1095, 434, 0, -1); + postExCommand(g_fp->_aniMan->_id, 2, 1095, 434, 0, -1); } } else { sceneHandler04_walkClimbLadder(0); @@ -385,22 +385,22 @@ void sceneHandler04_clickLadder() { } void sceneHandler04_jumpOnLadder() { - if (g_fullpipe->_aniMan->_movement && g_fullpipe->_aniMan->_movement->_id != MV_MAN_LOOKLADDER) + if (g_fp->_aniMan->_movement && g_fp->_aniMan->_movement->_id != MV_MAN_LOOKLADDER) return; - if (g_fullpipe->_aniMan->_statics->_staticsId != ST_MAN_STANDLADDER && g_fullpipe->_aniMan->_statics->_staticsId != ST_MAN_LADDERDOWN) + if (g_fp->_aniMan->_statics->_staticsId != ST_MAN_STANDLADDER && g_fp->_aniMan->_statics->_staticsId != ST_MAN_LADDERDOWN) return; - g_fullpipe->_aniMan->changeStatics2(ST_MAN_LADDERDOWN); + g_fp->_aniMan->changeStatics2(ST_MAN_LADDERDOWN); - g_fullpipe->_aniMan->_flags |= 1; + g_fp->_aniMan->_flags |= 1; MGM mgm; MGMInfo mgminfo; mgm.addItem(ANI_MAN); - mgminfo.ani = g_fullpipe->_aniMan; + mgminfo.ani = g_fp->_aniMan; mgminfo.staticsId2 = ST_MAN_ONPLANK; mgminfo.x1 = 938; mgminfo.y1 = 442; @@ -414,26 +414,26 @@ void sceneHandler04_jumpOnLadder() { if (mq) { mq->_flags |= 1; - if (!mq->chain(g_fullpipe->_aniMan)) + if (!mq->chain(g_fp->_aniMan)) delete mq; - g_fullpipe->_aniMan->_priority = 10; + g_fp->_aniMan->_priority = 10; } - g_vars->scene04_ladderOffset = g_vars->scene04_ladder->collisionDetection(g_fullpipe->_aniMan); + g_vars->scene04_ladderOffset = g_vars->scene04_ladder->collisionDetection(g_fp->_aniMan); } void sceneHandler04_clickPlank() { if (sceneHandler04_friesAreWalking()) sceneHandler04_jumpOnLadder(); else if (g_vars->scene04_dudeOnLadder) - g_fullpipe->playSound(SND_4_033, 0); + g_fp->playSound(SND_4_033, 0); else if (!g_vars->scene04_soundPlaying) chainQueue(QU_PNK_CLICK, 0); } void sceneHandler04_dropBottle() { - g_vars->scene04_var12 = 1; + g_vars->scene04_bottleIsDropped = true; g_vars->scene04_bottleY = 10; g_vars->scene04_bottleWeight = 0; @@ -465,7 +465,7 @@ void sceneHandler04_gotoLadder(ExCommand *ex) { mgm.addItem(ANI_MAN); - mgminfo.ani = g_fullpipe->_aniMan; + mgminfo.ani = g_fp->_aniMan; mgminfo.staticsId2 = ST_MAN_UP; mgminfo.x1 = 1095; mgminfo.y1 = 434; @@ -491,7 +491,7 @@ void sceneHandler04_gotoLadder(ExCommand *ex) { ex2->_keyCode = -1; mq->addExCommandToEnd(ex2); - ExCommand *ex3 = new ExCommand(g_fullpipe->_aniMan->_id, 34, 256, 0, 0, 0, 1, 0, 0, 0); + ExCommand *ex3 = new ExCommand(g_fp->_aniMan->_id, 34, 256, 0, 0, 0, 1, 0, 0, 0); ex3->_field_14 = 256; ex3->_messageNum = 0; ex3->_excFlags |= 3; @@ -505,15 +505,15 @@ void sceneHandler04_gotoLadder(ExCommand *ex) { mq->setFlags(mq->getFlags() | 1); - if (mq->chain(g_fullpipe->_aniMan)) { - g_fullpipe->_aniMan->_priority = 12; - g_fullpipe->_aniMan->_flags |= 1; + if (mq->chain(g_fp->_aniMan)) { + g_fp->_aniMan->_priority = 12; + g_fp->_aniMan->_flags |= 1; } else { delete mq; } } - g_vars->scene04_var04 = 0; + g_vars->scene04_kozyawkaOnLadder = false; } void sceneHandler04_lowerPlank() { @@ -522,7 +522,7 @@ void sceneHandler04_lowerPlank() { void sceneHandler04_manFromBottle() { for (Common::List<GameObject *>::iterator it = g_vars->scene04_bottleObjList.begin(); it != g_vars->scene04_bottleObjList.end(); ++it) - if (*it == g_fullpipe->_aniMan) { + if (*it == g_fp->_aniMan) { g_vars->scene04_bottleObjList.erase(it); g_vars->scene04_bottleWeight -= 9; break; @@ -533,28 +533,343 @@ void sceneHandler04_manFromBottle() { g_vars->scene04_ladder = 0; - getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->setEnabled(); + getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->setEnabled(); getGameLoaderInteractionController()->enableFlag24(); } void sceneHandler04_manToBottle() { - g_vars->scene04_bottleObjList.push_back(g_fullpipe->_aniMan); - g_vars->scene04_var20 = 5; + g_vars->scene04_bottleObjList.push_back(g_fp->_aniMan); + g_vars->scene04_springOffset = 5; g_vars->scene04_bottleWeight += 9; - g_fullpipe->_aniMan2 = g_fullpipe->_aniMan; - g_vars->scene04_var10 = 1; + g_fp->_aniMan2 = g_fp->_aniMan; + g_vars->scene04_dudeInBottle = 1; } void sceneHandler04_raisePlank() { g_vars->scene04_plank->startAnim(MV_PNK_WEIGHTLEFT, 0, -1); } +MessageQueue *sceneHandler04_kozFly3(StaticANIObject *ani, double phase) { + MGM mgm; + MGMInfo mgminfo; + + mgm.addItem(ANI_KOZAWKA); + + mgminfo.ani = ani; + mgminfo.staticsId2 = ST_KZW_SIT; + mgminfo.x1 = (int)(723.0 - phase * 185.0); + mgminfo.y1 = 486; + mgminfo.field_1C = 10; + mgminfo.field_10 = 1; + mgminfo.flags = 78; + mgminfo.movementId = MV_KZW_JUMP; + + MessageQueue *mq = mgm.genMovement(&mgminfo); + + if (mq) { + ExCommand *ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_STANDUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_TURN, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + for (int i = 0; i < 5; i++) { + ex = new ExCommand(ANI_KOZAWKA, 1, rMV_KZW_GOR, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + } + + ex = new ExCommand(ANI_KOZAWKA, 6, 0, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 17, MSG_KOZAWRESTART, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + } + + return mq; +} + +MessageQueue *sceneHandler04_kozFly5(StaticANIObject *ani, double phase) { + MGM mgm; + MGMInfo mgminfo; + + mgm.addItem(ANI_KOZAWKA); + + mgminfo.ani = ani; + mgminfo.staticsId2 = ST_KZW_JUMPOUT; + mgminfo.x1 = 525; + mgminfo.y1 = (int)(344.0 - (double)(320 - g_vars->scene04_bottle->_oy) * phase); + mgminfo.field_1C = 10; + mgminfo.field_10 = 1; + mgminfo.flags = 78; + mgminfo.movementId = MV_KZW_JUMPHIT; + + MessageQueue *mq1 = mgm.genMovement(&mgminfo); + + memset(&mgminfo, 0, sizeof(mgminfo)); + mgminfo.ani = ani; + mgminfo.staticsId1 = ST_KZW_JUMPOUT; + mgminfo.staticsId2 = ST_KZW_SIT; + mgminfo.x2 = 525; + mgminfo.y2 = (int)(344.0 - (double)(320 - g_vars->scene04_bottle->_oy) * phase); + mgminfo.y1 = 486; + mgminfo.field_1C = 10; + mgminfo.field_10 = 1; + mgminfo.flags = 117; + mgminfo.movementId = MV_KZW_JUMPOUT; + + MessageQueue *mq2 = mgm.genMovement(&mgminfo); + + if (mq1 && mq2) { + mq1->addExCommandToEnd(new ExCommand(mq2->getExCommandByIndex(0))); + + delete mq2; + + ExCommand *ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_STANDUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq1->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_TURN, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq1->addExCommandToEnd(ex); + + for (int i = 0; i < 5; i++) { + ex = new ExCommand(ANI_KOZAWKA, 1, rMV_KZW_GOR, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq1->addExCommandToEnd(ex); + } + + ex = new ExCommand(ANI_KOZAWKA, 6, 0, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + ex->_keyCode = ani->_okeyCode; + mq1->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 17, MSG_KOZAWRESTART, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + ex->_keyCode = ani->_okeyCode; + mq1->addExCommandToEnd(ex); + } + + return mq1; +} + +MessageQueue *sceneHandler04_kozFly6(StaticANIObject *ani) { + MGM mgm; + MGMInfo mgminfo; + + mgm.addItem(ANI_KOZAWKA); + + mgminfo.ani = ani; + mgminfo.staticsId2 = ST_KZW_SIT; + mgminfo.x1 = 397 - 4 * g_fp->_rnd->getRandomNumber(1); + mgminfo.field_1C = ani->_priority; + mgminfo.y1 = g_vars->scene04_bottle->_oy - 4 * g_fp->_rnd->getRandomNumber(1) + 109; + mgminfo.field_10 = 1; + mgminfo.flags = 78; + mgminfo.movementId = MV_KZW_JUMPROTATE; + + MessageQueue *mq = mgm.genMovement(&mgminfo); + + if (mq) { + mq->deleteExCommandByIndex(mq->getCount() - 1, 1); + + ExCommand *ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_STANDUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_GOR, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_RAISEHEAD, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + g_vars->scene04_kozHeadRaised = true; + } + + return mq; +} + +void sceneHandler04_kozMove(Movement *mov, int from, int to, Common::Point *points, double phase) { + for (int i = from; i < to; i++) { + mov->setDynamicPhaseIndex(i); + + Common::Point *p; + if (mov->_framePosOffsets) { + p = mov->_framePosOffsets[mov->_currDynamicPhaseIndex]; + } else { + p = &mov->_somePoint; + p->x = 0; + p->y = 0; + } + + p->y = (int)((double)points[i].y * phase); + } +} + +MessageQueue *sceneHandler04_kozFly7(StaticANIObject *ani, double phase) { + MGM mgm; + MGMInfo mgminfo; + + mgm.addItem(ANI_KOZAWKA); + + mgminfo.ani = ani; + mgminfo.staticsId2 = 560; + mgminfo.x1 = (int)(250.0 - phase * 100.0); + mgminfo.y1 = 455; + mgminfo.field_1C = 10; + mgminfo.field_10 = 1; + mgminfo.flags = 78; + mgminfo.movementId = MV_KZW_JUMPROTATE; + + MessageQueue *mq = mgm.genMovement(&mgminfo); + + if (mq) { + sceneHandler04_kozMove(ani->getMovementById(MV_KZW_JUMPROTATE), 1, 9, g_vars->scene04_jumpRotateKozyawki, phase * 0.5 + 1.5); + + ani->_priority = 10; + + ExCommand *ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_STANDUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_TURN, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + for (int i = 0; i < 2; i++) { + ex = new ExCommand(ANI_KOZAWKA, 1, rMV_KZW_GOR, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + } + + ex = new ExCommand(ANI_KOZAWKA, 6, 0, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 17, MSG_KOZAWRESTART, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + } + + return mq; +} + +static const int kozTrajectory3[] = { + 3, 2, 0, + 3, 2, 0, + 3, 2, 0 +}; + +static const int kozTrajectory4[] = { + 5, 3, 1, + 5, 4, 1, + 5, 3, 1 +}; + +static const int kozTrajectory5[] = { + 6, 5, 4, + 6, 5, 4, + 6, 5, 4 +}; + +static const int kozTrajectory6[] = { + 7, 6, 5, + 7, 6, 5, + 7, 6, 5 +}; + void sceneHandler04_shootKozyawka() { - warning("STUB: sceneHandler04_shootKozyawka()"); + g_vars->scene04_plank->changeStatics2(ST_PNK_WEIGHTRIGHT); + + if (!g_vars->scene04_walkingKozyawka) + return; + + if (g_vars->scene04_walkingKozyawka->_movement) { + if (g_vars->scene04_walkingKozyawka->_movement->_id == MV_KZW_WALKPLANK) { + int dphase = g_vars->scene04_walkingKozyawka->_movement->_currDynamicPhaseIndex; + + if (dphase < 41) { + int col = 3 * dphase / 15; + if (col > 2) + col = 2; + + int row = g_vars->scene04_kozyawkiAni.size(); + if (row > 2) + row = 2; + + int idx = 3 * row + col; + int phase; + + if (g_vars->scene04_ladderOffset == 3) { + phase = kozTrajectory3[idx]; + } else if (g_vars->scene04_ladderOffset == 4) { + phase = kozTrajectory4[idx]; + } else { + if (g_vars->scene04_ladderOffset == 5) + phase = kozTrajectory5[idx]; + else + phase = kozTrajectory6[idx]; + } + + g_vars->scene04_walkingKozyawka->queueMessageQueue(0); + g_vars->scene04_walkingKozyawka->_movement = 0; + g_vars->scene04_walkingKozyawka->_statics = g_vars->scene04_walkingKozyawka->getStaticsById(ST_KZW_RIGHT); + + MessageQueue *mq; + + if (phase > 2) { + if (phase > 5) { + if (phase == 6) + mq = sceneHandler04_kozFly6(g_vars->scene04_walkingKozyawka); + else + mq = sceneHandler04_kozFly7(g_vars->scene04_walkingKozyawka, (double)(phase - 6) * 0.3333333333333333); + } else { + mq = sceneHandler04_kozFly5(g_vars->scene04_walkingKozyawka, (double)(phase - 2) * 0.3333333333333333); + } + } else { + mq = sceneHandler04_kozFly3(g_vars->scene04_walkingKozyawka, (double)phase * 0.5); + } + + if (mq) { + g_vars->scene04_lastKozyawka = g_vars->scene04_walkingKozyawka; + + if (!mq->chain(g_vars->scene04_walkingKozyawka) ) + delete mq; + } + } + } + } + + if (g_vars->scene04_ladderOffset > 3) + g_fp->_aniMan->changeStatics1(ST_MAN_LOOKPLANK); + + g_vars->scene04_kozyawkaOnLadder = true; } void sceneHandler04_showCoin() { - StaticANIObject *ani = g_fullpipe->_currentScene->getStaticANIObject1ById(ANI_SC4_COIN, -1); + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_SC4_COIN, -1); if (ani) { ani->show1(MV_BDG_OPEN, MV_MAN_GOU, MV_SC4_COIN_default, 0); @@ -564,13 +879,15 @@ void sceneHandler04_showCoin() { } void sceneHandler04_stopSound() { + g_vars->scene04_soundPlaying = false; + warning("STUB: sceneHandler04_stopSound()"); } -void sceneHandler04_sub1(ExCommand *ex) { - g_fullpipe->_aniMan->changeStatics2(ST_MAN_SIT); +void sceneHandler04_animOutOfBottle(ExCommand *ex) { + g_fp->_aniMan->changeStatics2(ST_MAN_SIT); - MessageQueue *mq = new MessageQueue(g_fullpipe->_currentScene->getMessageQueueById(QU_SC4_MANFROMBOTTLE), 0, 0); + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC4_MANFROMBOTTLE), 0, 0); if (ex) { ExCommand *newex = new ExCommand(ex); @@ -581,8 +898,8 @@ void sceneHandler04_sub1(ExCommand *ex) { mq->_flags |= 1; mq->chain(0); - g_vars->scene04_var10 = 0; - g_fullpipe->_behaviorManager->setFlagByStaticAniObject(g_fullpipe->_aniMan, 1); + g_vars->scene04_dudeInBottle = false; + g_fp->_behaviorManager->setFlagByStaticAniObject(g_fp->_aniMan, 1); } void sceneHandler04_walkKozyawka() { @@ -590,7 +907,7 @@ void sceneHandler04_walkKozyawka() { g_vars->scene04_walkingKozyawka = g_vars->scene04_kozyawkiObjList.front(); g_vars->scene04_kozyawkiObjList.pop_front(); - MessageQueue *mq = new MessageQueue(g_fullpipe->_currentScene->getMessageQueueById(QU_KOZAW_WALK), 0, 1); + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_KOZAW_WALK), 0, 1); mq->replaceKeyCode(-1, g_vars->scene04_walkingKozyawka->_okeyCode); mq->chain(0); } @@ -606,34 +923,34 @@ void sceneHandler04_bottleUpdateObjects(int off) { void sceneHandler04_springWobble() { int oldDynIndex = g_vars->scene04_dynamicPhaseIndex; - int newdelta = g_vars->scene04_var20 + g_vars->scene04_dynamicPhaseIndex; + int newdelta = g_vars->scene04_springOffset + g_vars->scene04_dynamicPhaseIndex; - g_vars->scene04_dynamicPhaseIndex += g_vars->scene04_var20; + g_vars->scene04_dynamicPhaseIndex += g_vars->scene04_springOffset; if (newdelta < 0) { newdelta = 0; g_vars->scene04_dynamicPhaseIndex = 0; - g_vars->scene04_var20 = 0; + g_vars->scene04_springOffset = 0; } if (newdelta > 14) { newdelta = 14; g_vars->scene04_dynamicPhaseIndex = 14; - g_vars->scene04_var20 = 0; + g_vars->scene04_springOffset = 0; } if (g_vars->scene04_bottleWeight > newdelta) - g_vars->scene04_var20++; + g_vars->scene04_springOffset++; if (g_vars->scene04_bottleWeight < newdelta) - g_vars->scene04_var20--; + g_vars->scene04_springOffset--; if ((oldDynIndex > g_vars->scene04_bottleWeight && newdelta > g_vars->scene04_bottleWeight) || newdelta <= g_vars->scene04_bottleWeight) { - g_vars->scene04_var25++; + g_vars->scene04_springDelay++; - if (g_vars->scene04_var20 && g_vars->scene04_var25 > 1) { - g_vars->scene04_var25 = 0; - g_vars->scene04_var20 = g_vars->scene04_var20 - g_vars->scene04_var20 / abs(g_vars->scene04_var20); + if (g_vars->scene04_springOffset && g_vars->scene04_springDelay > 1) { + g_vars->scene04_springDelay = 0; + g_vars->scene04_springOffset = g_vars->scene04_springOffset - g_vars->scene04_springOffset / abs(g_vars->scene04_springOffset); } } @@ -652,8 +969,33 @@ void sceneHandler04_springWobble() { sceneHandler04_bottleUpdateObjects(oldDynIndex - g_vars->scene04_dynamicPhaseIndex); } -void sceneHandler04_sub5() { - warning("STUB: sceneHandler04_sub5()"); +void sceneHandler04_leaveScene() { + g_fp->_aniMan2 = 0; + + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC4_MANTOBOTTLE), 0, 0); + ExCommand *ex = 0; + + for (uint i = 0; i < mq->getCount(); i++) { + if (mq->getExCommandByIndex(i)->_messageKind == 27) { + ex = mq->getExCommandByIndex(i); + break; + } + } + + if (!ex) { + error("sceneHandler04_leaveScene(): Cannot find exit"); + } + + ex->_y = g_vars->scene04_bottle->_oy - 304; + + mq->chain(0); + + g_vars->scene04_var07 = false; + g_vars->scene04_dudeOnLadder = 0; + + g_fp->_behaviorManager->setFlagByStaticAniObject(g_fp->_aniMan, 0); + + g_fp->updateMapPiece(PIC_MAP_P03, 1); } void sceneHandler04_liftBottle() { @@ -669,46 +1011,122 @@ void sceneHandler04_liftBottle() { sceneHandler04_bottleUpdateObjects(226 - g_vars->scene04_bottle->_oy); g_vars->scene04_spring->setOXY(g_vars->scene04_spring->_ox, 437); - g_vars->scene04_var12 = 0; - g_vars->scene04_var09 = 0; - g_vars->scene04_var19 = 1; + g_vars->scene04_bottleIsDropped = false; + g_vars->scene04_handIsDown = false; + g_vars->scene04_objectIsTaken = true; g_vars->scene04_bottleWeight = 2; - g_vars->scene04_var20 = 10; - g_vars->scene04_var02 = 0; + g_vars->scene04_springOffset = 10; + g_vars->scene04_bottleIsTaken = false; - g_fullpipe->setObjectState(sO_LowerPipe, g_fullpipe->getObjectEnumState(sO_LowerPipe, sO_IsClosed)); + g_fp->setObjectState(sO_LowerPipe, g_fp->getObjectEnumState(sO_LowerPipe, sO_IsClosed)); } } void sceneHandler04_startSounds(const char *snd1, const char *snd2, const char *snd3) { warning("STUB: sceneHandler04_startSounds()"); + + // playFile(snd1); + // playFile(snd2); + // playFile(snd3); } void sceneHandler04_goClock() { sceneHandler04_walkKozyawka(); chainQueue(QU_SC4_GOCLOCK, 0); - g_vars->scene04_soundPlaying = 1; - g_vars->scene04_coinPut = 0; + g_vars->scene04_soundPlaying = true; + g_vars->scene04_coinPut = false; - g_fullpipe->stopAllSoundStreams(); + g_fp->stopAllSoundStreams(); sceneHandler04_startSounds("sc4_start.ogg", "sc4_loop.ogg", "sc4_stop2.ogg"); - g_vars->scene04_var14 = 0; + g_vars->scene04_bigBallCounter = 0; } -void sceneHandler04_sub8(ExCommand *ex) { - warning("STUB: sceneHandler04_sub8()"); -} - -void sceneHandler04_sub12() { - StaticANIObject *ball = g_fullpipe->_currentScene->getStaticANIObject1ById(ANI_BIGBALL, -1); +void sceneHandler04_bigBallOut() { + StaticANIObject *ball = g_fp->_currentScene->getStaticANIObject1ById(ANI_BIGBALL, -1); if (ball && ball->_flags & 4) for (uint i = 0; i < ball->_movements.size(); i++) ((Movement *)ball->_movements[i])->_counterMax = 0; - g_vars->scene04_var13 = 0; + g_vars->scene04_bigBallIn = false; +} + +void sceneHandler04_leaveLadder(ExCommand *ex) { + if (!g_fp->_aniMan->isIdle()) + return; + + if (!(g_fp->_aniMan->_flags & 0x100)) { + if (getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->_objtype == kObjTypeMctlCompound) { + MctlCompound *mc = (MctlCompound *)getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId); + + if (mc->_motionControllers[0]->_movGraphReactObj->pointInRegion(g_fp->_sceneRect.left + ex->_x, g_fp->_sceneRect.top + ex->_y)) { + if (g_vars->scene04_ladder->collisionDetection(g_fp->_aniMan)) { + MessageQueue *mq = g_vars->scene04_ladder->controllerWalkTo(g_fp->_aniMan, 0); + + if (mq) { + mq->addExCommandToEnd(new ExCommand(ex)); + + if (mq->chain(g_fp->_aniMan) ) + ex->_messageKind = 0; + else + delete mq; + + if (g_vars->scene04_bigBallIn) { + sceneHandler04_bigBallOut(); + return; + } + } + } else { + MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + ExCommand *ex1; + + if (g_fp->_aniMan->_statics->_staticsId == ST_MAN_LADDERDOWN) { + ex1 = new ExCommand(ANI_MAN, 1, MV_MAN_LOOKLADDERRV, 0, 0, 0, 1, 0, 0, 0); + ex1->_keyCode = g_fp->_aniMan->_okeyCode; + ex1->_excFlags |= 2; + mq->addExCommandToEnd(ex1); + } + + ex1 = new ExCommand(ANI_MAN, 1, MV_MAN_STARTLADDERD, 0, 0, 0, 1, 0, 0, 0); + ex1->_keyCode = g_fp->_aniMan->_okeyCode; + ex1->_excFlags |= 2; + mq->addExCommandToEnd(ex1); + + ex1 = new ExCommand(ANI_MAN, 1, MV_MAN_FROMLADDER, 0, 0, 0, 1, 0, 0, 0); + ex1->_keyCode = g_fp->_aniMan->_okeyCode; + ex1->_excFlags |= 2; + mq->addExCommandToEnd(ex1); + + ex1 = new ExCommand(ex); + mq->addExCommandToEnd(ex1); + + mq->setFlags(mq->getFlags() | 1); + + if (mq->chain(g_fp->_aniMan)) { + if (g_vars->scene04_ladder) + delete g_vars->scene04_ladder; + + g_vars->scene04_ladder = 0; + g_vars->scene04_dudeOnLadder = 0; + + ex->_messageKind = 0; + + mc->setEnabled(); + getGameLoaderInteractionController()->enableFlag24(); + } else { + delete mq; + } + + if (g_vars->scene04_bigBallIn) { + sceneHandler04_bigBallOut(); + return; + } + } + } + } + } } void sceneHandler04_handTake() { @@ -717,27 +1135,27 @@ void sceneHandler04_handTake() { if (g_vars->scene04_kozyawkiAni.size()) { if (g_vars->scene04_kozyawkiAni.size() == 1) { chainQueue(QU_HND_TAKE1, 0); - g_vars->scene04_var19 = 0; + g_vars->scene04_objectIsTaken = false; } else { chainQueue((g_vars->scene04_kozyawkiAni.size() != 2) ? QU_HND_TAKEBOTTLE : QU_HND_TAKE2, 0); - g_vars->scene04_var19 = 0; + g_vars->scene04_objectIsTaken = false; } } else { chainQueue(QU_HND_TAKE0, 0); - g_vars->scene04_var19 = 0; + g_vars->scene04_objectIsTaken = false; } } -void sceneHandler04_sub9(StaticANIObject *ani) { +void sceneHandler04_putKozyawkaBack(StaticANIObject *ani) { g_vars->scene04_bottleObjList.push_back(ani); g_vars->scene04_kozyawkiAni.push_back(ani); g_vars->scene04_bottleWeight += 2; g_vars->scene04_walkingKozyawka = 0; - g_vars->scene04_var24 = 0; + g_vars->scene04_lastKozyawka = 0; if (g_vars->scene04_kozyawkiAni.size() > 1 ) - g_vars->scene04_var19 = 0; + g_vars->scene04_objectIsTaken = false; if (g_vars->scene04_kozyawkiAni.size() <= 2 || g_vars->scene04_hand->_movement) { sceneHandler04_walkKozyawka(); @@ -747,39 +1165,39 @@ void sceneHandler04_sub9(StaticANIObject *ani) { } } -void sceneHandler04_sub17() { - StaticANIObject *ball = g_fullpipe->_currentScene->getStaticANIObject1ById(ANI_BIGBALL, -1); +void sceneHandler04_bigBallWalkIn() { + StaticANIObject *ball = g_fp->_currentScene->getStaticANIObject1ById(ANI_BIGBALL, -1); if (g_vars->scene04_dudeOnLadder && (!ball || !(ball->_flags & 4)) - && g_vars->scene04_ladder->collisionDetection(g_fullpipe->_aniMan) > 3) { + && g_vars->scene04_ladder->collisionDetection(g_fp->_aniMan) > 3) { - if (!g_fullpipe->_rnd->getRandomNumber(49)) { - if (g_vars->scene04_var15) + if (!g_fp->_rnd->getRandomNumber(49)) { + if (g_vars->scene04_bigBallFromLeft) chainQueue(QU_BALL_WALKR, 0); else chainQueue(QU_BALL_WALKL, 0); - g_vars->scene04_var15 = !g_vars->scene04_var15; + g_vars->scene04_bigBallFromLeft = !g_vars->scene04_bigBallFromLeft; sceneHandler04_checkBigBallClick(); - g_vars->scene04_var14 = 0; + g_vars->scene04_bigBallCounter = 0; } } } void sceneHandler04_takeBottle() { - g_vars->scene04_var02 = 1; + g_vars->scene04_bottleIsTaken = true; g_vars->scene04_hand->_priority = 5; - g_fullpipe->setObjectState(sO_LowerPipe, g_fullpipe->getObjectEnumState(sO_LowerPipe, sO_IsOpened)); + g_fp->setObjectState(sO_LowerPipe, g_fp->getObjectEnumState(sO_LowerPipe, sO_IsOpened)); } void sceneHandler04_takeKozyawka() { if (g_vars->scene04_kozyawkiAni.size() > 0) { if (g_vars->scene04_kozyawkiAni.size() == 1) - g_vars->scene04_var19 = 1; + g_vars->scene04_objectIsTaken = true; StaticANIObject *koz = g_vars->scene04_kozyawkiAni.front(); g_vars->scene04_kozyawkiAni.pop_front(); @@ -802,7 +1220,7 @@ void sceneHandler04_takeKozyawka() { } void sceneHandler04_testPlank(ExCommand *ex) { - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(ex->_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(ex->_parId); if (!mq) return; @@ -832,7 +1250,7 @@ void sceneHandler04_updateBottle() { } void sceneHandler04_winArcade() { - if (g_fullpipe->getObjectState(sO_LowerPipe) == g_fullpipe->getObjectEnumState(sO_LowerPipe, sO_IsClosed) + if (g_fp->getObjectState(sO_LowerPipe) == g_fp->getObjectEnumState(sO_LowerPipe, sO_IsClosed) && g_vars->scene04_soundPlaying) { g_vars->scene04_clock->changeStatics2(ST_CLK_CLOSED); g_vars->scene04_hand->changeStatics2(ST_HND_EMPTY); @@ -847,14 +1265,14 @@ void sceneHandler04_winArcade() { g_vars->scene04_walkingKozyawka = 0; } - g_vars->scene04_var19 = 0; - g_vars->scene04_soundPlaying = 0; + g_vars->scene04_objectIsTaken = false; + g_vars->scene04_soundPlaying = false; - getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->setEnabled(); + getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->setEnabled(); getGameLoaderInteractionController()->enableFlag24(); - g_fullpipe->stopSoundStream2(); + g_fp->stopSoundStream2(); } } @@ -876,16 +1294,16 @@ int sceneHandler04(ExCommand *ex) { break; case MSG_SHAKEBOTTLE: - if (!g_vars->scene04_var02) - ++g_vars->scene04_var20; + if (!g_vars->scene04_bottleIsTaken) + ++g_vars->scene04_springOffset; break; case MSG_STARTHAND: - g_vars->scene04_var09 = 1; - g_vars->scene04_coinPut = 0; + g_vars->scene04_handIsDown = true; + g_vars->scene04_coinPut = false; - if (g_vars->scene04_var10) - sceneHandler04_sub1(0); + if (g_vars->scene04_dudeInBottle) + sceneHandler04_animOutOfBottle(0); sceneHandler04_handTake(); sceneHandler04_stopSound(); @@ -929,93 +1347,93 @@ int sceneHandler04(ExCommand *ex) { case 33: { - g_vars->scene04_dudePosX = g_fullpipe->_aniMan->_ox; - g_vars->scene04_dudePosY = g_fullpipe->_aniMan->_oy; + g_vars->scene04_dudePosX = g_fp->_aniMan->_ox; + g_vars->scene04_dudePosY = g_fp->_aniMan->_oy; int res = 0; - if (g_fullpipe->_aniMan2) { - if (g_fullpipe->_aniMan->_ox < g_fullpipe->_sceneRect.left + 200) { - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan->_ox - g_fullpipe->_sceneRect.left - 300; - g_fullpipe->_aniMan->_ox = g_vars->scene04_dudePosX; + if (g_fp->_aniMan2) { + if (g_fp->_aniMan->_ox < g_fp->_sceneRect.left + 200) { + g_fp->_currentScene->_x = g_fp->_aniMan->_ox - g_fp->_sceneRect.left - 300; + g_fp->_aniMan->_ox = g_vars->scene04_dudePosX; } - if (g_fullpipe->_aniMan->_ox > g_fullpipe->_sceneRect.right - 200) { - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan->_ox - g_fullpipe->_sceneRect.right + 300; + if (g_fp->_aniMan->_ox > g_fp->_sceneRect.right - 200) { + g_fp->_currentScene->_x = g_fp->_aniMan->_ox - g_fp->_sceneRect.right + 300; } res = 1; if (g_vars->scene04_soundPlaying) { - if (g_fullpipe->_aniMan->_movement) { - if (g_fullpipe->_aniMan->_movement->_id == MV_MAN_TOLADDER) { - g_fullpipe->_aniMan2 = 0; + if (g_fp->_aniMan->_movement) { + if (g_fp->_aniMan->_movement->_id == MV_MAN_TOLADDER) { + g_fp->_aniMan2 = 0; - if (g_fullpipe->_sceneRect.left > 380) - g_fullpipe->_currentScene->_x = 380 - g_fullpipe->_sceneRect.left; + if (g_fp->_sceneRect.left > 380) + g_fp->_currentScene->_x = 380 - g_fp->_sceneRect.left; } } } } else { - if (g_fullpipe->_aniMan->_movement && g_fullpipe->_aniMan->_movement->_id == MV_MAN_GOD) - g_fullpipe->_aniMan2 = g_fullpipe->_aniMan; + if (g_fp->_aniMan->_movement && g_fp->_aniMan->_movement->_id == MV_MAN_GOD) + g_fp->_aniMan2 = g_fp->_aniMan; } sceneHandler04_springWobble(); - if (g_vars->scene04_var07 && !g_vars->scene04_var09) - sceneHandler04_sub5(); + if (g_vars->scene04_var07 && !g_vars->scene04_handIsDown) + sceneHandler04_leaveScene(); - if (g_vars->scene04_var12) + if (g_vars->scene04_bottleIsDropped) sceneHandler04_liftBottle(); - if (g_vars->scene04_var08) + if (g_vars->scene04_ladderClickable) sceneHandler04_clickLadder(); - if (g_vars->scene04_var10 && g_vars->scene04_hand->_movement) - sceneHandler04_sub1(0); + if (g_vars->scene04_dudeInBottle && g_vars->scene04_hand->_movement) + sceneHandler04_animOutOfBottle(0); - if (g_vars->scene04_coinPut && g_vars->scene04_var18 && !g_vars->scene04_var09 && !g_vars->scene04_soundPlaying) + if (g_vars->scene04_coinPut && g_vars->scene04_clockCanGo && !g_vars->scene04_handIsDown && !g_vars->scene04_soundPlaying) sceneHandler04_goClock(); if (g_vars->scene04_dudeOnLadder) { if (!g_vars->scene04_soundPlaying) { - g_fullpipe->startSceneTrack(); + g_fp->startSceneTrack(); - g_fullpipe->_behaviorManager->updateBehaviors(); + g_fp->_behaviorManager->updateBehaviors(); return res; } - g_vars->scene04_var14++; + g_vars->scene04_bigBallCounter++; - if (g_vars->scene04_var14 > 600) - sceneHandler04_sub17(); + if (g_vars->scene04_bigBallCounter > 600) + sceneHandler04_bigBallWalkIn(); } if (g_vars->scene04_soundPlaying) { - g_fullpipe->_behaviorManager->updateBehaviors(); + g_fp->_behaviorManager->updateBehaviors(); return res; } - g_fullpipe->startSceneTrack(); + g_fp->startSceneTrack(); - g_fullpipe->_behaviorManager->updateBehaviors(); + g_fp->_behaviorManager->updateBehaviors(); return res; } case 29: { - int picid = g_fullpipe->_currentScene->getPictureObjectIdAtPos(ex->_sceneClickX, ex->_sceneClickY); + int picid = g_fp->_currentScene->getPictureObjectIdAtPos(ex->_sceneClickX, ex->_sceneClickY); - if (g_vars->scene04_var10) { - sceneHandler04_sub1(ex); + if (g_vars->scene04_dudeInBottle) { + sceneHandler04_animOutOfBottle(ex); break; } if (picid == PIC_SC4_LADDER) { - if (!g_vars->scene04_var04) { + if (!g_vars->scene04_kozyawkaOnLadder) { g_vars->scene04_sceneClickX = ex->_sceneClickX; g_vars->scene04_sceneClickY = ex->_sceneClickY; @@ -1031,21 +1449,21 @@ int sceneHandler04(ExCommand *ex) { break; } - StaticANIObject *ani = g_fullpipe->_currentScene->getStaticANIObjectAtPos(ex->_sceneClickX, ex->_sceneClickY); + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObjectAtPos(ex->_sceneClickX, ex->_sceneClickY); if ((ani && ani->_id == ANI_PLANK) || picid == PIC_SC4_PLANK) { sceneHandler04_clickPlank(); ex->_messageKind = 0; } else if (g_vars->scene04_dudeOnLadder) { - sceneHandler04_sub8(ex); - } else if (!ani || !canInteractAny(g_fullpipe->_aniMan, ani, ex->_keyCode)) { - PictureObject *pic = g_fullpipe->_currentScene->getPictureObjectById(picid, 0); - - if (!pic || !canInteractAny(g_fullpipe->_aniMan, pic,ex->_keyCode)) { - if ((g_fullpipe->_sceneRect.right - ex->_sceneClickX < 47 && g_fullpipe->_sceneRect.right < g_fullpipe->_sceneWidth - 1) - || (ex->_sceneClickX - g_fullpipe->_sceneRect.left < 47 && g_fullpipe->_sceneRect.left > 0)) - g_fullpipe->processArcade(ex); + sceneHandler04_leaveLadder(ex); + } else if (!ani || !canInteractAny(g_fp->_aniMan, ani, ex->_keyCode)) { + PictureObject *pic = g_fp->_currentScene->getPictureObjectById(picid, 0); + + if (!pic || !canInteractAny(g_fp->_aniMan, pic,ex->_keyCode)) { + if ((g_fp->_sceneRect.right - ex->_sceneClickX < 47 && g_fp->_sceneRect.right < g_fp->_sceneWidth - 1) + || (ex->_sceneClickX - g_fp->_sceneRect.left < 47 && g_fp->_sceneRect.left > 0)) + g_fp->processArcade(ex); } } } @@ -1061,8 +1479,8 @@ int sceneHandler04(ExCommand *ex) { break; case MSG_SC4_HANDOVER: - g_vars->scene04_var09 = 0; - g_vars->scene04_var19 = 1; + g_vars->scene04_handIsDown = false; + g_vars->scene04_objectIsTaken = true; break; case MSG_SC4_DROPBOTTLE: @@ -1071,14 +1489,14 @@ int sceneHandler04(ExCommand *ex) { case MSG_SC4_COINOUT: g_vars->scene04_clock->changeStatics2(ST_CLK_CLOSED); - g_vars->scene04_coinPut = 0; + g_vars->scene04_coinPut = false; sceneHandler04_stopSound(); - if (g_vars->scene04_kozyawkiAni.size() && !g_vars->scene04_var02) { - g_vars->scene04_var09 = 1; + if (g_vars->scene04_kozyawkiAni.size() && !g_vars->scene04_bottleIsTaken) { + g_vars->scene04_handIsDown = true; - if (g_vars->scene04_var10) - sceneHandler04_sub1(0); + if (g_vars->scene04_dudeInBottle) + sceneHandler04_animOutOfBottle(0); sceneHandler04_handTake(); } @@ -1089,10 +1507,10 @@ int sceneHandler04(ExCommand *ex) { { ExCommand *exnew; - if (g_vars->scene04_var11) { - sceneHandler04_sub9(g_vars->scene04_var24); + if (g_vars->scene04_kozHeadRaised) { + sceneHandler04_putKozyawkaBack(g_vars->scene04_lastKozyawka); - g_vars->scene04_var11 = 0; + g_vars->scene04_kozHeadRaised = 0; exnew = new ExCommand(0, 35, SND_4_010, 0, 0, 0, 1, 0, 0, 0); } else { @@ -1130,7 +1548,7 @@ int sceneHandler04(ExCommand *ex) { break; case MSG_SC4_COINPUT: - g_vars->scene04_coinPut = 1; + g_vars->scene04_coinPut = true; break; } diff --git a/engines/fullpipe/scenes/scene05.cpp b/engines/fullpipe/scenes/scene05.cpp new file mode 100644 index 0000000000..c6e21daf1e --- /dev/null +++ b/engines/fullpipe/scenes/scene05.cpp @@ -0,0 +1,386 @@ +/* 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. + * + * 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. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objects.h" +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" +#include "fullpipe/statics.h" +#include "fullpipe/scene.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/messages.h" +#include "fullpipe/floaters.h" +#include "fullpipe/behavior.h" + +namespace Fullpipe { + +void scene05_initScene(Scene *sc) { + g_vars->scene05_handle = sc->getStaticANIObject1ById(ANI_HANDLE, -1); + g_vars->scene05_wacko = sc->getStaticANIObject1ById(ANI_OTMOROZ, -1); + g_vars->scene05_bigHatch = sc->getStaticANIObject1ById(ANI_BIGLUK, -1); + + + g_vars->scene05_wackoTicker = 0; + g_vars->scene05_handleFlipper = 1; + g_vars->scene05_floatersTicker = 1000; + + Scene *oldscene = g_fp->_currentScene; + + g_fp->_currentScene = sc; + + if (g_fp->getObjectState(sO_WeirdWacko) == g_fp->getObjectEnumState(sO_WeirdWacko, sO_InGlasses)) { + g_vars->scene05_wacko->changeStatics2(ST_OTM_GLS_LEFT); + g_vars->scene05_bigHatch->changeStatics2(ST_BLK_CLOSED); + + g_vars->scene05_handle->changeStatics2(ST_HDL_UP); + g_vars->scene05_handle->_flags |= 4; + } else if (g_fp->getObjectState(sO_WeirdWacko) == g_fp->getObjectEnumState(sO_WeirdWacko, sO_WithDrawer)) { + g_vars->scene05_wacko->changeStatics2(ST_OTM_BOX_LEFT); + g_vars->scene05_bigHatch->changeStatics2(ST_BLK_CLOSED); + g_vars->scene05_handle->changeStatics2(ST_HDL_UP); + g_vars->scene05_handle->_flags |= 4; + } else { + g_vars->scene05_wacko->changeStatics2(ST_OTM_VNT_LEFT); + + if (g_fp->getObjectState(sO_WeirdWacko) != g_fp->getObjectEnumState(sO_WeirdWacko, sO_WithPlunger)) { + g_vars->scene05_handle->changeStatics2(ST_HDL_BROKEN); + g_vars->scene05_bigHatch->changeStatics2(ST_BLK_CLOSED); + } + } + + g_fp->_currentScene = oldscene; +} + +void sceneHandler05_makeManFlight() { + int qid; + + if (!g_vars->scene05_bigHatch->_statics || g_vars->scene05_bigHatch->_statics->_staticsId != ST_BLK_OPEN) + qid = QU_SC5_MANBUMP; + else + qid = QU_SC5_MANFLY; + + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(qid), 0, 0); + + mq->setFlags(mq->getFlags() | 1); + + mq->chain(0); +} + +void sceneHandler05_makeWackoFeedback() { + int staticsId1; + int staticsId2; + + if (g_fp->getObjectState(sO_WeirdWacko) == g_fp->getObjectEnumState(sO_WeirdWacko, sO_InGlasses)) { + staticsId1 = ST_OTM_GLS_LEFT; + staticsId2 = (g_vars->scene05_handle->_statics->_staticsId == ST_HDL_DOWN) ? MV_OTM_HANDLEUP : MV_OTM_HANDLEDOWN; + } else if (g_fp->getObjectState(sO_WeirdWacko) != g_fp->getObjectEnumState(sO_WeirdWacko, sO_WithDrawer)) { + return; + } else { + staticsId1 = ST_OTM_BOX_LEFT; + staticsId2 = (g_vars->scene05_handle->_statics->_staticsId == ST_HDL_DOWN) ? MV_OTM_BOXHANDLEUP : MV_OTM_BOXHANDLEDOWN; + } + + if (g_vars->scene05_wacko->_movement) + g_vars->scene05_wacko->changeStatics2(g_vars->scene05_wacko->_movement->_staticsObj2->_staticsId); + + if (staticsId1 == g_vars->scene05_wacko->_statics->_staticsId) { + g_vars->scene05_wacko->startAnim(staticsId2, 0, -1); + } else { + MessageQueue *mq = g_vars->scene05_wacko->changeStatics1(staticsId1); + + if (mq) { + mq->setFlags(mq->getFlags() | 1); + + ExCommand *ex = new ExCommand(0, 17, MSG_SC5_MAKEOTMFEEDBACK, 0, 0, 0, 1, 0, 0, 0); + + ex->_excFlags |= 2; + + mq->addExCommandToEnd(ex); + mq->_isFinished = 0; + } + } +} + +void sceneHandler05_resetTicks() { + if (g_fp->_aniMan->_movement && (g_fp->_aniMan->_movement->_id == MV_MANHDL_HANDLEUP + || g_fp->_aniMan->_movement->_id == MV_MANHDL_HANDLEDOWN)) + g_vars->scene05_wackoTicker = g_fp->_updateTicks; + else + g_vars->scene05_wackoTicker = 0; +} + +void sceneHandler05_genFlies() { + if (g_vars->scene05_floatersTicker <= 1000) + return; + + if (g_fp->_rnd->getRandomNumber(1)) { + int numFlies = g_fp->_rnd->getRandomNumber(3) + 1; + + for (int i = 0; i < numFlies; i++) { + int x = g_fp->_rnd->getRandomNumber(55) + 538; + int y = g_fp->_rnd->getRandomNumber(60) + i * 30 + 520; + + g_fp->_floaters->genFlies(g_fp->_currentScene, x, y, 5, 1); + g_fp->_floaters->_array2.back()->val2 = 585; + g_fp->_floaters->_array2.back()->val3 = -70; + g_fp->_floaters->_array2.back()->val11 = 8.0; + } + } + + g_vars->scene05_floatersTicker = 0; +} + +void sceneHandler05_showHandle() { + g_fp->_currentScene->getStaticANIObject1ById(ANI_HANDLE, -1)->show1(-1, -1, -1, 0); +} + +void sceneHandler05_handleDown() { + StaticANIObject *hatch = g_fp->_currentScene->getStaticANIObject1ById(ANI_BIGLUK, -1); + + hatch->changeStatics2(ST_BLK_CLOSED); + hatch->startAnim(MV_BLK_OPEN, 0, -1); + + sceneHandler05_resetTicks(); + sceneHandler05_genFlies(); +} + +void sceneHandler05_hideHandle() { + g_fp->_currentScene->getStaticANIObject1ById(ANI_HANDLE, -1)->hide(); +} + +void sceneHandler05_handleUp() { + StaticANIObject *hatch = g_fp->_currentScene->getStaticANIObject1ById(ANI_BIGLUK, -1); + + hatch->changeStatics2(ST_BLK_OPEN); + hatch->startAnim(MV_BLK_CLOSE, 0, -1); + + sceneHandler05_resetTicks(); +} + +void sceneHandler05_testHatch(ExCommand *inex) { + ExCommand *ex; + + if (g_fp->_currentScene->getStaticANIObject1ById(ANI_BIGLUK, -1)->_statics->_staticsId == ST_BLK_CLOSED) { + ex = new ExCommand(SC_5, 17, 61, 0, 0, 0, 1, 0, 0, 0); + ex->_keyCode = TrubaLeft; + ex->_excFlags |= 2; + ex->postMessage(); + + return; + } + + StaticANIObject *wacko = g_fp->_currentScene->getStaticANIObject1ById(ANI_OTMOROZ, -1); + + if (wacko->_movement) + wacko->changeStatics2(wacko->_movement->_staticsObj2->_staticsId); + + if (g_fp->getObjectState(sO_WeirdWacko) == g_fp->getObjectEnumState(sO_WeirdWacko, sO_InGlasses)) { + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(inex->_parId); + + if (mq) + mq->deleteExCommandByIndex(mq->getCount() - 1, 1); + + if (wacko->_statics->_staticsId != ST_OTM_GLS_LEFT) { + mq = wacko->changeStatics1(ST_OTM_GLS_LEFT); + + if (!mq) { + wacko->changeStatics2(ST_OTM_GLS_LEFT); + mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + } + + mq->setFlags(mq->getFlags() | 1); + + ex = new ExCommand(ANI_OTMOROZ, 1, MV_OTM_HANDLEUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2u; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(SC_5, 17, 61, 0, 0, 0, 1, 0, 0, 0); + ex->_keyCode = TrubaLeft; + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + mq->_isFinished = 0; + return; + } + + mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + mq->setFlags(mq->getFlags() | 1); + + ex = new ExCommand(ANI_OTMOROZ, 1, MV_OTM_HANDLEUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(SC_5, 17, 61, 0, 0, 0, 1, 0, 0, 0); + ex->_keyCode = TrubaLeft; + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + if (!mq->chain(wacko)) + delete mq; + } else if (g_fp->getObjectState(sO_WeirdWacko) == g_fp->getObjectEnumState(sO_WeirdWacko, sO_WithDrawer)) { + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(inex->_parId); + + if (mq) + mq->deleteExCommandByIndex(mq->getCount() - 1, 1); + + if (wacko->_statics->_staticsId != ST_OTM_BOX_LEFT) { + mq = wacko->changeStatics1(ST_OTM_BOX_LEFT); + if (!mq) { + wacko->changeStatics2(ST_OTM_BOX_LEFT); + mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + } + + mq->setFlags(mq->getFlags() | 1); + + ex = new ExCommand(ANI_OTMOROZ, 1, MV_OTM_BOXHANDLEUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(SC_5, 17, 61, 0, 0, 0, 1, 0, 0, 0); + ex->_keyCode = TrubaLeft; + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + mq->_isFinished = 0; + + return; + } + + mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + mq->setFlags(mq->getFlags() | 1); + + ex = new ExCommand(ANI_OTMOROZ, 1, MV_OTM_BOXHANDLEUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(SC_5, 17, 61, 0, 0, 0, 1, 0, 0, 0); + ex->_keyCode = TrubaLeft; + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + if (!mq->chain(wacko)) + delete mq; + + return; + } else { + ex = new ExCommand(SC_5, 17, 61, 0, 0, 0, 1, 0, 0, 0); + ex->_keyCode = TrubaLeft; + ex->_excFlags |= 2; + ex->postMessage(); + + return; + } +} + + +int sceneHandler05(ExCommand *ex) { + if (ex->_messageKind != 17) + return 0; + + switch (ex->_messageNum) { + case MSG_SC5_BGRSOUNDOFF: + g_fp->stopAllSoundInstances(SND_5_026); + break; + + case MSG_SC5_BGRSOUNDON: + g_fp->playSound(SND_5_026, 1); + break; + + case MSG_SC5_MAKEMANFLIGHT: + sceneHandler05_makeManFlight(); + break; + + case MSG_SC5_MAKEOTMFEEDBACK: + if (!g_fp->_aniMan->_movement || (g_fp->_aniMan->_movement->_id != MV_MANHDL_HANDLEUP + && g_fp->_aniMan->_movement->_id != MV_MANHDL_HANDLEDOWN)) { + sceneHandler05_makeWackoFeedback(); + g_vars->scene05_wackoTicker = 0; + } + break; + + case MSG_SC5_SHOWHANDLE: + sceneHandler05_showHandle(); + break; + + case MSG_SC5_HANDLEDOWN: + g_vars->scene05_handle->changeStatics2(ST_HDL_DOWN); + sceneHandler05_handleDown(); + break; + + case MSG_SC5_HIDEHANDLE: + sceneHandler05_hideHandle(); + break; + + case MSG_SC5_HANDLEUP: + g_vars->scene05_handle->changeStatics2(ST_HDL_UP); + sceneHandler05_handleUp(); + break; + + case MSG_SC5_TESTLUK: + sceneHandler05_testHatch(ex); + break; + + case 33: + { + int res = 0; + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; + + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; + + res = 1; + } + + if (g_vars->scene05_wackoTicker) { + if ((g_fp->_updateTicks - g_vars->scene05_wackoTicker) > 62) { + if (!g_fp->_aniMan->_movement || (g_fp->_aniMan->_movement->_id != MV_MANHDL_HANDLEUP + && g_fp->_aniMan->_movement->_id != MV_MANHDL_HANDLEDOWN)) { + if (g_vars->scene05_handleFlipper % 2) + sceneHandler05_makeWackoFeedback(); + + g_vars->scene05_wackoTicker = 0; + + ++g_vars->scene05_handleFlipper; + } + } + } + + ++g_vars->scene05_floatersTicker; + + g_fp->_floaters->update(); + + g_fp->_behaviorManager->updateBehaviors(); + + g_fp->startSceneTrack(); + + return res; + } + } + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene06.cpp b/engines/fullpipe/scenes/scene06.cpp new file mode 100644 index 0000000000..c352d27dd6 --- /dev/null +++ b/engines/fullpipe/scenes/scene06.cpp @@ -0,0 +1,770 @@ +/* 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. + * + * 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. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objects.h" +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" +#include "fullpipe/gfx.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/statics.h" +#include "fullpipe/scene.h" +#include "fullpipe/messages.h" +#include "fullpipe/gameloader.h" +#include "fullpipe/behavior.h" +#include "fullpipe/interaction.h" + +namespace Fullpipe { + +void scene06_initMumsy() { + g_vars->scene06_mumsyJumpFw = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene06_mumsy, ST_MOM_STANDS, QU_MOM_JUMPFW); + g_vars->scene06_mumsyJumpBk = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene06_mumsy, ST_MOM_STANDS, QU_MOM_JUMPBK); + g_vars->scene06_mumsyJumpFwPercent = g_vars->scene06_mumsyJumpFw->_percent; + g_vars->scene06_mumsyJumpBkPercent = g_vars->scene06_mumsyJumpBk->_percent; +} + +int scene06_updateCursor() { + g_fp->updateCursorCommon(); + + if (g_vars->scene06_arcadeEnabled) { + if (g_vars->scene06_aimingBall) { + g_fp->_cursorId = PIC_CSR_ARCADE2_D; + + return PIC_CSR_ARCADE2_D; + } + if (g_fp->_aniMan == (StaticANIObject *)g_fp->_objectAtCursor) { + if (g_fp->_aniMan->_statics->_staticsId == ST_MAN6_BALL && g_fp->_cursorId == PIC_CSR_DEFAULT) { + g_fp->_cursorId = PIC_CSR_ITN; + + return PIC_CSR_ITN; + } + } else if (g_fp->_objectAtCursor && (StaticANIObject *)g_fp->_objectAtCursor == g_vars->scene06_currentBall + && g_fp->_cursorId == PIC_CSR_DEFAULT) { + g_fp->_cursorId = PIC_CSR_ITN; + } + } + + return g_fp->_cursorId; +} + +void sceneHandler06_setExits(Scene *sc) { + MotionController *mc = getSc2MctlCompoundBySceneId(sc->_sceneId); + + mc->enableLinks(sO_CloseThing, (g_fp->getObjectState(sO_BigMumsy) != g_fp->getObjectEnumState(sO_BigMumsy, sO_IsGone))); + mc->enableLinks(sO_CloseThing2, g_vars->scene06_arcadeEnabled); +} + +void sceneHandler06_winArcade() { + g_fp->setObjectState(sO_BigMumsy, g_fp->getObjectEnumState(sO_BigMumsy, sO_IsGone)); + + if (g_fp->getObjectState(sO_ClockAxis) == g_fp->getObjectEnumState(sO_ClockAxis, sO_IsNotAvailable)) + g_fp->setObjectState(sO_ClockAxis, g_fp->getObjectEnumState(sO_ClockAxis, sO_WithoutHandle)); + + if (g_vars->scene06_arcadeEnabled) { + g_fp->_aniMan->_callback2 = 0; + + g_fp->_aniMan->changeStatics2(ST_MAN_RIGHT | 0x4000); + + if (g_vars->scene06_someBall) { + g_vars->scene06_someBall->_flags &= 0xFFFB; + + g_vars->scene06_balls.push_back(g_vars->scene06_someBall); + + g_vars->scene06_someBall = 0; + } + + if (g_vars->scene06_flyingBall) { + g_vars->scene06_flyingBall->_flags &= 0xFFFB; + + g_vars->scene06_balls.push_back(g_vars->scene06_flyingBall); + + g_vars->scene06_flyingBall = 0; + } + + if (g_vars->scene06_ballInHands) { + g_vars->scene06_ballInHands->_flags &= 0xFFFB; + + g_vars->scene06_balls.push_back(g_vars->scene06_ballInHands); + + g_vars->scene06_ballInHands = 0; + } + + g_vars->scene06_arcadeEnabled = false; + g_vars->scene06_aimingBall = false; + } + + g_vars->scene06_mumsy->_flags &= 0xFFFB; + + sceneHandler06_setExits(g_fp->_currentScene); + + getCurrSceneSc2MotionController()->setEnabled(); + getGameLoaderInteractionController()->enableFlag24(); +} + +void sceneHandler06_enableDrops() { + chainQueue(QU_SC6_DROPS, 0); + + g_vars->scene06_mumsy->changeStatics2(ST_MOM_SITS); + g_fp->setObjectState(sO_BigMumsy, g_fp->getObjectEnumState(sO_BigMumsy, sO_IsPlaying)); + + chainQueue(QU_MOM_STANDUP, 1); + + g_vars->scene06_arcadeEnabled = true; + g_vars->scene06_numBallsGiven = 0; + g_vars->scene06_mumsyPos = 0; + g_vars->scene06_mumsyNumBalls = 0; + g_vars->scene06_mumsyGotBall = false; + + sceneHandler06_setExits(g_fp->_currentScene); +} + +void sceneHandler06_mumsyBallTake() { + int momAni = 0; + + switch (g_vars->scene06_mumsyNumBalls) { + case 1: + momAni = MV_MOM_TAKE1; + break; + case 2: + momAni = MV_MOM_TAKE2; + break; + case 3: + momAni = MV_MOM_TAKE3; + break; + case 4: + momAni = MV_MOM_TAKE4; + break; + case 5: + momAni = MV_MOM_TAKE5; + break; + } + + MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + + ExCommand *ex = new ExCommand(ANI_MAMASHA, 2, 50, 0, 0, 0, 1, 0, 0, 0); + + ex->_excFlags = 2u; + mq->addExCommandToEnd(ex); + + if (g_vars->scene06_mumsyNumBalls >= 5) { + g_fp->setObjectState(sO_BigMumsy, g_fp->getObjectEnumState(sO_BigMumsy, sO_IsGone)); + + if (g_fp->getObjectState(sO_ClockAxis) == g_fp->getObjectEnumState(sO_ClockAxis, sO_IsNotAvailable)) + g_fp->setObjectState(sO_ClockAxis, g_fp->getObjectEnumState(sO_ClockAxis, sO_WithoutHandle)); + + ex = new ExCommand(ANI_MAMASHA, 1, momAni, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + if (g_vars->scene06_mumsyPos + 3 >= 0) { + ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_STARTBK, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2u; + mq->addExCommandToEnd(ex); + + for (int i = 0; i < g_vars->scene06_mumsyPos + 3; i++) { + ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_CYCLEBK, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + } + + ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_STOPBK, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + } + + ex = new ExCommand(0, 18, QU_MOM_TOLIFT, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + mq->addExCommandToEnd(ex); + } else { + if (momAni) { + ex = new ExCommand(ANI_MAMASHA, 1, momAni, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + } + + if (g_vars->scene06_mumsyPos < 0) { + for (int i = 0; i > g_vars->scene06_mumsyPos; i--) { + ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_JUMPFW, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + } + } else if (g_vars->scene06_mumsyPos > 0) { + for (int i = 0; i < g_vars->scene06_mumsyPos; i++) { + ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_JUMPBK, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + } + } + + ex = new ExCommand(0, 18, QU_MOM_SITDOWN, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3u; + mq->addExCommandToEnd(ex); + } + + mq->setFlags(mq->getFlags() | 1); + mq->chain(0); + + g_vars->scene06_mumsyNumBalls = 0; + g_vars->scene06_arcadeEnabled = false; + + g_fp->_aniMan2 = 0; +} + +void sceneHandler06_spinHandle() { + int tummy = g_fp->getObjectState(sO_TummyTrampie); + + if (tummy == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsEating)) + g_fp->setObjectState(sO_TummyTrampie, g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsSleeping)); + else if (tummy == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsSleeping)) + g_fp->setObjectState(sO_TummyTrampie, g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsDrinking)); + else if (tummy == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsDrinking)) + g_fp->setObjectState(sO_TummyTrampie, g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsScratchingBelly)); + else if (tummy == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsScratchingBelly)) + g_fp->setObjectState(sO_TummyTrampie, g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsEating)); +} + +void sceneHandler06_uPipeClick() { + if (getGameLoaderInteractionController()->_flag24) + handleObjectInteraction(g_fp->_aniMan2, g_fp->_currentScene->getPictureObjectById(PIC_SC6_LADDER, 0), 0); +} + +void sceneHandler06_buttonPush() { + g_vars->scene06_invHandle = g_fp->_currentScene->getStaticANIObject1ById(ANI_INV_HANDLE, -1); + + if (g_vars->scene06_invHandle) + if (g_vars->scene06_invHandle->_flags & 4) + if (g_vars->scene06_invHandle->_statics) + if (g_vars->scene06_invHandle->_statics->_staticsId == ST_HDL_PLUGGED) + chainQueue(QU_SC6_FALLHANDLE, 1); +} + +void sceneHandler06_showNextBall() { + if (g_vars->scene06_balls.size()) { + g_vars->scene06_currentBall = new StaticANIObject(g_vars->scene06_balls.front()); + g_vars->scene06_balls.remove_at(0); + + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC6_SHOWNEXTBALL), 0, 1); + + mq->replaceKeyCode(-1, g_vars->scene06_currentBall->_okeyCode); + mq->chain(0); + + ++g_vars->scene06_numBallsGiven; + } +} + +void sceneHandler06_installHandle() { + chainQueue(QU_SC6_SHOWHANDLE, 0); +} + +int sceneHandler06_updateScreenCallback() { + int res; + + res = g_fp->drawArcadeOverlay(g_vars->scene06_arcadeEnabled); + + if (!res) + g_fp->_updateScreenCallback = 0; + + return res; +} + +void sceneHandler06_startAiming() { + if (g_vars->scene06_currentBall) { + g_vars->scene06_currentBall->hide(); + + g_fp->_aniMan->startAnim(MV_MAN6_TAKEBALL, 0, -1); + + g_vars->scene06_ballInHands = g_vars->scene06_currentBall; + g_vars->scene06_currentBall = 0; + + if (getCurrSceneSc2MotionController()->_isEnabled) + g_fp->_updateScreenCallback = sceneHandler06_updateScreenCallback; + + getCurrSceneSc2MotionController()->clearEnabled(); + getGameLoaderInteractionController()->disableFlag24(); + + g_vars->scene06_ballDrop->queueMessageQueue(0); + } +} + +void sceneHandler06_takeBall() { + if (g_vars->scene06_currentBall && !g_vars->scene06_currentBall->_movement && g_vars->scene06_currentBall->_statics->_staticsId == ST_NBL_NORM) { + if (abs(1158 - g_fp->_aniMan->_ox) > 1 + || abs(452 - g_fp->_aniMan->_oy) > 1 + || g_fp->_aniMan->_movement + || g_fp->_aniMan->_statics->_staticsId != (0x4000 | ST_MAN_RIGHT)) { + MessageQueue *mq = getCurrSceneSc2MotionController()->method34(g_fp->_aniMan, 1158, 452, 1, (0x4000 | ST_MAN_RIGHT)); + + if (mq) { + ExCommand *ex = new ExCommand(0, 17, MSG_SC6_TAKEBALL, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + mq->addExCommandToEnd(ex); + + postExCommand(g_fp->_aniMan->_id, 2, 1158, 452, 0, -1); + } + } else { + sceneHandler06_startAiming(); + } + } +} + +void sceneHandler06_aiming() { + if (g_vars->scene06_ballInHands) { + g_vars->scene06_ballDeltaX = 4 * g_fp->_aniMan->_movement->_currDynamicPhaseIndex + 16; + g_vars->scene06_ballDeltaY = 5 * (g_fp->_aniMan->_movement->_currDynamicPhaseIndex + 4); + + if (g_fp->_aniMan->_movement->_currDynamicPhaseIndex < 4) { + g_fp->_aniMan->_movement->setDynamicPhaseIndex(11); + + g_vars->scene06_aimingBall = false; + + return; + } + + g_fp->_aniMan->_movement->setDynamicPhaseIndex(9); + } + + g_vars->scene06_aimingBall = false; +} + +void sceneHandler06_ballStartFly() { + if (g_vars->scene06_ballInHands) { + g_vars->scene06_flyingBall = g_vars->scene06_ballInHands; + g_vars->scene06_ballInHands = 0; + g_vars->scene06_flyingBall->show1(g_fp->_aniMan->_ox - 60, g_fp->_aniMan->_oy - 60, -1, 0); + + g_vars->scene06_flyingBall->_priority = 27; + } +} + +void sceneHandler06_throwCallback(int *arg) { + if (g_vars->scene06_aimingBall) { + int dist = (g_fp->_mouseVirtY - g_vars->scene06_sceneClickY) + * (g_fp->_mouseVirtY - g_vars->scene06_sceneClickY) + + (g_fp->_mouseVirtX - g_vars->scene06_sceneClickX) + * (g_fp->_mouseVirtX - g_vars->scene06_sceneClickX); + + *arg = (int)(sqrt((double)dist) * 0.1); + + if (*arg > 8) + *arg = 8; + } else { + *arg = *arg + 1; + if (*arg == 12) + sceneHandler06_ballStartFly(); + } +} + +void sceneHandler06_throwBall() { + g_fp->_aniMan->_callback2 = sceneHandler06_throwCallback; + g_fp->_aniMan->startAnim(MV_MAN6_THROWBALL, 0, -1); + + g_vars->scene06_aimingBall = true; +} + +void sceneHandler06_eggieWalk() { + if (15 - g_vars->scene06_numBallsGiven >= 4 && !g_fp->_rnd->getRandomNumber(9)) { + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_EGGIE, -1); + + if (!ani || !(ani->_flags & 4)) { + if (g_vars->scene06_eggieDirection) + chainQueue(QU_EGG6_GOR, 0); + else + chainQueue(QU_EGG6_GOL, 0); + + g_vars->scene06_eggieTimeout = 0; + g_vars->scene06_eggieDirection = !g_vars->scene06_eggieDirection; + } + } +} + +void sceneHandler06_dropBall() { + if (g_vars->scene06_numBallsGiven >= 15 || g_vars->scene06_mumsyNumBalls >= 5) + g_vars->scene06_ballDrop->hide(); + else + chainQueue(QU_SC6_DROPS3, 0); +} + +void sceneHandler06_fallBall() { + g_vars->scene06_ballY = 475; + + g_vars->scene06_flyingBall->setOXY(g_vars->scene06_ballX, g_vars->scene06_ballY); + + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC6_FALLBALL), 0, 1); + + mq->replaceKeyCode(-1, g_vars->scene06_flyingBall->_okeyCode); + mq->chain(0); + + g_vars->scene06_balls.push_back(g_vars->scene06_flyingBall); + + g_vars->scene06_flyingBall = 0; + + sceneHandler06_dropBall(); + sceneHandler06_eggieWalk(); +} + +void sceneHandler06_catchBall() { + if (g_vars->scene06_flyingBall) { + g_vars->scene06_flyingBall->hide(); + + g_vars->scene06_balls.push_back(g_vars->scene06_flyingBall); + + g_vars->scene06_flyingBall = 0; + + g_vars->scene06_mumsyNumBalls++; + + if (g_vars->scene06_mumsy->_movement) { + Common::Point point; + + if (g_vars->scene06_mumsy->_movement->_id == MV_MOM_JUMPFW) { + if (g_vars->scene06_mumsy->_movement->_currDynamicPhaseIndex <= 5) { + g_vars->scene06_mumsy->_movement->calcSomeXY(point, 0); + + point.x = -point.x; + point.y = -point.y; + } else { + g_vars->scene06_mumsy->_movement->calcSomeXY(point, 1); + + g_vars->scene06_mumsyPos++; + } + } else if (g_vars->scene06_mumsy->_movement->_id == MV_MOM_JUMPBK) { + if (g_vars->scene06_mumsy->_movement->_currDynamicPhaseIndex <= 4) { + g_vars->scene06_mumsy->_movement->calcSomeXY(point, 0); + + point.x = -point.x; + point.y = -point.y; + } else { + g_vars->scene06_mumsy->_movement->calcSomeXY(point, 1); + + g_vars->scene06_mumsyPos--; + } + } + + g_vars->scene06_mumsy->changeStatics2(ST_MOM_STANDS); + g_vars->scene06_mumsy->setOXY(point.x + g_vars->scene06_mumsy->_ox, + point.y + g_vars->scene06_mumsy->_oy); + } else { + g_vars->scene06_mumsy->changeStatics2(ST_MOM_STANDS); + } + + chainQueue(QU_MOM_PUTBALL, 1); + g_vars->scene06_mumsyGotBall = true; + + sceneHandler06_dropBall(); + } +} + +void sceneHandler06_checkBallTarget(int par) { + int pixel; + + if (g_vars->scene06_ballY <= 475) { + if (g_vars->scene06_mumsy->getPixelAtPos(g_vars->scene06_ballX, g_vars->scene06_ballY, &pixel)) { + if (pixel) { + chainObjQueue(g_vars->scene06_mumsy, QU_MOM_JUMPBK, 0); + + sceneHandler06_catchBall(); + } + } + } else { + sceneHandler06_fallBall(); + } +} + +void scene06_initScene(Scene *sc) { + g_vars->scene06_mumsy = sc->getStaticANIObject1ById(ANI_MAMASHA, -1); + g_vars->scene06_someBall = 0; + g_vars->scene06_invHandle = sc->getStaticANIObject1ById(ANI_INV_HANDLE, -1); + g_vars->scene06_liftButton = sc->getStaticANIObject1ById(ANI_BUTTON_6, -1); + g_vars->scene06_ballDrop = sc->getStaticANIObject1ById(ANI_BALLDROP, -1); + g_vars->scene06_arcadeEnabled = false; + g_vars->scene06_aimingBall = false; + g_vars->scene06_currentBall = 0; + g_vars->scene06_ballInHands = 0; + g_vars->scene06_flyingBall = 0; + g_vars->scene06_balls.clear(); + g_vars->scene06_numBallsGiven = 0; + g_vars->scene06_mumsyNumBalls = 0; + g_vars->scene06_eggieTimeout = 0; + g_vars->scene06_eggieDirection = true; + + StaticANIObject *ball = sc->getStaticANIObject1ById(ANI_NEWBALL, -1); + + ball->hide(); + ball->_statics = ball->getStaticsById(ST_NBL_NORM); + g_vars->scene06_balls.push_back(ball); + + for (int i = 0; i < 3; i++) { + StaticANIObject *ball2 = new StaticANIObject(ball); + + ball2->hide(); + ball2->_statics = ball2->getStaticsById(ST_NBL_NORM); + + sc->addStaticANIObject(ball2, 1); + + g_vars->scene06_balls.push_back(ball2); + } + + if (g_fp->getObjectState(sO_BigMumsy) == g_fp->getObjectEnumState(sO_BigMumsy, sO_IsPlaying)) + g_fp->setObjectState(sO_BigMumsy, g_fp->getObjectEnumState(sO_BigMumsy, sO_IsSleeping)); + + if (g_fp->getObjectState(sO_BigMumsy) != g_fp->getObjectEnumState(sO_BigMumsy, sO_IsSleeping)) + g_vars->scene06_mumsy->hide(); + + g_fp->lift_setButton(sO_Level3, ST_LBN_3N); + g_fp->lift_sub5(sc, QU_SC6_ENTERLIFT, QU_SC6_EXITLIFT); + g_fp->initArcadeKeys("SC_6"); + + sceneHandler06_setExits(sc); + + g_fp->setArcadeOverlay(PIC_CSR_ARCADE2); +} + +int sceneHandler06(ExCommand *ex) { + if (ex->_messageKind != 17) + return 0; + + switch(ex->_messageNum) { + case MSG_LIFT_CLOSEDOOR: + g_fp->lift_closedoorSeq(); + break; + + case MSG_LIFT_EXITLIFT: + g_fp->lift_exitSeq(ex); + break; + + case MSG_CMN_WINARCADE: + sceneHandler06_winArcade(); + break; + + case MSG_LIFT_STARTEXITQUEUE: + g_fp->lift_startExitQueue(); + break; + + case MSG_SC6_RESTORESCROLL: + g_fp->_aniMan2 = g_fp->_aniMan; + getCurrSceneSc2MotionController()->setEnabled(); + getGameLoaderInteractionController()->enableFlag24(); + sceneHandler06_setExits(g_fp->_currentScene); + break; + + case MSG_SC6_STARTDROPS: + if (g_fp->getObjectState(sO_BigMumsy) == g_fp->getObjectEnumState(sO_BigMumsy, sO_IsSleeping)) + sceneHandler06_enableDrops(); + break; + + case MSG_SC6_TESTNUMBALLS: + g_vars->scene06_mumsyGotBall = false; + + if (g_vars->scene06_mumsyNumBalls < 5 || !g_vars->scene06_arcadeEnabled) + return 0; + + sceneHandler06_mumsyBallTake(); + break; + + case MSG_SC6_JUMPFW: + ++g_vars->scene06_mumsyPos; + break; + + case MSG_SC6_JUMPBK: + --g_vars->scene06_mumsyPos; + break; + + case MSG_LIFT_CLICKBUTTON: + g_fp->lift_animation3(); + break; + + case MSG_SPINHANDLE: + sceneHandler06_spinHandle(); + break; + + case MSG_LIFT_GO: + g_fp->lift_goAnimation(); + break; + + case MSG_SC6_UTRUBACLICK: + sceneHandler06_uPipeClick(); + break; + + case MSG_SC6_BTNPUSH: + sceneHandler06_buttonPush(); + break; + + case MSG_SC6_SHOWNEXTBALL: + sceneHandler06_showNextBall(); + break; + + case MSG_SC6_INSTHANDLE: + sceneHandler06_installHandle(); + break; + + case MSG_SC6_ENABLEDROPS: + sceneHandler06_enableDrops(); + break; + + case 64: + g_fp->lift_sub05(ex); + break; + + case MSG_SC6_TAKEBALL: + sceneHandler06_takeBall(); + break; + + case 30: + if (g_vars->scene06_aimingBall) { + sceneHandler06_aiming(); + break; + } + + if (!g_vars->scene06_arcadeEnabled) { + // Do nothing + break; + } + break; + + case 29: + { + StaticANIObject *st = g_fp->_currentScene->getStaticANIObjectAtPos(ex->_sceneClickX, ex->_sceneClickY); + + if (st) { + if (!g_vars->scene06_arcadeEnabled && st->_id == ANI_LIFTBUTTON) { + g_fp->lift_sub1(st); + ex->_messageKind = 0; + return 0; + } + + if (g_vars->scene06_currentBall == st) { + if (g_vars->scene06_numBallsGiven == 1) + sceneHandler06_takeBall(); + + ex->_messageKind = 0; + } else if (g_vars->scene06_ballInHands && g_fp->_aniMan == st && !g_fp->_aniMan->_movement && g_fp->_aniMan->_statics->_staticsId == ST_MAN6_BALL) { + g_vars->scene06_sceneClickX = ex->_sceneClickX; + g_vars->scene06_sceneClickY = ex->_sceneClickY; + + sceneHandler06_throwBall(); + } + } + + if (!st || !canInteractAny(g_fp->_aniMan, st, ex->_keyCode)) { + int picId = g_fp->_currentScene->getPictureObjectIdAtPos(ex->_sceneClickX, ex->_sceneClickY); + PictureObject *pic = g_fp->_currentScene->getPictureObjectById(picId, 0); + + if (!pic || !canInteractAny(g_fp->_aniMan, pic, ex->_keyCode)) { + if ((g_fp->_sceneRect.right - ex->_sceneClickX < 47 + && g_fp->_sceneRect.right < g_fp->_sceneWidth - 1) + || (ex->_sceneClickX - g_fp->_sceneRect.left < 47 && g_fp->_sceneRect.left > 0)) { + g_fp->processArcade(ex); + return 0; + } + } + } + } + + break; + + case 33: + { + int res = 0; + + if (g_fp->_aniMan2) { + int ox = g_fp->_aniMan2->_ox; + int oy = g_fp->_aniMan2->_oy; + + g_vars->scene06_manX = ox; + g_vars->scene06_manY = oy; + + if (g_vars->scene06_arcadeEnabled && oy <= 470 && ox >= 1088) { + if (ox < g_fp->_sceneRect.left + 600) { + g_fp->_currentScene->_x = ox - g_fp->_sceneRect.left - 700; + ox = g_vars->scene06_manX; + } + + if (ox > g_fp->_sceneRect.right - 50) + g_fp->_currentScene->_x = ox - g_fp->_sceneRect.right + 70; + } else { + if (ox < g_fp->_sceneRect.left + 200) { + g_fp->_currentScene->_x = ox - g_fp->_sceneRect.left - 300; + ox = g_vars->scene06_manX; + } + + if (ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = ox - g_fp->_sceneRect.right + 300; + } + + res = 1; + } + if (g_vars->scene06_arcadeEnabled) { + if (g_vars->scene06_mumsyPos > -3) + g_vars->scene06_mumsyJumpBk->_percent = g_vars->scene06_mumsyJumpBkPercent; + else + g_vars->scene06_mumsyJumpBk->_percent = 0; + + if (g_vars->scene06_mumsyPos < 4) + g_vars->scene06_mumsyJumpFw->_percent = g_vars->scene06_mumsyJumpFwPercent; + else + g_vars->scene06_mumsyJumpFw->_percent = 0; + + if (g_vars->scene06_aimingBall) { + g_vars->scene06_eggieTimeout++; + + if (g_vars->scene06_eggieTimeout >= 600) + sceneHandler06_eggieWalk(); + } + } else { + g_vars->scene06_mumsyJumpFw->_percent = 0; + g_vars->scene06_mumsyJumpBk->_percent = 0; + } + + if (g_vars->scene06_flyingBall) { + g_vars->scene06_ballX = g_vars->scene06_flyingBall->_ox - g_vars->scene06_ballDeltaX; + g_vars->scene06_ballY = g_vars->scene06_flyingBall->_oy - g_vars->scene06_ballDeltaY; + + g_vars->scene06_flyingBall->setOXY(g_vars->scene06_ballX, g_vars->scene06_ballY); + + if (g_vars->scene06_ballDeltaX >= 2) + g_vars->scene06_ballDeltaX -= 2; + + g_vars->scene06_ballDeltaY -= 5; + + sceneHandler06_checkBallTarget(g_vars->scene06_ballDeltaX); + } + if (g_vars->scene06_arcadeEnabled + && !g_vars->scene06_currentBall + && !g_vars->scene06_ballInHands + && !g_vars->scene06_flyingBall + && g_vars->scene06_numBallsGiven >= 15 + && !g_vars->scene06_ballDrop->_movement + && !g_vars->scene06_mumsy->_movement + && !g_vars->scene06_mumsyGotBall) + sceneHandler06_mumsyBallTake(); + g_fp->_behaviorManager->updateBehaviors(); + g_fp->startSceneTrack(); + + return res; + } + } + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene07.cpp b/engines/fullpipe/scenes/scene07.cpp new file mode 100644 index 0000000000..207189d151 --- /dev/null +++ b/engines/fullpipe/scenes/scene07.cpp @@ -0,0 +1,175 @@ +/* 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. + * + * 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. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objects.h" +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/scene.h" +#include "fullpipe/statics.h" +#include "fullpipe/messages.h" +#include "fullpipe/behavior.h" + +namespace Fullpipe { + +void scene07_initScene(Scene *sc) { + g_vars->scene07_lukeAnim = 0; + g_vars->scene07_lukePercent = 0; + g_vars->scene07_plusMinus = sc->getStaticANIObject1ById(ANI_PLUSMINUS, -1); + + if (g_fp->getObjectState(sO_Guard_1) == g_fp->getObjectEnumState(sO_Guard_1, sO_Off)) + g_vars->scene07_plusMinus->_statics = g_vars->scene07_plusMinus->getStaticsById(ST_PMS_MINUS); + else + g_vars->scene07_plusMinus->_statics = g_vars->scene07_plusMinus->getStaticsById(ST_PMS_PLUS); + + if (g_fp->getObjectState(sO_HareTheNooksiter) == g_fp->getObjectEnumState(sO_HareTheNooksiter, sO_WithoutHandle)) { + Scene *oldsc = g_fp->_currentScene; + + g_fp->_currentScene = sc; + + sc->getStaticANIObject1ById(ANI_CORNERSITTER, -1)->changeStatics2(ST_CST_HANDLELESS); + + g_fp->_currentScene = oldsc; + } +} + +void sceneHandler07_openLuke() { + StaticANIObject *luke = g_fp->_currentScene->getStaticANIObject1ById(ANI_LUKE, -1); + + luke->changeStatics2(ST_LUK_OPEN); + luke->show1(-1, -1, -1, 0); + + if (g_vars->scene07_lukeAnim) { + g_vars->scene07_lukeAnim->_percent = g_vars->scene07_lukePercent; + } else { + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_CORNERSITTER, -1); + + g_vars->scene07_lukeAnim = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(ani, ST_CST_HANDLELESS, QU_CST_CLOSELUKE); + + g_vars->scene07_lukeAnim->_percent = g_vars->scene07_lukePercent; + } +} + +void sceneHandler07_closeLuke() { + g_fp->_currentScene->getStaticANIObject1ById(ANI_LUKE, -1)->changeStatics2(ST_LUK_CLOSED); + + if (!g_vars->scene07_lukeAnim) { + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_CORNERSITTER, -1); + + g_vars->scene07_lukeAnim = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(ani, ST_CST_HANDLELESS, QU_CST_CLOSELUKE); + } + + g_vars->scene07_lukePercent = g_vars->scene07_lukeAnim->_percent; + g_vars->scene07_lukeAnim->_percent = 0; + + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_HOOLIGAN, -1); + + ani->changeStatics2(ST_HGN_LUKE); + ani->show1(-1, -1, -1, 0); +} + +void sceneHandler07_hideLuke() { + g_fp->_currentScene->getStaticANIObject1ById(ANI_LUKE, -1)->hide(); + + Movement *mov = g_fp->_currentScene->getStaticANIObject1ById(ANI_CORNERSITTER, -1)->_movement; + + if (mov) { + if (mov->_id == MV_CST_CLOSELUKE) { + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_HOOLIGAN, -1); + + ani->changeStatics2(ST_HGN_LOOK); + ani->_flags &= 0xFFFB; + } + } +} + +void sceneHandler07_showBox() { + StaticANIObject *box = g_fp->_currentScene->getStaticANIObject1ById(ANI_SC7_BOX, -1); + + box->show1(492, 474, MV_SC7_BOX_default, 0); + box->_priority = 25; +} + +void sceneHandler07_hideBox() { + g_fp->_currentScene->getStaticANIObject1ById(ANI_SC7_BOX, -1)->hide(); +} + +int sceneHandler07(ExCommand *ex) { + if (ex->_messageKind != 17) + return 0; + + switch(ex->_messageNum) { + case MSG_SC7_OPENLUKE: + sceneHandler07_openLuke(); + break; + + case MSG_SC7_PULL: + if (g_vars->scene07_plusMinus->_statics->_staticsId == ST_PMS_MINUS) + g_vars->scene07_plusMinus->_statics = g_vars->scene07_plusMinus->getStaticsById(ST_PMS_PLUS); + else + g_vars->scene07_plusMinus->_statics = g_vars->scene07_plusMinus->getStaticsById(ST_PMS_MINUS); + + break; + + case MSG_SC7_CLOSELUKE: + sceneHandler07_closeLuke(); + break; + + case MSG_SC7_HIDELUKE: + sceneHandler07_hideLuke(); + break; + + case MSG_SC7_SHOWBOX: + sceneHandler07_showBox(); + break; + + case MSG_SC7_HIDEBOX: + sceneHandler07_hideBox(); + break; + + case 33: + { + int res = 0; + + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; + + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; + + res = 1; + } + + g_fp->_behaviorManager->updateBehaviors(); + + return res; + } + } + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene08.cpp b/engines/fullpipe/scenes/scene08.cpp new file mode 100644 index 0000000000..ada63ef22d --- /dev/null +++ b/engines/fullpipe/scenes/scene08.cpp @@ -0,0 +1,546 @@ +/* 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. + * + * 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. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objects.h" +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/scene.h" +#include "fullpipe/statics.h" +#include "fullpipe/floaters.h" +#include "fullpipe/gameloader.h" +#include "fullpipe/behavior.h" +#include "fullpipe/interaction.h" + +namespace Fullpipe { + +void scene08_initScene(Scene *sc) { + g_vars->scene08_inArcade = false; + g_vars->scene08_inAir = false; + g_vars->scene08_flyingUp = false; + g_vars->scene08_onBelly = false; + g_vars->scene08_batuta = sc->getStaticANIObject1ById(ANI_BATUTA, -1); + g_vars->scene08_vmyats = sc->getStaticANIObject1ById(ANI_VMYATS, -1); + g_vars->scene08_clock = sc->getStaticANIObject1ById(ANI_CLOCK_8, -1); + g_vars->scene08_stairsOffset = -37; + g_vars->scene08_snoringCountdown = -1; + + Scene *oldsc = g_fp->_currentScene; + g_fp->_currentScene = sc; + + int batuta = g_fp->getObjectState(sO_TummyTrampie); + MovGraphLink *lock = getSc2MctlCompoundBySceneId(sc->_sceneId)->getLinkByName(sO_CloseThing); + + if (lock) + lock->_flags &= 0xDFFFFFFF; + + if (batuta == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsEating)) { + g_vars->scene08_batuta->changeStatics2(ST_BTT_SPOON); + } else if (batuta == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsDrinking)) { + g_vars->scene08_batuta->changeStatics2(ST_BTT_NOSPOON); + + g_vars->scene08_clock->startAnim(MV_CLK8_GO, 0, -1); + g_vars->scene08_clock->_movement->setDynamicPhaseIndex(3); + } else if (batuta== g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsScratchingBelly)) { + g_vars->scene08_batuta->changeStatics2(ST_BTT_CHESHET); + + g_vars->scene08_clock->startAnim(MV_CLK8_GO, 0, -1); + g_vars->scene08_clock->_movement->setDynamicPhaseIndex(8); + } else if (batuta == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsSleeping)) { + g_vars->scene08_batuta->changeStatics2(ST_BTT_SLEEPS); + + g_vars->scene08_clock->startAnim(MV_CLK8_GO, 0, -1); + g_vars->scene08_clock->_movement->setDynamicPhaseIndex(2); + + if (lock) + lock->_flags |= 0x20000000; + + g_vars->scene08_snoringCountdown = 71; + } + + g_vars->scene08_clock->_callback2 = 0; + + if (g_fp->getObjectState(sO_StairsUp_8) == g_fp->getObjectEnumState(sO_StairsUp_8, sO_Broken)) { + g_vars->scene08_stairsVisible = false; + + sc->getPictureObjectById(PIC_SC8_LADDER, 0)->_flags &= 0xFFFB; + + g_vars->scene08_stairsOffset = -39; + } else { + g_vars->scene08_stairsVisible = true; + } + + sc->getPictureObjectById(PIC_SC8_ARCADENOW, 0)->_flags &= 0xFFFB; + + g_fp->_currentScene = oldsc; + + g_fp->_floaters->init(g_fp->getGameLoaderGameVar()->getSubVarByName("SC_8")); + g_fp->_floaters->genFlies(sc, 100, 100, 0, 0); + + g_fp->setArcadeOverlay(PIC_CSR_ARCADE3); +} + +void scene08_setupMusic() { + if (g_fp->getObjectState(sO_TummyTrampie) == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsSleeping)) + g_fp->playTrack(g_fp->getGameLoaderGameVar()->getSubVarByName("SC_8"), "MUSIC_ARCADE", 1); +} + +int scene08_updateCursor() { + g_fp->updateCursorCommon(); + + if (g_vars->scene08_inArcade) { + if (g_vars->scene08_onBelly) { + if (g_fp->_objectIdAtCursor == PIC_SC8_LADDERD && g_fp->_cursorId == PIC_CSR_ITN) + g_fp->_cursorId = PIC_CSR_GOU; + } else { + g_fp->_cursorId = -1; + } + } else { + if (g_fp->_objectIdAtCursor == PIC_SC8_LADDERD && g_fp->_cursorId == PIC_CSR_ITN) { + if (g_fp->_aniMan2->_oy >= 520) { + if (g_fp->_aniMan2->_oy <= 750) + g_fp->_cursorId = PIC_CSR_GOU; + } else { + g_fp->_cursorId = PIC_CSR_GOD; + } + } + } + + return g_fp->_cursorId; +} + +void sceneHandler08_enterUp() { + g_fp->_currentScene->getPictureObjectById(PIC_SC8_LADDER, 0)->_flags &= 0xFFFB; + + g_fp->_aniMan->changeStatics2(ST_MAN8_HANDSUP); + g_fp->_aniMan->setOXY(386, 236); + g_fp->_aniMan->_priority = 10; + g_fp->_aniMan->_flags = 4; + + chainObjQueue(g_fp->_aniMan, QU_SC8_FINISH, 1); + + g_vars->scene08_inAir = false; +} + +void sceneHandler08_winArcade() { + if (g_vars->scene08_inArcade) { + g_vars->scene08_inArcade = false; + g_fp->_sceneRect.top = 0; + g_fp->_sceneRect.bottom = 600; + + sceneHandler08_enterUp(); + } +} + +void sceneHandler08_hideLadder() { + g_fp->_currentScene->getPictureObjectById(PIC_SC8_LADDER_D, 0)->_flags &= 0xFFFB; +} + +void sceneHandler08_arcadeNow() { + MovGraphLink *lnk = getCurrSceneSc2MotionController()->getLinkByName(sO_Stairway); + + g_fp->setObjectState(sO_TummyTrampie, g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsSleeping)); + + g_vars->scene08_batuta->changeStatics2(ST_BTT_SLEEPS); + + if (lnk) + lnk->_flags |= 0x20000000; +} + +void sceneHandler08_resumeFlight() { + g_vars->scene08_manOffsetY = 3; + g_vars->scene08_stairsOffset = -39; + g_vars->scene08_inAir = true; + g_vars->scene08_stairsVisible = false; +} + +int sceneHandler08_calcOffset(int off, int flag) { + if (off > 0) { + if (flag) + return off * 31 / 10; // off * 3.1 + else + return 5 * off; + } else { + return 5 * off; + } +} + +void sceneHandler08_pushCallback(int *par) { + Common::Point point; + + int y = g_fp->_aniMan->_oy + g_fp->_aniMan->getSomeXY(point)->y; + + if (g_fp->_aniMan->_statics && g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYDOWN) + y -= 25; + + *par = (y - 703) / 10; + if (*par > 11) { + *par = 11; + g_vars->scene08_manOffsetY = 0; + } + if (*par >= 0) + g_vars->scene08_manOffsetY -= sceneHandler08_calcOffset(*par, g_vars->scene08_manOffsetY < 0); + else + *par = 0; +} + +int sceneHandler08_updateScreenCallback() { + int res; + + res = g_fp->drawArcadeOverlay(g_vars->scene08_inArcade); + + if (!res) + g_fp->_updateScreenCallback = 0; + + return res; +} + +void sceneHandler08_startArcade() { + g_vars->scene08_inArcade = true; + g_vars->scene08_inAir = true; + g_vars->scene08_flyingUp = false; + g_vars->scene08_onBelly = false; + + getGameLoaderInteractionController()->disableFlag24(); + getCurrSceneSc2MotionController()->clearEnabled(); + + g_vars->scene08_batuta->stopAnim_maybe(); + + g_vars->scene08_vmyats->_statics = g_vars->scene08_vmyats->getStaticsById(ST_VMT_MIN); + g_vars->scene08_vmyats->setOXY(382, 703); + g_vars->scene08_vmyats->_priority = 29; + g_vars->scene08_vmyats->_callback2 = sceneHandler08_pushCallback; + + g_fp->_aniMan = g_fp->_currentScene->getStaticANIObject1ById(ANI_MAN, -1); + + g_vars->scene08_manOffsetY = 15; + + g_fp->_currentScene->_y = 0; + + g_fp->_updateScreenCallback = sceneHandler08_updateScreenCallback; +} + +void sceneHandler08_airMoves() { + if (g_fp->_aniMan->isIdle() && !(g_fp->_aniMan->_flags & 0x100)) { + int x = g_fp->_aniMan->_ox; + int y = g_fp->_aniMan->_oy; + Common::Point point; + + if (703 - g_fp->_aniMan->getSomeXY(point)->y - y < 150) { + if (g_fp->_aniMan->_statics) { + if (g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYDOWN) { + y -= 25; + + g_fp->_aniMan->setOXY(x, y); + } + } + + g_fp->_aniMan->changeStatics2(ST_MAN8_STAND); + g_fp->_aniMan->setOXY(380, y); + g_fp->_aniMan->startAnim(MV_MAN8_JUMP, 0, -1); + + } else if (g_fp->_aniMan->_statics) { + if (g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYUP) { + g_fp->_aniMan->startAnim(MV_MAN8_DRYGUP, 0, -1); + + } else if (g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYDOWN) { + g_fp->_aniMan->startAnim(MV_MAN8_DRYGDOWN, 0, -1); + } + } + } +} + +void sceneHandler08_finishArcade() { + g_vars->scene08_inArcade = false; + + getGameLoaderInteractionController()->enableFlag24(); + getCurrSceneSc2MotionController()->setEnabled(); +} + +void sceneHandler08_jumpOff(ExCommand *cmd) { + MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + + mq->addExCommandToEnd(new ExCommand(cmd)); + mq->setFlags(mq->getFlags() | 1); + + g_fp->_globalMessageQueueList->addMessageQueue(mq); + + g_fp->_aniMan->startAnim(MV_MAN8_JUMPOFF, mq->_id, -1); + + sceneHandler08_finishArcade(); +} + +void sceneHandler08_standUp() { + chainQueue(QU_SC8_STANDUP, 1); + g_vars->scene08_onBelly = false; +} + +void sceneHandler08_jumpLogic(ExCommand *cmd) { + if (g_fp->_currentScene->getPictureObjectIdAtPos(cmd->_sceneClickX, cmd->_sceneClickY) == PIC_SC8_LADDERD) { + sceneHandler08_jumpOff(cmd); + + cmd->_messageKind = 0; + } else { + sceneHandler08_standUp(); + } +} + +void sceneHandler08_badLuck() { + g_fp->_currentScene->getPictureObjectById(PIC_SC8_LADDER, 0)->_flags &= 0xFFFB; + + g_fp->_aniMan->changeStatics2(ST_MAN8_HANDSUP); + g_fp->_aniMan->setOXY(376, 280); + g_fp->_aniMan->_priority = 10; + + MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + + ExCommand *ex = new ExCommand(g_fp->_aniMan->_id, 1, MV_MAN8_BADLUCK, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = g_fp->_aniMan->_okeyCode; + mq->addExCommandToEnd(ex); + + mq->setFlags(mq->getFlags() | 1); + mq->chain(0); + + g_fp->setObjectState(sO_StairsUp_8, g_fp->getObjectEnumState(sO_StairsUp_8, sO_NotBroken)); + + g_vars->scene08_inAir = false; +} + +void sceneHandler08_sitDown() { + g_fp->_aniMan->setOXY(380, g_fp->_aniMan->_oy); + + g_fp->_aniMan->changeStatics2(ST_MAN8_FLYDOWN); + g_fp->_aniMan->startAnim(MV_MAN8_SITDOWN, 0, -1); + + g_vars->scene08_vmyats->changeStatics2(ST_VMT_MIN); + g_vars->scene08_vmyats->hide(); + + g_vars->scene08_inAir = false; + g_vars->scene08_onBelly = true; +} + +void sceneHandler08_calcFlight() { + Common::Point point; + int y = g_vars->scene08_manOffsetY + g_fp->_aniMan->_oy; + + g_fp->_aniMan->setOXY(g_fp->_aniMan->_ox, y); + + g_vars->scene08_manOffsetY += 2; + + if (g_vars->scene08_manOffsetY < g_vars->scene08_stairsOffset) + g_vars->scene08_manOffsetY = g_vars->scene08_stairsOffset; + + y = y + g_fp->_aniMan->getSomeXY(point)->y; + + if (g_fp->_aniMan->_statics && g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYDOWN) + y -= 25; + + if (y <= g_vars->scene08_vmyats->_oy) { + g_vars->scene08_vmyats->hide(); + } else { + g_vars->scene08_vmyats->show1(-1, -1, -1, 0); + + if (!g_vars->scene08_vmyats->_movement) + g_vars->scene08_vmyats->startAnim(MV_VMT_DEF, 0, -1); + } + + if (g_fp->_aniMan->_oy <= 280 && g_vars->scene08_stairsVisible + && g_fp->_aniMan->_statics && g_fp->_aniMan->_statics->_staticsId == ST_MAN8_HANDSUP) { + sceneHandler08_badLuck(); + } else if (g_fp->_aniMan->_oy > 236 || g_vars->scene08_stairsVisible + || !g_fp->_aniMan->_statics || g_fp->_aniMan->_statics->_staticsId != ST_MAN8_HANDSUP) { + if (g_fp->_aniMan->_movement || g_fp->_aniMan->_oy < 660 + || (g_vars->scene08_vmyats->_movement && g_vars->scene08_vmyats->_movement->_currDynamicPhaseIndex > 0) + || abs(g_vars->scene08_manOffsetY) > 2) { + if (g_vars->scene08_manOffsetY >= 0 && !g_fp->_aniMan->_movement) { + if (g_fp->_aniMan->_statics->_staticsId == ST_MAN8_HANDSUP) + g_fp->_aniMan->startAnim(MV_MAN8_HANDSDOWN, 0, -1); + else + g_fp->_aniMan->changeStatics2(ST_MAN8_FLYDOWN); + } + + if (g_fp->_aniMan->_oy < 500 && !g_fp->_aniMan->_movement && g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYUP && g_vars->scene08_manOffsetY < 0) + g_fp->_aniMan->startAnim(MV_MAN8_HANDSUP, 0, -1); + } else { + sceneHandler08_sitDown(); + } + } else { + sceneHandler08_enterUp(); + } +} + +void sceneHandler08_checkEndArcade() { + if (g_vars->scene08_flyingUp) { + int x = g_fp->_aniMan->_ox; + int y = g_vars->scene08_manOffsetY + g_fp->_aniMan->_oy; + + if (!((g_vars->scene08_manOffsetY + g_fp->_aniMan->_oy) % 3)) + g_vars->scene08_manOffsetY--; + + g_fp->_aniMan->setOXY(x, y); + + if (y < 80) { + sceneHandler08_finishArcade(); + + ExCommand *ex = new ExCommand(SC_8, 17, 0, 0, 0, 0, 1, 0, 0, 0); + ex->_messageNum = 61; + ex->_excFlags |= 2; + ex->_keyCode = TrubaUp; + + ex->postMessage(); + } + } +} + +int sceneHandler08(ExCommand *cmd) { + if (cmd->_messageKind != 17) + return 0; + + switch (cmd->_messageNum) { + case MSG_CMN_WINARCADE: + sceneHandler08_winArcade(); + break; + + case MSG_SC8_ENTERUP: + sceneHandler08_enterUp(); + break; + + case MSG_SC8_HIDELADDER_D: + sceneHandler08_hideLadder(); + break; + + case MSG_SC8_STANDUP: + g_vars->scene08_manOffsetY = -10; + g_vars->scene08_vmyats->changeStatics2(ST_VMT_MIN); + g_vars->scene08_vmyats->setOXY(382, 703); + g_vars->scene08_vmyats->_priority = 29; + g_vars->scene08_vmyats->_callback2 = sceneHandler08_pushCallback; + g_vars->scene08_inAir = true; + break; + + case MSG_SC8_ARCADENOW: + sceneHandler08_arcadeNow(); + break; + + case MSG_SC8_RESUMEFLIGHT: + sceneHandler08_resumeFlight(); + break; + + case MSG_SC8_GETHIMUP: + g_vars->scene08_manOffsetY = 0; + g_vars->scene08_flyingUp = true; + break; + + case MSG_STARTARCADE: + sceneHandler08_startArcade(); + break; + + case 29: + if (g_vars->scene08_inArcade) { + if (g_vars->scene08_inAir) { + sceneHandler08_airMoves(); + break; + } + if (g_vars->scene08_onBelly) { + sceneHandler08_jumpLogic(cmd); + break; + } + } + break; + + case 33: + { + int res = 0; + + if (g_fp->_aniMan2) { + if (g_vars->scene08_inArcade) { + int scHeight = g_fp->_sceneRect.bottom - g_fp->_sceneRect.top; + + if (g_fp->_aniMan2->_oy < g_fp->_sceneRect.top + 200) { + g_fp->_sceneRect.top = g_fp->_aniMan2->_oy - 200; + + if (g_fp->_sceneRect.top < 0) + g_fp->_sceneRect.top = 0; + + g_fp->_sceneRect.bottom = scHeight + g_fp->_sceneRect.top; + } + + if (g_fp->_aniMan2->_oy > g_fp->_sceneRect.bottom - 350) { + g_fp->_sceneRect.bottom = g_fp->_aniMan2->_oy + 350; + g_fp->_sceneRect.top = g_fp->_aniMan2->_oy + 350 - scHeight; + } + } else { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; + + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; + + res = 1; + } + } + + g_fp->_floaters->update(); + + if (g_vars->scene08_inArcade) { + if (g_vars->scene08_inAir) + sceneHandler08_calcFlight(); + } else { + Movement *mov = g_fp->_aniMan->_movement; + + if (mov) { + if (mov->_id == MV_MAN_TOLADDERD && mov->_currDynamicPhaseIndex == 8) + g_fp->_aniMan->_priority = 2; + + if (mov && mov->_id == MV_MAN_FROMLADDERUP && mov->_currDynamicPhaseIndex == 13) + g_fp->_aniMan->_priority = 20; + } + + g_fp->_behaviorManager->updateBehaviors(); + g_fp->startSceneTrack(); + } + + if (g_vars->scene08_flyingUp) + sceneHandler08_checkEndArcade(); + + if (g_vars->scene08_snoringCountdown > 0) { + g_vars->scene08_snoringCountdown--; + + if (!g_vars->scene08_snoringCountdown) { + g_fp->playSound(SND_8_014, 0); + + g_vars->scene08_snoringCountdown = 71; + } + } + + return res; + } + } + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene10.cpp b/engines/fullpipe/scenes/scene10.cpp new file mode 100644 index 0000000000..f8d16b2759 --- /dev/null +++ b/engines/fullpipe/scenes/scene10.cpp @@ -0,0 +1,220 @@ +/* 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. + * + * 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. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" + +#include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/statics.h" + +#include "fullpipe/behavior.h" +#include "fullpipe/interaction.h" + +namespace Fullpipe { + +void scene10_initScene(Scene *sc) { + g_vars->scene10_gum = sc->getStaticANIObject1ById(ANI_GUM, -1); + g_vars->scene10_packet = sc->getStaticANIObject1ById(ANI_PACHKA, -1); + g_vars->scene10_packet2 = sc->getStaticANIObject1ById(ANI_PACHKA2, -1); + g_vars->scene10_inflater = sc->getStaticANIObject1ById(ANI_NADUVATEL, -1); + g_vars->scene10_ladder = sc->getPictureObjectById(PIC_SC10_LADDER, 0); + + g_fp->lift_setButton(sO_Level1, ST_LBN_1N); + g_fp->lift_sub5(sc, QU_SC10_ENTERLIFT, QU_SC10_EXITLIFT); + + if (g_fp->getObjectState(sO_Inflater) == g_fp->getObjectEnumState(sO_Inflater, sO_WithGum)) { + g_vars->scene10_hasGum = 1; + } else { + g_vars->scene10_hasGum = 0; + g_vars->scene10_gum->hide(); + } +} + +bool sceneHandler10_inflaterIsBlind() { + return g_vars->scene10_inflater->_movement + && g_vars->scene10_inflater->_movement->_id == MV_NDV_BLOW2 + && g_vars->scene10_inflater->_movement->_currDynamicPhaseIndex < 42; +} + +int scene10_updateCursor() { + g_fp->updateCursorCommon(); + + if (g_fp->_objectIdAtCursor == ANI_PACHKA || g_fp->_objectIdAtCursor == ANI_GUM) { + if (g_fp->_cursorId == PIC_CSR_ITN) { + if (g_vars->scene10_hasGum) + g_fp->_cursorId = (sceneHandler10_inflaterIsBlind() != 0) ? PIC_CSR_ITN_RED : PIC_CSR_ITN_GREEN; + else + g_fp->_cursorId = PIC_CSR_DEFAULT; + } + } + + return g_fp->_cursorId; +} + +void sceneHandler10_clickGum() { + if (g_vars->scene10_hasGum) { + if (sceneHandler10_inflaterIsBlind()) { + if (g_vars->scene10_hasGum) { + int x = g_vars->scene10_gum->_ox - 139; + int y = g_vars->scene10_gum->_oy - 48; + + if (abs(x - g_fp->_aniMan->_ox) > 1 || abs(y - g_fp->_aniMan->_oy) > 1) { + MessageQueue *mq = getCurrSceneSc2MotionController()->method34(g_fp->_aniMan, x, y, 1, ST_MAN_RIGHT); + if (mq) { + ExCommand *ex = new ExCommand(0, 17, MSG_SC10_CLICKGUM, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags = 2; + mq->addExCommandToEnd(ex); + + postExCommand(g_fp->_aniMan->_id, 2, x, y, 0, -1); + } + } else { + g_vars->scene10_hasGum = 0; + + chainQueue(QU_SC10_TAKEGUM, 1); + } + } + } else { + g_vars->scene10_inflater->changeStatics2(ST_NDV_SIT); + + if (g_fp->getObjectState(sO_Inflater) == g_fp->getObjectEnumState(sO_Inflater, sO_WithGum)) + g_vars->scene10_inflater->startAnim(MV_NDV_DENIES, 0, -1); + else + g_vars->scene10_inflater->startAnim(MV_NDV_DENY_NOGUM, 0, -1); + } + } +} + +void sceneHandler10_hideGum() { + g_vars->scene10_gum->hide(); + g_vars->scene10_packet->hide(); + g_vars->scene10_packet2->hide(); +} + +void sceneHandler10_showGum() { + if (g_vars->scene10_hasGum) + g_vars->scene10_gum->show1(-1, -1, -1, 0); + + g_vars->scene10_packet->show1(-1, -1, -1, 0); + g_vars->scene10_packet2->show1(-1, -1, -1, 0); +} + + +int sceneHandler10(ExCommand *ex) { + if (ex->_messageKind != 17) + return 0; + + switch(ex->_messageNum) { + case MSG_LIFT_CLOSEDOOR: + g_fp->lift_closedoorSeq(); + break; + + case MSG_LIFT_EXITLIFT: + g_fp->lift_exitSeq(ex); + break; + + case MSG_LIFT_STARTEXITQUEUE: + g_fp->lift_startExitQueue(); + break; + + case MSG_LIFT_CLICKBUTTON: + g_fp->lift_animation3(); + break; + + case MSG_SC10_LADDERTOBACK: + g_vars->scene10_ladder->_priority = 49; + break; + + case MSG_SC10_LADDERTOFORE: + g_vars->scene10_ladder->_priority = 0; + break; + + case MSG_LIFT_GO: + g_fp->lift_goAnimation(); + break; + + case MSG_SC10_CLICKGUM: + sceneHandler10_clickGum(); + + ex->_messageKind = 0; + break; + + case MSG_SC10_HIDEGUM: + sceneHandler10_hideGum(); + break; + + case MSG_SC10_SHOWGUM: + sceneHandler10_showGum(); + break; + + case 64: + g_fp->lift_sub05(ex); + break; + + case 29: + { + if (g_fp->_currentScene->getPictureObjectIdAtPos(ex->_sceneClickX, ex->_sceneClickY) == PIC_SC10_LADDER) { + handleObjectInteraction(g_fp->_aniMan, g_fp->_currentScene->getPictureObjectById(PIC_SC10_DTRUBA, 0), ex->_keyCode); + ex->_messageKind = 0; + + return 0; + } + + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObjectAtPos(ex->_sceneClickX, ex->_sceneClickY); + + if (ani && ani->_id == ANI_LIFTBUTTON) { + g_fp->lift_sub1(ani); + ex->_messageKind = 0; + + return 0; + } + } + break; + + case 33: + { + int res = 0; + + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; + + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; + + res = 1; + } + + g_fp->_behaviorManager->updateBehaviors(); + g_fp->startSceneTrack(); + + return res; + } + } + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene11.cpp b/engines/fullpipe/scenes/scene11.cpp new file mode 100644 index 0000000000..240eccf61b --- /dev/null +++ b/engines/fullpipe/scenes/scene11.cpp @@ -0,0 +1,334 @@ +/* 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. + * + * 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. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" + +#include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/statics.h" + +#include "fullpipe/interaction.h" +#include "fullpipe/behavior.h" + + +namespace Fullpipe { + +void scene11_dudeSwingCallback(int *arg) { + warning("STUB: scene11_dudeSwingCallback()"); +} + +void scene11_setupMusic() { + if (g_fp->getObjectState(sO_DudeHasJumped) == g_fp->getObjectEnumState(sO_DudeHasJumped, sO_Yes)) + g_fp->playTrack(g_fp->getGameLoaderGameVar()->getSubVarByName("SC_11"), "MUSIC2", 1); +} + +void scene11_initScene(Scene *sc) { + g_vars->scene11_swingie = sc->getStaticANIObject1ById(ANI_SWINGER, -1); + g_vars->scene11_boots = sc->getStaticANIObject1ById(ANI_BOOTS_11, -1); + g_vars->scene11_var01.clear(); + g_vars->scene11_dudeOnSwing = sc->getStaticANIObject1ById(ANI_MAN11, -1); + g_vars->scene11_dudeOnSwing->_callback2 = scene11_dudeSwingCallback; + g_vars->scene11_dudeOnSwing = sc->getStaticANIObject1ById(ANI_KACHELI, -1); + g_vars->scene11_dudeOnSwing->_callback2 = scene11_dudeSwingCallback; + g_vars->scene11_hint = sc->getPictureObjectById(PIC_SC11_HINT, 0); + g_vars->scene11_hint->_flags &= 0xFFFB; + + g_vars->scene11_var02 = 0; + g_vars->scene11_var03 = 0; + g_vars->scene11_var04 = 0; + g_vars->scene11_var05 = 0; + g_vars->scene11_var06 = 0; + g_vars->scene11_var07 = 0; + g_vars->scene11_var08 = 1.0; + g_vars->scene11_var09 = 1.0; + g_vars->scene11_var10 = 1.0; + g_vars->scene11_var11 = 1.0; + g_vars->scene11_var12 = 1.9849218750000000; + g_vars->scene11_var13 = 0; + g_vars->scene11_var14 = 0; + g_vars->scene11_var15 = 0; + g_vars->scene11_var16 = 0; + g_vars->scene11_var17 = 0; + g_vars->scene11_var18 = 0; + + Scene *oldsc = g_fp->_currentScene; + + g_fp->_currentScene = sc; + + int swingie = g_fp->getObjectState(sO_Swingie); + + if (swingie == g_fp->getObjectEnumState(sO_Swingie, sO_IsSwinging) + || swingie == g_fp->getObjectEnumState(sO_Swingie, sO_IsSwingingWithBoot)) { + g_vars->scene11_var19 = 1; + g_vars->scene11_var20 = 0; + + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing1, 1); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing2, 1); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing3, 0); + + ((MctlCompound *)getCurrSceneSc2MotionController())->replaceNodeX(805, 905); + + getSc2MctlCompoundBySceneId(sc->_sceneId)->replaceNodeX(303, 353); + } else if (swingie == g_fp->getObjectEnumState(sO_Swingie, sO_IsStandingInBoots) + || swingie == g_fp->getObjectEnumState(sO_Swingie, sO_IsStandingInCorner)) { + g_vars->scene11_var19 = 0; + g_vars->scene11_var20 = 1; + + g_vars->scene11_swingie->changeStatics2(ST_SWR_STAND3); + + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing1, 0); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing2, 1); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing3, 0); + + ((MctlCompound *)getCurrSceneSc2MotionController())->replaceNodeX(905, 805); + } else { + g_vars->scene11_var19 = 0; + g_vars->scene11_var20 = 0; + + if (swingie == g_fp->getObjectEnumState(sO_Swingie, sO_IsSitting)) { + g_vars->scene11_swingie->_movement = 0; + g_vars->scene11_swingie->_statics = g_vars->scene11_swingie->getStaticsById(ST_SWR_SIT); + g_vars->scene11_swingie->setOXY(144, 389); + + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing1, 0); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing2, 0); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing3, 1); + } else { + g_vars->scene11_swingie->_movement = 0; + g_vars->scene11_swingie->_statics = g_vars->scene11_swingie->getStaticsById(ST_SWR_SITBALD); + g_vars->scene11_swingie->setOXY(144, 415); + + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing1, 0); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing2, 0); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing3, 1); + } + } + + if (!g_vars->scene11_var19) { + g_vars->scene11_dudeOnSwing->changeStatics2(ST_KCH_STATIC); + g_vars->scene11_dudeOnSwing->setOXY(691, 371); + g_vars->scene11_dudeOnSwing->_priority = 20; + + g_vars->scene11_dudeOnSwing->_flags |= 4; + } + + g_fp->_currentScene = oldsc; + + g_fp->initArcadeKeys("SC_11"); + g_fp->setArcadeOverlay(PIC_CSR_ARCADE5); +} + +int sceneHandler11(ExCommand *cmd) { +#if 0 + if (cmd->_messageKind != 17) + return 0; + + switch (cmd->_messageNum) { + case MSG_CMN_WINARCADE: + sceneHandler11_winArcade(); + break; + + case MSG_SC11_SITSWINGER: + if (g_fp->getObjectState(sO_Swingie) == getObjectEnumState(sO_Swingie, sO_IsStandingInBoots) + || g_fp->getObjectState(sO_Swingie) == g_fp->getObjectEnumState(sO_Swingie, sO_IsStandingInCorner)) { + g_fp->setObjectState(sO_Swingie, g_fp->getObjectEnumState(sO_Swingie, sO_IsSitting)); + } + break; + + case MSG_SC11_MANCRY: + playSound(g_vars->scene11_var07, 0); + g_vars->scene11_var07 = 0; + break; + + case MSG_SC11_RESTARTMAN: + sceneHandler11_restartMan(); + break; + + case MSG_SC11_HITMAN: + sceneHandler11_hitMan(); + break; + + case MSG_SC11_MANTOSWING: + sceneHandler11_manToSwing(); + break; + + case MSG_SC11_PUTBOOT: + sceneHandler11_putBoot(); + break; + + case MSG_SC11_SHOWSWING: + sceneHandler11_showSwing(); + break; + + case 107: + if (g_vars->scene11_var02) + sceneHandler11_sub01(); + break; + + case 33: + { + if (!g_fp->_aniMan2) + goto LABEL_27; + + int x = g_fp->_aniMan2->_ox; + g_vars->scene11_var21 = g_fp->_aniMan2->_ox; + int y = g_fp->_aniMan2->_oy; + g_vars->scene11_var22 = g_fp->_aniMan2->_oy; + if (g_vars->scene11_var03) { + if (x > g_fp->_sceneRect.right - 200) + OffsetRect(&g_fp->_sceneRect, x - g_fp->_sceneRect.right + 200, 0); + goto LABEL_26; + } + if (g_vars->scene11_var04) { + g_fp->_currentScene->bg._x = g_fp->_sceneWidth - x; + if (g_vars->scene11_var21 < 910) + g_vars->scene11_var04 = 0; + LABEL_26: + v2 = 1; + LABEL_27: + if (g_vars->scene11_var20) { + if (g_fp->_sceneRect.left >= 534 && g_vars->scene11_var06 < 534) + sceneHandler11_sub06(); + g_vars->scene11_var06 = g_fp->_sceneRect.left; + } + if (!g_vars->scene11_var02) + goto LABEL_50; + v6 = g_vars->scene11_var16; + if (g_vars->scene11_var16 <= 0 || g_vars->scene11_var15 - g_vars->scene11_var16 <= 72) { + v7 = g_vars->scene11_var18; + } else { + sceneHandler11_sub02(); + v7 = 0; + v6 = 0; + g_vars->scene11_var18 = 0; + g_vars->scene11_var16 = 0; + } + if (!g_vars->scene11_var02) + goto LABEL_50; + if (g_vars->scene11_var17 == v7 || v6 <= 0 || g_vars->scene11_var15 - v6 <= 2) { + LABEL_49: + if (g_vars->scene11_var02) { + LABEL_61: + g_fp->_behaviorManager_updateBehaviors(); + g_fp->startSceneTrack(); + return v2; + } + LABEL_50: + if (g_vars->scene11_var19 + || 0.0 == g_vars->scene11_var10 + && (v8 = g_vars->scene11_dudeOnSwing->_movement) != 0 + && v8->_currDynamicPhaseIndex == 45 + && (g_vars->scene11_dudeOnSwing->changeStatics2(ST_KCH_STATIC), !g_vars->scene11_var02) + && g_vars->scene11_var19) { + if (!g_vars->scene11_swingie->_movement) { + if (g_vars->scene11_boots->_flags & 4 && g_vars->scene11_boots->_statics->_staticsId == ST_BTS11_2) { + sceneHandler11_sub07(); + BehaviorManager_updateBehaviors(&g_behaviorManager); + startSceneTrack(); + return v2; + } + g_vars->scene11_swingie->startAnim(MV_SWR_SWING, 0, -1); + } + } + goto LABEL_61; + } + if (v7 == 1) { + if (!g_vars->scene11_var17) { + sceneHandler11_sub03(); + LABEL_48: + g_vars->scene11_var16 = g_vars->scene11_var15; + goto LABEL_49; + } + } else { + if (v7 != 2) + goto LABEL_48; + if (!g_vars->scene11_var17) { + sceneHandler11_sub04(); + goto LABEL_48; + } + } + sceneHandler11_sub02(); + goto LABEL_48; + } + if (x >= g_fp->_sceneRect.left + 200) { + if (x <= g_fp->_sceneRect.right - 200) { + LABEL_18: + if (y < g_fp->_sceneRect.top + 200) { + g_fp->_currentScene->bg._y = y - g_fp->_sceneRect.top - 300; + y = g_vars->scene11_var22; + x = g_vars->scene11_var21; + } + if (y > g_fp->_sceneRect.bottom - 300) { + g_fp->_currentScene->bg._y = y - g_fp->_sceneRect.bottom + 300; + x = g_vars->scene11_var21; + } + if (x >= 940) + g_vars->scene11_var04 = 1; + goto LABEL_26; + } + g_fp->_currentScene->bg._x = x - g_fp->_sceneRect.right + 300; + } else { + g_fp->_currentScene->bg._x = x - g_fp->_sceneRect.left - 300; + } + y = g_vars->scene11_var22; + x = g_vars->scene11_var21; + goto LABEL_18; + } + + break; + + case 29: + if (g_vars->scene11_var19) { + if (g_fp->_currentScene->getStaticANIObjectAtPos(g_fp->_sceneRect.left + cmd->_x, g_fp->_sceneRect.top + cmd->_y) == g_vars->scene11_swingie && cmd->_keyCode == ANI_INV_BOOT) + sceneHandler11_putBoot(); + } else { + if (!g_vars->scene11_var02) + goto LABEL_69; + sceneHandler11_sub05(); + g_vars->scene11_var16 = g_vars->scene11_var15; + } + if (!g_vars->scene11_var02) { + LABEL_69: + v10 = (GameObject *)Scene_getStaticANIObjectAtPos(g_fp->_currentScene, cmd->_sceneClickX, cmd->_sceneClickY); + if (!v10 || !canInteractAny(&g_fp->_aniMan->go, v10, cmd->_keyCode)) { + v11 = Scene_getPictureObjectIdAtPos(g_fp->_currentScene, cmd->_sceneClickX, cmd->_sceneClickY); + v12 = (GameObject *)Scene_getPictureObjectById(g_fp->_currentScene, v11, 0); + if (!v12 || !canInteractAny(g_fp->_aniMan, v12, cmd->_keyCode)) { + if ((v13 = cmd->_sceneClickX, g_fp->_sceneRect.right - v13 < 47) && g_fp->_sceneRect.right < g_fp->_sceneWidth - 1 || v13 - g_fp->_sceneRect.left < 47 && g_fp->_sceneRect.left > 0) { + processArcade(cmd); + return 0; + } + } + } + return 0; + } + } +#endif + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene12.cpp b/engines/fullpipe/scenes/scene12.cpp new file mode 100644 index 0000000000..65f50b465a --- /dev/null +++ b/engines/fullpipe/scenes/scene12.cpp @@ -0,0 +1,85 @@ +/* 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. + * + * 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. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objects.h" +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/scene.h" +#include "fullpipe/floaters.h" +#include "fullpipe/messages.h" +#include "fullpipe/statics.h" +#include "fullpipe/behavior.h" + +namespace Fullpipe { + +void scene12_initScene(Scene *sc) { + GameVar *var = g_fp->getGameLoaderGameVar()->getSubVarByName("SC_12"); + g_fp->_floaters->init(var); + + g_vars->scene12_fly = g_fp->getObjectState(sO_Fly_12); + + if (g_vars->scene12_fly) + g_vars->scene12_flyCountdown = 600 * g_fp->_rnd->getRandomNumber(32767) / 0x7fff + 600; + + g_fp->setObjectState(sO_Fly_12, g_fp->_rnd->getRandomNumber(1)); +} + +void sceneHandler12_updateFloaters() { + g_fp->_floaters->genFlies(g_fp->_currentScene, 397, -50, 100, 6); + + g_fp->_floaters->_array2[0]->countdown = g_fp->_rnd->getRandomNumber(6) + 4; + g_fp->_floaters->_array2[0]->val6 = 397; + g_fp->_floaters->_array2[0]->val7 = -50; +} + +int sceneHandler12(ExCommand *cmd) { + int res = 0; + + if (cmd->_messageKind == 17 && cmd->_messageNum == 33) { + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; + + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; + + res = 1; + } + + g_vars->scene12_flyCountdown--; + + if (!g_vars->scene12_flyCountdown) + sceneHandler12_updateFloaters(); + + g_fp->_floaters->update(); + + g_fp->_behaviorManager->updateBehaviors(); + } + + return res; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene15.cpp b/engines/fullpipe/scenes/scene15.cpp new file mode 100644 index 0000000000..8310fc8607 --- /dev/null +++ b/engines/fullpipe/scenes/scene15.cpp @@ -0,0 +1,209 @@ +/* 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. + * + * 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. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" + +#include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/statics.h" + +#include "fullpipe/interaction.h" +#include "fullpipe/behavior.h" + + +namespace Fullpipe { + +void scene15_initScene(Scene *sc) { + g_vars->scene15_chantingCountdown = 0; + + StaticANIObject *grandma = sc->getStaticANIObject1ById(ANI_GRANDMA_ASS, -1); + + Scene *oldsc = g_fp->_currentScene; + g_fp->_currentScene = sc; + + int grandmaState = g_fp->getObjectState(sO_Grandma); + + if (grandmaState == g_fp->getObjectEnumState(sO_Grandma, sO_In_15)) { + grandma->changeStatics2(ST_GMS_BOOT); + grandma->setOXY(97, 399); + g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsClosed)); + } else if (grandmaState == g_fp->getObjectEnumState(sO_Grandma, sO_In_15_1)) { + grandma->changeStatics2(ST_GMS_BOOT); + grandma->setOXY(86, 399); + g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsClosed)); + } else if (grandmaState == g_fp->getObjectEnumState(sO_Grandma, sO_In_15_2)) { + grandma->changeStatics2(ST_GMS_BOOT); + grandma->setOXY(71, 399); + g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsClosed)); + } else if (grandmaState == g_fp->getObjectEnumState(sO_Grandma, sO_In_15_3)) { + grandma->changeStatics2(ST_GMS_BOOT); + grandma->setOXY(49, 399); + g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsClosed)); + } else if (grandmaState == g_fp->getObjectEnumState(sO_Grandma, sO_WithoutBoot)) { + grandma->changeStatics2(ST_GMS_BOOT); + grandma->setOXY(97, 399); + grandma->changeStatics2(ST_GMS_BOOTLESS2); + g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsClosed)); + } else { + grandma->hide(); + g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsOpened)); + } + + g_vars->scene15_plusminus = sc->getStaticANIObject1ById(ANI_PLUSMINUS, -1); + + if (g_fp->getObjectState(sO_Gurad_2) == g_fp->getObjectEnumState(sO_Gurad_2, sO_Off)) + g_vars->scene15_plusminus->_statics = g_vars->scene15_plusminus->getStaticsById(ST_PMS_MINUS); + else + g_vars->scene15_plusminus->_statics = g_vars->scene15_plusminus->getStaticsById(ST_PMS_PLUS); + + g_vars->scene15_ladder = sc->getPictureObjectById(PIC_SC15_LADDER, 0); + g_vars->scene15_boot = sc->getStaticANIObject1ById(ANI_BOOT_15, -1); + + if (g_fp->getObjectState(sO_Boot_15) != g_fp->getObjectEnumState(sO_Boot_15, sO_Available)) + g_vars->scene15_boot->_flags &= 0xFFFB; + + g_fp->_currentScene = oldsc; + + g_fp->lift_setButton(sO_Level5, ST_LBN_5N); + g_fp->lift_sub5(sc, QU_SC15_ENTERLIFT, QU_SC15_EXITLIFT); +} + +int scene15_updateCursor() { + g_fp->updateCursorCommon(); + + if (g_fp->_cursorId == PIC_CSR_ITN && g_fp->_objectIdAtCursor == PIC_SC15_LTRUBA) + g_fp->_cursorId = PIC_CSR_GOL; + + return g_fp->_cursorId; +} + +int sceneHandler15(ExCommand *cmd) { + if (cmd->_messageKind != 17) + return 0; + + switch(cmd->_messageNum) { + case MSG_LIFT_CLOSEDOOR: + g_fp->lift_closedoorSeq(); + break; + + case MSG_LIFT_EXITLIFT: + g_fp->lift_exitSeq(cmd); + break; + + case MSG_LIFT_STARTEXITQUEUE: + g_fp->lift_startExitQueue(); + break; + + case MSG_SC4_HIDEBOOT: + g_vars->scene15_boot->_flags &= 0xFFFB; + break; + + case MSG_SC15_STOPCHANTING: + g_fp->stopAllSoundInstances(SND_15_001); + + g_vars->scene15_chantingCountdown = 120; + break; + + case MSG_SC15_ASSDRYG: + if (g_fp->_rnd->getRandomNumber(1)) + g_fp->playSound(SND_15_011, 0); + else + g_fp->playSound(SND_15_006, 0); + + break; + + case MSG_SC15_LADDERTOBACK: + g_vars->scene15_ladder->_priority = 60; + break; + + case MSG_LIFT_GO: + g_fp->lift_goAnimation(); + break; + + case MSG_LIFT_CLICKBUTTON: + g_fp->lift_animation3(); + break; + + case MSG_SC15_PULL: + if (g_vars->scene15_plusminus->_statics->_staticsId == ST_PMS_MINUS) + g_vars->scene15_plusminus->_statics = g_vars->scene15_plusminus->getStaticsById(ST_PMS_PLUS); + else + g_vars->scene15_plusminus->_statics = g_vars->scene15_plusminus->getStaticsById(ST_PMS_MINUS); + + break; + + case 64: + g_fp->lift_sub05(cmd); + break; + + case 29: + { + if (g_fp->_currentScene->getPictureObjectIdAtPos(cmd->_sceneClickX, cmd->_sceneClickY) == PIC_SC15_LADDER) { + handleObjectInteraction(g_fp->_aniMan, g_fp->_currentScene->getPictureObjectById(PIC_SC15_DTRUBA, 0), cmd->_keyCode); + cmd->_messageKind = 0; + + return 0; + } + + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObjectAtPos(cmd->_sceneClickX, cmd->_sceneClickY); + + if (ani && ani->_id == ANI_LIFTBUTTON) { + g_fp->lift_sub1(ani); + + cmd->_messageKind = 0; + } + break; + } + + case 30: + // nop + break; + + case 33: + if (g_fp->_aniMan2) { + int x = g_fp->_aniMan2->_ox; + + if (x < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = x - 300 - g_fp->_sceneRect.left; + + if (x > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = x + 300 - g_fp->_sceneRect.right; + } + + if (g_vars->scene15_chantingCountdown > 0) { + g_vars->scene15_chantingCountdown--; + + if (!g_vars->scene15_chantingCountdown) + g_fp->playSound(SND_15_001, 1); + } + + g_fp->_behaviorManager->updateBehaviors(); + } + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/sceneDbg.cpp b/engines/fullpipe/scenes/sceneDbg.cpp index 83f3b64ee5..4a3751940f 100644 --- a/engines/fullpipe/scenes/sceneDbg.cpp +++ b/engines/fullpipe/scenes/sceneDbg.cpp @@ -25,6 +25,7 @@ #include "fullpipe/constants.h" #include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/statics.h" #include "fullpipe/input.h" @@ -40,9 +41,9 @@ void sceneDbgMenu_initScene(Scene *sc) { } GameObject *sceneHandlerDbgMenu_getObjectAtXY(int x, int y) { - if (g_fullpipe->_currentScene) - for (uint i = 0; i < g_fullpipe->_currentScene->_picObjList.size(); i++) { - PictureObject *pic = (PictureObject *)g_fullpipe->_currentScene->_picObjList[i]; + if (g_fp->_currentScene) + for (uint i = 0; i < g_fp->_currentScene->_picObjList.size(); i++) { + PictureObject *pic = (PictureObject *)g_fp->_currentScene->_picObjList[i]; if (x >= pic->_ox && y >= pic->_oy) { Common::Point point; @@ -61,8 +62,8 @@ int sceneHandlerDbgMenu(ExCommand *ex) { if (ex->_messageKind != 17) return 0; - int mx = g_fullpipe->_mouseScreenPos.x + g_fullpipe->_sceneRect.left; - int my = g_fullpipe->_mouseScreenPos.y + g_fullpipe->_sceneRect.top; + int mx = g_fp->_mouseScreenPos.x + g_fp->_sceneRect.left; + int my = g_fp->_mouseScreenPos.y + g_fp->_sceneRect.top; if (ex->_messageNum == 29) { GameObject *obj = sceneHandlerDbgMenu_getObjectAtXY(mx, my); @@ -74,18 +75,18 @@ int sceneHandlerDbgMenu(ExCommand *ex) { } if (ex->_messageNum != 33) { if (ex->_messageNum == MSG_RESTARTGAME) { - g_fullpipe->_needRestart = true; + g_fp->_needRestart = true; return 0; } return 0; } - g_fullpipe->_cursorId = PIC_CSR_DEFAULT; - GameObject *obj = g_fullpipe->_currentScene->getStaticANIObjectAtPos(mx, my); + g_fp->_cursorId = PIC_CSR_DEFAULT; + GameObject *obj = g_fp->_currentScene->getStaticANIObjectAtPos(mx, my); if (obj) { if (canInteractAny(0, obj, -3)) { - g_fullpipe->_cursorId = PIC_CSR_DEFAULT; - g_fullpipe->setCursor(PIC_CSR_DEFAULT); + g_fp->_cursorId = PIC_CSR_DEFAULT; + g_fp->setCursor(PIC_CSR_DEFAULT); return 0; } } else { @@ -93,13 +94,13 @@ int sceneHandlerDbgMenu(ExCommand *ex) { if (obj && canInteractAny(0, obj, -3) ) { g_vars->selector->_flags |= 4; g_vars->selector->setOXY(obj->_ox, obj->_oy); - g_fullpipe->_cursorId = PIC_CSR_DEFAULT; - g_fullpipe->setCursor(PIC_CSR_DEFAULT); + g_fp->_cursorId = PIC_CSR_DEFAULT; + g_fp->setCursor(PIC_CSR_DEFAULT); return 0; } g_vars->selector->_flags &= 0xFFFB; } - g_fullpipe->setCursor(g_fullpipe->_cursorId); + g_fp->setCursor(g_fp->_cursorId); return 0; } diff --git a/engines/fullpipe/scenes/sceneIntro.cpp b/engines/fullpipe/scenes/sceneIntro.cpp index d60f90faf7..c9f19f3724 100644 --- a/engines/fullpipe/scenes/sceneIntro.cpp +++ b/engines/fullpipe/scenes/sceneIntro.cpp @@ -24,6 +24,7 @@ #include "fullpipe/constants.h" #include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/modal.h" #include "fullpipe/statics.h" @@ -31,13 +32,13 @@ namespace Fullpipe { int sceneIntro_updateCursor() { - g_fullpipe->_cursorId = 0; + g_fp->_cursorId = 0; return 0; } void sceneIntro_initScene(Scene *sc) { - g_fullpipe->_gameLoader->loadScene(SC_INTRO2); + g_fp->_gameLoader->loadScene(SC_INTRO2); g_vars->sceneIntro_aniin1man = sc->getStaticANIObject1ById(ANI_IN1MAN, -1); g_vars->sceneIntro_needSleep = true; @@ -45,19 +46,19 @@ void sceneIntro_initScene(Scene *sc) { g_vars->sceneIntro_playing = true; g_vars->sceneIntro_needBlackout = false; - if (g_fullpipe->_recordEvents || g_fullpipe->_inputArFlag) + if (g_fp->_recordEvents || g_fp->_inputArFlag) g_vars->sceneIntro_skipIntro = false; - g_fullpipe->_modalObject = new ModalIntro; + g_fp->_modalObject = new ModalIntro; } void sceneHandlerIntro_part1() { - g_fullpipe->_currentScene = g_fullpipe->accessScene(SC_INTRO1); + g_fp->_currentScene = g_fp->accessScene(SC_INTRO1); chainQueue(QU_INTR_FINISH, 0); } void sceneHandlerIntro_part2() { - g_fullpipe->_currentScene = g_fullpipe->accessScene(SC_INTRO2); + g_fp->_currentScene = g_fp->accessScene(SC_INTRO2); chainQueue(QU_IN2_DO, 0); } @@ -101,7 +102,7 @@ int sceneHandlerIntro(ExCommand *ex) { chainQueue(QU_INTR_GETUPMAN, 0); } - g_fullpipe->startSceneTrack(); + g_fp->startSceneTrack(); return 0; } diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp index 147d6218c6..a08152e94c 100644 --- a/engines/fullpipe/sound.cpp +++ b/engines/fullpipe/sound.cpp @@ -86,7 +86,7 @@ bool Sound::load(MfcArchive &file, NGIArchive *archive) { _id = file.readUint32LE(); _description = file.readPascalString(); - assert(g_fullpipe->_gameProjectVersion >= 6); + assert(g_fp->_gameProjectVersion >= 6); _objectId = file.readUint16LE(); @@ -128,7 +128,11 @@ void FullpipeEngine::toggleMute() { } void FullpipeEngine::playSound(int id, int flag) { - warning("STUB: FullpipeEngine::playSounds(%d, %d)", id, flag); + warning("STUB: FullpipeEngine::playSound(%d, %d)", id, flag); +} + +void FullpipeEngine::playTrack(GameVar *sceneVar, const char *name, bool delayed) { + warning("STUB: FullpipeEngine::playTrack(var, %s, %d)", name, delayed); } void global_messageHandler_handleSound(ExCommand *cmd) { @@ -143,5 +147,8 @@ void FullpipeEngine::stopAllSoundStreams() { warning("STUB: FullpipeEngine::stopAllSoundStreams()"); } +void FullpipeEngine::stopAllSoundInstances(int id) { + warning("STUB: FullpipeEngine::stopAllSoundInstances(%d)", id); +} } // End of namespace Fullpipe diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index 747015e9a1..6a56ffd662 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -115,25 +115,25 @@ bool GameProject::load(MfcArchive &file) { _headerFilename = 0; _field_10 = 12; - g_fullpipe->_gameProjectVersion = file.readUint32LE(); - g_fullpipe->_pictureScale = file.readUint16LE(); - g_fullpipe->_scrollSpeed = file.readUint32LE(); + g_fp->_gameProjectVersion = file.readUint32LE(); + g_fp->_pictureScale = file.readUint16LE(); + g_fp->_scrollSpeed = file.readUint32LE(); _headerFilename = file.readPascalString(); - debug(1, "_gameProjectVersion = %d", g_fullpipe->_gameProjectVersion); - debug(1, "_pictureScale = %d", g_fullpipe->_pictureScale); - debug(1, "_scrollSpeed = %d", g_fullpipe->_scrollSpeed); + debug(1, "_gameProjectVersion = %d", g_fp->_gameProjectVersion); + debug(1, "_pictureScale = %d", g_fp->_pictureScale); + debug(1, "_scrollSpeed = %d", g_fp->_scrollSpeed); debug(1, "_headerFilename = %s", _headerFilename); _sceneTagList = new SceneTagList(); _sceneTagList->load(file); - if (g_fullpipe->_gameProjectVersion >= 3) + if (g_fp->_gameProjectVersion >= 3) _field_4 = file.readUint32LE(); - if (g_fullpipe->_gameProjectVersion >= 5) { + if (g_fp->_gameProjectVersion >= 5) { file.readUint32LE(); file.readUint32LE(); } diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index 12c56fe429..2af9cff743 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -191,7 +191,7 @@ bool StaticANIObject::load(MfcArchive &file) { char *movname = genFileName(_id, movNum, "mov"); - Common::SeekableReadStream *f = g_fullpipe->_currArchive->createReadStreamForMember(movname); + Common::SeekableReadStream *f = g_fp->_currArchive->createReadStreamForMember(movname); Movement *mov = new Movement(); @@ -249,11 +249,11 @@ void StaticANIObject::setFlags40(bool state) { void StaticANIObject::deleteFromGlobalMessageQueue() { while (_messageQueueId) { - if (g_fullpipe->_globalMessageQueueList->getMessageQueueById(_messageQueueId)) { + if (g_fp->_globalMessageQueueList->getMessageQueueById(_messageQueueId)) { if (!isIdle()) return; - g_fullpipe->_globalMessageQueueList->deleteQueueById(_messageQueueId); + g_fp->_globalMessageQueueList->deleteQueueById(_messageQueueId); } else { _messageQueueId = 0; } @@ -285,7 +285,7 @@ MessageQueue *StaticANIObject::getMessageQueue() { if (this->_messageQueueId <= 0) return 0; - return g_fullpipe->_globalMessageQueueList->getMessageQueueById(_messageQueueId); + return g_fp->_globalMessageQueueList->getMessageQueueById(_messageQueueId); } bool StaticANIObject::trySetMessageQueue(int msgNum, int qId) { @@ -304,7 +304,7 @@ bool StaticANIObject::trySetMessageQueue(int msgNum, int qId) { bool StaticANIObject::isIdle() { if (_messageQueueId) { - MessageQueue *m = g_fullpipe->_globalMessageQueueList->getMessageQueueById(_messageQueueId); + MessageQueue *m = g_fp->_globalMessageQueueList->getMessageQueueById(_messageQueueId); if (m && m->getFlags() & 1) return false; @@ -429,7 +429,7 @@ void Movement::draw(bool flipFlag, int angle) { int y = _oy - point.y; if (_currDynamicPhase->getPaletteData()) - g_fullpipe->_globalPalette = _currDynamicPhase->getPaletteData(); + g_fp->_globalPalette = _currDynamicPhase->getPaletteData(); if (_currDynamicPhase->getAlpha() < 0xFF) { warning("Movement::draw: alpha < 0xff: %d", _currDynamicPhase->getAlpha()); @@ -499,7 +499,7 @@ void StaticANIObject::draw() { debug(6, "StaticANIObject::draw() (%s) [%d] [%d, %d]", transCyrillic((byte *)_objectName), _id, _ox, _oy); - if (_shadowsOn && g_fullpipe->_currentScene && g_fullpipe->_currentScene->_shadows + if (_shadowsOn && g_fp->_currentScene && g_fp->_currentScene->_shadows && (getCurrDimensions(point)->x != 1 || getCurrDimensions(point)->y != 1)) { DynamicPhase *dyn; @@ -517,7 +517,7 @@ void StaticANIObject::draw() { if (dyn->getDynFlags() & 4) { rect = *dyn->_rect; - DynamicPhase *shd = g_fullpipe->_currentScene->_shadows->findSize(rect.width(), rect.height()); + DynamicPhase *shd = g_fp->_currentScene->_shadows->findSize(rect.width(), rect.height()); if (shd) { shd->getDimensions(&point); int midx = _ox - point.x / 2 - dyn->_someX; @@ -573,7 +573,7 @@ void StaticANIObject::draw2() { } MovTable *StaticANIObject::countMovements() { - GameVar *preloadSubVar = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(getName())->getSubVarByName("PRELOAD"); + GameVar *preloadSubVar = g_fp->getGameLoaderGameVar()->getSubVarByName(getName())->getSubVarByName("PRELOAD"); if (!preloadSubVar || preloadSubVar->getSubVarsCount() == 0) return 0; @@ -599,7 +599,7 @@ MovTable *StaticANIObject::countMovements() { } void StaticANIObject::setSpeed(int speed) { - GameVar *var = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(getName())->getSubVarByName("SpeedUp"); + GameVar *var = g_fp->getGameLoaderGameVar()->getSubVarByName(getName())->getSubVarByName("SpeedUp"); if (!var) return; @@ -886,15 +886,15 @@ void StaticANIObject::changeStatics2(int objId) { deleteFromGlobalMessageQueue(); if (_movement || _statics) { - g_fullpipe->_mgm->addItem(_id); - g_fullpipe->_mgm->updateAnimStatics(this, objId); + g_fp->_mgm->addItem(_id); + g_fp->_mgm->updateAnimStatics(this, objId); } else { _statics = getStaticsById(objId); } if (_messageQueueId) { - if (g_fullpipe->_globalMessageQueueList->getMessageQueueById(_messageQueueId)) - g_fullpipe->_globalMessageQueueList->deleteQueueById(_messageQueueId); + if (g_fp->_globalMessageQueueList->getMessageQueueById(_messageQueueId)) + g_fp->_globalMessageQueueList->deleteQueueById(_messageQueueId); _messageQueueId = 0; } @@ -1376,10 +1376,10 @@ bool Movement::load(MfcArchive &file, StaticANIObject *ani) { _flipFlag = 1; } - if (g_fullpipe->_gameProjectVersion >= 8) + if (g_fp->_gameProjectVersion >= 8) _field_50 = file.readUint32LE(); - if (g_fullpipe->_gameProjectVersion < 12) + if (g_fp->_gameProjectVersion < 12) _counterMax = 83; else _counterMax = file.readUint32LE(); @@ -1817,9 +1817,9 @@ DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) { _data = _bitmap->_pixels; _dataSize = src->_dataSize; - if (g_fullpipe->_currArchive) { + if (g_fp->_currArchive) { _mfield_14 = 0; - _libHandle = g_fullpipe->_currArchive; + _libHandle = g_fp->_currArchive; } _mflags |= 1; @@ -1877,12 +1877,12 @@ bool DynamicPhase::load(MfcArchive &file) { _rect->right = file.readUint32LE(); _rect->bottom = file.readUint32LE(); - assert (g_fullpipe->_gameProjectVersion >= 1); + assert (g_fp->_gameProjectVersion >= 1); _someX = file.readUint32LE(); _someY = file.readUint32LE(); - assert (g_fullpipe->_gameProjectVersion >= 12); + assert (g_fp->_gameProjectVersion >= 12); _dynFlags = file.readUint32LE(); @@ -1909,13 +1909,13 @@ bool StaticPhase::load(MfcArchive &file) { _initialCountdown = file.readUint16LE(); _field_6A = file.readUint16LE(); - if (g_fullpipe->_gameProjectVersion >= 12) { + if (g_fp->_gameProjectVersion >= 12) { _exCommand = (ExCommand *)file.readClass(); return true; } - assert (g_fullpipe->_gameProjectVersion >= 12); + assert (g_fp->_gameProjectVersion >= 12); return true; } diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 3a65801951..b3668ea362 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -138,9 +138,9 @@ bool MemoryObject::load(MfcArchive &file) { } } - if (g_fullpipe->_currArchive) { + if (g_fp->_currArchive) { _mfield_14 = 0; - _libHandle = g_fullpipe->_currArchive; + _libHandle = g_fp->_currArchive; } return true; @@ -153,12 +153,12 @@ void MemoryObject::loadFile(char *filename) { return; if (!_data) { - NGIArchive *arr = g_fullpipe->_currArchive; + NGIArchive *arr = g_fp->_currArchive; - if (g_fullpipe->_currArchive != _libHandle && _libHandle) - g_fullpipe->_currArchive = _libHandle; + if (g_fp->_currArchive != _libHandle && _libHandle) + g_fp->_currArchive = _libHandle; - Common::SeekableReadStream *s = g_fullpipe->_currArchive->createReadStreamForMember(filename); + Common::SeekableReadStream *s = g_fp->_currArchive->createReadStreamForMember(filename); if (s) { assert(s->size() > 0); @@ -174,7 +174,7 @@ void MemoryObject::loadFile(char *filename) { warning("MemoryObject::loadFile(): reading failure"); } - g_fullpipe->_currArchive = arr; + g_fp->_currArchive = arr; } } diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 05b8296b86..a64e81fcc9 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1781,7 +1781,7 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init do { int dataVal1 = _vm->_script->handleOpcode(ptr + 20 * dataOffset); - if (_vm->shouldQuit()) + if (dataVal1 == -1 || _vm->shouldQuit()) return; if (dataVal1 == 2) diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp index adf7580e6b..0e86fa26a9 100644 --- a/engines/hopkins/hopkins.cpp +++ b/engines/hopkins/hopkins.cpp @@ -1923,7 +1923,6 @@ void HopkinsEngine::bombExplosion() { } void HopkinsEngine::restoreSystem() { - quitGame(); _events->refreshEvents(); } diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index f2f547557f..347a6aabe8 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -2629,7 +2629,7 @@ void ObjectsManager::loadObjectIniFile() { for (;;) { int opcodeType = _vm->_script->handleOpcode(data + 20 * lastOpcodeResult); - if (_vm->shouldQuit()) + if (opcodeType == -1 || _vm->shouldQuit()) return; if (opcodeType == 2) diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp index d218dd27b5..c80ea15554 100644 --- a/engines/hopkins/talk.cpp +++ b/engines/hopkins/talk.cpp @@ -825,7 +825,7 @@ void TalkManager::handleAnswer(int zone, int verb) { int lastOpcodeResult = 1; do { int opcodeType = _vm->_script->handleOpcode(ptr + 20 * lastOpcodeResult); - if (_vm->shouldQuit()) + if (opcodeType == -1 || _vm->shouldQuit()) return; if (opcodeType == 2) diff --git a/engines/neverhood/detection.cpp b/engines/neverhood/detection.cpp index e5486bbcf5..10f2bc1e00 100644 --- a/engines/neverhood/detection.cpp +++ b/engines/neverhood/detection.cpp @@ -130,6 +130,9 @@ static const NeverhoodGameDescription gameDescriptions[] = { 0, }, +// FIXME: Disabled for now, as it has broken resources that corrupt the heap +// (e.g. the menu header). +#if 0 { // Neverhood Russian version. Fargus { @@ -146,6 +149,7 @@ static const NeverhoodGameDescription gameDescriptions[] = { 0, 0, }, +#endif { AD_TABLE_END_MARKER, 0, 0, 0, 0 } }; diff --git a/engines/neverhood/diskplayerscene.cpp b/engines/neverhood/diskplayerscene.cpp index ef2b856b2f..7513034bf3 100644 --- a/engines/neverhood/diskplayerscene.cpp +++ b/engines/neverhood/diskplayerscene.cpp @@ -169,7 +169,7 @@ AsDiskplayerSceneKey::AsDiskplayerSceneKey(NeverhoodEngine *vm) uint32 AsDiskplayerSceneKey::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -442,7 +442,7 @@ uint32 DiskplayerScene::handleMessage(int messageNum, const MessageParam ¶m, Scene::handleMessage(messageNum, param, sender); if (!_inputDisabled) { switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) { sendMessage(_parentModule, 0x1009, 0); } else if (!_dropKey && @@ -460,7 +460,7 @@ uint32 DiskplayerScene::handleMessage(int messageNum, const MessageParam ¶m, } } break; - case 0x2000: + case NM_ANIMATION_UPDATE: tuneIn(); break; case 0x2001: diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp index 699df2ae7d..31eee4da55 100644 --- a/engines/neverhood/gamemodule.cpp +++ b/engines/neverhood/gamemodule.cpp @@ -105,7 +105,7 @@ void GameModule::handleMouseDown(int16 x, int16 y) { mousePos.x = x; mousePos.y = y; debug(2, "GameModule::handleMouseDown(%d, %d)", x, y); - sendPointMessage(_childObject, 0x0001, mousePos); + sendPointMessage(_childObject, NM_MOUSE_CLICK, mousePos); } } @@ -122,7 +122,7 @@ void GameModule::handleMouseUp(int16 x, int16 y) { void GameModule::handleSpaceKey() { if (_childObject) { debug(2, "GameModule::handleSpaceKey()"); - sendMessage(_childObject, 0x0009, 0); + sendMessage(_childObject, NM_KEYPRESS_SPACE, 0); } } @@ -150,7 +150,7 @@ void GameModule::handleEscapeKey() { else if (!_prevChildObject && _canRequestMainMenu) _mainMenuRequested = true; else if (_childObject) - sendMessage(_childObject, 0x000C, 0); + sendMessage(_childObject, NM_KEYPRESS_ESC, 0); } void GameModule::initKeySlotsPuzzle() { @@ -781,7 +781,7 @@ void GameModule::updateModule() { void GameModule::openMainMenu() { if (_childObject) { - sendMessage(_childObject, 0x101D, 0); + sendMessage(_childObject, NM_MOUSE_HIDE, 0); _childObject->draw(); } else { // If there's no module, create one so there's something to return to @@ -807,7 +807,7 @@ void GameModule::updateMenuModule() { if (!updateChild()) { _vm->_screen->restoreParams(); _childObject = _prevChildObject; - sendMessage(_childObject, 0x101E, 0); + sendMessage(_childObject, NM_MOUSE_SHOW, 0); _prevChildObject = NULL; _moduleNum = _prevModuleNum; SetUpdateHandler(&GameModule::updateModule); diff --git a/engines/neverhood/klaymen.cpp b/engines/neverhood/klaymen.cpp index e1a0d72d50..a813440f62 100644 --- a/engines/neverhood/klaymen.cpp +++ b/engines/neverhood/klaymen.cpp @@ -77,7 +77,7 @@ uint32 Klaymen::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4818: @@ -126,7 +126,7 @@ void Klaymen::stIdlePickEar() { uint32 Klaymen::hmIdlePickEar(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x04DBC02C) { playSound(0, 0x44528AA1); } @@ -152,7 +152,7 @@ void Klaymen::stIdleSpinHead() { uint32 Klaymen::hmIdleSpinHead(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x808A0008) { playSound(0, 0xD948A340); } @@ -179,7 +179,7 @@ void Klaymen::evIdleArmsDone() { uint32 Klaymen::hmIdleArms(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x5A0F0104) { playSound(0, 0x7970A100); } else if (param.asInteger() == 0x9A9A0109) { @@ -205,7 +205,7 @@ void Klaymen::stIdleChest() { uint32 Klaymen::hmIdleChest(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x0D2A0288) { playSound(0, 0xD192A368); } @@ -227,7 +227,7 @@ void Klaymen::stIdleHeadOff() { uint32 Klaymen::hmIdleHeadOff(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0xC006000C) { playSound(0, 0x9D406340); } else if (param.asInteger() == 0x2E4A2940) { @@ -333,9 +333,9 @@ void Klaymen::stPickUpTube() { uint32 Klaymen::hmPickUpTube(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0xC1380080) { - sendMessage(_attachedSprite, 0x4806, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_USE_OBJECT, 0); playSound(0, 0xC8004340); } else if (param.asInteger() == 0x02B20220) { playSound(0, 0xC5408620); @@ -394,7 +394,7 @@ void Klaymen::stSitInTeleporter() { uint32 Klaymen::hmSitInTeleporter(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x001A2832) { playSound(0, 0xC0E4884C); } @@ -518,7 +518,7 @@ uint32 Klaymen::hmLowLevel(int messageNum, const MessageParam ¶m, Entity *se case 0x1014: _attachedSprite = (Sprite*)(param.asEntity()); break; - case 0x1019: + case NM_SCENE_LEAVE: gotoNextStateExt(); break; case 0x101C: @@ -556,7 +556,7 @@ void Klaymen::stIdleBlink() { uint32 Klaymen::hmLowLevelAnimation(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevel(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextStateExt(); break; } @@ -575,7 +575,7 @@ void Klaymen::stStandAround() { uint32 Klaymen::hmStartAction(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x271AA210) { playSound(0, 0x4924AAC4); } else if (param.asInteger() == 0x2B22AA81) { @@ -730,7 +730,7 @@ void Klaymen::evSneakingDone() { uint32 Klaymen::hmSneaking(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevel(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x32180101) { playSound(0, 0x4924AAC4); } else if (param.asInteger() == 0x0A2A9098) { @@ -741,7 +741,7 @@ uint32 Klaymen::hmSneaking(int messageNum, const MessageParam ¶m, Entity *se playSound(0, _soundFlag ? 0x50399F64 : 0x0460E2FA); } break; - case 0x3002: + case NM_ANIMATION_STOP: _x = _destX; gotoNextStateExt(); break; @@ -771,7 +771,7 @@ void Klaymen::evStartWalkingDone() { uint32 Klaymen::hmStartWalking(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x32180101) { playSound(0, _soundFlag ? 0x48498E46 : 0x405002D8); } else if (param.asInteger() == 0x0A2A9098) { @@ -802,7 +802,7 @@ void Klaymen::suWalkingFirst() { uint32 Klaymen::hmWalking(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevel(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x32180101) { playSound(0, _soundFlag ? 0x48498E46 : 0x405002D8); } else if (param.asInteger() == 0x0A2A9098) { @@ -861,7 +861,7 @@ void Klaymen::suWalkingTestExit() { (_actionStatus != 2 && _actionStatus != 3 && xdiff <= 10 && (_currFrameIndex >= 12 || _currFrameIndex <= 4)) || (_actionStatus == 3 && xdiff < 30) || (_actionStatus == 3 && xdiff < 150 && _currFrameIndex >= 6)) { - sendMessage(this, 0x1019, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); } else { HitRect *hitRectPrev = _parentScene->findHitRectAtPos(_x, _y); _x += xdelta; @@ -893,11 +893,11 @@ void Klaymen::suWalkingTestExit() { uint32 Klaymen::hmLever(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x4AB28209) { - sendMessage(_attachedSprite, 0x482A, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_BACK, 0); } else if (param.asInteger() == 0x88001184) { - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); } break; } @@ -919,9 +919,9 @@ void Klaymen::stPickUpGeneric() { uint32 Klaymen::hmPickUpObject(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0xC1380080) { - sendMessage(_attachedSprite, 0x4806, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_USE_OBJECT, 0); playSound(0, 0x40208200); } else if (param.asInteger() == 0x02B20220) { playSound(0, 0xC5408620); @@ -954,7 +954,7 @@ void Klaymen::stPressButton() { uint32 Klaymen::hmPressButton(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x0D01B294) { sendMessage(_attachedSprite, 0x480B, 0); } else if (param.asInteger() == 0x32180101) { @@ -1048,7 +1048,7 @@ void Klaymen::stStartWalkingSmall() { uint32 Klaymen::hmWalkingSmall(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevel(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x32180101) playSound(0, 0x4924AAC4); else if (param.asInteger() == 0x0A2A9098) @@ -1105,11 +1105,11 @@ void Klaymen::stWalkToFrontNoStepSmall() { uint32 Klaymen::hmWalkFrontBackSmall(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x80C110B5) - sendMessage(_parentScene, 0x482A, 0); + sendMessage(_parentScene, NM_MOVE_TO_BACK, 0); else if (param.asInteger() == 0x110010D1) - sendMessage(_parentScene, 0x482B, 0); + sendMessage(_parentScene, NM_MOVE_TO_FRONT, 0); else if (param.asInteger() == 0x32180101) playSound(0, 0x4924AAC4); else if (param.asInteger() == 0x0A2A9098) @@ -1187,12 +1187,12 @@ void Klaymen::stReleaseCord() { uint32 Klaymen::hmPullReleaseCord(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x4AB28209) { - sendMessage(_attachedSprite, 0x482A, 0); - sendMessage(_attachedSprite, 0x480F, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_BACK, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_LOWER_LEVER, 0); } else if (param.asInteger() == 0x88001184) { - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); } break; } @@ -1213,7 +1213,7 @@ void Klaymen::stUseTube() { uint32 Klaymen::hmUseTube(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x02B20220) playSound(0, 0xC5408620); else if (param.asInteger() == 0x0A720138) @@ -1369,14 +1369,14 @@ void Klaymen::suLargeStep() { uint32 Klaymen::hmLargeStep(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevel(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x32180101) { playSound(0, 0x4924AAC4); } else if (param.asInteger() == 0x0A2A9098) { playSound(0, 0x0A2AA8E0); } break; - case 0x3002: + case NM_ANIMATION_STOP: _x = _destX; gotoNextStateExt(); break; @@ -1414,7 +1414,7 @@ void Klaymen::stTurnToUseHalf() { uint32 Klaymen::hmTurnToUse(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x32180101) { playSound(0, 0x4924AAC4); } else if (param.asInteger() == 0x0A2A9098) { @@ -1460,7 +1460,7 @@ uint32 Klaymen::hmPeekWall(int messageNum, const MessageParam ¶m, Entity *se if (_currFrameIndex < speedUpFrameIndex) startAnimation(0xAC20C012, speedUpFrameIndex, -1); return 0; - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x32180101) { playSound(0, 0x405002D8); } else if (param.asInteger() == 0x0A2A9098) { @@ -1479,7 +1479,7 @@ void Klaymen::suUpdateDestX() { void Klaymen::stReleaseRing() { _busyStatus = 1; _acceptInput = false; - sendMessage(_attachedSprite, 0x4807, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_RAISE_LEVER, 0); _attachedSprite = NULL; startAnimation(0xB869A4B9, 0, -1); SetUpdateHandler(&Klaymen::update); @@ -1559,7 +1559,7 @@ void Klaymen::stClimbLadderHalf() { uint32 Klaymen::hmClimbLadderHalf(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x489B025C) { playSound(0, 0x52C4C2D7); } else if (param.asInteger() == 0x400A0E64) { @@ -1577,7 +1577,7 @@ uint32 Klaymen::hmClimbLadderHalf(int messageNum, const MessageParam ¶m, Ent uint32 Klaymen::hmClimbLadderUpDown(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevel(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x01084280) { _acceptInput = true; } else if (param.asInteger() == 0x489B025C) { @@ -1588,11 +1588,11 @@ uint32 Klaymen::hmClimbLadderUpDown(int messageNum, const MessageParam ¶m, E if (_ladderStatus == 1) { startAnimationByHash(0x3A292504, 0x01084280, 0); if (_destY >= _y - 30) - sendMessage(this, 0x1019, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); } else { startAnimationByHash(0x122D1505, 0x01084280, 0); if (_destY <= _y) - sendMessage(this, 0x1019, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); } } break; @@ -1639,11 +1639,11 @@ void Klaymen::stWalkToFrontNoStep() { uint32 Klaymen::hmWalkToFront(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x80C110B5) { - sendMessage(_parentScene, 0x482A, 0); + sendMessage(_parentScene, NM_MOVE_TO_BACK, 0); } else if (param.asInteger() == 0x110010D1) { - sendMessage(_parentScene, 0x482B, 0); + sendMessage(_parentScene, NM_MOVE_TO_FRONT, 0); } else if (param.asInteger() == 0x32180101) { playSound(0, _soundFlag ? 0x48498E46 : 0x405002D8); } else if (param.asInteger() == 0x0A2A9098) { @@ -1699,7 +1699,7 @@ void Klaymen::stLandOnFeet() { uint32 Klaymen::hmLandOnFeet(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x320AC306) { playSound(0, 0x5860C640); } @@ -1722,7 +1722,7 @@ void Klaymen::stTurnToBackToUse() { uint32 Klaymen::hmTurnToBackToUse(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0xC61A0119) { playSound(0, 0x402338C2); } else if (param.asInteger() == 0x32180101) { @@ -1783,12 +1783,12 @@ void Klaymen::stMoveObjectSkipTurnFaceObject() { } void Klaymen::evMoveObjectTurnDone() { - sendMessage(_attachedSprite, 0x4807, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_RAISE_LEVER, 0); } uint32 Klaymen::hmMoveObjectTurn(int messageNum, const MessageParam ¶m, Entity *sender) { switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x01084280) { sendMessage(_attachedSprite, 0x480B, _doDeltaX ? 1 : 0); } else if (param.asInteger() == 0x02421405) { @@ -1804,7 +1804,7 @@ uint32 Klaymen::hmMoveObjectTurn(int messageNum, const MessageParam ¶m, Enti playSound(0, 0x0460E2FA); } break; - case 0x480A: + case NM_KLAYMEN_MOVE_OBJECT: _isMoveObjectRequested = true; return 0; } @@ -1839,7 +1839,7 @@ void Klaymen::stUseLever() { if (_isLeverDown) { stUseLeverRelease(); } else { - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); startAnimation(0x0C303040, 0, -1); SetSpriteUpdate(&Klaymen::suUpdateDestX); SetMessageHandler(&Klaymen::hmLever); @@ -1853,7 +1853,7 @@ void Klaymen::stUseLever() { // Exactly the same code as sub420DA0 which was removed void Klaymen::stPullLeverDown() { startAnimation(0x0D318140, 0, -1); - sendMessage(_attachedSprite, 0x480F, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_LOWER_LEVER, 0); NextState(&Klaymen::stHoldLeverDown); } @@ -1871,7 +1871,7 @@ void Klaymen::stUseLeverRelease() { SetUpdateHandler(&Klaymen::update); SetMessageHandler(&Klaymen::hmLever); SetSpriteUpdate(&Klaymen::suUpdateDestX); - sendMessage(_attachedSprite, 0x4807, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_RAISE_LEVER, 0); NextState(&Klaymen::stPullLeverDown); _acceptInput = false; } @@ -1883,7 +1883,7 @@ void Klaymen::stReleaseLever() { SetUpdateHandler(&Klaymen::update); SetMessageHandler(&Klaymen::hmLever); SetSpriteUpdate(&Klaymen::suUpdateDestX); - sendMessage(_attachedSprite, 0x4807, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_RAISE_LEVER, 0); NextState(&Klaymen::stLetGoOfLever); _acceptInput = false; _isLeverDown = false; @@ -1898,7 +1898,7 @@ void Klaymen::stLetGoOfLever() { } void Klaymen::evLeverReleasedEvent() { - sendMessage(_attachedSprite, 0x482A, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_BACK, 0); } void Klaymen::stInsertDisk() { @@ -1929,7 +1929,7 @@ void Klaymen::stInsertDisk() { uint32 Klaymen::hmInsertDisk(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Klaymen::hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (_tapesToInsert == 0 && param.asInteger() == 0x06040580) { nextAnimationByHash(0xD8C8D100, calcHash("GoToStartLoop/Finish"), 0); } else if (_tapesToInsert != 0 && param.asInteger() == calcHash("GoToStartLoop/Finish")) { @@ -2033,15 +2033,15 @@ void Klaymen::suJumpToGrab() { uint32 Klaymen::hmJumpToGrab(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevel(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x168050A0) - sendMessage(_attachedSprite, 0x4806, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_USE_OBJECT, 0); else if (param.asInteger() == 0x320AC306) startAnimationByHash(0x00AB8C10, 0x01084280, 0); else if (param.asInteger() == 0x4AB28209) - sendMessage(_attachedSprite, 0x482A, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_BACK, 0); else if (param.asInteger() == 0x88001184) - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); break; } return messageResult; @@ -2059,7 +2059,7 @@ void Klaymen::stFinishGrow() { uint32 Klaymen::hmFinishGrow(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x040C4C01) playSound(0, 0x01E11140); break; @@ -2086,7 +2086,7 @@ void Klaymen::stJumpToGrabFall() { SetUpdateHandler(&Klaymen::update); SetMessageHandler(&Klaymen::hmJumpToGrab); SetSpriteUpdate(&Klaymen::suJumpToGrab); - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); } } @@ -2103,7 +2103,7 @@ void Klaymen::stJumpToGrabRelease() { uint32 Klaymen::hmJumpToGrabRelease(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x320AC306) playSound(0, 0x5860C640); break; @@ -2152,7 +2152,7 @@ void Klaymen::teleporterDisappear(uint32 fileHash) { uint32 Klaymen::hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x4E0A2C24) { playSound(0, 0x85B10BB8); } else if (param.asInteger() == 0x4E6A0CA0) { @@ -2185,7 +2185,7 @@ uint32 Klaymen::hmDrinkPotion(int messageNum, const MessageParam ¶m, Entity } else _potionFlag2 = true; break; - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x0002418E) sendMessage(_parentScene, 0x2000, 0); else if (param.asInteger() == 0x924090C2) { @@ -2230,7 +2230,7 @@ uint32 Klaymen::hmDrinkPotion(int messageNum, const MessageParam ¶m, Entity uint32 Klaymen::hmGrow(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x32180101) playSound(0, 0x405002D8); else if (param.asInteger() == 0x0A2A9098) @@ -2283,7 +2283,7 @@ void Klaymen::stDrinkPotion() { uint32 Klaymen::hmInsertKey(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Klaymen::hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (_keysToInsert == 0 && param.asInteger() == 0x06040580) { nextAnimationByHash(0xDC409440, 0x46431401, 0); } else if (_keysToInsert != 0 && param.asInteger() == 0x46431401) { @@ -2344,7 +2344,7 @@ void Klaymen::stInsertKey() { uint32 Klaymen::hmPeekWallReturn(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == calcHash("PopBalloon")) { sendMessage(_parentScene, 0x2000, 0); } else if (param.asInteger() == 0x02B20220) { @@ -2444,7 +2444,7 @@ void Klaymen::suFallDown() { if (hitRect->type == 0x5001) { _y = hitRect->rect.y1; updateBounds(); - sendMessage(this, 0x1019, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); } _parentScene->checkCollision(this, 0xFFFF, 0x4810, 0); } @@ -2495,7 +2495,7 @@ void Klaymen::stFalling() { SetSpriteUpdate(NULL); SetMessageHandler(&Klaymen::hmLowLevelAnimation); NextState(&Klaymen::stFallTouchdown); - sendMessage(_parentScene, 0x2002, 0); + sendMessage(_parentScene, NM_POSITION_CHANGE, 0); _attachedSprite = NULL; sendMessage(_parentScene, 0x8001, 0); } @@ -2511,7 +2511,7 @@ void Klaymen::suFallSkipJump() { if (hitRect->type == 0x5001) { _y = hitRect->rect.y1; updateBounds(); - sendMessage(this, 0x1019, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); } } @@ -2533,7 +2533,7 @@ void Klaymen::upMoveObject() { uint32 Klaymen::hmMoveObject(int messageNum, const MessageParam ¶m, Entity *sender) { switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x01084280) { playSound(0, 0x405002D8); sendMessage(_attachedSprite, 0x480B, 0); @@ -2607,7 +2607,7 @@ void Klaymen::stInteractLever() { void Klaymen::stPullLever() { startAnimation(0x0D318140, 0, -1); NextState(&Klaymen::stLookLeverDown); - sendMessage(_attachedSprite, 0x480F, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_LOWER_LEVER, 0); } void Klaymen::stLookLeverDown() { diff --git a/engines/neverhood/menumodule.cpp b/engines/neverhood/menumodule.cpp index 6b0635598f..b6aff48e0e 100644 --- a/engines/neverhood/menumodule.cpp +++ b/engines/neverhood/menumodule.cpp @@ -374,7 +374,7 @@ MainMenu::MainMenu(NeverhoodEngine *vm, Module *parentModule) uint32 MainMenu::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: leaveScene(param.asInteger()); break; } @@ -448,17 +448,17 @@ void CreditsScene::update() { uint32 CreditsScene::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0009: + case NM_KEYPRESS_SPACE: leaveScene(0); break; case 0x000B: if (param.asInteger() == Common::KEYCODE_ESCAPE && _canAbort) leaveScene(0); break; - case 0x101D: + case NM_MOUSE_HIDE: _ticksDuration = _ticksTime - _vm->_system->getMillis(); break; - case 0x101E: + case NM_MOUSE_SHOW: _ticksTime = _ticksDuration + _vm->_system->getMillis(); break; } @@ -997,7 +997,7 @@ uint32 GameStateMenu::handleMessage(int messageNum, const MessageParam ¶m, E setCurrWidget(_textEditWidget); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: // Handle menu button click switch (param.asInteger()) { case 0: @@ -1166,7 +1166,7 @@ QueryOverwriteMenu::QueryOverwriteMenu(NeverhoodEngine *vm, Module *parentModule uint32 QueryOverwriteMenu::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: // Handle menu button click leaveScene(param.asInteger()); break; diff --git a/engines/neverhood/messages.h b/engines/neverhood/messages.h index 78c66868d5..7f165787bf 100644 --- a/engines/neverhood/messages.h +++ b/engines/neverhood/messages.h @@ -26,10 +26,45 @@ namespace Neverhood { enum NeverhoodMessage { + NM_MOUSE_MOVE = 0x0000, + NM_MOUSE_CLICK = 0x0001, + NM_MOUSE_HIDE = 0x101D, + NM_MOUSE_SHOW = 0x101E, + NM_KEYPRESS_SPACE = 0x0009, + NM_KEYPRESS_ESC = 0x000C, + NM_ANIMATION_START = 0x100D, + NM_SCENE_LEAVE = 0x1019, + NM_PRIORITY_CHANGE = 0x1022, + NM_ANIMATION_UPDATE = 0x2000, + NM_POSITION_CHANGE = 0x2002, + NM_KLAYMEN_CLIMB_LADDER = 0x2005, + NM_KLAYMEN_STOP_CLIMBING = 0x2006, + + NM_CAR_MOVE_TO_PREV_POINT = 0x2007, + NM_CAR_MOVE_TO_NEXT_POINT = 0x2008, + NM_CAR_ENTER = 0x2009, + NM_CAR_LEAVE = 0x200A, + NM_CAR_TURN = 0x200E, + NM_CAR_AT_HOME = 0x200F, + + NM_ANIMATION_STOP = 0x3002, + + NM_KLAYMEN_STAND_IDLE = 0x4004, + NM_KLAYMEN_USE_OBJECT = 0x4806, + NM_KLAYMEN_RAISE_LEVER = 0x4807, + NM_KLAYMEN_OPEN_DOOR = 0x4808, + NM_KLAYMEN_CLOSE_DOOR = 0x4809, + NM_KLAYMEN_MOVE_OBJECT = 0x480A, + NM_KLAYMEN_LOWER_LEVER = 0x480F, NM_KLAYMEN_PICKUP = 0x4812, NM_KLAYMEN_PRESS_BUTTON = 0x4816, NM_KLAYMEN_INSERT_DISK = 0x481A, - NM_KLAYMEN_RELEASE_LEVER = 0x4827 + NM_KLAYMEN_TURN_TO_USE = 0x481D, + NM_KLAYMEN_RETURN_FROM_USE = 0x481E, + NM_KLAYMEN_RELEASE_LEVER = 0x4827, + + NM_MOVE_TO_BACK = 0x482A, + NM_MOVE_TO_FRONT = 0x482B }; } // End of namespace Neverhood diff --git a/engines/neverhood/modules/module1000.cpp b/engines/neverhood/modules/module1000.cpp index 534fb2ec2f..788e22dc1b 100644 --- a/engines/neverhood/modules/module1000.cpp +++ b/engines/neverhood/modules/module1000.cpp @@ -192,7 +192,7 @@ uint32 Scene1001::handleMessage(int messageNum, const MessageParam ¶m, Entit uint32 messageResult = 0; Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x00342624) { sendEntityMessage(_klaymen, 0x1014, _asLever); setMessageList2(0x004B4910); @@ -214,13 +214,13 @@ uint32 Scene1001::handleMessage(int messageNum, const MessageParam ¶m, Entit } } break; - case 0x2002: + case NM_POSITION_CHANGE: setRectList(0x004B49F0); break; case 0x480B: sendMessage(_asWindow, 0x2001, 0); break; - case 0x480F: + case NM_KLAYMEN_LOWER_LEVER: sendMessage(_asHammer, 0x2000, 0); break; } @@ -317,7 +317,7 @@ Scene1002::Scene1002(NeverhoodEngine *vm, Module *parentModule, int which) _asVenusFlyTrap = insertSprite<AsScene1002VenusFlyTrap>(this, _klaymen, false); addCollisionSprite(_asVenusFlyTrap); - sendEntityMessage(_klaymen, 0x2007, _asVenusFlyTrap); + sendEntityMessage(_klaymen, NM_CAR_MOVE_TO_PREV_POINT, _asVenusFlyTrap); _asOutsideDoorBackground = insertSprite<AsScene1002OutsideDoorBackground>(); @@ -347,7 +347,7 @@ uint32 Scene1002::handleMessage(int messageNum, const MessageParam ¶m, Entit uint32 messageResult = 0; Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0xE6EE60E1) { if (getGlobalVar(V_FLYTRAP_RING_DOOR)) setMessageList(0x004B4428); @@ -381,7 +381,7 @@ uint32 Scene1002::handleMessage(int messageNum, const MessageParam ¶m, Entit case 0x1024: sendMessage(_parentModule, 0x1024, param.asInteger()); break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (_isClimbingLadder) { setMessageList2(0x004B43D0); } else { @@ -395,18 +395,18 @@ uint32 Scene1002::handleMessage(int messageNum, const MessageParam ¶m, Entit } } break; - case 0x2002: + case NM_POSITION_CHANGE: _messageList = NULL; break; - case 0x2005: + case NM_KLAYMEN_CLIMB_LADDER: _isClimbingLadder = true; setRectList(0x004B4418); break; - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: _isClimbingLadder = false; setRectList(0x004B43A0); break; - case 0x4806: + case NM_KLAYMEN_USE_OBJECT: if (sender == _asRing1) { setGlobalVar(V_RADIO_ENABLED, 0); playSound(0, 0x665198C0); @@ -416,8 +416,8 @@ uint32 Scene1002::handleMessage(int messageNum, const MessageParam ¶m, Entit } else if (sender == _asRing3) { setGlobalVar(V_RADIO_ENABLED, 0); playSound(1); - sendMessage(_asDoor, 0x4808, 0); - sendMessage(_asOutsideDoorBackground, 0x4808, 0); + sendMessage(_asDoor, NM_KLAYMEN_OPEN_DOOR, 0); + sendMessage(_asOutsideDoorBackground, NM_KLAYMEN_OPEN_DOOR, 0); } else if (sender == _asRing4) { setGlobalVar(V_RADIO_ENABLED, 0); playSound(0, 0xE0558848); @@ -426,25 +426,25 @@ uint32 Scene1002::handleMessage(int messageNum, const MessageParam ¶m, Entit playSound(0, 0x44014282); } break; - case 0x4807: + case NM_KLAYMEN_RAISE_LEVER: if (sender == _asRing3) { playSound(2); - sendMessage(_asDoor, 0x4809, 0); - sendMessage(_asOutsideDoorBackground, 0x4809, 0); + sendMessage(_asDoor, NM_KLAYMEN_CLOSE_DOOR, 0); + sendMessage(_asOutsideDoorBackground, NM_KLAYMEN_CLOSE_DOOR, 0); } else if (sender == _asVenusFlyTrap) { if (getGlobalVar(V_FLYTRAP_RING_DOOR)) { - sendMessage(_asRing3, 0x4807, 0); + sendMessage(_asRing3, NM_KLAYMEN_RAISE_LEVER, 0); } } break; case 0x480B: sendEntityMessage(_klaymen, 0x1014, _asDoorSpy); break; - case 0x480F: + case NM_KLAYMEN_LOWER_LEVER: setGlobalVar(V_RADIO_ENABLED, 0); playSound(1); - sendMessage(_asDoor, 0x4808, 0); - sendMessage(_asOutsideDoorBackground, 0x4808, 0); + sendMessage(_asDoor, NM_KLAYMEN_OPEN_DOOR, 0); + sendMessage(_asOutsideDoorBackground, NM_KLAYMEN_OPEN_DOOR, 0); break; case 0x8000: setSpriteSurfacePriority(_ssCeiling, 995); @@ -521,20 +521,20 @@ uint32 Scene1004::handleMessage(int messageNum, const MessageParam ¶m, Entit uint32 messageResult = 0; Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x926500A1) { setMessageList(0x004B7C20); messageResult = 1; } break; - case 0x2000: + case NM_ANIMATION_UPDATE: loadDataResource(0x01900A04); break; case 0x2001: setRectList(0x004B7C70); break; - case 0x2002: - sendMessage(_asTrashCan, 0x2002, 0); + case NM_POSITION_CHANGE: + sendMessage(_asTrashCan, NM_POSITION_CHANGE, 0); break; } return messageResult; @@ -581,7 +581,7 @@ Scene1005::Scene1005(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene1005::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) leaveScene(0); break; diff --git a/engines/neverhood/modules/module1000_sprites.cpp b/engines/neverhood/modules/module1000_sprites.cpp index 573474de02..a028df4b10 100644 --- a/engines/neverhood/modules/module1000_sprites.cpp +++ b/engines/neverhood/modules/module1000_sprites.cpp @@ -39,10 +39,10 @@ AsScene1001Door::AsScene1001Door(NeverhoodEngine *vm) uint32 AsScene1001Door::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: hammerHitsDoor(); break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -118,13 +118,13 @@ AsScene1001Hammer::AsScene1001Hammer(NeverhoodEngine *vm, Sprite *asDoor) uint32 AsScene1001Hammer::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x00352100) sendMessage(_asDoor, 0x2000, 0); else if (param.asInteger() == 0x0A1A0109) playSound(0, 0x66410886); break; - case 0x2000: + case NM_ANIMATION_UPDATE: startAnimation(0x022C90D4, 1, -1); playSound(0, 0xE741020A); _newStickFrameIndex = STICK_LAST_FRAME; @@ -148,14 +148,14 @@ AsScene1001Window::AsScene1001Window(NeverhoodEngine *vm) uint32 AsScene1001Window::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x0E0A1410) playSound(0, 0x60803F10); break; case 0x2001: startAnimation(0xC68C2299, 0, -1); break; - case 0x3002: + case NM_ANIMATION_STOP: SetMessageHandler(NULL); setGlobalVar(V_WINDOW_OPEN, 1); setVisible(false); @@ -180,9 +180,9 @@ AsScene1001Lever::AsScene1001Lever(NeverhoodEngine *vm, Scene *parentScene, int1 uint32 AsScene1001Lever::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x00C0C444) - sendMessage(_parentScene, 0x480F, 0); + sendMessage(_parentScene, NM_KLAYMEN_LOWER_LEVER, 0); else if (param.asInteger() == 0xC41A02C0) playSound(0, 0x40581882); break; @@ -190,18 +190,18 @@ uint32 AsScene1001Lever::handleMessage(int messageNum, const MessageParam ¶m sendMessage(_parentScene, 0x4826, 0); messageResult = 1; break; - case 0x3002: + case NM_ANIMATION_STOP: startAnimation(0x04A98C36, 0, -1); _newStickFrameIndex = 0; break; - case 0x480F: + case NM_KLAYMEN_LOWER_LEVER: startAnimation(0x04A98C36, 0, -1); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -272,23 +272,23 @@ void AsScene1002Ring::update() { uint32 AsScene1002Ring::hmRingIdle(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x4806: + case NM_KLAYMEN_USE_OBJECT: setDoDeltaX(((Sprite*)sender)->isDoDeltaX() ? 1 : 0); - sendMessage(_parentScene, 0x4806, 0); + sendMessage(_parentScene, NM_KLAYMEN_USE_OBJECT, 0); SetMessageHandler(&AsScene1002Ring::hmRingPulled1); startAnimation(_isSpecial ? 0x87502558 : 0x80DD4010, 0, -1); break; - case 0x480F: + case NM_KLAYMEN_LOWER_LEVER: setDoDeltaX(((Sprite*)sender)->isDoDeltaX() ? 1 : 0); - sendMessage(_parentScene, 0x480F, 0); + sendMessage(_parentScene, NM_KLAYMEN_LOWER_LEVER, 0); SetMessageHandler(&AsScene1002Ring::hmRingPulled2); startAnimation(0x861A2020, 0, -1); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -297,21 +297,21 @@ uint32 AsScene1002Ring::hmRingIdle(int messageNum, const MessageParam ¶m, En uint32 AsScene1002Ring::hmRingPulled1(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: startAnimation(_isSpecial ? 0x78D0A812 : 0xB85D2A10, 0, -1); SetMessageHandler(&AsScene1002Ring::hmRingHangingLow); break; - case 0x4807: - sendMessage(_parentScene, 0x4807, 0); + case NM_KLAYMEN_RAISE_LEVER: + sendMessage(_parentScene, NM_KLAYMEN_RAISE_LEVER, 0); setDoDeltaX(_vm->_rnd->getRandomNumber(1)); startAnimation(0x8258A030, 0, -1); SetMessageHandler(&AsScene1002Ring::hmRingReleased); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -320,15 +320,15 @@ uint32 AsScene1002Ring::hmRingPulled1(int messageNum, const MessageParam ¶m, uint32 AsScene1002Ring::hmRingPulled2(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: startAnimation(0x04103090, 0, -1); SetMessageHandler(&AsScene1002Ring::hmRingHangingLow); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -337,17 +337,17 @@ uint32 AsScene1002Ring::hmRingPulled2(int messageNum, const MessageParam ¶m, uint32 AsScene1002Ring::hmRingHangingLow(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x4807: - sendMessage(_parentScene, 0x4807, 0); + case NM_KLAYMEN_RAISE_LEVER: + sendMessage(_parentScene, NM_KLAYMEN_RAISE_LEVER, 0); setDoDeltaX(_vm->_rnd->getRandomNumber(1)); startAnimation(0x8258A030, 0, -1); SetMessageHandler(&AsScene1002Ring::hmRingReleased); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -356,18 +356,18 @@ uint32 AsScene1002Ring::hmRingHangingLow(int messageNum, const MessageParam &par uint32 AsScene1002Ring::hmRingReleased(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmRingIdle(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x05410F72) playSound(0, 0x21EE40A9); break; - case 0x3002: + case NM_ANIMATION_STOP: startAnimation(0xA85C4011, 0, -1); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -391,11 +391,11 @@ void AsScene1002Door::update() { uint32 AsScene1002Door::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: setGlobalVar(V_FLYTRAP_RING_DOOR, 1); SetSpriteUpdate(&AsScene1002Door::suOpenDoor); break; - case 0x4809: + case NM_KLAYMEN_CLOSE_DOOR: setGlobalVar(V_FLYTRAP_RING_DOOR, 0); SetSpriteUpdate(&AsScene1002Door::suCloseDoor); break; @@ -443,7 +443,7 @@ uint32 AsScene1002BoxingGloveHitEffect::handleMessage(int messageNum, const Mess startAnimation(0x0422255A, 0, -1); setVisible(true); break; - case 0x3002: + case NM_ANIMATION_STOP: stopAnimation(); setVisible(false); break; @@ -467,7 +467,7 @@ AsScene1002DoorSpy::AsScene1002DoorSpy(NeverhoodEngine *vm, NRect &clipRect, Sce uint32 AsScene1002DoorSpy::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0xA61CA1C2) sendMessage(_asBoxingGloveHitEffect, 0x2004, 0); else if (param.asInteger() == 0x14CE0620) @@ -483,7 +483,7 @@ uint32 AsScene1002DoorSpy::handleMessage(int messageNum, const MessageParam &par uint32 AsScene1002DoorSpy::hmDoorSpyAnimation(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -607,7 +607,7 @@ void AsScene1002VenusFlyTrap::upIdle() { uint32 AsScene1002VenusFlyTrap::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x000890C4) playSound(0, 0xC21190D8); else if (param.asInteger() == 0x522200A0) @@ -660,11 +660,11 @@ uint32 AsScene1002VenusFlyTrap::handleMessage(int messageNum, const MessageParam case 0x4810: swallowKlaymen(); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 995); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 995); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1015); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1015); break; } return messageResult; @@ -673,7 +673,7 @@ uint32 AsScene1002VenusFlyTrap::handleMessage(int messageNum, const MessageParam uint32 AsScene1002VenusFlyTrap::hmAnimationSimple(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -683,7 +683,7 @@ uint32 AsScene1002VenusFlyTrap::hmAnimationSimple(int messageNum, const MessageP uint32 AsScene1002VenusFlyTrap::hmAnimationExt(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x000890C4) playSound(0, 0xC21190D8); else if (param.asInteger() == 0x41881801) { @@ -698,14 +698,14 @@ uint32 AsScene1002VenusFlyTrap::hmAnimationExt(int messageNum, const MessagePara } else if (param.asInteger() == 0x522200A0) playSound(0, 0x931080C8); break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 995); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 995); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1015); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1015); break; } return messageResult; @@ -727,7 +727,7 @@ void AsScene1002VenusFlyTrap::stWalk() { } void AsScene1002VenusFlyTrap::stRelease() { - sendMessage(_parentScene, 0x4807, 0); + sendMessage(_parentScene, NM_KLAYMEN_RAISE_LEVER, 0); startAnimation(0x82292851, 0, -1); SetUpdateHandler(&AsScene1002VenusFlyTrap::update); SetMessageHandler(&AsScene1002VenusFlyTrap::hmAnimationSimple); @@ -833,11 +833,11 @@ void AsScene1002OutsideDoorBackground::update() { uint32 AsScene1002OutsideDoorBackground::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageResult) { - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: _isDoorClosed = false; _countdown = 2; break; - case 0x4809: + case NM_KLAYMEN_CLOSE_DOOR: _isDoorClosed = true; _countdown = 2; break; @@ -848,7 +848,7 @@ uint32 AsScene1002OutsideDoorBackground::handleMessage(int messageNum, const Mes uint32 AsScene1002OutsideDoorBackground::hmAnimation(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = handleMessage(messageNum, param, sender); switch (messageResult) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -930,14 +930,14 @@ void AsScene1002KlaymenPeekHand::update() { uint32 AsScene1002KlaymenPeekHand::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x4AB28209) { - sendMessage(_parentScene, 0x1022, 1200); + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1200); _isClipRectSaved = true; _savedClipRect = _surface->getClipRect(); setClipRect(0, 0, 640, 480); } else if (param.asInteger() == 0x88001184) { - sendMessage(_parentScene, 0x1022, 1000); + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1000); if (_isClipRectSaved) setClipRect(_savedClipRect); } @@ -960,15 +960,15 @@ AsScene1004TrashCan::AsScene1004TrashCan(NeverhoodEngine *vm) uint32 AsScene1004TrashCan::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x225A8587) playSound(0, 0x109AFC4C); break; - case 0x2002: + case NM_POSITION_CHANGE: startAnimation(0xEB312C11, 0, -1); setVisible(true); break; - case 0x3002: + case NM_ANIMATION_STOP: stopAnimation(); setVisible(false); break; @@ -991,7 +991,7 @@ uint32 KmScene1001::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4804: @@ -1001,10 +1001,10 @@ uint32 KmScene1001::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x480D: GotoState(&KmScene1001::stPullHammerLever); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: GotoState(&Klaymen::stPickUpGeneric); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 1) GotoState(&Klaymen::stPressButton); else if (param.asInteger() == 2) @@ -1040,7 +1040,7 @@ uint32 KmScene1001::xHandleMessage(int messageNum, const MessageParam ¶m) { break; case 0x4836: if (param.asInteger() == 1) { - sendMessage(_parentScene, 0x2002, 0); + sendMessage(_parentScene, NM_POSITION_CHANGE, 0); GotoState(&KmScene1001::stWakeUp); } break; @@ -1075,7 +1075,7 @@ void KmScene1001::stSleeping() { uint32 KmScene1001::hmSleeping(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevel(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x03060012) { playSound(0, 0xC0238244); } @@ -1098,9 +1098,9 @@ void KmScene1001::stPullHammerLever() { uint32 KmScene1001::hmPullHammerLever(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Klaymen::hmLever(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x4AB28209) - sendMessage(_attachedSprite, 0x480F, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_LOWER_LEVER, 0); break; } return messageResult; @@ -1129,14 +1129,14 @@ uint32 KmScene1002::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x2001: GotoState(&Klaymen::stStandIdleSpecial); break; - case 0x2007: + case NM_CAR_MOVE_TO_PREV_POINT: _otherSprite = (Sprite*)param.asEntity(); break; case 0x4001: case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4803: @@ -1164,13 +1164,13 @@ uint32 KmScene1002::xHandleMessage(int messageNum, const MessageParam ¶m) { break; } break; - case 0x480A: + case NM_KLAYMEN_MOVE_OBJECT: GotoState(&KmScene1002::stMoveVenusFlyTrap); break; case 0x480D: GotoState(&KmScene1002::stJumpToRingVenusFlyTrap); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 0) GotoState(&KmScene1002::stPressDoorButton); break; @@ -1182,21 +1182,21 @@ uint32 KmScene1002::xHandleMessage(int messageNum, const MessageParam ¶m) { startWalkToAttachedSpriteXDistance(param.asInteger()); break; case 0x4820: - sendMessage(_parentScene, 0x2005, 0); + sendMessage(_parentScene, NM_KLAYMEN_CLIMB_LADDER, 0); GotoState(&Klaymen::stContinueClimbLadderUp); break; case 0x4821: - sendMessage(_parentScene, 0x2005, 0); + sendMessage(_parentScene, NM_KLAYMEN_CLIMB_LADDER, 0); _destY = param.asInteger(); GotoState(&Klaymen::stStartClimbLadderDown); break; case 0x4822: - sendMessage(_parentScene, 0x2005, 0); + sendMessage(_parentScene, NM_KLAYMEN_CLIMB_LADDER, 0); _destY = param.asInteger(); GotoState(&Klaymen::stStartClimbLadderUp); break; case 0x4823: - sendMessage(_parentScene, 0x2006, 0); + sendMessage(_parentScene, NM_KLAYMEN_STOP_CLIMBING, 0); GotoState(&Klaymen::stClimbLadderHalf); break; case 0x482E: @@ -1227,22 +1227,22 @@ void KmScene1002::setupJumpToRing() { SetMessageHandler(&KmScene1002::hmJumpToRing); SetSpriteUpdate(&Klaymen::suUpdateDestX); NextState(&KmScene1002::stHangOnRing); - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); } uint32 KmScene1002::hmJumpToRing(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x168050A0) { - sendMessage(_attachedSprite, 0x4806, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_USE_OBJECT, 0); _acceptInput = true; } else if (param.asInteger() == 0x320AC306) { playSound(0, 0x5860C640); } else if (param.asInteger() == 0x4AB28209) { - sendMessage(_attachedSprite, 0x482A, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_BACK, 0); } else if (param.asInteger() == 0x88001184) { - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); } break; } @@ -1283,22 +1283,22 @@ void KmScene1002::stJumpToRing3() { SetSpriteUpdate(&Klaymen::suUpdateDestX); SetMessageHandler(&KmScene1002::hmJumpToRing3); NextState(&KmScene1002::stHoldRing3); - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); } } uint32 KmScene1002::hmJumpToRing3(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x168050A0) { - sendMessage(_attachedSprite, 0x4806, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_USE_OBJECT, 0); } else if (param.asInteger() == 0x320AC306) { playSound(0, 0x5860C640); } else if (param.asInteger() == 0x4AB28209) { - sendMessage(_attachedSprite, 0x482A, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_BACK, 0); } else if (param.asInteger() == 0x88001184) { - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); } break; } @@ -1339,22 +1339,22 @@ void KmScene1002::stJumpToRingVenusFlyTrap() { SetMessageHandler(&KmScene1002::hmJumpToRingVenusFlyTrap); SetSpriteUpdate(&AnimatedSprite::updateDeltaXY); NextState(&KmScene1002::stLandOnFeet); - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); } } uint32 KmScene1002::hmJumpToRingVenusFlyTrap(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x168050A0) { - sendMessage(_attachedSprite, 0x480F, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_LOWER_LEVER, 0); } else if (param.asInteger() == 0x586B0300) { sendMessage(_otherSprite, 0x480E, 1); } else if (param.asInteger() == 0x4AB28209) { - sendMessage(_attachedSprite, 0x482A, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_BACK, 0); } else if (param.asInteger() == 0x88001184) { - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); } break; } @@ -1377,7 +1377,7 @@ void KmScene1002::stJumpAndFall() { void KmScene1002::stDropFromRing() { if (_attachedSprite) { _x = _attachedSprite->getX(); - sendMessage(_attachedSprite, 0x4807, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_RAISE_LEVER, 0); _attachedSprite = NULL; } _busyStatus = 2; @@ -1392,7 +1392,7 @@ void KmScene1002::stDropFromRing() { uint32 KmScene1002::hmJumpAndFall(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevel(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x1307050A) { playSound(0, 0x40428A09); } @@ -1426,12 +1426,12 @@ void KmScene1002::stContinueMovingVenusFlyTrap() { } void KmScene1002::evMoveVenusFlyTrapDone() { - sendMessage(_attachedSprite, 0x482A, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_BACK, 0); } uint32 KmScene1002::hmMoveVenusFlyTrap(int messageNum, const MessageParam ¶m, Entity *sender) { switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x01084280) { sendMessage(_attachedSprite, 0x480B, (uint32)_doDeltaX); } else if (param.asInteger() == 0x02421405) { @@ -1442,16 +1442,16 @@ uint32 KmScene1002::hmMoveVenusFlyTrap(int messageNum, const MessageParam ¶m SetMessageHandler(&KmScene1002::hmFirstMoveVenusFlyTrap); } } else if (param.asInteger() == 0x4AB28209) { - sendMessage(_attachedSprite, 0x482A, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_BACK, 0); } else if (param.asInteger() == 0x88001184) { - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); } else if (param.asInteger() == 0x32180101) { playSound(0, 0x405002D8); } else if (param.asInteger() == 0x0A2A9098) { playSound(0, 0x0460E2FA); } break; - case 0x480A: + case NM_KLAYMEN_MOVE_OBJECT: _isMoveObjectRequested = true; return 0; } @@ -1461,11 +1461,11 @@ uint32 KmScene1002::hmMoveVenusFlyTrap(int messageNum, const MessageParam ¶m uint32 KmScene1002::hmFirstMoveVenusFlyTrap(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x4AB28209) { - sendMessage(_attachedSprite, 0x482A, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_BACK, 0); } else if (param.asInteger() == 0x88001184) { - sendMessage(_attachedSprite, 0x482B, 0); + sendMessage(_attachedSprite, NM_MOVE_TO_FRONT, 0); } else if (param.asInteger() == 0x32180101) { playSound(0, 0x405002D8); } else if (param.asInteger() == 0x0A2A9098) { @@ -1503,7 +1503,7 @@ void KmScene1002::evHitByBoxingGloveDone() { uint32 KmScene1002::hmPressDoorButton(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x942D2081) { _acceptInput = false; sendMessage(_attachedSprite, 0x2003, 0); @@ -1530,7 +1530,7 @@ uint32 KmScene1002::hmHitByBoxingGlove(int messageNum, const MessageParam ¶m } messageResult = 0; break; - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x1A1A0785) { playSound(0, 0x40F0A342); } else if (param.asInteger() == 0x60428026) { @@ -1553,7 +1553,7 @@ uint32 KmScene1004::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4817: @@ -1563,7 +1563,7 @@ uint32 KmScene1004::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4818: startWalkToX(_dataResource.getPoint(param.asInteger()).x, false); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: GotoState(&KmScene1004::stReadNote); break; case 0x4820: @@ -1610,10 +1610,10 @@ uint32 KmScene1004::xHandleMessage(int messageNum, const MessageParam ¶m) { uint32 KmScene1004::hmReadNote(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x04684052) { _acceptInput = true; - sendMessage(_parentScene, 0x2002, 0); + sendMessage(_parentScene, NM_POSITION_CHANGE, 0); } break; } diff --git a/engines/neverhood/modules/module1100.cpp b/engines/neverhood/modules/module1100.cpp index af2df2e742..e7dd6e4210 100644 --- a/engines/neverhood/modules/module1100.cpp +++ b/engines/neverhood/modules/module1100.cpp @@ -286,7 +286,7 @@ uint32 Scene1105::handleMessage(int messageNum, const MessageParam ¶m, Entit uint32 messageResult = 0; Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) { if (!_isActionButtonClicked && _backgroundIndex == 0) { if (_isPanelOpen) { @@ -309,7 +309,7 @@ uint32 Scene1105::handleMessage(int messageNum, const MessageParam ¶m, Entit _leaveResult = 1; SetUpdateHandler(&Scene1105::upClosePanel); break; - case 0x4807: + case NM_KLAYMEN_RAISE_LEVER: if (sender == _ssActionButton) { if (getSubVar(VA_GOOD_DICE_NUMBERS, 0) == getSubVar(VA_CURR_DICE_NUMBERS, 0) && getSubVar(VA_GOOD_DICE_NUMBERS, 1) == getSubVar(VA_CURR_DICE_NUMBERS, 1) && @@ -318,7 +318,7 @@ uint32 Scene1105::handleMessage(int messageNum, const MessageParam ¶m, Entit playSound(2); _doMoveTeddy = true; } else { - sendMessage(_asTeddyBear, 0x2002, 0); + sendMessage(_asTeddyBear, NM_POSITION_CHANGE, 0); } showMouse(false); _isActionButtonClicked = true; @@ -460,7 +460,7 @@ void Scene1105::update() { if (_isClosePanelDone && !isSoundPlaying(1)) leaveScene(_leaveResult); if (_doMoveTeddy && !isSoundPlaying(2)) { - sendMessage(_asTeddyBear, 0x2002, 0); + sendMessage(_asTeddyBear, NM_POSITION_CHANGE, 0); _doMoveTeddy = false; } } @@ -513,7 +513,7 @@ Scene1109::Scene1109(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene1109::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: if (param.asInteger()) { setRectList(0x004B63A8); _klaymen->setKlaymenIdleTable3(); diff --git a/engines/neverhood/modules/module1100_sprites.cpp b/engines/neverhood/modules/module1100_sprites.cpp index 51e0bb3f49..49a388ffca 100644 --- a/engines/neverhood/modules/module1100_sprites.cpp +++ b/engines/neverhood/modules/module1100_sprites.cpp @@ -48,7 +48,7 @@ SsScene1105Button::SsScene1105Button(NeverhoodEngine *vm, Scene *parentScene, ui void SsScene1105Button::update() { if (_countdown != 0 && (--_countdown == 0)) { - sendMessage(_parentScene, 0x4807, 0); + sendMessage(_parentScene, NM_KLAYMEN_RAISE_LEVER, 0); setVisible(false); } } @@ -96,7 +96,7 @@ SsScene1105SymbolDie::SsScene1105SymbolDie(NeverhoodEngine *vm, uint dieIndex, i uint32 SsScene1105SymbolDie::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: loadSymbolSprite(); break; } @@ -133,7 +133,7 @@ AsScene1105TeddyBear::AsScene1105TeddyBear(NeverhoodEngine *vm, Scene *parentSce uint32 AsScene1105TeddyBear::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2002: + case NM_POSITION_CHANGE: if (getGlobalVar(V_ROBOT_TARGET)) { startAnimation(0x6B0C0432, 0, -1); playSound(0); @@ -142,7 +142,7 @@ uint32 AsScene1105TeddyBear::handleMessage(int messageNum, const MessageParam &p playSound(1); } break; - case 0x3002: + case NM_ANIMATION_STOP: sendMessage(_parentScene, 0x2003, 0); stopAnimation(); break; @@ -206,7 +206,7 @@ KmScene1109::KmScene1109(NeverhoodEngine *vm, Scene *parentScene, int16 x, int16 uint32 KmScene1109::xHandleMessage(int messageNum, const MessageParam ¶m) { uint32 messageResult = 0; switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: _isSittingInTeleporter = param.asInteger() != 0; messageResult = 1; break; @@ -214,7 +214,7 @@ uint32 KmScene1109::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: if (_isSittingInTeleporter) GotoState(&Klaymen::stSitIdleTeleporter); else @@ -231,11 +231,11 @@ uint32 KmScene1109::xHandleMessage(int messageNum, const MessageParam ¶m) { setDoDeltaX(param.asInteger()); gotoNextStateExt(); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stTurnToUseInTeleporter); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stReturnFromUseInTeleporter); break; diff --git a/engines/neverhood/modules/module1200.cpp b/engines/neverhood/modules/module1200.cpp index 975545091d..8bf42b3b96 100644 --- a/engines/neverhood/modules/module1200.cpp +++ b/engines/neverhood/modules/module1200.cpp @@ -296,15 +296,15 @@ void Scene1201::update() { uint32 Scene1201::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x07053000) { _creatureExploded = true; sendMessage(_asCreature, 0x2004, 0); } else if (param.asInteger() == 0x140E5744) - sendMessage(_asCreature, 0x2005, 0); + sendMessage(_asCreature, NM_KLAYMEN_CLIMB_LADDER, 0); else if (param.asInteger() == 0x40253C40) { _canAcceptInput = false; - sendMessage(_asCreature, 0x2006, 0); + sendMessage(_asCreature, NM_KLAYMEN_STOP_CLIMBING, 0); } else if (param.asInteger() == 0x090EB048) { if (_klaymen->getX() < 572) setMessageList2(0x004AEC90); @@ -320,7 +320,7 @@ uint32 Scene1201::handleMessage(int messageNum, const MessageParam ¶m, Entit setMessageList2(0x004AECC0); } break; - case 0x2002: + case NM_POSITION_CHANGE: if (getGlobalVar(V_TNT_DUMMY_FUSE_LIT)) { // Move the TNT dummy if the fuse is burning sendEntityMessage(_klaymen, 0x1014, _asTntMan); @@ -347,7 +347,7 @@ uint32 Scene1201::handleMessage(int messageNum, const MessageParam ¶m, Entit sendMessage(_asRightDoor, 0x4829, 0); break; case 0x8000: - sendMessage(_asKlaymenHead, 0x2006, 0); + sendMessage(_asKlaymenHead, NM_KLAYMEN_STOP_CLIMBING, 0); break; } return messageResult; @@ -427,14 +427,14 @@ uint32 Scene1202::handleMessage(int messageNum, const MessageParam ¶m, Entit uint32 messageResult = 0; Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if ((param.asPoint().x <= 20 || param.asPoint().x >= 620) && !_isPuzzleSolved) leaveScene(0); break; - case 0x2000: + case NM_ANIMATION_UPDATE: _clickedIndex = (int)param.asInteger(); break; - case 0x2002: + case NM_POSITION_CHANGE: _counter--; break; } @@ -444,7 +444,7 @@ uint32 Scene1202::handleMessage(int messageNum, const MessageParam ¶m, Entit uint32 Scene1202::hmSolved(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) leaveScene(0); break; diff --git a/engines/neverhood/modules/module1200_sprites.cpp b/engines/neverhood/modules/module1200_sprites.cpp index da38924d9a..5848e16092 100644 --- a/engines/neverhood/modules/module1200_sprites.cpp +++ b/engines/neverhood/modules/module1200_sprites.cpp @@ -72,7 +72,7 @@ uint32 AsScene1201Tape::handleMessage(int messageNum, const MessageParam ¶m, sendMessage(_parentScene, 0x4826, 0); messageResult = 1; break; - case 0x4806: + case NM_KLAYMEN_USE_OBJECT: setSubVar(VA_HAS_TAPE, _nameHash, 1); setVisible(false); SetMessageHandler(NULL); @@ -101,11 +101,11 @@ AsScene1201TntManRope::AsScene1201TntManRope(NeverhoodEngine *vm, bool isDummyHa uint32 AsScene1201TntManRope::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x02060018) playSound(0, 0x47900E06); break; - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: startAnimation(0x928F0C10, 1, -1); _newStickFrameIndex = STICK_LAST_FRAME; break; @@ -141,7 +141,7 @@ void AsScene1201RightDoor::update() { uint32 AsScene1201RightDoor::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; case 0x4829: @@ -184,13 +184,13 @@ AsScene1201KlaymenHead::AsScene1201KlaymenHead(NeverhoodEngine *vm) uint32 AsScene1201KlaymenHead::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: _x = 436; _y = 339; startAnimation(0xA060C599, 0, -1); setVisible(true); break; - case 0x3002: + case NM_ANIMATION_STOP: stopAnimation(); setVisible(false); gotoNextState(); @@ -223,14 +223,14 @@ AsScene1201TntMan::~AsScene1201TntMan() { uint32 AsScene1201TntMan::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x092870C0) - sendMessage(_asTntManRope, 0x2006, 0); + sendMessage(_asTntManRope, NM_KLAYMEN_STOP_CLIMBING, 0); else if (param.asInteger() == 0x11CA0144) playSound(0, 0x51800A04); break; case 0x1011: - sendMessage(_parentScene, 0x2002, 0); + sendMessage(_parentScene, NM_POSITION_CHANGE, 0); messageResult = 1; break; case 0x480B: @@ -247,7 +247,7 @@ uint32 AsScene1201TntMan::handleMessage(int messageNum, const MessageParam ¶ uint32 AsScene1201TntMan::hmComingDown(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = AsScene1201TntMan::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -353,7 +353,7 @@ void AsScene1201Match::update() { uint32 AsScene1201Match::hmOnDoorFrameAboutToMove(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x86668011) playSound(0); break; @@ -364,7 +364,7 @@ uint32 AsScene1201Match::hmOnDoorFrameAboutToMove(int messageNum, const MessageP uint32 AsScene1201Match::hmOnDoorFrameMoving(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmOnDoorFrameAboutToMove(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -378,7 +378,7 @@ uint32 AsScene1201Match::hmIdle(int messageNum, const MessageParam ¶m, Entit sendMessage(_parentScene, 0x2001, 0); messageResult = 1; break; - case 0x4806: + case NM_KLAYMEN_USE_OBJECT: setVisible(false); setGlobalVar(V_MATCH_STATUS, 3); break; @@ -459,14 +459,14 @@ void AsScene1201Creature::update() { uint32 AsScene1201Creature::hmWaiting(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x02060018) playSound(0, 0xCD298116); break; case 0x2004: GotoState(&AsScene1201Creature::stStartReachForTntDummy); break; - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: GotoState(&AsScene1201Creature::stPincerSnapKlaymen); break; } @@ -476,7 +476,7 @@ uint32 AsScene1201Creature::hmWaiting(int messageNum, const MessageParam ¶m, uint32 AsScene1201Creature::hmPincerSnap(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmWaiting(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -486,14 +486,14 @@ uint32 AsScene1201Creature::hmPincerSnap(int messageNum, const MessageParam &par uint32 AsScene1201Creature::hmPincerSnapKlaymen(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x02060018) { playSound(0, 0xCD298116); sendMessage(_parentScene, 0x4814, 0); sendMessage(_klaymen, 0x4814, 0); } break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -556,7 +556,7 @@ AsScene1201LeftDoor::AsScene1201LeftDoor(NeverhoodEngine *vm, Sprite *klaymen) uint32 AsScene1201LeftDoor::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x4809: + case NM_KLAYMEN_CLOSE_DOOR: stCloseDoor(); break; } @@ -619,7 +619,7 @@ uint32 AsScene1202TntItem::hmShowIdle(int messageNum, const MessageParam ¶m, uint32 AsScene1202TntItem::hmChangePosition(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -648,7 +648,7 @@ void AsScene1202TntItem::stChangePositionFadeIn() { } void AsScene1202TntItem::stChangePositionDone() { - sendMessage(_parentScene, 0x2002, _itemIndex); + sendMessage(_parentScene, NM_POSITION_CHANGE, _itemIndex); stShowIdle(); } @@ -671,13 +671,13 @@ uint32 KmScene1201::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; - case 0x480A: + case NM_KLAYMEN_MOVE_OBJECT: GotoState(&Klaymen::stMoveObject); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: GotoState(&Klaymen::stPickUpGeneric); break; case 0x4813: @@ -689,7 +689,7 @@ uint32 KmScene1201::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4815: GotoState(&KmScene1201::stCloseEyes); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 0) GotoState(&Klaymen::stPressButtonSide); break; @@ -703,10 +703,10 @@ uint32 KmScene1201::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: GotoState(&Klaymen::stTurnToUse); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: GotoState(&Klaymen::stReturnFromUse); break; case 0x481F: @@ -755,7 +755,7 @@ void KmScene1201::stCloseEyes() { uint32 KmScene1201::hmMatch(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Klaymen::hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x51281850) { setGlobalVar(V_TNT_DUMMY_FUSE_LIT, 1); } else if (param.asInteger() == 0x43000538) { @@ -798,7 +798,7 @@ void KmScene1201::stLightMatch() { uint32 KmScene1201::hmTumbleHeadless(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Klaymen::hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x000F0082) { playSound(0, 0x74E2810F); } diff --git a/engines/neverhood/modules/module1300.cpp b/engines/neverhood/modules/module1300.cpp index 312fb85ae7..fe119c1732 100644 --- a/engines/neverhood/modules/module1300.cpp +++ b/engines/neverhood/modules/module1300.cpp @@ -350,7 +350,7 @@ Scene1302::Scene1302(NeverhoodEngine *vm, Module *parentModule, int which) _asVenusFlyTrap = insertSprite<AsScene1002VenusFlyTrap>(this, _klaymen, true); addCollisionSprite(_asVenusFlyTrap); - sendEntityMessage(_klaymen, 0x2007, _asVenusFlyTrap); + sendEntityMessage(_klaymen, NM_CAR_MOVE_TO_PREV_POINT, _asVenusFlyTrap); } @@ -358,10 +358,10 @@ uint32 Scene1302::handleMessage(int messageNum, const MessageParam ¶m, Entit uint32 messageResult = 0; Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: - if (param.asInteger() == 0x4A845A00) + case NM_ANIMATION_START: + if (param.asInteger() == 0x4A845A00) { sendEntityMessage(_klaymen, 0x1014, _asRing1); - else if (param.asInteger() == 0x43807801) { + } else if (param.asInteger() == 0x43807801) { if (!getGlobalVar(V_FLYTRAP_RING_BRIDGE)) { sendEntityMessage(_klaymen, 0x1014, _asRing2); if (_asVenusFlyTrap->getX() - 10 < 218 + 32 && _asVenusFlyTrap->getX() + 10 > 218 + 32) @@ -371,9 +371,9 @@ uint32 Scene1302::handleMessage(int messageNum, const MessageParam ¶m, Entit } else setMessageList(0x004B0950); messageResult = 1; - } else if (param.asInteger() == 0x46C26A01) + } else if (param.asInteger() == 0x46C26A01) { sendEntityMessage(_klaymen, 0x1014, _asRing3); - else if (param.asInteger() == 0x468C7B11) { + } else if (param.asInteger() == 0x468C7B11) { if (!getGlobalVar(V_FLYTRAP_RING_FENCE)) { sendEntityMessage(_klaymen, 0x1014, _asRing4); if (_asVenusFlyTrap->getX() - 10 < 218 + 32 + 32 + 32 && _asVenusFlyTrap->getX() + 10 > 218 + 32 + 32 + 32) @@ -383,9 +383,9 @@ uint32 Scene1302::handleMessage(int messageNum, const MessageParam ¶m, Entit } else setMessageList(0x004B0950); messageResult = 1; - } else if (param.asInteger() == 0x42845B19) + } else if (param.asInteger() == 0x42845B19) { sendEntityMessage(_klaymen, 0x1014, _asRing5); - else if (param.asInteger() == 0x430A6060) { + } else if (param.asInteger() == 0x430A6060) { if (getGlobalVar(V_FLYTRAP_RING_BRIDGE)) setMessageList2(0x004B0910); else @@ -402,66 +402,66 @@ uint32 Scene1302::handleMessage(int messageNum, const MessageParam ¶m, Entit setMessageList(0x004B0978); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (_klaymen->getY() > 360) { sendEntityMessage(_klaymen, 0x1014, _asVenusFlyTrap); setMessageList2(0x004B08F0); } else setMessageList2(0x004B0920); break; - case 0x2002: + case NM_POSITION_CHANGE: if (_klaymen->getX() > 545) leaveScene(1); break; case 0x2032: _sprite2->setVisible(true); break; - case 0x4806: + case NM_KLAYMEN_USE_OBJECT: sendMessage(_parentModule, 0x1024, 2); if (sender == _asRing1) playSound(0, 0x665198C0); else if (sender == _asRing2) { - sendMessage(_asBridge, 0x4808, 0); + sendMessage(_asBridge, NM_KLAYMEN_OPEN_DOOR, 0); setGlobalVar(V_FLYTRAP_RING_BRIDGE, 1); - } else if (sender == _asRing3) + } else if (sender == _asRing3) { playSound(0, 0xE2D389C0); - else if (sender == _asRing4) { - sendMessage(_ssFence, 0x4808, 0); + } else if (sender == _asRing4) { + sendMessage(_ssFence, NM_KLAYMEN_OPEN_DOOR, 0); setGlobalVar(V_FLYTRAP_RING_FENCE, 1); } else if (sender == _asRing5) playSound(0, 0x40428A09); break; - case 0x4807: + case NM_KLAYMEN_RAISE_LEVER: if (sender == _asRing2) { - sendMessage(_asBridge, 0x4809, 0); + sendMessage(_asBridge, NM_KLAYMEN_CLOSE_DOOR, 0); setGlobalVar(V_FLYTRAP_RING_BRIDGE, 0); _sprite2->setVisible(false); } else if (sender == _asRing4) { - sendMessage(_ssFence, 0x4809, 0); + sendMessage(_ssFence, NM_KLAYMEN_CLOSE_DOOR, 0); setGlobalVar(V_FLYTRAP_RING_FENCE, 0); } else if (sender == _asVenusFlyTrap) { if (getGlobalVar(V_FLYTRAP_RING_BRIDGE)) - sendMessage(_asRing2, 0x4807, 0); + sendMessage(_asRing2, NM_KLAYMEN_RAISE_LEVER, 0); else - sendMessage(_asRing4, 0x4807, 0); + sendMessage(_asRing4, NM_KLAYMEN_RAISE_LEVER, 0); } break; - case 0x480F: + case NM_KLAYMEN_LOWER_LEVER: if (sender == _asRing2) { playSound(0, 0x60755842); - sendMessage(_asBridge, 0x4808, 0); + sendMessage(_asBridge, NM_KLAYMEN_OPEN_DOOR, 0); setGlobalVar(V_FLYTRAP_RING_BRIDGE, 1); } else if (sender == _asRing4) { playSound(0, 0x60755842); - sendMessage(_ssFence, 0x4808, 0); + sendMessage(_ssFence, NM_KLAYMEN_OPEN_DOOR, 0); setGlobalVar(V_FLYTRAP_RING_FENCE, 1); } break; - case 0x482A: - sendMessage(_asVenusFlyTrap, 0x482B, 0); + case NM_MOVE_TO_BACK: + sendMessage(_asVenusFlyTrap, NM_MOVE_TO_FRONT, 0); break; - case 0x482B: - sendMessage(_asVenusFlyTrap, 0x482A, 0); + case NM_MOVE_TO_FRONT: + sendMessage(_asVenusFlyTrap, NM_MOVE_TO_BACK, 0); break; case 0x8000: setSpriteSurfacePriority(_class595, 995); @@ -500,7 +500,7 @@ Scene1303::Scene1303(NeverhoodEngine *vm, Module *parentModule) uint32 Scene1303::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: setGlobalVar(V_BALLOON_POPPED, 1); sendMessage(_asBalloon, 0x2000, 0); break; @@ -555,7 +555,7 @@ Scene1304::Scene1304(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene1304::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x415634A4) { if (getGlobalVar(V_BALLOON_POPPED)) cancelMessageList(); @@ -629,7 +629,7 @@ Scene1306::Scene1306(NeverhoodEngine *vm, Module *parentModule, int which) insertStaticSprite(0x00042313, 1100); if (which < 0) { - // Resoring game + // Restoring game insertKlaymen<KmScene1306>(380, 440); setMessageList(0x004AFAD0); sendMessage(this, 0x2000, 0); @@ -681,7 +681,7 @@ Scene1306::Scene1306(NeverhoodEngine *vm, Module *parentModule, int which) sendMessage(this, 0x2000, 0); SetMessageHandler(&Scene1306::handleMessage416EB0); clearRectList(); - sendMessage(_asElevator, 0x4808, 0); + sendMessage(_asElevator, NM_KLAYMEN_OPEN_DOOR, 0); } } @@ -693,7 +693,7 @@ Scene1306::~Scene1306() { uint32 Scene1306::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x402064D8) sendEntityMessage(_klaymen, 0x1014, _ssButton); else if (param.asInteger() == 0x01C66840) { @@ -707,7 +707,7 @@ uint32 Scene1306::handleMessage(int messageNum, const MessageParam ¶m, Entit SetMessageHandler(&Scene1306::handleMessage416EB0); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (param.asInteger() != 0) { setRectList(0x004AFD28); _klaymen->setKlaymenIdleTable3(); @@ -718,7 +718,7 @@ uint32 Scene1306::handleMessage(int messageNum, const MessageParam ¶m, Entit break; case 0x480B: if (sender == _ssButton) - sendMessage(_asElevator, 0x4808, 0); + sendMessage(_asElevator, NM_KLAYMEN_OPEN_DOOR, 0); break; case 0x4826: if (sender == _asKey) { @@ -733,12 +733,12 @@ uint32 Scene1306::handleMessage(int messageNum, const MessageParam ¶m, Entit } } break; - case 0x482A: + case NM_MOVE_TO_BACK: setSurfacePriority(_asElevator->getSurface(), 1100); setSurfacePriority(_asElevatorDoor->getSurface(), 1090); setSurfacePriority(_sprite1->getSurface(), 1080); break; - case 0x482B: + case NM_MOVE_TO_FRONT: setSurfacePriority(_asElevator->getSurface(), 100); setSurfacePriority(_asElevatorDoor->getSurface(), 90); setSurfacePriority(_sprite1->getSurface(), 80); @@ -752,19 +752,19 @@ uint32 Scene1306::handleMessage(int messageNum, const MessageParam ¶m, Entit uint32 Scene1306::handleMessage416EB0(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: setMessageList(0x004AFBD0); SetMessageHandler(&Scene1306::handleMessage); break; - case 0x4809: + case NM_KLAYMEN_CLOSE_DOOR: leaveScene(1); break; - case 0x482A: + case NM_MOVE_TO_BACK: setSurfacePriority(_asElevator->getSurface(), 1100); setSurfacePriority(_asElevatorDoor->getSurface(), 1090); setSurfacePriority(_sprite1->getSurface(), 1080); break; - case 0x482B: + case NM_MOVE_TO_FRONT: setSurfacePriority(_asElevator->getSurface(), 100); setSurfacePriority(_asElevatorDoor->getSurface(), 90); setSurfacePriority(_sprite1->getSurface(), 80); @@ -840,7 +840,7 @@ uint32 Scene1307::handleMessage(int messageNum, const MessageParam ¶m, Entit uint32 messageResult = 0; Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (!_isPuzzleSolved) { if (param.asPoint().x > 20 && param.asPoint().x < 620) { if (_asCurrKey && !_isInsertingKey) { @@ -873,7 +873,7 @@ uint32 Scene1307::handleMessage(int messageNum, const MessageParam ¶m, Entit leaveScene(0); } break; - case 0x2002: + case NM_POSITION_CHANGE: // Check if all keys are in the correct keyholes if (getSubVar(VA_IS_KEY_INSERTED, 0) && getSubVar(VA_CURR_KEY_SLOT_NUMBERS, 0) == getSubVar(VA_GOOD_KEY_SLOT_NUMBERS, 0) && getSubVar(VA_IS_KEY_INSERTED, 1) && getSubVar(VA_CURR_KEY_SLOT_NUMBERS, 1) == getSubVar(VA_GOOD_KEY_SLOT_NUMBERS, 1) && @@ -981,7 +981,7 @@ Scene1308::Scene1308(NeverhoodEngine *vm, Module *parentModule, int which) // Klaymen entering from the left insertKlaymen<KmScene1308>(41, 440); setMessageList(0x004B57D0); - sendMessage(_asJaggyDoor, 0x4808, 0); + sendMessage(_asJaggyDoor, NM_KLAYMEN_OPEN_DOOR, 0); _sprite1->setVisible(false); if (getGlobalVar(V_KEYDOOR_UNLOCKED)) { _sprite4 = insertStaticSprite(0x0101A624, 1100); @@ -1009,7 +1009,7 @@ Scene1308::Scene1308(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene1308::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x88C11390) { setRectList(0x004B59A0); _isProjecting = true; @@ -1022,12 +1022,12 @@ uint32 Scene1308::handleMessage(int messageNum, const MessageParam ¶m, Entit _isProjecting = false; } else if (param.asInteger() == 0x4AC68808) { clearRectList(); - sendMessage(_asJaggyDoor, 0x4809, 0); + sendMessage(_asJaggyDoor, NM_KLAYMEN_CLOSE_DOOR, 0); _sprite1->setVisible(false); _klaymen->setVisible(false); } break; - case 0x1022: + case NM_PRIORITY_CHANGE: if (sender == _asProjector) { if (param.asInteger() >= 1000) setSurfacePriority(_sprite3->getSurface(), 1100); @@ -1035,7 +1035,7 @@ uint32 Scene1308::handleMessage(int messageNum, const MessageParam ¶m, Entit setSurfacePriority(_sprite3->getSurface(), 995); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (getGlobalVar(V_KEYDOOR_UNLOCKED)) setRectList(0x004B5990); else @@ -1056,11 +1056,11 @@ uint32 Scene1308::handleMessage(int messageNum, const MessageParam ¶m, Entit _sprite4->setVisible(true); setRectList(0x004B5990); break; - case 0x4807: + case NM_KLAYMEN_RAISE_LEVER: sendMessage(_asLightWallSymbols, 0x2003, 0); break; - case 0x480F: - sendMessage(_asLightWallSymbols, 0x2002, 0); + case NM_KLAYMEN_LOWER_LEVER: + sendMessage(_asLightWallSymbols, NM_POSITION_CHANGE, 0); _ssNumber1->setVisible(true); _ssNumber2->setVisible(true); _ssNumber3->setVisible(true); @@ -1141,7 +1141,7 @@ void Scene1317::upChooseKing() { uint32 Scene1317::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: stChooseKing(); break; } @@ -1151,7 +1151,7 @@ uint32 Scene1317::handleMessage(int messageNum, const MessageParam ¶m, Entit uint32 Scene1317::hmChooseKing(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x >= 21 && param.asPoint().y >= 24 && param.asPoint().x <= 261 && param.asPoint().y <= 280) { stHoborgAsKing(); @@ -1170,7 +1170,7 @@ uint32 Scene1317::hmChooseKing(int messageNum, const MessageParam ¶m, Entity uint32 Scene1317::hmHoborgAsKing(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: stEndMovie(); break; } @@ -1180,7 +1180,7 @@ uint32 Scene1317::hmHoborgAsKing(int messageNum, const MessageParam ¶m, Enti uint32 Scene1317::hmEndMovie(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: leaveScene(0); break; } diff --git a/engines/neverhood/modules/module1300_sprites.cpp b/engines/neverhood/modules/module1300_sprites.cpp index a65f2363a3..0c1632501e 100644 --- a/engines/neverhood/modules/module1300_sprites.cpp +++ b/engines/neverhood/modules/module1300_sprites.cpp @@ -46,13 +46,13 @@ AsScene1302Bridge::AsScene1302Bridge(NeverhoodEngine *vm, Scene *parentScene) uint32 AsScene1302Bridge::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: stLowerBridge(); break; - case 0x4809: + case NM_KLAYMEN_CLOSE_DOOR: stRaiseBridge(); break; } @@ -99,12 +99,12 @@ void SsScene1302Fence::update() { uint32 SsScene1302Fence::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: playSound(0); SetMessageHandler(NULL); SetSpriteUpdate(&SsScene1302Fence::suMoveDown); break; - case 0x4809: + case NM_KLAYMEN_CLOSE_DOOR: playSound(1); SetMessageHandler(NULL); SetSpriteUpdate(&SsScene1302Fence::suMoveUp); @@ -150,7 +150,7 @@ uint32 AsScene1303Balloon::handleMessage(int messageNum, const MessageParam &par sendMessage(_parentScene, 0x4826, 0); messageResult = 1; break; - case 0x2000: + case NM_ANIMATION_UPDATE: stPopBalloon(); break; } @@ -160,11 +160,11 @@ uint32 AsScene1303Balloon::handleMessage(int messageNum, const MessageParam &par uint32 AsScene1303Balloon::hmBalloonPopped(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x020B0003) playSound(0, 0x742B0055); break; - case 0x3002: + case NM_ANIMATION_STOP: playSound(0, 0x470007EE); stopAnimation(); setVisible(false); @@ -193,7 +193,7 @@ uint32 AsScene1304Needle::handleMessage(int messageNum, const MessageParam ¶ sendMessage(_parentScene, 0x4826, 0); messageResult = 1; break; - case 0x4806: + case NM_KLAYMEN_USE_OBJECT: setGlobalVar(V_HAS_NEEDLE, 1); setVisible(false); SetMessageHandler(NULL); @@ -241,10 +241,10 @@ uint32 AsScene1306Elevator::handleMessage(int messageNum, const MessageParam &pa _countdown = 144; messageResult = _isUp ? 1 : 0; break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: if (_isDown) stGoingUp(); break; @@ -262,7 +262,7 @@ void AsScene1306Elevator::stGoingUp() { } void AsScene1306Elevator::cbGoingUpEvent() { - sendMessage(_parentScene, 0x4808, 0); + sendMessage(_parentScene, NM_KLAYMEN_OPEN_DOOR, 0); _isUp = true; _countdown = 144; stopAnimation(); @@ -282,7 +282,7 @@ void AsScene1306Elevator::stGoingDown() { void AsScene1306Elevator::cbGoingDownEvent() { _isDown = true; - sendMessage(_parentScene, 0x4809, 0); + sendMessage(_parentScene, NM_KLAYMEN_CLOSE_DOOR, 0); stopAnimation(); SetUpdateHandler(&AsScene1306Elevator::update); } @@ -361,7 +361,7 @@ uint32 AsScene1307Key::handleMessage(int messageNum, const MessageParam ¶m, messageResult = 1; } break; - case 0x2000: + case NM_ANIMATION_UPDATE: _isClickable = param.asInteger() != 0; break; case 0x2001: @@ -401,7 +401,7 @@ void AsScene1307Key::suInsertKey() { playSound(0); } else { SetSpriteUpdate(NULL); - sendMessage(_parentScene, 0x2002, 0); + sendMessage(_parentScene, NM_POSITION_CHANGE, 0); } } @@ -430,7 +430,7 @@ void AsScene1307Key::stRemoveKey() { void AsScene1307Key::stInsertKey() { _pointIndex = 0; - sendMessage(_parentScene, 0x1022, kAsScene1307KeySurfacePriorities[getSubVar(VA_CURR_KEY_SLOT_NUMBERS, _keyIndex) % 4]); + sendMessage(_parentScene, NM_PRIORITY_CHANGE, kAsScene1307KeySurfacePriorities[getSubVar(VA_CURR_KEY_SLOT_NUMBERS, _keyIndex) % 4]); setClipRect(_clipRects[getSubVar(VA_CURR_KEY_SLOT_NUMBERS, _keyIndex) % 4]); _newStickFrameIndex = STICK_LAST_FRAME; SetSpriteUpdate(&AsScene1307Key::suInsertKey); @@ -440,7 +440,7 @@ void AsScene1307Key::stMoveKey() { NPoint pt = (*_pointList)[getSubVar(VA_CURR_KEY_SLOT_NUMBERS, _keyIndex)]; int16 newX = pt.x + kAsScene1307KeyXDelta; int16 newY = pt.y + kAsScene1307KeyYDelta; - sendMessage(_parentScene, 0x1022, 1000); + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1000); setClipRect(0, 0, 640, 480); _prevX = _x; _prevY = _y; @@ -480,13 +480,13 @@ AsScene1308JaggyDoor::AsScene1308JaggyDoor(NeverhoodEngine *vm, Scene *parentSce uint32 AsScene1308JaggyDoor::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: stOpenDoor(); break; - case 0x4809: + case NM_KLAYMEN_CLOSE_DOOR: stCloseDoor(); break; } @@ -530,7 +530,7 @@ AsScene1308KeyboardDoor::AsScene1308KeyboardDoor(NeverhoodEngine *vm, Scene *par uint32 AsScene1308KeyboardDoor::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -562,13 +562,13 @@ AsScene1308LightWallSymbols::AsScene1308LightWallSymbols(NeverhoodEngine *vm, Sc uint32 AsScene1308LightWallSymbols::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2002: + case NM_POSITION_CHANGE: stFadeIn(); break; case 0x2003: stFadeOut(); break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -615,7 +615,7 @@ AsScene1308Mouse::AsScene1308Mouse(NeverhoodEngine *vm) uint32 AsScene1308Mouse::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x66382026) playSound(0, 0x0CD84468); else if (param.asInteger() == 0x6E28061C) @@ -660,10 +660,10 @@ uint32 KmScene1304::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 2) GotoState(&Klaymen::stPickUpNeedle); else if (param.asInteger() == 1) @@ -711,7 +711,7 @@ uint32 KmScene1305::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4804: @@ -750,7 +750,7 @@ KmScene1306::KmScene1306(NeverhoodEngine *vm, Scene *parentScene, int16 x, int16 uint32 KmScene1306::xHandleMessage(int messageNum, const MessageParam ¶m) { uint32 messageResult = 0; switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: _isSittingInTeleporter = param.asInteger() != 0; messageResult = 1; break; @@ -758,13 +758,13 @@ uint32 KmScene1306::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: if (_isSittingInTeleporter) GotoState(&Klaymen::stSitIdleTeleporter); else GotoState(&Klaymen::stTryStandIdle); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 2) GotoState(&Klaymen::stPickUpNeedle); else if (param.asInteger() == 1) @@ -772,7 +772,7 @@ uint32 KmScene1306::xHandleMessage(int messageNum, const MessageParam ¶m) { else GotoState(&Klaymen::stPickUpGeneric); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 1) GotoState(&Klaymen::stPressButton); else if (param.asInteger() == 2) @@ -784,7 +784,7 @@ uint32 KmScene1306::xHandleMessage(int messageNum, const MessageParam ¶m) { setDoDeltaX(param.asInteger()); gotoNextStateExt(); break; - case 0x481A: + case NM_KLAYMEN_INSERT_DISK: GotoState(&Klaymen::stInsertDisk); break; case 0x481B: @@ -793,13 +793,13 @@ uint32 KmScene1306::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stTurnToUseInTeleporter); else GotoState(&Klaymen::stTurnToUse); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stReturnFromUseInTeleporter); else @@ -874,10 +874,10 @@ uint32 KmScene1308::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; - case 0x480A: + case NM_KLAYMEN_MOVE_OBJECT: if (param.asInteger() == 1) GotoState(&Klaymen::stMoveObjectSkipTurnFaceObject); else @@ -886,7 +886,7 @@ uint32 KmScene1308::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x480D: GotoState(&Klaymen::stUseLever); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 2) GotoState(&Klaymen::stPickUpNeedle); else if (param.asInteger() == 1) @@ -898,7 +898,7 @@ uint32 KmScene1308::xHandleMessage(int messageNum, const MessageParam ¶m) { setDoDeltaX(param.asInteger()); gotoNextStateExt(); break; - case 0x481A: + case NM_KLAYMEN_INSERT_DISK: if (param.asInteger() == 1) GotoState(&Klaymen::stInsertKey); else @@ -910,13 +910,13 @@ uint32 KmScene1308::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: GotoState(&Klaymen::stTurnToUse); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: GotoState(&Klaymen::stReturnFromUse); break; - case 0x4827: + case NM_KLAYMEN_RELEASE_LEVER: GotoState(&Klaymen::stReleaseLever); break; case 0x4834: diff --git a/engines/neverhood/modules/module1400.cpp b/engines/neverhood/modules/module1400.cpp index 2fc1052ab1..018f27e2b7 100644 --- a/engines/neverhood/modules/module1400.cpp +++ b/engines/neverhood/modules/module1400.cpp @@ -207,7 +207,7 @@ Scene1401::Scene1401(NeverhoodEngine *vm, Module *parentModule, int which) _klaymen->setClipRect(_sprite3->getDrawRect().x, 0, 640, 480); if (which == 0 && _asProjector) - sendMessage(_asProjector, 0x482B, 0); + sendMessage(_asProjector, NM_MOVE_TO_FRONT, 0); _asBackDoor = insertSprite<AsScene1401BackDoor>(_klaymen, which == 0); @@ -225,7 +225,7 @@ void Scene1401::update() { uint32 Scene1401::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x02144CB1) sendEntityMessage(_klaymen, 0x1014, _ssFloorButton); else if (param.asInteger() == 0x402064D8) @@ -237,7 +237,7 @@ uint32 Scene1401::handleMessage(int messageNum, const MessageParam ¶m, Entit setMessageList(0x004B66B0); } break; - case 0x1019: + case NM_SCENE_LEAVE: if (param.asInteger() != 0) leaveScene(2); else @@ -254,7 +254,7 @@ uint32 Scene1401::handleMessage(int messageNum, const MessageParam ¶m, Entit if (_asProjector && _asProjector->getX() > 404 && _asProjector->getX() < 504) sendMessage(_asProjector , 0x4839, 0); } else if (sender == _ssButton) - sendMessage(_asBackDoor, 0x4808, 0); + sendMessage(_asBackDoor, NM_KLAYMEN_OPEN_DOOR, 0); break; case 0x4826: if (sender == _asProjector) { @@ -265,15 +265,15 @@ uint32 Scene1401::handleMessage(int messageNum, const MessageParam ¶m, Entit setMessageList2(0x004B65F0); } break; - case 0x482A: + case NM_MOVE_TO_BACK: _sprite1->setVisible(true); if (_asProjector) - sendMessage(_asProjector, 0x482B, 0); + sendMessage(_asProjector, NM_MOVE_TO_FRONT, 0); break; - case 0x482B: + case NM_MOVE_TO_FRONT: _sprite1->setVisible(false); if (_asProjector) - sendMessage(_asProjector, 0x482A, 0); + sendMessage(_asProjector, NM_MOVE_TO_BACK, 0); break; } return 0; @@ -375,7 +375,7 @@ void Scene1402::upShaking() { uint32 Scene1402::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x00F43389) { if (getGlobalVar(V_MOUSE_PUZZLE_SOLVED)) leaveScene(0); @@ -383,18 +383,18 @@ uint32 Scene1402::handleMessage(int messageNum, const MessageParam ¶m, Entit clearRectList(); _klaymen->setVisible(false); showMouse(false); - sendMessage(_asPuzzleBox, 0x2002, 0); + sendMessage(_asPuzzleBox, NM_POSITION_CHANGE, 0); startShaking(); } } break; - case 0x1019: + case NM_SCENE_LEAVE: if (param.asInteger()) leaveScene(0); else leaveScene(1); break; - case 0x2000: + case NM_ANIMATION_UPDATE: stopShaking(); showMouse(true); setRectList(0x004B0C48); @@ -455,7 +455,7 @@ void Scene1407::update() { uint32 Scene1407::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (_puzzleSolvedCountdown == 0) { if (param.asPoint().x <= 20 || param.asPoint().x >= 620) { // Exit scene @@ -473,7 +473,7 @@ uint32 Scene1407::handleMessage(int messageNum, const MessageParam ¶m, Entit } } break; - case 0x2000: + case NM_ANIMATION_UPDATE: // The mouse got the cheese (nomnom) setGlobalVar(V_MOUSE_PUZZLE_SOLVED, 1); playSound(0, 0x68E25540); @@ -534,7 +534,7 @@ Scene1403::Scene1403(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene1403::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x88C11390) { setRectList(0x004B2008); _isProjecting = true; @@ -544,10 +544,10 @@ uint32 Scene1403::handleMessage(int messageNum, const MessageParam ¶m, Entit _isProjecting = false; } break; - case 0x1019: + case NM_SCENE_LEAVE: leaveScene(0); break; - case 0x1022: + case NM_PRIORITY_CHANGE: if (sender == _asProjector) { if (param.asInteger() >= 1000) setSurfacePriority(_sprite3->getSurface(), 1100); @@ -555,10 +555,10 @@ uint32 Scene1403::handleMessage(int messageNum, const MessageParam ¶m, Entit setSurfacePriority(_sprite3->getSurface(), 995); } break; - case 0x4807: + case NM_KLAYMEN_RAISE_LEVER: _sprite1->setVisible(false); break; - case 0x480F: + case NM_KLAYMEN_LOWER_LEVER: _sprite1->setVisible(true); break; case 0x4826: @@ -655,7 +655,7 @@ Scene1404::~Scene1404() { uint32 Scene1404::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x410650C2) { if (_asProjector && _asProjector->getX() == 220) setMessageList(0x004B8C40); @@ -663,7 +663,7 @@ uint32 Scene1404::handleMessage(int messageNum, const MessageParam ¶m, Entit setMessageList(0x004B8CE8); } break; - case 0x1019: + case NM_SCENE_LEAVE: leaveScene(0); break; case 0x4826: @@ -725,11 +725,11 @@ void Scene1405::update() { uint32 Scene1405::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) leaveScene(0); break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (_selectFirstTile) { _firstTileIndex = param.asInteger(); _selectFirstTile = false; diff --git a/engines/neverhood/modules/module1400_sprites.cpp b/engines/neverhood/modules/module1400_sprites.cpp index c0ab73c93d..478b328034 100644 --- a/engines/neverhood/modules/module1400_sprites.cpp +++ b/engines/neverhood/modules/module1400_sprites.cpp @@ -59,11 +59,11 @@ void AsScene1401Pipe::upSuckInProjector() { uint32 AsScene1401Pipe::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x0A8A1490) playSound(1, 0x6AB6666F); break; - case 0x2000: + case NM_ANIMATION_UPDATE: _countdown1 = 70; _countdown2 = 8; stStartSucking(); @@ -78,7 +78,7 @@ uint32 AsScene1401Pipe::handleMessage(int messageNum, const MessageParam ¶m, uint32 AsScene1401Pipe::hmSuckInProjector(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: if (_countdown1 != 0) stStartSucking(); else @@ -121,7 +121,7 @@ AsScene1401Mouse::AsScene1401Mouse(NeverhoodEngine *vm) uint32 AsScene1401Mouse::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x66382026) playSound(0, 0x0CD84468); else if (param.asInteger() == 0x6E28061C) @@ -222,10 +222,10 @@ uint32 AsScene1401BackDoor::handleMessage(int messageNum, const MessageParam &pa _countdown = 168; messageResult = _isOpen ? 1 : 0; break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: _countdown = 168; if (!_isOpen) stOpenDoor(); @@ -292,7 +292,7 @@ uint32 AsCommonProjector::handleMessage(int messageNum, const MessageParam ¶ sendMessage(_parentScene, 0x4826, 0); messageResult = 1; break; - case 0x4807: + case NM_KLAYMEN_RAISE_LEVER: setGlobalVar(V_PROJECTOR_SLOT, (_x - _asProjectorItem->point.x) / 108); if ((int8)getGlobalVar(V_PROJECTOR_SLOT) == _asProjectorItem->lockSlotIndex) stStartLockedInSlot(); @@ -314,11 +314,11 @@ uint32 AsCommonProjector::handleMessage(int messageNum, const MessageParam ¶ else messageResult = getGlobalVar(V_PROJECTOR_SLOT) > 0 ? 1 : 0; break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; case 0x4839: stStartSuckedIn(); @@ -338,8 +338,8 @@ uint32 AsCommonProjector::hmLockedInSlot(int messageNum, const MessageParam &par sendMessage(_parentScene, 0x4826, 0); messageResult = 1; break; - case 0x4807: - sendMessage(_parentScene, 0x4807, 0); + case NM_KLAYMEN_RAISE_LEVER: + sendMessage(_parentScene, NM_KLAYMEN_RAISE_LEVER, 0); stStopProjecting(); break; case 0x480B: @@ -357,14 +357,14 @@ uint32 AsCommonProjector::hmLockedInSlot(int messageNum, const MessageParam &par else messageResult = getGlobalVar(V_PROJECTOR_SLOT) > 0 ? 1 : 0; break; - case 0x480F: + case NM_KLAYMEN_LOWER_LEVER: stStartProjecting(); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -373,7 +373,7 @@ uint32 AsCommonProjector::hmLockedInSlot(int messageNum, const MessageParam &par uint32 AsCommonProjector::hmAnimation(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -388,11 +388,11 @@ void AsCommonProjector::suMoving() { moveProjector(); if (_beforeMoveX == _x) { if (getGlobalVar(V_PROJECTOR_SLOT) == 0 && _asProjectorItem->leftBorderLeaves != 0) { - sendMessage(_parentScene, 0x1019, 0); + sendMessage(_parentScene, NM_SCENE_LEAVE, 0); incGlobalVar(V_PROJECTOR_LOCATION, -1); setGlobalVar(V_PROJECTOR_SLOT, kAsCommonProjectorItems[getGlobalVar(V_PROJECTOR_LOCATION)].maxSlotCount); } else if ((int8)getGlobalVar(V_PROJECTOR_SLOT) == _asProjectorItem->maxSlotCount && _asProjectorItem->rightBorderLeaves != 0) { - sendMessage(_parentScene, 0x1019, 1); + sendMessage(_parentScene, NM_SCENE_LEAVE, 1); incGlobalVar(V_PROJECTOR_LOCATION, +1); setGlobalVar(V_PROJECTOR_SLOT, 0); } @@ -481,7 +481,7 @@ void AsCommonProjector::stStartProjecting() { } void AsCommonProjector::stLockedInSlot() { - sendMessage(_parentScene, 0x480F, 0); + sendMessage(_parentScene, NM_KLAYMEN_LOWER_LEVER, 0); startAnimation(0xD833207F, 0, -1); SetMessageHandler(&AsCommonProjector::hmLockedInSlot); SetSpriteUpdate(NULL); @@ -553,13 +553,13 @@ AsScene1402PuzzleBox::AsScene1402PuzzleBox(NeverhoodEngine *vm, Scene *parentSce uint32 AsScene1402PuzzleBox::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2002: + case NM_POSITION_CHANGE: playSound(1); startAnimation(0x20060259, -1, -1); _playBackwards = true; NextState(&AsScene1402PuzzleBox::stMoveDownDone); break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -691,7 +691,7 @@ void AsScene1407Mouse::suWalkTo() { xdelta = -_deltaX; _deltaX = 0; if (_walkDestX == _x) - sendMessage(this, 0x1019, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); else { _x += xdelta; updateBounds(); @@ -709,7 +709,7 @@ void AsScene1407Mouse::upGoThroughHole() { uint32 AsScene1407Mouse::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: { int16 mouseX = param.asPoint().x; int16 mouseY = param.asPoint().y; @@ -735,7 +735,7 @@ uint32 AsScene1407Mouse::handleMessage(int messageNum, const MessageParam ¶m } } break; - case 0x1019: + case NM_SCENE_LEAVE: gotoNextState(); break; case 0x2001: @@ -893,16 +893,16 @@ uint32 KmScene1401::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; - case 0x480A: + case NM_KLAYMEN_MOVE_OBJECT: if (param.asInteger() == 1) GotoState(&Klaymen::stMoveObjectSkipTurnFaceObject); else GotoState(&Klaymen::stMoveObjectFaceObject); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 1) GotoState(&Klaymen::stPressButton); else if (param.asInteger() == 2) @@ -960,10 +960,10 @@ uint32 KmScene1402::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; - case 0x480A: + case NM_KLAYMEN_MOVE_OBJECT: if (param.asInteger() == 1) GotoState(&Klaymen::stMoveObjectSkipTurnFaceObject); else @@ -979,10 +979,10 @@ uint32 KmScene1402::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: GotoState(&Klaymen::stTurnToUse); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: GotoState(&Klaymen::stReturnFromUse); break; } @@ -1007,10 +1007,10 @@ uint32 KmScene1403::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; - case 0x480A: + case NM_KLAYMEN_MOVE_OBJECT: if (param.asInteger() == 1) GotoState(&Klaymen::stMoveObjectSkipTurnFaceObject); else @@ -1019,7 +1019,7 @@ uint32 KmScene1403::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x480D: GotoState(&Klaymen::stUseLever); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 2) GotoState(&Klaymen::stPickUpNeedle); else if (param.asInteger() == 1) @@ -1037,7 +1037,7 @@ uint32 KmScene1403::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x4827: + case NM_KLAYMEN_RELEASE_LEVER: GotoState(&Klaymen::stReleaseLever); break; case 0x483F: @@ -1064,16 +1064,16 @@ uint32 KmScene1404::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; - case 0x480A: + case NM_KLAYMEN_MOVE_OBJECT: if (param.asInteger() == 1) GotoState(&Klaymen::stMoveObjectSkipTurnFaceObject); else GotoState(&Klaymen::stMoveObjectFaceObject); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 2) GotoState(&Klaymen::stPickUpNeedle); else if (param.asInteger() == 1) @@ -1085,7 +1085,7 @@ uint32 KmScene1404::xHandleMessage(int messageNum, const MessageParam ¶m) { setDoDeltaX(param.asInteger()); gotoNextStateExt(); break; - case 0x481A: + case NM_KLAYMEN_INSERT_DISK: GotoState(&Klaymen::stInsertDisk); break; case 0x481B: @@ -1094,10 +1094,10 @@ uint32 KmScene1404::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: GotoState(&Klaymen::stTurnToUse); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: GotoState(&Klaymen::stReturnFromUse); break; case 0x481F: diff --git a/engines/neverhood/modules/module1500.cpp b/engines/neverhood/modules/module1500.cpp index 3ce9783b69..eaa23e586b 100644 --- a/engines/neverhood/modules/module1500.cpp +++ b/engines/neverhood/modules/module1500.cpp @@ -102,11 +102,11 @@ void Scene1501::update() { Scene::update(); if (_countdown1 != 0) { _countdown1--; - if (_countdown1 == 0) { + if (_countdown1 == 0 || _skip) { _vm->_screen->clear(); leaveScene(0); } - } else if ((_countdown2 != 0 && (--_countdown2 == 0)) || (_countdown2 == 0 && !isSoundPlaying(0))) { + } else if ((_countdown2 != 0 && (--_countdown2 == 0)) || (_countdown2 == 0 && !isSoundPlaying(0)) || _skip) { _countdown1 = 12; _palette->startFadeToBlack(11); } @@ -124,7 +124,7 @@ void Scene1501::update() { uint32 Scene1501::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0009: + case NM_KEYPRESS_SPACE: _skip = true; break; } diff --git a/engines/neverhood/modules/module1600.cpp b/engines/neverhood/modules/module1600.cpp index 0df7dd8925..d66d5c1b8e 100644 --- a/engines/neverhood/modules/module1600.cpp +++ b/engines/neverhood/modules/module1600.cpp @@ -258,7 +258,7 @@ Scene1608::Scene1608(NeverhoodEngine *vm, Module *parentModule, int which) SetMessageHandler(&Scene1608::hmUpperFloor); SetUpdateHandler(&Scene1608::upUpperFloor); _asCar->setPathPoints(_roomPathPoints); - sendMessage(_asCar, 0x2002, _roomPathPoints->size() - 1); + sendMessage(_asCar, NM_POSITION_CHANGE, _roomPathPoints->size() - 1); _sprite3 = insertStaticSprite(0xB47026B0, 1100); _clipRect1.set(_sprite3->getDrawRect().x, _sprite3->getDrawRect().y, 640, _sprite2->getDrawRect().y2()); _clipRect3.set(_sprite2->getDrawRect().x, _sprite3->getDrawRect().y, 640, _sprite2->getDrawRect().y2()); @@ -299,8 +299,8 @@ Scene1608::Scene1608(NeverhoodEngine *vm, Module *parentModule, int which) _asIdleCarLower->setVisible(false); _asIdleCarFull->setVisible(false); _asCar->setPathPoints(_roomPathPoints); - sendMessage(_asCar, 0x2002, 0); - sendMessage(_asCar, 0x2008, 90); + sendMessage(_asCar, NM_POSITION_CHANGE, 0); + sendMessage(_asCar, NM_CAR_MOVE_TO_NEXT_POINT, 90); _sprite3 = insertStaticSprite(0xB47026B0, 1100); _clipRect1.set(_sprite3->getDrawRect().x, _sprite3->getDrawRect().y, 640, _sprite2->getDrawRect().y2()); _clipRect3.set(_sprite2->getDrawRect().x, _sprite3->getDrawRect().y, 640, _sprite2->getDrawRect().y2()); @@ -349,7 +349,7 @@ void Scene1608::upUpperFloor() { _asIdleCarLower->setVisible(false); _asIdleCarFull->setVisible(false); _asCar->setVisible(true); - sendMessage(_asCar, 0x2009, 0); + sendMessage(_asCar, NM_CAR_ENTER, 0); _asCar->handleUpdate(); _klaymen = NULL; _carStatus = 0; @@ -361,7 +361,7 @@ void Scene1608::upCarAtHome() { Scene::update(); if (_mouseClicked) { if (_mouseClickPos.x <= 329 && _asCar->getX() == 375 && _asCar->getY() == 227) { - sendMessage(_asCar, 0x200A, 0); + sendMessage(_asCar, NM_CAR_LEAVE, 0); SetUpdateHandler(&Scene1608::upGettingOutOfCar); } else { sendPointMessage(_asCar, 0x2004, _mouseClickPos); @@ -406,7 +406,7 @@ void Scene1608::upRidingCar() { _carClipFlag = false; _asCar->setClipRect(_clipRect1); if (!_asCar->isDoDeltaX()) - sendMessage(_asCar, 0x200E, 0); + sendMessage(_asCar, NM_CAR_TURN, 0); } } else if (!_carClipFlag) { _carClipFlag = true; @@ -417,13 +417,13 @@ void Scene1608::upRidingCar() { uint32 Scene1608::hmLowerFloor(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x20250B1A) { clearRectList(); _klaymen->setVisible(false); showMouse(false); _sprite1->setVisible(false); - //sendMessage(_asDoor, 0x4809, 0); // Play sound? + //sendMessage(_asDoor, NM_KLAYMEN_CLOSE_DOOR, 0); // Play sound? _countdown1 = 28; } break; @@ -444,7 +444,7 @@ uint32 Scene1608::hmLowerFloor(int messageNum, const MessageParam ¶m, Entity uint32 Scene1608::hmUpperFloor(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x60842040) _carStatus = 1; break; @@ -464,13 +464,13 @@ uint32 Scene1608::hmUpperFloor(int messageNum, const MessageParam ¶m, Entity uint32 Scene1608::hmRidingCar(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2005: + case NM_KLAYMEN_CLIMB_LADDER: leaveScene(1); break; - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: SetMessageHandler(&Scene1608::hmCarAtHome); SetUpdateHandler(&Scene1608::upCarAtHome); - sendMessage(_asCar, 0x200F, 1); + sendMessage(_asCar, NM_CAR_AT_HOME, 1); break; case 0x200D: sendMessage(_parentModule, 0x200D, 0); @@ -482,7 +482,7 @@ uint32 Scene1608::hmRidingCar(int messageNum, const MessageParam ¶m, Entity uint32 Scene1608::hmCarAtHome(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x200A: + case NM_CAR_LEAVE: _carStatus = 2; break; case 0x200D: @@ -544,11 +544,11 @@ void Scene1609::update() { uint32 Scene1609::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) leaveScene(0); break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (!_isSolved) { if (_changeCurrentSymbol) _asSymbols[_symbolPosition]->change(_currentSymbolIndex + 12, false); diff --git a/engines/neverhood/modules/module1600_sprites.cpp b/engines/neverhood/modules/module1600_sprites.cpp index 06a00c82c0..b7b3658c5e 100644 --- a/engines/neverhood/modules/module1600_sprites.cpp +++ b/engines/neverhood/modules/module1600_sprites.cpp @@ -94,10 +94,10 @@ void AsCommonCar::upIdle() { uint32 AsCommonCar::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x1019: + case NM_SCENE_LEAVE: SetSpriteUpdate(NULL); break; - case 0x2002: + case NM_POSITION_CHANGE: // Set the current position without moving _currPointIndex = param.asInteger(); _stepError = 0; @@ -116,10 +116,10 @@ uint32 AsCommonCar::handleMessage(int messageNum, const MessageParam ¶m, Ent } else if (_currPointIndex == newPointIndex && _stepError == 0) { if (_currPointIndex == 0) { _yMoveTotalSteps = 0; - sendMessage(_parentScene, 0x2005, 0); + sendMessage(_parentScene, NM_KLAYMEN_CLIMB_LADDER, 0); } else if (_currPointIndex == (int)_pathPoints->size()) { _yMoveTotalSteps = 0; - sendMessage(_parentScene, 0x2006, 0); + sendMessage(_parentScene, NM_KLAYMEN_STOP_CLIMBING, 0); } } else { moveToPrevPoint(); @@ -177,30 +177,30 @@ uint32 AsCommonCar::handleMessage(int messageNum, const MessageParam ¶m, Ent } } break; - case 0x2007: + case NM_CAR_MOVE_TO_PREV_POINT: _yMoveTotalSteps = param.asInteger(); _steps = 0; _isBraking = false; _lastDistance = 640; SetSpriteUpdate(&AsCommonCar::suMoveToPrevPoint); break; - case 0x2008: + case NM_CAR_MOVE_TO_NEXT_POINT: _yMoveTotalSteps = param.asInteger(); _steps = 0; _isBraking = false; _lastDistance = 640; SetSpriteUpdate(&AsCommonCar::suMoveToNextPoint); break; - case 0x2009: + case NM_CAR_ENTER: stEnterCar(); break; - case 0x200A: + case NM_CAR_LEAVE: stLeaveCar(); break; - case 0x200E: + case NM_CAR_TURN: stTurnCar(); break; - case 0x200F: + case NM_CAR_AT_HOME: stCarAtHome(); _newDeltaXType = param.asInteger(); break; @@ -211,11 +211,11 @@ uint32 AsCommonCar::handleMessage(int messageNum, const MessageParam ¶m, Ent uint32 AsCommonCar::hmAnimation(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = AsCommonCar::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (_isBusy && param.asInteger() == 0x025424A2) gotoNextState(); break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -224,11 +224,11 @@ uint32 AsCommonCar::hmAnimation(int messageNum, const MessageParam ¶m, Entit uint32 AsCommonCar::hmLeaveCar(int messageNum, const MessageParam ¶m, Entity *sender) { switch (messageNum) { - case 0x2009: + case NM_CAR_ENTER: stEnterCar(); break; - case 0x3002: - sendMessage(_parentScene, 0x200A, 0); + case NM_ANIMATION_STOP: + sendMessage(_parentScene, NM_CAR_LEAVE, 0); SetMessageHandler(&AsCommonCar::handleMessage); break; } @@ -350,8 +350,8 @@ void AsCommonCar::stUpdateMoveDirection() { void AsCommonCar::moveToNextPoint() { if (_currPointIndex >= (int)_pathPoints->size() - 1) { _yMoveTotalSteps = 0; - sendMessage(this, 0x1019, 0); - sendMessage(_parentScene, 0x2006, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); + sendMessage(_parentScene, NM_KLAYMEN_STOP_CLIMBING, 0); } else { NPoint nextPt = pathPoint(_currPointIndex + 1); NPoint currPt = pathPoint(_currPointIndex); @@ -431,8 +431,8 @@ void AsCommonCar::stTurnCarMoveToPrevPoint() { void AsCommonCar::moveToPrevPoint() { if (_currPointIndex == 0 && _stepError == 0) { _yMoveTotalSteps = 0; - sendMessage(this, 0x1019, 0); - sendMessage(_parentScene, 0x2005, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); + sendMessage(_parentScene, NM_KLAYMEN_CLIMB_LADDER, 0); } else { NPoint prevPt; NPoint currPt; @@ -492,14 +492,14 @@ void AsCommonCar::suMoveToNextPoint() { if (_currPointIndex >= (int)_pathPoints->size()) { _yMoveTotalSteps = 0; - sendMessage(this, 0x1019, 0); - sendMessage(_parentScene, 0x2006, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); + sendMessage(_parentScene, NM_KLAYMEN_STOP_CLIMBING, 0); return; } if (_isBraking) { if (_steps <= 0) { - sendMessage(this, 0x1019, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); return; } else _steps--; @@ -623,8 +623,8 @@ void AsCommonCar::suMoveToNextPoint() { if (_currPointIndex == (int)_pathPoints->size() - 1) { _isBraking = true; _yMoveTotalSteps = 0; - sendMessage(this, 0x1019, 0); - sendMessage(_parentScene, 0x2006, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); + sendMessage(_parentScene, NM_KLAYMEN_STOP_CLIMBING, 0); } } @@ -635,14 +635,14 @@ void AsCommonCar::suMoveToPrevPoint() { if (_currPointIndex == 0 && _stepError == 0) { _yMoveTotalSteps = 0; - sendMessage(this, 0x1019, 0); - sendMessage(_parentScene, 0x2005, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); + sendMessage(_parentScene, NM_KLAYMEN_CLIMB_LADDER, 0); return; } if (_isBraking) { if (_steps <= 0) { - sendMessage(this, 0x1019, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); return; } else _steps--; @@ -768,8 +768,8 @@ void AsCommonCar::suMoveToPrevPoint() { if (_currPointIndex == 0 && _stepError == 0) { _isBraking = true; _yMoveTotalSteps = 0; - sendMessage(this, 0x1019, 0); - sendMessage(_parentScene, 0x2005, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); + sendMessage(_parentScene, NM_KLAYMEN_CLIMB_LADDER, 0); } } @@ -860,13 +860,13 @@ uint32 KmScene1608::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: if (_isSittingInTeleporter) GotoState(&Klaymen::stSitIdleTeleporter); else GotoState(&Klaymen::stTryStandIdle); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 2) GotoState(&Klaymen::stPickUpNeedle); else if (param.asInteger() == 1) @@ -884,11 +884,11 @@ uint32 KmScene1608::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stTurnToUseInTeleporter); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stReturnFromUseInTeleporter); break; diff --git a/engines/neverhood/modules/module1700.cpp b/engines/neverhood/modules/module1700.cpp index e3a5fc3663..1062691cd2 100644 --- a/engines/neverhood/modules/module1700.cpp +++ b/engines/neverhood/modules/module1700.cpp @@ -215,7 +215,7 @@ void Scene1705::update() { uint32 Scene1705::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: if (param.asInteger()) { setRectList(0x004B6B40); _klaymen->setKlaymenIdleTable3(); diff --git a/engines/neverhood/modules/module1700_sprites.cpp b/engines/neverhood/modules/module1700_sprites.cpp index 6274e5a8cc..d6e00c95f3 100644 --- a/engines/neverhood/modules/module1700_sprites.cpp +++ b/engines/neverhood/modules/module1700_sprites.cpp @@ -56,7 +56,7 @@ uint32 SsScene1705Tape::handleMessage(int messageNum, const MessageParam ¶m, sendMessage(_parentScene, 0x4826, 0); messageResult = 1; break; - case 0x4806: + case NM_KLAYMEN_USE_OBJECT: setSubVar(VA_HAS_TAPE, _tapeIndex, 1); setVisible(false); SetMessageHandler(NULL); @@ -74,7 +74,7 @@ KmScene1705::KmScene1705(NeverhoodEngine *vm, Scene *parentScene, int16 x, int16 uint32 KmScene1705::xHandleMessage(int messageNum, const MessageParam ¶m) { uint32 messageResult = 0; switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: _isSittingInTeleporter = param.asInteger() != 0; messageResult = 1; break; @@ -82,7 +82,7 @@ uint32 KmScene1705::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: if (_isSittingInTeleporter) GotoState(&Klaymen::stSitIdleTeleporter); else @@ -91,7 +91,7 @@ uint32 KmScene1705::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4803: GotoState(&Klaymen::stFallSkipJump); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 2) GotoState(&Klaymen::stPickUpNeedle); else if (param.asInteger() == 1) @@ -109,12 +109,12 @@ uint32 KmScene1705::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: if (_isSittingInTeleporter) { GotoState(&Klaymen::stTurnToUseInTeleporter); } break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stReturnFromUseInTeleporter); break; diff --git a/engines/neverhood/modules/module1900.cpp b/engines/neverhood/modules/module1900.cpp index a920893755..5fdc6091dc 100644 --- a/engines/neverhood/modules/module1900.cpp +++ b/engines/neverhood/modules/module1900.cpp @@ -198,13 +198,13 @@ void Scene1907::update() { uint32 Scene1907::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if ((param.asPoint().x <= 20 || param.asPoint().x >= 620) && !_hasPlugInFailed && _moveDownCountdown == 0 && _moveUpCountdown == 0 && _countdown3 == 0) { leaveScene(0); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (getGlobalVar(V_STAIRS_DOWN)) { playSound(0); for (int i = 0; i < 9; i++) diff --git a/engines/neverhood/modules/module1900_sprites.cpp b/engines/neverhood/modules/module1900_sprites.cpp index 09c0b132d5..9e43203def 100644 --- a/engines/neverhood/modules/module1900_sprites.cpp +++ b/engines/neverhood/modules/module1900_sprites.cpp @@ -122,7 +122,7 @@ uint32 AsScene1907Symbol::handleMessage(int messageNum, const MessageParam ¶ uint32 AsScene1907Symbol::hmTryToPlugIn(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -216,7 +216,7 @@ void AsScene1907Symbol::tryToPlugIn() { _plugInTryCount++; _newPositionIndex = _parentScene->getNextPosition(); _parentScene->setPositionFree(_currPositionIndex, true); - sendMessage(_parentScene, 0x1022, 1100 + _newPositionIndex); + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1100 + _newPositionIndex); startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], 0, -1); SetUpdateHandler(&AsScene1907Symbol::update); SetMessageHandler(&AsScene1907Symbol::hmTryToPlugIn); @@ -255,7 +255,7 @@ void AsScene1907Symbol::fallOff(int newPositionIndex, int fallOffDelay) { void AsScene1907Symbol::stFallOffHitGround() { playSound(1); - sendMessage(_parentScene, 0x1022, 1000 + _newPositionIndex); + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1000 + _newPositionIndex); Entity::_priority = 1000 - _newPositionIndex; _parentScene->removeCollisionSprite(this); _parentScene->addCollisionSprite(this); @@ -394,7 +394,7 @@ void AsScene1907WaterHint::update() { uint32 AsScene1907WaterHint::hmShowing(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -426,17 +426,17 @@ uint32 KmScene1901::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4817: setDoDeltaX(param.asInteger()); gotoNextStateExt(); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: GotoState(&Klaymen::stTurnToUse); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: GotoState(&Klaymen::stReturnFromUse); break; case 0x482D: diff --git a/engines/neverhood/modules/module2000.cpp b/engines/neverhood/modules/module2000.cpp index 3364f60f8b..ad18e65cdd 100644 --- a/engines/neverhood/modules/module2000.cpp +++ b/engines/neverhood/modules/module2000.cpp @@ -144,7 +144,7 @@ Scene2001::Scene2001(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene2001::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: if (param.asInteger()) { setRectList(0x004B3680); _klaymen->setKlaymenIdleTable3(); diff --git a/engines/neverhood/modules/module2000_sprites.cpp b/engines/neverhood/modules/module2000_sprites.cpp index c9c1481aa7..35edd8e73f 100644 --- a/engines/neverhood/modules/module2000_sprites.cpp +++ b/engines/neverhood/modules/module2000_sprites.cpp @@ -33,7 +33,7 @@ KmScene2001::KmScene2001(NeverhoodEngine *vm, Scene *parentScene, int16 x, int16 uint32 KmScene2001::xHandleMessage(int messageNum, const MessageParam ¶m) { uint32 messageResult = 0; switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: _isSittingInTeleporter = param.asInteger() != 0; messageResult = 1; break; @@ -41,7 +41,7 @@ uint32 KmScene2001::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: if (_isSittingInTeleporter) GotoState(&Klaymen::stSitIdleTeleporter); else @@ -58,11 +58,11 @@ uint32 KmScene2001::xHandleMessage(int messageNum, const MessageParam ¶m) { setDoDeltaX(param.asInteger()); gotoNextStateExt(); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stTurnToUseInTeleporter); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stReturnFromUseInTeleporter); break; diff --git a/engines/neverhood/modules/module2100.cpp b/engines/neverhood/modules/module2100.cpp index db7258b066..e95eb58420 100644 --- a/engines/neverhood/modules/module2100.cpp +++ b/engines/neverhood/modules/module2100.cpp @@ -147,7 +147,7 @@ void Scene2101::update() { if (_countdown1 != 0) { if (_doorStatus == 2) { if (--_countdown1 == 0) { - sendMessage(_asDoor, 0x4809, 0); + sendMessage(_asDoor, NM_KLAYMEN_CLOSE_DOOR, 0); _doorStatus = 1; } } else { @@ -155,12 +155,12 @@ void Scene2101::update() { _canAcceptInput = false; if (--_countdown1 == 0) { if (_klaymen->getX() < 480) { - sendMessage(_asDoor, 0x4809, 0); + sendMessage(_asDoor, NM_KLAYMEN_CLOSE_DOOR, 0); _doorStatus = 1; } else if (_klaymen->getX() >= 480 && _klaymen->getX() <= 575) { _klaymen->setDoDeltaX(0); setMessageList2(0x004B8F48); - sendMessage(_asDoor, 0x4809, 0); + sendMessage(_asDoor, NM_KLAYMEN_CLOSE_DOOR, 0); sendMessage(_asHitByDoorEffect, 0x2001, 0); _doorStatus = 1; } @@ -174,7 +174,7 @@ void Scene2101::update() { uint32 Scene2101::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x02144CB1) sendEntityMessage(_klaymen, 0x1014, _ssFloorButton); else if (param.asInteger() == 0x21E64A00) { @@ -185,7 +185,7 @@ uint32 Scene2101::handleMessage(int messageNum, const MessageParam ¶m, Entit } else if (param.asInteger() == 0x41442820) cancelMessageList(); break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (param.asInteger() != 0) { setRectList(0x004B9008); _klaymen->setKlaymenIdleTable3(); @@ -196,7 +196,7 @@ uint32 Scene2101::handleMessage(int messageNum, const MessageParam ¶m, Entit break; case 0x480B: if (sender == _ssFloorButton && _doorStatus == 1) { - sendMessage(_asDoor, 0x4808, 0); + sendMessage(_asDoor, NM_KLAYMEN_OPEN_DOOR, 0); _doorStatus = 0; _countdown1 = 90; } diff --git a/engines/neverhood/modules/module2100_sprites.cpp b/engines/neverhood/modules/module2100_sprites.cpp index 707ebe342f..f43c0afed5 100644 --- a/engines/neverhood/modules/module2100_sprites.cpp +++ b/engines/neverhood/modules/module2100_sprites.cpp @@ -42,13 +42,13 @@ AsScene2101Door::AsScene2101Door(NeverhoodEngine *vm, bool isOpen) uint32 AsScene2101Door::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: stOpenDoor(); break; - case 0x4809: + case NM_KLAYMEN_CLOSE_DOOR: stCloseDoor(); break; } @@ -93,7 +93,7 @@ uint32 AsScene2101HitByDoorEffect::handleMessage(int messageNum, const MessagePa startAnimation(0x0422255A, 0, -1); setVisible(true); break; - case 0x3002: + case NM_ANIMATION_STOP: stopAnimation(); setVisible(false); break; @@ -118,7 +118,7 @@ SsCommonFloorButton::SsCommonFloorButton(NeverhoodEngine *vm, Scene *parentScene void SsCommonFloorButton::update() { if (_countdown != 0 && (--_countdown == 0)) { - sendMessage(_parentScene, 0x1022, 1010); + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); if (_fileHash1) loadSprite(_fileHash1, kSLFDefDrawOffset | kSLFDefPosition); else @@ -132,7 +132,7 @@ uint32 SsCommonFloorButton::handleMessage(int messageNum, const MessageParam &pa case 0x480B: sendMessage(_parentScene, 0x480B, 0); setVisible(true); - sendMessage(_parentScene, 0x1022, 990); + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); loadSprite(_fileHash2, kSLFDefDrawOffset | kSLFDefPosition); _countdown = 16; playSound(0, _soundFileHash); @@ -150,7 +150,7 @@ KmScene2101::KmScene2101(NeverhoodEngine *vm, Scene *parentScene, int16 x, int16 uint32 KmScene2101::xHandleMessage(int messageNum, const MessageParam ¶m) { uint32 messageResult = 0; switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: _isSittingInTeleporter = param.asInteger() != 0; messageResult = 1; break; @@ -158,7 +158,7 @@ uint32 KmScene2101::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: if (_isSittingInTeleporter) GotoState(&Klaymen::stSitIdleTeleporter); else @@ -167,7 +167,7 @@ uint32 KmScene2101::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4811: GotoState(&KmScene2101::stHitByDoor); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 2) GotoState(&Klaymen::stPickUpNeedle); else if (param.asInteger() == 1) @@ -175,7 +175,7 @@ uint32 KmScene2101::xHandleMessage(int messageNum, const MessageParam ¶m) { else GotoState(&Klaymen::stPickUpGeneric); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 1) GotoState(&Klaymen::stPressButton); else if (param.asInteger() == 2) @@ -193,11 +193,11 @@ uint32 KmScene2101::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stTurnToUseInTeleporter); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stReturnFromUseInTeleporter); break; @@ -236,7 +236,7 @@ uint32 KmScene2101::hmHitByDoor(int messageNum, const MessageParam ¶m, Entit } messageResult = 0; break; - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x1A1A0785) { playSound(0, 0x40F0A342); } else if (param.asInteger() == 0x60428026) { diff --git a/engines/neverhood/modules/module2200.cpp b/engines/neverhood/modules/module2200.cpp index eecddf904c..f1d5d2854d 100644 --- a/engines/neverhood/modules/module2200.cpp +++ b/engines/neverhood/modules/module2200.cpp @@ -551,7 +551,7 @@ void Scene2201::update() { uint32 Scene2201::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x402064D8) sendEntityMessage(_klaymen, 0x1014, _ssDoorButton); else if (param.asInteger() == 0x35803198) { @@ -575,7 +575,7 @@ uint32 Scene2201::handleMessage(int messageNum, const MessageParam ¶m, Entit break; case 0x480B: if (sender == _ssDoorButton) - sendMessage(_asDoor, 0x4808, 0); + sendMessage(_asDoor, NM_KLAYMEN_OPEN_DOOR, 0); break; case 0x4826: if (sender == _asTape) { @@ -662,15 +662,15 @@ void Scene2202::update() { uint32 Scene2202::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) leaveScene(0); break; - case 0x2000: + case NM_ANIMATION_UPDATE: _movingCubePosition = (int16)param.asInteger(); _ssMovingCube = (Sprite*)sender; break; - case 0x2002: + case NM_POSITION_CHANGE: _isCubeMoving = false; _ssDoneMovingCube = (Sprite*)sender; if (param.asInteger() <= 2) @@ -786,7 +786,7 @@ uint32 Scene2203::handleMessage(int messageNum, const MessageParam ¶m, Entit else setMessageList2(0x004B83C8); break; - case 0x2002: + case NM_POSITION_CHANGE: if (sender == _asLeftDoor) setMessageList2(0x004B8370); else @@ -798,7 +798,7 @@ uint32 Scene2203::handleMessage(int messageNum, const MessageParam ¶m, Entit else _ssSmallRightDoor->setVisible(false); break; - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: if (sender == _asLeftDoor) { _ssSmallLeftDoor->setVisible(true); _klaymen->setClipRect(_leftDoorClipRect); @@ -911,7 +911,7 @@ void Scene2205::update() { uint32 Scene2205::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x6449569A) setMessageList(0x004B0690); else if (param.asInteger() == 0x2841369C) @@ -1012,7 +1012,7 @@ Scene2206::~Scene2206() { uint32 Scene2206::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x800C6694) readClickedColumn(); else if (param.asInteger() == 0x402064D8) @@ -1031,19 +1031,19 @@ uint32 Scene2206::handleMessage(int messageNum, const MessageParam ¶m, Entit if (sender == _ssButton) { setGlobalVar(V_SPIKES_RETRACTED, getGlobalVar(V_SPIKES_RETRACTED) ? 0 : 1); if (getGlobalVar(V_SPIKES_RETRACTED)) - sendMessage(_asDoorSpikes, 0x4808, 0); + sendMessage(_asDoorSpikes, NM_KLAYMEN_OPEN_DOOR, 0); else - sendMessage(_asDoorSpikes, 0x4809, 0); + sendMessage(_asDoorSpikes, NM_KLAYMEN_CLOSE_DOOR, 0); } break; case 0x4826: sendEntityMessage(_klaymen, 0x1014, _ssTestTube); setMessageList(0x004B8988); break; - case 0x482A: + case NM_MOVE_TO_BACK: klaymenBehindSpikes(); break; - case 0x482B: + case NM_MOVE_TO_FRONT: klaymenInFrontSpikes(); break; } @@ -1179,7 +1179,7 @@ void Scene2207::update() { uint32 Scene2207::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x0014F275) { if (_klaymenAtElevator) { sendMessage(_asElevator, 0x2000, _mouseClickPos.y); @@ -1215,15 +1215,15 @@ uint32 Scene2207::handleMessage(int messageNum, const MessageParam ¶m, Entit setMessageList(0x004B37D8); } break; - case 0x2002: + case NM_POSITION_CHANGE: _elevatorSurfacePriority = param.asInteger(); break; case 0x2003: _isKlaymenBusy = false; break; - case 0x4807: - sendMessage(_asWallRobotAnimation, 0x2007, 0); - sendMessage(_asWallCannonAnimation, 0x2007, 0); + case NM_KLAYMEN_RAISE_LEVER: + sendMessage(_asWallRobotAnimation, NM_CAR_MOVE_TO_PREV_POINT, 0); + sendMessage(_asWallCannonAnimation, NM_CAR_MOVE_TO_PREV_POINT, 0); break; case 0x480B: if (sender == _ssButton) { @@ -1236,9 +1236,9 @@ uint32 Scene2207::handleMessage(int messageNum, const MessageParam ¶m, Entit } } break; - case 0x480F: - sendMessage(_asWallRobotAnimation, 0x2006, 0); - sendMessage(_asWallCannonAnimation, 0x2006, 0); + case NM_KLAYMEN_LOWER_LEVER: + sendMessage(_asWallRobotAnimation, NM_KLAYMEN_STOP_CLIMBING, 0); + sendMessage(_asWallCannonAnimation, NM_KLAYMEN_STOP_CLIMBING, 0); _asWallRobotAnimation->setVisible(true); _asWallCannonAnimation->setVisible(true); break; @@ -1262,12 +1262,12 @@ uint32 Scene2207::handleMessage(int messageNum, const MessageParam ¶m, Entit uint32 Scene2207::handleMessage2(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2002: + case NM_POSITION_CHANGE: _elevatorSurfacePriority = param.asInteger(); break; case 0x2004: SetMessageHandler(&Scene2207::handleMessage); - sendMessage(_klaymen, 0x2005, 0); + sendMessage(_klaymen, NM_KLAYMEN_CLIMB_LADDER, 0); sendEntityMessage(_klaymen, 0x1014, _asLever); setMessageList(0x004B3920); setRectList(0x004B3948); @@ -1400,7 +1400,7 @@ void Scene2208::update() { uint32 Scene2208::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 40 || param.asPoint().x >= 600) leaveScene(0); break; @@ -1519,7 +1519,7 @@ void Scene2242::update() { uint32 Scene2242::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x800C6694) readClickedColumn(); break; @@ -1620,7 +1620,7 @@ HallOfRecordsScene::~HallOfRecordsScene() { uint32 HallOfRecordsScene::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x800C6694) readClickedColumn(); break; @@ -1708,7 +1708,7 @@ Scene2247::~Scene2247() { uint32 Scene2247::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x800C6694) readClickedColumn(); break; diff --git a/engines/neverhood/modules/module2200_sprites.cpp b/engines/neverhood/modules/module2200_sprites.cpp index 30f0404cf1..ddf31f7920 100644 --- a/engines/neverhood/modules/module2200_sprites.cpp +++ b/engines/neverhood/modules/module2200_sprites.cpp @@ -62,7 +62,7 @@ void AsScene2201Door::update() { uint32 AsScene2201Door::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x11001090) { if (_isOpen) _ssDoorLight->setVisible(true); @@ -71,15 +71,15 @@ uint32 AsScene2201Door::handleMessage(int messageNum, const MessageParam ¶m, _ssDoorLight->setVisible(false); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (_isOpen) _countdown = 144; messageResult = _isOpen ? 1 : 0; break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: _countdown = 144; if (!_isOpen) stOpenDoor(); @@ -317,7 +317,7 @@ void SsScene2202PuzzleCube::stopMoving() { loadSprite(kSsScene2202PuzzleCubeFileHashes2[_cubeSymbol], kSLFCenteredDrawOffset); SetSpriteUpdate(NULL); _isMoving = false; - sendMessage(_parentScene, 0x2002, _cubePosition); + sendMessage(_parentScene, NM_POSITION_CHANGE, _cubePosition); } static const uint32 kAsCommonKeyFileHashes[] = { @@ -343,7 +343,7 @@ uint32 AsCommonKey::handleMessage(int messageNum, const MessageParam ¶m, Ent sendMessage(_parentScene, 0x4826, 0); messageResult = 1; break; - case 0x4806: + case NM_KLAYMEN_USE_OBJECT: setSubVar(VA_HAS_KEY, _keyIndex, 1); setVisible(false); SetMessageHandler(NULL); @@ -377,25 +377,25 @@ uint32 AsScene2203Door::handleMessage(int messageNum, const MessageParam ¶m, switch (messageNum) { case 0x1011: if (_doorIndex == getGlobalVar(V_LARGE_DOOR_NUMBER)) - sendMessage(_parentScene, 0x2002, 0); + sendMessage(_parentScene, NM_POSITION_CHANGE, 0); else sendMessage(_parentScene, 0x2001, 0); messageResult = 1; break; - case 0x2000: + case NM_ANIMATION_UPDATE: _otherDoor = (Sprite*)param.asEntity(); break; - case 0x3002: + case NM_ANIMATION_STOP: if (_doorIndex == getGlobalVar(V_LARGE_DOOR_NUMBER)) - sendMessage(_parentScene, 0x4808, 0); + sendMessage(_parentScene, NM_KLAYMEN_OPEN_DOOR, 0); stopAnimation(); break; - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: setGlobalVar(V_LARGE_DOOR_NUMBER, _doorIndex); - sendMessage(_otherDoor, 0x4809, 0); + sendMessage(_otherDoor, NM_KLAYMEN_CLOSE_DOOR, 0); openDoor(); break; - case 0x4809: + case NM_KLAYMEN_CLOSE_DOOR: closeDoor(); sendMessage(_parentScene, 0x2003, 0); break; @@ -425,7 +425,7 @@ SsScene2205DoorFrame::SsScene2205DoorFrame(NeverhoodEngine *vm) uint32 SsScene2205DoorFrame::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: loadSprite(getGlobalVar(V_LIGHTS_ON) ? 0x24306227 : 0xD90032A0, kSLFDefDrawOffset | kSLFDefPosition); break; } @@ -458,13 +458,13 @@ void AsScene2206DoorSpikes::update() { uint32 AsScene2206DoorSpikes::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: _deltaIndex = 0; playSound(0, 0x032746E0); SetMessageHandler(NULL); SetSpriteUpdate(&AsScene2206DoorSpikes::suOpen); break; - case 0x4809: + case NM_KLAYMEN_CLOSE_DOOR: _deltaIndex = 0; playSound(0, 0x002642C0); SetMessageHandler(NULL); @@ -543,7 +543,7 @@ uint32 SsScene2206TestTube::handleMessage(int messageNum, const MessageParam &pa sendMessage(_parentScene, 0x4826, 0); messageResult = 1; break; - case 0x4806: + case NM_KLAYMEN_USE_OBJECT: setGlobalVar(V_HAS_TEST_TUBE, 1); setVisible(false); SetMessageHandler(NULL); @@ -607,9 +607,9 @@ void AsScene2207Elevator::update() { } if (_pointIndex > 20 && _surface->getPriority() != 900) - sendMessage(_parentScene, 0x2002, 900); + sendMessage(_parentScene, NM_POSITION_CHANGE, 900); else if (_pointIndex < 20 && _surface->getPriority() != 1100) - sendMessage(_parentScene, 0x2002, 1100); + sendMessage(_parentScene, NM_POSITION_CHANGE, 1100); AnimatedSprite::update(); @@ -629,7 +629,7 @@ void AsScene2207Elevator::suSetPosition() { uint32 AsScene2207Elevator::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: moveToY(param.asInteger()); break; } @@ -685,21 +685,21 @@ uint32 AsScene2207Lever::handleMessage(int messageNum, const MessageParam ¶m sendMessage(_parentScene, 0x4826, 0); messageResult = 1; break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); stopAnimation(); break; - case 0x4807: + case NM_KLAYMEN_RAISE_LEVER: stLeverUp(); break; - case 0x480F: + case NM_KLAYMEN_LOWER_LEVER: stLeverDown(); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -712,7 +712,7 @@ void AsScene2207Lever::stLeverDown() { } void AsScene2207Lever::stLeverDownEvent() { - sendMessage(_parentScene, 0x480F, 0); + sendMessage(_parentScene, NM_KLAYMEN_LOWER_LEVER, 0); } void AsScene2207Lever::stLeverUp() { @@ -723,7 +723,7 @@ void AsScene2207Lever::stLeverUp() { } void AsScene2207Lever::stLeverUpEvent() { - sendMessage(_parentScene, 0x4807, 0); + sendMessage(_parentScene, NM_KLAYMEN_RAISE_LEVER, 0); } AsScene2207WallRobotAnimation::AsScene2207WallRobotAnimation(NeverhoodEngine *vm, Scene *parentScene) @@ -748,7 +748,7 @@ AsScene2207WallRobotAnimation::~AsScene2207WallRobotAnimation() { uint32 AsScene2207WallRobotAnimation::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (!_idle) { if (param.asInteger() == 0x3423093) { _vm->_soundMan->addSound(0x80D00820, 0x12121943); @@ -769,13 +769,13 @@ uint32 AsScene2207WallRobotAnimation::handleMessage(int messageNum, const Messag playSound(0, 0xE0702146); } break; - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: stStartAnimation(); break; - case 0x2007: + case NM_CAR_MOVE_TO_PREV_POINT: stStopAnimation(); break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -822,13 +822,13 @@ AsScene2207WallCannonAnimation::AsScene2207WallCannonAnimation(NeverhoodEngine * uint32 AsScene2207WallCannonAnimation::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: stStartAnimation(); break; - case 0x2007: + case NM_CAR_MOVE_TO_PREV_POINT: stStopAnimation(); break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -876,13 +876,13 @@ uint32 KmScene2201::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: GotoState(&Klaymen::stPickUpGeneric); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 0) GotoState(&Klaymen::stPressButtonSide); break; @@ -899,10 +899,10 @@ uint32 KmScene2201::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: GotoState(&Klaymen::stTurnToUse); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: GotoState(&Klaymen::stReturnFromUse); break; case 0x482D: @@ -943,10 +943,10 @@ uint32 KmScene2203::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 2) GotoState(&Klaymen::stPickUpNeedle); else if (param.asInteger() == 1) @@ -954,7 +954,7 @@ uint32 KmScene2203::xHandleMessage(int messageNum, const MessageParam ¶m) { else GotoState(&Klaymen::stPickUpGeneric); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 1) GotoState(&Klaymen::stPressButton); else if (param.asInteger() == 2) @@ -972,7 +972,7 @@ uint32 KmScene2203::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4819: GotoState(&KmScene2203::stClayDoorOpen); break; - case 0x481A: + case NM_KLAYMEN_INSERT_DISK: GotoState(&Klaymen::stInsertDisk); break; case 0x481B: @@ -981,10 +981,10 @@ uint32 KmScene2203::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: GotoState(&Klaymen::stTurnToUse); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: GotoState(&Klaymen::stReturnFromUse); break; case 0x482D: @@ -1015,9 +1015,9 @@ void KmScene2203::stClayDoorOpen() { uint32 KmScene2203::hmClayDoorOpen(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x040D4186) { - sendMessage(_attachedSprite, 0x4808, 0); + sendMessage(_attachedSprite, NM_KLAYMEN_OPEN_DOOR, 0); } break; } @@ -1040,7 +1040,7 @@ uint32 KmScene2205::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4804: @@ -1050,7 +1050,7 @@ uint32 KmScene2205::xHandleMessage(int messageNum, const MessageParam ¶m) { } else GotoState(&Klaymen::stPeekWall); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 0) GotoState(&Klaymen::stPressButtonSide); break; @@ -1092,7 +1092,7 @@ uint32 KmScene2206::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4803: @@ -1105,13 +1105,13 @@ uint32 KmScene2206::xHandleMessage(int messageNum, const MessageParam ¶m) { } else GotoState(&Klaymen::stPeekWall); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 1) GotoState(&Klaymen::stPickUpTube); else GotoState(&Klaymen::stPickUpGeneric); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 1) GotoState(&Klaymen::stPressButton); else if (param.asInteger() == 2) @@ -1174,7 +1174,7 @@ void KmScene2206::suRidePlatformDown() { _platformDeltaY++; _y += _platformDeltaY; if (_y > 600) - sendMessage(this, 0x1019, 0); + sendMessage(this, NM_SCENE_LEAVE, 0); } void KmScene2206::stRidePlatformDown() { @@ -1202,7 +1202,7 @@ uint32 KmScene2207::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x2001: GotoState(&Klaymen::stRidePlatform); break; - case 0x2005: + case NM_KLAYMEN_CLIMB_LADDER: suRidePlatform(); GotoState(&Klaymen::stTryStandIdle); break; @@ -1210,16 +1210,16 @@ uint32 KmScene2207::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x480D: GotoState(&Klaymen::stInteractLever); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: GotoState(&Klaymen::stPickUpGeneric); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 1) GotoState(&Klaymen::stPressButton); else if (param.asInteger() == 2) @@ -1237,7 +1237,7 @@ uint32 KmScene2207::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x4827: + case NM_KLAYMEN_RELEASE_LEVER: GotoState(&Klaymen::stReleaseLever); break; case 0x482D: @@ -1270,7 +1270,7 @@ uint32 KmScene2242::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4804: @@ -1280,7 +1280,7 @@ uint32 KmScene2242::xHandleMessage(int messageNum, const MessageParam ¶m) { } else GotoState(&Klaymen::stPeekWall); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 2) GotoState(&Klaymen::stPickUpNeedle); else if (param.asInteger() == 1) @@ -1336,7 +1336,7 @@ uint32 KmHallOfRecords::xHandleMessage(int messageNum, const MessageParam ¶m case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4804: @@ -1389,7 +1389,7 @@ uint32 KmScene2247::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4804: diff --git a/engines/neverhood/modules/module2400.cpp b/engines/neverhood/modules/module2400.cpp index dab39b24f6..867fb692f2 100644 --- a/engines/neverhood/modules/module2400.cpp +++ b/engines/neverhood/modules/module2400.cpp @@ -253,11 +253,11 @@ void Scene2401::update() { if (puzzleSolved) { setGlobalVar(V_NOTES_DOOR_UNLOCKED, 1); setGlobalVar(V_NOTES_PUZZLE_SOLVED, 1); - sendMessage(_asDoor, 0x4808, 0); + sendMessage(_asDoor, NM_KLAYMEN_OPEN_DOOR, 0); } else if (waterInside) { playPipeSound(0xD0431020); for (uint i = 0; i < 5; i++) { - sendMessage(_asWaterFlushing[i], 0x2002, getSubVar(VA_CURR_WATER_PIPES_LEVEL, i)); + sendMessage(_asWaterFlushing[i], NM_POSITION_CHANGE, getSubVar(VA_CURR_WATER_PIPES_LEVEL, i)); setSubVar(VA_CURR_WATER_PIPES_LEVEL, i, 0); } } @@ -283,7 +283,7 @@ void Scene2401::update() { uint32 Scene2401::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x402064D8) sendEntityMessage(_klaymen, 0x1014, _ssButton); else if (param.asInteger() == 0x02144CB1) @@ -313,7 +313,7 @@ uint32 Scene2401::handleMessage(int messageNum, const MessageParam ¶m, Entit } else if (param.asInteger() == 0x09C4B40A && _countdown2 > 12) _countdown2 = 12; break; - case 0x2000: + case NM_ANIMATION_UPDATE: messageResult = 0; for (uint32 i = 0; i < 5; i++) if (kScene2401Rects[i].contains(_mouseClickPos.x, _mouseClickPos.y)) { @@ -334,15 +334,15 @@ uint32 Scene2401::handleMessage(int messageNum, const MessageParam ¶m, Entit _countdown1 = 8; } else if (sender == _ssFloorButton && getGlobalVar(V_WATER_RUNNING)) { _countdown2 = 144; - sendMessage(_asFlowingWater, 0x2002, 0); + sendMessage(_asFlowingWater, NM_POSITION_CHANGE, 0); playSound(0, 0xE1130324); } break; - case 0x482A: + case NM_MOVE_TO_BACK: _palette->addBasePalette(0xB103B604, 0, 65, 0); _palette->startFadeToPalette(12); break; - case 0x482B: + case NM_MOVE_TO_FRONT: _palette->addBasePalette(0x91D3A391, 0, 65, 0); _palette->startFadeToPalette(12); break; @@ -411,7 +411,7 @@ Scene2402::~Scene2402() { void Scene2402::update() { if (_countdown != 0 && (--_countdown) == 0) { if (_pipeStatus >= 10) { - sendMessage(_asDoor, 0x4808, 0); + sendMessage(_asDoor, NM_KLAYMEN_OPEN_DOOR, 0); _ssDoorFrame->loadSprite(0x00B415E0, kSLFDefDrawOffset | kSLFDefPosition); } else if (_pipeStatus >= 5) { _countdown = 8; @@ -428,7 +428,7 @@ void Scene2402::update() { uint32 Scene2402::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x402064D8) sendEntityMessage(_klaymen, 0x1014, _ssButton); else if (param.asInteger() == 0x01C66840) { @@ -516,13 +516,13 @@ Scene2403::Scene2403(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene2403::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x040424D0) sendEntityMessage(_klaymen, 0x1014, _ssButton); else if (param.asInteger() == 0x180CE614) sendEntityMessage(_klaymen, 0x1014, _asLightCord); break; - case 0x2000: + case NM_ANIMATION_UPDATE: _isClimbingLadder = true; setRectList(0x004B5E28); break; @@ -541,7 +541,7 @@ uint32 Scene2403::handleMessage(int messageNum, const MessageParam ¶m, Entit } } break; - case 0x480F: + case NM_KLAYMEN_LOWER_LEVER: if (sender == _asLightCord) leaveScene(2); break; @@ -637,7 +637,7 @@ Scene2406::Scene2406(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene2406::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x41062804) { if (getGlobalVar(V_SPIKES_RETRACTED)) setMessageList(0x004B7758); @@ -645,7 +645,7 @@ uint32 Scene2406::handleMessage(int messageNum, const MessageParam ¶m, Entit setMessageList(0x004B7738); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: _isClimbingLadder = true; setRectList(0x004B78D8); break; diff --git a/engines/neverhood/modules/module2400_sprites.cpp b/engines/neverhood/modules/module2400_sprites.cpp index bf85b0dc37..32c00cde27 100644 --- a/engines/neverhood/modules/module2400_sprites.cpp +++ b/engines/neverhood/modules/module2400_sprites.cpp @@ -49,11 +49,11 @@ AsScene2401WaterSpit::AsScene2401WaterSpit(NeverhoodEngine *vm) uint32 AsScene2401WaterSpit::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x120A0013) playSound(0, kAsScene2401WaterSpitFileHashes1[_soundIndex]); break; - case 0x2000: + case NM_ANIMATION_UPDATE: _x = 240; _y = 447; _soundIndex = getSubVar(VA_CURR_WATER_PIPES_LEVEL, param.asInteger()); @@ -61,7 +61,7 @@ uint32 AsScene2401WaterSpit::handleMessage(int messageNum, const MessageParam &p setVisible(true); playSound(0, 0x48640244); break; - case 0x3002: + case NM_ANIMATION_STOP: stopAnimation(); setVisible(false); break; @@ -87,11 +87,11 @@ AsScene2401FlowingWater::~AsScene2401FlowingWater() { uint32 AsScene2401FlowingWater::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (_isWaterFlowing && param.asInteger() == 0x02421405) startAnimationByHash(0x10203116, 0x01084280, 0); break; - case 0x2002: + case NM_POSITION_CHANGE: if (!_isWaterFlowing) { _vm->_soundMan->addSound(0x40F11C09, 0x980C1420); _vm->_soundMan->playSoundLooping(0x980C1420); @@ -104,7 +104,7 @@ uint32 AsScene2401FlowingWater::handleMessage(int messageNum, const MessageParam _vm->_soundMan->deleteSound(0x980C1420); _isWaterFlowing = false; break; - case 0x3002: + case NM_ANIMATION_STOP: stopAnimation(); setVisible(false); break; @@ -135,19 +135,19 @@ void AsScene2401WaterFlushing::update() { uint32 AsScene2401WaterFlushing::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (_flushLoopCount > 0 && param.asInteger() == 0x02421405) { startAnimationByHash(0xB8596884, 0x01084280, 0); _flushLoopCount--; } break; - case 0x2002: + case NM_POSITION_CHANGE: if (param.asInteger() > 0) { _flushLoopCount = param.asInteger() - 1; _countdown = _vm->_rnd->getRandomNumber(3) + 1; } break; - case 0x3002: + case NM_ANIMATION_STOP: stopAnimation(); setVisible(false); break; @@ -194,10 +194,10 @@ uint32 AsScene2401Door::handleMessage(int messageNum, const MessageParam ¶m, _countdown = 168; messageResult = _isOpen ? 1 : 0; break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: if (!_isOpen) { _countdown = 168; _isOpen = true; @@ -249,15 +249,15 @@ void AsScene2402Door::update() { uint32 AsScene2402Door::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: if (_isOpen) _countdown = 144; messageResult = _isOpen ? 1 : 0; break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; - case 0x4808: + case NM_KLAYMEN_OPEN_DOOR: _countdown = 144; _isOpen = true; setVisible(true); @@ -342,11 +342,11 @@ void AsScene2402TV::stJokeFinished() { uint32 AsScene2402TV::hmJoke(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x431EA0B0) playSound(0); break; - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -368,10 +368,10 @@ uint32 KmScene2401::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 1) GotoState(&Klaymen::stPressButton); else if (param.asInteger() == 2) @@ -437,7 +437,7 @@ uint32 KmScene2401::xHandleMessage(int messageNum, const MessageParam ¶m) { uint32 KmScene2401::hmSpit(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Klaymen::hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x16401CA6) { _canSpitPipe = true; if (_contSpitPipe) @@ -508,7 +508,7 @@ uint32 KmScene2402::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: if (!getGlobalVar(V_TV_JOKE_TOLD)) GotoState(&Klaymen::stStandWonderAbout); else @@ -521,10 +521,10 @@ uint32 KmScene2402::xHandleMessage(int messageNum, const MessageParam ¶m) { } else GotoState(&Klaymen::stPeekWall); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: GotoState(&Klaymen::stPickUpGeneric); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 1) GotoState(&Klaymen::stPressButton); else if (param.asInteger() == 2) @@ -577,16 +577,16 @@ uint32 KmScene2403::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x480D: GotoState(&Klaymen::stPullCord); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: GotoState(&Klaymen::stPickUpGeneric); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 1) GotoState(&Klaymen::stPressButton); else if (param.asInteger() == 2) @@ -661,7 +661,7 @@ uint32 KmScene2406::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4804: @@ -671,7 +671,7 @@ uint32 KmScene2406::xHandleMessage(int messageNum, const MessageParam ¶m) { } else GotoState(&Klaymen::stPeekWall); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 2) GotoState(&Klaymen::stPickUpNeedle); else if (param.asInteger() == 1) @@ -683,7 +683,7 @@ uint32 KmScene2406::xHandleMessage(int messageNum, const MessageParam ¶m) { setDoDeltaX(param.asInteger()); gotoNextStateExt(); break; - case 0x481A: + case NM_KLAYMEN_INSERT_DISK: GotoState(&Klaymen::stInsertDisk); break; case 0x481B: @@ -692,10 +692,10 @@ uint32 KmScene2406::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: GotoState(&Klaymen::stTurnToUse); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: GotoState(&Klaymen::stReturnFromUse); break; case 0x481F: diff --git a/engines/neverhood/modules/module2500.cpp b/engines/neverhood/modules/module2500.cpp index d0e60adf65..eb1b65cd83 100644 --- a/engines/neverhood/modules/module2500.cpp +++ b/engines/neverhood/modules/module2500.cpp @@ -252,7 +252,7 @@ Scene2501::Scene2501(NeverhoodEngine *vm, Module *parentModule, int which) setRectList(0x004B2608); SetMessageHandler(&Scene2501::handleMessage); SetUpdateHandler(&Scene2501::update); - sendMessage(_asCar, 0x2009, 0); + sendMessage(_asCar, NM_CAR_ENTER, 0); _asCar->setVisible(false); _currTrackIndex = 0; } else if (which == 1 || which == 2) { @@ -277,7 +277,7 @@ Scene2501::Scene2501(NeverhoodEngine *vm, Module *parentModule, int which) setRectList(0x004B2608); SetMessageHandler(&Scene2501::handleMessage); SetUpdateHandler(&Scene2501::update); - sendMessage(_asCar, 0x2009, 0); + sendMessage(_asCar, NM_CAR_ENTER, 0); _asCar->setVisible(false); _currTrackIndex = 0; } @@ -295,14 +295,14 @@ Scene2501::Scene2501(NeverhoodEngine *vm, Module *parentModule, int which) if (which >= 0 && _tracks[_currTrackIndex]->which2 == which) { NPoint testPoint = (*_trackPoints)[_trackPoints->size() - 1]; - sendMessage(_asCar, 0x2002, _trackPoints->size() - 1); + sendMessage(_asCar, NM_POSITION_CHANGE, _trackPoints->size() - 1); if (testPoint.x < 0 || testPoint.x >= 640 || testPoint.y < 0 || testPoint.y >= 480) - sendMessage(_asCar, 0x2007, 150); + sendMessage(_asCar, NM_CAR_MOVE_TO_PREV_POINT, 150); } else { NPoint testPoint = (*_trackPoints)[0]; - sendMessage(_asCar, 0x2002, 0); + sendMessage(_asCar, NM_POSITION_CHANGE, 0); if (testPoint.x < 0 || testPoint.x >= 640 || testPoint.y < 0 || testPoint.y >= 480) - sendMessage(_asCar, 0x2008, 150); + sendMessage(_asCar, NM_CAR_MOVE_TO_NEXT_POINT, 150); } _carStatus = 0; @@ -329,7 +329,7 @@ void Scene2501::update() { _asIdleCarLower->setVisible(false); _asIdleCarFull->setVisible(false); _asCar->setVisible(true); - sendMessage(_asCar, 0x2009, 0); + sendMessage(_asCar, NM_CAR_ENTER, 0); _asCar->handleUpdate(); _klaymen = NULL; _carStatus = 0; @@ -341,7 +341,7 @@ void Scene2501::upCarAtHome() { Scene::update(); if (_mouseClicked) { if (_mouseClickPos.x <= 210 && _asCar->getX() == 211 && _asCar->getY() == 400) { - sendMessage(_asCar, 0x200A, 0); + sendMessage(_asCar, NM_CAR_LEAVE, 0); SetUpdateHandler(&Scene2501::upGettingOutOfCar); } else { moveCarToPoint(_mouseClickPos); @@ -385,7 +385,7 @@ void Scene2501::upRidingCar() { uint32 Scene2501::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x60842040) _carStatus = 1; break; @@ -399,23 +399,23 @@ uint32 Scene2501::handleMessage(int messageNum, const MessageParam ¶m, Entit uint32 Scene2501::hmRidingCar(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2005: + case NM_KLAYMEN_CLIMB_LADDER: if (_tracks[_currTrackIndex]->which1 < 0 && _newTrackIndex >= 0) changeTrack(); else if (_tracks[_currTrackIndex]->which1 == 0) { SetMessageHandler(&Scene2501::hmCarAtHome); SetUpdateHandler(&Scene2501::upCarAtHome); - sendMessage(_asCar, 0x200F, 1); + sendMessage(_asCar, NM_CAR_AT_HOME, 1); } else if (_tracks[_currTrackIndex]->which1 > 0) leaveScene(_tracks[_currTrackIndex]->which1); break; - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: if (_tracks[_currTrackIndex]->which2 < 0 && _newTrackIndex >= 0) changeTrack(); else if (_tracks[_currTrackIndex]->which2 == 0) { SetMessageHandler(&Scene2501::hmCarAtHome); SetUpdateHandler(&Scene2501::upCarAtHome); - sendMessage(_asCar, 0x200F, 1); + sendMessage(_asCar, NM_CAR_AT_HOME, 1); } else if (_tracks[_currTrackIndex]->which2 > 0) leaveScene(_tracks[_currTrackIndex]->which2); break; @@ -429,7 +429,7 @@ uint32 Scene2501::hmRidingCar(int messageNum, const MessageParam ¶m, Entity uint32 Scene2501::hmCarAtHome(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x200A: + case NM_CAR_LEAVE: _carStatus = 2; break; case 0x200D: @@ -460,9 +460,9 @@ void Scene2501::changeTrack() { _trackPoints = _dataResource.getPointArray(_tracks[_currTrackIndex]->trackPointsName); _asCar->setPathPoints(_trackPoints); if (_currTrackIndex == 0) - sendMessage(_asCar, 0x2002, _trackPoints->size() - 1); + sendMessage(_asCar, NM_POSITION_CHANGE, _trackPoints->size() - 1); else - sendMessage(_asCar, 0x2002, 0); + sendMessage(_asCar, NM_POSITION_CHANGE, 0); sendPointMessage(_asCar, 0x2004, _clickPoint); _newTrackIndex = -1; } @@ -491,7 +491,7 @@ Scene2504::Scene2504(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene2504::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) leaveScene(0); break; diff --git a/engines/neverhood/modules/module2500_sprites.cpp b/engines/neverhood/modules/module2500_sprites.cpp index ab6b3dcfbe..1394a87db6 100644 --- a/engines/neverhood/modules/module2500_sprites.cpp +++ b/engines/neverhood/modules/module2500_sprites.cpp @@ -81,7 +81,7 @@ KmScene2501::KmScene2501(NeverhoodEngine *vm, Scene *parentScene, int16 x, int16 uint32 KmScene2501::xHandleMessage(int messageNum, const MessageParam ¶m) { uint32 messageResult = 0; switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: _isSittingInTeleporter = param.asInteger() != 0; messageResult = 1; break; @@ -89,7 +89,7 @@ uint32 KmScene2501::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: if (_isSittingInTeleporter) GotoState(&Klaymen::stSitIdleTeleporter); else @@ -99,11 +99,11 @@ uint32 KmScene2501::xHandleMessage(int messageNum, const MessageParam ¶m) { setDoDeltaX(param.asInteger()); gotoNextStateExt(); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stTurnToUseInTeleporter); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stReturnFromUseInTeleporter); break; diff --git a/engines/neverhood/modules/module2600.cpp b/engines/neverhood/modules/module2600.cpp index a6484a4926..3c3e733b3f 100644 --- a/engines/neverhood/modules/module2600.cpp +++ b/engines/neverhood/modules/module2600.cpp @@ -239,20 +239,20 @@ Scene2609::Scene2609(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene2609::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if ((param.asPoint().x <= 20 || param.asPoint().x >= 620) && !_isBusy) leaveScene(0); break; - case 0x2000: + case NM_ANIMATION_UPDATE: _isBusy = true; break; case 0x2001: _isBusy = false; sendMessage(_asWater, 0x2001, 0); break; - case 0x2002: + case NM_POSITION_CHANGE: _isBusy = false; - sendMessage(_asWater, 0x2002, 0); + sendMessage(_asWater, NM_POSITION_CHANGE, 0); break; } return 0; diff --git a/engines/neverhood/modules/module2600_sprites.cpp b/engines/neverhood/modules/module2600_sprites.cpp index 2c24b533f3..2506a6eb48 100644 --- a/engines/neverhood/modules/module2600_sprites.cpp +++ b/engines/neverhood/modules/module2600_sprites.cpp @@ -47,7 +47,7 @@ void SsScene2609Button::update() { sendMessage(_parentScene, 0x2001, 0); } else { setGlobalVar(V_WATER_RUNNING, 1); - sendMessage(_parentScene, 0x2002, 0); + sendMessage(_parentScene, NM_POSITION_CHANGE, 0); } } } @@ -88,7 +88,7 @@ AsScene2609Water::AsScene2609Water(NeverhoodEngine *vm) SetUpdateHandler(&AnimatedSprite::update); SetMessageHandler(&AsScene2609Water::handleMessage); if (getGlobalVar(V_WATER_RUNNING)) - sendMessage(this, 0x2002, 0); + sendMessage(this, NM_POSITION_CHANGE, 0); } AsScene2609Water::~AsScene2609Water() { @@ -103,7 +103,7 @@ uint32 AsScene2609Water::handleMessage(int messageNum, const MessageParam ¶m setVisible(false); _vm->_soundMan->stopSound(0xDC2769B0); break; - case 0x2002: + case NM_POSITION_CHANGE: startAnimation(0x9C210C90, 0, -1); setVisible(true); _vm->_soundMan->playSoundLooping(0xDC2769B0); diff --git a/engines/neverhood/modules/module2700.cpp b/engines/neverhood/modules/module2700.cpp index 1b78615fdb..13c30048a4 100644 --- a/engines/neverhood/modules/module2700.cpp +++ b/engines/neverhood/modules/module2700.cpp @@ -576,14 +576,14 @@ Scene2701::Scene2701(NeverhoodEngine *vm, Module *parentModule, int which) if (which == _which2) { NPoint testPoint = (*_trackPoints)[_trackPoints->size() - 1]; - sendMessage(_asCar, 0x2002, _trackPoints->size() - 1); + sendMessage(_asCar, NM_POSITION_CHANGE, _trackPoints->size() - 1); if (testPoint.x < 0 || testPoint.x >= 640 || testPoint.y < 0 || testPoint.y >= 480) - sendMessage(_asCar, 0x2007, 150); + sendMessage(_asCar, NM_CAR_MOVE_TO_PREV_POINT, 150); } else { NPoint testPoint = (*_trackPoints)[0]; - sendMessage(_asCar, 0x2002, 0); + sendMessage(_asCar, NM_POSITION_CHANGE, 0); if (testPoint.x < 0 || testPoint.x >= 640 || testPoint.y < 0 || testPoint.y >= 480) - sendMessage(_asCar, 0x2008, 150); + sendMessage(_asCar, NM_CAR_MOVE_TO_NEXT_POINT, 150); } _asCar->setClipRect(clipRect); @@ -592,7 +592,7 @@ Scene2701::Scene2701(NeverhoodEngine *vm, Module *parentModule, int which) if (which == 1) { SetMessageHandler(&Scene2701::hmRidingCar); } else { - sendMessage(_asCar, 0x2009, 0); + sendMessage(_asCar, NM_CAR_ENTER, 0); SetMessageHandler(&Scene2701::hmCarAtHome); } @@ -601,14 +601,14 @@ Scene2701::Scene2701(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene2701::hmRidingCar(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: sendPointMessage(_asCar, 0x2004, param.asPoint()); break; - case 0x2005: + case NM_KLAYMEN_CLIMB_LADDER: if (_which1 >= 0) SetMessageHandler(&Scene2701::hmCarAtHome); break; - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: if (_which2 >= 0) leaveScene(_which2); break; @@ -622,7 +622,7 @@ uint32 Scene2701::hmRidingCar(int messageNum, const MessageParam ¶m, Entity uint32 Scene2701::hmCarAtHome(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x >= 385) leaveScene(0); else { @@ -702,11 +702,11 @@ Scene2702::Scene2702(NeverhoodEngine *vm, Module *parentModule, int which) _asCar->setPathPoints(_trackPoints); if (which == _tracks[_currTrackIndex]->which2) { - sendMessage(_asCar, 0x2002, _trackPoints->size() - 1); - sendMessage(_asCar, 0x2007, 150); + sendMessage(_asCar, NM_POSITION_CHANGE, _trackPoints->size() - 1); + sendMessage(_asCar, NM_CAR_MOVE_TO_PREV_POINT, 150); } else { - sendMessage(_asCar, 0x2002, 0); - sendMessage(_asCar, 0x2008, 150); + sendMessage(_asCar, NM_POSITION_CHANGE, 0); + sendMessage(_asCar, NM_CAR_MOVE_TO_NEXT_POINT, 150); } _palette->copyBasePalette(0, 256, 0); @@ -731,17 +731,17 @@ void Scene2702::update() { uint32 Scene2702::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: moveCarToPoint(param.asPoint()); break; - case 0x2005: + case NM_KLAYMEN_CLIMB_LADDER: if (_newTrackIndex >= 0) { if (_tracks[_currTrackIndex]->which1 < 0) changeTrack(); } else if (_tracks[_currTrackIndex]->which1 >= 0) leaveScene(_tracks[_currTrackIndex]->which1); break; - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: if (_newTrackIndex >= 0) { if (_tracks[_currTrackIndex]->which2 < 0) changeTrack(); @@ -782,13 +782,13 @@ void Scene2702::changeTrack() { _asCar->setPathPoints(_trackPoints); if (_isUpperTrack) { if (_currTrackIndex == 0) - sendMessage(_asCar, 0x2002, _trackPoints->size() - 1); + sendMessage(_asCar, NM_POSITION_CHANGE, _trackPoints->size() - 1); else - sendMessage(_asCar, 0x2002, 0); + sendMessage(_asCar, NM_POSITION_CHANGE, 0); } else if (_currTrackIndex == 2) - sendMessage(_asCar, 0x2002, 0); + sendMessage(_asCar, NM_POSITION_CHANGE, 0); else - sendMessage(_asCar, 0x2002, _trackPoints->size() - 1); + sendMessage(_asCar, NM_POSITION_CHANGE, _trackPoints->size() - 1); sendMessage(_asCar, 0x2004, _newTrackDestX); _newTrackIndex = -1; } @@ -832,18 +832,18 @@ Scene2703::Scene2703(NeverhoodEngine *vm, Module *parentModule, int which, uint3 if (which == _which2) { NPoint testPoint = (*_trackPoints)[_trackPoints->size() - 1]; - sendMessage(_asCar, 0x2002, _trackPoints->size() - 1); + sendMessage(_asCar, NM_POSITION_CHANGE, _trackPoints->size() - 1); if (testPoint.x > 0 && testPoint.x < 640 && testPoint.y > 0 && testPoint.y < 480) - sendMessage(_asCar, 0x2009, 0); + sendMessage(_asCar, NM_CAR_ENTER, 0); else - sendMessage(_asCar, 0x2007, 150); + sendMessage(_asCar, NM_CAR_MOVE_TO_PREV_POINT, 150); } else { NPoint testPoint = (*_trackPoints)[0]; - sendMessage(_asCar, 0x2002, 0); + sendMessage(_asCar, NM_POSITION_CHANGE, 0); if (testPoint.x > 0 && testPoint.x < 640 && testPoint.y > 0 && testPoint.y < 480) - sendMessage(_asCar, 0x2009, 0); + sendMessage(_asCar, NM_CAR_ENTER, 0); else - sendMessage(_asCar, 0x2008, 150); + sendMessage(_asCar, NM_CAR_MOVE_TO_NEXT_POINT, 150); } if (which == 0) { @@ -891,11 +891,11 @@ void Scene2703::update() { uint32 Scene2703::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2005: + case NM_KLAYMEN_CLIMB_LADDER: if (_which1 >= 0) leaveScene(_which1); break; - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: if (_which2 >= 0) leaveScene(_which2); break; @@ -951,18 +951,18 @@ Scene2704::Scene2704(NeverhoodEngine *vm, Module *parentModule, int which, uint3 if (which == _which2) { NPoint testPoint = (*_trackPoints)[_trackPoints->size() - 1]; - sendMessage(_asCar, 0x2002, _trackPoints->size() - 1); + sendMessage(_asCar, NM_POSITION_CHANGE, _trackPoints->size() - 1); if (testPoint.x > 0 && testPoint.x < 640 && testPoint.y > 0 && testPoint.y < 480) - sendMessage(_asCar, 0x2009, 0); + sendMessage(_asCar, NM_CAR_ENTER, 0); else - sendMessage(_asCar, 0x2007, 0); + sendMessage(_asCar, NM_CAR_MOVE_TO_PREV_POINT, 150); } else { NPoint testPoint = (*_trackPoints)[0]; - sendMessage(_asCar, 0x2002, 0); + sendMessage(_asCar, NM_POSITION_CHANGE, 0); if (testPoint.x > 0 && testPoint.x < 640 && testPoint.y > 0 && testPoint.y < 480) - sendMessage(_asCar, 0x2009, 0); + sendMessage(_asCar, NM_CAR_ENTER, 0); else - sendMessage(_asCar, 0x2008, 0); + sendMessage(_asCar, NM_CAR_MOVE_TO_NEXT_POINT, 150); } if (clipRect) { @@ -990,11 +990,11 @@ void Scene2704::update() { uint32 Scene2704::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2005: + case NM_KLAYMEN_CLIMB_LADDER: if (_which1 >= 0) leaveScene(_which1); break; - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: if (_which2 >= 0) leaveScene(_which2); break; @@ -1044,17 +1044,17 @@ Scene2706::Scene2706(NeverhoodEngine *vm, Module *parentModule, int which) _asCar->setPathPoints(_trackPoints); if (which == _tracks[_currTrackIndex]->which2) { - sendMessage(_asCar, 0x2002, _trackPoints->size() - 1); + sendMessage(_asCar, NM_POSITION_CHANGE, _trackPoints->size() - 1); if (which == 5) - sendMessage(_asCar, 0x2007, 50); + sendMessage(_asCar, NM_CAR_MOVE_TO_PREV_POINT, 50); else - sendMessage(_asCar, 0x2007, 150); + sendMessage(_asCar, NM_CAR_MOVE_TO_PREV_POINT, 150); } else { - sendMessage(_asCar, 0x2002, 0); + sendMessage(_asCar, NM_POSITION_CHANGE, 0); if (which == 5) - sendMessage(_asCar, 0x2008, 50); + sendMessage(_asCar, NM_CAR_MOVE_TO_NEXT_POINT, 50); else - sendMessage(_asCar, 0x2008, 150); + sendMessage(_asCar, NM_CAR_MOVE_TO_NEXT_POINT, 150); } } @@ -1062,17 +1062,17 @@ Scene2706::Scene2706(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene2706::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: moveCarToPoint(param.asPoint()); break; - case 0x2005: + case NM_KLAYMEN_CLIMB_LADDER: if (_newTrackIndex >= 0) { if (_tracks[_currTrackIndex]->which1 < 0) changeTrack(); } else if (_tracks[_currTrackIndex]->which1 >= 0) leaveScene(_tracks[_currTrackIndex]->which1); break; - case 0x2006: + case NM_KLAYMEN_STOP_CLIMBING: if (_newTrackIndex >= 0) { if (_tracks[_currTrackIndex]->which2 < 0) changeTrack(); @@ -1107,9 +1107,9 @@ void Scene2706::changeTrack() { _trackPoints = _dataResource.getPointArray(_tracks[_currTrackIndex]->trackPointsName); _asCar->setPathPoints(_trackPoints); if (_currTrackIndex == 0) - sendMessage(_asCar, 0x2002, _trackPoints->size() - 1); + sendMessage(_asCar, NM_POSITION_CHANGE, _trackPoints->size() - 1); else - sendMessage(_asCar, 0x2002, 0); + sendMessage(_asCar, NM_POSITION_CHANGE, 0); sendMessage(_asCar, 0x2004, _newTrackDestX); _newTrackIndex = -1; } diff --git a/engines/neverhood/modules/module2800.cpp b/engines/neverhood/modules/module2800.cpp index d51515ce81..8f23de33db 100644 --- a/engines/neverhood/modules/module2800.cpp +++ b/engines/neverhood/modules/module2800.cpp @@ -478,11 +478,11 @@ uint32 Scene2801::handleMessage(int messageNum, const MessageParam ¶m, Entit setMessageList(0x004B6C40); } break; - case 0x482A: + case NM_MOVE_TO_BACK: _palette->addBasePalette(0xB103B604, 0, 65, 0); _palette->startFadeToPalette(12); break; - case 0x482B: + case NM_MOVE_TO_FRONT: _palette->addBasePalette(_paletteHash, 0, 65, 0); _palette->startFadeToPalette(12); break; @@ -586,7 +586,7 @@ uint32 Scene2802::handleMessage(int messageNum, const MessageParam ¶m, Entit int prevTuneStatus = _currTuneStatus; Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) { leaveScene(0); } else if (_currTuneStatus == 0) { @@ -779,10 +779,10 @@ void Scene2803::upKlaymenStairs() { uint32 Scene2803::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x480F: + case NM_KLAYMEN_LOWER_LEVER: toggleBackground(); // NOTE Intentional fall-through - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x84251F82) setMessageList(0x004B7A50); else if (param.asInteger() == 0x4254A2D2) @@ -797,11 +797,11 @@ uint32 Scene2803::handleMessage(int messageNum, const MessageParam ¶m, Entit } else if (param.asInteger() == 0x9626F390) setMessageList(0x004B7A88); break; - case 0x482A: + case NM_MOVE_TO_BACK: klaymenStairs(); setPaletteArea1(); break; - case 0x482B: + case NM_MOVE_TO_FRONT: klaymenFloor(); setPaletteArea0(); break; @@ -1015,7 +1015,7 @@ Scene2803Small::Scene2803Small(NeverhoodEngine *vm, Module *parentModule, int wh uint32 Scene2803Small::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0xB4E4884C) { setMessageList(0x004B6180); } else if (param.asInteger() == 0xB1FDAB2E) { @@ -1043,7 +1043,7 @@ uint32 Scene2803Small::handleMessage(int messageNum, const MessageParam ¶m, setMessageList(0x004B61A8); } break; - case 0x482A: + case NM_MOVE_TO_BACK: if (_klaymen->getX() < 200) { setPaletteArea3(); } else if (_klaymen->getX() < 500) { @@ -1055,7 +1055,7 @@ uint32 Scene2803Small::handleMessage(int messageNum, const MessageParam ¶m, setPaletteArea2(); } break; - case 0x482B: + case NM_MOVE_TO_FRONT: _sprite6->setVisible(false); _sprite7->setVisible(false); _klaymen->setClipRect(0, 0, 640, 480); @@ -1206,14 +1206,14 @@ Scene2804::Scene2804(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene2804::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) { leaveScene(0); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: _isWorking = true; - sendMessage(_asCoil, 0x2002, 0); + sendMessage(_asCoil, NM_POSITION_CHANGE, 0); if (getGlobalVar(V_SHRINK_LIGHTS_ON)) { sendMessage(_asTarget, 0x2004, 0); _countdown2 = 48; @@ -1243,7 +1243,7 @@ void Scene2804::update() { if (_countdown2 != 0 && (--_countdown2) == 0) { _isWorking = false; sendMessage(_asCoil, 0x2003, 0); - sendMessage(_asTarget, 0x2005, 0); + sendMessage(_asTarget, NM_KLAYMEN_CLIMB_LADDER, 0); for (uint index = 0; index < 5; index++) _asCrystals[index]->hide(); } @@ -1317,7 +1317,7 @@ Scene2805::Scene2805(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene2805::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: if (param.asInteger()) { setRectList(0x004AE318); _klaymen->setKlaymenIdleTable3(); @@ -1407,12 +1407,12 @@ Scene2806::Scene2806(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene2806::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x44262B12) { setMessageList(0x004AF0E0); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: sendMessage(_asSpew, 0x2000, 0); break; } @@ -1487,7 +1487,7 @@ Scene2807::Scene2807(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene2807::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) { leaveScene(0); } @@ -1557,19 +1557,19 @@ Scene2808::Scene2808(NeverhoodEngine *vm, Module *parentModule, int which) uint32 Scene2808::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if ((param.asPoint().x <= 20 || param.asPoint().x >= 620) && !isAnyTestTubeFilled()) { leaveScene(1); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (!_isFlowing) _asTestTubes[param.asInteger()]->fill(); break; case 0x2001: _isFlowing = true; break; - case 0x2002: + case NM_POSITION_CHANGE: if (isAnyTestTubeFilled()) { _leaveResult = 3; if (!isMixtureGood()) @@ -1697,12 +1697,12 @@ void Scene2809::update() { uint32 Scene2809::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x160DA937) { setMessageList(0x004B5B98); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: sendMessage(_asSpew, 0x2000, 0); break; } @@ -1904,7 +1904,7 @@ void Scene2810::insertKlaymenLadder() { uint32 Scene2810::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0xE574F14C) setMessageList(0x004AE458); else if (param.asInteger() == 0x7214A05C || param.asInteger() == 0x2905E574) @@ -1934,7 +1934,7 @@ uint32 Scene2810::handleMessage(int messageNum, const MessageParam ¶m, Entit else if (param.asInteger() == 0x2064294C || param.asInteger() == 0x2194E053) setMessageList(0x004AE688); break; - case 0x2000: + case NM_ANIMATION_UPDATE: setRectList(0x004AE800); _isRopingDown = true; break; @@ -2037,7 +2037,7 @@ void Scene2812::update() { uint32 Scene2812::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x0004269B) sendEntityMessage(_klaymen, 0x1014, _asRope); break; @@ -2046,12 +2046,12 @@ uint32 Scene2812::handleMessage(int messageNum, const MessageParam ¶m, Entit setRectList(0x004AF710); _klaymen->setClipRect(_sprite4->getDrawRect().x, 0, 640, _sprite4->getDrawRect().y2()); break; - case 0x2002: + case NM_POSITION_CHANGE: _isRopingDown = false; setRectList(0x004AF700); _klaymen->setClipRect(_sprite4->getDrawRect().x, 0, 640, _sprite3->getDrawRect().y2()); break; - case 0x4806: + case NM_KLAYMEN_USE_OBJECT: sendMessage(_asWinch, 0x2000, 0); sendMessage(_asTrapDoor, 0x2000, 0); break; @@ -2064,12 +2064,12 @@ uint32 Scene2812::handleMessage(int messageNum, const MessageParam ¶m, Entit setMessageList(0x004AF668); } break; - case 0x482A: + case NM_MOVE_TO_BACK: setPaletteArea1(false); _sprite1->setVisible(true); _klaymen->setClipRect(_sprite1->getDrawRect().x, 0, _sprite1->getDrawRect().x2(), _sprite3->getDrawRect().y2()); break; - case 0x482B: + case NM_MOVE_TO_FRONT: setPaletteArea0(false); _sprite1->setVisible(false); _klaymen->setClipRect(_sprite4->getDrawRect().x, 0, 640, _sprite3->getDrawRect().y2()); @@ -2160,7 +2160,7 @@ void Scene2822::update() { uint32 Scene2822::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) { leaveScene(0); } else if (param.asPoint().x >= 257 && param.asPoint().y >= 235 && diff --git a/engines/neverhood/modules/module2800_sprites.cpp b/engines/neverhood/modules/module2800_sprites.cpp index a600c55dd3..35596da6b5 100644 --- a/engines/neverhood/modules/module2800_sprites.cpp +++ b/engines/neverhood/modules/module2800_sprites.cpp @@ -40,20 +40,20 @@ AsScene2803LightCord::AsScene2803LightCord(NeverhoodEngine *vm, Scene *parentSce uint32 AsScene2803LightCord::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (!_isBusy && param.asInteger() == calcHash("ClickSwitch")) { - sendMessage(_parentScene, 0x480F, 0); + sendMessage(_parentScene, NM_KLAYMEN_LOWER_LEVER, 0); playSound(0, 0x4E1CA4A0); } break; - case 0x480F: + case NM_KLAYMEN_LOWER_LEVER: stPulled(); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -62,7 +62,7 @@ uint32 AsScene2803LightCord::handleMessage(int messageNum, const MessageParam &p uint32 AsScene2803LightCord::hmPulled(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -107,7 +107,7 @@ AsScene2803TestTubeOne::AsScene2803TestTubeOne(NeverhoodEngine *vm, uint32 fileH uint32 AsScene2803TestTubeOne::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: if (param.asInteger()) startAnimation(_fileHash2, 0, -1); else @@ -133,15 +133,15 @@ AsScene2803Rope::AsScene2803Rope(NeverhoodEngine *vm, Scene *parentScene, int16 uint32 AsScene2803Rope::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: startAnimation(0x9D098C23, 50, -1); SetMessageHandler(&AsScene2803Rope::hmReleased); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -150,14 +150,14 @@ uint32 AsScene2803Rope::handleMessage(int messageNum, const MessageParam ¶m, uint32 AsScene2803Rope::hmReleased(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -217,7 +217,7 @@ SsScene2804LightCoil::SsScene2804LightCoil(NeverhoodEngine *vm) uint32 SsScene2804LightCoil::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2002: + case NM_POSITION_CHANGE: setVisible(true); updatePosition(); messageResult = 1; @@ -247,7 +247,7 @@ uint32 SsScene2804LightTarget::handleMessage(int messageNum, const MessageParam updatePosition(); messageResult = 1; break; - case 0x2005: + case NM_KLAYMEN_CLIMB_LADDER: setVisible(false); updatePosition(); messageResult = 1; @@ -470,7 +470,7 @@ void AsScene2804BeamCoil::update() { uint32 AsScene2804BeamCoil::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2002: + case NM_POSITION_CHANGE: show(); _countdown = 92; messageResult = 1; @@ -509,7 +509,7 @@ void AsScene2804BeamCoil::stBeaming() { uint32 AsScene2804BeamCoil::hmBeaming(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -537,7 +537,7 @@ uint32 AsScene2804BeamTarget::handleMessage(int messageNum, const MessageParam & startAnimation(0x03842000, 0, -1); messageResult = 1; break; - case 0x2005: + case NM_KLAYMEN_CLIMB_LADDER: setVisible(false); stopAnimation(); messageResult = 1; @@ -561,12 +561,12 @@ AsScene2806Spew::AsScene2806Spew(NeverhoodEngine *vm) uint32 AsScene2806Spew::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: playSound(0, 0x48640244); startAnimation(0x04211490, 0, -1); setVisible(true); break; - case 0x3002: + case NM_ANIMATION_STOP: stopAnimation(); setVisible(false); break; @@ -774,7 +774,7 @@ uint32 AsScene2808Handle::handleMessage(int messageNum, const MessageParam ¶ uint32 AsScene2808Handle::hmActivating(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -791,7 +791,7 @@ void AsScene2808Handle::activate() { void AsScene2808Handle::stActivated() { stopAnimation(); - sendMessage(_parentScene, 0x2002, 0); + sendMessage(_parentScene, NM_POSITION_CHANGE, 0); } AsScene2808Flow::AsScene2808Flow(NeverhoodEngine *vm, Scene *parentScene, int testTubeSetNum) @@ -817,7 +817,7 @@ AsScene2808Flow::AsScene2808Flow(NeverhoodEngine *vm, Scene *parentScene, int te uint32 AsScene2808Flow::hmFlowing(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -875,12 +875,12 @@ AsScene2809Spew::AsScene2809Spew(NeverhoodEngine *vm) uint32 AsScene2809Spew::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: playSound(0, 0x48640244); startAnimation(0x04211490, 0, -1); setVisible(true); break; - case 0x3002: + case NM_ANIMATION_STOP: stopAnimation(); setVisible(false); break; @@ -903,14 +903,14 @@ AsScene2810Rope::AsScene2810Rope(NeverhoodEngine *vm, Scene *parentScene, int16 uint32 AsScene2810Rope::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: startAnimation(0x9D098C23, 35, 53); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -934,13 +934,13 @@ AsScene2812Winch::~AsScene2812Winch() { uint32 AsScene2812Winch::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: startAnimation(0x20DA08A0, 0, -1); setVisible(true); _vm->_soundMan->addSound(0x00B000E2, 0xC874EE6C); _vm->_soundMan->playSoundLooping(0xC874EE6C); break; - case 0x3002: + case NM_ANIMATION_STOP: startAnimation(0x20DA08A0, 7, -1); break; } @@ -962,15 +962,15 @@ AsScene2812Rope::AsScene2812Rope(NeverhoodEngine *vm, Scene *parentScene) uint32 AsScene2812Rope::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x4806: + case NM_KLAYMEN_USE_OBJECT: setDoDeltaX(((Sprite*)sender)->isDoDeltaX() ? 1 : 0); stRopingDown(); break; - case 0x482A: - sendMessage(_parentScene, 0x1022, 990); + case NM_MOVE_TO_BACK: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 990); break; - case 0x482B: - sendMessage(_parentScene, 0x1022, 1010); + case NM_MOVE_TO_FRONT: + sendMessage(_parentScene, NM_PRIORITY_CHANGE, 1010); break; } return messageResult; @@ -979,7 +979,7 @@ uint32 AsScene2812Rope::handleMessage(int messageNum, const MessageParam ¶m, uint32 AsScene2812Rope::hmRopingDown(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } @@ -987,7 +987,7 @@ uint32 AsScene2812Rope::hmRopingDown(int messageNum, const MessageParam ¶m, } void AsScene2812Rope::stRopingDown() { - sendMessage(_parentScene, 0x4806, 0); + sendMessage(_parentScene, NM_KLAYMEN_USE_OBJECT, 0); startAnimation(0x9D098C23, 0, -1); SetMessageHandler(&AsScene2812Rope::hmRopingDown); } @@ -1002,7 +1002,7 @@ AsScene2812TrapDoor::AsScene2812TrapDoor(NeverhoodEngine *vm) uint32 AsScene2812TrapDoor::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: startAnimation(0x805D0029, 0, -1); playSound(0, 0xEA005F40); _newStickFrameIndex = STICK_LAST_FRAME; @@ -1023,10 +1023,10 @@ uint32 KmScene2801::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: GotoState(&Klaymen::stPickUpGeneric); break; case 0x4817: @@ -1039,10 +1039,10 @@ uint32 KmScene2801::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: GotoState(&Klaymen::stTurnToUse); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: GotoState(&Klaymen::stReturnFromUse); break; case 0x481F: @@ -1093,7 +1093,7 @@ uint32 KmScene2803::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4803: @@ -1114,10 +1114,10 @@ uint32 KmScene2803::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4818: startWalkToX(_dataResource.getPoint(param.asInteger()).x, false); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: GotoState(&Klaymen::stTurnToUse); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: GotoState(&Klaymen::stReturnFromUse); break; case 0x481F: @@ -1154,7 +1154,7 @@ uint32 KmScene2803Small::xHandleMessage(int messageNum, const MessageParam ¶ case 0x4800: startWalkToXSmall(param.asPoint().x); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stStandIdleSmall); break; case 0x4817: @@ -1198,9 +1198,9 @@ uint32 KmScene2803Small::xHandleMessage(int messageNum, const MessageParam ¶ uint32 KmScene2803Small::hmShrink(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender); switch (messageNum) { - case 0x100D: + case NM_ANIMATION_START: if (param.asInteger() == 0x80C110B5) - sendMessage(_parentScene, 0x482A, 0); + sendMessage(_parentScene, NM_MOVE_TO_BACK, 0); else if (param.asInteger() == 0x33288344) playSound(2, 0x10688664); break; @@ -1227,7 +1227,7 @@ KmScene2805::KmScene2805(NeverhoodEngine *vm, Scene *parentScene, int16 x, int16 uint32 KmScene2805::xHandleMessage(int messageNum, const MessageParam ¶m) { uint32 messageResult = 0; switch (messageNum) { - case 0x2000: + case NM_ANIMATION_UPDATE: _isSittingInTeleporter = param.asInteger() != 0; messageResult = 1; break; @@ -1235,7 +1235,7 @@ uint32 KmScene2805::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: if (_isSittingInTeleporter) GotoState(&Klaymen::stSitIdleTeleporter); else @@ -1245,11 +1245,11 @@ uint32 KmScene2805::xHandleMessage(int messageNum, const MessageParam ¶m) { setDoDeltaX(param.asInteger()); gotoNextStateExt(); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stTurnToUseInTeleporter); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: if (_isSittingInTeleporter) GotoState(&Klaymen::stReturnFromUseInTeleporter); break; @@ -1301,7 +1301,7 @@ uint32 KmScene2806::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4804: @@ -1310,7 +1310,7 @@ uint32 KmScene2806::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x480D: GotoState(&Klaymen::stPullCord); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 0) GotoState(&Klaymen::stPressButtonSide); break; @@ -1359,7 +1359,7 @@ uint32 KmScene2809::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4804: @@ -1368,7 +1368,7 @@ uint32 KmScene2809::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x480D: GotoState(&Klaymen::stPullCord); break; - case 0x4816: + case NM_KLAYMEN_PRESS_BUTTON: if (param.asInteger() == 0) GotoState(&Klaymen::stPressButtonSide); break; @@ -1404,7 +1404,7 @@ uint32 KmScene2810Small::xHandleMessage(int messageNum, const MessageParam ¶ case 0x4800: startWalkToXSmall(param.asPoint().x); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stStandIdleSmall); break; case 0x4817: @@ -1453,7 +1453,7 @@ uint32 KmScene2810::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4803: @@ -1464,7 +1464,7 @@ uint32 KmScene2810::xHandleMessage(int messageNum, const MessageParam ¶m) { if (param.asInteger() == 3) GotoState(&Klaymen::stFinishGrow); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: GotoState(&Klaymen::stPickUpGeneric); break; case 0x4817: @@ -1545,14 +1545,14 @@ uint32 KmScene2812::xHandleMessage(int messageNum, const MessageParam ¶m) { case 0x4800: startWalkToX(param.asPoint().x, false); break; - case 0x4004: + case NM_KLAYMEN_STAND_IDLE: GotoState(&Klaymen::stTryStandIdle); break; case 0x4805: _destY = param.asInteger(); GotoState(&Klaymen::stJumpToGrabFall); break; - case 0x4812: + case NM_KLAYMEN_PICKUP: if (param.asInteger() == 2) GotoState(&Klaymen::stPickUpNeedle); else if (param.asInteger() == 1) @@ -1564,7 +1564,7 @@ uint32 KmScene2812::xHandleMessage(int messageNum, const MessageParam ¶m) { setDoDeltaX(param.asInteger()); gotoNextStateExt(); break; - case 0x481A: + case NM_KLAYMEN_INSERT_DISK: GotoState(&Klaymen::stInsertDisk); break; case 0x481B: @@ -1573,10 +1573,10 @@ uint32 KmScene2812::xHandleMessage(int messageNum, const MessageParam ¶m) { else startWalkToAttachedSpriteXDistance(param.asPoint().x); break; - case 0x481D: + case NM_KLAYMEN_TURN_TO_USE: GotoState(&Klaymen::stTurnToUse); break; - case 0x481E: + case NM_KLAYMEN_RETURN_FROM_USE: GotoState(&Klaymen::stReturnFromUse); break; case 0x4820: @@ -1594,7 +1594,7 @@ uint32 KmScene2812::xHandleMessage(int messageNum, const MessageParam ¶m) { GotoState(&Klaymen::stStartClimbLadderUp); break; case 0x4823: - sendMessage(_parentScene, 0x2002, 0); + sendMessage(_parentScene, NM_POSITION_CHANGE, 0); GotoState(&Klaymen::stClimbLadderHalf); break; case 0x482D: diff --git a/engines/neverhood/modules/module2900.cpp b/engines/neverhood/modules/module2900.cpp index bb0b69f35d..ca734972ca 100644 --- a/engines/neverhood/modules/module2900.cpp +++ b/engines/neverhood/modules/module2900.cpp @@ -211,11 +211,11 @@ void Scene2901::update() { uint32 Scene2901::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) leaveScene((uint32)-1); break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (_currLocationButtonNum != _selectedButtonNum) leaveScene(_selectedButtonNum); break; diff --git a/engines/neverhood/modules/module3000.cpp b/engines/neverhood/modules/module3000.cpp index a12776611e..dc6fb984ef 100644 --- a/engines/neverhood/modules/module3000.cpp +++ b/engines/neverhood/modules/module3000.cpp @@ -552,13 +552,13 @@ void Scene3009::update() { uint32 Scene3009::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if ((param.asPoint().x <= 20 || param.asPoint().x >= 620) && !getGlobalVar(V_CANNON_RAISED)) { setGlobalVar(V_CANNON_TARGET_STATUS, 0); leaveScene(0); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (!getGlobalVar(V_CANNON_RAISED)) { if (!getGlobalVar(V_WALL_BROKEN)) { _cannonTargetStatus = kCTSBreakWall; @@ -581,7 +581,7 @@ uint32 Scene3009::handleMessage(int messageNum, const MessageParam ¶m, Entit case 0x2001: _lockSymbolsPart1Countdown = 24; break; - case 0x2002: + case NM_POSITION_CHANGE: // Raise/lower the cannon if (!getGlobalVar(V_CANNON_TURNED) && !_isTurning) { if (getGlobalVar(V_CANNON_RAISED)) { @@ -731,7 +731,7 @@ void Scene3010::update() { uint32 Scene3010::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if ((param.asPoint().x <= 20 || param.asPoint().x >= 620) && _countdown == 0 && !_checkUnlocked) { if (!_boltUnlocking[0] && !_boltUnlocking[1] && !_boltUnlocking[2]) { showMouse(false); @@ -749,7 +749,7 @@ uint32 Scene3010::handleMessage(int messageNum, const MessageParam ¶m, Entit } } break; - case 0x2000: + case NM_ANIMATION_UPDATE: if (!_boltUnlocked[param.asInteger()] && !_checkUnlocked && _countdown == 0) { _asDeadBolts[param.asInteger()]->unlock(false); _boltUnlocking[param.asInteger()] = true; @@ -769,7 +769,7 @@ uint32 Scene3010::handleMessage(int messageNum, const MessageParam ¶m, Entit _doorUnlocked = true; } break; - case 0x2002: + case NM_POSITION_CHANGE: if (!_checkUnlocked && _countdown == 0) { _asDeadBolts[param.asInteger()]->lock(); } @@ -853,12 +853,12 @@ void Scene3011::update() { uint32 Scene3011::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) { leaveScene(0); } break; - case 0x2000: + case NM_ANIMATION_UPDATE: _buttonClicked = true; if (_countdown == 0) _countdown = 1; diff --git a/engines/neverhood/modules/module3000_sprites.cpp b/engines/neverhood/modules/module3000_sprites.cpp index 7d0162d7d0..3c0c5fe209 100644 --- a/engines/neverhood/modules/module3000_sprites.cpp +++ b/engines/neverhood/modules/module3000_sprites.cpp @@ -261,7 +261,7 @@ uint32 SsScene3009SymbolArrow::handleMessage(int messageNum, const MessageParam _countdown = 2; loadSprite(kSsScene3009SymbolArrowFileHashes1[_index], kSLFDefDrawOffset); playSound(0); - sendMessage(_asSymbol, 0x2005, _incrDecr); + sendMessage(_asSymbol, NM_KLAYMEN_CLIMB_LADDER, _incrDecr); } messageResult = 1; break; @@ -294,7 +294,7 @@ uint32 AsScene3009VerticalIndicator::handleMessage(int messageNum, const Message switch (messageNum) { case 0x1011: if (_enabled) { - sendMessage(_parentScene, 0x2002, 0); + sendMessage(_parentScene, NM_POSITION_CHANGE, 0); } messageResult = 1; break; @@ -388,7 +388,7 @@ AsScene3009Symbol::AsScene3009Symbol(NeverhoodEngine *vm, Scene3009 *parentScene uint32 AsScene3009Symbol::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x2005: + case NM_KLAYMEN_CLIMB_LADDER: if (param.asInteger()) { if (_symbolIndex == 11) _symbolIndex = 0; @@ -501,7 +501,7 @@ uint32 SsScene3010DeadBoltButton::handleMessage(int messageNum, const MessagePar _buttonLocked = true; sendMessage(_parentScene, 0x2000, _buttonIndex); } else { - sendMessage(_parentScene, 0x2002, _buttonIndex); + sendMessage(_parentScene, NM_POSITION_CHANGE, _buttonIndex); } _needRefresh = true; updatePosition(); @@ -565,7 +565,7 @@ void AsScene3010DeadBolt::update() { uint32 AsScene3010DeadBolt::hmAnimation(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x3002: + case NM_ANIMATION_STOP: gotoNextState(); break; } diff --git a/engines/neverhood/navigationscene.cpp b/engines/neverhood/navigationscene.cpp index a15c00de07..adbb6aef7a 100644 --- a/engines/neverhood/navigationscene.cpp +++ b/engines/neverhood/navigationscene.cpp @@ -106,19 +106,19 @@ void NavigationScene::update() { uint32 NavigationScene::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { switch (messageNum) { - case 0x0000: + case NM_MOUSE_MOVE: if (_interactive) sendMessage(_mouseCursor, 0x4002, param); break; - case 0x0001: + case NM_MOUSE_CLICK: if (_interactive) handleNavigation(param.asPoint()); break; - case 0x0009: + case NM_KEYPRESS_SPACE: if (!_interactive) _smackerDone = true; break; - case 0x3002: + case NM_ANIMATION_STOP: _smackerDone = true; break; } diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp index 9a7e87ac8d..b8cde73e81 100644 --- a/engines/neverhood/scene.cpp +++ b/engines/neverhood/scene.cpp @@ -283,11 +283,11 @@ void Scene::leaveScene(uint32 result) { uint32 Scene::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { switch (messageNum) { - case 0x0000: // mouse moved + case NM_MOUSE_MOVE: if (_mouseCursor && _mouseCursor->hasMessageHandler()) sendMessage(_mouseCursor, 0x4002, param); break; - case 0x0001: // mouse clicked + case NM_MOUSE_CLICK: _mouseClicked = true; _mouseClickPos = param.asPoint(); break; @@ -301,7 +301,7 @@ uint32 Scene::handleMessage(int messageNum, const MessageParam ¶m, Entity *s if (_messageListIndex == _messageListCount) { // If the current message list was processed completely, // sent Klaymen into the idle state. - sendMessage(_klaymen, 0x4004, 0); + sendMessage(_klaymen, NM_KLAYMEN_STAND_IDLE, 0); } else { // Else continue with the next message in the current message list processMessageList(); @@ -314,23 +314,21 @@ uint32 Scene::handleMessage(int messageNum, const MessageParam ¶m, Entity *s if (_isKlaymenBusy) { _isKlaymenBusy = false; _messageList = NULL; - sendMessage(_klaymen, 0x4004, 0); + sendMessage(_klaymen, NM_KLAYMEN_STAND_IDLE, 0); } break; - case 0x101D: - // Hide the mouse cursor + case NM_MOUSE_HIDE: if (_mouseCursor) { _mouseCursorWasVisible = _mouseCursor->getSurface()->getVisible(); _mouseCursor->getSurface()->setVisible(false); } break; - case 0x101E: - // Show the mouse cursor + case NM_MOUSE_SHOW: if (_mouseCursorWasVisible && _mouseCursor) { _mouseCursor->getSurface()->setVisible(true); } break; - case 0x1022: + case NM_PRIORITY_CHANGE: // Set the sender's surface priority setSurfacePriority(((Sprite*)sender)->getSurface(), param.asInteger()); break; @@ -451,7 +449,7 @@ void Scene::processMessageList() { _isKlaymenBusy = true; sendPointMessage(_klaymen, 0x4001, _mouseClickPos); } else if (messageNum == 0x100D) { - if (this->hasMessageHandler() && sendMessage(this, 0x100D, messageParam) != 0) + if (this->hasMessageHandler() && sendMessage(this, NM_ANIMATION_START, messageParam) != 0) continue; } else if (messageNum == 0x101A) { _messageListStatus = 0; @@ -485,7 +483,7 @@ void Scene::cancelMessageList() { _isKlaymenBusy = false; _messageList = NULL; _canAcceptInput = true; - sendMessage(_klaymen, 0x4004, 0); + sendMessage(_klaymen, NM_KLAYMEN_STAND_IDLE, 0); } void Scene::setRectList(uint32 id) { @@ -617,7 +615,7 @@ StaticScene::StaticScene(NeverhoodEngine *vm, Module *parentModule, uint32 backg uint32 StaticScene::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0001: + case NM_MOUSE_CLICK: if (param.asPoint().x <= 20 || param.asPoint().x >= 620) leaveScene(0); break; diff --git a/engines/neverhood/smackerplayer.cpp b/engines/neverhood/smackerplayer.cpp index 187939faee..4b4982f68e 100644 --- a/engines/neverhood/smackerplayer.cpp +++ b/engines/neverhood/smackerplayer.cpp @@ -204,7 +204,7 @@ void SmackerPlayer::update() { } else if (!_keepLastFrame) { // Inform the scene about the end of the video playback if (_scene) - sendMessage(_scene, 0x3002, 0); + sendMessage(_scene, NM_ANIMATION_STOP, 0); _videoDone = true; } else { rewind(); diff --git a/engines/neverhood/smackerscene.cpp b/engines/neverhood/smackerscene.cpp index d9d032a3b5..c3915200b5 100644 --- a/engines/neverhood/smackerscene.cpp +++ b/engines/neverhood/smackerscene.cpp @@ -104,15 +104,15 @@ void SmackerScene::update() { uint32 SmackerScene::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Scene::handleMessage(messageNum, param, sender); switch (messageNum) { - case 0x0009: + case NM_KEYPRESS_SPACE: if ((_videoPlayedBefore && _canSkip) || (_canAbort && _canSkip)) _playNextVideoFlag = true; break; - case 0x000C: + case NM_KEYPRESS_ESC: if (_canAbort) sendMessage(_parentModule, 0x1009, 0); break; - case 0x3002: + case NM_ANIMATION_STOP: _playNextVideoFlag = true; break; } diff --git a/engines/neverhood/sprite.cpp b/engines/neverhood/sprite.cpp index 1a432461fb..05fc9b256f 100644 --- a/engines/neverhood/sprite.cpp +++ b/engines/neverhood/sprite.cpp @@ -372,7 +372,7 @@ void AnimatedSprite::updateFrameIndex() { } else { // Inform self about end of current animation // The caller can then e.g. set a new animation fileHash - sendMessage(this, 0x3002, 0); + sendMessage(this, NM_ANIMATION_STOP, 0); if (_newAnimFileHash == 0) _currFrameIndex = 0; } @@ -380,7 +380,7 @@ void AnimatedSprite::updateFrameIndex() { if (_currFrameIndex > 0) { _currFrameIndex--; } else { - sendMessage(this, 0x3002, 0); + sendMessage(this, NM_ANIMATION_STOP, 0); if (_newAnimFileHash == 0) _currFrameIndex = _lastFrameIndex; } @@ -399,7 +399,7 @@ void AnimatedSprite::updateFrameInfo() { updateBounds(); _needRefresh = true; if (frameInfo.frameHash != 0) - sendMessage(this, 0x100D, frameInfo.frameHash); + sendMessage(this, NM_ANIMATION_START, frameInfo.frameHash); } void AnimatedSprite::createSurface1(uint32 fileHash, int surfacePriority) { diff --git a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp index d62b069e46..190984f8bc 100644 --- a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp +++ b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp @@ -124,11 +124,6 @@ void Prehistoric::setUpAIRules() { AIHasItemCondition *hasLogCondition = new AIHasItemCondition(kHistoricalLog); AIRule *rule = new AIRule(hasLogCondition, doneAction); g_AIArea->addAIRule(rule); - } else { - AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP25W", false); - AIHasItemCondition *hasLogCondition = new AIHasItemCondition(kHistoricalLog); - AIRule *rule = new AIRule(hasLogCondition, messageAction); - g_AIArea->addAIRule(rule); } if (!_vm->isOldDemo()) { @@ -167,6 +162,13 @@ void Prehistoric::setUpAIRules() { rule = new AIRule(timerCondition, messageAction); g_AIArea->addAIRule(rule); } + + if (!_vm->isDemo()) { + AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP25W", false); + AIHasItemCondition *hasLogCondition = new AIHasItemCondition(kHistoricalLog); + AIRule *rule = new AIRule(hasLogCondition, messageAction); + g_AIArea->addAIRule(rule); + } } } @@ -202,11 +204,11 @@ TimeValue Prehistoric::getViewTime(const RoomID room, const DirectionConstant di void Prehistoric::findSpotEntry(const RoomID room, const DirectionConstant direction, SpotFlags flags, SpotTable::Entry &entry) { Neighborhood::findSpotEntry(room, direction, flags, entry); + // The original strangely disabled the loop for the two volcano spots: + // (kPrehistoric01, kSouth) and (kPrehistoric25, kSouth) + // We don't do that here. + switch (MakeRoomView(room, direction)) { - case MakeRoomView(kPrehistoric01, kSouth): - case MakeRoomView(kPrehistoric25, kSouth): - entry.clear(); - break; case MakeRoomView(kPrehistoric01, kEast): if (GameState.getPrehistoricSeenFlyer1()) entry.clear(); diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp index 3bd29ce8dd..0148470cd5 100644 --- a/engines/pegasus/pegasus.cpp +++ b/engines/pegasus/pegasus.cpp @@ -429,7 +429,7 @@ void PegasusEngine::removeTimeBase(TimeBase *timeBase) { _timeBases.remove(timeBase); } -bool PegasusEngine::loadFromStream(Common::ReadStream *stream) { +bool PegasusEngine::loadFromStream(Common::SeekableReadStream *stream) { // Dispose currently running stuff useMenu(0); useNeighborhood(0); @@ -520,8 +520,36 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) { performJump(GameState.getCurrentNeighborhood()); // AI rules - if (g_AIArea) - g_AIArea->readAIRules(stream); + if (g_AIArea) { + // HACK: clone2727 accidentally changed some Prehistoric code to output some bad saves + // at one point. That's fixed now, but I don't want to leave the other users high + // and dry. + if (GameState.getCurrentNeighborhood() == kPrehistoricID && !isDemo()) { + uint32 pos = stream->pos(); + stream->seek(0x208); + uint32 roomView = stream->readUint32BE(); + stream->seek(pos); + + if (roomView == 0x30019) { + // This is a bad save -> Let's fix the data + // One byte should be put at the end instead + uint32 size = stream->size() - pos; + byte *data = (byte *)malloc(size); + data[0] = stream->readByte(); + data[1] = stream->readByte(); + data[2] = stream->readByte(); + byte wrongData = stream->readByte(); + stream->read(data + 3, size - 4); + data[size - 1] = wrongData; + Common::MemoryReadStream tempStream(data, size, DisposeAfterUse::YES); + g_AIArea->readAIRules(&tempStream); + } else { + g_AIArea->readAIRules(stream); + } + } else { + g_AIArea->readAIRules(stream); + } + } startNeighborhood(); diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h index 07e6d8f761..59637e38df 100644 --- a/engines/pegasus/pegasus.h +++ b/engines/pegasus/pegasus.h @@ -249,7 +249,7 @@ private: Common::List<TimeBase *> _timeBases; // Save/Load - bool loadFromStream(Common::ReadStream *stream); + bool loadFromStream(Common::SeekableReadStream *stream); bool writeToStream(Common::WriteStream *stream, int saveType); void loadFromContinuePoint(); void writeContinueStream(Common::WriteStream *stream); diff --git a/engines/sci/engine/object.cpp b/engines/sci/engine/object.cpp index b28026b71f..6f219b388e 100644 --- a/engines/sci/engine/object.cpp +++ b/engines/sci/engine/object.cpp @@ -175,6 +175,7 @@ bool Object::initBaseObject(SegManager *segMan, reg_t addr, bool doInitSuperClas _variables.resize(baseObj->getVarCount()); // Copy base from species class, as we need its selector IDs _baseObj = baseObj->_baseObj; + assert(_baseObj); if (doInitSuperClass) initSuperClass(segMan, addr); diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 16b88b5672..ce9a672572 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -219,25 +219,30 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) { syncArray<Class>(s, _classTable); - // Now that all scripts are loaded, init their objects - for (uint i = 0; i < _heap.size(); i++) { - if (!_heap[i] || _heap[i]->getType() != SEG_TYPE_SCRIPT) - continue; + // Now that all scripts are loaded, init their objects. + // Just like in Script::initializeObjectsSci0, we do two passes + // in case an object is loaded before its base. + int passes = getSciVersion() < SCI_VERSION_1_1 ? 2 : 1; + for (int pass = 1; pass <= passes; ++pass) { + for (uint i = 0; i < _heap.size(); i++) { + if (!_heap[i] || _heap[i]->getType() != SEG_TYPE_SCRIPT) + continue; - Script *scr = (Script *)_heap[i]; - scr->syncLocalsBlock(this); + Script *scr = (Script *)_heap[i]; + scr->syncLocalsBlock(this); - ObjMap objects = scr->getObjectMap(); - for (ObjMap::iterator it = objects.begin(); it != objects.end(); ++it) { - reg_t addr = it->_value.getPos(); - Object *obj = scr->scriptObjInit(addr, false); + ObjMap objects = scr->getObjectMap(); + for (ObjMap::iterator it = objects.begin(); it != objects.end(); ++it) { + reg_t addr = it->_value.getPos(); + Object *obj = scr->scriptObjInit(addr, false); - if (getSciVersion() < SCI_VERSION_1_1) { - if (!obj->initBaseObject(this, addr, false)) { - // TODO/FIXME: This should not be happening at all. It might indicate a possible issue - // with the garbage collector. It happens for example in LSL5 (German, perhaps English too). - warning("Failed to locate base object for object at %04X:%04X; skipping", PRINT_REG(addr)); - objects.erase(addr.toUint16()); + if (pass == 2) { + if (!obj->initBaseObject(this, addr, false)) { + // TODO/FIXME: This should not be happening at all. It might indicate a possible issue + // with the garbage collector. It happens for example in LSL5 (German, perhaps English too). + warning("Failed to locate base object for object at %04X:%04X; skipping", PRINT_REG(addr)); + objects.erase(addr.toUint16()); + } } } } diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp index e776c8fb3a..8f05cc1453 100644 --- a/engines/sci/engine/script_patches.cpp +++ b/engines/sci/engine/script_patches.cpp @@ -85,10 +85,12 @@ static const char *const selectorNameTable[] = { "new", // system selector "curEvent", // system selector "disable", // system selector + "doit", // system selector "show", // system selector "x", // system selector "cel", // system selector "setMotion", // system selector + "overlay", // system selector "deskSarg", // Gabriel Knight "localize", // Freddy Pharkas "put", // Police Quest 1 VGA @@ -108,10 +110,12 @@ enum ScriptPatcherSelectors { SELECTOR_new, SELECTOR_curEvent, SELECTOR_disable, + SELECTOR_doit, SELECTOR_show, SELECTOR_x, SELECTOR_cel, SELECTOR_setMotion, + SELECTOR_overlay, SELECTOR_deskSarg, SELECTOR_localize, SELECTOR_put, @@ -143,25 +147,25 @@ enum ScriptPatcherSelectors { // Responsible method: fawaz::handleEvent // Fixes bug: #6402 static const uint16 camelotSignaturePeepingTom[] = { - 0x72, SIG_MAGICDWORD, SIG_UINT16 + 0x7e, 0x07, // lofsa fawaz <-- start of proper initializion code + 0x72, SIG_MAGICDWORD, SIG_UINT16(0x077e), // lofsa fawaz <-- start of proper initializion code 0xa1, 0xb9, // sag b9h - SIG_ADDTOOFFSET +571, // skip 571 bytes + SIG_ADDTOOFFSET(+571), // skip 571 bytes 0x39, 0x7a, // pushi 7a <-- initialization code when walking automatically 0x78, // push1 0x7a, // push2 - 0x38, SIG_UINT16 + 0xa9, 0x00, // pushi 00a9 - script 169 + 0x38, SIG_UINT16(0x00a9), // + 0xa9, 0x00, // pushi 00a9 - script 169 0x78, // push1 0x43, 0x02, 0x04, // call kScriptID 0x36, // push 0x81, 0x00, // lag 00 0x4a, 0x06, // send 06 - 0x32, SIG_UINT16 + 0x20, 0x05, // jmp [end of fawaz::handleEvent] + 0x32, SIG_UINT16(0x0520), // jmp [end of fawaz::handleEvent] SIG_END }; static const uint16 camelotPatchPeepingTom[] = { - PATCH_ADDTOOFFSET +576, - 0x32, PATCH_UINT16 + 0xbd, 0xfd, // jmp to fawaz::doit / properly init peepingTom code + PATCH_ADDTOOFFSET(+576), + 0x32, PATCH_UINT16(0xfdbd), // jmp to fawaz::doit / properly init peepingTom code PATCH_END }; @@ -192,12 +196,12 @@ static const uint16 ecoquest1SignatureStayAndHelp[] = { 0x76, // push0 0x45, 0x01, 0x00, // callb export1 from script 0 (switching control off) SIG_MAGICDWORD, - 0x38, SIG_UINT16 + 0x22, 0x01, // pushi 0122 + 0x38, SIG_UINT16(0x0122), // pushi 0122 0x78, // push1 0x76, // push0 0x81, 0x00, // lag global[0] 0x4a, 0x06, // send 06 - call ego::setMotion(0) - 0x39, SIG_SELECTOR8 + SELECTOR_init, // pushi "init" + 0x39, SIG_SELECTOR8(init), // pushi "init" 0x39, 0x04, // pushi 04 0x76, // push0 0x76, // push0 @@ -216,19 +220,19 @@ static const uint16 ecoquest1PatchStayAndHelp[] = { 0x2f, 0x22, // bt [next state] (this optimization saves 6 bytes) 0x39, 0x00, // pushi 0 (wasting 1 byte here) 0x45, 0x01, 0x00, // callb export1 from script 0 (switching control off) - 0x38, PATCH_UINT16 + 0x22, 0x01, // pushi 0122 + 0x38, PATCH_UINT16(0x0122), // pushi 0122 0x78, // push1 0x76, // push0 0x81, 0x00, // lag global[0] 0x4a, 0x06, // send 06 - call ego::setMotion(0) - 0x39, PATCH_SELECTOR8 + SELECTOR_init, // pushi "init" + 0x39, PATCH_SELECTOR8(init), // pushi "init" 0x39, 0x06, // pushi 06 0x39, 0x02, // pushi 02 (additional 2 bytes) 0x76, // push0 0x76, // push0 0x39, 0x17, // pushi 17 0x7c, // pushSelf - 0x38, PATCH_UINT16 + 0x80, 0x02, // pushi 280 (additional 3 bytes) + 0x38, PATCH_UINT16(0x0280), // pushi 280 (additional 3 bytes) 0x51, 0x82, // class EcoNarrator 0x4a, 0x10, // send 10 - call EcoNarrator::init(2, 0, 0, 23, self, 640) PATCH_END @@ -259,14 +263,14 @@ static const uint16 ecoquest2SignatureEcorder[] = { 0x39, 0x66, // pushi 66 0x39, 0x17, // pushi 17 0x39, 0x69, // pushi 69 - 0x38, PATCH_UINT16 + 0x31, 0x26, // pushi 2631 + 0x38, PATCH_UINT16(0x2631), // pushi 2631 0x39, 0x6a, // pushi 6a 0x39, 0x64, // pushi 64 0x43, 0x1b, 0x14, // call kDisplay 0x35, 0x0a, // ldi 0a 0x65, 0x20, // aTop ticks 0x33, // jmp [end] - SIG_ADDTOOFFSET +1, // [skip 1 byte] + SIG_ADDTOOFFSET(+1), // [skip 1 byte] 0x3c, // dup 0x35, 0x03, // ldi 03 0x1a, // eq? @@ -278,21 +282,21 @@ static const uint16 ecoquest2PatchEcorder[] = { 0x2f, 0x02, // bt [to pushi 07] 0x3a, // toss 0x48, // ret - 0x38, PATCH_UINT16 + 0x07, 0x00, // pushi 07 (parameter count) (waste 1 byte) + 0x38, PATCH_UINT16(0x0007), // pushi 07 (parameter count) (waste 1 byte) 0x39, 0x0b, // push (FillBoxAny) 0x39, 0x1d, // pushi 29d 0x39, 0x73, // pushi 115d 0x39, 0x5e, // pushi 94d - 0x38, PATCH_UINT16 + 0xd7, 0x00, // pushi 215d + 0x38, PATCH_UINT16(0x00d7), // pushi 215d 0x78, // push1 (visual screen) - 0x38, PATCH_UINT16 + 0x17, 0x00, // pushi 17 (color) (waste 1 byte) + 0x38, PATCH_UINT16(0x0017), // pushi 17 (color) (waste 1 byte) 0x43, 0x6c, 0x0e, // call kGraph - 0x38, PATCH_UINT16 + 0x05, 0x00, // pushi 05 (parameter count) (waste 1 byte) + 0x38, PATCH_UINT16(0x0005), // pushi 05 (parameter count) (waste 1 byte) 0x39, 0x0c, // pushi 12d (UpdateBox) 0x39, 0x1d, // pushi 29d 0x39, 0x73, // pushi 115d 0x39, 0x5e, // pushi 94d - 0x38, PATCH_UINT16 + 0xd7, 0x00, // pushi 215d + 0x38, PATCH_UINT16(0x00d7), // pushi 215d 0x43, 0x6c, 0x0a, // call kGraph PATCH_END }; @@ -304,7 +308,7 @@ static const uint16 ecoquest2PatchEcorder[] = { // the function otherwise. // Fixes bug: #6467 static const uint16 ecoquest2SignatureEcorderTutorial[] = { - 0x30, SIG_UINT16 + 0x23, 0x00, // bnt [next state] + 0x30, SIG_UINT16(0x0023), // bnt [next state] 0x39, 0x0a, // pushi 0a 0x5b, 0x04, 0x1f, // lea temp[1f] 0x36, // push @@ -315,7 +319,7 @@ static const uint16 ecoquest2SignatureEcorderTutorial[] = { 0x39, 0x66, // pushi 66 0x39, 0x17, // pushi 17 0x39, 0x69, // pushi 69 - 0x38, SIG_UINT16 + 0x31, 0x26, // pushi 2631 + 0x38, SIG_UINT16(0x2631), // pushi 2631 0x39, 0x6a, // pushi 6a 0x39, 0x64, // pushi 64 0x43, 0x1b, 0x14, // call kDisplay @@ -336,7 +340,7 @@ static const uint16 ecoquest2PatchEcorderTutorial[] = { 0x39, 0x1d, // pushi 29d 0x39, 0x73, // pushi 115d 0x39, 0x5e, // pushi 94d - 0x38, PATCH_UINT16 + 0xd7, 0x00, // pushi 215d + 0x38, PATCH_UINT16(0x00d7), // pushi 215d 0x78, // push1 (visual screen) 0x39, 0x17, // pushi 17 (color) 0x43, 0x6c, 0x0e, // call kGraph @@ -348,14 +352,14 @@ static const uint16 ecoquest2PatchEcorderTutorial[] = { 0x39, 0x1d, // pushi 29d 0x39, 0x73, // pushi 115d 0x39, 0x5e, // pushi 94d - 0x38, PATCH_UINT16 + 0xd7, 0x00, // pushi 215d + 0x38, PATCH_UINT16(0x00d7), // pushi 215d 0x43, 0x6c, 0x0a, // call kGraph // We are out of bytes to patch at this point, // so we skip 494 (0x1EE) bytes to reuse this code: // ldi 1e // aTop 20 // jmp 030e (jump to end) - 0x32, PATCH_UINT16 + 0xee, 0x01, // skip 494 (0x1EE) bytes + 0x32, PATCH_UINT16(0x01ee), // skip 494 (0x1EE) bytes PATCH_END }; @@ -373,19 +377,19 @@ static const SciScriptPatcherEntry ecoquest2Signatures[] = { // event handling was slightly different there, so it was never discovered. // Fixes bug: #5120 static const uint16 fanmadeSignatureInfiniteLoop[] = { - 0x38, SIG_UINT16 + 0x4c, 0x00, // pushi 004c + 0x38, SIG_UINT16(0x004c), // pushi 004c 0x39, 0x00, // pushi 00 0x87, 0x01, // lap 01 0x4b, 0x04, // send 04 SIG_MAGICDWORD, 0x18, // not - 0x30, SIG_UINT16 + 0x2f, 0x00, // bnt 002f [06a5] --> jmp ffbc [0664] --> BUG! infinite loop + 0x30, SIG_UINT16(0x002f), // bnt 002f [06a5] --> jmp ffbc [0664] --> BUG! infinite loop SIG_END }; static const uint16 fanmadePatchInfiniteLoop[] = { - PATCH_ADDTOOFFSET | +10, - 0x30, SIG_UINT16 + 0x32, 0x00, // bnt 0032 [06a8] --> pushi 004c + PATCH_ADDTOOFFSET(+10), + 0x30, SIG_UINT16(0x0032), // bnt 0032 [06a8] --> pushi 004c PATCH_END }; @@ -417,9 +421,9 @@ static const uint16 freddypharkasSignatureScoreDisposal[] = { }; static const uint16 freddypharkasPatchScoreDisposal[] = { - 0x34, PATCH_UINT16 + 0x00, 0x00, // ldi 0000 - 0x34, PATCH_UINT16 + 0x00, 0x00, // ldi 0000 - 0x34, PATCH_UINT16 + 0x00, 0x00, // ldi 0000 + 0x34, PATCH_UINT16(0x0000), // ldi 0000 + 0x34, PATCH_UINT16(0x0000), // ldi 0000 + 0x34, PATCH_UINT16(0x0000), // ldi 0000 PATCH_END }; @@ -432,7 +436,7 @@ static const uint16 freddypharkasPatchScoreDisposal[] = { // Applies to at least: English PC-CD // Responsible method: rm235::init and sEnterFrom500::changeState static const uint16 freddypharkasSignatureCanisterHang[] = { - 0x38, SIG_SELECTOR16 + SELECTOR_disable, // pushi disable + 0x38, SIG_SELECTOR16(disable), // pushi disable 0x7a, // push2 SIG_MAGICDWORD, 0x39, 0x07, // pushi 07 @@ -443,11 +447,11 @@ static const uint16 freddypharkasSignatureCanisterHang[] = { }; static const uint16 freddypharkasPatchCanisterHang[] = { - PATCH_ADDTOOFFSET | +3, + PATCH_ADDTOOFFSET(+3), 0x78, // push1 - PATCH_ADDTOOFFSET | +2, + PATCH_ADDTOOFFSET(+2), 0x33, 0x00, // ldi 00 (waste 2 bytes) - PATCH_ADDTOOFFSET | +3, + PATCH_ADDTOOFFSET(+3), 0x06, // send 06 - call IconBar::disable(7) PATCH_END }; @@ -464,15 +468,15 @@ static const uint16 freddypharkasPatchCanisterHang[] = { // Responsible method: lowerLadder::doit and highLadder::doit static const uint16 freddypharkasSignatureLadderEvent[] = { 0x39, SIG_MAGICDWORD, - SIG_SELECTOR8 + SELECTOR_new, // pushi new + SIG_SELECTOR8(new), // pushi new 0x76, // push0 - 0x38, SIG_SELECTOR16 + SELECTOR_curEvent, // pushi curEvent + 0x38, SIG_SELECTOR16(curEvent), // pushi curEvent 0x76, // push0 0x81, 0x50, // lag global[50] 0x4a, 0x04, // send 04 - read User::curEvent 0x4a, 0x04, // send 04 - call curEvent::new 0xa5, 0x00, // sat temp[0] - 0x38, SIG_SELECTOR16 + SELECTOR_localize, + 0x38, SIG_SELECTOR16(localize), 0x76, // push0 0x4a, 0x04, // send 04 - call curEvent::localize SIG_END @@ -480,9 +484,9 @@ static const uint16 freddypharkasSignatureLadderEvent[] = { static const uint16 freddypharkasPatchLadderEvent[] = { 0x34, 0x00, 0x00, // ldi 0000 (waste 3 bytes, overwrites first 2 pushes) - PATCH_ADDTOOFFSET | +8, + PATCH_ADDTOOFFSET(+8), 0xa5, 0x00, // sat temp[0] (waste 2 bytes, overwrites 2nd send) - PATCH_ADDTOOFFSET | +2, + PATCH_ADDTOOFFSET(+2), 0x34, 0x00, 0x00, // ldi 0000 0x34, 0x00, 0x00, // ldi 0000 (waste 6 bytes, overwrites last 3 opcodes) PATCH_END @@ -498,19 +502,19 @@ static const uint16 freddypharkasSignatureMacInventory[] = { 0x39, 0x23, // pushi 23 0x39, 0x74, // pushi 74 0x78, // push1 - 0x38, SIG_UINT16 + 0x74, 0x01, // pushi 0174 (on mac it's actually 0x01, 0x74) + 0x38, SIG_UINT16(0x0174), // pushi 0174 (on mac it's actually 0x01, 0x74) 0x85, 0x15, // lat 15 SIG_END }; static const uint16 freddypharkasPatchMacInventory[] = { 0x39, 0x02, // pushi 02 (now matches the DOS version) - PATCH_ADDTOOFFSET +23, + PATCH_ADDTOOFFSET(+23), 0x39, 0x04, // pushi 04 (now matches the DOS version) PATCH_END }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry freddypharkasSignatures[] = { { true, 0, "CD: score early disposal", 1, freddypharkasSignatureScoreDisposal, freddypharkasPatchScoreDisposal }, { true, 15, "Mac: broken inventory", 1, freddypharkasSignatureMacInventory, freddypharkasPatchMacInventory }, @@ -527,22 +531,22 @@ static const SciScriptPatcherEntry freddypharkasSignatures[] = { static const uint16 gk1SignatureDay6PoliceBeignet[] = { 0x35, 0x04, // ldi 04 0x1a, // eq? - 0x30, SIG_ADDTOOFFSET +2, // bnt [next state check] - 0x38, SIG_SELECTOR16 + SELECTOR_dispose, // pushi dispose + 0x30, SIG_ADDTOOFFSET(+2), // bnt [next state check] + 0x38, SIG_SELECTOR16(dispose), // pushi dispose 0x76, // push0 - 0x72, SIG_ADDTOOFFSET +2, // lofsa deskSarg - 0x4a, SIG_UINT16 + 0x04, 0x00, // send 04 + 0x72, SIG_ADDTOOFFSET(+2), // lofsa deskSarg + 0x4a, SIG_UINT16(0x0004), // send 04 SIG_MAGICDWORD, - 0x34, SIG_UINT16 + 0xdc, 0x00, // ldi 220 - 0x65, SIG_ADDTOOFFSET +1, // aTop cycles (1a for PC, 1c for Mac) + 0x34, SIG_UINT16(0x00dc), // ldi 220 + 0x65, SIG_ADDTOOFFSET(+1), // aTop cycles (1a for PC, 1c for Mac) 0x32, // jmp [end] SIG_END }; static const uint16 gk1PatchDay6PoliceBeignet[] = { - PATCH_ADDTOOFFSET +16, - 0x34, PATCH_UINT16 + 0x17, 0x00, // ldi 23 - 0x65, PATCH_GETORIGINALBYTEADJUST +20, +2, // aTop seconds (1c for PC, 1e for Mac) + PATCH_ADDTOOFFSET(+16), + 0x34, PATCH_UINT16(0x0017), // ldi 23 + 0x65, PATCH_GETORIGINALBYTEADJUST(+20, +2), // aTop seconds (1c for PC, 1e for Mac) PATCH_END }; @@ -553,18 +557,18 @@ static const uint16 gk1PatchDay6PoliceBeignet[] = { static const uint16 gk1SignatureDay6PoliceSleep[] = { 0x35, 0x08, // ldi 08 0x1a, // eq? - 0x31, SIG_ADDTOOFFSET +1, // bnt [next state check] + 0x31, SIG_ADDTOOFFSET(+1), // bnt [next state check] SIG_MAGICDWORD, - 0x34, SIG_UINT16 + 0xdc, 0x00, // ldi 220 - 0x65, SIG_ADDTOOFFSET +1, // aTop cycles (1a for PC, 1c for Mac) + 0x34, SIG_UINT16(0x00dc), // ldi 220 + 0x65, SIG_ADDTOOFFSET(+1), // aTop cycles (1a for PC, 1c for Mac) 0x32, // jmp [end] 0 }; static const uint16 gk1PatchDay6PoliceSleep[] = { - PATCH_ADDTOOFFSET +5, - 0x34, SIG_UINT16 + 0x2a, 0x00, // ldi 42 - 0x65, PATCH_GETORIGINALBYTEADJUST +9, +2, // aTop seconds (1c for PC, 1e for Mac) + PATCH_ADDTOOFFSET(+5), + 0x34, SIG_UINT16(0x002a), // ldi 42 + 0x65, PATCH_GETORIGINALBYTEADJUST(+9, +2), // aTop seconds (1c for PC, 1e for Mac) PATCH_END }; @@ -573,19 +577,19 @@ static const uint16 gk1PatchDay6PoliceSleep[] = { // Responsible method: startOfDay5::changeState static const uint16 gk1SignatureDay5PhoneFreeze[] = { 0x4a, - SIG_MAGICDWORD, SIG_UINT16 + 0x0c, 0x00, // send 0c + SIG_MAGICDWORD, SIG_UINT16(0x000c), // send 0c 0x35, 0x03, // ldi 03 - 0x65, SIG_ADDTOOFFSET +1, // aTop cycles - 0x32, SIG_ADDTOOFFSET +2, // jmp [end] + 0x65, SIG_ADDTOOFFSET(+1), // aTop cycles + 0x32, SIG_ADDTOOFFSET(+2), // jmp [end] 0x3c, // dup 0x35, 0x21, // ldi 21 SIG_END }; static const uint16 gk1PatchDay5PhoneFreeze[] = { - PATCH_ADDTOOFFSET +3, + PATCH_ADDTOOFFSET(+3), 0x35, 0x06, // ldi 01 - 0x65, PATCH_GETORIGINALBYTEADJUST +6, +6, // aTop ticks + 0x65, PATCH_GETORIGINALBYTEADJUST(+6, +6), // aTop ticks PATCH_END }; @@ -604,23 +608,23 @@ static const uint16 gk1SignatureInterrogationBug[] = { SIG_MAGICDWORD, 0x65, 0x4c, // aTop 4c 0x67, 0x50, // pTos 50 - 0x34, SIG_UINT16 + 0x10, 0x27, // ldi 2710 + 0x34, SIG_UINT16(0x2710), // ldi 2710 0x1e, // gt? 0x31, 0x08, // bnt 08 [05a0] 0x67, 0x50, // pTos 50 - 0x34, SIG_UINT16 + 0x10, 0x27, // ldi 2710 + 0x34, SIG_UINT16(0x2710), // ldi 2710 0x04, // sub 0x65, 0x50, // aTop 50 0x63, 0x50, // pToa 50 0x31, 0x15, // bnt 15 [05b9] 0x39, 0x0e, // pushi 0e 0x76, // push0 - 0x4a, SIG_UINT16 + 0x04, 0x00, // send 0004 + 0x4a, SIG_UINT16(0x0004), // send 0004 0xa5, 0x00, // sat 00 - 0x38, SIG_SELECTOR16 + SELECTOR_dispose, // pushi dispose + 0x38, SIG_SELECTOR16(dispose), // pushi dispose 0x76, // push0 0x63, 0x50, // pToa 50 - 0x4a, SIG_UINT16 + 0x04, 0x00, // send 0004 + 0x4a, SIG_UINT16(0x0004), // send 0004 0x85, 0x00, // lat 00 0x65, 0x50, // aTop 50 SIG_END @@ -634,24 +638,24 @@ static const uint16 gk1PatchInterrogationBug[] = { 0x76, // push0 0x4a, 0x04, 0x00, // send 0004 0xa5, 0x00, // sat 00 - 0x38, SIG_SELECTOR16 + SELECTOR_dispose, // pushi dispose + 0x38, SIG_SELECTOR16(dispose), // pushi dispose 0x76, // push0 0x63, 0x50, // pToa 50 0x4a, 0x04, 0x00, // send 0004 0x85, 0x00, // lat 00 0x65, 0x50, // aTop 50 0x67, 0x50, // pTos 50 - 0x34, PATCH_UINT16 + 0x10, 0x27, // ldi 2710 + 0x34, PATCH_UINT16(0x2710), // ldi 2710 0x1e, // gt? 0x31, 0x08, // bnt 08 [05b9] 0x67, 0x50, // pTos 50 - 0x34, PATCH_UINT16 + 0x10, 0x27, // ldi 2710 + 0x34, PATCH_UINT16(0x2710), // ldi 2710 0x04, // sub 0x65, 0x50, // aTop 50 PATCH_END }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry gk1Signatures[] = { { true, 51, "interrogation bug", 1, gk1SignatureInterrogationBug, gk1PatchInterrogationBug }, { true, 212, "day 5 phone freeze", 1, gk1SignatureDay5PhoneFreeze, gk1PatchDay5PhoneFreeze }, @@ -668,17 +672,17 @@ static const SciScriptPatcherEntry gk1Signatures[] = { // those cases. static const uint16 kq5SignatureCdHarpyVolume[] = { SIG_MAGICDWORD, - 0x80, SIG_UINT16 + 0x91, 0x01, // lag global[191h] + 0x80, SIG_UINT16(0x0191), // lag global[191h] 0x18, // not - 0x30, SIG_UINT16 + 0x2c, 0x00, // bnt [jump further] (jumping, if global 191h is 1) + 0x30, SIG_UINT16(0x002c), // bnt [jump further] (jumping, if global 191h is 1) 0x35, 0x01, // ldi 01 - 0xa0, SIG_UINT16 + 0x91, 0x01, // sag global[191h] (setting global 191h to 1) - 0x38, SIG_UINT16 + 0x7b, 0x01, // pushi 017b + 0xa0, SIG_UINT16(0x0191), // sag global[191h] (setting global 191h to 1) + 0x38, SIG_UINT16(0x017b), // pushi 017b 0x76, // push0 0x81, 0x01, // lag global[1] 0x4a, 0x04, // send 04 - read KQ5::masterVolume 0xa5, 0x03, // sat temp[3] (store volume in temp 3) - 0x38, SIG_UINT16 + 0x7b, 0x01, // pushi 017b + 0x38, SIG_UINT16(0x017b), // pushi 017b 0x76, // push0 0x81, 0x01, // lag global[1] 0x4a, 0x04, // send 04 - read KQ5::masterVolume @@ -689,17 +693,17 @@ static const uint16 kq5SignatureCdHarpyVolume[] = { }; static const uint16 kq5PatchCdHarpyVolume[] = { - 0x38, PATCH_UINT16 + 0x2f, 0x02, // pushi 022f (selector theVol) (3 new bytes) + 0x38, PATCH_UINT16(0x022f), // pushi 022f (selector theVol) (3 new bytes) 0x76, // push0 (1 new byte) 0x51, 0x88, // class SpeakTimer (2 new bytes) 0x4a, 0x04, // send 04 (2 new bytes) -> read SpeakTimer::theVol 0xa5, 0x03, // sat temp[3] (2 new bytes) -> write to temp 3 - 0x80, PATCH_UINT16 + 0x91, 0x01, // lag global[191h] + 0x80, PATCH_UINT16(0x0191), // lag global[191h] // saving 1 byte due optimization - 0x2e, PATCH_UINT16 + 0x23, 0x00, // bt [jump further] (jumping, if global 191h is 1) + 0x2e, PATCH_UINT16(0x0023), // bt [jump further] (jumping, if global 191h is 1) 0x35, 0x01, // ldi 01 - 0xa0, PATCH_UINT16 + 0x91, 0x01, // sag global[191h] (setting global 191h to 1) - 0x38, PATCH_UINT16 + 0x7b, 0x01, // pushi 017b + 0xa0, PATCH_UINT16(0x0191), // sag global[191h] (setting global 191h to 1) + 0x38, PATCH_UINT16(0x017b), // pushi 017b 0x76, // push0 0x81, 0x01, // lag global[1] 0x4a, 0x04, // send 04 - read KQ5::masterVolume @@ -727,23 +731,23 @@ static const uint16 kq5PatchCdHarpyVolume[] = { // // Fixes bug: #4964 static const uint16 kq5SignatureWitchCageInit[] = { - SIG_UINT16 + 0x00, 0x00, // top - SIG_UINT16 + 0x00, 0x00, // left - SIG_UINT16 + 0x00, 0x00, // bottom - SIG_UINT16 + 0x00, 0x00, // right - SIG_UINT16 + 0x00, 0x00, // extra property #1 + SIG_UINT16(0x0000), // top + SIG_UINT16(0x0000), // left + SIG_UINT16(0x0000), // bottom + SIG_UINT16(0x0000), // right + SIG_UINT16(0x0000), // extra property #1 SIG_MAGICDWORD, - SIG_UINT16 + 0x7a, 0x00, // extra property #2 - SIG_UINT16 + 0xc8, 0x00, // extra property #3 - SIG_UINT16 + 0xa3, 0x00, // extra property #4 + SIG_UINT16(0x007a), // extra property #2 + SIG_UINT16(0x00c8), // extra property #3 + SIG_UINT16(0x00a3), // extra property #4 SIG_END }; static const uint16 kq5PatchWitchCageInit[] = { - PATCH_UINT16 + 0x00, 0x00, // top - PATCH_UINT16 + 0x7a, 0x00, // left - PATCH_UINT16 + 0xc8, 0x00, // bottom - PATCH_UINT16 + 0xa3, 0x00, // right + PATCH_UINT16(0x0000), // top + PATCH_UINT16(0x007a), // left + PATCH_UINT16(0x00c8), // bottom + PATCH_UINT16(0x00a3), // right PATCH_END }; @@ -763,19 +767,19 @@ static const uint16 kq5PatchWitchCageInit[] = { // TODO: Investigate these side effects more closely. static const uint16 kq5SignatureWinGMSignals[] = { SIG_MAGICDWORD, - 0x80, SIG_UINT16 + 0x90, 0x01, // lag 0x190 + 0x80, SIG_UINT16(0x0190), // lag 0x190 0x18, // not - 0x30, SIG_UINT16 + 0x1b, 0x00, // bnt +0x001B + 0x30, SIG_UINT16(0x001b), // bnt +0x001B 0x89, 0x57, // lsg 0x57 SIG_END }; static const uint16 kq5PatchWinGMSignals[] = { - 0x34, PATCH_UINT16 + 0x01, 0x00, // ldi 0x0001 + 0x34, PATCH_UINT16(0x0001), // ldi 0x0001 PATCH_END }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry kq5Signatures[] = { { true, 0, "CD: harpy volume change", 1, kq5SignatureCdHarpyVolume, kq5PatchCdHarpyVolume }, { true, 200, "CD: witch cage init", 1, kq5SignatureWitchCageInit, kq5PatchWitchCageInit }, @@ -818,7 +822,7 @@ static const uint16 kq6PatchDuplicateBabyCry[] = { // Fixes bug: #5681 static const uint16 kq6SignatureInventoryStackFix[] = { 0x67, 0x30, // pTos state - 0x34, SIG_UINT16 + 0x00, 0x20, // ldi 2000 + 0x34, SIG_UINT16(0x2000), // ldi 2000 0x12, // and 0x18, // not 0x31, 0x04, // bnt [not first refresh] @@ -826,10 +830,10 @@ static const uint16 kq6SignatureInventoryStackFix[] = { SIG_MAGICDWORD, 0x65, 0x1e, // aTop curIcon 0x67, 0x30, // pTos state - 0x34, SIG_UINT16 + 0xff, 0xdf, // ldi dfff + 0x34, SIG_UINT16(0xdfff), // ldi dfff 0x12, // and 0x65, 0x30, // aTop state - 0x38, SIG_SELECTOR16 + SELECTOR_show, // pushi "show" ("show" is e1h for KQ6CD) + 0x38, SIG_SELECTOR16(show), // pushi "show" ("show" is e1h for KQ6CD) 0x78, // push1 0x87, 0x00, // lap param[0] 0x31, 0x04, // bnt [use global for show] @@ -838,7 +842,7 @@ static const uint16 kq6SignatureInventoryStackFix[] = { 0x81, 0x00, // lag global[0] 0x36, // push 0x54, 0x06, // self 06 (KqInv::show) - 0x31, SIG_ADDTOOFFSET + 1, // bnt [exit menu code] (0x08 for PC, 0x07 for mac) + 0x31, SIG_ADDTOOFFSET(+1), // bnt [exit menu code] (0x08 for PC, 0x07 for mac) 0x39, 0x39, // pushi 39 0x76, // push0 0x54, 0x04, // self 04 (KqInv::doit) @@ -849,7 +853,7 @@ static const uint16 kq6PatchInventoryStackFix[] = { 0x67, 0x30, // pTos state 0x3c, // dup (1 more byte, needed for patch) 0x3c, // dup (1 more byte, saves 1 byte later) - 0x34, PATCH_UINT16 + 0x00, 0x20, // ldi 2000 + 0x34, PATCH_UINT16(0x2000), // ldi 2000 0x12, // and 0x2f, 0x02, // bt [not first refresh] - saves 3 bytes in total 0x65, 0x1e, // aTop curIcon @@ -857,8 +861,8 @@ static const uint16 kq6PatchInventoryStackFix[] = { 0x12, // and 0x65, 0x30, // aTop state 0x38, // pushi "show" - PATCH_GETORIGINALBYTE +22, - PATCH_GETORIGINALBYTE +23, + PATCH_GETORIGINALBYTE(+22), + PATCH_GETORIGINALBYTE(+23), 0x78, // push1 0x87, 0x00, // lap param[0] 0x31, 0x04, // bnt [call show using global 0] @@ -867,8 +871,8 @@ static const uint16 kq6PatchInventoryStackFix[] = { 0x89, 0x00, // lsg global[0], save 1 byte total, see above 0x54, 0x06, // self 06 (call x::show) 0x31, // bnt [menu exit code] - PATCH_GETORIGINALBYTEADJUST +39, +6,// dynamic offset must be 0x0E for PC and 0x0D for mac - 0x34, PATCH_UINT16 + 0x00, 0x20, // ldi 2000 + PATCH_GETORIGINALBYTEADJUST(+39, +6),// dynamic offset must be 0x0E for PC and 0x0D for mac + 0x34, PATCH_UINT16(0x2000), // ldi 2000 0x12, // and 0x2f, 0x05, // bt [to return] 0x39, 0x39, // pushi 39 @@ -878,9 +882,63 @@ static const uint16 kq6PatchInventoryStackFix[] = { PATCH_END }; +// The "Drink Me" bottle code doesn't repaint the AddToPics elements to the screen, +// when Alexander returns back from the effect of the bottle. +// It's pretty strange that Sierra didn't find this bug, because it occurs when +// drinking the bottle right on the screen, where the bottle is found. +// This bug also occurs in Sierra SCI. +// Applies to at least: PC-CD, English PC floppy, German PC floppy, English Mac +// Responsible method: drinkMeScript::changeState +// Fixes bug: #5252 +static const uint16 kq6SignatureDrinkMeFix[] = { + SIG_MAGICDWORD, + 0x3c, // dup + 0x35, 0x0f, // ldi 0f + 0x1a, // eq? + 0x30, SIG_UINT16(0x00a4), // bnt [skip to next check] + SIG_ADDTOOFFSET(+161), + 0x32, SIG_UINT16(0x007f), // jmp [return] + 0x3c, // dup + 0x35, 0x10, // ldi 10 + 0x1a, // eq? + 0x31, 0x07, // bnt [skip to next check] + 0x35, 0x03, // ldi 03 + 0x65, 0x1a, // aTop (cycles) + 0x32, SIG_UINT16(0x0072), // jmp [return] + 0x3c, // dup + 0x35, 0x11, // ldi 11 + 0x1a, // eq? + 0x31, 0x13, // bnt [skip to next check] + SIG_ADDTOOFFSET(+20), + 0x35, 0x12, // ldi 12 + SIG_ADDTOOFFSET(+23), + 0x35, 0x13, // ldi 13 + SIG_END +}; + +static const uint16 kq6PatchDrinkMeFix[] = { + PATCH_ADDTOOFFSET(+5), // skip to bnt offset + PATCH_GETORIGINALBYTEADJUST(+5, +13), // adjust jump to [check for 11h code] + PATCH_ADDTOOFFSET(+162), + 0x39, PATCH_SELECTOR8(doit), // pushi (doit) + 0x76, // push0 + 0x81, 0x0a, // lag 0a + 0x4a, 0x04, // send 04 (call addToPics::doit) + 0x3a, // toss + 0x48, // ret + PATCH_ADDTOOFFSET(+8), // skip to check 11h code + 0x35, 0x10, // ldi 10 instead of 11 + PATCH_ADDTOOFFSET(+23), // skip to check 12h code + 0x35, 0x11, // ldi 11 instead of 12 + PATCH_ADDTOOFFSET(+23), // skip to check 13h code + 0x35, 0x12, // ldi 12 instead of 13 + PATCH_END +}; + // Audio + subtitles support - SHARED! - used for King's Quest 6 and Laura Bow 2 // this patch gets enabled, when the user selects "both" in the ScummVM "Speech + Subtitles" menu // We currently use global 98d to hold a kMemory pointer. +// Applies to at least: KQ6 PC-CD, LB2 PC-CD // Patched method: Messager::sayNext / lb2Messager::sayNext (always use text branch) static const uint16 kq6laurabow2CDSignatureAudioTextSupport1[] = { 0x89, 0x5a, // lsg global[5a] @@ -888,16 +946,17 @@ static const uint16 kq6laurabow2CDSignatureAudioTextSupport1[] = { 0x12, // and SIG_MAGICDWORD, 0x31, 0x13, // bnt [audio call] - 0x38, SIG_SELECTOR16 + SELECTOR_modNum, // pushi modNum + 0x38, SIG_SELECTOR16(modNum), // pushi modNum SIG_END }; static const uint16 kq6laurabow2CDPatchAudioTextSupport1[] = { - PATCH_ADDTOOFFSET +5, + PATCH_ADDTOOFFSET(+5), 0x33, 0x13, // jmp [audio call] PATCH_END }; +// Applies to at least: KQ6 PC-CD, LB2 PC-CD // Patched method: Messager::sayNext / lb2Messager::sayNext (allocate audio memory) static const uint16 kq6laurabow2CDSignatureAudioTextSupport2[] = { 0x7a, // push2 @@ -909,11 +968,12 @@ static const uint16 kq6laurabow2CDSignatureAudioTextSupport2[] = { }; static const uint16 kq6laurabow2CDPatchAudioTextSupport2[] = { - PATCH_ADDTOOFFSET +7, + PATCH_ADDTOOFFSET(+7), 0xa1, 98, // sag global[98d] PATCH_END }; +// Applies to at least: KQ6 PC-CD, LB2 PC-CD // Patched method: Messager::sayNext / lb2Messager::sayNext (release audio memory) static const uint16 kq6laurabow2CDSignatureAudioTextSupport3[] = { 0x7a, // push2 @@ -925,18 +985,29 @@ static const uint16 kq6laurabow2CDSignatureAudioTextSupport3[] = { }; static const uint16 kq6laurabow2CDPatchAudioTextSupport3[] = { - PATCH_ADDTOOFFSET +3, + PATCH_ADDTOOFFSET(+3), 0x89, 98, // lsg global[98d] PATCH_END }; +// startText call gets acc = 0 for text-only and acc = 2 for audio+text +// Applies to at least: KQ6 PC-CD, LB2 PC-CD // Patched method: Narrator::say (use audio memory) static const uint16 kq6laurabow2CDSignatureAudioTextSupport4[] = { + // set caller property code + 0x31, 0x08, // bnt [set acc to 0 for caller] + 0x87, 0x02, // lap param[2] + 0x31, 0x04, // bnt [set acc to 0 for caller] + 0x87, 0x02, // lap param[2] + 0x33, 0x02, // jmp [set caller] + 0x35, 0x00, // ldi 00 + 0x65, 0x68, // aTop caller + // call startText + startAudio code 0x89, 0x5a, // lsg global[5a] 0x35, 0x01, // ldi 01 0x12, // and 0x31, 0x08, // bnt [skip code] - 0x38, SIG_SELECTOR16 + SELECTOR_startText, // pushi startText + 0x38, SIG_SELECTOR16(startText), // pushi startText 0x78, // push1 0x8f, 0x01, // lsp param[1] 0x54, 0x06, // self 06 @@ -945,7 +1016,7 @@ static const uint16 kq6laurabow2CDSignatureAudioTextSupport4[] = { 0x12, // and 0x31, 0x08, // bnt [skip code] SIG_MAGICDWORD, - 0x38, SIG_SELECTOR16 + SELECTOR_startAudio, // pushi startAudio + 0x38, SIG_SELECTOR16(startAudio), // pushi startAudio 0x78, // push1 0x8f, 0x01, // lsp param[1] 0x54, 0x06, // self 06 @@ -953,15 +1024,23 @@ static const uint16 kq6laurabow2CDSignatureAudioTextSupport4[] = { }; static const uint16 kq6laurabow2CDPatchAudioTextSupport4[] = { - PATCH_ADDTOOFFSET +2, - 0x34, PATCH_UINT16 + 0x01, 0x00, // ldi 0001 (waste 1 byte) - 0x12, - 0x18, // not - prepares acc for KQ6 talker::startText - PATCH_ADDTOOFFSET +19, + 0x31, 0x02, // bnt [set caller] + 0x87, 0x02, // lap param[2] + 0x65, 0x68, // aTop caller + 0x81, 0x5a, // lag global[5a] + 0x78, // push1 + 0x12, // and + 0x31, 0x11, // bnt [skip startText code] + 0x81, 0x5a, // lag global[5a] + 0x7a, // push2 + 0x12, // and + 0x33, 0x03, // skip over 3 unused bytes + PATCH_ADDTOOFFSET(+22), 0x89, 98, // lsp global[98d] PATCH_END }; +// Applies to at least: KQ6 PC-CD, LB2 PC-CD // Patched method: Talker::display/Narrator::say (remove reset saved mouse cursor code) // code would screw over mouse cursor static const uint16 kq6laurabow2CDSignatureAudioTextSupport5[] = { @@ -976,50 +1055,113 @@ static const uint16 kq6laurabow2CDPatchAudioTextSupport5[] = { PATCH_END }; -// Additional patches specifically for King's Quest 6 -// Fixes text window placement, when portrait+text is shown +// Additional patch specifically for King's Quest 6 +// Fixes text window placement, when in "dual" mode +// Applies to at least: PC-CD // Patched method: Kq6Talker::init static const uint16 kq6CDSignatureAudioTextSupport1[] = { SIG_MAGICDWORD, 0x89, 0x5a, // lsg global[5a] 0x35, 0x02, // ldi 02 0x1a, // eq? - 0x31, 0x32, // bnt [jump-for-text-code] - 0x87, 0x00, // lap param[0] + 0x31, SIG_ADDTOOFFSET(+1), // bnt [jump-to-text-code] + 0x78, // push1 SIG_END }; static const uint16 kq6CDPatchAudioTextSupport1[] = { - PATCH_ADDTOOFFSET +5, - 0x33, 0x32, // jmp [jump-for-text-code] + PATCH_ADDTOOFFSET(+4), + 0x12, // and PATCH_END }; -// Additional patches specifically for King's Quest 6 +// Additional patch specifically for King's Quest 6 // Fixes low-res portrait staying on screen for hi-res mode +// Applies to at least: PC-CD // Patched method: Talker::startText -// this method is called by Narrator::say and acc is 0 for text-only and true for audio+text +// this method is called by Narrator::say and acc is 0 for text-only and 2 for dual mode (audio+text) static const uint16 kq6CDSignatureAudioTextSupport2[] = { SIG_MAGICDWORD, 0x3f, 0x01, // link 01 0x63, 0x8a, // pToa viewInPrint 0x18, // not 0x31, 0x06, // bnt [skip following code] - 0x38, SIG_UINT16 + 0xe1, 0x00, // pushi 00e1 + 0x38, SIG_UINT16(0x00e1), // pushi 00e1 0x76, // push0 0x54, 0x04, // self 04 SIG_END }; static const uint16 kq6CDPatchAudioTextSupport2[] = { - PATCH_ADDTOOFFSET +2, + PATCH_ADDTOOFFSET(+2), 0x67, 0x8a, // pTos viewInPrint 0x14, // or 0x2f, // bt [skip following code] PATCH_END }; -// Fixes text window placement, when portrait+text is shown (Guard in room 220) +// Additional patch specifically for King's Quest 6 +// Fixes special windows, used for example in the Pawn shop (room 280), +// when the man in a robe complains about no more mints. +// We have to change even more code, because the game uses PODialog class for +// text windows and myDialog class for audio. Both are saved to KQ6Print::dialog +// Sadly PODialog is created during KQ6Print::addText, myDialog is set during +// KQ6Print::showSelf, which is called much later and KQ6Print::addText requires +// KQ6Print::dialog to be set, which means we have to set it before calling addText +// for audio mode, otherwise the user would have to click to get those windows disposed. +// Applies to at least: PC-CD +// Patched method: KQ6Print::say +static const uint16 kq6CDSignatureAudioTextSupport3[] = { + 0x31, 0x6e, // bnt [to text code] + SIG_ADDTOOFFSET(+85), + SIG_MAGICDWORD, + 0x8f, 0x01, // lsp param[1] + 0x35, 0x01, // ldi 01 + 0x1a, // eq? + 0x31, 0x0c, // bnt [code to set property repressText to 1] + 0x38, // pushi (selector addText) + SIG_ADDTOOFFSET(+9), // skip addText-calling code + 0x33, 0x10, // jmp [to ret] + 0x35, 0x01, // ldi 01 + 0x65, 0x2e, // aTop repressText + 0x33, 0x0a, // jmp [to ret] + SIG_END +}; + +static const uint16 kq6CDPatchAudioTextSupport3[] = { + 0x31, 0x5c, // adjust jump to reuse audio mode addText-calling code + PATCH_ADDTOOFFSET(102), + 0x48, // ret + 0x48, // ret (waste byte) + 0x72, 0x0e, 0x00, // lofsa myDialog + 0x65, 0x12, // aTop dialog + 0x33, 0xed, // jump back to audio mode addText-calling code + PATCH_END +}; + +// Additional patch specifically for King's Quest 6 +// Fixes text-window size for hires portraits mode +// Otherwise at least at the end some text-windows will be way too small +// Applies to at least: PC-CD +// Patched method: Talker::init +static const uint16 kq6CDSignatureAudioTextSupport4[] = { + SIG_MAGICDWORD, + 0x63, 0x94, // pToa raving + 0x31, 0x0a, // bnt [no rave code] + 0x35, 0x00, // ldi 00 + SIG_ADDTOOFFSET(6), // skip reset of bust, eyes and mouth + 0x33, 0x24, // jmp [to super class code] + SIG_END +}; + +static const uint16 kq6CDPatchAudioTextSupport4[] = { + PATCH_ADDTOOFFSET(+12), + 0x33, PATCH_GETORIGINALBYTEADJUST(+13, -6), // adjust jump to also include setSize call + PATCH_END +}; + +// Fixes text window placement, when dual mode is active (Guards in room 220) +// Applies to at least: PC-CD // Patched method: tlkGateGuard1::init & tlkGateGuard2::init static const uint16 kq6CDSignatureAudioTextSupportGuards[] = { SIG_MAGICDWORD, @@ -1030,56 +1172,141 @@ static const uint16 kq6CDSignatureAudioTextSupportGuards[] = { }; static const uint16 kq6CDPatchAudioTextSupportGuards[] = { - PATCH_ADDTOOFFSET +2, - 0x34, PATCH_UINT16 + 0x01, 0x00, // ldi 0001 (waste 1 byte to overwrite eq?) + PATCH_ADDTOOFFSET(+2), + 0x35, 0x02, // ldi 02 + 0x1c, // ne? PATCH_END }; // Fixes text window placement, when portrait+text is shown (Stepmother in room 250) +// Applies to at least: PC-CD // Patched method: tlkStepmother::init static const uint16 kq6CDSignatureAudioTextSupportStepmother[] = { SIG_MAGICDWORD, 0x89, 0x5a, // lsg global[5a] 0x35, 0x02, // ldi 02 0x12, // and - 0x31, 0x1a, // bnt [jump-for-text-code] + 0x31, // bnt [jump-for-text-code] SIG_END }; static const uint16 kq6CDPatchAudioTextSupportJumpAlways[] = { - PATCH_ADDTOOFFSET +5, - 0x33, // jump always + PATCH_ADDTOOFFSET(+4), + 0x1a, // eq? PATCH_END }; -// Fixes text window placement, when portrait+text is shown (Gnomes in room 450) -// Patched method: GnomeTalker::init -static const uint16 kq6CDSignatureAudioTextSupportGnomes[] = { +// Fixes "Girl In The Tower" to get played in dual mode as well +// Applies to at least: PC-CD +// Patched method: rm740::cue +static const uint16 kq6CDSignatureAudioTextSupportGirlInTheTower[] = { SIG_MAGICDWORD, 0x89, 0x5a, // lsg global[5a] 0x35, 0x02, // ldi 02 0x1a, // eq? - 0x31, 0x16, // bnt [jump-for-text-code] + 0x31, // bnt [jump-for-text-code] + SIG_END +}; + +static const uint16 kq6CDPatchAudioTextSupportGirlInTheTower[] = { + PATCH_ADDTOOFFSET(+4), + 0x12, // and + PATCH_END +}; + +// Additional patch specifically for King's Quest 6 +// Adds another button state for the text/audio button. We currently use the "speech" view for "dual" mode. +// View 947, loop 9, cel 0+1 -> "text" +// View 947, loop 8, cel 0+1 -> "speech" +// View 947, loop 12, cel 0+1 -> "dual" (TODO: inject our own 2 views for the new "dual" mode) +// Applies to at least: PC-CD +// Patched method: iconTextSwitch::show, iconTextSwitch::doit +static const uint16 kq6CDSignatureAudioTextMenuSupport[] = { + SIG_MAGICDWORD, + 0x89, 0x5a, // lsg global[5a] + 0x35, 0x02, // ldi 02 + 0x1a, // eq? + 0x31, 0x06, // bnt [set text view] + 0x35, 0x08, // ldi 08 + 0x65, 0x14, // aTop loop + 0x33, 0x04, // jmp [skip over text view] + 0x35, 0x09, // ldi 09 + 0x65, 0x14, // aTop loop + SIG_ADDTOOFFSET(+102), // skip to iconTextSwitch::doit code + 0x89, 0x5a, // lsg global[5a] + 0x3c, // dup + 0x35, 0x01, // ldi 01 + 0x1a, // eq? + 0x31, 0x06, // bnt [set text mode] + 0x35, 0x02, // ldi 02 + 0xa1, 0x5a, // sag global[5a] + 0x33, 0x0a, // jmp [skip over text mode code] + 0x3c, // dup + 0x35, 0x02, // ldi 02 + 0x1a, // eq? + 0x31, 0x04, // bnt [skip over text ode code] + 0x35, 0x01, // ldi 01 + 0xa1, 0x5a, // sag global[5a] + 0x3a, // toss + 0x67, 0x14, // pTos loop + 0x35, 0x09, // ldi 09 + 0x1a, // eq? + 0x31, 0x04, // bnt [set text view] + 0x35, 0x08, // ldi 08 + 0x33, 0x02, // jmp [skip text view] + 0x35, 0x09, // ldi 09 + 0x65, 0x14, // aTop loop SIG_END }; +static const uint16 kq6CDPatchAudioTextMenuSupport[] = { + PATCH_ADDTOOFFSET(+13), + 0x33, 0x79, // jmp to new text+dual code + PATCH_ADDTOOFFSET(+104), // seek to iconTextSwitch::doit + 0x81, 0x5a, // lag global[5a] + 0x78, // push1 + 0x02, // add + 0xa1, 0x5a, // sag global[5a] + 0x36, // push + 0x35, 0x03, // ldi 03 + 0x1e, // gt? + 0x31, 0x03, // bnt [skip over] + 0x78, // push1 + 0xa9, 0x5a, // ssg global[5a] + 0x33, 0x17, // jmp [iconTextSwitch::show call] + // additional code for iconTextSwitch::show + 0x89, 0x5a, // lsg global[5a] + 0x35, 0x01, // ldi 01 + 0x1a, // eq? + 0x31, 0x04, // bnt [dual mode] + 0x35, 0x09, // ldi 09 + 0x33, 0x02, // jmp [skip over dual mode] + 0x35, 0x0c, // ldi 0c (view 947, loop 12, cel 0+1 is our "dual" view, injected by view.cpp) + 0x65, 0x14, // aTop loop + 0x32, PATCH_UINT16(0xff75), // jmp [back to iconTextSwitch::show] + PATCH_END +}; + // script, description, signature patch static const SciScriptPatcherEntry kq6Signatures[] = { { true, 481, "duplicate baby cry", 1, kq6SignatureDuplicateBabyCry, kq6PatchDuplicateBabyCry }, { true, 907, "inventory stack fix", 1, kq6SignatureInventoryStackFix, kq6PatchInventoryStackFix }, + { true, 87, "Drink Me bottle fix", 1, kq6SignatureDrinkMeFix, kq6PatchDrinkMeFix }, // King's Quest 6 and Laura Bow 2 share basic patches for audio + text support // *** King's Quest 6 audio + text support *** - // TODO: all window placements seems to be fixed, game should be played through to check for any more issues - { false, 924, "CD: audio + text support KQ6&LB2 1", 1, kq6laurabow2CDSignatureAudioTextSupport1, kq6laurabow2CDPatchAudioTextSupport1 }, - { false, 924, "CD: audio + text support KQ6&LB2 2", 1, kq6laurabow2CDSignatureAudioTextSupport2, kq6laurabow2CDPatchAudioTextSupport2 }, - { false, 924, "CD: audio + text support KQ6&LB2 3", 1, kq6laurabow2CDSignatureAudioTextSupport3, kq6laurabow2CDPatchAudioTextSupport3 }, - { false, 928, "CD: audio + text support KQ6&LB2 4", 1, kq6laurabow2CDSignatureAudioTextSupport4, kq6laurabow2CDPatchAudioTextSupport4 }, - { false, 928, "CD: audio + text support KQ6&LB2 5", 2, kq6laurabow2CDSignatureAudioTextSupport5, kq6laurabow2CDPatchAudioTextSupport5 }, - { false, 909, "CD: audio + text support KQ6 1", 1, kq6CDSignatureAudioTextSupport1, kq6CDPatchAudioTextSupport1 }, - { false, 928, "CD: audio + text support KQ6 2", 1, kq6CDSignatureAudioTextSupport2, kq6CDPatchAudioTextSupport2 }, - { false, 1009, "CD: audio + text support KQ6 Guards", 2, kq6CDSignatureAudioTextSupportGuards, kq6CDPatchAudioTextSupportGuards }, - { false, 1027, "CD: audio + text support KQ6 Stepmother", 1, kq6CDSignatureAudioTextSupportStepmother, kq6CDPatchAudioTextSupportJumpAlways }, - { false, 1037, "CD: audio + text support KQ6 Gnomes", 1, kq6CDSignatureAudioTextSupportGnomes, kq6CDPatchAudioTextSupportJumpAlways }, + { false, 924, "CD: audio + text support KQ6&LB2 1", 1, kq6laurabow2CDSignatureAudioTextSupport1, kq6laurabow2CDPatchAudioTextSupport1 }, + { false, 924, "CD: audio + text support KQ6&LB2 2", 1, kq6laurabow2CDSignatureAudioTextSupport2, kq6laurabow2CDPatchAudioTextSupport2 }, + { false, 924, "CD: audio + text support KQ6&LB2 3", 1, kq6laurabow2CDSignatureAudioTextSupport3, kq6laurabow2CDPatchAudioTextSupport3 }, + { false, 928, "CD: audio + text support KQ6&LB2 4", 1, kq6laurabow2CDSignatureAudioTextSupport4, kq6laurabow2CDPatchAudioTextSupport4 }, + { false, 928, "CD: audio + text support KQ6&LB2 5", 2, kq6laurabow2CDSignatureAudioTextSupport5, kq6laurabow2CDPatchAudioTextSupport5 }, + { false, 909, "CD: audio + text support KQ6 1", 2, kq6CDSignatureAudioTextSupport1, kq6CDPatchAudioTextSupport1 }, + { false, 928, "CD: audio + text support KQ6 2", 1, kq6CDSignatureAudioTextSupport2, kq6CDPatchAudioTextSupport2 }, + { false, 104, "CD: audio + text support KQ6 3", 1, kq6CDSignatureAudioTextSupport3, kq6CDPatchAudioTextSupport3 }, + { false, 928, "CD: audio + text support KQ6 4", 1, kq6CDSignatureAudioTextSupport4, kq6CDPatchAudioTextSupport4 }, + { false, 1009, "CD: audio + text support KQ6 Guards", 2, kq6CDSignatureAudioTextSupportGuards, kq6CDPatchAudioTextSupportGuards }, + { false, 1027, "CD: audio + text support KQ6 Stepmother", 1, kq6CDSignatureAudioTextSupportStepmother, kq6CDPatchAudioTextSupportJumpAlways }, + { false, 740, "CD: audio + text support KQ6 Girl In The Tower", 1, kq6CDSignatureAudioTextSupportGirlInTheTower, kq6CDPatchAudioTextSupportGirlInTheTower }, + { false, 903, "CD: audio + text support KQ6 menu", 1, kq6CDSignatureAudioTextMenuSupport, kq6CDPatchAudioTextMenuSupport }, SCI_SIGNATUREENTRY_TERMINATOR }; @@ -1099,25 +1326,25 @@ static const SciScriptPatcherEntry kq6Signatures[] = { static const uint16 longbowSignatureShowHandCode[] = { 0x78, // push1 0x78, // push1 - 0x72, SIG_ADDTOOFFSET +2, // lofsa (letter, that was typed) + 0x72, SIG_ADDTOOFFSET(+2), // lofsa (letter, that was typed) 0x36, // push - 0x40, SIG_ADDTOOFFSET +2, // call + 0x40, SIG_ADDTOOFFSET(+2), // call 0x02, // perform the call above with 2 parameters 0x36, // push - 0x40, SIG_ADDTOOFFSET +2, // call + 0x40, SIG_ADDTOOFFSET(+2), // call SIG_MAGICDWORD, 0x02, // perform the call above with 2 parameters - 0x38, SIG_SELECTOR16 + SELECTOR_setMotion, // pushi "setMotion" (0x11c in Longbow German) - 0x39, SIG_SELECTOR8 + SELECTOR_x, // pushi "x" (0x04 in Longbow German) + 0x38, SIG_SELECTOR16(setMotion), // pushi "setMotion" (0x11c in Longbow German) + 0x39, SIG_SELECTOR8(x), // pushi "x" (0x04 in Longbow German) 0x51, 0x1e, // class MoveTo SIG_END }; static const uint16 longbowPatchShowHandCode[] = { 0x39, 0x01, // pushi 1 (combine the two push1's in one, like in the English version) - PATCH_ADDTOOFFSET +3, // leave the lofsa call untouched + PATCH_ADDTOOFFSET(+3), // leave the lofsa call untouched // The following will remove the duplicate call - 0x32, PATCH_UINT16 + 0x02, 0x00, // jmp 02 - skip 2 bytes (the remainder of the first call) + 0x32, PATCH_UINT16(0x0002), // jmp 02 - skip 2 bytes (the remainder of the first call) 0x48, // ret (dummy, should never be reached) 0x48, // ret (dummy, should never be reached) PATCH_END @@ -1149,23 +1376,23 @@ static const SciScriptPatcherEntry longbowSignatures[] = { static const uint16 larry2SignatureWearParachutePoints[] = { 0x35, 0x01, // ldi 01 0xa1, SIG_MAGICDWORD, 0x8e, // sag 8e - 0x80, SIG_UINT16 + 0xe0, 0x01, // lag 1e0 + 0x80, SIG_UINT16(0x01e0), // lag 1e0 0x18, // not - 0x30, SIG_UINT16 + 0x0f, 0x00, // bnt [don't give points] + 0x30, SIG_UINT16(0x000f), // bnt [don't give points] 0x35, 0x01, // ldi 01 0xa0, 0xe0, 0x01, // sag 1e0 SIG_END }; static const uint16 larry2PatchWearParachutePoints[] = { - PATCH_ADDTOOFFSET +4, - 0x80, PATCH_UINT16 + 0x5a, 0x00, // lag 5a (global 90) - PATCH_ADDTOOFFSET +6, - 0xa0, PATCH_UINT16 + 0x5a, 0x00, // sag 5a (global 90) + PATCH_ADDTOOFFSET(+4), + 0x80, PATCH_UINT16(0x005a), // lag 5a (global 90) + PATCH_ADDTOOFFSET(+6), + 0xa0, PATCH_UINT16(0x005a), // sag 5a (global 90) PATCH_END }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry larry2Signatures[] = { { true, 63, "plane: no points for wearing plane", 1, larry2SignatureWearParachutePoints, larry2PatchWearParachutePoints }, SCI_SIGNATUREENTRY_TERMINATOR @@ -1181,20 +1408,20 @@ static const SciScriptPatcherEntry larry2Signatures[] = { // Responsible method: none, position of talker object on screen needs to get modified static const uint16 larry5SignatureGermanEndingPattiTalker[] = { SIG_MAGICDWORD, - SIG_UINT16 + 0x6e, 0x00, // object pattiTalker::x (110) - SIG_UINT16 + 0xb4, 0x00, // object pattiTalker::y (180) - SIG_ADDTOOFFSET + 469, // verify that it's really the German version + SIG_UINT16(0x006e), // object pattiTalker::x (110) + SIG_UINT16(0x00b4), // object pattiTalker::y (180) + SIG_ADDTOOFFSET(+469), // verify that it's really the German version 0x59, 0x6f, 0x75, // (object name) "You" 0x23, 0x47, 0x44, 0x75, // "#GDu" SIG_END }; static const uint16 larry5PatchGermanEndingPattiTalker[] = { - PATCH_UINT16 + 0x5a, 0x00, // change pattiTalker::x to 90 + PATCH_UINT16(0x005a), // change pattiTalker::x to 90 PATCH_END }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry larry5Signatures[] = { { true, 380, "German-only: Enlarge Patti Textbox", 1, larry5SignatureGermanEndingPattiTalker, larry5PatchGermanEndingPattiTalker }, SCI_SIGNATUREENTRY_TERMINATOR @@ -1212,40 +1439,40 @@ static const SciScriptPatcherEntry larry5Signatures[] = { // Responsible method: unknown static const uint16 larry6SignatureDeathDialog[] = { SIG_MAGICDWORD, - 0x3e, SIG_UINT16 + 0x33, 0x01, // link 0133 (offset 0x20) + 0x3e, SIG_UINT16(0x0133), // link 0133 (offset 0x20) 0x35, 0xff, // ldi ff 0xa3, 0x00, // sal 00 - SIG_ADDTOOFFSET +680, // [skip 680 bytes] + SIG_ADDTOOFFSET(+680), // [skip 680 bytes] 0x8f, 0x01, // lsp 01 (offset 0x2cf) 0x7a, // push2 - 0x5a, SIG_UINT16 + 0x04, 0x00, SIG_UINT16 + 0x0e, 0x01, // lea 0004 010e + 0x5a, SIG_UINT16(0x0004), SIG_UINT16(0x010e), // lea 0004 010e 0x36, // push 0x43, 0x7c, 0x0e, // kMessage[7c] 0e - SIG_ADDTOOFFSET +90, // [skip 90 bytes] - 0x38, SIG_UINT16 + 0xd6, 0x00, // pushi 00d6 (offset 0x335) + SIG_ADDTOOFFSET(+90), // [skip 90 bytes] + 0x38, SIG_UINT16(0x00d6), // pushi 00d6 (offset 0x335) 0x78, // push1 - 0x5a, SIG_UINT16 + 0x04, 0x00, SIG_UINT16 + 0x0e, 0x01, // lea 0004 010e + 0x5a, SIG_UINT16(0x0004), SIG_UINT16(0x010e), // lea 0004 010e 0x36, // push - SIG_ADDTOOFFSET +76, // [skip 76 bytes] - 0x38, SIG_UINT16 + 0xcd, 0x00, // pushi 00cd (offset 0x38b) + SIG_ADDTOOFFSET(+76), // [skip 76 bytes] + 0x38, SIG_UINT16(0x00cd), // pushi 00cd (offset 0x38b) 0x39, 0x03, // pushi 03 - 0x5a, SIG_UINT16 + 0x04, 0x00, SIG_UINT16 + 0x0e, 0x01, // lea 0004 010e + 0x5a, SIG_UINT16(0x0004), SIG_UINT16(0x010e), // lea 0004 010e 0x36, SIG_END }; static const uint16 larry6PatchDeathDialog[] = { 0x3e, 0x00, 0x02, // link 0200 - PATCH_ADDTOOFFSET +687, - 0x5a, PATCH_UINT16 + 0x04, 0x00, PATCH_UINT16 + 0x40, 0x01, // lea 0004 0140 - PATCH_ADDTOOFFSET +98, - 0x5a, PATCH_UINT16 + 0x04, 0x00, PATCH_UINT16 + 0x40, 0x01, // lea 0004 0140 - PATCH_ADDTOOFFSET +82, - 0x5a, PATCH_UINT16 + 0x04, 0x00, PATCH_UINT16 + 0x40, 0x01, // lea 0004 0140 + PATCH_ADDTOOFFSET(+687), + 0x5a, PATCH_UINT16(0x0004), PATCH_UINT16(0x0140), // lea 0004 0140 + PATCH_ADDTOOFFSET(+98), + 0x5a, PATCH_UINT16(0x0004), PATCH_UINT16(0x0140), // lea 0004 0140 + PATCH_ADDTOOFFSET(+82), + 0x5a, PATCH_UINT16(0x0004), PATCH_UINT16(0x0140), // lea 0004 0140 PATCH_END }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry larry6Signatures[] = { { true, 82, "death dialog memory corruption", 1, larry6SignatureDeathDialog, larry6PatchDeathDialog }, SCI_SIGNATUREENTRY_TERMINATOR @@ -1283,13 +1510,13 @@ static const uint16 laurabow2CDSignaturePaintingClosing[] = { 0x76, // push0 SIG_MAGICDWORD, 0x7a, // push2 - 0x38, SIG_UINT16 + 0x31, 0x02, // pushi 0231h (561) + 0x38, SIG_UINT16(0x0231), // pushi 0231h (561) 0x76, // push0 0x43, 0x02, 0x04, // kScriptID (get export 0 of script 561) 0x4a, 0x04, // send 04 (gets safePicture::cel) 0x18, // not 0x31, 0x21, // bnt [exit] - 0x38, SIG_UINT16 + 0x83, 0x02, // pushi 0283h + 0x38, SIG_UINT16(0x0283), // pushi 0283h 0x76, // push0 0x7a, // push2 0x39, 0x20, // pushi 20 @@ -1306,19 +1533,19 @@ static const uint16 laurabow2CDSignaturePaintingClosing[] = { }; static const uint16 laurabow2CDPatchPaintingClosing[] = { - PATCH_ADDTOOFFSET +2, + PATCH_ADDTOOFFSET(+2), 0x3c, // dup (1 additional byte) 0x76, // push0 0x3c, // dup (1 additional byte) 0xab, 0x00, // ssl local[0] -> reset safePic signal 0x7a, // push2 - 0x38, PATCH_UINT16 + 0x31, 0x02, // pushi 0231h (561) + 0x38, PATCH_UINT16(0x0231), // pushi 0231h (561) 0x76, // push0 0x43, 0x02, 0x04, // kScriptID (get export 0 of script 561) 0x4a, 0x04, // send 04 (gets safePicture::cel) 0x1a, // eq? 0x31, 0x1d, // bnt [exit] - 0x38, PATCH_UINT16 + 0x83, 0x02, // pushi 0283h + 0x38, PATCH_UINT16(0x0283), // pushi 0283h 0x76, // push0 0x7a, // push2 0x39, 0x20, // pushi 20 @@ -1353,7 +1580,7 @@ static const uint16 laurabow2CDPatchPaintingClosing[] = { // Fixes bug: #6440 static const uint16 laurabow2CDSignatureFixProblematicIconBar[] = { SIG_MAGICDWORD, - 0x38, SIG_UINT16 + 0xf1, 0x00, // pushi 00f1 (disable) - hardcoded, we only want to patch the CD version + 0x38, SIG_UINT16(0x00f1), // pushi 00f1 (disable) - hardcoded, we only want to patch the CD version 0x76, // push0 0x81, 0x45, // lag global[45] 0x4a, 0x04, // send 04 @@ -1368,17 +1595,105 @@ static const uint16 laurabow2CDPatchFixProblematicIconBar[] = { PATCH_END }; +// Laura Bow 2 CD resets the audio mode to speech on init/restart +// We already sync the settings from ScummVM (see SciEngine::syncIngameAudioOptions()) +// and this script code would make it impossible to see the intro using "dual" mode w/o using debugger command +// That's why we remove the corresponding code +// Patched method: LB2::init, rm100::init +static const uint16 laurabow2CDSignatureAudioTextSupportModeReset[] = { + SIG_MAGICDWORD, + 0x35, 0x02, // ldi 02 + 0xa1, 0x5a, // sag global[5a] + SIG_END +}; + +static const uint16 laurabow2CDPatchAudioTextSupportModeReset[] = { + 0x34, PATCH_UINT16(0x0001), // ldi 0001 (waste bytes) + 0x18, // not (waste bytes) + PATCH_END +}; + +// Directly use global 5a for view-cel id +// That way it's possible to use a new "dual" mode view in the game menu +// View 995, loop 13, cel 0 -> "text" +// View 995, loop 13, cel 1 -> "speech" +// View 995, loop 13, cel 2 -> "dual" (TODO: inject our own view for the new "dual" mode) +// Patched method: gcWin::open +static const uint16 laurabow2CDSignatureAudioTextMenuSupport1[] = { + SIG_MAGICDWORD, + 0x89, 0x5a, // lsg global[5a] + 0x35, 0x02, // ldi 02 + 0x1a, // eq? + 0x36, // push + SIG_END +}; + +static const uint16 laurabow2CDPatchAudioTextMenuSupport1[] = { + PATCH_ADDTOOFFSET(+2), + 0x35, 0x01, // ldi 01 + 0x04, // sub + PATCH_END +}; + +// Adds another button state for the text/audio button. We currently use the "speech" view for "dual" mode. +// TODO: inject our own 2 views for the new "dual" mode +// Patched method: iconMode::doit +static const uint16 laurabow2CDSignatureAudioTextMenuSupport2[] = { + SIG_MAGICDWORD, + 0x89, 0x5a, // lsg global[5a] + 0x3c, // dup + 0x1a, // eq? + 0x31, 0x0a, // bnt [set text mode] + 0x35, 0x02, // ldi 02 + 0xa1, 0x5a, // sag global[5a] + 0x35, 0x01, // ldi 01 + 0xa5, 0x00, // sat temp[0] + 0x33, 0x0e, // jmp [draw cel code] + 0x3c, // dup + 0x35, 0x02, // ldi 02 + 0x1a, // eq? + 0x31, 0x08, // bnt [draw cel code] + 0x35, 0x01, // ldi 01 + 0xa1, 0x5a, // sag global[5a] + 0x35, 0x00, // ldi 00 + 0xa5, 0x00, // sat temp[0] + 0x3a, // toss + SIG_END +}; + +static const uint16 laurabow2CDPatchAudioTextMenuSupport2[] = { + 0x81, 0x5a, // lag global[5a] + 0x78, // push1 + 0x02, // add + 0xa1, 0x5a, // sag global[5a] + 0x36, // push + 0x35, 0x03, // ldi 03 + 0x1e, // gt? + 0x31, 0x03, // bnt [skip over] + 0x78, // push1 + 0xa9, 0x5a, // ssg global[5a] + 0x89, 0x5a, // lsg global[5a] + 0x35, 0x01, // ldi 01 + 0x04, // sub + 0xa5, 0x00, // sat temp[0] - calculate global[5a] - 1 to use as view cel id + 0x33, 0x07, // jmp [draw cel code, don't do toss] + PATCH_END +}; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry laurabow2Signatures[] = { - { true, 560, "CD: painting closing immediately", 1, laurabow2CDSignaturePaintingClosing, laurabow2CDPatchPaintingClosing }, - { true, 0, "CD: fix problematic icon bar", 1, laurabow2CDSignatureFixProblematicIconBar, laurabow2CDPatchFixProblematicIconBar }, + { true, 560, "CD: painting closing immediately", 1, laurabow2CDSignaturePaintingClosing, laurabow2CDPatchPaintingClosing }, + { true, 0, "CD: fix problematic icon bar", 1, laurabow2CDSignatureFixProblematicIconBar, laurabow2CDPatchFixProblematicIconBar }, // King's Quest 6 and Laura Bow 2 share basic patches for audio + text support - { false, 924, "CD: audio + text support 1", 1, kq6laurabow2CDSignatureAudioTextSupport1, kq6laurabow2CDPatchAudioTextSupport1 }, - { false, 924, "CD: audio + text support 2", 1, kq6laurabow2CDSignatureAudioTextSupport2, kq6laurabow2CDPatchAudioTextSupport2 }, - { false, 924, "CD: audio + text support 3", 1, kq6laurabow2CDSignatureAudioTextSupport3, kq6laurabow2CDPatchAudioTextSupport3 }, - { false, 928, "CD: audio + text support 4", 1, kq6laurabow2CDSignatureAudioTextSupport4, kq6laurabow2CDPatchAudioTextSupport4 }, - { false, 928, "CD: audio + text support 5", 2, kq6laurabow2CDSignatureAudioTextSupport5, kq6laurabow2CDPatchAudioTextSupport5 }, + { false, 924, "CD: audio + text support 1", 1, kq6laurabow2CDSignatureAudioTextSupport1, kq6laurabow2CDPatchAudioTextSupport1 }, + { false, 924, "CD: audio + text support 2", 1, kq6laurabow2CDSignatureAudioTextSupport2, kq6laurabow2CDPatchAudioTextSupport2 }, + { false, 924, "CD: audio + text support 3", 1, kq6laurabow2CDSignatureAudioTextSupport3, kq6laurabow2CDPatchAudioTextSupport3 }, + { false, 928, "CD: audio + text support 4", 1, kq6laurabow2CDSignatureAudioTextSupport4, kq6laurabow2CDPatchAudioTextSupport4 }, + { false, 928, "CD: audio + text support 5", 2, kq6laurabow2CDSignatureAudioTextSupport5, kq6laurabow2CDPatchAudioTextSupport5 }, + { false, 0, "CD: audio + text support disable mode reset", 1, laurabow2CDSignatureAudioTextSupportModeReset, laurabow2CDPatchAudioTextSupportModeReset }, + { false, 100, "CD: audio + text support disable mode reset", 1, laurabow2CDSignatureAudioTextSupportModeReset, laurabow2CDPatchAudioTextSupportModeReset }, + { false, 24, "CD: audio + text support LB2 menu 1", 1, laurabow2CDSignatureAudioTextMenuSupport1, laurabow2CDPatchAudioTextMenuSupport1 }, + { false, 24, "CD: audio + text support LB2 menu 2", 1, laurabow2CDSignatureAudioTextMenuSupport2, laurabow2CDPatchAudioTextMenuSupport2 }, SCI_SIGNATUREENTRY_TERMINATOR }; @@ -1396,8 +1711,8 @@ static const uint16 mothergoose256SignatureReplay[] = { }; static const uint16 mothergoose256PatchReplay[] = { - 0x34, PATCH_UINT16 + 0x00, 0x00, // ldi 0000 (dummy) - 0x34, PATCH_UINT16 + 0x00, 0x00, // ldi 0000 (dummy) + 0x34, PATCH_UINT16(0x0000), // ldi 0000 (dummy) + 0x34, PATCH_UINT16(0x0000), // ldi 0000 (dummy) PATCH_END }; @@ -1411,12 +1726,12 @@ static const uint16 mothergoose256SignatureSaveLimit[] = { }; static const uint16 mothergoose256PatchSaveLimit[] = { - PATCH_ADDTOOFFSET | +2, + PATCH_ADDTOOFFSET(+2), 0x35, 0x0d + SAVEGAMEID_OFFICIALRANGE_START, // ldi 113d PATCH_END }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry mothergoose256Signatures[] = { { true, 0, "replay save issue", 1, mothergoose256SignatureReplay, mothergoose256PatchReplay }, { true, 0, "save limit dialog (SCI1.1)", 1, mothergoose256SignatureSaveLimit, mothergoose256PatchSaveLimit }, @@ -1441,9 +1756,9 @@ static const uint16 pq1vgaSignaturePutGunInLockerBug[] = { 0x35, 0x00, // ldi 00 0x1a, // eq? 0x31, 0x25, // bnt [next state check] - SIG_ADDTOOFFSET +22, // [skip 22 bytes] + SIG_ADDTOOFFSET(+22), // [skip 22 bytes] SIG_MAGICDWORD, - 0x38, SIG_SELECTOR16 + SELECTOR_put, // pushi "put" + 0x38, SIG_SELECTOR16(put), // pushi "put" 0x78, // push1 0x76, // push0 0x81, 0x00, // lag 00 @@ -1455,17 +1770,17 @@ static const uint16 pq1vgaSignaturePutGunInLockerBug[] = { 0x35, 0x01, // ldi 01 0x1a, // eq? 0x31, 0x08, // bnt [end of method] - 0x39, SIG_SELECTOR8 + SELECTOR_dispose, // pushi "dispose" + 0x39, SIG_SELECTOR8(dispose), // pushi "dispose" 0x76, // push0 - 0x72, SIG_UINT16 + 0x88, 0x00, // lofsa 0088 + 0x72, SIG_UINT16(0x0088), // lofsa 0088 0x4a, 0x04, // send 04 - locker::dispose SIG_END }; static const uint16 pq1vgaPatchPutGunInLockerBug[] = { - PATCH_ADDTOOFFSET +3, + PATCH_ADDTOOFFSET(+3), 0x31, 0x1c, // bnt [next state check] - PATCH_ADDTOOFFSET +22, + PATCH_ADDTOOFFSET(+22), 0x35, 0x02, // ldi 02 0x65, 0x1c, // aTop 1c (set timer to 2 seconds) 0x33, 0x17, // jmp [end of method] @@ -1473,7 +1788,7 @@ static const uint16 pq1vgaPatchPutGunInLockerBug[] = { 0x35, 0x01, // ldi 01 0x1a, // eq? 0x31, 0x11, // bnt [end of method] - 0x38, PATCH_SELECTOR16 + SELECTOR_put, // pushi "put" + 0x38, PATCH_SELECTOR16(put), // pushi "put" 0x78, // push1 0x76, // push0 0x81, 0x00, // lag 00 @@ -1481,9 +1796,42 @@ static const uint16 pq1vgaPatchPutGunInLockerBug[] = { PATCH_END }; -// script, description, signature patch +// When restoring a saved game, which was made while driving around, +// the game didn't redraw the map. This also happened in Sierra SCI. +// +// The map is a picture resource and drawn over the main picture. +// This is called an "overlay" in SCI. This wasn't implemented properly. +// We fix it by actually implementing it properly. +// +// Applies to at least: English floppy +// Responsible method: rm500::init, changeOverlay::changeState (script 500) +// Fixes bug: #5016 +static const uint16 pq1vgaSignatureMapSaveRestoreBug[] = { + 0x39, 0x04, // pushi 04 + SIG_ADDTOOFFSET(+2), // skip either lsg global[f9] or pTos register + SIG_MAGICDWORD, + 0x38, 0x64, 0x80, // pushi 8064 + 0x76, // push0 + 0x89, 0x28, // lsg global[28] + 0x43, 0x08, 0x08, // kDrawPic (8) + SIG_END +}; + +static const uint16 pq1vgaPatchMapSaveRestoreBug[] = { + 0x38, PATCH_SELECTOR16(overlay), // pushi "overlay" + 0x7a, // push2 + 0x89, 0xf9, // lsg global[f9] + 0x39, 0x64, // pushi 64 (no transition) + 0x81, 0x02, // lag global[02] (current room object) + 0x4a, 0x08, // send 08 + 0x18, // not (waste byte) + PATCH_END +}; + +// script, description, signature patch static const SciScriptPatcherEntry pq1vgaSignatures[] = { { true, 341, "put gun in locker bug", 1, pq1vgaSignaturePutGunInLockerBug, pq1vgaPatchPutGunInLockerBug }, + { true, 500, "map save/restore bug", 2, pq1vgaSignatureMapSaveRestoreBug, pq1vgaPatchMapSaveRestoreBug }, SCI_SIGNATUREENTRY_TERMINATOR }; @@ -1500,7 +1848,7 @@ static const SciScriptPatcherEntry pq1vgaSignatures[] = { // Responsible method: pointBox::doit static const uint16 qfg1vgaSignatureFightEvents[] = { 0x39, SIG_MAGICDWORD, - SIG_SELECTOR8 + SELECTOR_new, // pushi "new" + SIG_SELECTOR8(new), // pushi "new" 0x76, // push0 0x51, 0x07, // class Event 0x4a, 0x04, // send 04 - call Event::new @@ -1520,7 +1868,7 @@ static const uint16 qfg1vgaSignatureFightEvents[] = { }; static const uint16 qfg1vgaPatchFightEvents[] = { - 0x38, PATCH_SELECTOR16 + SELECTOR_curEvent, // pushi 15a (selector curEvent) + 0x38, PATCH_SELECTOR16(curEvent), // pushi 15a (selector curEvent) 0x76, // push0 0x81, 0x50, // lag global[50] 0x4a, 0x04, // send 04 - read User::curEvent -> needs one byte more than previous code @@ -1587,13 +1935,13 @@ static const uint16 qfg1vgaSignatureMoveToCrusher[] = { 0x51, 0x1f, // class Motion 0x36, // push 0x39, 0x4f, // pushi 4f (79 - x) - 0x38, SIG_UINT16 + 0xa5, 0x00, // pushi 00a5 (165 - y) + 0x38, SIG_UINT16(0x00a5), // pushi 00a5 (165 - y) 0x7c, // pushSelf SIG_END }; static const uint16 qfg1vgaPatchMoveToCrusher[] = { - PATCH_ADDTOOFFSET +3, + PATCH_ADDTOOFFSET(+3), 0x39, 0x55, // pushi 55 (85 - x) PATCH_END }; @@ -1613,7 +1961,7 @@ static const uint16 qfg1vgaSignatureMoveToCastleGate[] = { }; static const uint16 qfg1vgaPatchMoveToCastleGate[] = { - PATCH_ADDTOOFFSET +3, + PATCH_ADDTOOFFSET(+3), 0x39, 0x72, // pushi 72 (114 - x) PATCH_END }; @@ -1626,10 +1974,10 @@ static const uint16 qfg1vgaPatchMoveToCastleGate[] = { // Fixes bug #6249 static const uint16 qfg1vgaSignatureCheetaurDescription[] = { SIG_MAGICDWORD, - 0x34, SIG_UINT16 + 0xb8, 0x01, // ldi 01b8 + 0x34, SIG_UINT16(0x01b8), // ldi 01b8 0x1a, // eq? 0x31, 0x16, // bnt 16 - 0x38, SIG_UINT16 + 0x27, 0x01, // pushi 0127 + 0x38, SIG_UINT16(0x0127), // pushi 0127 0x39, 0x06, // pushi 06 0x39, 0x03, // pushi 03 0x78, // push1 @@ -1638,7 +1986,7 @@ static const uint16 qfg1vgaSignatureCheetaurDescription[] = { }; static const uint16 qfg1vgaPatchCheetaurDescription[] = { - PATCH_ADDTOOFFSET +14, + PATCH_ADDTOOFFSET(+14), 0x39, 0x11, // pushi 11 -> monster type cheetaur PATCH_END }; @@ -1662,7 +2010,7 @@ static const uint16 qfg1vgaSignatureFunnyRoomFix[] = { 0x3c, // dup 0x35, 0x00, // ldi 00 0x1a, // eq? - 0x30, SIG_UINT16 + 0x25, 0x00, // bnt 0025 [-> next state] + 0x30, SIG_UINT16(0x0025), // bnt 0025 [-> next state] SIG_MAGICDWORD, 0x35, 0x01, // ldi 01 0xa3, 0x4e, // sal 4e @@ -1670,8 +2018,8 @@ static const uint16 qfg1vgaSignatureFunnyRoomFix[] = { }; static const uint16 qfg1vgaPatchFunnyRoomFix[] = { - PATCH_ADDTOOFFSET +3, - 0x2e, PATCH_UINT16 + 0x29, 0x00, // bt 0029 [-> next state] - saves 4 bytes + PATCH_ADDTOOFFSET(+3), + 0x2e, PATCH_UINT16(0x0029), // bt 0029 [-> next state] - saves 4 bytes 0x35, 0x01, // ldi 01 0xa3, 0x4e, // sal 4e 0xa3, 0x05, // sal 05 (sets local 5 to 1) @@ -1679,7 +2027,7 @@ static const uint16 qfg1vgaPatchFunnyRoomFix[] = { PATCH_END }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry qfg1vgaSignatures[] = { { true, 215, "fight event issue", 1, qfg1vgaSignatureFightEvents, qfg1vgaPatchFightEvents }, { true, 216, "weapon master event issue", 1, qfg1vgaSignatureFightEvents, qfg1vgaPatchFightEvents }, @@ -1708,7 +2056,7 @@ static const SciScriptPatcherEntry qfg1vgaSignatures[] = { // Fixes bug: #5096 static const uint16 qfg2SignatureImportDialog[] = { 0x63, SIG_MAGICDWORD, 0x20, // pToa text - 0x30, SIG_UINT16 + 0x0b, 0x00, // bnt [next state] + 0x30, SIG_UINT16(0x000b), // bnt [next state] 0x7a, // push2 0x39, 0x03, // pushi 03 0x36, // push @@ -1719,12 +2067,12 @@ static const uint16 qfg2SignatureImportDialog[] = { }; static const uint16 qfg2PatchImportDialog[] = { - PATCH_ADDTOOFFSET +5, + PATCH_ADDTOOFFSET(+5), 0x48, // ret PATCH_END }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry qfg2Signatures[] = { { true, 944, "import dialog continuous calls", 1, qfg2SignatureImportDialog, qfg2PatchImportDialog }, SCI_SIGNATUREENTRY_TERMINATOR @@ -1745,7 +2093,7 @@ static const uint16 qfg3SignatureImportDialog[] = { }; static const uint16 qfg3PatchImportDialog[] = { - PATCH_ADDTOOFFSET +4, + PATCH_ADDTOOFFSET(+4), 0x48, // ret PATCH_END }; @@ -1778,9 +2126,9 @@ static const uint16 qfg3SignatureWooDialog[] = { 0x35, 0x9b, // ldi 9b 0x1a, // eq? 0x31, 0x0c, // bnt 0c - 0x38, SIG_SELECTOR16 + SELECTOR_solvePuzzle, // pushi 0297 + 0x38, SIG_SELECTOR16(solvePuzzle), // pushi 0297 0x7a, // push2 - 0x38, SIG_UINT16 + 0x0c, 0x01, // pushi 010c + 0x38, SIG_UINT16(0x010c), // pushi 010c 0x7a, // push2 0x81, 0x00, // lag 00 0x4a, 0x08, // send 08 @@ -1790,12 +2138,12 @@ static const uint16 qfg3SignatureWooDialog[] = { }; static const uint16 qfg3PatchWooDialog[] = { - PATCH_ADDTOOFFSET +0x29, + PATCH_ADDTOOFFSET(+0x29), 0x33, 0x11, // jmp to 0x6a2, the call to hero::solvePuzzle for 0xFFFC PATCH_END }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry qfg3Signatures[] = { { true, 944, "import dialog continuous calls", 1, qfg3SignatureImportDialog, qfg3PatchImportDialog }, { true, 440, "dialog crash when asking about Woo", 1, qfg3SignatureWooDialog, qfg3PatchWooDialog }, @@ -1815,17 +2163,49 @@ static const uint16 sq4FloppySignatureEndlessFlight[] = { SIG_MAGICDWORD, 0x78, // push1 0x67, 0x08, // pTos 08 (property x) - 0x63, SIG_ADDTOOFFSET + 1, // pToa (invalid property) - 44h for English floppy, 4ch for German floppy + 0x63, SIG_ADDTOOFFSET(+1), // pToa (invalid property) - 44h for English floppy, 4ch for German floppy 0x02, // add SIG_END }; static const uint16 sq4FloppyPatchEndlessFlight[] = { - PATCH_ADDTOOFFSET +5, + PATCH_ADDTOOFFSET(+5), 0x35, 0x03, // ldi 03 (which would be the content of the property) PATCH_END }; +// Floppy-only: When the player tries to throw something at the sequel police in Space Quest X (zero g zone), +// the game will first show a textbox and then cause a signature mismatch in ScummVM/ +// crash the whole game in Sierra SCI/display garbage (the latter when the Sierra "patch" got applied). +// +// All of this is caused by a typo in the script. Right after the code for showing the textbox, +// there is more similar code for showing another textbox, but without a pointer to the text. +// This has to be a typo, because there is no unused text to be found within that script. +// +// Sierra's "patch" didn't include a proper fix (as in a modified script). Instead they shipped a dummy +// text resource, which somewhat "solved" the issue in Sierra SCI, but it still showed another textbox +// with garbage in it. Funnily Sierra must have known that, because that new text resource contains: +// "Hi! This is a kludge!" +// +// We properly fix it by removing the faulty code. +// Applies to at least: English Floppy +// Responsible method: sp1::doVerb +// Fixes bug: found by SCI developer +static const uint16 sq4FloppySignatureThrowStuffAtSequelPoliceBug[] = { + 0x47, 0xff, 0x00, 0x02, // call export 255_0, 2 + 0x3a, // toss + SIG_MAGICDWORD, + 0x36, // push + 0x47, 0xff, 0x00, 0x02, // call export 255_0, 2 + SIG_END +}; + +static const uint16 sq4FloppyPatchThrowStuffAtSequelPoliceBug[] = { + PATCH_ADDTOOFFSET(+5), + 0x48, // ret + PATCH_END +}; + // The scripts in SQ4CD support simultaneous playing of speech and subtitles, // but this was not available as an option. The following two patches enable // this functionality in the game's GUI options dialog. @@ -1844,7 +2224,7 @@ static const uint16 sq4CdSignatureTextOptionsButton[] = { }; static const uint16 sq4CdPatchTextOptionsButton[] = { - PATCH_ADDTOOFFSET +7, + PATCH_ADDTOOFFSET(+7), 0x39, 0x0b, // pushi 0x0b PATCH_END }; @@ -1890,7 +2270,7 @@ static const uint16 sq4CdSignatureTextOptions[] = { 0x35, 0x01, // ldi 0x01 0xa1, 0x5a, // sag 0x5a (save acc to global 90) 0x3a, // toss - 0x38, SIG_SELECTOR16 + SELECTOR_show, // pushi 0x00d9 + 0x38, SIG_SELECTOR16(show), // pushi 0x00d9 0x76, // push0 0x54, 0x04, // self 0x04 0x48, // ret @@ -1910,18 +2290,19 @@ static const uint16 sq4CdPatchTextOptions[] = { 0x35, 0x01, // ldi 0x01 (reset acc to 1) 0xa1, 0x5a, // sag 0x5a (save acc to global 90) 0x33, 0x03, // jmp 0x03 (jump over the wasted bytes below) - 0x34, PATCH_UINT16 + 0x00, 0x00, // ldi 0x0000 (waste 3 bytes) + 0x34, PATCH_UINT16(0x0000), // ldi 0x0000 (waste 3 bytes) 0x3a, // toss // (the rest of the code is the same) PATCH_END }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry sq4Signatures[] = { - { true, 298, "Floppy: endless flight", 1, sq4FloppySignatureEndlessFlight, sq4FloppyPatchEndlessFlight }, - { true, 818, "CD: Speech and subtitles option", 1, sq4CdSignatureTextOptions, sq4CdPatchTextOptions }, - { true, 0, "CD: Babble icon speech and subtitles fix", 1, sq4CdSignatureBabbleIcon, sq4CdPatchBabbleIcon }, - { true, 818, "CD: Speech and subtitles option button", 1, sq4CdSignatureTextOptionsButton, sq4CdPatchTextOptionsButton }, + { true, 298, "Floppy: endless flight", 1, sq4FloppySignatureEndlessFlight, sq4FloppyPatchEndlessFlight }, + { true, 700, "Floppy: throw stuff at sequel police bug", 1, sq4FloppySignatureThrowStuffAtSequelPoliceBug, sq4FloppyPatchThrowStuffAtSequelPoliceBug }, + { true, 818, "CD: Speech and subtitles option", 1, sq4CdSignatureTextOptions, sq4CdPatchTextOptions }, + { true, 0, "CD: Babble icon speech and subtitles fix", 1, sq4CdSignatureBabbleIcon, sq4CdPatchBabbleIcon }, + { true, 818, "CD: Speech and subtitles option button", 1, sq4CdSignatureTextOptionsButton, sq4CdPatchTextOptionsButton }, SCI_SIGNATUREENTRY_TERMINATOR }; @@ -1938,24 +2319,24 @@ static const SciScriptPatcherEntry sq4Signatures[] = { // Responsible method: robotIntoShip::changeState(9) static const uint16 sq1vgaSignatureUlenceFlatsTimepodGfxGlitch[] = { 0x39, - SIG_MAGICDWORD, SIG_SELECTOR8 + SELECTOR_cel, // pushi "cel" + SIG_MAGICDWORD, SIG_SELECTOR8(cel), // pushi "cel" 0x78, // push1 0x39, 0x0a, // pushi 0x0a (set ship::cel to 10) - 0x38, SIG_UINT16 + 0xa0, 0x00, // pushi 0x00a0 (ship::setLoop) + 0x38, SIG_UINT16(0x00a0), // pushi 0x00a0 (ship::setLoop) SIG_END }; static const uint16 sq1vgaPatchUlenceFlatsTimepodGfxGlitch[] = { - PATCH_ADDTOOFFSET +3, + PATCH_ADDTOOFFSET(+3), 0x39, 0x09, // pushi 0x09 (set ship::cel to 9) PATCH_END }; static const uint16 sq1vgaSignatureEgoShowsCard[] = { SIG_MAGICDWORD, - 0x38, SIG_SELECTOR16 + SELECTOR_timesShownID, // push "timesShownID" + 0x38, SIG_SELECTOR16(timesShownID), // push "timesShownID" 0x78, // push1 - 0x38, SIG_SELECTOR16 + SELECTOR_timesShownID, // push "timesShownID" + 0x38, SIG_SELECTOR16(timesShownID), // push "timesShownID" 0x76, // push0 0x51, 0x7c, // class DeltaurRegion 0x4a, 0x04, // send 0x04 (get timesShownID) @@ -1974,7 +2355,7 @@ static const uint16 sq1vgaSignatureEgoShowsCard[] = { // Note that this script patch is merely a reordering of the // instructions in the original script. static const uint16 sq1vgaPatchEgoShowsCard[] = { - 0x38, PATCH_SELECTOR16 + SELECTOR_timesShownID, // push "timesShownID" + 0x38, PATCH_SELECTOR16(timesShownID), // push "timesShownID" 0x76, // push0 0x51, 0x7c, // class DeltaurRegion 0x4a, 0x04, // send 0x04 (get timesShownID) @@ -1982,7 +2363,7 @@ static const uint16 sq1vgaPatchEgoShowsCard[] = { 0x35, 0x01, // ldi 1 0x02, // add 0x36, // push (this push corresponds to the wrong one above) - 0x38, PATCH_SELECTOR16 + SELECTOR_timesShownID, // push "timesShownID" + 0x38, PATCH_SELECTOR16(timesShownID), // push "timesShownID" 0x78, // push1 0x36, // push 0x51, 0x7c, // class DeltaurRegion @@ -1993,7 +2374,7 @@ static const uint16 sq1vgaPatchEgoShowsCard[] = { }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry sq1vgaSignatures[] = { { true, 45, "Ulence Flats: timepod graphic glitch", 1, sq1vgaSignatureUlenceFlatsTimepodGfxGlitch, sq1vgaPatchUlenceFlatsTimepodGfxGlitch }, { true, 58, "Sarien armory droid zapping ego first time", 1, sq1vgaSignatureEgoShowsCard, sq1vgaPatchEgoShowsCard }, @@ -2025,7 +2406,7 @@ static const SciScriptPatcherEntry sq1vgaSignatures[] = { static const uint16 sq5SignatureToolboxFix[] = { 0x31, 0x13, // bnt [check for state 1] SIG_MAGICDWORD, - 0x38, SIG_UINT16 + 0xaa, 0x00, // pushi 00aa + 0x38, SIG_UINT16(0x00aa), // pushi 00aa 0x39, 0x05, // pushi 05 0x39, 0x16, // pushi 16 0x76, // push0 @@ -2034,7 +2415,7 @@ static const uint16 sq5SignatureToolboxFix[] = { 0x7c, // pushSelf 0x81, 0x5b, // lag 5b 0x4a, 0x0e, // send 0e - 0x32, SIG_UINT16 + 0x88, 0x00, // jmp [end-of-method] + 0x32, SIG_UINT16(0x0088), // jmp [end-of-method] 0x3c, // dup 0x35, 0x01, // ldi 01 0x1a, // eq? @@ -2044,7 +2425,7 @@ static const uint16 sq5SignatureToolboxFix[] = { static const uint16 sq5PatchToolboxFix[] = { 0x31, 0x41, // bnt [check for state 2] - PATCH_ADDTOOFFSET +16, // skip to jmp offset + PATCH_ADDTOOFFSET(+16), // skip to jmp offset 0x35, 0x01, // ldi 01 0x65, 0x14, // aTop [state] 0x36, 0x00, 0x00, // ldi 0000 (waste 3 bytes) @@ -2052,7 +2433,7 @@ static const uint16 sq5PatchToolboxFix[] = { PATCH_END }; -// script, description, signature patch +// script, description, signature patch static const SciScriptPatcherEntry sq5Signatures[] = { { true, 226, "toolbox fix", 1, sq5SignatureToolboxFix, sq5PatchToolboxFix }, SCI_SIGNATUREENTRY_TERMINATOR @@ -2095,12 +2476,12 @@ void ScriptPatcher::applyPatch(const SciScriptPatcherEntry *patchEntry, byte *sc uint16 patchCommand = patchWord & PATCH_COMMANDMASK; uint16 patchValue = patchWord & PATCH_VALUEMASK; switch (patchCommand) { - case PATCH_ADDTOOFFSET: { + case PATCH_CODE_ADDTOOFFSET: { // add value to offset offset += patchValue; break; } - case PATCH_GETORIGINALBYTE: { + case PATCH_CODE_GETORIGINALBYTE: { // get original byte from script if (patchValue >= orgDataSize) error("Script-Patcher: can not get requested original byte from script"); @@ -2108,7 +2489,7 @@ void ScriptPatcher::applyPatch(const SciScriptPatcherEntry *patchEntry, byte *sc offset++; break; } - case PATCH_GETORIGINALBYTEADJUST: { + case PATCH_CODE_GETORIGINALBYTEADJUST: { // get original byte from script and adjust it if (patchValue >= orgDataSize) error("Script-Patcher: can not get requested original byte from script"); @@ -2119,13 +2500,13 @@ void ScriptPatcher::applyPatch(const SciScriptPatcherEntry *patchEntry, byte *sc offset++; break; } - case PATCH_UINT16: - case PATCH_SELECTOR16: { + case PATCH_CODE_UINT16: + case PATCH_CODE_SELECTOR16: { byte byte1; byte byte2; switch (patchCommand) { - case PATCH_UINT16: { + case PATCH_CODE_UINT16: { byte1 = patchValue & PATCH_BYTEMASK; patchData++; patchWord = *patchData; if (patchWord & PATCH_COMMANDMASK) @@ -2133,7 +2514,7 @@ void ScriptPatcher::applyPatch(const SciScriptPatcherEntry *patchEntry, byte *sc byte2 = patchWord & PATCH_BYTEMASK; break; } - case PATCH_SELECTOR16: { + case PATCH_CODE_SELECTOR16: { patchSelector = _selectorIdTable[patchValue]; byte1 = patchSelector & 0xFF; byte2 = patchSelector >> 8; @@ -2152,7 +2533,7 @@ void ScriptPatcher::applyPatch(const SciScriptPatcherEntry *patchEntry, byte *sc } break; } - case PATCH_SELECTOR8: { + case PATCH_CODE_SELECTOR8: { patchSelector = _selectorIdTable[patchValue]; if (patchSelector & 0xFF00) error("Script-Patcher: 8 bit selector required, game uses 16 bit selector"); @@ -2160,7 +2541,7 @@ void ScriptPatcher::applyPatch(const SciScriptPatcherEntry *patchEntry, byte *sc offset++; break; } - case PATCH_BYTE: + case PATCH_CODE_BYTE: scriptData[offset] = patchValue & PATCH_BYTEMASK; offset++; } @@ -2191,19 +2572,19 @@ int32 ScriptPatcher::findSignature(const SciScriptPatcherEntry *patchEntry, SciS uint16 sigCommand = sigWord & SIG_COMMANDMASK; uint16 sigValue = sigWord & SIG_VALUEMASK; switch (sigCommand) { - case SIG_ADDTOOFFSET: { + case SIG_CODE_ADDTOOFFSET: { // add value to offset byteOffset += sigValue; break; } - case SIG_UINT16: - case SIG_SELECTOR16: { + case SIG_CODE_UINT16: + case SIG_CODE_SELECTOR16: { if ((byteOffset + 1) < scriptSize) { byte byte1; byte byte2; switch (sigCommand) { - case SIG_UINT16: { + case SIG_CODE_UINT16: { byte1 = sigValue & SIG_BYTEMASK; signatureData++; sigWord = *signatureData; if (sigWord & SIG_COMMANDMASK) @@ -2211,7 +2592,7 @@ int32 ScriptPatcher::findSignature(const SciScriptPatcherEntry *patchEntry, SciS byte2 = sigWord & SIG_BYTEMASK; break; } - case SIG_SELECTOR16: { + case SIG_CODE_SELECTOR16: { sigSelector = _selectorIdTable[sigValue]; byte1 = sigSelector & 0xFF; byte2 = sigSelector >> 8; @@ -2234,7 +2615,7 @@ int32 ScriptPatcher::findSignature(const SciScriptPatcherEntry *patchEntry, SciS } break; } - case SIG_SELECTOR8: { + case SIG_CODE_SELECTOR8: { if (byteOffset < scriptSize) { sigSelector = _selectorIdTable[sigValue]; if (sigSelector & 0xFF00) @@ -2247,7 +2628,7 @@ int32 ScriptPatcher::findSignature(const SciScriptPatcherEntry *patchEntry, SciS } break; } - case SIG_BYTE: + case SIG_CODE_BYTE: if (byteOffset < scriptSize) { if (scriptData[byteOffset] != sigWord) sigWord = SIG_MISMATCH; @@ -2329,17 +2710,17 @@ void ScriptPatcher::initSignature(const SciScriptPatcherEntry *patchTable, bool } break; } - case SIG_ADDTOOFFSET: { + case SIG_CODE_ADDTOOFFSET: { magicOffset -= curValue; if (magicDWordLeft) error("Script-Patcher: Magic-DWORD contains AddToOffset command\nFaulty patch: '%s'", curEntry->description); break; } - case SIG_UINT16: - case SIG_SELECTOR16: { + case SIG_CODE_UINT16: + case SIG_CODE_SELECTOR16: { // UINT16 or 1 switch (curCommand) { - case SIG_UINT16: { + case SIG_CODE_UINT16: { curData++; curWord = *curData; if (curWord & SIG_COMMANDMASK) error("Script-Patcher: signature entry inconsistent\nFaulty patch: '%s'", curEntry->description); @@ -2352,7 +2733,7 @@ void ScriptPatcher::initSignature(const SciScriptPatcherEntry *patchTable, bool } break; } - case SIG_SELECTOR16: { + case SIG_CODE_SELECTOR16: { curSelector = _selectorIdTable[curValue]; if (curSelector == -1) { curSelector = g_sci->getKernel()->findSelector(selectorNameTable[curValue]); @@ -2383,9 +2764,9 @@ void ScriptPatcher::initSignature(const SciScriptPatcherEntry *patchTable, bool } break; } - case SIG_BYTE: - case SIG_SELECTOR8: { - if (curCommand == SIG_SELECTOR8) { + case SIG_CODE_BYTE: + case SIG_CODE_SELECTOR8: { + if (curCommand == SIG_CODE_SELECTOR8) { curSelector = _selectorIdTable[curValue]; if (curSelector == -1) { curSelector = g_sci->getKernel()->findSelector(selectorNameTable[curValue]); @@ -2536,14 +2917,14 @@ void ScriptPatcher::processScript(uint16 scriptNr, byte *scriptData, const uint3 } break; case GID_KQ6: - if (g_sci->speechAndSubtitlesEnabled()) { - // Enables Audio + subtitles patches for King's Quest 6, when "Text and Speech: Both" is selected + if (g_sci->isCD()) { + // Enables Dual mode patches (audio + subtitles at the same time) for King's Quest 6 enablePatch(signatureTable, "CD: audio + text support"); } break; case GID_LAURABOW2: - if (g_sci->speechAndSubtitlesEnabled()) { - // Enables Audio + subtitles patches for Laura Bow 2, when "Text and Speech: Both" is selected + if (g_sci->isCD()) { + // Enables Dual mode patches (audio + subtitles at the same time) for Laura Bow 2 enablePatch(signatureTable, "CD: audio + text support"); } break; diff --git a/engines/sci/engine/script_patches.h b/engines/sci/engine/script_patches.h index 5d3ee22f7a..9e572f33fa 100644 --- a/engines/sci/engine/script_patches.h +++ b/engines/sci/engine/script_patches.h @@ -27,41 +27,49 @@ namespace Sci { -#define SIG_END 0xFFFF -#define SIG_MISMATCH 0xFFFE -#define SIG_COMMANDMASK 0xF000 -#define SIG_VALUEMASK 0x0FFF -#define SIG_BYTEMASK 0x00FF -#define SIG_MAGICDWORD 0xF000 -#define SIG_ADDTOOFFSET 0xE000 -#define SIG_SELECTOR16 0x9000 -#define SIG_SELECTOR8 0x8000 -#define SIG_UINT16 0x1000 -#define SIG_BYTE 0x0000 - -#define PATCH_END SIG_END -#define PATCH_COMMANDMASK SIG_COMMANDMASK -#define PATCH_VALUEMASK SIG_VALUEMASK -#define PATCH_BYTEMASK SIG_BYTEMASK -#define PATCH_ADDTOOFFSET SIG_ADDTOOFFSET -#define PATCH_GETORIGINALBYTE 0xD000 -#define PATCH_GETORIGINALBYTEADJUST 0xC000 -#define PATCH_SELECTOR16 SIG_SELECTOR16 -#define PATCH_SELECTOR8 SIG_SELECTOR8 -#define PATCH_UINT16 SIG_UINT16 -#define PATCH_BYTE SIG_BYTE +// Please do not use the #defines, that are called SIG_CODE_* / PATCH_CODE_* inside signature/patch-tables +#define SIG_END 0xFFFF +#define SIG_MISMATCH 0xFFFE +#define SIG_COMMANDMASK 0xF000 +#define SIG_VALUEMASK 0x0FFF +#define SIG_BYTEMASK 0x00FF +#define SIG_MAGICDWORD 0xF000 +#define SIG_CODE_ADDTOOFFSET 0xE000 +#define SIG_ADDTOOFFSET(_offset_) SIG_CODE_ADDTOOFFSET | _offset_ +#define SIG_CODE_SELECTOR16 0x9000 +#define SIG_SELECTOR16(_selectorID_) SIG_CODE_SELECTOR16 | SELECTOR_##_selectorID_ +#define SIG_CODE_SELECTOR8 0x8000 +#define SIG_SELECTOR8(_selectorID_) SIG_CODE_SELECTOR8 | SELECTOR_##_selectorID_ +#define SIG_CODE_UINT16 0x1000 +#define SIG_UINT16(_value_) SIG_CODE_UINT16 | (_value_ & 0xFF), (_value_ >> 8) +#define SIG_CODE_BYTE 0x0000 + +#define PATCH_END SIG_END +#define PATCH_COMMANDMASK SIG_COMMANDMASK +#define PATCH_VALUEMASK SIG_VALUEMASK +#define PATCH_BYTEMASK SIG_BYTEMASK +#define PATCH_CODE_ADDTOOFFSET SIG_CODE_ADDTOOFFSET +#define PATCH_ADDTOOFFSET(_offset_) SIG_CODE_ADDTOOFFSET | _offset_ +#define PATCH_CODE_GETORIGINALBYTE 0xD000 +#define PATCH_GETORIGINALBYTE(_offset_) PATCH_CODE_GETORIGINALBYTE | _offset_ +#define PATCH_CODE_GETORIGINALBYTEADJUST 0xC000 +#define PATCH_GETORIGINALBYTEADJUST(_offset_, _adjustValue_) PATCH_CODE_GETORIGINALBYTEADJUST | _offset_, (uint16)(_adjustValue_) +#define PATCH_CODE_SELECTOR16 SIG_CODE_SELECTOR16 +#define PATCH_SELECTOR16(_selectorID_) SIG_CODE_SELECTOR16 | SELECTOR_##_selectorID_ +#define PATCH_CODE_SELECTOR8 SIG_CODE_SELECTOR8 +#define PATCH_SELECTOR8(_selectorID_) SIG_CODE_SELECTOR8 | SELECTOR_##_selectorID_ +#define PATCH_CODE_UINT16 SIG_CODE_UINT16 +#define PATCH_UINT16(_value_) SIG_CODE_UINT16 | (_value_ & 0xFF), (_value_ >> 8) +#define PATCH_CODE_BYTE SIG_CODE_BYTE // defines maximum scratch area for getting original bytes from unpatched script data #define PATCH_VALUELIMIT 4096 struct SciScriptPatcherEntry { bool defaultActive; -// bool active; uint16 scriptNr; const char *description; int16 applyCount; -// uint32 magicDWord; -// int magicOffset; const uint16 *signatureData; const uint16 *patchData; }; diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp index 6fdff1ce91..4b8500bbcb 100644 --- a/engines/sci/engine/workarounds.cpp +++ b/engines/sci/engine/workarounds.cpp @@ -32,137 +32,137 @@ namespace Sci { // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry arithmeticWorkarounds[] = { - { GID_CAMELOT, 92, 92, 0, "endingCartoon2", "changeState", 0x20d, 0, { WORKAROUND_FAKE, 0 } }, // op_lai: during the ending, sub gets called with no parameters, uses parameter 1 which is theGrail in this case - bug #3044734 - { GID_ECOQUEST2, 100, 0, 0, "Rain", "points", 0xcc6, 0, { WORKAROUND_FAKE, 0 } }, // op_or: when giving the papers to the customs officer, gets called against a pointer instead of a number - bug #3034464 - { GID_ECOQUEST2, 100, 0, 0, "Rain", "points", 0xce0, 0, { WORKAROUND_FAKE, 0 } }, // Same as above, for the Spanish version - bug #3313962 - { GID_FANMADE, 516, 983, 0, "Wander", "setTarget", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_mul: The Legend of the Lost Jewel Demo (fan made): called with object as second parameter when attacked by insects - bug #3038913 + { GID_CAMELOT, 92, 92, 0, "endingCartoon2", "changeState", 0x20d, 0, { WORKAROUND_FAKE, 0 } }, // op_lai: during the ending, sub gets called with no parameters, uses parameter 1 which is theGrail in this case - bug #5237 + { GID_ECOQUEST2, 100, 0, 0, "Rain", "points", 0xcc6, 0, { WORKAROUND_FAKE, 0 } }, // op_or: when giving the papers to the customs officer, gets called against a pointer instead of a number - bug #4939 + { GID_ECOQUEST2, 100, 0, 0, "Rain", "points", 0xce0, 0, { WORKAROUND_FAKE, 0 } }, // Same as above, for the Spanish version - bug #5750 + { GID_FANMADE, 516, 983, 0, "Wander", "setTarget", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_mul: The Legend of the Lost Jewel Demo (fan made): called with object as second parameter when attacked by insects - bug #5124 { GID_GK1, 800,64992, 0, "Fwd", "doit", -1, 0, { WORKAROUND_FAKE, 1 } }, // op_gt: when Mosely finds Gabriel and Grace near the end of the game, compares the Grooper object with 7 { GID_HOYLE4, 700, -1, 1, "Code", "doit", -1, 0, { WORKAROUND_FAKE, 1 } }, // op_add: while bidding in Bridge, an object ("Bid") is added to an object in another segment ("hand3") { GID_ICEMAN, 199, 977, 0, "Grooper", "doit", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_add: While dancing with the girl { GID_MOTHERGOOSE256, -1, 999, 0, "Event", "new", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_and: constantly during the game (SCI1 version) - { GID_MOTHERGOOSE256, -1, 4, 0, "rm004", "doit", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_or: when going north and reaching the castle (rooms 4 and 37) - bug #3038228 + { GID_MOTHERGOOSE256, -1, 4, 0, "rm004", "doit", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_or: when going north and reaching the castle (rooms 4 and 37) - bug #5101 { GID_MOTHERGOOSEHIRES,90, 90, 0, "newGameButton", "select", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_ge: MUMG Deluxe, when selecting "New Game" in the main menu. It tries to compare an integer with a list. Needs to return false for the game to continue. { GID_PHANTASMAGORIA, 902, 0, 0, "", "export 7", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_shr: when starting a chapter in Phantasmagoria { GID_QFG1VGA, 301, 928, 0, "Blink", "init", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_div: when entering the inn, gets called with 1 parameter, but 2nd parameter is used for div which happens to be an object - { GID_QFG2, 200, 200, 0, "astro", "messages", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_lsi: when getting asked for your name by the astrologer bug #3039879 + { GID_QFG2, 200, 200, 0, "astro", "messages", -1, 0, { WORKAROUND_FAKE, 0 } }, // op_lsi: when getting asked for your name by the astrologer bug #5152 { GID_QFG4, 710,64941, 0, "RandCycle", "doit", -1, 0, { WORKAROUND_FAKE, 1 } }, // op_gt: when the tentacle appears in the third room of the caves SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry uninitializedReadWorkarounds[] = { - { GID_CAMELOT, 40, 40, 0, "Rm40", "handleEvent", -1, 0, { WORKAROUND_FAKE, 0 } }, // when looking at the ground at the pool of Siloam - bug #3614968 - { GID_CASTLEBRAIN, 280, 280, 0, "programmer", "dispatchEvent", -1, 0, { WORKAROUND_FAKE, 0xf } }, // pressing 'q' on the computer screen in the robot room, and closing the help dialog that pops up (bug #3039656). Moves the cursor to the view with the ID returned (in this case, the robot hand) - { GID_CNICK_KQ, -1, 0, 1, "Character", "say", -1, -1, { WORKAROUND_FAKE, 0 } }, // checkers/backgammon, like in hoyle 3 - temps 504 and 505 - bug #3606025 + { GID_CAMELOT, 40, 40, 0, "Rm40", "handleEvent", -1, 0, { WORKAROUND_FAKE, 0 } }, // when looking at the ground at the pool of Siloam - bug #6401 + { GID_CASTLEBRAIN, 280, 280, 0, "programmer", "dispatchEvent", -1, 0, { WORKAROUND_FAKE, 0xf } }, // pressing 'q' on the computer screen in the robot room, and closing the help dialog that pops up (bug #5143). Moves the cursor to the view with the ID returned (in this case, the robot hand) + { GID_CNICK_KQ, -1, 0, 1, "Character", "say", -1, -1, { WORKAROUND_FAKE, 0 } }, // checkers/backgammon, like in hoyle 3 - temps 504 and 505 - bug #6255 { GID_CNICK_KQ, -1, 700, 0, "gcWindow", "open", -1, -1, { WORKAROUND_FAKE, 0 } }, // when entering the control menu, like in hoyle 3 - { GID_CNICK_KQ, 300, 303, 0, "theDoubleCube", "<noname520>", -1, 5, { WORKAROUND_FAKE, 0 } }, // while playing backgammon with doubling enabled - bug #3615121 (same as the theDoubleCube::make workaround for Hoyle 3) + { GID_CNICK_KQ, 300, 303, 0, "theDoubleCube", "<noname520>", -1, 5, { WORKAROUND_FAKE, 0 } }, // while playing backgammon with doubling enabled - bug #6426 (same as the theDoubleCube::make workaround for Hoyle 3) { GID_CNICK_KQ, 300, 303, 0, "theDoubleCube", "<noname519>", -1, 9, { WORKAROUND_FAKE, 0 } }, // when accepting a double, while playing backgammon with doubling enabled (same as the theDoubleCube::accept workaround for Hoyle 3) - { GID_CNICK_LAURABOW, -1, 0, 1, "Character", "say", -1, -1, { WORKAROUND_FAKE, 0 } }, // Yatch, like in hoyle 3 - temps 504 and 505 - bug #3615119 - { GID_CNICK_LAURABOW, -1, 700, 0, NULL, "open", -1, -1, { WORKAROUND_FAKE, 0 } }, // when entering control menu - bug #3615118 (same as the gcWindow workaround for Hoyle 3) - { GID_CNICK_LAURABOW,100, 100, 0, NULL, "<noname144>", -1, 1, { WORKAROUND_FAKE, 0 } }, // while playing domino - bug #3615129 (same as the dominoHand2 workaround for Hoyle 3) - { GID_CNICK_LAURABOW,100, 110, 0, NULL, "doit", -1, -1, { WORKAROUND_FAKE, 0 } }, // when changing the "Dominoes per hand" setting - bug #3615130 + { GID_CNICK_LAURABOW, -1, 0, 1, "Character", "say", -1, -1, { WORKAROUND_FAKE, 0 } }, // Yatch, like in hoyle 3 - temps 504 and 505 - bug #6424 + { GID_CNICK_LAURABOW, -1, 700, 0, NULL, "open", -1, -1, { WORKAROUND_FAKE, 0 } }, // when entering control menu - bug #6423 (same as the gcWindow workaround for Hoyle 3) + { GID_CNICK_LAURABOW,100, 100, 0, NULL, "<noname144>", -1, 1, { WORKAROUND_FAKE, 0 } }, // while playing domino - bug #6429 (same as the dominoHand2 workaround for Hoyle 3) + { GID_CNICK_LAURABOW,100, 110, 0, NULL, "doit", -1, -1, { WORKAROUND_FAKE, 0 } }, // when changing the "Dominoes per hand" setting - bug #6430 { GID_CNICK_LONGBOW, 0, 0, 0, "RH Budget", "init", -1, 1, { WORKAROUND_FAKE, 0 } }, // when starting the game { GID_ECOQUEST, -1, -1, 0, NULL, "doVerb", -1, 0, { WORKAROUND_FAKE, 0 } }, // almost clicking anywhere triggers this in almost all rooms { GID_FANMADE, 516, 979, 0, "", "export 0", -1, 20, { WORKAROUND_FAKE, 0 } }, // Happens in Grotesteing after the logos - { GID_FANMADE, 528, 990, 0, "GDialog", "doit", -1, 4, { WORKAROUND_FAKE, 0 } }, // Happens in Cascade Quest when closing the glossary - bug #3038757 - { GID_FANMADE, 488, 1, 0, "RoomScript", "doit", 0x1f17, 1, { WORKAROUND_FAKE, 0 } }, // Happens in Ocean Battle while playing - bug #3059871 + { GID_FANMADE, 528, 990, 0, "GDialog", "doit", -1, 4, { WORKAROUND_FAKE, 0 } }, // Happens in Cascade Quest when closing the glossary - bug #5116 + { GID_FANMADE, 488, 1, 0, "RoomScript", "doit", 0x1f17, 1, { WORKAROUND_FAKE, 0 } }, // Happens in Ocean Battle while playing - bug #5335 { GID_FREDDYPHARKAS, -1, 24, 0, "gcWin", "open", -1, 5, { WORKAROUND_FAKE, 0xf } }, // is used as priority for game menu { GID_FREDDYPHARKAS, -1, 31, 0, "quitWin", "open", -1, 5, { WORKAROUND_FAKE, 0xf } }, // is used as priority for game menu - { GID_FREDDYPHARKAS, 540, 540, 0, "WaverCode", "init", -1, -1, { WORKAROUND_FAKE, 0 } }, // Gun pratice mini-game (bug #3044218) + { GID_FREDDYPHARKAS, 540, 540, 0, "WaverCode", "init", -1, -1, { WORKAROUND_FAKE, 0 } }, // Gun pratice mini-game - bug #5232 { GID_GK1, -1, 64950, -1, "Feature", "handleEvent", -1, 0, { WORKAROUND_FAKE, 0 } }, // sometimes when walk-clicking { GID_GK2, -1, 11, 0, "", "export 10", -1, 3, { WORKAROUND_FAKE, 0 } }, // called when the game starts { GID_GK2, -1, 11, 0, "", "export 10", -1, 4, { WORKAROUND_FAKE, 0 } }, // called during the game { GID_HOYLE1, 4, 104, 0, "GinRummyCardList", "calcRuns", -1, 4, { WORKAROUND_FAKE, 0 } }, // Gin Rummy / right when the game starts { GID_HOYLE1, 5, 204, 0, "tableau", "checkRuns", -1, 2, { WORKAROUND_FAKE, 0 } }, // Cribbage / during the game - { GID_HOYLE1, 3, 16, 0, "", "export 0", 0x37c, 3, { WORKAROUND_FAKE, 0 } }, // Hearts / during the game - bug #3052359 - { GID_HOYLE1, -1, 997, 0, "MenuBar", "doit", -1, 0, { WORKAROUND_FAKE, 0 } }, // When changing game speed settings - bug #3108012 + { GID_HOYLE1, 3, 16, 0, "", "export 0", 0x37c, 3, { WORKAROUND_FAKE, 0 } }, // Hearts / during the game - bug #5299 + { GID_HOYLE1, -1, 997, 0, "MenuBar", "doit", -1, 0, { WORKAROUND_FAKE, 0 } }, // When changing game speed settings - bug #5512 { GID_HOYLE3, -1, 0, 1, "Character", "say", -1, -1, { WORKAROUND_FAKE, 0 } }, // when starting checkers or dominoes, first time a character says something - temps 504 and 505 { GID_HOYLE3, -1, 700, 0, "gcWindow", "open", -1, -1, { WORKAROUND_FAKE, 0 } }, // when entering control menu - { GID_HOYLE3, 100, 100, 0, "dominoHand2", "cue", -1, 1, { WORKAROUND_FAKE, 0 } }, // while playing domino - bug #3036918 - { GID_HOYLE3, 100, 110, 0, "OKButton", "doit", -1, -1, { WORKAROUND_FAKE, 0 } }, // when changing the "Dominoes per hand" setting - bug #3615130 + { GID_HOYLE3, 100, 100, 0, "dominoHand2", "cue", -1, 1, { WORKAROUND_FAKE, 0 } }, // while playing domino - bug #5042 + { GID_HOYLE3, 100, 110, 0, "OKButton", "doit", -1, -1, { WORKAROUND_FAKE, 0 } }, // when changing the "Dominoes per hand" setting - bug #6430 { GID_HOYLE3, 300, 303, 0, "theDoubleCube", "make", -1, 5, { WORKAROUND_FAKE, 0 } }, // while playing backgammon with doubling enabled { GID_HOYLE3, 300, 303, 0, "theDoubleCube", "accept", -1, 9, { WORKAROUND_FAKE, 0 } }, // when accepting a double, while playing backgammon with doubling enabled - { GID_HOYLE4, -1, 0, 0, NULL, "open", -1, -1, { WORKAROUND_FAKE, 0 } }, // when selecting "Control" from the menu (temp vars 0-3) - bug #3039294 - { GID_HOYLE4, 910, 18, 0, NULL, "init", -1, 0, { WORKAROUND_FAKE, 0 } }, // during tutorial - bug #3042756 - { GID_HOYLE4, 910, 910, 0, NULL, "setup", -1, 3, { WORKAROUND_FAKE, 0 } }, // when selecting "Tutorial" from the main menu - bug #3039294 + { GID_HOYLE4, -1, 0, 0, NULL, "open", -1, -1, { WORKAROUND_FAKE, 0 } }, // when selecting "Control" from the menu (temp vars 0-3) - bug #5132 + { GID_HOYLE4, 910, 18, 0, NULL, "init", -1, 0, { WORKAROUND_FAKE, 0 } }, // during tutorial - bug #5213 + { GID_HOYLE4, 910, 910, 0, NULL, "setup", -1, 3, { WORKAROUND_FAKE, 0 } }, // when selecting "Tutorial" from the main menu - bug #5132 { GID_HOYLE4, 700, 700, 1, "BridgeHand", "calcQTS", -1, 3, { WORKAROUND_FAKE, 0 } }, // when placing a bid in bridge (always) - { GID_HOYLE4, 700, 710, 1, "BridgeStrategyPlay", "checkSplitTops", -1, 10, { WORKAROUND_FAKE, 0 } }, // while playing bridge, objects LeadReturn_Trump, SecondSeat_Trump, ThirdSeat_Trump and others - bug #3361925 + { GID_HOYLE4, 700, 710, 1, "BridgeStrategyPlay", "checkSplitTops", -1, 10, { WORKAROUND_FAKE, 0 } }, // while playing bridge, objects LeadReturn_Trump, SecondSeat_Trump, ThirdSeat_Trump and others - bug #5794 { GID_HOYLE4, 700, -1, 1, "BridgeDefense", "think", -1, -1, { WORKAROUND_FAKE, 0 } }, // sometimes while playing bridge, temp var 3, 17 and others, objects LeadReturn_Trump, ThirdSeat_Trump and others { GID_HOYLE4, 700, 730, 1, "BridgeDefense", "beatTheirBest", -1, 3, { WORKAROUND_FAKE, 0 } }, // rarely while playing bridge - { GID_HOYLE4, 700, -1, 1, "Code", "doit", -1, -1, { WORKAROUND_FAKE, 0 } }, // when placing a bid in bridge (always), temp var 11, 24, 27, 46, 75, objects compete_tree, compwe_tree, other1_tree, b1 - bugs #3292332 and #3361925 + { GID_HOYLE4, 700, -1, 1, "Code", "doit", -1, -1, { WORKAROUND_FAKE, 0 } }, // when placing a bid in bridge (always), temp var 11, 24, 27, 46, 75, objects compete_tree, compwe_tree, other1_tree, b1 - bugs #5663 and #5794 { GID_HOYLE4, 300, 300, 0, "", "export 2", 0x1d4d, 0, { WORKAROUND_FAKE, 0 } }, // after passing around cards in hearts - { GID_HOYLE4, 400, 400, 1, "GinHand", "calcRuns", -1, 4, { WORKAROUND_FAKE, 0 } }, // sometimes while playing Gin Rummy (e.g. when knocking and placing a card) - bug #3292334 - { GID_HOYLE4, 500, 17, 1, "Character", "say", -1, 504, { WORKAROUND_FAKE, 0 } }, // sometimes while playing Cribbage (e.g. when the opponent says "Last Card") - bug #3292327 - { GID_ISLANDBRAIN, 100, 937, 0, "IconBar", "dispatchEvent", -1, 58, { WORKAROUND_FAKE, 0 } }, // when using ENTER at the startup menu - bug #3045225 + { GID_HOYLE4, 400, 400, 1, "GinHand", "calcRuns", -1, 4, { WORKAROUND_FAKE, 0 } }, // sometimes while playing Gin Rummy (e.g. when knocking and placing a card) - bug #5665 + { GID_HOYLE4, 500, 17, 1, "Character", "say", -1, 504, { WORKAROUND_FAKE, 0 } }, // sometimes while playing Cribbage (e.g. when the opponent says "Last Card") - bug #5662 + { GID_ISLANDBRAIN, 100, 937, 0, "IconBar", "dispatchEvent", -1, 58, { WORKAROUND_FAKE, 0 } }, // when using ENTER at the startup menu - bug #5241 { GID_ISLANDBRAIN, 140, 140, 0, "piece", "init", -1, 3, { WORKAROUND_FAKE, 1 } }, // first puzzle right at the start, some initialization variable. bnt is done on it, and it should be non-0 { GID_ISLANDBRAIN, 200, 268, 0, "anElement", "select", -1, 0, { WORKAROUND_FAKE, 0 } }, // elements puzzle, gets used before super TextIcon { GID_JONES, 1, 232, 0, "weekendText", "draw", 0x3d3, 0, { WORKAROUND_FAKE, 0 } }, // jones/cd only - gets called during the game { GID_JONES, 1, 255, 0, "", "export 0", -1, -1, { WORKAROUND_FAKE, 0 } }, // jones/cd only - called when a game ends, temps 13 and 14 { GID_JONES, 764, 255, 0, "", "export 0", -1, -1, { WORKAROUND_FAKE, 0 } }, // jones/ega&vga only - called when the game starts, temps 13 and 14 - //{ GID_KQ5, -1, 0, 0, "", "export 29", -1, 3, { WORKAROUND_FAKE, 0xf } }, // called when playing harp for the harpies or when aborting dialog in toy shop, is used for kDoAudio - bug #3034700 + //{ GID_KQ5, -1, 0, 0, "", "export 29", -1, 3, { WORKAROUND_FAKE, 0xf } }, // called when playing harp for the harpies or when aborting dialog in toy shop, is used for kDoAudio - bug #4961 // ^^ shouldn't be needed anymore, we got a script patch instead (kq5PatchCdHarpyVolume) { GID_KQ5, 25, 25, 0, "rm025", "doit", -1, 0, { WORKAROUND_FAKE, 0 } }, // inside witch forest, when going to the room where the walking rock is - { GID_KQ5, 55, 55, 0, "helpScript", "doit", -1, 0, { WORKAROUND_FAKE, 0 } }, // when giving the tambourine to the monster in the labyrinth (only happens at one of the locations) - bug #3041262 + { GID_KQ5, 55, 55, 0, "helpScript", "doit", -1, 0, { WORKAROUND_FAKE, 0 } }, // when giving the tambourine to the monster in the labyrinth (only happens at one of the locations) - bug #5198 { GID_KQ5, -1, 755, 0, "gcWin", "open", -1, -1, { WORKAROUND_FAKE, 0 } }, // when entering control menu in the FM-Towns version - { GID_KQ6, -1, 30, 0, "rats", "changeState", -1, -1, { WORKAROUND_FAKE, 0 } }, // rats in the catacombs (temps 1 - 5) - bugs #3034597, #3035495, #3035824 - { GID_KQ6, 210, 210, 0, "rm210", "scriptCheck", -1, 0, { WORKAROUND_FAKE, 1 } }, // using inventory in that room - bug #3034565 + { GID_KQ6, -1, 30, 0, "rats", "changeState", -1, -1, { WORKAROUND_FAKE, 0 } }, // rats in the catacombs (temps 1 - 5) - bugs #4958, #4998, #5017 + { GID_KQ6, 210, 210, 0, "rm210", "scriptCheck", -1, 0, { WORKAROUND_FAKE, 1 } }, // using inventory in that room - bug #4953 { GID_KQ6, 500, 500, 0, "rm500", "init", -1, 0, { WORKAROUND_FAKE, 0 } }, // going to island of the beast { GID_KQ6, 520, 520, 0, "rm520", "init", -1, 0, { WORKAROUND_FAKE, 0 } }, // going to boiling water trap on beast isle { GID_KQ6, -1, 903, 0, "controlWin", "open", -1, 4, { WORKAROUND_FAKE, 0 } }, // when opening the controls window (save, load etc) - { GID_KQ6, -1, 907, 0, "tomato", "doVerb", -1, 2, { WORKAROUND_FAKE, 0 } }, // when looking at the rotten tomato in the inventory - bug #3059544 + { GID_KQ6, -1, 907, 0, "tomato", "doVerb", -1, 2, { WORKAROUND_FAKE, 0 } }, // when looking at the rotten tomato in the inventory - bug #5331 { GID_KQ6, -1, 928, 0, NULL, "startText", -1, 0, { WORKAROUND_FAKE, 0 } }, // gets caused by Text+Audio support (see script patcher) { GID_KQ7, -1, 64996, 0, "User", "handleEvent", -1, 1, { WORKAROUND_FAKE, 0 } }, // called when pushing a keyboard key - { GID_LAURABOW, 37, 0, 0, "CB1", "doit", -1, 1, { WORKAROUND_FAKE, 0 } }, // when going up the stairs (bug #3037694) - { GID_LAURABOW, -1, 967, 0, "myIcon", "cycle", -1, 1, { WORKAROUND_FAKE, 0 } }, // having any portrait conversation coming up (initial bug #3034985) + { GID_LAURABOW, 37, 0, 0, "CB1", "doit", -1, 1, { WORKAROUND_FAKE, 0 } }, // when going up the stairs - bug #5084 + { GID_LAURABOW, -1, 967, 0, "myIcon", "cycle", -1, 1, { WORKAROUND_FAKE, 0 } }, // having any portrait conversation coming up - initial bug #4971 { GID_LAURABOW2, -1, 24, 0, "gcWin", "open", -1, 5, { WORKAROUND_FAKE, 0xf } }, // is used as priority for game menu - { GID_LAURABOW2, -1, 21, 0, "dropCluesCode", "doit", -1, 1, { WORKAROUND_FAKE, 0x7fff } }, // when asking some questions (e.g. the reporter about the burglary, or the policeman about Ziggy). Must be big, as the game scripts perform lt on it and start deleting journal entries - bugs #3035068, #3036274 - { GID_LAURABOW2, -1, 90, 1, "MuseumActor", "init", -1, 6, { WORKAROUND_FAKE, 0 } }, // Random actors in museum (bug #3041257) - { GID_LAURABOW2, 240, 240, 0, "sSteveAnimates", "changeState", -1, 0, { WORKAROUND_FAKE, 0 } }, // Steve Dorian's idle animation at the docks - bug #3036291 + { GID_LAURABOW2, -1, 21, 0, "dropCluesCode", "doit", -1, 1, { WORKAROUND_FAKE, 0x7fff } }, // when asking some questions (e.g. the reporter about the burglary, or the policeman about Ziggy). Must be big, as the game scripts perform lt on it and start deleting journal entries - bugs #4979, #5026 + { GID_LAURABOW2, -1, 90, 1, "MuseumActor", "init", -1, 6, { WORKAROUND_FAKE, 0 } }, // Random actors in museum - bug #5197 + { GID_LAURABOW2, 240, 240, 0, "sSteveAnimates", "changeState", -1, 0, { WORKAROUND_FAKE, 0 } }, // Steve Dorian's idle animation at the docks - bug #5028 { GID_LAURABOW2, -1, 928, 0, NULL, "startText", -1, 0, { WORKAROUND_FAKE, 0 } }, // gets caused by Text+Audio support (see script patcher) - { GID_LONGBOW, -1, 0, 0, "Longbow", "restart", -1, 0, { WORKAROUND_FAKE, 0 } }, // When canceling a restart game - bug #3046200 + { GID_LONGBOW, -1, 0, 0, "Longbow", "restart", -1, 0, { WORKAROUND_FAKE, 0 } }, // When canceling a restart game - bug #5244 { GID_LONGBOW, -1, 213, 0, "clear", "handleEvent", -1, 0, { WORKAROUND_FAKE, 0 } }, // When giving an answer using the druid hand sign code in any room - { GID_LONGBOW, -1, 213, 0, "letter", "handleEvent", 0xa8, 1, { WORKAROUND_FAKE, 0 } }, // When using the druid hand sign code in any room - bug #3036601 + { GID_LONGBOW, -1, 213, 0, "letter", "handleEvent", 0xa8, 1, { WORKAROUND_FAKE, 0 } }, // When using the druid hand sign code in any room - bug #5035 { GID_LSL1, 250, 250, 0, "increase", "handleEvent", -1, 2, { WORKAROUND_FAKE, 0 } }, // casino, playing game, increasing bet { GID_LSL1, 720, 720, 0, "rm720", "init", -1, 0, { WORKAROUND_FAKE, 0 } }, // age check room - { GID_LSL2, 38, 38, 0, "cloudScript", "changeState", -1, 1, { WORKAROUND_FAKE, 0 } }, // entering the room in the middle deck of the ship - bug #3036483 + { GID_LSL2, 38, 38, 0, "cloudScript", "changeState", -1, 1, { WORKAROUND_FAKE, 0 } }, // entering the room in the middle deck of the ship - bug #5034 { GID_LSL3, 340, 340, 0, "ComicScript", "changeState", -1, -1, { WORKAROUND_FAKE, 0 } }, // right after entering the 3 ethnic groups inside comedy club (temps 200, 201, 202, 203) { GID_LSL3, -1, 997, 0, "TheMenuBar", "handleEvent", -1, 1, { WORKAROUND_FAKE, 0xf } }, // when setting volume the first time, this temp is used to set volume on entry (normally it would have been initialized to 's') - { GID_LSL6, 820, 82, 0, "", "export 0", -1, -1, { WORKAROUND_FAKE, 0 } }, // when touching the electric fence - bug #3038326 + { GID_LSL6, 820, 82, 0, "", "export 0", -1, -1, { WORKAROUND_FAKE, 0 } }, // when touching the electric fence - bug #5103 { GID_LSL6, -1, 85, 0, "washcloth", "doVerb", -1, 0, { WORKAROUND_FAKE, 0 } }, // washcloth in inventory { GID_LSL6, -1, 928, -1, "Narrator", "startText", -1, 0, { WORKAROUND_FAKE, 0 } }, // used by various objects that are even translated in foreign versions, that's why we use the base-class { GID_LSL6HIRES, 0, 85, 0, "LL6Inv", "init", -1, 0, { WORKAROUND_FAKE, 0 } }, // on startup { GID_LSL6HIRES, -1, 64950, 1, "Feature", "handleEvent", -1, 0, { WORKAROUND_FAKE, 0 } }, // at least when entering swimming pool area { GID_LSL6HIRES, -1, 64964, 0, "DPath", "init", -1, 1, { WORKAROUND_FAKE, 0 } }, // during the game - { GID_MOTHERGOOSE256, -1, 0, 0, "MG", "doit", -1, 5, { WORKAROUND_FAKE, 0 } }, // SCI1.1: When moving the cursor all the way to the left during the game (bug #3043955) - { GID_MOTHERGOOSE256, -1, 992, 0, "AIPath", "init", -1, 0, { WORKAROUND_FAKE, 0 } }, // Happens in the demo and full version. In the demo, it happens when walking two screens from mother goose's house to the north. In the full version, it happens in rooms 7 and 23 - bug #3049146 - { GID_MOTHERGOOSE256, 90, 90, 0, "introScript", "changeState", -1, 65, { WORKAROUND_FAKE, 0 } }, // SCI1(CD): At the very end, after the game is completed and restarted - bug #3268076 - { GID_MOTHERGOOSE256, 94, 94, 0, "sunrise", "changeState", -1, 367, { WORKAROUND_FAKE, 0 } }, // At the very end, after the game is completed - bug #3051163 + { GID_MOTHERGOOSE256, -1, 0, 0, "MG", "doit", -1, 5, { WORKAROUND_FAKE, 0 } }, // SCI1.1: When moving the cursor all the way to the left during the game - bug #5224 + { GID_MOTHERGOOSE256, -1, 992, 0, "AIPath", "init", -1, 0, { WORKAROUND_FAKE, 0 } }, // Happens in the demo and full version. In the demo, it happens when walking two screens from mother goose's house to the north. In the full version, it happens in rooms 7 and 23 - bug #5269 + { GID_MOTHERGOOSE256, 90, 90, 0, "introScript", "changeState", -1, 65, { WORKAROUND_FAKE, 0 } }, // SCI1(CD): At the very end, after the game is completed and restarted - bug #5626 + { GID_MOTHERGOOSE256, 94, 94, 0, "sunrise", "changeState", -1, 367, { WORKAROUND_FAKE, 0 } }, // At the very end, after the game is completed - bug #5294 { GID_MOTHERGOOSEHIRES,-1,64950, 1, "Feature", "handleEvent", -1, 0, { WORKAROUND_FAKE, 0 } }, // right when clicking on a child at the start and probably also later { GID_MOTHERGOOSEHIRES,-1,64950, 1, "View", "handleEvent", -1, 0, { WORKAROUND_FAKE, 0 } }, // see above - { GID_PEPPER, -1, 894, 0, "Package", "doVerb", -1, 3, { WORKAROUND_FAKE, 0 } }, // using the hand on the book in the inventory - bug #3040012 + { GID_PEPPER, -1, 894, 0, "Package", "doVerb", -1, 3, { WORKAROUND_FAKE, 0 } }, // using the hand on the book in the inventory - bug #5154 { GID_PEPPER, 150, 928, 0, "Narrator", "startText", -1, 0, { WORKAROUND_FAKE, 0 } }, // happens during the non-interactive demo of Pepper { GID_PQ4, -1, 25, 0, "iconToggle", "select", -1, 1, { WORKAROUND_FAKE, 0 } }, // when toggling the icon bar to auto-hide or not { GID_PQSWAT, -1, 64950, 0, "View", "handleEvent", -1, 0, { WORKAROUND_FAKE, 0 } }, // Using the menu in the beginning { GID_QFG1, -1, 210, 0, "Encounter", "init", 0xbd0, 0, { WORKAROUND_FAKE, 0 } }, // hq1: going to the brigands hideout { GID_QFG1, -1, 210, 0, "Encounter", "init", 0xbe4, 0, { WORKAROUND_FAKE, 0 } }, // qfg1: going to the brigands hideout - { GID_QFG1VGA, 16, 16, 0, "lassoFailed", "changeState", -1, -1, { WORKAROUND_FAKE, 0 } }, // qfg1vga: casting the "fetch" spell in the screen with the flowers, temps 0 and 1 - bug #3053268 - { GID_QFG1VGA, -1, 210, 0, "Encounter", "init", 0xcee, 0, { WORKAROUND_FAKE, 0 } }, // qfg1vga: going to the brigands hideout - bug #3109299 + { GID_QFG1VGA, 16, 16, 0, "lassoFailed", "changeState", -1, -1, { WORKAROUND_FAKE, 0 } }, // qfg1vga: casting the "fetch" spell in the screen with the flowers, temps 0 and 1 - bug #5309 + { GID_QFG1VGA, -1, 210, 0, "Encounter", "init", 0xcee, 0, { WORKAROUND_FAKE, 0 } }, // qfg1vga: going to the brigands hideout - bug #5515 { GID_QFG1VGA, -1, 210, 0, "Encounter", "init", 0xce7, 0, { WORKAROUND_FAKE, 0 } }, // qfg1vga: going to room 92 { GID_QFG2, -1, 71, 0, "theInvSheet", "doit", -1, 1, { WORKAROUND_FAKE, 0 } }, // accessing the inventory - { GID_QFG2, -1, 701, -1, "Alley", "at", -1, 0, { WORKAROUND_FAKE, 0 } }, // when walking inside the alleys in the town - bug #3035835 & #3038367 + { GID_QFG2, -1, 701, -1, "Alley", "at", -1, 0, { WORKAROUND_FAKE, 0 } }, // when walking inside the alleys in the town - bug #5019 & #5106 { GID_QFG2, -1, 990, 0, "Restore", "doit", -1, 364, { WORKAROUND_FAKE, 0 } }, // when pressing enter in restore dialog w/o any saved games present - { GID_QFG2, 260, 260, 0, "abdulS", "changeState",0x2d22, -1, { WORKAROUND_FAKE, 0 } }, // During the thief's first mission (in the house), just before Abdul is about to enter the house (where you have to hide in the wardrobe), bug #3039891, temps 1 and 2 - { GID_QFG2, 260, 260, 0, "jabbarS", "changeState",0x2d22, -1, { WORKAROUND_FAKE, 0 } }, // During the thief's first mission (in the house), just before Jabbar is about to enter the house (where you have to hide in the wardrobe), bug #3040469, temps 1 and 2 - { GID_QFG2, 500, 500, 0, "lightNextCandleS", "changeState", -1, -1, { WORKAROUND_FAKE, 0 } }, // Inside the last room, while Ad Avis performs the ritual to summon the genie - bug #3148418 - { GID_QFG2, -1, 700, 0, NULL, "showSign", -1, 10, { WORKAROUND_FAKE, 0 } }, // Occurs sometimes when reading a sign in Raseir, Shapeir et al - bugs #3272735, #3275413 - { GID_QFG3, 510, 510, 0, "awardPrize", "changeState", -1, 0, { WORKAROUND_FAKE, 1 } }, // Simbani warrior challenge, after throwing the spears and retrieving the ring - bug #3049435. Must be non-zero, otherwise the prize is awarded twice - bug #3575570. - { GID_QFG3, 140, 140, 0, "rm140", "init", 0x1008, 0, { WORKAROUND_FAKE, 0 } }, // when importing a character and selecting the previous profession - bug #3040460 - { GID_QFG3, 330, 330, -1, "Teller", "doChild", -1, -1, { WORKAROUND_FAKE, 0 } }, // when talking to King Rajah about "Rajah" (bug #3036390, temp 1) or "Tarna" (temp 0), or when clicking on yourself and saying "Greet" (bug #3039774, temp 1) - { GID_QFG3, 700, 700, -1, "monsterIsDead", "changeState", -1, 0, { WORKAROUND_FAKE, 0 } }, // in the jungle, after winning any fight, bug #3040624 - { GID_QFG3, 470, 470, -1, "rm470", "notify", -1, 0, { WORKAROUND_FAKE, 0 } }, // closing the character screen in the Simbani village in the room with the bridge, bug #3040565 - { GID_QFG3, 490, 490, -1, "computersMove", "changeState", -1, 0, { WORKAROUND_FAKE, 0 } }, // when finishing awari game, bug #3040579 + { GID_QFG2, 260, 260, 0, "abdulS", "changeState",0x2d22, -1, { WORKAROUND_FAKE, 0 } }, // During the thief's first mission (in the house), just before Abdul is about to enter the house (where you have to hide in the wardrobe), bug #5153, temps 1 and 2 + { GID_QFG2, 260, 260, 0, "jabbarS", "changeState",0x2d22, -1, { WORKAROUND_FAKE, 0 } }, // During the thief's first mission (in the house), just before Jabbar is about to enter the house (where you have to hide in the wardrobe), bug #5164, temps 1 and 2 + { GID_QFG2, 500, 500, 0, "lightNextCandleS", "changeState", -1, -1, { WORKAROUND_FAKE, 0 } }, // Inside the last room, while Ad Avis performs the ritual to summon the genie - bug #5566 + { GID_QFG2, -1, 700, 0, NULL, "showSign", -1, 10, { WORKAROUND_FAKE, 0 } }, // Occurs sometimes when reading a sign in Raseir, Shapeir et al - bugs #5627, #5635 + { GID_QFG3, 510, 510, 0, "awardPrize", "changeState", -1, 0, { WORKAROUND_FAKE, 1 } }, // Simbani warrior challenge, after throwing the spears and retrieving the ring - bug #5277. Must be non-zero, otherwise the prize is awarded twice - bug #6160 + { GID_QFG3, 140, 140, 0, "rm140", "init", 0x1008, 0, { WORKAROUND_FAKE, 0 } }, // when importing a character and selecting the previous profession - bug #5163 + { GID_QFG3, 330, 330, -1, "Teller", "doChild", -1, -1, { WORKAROUND_FAKE, 0 } }, // when talking to King Rajah about "Rajah" (bug #5033, temp 1) or "Tarna" (temp 0), or when clicking on yourself and saying "Greet" (bug #5148, temp 1) + { GID_QFG3, 700, 700, -1, "monsterIsDead", "changeState", -1, 0, { WORKAROUND_FAKE, 0 } }, // in the jungle, after winning any fight, bug #5169 + { GID_QFG3, 470, 470, -1, "rm470", "notify", -1, 0, { WORKAROUND_FAKE, 0 } }, // closing the character screen in the Simbani village in the room with the bridge, bug #5165 + { GID_QFG3, 490, 490, -1, "computersMove", "changeState", -1, 0, { WORKAROUND_FAKE, 0 } }, // when finishing awari game, bug #5167 { GID_QFG3, 490, 490, -1, "computersMove", "changeState", 0xf53, 4, { WORKAROUND_FAKE, 0 } }, // also when finishing awari game - { GID_QFG3, 851, 32, -1, "ProjObj", "doit", -1, 1, { WORKAROUND_FAKE, 0 } }, // near the end, when throwing the spear of death, bug #3050122 + { GID_QFG3, 851, 32, -1, "ProjObj", "doit", -1, 1, { WORKAROUND_FAKE, 0 } }, // near the end, when throwing the spear of death, bug #5282 { GID_QFG4, -1, 15, -1, "charInitScreen", "dispatchEvent", -1, 5, { WORKAROUND_FAKE, 0 } }, // floppy version, when viewing the character screen { GID_QFG4, -1, 64917, -1, "controlPlane", "setBitmap", -1, 3, { WORKAROUND_FAKE, 0 } }, // floppy version, when entering the game menu { GID_QFG4, -1, 64917, -1, "Plane", "setBitmap", -1, 3, { WORKAROUND_FAKE, 0 } }, // floppy version, happens sometimes in fight scenes @@ -185,7 +185,7 @@ const SciWorkaroundEntry uninitializedReadWorkarounds[] = { { GID_SQ4, -1, 708, -1, "exitBut", "doVerb", -1, 0, { WORKAROUND_FAKE, 0 } }, // Floppy: happens, when looking at the "close" button in the sq4 hintbook - bug #6447 { GID_SQ4, -1, 708, -1, "prevBut", "doVerb", -1, 0, { WORKAROUND_FAKE, 0 } }, // Floppy: happens, when looking at the "previous" button in the sq4 hintbook - bug #6447 { GID_SQ4, -1, 708, -1, "nextBut", "doVerb", -1, 0, { WORKAROUND_FAKE, 0 } }, // Floppy: happens, when looking at the "next" button in the sq4 hintbook - bug #6447 - { GID_SQ5, 201, 201, 0, "buttonPanel", "doVerb", -1, 0, { WORKAROUND_FAKE, 1 } }, // when looking at the orange or red button - bug #3038563 + { GID_SQ5, 201, 201, 0, "buttonPanel", "doVerb", -1, 0, { WORKAROUND_FAKE, 1 } }, // when looking at the orange or red button - bug #5112 { GID_SQ6, -1, 0, 0, "SQ6", "init", -1, 2, { WORKAROUND_FAKE, 0 } }, // Demo and full version: called when the game starts (demo: room 0, full: room 100) { GID_SQ6, -1, 64950, -1, "Feature", "handleEvent", -1, 0, { WORKAROUND_FAKE, 0 } }, // called when pressing "Start game" in the main menu, when entering the Orion's Belt bar (room 300), and perhaps other places { GID_SQ6, -1, 64964, 0, "DPath", "init", -1, 1, { WORKAROUND_FAKE, 0 } }, // during the game @@ -199,25 +199,25 @@ const SciWorkaroundEntry kAbs_workarounds[] = { { GID_HOYLE1, 2, 2, 0, "room2", "doit", -1, 0, { WORKAROUND_FAKE, 0x3e9 } }, // old maid - called with objects instead of integers { GID_HOYLE1, 3, 3, 0, "room3", "doit", -1, 0, { WORKAROUND_FAKE, 0x3e9 } }, // hearts - called with objects instead of integers { GID_QFG1VGA, -1, -1, 0, NULL, "doit", -1, 0, { WORKAROUND_FAKE, 0x3e9 } }, // when the game is patched with the NRS patch - { GID_QFG3 , -1, -1, 0, NULL, "doit", -1, 0, { WORKAROUND_FAKE, 0x3e9 } }, // when the game is patched with the NRS patch (bugs #3528416, #3528542) + { GID_QFG3 , -1, -1, 0, NULL, "doit", -1, 0, { WORKAROUND_FAKE, 0x3e9 } }, // when the game is patched with the NRS patch - bugs #6042, #6043 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kCelHigh_workarounds[] = { - { GID_KQ5, -1, 255, 0, "deathIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // english floppy: when getting beaten up in the inn and probably more, called with 2nd parameter as object - bug #3037003 + { GID_KQ5, -1, 255, 0, "deathIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // english floppy: when getting beaten up in the inn and probably more, called with 2nd parameter as object - bug #5049 { GID_PQ2, -1, 255, 0, "DIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when showing picture within windows, called with 2nd/3rd parameters as objects - { GID_SQ1, 1, 255, 0, "DIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // DEMO: Called with 2nd/3rd parameters as objects when clicking on the menu - bug #3035720 - { GID_FANMADE, -1, 979, 0, "DIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // In The Gem Scenario and perhaps other fanmade games, this is called with 2nd/3rd parameters as objects - bug #3039679 + { GID_SQ1, 1, 255, 0, "DIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // DEMO: Called with 2nd/3rd parameters as objects when clicking on the menu - bug #5012 + { GID_FANMADE, -1, 979, 0, "DIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // In The Gem Scenario and perhaps other fanmade games, this is called with 2nd/3rd parameters as objects - bug #5144 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kCelWide_workarounds[] = { - { GID_KQ5, -1, 255, 0, "deathIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // english floppy: when getting beaten up in the inn and probably more, called with 2nd parameter as object - bug #3037003 + { GID_KQ5, -1, 255, 0, "deathIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // english floppy: when getting beaten up in the inn and probably more, called with 2nd parameter as object - bug #5049 { GID_PQ2, -1, 255, 0, "DIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when showing picture within windows, called with 2nd/3rd parameters as objects - { GID_SQ1, 1, 255, 0, "DIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // DEMO: Called with 2nd/3rd parameters as objects when clicking on the menu - bug #3035720 - { GID_FANMADE, -1, 979, 0, "DIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // In The Gem Scenario and perhaps other fanmade games, this is called with 2nd/3rd parameters as objects - bug #3039679 + { GID_SQ1, 1, 255, 0, "DIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // DEMO: Called with 2nd/3rd parameters as objects when clicking on the menu - bug #5012 + { GID_FANMADE, -1, 979, 0, "DIcon", "setSize", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // In The Gem Scenario and perhaps other fanmade games, this is called with 2nd/3rd parameters as objects - bug #5144 SCI_WORKAROUNDENTRY_TERMINATOR }; @@ -239,9 +239,9 @@ const SciWorkaroundEntry kDeviceInfo_workarounds[] = { const SciWorkaroundEntry kDisplay_workarounds[] = { { GID_ISLANDBRAIN, 300, 300, 0, "geneDude", "show", -1, 0, { WORKAROUND_IGNORE, 0 } }, // when looking at the gene explanation chart - a parameter is an object { GID_PQ2, 23, 23, 0, "rm23Script", "elements", 0x4ae, 0, { WORKAROUND_IGNORE, 0 } }, // when looking at the 2nd page of pate's file - 0x75 as id - { GID_PQ2, 23, 23, 0, "rm23Script", "elements", 0x4c1, 0, { WORKAROUND_IGNORE, 0 } }, // when looking at the 2nd page of pate's file - 0x75 as id (another pq2 version, bug #3043904) + { GID_PQ2, 23, 23, 0, "rm23Script", "elements", 0x4c1, 0, { WORKAROUND_IGNORE, 0 } }, // when looking at the 2nd page of pate's file - 0x75 as id (another pq2 version, bug #5223) { GID_QFG1, 11, 11, 0, "battle", "<noname90>", -1, 0, { WORKAROUND_IGNORE, 0 } }, // DEMO: When entering battle, 0x75 as id - { GID_SQ4, 397, 0, 0, "", "export 12", -1, 0, { WORKAROUND_IGNORE, 0 } }, // FLOPPY: when going into the computer store (bug #3044044) + { GID_SQ4, 397, 0, 0, "", "export 12", -1, 0, { WORKAROUND_IGNORE, 0 } }, // FLOPPY: when going into the computer store - bug #5227 { GID_SQ4, 391, 391, 0, "doCatalog", "mode", 0x84, 0, { WORKAROUND_IGNORE, 0 } }, // CD: clicking on catalog in roboter sale - a parameter is an object { GID_SQ4, 391, 391, 0, "choosePlug", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // CD: ordering connector in roboter sale - a parameter is an object SCI_WORKAROUNDENTRY_TERMINATOR @@ -249,13 +249,13 @@ const SciWorkaroundEntry kDisplay_workarounds[] = { // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kDirLoop_workarounds[] = { - { GID_KQ4, 4, 992, 0, "Avoid", "doit", -1, 0, { WORKAROUND_IGNORE, 0 } }, // when the ogre catches you in front of his house, second parameter points to the same object as the first parameter, instead of being an integer (the angle) - bug #3042964 + { GID_KQ4, 4, 992, 0, "Avoid", "doit", -1, 0, { WORKAROUND_IGNORE, 0 } }, // when the ogre catches you in front of his house, second parameter points to the same object as the first parameter, instead of being an integer (the angle) - bug #5217 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kDisposeScript_workarounds[] = { - { GID_LAURABOW, 777, 777, 0, "myStab", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // DEMO: after the will is signed, parameter 0 is an object - bug #3034907 + { GID_LAURABOW, 777, 777, 0, "myStab", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // DEMO: after the will is signed, parameter 0 is an object - bug #4967 { GID_QFG1, -1, 64, 0, "rm64", "dispose", -1, 0, { WORKAROUND_IGNORE, 0 } }, // when leaving graveyard, parameter 0 is an object { GID_SQ4, 150, 151, 0, "fightScript", "dispose", -1, 0, { WORKAROUND_IGNORE, 0 } }, // during fight with Vohaul, parameter 0 is an object { GID_SQ4, 150, 152, 0, "driveCloseUp", "dispose", -1, 0, { WORKAROUND_IGNORE, 0 } }, // when choosing "beam download", parameter 0 is an object @@ -264,26 +264,26 @@ const SciWorkaroundEntry kDisposeScript_workarounds[] = { // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kDoSoundFade_workarounds[] = { - { GID_KQ5, 213, 989, 0, "globalSound3", "fade", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // english floppy: when bandits leave the secret temple, parameter 4 is an object - bug #3037594 + { GID_KQ5, 213, 989, 0, "globalSound3", "fade", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // english floppy: when bandits leave the secret temple, parameter 4 is an object - bug #5078 { GID_KQ6, 105, 989, 0, "globalSound", "fade", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // floppy: during intro, parameter 4 is an object - { GID_KQ6, 460, 989, 0, "globalSound2", "fade", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // after pulling the black widow's web on the isle of wonder, parameter 4 is an object - bug #3034567 + { GID_KQ6, 460, 989, 0, "globalSound2", "fade", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // after pulling the black widow's web on the isle of wonder, parameter 4 is an object - bug #4954 { GID_QFG4, -1, 64989, 0, "longSong", "fade", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // CD version: many places, parameter 4 is an object (longSong) - { GID_SQ5, 800, 989, 0, "sq5Music1", "fade", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when cutting the wrong part of Goliath with the laser - bug #3614145 + { GID_SQ5, 800, 989, 0, "sq5Music1", "fade", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when cutting the wrong part of Goliath with the laser - bug #6341 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kGetAngle_workarounds[] = { { GID_FANMADE, 516, 992, 0, "Motion", "init", -1, 0, { WORKAROUND_FAKE, 0 } }, // The Legend of the Lost Jewel Demo (fan made): called with third/fourth parameters as objects - { GID_KQ6, -1, 752, 0, "throwDazzle", "changeState", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // room 740/790 after the Genie is exposed in the Palace (short and long ending), it starts shooting lightning bolts around. An extra 5th parameter is passed - bug #3034610 & #3041734 - { GID_SQ1, -1, 927, 0, "PAvoider", "doit", -1, 0, { WORKAROUND_FAKE, 0 } }, // all rooms in Ulence Flats after getting the Pilot Droid: called with a single parameter when the droid is in Roger's path - bug #3513207 + { GID_KQ6, -1, 752, 0, "throwDazzle", "changeState", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // room 740/790 after the Genie is exposed in the Palace (short and long ending), it starts shooting lightning bolts around. An extra 5th parameter is passed - bug #4959 & #5203 + { GID_SQ1, -1, 927, 0, "PAvoider", "doit", -1, 0, { WORKAROUND_FAKE, 0 } }, // all rooms in Ulence Flats after getting the Pilot Droid: called with a single parameter when the droid is in Roger's path - bug #6016 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kFindKey_workarounds[] = { - { GID_ECOQUEST2, 100, 999, 0, "myList", "contains", -1, 0, { WORKAROUND_FAKE, 0 } }, // When Noah Greene gives Adam the Ecorder, and just before the game gives a demonstration, a null reference to a list is passed - bug #3035186 - { GID_HOYLE4, 300, 999, 0, "Piles", "contains", -1, 0, { WORKAROUND_FAKE, 0 } }, // When passing the three cards in Hearts, a null reference to a list is passed - bug #3292333 + { GID_ECOQUEST2, 100, 999, 0, "myList", "contains", -1, 0, { WORKAROUND_FAKE, 0 } }, // When Noah Greene gives Adam the Ecorder, and just before the game gives a demonstration, a null reference to a list is passed - bug #4987 + { GID_HOYLE4, 300, 999, 0, "Piles", "contains", -1, 0, { WORKAROUND_FAKE, 0 } }, // When passing the three cards in Hearts, a null reference to a list is passed - bug #5664 SCI_WORKAROUNDENTRY_TERMINATOR }; @@ -291,18 +291,18 @@ const SciWorkaroundEntry kFindKey_workarounds[] = { const SciWorkaroundEntry kGraphDrawLine_workarounds[] = { { GID_ISLANDBRAIN, 300, 300, 0, "dudeViewer", "show", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when looking at the gene explanation chart, gets called with 1 extra parameter { GID_SQ1, 43, 43, 0, "someoneDied", "changeState", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when ordering beer, gets called with 1 extra parameter - { GID_SQ1, 71, 71, 0, "destroyXenon", "changeState", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // during the Xenon destruction cutscene (which results in death), gets called with 1 extra parameter - bug #3040894 - { GID_SQ1, 53, 53, 0, "blastEgo", "changeState", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when Roger is found and zapped by the cleaning robot, gets called with 1 extra parameter - bug #3040905 + { GID_SQ1, 71, 71, 0, "destroyXenon", "changeState", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // during the Xenon destruction cutscene (which results in death), gets called with 1 extra parameter - bug #5176 + { GID_SQ1, 53, 53, 0, "blastEgo", "changeState", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when Roger is found and zapped by the cleaning robot, gets called with 1 extra parameter - bug #5177 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kGraphSaveBox_workarounds[] = { { GID_CASTLEBRAIN, 420, 427, 0, "alienIcon", "select", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when selecting a card during the alien card game, gets called with 1 extra parameter - { GID_ISLANDBRAIN, 290, 291, 0, "upElevator", "changeState",0x201f, 0, { WORKAROUND_STILLCALL, 0 } }, // when testing in the elevator puzzle, gets called with 1 argument less - 15 is on stack - bug #3034485 + { GID_ISLANDBRAIN, 290, 291, 0, "upElevator", "changeState",0x201f, 0, { WORKAROUND_STILLCALL, 0 } }, // when testing in the elevator puzzle, gets called with 1 argument less - 15 is on stack - bug #4943 { GID_ISLANDBRAIN, 290, 291, 0, "downElevator", "changeState",0x201f, 0, { WORKAROUND_STILLCALL, 0 } }, // see above { GID_ISLANDBRAIN, 290, 291, 0, "correctElevator", "changeState",0x201f, 0, { WORKAROUND_STILLCALL, 0 } }, // see above (when testing the correct solution) - { GID_PQ3, 202, 202, 0, "MapEdit", "movePt", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when plotting crimes, gets called with 2 extra parameters - bug #3038077 + { GID_PQ3, 202, 202, 0, "MapEdit", "movePt", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when plotting crimes, gets called with 2 extra parameters - bug #5099 SCI_WORKAROUNDENTRY_TERMINATOR }; @@ -332,12 +332,12 @@ const SciWorkaroundEntry kGraphRedrawBox_workarounds[] = { { GID_SQ4, 406, 406, 0, "swimAndShoot", "changeState", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // skateOrama when "swimming" in the air - accidental additional parameter specified { GID_SQ4, 410, 410, 0, "swimAfterEgo", "changeState", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // skateOrama when "swimming" in the air - accidental additional parameter specified { GID_SQ4, 411, 411, 0, "swimAndShoot", "changeState", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // skateOrama when "swimming" in the air - accidental additional parameter specified - { GID_SQ4, 150, 150, 0, "laserScript", "changeState", 0xb2, 0, { WORKAROUND_STILLCALL, 0 } }, // when visiting the pedestral where Roger Jr. is trapped, before trashing the brain icon in the programming chapter, accidental additional parameter specified - bug #3094235 - { GID_SQ4, 150, 150, 0, "laserScript", "changeState", 0x16, 0, { WORKAROUND_STILLCALL, 0 } }, // same as above, for the German version - bug #3116892 + { GID_SQ4, 150, 150, 0, "laserScript", "changeState", 0xb2, 0, { WORKAROUND_STILLCALL, 0 } }, // when visiting the pedestral where Roger Jr. is trapped, before trashing the brain icon in the programming chapter, accidental additional parameter specified - bug #5479 + { GID_SQ4, 150, 150, 0, "laserScript", "changeState", 0x16, 0, { WORKAROUND_STILLCALL, 0 } }, // same as above, for the German version - bug #5527 { GID_SQ4, -1, 704, 0, "shootEgo", "changeState", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // When shot by Droid in Super Computer Maze (Rooms 500, 505, 510...) - accidental additional parameter specified - { GID_KQ5, -1, 981, 0, "myWindow", "dispose", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // Happens in the floppy version, when closing any dialog box, accidental additional parameter specified - bug #3036331 + { GID_KQ5, -1, 981, 0, "myWindow", "dispose", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // Happens in the floppy version, when closing any dialog box, accidental additional parameter specified - bug #5031 { GID_KQ5, -1, 995, 0, "invW", "doit", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // Happens in the floppy version, when closing the inventory window, accidental additional parameter specified - { GID_KQ5, -1, 995, 0, "", "export 0", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // Happens in the floppy version, when opening the gem pouch, accidental additional parameter specified - bug #3039395 + { GID_KQ5, -1, 995, 0, "", "export 0", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // Happens in the floppy version, when opening the gem pouch, accidental additional parameter specified - bug #5138 { GID_KQ5, -1, 403, 0, "KQ5Window", "dispose", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // Happens in the FM Towns version when closing any dialog box, accidental additional parameter specified SCI_WORKAROUNDENTRY_TERMINATOR }; @@ -345,49 +345,49 @@ const SciWorkaroundEntry kGraphRedrawBox_workarounds[] = { // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kGraphUpdateBox_workarounds[] = { { GID_ECOQUEST2, 100, 333, 0, "showEcorder", "changeState", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // necessary workaround for our ecorder script patch, because there isn't enough space to patch the function - { GID_PQ3, 202, 202, 0, "MapEdit", "addPt", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when plotting crimes, gets called with 2 extra parameters - bug #3038077 - { GID_PQ3, 202, 202, 0, "MapEdit", "movePt", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when plotting crimes, gets called with 2 extra parameters - bug #3038077 + { GID_PQ3, 202, 202, 0, "MapEdit", "addPt", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when plotting crimes, gets called with 2 extra parameters - bug #5099 + { GID_PQ3, 202, 202, 0, "MapEdit", "movePt", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when plotting crimes, gets called with 2 extra parameters - bug #5099 { GID_PQ3, 202, 202, 0, "MapEdit", "dispose", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // when plotting crimes, gets called with 2 extra parameters SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kIsObject_workarounds[] = { - { GID_GK1, 50, 999, 0, "List", "eachElementDo", -1, 0, { WORKAROUND_FAKE, 0 } }, // GK1 demo, when asking Grace for messages it gets called with an invalid parameter (type "error") - bug #3034519 - { GID_ISLANDBRAIN, -1, 999, 0, "List", "eachElementDo", -1, 0, { WORKAROUND_FAKE, 0 } }, // when going to the game options, choosing "Info" and selecting anything from the list, gets called with an invalid parameter (type "error") - bug #3035262 + { GID_GK1, 50, 999, 0, "List", "eachElementDo", -1, 0, { WORKAROUND_FAKE, 0 } }, // GK1 demo, when asking Grace for messages it gets called with an invalid parameter (type "error") - bug #4950 + { GID_ISLANDBRAIN, -1, 999, 0, "List", "eachElementDo", -1, 0, { WORKAROUND_FAKE, 0 } }, // when going to the game options, choosing "Info" and selecting anything from the list, gets called with an invalid parameter (type "error") - bug #4989 { GID_QFG3, -1, 999, 0, "List", "eachElementDo", -1, 0, { WORKAROUND_FAKE, 0 } }, // when asking for something, gets called with type error parameter SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kMemory_workarounds[] = { - { GID_LAURABOW2, -1, 999, 0, "", "export 6", -1, 0, { WORKAROUND_FAKE, 0 } }, // during the intro, when exiting the train (room 160), talking to Mr. Augustini, etc. - bug #3034490 - { GID_SQ1, -1, 999, 0, "", "export 6", -1, 0, { WORKAROUND_FAKE, 0 } }, // during walking Roger around Ulence Flats - bug #3513765 + { GID_LAURABOW2, -1, 999, 0, "", "export 6", -1, 0, { WORKAROUND_FAKE, 0 } }, // during the intro, when exiting the train (room 160), talking to Mr. Augustini, etc. - bug #4944 + { GID_SQ1, -1, 999, 0, "", "export 6", -1, 0, { WORKAROUND_FAKE, 0 } }, // during walking Roger around Ulence Flats - bug #6017 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kMoveCursor_workarounds[] = { - { GID_KQ5, -1, 937, 0, "IconBar", "handleEvent", -1, 0, { WORKAROUND_IGNORE, 0 } }, // when pressing escape to open the menu, gets called with one parameter instead of 2 - bug #3156472 + { GID_KQ5, -1, 937, 0, "IconBar", "handleEvent", -1, 0, { WORKAROUND_IGNORE, 0 } }, // when pressing escape to open the menu, gets called with one parameter instead of 2 - bug #5575 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kNewWindow_workarounds[] = { - { GID_ECOQUEST, -1, 981, 0, "SysWindow", "open", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // EcoQuest 1 demo uses an in-between interpreter from SCI1 to SCI1.1. It's SCI1.1, but uses the SCI1 semantics for this call - bug #3035057 + { GID_ECOQUEST, -1, 981, 0, "SysWindow", "open", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // EcoQuest 1 demo uses an in-between interpreter from SCI1 to SCI1.1. It's SCI1.1, but uses the SCI1 semantics for this call - bug #4976 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kReadNumber_workarounds[] = { - { GID_CNICK_LAURABOW,100, 101, 0, "dominoes.opt", "doit", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // When dominoes.opt is present, the game scripts call kReadNumber with an extra integer parameter - bug #3615120 - { GID_HOYLE3, 100, 101, 0, "dominoes.opt", "doit", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // When dominoes.opt is present, the game scripts call kReadNumber with an extra integer parameter - bug #3615120 + { GID_CNICK_LAURABOW,100, 101, 0, "dominoes.opt", "doit", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // When dominoes.opt is present, the game scripts call kReadNumber with an extra integer parameter - bug #6425 + { GID_HOYLE3, 100, 101, 0, "dominoes.opt", "doit", -1, 0, { WORKAROUND_STILLCALL, 0 } }, // When dominoes.opt is present, the game scripts call kReadNumber with an extra integer parameter - bug #6425 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kPaletteUnsetFlag_workarounds[] = { - { GID_QFG4, 100, 100, 0, "doMovie", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // after the Sierra logo, no flags are passed, thus the call is meaningless - bug #3034506 + { GID_QFG4, 100, 100, 0, "doMovie", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // after the Sierra logo, no flags are passed, thus the call is meaningless - bug #4947 SCI_WORKAROUNDENTRY_TERMINATOR }; @@ -400,28 +400,28 @@ const SciWorkaroundEntry kSetCursor_workarounds[] = { // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kSetPort_workarounds[] = { { GID_LSL6, 740, 740, 0, "rm740", "drawPic", -1, 0, { WORKAROUND_IGNORE, 0 } }, // ending scene, is called with additional 3 (!) parameters - { GID_QFG3, 830, 830, 0, "portalOpens", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // when the portal appears during the end, gets called with 4 parameters (bug #3040844) + { GID_QFG3, 830, 830, 0, "portalOpens", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // when the portal appears during the end, gets called with 4 parameters - bug #5174 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kStrAt_workarounds[] = { - { GID_CASTLEBRAIN, 220, 220, 0, "robotJokes", "animateOnce", -1, 0, { WORKAROUND_FAKE, 0 } }, // when trying to view the terminal at the end of the maze without having collected any robot jokes - bug #3039036 - { GID_ISLANDBRAIN, 300, 310, 0, "childBreed", "changeState",0x1c7c, 0, { WORKAROUND_FAKE, 0 } }, // when clicking Breed to get the second-generation cyborg hybrid (Standard difficulty), the two parameters are swapped - bug #3037835 + { GID_CASTLEBRAIN, 220, 220, 0, "robotJokes", "animateOnce", -1, 0, { WORKAROUND_FAKE, 0 } }, // when trying to view the terminal at the end of the maze without having collected any robot jokes - bug #5127 + { GID_ISLANDBRAIN, 300, 310, 0, "childBreed", "changeState",0x1c7c, 0, { WORKAROUND_FAKE, 0 } }, // when clicking Breed to get the second-generation cyborg hybrid (Standard difficulty), the two parameters are swapped - bug #5088 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kStrLen_workarounds[] = { - { GID_QFG2, 210, 2, 0, "", "export 21", 0xdeb, 0, { WORKAROUND_FAKE, 0 } }, // When saying something incorrect at the WIT, an integer is passed instead of a reference - bug #3100292 + { GID_QFG2, 210, 2, 0, "", "export 21", 0xdeb, 0, { WORKAROUND_FAKE, 0 } }, // When saying something incorrect at the WIT, an integer is passed instead of a reference - bug #5489 SCI_WORKAROUNDENTRY_TERMINATOR }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry kUnLoad_workarounds[] = { { GID_ECOQUEST, 380, 61, 0, "gotIt", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // CD version: after talking to the dolphin the first time, a 3rd parameter is passed by accident - { GID_ECOQUEST, 380, 69, 0, "lookAtBlackBoard", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // German version, when closing the blackboard closeup in the dolphin room, a 3rd parameter is passed by accident - bug #3098353 - { GID_LAURABOW2, -1, -1, 0, "sCartoon", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // DEMO: during the intro, a 3rd parameter is passed by accident - bug #3034902 + { GID_ECOQUEST, 380, 69, 0, "lookAtBlackBoard", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // German version, when closing the blackboard closeup in the dolphin room, a 3rd parameter is passed by accident - bug #5483 + { GID_LAURABOW2, -1, -1, 0, "sCartoon", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // DEMO: during the intro, a 3rd parameter is passed by accident - bug #4966 { GID_LSL6, 130, 130, 0, "recruitLarryScr", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // during intro, a 3rd parameter is passed by accident { GID_LSL6, 740, 740, 0, "showCartoon", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // during ending, 4 additional parameters are passed by accident { GID_LSL6HIRES, 130, 130, 0, "recruitLarryScr", "changeState", -1, 0, { WORKAROUND_IGNORE, 0 } }, // during intro, a 3rd parameter is passed by accident @@ -487,7 +487,7 @@ SciWorkaroundSolution trackOriginAndFindWorkaround(int index, const SciWorkaroun // Special case: in the fanmade Russian translation of SQ4, all // of the object names have been deleted or renamed to Russian, - // thus we disable checking of the object name. Fixes bug #3155550. + // thus we disable checking of the object name. Fixes bug #5573. if (g_sci->getLanguage() == Common::RU_RUS && g_sci->getGameId() == GID_SQ4) objectNameMatches = true; diff --git a/engines/sci/graphics/picture.cpp b/engines/sci/graphics/picture.cpp index 8ad4f535f9..7d7bca22a1 100644 --- a/engines/sci/graphics/picture.cpp +++ b/engines/sci/graphics/picture.cpp @@ -783,7 +783,13 @@ void GfxPicture::drawVectorData(byte *data, int dataSize) { case PIC_OPX_VGA_EMBEDDED_VIEW: // draw cel vectorGetAbsCoordsNoMirror(data, curPos, x, y); size = READ_LE_UINT16(data + curPos); curPos += 2; - _priority = pic_priority; // set global priority so the cel gets drawn using current priority as well + if (getSciVersion() <= SCI_VERSION_1_EARLY) { + // During SCI1Early sierra always used 0 as priority for cels inside picture resources + // fixes Space Quest 4 orange ship lifting off (bug #6446) + _priority = 0; + } else { + _priority = pic_priority; // set global priority so the cel gets drawn using current priority as well + } drawCelData(data, _resource->size, curPos, curPos + 8, 0, x, y, 0, 0); curPos += size; break; @@ -967,6 +973,12 @@ void GfxPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority, by _screen->putPixel(--w, p.y, screenMask, color, priority, control); while (e < r && (matchedMask = _screen->isFillMatch(e + 1, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA))) _screen->putPixel(++e, p.y, screenMask, color, priority, control); +#if 0 + // debug code for floodfill + _screen->copyToScreen(); + g_system->updateScreen(); + g_system->delayMillis(100); +#endif // checking lines above and below for possible flood targets a_set = b_set = 0; while (w <= e) { diff --git a/engines/sci/graphics/portrait.cpp b/engines/sci/graphics/portrait.cpp index 7217af51f7..d589ee17f9 100644 --- a/engines/sci/graphics/portrait.cpp +++ b/engines/sci/graphics/portrait.cpp @@ -176,26 +176,40 @@ void Portrait::init() { // last 4 bytes seem to be garbage } +// use this to print out kPortrait debug data +//#define DEBUG_PORTRAIT +// use this to use sync resources instead of rave resources (rave resources are better though) +//#define DEBUG_PORTRAIT_USE_SYNC_RESOURCES + void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq) { _position = position; // Now init audio and sync resource uint32 audioNumber = ((noun & 0xff) << 24) | ((verb & 0xff) << 16) | ((cond & 0xff) << 8) | (seq & 0xff); - //ResourceId syncResourceId = ResourceId(kResourceTypeSync36, resourceId, noun, verb, cond, seq); - //Resource *syncResource = _resMan->findResource(syncResourceId, true); +#ifndef DEBUG_PORTRAIT_USE_SYNC_RESOURCES ResourceId raveResourceId = ResourceId(kResourceTypeRave, resourceId, noun, verb, cond, seq); Resource *raveResource = _resMan->findResource(raveResourceId, true); - -#if 0 + uint raveOffset = 0; +#else + ResourceId syncResourceId = ResourceId(kResourceTypeSync36, resourceId, noun, verb, cond, seq); + Resource *syncResource = _resMan->findResource(syncResourceId, true); uint syncOffset = 0; #endif + +#ifdef DEBUG_PORTRAIT + // prints out the current lip sync ASCII data + char debugPrint[4000]; + if (raveResource->size < 4000) { + memcpy(debugPrint, raveResource->data, raveResource->size); + debugPrint[raveResource->size] = 0; // set terminating NUL + debug("kPortrait (noun %d, verb %d, cond %d, seq %d)", noun, verb, cond, seq); + debug("kPortrait: %s", debugPrint); + } +#endif - // TODO: play through the game if this is 100% accurate // TODO: maybe try to create the missing sync resources for low-res KQ6 out of the rave resources - uint raveOffset = 0; - -#if 0 +#ifdef DEBUG_PORTRAIT_USE_SYNC_RESOURCES // Dump the sync resources to disk Common::DumpFile *outFile = new Common::DumpFile(); Common::String outName = syncResourceId.toPatchNameBase36() + ".sync36"; @@ -226,7 +240,8 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint // Start playing audio... _audio->stopAudio(); _audio->startAudio(resourceId, audioNumber); - + +#ifndef DEBUG_PORTRAIT_USE_SYNC_RESOURCES if (!raveResource) { warning("kPortrait: no rave resource %d %X", resourceId, audioNumber); return; @@ -309,9 +324,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint } } } - -// old sync resource code -#if 0 +#else if (!syncResource) { // Getting the book in the book shop calls kPortrait where no sync exists // TODO: find out what to do then @@ -359,17 +372,17 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint } } #endif - + + // Reset the portrait bitmap to "closed mouth" state (rave.dll seems to do the same) + drawBitmap(0); + bitsShow(); if (userAbort) { - // Reset the portrait bitmap to "closed mouth" state, when skipping dialogs - drawBitmap(0); - bitsShow(); _audio->stopAudio(); } +#ifndef DEBUG_PORTRAIT_USE_SYNC_RESOURCES _resMan->unlockResource(raveResource); - -#if 0 +#else _resMan->unlockResource(syncResource); #endif } diff --git a/engines/sci/graphics/view.cpp b/engines/sci/graphics/view.cpp index 36aaae9232..3d72743ff4 100644 --- a/engines/sci/graphics/view.cpp +++ b/engines/sci/graphics/view.cpp @@ -55,6 +55,56 @@ static const byte EGAmappingStraight[SCI_VIEW_EGAMAPPING_SIZE] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; +static const byte ViewInject_LauraBow2_Dual[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x37,0x37,0x37,0x37,0x00,0x00,0x37,0x37,0x00,0x00,0x37,0x37,0x00,0x00,0x00,0x37,0x37,0x37,0x00,0x00,0x37,0x37,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x08,0x08,0x08,0x08,0x37,0x00,0x37,0x08,0x32,0x00,0x37,0x08,0x32,0x00,0x37,0x08,0x08,0x08,0x37,0x00,0x37,0x08,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x08,0x33,0x32,0x37,0x08,0x00,0x37,0x08,0x32,0x00,0x37,0x08,0x32,0x37,0x08,0x32,0x32,0x33,0x08,0x32,0x37,0x08,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x08,0x32,0x00,0x37,0x08,0x32,0x37,0x08,0x32,0x00,0x37,0x08,0x32,0x37,0x08,0x33,0x37,0x37,0x08,0x32,0x37,0x08,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x08,0x32,0x00,0x37,0x08,0x32,0x37,0x08,0x32,0x00,0x37,0x08,0x32,0x37,0x08,0x08,0x08,0x08,0x08,0x32,0x37,0x08,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x08,0x32,0x00,0x37,0x08,0x32,0x37,0x08,0x32,0x00,0x37,0x08,0x32,0x37,0x08,0x32,0x32,0x33,0x08,0x32,0x37,0x08,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x08,0x33,0x37,0x37,0x08,0x32,0x37,0x08,0x33,0x37,0x37,0x08,0x32,0x37,0x08,0x32,0x00,0x37,0x08,0x32,0x37,0x08,0x33,0x37,0x37,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x08,0x08,0x08,0x08,0x32,0x00,0x00,0x37,0x08,0x08,0x08,0x32,0x00,0x37,0x08,0x32,0x00,0x37,0x08,0x32,0x37,0x08,0x08,0x08,0x08,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x32,0x32,0x32,0x00,0x00,0x00,0x00,0x32,0x32,0x32,0x00,0x00,0x00,0x32,0x32,0x00,0x00,0x32,0x32,0x00,0x32,0x32,0x32,0x32,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +}; + +static const byte ViewInject_KingsQuest6_Dual1[] = { + 0x17,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x13, + 0x17,0x17,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x13,0x11, + 0x16,0x17,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x11, + 0x16,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x17,0x16,0x16,0x16,0x16,0x13,0x13,0x17,0x16,0x13,0x13,0x17,0x16,0x13,0x13,0x13,0x17,0x16,0x16,0x13,0x13,0x17,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x11, + 0x16,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x16,0x10,0x10,0x10,0x10,0x16,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x10,0x10,0x16,0x13,0x16,0x10,0x11,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x11, + 0x16,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x16,0x10,0x11,0x11,0x16,0x10,0x11,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x16,0x10,0x11,0x11,0x13,0x10,0x11,0x16,0x10,0x11,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x11, + 0x16,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x16,0x10,0x13,0x16,0x16,0x10,0x11,0x16,0x10,0x11,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x11, + 0x16,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x16,0x10,0x10,0x10,0x10,0x10,0x11,0x16,0x10,0x11,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x11, + 0x16,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x16,0x10,0x11,0x11,0x13,0x10,0x11,0x16,0x10,0x11,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x11, + 0x16,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x16,0x10,0x13,0x16,0x16,0x10,0x11,0x16,0x10,0x13,0x16,0x16,0x10,0x11,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x16,0x10,0x13,0x16,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x11, + 0x16,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x16,0x10,0x10,0x10,0x10,0x11,0x11,0x13,0x16,0x10,0x10,0x10,0x11,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x13,0x10,0x10,0x10,0x10,0x11,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x11, + 0x16,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x11,0x11,0x11,0x11,0x13,0x13,0x13,0x11,0x11,0x11,0x13,0x13,0x13,0x11,0x11,0x13,0x13,0x11,0x11,0x13,0x11,0x11,0x11,0x11,0x11,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x11, + 0x16,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x11, + 0x16,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, + 0x13,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x11 +}; + +static const byte ViewInject_KingsQuest6_Dual2[] = { + 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, + 0x10,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x10, + 0x10,0x13,0x16,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x11,0x10,0x10, + 0x10,0x13,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x16,0x13,0x13,0x13,0x13,0x11,0x11,0x16,0x13,0x11,0x11,0x16,0x13,0x11,0x11,0x11,0x16,0x13,0x13,0x11,0x11,0x16,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x10, + 0x10,0x13,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x16,0x16,0x16,0x16,0x13,0x11,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x13,0x16,0x16,0x16,0x13,0x11,0x13,0x16,0x10,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x10, + 0x10,0x13,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x16,0x10,0x10,0x13,0x16,0x10,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x13,0x16,0x10,0x10,0x11,0x16,0x10,0x13,0x16,0x10,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x10, + 0x10,0x13,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x13,0x16,0x11,0x13,0x13,0x16,0x10,0x13,0x16,0x10,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x10, + 0x10,0x13,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x13,0x16,0x16,0x16,0x16,0x16,0x10,0x13,0x16,0x10,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x10, + 0x10,0x13,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x13,0x16,0x10,0x10,0x11,0x16,0x10,0x13,0x16,0x10,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x10, + 0x10,0x13,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x16,0x11,0x13,0x13,0x16,0x10,0x13,0x16,0x11,0x13,0x13,0x16,0x10,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x13,0x16,0x11,0x13,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x10, + 0x10,0x13,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x16,0x16,0x16,0x16,0x10,0x10,0x11,0x13,0x16,0x16,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x13,0x16,0x10,0x11,0x16,0x16,0x16,0x16,0x10,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x10, + 0x10,0x13,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x10,0x10,0x10,0x10,0x11,0x11,0x11,0x10,0x10,0x10,0x11,0x11,0x11,0x10,0x10,0x11,0x11,0x10,0x10,0x11,0x10,0x10,0x10,0x10,0x10,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x10, + 0x10,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x10, + 0x10,0x11,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, + 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10 +}; + void GfxView::initData(GuiResourceId resourceId) { _resource = _resMan->findResource(ResourceId(kResourceTypeView, resourceId), true); if (!_resource) { @@ -316,6 +366,68 @@ void GfxView::initData(GuiResourceId resourceId) { default: error("ViewType was not detected, can't continue"); } + + // Inject our own views + // Currently only used for Dual mode (speech + text) for games, that do not have a "dual" icon already + // Which is Laura Bow 2 + King's Quest 6 + switch (g_sci->getGameId()) { + case GID_LAURABOW2: + // View 995, Loop 13, Cel 0 = "TEXT" + // View 995, Loop 13, Cel 1 = "SPEECH" + // View 995, Loop 13, Cel 2 = "DUAL" (<- our injected view) + if ((g_sci->isCD()) && (resourceId == 995)) { + // security checks + if (_loopCount >= 14) { + if ((_loop[13].celCount == 2) && (_loop[13].cel[0].width == 46) && (_loop[13].cel[0].height == 11)) { + // copy current cels over + CelInfo *newCels = new CelInfo[3]; + memcpy(newCels, _loop[13].cel, sizeof(CelInfo) * 2); + delete[] _loop[13].cel; + _loop[13].celCount++; + _loop[13].cel = newCels; + // Duplicate cel 0 to cel 2 + memcpy(&_loop[13].cel[2], &_loop[13].cel[0], sizeof(CelInfo)); + // copy over our data (which is uncompressed bitmap data) + _loop[13].cel[2].rawBitmap = new byte[sizeof(ViewInject_LauraBow2_Dual)]; + memcpy(_loop[13].cel[2].rawBitmap, ViewInject_LauraBow2_Dual, sizeof(ViewInject_LauraBow2_Dual)); + } + } + } + break; + case GID_KQ6: + // View 947, Loop 8, Cel 0 = "SPEECH" (not pressed) + // View 947, Loop 8, Cel 1 = "SPEECH" (pressed) + // View 947, Loop 9, Cel 0 = "TEXT" (not pressed) + // View 947, Loop 9, Cel 1 = "TEXT" (pressed) + // View 947, Loop 12, Cel 0 = "DUAL" (not pressed) (<- our injected view) + // View 947, Loop 12, Cel 1 = "DUAL" (pressed) (<- our injected view) + if ((g_sci->isCD()) && (resourceId == 947)) { + // security checks + if (_loopCount == 12) { + if ((_loop[8].celCount == 2) && (_loop[8].cel[0].width == 50) && (_loop[8].cel[0].height == 15)) { + // add another loop + LoopInfo *newLoops = new LoopInfo[_loopCount + 1]; + memcpy(newLoops, _loop, sizeof(LoopInfo) * _loopCount); + delete[] _loop; + _loop = newLoops; + _loopCount++; + // copy loop 8 to loop 12 + memcpy(&_loop[12], &_loop[8], sizeof(LoopInfo)); + _loop[12].cel = new CelInfo[2]; + // duplicate all cels of loop 8 and into loop 12 + memcpy(_loop[12].cel, _loop[8].cel, sizeof(CelInfo) * _loop[8].celCount); + // copy over our data (which is uncompressed bitmap data) + _loop[12].cel[0].rawBitmap = new byte[sizeof(ViewInject_KingsQuest6_Dual1)]; + memcpy(_loop[12].cel[0].rawBitmap, ViewInject_KingsQuest6_Dual1, sizeof(ViewInject_KingsQuest6_Dual1)); + _loop[12].cel[1].rawBitmap = new byte[sizeof(ViewInject_KingsQuest6_Dual2)]; + memcpy(_loop[12].cel[1].rawBitmap, ViewInject_KingsQuest6_Dual2, sizeof(ViewInject_KingsQuest6_Dual2)); + } + } + } + break; + default: + break; + } } GuiResourceId GfxView::getResourceId() const { diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index ff804af4b4..f32e0e16f9 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -913,12 +913,10 @@ void SciEngine::syncIngameAudioOptions() { case GID_FREDDYPHARKAS: case GID_ECOQUEST: case GID_LSL6: - _gamestate->variables[VAR_GLOBAL][90] = make_reg(0, 3); // speech + subtitles - break; case GID_LAURABOW2: case GID_KQ6: - // Laura Bow 2 + King's Quest 6 get patched when speech and subtitles are enabled - // When the user has "speech" selected, the game will then do both That's why we select speech here + _gamestate->variables[VAR_GLOBAL][90] = make_reg(0, 3); // speech + subtitles + break; default: // Game does not support speech and subtitles, set it to speech _gamestate->variables[VAR_GLOBAL][90] = make_reg(0, 2); // speech @@ -932,8 +930,6 @@ void SciEngine::updateScummVMAudioOptions() { // depending on the in-game settings if (isCD() && getSciVersion() == SCI_VERSION_1_1) { uint16 ingameSetting = _gamestate->variables[VAR_GLOBAL][90].getOffset(); - bool subtitlesOn = ConfMan.getBool("subtitles"); - bool speechOn = !ConfMan.getBool("speech_mute"); switch (ingameSetting) { case 1: @@ -943,17 +939,6 @@ void SciEngine::updateScummVMAudioOptions() { break; case 2: // speech - switch (_gameId) { - case GID_LAURABOW2: - case GID_KQ6: - // We don't sync "speech" for Laura Bow 2 in case the user choose "both" in the setting - // Because "speech" (2) within SCI means "speech + subtitles" for Laura Bow 2 - if (subtitlesOn && speechOn) - return; - break; - default: - break; - } ConfMan.setBool("subtitles", false); ConfMan.setBool("speech_mute", false); break; diff --git a/engines/tinsel/detection_tables.h b/engines/tinsel/detection_tables.h index cc8166f295..6e83fce3b1 100644 --- a/engines/tinsel/detection_tables.h +++ b/engines/tinsel/detection_tables.h @@ -319,7 +319,7 @@ static const TinselGameDescription gameDescriptions[] = { }, Common::DE_DEU, Common::kPlatformDOS, - ADGF_DROPLANGUAGE, + ADGF_DROPLANGUAGE | ADGF_CD, GUIO0() }, GID_DW1, diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index a732862854..02991975ce 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -40,7 +40,7 @@ namespace Tony { \****************************************************************************/ RMWindow::RMWindow() { - _showDirtyRects = false; + reset(); } RMWindow::~RMWindow() { @@ -55,11 +55,21 @@ RMWindow::~RMWindow() { void RMWindow::init() { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); initGraphics(RM_SX, RM_SY, true, &pixelFormat); + + reset(); +} +/** + * Reset the variables + */ +void RMWindow::reset() { + _showDirtyRects = false; _bGrabScreenshot = false; _bGrabThumbnail = false; _bGrabMovie = false; _wiping = false; + + _wThumbBuf = nullptr; } void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { diff --git a/engines/tony/window.h b/engines/tony/window.h index 3874652f64..2cc9bfd37c 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -72,6 +72,7 @@ public: * Initialization */ void init(); + void reset(); void close(); /** diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index be5fb4c7b7..c8a0117bcf 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -875,7 +875,6 @@ void PalettedScene::synchronize(Serializer &s) { void PalettedScene::postInit(SceneObjectList *OwnerList) { _hasFader = false; - _palette._field412 = 1; SceneExt::postInit(OwnerList); } @@ -890,8 +889,6 @@ void PalettedScene::remove() { BF_GLOBALS._scenePalette.loadPalette(2); BF_GLOBALS._sceneManager._hasPalette = true; } - - BF_GLOBALS._scenePalette._field412 = 0; } PaletteFader *PalettedScene::addFader(const byte *arrBufferRGB, int step, Action *action) { diff --git a/engines/tsage/blue_force/blueforce_scenes2.cpp b/engines/tsage/blue_force/blueforce_scenes2.cpp index 1b0ed2a145..e444c8b91d 100644 --- a/engines/tsage/blue_force/blueforce_scenes2.cpp +++ b/engines/tsage/blue_force/blueforce_scenes2.cpp @@ -1748,7 +1748,7 @@ void Scene280::Action1::signal() { case 1: scene->_jake.setStrip(2); scene->_jake.setFrame(1); - scene->_jake.animate(ANIM_MODE_8, NULL); + scene->_jake.animate(ANIM_MODE_8, 0, NULL); scene->_jake._numFrames = 5; scene->_stripManager.start(2800, this); diff --git a/engines/tsage/blue_force/blueforce_scenes4.cpp b/engines/tsage/blue_force/blueforce_scenes4.cpp index e4a349bc93..2b4c0ff348 100644 --- a/engines/tsage/blue_force/blueforce_scenes4.cpp +++ b/engines/tsage/blue_force/blueforce_scenes4.cpp @@ -295,9 +295,9 @@ bool Scene410::Driver::startAction(CursorType action, Event &event) { } } else if (!scene->_cuffedDriverFl) { SceneItem::display2(410, 7); - } else if (!scene->_field1FC0) { + } else if (!scene->_getDriverFl) { scene->_sceneMode = 4124; - scene->_field1FC0 = true; + scene->_getDriverFl = true; T2_GLOBALS._uiElements.addScore(30); scene->signal(); } else { @@ -483,7 +483,7 @@ bool Scene410::Harrison::startAction(CursorType action, Event &event) { } else { BF_GLOBALS._player.disableControl(); scene->_cuffedDriverFl = true; - scene->_field1FC0 = true; + scene->_getDriverFl = true; BF_GLOBALS._walkRegions.enableRegion(22); scene->_sceneMode = 4109; scene->_stripManager.start(4112, scene); @@ -505,7 +505,7 @@ Scene410::Scene410(): SceneExt() { _action1Count = _talkCount = 0; _cuffedPassengerFl = false; - _field1FC0 = false; + _getDriverFl = false; } void Scene410::synchronize(Serializer &s) { @@ -515,7 +515,7 @@ void Scene410::synchronize(Serializer &s) { s.syncAsSint16LE(_harrissonTalkFl); s.syncAsSint16LE(_cuffedDriverFl); s.syncAsSint16LE(_cuffedPassengerFl); - s.syncAsSint16LE(_field1FC0); + s.syncAsSint16LE(_getDriverFl); s.syncAsSint16LE(_driverOutOfTruckFl); s.syncAsSint16LE(_harrisonMovedFl); } diff --git a/engines/tsage/blue_force/blueforce_scenes4.h b/engines/tsage/blue_force/blueforce_scenes4.h index 92e91c93b2..e5877df4f0 100644 --- a/engines/tsage/blue_force/blueforce_scenes4.h +++ b/engines/tsage/blue_force/blueforce_scenes4.h @@ -120,7 +120,7 @@ public: bool _harrissonTalkFl; bool _cuffedDriverFl; bool _cuffedPassengerFl; - bool _field1FC0; + bool _getDriverFl; bool _driverOutOfTruckFl, _harrisonMovedFl; Scene410(); diff --git a/engines/tsage/blue_force/blueforce_scenes9.cpp b/engines/tsage/blue_force/blueforce_scenes9.cpp index 2b42dc8625..405a436f55 100644 --- a/engines/tsage/blue_force/blueforce_scenes9.cpp +++ b/engines/tsage/blue_force/blueforce_scenes9.cpp @@ -2977,7 +2977,6 @@ bool Scene920::Item8::startAction(CursorType action, Event &event) { // On the other hand, it's not really important as just after the hero leaves the scene // so the variable is no longer used. // scene->_oldCoord = &scene; - _field10 = 1; } else { scene->_sceneMode = 9201; scene->setAction(&scene->_sequenceManager1, scene, 9201, &BF_GLOBALS._player, NULL); diff --git a/engines/tsage/converse.cpp b/engines/tsage/converse.cpp index f7c1dd24e6..ba8cfb82a9 100644 --- a/engines/tsage/converse.cpp +++ b/engines/tsage/converse.cpp @@ -648,11 +648,11 @@ void StripManager::reset() { _delayFrames = 0; _owner = NULL; _endHandler = NULL; - _field2E6 = false; + _uselessFl = false; _stripNum = -1; - _obj44Index = 0; - _field2E8 = 0; - _field20 = 0; + _obj44ListIndex = 0; + _currObj44Id = 0; + _useless = 0; _activeSpeaker = NULL; _textShown = false; _callbackObject = NULL; @@ -696,14 +696,14 @@ void StripManager::synchronize(Serializer &s) { Action::synchronize(s); s.syncAsSint32LE(_stripNum); - s.syncAsSint32LE(_obj44Index); - s.syncAsSint32LE(_field20); + s.syncAsSint32LE(_obj44ListIndex); + s.syncAsSint32LE(_useless); s.syncAsSint32LE(_sceneNumber); _sceneBounds.synchronize(s); SYNC_POINTER(_activeSpeaker); s.syncAsByte(_textShown); - s.syncAsByte(_field2E6); - s.syncAsSint32LE(_field2E8); + s.syncAsByte(_uselessFl); + s.syncAsSint32LE(_currObj44Id); if (g_vm->getGameID() == GType_Ringworld2) s.syncAsSint16LE(_exitMode); @@ -785,14 +785,14 @@ void StripManager::signal() { _textShown = false; } - if (_obj44Index < 0) { + if (_obj44ListIndex < 0) { EventHandler *owner = _endHandler; - int stripNum = ABS(_obj44Index); + int stripNum = ABS(_obj44ListIndex); remove(); start(stripNum, owner); return; - } else if (_obj44Index == 10000) { + } else if (_obj44ListIndex == 10000) { // Reached end of strip EventHandler *endHandler = _endHandler; remove(); @@ -809,7 +809,7 @@ void StripManager::signal() { // Load the data for the strip load(); - Obj44 &obj44 = _obj44List[_obj44Index]; + Obj44 &obj44 = _obj44List[_obj44ListIndex]; if (g_vm->getGameID() == GType_Ringworld2) { // Return to Ringworld specific handling @@ -831,7 +831,7 @@ void StripManager::signal() { } } - _field2E8 = obj44._id; + _currObj44Id = obj44._id; Common::StringArray choiceList; // Build up a list of script entries @@ -925,7 +925,7 @@ void StripManager::signal() { // Get the user to select a conversation option strIndex = _choiceDialog.execute(choiceList); - if ((delayFlag || choiceList.size() != 1) && !_field2E6) + if ((delayFlag || choiceList.size() != 1) && !_uselessFl) _delayFrames = 1; else { Speaker *speakerP = getSpeaker((const char *)&_script[0] + obj44._speakerOffset); @@ -978,10 +978,10 @@ void StripManager::signal() { } } - _obj44Index = getNewIndex(obj44._list[strIndex]._id); - if (_obj44Index == 10001) { + _obj44ListIndex = getNewIndex(obj44._list[strIndex]._id); + if (_obj44ListIndex == 10001) { MessageDialog::show("Strip Failure: Node not found", OK_BTN_STRING); - _obj44Index = 0; + _obj44ListIndex = 0; } } @@ -991,16 +991,16 @@ void StripManager::process(Event &event) { return; if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) { - if (_obj44Index != 10000) { - int currIndex = _obj44Index; - while (!_obj44List[_obj44Index]._list[1]._id) { - _obj44Index = getNewIndex(_obj44List[_obj44Index]._list[0]._id); - if ((_obj44Index < 0) || (_obj44Index == 10000)) + if (_obj44ListIndex != 10000) { + int currIndex = _obj44ListIndex; + while (!_obj44List[_obj44ListIndex]._list[1]._id) { + _obj44ListIndex = getNewIndex(_obj44List[_obj44ListIndex]._list[0]._id); + if ((_obj44ListIndex < 0) || (_obj44ListIndex == 10000)) break; - currIndex = _obj44Index; + currIndex = _obj44ListIndex; } - _field2E8 = _obj44List[currIndex]._id; + _currObj44Id = _obj44List[currIndex]._id; } // Signal the end of the strip diff --git a/engines/tsage/converse.h b/engines/tsage/converse.h index e7b8e811ca..8aa91ec3ef 100644 --- a/engines/tsage/converse.h +++ b/engines/tsage/converse.h @@ -212,8 +212,8 @@ private: int getNewIndex(int newId); public: int _stripNum; - int _obj44Index; - int _field20; + int _obj44ListIndex; + int _useless; int _sceneNumber; Rect _sceneBounds; ConversationChoiceDialog _choiceDialog; @@ -221,8 +221,8 @@ public: StripCallback *_callbackObject; Speaker *_activeSpeaker; bool _textShown; - bool _field2E6; - int _field2E8; + bool _uselessFl; + int _currObj44Id; int _exitMode; Common::Array<Obj44> _obj44List; Common::Array<byte> _script; diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 0b3eb53268..7f27c43a22 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -1301,7 +1301,6 @@ ScenePalette::ScenePalette() { *palData++ = idx; } - _field412 = 0; _redColor = _greenColor = _blueColor = 0; _aquaColor = 0; _purpleColor = 0; @@ -1313,7 +1312,6 @@ ScenePalette::~ScenePalette() { } ScenePalette::ScenePalette(int paletteNum) { - _field412 = 0; _redColor = _greenColor = _blueColor = 0; _aquaColor = 0; _purpleColor = 0; @@ -1565,8 +1563,13 @@ void SceneItem::synchronize(Serializer &s) { _bounds.synchronize(s); s.syncString(_msg); - s.syncAsSint32LE(_fieldE); - s.syncAsSint32LE(_field10); + + if (s.getVersion() < 15) { + int useless = 0; + s.syncAsSint32LE(useless); + s.syncAsSint32LE(useless); + } + s.syncAsSint16LE(_position.x); s.syncAsSint32LE(_position.y); s.syncAsSint16LE(_yDiff); s.syncAsSint32LE(_sceneRegionId); @@ -2119,7 +2122,7 @@ SceneObject::SceneObject() : SceneHotspot() { _xs = 0; _xe = 0; _endFrame = 0; - _field68 = 0; + _loopCount = 0; _regionIndex = 0; _shadowMap = NULL; } @@ -2368,7 +2371,7 @@ void SceneObject::animate(AnimateMode animMode, ...) { case ANIM_MODE_1: _frameChange = 1; - _field2E = _position; + _oldPosition = _position; _endAction = 0; break; @@ -2416,9 +2419,9 @@ void SceneObject::animate(AnimateMode animMode, ...) { case ANIM_MODE_9: if (_animateMode == ANIM_MODE_9 && g_vm->getGameID() == GType_Ringworld2) { _frameChange = -1; - _field2E = _position; + _oldPosition = _position; } else { - _field68 = va_arg(va, int); + _loopCount = va_arg(va, int); _endAction = va_arg(va, Action *); _frameChange = 1; _endFrame = getFrameCount(); @@ -2485,7 +2488,7 @@ void SceneObject::synchronize(Serializer &s) { s.syncAsUint32LE(_updateStartFrame); s.syncAsUint32LE(_walkStartFrame); - s.syncAsSint16LE(_field2E.x); s.syncAsSint16LE(_field2E.y); + s.syncAsSint16LE(_oldPosition.x); s.syncAsSint16LE(_oldPosition.y); s.syncAsSint16LE(_percent); s.syncAsSint16LE(_priority); s.syncAsSint16LE(_angle); @@ -2500,7 +2503,7 @@ void SceneObject::synchronize(Serializer &s) { SYNC_ENUM(_animateMode, AnimateMode); s.syncAsSint32LE(_frame); s.syncAsSint32LE(_endFrame); - s.syncAsSint32LE(_field68); + s.syncAsSint32LE(_loopCount); s.syncAsSint32LE(_frameChange); s.syncAsSint32LE(_numFrames); s.syncAsSint32LE(_regionIndex); @@ -2587,9 +2590,9 @@ void SceneObject::dispatch() { case ANIM_MODE_1: if (isNoMover()) setFrame(1); - else if ((_field2E.x != _position.x) || (_field2E.y != _position.y)) { + else if ((_oldPosition.x != _position.x) || (_oldPosition.y != _position.y)) { setFrame(changeFrame()); - _field2E = _position; + _oldPosition = _position; } break; @@ -2632,7 +2635,7 @@ void SceneObject::dispatch() { _endFrame = 1; setFrame(changeFrame()); - } else if (!_field68 || (--_field68 > 0)) { + } else if (!_loopCount || (--_loopCount > 0)) { _frameChange = 1; _endFrame = getFrameCount(); @@ -2651,7 +2654,7 @@ void SceneObject::dispatch() { _frameChange = -1; _strip = ((_strip - 1) ^ 1) + 1; _endFrame = 1; - } else if ((_field68 == 0) || (--_field68 != 0)) { + } else if (!_loopCount || (--_loopCount > 0)) { _frameChange = 1; _endFrame = getFrameCount(); @@ -3365,7 +3368,6 @@ Player::Player(): SceneObject() { _canWalk = false; _enabled = false; _uiEnabled = false; - _field8C = 0; // Return to Ringworld specific fields _characterIndex = R2_NONE; @@ -3384,15 +3386,11 @@ void Player::postInit(SceneObjectList *OwnerList) { _canWalk = true; _uiEnabled = true; _percent = 100; - _field8C = 10; - if (g_vm->getGameID() != GType_Ringworld2) - { + if (g_vm->getGameID() != GType_Ringworld2) { _moveDiff.x = 4; _moveDiff.y = 2; - } - else - { + } else { _moveDiff.x = 3; _moveDiff.y = 2; _effect = EFFECT_SHADED; @@ -3500,7 +3498,10 @@ void Player::synchronize(Serializer &s) { s.syncAsByte(_canWalk); s.syncAsByte(_uiEnabled); - s.syncAsSint16LE(_field8C); + if (s.getVersion() < 15) { + int useless = 0; + s.syncAsSint16LE(useless); + } if (g_vm->getGameID() != GType_Ringworld) s.syncAsByte(_enabled); @@ -4248,7 +4249,6 @@ double FloatSet::sqrt(FloatSet &floatSet) { GameHandler::GameHandler() : EventHandler() { _nextWaitCtr = 1; _waitCtr.setCtr(1); - _field14 = 10; } GameHandler::~GameHandler() { @@ -4270,7 +4270,11 @@ void GameHandler::synchronize(Serializer &s) { _lockCtr.synchronize(s); _waitCtr.synchronize(s); s.syncAsSint16LE(_nextWaitCtr); - s.syncAsSint16LE(_field14); + + if (s.getVersion() < 14) { + int useless = 0; + s.syncAsSint16LE(useless); + } } /*--------------------------------------------------------------------------*/ diff --git a/engines/tsage/core.h b/engines/tsage/core.h index 3286ee1448..c285fba669 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -358,7 +358,6 @@ public: byte _palette[256 * 3]; GfxColors _colors; SynchronizedList<PaletteModifier *> _listeners; - int _field412; uint8 _redColor; uint8 _greenColor; @@ -410,12 +409,11 @@ class SceneItem : public EventHandler { public: Rect _bounds; Common::String _msg; - int _fieldE, _field10; Common::Point _position; int _yDiff; int _sceneRegionId; public: - SceneItem() : EventHandler() { _msg = "Feature"; _action = NULL; _sceneRegionId = 0; _yDiff = 0; _fieldE = _field10 = 0;} + SceneItem() : EventHandler() { _msg = "Feature"; _action = NULL; _sceneRegionId = 0; _yDiff = 0;} virtual void synchronize(Serializer &s); virtual Common::String getClassName() { return "SceneItem"; } @@ -529,7 +527,7 @@ public: int changeFrame(); uint32 _updateStartFrame; uint32 _walkStartFrame; - Common::Point _field2E; + Common::Point _oldPosition; int _percent; int _priority; int _angle; @@ -542,7 +540,7 @@ public: AnimateMode _animateMode; int _frame; int _endFrame; - int _field68; + int _loopCount; int _frameChange; int _numFrames; int _regionIndex; @@ -651,7 +649,6 @@ class Player : public SceneObject { public: bool _canWalk; bool _uiEnabled; - int _field8C; bool _enabled; // Return to Ringworld specific fields @@ -778,8 +775,6 @@ public: class ScenePriorities : public Common::List<Region> { public: int _resNum; - int _field14; - int _field16; Region _defaultPriorityRegion; public: void load(int resNum); @@ -885,7 +880,6 @@ public: RefCounter _lockCtr; RefCounter _waitCtr; int _nextWaitCtr; - int _field14; public: GameHandler(); virtual ~GameHandler(); diff --git a/engines/tsage/ringworld/ringworld_scenes1.cpp b/engines/tsage/ringworld/ringworld_scenes1.cpp index 5a42bc530d..df456f9ced 100644 --- a/engines/tsage/ringworld/ringworld_scenes1.cpp +++ b/engines/tsage/ringworld/ringworld_scenes1.cpp @@ -1623,7 +1623,7 @@ void Scene50::Action1::signal() { scene->_stripManager.start(63, this); break; case 2: - if (scene->_stripManager._field2E8 != 107) { + if (scene->_stripManager._currObj44Id != 107) { g_globals->_player.enableControl(); remove(); } else { @@ -2498,7 +2498,7 @@ void Scene90::Action1::signal() { case 5: scene->_soundHandler2.play(58); - if (scene->_stripManager._field2E8 == 220) + if (scene->_stripManager._currObj44Id == 220) scene->_stripManager.start(91, this, scene); else { scene->_stripManager.start(g_globals->getFlag(104) ? 93 : 92, this, scene); @@ -2714,7 +2714,7 @@ void Scene90::signal() { g_globals->_player.enableControl(); break; case 97: - _stripManager._field2E8 = 0; + _stripManager._currObj44Id = 0; _action1.setActionIndex(5); _action1.setDelay(1); break; @@ -2939,7 +2939,7 @@ void Scene6100::Action3::signal() { case 4: g_globals->setFlag(76); g_globals->_sceneManager.changeScene( - (scene->_stripManager._field2E8 == 135) ? 6100 : 2320); + (scene->_stripManager._currObj44Id == 135) ? 6100 : 2320); remove(); break; } diff --git a/engines/tsage/ringworld/ringworld_scenes3.cpp b/engines/tsage/ringworld/ringworld_scenes3.cpp index b2ed986331..e834e659b5 100644 --- a/engines/tsage/ringworld/ringworld_scenes3.cpp +++ b/engines/tsage/ringworld/ringworld_scenes3.cpp @@ -799,7 +799,7 @@ void Scene2100::Action9::signal() { scene->_stripManager.start(6010, this); break; case 6: - if (scene->_stripManager._field2E8 != 165) + if (scene->_stripManager._currObj44Id != 165) setAction(&scene->_action10); else setAction(&scene->_action11); @@ -1010,7 +1010,7 @@ void Scene2100::Action12::signal() { scene->_stripManager.start(6052, this); break; case 8: - if (scene->_stripManager._field2E8 == 320) + if (scene->_stripManager._currObj44Id == 320) g_globals->setFlag(74); setDelay(30); break; @@ -2352,11 +2352,11 @@ void Scene2150::Action2::signal() { scene->_hotspot14.setStrip(6); scene->_hotspot14.setPosition(Common::Point(59, 54)); - if (scene->_stripManager._field2E8 == 15) { + if (scene->_stripManager._currObj44Id == 15) { scene->_hotspot14.setFrame(5); RING_INVENTORY._ale._sceneNumber = 1; } else { - scene->_hotspot14.setFrame(scene->_stripManager._field2E8 - 5); + scene->_hotspot14.setFrame(scene->_stripManager._currObj44Id - 5); } g_globals->_player.setFrame(1); @@ -3160,7 +3160,7 @@ void Scene2230::Action1::signal() { switch (_actionIndex++) { case 0: - switch (scene->_field30A) { + switch (scene->_sceneMode) { case 1: scene->setAction(&scene->_action3); break; @@ -3201,7 +3201,7 @@ void Scene2230::Action2::signal() { switch (_actionIndex++) { case 0: - switch (scene->_field30A) { + switch (scene->_sceneMode) { case 2: scene->setAction(&scene->_action6, this); break; @@ -3212,7 +3212,7 @@ void Scene2230::Action2::signal() { break; case 1: { g_globals->_player.disableControl(); - scene->_field30A = 1; + scene->_sceneMode = 1; g_globals->_player._regionBitList |= ~0x80; Common::Point pt(160, 96); NpcMover *mover = new NpcMover(); @@ -3262,7 +3262,7 @@ void Scene2230::Action3::signal() { break; case 2: g_globals->_player._regionBitList |= 0x80; - scene->_field30A = 0; + scene->_sceneMode = 0; g_globals->_player.setVisage(0); g_globals->_player.setStrip2(-1); @@ -3292,7 +3292,7 @@ void Scene2230::Action5::signal() { switch (_actionIndex++) { case 0: - switch (scene->_field30A) { + switch (scene->_sceneMode) { case 2: scene->setAction(&scene->_action3, this); break; @@ -3318,7 +3318,7 @@ void Scene2230::Action5::signal() { case 3: g_globals->_events.setCursor(CURSOR_USE); g_globals->_player._uiEnabled = true; - scene->_field30A = 2; + scene->_sceneMode = 2; remove(); break; } @@ -3335,7 +3335,7 @@ void Scene2230::Action6::signal() { g_globals->_player.animate(ANIM_MODE_5, this); break; case 1: - scene->_field30A = 0; + scene->_sceneMode = 0; g_globals->_player.setVisage(0); g_globals->_player._strip = 1; g_globals->_player._canWalk = true; @@ -3352,7 +3352,7 @@ void Scene2230::Action7::signal() { case 0: g_globals->_player.disableControl(); - switch (scene->_field30A) { + switch (scene->_sceneMode) { case 1: scene->setAction(&scene->_action3, this); break; @@ -3408,7 +3408,7 @@ void Scene2230::Action8::signal() { case 0: g_globals->_player.disableControl(); - switch (scene->_field30A) { + switch (scene->_sceneMode) { case 1: scene->setAction(&scene->_action3, this); break; @@ -3431,7 +3431,7 @@ void Scene2230::Action8::signal() { g_globals->_sceneItems.remove(&scene->_hotspot11); g_globals->_sceneItems.remove(&scene->_hotspot12); - switch (scene->_field30A) { + switch (scene->_sceneMode) { case 1: scene->setAction(&scene->_action3, this); break; @@ -3560,7 +3560,7 @@ void Scene2230::Hotspot6::doAction(int action) { } break; case CURSOR_USE: - if (scene->_field30A == 1) + if (scene->_sceneMode == 1) scene->setAction(&scene->_action3); else if (g_globals->getFlag(13)) SceneItem::display2(2230, 28); @@ -3586,7 +3586,7 @@ void Scene2230::Hotspot7::doAction(int action) { } break; case CURSOR_USE: - if (scene->_field30A == 2) + if (scene->_sceneMode == 2) scene->setAction(&scene->_action6); else if (g_globals->getFlag(13)) SceneItem::display2(2230, 29); @@ -3692,7 +3692,7 @@ void Scene2230::Hotspot12::doAction(int action) { /*--------------------------------------------------------------------------*/ Scene2230::Scene2230() : _hotspot9(0, CURSOR_LOOK, 2230, 16, CURSOR_USE, 2230, 18, LIST_END) { - _field30A = 0; + _sceneMode = 0; } void Scene2230::postInit(SceneObjectList *OwnerList) { @@ -3726,7 +3726,7 @@ void Scene2230::postInit(SceneObjectList *OwnerList) { g_globals->_player._regionBitList |= 0x80; g_globals->_player.changeZoom(-1); - _field30A = 0; + _sceneMode = 0; g_globals->_player.enableControl(); _hotspot5.setBounds(Rect(108, 34, 142, 76)); @@ -3748,7 +3748,7 @@ void Scene2230::postInit(SceneObjectList *OwnerList) { void Scene2230::synchronize(Serializer &s) { Scene::synchronize(s); _rect1.synchronize(s); - s.syncAsSint16LE(_field30A); + s.syncAsSint16LE(_sceneMode); } void Scene2230::dispatch() { diff --git a/engines/tsage/ringworld/ringworld_scenes3.h b/engines/tsage/ringworld/ringworld_scenes3.h index 682ef44fc6..fafb72fcea 100644 --- a/engines/tsage/ringworld/ringworld_scenes3.h +++ b/engines/tsage/ringworld/ringworld_scenes3.h @@ -579,7 +579,7 @@ public: Hotspot11 _hotspot11; Hotspot12 _hotspot12; Rect _rect1; - int _field30A; + int _sceneMode; Scene2230(); virtual void postInit(SceneObjectList *OwnerList = NULL); diff --git a/engines/tsage/ringworld/ringworld_scenes5.cpp b/engines/tsage/ringworld/ringworld_scenes5.cpp index 1b6cd78223..1242f9f448 100644 --- a/engines/tsage/ringworld/ringworld_scenes5.cpp +++ b/engines/tsage/ringworld/ringworld_scenes5.cpp @@ -462,7 +462,7 @@ void Scene4000::Action12::signal() { break; case 2: g_globals->setFlag(32); - if (scene->_stripManager._field2E8 == 275) { + if (scene->_stripManager._currObj44Id == 275) { g_globals->setFlag(82); ADD_MOVER_NULL(scene->_guardRock, 292, 138); ADD_PLAYER_MOVER(283, 147); @@ -471,7 +471,7 @@ void Scene4000::Action12::signal() { } break; case 3: - if (scene->_stripManager._field2E8 == 275) { + if (scene->_stripManager._currObj44Id == 275) { g_globals->_sceneManager.changeScene(4100); } else { ADD_PLAYER_MOVER_THIS(scene->_guardRock, 300, 132); @@ -4222,7 +4222,12 @@ void Scene4300::process(Event &event) { void Scene4301::Action1::synchronize(Serializer &s) { Action::synchronize(s); - s.syncAsSint16LE(_field34E); + + if (s.getVersion() < 14) { + int useless = 0; + s.syncAsSint16LE(useless); + } + for (int idx = 0; idx < 6; ++idx) s.syncAsSint16LE(_indexList[idx]); } @@ -4268,7 +4273,6 @@ void Scene4301::Action1::signal() { scene->_hotspot3.fixPriority(255); scene->_hotspot3.hide(); - _field34E = 0; _state = 0; _actionIndex = 2; break; diff --git a/engines/tsage/ringworld/ringworld_scenes5.h b/engines/tsage/ringworld/ringworld_scenes5.h index 2fe26d9712..b49d2a6f02 100644 --- a/engines/tsage/ringworld/ringworld_scenes5.h +++ b/engines/tsage/ringworld/ringworld_scenes5.h @@ -656,7 +656,6 @@ class Scene4301 : public Scene { class Action1 : public ActionExt { public: SceneObject _buttonList[6]; - int _field34E; int _indexList[6]; virtual void synchronize(Serializer &s); diff --git a/engines/tsage/ringworld/ringworld_scenes6.cpp b/engines/tsage/ringworld/ringworld_scenes6.cpp index 65c1ed39c6..777eed2aab 100644 --- a/engines/tsage/ringworld/ringworld_scenes6.cpp +++ b/engines/tsage/ringworld/ringworld_scenes6.cpp @@ -1608,8 +1608,6 @@ Scene5200::Scene5200() : void Scene5200::postInit(SceneObjectList *OwnerList) { Scene::postInit(); setZoomPercents(0, 150, 199, 150); - _fieldA = 5600; - _fieldE = 5100; _hotspot9._state = 0; _hotspot10._state = 0; diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp index e1d6e79423..25eafbb171 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.cpp +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -368,7 +368,6 @@ void SceneExt::postInit(SceneObjectList *OwnerList) { // Initialize fields _action = NULL; - _field12 = 0; _sceneMode = 0; static_cast<SceneHandlerExt *>(R2_GLOBALS._sceneHandler)->setupPaletteMaps(); diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp index 2592bde19a..7fdc1dc8a7 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp @@ -1541,7 +1541,7 @@ void Scene180::postInit(SceneObjectList *OwnerList) { } void Scene180::remove() { - _stripManager._field2E8 = -1; + _stripManager._currObj44Id = -1; // _stripManager._field2EA = -1; SceneExt::remove(); @@ -3556,7 +3556,7 @@ void Scene300::signal() { break; } - _stripManager._field2E8 = 0; + _stripManager._currObj44Id = 0; switch (_stripId) { case 400: R2_GLOBALS._player.disableControl(); diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp index 39072f0329..0025d0ba61 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp @@ -1202,18 +1202,10 @@ void Scene1100::signal() { R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); if (_nextStripNum == 0) { R2_GLOBALS.setFlag(55); - if (R2_GLOBALS.getFlag(55)) { - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _stripManager.start(318, this); - else - _stripManager.start(323, this); - } else { - // This part is totally useless as flag 55 has been set right before the check - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _stripManager.start(317, this); - else - _stripManager.start(322, this); - } + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + _stripManager.start(318, this); + else + _stripManager.start(323, this); } else _stripManager.start3(_nextStripNum, this, _stripManager._lookupList); @@ -2257,7 +2249,7 @@ Scene1337::Scene1337() { _actionIdx2 = 0; _showPlayerTurn = false; _displayHelpFl = false; - _winnerId = 0; + _winnerId = -1; _instructionsDisplayedFl = false; _instructionsWaitCount = 0; @@ -3158,14 +3150,12 @@ void Scene1337::Action3::signal() { scene->_gameBoardSide[2]._handCard[0]._card.setVisage(1332); scene->_gameBoardSide[2]._handCard[0]._card.setPosition(scene->_gameBoardSide[2]._handCard[0]._stationPos, 0); scene->_gameBoardSide[2]._handCard[0]._card.fixPriority(170); - if (scene->_gameBoardSide[2]._handCard[0]._cardId > 9) { - if (scene->_gameBoardSide[2]._handCard[0]._cardId > 25) { - scene->_gameBoardSide[2]._handCard[0]._card.setStrip(4); - scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId - 25); - } else { - scene->_gameBoardSide[2]._handCard[0]._card.setStrip(3); - scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId - 9); - } + if (scene->_gameBoardSide[2]._handCard[0]._cardId > 25) { + scene->_gameBoardSide[2]._handCard[0]._card.setStrip(4); + scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId - 25); + } else if (scene->_gameBoardSide[2]._handCard[0]._cardId > 9) { + scene->_gameBoardSide[2]._handCard[0]._card.setStrip(3); + scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId - 9); } else { scene->_gameBoardSide[2]._handCard[0]._card.setStrip(2); scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId); @@ -3237,14 +3227,12 @@ void Scene1337::Action3::signal() { scene->_gameBoardSide[2]._handCard[1]._card.setPosition(scene->_gameBoardSide[2]._handCard[1]._stationPos, 0); scene->_gameBoardSide[2]._handCard[1]._card.fixPriority(170); - if (scene->_gameBoardSide[2]._handCard[1]._cardId > 9) { - if (scene->_gameBoardSide[2]._handCard[1]._cardId > 25) { - scene->_gameBoardSide[2]._handCard[1]._card.setStrip(4); - scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId - 25); - } else { - scene->_gameBoardSide[2]._handCard[1]._card.setStrip(3); - scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId - 9); - } + if (scene->_gameBoardSide[2]._handCard[1]._cardId > 25) { + scene->_gameBoardSide[2]._handCard[1]._card.setStrip(4); + scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId - 25); + } else if (scene->_gameBoardSide[2]._handCard[1]._cardId > 9) { + scene->_gameBoardSide[2]._handCard[1]._card.setStrip(3); + scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId - 9); } else { scene->_gameBoardSide[2]._handCard[1]._card.setStrip(2); scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId); @@ -3317,14 +3305,12 @@ void Scene1337::Action3::signal() { scene->_gameBoardSide[2]._handCard[2]._card.setPosition(scene->_gameBoardSide[2]._handCard[2]._stationPos, 0); scene->_gameBoardSide[2]._handCard[2]._card.fixPriority(170); - if (scene->_gameBoardSide[2]._handCard[2]._cardId > 9) { - if (scene->_gameBoardSide[2]._handCard[2]._cardId > 25) { - scene->_gameBoardSide[2]._handCard[2]._card.setStrip(4); - scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId - 25); - } else { - scene->_gameBoardSide[2]._handCard[2]._card.setStrip(3); - scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId - 9); - } + if (scene->_gameBoardSide[2]._handCard[2]._cardId > 25) { + scene->_gameBoardSide[2]._handCard[2]._card.setStrip(4); + scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId - 25); + } else if (scene->_gameBoardSide[2]._handCard[2]._cardId > 9) { + scene->_gameBoardSide[2]._handCard[2]._card.setStrip(3); + scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId - 9); } else { scene->_gameBoardSide[2]._handCard[2]._card.setStrip(2); scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId); @@ -3388,7 +3374,8 @@ void Scene1337::Action4::signal() { switch (_actionIndex++) { case 0: - if ((scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._cardId == 0) && (!scene->subC264B(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) { + if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._cardId == 0) + && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) { if (scene->_cardsAvailableNumb < 0) scene->shuffleCards(); scene->_animatedCard._card.setPosition(Common::Point(162, 95), 0); @@ -3410,8 +3397,8 @@ void Scene1337::Action4::signal() { } break; case 1: - if ( ( scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos.x) - && ( scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos.y) ) { + if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos.x) + && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos.y) ) { scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.postInit(); scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card._moveDiff = Common::Point(30, 30); scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setVisage(1332); @@ -3425,7 +3412,8 @@ void Scene1337::Action4::signal() { scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]); scene->_animatedCard._card.hide(); - if ((scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._cardId == 0) && (!scene->subC264B(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) { + if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._cardId == 0) + && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) { if (scene->_cardsAvailableNumb < 0) scene->shuffleCards(); scene->_animatedCard._card.setPosition(Common::Point(162, 95)); @@ -3445,8 +3433,8 @@ void Scene1337::Action4::signal() { signal(); break; case 2: - if ( ( scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos.x) - && ( scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos.y) ) { + if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos.x) + && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos.y) ) { scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.postInit(); scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card._moveDiff = Common::Point(30, 30); scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setVisage(1332); @@ -3460,7 +3448,8 @@ void Scene1337::Action4::signal() { scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]); scene->_animatedCard._card.hide(); - if ((scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._cardId == 0) && (!scene->subC264B(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) { + if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._cardId == 0) + && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) { if (scene->_cardsAvailableNumb < 0) scene->shuffleCards(); scene->_animatedCard._card.setPosition(Common::Point(162, 95)); @@ -3480,8 +3469,8 @@ void Scene1337::Action4::signal() { signal(); break; case 3: - if ( ( scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos.x) - && ( scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos.y) ) { + if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos.x) + && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos.y) ) { scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.postInit(); scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card._moveDiff = Common::Point(30, 30); scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setVisage(1332); @@ -3495,7 +3484,8 @@ void Scene1337::Action4::signal() { scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]); scene->_animatedCard._card.hide(); - if ((scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._cardId == 0) && (!scene->subC264B(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) { + if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._cardId == 0) + && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) { if (scene->_cardsAvailableNumb < 0) scene->shuffleCards(); scene->_animatedCard._card.setPosition(Common::Point(162, 95)); @@ -3515,8 +3505,8 @@ void Scene1337::Action4::signal() { signal(); break; case 4: - if ( ( scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos.x) - && ( scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos.y) ) { + if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos.x) + && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos.y) ) { scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.postInit(); scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card._moveDiff = Common::Point(30, 30); scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setVisage(1332); @@ -3538,7 +3528,7 @@ void Scene1337::Action4::signal() { scene->handlePlayer1(); break; case 2: - scene->handlePlayer2(); + scene->handleAutoplayPlayer2(); break; case 3: scene->handlePlayer3(); @@ -3598,7 +3588,7 @@ void Scene1337::Action5::signal() { } /** - * Animations for playing a card + * Animations for playing a platform card */ void Scene1337::Action6::signal() { Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene; @@ -3637,6 +3627,9 @@ void Scene1337::Action6::signal() { } } +/** + * Upgrade platform to station by playing a station card on top of it + */ void Scene1337::Action7::signal() { Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene; @@ -3660,13 +3653,13 @@ void Scene1337::Action7::signal() { } scene->setAnimationInfo(scene->_actionCard2); scene->_aSound1.play(59); - scene->_item5._cardId = 1; - scene->_item5._stationPos = scene->_actionCard2->_stationPos; - scene->_item5._card.postInit(); - scene->_item5._card.hide(); - scene->_item5._card._flags = OBJFLAG_HIDING; + scene->_discardedPlatformCard._cardId = 1; + scene->_discardedPlatformCard._stationPos = scene->_actionCard2->_stationPos; + scene->_discardedPlatformCard._card.postInit(); + scene->_discardedPlatformCard._card.hide(); + scene->_discardedPlatformCard._card._flags = OBJFLAG_HIDING; - scene->discardCard(&scene->_item5); + scene->discardCard(&scene->_discardedPlatformCard); break; default: break; @@ -3969,7 +3962,7 @@ void Scene1337::Action11::signal() { int tmpVal = scene->getFreeHandCard(scene->_actionIdx1); scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionIdx1]._handCard[tmpVal]; } - scene->_item1.setAction(&scene->_action12); + scene->_actionItem.setAction(&scene->_action12); noAction = false; } break; @@ -3988,7 +3981,7 @@ void Scene1337::Action11::signal() { int tmpVal = scene->getFreeHandCard(scene->_actionIdx1); scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionIdx1]._handCard[tmpVal]; } - scene->_item1.setAction(&scene->_action12); + scene->_actionItem.setAction(&scene->_action12); noAction = false; } break; @@ -4012,7 +4005,7 @@ void Scene1337::Action11::signal() { int tmpVal = scene->getFreeHandCard(scene->_actionIdx1); scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionIdx1]._handCard[tmpVal]; } - scene->_item1.setAction(&scene->_action12); + scene->_actionItem.setAction(&scene->_action12); noAction = false; } } @@ -4032,7 +4025,7 @@ void Scene1337::Action11::signal() { int tmpVal = scene->getFreeHandCard(scene->_actionIdx1); scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionIdx1]._handCard[tmpVal]; } - scene->_item1.setAction(&scene->_action12); + scene->_actionItem.setAction(&scene->_action12); noAction = false; } break; @@ -4094,11 +4087,9 @@ void Scene1337::Action11::signal() { } // while scene->_displayHelpFl = true; scene->subC4CEC(); - } else { - if (scene->_actionIdx2 != 2) { - int tmpVal = scene->getFreeHandCard(scene->_actionIdx2); - scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionIdx2]._handCard[tmpVal]; - } + } else if (scene->_actionIdx2 != 2) { + int tmpVal = scene->getFreeHandCard(scene->_actionIdx2); + scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionIdx2]._handCard[tmpVal]; } } @@ -4261,21 +4252,19 @@ void Scene1337::Action12::signal() { } } scene->subC4CEC(); - } else { - if (scene->_actionIdx1 != 1) { - switch (scene->_actionIdx1) { - case 0: - scene->_actionCard3 = &scene->_gameBoardSide[0]._handCard[scene->getFreeHandCard(0)]; - break; - case 3: - scene->_actionCard3 = &scene->_gameBoardSide[3]._handCard[scene->getFreeHandCard(3)]; - break; - default: - break; - } - } else { - scene->_actionCard3 = &scene->_gameBoardSide[1]._handCard[scene->getFreeHandCard(1)]; + } else if (scene->_actionIdx1 != 1) { + switch (scene->_actionIdx1) { + case 0: + scene->_actionCard3 = &scene->_gameBoardSide[0]._handCard[scene->getFreeHandCard(0)]; + break; + case 3: + scene->_actionCard3 = &scene->_gameBoardSide[3]._handCard[scene->getFreeHandCard(3)]; + break; + default: + break; } + } else { + scene->_actionCard3 = &scene->_gameBoardSide[1]._handCard[scene->getFreeHandCard(1)]; } scene->_actionCard1->_card.postInit(); @@ -4317,6 +4306,7 @@ void Scene1337::Action12::signal() { break; } scene->discardCard(scene->_actionCard2); + scene->handleNextTurn(); break; default: break; @@ -4487,12 +4477,13 @@ void Scene1337::remove() { } R2_GLOBALS._uiElements._active = true; + R2_GLOBALS._uiElements._visible = true; SceneExt::remove(); } void Scene1337::process(Event &event) { if (event.eventType == EVENT_BUTTON_DOWN) { - if (event.btnState != BTNSHIFT_RIGHT) { + if (event.btnState == BTNSHIFT_RIGHT) { updateCursorId(R2_GLOBALS._mouseCursorId, true); event.handled = true; } else if (_delayedFunction) { @@ -4548,14 +4539,12 @@ void Scene1337::setAnimationInfo(Card *card) { if (!card) return; - if (card->_cardId > 9) { - if (card->_cardId > 25) { - card->_card.setStrip2(4); - card->_card.setFrame(card->_cardId - 25); - } else { - card->_card.setStrip2(3); - card->_card.setFrame(card->_cardId - 9); - } + if (card->_cardId > 25) { + card->_card.setStrip2(4); + card->_card.setFrame(card->_cardId - 25); + } else if (card->_cardId > 9) { + card->_card.setStrip2(3); + card->_card.setFrame(card->_cardId - 9); } else { card->_card.setStrip2(2); card->_card.setFrame(card->_cardId); @@ -4565,10 +4554,6 @@ void Scene1337::setAnimationInfo(Card *card) { R2_GLOBALS._sceneObjects->draw(); } -void Scene1337::subC20E5() { - subC2586(); -} - void Scene1337::handleNextTurn() { switch (_winnerId) { case -1: @@ -4598,11 +4583,11 @@ void Scene1337::handleNextTurn() { } if (!_autoplay) - _delayedFunction = &Scene1337::subC20E5; + _delayedFunction = &Scene1337::handlePlayerTurn; else - subC20E5(); + handlePlayerTurn(); } else { - subC20E5(); + handlePlayerTurn(); } break; case 0: @@ -4646,7 +4631,7 @@ void Scene1337::handleNextTurn() { } -void Scene1337::subC2586() { +void Scene1337::handlePlayerTurn() { if (_showPlayerTurn) _currentPlayerArrow.hide(); @@ -4662,7 +4647,7 @@ void Scene1337::subC2586() { case 1: // No break on purpose case 3: - _item1.setAction(&_action4); + _actionItem.setAction(&_action4); default: break; } @@ -4671,7 +4656,7 @@ void Scene1337::subC2586() { } -bool Scene1337::subC264B(int cardId) { +bool Scene1337::isStationCard(int cardId) { switch (cardId) { case 10: // No break on purpose @@ -4694,7 +4679,7 @@ bool Scene1337::subC264B(int cardId) { } } -bool Scene1337::subC2687(int cardId) { +bool Scene1337::isStopConstructionCard(int cardId) { switch (cardId) { case 11: // No break on purpose @@ -4709,14 +4694,14 @@ bool Scene1337::subC2687(int cardId) { } } -int Scene1337::subC26CB(int playerId, int handCardId) { +int Scene1337::getStationId(int playerId, int handCardId) { if ((_gameBoardSide[playerId]._handCard[handCardId]._cardId > 1) && (_gameBoardSide[playerId]._handCard[handCardId]._cardId <= 9)) return handCardId; return -1; } -int Scene1337::findNormalCardInHand(int playerId) { +int Scene1337::findPlatformCardInHand(int playerId) { for (int i = 0; i <= 3; i++) { if (_gameBoardSide[playerId]._handCard[i]._cardId == 1) return i; @@ -4725,7 +4710,7 @@ int Scene1337::findNormalCardInHand(int playerId) { return -1; } -int Scene1337::subC274D(int playerId) { +int Scene1337::findCard13InHand(int playerId) { for (int i = 0; i <= 3; i++) { if (_gameBoardSide[playerId]._handCard[i]._cardId == 13) return i; @@ -4734,17 +4719,17 @@ int Scene1337::subC274D(int playerId) { return -1; } -int Scene1337::subC2781(int arg1) { +int Scene1337::checkThieftCard(int playerId) { for (int i = 0; i <= 3; i++) { - if (_gameBoardSide[arg1]._handCard[i]._cardId == 25) + if (_gameBoardSide[playerId]._handCard[i]._cardId == 25) return i; } return -1; } -int Scene1337::subC27B5(int arg1) { - switch (arg1) { +int Scene1337::isDelayCard(int cardId) { + switch (cardId) { case 11: // No break on purpose case 14: @@ -4752,7 +4737,7 @@ int Scene1337::subC27B5(int arg1) { case 16: // No break on purpose case 24: - return arg1; + return cardId; break; default: return -1; @@ -4760,7 +4745,7 @@ int Scene1337::subC27B5(int arg1) { } } -int Scene1337::isSlowCard(int cardId) { +int Scene1337::getStationCardId(int cardId) { switch (cardId) { case 10: // No break on purpose @@ -4783,152 +4768,112 @@ int Scene1337::isSlowCard(int cardId) { } } -void Scene1337::subC2835(int arg1) { - int i; - bool found = false; - switch (arg1) { +void Scene1337::handlePlayer01Discard(int playerId) { + switch (playerId) { case 0: - for (i = 0; i <= 3; i++) { - if (isSlowCard(_gameBoardSide[arg1]._handCard[i]._cardId) != -1) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if (getStationCardId(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } - if (found) - break; - - for (i = 0; i <= 3; i++) { - if (subC27B5(_gameBoardSide[arg1]._handCard[i]._cardId) != -1) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if (isDelayCard(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } - if (found) - break; - - for (i = 0; i <= 3; i++) { - if ((_gameBoardSide[arg1]._handCard[i]._cardId > 1) && (_gameBoardSide[arg1]._handCard[i]._cardId <= 9)) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if ((_gameBoardSide[playerId]._handCard[i]._cardId > 1) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 9)) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } - if (found) - break; - - for (i = 0; i <= 3; i++) { - if ((_gameBoardSide[arg1]._handCard[i]._cardId >= 26) && (_gameBoardSide[arg1]._handCard[i]._cardId <= 33)) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if ((_gameBoardSide[playerId]._handCard[i]._cardId >= 26) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 33)) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } - if (found) - break; - - for (i = 0; i <= 3; i++) { - if (_gameBoardSide[arg1]._handCard[i]._cardId == 1) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if (_gameBoardSide[playerId]._handCard[i]._cardId == 1) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } - if (found) - break; - - for (i = 0; i <= 3; i++) { - if (_gameBoardSide[arg1]._handCard[i]._cardId == 25) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if (_gameBoardSide[playerId]._handCard[i]._cardId == 25) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } - if (found) - break; - - for (i = 0; i <= 3; i++) { - if (_gameBoardSide[arg1]._handCard[i]._cardId == 13) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if (_gameBoardSide[playerId]._handCard[i]._cardId == 13) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } break; case 1: - for (i = 0; i <= 3; i++) { - if ((_gameBoardSide[arg1]._handCard[i]._cardId >= 26) && (_gameBoardSide[arg1]._handCard[i]._cardId <= 33)) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if ((_gameBoardSide[playerId]._handCard[i]._cardId >= 26) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 33)) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } - if (found) - break; - - for (i = 0; i <= 3; i++) { - if (_gameBoardSide[arg1]._handCard[i]._cardId == 1) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if (_gameBoardSide[playerId]._handCard[i]._cardId == 1) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } - if (found) - break; - - for (i = 0; i <= 3; i++) { - if ((_gameBoardSide[arg1]._handCard[i]._cardId > 1) && (_gameBoardSide[arg1]._handCard[i]._cardId <= 9)) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if ((_gameBoardSide[playerId]._handCard[i]._cardId > 1) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 9)) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } - if (found) - break; - - for (i = 0; i <= 3; i++) { - if (isSlowCard(_gameBoardSide[arg1]._handCard[i]._cardId) != -1) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if (getStationCardId(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } - if (found) - break; - - for (i = 0; i <= 3; i++) { - if (subC27B5(_gameBoardSide[arg1]._handCard[i]._cardId) != -1) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if (isDelayCard(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } - if (found) - break; - - for (i = 0; i <= 3; i++) { - if (_gameBoardSide[arg1]._handCard[i]._cardId == 25) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if (_gameBoardSide[playerId]._handCard[i]._cardId == 25) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } - if (found) - break; - - for (i = 0; i <= 3; i++) { - if (_gameBoardSide[arg1]._handCard[i]._cardId == 13) { - found = true; - break; + for (int i = 0; i <= 3; i++) { + if (_gameBoardSide[playerId]._handCard[i]._cardId == 13) { + discardCard(&_gameBoardSide[playerId]._handCard[i]); + return; } } break; default: - return; + break; } - - discardCard(&_gameBoardSide[arg1]._handCard[i]); } void Scene1337::playThieftCard(int playerId, Card *card, int victimId) { @@ -4947,13 +4892,13 @@ void Scene1337::playThieftCard(int playerId, Card *card, int victimId) { _actionCard2 = &_gameBoardSide[victimId]._emptyStationPos; _actionCard3 = &_gameBoardSide[victimId]._handCard[randIndx]; - _item1.setAction(&_action11); + _actionItem.setAction(&_action11); } -int Scene1337::subC3257(int arg1) { +int Scene1337::getPreventionCardId(int cardId) { int retVal; - switch (arg1) { + switch (cardId) { case 10: retVal = 2; break; @@ -4985,35 +4930,35 @@ int Scene1337::subC3257(int arg1) { return retVal; } -bool Scene1337::subC32B1(int arg1, int arg2) { +bool Scene1337::isAttackPossible(int victimId, int cardId) { for (int i = 0; i <= 7; i++) { - if (_gameBoardSide[arg1]._outpostStation[i]._cardId != 0) { - if (subC3257(arg2) == _gameBoardSide[arg1]._outpostStation[i]._cardId) + if (_gameBoardSide[victimId]._outpostStation[i]._cardId != 0) { + if (getPreventionCardId(cardId) == _gameBoardSide[victimId]._outpostStation[i]._cardId) return false; } } return true; } -int Scene1337::subC331B(int arg1) { - int randIndx = R2_GLOBALS._randomSource.getRandomNumber(3); +int Scene1337::getPlayerWithOutpost(int playerId) { + int randPlayerId = R2_GLOBALS._randomSource.getRandomNumber(3); for (int i = 0; i <= 3; i++) { - if (randIndx != arg1) { + if (randPlayerId != playerId) { for (int j = 0; j <= 7; j++) { - if (_gameBoardSide[randIndx]._outpostStation[j]._cardId != 0) - return randIndx; + if (_gameBoardSide[randPlayerId]._outpostStation[j]._cardId != 0) + return randPlayerId; } } - if (arg1 == 1) { - randIndx--; - if (randIndx < 0) - randIndx = 3; + if (playerId == 1) { + randPlayerId--; + if (randPlayerId < 0) + randPlayerId = 3; } else { - ++randIndx; - if (randIndx > 3) - randIndx = 0; + ++randPlayerId; + if (randPlayerId > 3) + randPlayerId = 0; } } @@ -5036,10 +4981,10 @@ bool Scene1337::checkAntiDelayCard(int delayCardId, int cardId) { return false; } -void Scene1337::subC33C0(Card *subObj1, Card *subObj2) { - _actionCard1 = subObj1; - _actionCard2 = subObj2; - _item1.setAction(&_action7); +void Scene1337::playStationCard(Card *station, Card *platform) { + _actionCard1 = station; + _actionCard2 = platform; + _actionItem.setAction(&_action7); } int Scene1337::getFreeHandCard(int playerId) { @@ -5059,31 +5004,34 @@ int Scene1337::getFreeHandCard(int playerId) { return randIndx; } -void Scene1337::playCard(Card *card, Card *dest) { +void Scene1337::playPlatformCard(Card *card, Card *dest) { _actionCard1 = card; _actionCard2 = dest; - _item1.setAction(&_action6); + _actionItem.setAction(&_action6); } void Scene1337::playDelayCard(Card *card, Card *dest) { _actionCard1 = card; _actionCard2 = dest; - _item1.setAction(&_action9); + _actionItem.setAction(&_action9); } void Scene1337::playAntiDelayCard(Card *card, Card *dest) { _actionCard1 = card; _actionCard2 = dest; - _item1.setAction(&_action8); + _actionItem.setAction(&_action8); + + handleNextTurn(); } -Scene1337::Card *Scene1337::subC34EC(int arg1) { + +Scene1337::Card *Scene1337::getStationCard(int playerId) { for (int i = 0; i <= 7; i++) { - if ((_gameBoardSide[arg1]._outpostStation[i]._cardId > 0) && (_gameBoardSide[arg1]._outpostStation[i]._cardId < 10)) - return &_gameBoardSide[arg1]._outpostStation[i]; + if ((_gameBoardSide[playerId]._outpostStation[i]._cardId >= 1) && (_gameBoardSide[playerId]._outpostStation[i]._cardId <= 9)) + return &_gameBoardSide[playerId]._outpostStation[i]; } return nullptr; @@ -5091,16 +5039,17 @@ Scene1337::Card *Scene1337::subC34EC(int arg1) { void Scene1337::playCounterTrickCard(Card *card, int playerId) { _actionCard1 = card; - _actionCard2 = subC34EC(playerId); + _actionCard2 = getStationCard(playerId); _actionCard3 = &_gameBoardSide[playerId]._emptyStationPos; _actionIdx1 = playerId; - _item1.setAction(&_action10); + _actionItem.setAction(&_action10); + handleNextTurn(); } void Scene1337::discardCard(Card *card) { _actionCard1 = card; - _item1.setAction(&_action5); + _actionItem.setAction(&_action5); } void Scene1337::subC4CD2() { @@ -5121,7 +5070,7 @@ void Scene1337::subC51A0(Card *subObj1, Card *subObj2) { _actionCard1 = subObj1; _actionCard2 = subObj2; - _item1.setAction(&_action13); + _actionItem.setAction(&_action13); } void Scene1337::displayDialog(int dialogNumb) { @@ -5398,7 +5347,7 @@ void Scene1337::suggestInstructions() { } void Scene1337::displayInstructions() { - _item1.setAction(&_action1); + _actionItem.setAction(&_action1); } void Scene1337::shuffleCards() { @@ -5453,11 +5402,12 @@ void Scene1337::dealCards() { shuffleCards(); // Deal cards - _item1.setAction(&_action3); + _actionItem.setAction(&_action3); } -void Scene1337::subCD193() { + +void Scene1337::showOptionsDialog() { // Display menu with "Auto Play", "New Game", "Quit" and "Continue" - warning("STUBBED: subCD193()"); + OptionsDialog::show(); } void Scene1337::handleClick(int arg1, Common::Point pt) { @@ -5505,98 +5455,88 @@ void Scene1337::handleClick(int arg1, Common::Point pt) { default: break; } - } else { - if ( _gameBoardSide[2]._delayCard.isIn(pt) + } else if ( _gameBoardSide[2]._delayCard.isIn(pt) || _gameBoardSide[0]._delayCard.isIn(pt) || _gameBoardSide[1]._delayCard.isIn(pt) || _gameBoardSide[3]._delayCard.isIn(pt) ) { - found = true; + switch (curReg) { + case 5: + if (_gameBoardSide[2]._delayCard._cardId != 0) + displayDialog(_gameBoardSide[2]._delayCard._cardId); + else + actionDisplay(1330, 10, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 10: + if (_gameBoardSide[3]._delayCard._cardId != 0) + displayDialog(_gameBoardSide[3]._delayCard._cardId); + else + actionDisplay(1330, 16, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 15: + if (_gameBoardSide[0]._delayCard._cardId != 0) + displayDialog(_gameBoardSide[0]._delayCard._cardId); + else + actionDisplay(1330, 13, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 20: + if (_gameBoardSide[1]._delayCard._cardId != 0) + displayDialog(_gameBoardSide[1]._delayCard._cardId); + else + actionDisplay(1330, 18, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + default: + break; } - - if (found) { - switch (curReg) { - case 5: - if (_gameBoardSide[2]._delayCard._cardId != 0) - displayDialog(_gameBoardSide[2]._delayCard._cardId); - else - actionDisplay(1330, 10, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 10: - if (_gameBoardSide[3]._delayCard._cardId != 0) - displayDialog(_gameBoardSide[3]._delayCard._cardId); - else - actionDisplay(1330, 16, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 15: - if (_gameBoardSide[0]._delayCard._cardId != 0) - displayDialog(_gameBoardSide[3]._delayCard._cardId); - else - actionDisplay(1330, 13, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 20: - if (_gameBoardSide[1]._delayCard._cardId != 0) - displayDialog(_gameBoardSide[1]._delayCard._cardId); - else - actionDisplay(1330, 18, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - default: - break; - } - } else { - if (_discardPile.isIn(pt)) { - if (_discardPile._cardId != 0) - displayDialog(_discardPile._cardId); - else - actionDisplay(1330, 7, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else if (_helpIcon._bounds.contains(pt)) { - actionDisplay(1330, 43, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else if (_stockCard.isIn(pt)) { - actionDisplay(1330, 4, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else if ( (_gameBoardSide[2]._emptyStationPos.isIn(pt)) - || (_gameBoardSide[3]._emptyStationPos.isIn(pt)) - || (_gameBoardSide[0]._emptyStationPos.isIn(pt)) - || (_gameBoardSide[1]._emptyStationPos.isIn(pt)) ) { - actionDisplay(1330, 32, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else { - if (_gameBoardSide[2]._handCard[0].isIn(pt)) - displayDialog(_gameBoardSide[2]._handCard[0]._cardId); - else if (_gameBoardSide[2]._handCard[1].isIn(pt)) - displayDialog(_gameBoardSide[2]._handCard[1]._cardId); - else if (_gameBoardSide[2]._handCard[2].isIn(pt)) - displayDialog(_gameBoardSide[2]._handCard[2]._cardId); - else if (_gameBoardSide[2]._handCard[3].isIn(pt)) - displayDialog(_gameBoardSide[2]._handCard[3]._cardId); - else if ((curReg >= 6) && (curReg <= 9)) - actionDisplay(1330, 29, 159, 10, 1, 200, 0, 7, 0, 154, 154); - else if ((curReg >= 11) && (curReg <= 14)) - actionDisplay(1330, 31, 159, 10, 1, 200, 0, 7, 0, 154, 154); - else if ((curReg >= 16) && (curReg <= 19)) - actionDisplay(1330, 30, 159, 10, 1, 200, 0, 7, 0, 154, 154); - else { - switch (curReg) { - case 0: - actionDisplay(1330, 2, 159, 134, 1, 200, 0, 7, 0, 105, 105); - break; - case 5: - actionDisplay(1330, 25, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 10: - actionDisplay(1330, 27, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 15: - actionDisplay(1330, 26, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 20: - actionDisplay(1330, 28, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 21: - actionDisplay(1330, 24, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - default: - break; - } - } - } + } else if (_discardPile.isIn(pt)) { + if (_discardPile._cardId != 0) + displayDialog(_discardPile._cardId); + else + actionDisplay(1330, 7, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } else if (_helpIcon._bounds.contains(pt)) + actionDisplay(1330, 43, 159, 10, 1, 200, 0, 7, 0, 154, 154); + else if (_stockCard.isIn(pt)) + actionDisplay(1330, 4, 159, 10, 1, 200, 0, 7, 0, 154, 154); + else if ( (_gameBoardSide[2]._emptyStationPos.isIn(pt)) + || (_gameBoardSide[3]._emptyStationPos.isIn(pt)) + || (_gameBoardSide[0]._emptyStationPos.isIn(pt)) + || (_gameBoardSide[1]._emptyStationPos.isIn(pt)) ) + actionDisplay(1330, 32, 159, 10, 1, 200, 0, 7, 0, 154, 154); + else if (_gameBoardSide[2]._handCard[0].isIn(pt)) + displayDialog(_gameBoardSide[2]._handCard[0]._cardId); + else if (_gameBoardSide[2]._handCard[1].isIn(pt)) + displayDialog(_gameBoardSide[2]._handCard[1]._cardId); + else if (_gameBoardSide[2]._handCard[2].isIn(pt)) + displayDialog(_gameBoardSide[2]._handCard[2]._cardId); + else if (_gameBoardSide[2]._handCard[3].isIn(pt)) + displayDialog(_gameBoardSide[2]._handCard[3]._cardId); + else if ((curReg >= 6) && (curReg <= 9)) + actionDisplay(1330, 29, 159, 10, 1, 200, 0, 7, 0, 154, 154); + else if ((curReg >= 11) && (curReg <= 14)) + actionDisplay(1330, 31, 159, 10, 1, 200, 0, 7, 0, 154, 154); + else if ((curReg >= 16) && (curReg <= 19)) + actionDisplay(1330, 30, 159, 10, 1, 200, 0, 7, 0, 154, 154); + else { + switch (curReg) { + case 0: + actionDisplay(1330, 2, 159, 134, 1, 200, 0, 7, 0, 105, 105); + break; + case 5: + actionDisplay(1330, 25, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 10: + actionDisplay(1330, 27, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 15: + actionDisplay(1330, 26, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 20: + actionDisplay(1330, 28, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 21: + actionDisplay(1330, 24, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + default: + break; } } } @@ -5617,9 +5557,9 @@ void Scene1337::handleClick(int arg1, Common::Point pt) { actionDisplay(1330, 34, 159, 10, 1, 200, 0, 7, 0, 154, 154); break; } - found = true; - break; - } else if (_gameBoardSide[0]._outpostStation[i].isIn(pt)) { + return; + } + if (_gameBoardSide[0]._outpostStation[i].isIn(pt)) { switch (_gameBoardSide[0]._outpostStation[i]._cardId) { case 0: actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154); @@ -5628,9 +5568,9 @@ void Scene1337::handleClick(int arg1, Common::Point pt) { actionDisplay(1330, 1, 159, 10, 1, 200, 0, 7, 0, 154, 154); break; } - found = true; - break; - } else if (_gameBoardSide[1]._outpostStation[i].isIn(pt)) { + return; + } + if (_gameBoardSide[1]._outpostStation[i].isIn(pt)) { switch (_gameBoardSide[1]._outpostStation[i]._cardId) { case 0: actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117); @@ -5639,9 +5579,9 @@ void Scene1337::handleClick(int arg1, Common::Point pt) { actionDisplay(1330, 144, 300, 99, 1, 136, 0, 7, 0, 117, 117); break; } - found = true; - break; - } else if (_gameBoardSide[3]._outpostStation[i].isIn(pt)) { + return; + } + if (_gameBoardSide[3]._outpostStation[i].isIn(pt)) { switch (_gameBoardSide[3]._outpostStation[i]._cardId) { case 0: actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172); @@ -5650,68 +5590,58 @@ void Scene1337::handleClick(int arg1, Common::Point pt) { actionDisplay(1330, 145, 20, 99, 1, 136, 0, 7, 0, 172, 172); break; } - found = true; - break; + return; } } if (_gameBoardSide[2]._delayCard.isIn(pt)) { // The original uses _gameBoardSide[0], which is obviously a bug. - if (_gameBoardSide[2]._delayCard._cardId != 0) { + if (_gameBoardSide[2]._delayCard._cardId != 0) actionDisplay(1330, 39, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else { + else actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } - found = true; - } + return; + } if (_gameBoardSide[3]._delayCard.isIn(pt)) { - if (_gameBoardSide[3]._delayCard._cardId != 0) { + if (_gameBoardSide[3]._delayCard._cardId != 0) actionDisplay(1330, 145, 20, 99, 1, 136, 0, 7, 0, 172, 172); - } else { + else actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172); - } - found = true; - } + return; + } if (_gameBoardSide[1]._delayCard.isIn(pt)) { - if (_gameBoardSide[1]._delayCard._cardId != 0) { + if (_gameBoardSide[1]._delayCard._cardId != 0) actionDisplay(1330, 144, 300, 99, 1, 136, 0, 7, 0, 117, 117); - } else { + else actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117); - } - found = true; - } + return; + } if (_gameBoardSide[0]._delayCard.isIn(pt)) { - if (_gameBoardSide[0]._delayCard._cardId != 0) { + if (_gameBoardSide[0]._delayCard._cardId != 0) actionDisplay(1330, 1, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else { + else actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } - found = true; - } + return; + } if (_gameBoardSide[3]._emptyStationPos.isIn(pt)) { actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172); - found = true; + return; } - if (_gameBoardSide[1]._emptyStationPos.isIn(pt)) { actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117); - found = true; + return; } - if (_gameBoardSide[0]._emptyStationPos.isIn(pt)) { actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154); - found = true; - } - - if (found) return; + } if (_helpIcon._bounds.contains(pt)) { - subCD193(); + showOptionsDialog(); return; } @@ -5765,8 +5695,6 @@ void Scene1337::handleClick(int arg1, Common::Point pt) { } void Scene1337::handlePlayer0() { - bool found = true; - if (_gameBoardSide[0]._delayCard._cardId != 0) { switch (_gameBoardSide[0]._delayCard._cardId) { case 10: @@ -5785,243 +5713,154 @@ void Scene1337::handlePlayer0() { //No break on purpose case 21: discardCard(&_gameBoardSide[0]._delayCard); - found = false; break; default: - int i; - found = false; - - for (i = 0; i <= 3; i++) { + for (int i = 0; i <= 3; i++) { if (checkAntiDelayCard(_gameBoardSide[0]._delayCard._cardId, _gameBoardSide[0]._handCard[i]._cardId)) { - found = true; - break; + playAntiDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[0]._delayCard); + return; } } - if (found) { - found = false; - playAntiDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[0]._delayCard); - } break; } } - if (found) - return; - - int tmpVal; - found = false; for (int i = 0; i <= 3; i++) { - tmpVal = subC26CB(0, i); + int tmpVal = getStationId(0, i); if (tmpVal != -1) { - bool flag = false; + bool stationAlreadyPresentFl = false; for (int j = 0; j <= 7; j++) { if (_gameBoardSide[0]._outpostStation[j]._cardId == _gameBoardSide[0]._handCard[tmpVal]._cardId) { - flag = true; + stationAlreadyPresentFl = true; break; } } - if (!flag) { + if (!stationAlreadyPresentFl) { for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[0]._outpostStation[j]._cardId == 1) && (!subC2687(_gameBoardSide[0]._delayCard._cardId))) { - int count = 0; + if ((_gameBoardSide[0]._outpostStation[j]._cardId == 1) && !isStopConstructionCard(_gameBoardSide[0]._delayCard._cardId)) { + int stationCount = 0; for (int k = 0; k <= 7; k++) { if ((_gameBoardSide[0]._outpostStation[k]._cardId > 1) && (_gameBoardSide[0]._outpostStation[k]._cardId <= 9)) { - ++count; + ++stationCount; } } - if (count == 7) + if (stationCount == 7) _winnerId = 0; - subC33C0(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[j]); - found = true; + playStationCard(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[j]); + return; } } } } - - if (found) - break; } - if (found) - return; - - found = false; - tmpVal = findNormalCardInHand(0); + int tmpVal = findPlatformCardInHand(0); if (tmpVal != -1) { for (int i = 0; i <= 7; i++) { - if ((_gameBoardSide[0]._outpostStation[i]._cardId == 0) && (!subC2687(_gameBoardSide[0]._delayCard._cardId))) { - playCard(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[i]); - found = true; - break; + if ((_gameBoardSide[0]._outpostStation[i]._cardId == 0) && !isStopConstructionCard(_gameBoardSide[0]._delayCard._cardId)) { + playPlatformCard(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[i]); + return; } } } - if (found) - return; - - tmpVal = subC274D(0); - if (tmpVal != -1) { + int card13Id = findCard13InHand(0); + if (card13Id != -1) { for (int i = 0; i <= 7; i++) { if (_gameBoardSide[2]._outpostStation[i]._cardId != 0) { - playCounterTrickCard(&_gameBoardSide[0]._handCard[tmpVal], 2); - found = true; - break; + playCounterTrickCard(&_gameBoardSide[0]._handCard[card13Id], 2); + return; } } } - if (found) - return; - - tmpVal = subC2781(0); - if (tmpVal != -1) { + int thieftId = checkThieftCard(0); + if (thieftId != -1) { if ( (_gameBoardSide[2]._handCard[0]._cardId != 0) || (_gameBoardSide[2]._handCard[1]._cardId != 0) || (_gameBoardSide[2]._handCard[2]._cardId != 0) || (_gameBoardSide[2]._handCard[3]._cardId != 0) ) { - playThieftCard(0, &_gameBoardSide[0]._handCard[tmpVal], 2); - found = true; + playThieftCard(0, &_gameBoardSide[0]._handCard[thieftId], 2); + return; } } - if (found) - return; - for (int i = 0; i <= 3; i++) { - if (subC27B5(_gameBoardSide[0]._handCard[i]._cardId) != -1) { - // The variable 'j' is not used in the inner code of the loop. It's suspect - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[2]._delayCard._cardId == 0) && (subC32B1(2, _gameBoardSide[0]._handCard[i]._cardId))) { - playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard); - found = true; - break; - } - } - - if (found) - break; + if ((isDelayCard(_gameBoardSide[0]._handCard[i]._cardId) != -1) + && (_gameBoardSide[2]._delayCard._cardId == 0) + && isAttackPossible(2, _gameBoardSide[0]._handCard[i]._cardId)) { + playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard); + return; } } - if (found) - return; - for (int i = 0; i <= 3; i++) { - if (isSlowCard(_gameBoardSide[0]._handCard[i]._cardId) != -1) { - // The variable 'j' is not used in the inner code of the loop. It's suspect - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[2]._delayCard._cardId == 0) && (subC32B1(2, _gameBoardSide[0]._handCard[i]._cardId))) { - playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard); - found = true; - } - } - - if (found) - break; + if ((getStationCardId(_gameBoardSide[0]._handCard[i]._cardId) != -1) + && (_gameBoardSide[2]._delayCard._cardId == 0) + && isAttackPossible(2, _gameBoardSide[0]._handCard[i]._cardId)) { + playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard); + return; } } - if (found) - return; + card13Id = findCard13InHand(0); + int victimPlayerId = getPlayerWithOutpost(0); - tmpVal = subC274D(0); - int tmpVal2 = subC331B(0); - - if ((tmpVal != -1) && (tmpVal2 != -1)) { - playCounterTrickCard(&_gameBoardSide[0]._handCard[tmpVal], tmpVal2); - found = true; - } - - if (found) + if ((card13Id != -1) && (victimPlayerId != -1)) { + playCounterTrickCard(&_gameBoardSide[0]._handCard[card13Id], victimPlayerId); return; + } - tmpVal = subC2781(0); - if (tmpVal != -1) { + thieftId = checkThieftCard(0); + if (thieftId != -1) { if ( (_gameBoardSide[1]._handCard[0]._cardId != 0) || (_gameBoardSide[1]._handCard[1]._cardId != 0) || (_gameBoardSide[1]._handCard[2]._cardId != 0) || (_gameBoardSide[1]._handCard[3]._cardId != 0) ) { - playThieftCard(0, &_gameBoardSide[0]._handCard[tmpVal], 1); - found = true; + playThieftCard(0, &_gameBoardSide[0]._handCard[thieftId], 1); + return; } } - if (found) - return; - for (int i = 0; i <= 3; i++) { - tmpVal = isSlowCard(_gameBoardSide[0]._handCard[i]._cardId); - if (tmpVal != -1) { - // The variable 'j' is not used in the inner code of the loop. It's suspect. - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[1]._delayCard._cardId == 0) && (subC32B1(1, _gameBoardSide[0]._handCard[i]._cardId))) { - playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard); - found = true; - } + if (getStationCardId(_gameBoardSide[0]._handCard[i]._cardId) != -1) { + if ((_gameBoardSide[1]._delayCard._cardId == 0) && isAttackPossible(1, _gameBoardSide[0]._handCard[i]._cardId)) { + playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard); + return; } - if (!found) { - // The variable 'j' is not used in the inner code of the loop. It's suspect. - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[3]._delayCard._cardId == 0) && (subC32B1(3, _gameBoardSide[0]._handCard[i]._cardId))) { - playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard); - found = true; - } - } + if ((_gameBoardSide[3]._delayCard._cardId == 0) && isAttackPossible(3, _gameBoardSide[0]._handCard[i]._cardId)) { + playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard); + return; } - - if (found) - break; } } - if (found) - return; - for (int i = 0; i <= 3; i++) { - tmpVal = subC27B5(_gameBoardSide[0]._handCard[i]._cardId); + tmpVal = isDelayCard(_gameBoardSide[0]._handCard[i]._cardId); if (tmpVal != -1) { - // The variable 'j' is not used in the inner code of the loop. It's suspect. - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[1]._delayCard._cardId == 0) && (subC32B1(1, _gameBoardSide[0]._handCard[i]._cardId))) { - playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard); - found = true; - } + if ((_gameBoardSide[1]._delayCard._cardId == 0) && isAttackPossible(1, _gameBoardSide[0]._handCard[i]._cardId)) { + playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard); + return; } - if (!found) { - // The variable 'j' is not used in the inner code of the loop. It's suspect. - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[3]._delayCard._cardId == 0) && (subC32B1(3, _gameBoardSide[0]._handCard[i]._cardId))) { - playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard); - found = true; - } - } + if ((_gameBoardSide[3]._delayCard._cardId == 0) && isAttackPossible(3, _gameBoardSide[0]._handCard[i]._cardId)) { + playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard); + return; } - - if (found) - break; } } - if (found) - return; - - subC2835(0); + handlePlayer01Discard(0); } void Scene1337::handlePlayer1() { - int tmpVal = 1; - bool found; - int count; - if (this->_gameBoardSide[1]._delayCard._cardId != 0) { switch (_gameBoardSide[1]._delayCard._cardId) { case 10: @@ -6039,36 +5878,25 @@ void Scene1337::handlePlayer1() { case 20: // No break on purpose case 21: - tmpVal = 0; discardCard(&_gameBoardSide[1]._delayCard); - break; + return; default: - found = false; - int i; - for (i = 0; i <= 3; i++) { + for (int i = 0; i <= 3; i++) { if (checkAntiDelayCard(_gameBoardSide[1]._delayCard._cardId, _gameBoardSide[1]._handCard[i]._cardId)) { - found = true; - break; + playAntiDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[1]._delayCard); + return; } } - - if (found) { - tmpVal = 0; - playAntiDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[1]._delayCard); - } + break; } } - if (tmpVal != 1) - return; - - found = false; for (int i = 0; i <= 3; i++) { - int tmpIndx = subC26CB(1, i); + int tmpIndx = getStationId(1, i); if (tmpIndx == -1) break; - tmpVal = 0; + int tmpVal = 0; for (int j = 0; j <= 7; j++) { if (_gameBoardSide[1]._outpostStation[j]._cardId == _gameBoardSide[1]._handCard[tmpIndx]._cardId) { tmpVal = 1; @@ -6080,54 +5908,43 @@ void Scene1337::handlePlayer1() { break; for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[1]._outpostStation[j]._cardId == 1) && !subC2687(_gameBoardSide[1]._delayCard._cardId)) { - count = 0; + if ((_gameBoardSide[1]._outpostStation[j]._cardId == 1) && !isStopConstructionCard(_gameBoardSide[1]._delayCard._cardId)) { + int stationCount = 0; for (int k = 0; k <= 7; k++) { if ((_gameBoardSide[1]._outpostStation[k]._cardId > 1) && (_gameBoardSide[1]._outpostStation[k]._cardId <= 9)) - ++count; + ++stationCount; } - if (count == 7) + if (stationCount == 7) _winnerId = 1; - subC33C0(&_gameBoardSide[1]._handCard[tmpIndx], &_gameBoardSide[1]._outpostStation[j]); - found = true; - break; + playStationCard(&_gameBoardSide[1]._handCard[tmpIndx], &_gameBoardSide[1]._outpostStation[j]); + return; } } } - if (found) - return; - - tmpVal = findNormalCardInHand(1); - if (tmpVal != -1) { + int normalCardId = findPlatformCardInHand(1); + if (normalCardId != -1) { for (int i = 0; i <= 7; i++) { - if ((_gameBoardSide[1]._outpostStation[i]._cardId == 0) && (!subC2687(_gameBoardSide[1]._delayCard._cardId))) { - playCard(&_gameBoardSide[1]._handCard[tmpVal], &_gameBoardSide[1]._outpostStation[i]); - found = true; - break; + if ((_gameBoardSide[1]._outpostStation[i]._cardId == 0) && !isStopConstructionCard(_gameBoardSide[1]._delayCard._cardId)) { + playPlatformCard(&_gameBoardSide[1]._handCard[normalCardId], &_gameBoardSide[1]._outpostStation[i]); + return; } } } - if (found) - return; - - tmpVal = subC274D(1); - int tmpVal2 = subC331B(1); + int card13Id = findCard13InHand(1); + int tmpVal2 = getPlayerWithOutpost(1); - if ((tmpVal != -1) && ( tmpVal2 != -1)) { - playCounterTrickCard(&_gameBoardSide[1]._handCard[tmpVal], tmpVal2); - found = true; - } - - if (found) + if ((card13Id != -1) && (tmpVal2 != -1)) { + playCounterTrickCard(&_gameBoardSide[1]._handCard[card13Id], tmpVal2); return; + } - tmpVal = subC2781(1); - if (tmpVal != -1) { - count = -1; + int thieftId = checkThieftCard(1); + if (thieftId != -1) { + int playerIdFound = -1; int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3); for (int i = 0; i <= 3; i++) { if (rndVal != 1) { @@ -6135,103 +5952,75 @@ void Scene1337::handlePlayer1() { || (_gameBoardSide[rndVal]._handCard[1]._cardId != 0) || (_gameBoardSide[rndVal]._handCard[2]._cardId != 0) || (_gameBoardSide[rndVal]._handCard[3]._cardId == 0)) { - count = rndVal; + playerIdFound = rndVal; break; } - // CHECKME: inside the check on rndVal? - rndVal--; - if (rndVal < 0) - rndVal = 3; } + // The original was only updating in the rndVal block, + // which was a bug as the checks were stopping at this point + rndVal--; + if (rndVal < 0) + rndVal = 3; } - if (count != -1) { - playThieftCard(1, &_gameBoardSide[1]._handCard[tmpVal], count); - found = true; + if (playerIdFound != -1) { + playThieftCard(1, &_gameBoardSide[1]._handCard[thieftId], playerIdFound); + return; } } - if (found) - return; - - count = -1; + int count = -1; int i; for (i = 0; i <= 3; i++) { - tmpVal = subC27B5(_gameBoardSide[1]._handCard[i]._cardId); + int tmpVal = isDelayCard(_gameBoardSide[1]._handCard[i]._cardId); if (tmpVal != -1) { int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3); for (int j = 0; j <= 3; j++) { //CHECKME: tmpVal or rndVal? if (tmpVal != 1) { - for (int k = 0; k <= 7; k++) { - // CHECKME: 'k' is not used in that loop. - // It looks suspicious. - if ((_gameBoardSide[tmpVal]._delayCard._cardId == 0) && (subC32B1(tmpVal, _gameBoardSide[1]._handCard[i]._cardId))) { - count = tmpVal; - break; - } - } + if ((_gameBoardSide[tmpVal]._delayCard._cardId == 0) && isAttackPossible(tmpVal, _gameBoardSide[1]._handCard[i]._cardId)) + count = tmpVal; } if (count != -1) { - found = true; - break; + playDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[count]._delayCard); + return; } else { rndVal--; if (rndVal < 0) rndVal = 3; } } - - if (found) - break; } } - if (found) - playDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[count]._delayCard); - else { - int j; - for (j = 0; j <= 3; j++) { - if (isSlowCard(_gameBoardSide[1]._handCard[j]._cardId) != -1) { - count = -1; - int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3); - for (int l = 0; l <= 3; l++) { - if (rndVal != 1) { - for (int m = 0; m <= 7; m++) { - // 'm' is not used in that loop. It looks suspicious. - if ((_gameBoardSide[rndVal]._delayCard._cardId == 0) && (_gameBoardSide[1]._handCard[j]._cardId == 1)) { - count = rndVal; - break; - } - } - } - if (count != -1) { - found = true; - break; - } else { - rndVal--; - if (rndVal < 0) - rndVal = 3; - } + int j; + for (j = 0; j <= 3; j++) { + if (getStationCardId(_gameBoardSide[1]._handCard[j]._cardId) != -1) { + count = -1; + int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3); + for (int l = 0; l <= 3; l++) { + if (rndVal != 1) { + if ((_gameBoardSide[rndVal]._delayCard._cardId == 0) && (_gameBoardSide[1]._handCard[j]._cardId == 1)) + count = rndVal; + } + if (count != -1) { + playDelayCard(&_gameBoardSide[1]._handCard[j], &_gameBoardSide[count]._delayCard); + return; + } else { + rndVal--; + if (rndVal < 0) + rndVal = 3; } - if (found) - break; } } - - if (found) - playDelayCard(&_gameBoardSide[1]._handCard[j], &_gameBoardSide[count]._delayCard); - else - subC2835(1); } + handlePlayer01Discard(1); } void Scene1337::handlePlayer3() { - bool found = true; - if (_gameBoardSide[3]._delayCard._cardId != 0) { switch (_gameBoardSide[3]._delayCard._cardId) { case 10: @@ -6250,86 +6039,59 @@ void Scene1337::handlePlayer3() { // No break on purpose case 21: discardCard(&_gameBoardSide[3]._delayCard); - found = false; - break; + return; default: - found = false; - int i; - for (i = 0; i <= 3; i++) { + for (int i = 0; i <= 3; i++) { if (checkAntiDelayCard(_gameBoardSide[3]._delayCard._cardId, _gameBoardSide[3]._handCard[i]._cardId)) { - found = true; - break; + playAntiDelayCard(&_gameBoardSide[3]._handCard[i], &_gameBoardSide[3]._delayCard); + return; } } - - if (found) { - found = false; - playAntiDelayCard(&_gameBoardSide[3]._handCard[i], &_gameBoardSide[3]._delayCard); - } break; } } - if (!found) - return; - int randIndx = R2_GLOBALS._randomSource.getRandomNumber(3); if (_gameBoardSide[3]._handCard[randIndx]._cardId == 1) { - found = false; - for (int i = 0; i <= 7; i++) { - if ((_gameBoardSide[3]._outpostStation[i]._cardId == 0) && (!subC2687(_gameBoardSide[3]._delayCard._cardId))) { - playCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]); - found = true; - break; + if ((_gameBoardSide[3]._outpostStation[i]._cardId == 0) && !isStopConstructionCard(_gameBoardSide[3]._delayCard._cardId)) { + playPlatformCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]); + return; } } - - if (found) { - return; - } } else if (_gameBoardSide[3]._handCard[randIndx]._cardId <= 9) { - found = false; - for (int i = 0; i <= 7; i++) { if (_gameBoardSide[3]._outpostStation[i]._cardId == _gameBoardSide[3]._handCard[randIndx]._cardId) { - found = true; - break; + discardCard(&_gameBoardSide[3]._handCard[randIndx]); + return; } } - if (!found) { - for (int i = 0; i <= 7; i++) { - if ((_gameBoardSide[3]._outpostStation[i]._cardId == 1) && (!subC2687(_gameBoardSide[3]._delayCard._cardId))) { - int tmpVal = 0; - - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[3]._outpostStation[j]._cardId > 1) && (_gameBoardSide[3]._outpostStation[j]._cardId <= 9)) - ++tmpVal; - } + for (int i = 0; i <= 7; i++) { + if ((_gameBoardSide[3]._outpostStation[i]._cardId == 1) && !isStopConstructionCard(_gameBoardSide[3]._delayCard._cardId)) { + int stationCount = 0; + for (int j = 0; j <= 7; j++) { + if ((_gameBoardSide[3]._outpostStation[j]._cardId > 1) && (_gameBoardSide[3]._outpostStation[j]._cardId <= 9)) + ++stationCount; + } - if (tmpVal == 7) - _winnerId = 3; + if (stationCount == 7) + _winnerId = 3; - subC33C0(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]); - found = true; - break; - } - } - if (found) + playStationCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]); return; + } } } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 13) { - int tmpVal = subC331B(3); + int victimId = getPlayerWithOutpost(3); - if (tmpVal != -1) { - playCounterTrickCard(&_gameBoardSide[3]._handCard[randIndx], tmpVal); + if (victimId != -1) { + playCounterTrickCard(&_gameBoardSide[3]._handCard[randIndx], victimId); return; } } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 25) { - int tmpVal = -1; - found = false; + int victimId = -1; int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3); for (int i = 0; i <= 3; i++) { @@ -6338,7 +6100,7 @@ void Scene1337::handlePlayer3() { || (_gameBoardSide[tmpRandIndx]._handCard[1]._cardId != 0) || (_gameBoardSide[tmpRandIndx]._handCard[2]._cardId != 0) || (_gameBoardSide[tmpRandIndx]._handCard[3]._cardId != 0) )) { - tmpVal = tmpRandIndx; + victimId = tmpRandIndx; break; } @@ -6347,8 +6109,8 @@ void Scene1337::handlePlayer3() { tmpRandIndx = 0; } - if (tmpVal != -1) { - playThieftCard(3, &_gameBoardSide[3]._handCard[randIndx], tmpVal); + if (victimId != -1) { + playThieftCard(3, &_gameBoardSide[3]._handCard[randIndx], victimId); return; } } else { @@ -6376,30 +6138,27 @@ void Scene1337::handlePlayer3() { case 21: // No break on purpose case 24: { - int tmpVal = -1; + int victimId = -1; int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3); for (int i = 0; i <= 3; i++) { if (tmpRandIndx != 3) { - // The variable 'j' is not used in the inner code of the loop, which is suspicious. - // 'i' is used indirectly to increment tmpRandIndx. - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[tmpRandIndx]._delayCard._cardId == 0) && subC32B1(tmpRandIndx, _gameBoardSide[3]._handCard[randIndx]._cardId)) - tmpVal = tmpRandIndx; - } + if ((_gameBoardSide[tmpRandIndx]._delayCard._cardId == 0) + && isAttackPossible(tmpRandIndx, _gameBoardSide[3]._handCard[randIndx]._cardId)) + victimId = tmpRandIndx; } ++tmpRandIndx; if (tmpRandIndx > 3) tmpRandIndx = 0; - if (tmpVal != -1) + if (victimId != -1) break; } - if (tmpVal != -1) { + if (victimId != -1) { // Useless second identical check skipped - playDelayCard(&_gameBoardSide[tmpVal]._handCard[randIndx], &_gameBoardSide[tmpVal]._delayCard); + playDelayCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[victimId]._delayCard); return; } } @@ -6411,14 +6170,14 @@ void Scene1337::handlePlayer3() { discardCard(&_gameBoardSide[3]._handCard[randIndx]); } -void Scene1337::handlePlayer2() { - if (isSlowCard(this->_gameBoardSide[2]._delayCard._cardId) == -1) - _delayedFunction = &Scene1337::subD02CA; +void Scene1337::handleAutoplayPlayer2() { + if (getStationCardId(this->_gameBoardSide[2]._delayCard._cardId) == -1) + _delayedFunction = &Scene1337::handlePlayer2; else discardCard(&_gameBoardSide[2]._delayCard); } -void Scene1337::subD02CA() { +void Scene1337::handlePlayer2() { _selectedCard._stationPos = g_globals->_events._mousePos; if (R2_GLOBALS._v57810 == 200) { @@ -6429,12 +6188,12 @@ void Scene1337::subD02CA() { Card *handcard = &_gameBoardSide[2]._handCard[i]; _selectedCard._cardId = handcard->_cardId; _selectedCard._stationPos = handcard->_stationPos; - // _selectedCard._actorName = handcard->_actorName; - _selectedCard._fieldE = handcard->_fieldE; - _selectedCard._field10 = handcard->_field10; - warning("_selectedCard._field12 = handcard->_field12;"); - warning("_selectedCard._field14 = handcard->_field14;"); - warning("_selectedCard._field16 = handcard->_field16;"); + //warning("_selectedCard._actorName = handcard->_actorName;"); + //warning("_selectedCard._fieldE = handcard->_fieldE;"); + //warning("_selectedCard._field10 = handcard->_field10;"); + //warning("_selectedCard._field12 = handcard->_field12;"); + //warning("_selectedCard._field14 = handcard->_field14;"); + //warning("_selectedCard._field16 = handcard->_field16;"); _selectedCard._sceneRegionId = handcard->_sceneRegionId; _selectedCard._position = handcard->_position; _selectedCard._yDiff = handcard->_yDiff; @@ -6444,11 +6203,11 @@ void Scene1337::subD02CA() { _selectedCard._talkLineNum = handcard->_talkLineNum; _selectedCard._useLineNum = handcard->_useLineNum; _selectedCard._action = handcard->_action; - warning("_selectedCard._field0 = handcard->_field0;"); + //warning("_selectedCard._field0 = handcard->_field0;"); _selectedCard._card._updateStartFrame = handcard->_card._updateStartFrame; _selectedCard._card._walkStartFrame = handcard->_card._walkStartFrame; // _field2E is named _field3C in R2R - _selectedCard._card._field2E = handcard->_card._field2E; + _selectedCard._card._oldPosition = handcard->_card._oldPosition; _selectedCard._card._percent = handcard->_card._percent; _selectedCard._card._priority = handcard->_card._priority; _selectedCard._card._angle = handcard->_card._angle; @@ -6464,7 +6223,7 @@ void Scene1337::subD02CA() { _selectedCard._card._frame = handcard->_card._frame; _selectedCard._card._endFrame = handcard->_card._endFrame; // _field68 is named _field76 in R2R - _selectedCard._card._field68 = handcard->_card._field68; + _selectedCard._card._loopCount = handcard->_card._loopCount; _selectedCard._card._frameChange = handcard->_card._frameChange; _selectedCard._card._numFrames = handcard->_card._numFrames; _selectedCard._card._regionIndex = handcard->_card._regionIndex; @@ -6475,12 +6234,11 @@ void Scene1337::subD02CA() { _selectedCard._card._endAction = handcard->_card._endAction; _selectedCard._card._regionBitList = handcard->_card._regionBitList; // _selectedCard._object1._actorName = handcard->_object1._actorName; - _selectedCard._card._fieldE = handcard->_card._fieldE; - _selectedCard._card._field10 = handcard->_card._field10; - warning("_selectedCard._card._field12 = handcard->_card._field12;"); - warning("_selectedCard._card._field14 = handcard->_card._field14;"); - warning("_selectedCard._card._field16 = handcard->_card._field16;"); - // _selectedCard._card = _gameBoardSide[2]._handCard[i]._card; + //warning("_selectedCard._card._fieldE = handcard->_card._fieldE;"); + //warning("_selectedCard._card._field10 = handcard->_card._field10;"); + //warning("_selectedCard._card._field12 = handcard->_card._field12;"); + //warning("_selectedCard._card._field14 = handcard->_card._field14;"); + //warning("_selectedCard._card._field16 = handcard->_card._field16;"); _gameBoardSide[2]._handCard[i]._cardId = 0; _gameBoardSide[2]._handCard[i]._card.remove(); @@ -6490,7 +6248,7 @@ void Scene1337::subD02CA() { if (i == 4) { handleClick(1, _selectedCard._stationPos); - handlePlayer2(); + handleAutoplayPlayer2(); return; } else { setCursorData(1332, _selectedCard._card._strip, _selectedCard._card._frame); @@ -6499,25 +6257,24 @@ void Scene1337::subD02CA() { } else if (R2_GLOBALS._v57810 == 300) { // Eye handleClick(3, _selectedCard._stationPos); - handlePlayer2(); + handleAutoplayPlayer2(); return; } else { // The original code is calling a function full of dead code. // Only this message remains after a cleanup. MessageDialog::show(WRONG_ANSWER_MSG, OK_BTN_STRING); // - handlePlayer2(); + handleAutoplayPlayer2(); return; } Event event; - bool found = false; - bool found_di; + bool found; for (;;) { if ( ((g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN)) && (event.btnState == BTNSHIFT_RIGHT)) || (g_globals->_events.getEvent(event, EVENT_KEYPRESS)) ){ _selectedCard._stationPos = g_globals->_events._mousePos; - found_di = false; + found = false; for (int i = 0; i <= 3; i ++) { if (_gameBoardSide[2]._handCard[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { @@ -6530,320 +6287,308 @@ void Scene1337::subD02CA() { _gameBoardSide[2]._handCard[i]._card.fixPriority(170); setAnimationInfo(&_gameBoardSide[2]._handCard[i]); setCursorData(5, 1, 4); - found = true; _currentPlayerNumb--; _showPlayerTurn = false; handleNextTurn(); + return; } else { actionDisplay(1330, 127, 159, 10, 1, 200, 0, 7, 0, 154, 154); - found_di = true; + found = true; } break; } } - if ((!found) && (!found_di)) { + if (!found) { if (_discardPile.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { discardCard(&_selectedCard); - } else if (!found) { - bool foundVar4; + return; + } else if (_selectedCard._cardId == 1) { + bool isInCardFl = false; int i; - if (_selectedCard._cardId == 1) { - foundVar4 = false; - for (i = 0; i <= 7; i++) { - if (_gameBoardSide[2]._outpostStation[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { - foundVar4 = true; - break; - } + for (i = 0; i <= 7; i++) { + if (_gameBoardSide[2]._outpostStation[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { + isInCardFl = true; + break; } + } - if ((foundVar4) && (_gameBoardSide[2]._outpostStation[i]._cardId == 0)) { - if (subC27B5(_gameBoardSide[2]._delayCard._cardId) != -1) { - actionDisplay(1330, 55, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else { - playCard(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]); - return; - } + if ((isInCardFl) && (_gameBoardSide[2]._outpostStation[i]._cardId == 0)) { + if (isDelayCard(_gameBoardSide[2]._delayCard._cardId) != -1) { + actionDisplay(1330, 55, 159, 10, 1, 200, 0, 7, 0, 154, 154); } else { - actionDisplay(1330, 56, 159, 10, 1, 200, 0, 7, 0, 154, 154); + playPlatformCard(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]); + return; + } + } else { + actionDisplay(1330, 56, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } + } else if (_selectedCard._cardId <= 9) { + bool isInCardFl = false; + int i; + for (i = 0; i <= 7; i++) { + if (_gameBoardSide[2]._outpostStation[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { + isInCardFl = true; + break; } - } else if (_selectedCard._cardId <= 9) { - foundVar4 = false; - for (i = 0; i <= 7; i++) { - if (_gameBoardSide[2]._outpostStation[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { - foundVar4 = true; + } + if ((isInCardFl) && (_gameBoardSide[2]._outpostStation[i]._cardId == 1)) { + isInCardFl = false; + for (int j = 0; j <= 7; j++) { + if (_selectedCard._cardId == _gameBoardSide[2]._outpostStation[j]._cardId) { + isInCardFl = true; break; } } - if ((foundVar4) && (_gameBoardSide[2]._outpostStation[i]._cardId == 1)) { - foundVar4 = false; - int j; - for (j = 0; j <= 7; j++) { - if (_selectedCard._cardId == _gameBoardSide[2]._outpostStation[j]._cardId) { - foundVar4 = true; - break; - } + if (isInCardFl) { + // This station is already in place + actionDisplay(1330, 34, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } else if (isDelayCard(_gameBoardSide[2]._delayCard._cardId) != -1) { + // You must eliminate your delay before you can play a station + actionDisplay(1330, 35, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } else { + int stationCount = 0; + for (int k = 0; k <= 7; k++) { + if ((_gameBoardSide[2]._outpostStation[k]._cardId > 1) && (_gameBoardSide[2]._outpostStation[k]._cardId <= 9)) + ++stationCount; } - if (foundVar4) { - // This station is already in place - actionDisplay(1330, 34, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else if (subC27B5(_gameBoardSide[2]._delayCard._cardId) != -1) { - // You must eliminate your delay before you can play a station - actionDisplay(1330, 35, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else { - int tmpVal = 0; - for (int j = 0; j <= 7; j++) { - if ((_gameBoardSide[2]._outpostStation[j]._cardId > 1) && (_gameBoardSide[2]._outpostStation[j]._cardId <= 9)) - ++tmpVal; - } - - if (tmpVal == 7) - _winnerId = 2; + if (stationCount == 7) + _winnerId = 2; - subC33C0(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]); - return; + playStationCard(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]); + return; + } + } else { + actionDisplay(1330, 37, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } + } else if ((_selectedCard._cardId == 26) || (_selectedCard._cardId == 30) ||(_selectedCard._cardId == 32) || (_selectedCard._cardId == 28)) { + // Check anti-delay card + if (_gameBoardSide[2]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { + actionDisplay(1330, 42, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } else if (checkAntiDelayCard(_gameBoardSide[2]._delayCard._cardId, _selectedCard._cardId)) { + playAntiDelayCard(&_selectedCard, &_gameBoardSide[2]._delayCard); + return; + } else { + if (_gameBoardSide[2]._delayCard._cardId != 0) { + switch (_gameBoardSide[2]._delayCard._cardId) { + case 11: + actionDisplay(1330, 68, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 14: + actionDisplay(1330, 80, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 16: + actionDisplay(1330, 84, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 24: + actionDisplay(1330, 96, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + default: + break; } } else { - actionDisplay(1330, 37, 159, 10, 1, 200, 0, 7, 0, 154, 154); + actionDisplay(1330, 41, 159, 10, 1, 200, 0, 7, 0, 154, 154); } - } else { - if ((_selectedCard._cardId == 26) || (_selectedCard._cardId == 30) ||(_selectedCard._cardId == 32) || (_selectedCard._cardId == 28)) { - if (_gameBoardSide[2]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { - actionDisplay(1330, 42, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else if (!checkAntiDelayCard(_gameBoardSide[2]._delayCard._cardId, _selectedCard._cardId)) { - if (_gameBoardSide[2]._delayCard._cardId != 0) { - switch (_gameBoardSide[2]._delayCard._cardId) { - case 11: - actionDisplay(1330, 68, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 14: - actionDisplay(1330, 80, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 16: - actionDisplay(1330, 84, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 24: - actionDisplay(1330, 96, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - default: - break; - } - } else { - actionDisplay(1330, 41, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } + } else if ((getStationCardId(_selectedCard._cardId) == -1) && (isDelayCard(_selectedCard._cardId) == -1)) { + if (_selectedCard._cardId == 13) { + if (_gameBoardSide[0]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { + for (int k = 0; k <= 7; k++) { + if (_gameBoardSide[0]._outpostStation[k]._cardId != 0) { + playCounterTrickCard(&_selectedCard, 0); + return; + } + } + actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } else if (_gameBoardSide[3]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { + for (int k = 0; k <= 7; k++) { + if (_gameBoardSide[3]._outpostStation[k]._cardId != 0) { + playCounterTrickCard(&_selectedCard, 3); + return; + } + } + actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } else if (_gameBoardSide[1]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { + for (int k = 0; k <= 7; k++) { + if (_gameBoardSide[1]._outpostStation[k]._cardId == 0) { + playCounterTrickCard(&_selectedCard, 1); + return; } - } else { - playAntiDelayCard(&_selectedCard, &_gameBoardSide[2]._delayCard); - return; } + actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154); } else { - if ((isSlowCard(_selectedCard._cardId) == -1) && (subC27B5(_selectedCard._cardId) == -1)) { - if (_selectedCard._cardId == 13) { - if (_gameBoardSide[0]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { - for (int k = 0; k <= 7; k++) { - if (_gameBoardSide[0]._outpostStation[k]._cardId != 0) { - found = true; - playCounterTrickCard(&_selectedCard, 0); - } - } - - if (!found) - actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else if (_gameBoardSide[3]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { - for (int k = 0; k <= 7; k++) { - if (_gameBoardSide[3]._outpostStation[k]._cardId != 0) { - found = true; - playCounterTrickCard(&_selectedCard, 3); - } - } - if (!found) - actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else if (_gameBoardSide[1]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { - for (int k = 0; k <= 7; k++) { - if (_gameBoardSide[1]._outpostStation[k]._cardId == 0) { - found = true; - playCounterTrickCard(&_selectedCard, 1); - } - } - if (!found) - actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else { - actionDisplay(1330, 128, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } - } else if (_selectedCard._cardId == 25) { + actionDisplay(1330, 128, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } + } else if (_selectedCard._cardId == 25) { + if (_gameBoardSide[0]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { + if ( (_gameBoardSide[0]._handCard[0]._cardId != 0) + || (_gameBoardSide[0]._handCard[1]._cardId != 0) + || (_gameBoardSide[0]._handCard[2]._cardId != 0) + || (_gameBoardSide[0]._handCard[3]._cardId != 0) ) { int k; - if (_gameBoardSide[0]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { - if ( (_gameBoardSide[0]._handCard[0]._cardId != 0) - || (_gameBoardSide[0]._handCard[1]._cardId != 0) - || (_gameBoardSide[0]._handCard[2]._cardId != 0) - || (_gameBoardSide[0]._handCard[3]._cardId != 0) ) { - for (k = 0; k <= 3; k++){ - if (_gameBoardSide[2]._handCard[k]._cardId == 0) - break; - } - playThieftCard(2, &_gameBoardSide[2]._handCard[k], 0); - return; - } else { - actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } - } else if (_gameBoardSide[1]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { - if ( (_gameBoardSide[1]._handCard[0]._cardId != 0) - || (_gameBoardSide[1]._handCard[1]._cardId != 0) - || (_gameBoardSide[1]._handCard[2]._cardId != 0) - || (_gameBoardSide[1]._handCard[3]._cardId != 0) ) { - for (k = 0; k <= 3; k++){ - if (_gameBoardSide[2]._handCard[k]._cardId == 0) - break; - } - playThieftCard(2, &_gameBoardSide[2]._handCard[k], 1); - return; - } else { - actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } - } - - if (_gameBoardSide[3]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { - if ( (_gameBoardSide[3]._handCard[0]._cardId != 0) - || (_gameBoardSide[3]._handCard[1]._cardId != 0) - || (_gameBoardSide[3]._handCard[2]._cardId != 0) - || (_gameBoardSide[3]._handCard[3]._cardId != 0) ) { - for (k = 0; k <= 3; k++){ - if (_gameBoardSide[2]._handCard[k]._cardId == 0) - break; - } - playThieftCard(2, &_gameBoardSide[2]._handCard[k], 3); - return; - } else { - actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } - } else { - actionDisplay(1330, 129, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } - } else if (_selectedCard._cardId == 29) { - actionDisplay(1330, 136, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else if (_selectedCard._cardId == 27) { - actionDisplay(1330, 137, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } - } else { - if (_gameBoardSide[0]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { - if (_gameBoardSide[0]._delayCard._cardId != 0) { - actionDisplay(1330, 15, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else if (!subC32B1(0, _selectedCard._cardId)) { - switch (_selectedCard._cardId) { - case 10: - actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 12: - actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 15: - actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 17: - actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 18: - actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 19: - actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 20: - actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154); + for (k = 0; k <= 3; k++){ + if (_gameBoardSide[2]._handCard[k]._cardId == 0) break; - case 21: - actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - default: - break; - } - } else { - playDelayCard(&_selectedCard, &_gameBoardSide[0]._delayCard); - found = true; } - } else if (_gameBoardSide[3]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { - if (_gameBoardSide[3]._delayCard._cardId != 0) { - actionDisplay(1330, 17, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else if (!subC32B1(3, _selectedCard._cardId)) { - switch (_selectedCard._cardId) { - case 10: - actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 12: - actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 15: - actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 17: - actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 18: - actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 19: - actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 20: - actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 21: - actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - default: + playThieftCard(2, &_gameBoardSide[2]._handCard[k], 0); + return; + } else { + actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } + } else if (_gameBoardSide[1]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { + if ( (_gameBoardSide[1]._handCard[0]._cardId != 0) + || (_gameBoardSide[1]._handCard[1]._cardId != 0) + || (_gameBoardSide[1]._handCard[2]._cardId != 0) + || (_gameBoardSide[1]._handCard[3]._cardId != 0) ) { + int k; + for (k = 0; k <= 3; k++){ + if (_gameBoardSide[2]._handCard[k]._cardId == 0) break; - } - } else { - playDelayCard(&_selectedCard, &_gameBoardSide[3]._delayCard); - found = true; } - } else if (_gameBoardSide[1]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { - if (_gameBoardSide[1]._delayCard._cardId != 0) { - actionDisplay(1330, 19, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } else if (!subC32B1(1, _selectedCard._cardId)) { - switch (_selectedCard._cardId) { - case 10: - actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 12: - actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 15: - actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 17: - actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 18: - actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 19: - actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 20: - actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - case 21: - actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154); - break; - default: + playThieftCard(2, &_gameBoardSide[2]._handCard[k], 1); + return; + } else { + actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } + } + + if (_gameBoardSide[3]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { + if ( (_gameBoardSide[3]._handCard[0]._cardId != 0) + || (_gameBoardSide[3]._handCard[1]._cardId != 0) + || (_gameBoardSide[3]._handCard[2]._cardId != 0) + || (_gameBoardSide[3]._handCard[3]._cardId != 0) ) { + int k; + for (k = 0; k <= 3; k++){ + if (_gameBoardSide[2]._handCard[k]._cardId == 0) break; - } - } else { - playDelayCard(&_selectedCard, &_gameBoardSide[1]._delayCard); - found = true; } - } else { - actionDisplay(1330, 38, 159, 10, 1, 200, 0, 7, 0, 154, 154); - } + playThieftCard(2, &_gameBoardSide[2]._handCard[k], 3); + return; + } else { + actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154); } + } else { + actionDisplay(1330, 129, 159, 10, 1, 200, 0, 7, 0, 154, 154); } + } else if (_selectedCard._cardId == 29) { + // Interceptor cards are used to prevent collision + actionDisplay(1330, 136, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } else if (_selectedCard._cardId == 27) { + actionDisplay(1330, 137, 159, 10, 1, 200, 0, 7, 0, 154, 154); } + } else if (_gameBoardSide[0]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { + if (_gameBoardSide[0]._delayCard._cardId != 0) { + actionDisplay(1330, 15, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } else if (!isAttackPossible(0, _selectedCard._cardId)) { + switch (_selectedCard._cardId) { + case 10: + actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 12: + actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 15: + actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 17: + actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 18: + actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 19: + actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 20: + actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 21: + actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + default: + break; + } + } else { + playDelayCard(&_selectedCard, &_gameBoardSide[0]._delayCard); + return; + } + } else if (_gameBoardSide[3]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { + if (_gameBoardSide[3]._delayCard._cardId != 0) { + actionDisplay(1330, 17, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } else if (!isAttackPossible(3, _selectedCard._cardId)) { + switch (_selectedCard._cardId) { + case 10: + actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 12: + actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 15: + actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 17: + actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 18: + actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 19: + actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 20: + actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 21: + actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + default: + break; + } + } else { + playDelayCard(&_selectedCard, &_gameBoardSide[3]._delayCard); + return; + } + } else if (_gameBoardSide[1]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) { + if (_gameBoardSide[1]._delayCard._cardId != 0) { + actionDisplay(1330, 19, 159, 10, 1, 200, 0, 7, 0, 154, 154); + } else if (!isAttackPossible(1, _selectedCard._cardId)) { + switch (_selectedCard._cardId) { + case 10: + actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 12: + actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 15: + actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 17: + actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 18: + actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 19: + actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 20: + actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + case 21: + actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154); + break; + default: + break; + } + } else { + playDelayCard(&_selectedCard, &_gameBoardSide[1]._delayCard); + return; + } + } else { + actionDisplay(1330, 38, 159, 10, 1, 200, 0, 7, 0, 154, 154); } } - - if (found) - return; } else { g_globals->_scenePalette.signalListeners(); R2_GLOBALS._sceneObjects->draw(); @@ -6940,6 +6685,94 @@ void Scene1337::subD1975(int arg1, int arg2) { warning("STUBBED lvl2 Scene1337::subD1975()"); } +void Scene1337::OptionsDialog::show() { + OptionsDialog *dlg = new OptionsDialog(); + dlg->draw(); + + // Show the dialog + GfxButton *btn = dlg->execute(NULL); + + // Figure out the new selected character + if (btn == &dlg->_quitGame) + R2_GLOBALS._sceneManager.changeScene(125); + else if (btn == &dlg->_restartGame) + R2_GLOBALS._sceneManager.changeScene(1330); + + // Remove the dialog + dlg->remove(); + delete dlg; +} + +Scene1337::OptionsDialog::OptionsDialog() { + // Set the elements text + Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene; + _autoplay.setText(scene->_autoplay ? AUTO_PLAY_ON : AUTO_PLAY_OFF); + _restartGame.setText(START_NEW_CARD_GAME); + _quitGame.setText(QUIT_CARD_GAME); + _continueGame.setText(CONTINUE_CARD_GAME); + + // Set position of the elements + _autoplay._bounds.moveTo(5, 2); + _restartGame._bounds.moveTo(5, _autoplay._bounds.bottom + 2); + _quitGame._bounds.moveTo(5, _restartGame._bounds.bottom + 2); + _continueGame._bounds.moveTo(5, _quitGame._bounds.bottom + 2); + + // Add the items to the dialog + addElements(&_autoplay, &_restartGame, &_quitGame, &_continueGame, NULL); + + // Set the dialog size and position + frame(); + _bounds.collapse(-6, -6); + setCenter(160, 100); +} + +GfxButton *Scene1337::OptionsDialog::execute(GfxButton *defaultButton) { + _gfxManager.activate(); + + // Event loop + GfxButton *selectedButton = NULL; + + bool breakFlag = false; + while (!g_vm->shouldQuit() && !breakFlag) { + Event event; + while (g_globals->_events.getEvent(event) && !breakFlag) { + // Adjust mouse positions to be relative within the dialog + event.mousePos.x -= _gfxManager._bounds.left; + event.mousePos.y -= _gfxManager._bounds.top; + + for (GfxElementList::iterator i = _elements.begin(); i != _elements.end(); ++i) { + if ((*i)->process(event)) + selectedButton = static_cast<GfxButton *>(*i); + } + + if (selectedButton == &_autoplay) { + // Toggle Autoplay + selectedButton = NULL; + Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene; + scene->_autoplay = !scene->_autoplay; + + _autoplay.setText(scene->_autoplay ? AUTO_PLAY_ON : AUTO_PLAY_OFF); + _autoplay.draw(); + } else if (selectedButton) { + breakFlag = true; + break; + } else if (!event.handled) { + if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) { + selectedButton = NULL; + breakFlag = true; + break; + } + } + } + + g_system->delayMillis(10); + GLOBALS._screenSurface.updateScreen(); + } + + _gfxManager.deactivate(); + return selectedButton; +} + /*-------------------------------------------------------------------------- * Scene 1500 - Cutscene: Ship landing * @@ -8839,12 +8672,10 @@ void Scene1550::enterArea() { R2_GLOBALS._sceneManager._hasPalette = false; _wallType = 0; } - } else { - if (_screenNumber == 1234) { - R2_GLOBALS._sceneManager._fadeMode = FADEMODE_IMMEDIATE; - loadScene(1550); - R2_GLOBALS._sceneManager._hasPalette = false; - } + } else if (_screenNumber == 1234) { + R2_GLOBALS._sceneManager._fadeMode = FADEMODE_IMMEDIATE; + loadScene(1550); + R2_GLOBALS._sceneManager._hasPalette = false; } if (_screenNumber == 1234) @@ -10228,7 +10059,7 @@ void Scene1625::signal() { break; } //_field412 = _stripManager._field2E8; - _stripManager._field2E8 = 0; + _stripManager._currObj44Id = 0; break; case 1625: _tealHead.postInit(); @@ -11312,30 +11143,28 @@ bool Scene1800::PassengerDoor::startAction(CursorType action, Event &event) { } } } + } else if (scene->_leftStaircase._frame == 1) { + return SceneActor::startAction(action, event); } else { - if (scene->_leftStaircase._frame == 1) { - return SceneActor::startAction(action, event); + R2_GLOBALS.clearFlag(29); + R2_GLOBALS._player.disableControl(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + if (R2_GLOBALS.getFlag(14)) { + scene->_sceneMode = 2; + scene->setAction(&scene->_sequenceManager, scene, 1809, &scene->_companion, &scene->_doors, NULL); + R2_GLOBALS.clearFlag(14); + } else { + scene->_sceneMode = 1806; + scene->setAction(&scene->_sequenceManager, scene, 1806, &R2_GLOBALS._player, &scene->_companion, &scene->_rightDoor, NULL); + } } else { - R2_GLOBALS.clearFlag(29); - R2_GLOBALS._player.disableControl(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - if (R2_GLOBALS.getFlag(14)) { - scene->_sceneMode = 2; - scene->setAction(&scene->_sequenceManager, scene, 1809, &scene->_companion, &scene->_doors, NULL); - R2_GLOBALS.clearFlag(14); - } else { - scene->_sceneMode = 1806; - scene->setAction(&scene->_sequenceManager, scene, 1806, &R2_GLOBALS._player, &scene->_companion, &scene->_rightDoor, NULL); - } + if (R2_GLOBALS.getFlag(14)) { + scene->_sceneMode = 2; + scene->setAction(&scene->_sequenceManager, scene, 1809, &R2_GLOBALS._player, &scene->_doors, NULL); + R2_GLOBALS.clearFlag(14); } else { - if (R2_GLOBALS.getFlag(14)) { - scene->_sceneMode = 2; - scene->setAction(&scene->_sequenceManager, scene, 1809, &R2_GLOBALS._player, &scene->_doors, NULL); - R2_GLOBALS.clearFlag(14); - } else { - scene->_sceneMode = 1807; - scene->setAction(&scene->_sequenceManager, scene, 1807, &R2_GLOBALS._player, &scene->_companion, &scene->_rightDoor, NULL); - } + scene->_sceneMode = 1807; + scene->setAction(&scene->_sequenceManager, scene, 1807, &R2_GLOBALS._player, &scene->_companion, &scene->_rightDoor, NULL); } } } @@ -11492,14 +11321,12 @@ void Scene1800::postInit(SceneObjectList *OwnerList) { R2_GLOBALS._walkRegions.disableRegion(10); R2_GLOBALS._walkRegions.disableRegion(11); } + } else if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + R2_GLOBALS._player.setPosition(Common::Point(140, 160)); + _companion.setPosition(Common::Point(180, 160)); } else { - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - R2_GLOBALS._player.setPosition(Common::Point(140, 160)); - _companion.setPosition(Common::Point(180, 160)); - } else { - R2_GLOBALS._player.setPosition(Common::Point(180, 160)); - _companion.setPosition(Common::Point(140, 160)); - } + R2_GLOBALS._player.setPosition(Common::Point(180, 160)); + _companion.setPosition(Common::Point(140, 160)); } _playerShadow.postInit(); @@ -11554,23 +11381,19 @@ void Scene1800::postInit(SceneObjectList *OwnerList) { _sceneMode = 1815; setAction(&_sequenceManager, this, 1815, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); } + } else if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + _sceneMode = 1816; + setAction(&_sequenceManager, this, 1816, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); } else { - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _sceneMode = 1816; - setAction(&_sequenceManager, this, 1816, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); - } else { - _sceneMode = 1817; - setAction(&_sequenceManager, this, 1817, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); - } + _sceneMode = 1817; + setAction(&_sequenceManager, this, 1817, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); } + } else if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + _sceneMode = 1800; + setAction(&_sequenceManager, this, 1800, &R2_GLOBALS._player, &_companion, NULL); } else { - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _sceneMode = 1800; - setAction(&_sequenceManager, this, 1800, &R2_GLOBALS._player, &_companion, NULL); - } else { - _sceneMode = 1801; - setAction(&_sequenceManager, this, 1801, &R2_GLOBALS._player, &_companion, NULL); - } + _sceneMode = 1801; + setAction(&_sequenceManager, this, 1801, &R2_GLOBALS._player, &_companion, NULL); } R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1800; @@ -11617,7 +11440,7 @@ void Scene1800::signal() { _sceneMode = 14; R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); R2_GLOBALS._player.setup(1801, 7, 1); - R2_GLOBALS._player.animate(ANIM_MODE_8, NULL); + R2_GLOBALS._player.animate(ANIM_MODE_8, 0, NULL); _stripManager.start(550, this); break; case 14: @@ -11637,7 +11460,7 @@ void Scene1800::signal() { _sceneMode = 24; R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); R2_GLOBALS._player.setup(1801, 5, 1); - R2_GLOBALS._player.animate(ANIM_MODE_8, NULL); + R2_GLOBALS._player.animate(ANIM_MODE_8, 0, NULL); _stripManager.start(550, this); break; case 24: @@ -12056,28 +11879,14 @@ void Scene1850::postInit(SceneObjectList *OwnerList) { _screen.setPosition(Common::Point(122, 113)); _screen.fixPriority(114); _screen._effect = EFFECT_SHADED2; - - // Totally useless test - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _screen.setDetails(1850, 28, -1, -1, 2, (SceneItem *) NULL); - } else { - // And the associated dead code - _screen.setDetails(1850, 30, -1, -1, 2, (SceneItem *) NULL); - } + _screen.setDetails(1850, 28, -1, -1, 2, (SceneItem *) NULL); _helmet.postInit(); _helmet.setup(1853, 3, 2); _helmet.setPosition(Common::Point(139, 111)); _helmet.fixPriority(114); _helmet._effect = EFFECT_SHADED2; - - // Still totally useless test - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _helmet.setDetails(1850, 29, -1, -1, 2, (SceneItem *) NULL); - } else { - // Another piece of dead code - _helmet.setDetails(1850, 28, -1, -1, 2, (SceneItem *) NULL); - } + _helmet.setDetails(1850, 29, -1, -1, 2, (SceneItem *) NULL); if (R2_GLOBALS.getFlag(31)) { _screen._shade = 0; @@ -12090,50 +11899,36 @@ void Scene1850::postInit(SceneObjectList *OwnerList) { R2_GLOBALS._player.setVisage(1500); _companion.setVisage(1505); } - } else { // Not Quinn - if (R2_GLOBALS.getFlag(32)) { - R2_GLOBALS._player.setVisage(1508); - _companion.setVisage(1511); - - _screen.postInit(); - _screen.setup(1853, 3, 1); - _screen.setPosition(Common::Point(122, 113)); - _screen.fixPriority(114); - _screen._effect = EFFECT_SHADED2; - - // Totally useless test - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - // Dead code - _screen.setDetails(1850, 28, -1, -1, 2, (SceneItem *) NULL); - } else { - _screen.setDetails(1850, 30, -1, -1, 2, (SceneItem *) NULL); - } - - _helmet.postInit(); - _helmet.setup(1853, 3, 2); - _helmet.setPosition(Common::Point(139, 111)); - _helmet.fixPriority(114); - _helmet._effect = EFFECT_SHADED2; - - // Again, useless test - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - // and dead code - _helmet.setDetails(1850, 29, -1, -1, 1, (SceneItem *) NULL); - } else { - _helmet.setDetails(1850, 28, -1, -1, 1, (SceneItem *) NULL); - } - - if (R2_GLOBALS.getFlag(31)) { - _screen._shade = 0; - _helmet._shade = 0; - } else { - _screen._shade = 6; - _helmet._shade = 6; - } + } else if (R2_GLOBALS.getFlag(32)) { + // Not Quinn, flag 32 + R2_GLOBALS._player.setVisage(1508); + _companion.setVisage(1511); + + _screen.postInit(); + _screen.setup(1853, 3, 1); + _screen.setPosition(Common::Point(122, 113)); + _screen.fixPriority(114); + _screen._effect = EFFECT_SHADED2; + _screen.setDetails(1850, 30, -1, -1, 2, (SceneItem *) NULL); + + _helmet.postInit(); + _helmet.setup(1853, 3, 2); + _helmet.setPosition(Common::Point(139, 111)); + _helmet.fixPriority(114); + _helmet._effect = EFFECT_SHADED2; + _helmet.setDetails(1850, 28, -1, -1, 1, (SceneItem *) NULL); + + if (R2_GLOBALS.getFlag(31)) { + _screen._shade = 0; + _helmet._shade = 0; } else { - R2_GLOBALS._player.setVisage(1505); - _companion.setVisage(1500); + _screen._shade = 6; + _helmet._shade = 6; } + } else { + // Not Quinn, nor flag 32 + R2_GLOBALS._player.setVisage(1505); + _companion.setVisage(1500); } R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); @@ -15309,7 +15104,7 @@ void Scene1950::signal() { R2_GLOBALS._player.disableControl(CURSOR_WALK); R2_GLOBALS._player._canWalk = true; R2_GLOBALS._player.setVisage(22); - R2_GLOBALS._player.animate(ANIM_MODE_9, NULL); + R2_GLOBALS._player.animate(ANIM_MODE_9); Common::Point pt(340, 160); NpcMover *mover = new NpcMover(); R2_GLOBALS._player.addMover(mover, &pt, this); @@ -15325,7 +15120,7 @@ void Scene1950::signal() { R2_GLOBALS._player.disableControl(CURSOR_WALK); R2_GLOBALS._player._canWalk = true; R2_GLOBALS._player.setVisage(22); - R2_GLOBALS._player.animate(ANIM_MODE_9, NULL); + R2_GLOBALS._player.animate(ANIM_MODE_9); Common::Point pt(-20, 160); NpcMover *mover = new NpcMover(); R2_GLOBALS._player.addMover(mover, &pt, this); diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.h b/engines/tsage/ringworld2/ringworld2_scenes1.h index 6cbc617578..c809353051 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.h +++ b/engines/tsage/ringworld2/ringworld2_scenes1.h @@ -183,6 +183,20 @@ public: }; class Scene1337 : public SceneExt { + class OptionsDialog: public GfxDialog { + private: + GfxButton _autoplay; + GfxButton _restartGame; + GfxButton _quitGame; + GfxButton _continueGame; + + OptionsDialog(); + virtual ~OptionsDialog() {} + virtual GfxButton *execute(GfxButton *defaultButton); + public: + static void show(); + }; + class Card: public SceneHotspot { public: SceneObject _card; @@ -270,16 +284,6 @@ class Scene1337 : public SceneExt { void signal(); }; public: - typedef void (Scene1337::*FunctionPtrType)(); - FunctionPtrType _delayedFunction; - - ASound _aSound1; - ASound _aSound2; - SceneActor _helpIcon; - bool _autoplay; - GameBoardSide _gameBoardSide[4]; - SceneItem _item1; - SceneObject _currentPlayerArrow; Action1 _action1; Action2 _action2; Action3 _action3; @@ -293,35 +297,47 @@ public: Action11 _action11; Action12 _action12; Action13 _action13; - Card _animatedCard; - Card _shuffleAnimation; - Card _item4; - SceneActor _stockPile; - int _cardsAvailableNumb; + + typedef void (Scene1337::*FunctionPtrType)(); + FunctionPtrType _delayedFunction; + + bool _autoplay; + bool _shuffleEndedFl; + bool _showPlayerTurn; + bool _displayHelpFl; + bool _instructionsDisplayedFl; // Discarded cards are put in the available cards pile, with an higher index so there no conflict int _currentDiscardIndex; int _availableCardsPile[100]; - Card *_actionCard1; - Card *_actionCard2; - Card *_actionCard3; - Card _item5; - Card _selectedCard; - Card _discardPile; - Card _stockCard; - bool _shuffleEndedFl; + int _cardsAvailableNumb; int _currentPlayerNumb; int _actionIdx1; int _actionIdx2; - bool _showPlayerTurn; - bool _displayHelpFl; int _winnerId; - bool _instructionsDisplayedFl; int _instructionsWaitCount; int _cursorCurRes; int _cursorCurStrip; int _cursorCurFrame; + ASound _aSound1; + ASound _aSound2; + GameBoardSide _gameBoardSide[4]; + SceneActor _helpIcon; + SceneActor _stockPile; + SceneItem _actionItem; + SceneObject _currentPlayerArrow; + + Card *_actionCard1; + Card *_actionCard2; + Card *_actionCard3; + Card _animatedCard; + Card _shuffleAnimation; + Card _discardedPlatformCard; + Card _selectedCard; + Card _discardPile; + Card _stockCard; + SceneObject _upperDisplayCard[8]; SceneObject _lowerDisplayCard[8]; @@ -330,28 +346,27 @@ public: void actionDisplay(int resNum, int lineNum, int x, int y, int keepOnScreen, int width, int textMode, int fontNum, int colFG, int colBGExt, int colFGExt); void setAnimationInfo(Card *card); - void subC20E5(); void handleNextTurn(); - void subC2586(); - bool subC264B(int cardId); - bool subC2687(int cardId); - int subC26CB(int playerId, int handCardId); - int findNormalCardInHand(int playerId); - int subC274D(int arg1); - int subC2781(int arg1); - int subC27B5(int arg1); - int isSlowCard(int cardId); - void subC2835(int arg1); + void handlePlayerTurn(); + bool isStationCard(int cardId); + bool isStopConstructionCard(int cardId); + int getStationId(int playerId, int handCardId); + int findPlatformCardInHand(int playerId); + int findCard13InHand(int playerId); + int checkThieftCard(int playerId); + int isDelayCard(int cardId); + int getStationCardId(int cardId); + void handlePlayer01Discard(int playerId); void playThieftCard(int playerId, Card *card, int victimId); - int subC3257(int arg1); - bool subC32B1(int arg1, int arg2); - int subC331B(int arg1); + int getPreventionCardId(int cardId); + bool isAttackPossible(int victimId, int cardId); + int getPlayerWithOutpost(int playerId); bool checkAntiDelayCard(int delayCardId, int cardId); - void subC33C0(Card *subObj1, Card *subObj2); + void playStationCard(Card *station, Card *platform); void playDelayCard(Card *card, Card *dest); - void playCard(Card *card, Card *dest); + void playPlatformCard(Card *card, Card *dest); void playAntiDelayCard(Card *card, Card *dest); - Card *subC34EC(int arg1); + Card *getStationCard(int arg1); void playCounterTrickCard(Card *card, int playerId); int getFreeHandCard(int playerId); void discardCard(Card *card); @@ -364,13 +379,13 @@ public: void suggestInstructions(); void shuffleCards(); void dealCards(); - void subCD193(); + void showOptionsDialog(); void handleClick(int arg1, Common::Point pt); void handlePlayer0(); void handlePlayer1(); void handlePlayer2(); void handlePlayer3(); - void subD02CA(); + void handleAutoplayPlayer2(); void updateCursorId(int arg1, bool arg2); void setCursorData(int resNum, int rlbNum, int frameNum); void subD18F5(); diff --git a/engines/tsage/ringworld2/ringworld2_scenes3.cpp b/engines/tsage/ringworld2/ringworld2_scenes3.cpp index 732add03ec..5b41a85326 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes3.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes3.cpp @@ -2969,18 +2969,20 @@ void Scene3400::signal() { Scene3500::Action1::Action1() { _direction = 0; - _field20 = false; - _field22 = 0; - _field24 = false; + _headingRightFl = false; + _turningFl = false; } void Scene3500::Action1::synchronize(Serializer &s) { Action::synchronize(s); s.syncAsSint16LE(_direction); - s.syncAsSint16LE(_field20); - s.syncAsSint16LE(_field22); - s.syncAsSint16LE(_field24); + s.syncAsSint16LE(_headingRightFl); + if (s.getVersion() < 13) { + int useless = 0; + s.syncAsSint32LE(useless); + } + s.syncAsSint16LE(_turningFl); } void Scene3500::Action1::handleHorzButton(int direction) { @@ -2988,8 +2990,8 @@ void Scene3500::Action1::handleHorzButton(int direction) { // Direction: -1 == Left, 1 == Right _direction = direction; - _field20 = true; - _field24 = true; + _headingRightFl = true; + _turningFl = true; scene->_tunnelHorzCircle.setStrip(2); scene->_tunnelHorzCircle.show(); @@ -3010,7 +3012,7 @@ void Scene3500::Action1::handleHorzButton(int direction) { void Scene3500::Action1::turnShuttle(bool arg1) { Scene3500 *scene = (Scene3500 *)R2_GLOBALS._sceneManager._scene; - _field20 = arg1; + _headingRightFl = arg1; _direction = -_direction; if (_direction == 1) { @@ -3068,7 +3070,7 @@ void Scene3500::Action1::signal() { if (scene->_speed != 0) { scene->_speed = 0; scene->_mazeChangeAmount = 0; - scene->_field1272 = false; + scene->_updateIdxChangeFl = false; scene->_rotation->_idxChange = 0; } break; @@ -3109,49 +3111,49 @@ void Scene3500::Action1::signal() { if ( ((cellId != 2) && (cellId != 3) && (cellId != 6) && (cellId != 1) && (cellId != 23) && (cellId != 24) && (cellId != 4) && (cellId != 11)) || (var6 != 0)) { if ((cellId != 25) && (cellId != 26) && (cellId != 5) && (cellId != 14) && (cellId != 15)) - _field20 = false; + _headingRightFl = false; else if ((var6 != 0) || (di <= 3)) // useless, skipped: "|| (di == 0)" - _field20 = false; + _headingRightFl = false; else - _field20 = true; + _headingRightFl = true; } else - _field20 = true; + _headingRightFl = true; break; case MAZEDIR_EAST: if ( ((cellId != 12) && (cellId != 13) && (cellId != 11) && (cellId != 16) && (cellId != 26) && (cellId != 24) && (cellId != 15) && (cellId != 6) && (cellId != 31)) || (di != 0)) { if ((cellId != 25) && (cellId != 23) && (cellId != 14) && (cellId != 5) && (cellId != 4)) - _field20 = false; + _headingRightFl = false; else if ((di != 0) || (var6 <= 3)) // useless, skipped: "|| (var6 == 0)" - _field20 = false; + _headingRightFl = false; else - _field20 = true; + _headingRightFl = true; } else - _field20 = true; + _headingRightFl = true; break; case MAZEDIR_SOUTH: if ( ((cellId != 2) && (cellId != 3) && (cellId != 6) && (cellId != 1) && (cellId != 25) && (cellId != 26) && (cellId != 5) && (cellId != 16) && (cellId != 31)) || (var6 != 0)) { if ((cellId != 23) && (cellId != 24) && (cellId != 4) && (cellId != 14) && (cellId != 15)) - _field20 = false; + _headingRightFl = false; else if ((var6 != 0) || (di <= 3)) // useless, skipped: "|| (di == 0)" - _field20 = false; + _headingRightFl = false; else - _field20 = true; + _headingRightFl = true; } else - _field20 = true; + _headingRightFl = true; break; case MAZEDIR_WEST: if ( ((cellId != 12) && (cellId != 13) && (cellId != 11) && (cellId != 16) && (cellId != 25) && (cellId != 23) && (cellId != 14) && (cellId != 1) && (cellId != 31)) || (var6 != 0)) { if ((cellId != 26) && (cellId != 24) && (cellId != 15) && (cellId != 5) && (cellId != 4)) - _field20 = false; + _headingRightFl = false; else if ((var6 <= 0) || (di != 0)) // useless, skipped: "|| (var6 == 0)" - _field20 = false; + _headingRightFl = false; else - _field20 = true; + _headingRightFl = true; } else - _field20 = true; + _headingRightFl = true; default: break; } @@ -3181,7 +3183,7 @@ void Scene3500::Action1::signal() { break; case 6: scene->_tunnelVertCircle.setPosition(Common::Point(160, 73)); - if (!_field20) + if (!_headingRightFl) scene->_tunnelVertCircle.setStrip(1); else scene->_tunnelVertCircle.setStrip(2); @@ -3235,8 +3237,8 @@ void Scene3500::Action1::signal() { } scene->_symbolLeft.hide(); scene->_symbolRight.hide(); - _field24 = false; - if (!_field20) { + _turningFl = false; + if (!_headingRightFl) { scene->_throttle.updateSpeed(); if (scene->_mazeChangeAmount == scene->_speed) scene->_aSound1.play(276); @@ -3264,7 +3266,7 @@ void Scene3500::Action1::signal() { NpcMover *mover = new NpcMover(); scene->_tunnelVertCircle.addMover(mover, &pt, NULL); scene->_tunnelVertCircle.fixPriority(11); - if (!_field20) + if (!_headingRightFl) scene->_tunnelHorzCircle.setStrip(1); else scene->_tunnelHorzCircle.setStrip(2); @@ -3465,7 +3467,7 @@ void Scene3500::Throttle::process(Event &event) { if ((event.eventType == EVENT_BUTTON_UP) && (_deltaMouseY != 0)) { _deltaMouseY = 0; event.handled = true; - if (!scene->_action1._field24) + if (!scene->_action1._turningFl) updateSpeed(); } @@ -3500,11 +3502,11 @@ bool Scene3500::Throttle::startAction(CursorType action, Event &event) { /*--------------------------------------------------------------------------*/ -int Scene3500::MazeUI3500::cellFromX(int x) { +int16 Scene3500::MazeUI3500::cellFromX(int x) { return (_cellSize.x / 2) + x - (x % _cellSize.x); } -int Scene3500::MazeUI3500::cellFromY(int y) { +int16 Scene3500::MazeUI3500::cellFromY(int y) { return (_cellSize.y / 2) + y - (y % _cellSize.y) - 1; } @@ -3533,13 +3535,13 @@ Scene3500::Scene3500() { _rotation = NULL; _mazeChangeAmount = 0; _speed = 0; - _field1272 = false; + _updateIdxChangeFl = false; _mazeDirection = MAZEDIR_NONE; _nextMove = 0; _mazePosition.x = 0; _mazePosition.y = 0; - _field1282 = true; // Set to true in fixup() - _field1284 = 0; + _postFixupFl = true; // Set to true in fixup() + _exitCounter = 0; _directionChangesEnabled = false; } @@ -3551,13 +3553,13 @@ void Scene3500::synchronize(Serializer &s) { s.syncAsSint16LE(_moverHorzX); s.syncAsSint16LE(_mazeChangeAmount); s.syncAsSint16LE(_speed); - s.syncAsSint16LE(_field1272); + s.syncAsSint16LE(_updateIdxChangeFl); s.syncAsSint16LE(_mazeDirection); s.syncAsSint16LE(_nextMove); s.syncAsSint16LE(_mazePosition.x); s.syncAsSint16LE(_mazePosition.y); - s.syncAsSint16LE(_field1282); - s.syncAsSint16LE(_field1284); + s.syncAsSint16LE(_postFixupFl); + s.syncAsSint16LE(_exitCounter); s.syncAsSint16LE(_directionChangesEnabled); } @@ -3573,10 +3575,10 @@ void Scene3500::postInit(SceneObjectList *OwnerList) { R2_GLOBALS._player._characterScene[R2_QUINN] = 3500; R2_GLOBALS._player._characterScene[R2_SEEKER] = 3500; R2_GLOBALS._player._characterScene[R2_MIRANDA] = 3500; - _field1284 = 0; - _field1282 = false; + _exitCounter = 0; + _postFixupFl = false; _nextMove = 0; - _field1272 = true; + _updateIdxChangeFl = true; _speed = 4; _mazeChangeAmount = 4; _mazePosition = Common::Point(860, 891); @@ -3670,7 +3672,7 @@ void Scene3500::postInit(SceneObjectList *OwnerList) { _mazeUI.load(2); _mazeUI.setMazePosition(_mazePosition); - _action1._field24 = false; + _action1._turningFl = false; _mazeUI.draw(); _directionChangesEnabled = true; @@ -3689,7 +3691,7 @@ void Scene3500::doMovement(int id) { _speed--; _throttle.setSpeed(_speed); } - if (_action1._field24) + if (_action1._turningFl) _speed = 0; break; case 1: @@ -3698,13 +3700,13 @@ void Scene3500::doMovement(int id) { ++_speed; _throttle.setSpeed(_speed); } - if (_action1._field24) + if (_action1._turningFl) _speed = 0; break; case 88: // Up button has been pressed // The original was doing a double check on action, only one is here. - if (!_action || (!_action1._field24)) { + if (!_action || (!_action1._turningFl)) { _action2.handleVertButton(2); if (_action && ((_action2.getActionIndex() != 0) || (_action2._direction != 2))) { _action2.signal(); @@ -3715,10 +3717,10 @@ void Scene3500::doMovement(int id) { break; case 96: // Right button has been pressed - if (!_action || !_action1._field24 || (_action1._direction == 1)) { - if (_action && (_nextMove == 0) && (_action1._field24)) { + if (!_action || !_action1._turningFl || (_action1._direction == 1)) { + if (_action && (_nextMove == 0) && (_action1._turningFl)) { _nextMove = id; - } else if (_action && (!_action1._field24)) { + } else if (_action && (!_action1._turningFl)) { _action1.handleHorzButton(1); _action1.signal(); } else if (!_action) { @@ -3735,7 +3737,7 @@ void Scene3500::doMovement(int id) { break; case 104: // Down button has been pressed - if (!_action || (!_action1._field24)) { + if (!_action || (!_action1._turningFl)) { _action2.handleVertButton(-1); if ((_action) && ((_action2.getActionIndex() != 0) || (_action2._direction != -1))) { _action2.signal(); @@ -3746,10 +3748,10 @@ void Scene3500::doMovement(int id) { break; case 112: // Left button has been pressed - if (!_action || !_action1._field24 || (_action1._direction == 1)) { - if (_action && (_nextMove == 0) && (_action1._field24)) { + if (!_action || !_action1._turningFl || (_action1._direction == 1)) { + if (_action && (_nextMove == 0) && (_action1._turningFl)) { _nextMove = id; - } else if (_action && (!_action1._field24)) { + } else if (_action && (!_action1._turningFl)) { _action1.handleHorzButton(-1); _action1.signal(); } else if (!_action) { @@ -3767,7 +3769,7 @@ void Scene3500::doMovement(int id) { default: _speed = id; _throttle.setSpeed(id); - if (_action1._field24) { + if (_action1._turningFl) { _speed = 0; } break; @@ -3874,12 +3876,12 @@ void Scene3500::dispatch() { Rect tmpRect; Scene::dispatch(); - if (((_shuttle._frame % 2) == 0) && (!_action1._field24)) { + if (((_shuttle._frame % 2) == 0) && (!_action1._turningFl)) { _shuttle.setFrame(_shuttle.changeFrame()); _mazeDirection = _shuttle._frame; } - if ((_nextMove != 0) && (!_action1._field24)) { + if ((_nextMove != 0) && (!_action1._turningFl)) { int move = _nextMove; _nextMove = 0; doMovement(move); @@ -3888,20 +3890,20 @@ void Scene3500::dispatch() { if (!_rotation) return; - int newMazeX = 0; - int newMazeY = 0; - int mazePosX = 0; - int mazePosY = 0; + int16 newMazeX = 0; + int16 newMazeY = 0; + int16 mazePosX = 0; + int16 mazePosY = 0; int deltaX = 0; int deltaY = 0; int tmpCellId = 0; int cellId = 0; - if ((_mazeChangeAmount == 0) && !_field1282) { - if (_field1284 == 2) + if ((_mazeChangeAmount == 0) && !_postFixupFl) { + if (_exitCounter == 2) R2_GLOBALS._sceneManager.changeScene(1000); } else { - _field1282 = false; + _postFixupFl = false; tmpRect.set(160, 89, 299, 182); newMazeX = _mazePosition.x; @@ -3921,8 +3923,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else { mazePosY = _mazeUI.cellFromY(newMazeY + 46) - 46; @@ -3934,8 +3936,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if ((cellId == 11) && (cellId != tmpCellId)) { newMazeY = mazePosY + 3; @@ -3943,8 +3945,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else { mazePosY = _mazeUI.cellFromY(newMazeY + 46) - 46; @@ -3952,23 +3954,23 @@ void Scene3500::dispatch() { cellId = _mazeUI.getCellFromMapXY(Common::Point(newMazeX + 70, newMazeY + 46)); if ( (((cellId == 23) || (cellId == 24) || (cellId == 4)) && (newMazeY <= mazePosY) && (_mazePosition.y>= mazePosY)) - || (((cellId == 25) || (cellId == 26) || (cellId == 5) || (cellId == 14) || (cellId == 15)) && (_mazeChangeAmount >= deltaY) && (_mazeChangeAmount > 3) && (_action1._field24 != 0)) ) { + || (((cellId == 25) || (cellId == 26) || (cellId == 5) || (cellId == 14) || (cellId == 15)) && (_mazeChangeAmount >= deltaY) && (_mazeChangeAmount > 3) && (_action1._turningFl != 0)) ) { newMazeY = mazePosY; if ((cellId != 25) && (cellId != 26) && (cellId != 5) && (cellId != 14) && (cellId == 15)) R2_GLOBALS._sound2.play(339); _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if ((cellId == 11) && (mazePosY + 3 >= newMazeY) && (_mazePosition.y >= mazePosY + 3)) { R2_GLOBALS._sound2.play(339); _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if (((cellId == 25) || (cellId == 26) || (cellId == 5) || (cellId == 14) || (cellId == 15)) && (deltaX != 0) && (deltaX <= 3)) { newMazeX = mazePosX; @@ -3987,8 +3989,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else { mazePosX = _mazeUI.cellFromX(newMazeX + 70) - 70; @@ -4000,8 +4002,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if ((cellId == 6) && (cellId != tmpCellId)) { newMazeX = mazePosX - 5; @@ -4009,23 +4011,23 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else { mazePosX = _mazeUI.cellFromX(newMazeX + 70) - 70; deltaX = abs(newMazeX - mazePosX); cellId = _mazeUI.getCellFromMapXY(Common::Point(newMazeX + 70, newMazeY + 46)); if ( (((cellId == 26) || (cellId == 24) || (cellId == 15)) && (newMazeX >= mazePosX) && (_mazePosition.x <= mazePosX)) - || (((cellId == 25) || (cellId == 23) || (cellId == 14) || (cellId == 5) || (cellId == 4)) && (_mazeChangeAmount >= deltaX) && (_mazeChangeAmount <= 3) && (_action1._field24 != 0)) ) { + || (((cellId == 25) || (cellId == 23) || (cellId == 14) || (cellId == 5) || (cellId == 4)) && (_mazeChangeAmount >= deltaX) && (_mazeChangeAmount <= 3) && (_action1._turningFl != 0)) ) { newMazeX = mazePosX; if ((cellId == 25) || (cellId == 23) || (cellId == 14) || (cellId == 5) || (cellId == 4)) R2_GLOBALS._sound2.play(339); _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if ((cellId == 6) && (mazePosX - 5 <= newMazeX) && (_mazePosition.x <= mazePosX - 5)) { newMazeX = mazePosX - 5; @@ -4033,8 +4035,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if (((cellId == 25) || (cellId == 23) || (cellId == 14) || (cellId == 5) || (cellId == 4)) && (deltaY != 0) && (deltaY <= 3)) { newMazeY = mazePosY; @@ -4053,8 +4055,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else { mazePosY = _mazeUI.cellFromY(newMazeY + 46) - 46; @@ -4066,8 +4068,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if ((cellId == 16) && (cellId != tmpCellId)) { newMazeY = mazePosY - 3; @@ -4075,8 +4077,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if ((cellId == 31) && (cellId != tmpCellId)) { newMazeY = mazePosY + 4; @@ -4084,15 +4086,15 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else { mazePosY = _mazeUI.cellFromY(newMazeY + 46) - 46; deltaY = abs(newMazeY - mazePosY); cellId = _mazeUI.getCellFromMapXY(Common::Point(newMazeX + 70, newMazeY + 46)); if ( (((cellId == 25) || (cellId == 26) || (cellId == 5)) && (newMazeY >= mazePosY) && (_mazePosition.y <= mazePosY)) - || (((cellId == 23) || (cellId == 24) || (cellId == 4) || (cellId == 14) || (cellId == 15)) && (_mazeChangeAmount >= deltaY) && (_mazeChangeAmount <= 3) && (_action1._field24 != 0)) ){ + || (((cellId == 23) || (cellId == 24) || (cellId == 4) || (cellId == 14) || (cellId == 15)) && (_mazeChangeAmount >= deltaY) && (_mazeChangeAmount <= 3) && (_action1._turningFl != 0)) ){ newMazeY = mazePosY; if ((cellId != 23) && (cellId != 24) && (cellId != 4) && (cellId != 14) && (cellId != 15)) @@ -4100,8 +4102,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if ((cellId == 16) && (mazePosY - 3 <= newMazeY) && (_mazePosition.y <= mazePosY - 3)) { newMazeY = mazePosY - 3; @@ -4109,19 +4111,19 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if ((cellId == 31) && (mazePosY + 4 <= newMazeY) && (_mazePosition.y <= mazePosY + 4)) { newMazeY = mazePosY + 4; _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); if ((newMazeX == 660) && (_mazeChangeAmount + 306 <= newMazeY) && (newMazeY <= 307)) - ++_field1284; + ++_exitCounter; else R2_GLOBALS._sound2.play(339); } else if (((cellId == 23) || (cellId == 24) || (cellId == 4) || (cellId == 14) || (cellId == 15)) && (deltaX != 0) && (deltaX <= 3)) { @@ -4141,8 +4143,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else { mazePosX = _mazeUI.cellFromX(newMazeX + 70) - 70; @@ -4154,8 +4156,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if ((cellId == 1) && (cellId != tmpCellId)) { newMazeX = mazePosX + 5; @@ -4163,23 +4165,23 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else { mazePosX = _mazeUI.cellFromX(newMazeX + 70) - 70; deltaX = abs(mazePosX - newMazeX); cellId = _mazeUI.getCellFromMapXY(Common::Point(newMazeX + 70, newMazeY + 46)); if ( (((cellId == 25) || (cellId == 23) || (cellId == 14)) && (newMazeX <= mazePosX) && (_mazePosition.x >= mazePosX)) - || (((cellId == 26) || (cellId == 24) || (cellId == 15) || (cellId == 5) || (cellId == 4)) && (_mazeChangeAmount >= deltaX) && (_mazeChangeAmount <= 3) && (_action1._field24)) ) { + || (((cellId == 26) || (cellId == 24) || (cellId == 15) || (cellId == 5) || (cellId == 4)) && (_mazeChangeAmount >= deltaX) && (_mazeChangeAmount <= 3) && (_action1._turningFl)) ) { newMazeX = mazePosX; if ((cellId == 26) || (cellId == 24) || (cellId == 15) || (cellId == 5) || (cellId == 4)) R2_GLOBALS._sound2.play(339); _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if ((cellId == 1) && (newMazeX >= mazePosX + 5) && (_mazePosition.x >= mazePosX + 5)) { newMazeX = mazePosX + 5; @@ -4187,8 +4189,8 @@ void Scene3500::dispatch() { _rotation->_idxChange = 0; _speed = 0; _mazeChangeAmount = 0; - _field1272 = false; - if (!_action1._field24) + _updateIdxChangeFl = false; + if (!_action1._turningFl) _tunnelVertCircle.hide(); } else if (((cellId == 26) || (cellId == 24) || (cellId == 15) || (cellId == 5) || (cellId == 4)) && (deltaY != 0) && (deltaY <= 3)) { newMazeY = mazePosY; @@ -4203,11 +4205,11 @@ void Scene3500::dispatch() { break; } - if (_field1284 < 2) { + if (_exitCounter < 2) { _mazePosition.x = newMazeX; _mazePosition.y = newMazeY; if (_mazeUI.setMazePosition2(_mazePosition) != 0) { - _field1272 = false; + _updateIdxChangeFl = false; _mazeChangeAmount = 0; _speed = 0; _rotation->setDelay(0); @@ -4215,16 +4217,16 @@ void Scene3500::dispatch() { } _mazeUI.draw(); - if (_field1284 != 0) - ++_field1284; + if (_exitCounter != 0) + ++_exitCounter; } } - if (!_field1272) { + if (!_updateIdxChangeFl) { if (_mazeChangeAmount != _speed) { if (_mazeChangeAmount >= _speed) { if (_mazeChangeAmount == 1) { - if (_action1._field24) { + if (_action1._turningFl) { if ( ((_mazeDirection == 1) && (deltaX == 0) && (deltaY != 0) && (deltaY <= 3) && ((cellId == 25) || (cellId == 26) || (cellId == 5) || (cellId == 14) || (cellId == 15))) || ((_mazeDirection == 3) && (deltaY == 0) && (deltaX != 0) && (deltaX <= 3) && ((cellId == 25) || (cellId == 23) || (cellId == 14) || (cellId == 5) || (cellId == 4))) || ((_mazeDirection == 5) && (deltaX == 0) && (deltaY != 0) && (deltaY <= 3) && ((cellId == 23) || (cellId == 24) || (cellId == 4) || (cellId == 14) || (cellId == 15))) @@ -4238,12 +4240,12 @@ void Scene3500::dispatch() { _mazeChangeAmount--; } else ++_mazeChangeAmount; - _field1272 = true; + _updateIdxChangeFl = true; } _verticalSpeedDisplay.setFrame2(_mazeChangeAmount + 1); } - if (_field1272) { + if (_updateIdxChangeFl) { if (_mazeChangeAmount == 0) _rotation->_idxChange = 0; else if (_mazeChangeAmount > 8) @@ -4251,7 +4253,7 @@ void Scene3500::dispatch() { else _rotation->_idxChange = 1; - _field1272 = false; + _updateIdxChangeFl = false; } if (_mazeChangeAmount != 0) { @@ -4283,14 +4285,14 @@ void Scene3600::synchronize(Serializer &s) { } Scene3600::Action3600::Action3600() { - _field1E = false; + _part2Fl = false; _fadePct = 0; } void Scene3600::Action3600::synchronize(Serializer &s) { Action::synchronize(s); - s.syncAsSint16LE(_field1E); + s.syncAsSint16LE(_part2Fl); s.syncAsSint16LE(_fadePct); } @@ -4303,8 +4305,8 @@ void Scene3600::Action3600::signal() { setDelay(60); break; case 1: - if (!_field1E) { - _field1E = true; + if (!_part2Fl) { + _part2Fl = true; scene->_steppingDisk.setAction(NULL); R2_GLOBALS._sound2.play(330, NULL, 0); R2_GLOBALS._sound2.fade(127, 5, 10, false, NULL); @@ -4358,7 +4360,7 @@ void Scene3600::Action2::signal() { bool Scene3600::LightShaft::startAction(CursorType action, Event &event) { Scene3600 *scene = (Scene3600 *)R2_GLOBALS._sceneManager._scene; - if ((action != CURSOR_USE) || !scene->_action1._field1E) + if ((action != CURSOR_USE) || !scene->_action1._part2Fl) return SceneItem::startAction(action, event); R2_GLOBALS._walkRegions.enableRegion(2); @@ -4579,7 +4581,7 @@ void Scene3600::postInit(SceneObjectList *OwnerList) { _consoleLights.setup(3601, 5, 1); _consoleLights.animate(ANIM_MODE_2, NULL); - _action1._field1E = true; + _action1._part2Fl = true; _action1._fadePct = 0; _action1.setActionIndex(1); @@ -4614,7 +4616,7 @@ void Scene3600::postInit(SceneObjectList *OwnerList) { _steppingDisk.fixPriority(149); _steppingDisk.changeZoom(-1); - _action1._field1E = false; + _action1._part2Fl = false; _action1._fadePct = 90; _sceneMode = 3600; @@ -4852,7 +4854,7 @@ void Scene3600::signal() { // No break on purpose case 3623: if ((_protector._position.x == 226) && (_protector._position.y == 152) - && _action1._field1E && (_protector._visage == 3127) && (!R2_GLOBALS.getFlag(71))) { + && _action1._part2Fl && (_protector._visage == 3127) && (!R2_GLOBALS.getFlag(71))) { R2_GLOBALS._sound2.stop(); R2_GLOBALS._sound2.play(331); R2_GLOBALS.setFlag(71); @@ -4900,7 +4902,7 @@ void Scene3600::process(Event &event) { } void Scene3600::dispatch() { - if ((R2_GLOBALS._player.getRegionIndex() == 200) && _action1._field1E && !_lightEntered) { + if ((R2_GLOBALS._player.getRegionIndex() == 200) && _action1._part2Fl && !_lightEntered) { R2_GLOBALS._sound2.fadeOut2(NULL); if (_protector._mover) _protector.addMover(NULL); @@ -4941,7 +4943,7 @@ void Scene3600::dispatch() { _webbster.setAction(&_sequenceManager1, this, 3613, &_webbster, NULL); } - if ((_protector.getRegionIndex() == 200) && _action1._field1E && !_ghoulTeleported) { + if ((_protector.getRegionIndex() == 200) && _action1._part2Fl && !_ghoulTeleported) { R2_GLOBALS._sound2.fadeOut2(NULL); _sceneMode = 3620; _ghoulTeleported = true; diff --git a/engines/tsage/ringworld2/ringworld2_scenes3.h b/engines/tsage/ringworld2/ringworld2_scenes3.h index 398d09a01e..e6f74d6e53 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes3.h +++ b/engines/tsage/ringworld2/ringworld2_scenes3.h @@ -565,9 +565,8 @@ class Scene3500 : public SceneExt { class Action1: public Action { public: int _direction; - bool _field20; - int _field22; // CHECKME: Useless field - bool _field24; + bool _headingRightFl; + bool _turningFl; Action1(); virtual void synchronize(Serializer &s); @@ -619,8 +618,8 @@ class Scene3500 : public SceneExt { class MazeUI3500 : public MazeUI { public: - int cellFromX(int arg1); - int cellFromY(int arg1); + int16 cellFromX(int arg1); + int16 cellFromY(int arg1); int getCellFromMapXY(Common::Point pt); bool setMazePosition2(Common::Point &p); }; @@ -653,12 +652,12 @@ public: PaletteRotation *_rotation; int _mazeChangeAmount; int _speed; - bool _field1272; + bool _updateIdxChangeFl; int _mazeDirection; int _nextMove; Common::Point _mazePosition; - bool _field1282; - int _field1284; + bool _postFixupFl; + int _exitCounter; bool _directionChangesEnabled; Scene3500(); @@ -675,7 +674,7 @@ public: class Scene3600 : public SceneExt { class Action3600: public ActionExt { public: - bool _field1E; + bool _part2Fl; int _fadePct; Action3600(); diff --git a/engines/tsage/saveload.h b/engines/tsage/saveload.h index 32da6ee7f4..42fd4f3282 100644 --- a/engines/tsage/saveload.h +++ b/engines/tsage/saveload.h @@ -33,7 +33,7 @@ namespace TsAGE { typedef void (*SaveNotifierFn)(bool postFlag); -#define TSAGE_SAVEGAME_VERSION 12 +#define TSAGE_SAVEGAME_VERSION 15 class SavedObject; diff --git a/engines/tsage/scenes.cpp b/engines/tsage/scenes.cpp index 1726d6ad20..b41e8175c6 100644 --- a/engines/tsage/scenes.cpp +++ b/engines/tsage/scenes.cpp @@ -275,10 +275,7 @@ Scene::Scene() : _sceneBounds(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), _oldSceneBounds = Rect(4000, 4000, 4100, 4100); Common::fill(&_zoomPercents[0], &_zoomPercents[256], 0); - _field12 = 0; _screenNumber = 0; - _fieldA = 0; - _fieldE = 0; } Scene::~Scene() { @@ -288,15 +285,23 @@ void Scene::synchronize(Serializer &s) { if (s.getVersion() >= 2) StripCallback::synchronize(s); - s.syncAsSint32LE(_field12); + if (s.getVersion() < 14) { + int useless = 0; + s.syncAsSint32LE(useless); + } + s.syncAsSint32LE(_screenNumber); s.syncAsSint32LE(_activeScreenNumber); s.syncAsSint32LE(_sceneMode); _backgroundBounds.synchronize(s); _sceneBounds.synchronize(s); _oldSceneBounds.synchronize(s); - s.syncAsSint16LE(_fieldA); - s.syncAsSint16LE(_fieldE); + + if (s.getVersion() < 14) { + int useless = 0; + s.syncAsSint16LE(useless); + s.syncAsSint16LE(useless); + } for (int i = 0; i < 256; ++i) s.syncAsUint16LE(_enabledSections[i]); @@ -309,7 +314,6 @@ void Scene::synchronize(Serializer &s) { void Scene::postInit(SceneObjectList *OwnerList) { _action = NULL; - _field12 = 0; _sceneMode = 0; } diff --git a/engines/tsage/scenes.h b/engines/tsage/scenes.h index d5ac88c692..4d36192cec 100644 --- a/engines/tsage/scenes.h +++ b/engines/tsage/scenes.h @@ -35,7 +35,6 @@ class Scene : public StripCallback { private: void drawBackgroundObjects(); public: - int _field12; int _screenNumber; int _activeScreenNumber; int _sceneMode; @@ -49,9 +48,6 @@ public: int _zoomPercents[256]; ScenePriorities _priorities; SceneObjectList _bgSceneObjects; - - int _fieldA; - int _fieldE; public: Scene(); virtual ~Scene(); diff --git a/engines/tsage/staticres.cpp b/engines/tsage/staticres.cpp index 2749f2ac90..3c850cf8dc 100644 --- a/engines/tsage/staticres.cpp +++ b/engines/tsage/staticres.cpp @@ -213,6 +213,14 @@ char const *const ACCESS_CODE_REQUIRED = "access code required"; char const *const INVALID_ACCESS_CODE = "invalid access code"; char const *const FOREIGN_OBJECT_EXTRACTED = "foreign object extracted"; +// Scene 1330/7 Options dialog messages +char const *const AUTO_PLAY_ON = "Auto-Play is On"; +char const *const AUTO_PLAY_OFF = "Auto-Play is Off"; +char const *const START_NEW_CARD_GAME = "Start a new game"; +char const *const QUIT_CARD_GAME = "Quit Outpost Alpha"; +char const *const CONTINUE_CARD_GAME = "Continue Outpost Alpha"; + +// char const *const HELP_MSG = "\x1\rRETURN TO\r RINGWORLD\x14"; char const *const CHAR_TITLE = "\x01Select Character:"; char const *const CHAR_QUINN_MSG = " Quinn "; diff --git a/engines/tsage/staticres.h b/engines/tsage/staticres.h index 587463a918..c18f31fdfc 100644 --- a/engines/tsage/staticres.h +++ b/engines/tsage/staticres.h @@ -165,6 +165,13 @@ extern char const *const ACCESS_CODE_REQUIRED; extern char const *const INVALID_ACCESS_CODE; extern char const *const FOREIGN_OBJECT_EXTRACTED; +// Scene 1330/7 Options dialog messages +extern char const *const AUTO_PLAY_ON; +extern char const *const AUTO_PLAY_OFF; +extern char const *const START_NEW_CARD_GAME; +extern char const *const QUIT_CARD_GAME; +extern char const *const CONTINUE_CARD_GAME; + // Dialog messages extern char const *const HELP_MSG; extern char const *const CHAR_TITLE; diff --git a/engines/tsage/tsage.cpp b/engines/tsage/tsage.cpp index 37e96c75e0..80e2116c54 100644 --- a/engines/tsage/tsage.cpp +++ b/engines/tsage/tsage.cpp @@ -177,8 +177,4 @@ void TSageEngine::syncSoundSettings() { g_globals->_soundManager.syncSounds(); } -bool TSageEngine::shouldQuit() { - return getEventManager()->shouldQuit() || getEventManager()->shouldRTL(); -} - } // End of namespace TsAGE diff --git a/engines/tsage/tsage.h b/engines/tsage/tsage.h index 0896580b04..e69fe0612a 100644 --- a/engines/tsage/tsage.h +++ b/engines/tsage/tsage.h @@ -83,7 +83,6 @@ public: uint32 getGameID() const; uint32 getFeatures() const; Common::String getPrimaryFilename() const; - bool shouldQuit(); virtual Common::Error init(); virtual Common::Error run(); diff --git a/engines/tsage/user_interface.cpp b/engines/tsage/user_interface.cpp index ae34ac0574..ae5c6c8cee 100644 --- a/engines/tsage/user_interface.cpp +++ b/engines/tsage/user_interface.cpp @@ -38,13 +38,15 @@ void StripProxy::process(Event &event) { void UIElement::synchronize(Serializer &s) { BackgroundSceneObject::synchronize(s); - s.syncAsSint16LE(_field88); + if (s.getVersion() < 15) { + int useless = 0; + s.syncAsSint16LE(useless); + } s.syncAsSint16LE(_enabled); s.syncAsSint16LE(_frameNum); } void UIElement::setup(int visage, int stripNum, int frameNum, int posX, int posY, int priority) { - _field88 = 0; _frameNum = frameNum; _enabled = true; diff --git a/engines/tsage/user_interface.h b/engines/tsage/user_interface.h index 60cefc0751..bc2398bf05 100644 --- a/engines/tsage/user_interface.h +++ b/engines/tsage/user_interface.h @@ -37,7 +37,6 @@ public: class UIElement: public BackgroundSceneObject { public: - int _field88; bool _enabled; int _frameNum; diff --git a/engines/wintermute/detection_tables.h b/engines/wintermute/detection_tables.h index bec52c4957..24f85239c1 100644 --- a/engines/wintermute/detection_tables.h +++ b/engines/wintermute/detection_tables.h @@ -27,8 +27,9 @@ namespace Wintermute { static const PlainGameDescriptor wintermuteGames[] = { {"5ld", "Five Lethal Demons"}, {"5ma", "Five Magical Amulets"}, - {"bthreshold", "Beyond the Threshold"}, {"actualdest", "Actual Destination"}, + {"bookofgron", "Book of Gron Part One"}, + {"bthreshold", "Beyond the Threshold"}, {"carolreed4", "Carol Reed 4 - East Side Story"}, {"carolreed5", "Carol Reed 5 - The Colour of Murder"}, {"carolreed6", "Carol Reed 6 - Black Circle"}, @@ -41,15 +42,19 @@ static const PlainGameDescriptor wintermuteGames[] = { {"dirtysplit", "Dirty Split"}, {"dreamscape", "Dreamscape"}, {"escapemansion", "Escape from the Mansion"}, + {"framed", "Framed"}, {"ghostsheet", "Ghost in the Sheet"}, {"hamlet", "Hamlet or the last game without MMORPS features, shaders and product placement"}, {"helga", "Helga Deep In Trouble"}, {"jamesperis", "James Peris: No License Nor Control"}, + {"kulivocko", "Kulivocko"}, + {"lonelyrobot", "Project Lonely Robot"}, {"looky", "Looky"}, {"julia", "J.U.L.I.A."}, {"mirage", "Mirage"}, {"paintaria", "Paintaria"}, {"pigeons", "Pigeons in the Park"}, + {"projectdoom", "Project: Doom"}, {"reversion1", "Reversion: The Escape"}, {"reversion2", "Reversion: The Meeting"}, {"rosemary", "Rosemary"}, @@ -106,6 +111,16 @@ static const ADGameDescription gameDescriptions[] = { ADGF_UNSTABLE, GUIO0() }, + // Book of Gron Part One + { + "bookofgron", + "", + AD_ENTRY1s("data.dcp", "e61b2ebee044a82fa0f8ca0fce2c8946", 83129531), + Common::RU_RUS, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, // Carol Reed 4 - East Side Story (Demo) { "carolreed4", @@ -327,6 +342,16 @@ static const ADGameDescription gameDescriptions[] = { ADGF_UNSTABLE, GUIO0() }, + // Framed + { + "framed", + "", + AD_ENTRY1s("data.dcp", "e7259fb36f2c6f9f28242291e0c3de98", 34690568), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, // Ghosts in the Sheet { "ghostsheet", @@ -348,6 +373,20 @@ static const ADGameDescription gameDescriptions[] = { ADGF_UNSTABLE, GUIO0() }, + // Helga Deep In Trouble (English) + { + "helga", + "", + { + {"english.dcp", 0, "bfa136b21bdbc7d8691c0770a6d40bc3", 135931}, + {"data.dcp", 0, "25cb955a60b58326f2eeda1ce288fb37", 183251259}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, // Helga Deep In Trouble (Demo) (English) { "helga", @@ -437,6 +476,27 @@ static const ADGameDescription gameDescriptions[] = { ADGF_DEMO, GUIO0() }, + // Kulivocko (Czech) + { + "kulivocko", + "", + AD_ENTRY1s("data.dcp", "44306dc470e9b27474043932eccee02f", 155106392), + Common::CZ_CZE, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // Kulivocko (Czech) (Demo) + { + "kulivocko", + "Demo", + AD_ENTRY1s("data.dcp", "63b164bdfadecbb0deb5da691afb8154", 48362234), + Common::CZ_CZE, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, // Looky Demo (English) { "looky", @@ -511,6 +571,27 @@ static const ADGameDescription gameDescriptions[] = { ADGF_UNSTABLE, GUIO0() }, + // Project: Doom + { + "projectdoom", + "", + AD_ENTRY1s("data.dcp", "d5894b65a40706845434b99870bcab92", 99223761), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // Project Lonely Robot + { + "lonelyrobot", + "beta", + AD_ENTRY1s("data.dcp", "a0cf7ad5bab957416dcda454e9f28ef0", 3420120), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, // Reversion: The Escape Version 1.0 { "reversion1", diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 491a9d7f42..ce04db8a67 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -1266,51 +1266,50 @@ template<typename PixelType> void VectorRendererSpec<PixelType>:: drawBevelSquareAlg(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color, bool fill) { int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; + int i, j; + PixelType *ptr_left; - int height = h; - PixelType *ptr_fill = (PixelType *)_activeSurface->getBasePtr(x, y); - + // Fill Background + ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y); + i = h; if (fill) { assert((_bgColor & ~_alphaMask) == 0); // only support black - while (height--) { - darkenFill(ptr_fill, ptr_fill + w); - ptr_fill += pitch; + while (i--) { + darkenFill(ptr_left, ptr_left + w); + ptr_left += pitch; } } - int i, j; - x = MAX(x - bevel, 0); y = MAX(y - bevel, 0); w = MIN(w + (bevel * 2), (int)_activeSurface->w); h = MIN(h + (bevel * 2), (int)_activeSurface->h); - PixelType *ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y); - + ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y); i = bevel; while (i--) { colorFill<PixelType>(ptr_left, ptr_left + w, top_color); ptr_left += pitch; } - i = h - bevel; ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y + bevel); + i = h - bevel; while (i--) { colorFill<PixelType>(ptr_left, ptr_left + bevel, top_color); ptr_left += pitch; } - i = bevel; ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y + h - bevel); + i = bevel; while (i--) { colorFill<PixelType>(ptr_left + i, ptr_left + w, bottom_color); ptr_left += pitch; } + ptr_left = (PixelType *)_activeSurface->getBasePtr(x + w - bevel, y); i = h - bevel; j = bevel - 1; - ptr_left = (PixelType *)_activeSurface->getBasePtr(x + w - bevel, y); while (i--) { colorFill<PixelType>(ptr_left + j, ptr_left + bevel, bottom_color); if (j > 0) j--; |