diff options
author | Marisa-Chan | 2014-06-13 21:43:04 +0700 |
---|---|---|
committer | Marisa-Chan | 2014-06-13 21:43:04 +0700 |
commit | 45589950c0fb1a449351e6a00ef10d42290d8bae (patch) | |
tree | 44e4eedcb7e69d5fc386155b000ed038af07251d /engines/touche | |
parent | 48360645dcd5f8fddb135b6e31ae5cae4be8d77f (diff) | |
parent | 5c005ad3a3f1df0bc968c85c1cf0fc48e36ab0b2 (diff) | |
download | scummvm-rg350-45589950c0fb1a449351e6a00ef10d42290d8bae.tar.gz scummvm-rg350-45589950c0fb1a449351e6a00ef10d42290d8bae.tar.bz2 scummvm-rg350-45589950c0fb1a449351e6a00ef10d42290d8bae.zip |
Merge remote-tracking branch 'upstream/master' into zvision
Conflicts:
engines/zvision/animation/rlf_animation.cpp
engines/zvision/animation_control.h
engines/zvision/core/console.cpp
engines/zvision/core/events.cpp
engines/zvision/cursors/cursor.cpp
engines/zvision/cursors/cursor_manager.cpp
engines/zvision/cursors/cursor_manager.h
engines/zvision/fonts/truetype_font.cpp
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/inventory/inventory_manager.h
engines/zvision/inventory_manager.h
engines/zvision/meta_animation.h
engines/zvision/module.mk
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/control.h
engines/zvision/scripting/controls/animation_control.cpp
engines/zvision/scripting/controls/animation_control.h
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/lever_control.cpp
engines/zvision/scripting/controls/timer_node.cpp
engines/zvision/scripting/controls/timer_node.h
engines/zvision/scripting/puzzle.h
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
engines/zvision/sidefx.cpp
engines/zvision/sound/zork_raw.cpp
engines/zvision/sound/zork_raw.h
engines/zvision/video/video.cpp
engines/zvision/video/zork_avi_decoder.h
engines/zvision/zvision.cpp
engines/zvision/zvision.h
Diffstat (limited to 'engines/touche')
-rw-r--r-- | engines/touche/configure.engine | 3 | ||||
-rw-r--r-- | engines/touche/console.cpp | 10 | ||||
-rw-r--r-- | engines/touche/console.h | 4 | ||||
-rw-r--r-- | engines/touche/detection.cpp | 4 | ||||
-rw-r--r-- | engines/touche/graphics.cpp | 4 | ||||
-rw-r--r-- | engines/touche/graphics.h | 4 | ||||
-rw-r--r-- | engines/touche/menu.cpp | 175 | ||||
-rw-r--r-- | engines/touche/midi.cpp | 4 | ||||
-rw-r--r-- | engines/touche/midi.h | 4 | ||||
-rw-r--r-- | engines/touche/opcodes.cpp | 4 | ||||
-rw-r--r-- | engines/touche/resource.cpp | 24 | ||||
-rw-r--r-- | engines/touche/saveload.cpp | 4 | ||||
-rw-r--r-- | engines/touche/staticres.cpp | 4 | ||||
-rw-r--r-- | engines/touche/touche.cpp | 111 | ||||
-rw-r--r-- | engines/touche/touche.h | 114 |
15 files changed, 287 insertions, 186 deletions
diff --git a/engines/touche/configure.engine b/engines/touche/configure.engine new file mode 100644 index 0000000000..777578e623 --- /dev/null +++ b/engines/touche/configure.engine @@ -0,0 +1,3 @@ +# This file is included from the main "configure" script +# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] +add_engine touche "Touche: The Adventures of the Fifth Musketeer" yes diff --git a/engines/touche/console.cpp b/engines/touche/console.cpp index 2c4c6a0da1..472863c817 100644 --- a/engines/touche/console.cpp +++ b/engines/touche/console.cpp @@ -8,12 +8,12 @@ * 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. @@ -26,8 +26,8 @@ namespace Touche { ToucheConsole::ToucheConsole(ToucheEngine *vm) : GUI::Debugger(), _vm(vm) { - DCmd_Register("startMusic", WRAP_METHOD(ToucheConsole, Cmd_StartMusic)); - DCmd_Register("stopMusic", WRAP_METHOD(ToucheConsole, Cmd_StopMusic)); + registerCmd("startMusic", WRAP_METHOD(ToucheConsole, Cmd_StartMusic)); + registerCmd("stopMusic", WRAP_METHOD(ToucheConsole, Cmd_StopMusic)); } ToucheConsole::~ToucheConsole() { @@ -35,7 +35,7 @@ ToucheConsole::~ToucheConsole() { bool ToucheConsole::Cmd_StartMusic(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Usage: startMusic <num>\n"); + debugPrintf("Usage: startMusic <num>\n"); return true; } diff --git a/engines/touche/console.h b/engines/touche/console.h index 43a303ad77..ed7620a820 100644 --- a/engines/touche/console.h +++ b/engines/touche/console.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp index 0662e718d5..97a14e5bc1 100644 --- a/engines/touche/detection.cpp +++ b/engines/touche/detection.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/touche/graphics.cpp b/engines/touche/graphics.cpp index 6e565327ba..95ef16e9bd 100644 --- a/engines/touche/graphics.cpp +++ b/engines/touche/graphics.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/touche/graphics.h b/engines/touche/graphics.h index 5b2ea39a24..3fdbf9b145 100644 --- a/engines/touche/graphics.h +++ b/engines/touche/graphics.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp index 85ca519f05..b94776eee5 100644 --- a/engines/touche/menu.cpp +++ b/engines/touche/menu.cpp @@ -8,12 +8,12 @@ * 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. @@ -31,96 +31,6 @@ namespace Touche { -enum ActionId { - kActionNone, - - // settings menu - kActionLoadMenu, - kActionSaveMenu, - kActionRestartGame, - kActionPlayGame, - kActionQuitGame, - kActionTextOnly, - kActionVoiceOnly, - kActionTextAndVoice, - kActionLowerVolume, - kActionUpperVolume, - - // saveLoad menu - kActionGameState1, - kActionGameState2, - kActionGameState3, - kActionGameState4, - kActionGameState5, - kActionGameState6, - kActionGameState7, - kActionGameState8, - kActionGameState9, - kActionGameState10, - kActionScrollUpSaves, - kActionScrollDownSaves, - kActionPerformSaveLoad, - kActionCancelSaveLoad -}; - -enum MenuMode { - kMenuSettingsMode = 0, - kMenuLoadStateMode, - kMenuSaveStateMode -}; - -enum ButtonFlags { - kButtonBorder = 1 << 0, - kButtonText = 1 << 1, - kButtonArrow = 1 << 2 -}; - -struct Button { - int x, y; - int w, h; - ActionId action; - int data; - uint8 flags; -}; - -struct MenuData { - MenuMode mode; - Button *buttonsTable; - uint buttonsCount; - bool quit; - bool exit; - char saveLoadDescriptionsTable[kMaxSaveStates][33]; - - void removeLastCharFromDescription(int slot) { - char *description = saveLoadDescriptionsTable[slot]; - int descriptionLen = strlen(description); - if (descriptionLen > 0) { - --descriptionLen; - description[descriptionLen] = 0; - } - } - - void addCharToDescription(int slot, char chr) { - char *description = saveLoadDescriptionsTable[slot]; - int descriptionLen = strlen(description); - if (descriptionLen < 32 && Common::isPrint(chr)) { - description[descriptionLen] = chr; - description[descriptionLen + 1] = 0; - } - } - - const Button *findButtonUnderCursor(int cursorX, int cursorY) const { - for (uint i = 0; i < buttonsCount; ++i) { - const Button *button = &buttonsTable[i]; - if (cursorX >= button->x && cursorX < button->x + button->w && - cursorY >= button->y && cursorY < button->y + button->h) { - return button; - } - } - return 0; - } -}; - static void drawArrow(uint8 *dst, int dstPitch, int x, int y, int delta, uint8 color) { static const int8 arrowCoordsTable[7][4] = { { 5, 0, 9, 0 }, @@ -140,25 +50,24 @@ static void drawArrow(uint8 *dst, int dstPitch, int x, int y, int delta, uint8 c } } -void ToucheEngine::drawButton(void *button) { - Button *b = (Button *)button; - if (b->flags & kButtonBorder) { - Graphics::drawRect(_offscreenBuffer, kScreenWidth, b->x, b->y, b->w, b->h, 0xF7, 0xF9); +void ToucheEngine::drawButton(Button *button) { + if (button->flags & kButtonBorder) { + Graphics::drawRect(_offscreenBuffer, kScreenWidth, button->x, button->y, button->w, button->h, 0xF7, 0xF9); } - if (b->flags & kButtonText) { - if (b->data != 0) { - const char *str = getString(b->data); - const int w = getStringWidth(b->data); + if (button->flags & kButtonText) { + if (button->data != 0) { + const char *str = getString(button->data); + const int w = getStringWidth(button->data); const int h = kTextHeight; - const int x = b->x + (b->w - w) / 2; - const int y = b->y + (b->h - h) / 2; + const int x = button->x + (button->w - w) / 2; + const int y = button->y + (button->h - h) / 2; Graphics::drawString16(_offscreenBuffer, kScreenWidth, 0xFF, x, y, str); } } - if (b->flags & kButtonArrow) { + if (button->flags & kButtonArrow) { int dx = 0; int dy = 0; - switch (b->data) { + switch (button->data) { case 2000: // up arrow dx = 1; dy = 2; @@ -168,8 +77,8 @@ void ToucheEngine::drawButton(void *button) { dy = -2; break; } - const int x = b->x + b->w / 2; - const int y = b->y + b->h / 2; + const int x = button->x + button->w / 2; + const int y = button->y + button->h / 2; drawArrow(_offscreenBuffer, kScreenWidth, x, y + dy + 1, dx, 0xD2); drawArrow(_offscreenBuffer, kScreenWidth, x, y + dy, dx, 0xFF); } @@ -253,49 +162,47 @@ static void setupMenu(MenuMode mode, MenuData *menuData) { } } -void ToucheEngine::redrawMenu(void *menu) { - MenuData *menuData = (MenuData *)menu; +void ToucheEngine::redrawMenu(MenuData *menu) { Graphics::fillRect(_offscreenBuffer, kScreenWidth, 90, 102, 460, 196, 0xF8); Graphics::drawRect(_offscreenBuffer, kScreenWidth, 90, 102, 460, 196, 0xF7, 0xF9); Graphics::drawRect(_offscreenBuffer, kScreenWidth, 106, 118, 340, 164, 0xF9, 0xF7); - switch (menuData->mode) { + switch (menu->mode) { case kMenuSettingsMode: drawVolumeSlideBar(_offscreenBuffer, kScreenWidth, getMusicVolume()); - menuData->buttonsTable[5].data = 0; - menuData->buttonsTable[6].data = 0; - menuData->buttonsTable[7].data = 0; - menuData->buttonsTable[5 + _talkTextMode].data = -86; + menu->buttonsTable[5].data = 0; + menu->buttonsTable[6].data = 0; + menu->buttonsTable[7].data = 0; + menu->buttonsTable[5 + _talkTextMode].data = -86; break; case kMenuLoadStateMode: case kMenuSaveStateMode: - drawSaveGameStateDescriptions(_offscreenBuffer, kScreenWidth, menuData, _saveLoadCurrentPage, _saveLoadCurrentSlot); + drawSaveGameStateDescriptions(_offscreenBuffer, kScreenWidth, menu, _saveLoadCurrentPage, _saveLoadCurrentSlot); break; } - for (uint i = 0; i < menuData->buttonsCount; ++i) { - drawButton(&menuData->buttonsTable[i]); + for (uint i = 0; i < menu->buttonsCount; ++i) { + drawButton(&menu->buttonsTable[i]); } } -void ToucheEngine::handleMenuAction(void *menu, int actionId) { - MenuData *menuData = (MenuData *)menu; +void ToucheEngine::handleMenuAction(MenuData *menu, int actionId) { switch (actionId) { case kActionLoadMenu: - menuData->mode = kMenuLoadStateMode; + menu->mode = kMenuLoadStateMode; break; case kActionSaveMenu: _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true); - menuData->mode = kMenuSaveStateMode; + menu->mode = kMenuSaveStateMode; break; case kActionRestartGame: restart(); - menuData->quit = true; + menu->quit = true; break; case kActionPlayGame: - menuData->quit = true; + menu->quit = true; break; case kActionQuitGame: quitGame(); - menuData->quit = true; + menu->quit = true; break; case kActionTextOnly: _talkTextMode = kTalkModeTextOnly; @@ -327,23 +234,23 @@ void ToucheEngine::handleMenuAction(void *menu, int actionId) { _saveLoadCurrentSlot = _saveLoadCurrentPage * 10 + (_saveLoadCurrentSlot % 10); break; case kActionPerformSaveLoad: - if (menuData->mode == kMenuLoadStateMode) { + if (menu->mode == kMenuLoadStateMode) { if (loadGameState(_saveLoadCurrentSlot).getCode() == Common::kNoError) { - menuData->quit = true; + menu->quit = true; } - } else if (menuData->mode == kMenuSaveStateMode) { + } else if (menu->mode == kMenuSaveStateMode) { _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); - const char *description = menuData->saveLoadDescriptionsTable[_saveLoadCurrentSlot]; + const char *description = menu->saveLoadDescriptionsTable[_saveLoadCurrentSlot]; if (strlen(description) > 0) { if (saveGameState(_saveLoadCurrentSlot, description).getCode() == Common::kNoError) { - menuData->quit = true; + menu->quit = true; } } } break; case kActionCancelSaveLoad: _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); - menuData->mode = kMenuSettingsMode; + menu->mode = kMenuSettingsMode; break; default: if (actionId >= kActionGameState1 && actionId <= kActionGameState10) { @@ -569,29 +476,29 @@ int ToucheEngine::displayQuitDialog() { quitLoop = true; switch (_language) { case Common::FR_FRA: - if (event.kbd.ascii == 'o' || event.kbd.ascii == 'O') { + if (event.kbd.keycode == Common::KEYCODE_o) { ret = 1; } break; case Common::DE_DEU: - if (event.kbd.ascii == 'j' || event.kbd.ascii == 'J') { + if (event.kbd.keycode == Common::KEYCODE_j) { ret = 1; } break; case Common::ES_ESP: - if (event.kbd.ascii == 's' || event.kbd.ascii == 'S') { + if (event.kbd.keycode == Common::KEYCODE_s) { ret = 1; } break; case Common::PL_POL: - if (event.kbd.ascii == 's' || event.kbd.ascii == 'S' || event.kbd.ascii == 't' || event.kbd.ascii == 'T') { + if (event.kbd.keycode == Common::KEYCODE_s || event.kbd.keycode == Common::KEYCODE_t) { ret = 1; } break; default: // According to cyx, the Italian version uses the same // keys as the English one. - if (event.kbd.ascii == 'y' || event.kbd.ascii == 'Y') { + if (event.kbd.keycode == Common::KEYCODE_y) { ret = 1; } break; diff --git a/engines/touche/midi.cpp b/engines/touche/midi.cpp index da14baa484..96813077ce 100644 --- a/engines/touche/midi.cpp +++ b/engines/touche/midi.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/touche/midi.h b/engines/touche/midi.h index 24f9da0474..e54d43209c 100644 --- a/engines/touche/midi.h +++ b/engines/touche/midi.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/touche/opcodes.cpp b/engines/touche/opcodes.cpp index 18677eae26..ee7f3a9b6b 100644 --- a/engines/touche/opcodes.cpp +++ b/engines/touche/opcodes.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp index 9625224316..467d2bed90 100644 --- a/engines/touche/resource.cpp +++ b/engines/touche/resource.cpp @@ -8,12 +8,12 @@ * 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. @@ -150,38 +150,38 @@ void ToucheEngine::res_allocateTables() { void ToucheEngine::res_deallocateTables() { free(_textData); - _textData = 0; + _textData = nullptr; free(_backdropBuffer); - _backdropBuffer = 0; + _backdropBuffer = nullptr; free(_menuKitData); - _menuKitData = 0; + _menuKitData = nullptr; free(_convKitData); - _convKitData = 0; + _convKitData = nullptr; for (int i = 0; i < NUM_SEQUENCES; ++i) { free(_sequenceDataTable[i]); - _sequenceDataTable[i] = 0; + _sequenceDataTable[i] = nullptr; } free(_programData); - _programData = 0; + _programData = nullptr; free(_mouseData); - _mouseData = 0; + _mouseData = nullptr; free(_iconData); - _iconData = 0; + _iconData = nullptr; for (int i = 0; i < NUM_SPRITES; ++i) { free(_spritesTable[i].ptr); - _spritesTable[i].ptr = 0; + _spritesTable[i].ptr = nullptr; } free(_offscreenBuffer); - _offscreenBuffer = 0; + _offscreenBuffer = nullptr; } uint32 ToucheEngine::res_getDataOffset(ResourceType type, int num, uint32 *size) { diff --git a/engines/touche/saveload.cpp b/engines/touche/saveload.cpp index a054299ecd..d44a3d43ff 100644 --- a/engines/touche/saveload.cpp +++ b/engines/touche/saveload.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/touche/staticres.cpp b/engines/touche/staticres.cpp index 23b76558e4..d2359dd130 100644 --- a/engines/touche/staticres.cpp +++ b/engines/touche/staticres.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp index 5c133ccbc6..ff4f41f44d 100644 --- a/engines/touche/touche.cpp +++ b/engines/touche/touche.cpp @@ -8,12 +8,12 @@ * 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. @@ -46,11 +46,33 @@ namespace Touche { ToucheEngine::ToucheEngine(OSystem *system, Common::Language language) - : Engine(system), _midiPlayer(0), _language(language), _rnd("touche") { + : Engine(system), _midiPlayer(nullptr), _language(language), _rnd("touche") { _saveLoadCurrentPage = 0; _saveLoadCurrentSlot = 0; _hideInventoryTexts = false; + _numOpcodes = 0; + _compressedSpeechData = 0; + _textData = nullptr; + _backdropBuffer = nullptr; + _menuKitData = nullptr; + _convKitData = nullptr; + + for (int i = 0; i < NUM_SEQUENCES; i++) + _sequenceDataTable[i] = nullptr; + + _programData = nullptr; + _programDataSize = 0; + _mouseData = nullptr; + _iconData = nullptr; + _currentBitmapWidth = 0; + _currentBitmapHeight = 0; + _currentImageWidth = 0; + _currentImageHeight = 0; + _roomWidth = 0; + _programTextDataPtr = nullptr; + _offscreenBuffer = nullptr; + _screenRect = Common::Rect(kScreenWidth, kScreenHeight); _roomAreaRect = Common::Rect(kScreenWidth, kRoomHeight); @@ -88,6 +110,83 @@ ToucheEngine::ToucheEngine(OSystem *system, Common::Language language) DebugMan.addDebugChannel(kDebugCharset, "Charset", "Charset debug level"); _console = new ToucheConsole(this); + + _newEpisodeNum = 0; + _currentEpisodeNum = 0; + _currentAmountOfMoney = 0; + _giveItemToKeyCharNum = 0; + _giveItemToObjectNum = 0; + _giveItemToCounter = 0; + _currentRoomNum = 0; + _waitingSetKeyCharNum1 = 0; + _waitingSetKeyCharNum2 = 0; + _waitingSetKeyCharNum3 = 0; + _script.opcodeNum = 0; + _script.dataOffset = 0; + _script.keyCharNum = 0; + _script.dataPtr = nullptr; + _script.stackDataPtr = nullptr; + _script.stackDataBasePtr = nullptr; + _script.quitFlag = 0; + _opcodesTable = nullptr; + + for (uint i = 0; i < NUM_SPRITES; i++) + memset(&_spritesTable[i], 0, sizeof(SpriteData)); + + for (uint i = 0; i < NUM_SEQUENCES; i++) + memset(&_sequenceEntryTable[i], 0, sizeof(SequenceEntry)); + + _talkListEnd = 0; + _talkListCurrent = 0; + _talkTextRectDefined = false; + _talkTextDisplayed = false; + _talkTextInitialized = false; + _skipTalkText = false; + _talkTextSpeed = 0; + _keyCharTalkCounter = 0; + _talkTableLastTalkingKeyChar = 0; + _talkTableLastOtherKeyChar = 0; + _talkTableLastStringNum = 0; + + for (uint i = 0; i < NUM_TALK_ENTRIES; i++) + memset(&_talkTable[i], 0, sizeof(TalkEntry)); + + _conversationChoicesUpdated = false; + _conversationReplyNum = 0; + _conversationEnded = false; + _conversationNum = 0; + _scrollConversationChoiceOffset = 0; + _currentConversation = 0; + _disableConversationScript = false; + _conversationAreaCleared = false; + + for (uint i = 0; i < NUM_CONVERSATION_CHOICES; i++) + memset(&_conversationChoicesTable[i], 0, sizeof(ConversationChoice)); + + for (uint i = 0; i < NUM_KEYCHARS; i++) + _sortedKeyCharsTable[i] = 0; + + _currentKeyCharNum = 0; + _inp_leftMouseButtonPressed = false; + _inp_rightMouseButtonPressed = false; + _disabledInputCounter = 0; + _gameState = kGameStateNone; + _displayQuitDialog = false; + _newMusicNum = 0; + _currentMusicNum = 0; + _newSoundNum = 0; + _newSoundDelay = 0; + _newSoundPriority = 0; + for (int i = 0; i < 3; ++i) { + _inventoryStateTable[i].displayOffset = 0; + _inventoryStateTable[i].lastItem = 0; + _inventoryStateTable[i].itemsPerLine = 0; + _inventoryStateTable[i].itemsList = nullptr; + } + _inventoryVar1 = nullptr; + _inventoryVar2 = nullptr; + _currentCursorObject = 0; + _talkTextMode = 0; } ToucheEngine::~ToucheEngine() { @@ -337,13 +436,13 @@ void ToucheEngine::processEvents(bool handleKeyEvents) { this->getDebugger()->onFrame(); } } else { - if (event.kbd.ascii == 't') { + if (event.kbd.keycode == Common::KEYCODE_t) { ++_talkTextMode; if (_talkTextMode == kTalkModeCount) { _talkTextMode = 0; } displayTextMode(-(92 + _talkTextMode)); - } else if (event.kbd.ascii == ' ') { + } else if (event.kbd.keycode == Common::KEYCODE_SPACE) { updateKeyCharTalk(2); } } @@ -3015,12 +3114,12 @@ void ToucheEngine::buildWalkPath(int dstPosX, int dstPosY, int keyChar) { for (uint i = 0; i < _programWalkTable.size(); ++i) { const ProgramWalkData *pwd = &_programWalkTable[i]; if ((pwd->point1 & 0x4000) == 0) { - int distance = 32000; ProgramPointData *pts1 = &_programPointsTable[pwd->point1]; ProgramPointData *pts2 = &_programPointsTable[pwd->point2]; if (pts1->order != 0) { int dx = pts2->x - pts1->x; int dy = pts2->y - pts1->y; + int distance = 32000; if (dx == 0) { if (dstPosY > MIN(pts2->y, pts1->y) && dstPosY < MAX(pts2->y, pts1->y)) { int d = ABS(dstPosX - pts1->x); diff --git a/engines/touche/touche.h b/engines/touche/touche.h index 6ac43e7dfe..20bf723553 100644 --- a/engines/touche/touche.h +++ b/engines/touche/touche.h @@ -8,12 +8,12 @@ * 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. @@ -102,7 +102,7 @@ struct KeyChar { int16 zPosPrev; int16 prevWalkDataNum; uint16 textColor; - int16 inventoryItems[4]; + int16 inventoryItems[5]; int16 money; int16 pointsDataNum; int16 currentWalkBox; @@ -346,16 +346,108 @@ enum StringType { kStringTypeConversation }; -void readGameStateDescription(Common::ReadStream *f, char *description, int len); -Common::String generateGameStateFileName(const char *target, int slot, bool prefixOnly = false); -int getGameStateFileSlot(const char *filename); - enum GameState { kGameStateGameLoop, kGameStateOptionsDialog, - kGameStateQuitDialog + kGameStateQuitDialog, + kGameStateNone +}; + +enum ActionId { + kActionNone, + + // settings menu + kActionLoadMenu, + kActionSaveMenu, + kActionRestartGame, + kActionPlayGame, + kActionQuitGame, + kActionTextOnly, + kActionVoiceOnly, + kActionTextAndVoice, + kActionLowerVolume, + kActionUpperVolume, + + // saveLoad menu + kActionGameState1, + kActionGameState2, + kActionGameState3, + kActionGameState4, + kActionGameState5, + kActionGameState6, + kActionGameState7, + kActionGameState8, + kActionGameState9, + kActionGameState10, + kActionScrollUpSaves, + kActionScrollDownSaves, + kActionPerformSaveLoad, + kActionCancelSaveLoad +}; + +enum MenuMode { + kMenuSettingsMode = 0, + kMenuLoadStateMode, + kMenuSaveStateMode +}; + +enum ButtonFlags { + kButtonBorder = 1 << 0, + kButtonText = 1 << 1, + kButtonArrow = 1 << 2 +}; + +struct Button { + int x, y; + int w, h; + ActionId action; + int data; + uint8 flags; }; +struct MenuData { + MenuMode mode; + Button *buttonsTable; + uint buttonsCount; + bool quit; + bool exit; + char saveLoadDescriptionsTable[kMaxSaveStates][33]; + + void removeLastCharFromDescription(int slot) { + char *description = saveLoadDescriptionsTable[slot]; + int descriptionLen = strlen(description); + if (descriptionLen > 0) { + --descriptionLen; + description[descriptionLen] = 0; + } + } + + void addCharToDescription(int slot, char chr) { + char *description = saveLoadDescriptionsTable[slot]; + int descriptionLen = strlen(description); + if (descriptionLen < 32 && Common::isPrint(chr)) { + description[descriptionLen] = chr; + description[descriptionLen + 1] = 0; + } + } + + const Button *findButtonUnderCursor(int cursorX, int cursorY) const { + for (uint i = 0; i < buttonsCount; ++i) { + const Button *button = &buttonsTable[i]; + if (cursorX >= button->x && cursorX < button->x + button->w && + cursorY >= button->y && cursorY < button->y + button->h) { + return button; + } + } + return 0; + } +}; + + +void readGameStateDescription(Common::ReadStream *f, char *description, int len); +Common::String generateGameStateFileName(const char *target, int slot, bool prefixOnly = false); +int getGameStateFileSlot(const char *filename); + class MidiPlayer; class ToucheEngine: public Engine { @@ -631,9 +723,9 @@ protected: void res_loadSpeechSegment(int num); void res_stopSpeech(); - void drawButton(void *button); - void redrawMenu(void *menu); - void handleMenuAction(void *menu, int actionId); + void drawButton(Button *button); + void redrawMenu(MenuData *menu); + void handleMenuAction(MenuData *menu, int actionId); void handleOptions(int forceDisplay); void drawActionsPanel(int dstX, int dstY, int deltaX, int deltaY); void drawConversationPanelBorder(int dstY, int srcX, int srcY); |