diff options
-rw-r--r-- | engines/lilliput/lilliput.cpp | 104 | ||||
-rw-r--r-- | engines/lilliput/lilliput.h | 12 | ||||
-rw-r--r-- | engines/lilliput/script.cpp | 17 |
3 files changed, 100 insertions, 33 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp index d0b77013bf..88f0e57609 100644 --- a/engines/lilliput/lilliput.cpp +++ b/engines/lilliput/lilliput.cpp @@ -134,7 +134,7 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd) _soundHandler = new LilliputSound(this); _byte1714E = 0; - _byte12FCE = 0; + _byte12FCE = false; _byte129A0 = -1; _numCharactersToDisplay = 0; _nextDisplayCharacterPos = Common::Point(0, 0); @@ -1889,10 +1889,10 @@ void LilliputEngine::sub13156(bool &forceReturnFl) { if (!_keyboard_checkKeyboard()) return; - Common::KeyState state = _keyboard_getch(); - uint16 var1 = state.ascii; + Common::Event event = _keyboard_getch(); + uint16 var1 = event.kbd.ascii; for (int i = 0; i < 20; i++) { - warning("%d - 0x%x", i, _rulesBuffer13_4[i]); + warning("%d - 0x%x", i, _keyboardMapping[i]); } // TODO: Very incomplete! @@ -1902,10 +1902,68 @@ void LilliputEngine::sub13156(bool &forceReturnFl) { } +void LilliputEngine::sub147D7() { + debugC(2, kDebugEngine, "sub147D7()"); + + static bool altKeyFl = false; + static int16 keyCount = 0; + + if (_keyboard_oldIndex == _keyboard_nextIndex) + return; + + Common::Event oldEvent = _keyboard_buffer[_keyboard_oldIndex]; + if ((oldEvent.kbd.keycode == Common::KEYCODE_LALT) || (oldEvent.kbd.keycode == Common::KEYCODE_RALT)) { + if (oldEvent.type == Common::EVENT_KEYDOWN) { + altKeyFl = true; + keyCount = 0; + return; + } else if (oldEvent.type == Common::EVENT_KEYUP) { + altKeyFl = false; + if (keyCount == 3) + _byte16F07_menuId = 6; + return; + } + } + + if (keyCount >= 3) + return; + + if ((altKeyFl) && (oldEvent.type == Common::EVENT_KEYDOWN)) { + switch (oldEvent.kbd.keycode) { + case Common::KEYCODE_KP0: + case Common::KEYCODE_KP1: + case Common::KEYCODE_KP2: + case Common::KEYCODE_KP3: + case Common::KEYCODE_KP4: + case Common::KEYCODE_KP5: + case Common::KEYCODE_KP6: + case Common::KEYCODE_KP7: + case Common::KEYCODE_KP8: + case Common::KEYCODE_KP9: + case Common::KEYCODE_0: + case Common::KEYCODE_1: + case Common::KEYCODE_2: + case Common::KEYCODE_3: + case Common::KEYCODE_4: + case Common::KEYCODE_5: + case Common::KEYCODE_6: + case Common::KEYCODE_7: + case Common::KEYCODE_8: + case Common::KEYCODE_9: + _array147D1[keyCount] = oldEvent.kbd.keycode - Common::KEYCODE_0; + ++keyCount; + break; + default: + break; + } + } +} + void LilliputEngine::sub130EE() { debugC(2, kDebugEngine, "sub130EE()"); -// warning("sub147D7"); + sub147D7(); + bool forceReturnFl = false; sub13156(forceReturnFl); if (forceReturnFl) @@ -1974,7 +2032,7 @@ void LilliputEngine::sub131B2(Common::Point pos, bool &forceReturnFl) { if ((pos.x >= _characterDisplayX[i]) && (pos.x <= _characterDisplayX[i] + 17) && (pos.y >= _characterDisplayY[i]) && (pos.y <= _characterDisplayY[i] + 17) && (i != _word10804)) { _byte129A0 = i; _byte16F07_menuId = 4; - if (_byte12FCE == 1) + if (_byte12FCE) _byte16F07_menuId = 3; return; @@ -2016,7 +2074,7 @@ void LilliputEngine::sub1305C(byte index, byte button) { _lastInterfaceHotspotButton = button; if (button == 2) { - if (_byte12FCE != 1) { + if (!_byte12FCE) { _scriptHandler->_interfaceHotspotStatus[index] = kHotspotEnabled; _byte16F07_menuId = 2; displayInterfaceHotspots(); @@ -2024,7 +2082,7 @@ void LilliputEngine::sub1305C(byte index, byte button) { return; } - if (_byte12FCE == 1) { + if (_byte12FCE) { unselectInterfaceButton(); return; } @@ -2032,7 +2090,7 @@ void LilliputEngine::sub1305C(byte index, byte button) { unselectInterfaceHotspots(); _scriptHandler->_interfaceHotspotStatus[index] = kHotspotSelected; if (_rulesBuffer13_1[index] == 1) { - _byte12FCE = 1; + _byte12FCE = true; _word15AC2 = 1; } else { _byte16F07_menuId = 1; @@ -2379,21 +2437,25 @@ void LilliputEngine::pollEvent() { _mouseDisplayPos = newMousePos; } } + _lastEventType = event.type; } break; case Common::EVENT_QUIT: _shouldQuit = true; break; + case Common::EVENT_KEYUP: case Common::EVENT_KEYDOWN: { - if (event.kbd == _lastKeyPressed) + if ((event.type == _lastKeyPressed.type) && (event.kbd == _lastKeyPressed.kbd)) break; - _lastKeyPressed = event.kbd; + _lastKeyPressed = event; int nextIndex = (_keyboard_nextIndex + 1) % 8; if (_keyboard_oldIndex != nextIndex) { - _keyboard_buffer[_keyboard_nextIndex] = event.kbd; + _keyboard_buffer[_keyboard_nextIndex] = event; _keyboard_nextIndex = nextIndex; } + + _lastEventType = event.type; } break; default: @@ -2639,18 +2701,18 @@ void LilliputEngine::loadRules() { byte curByte = f.readByte(); if (curByte == 0x20) - _rulesBuffer13_4[i] = 0x39; + _keyboardMapping[i] = 0x39; else if (curByte == 0xD) - _rulesBuffer13_4[i] = 0x1C; + _keyboardMapping[i] = 0x1C; // Hack to avoid xlat out of bounds else if (curByte == 0xFF) - _rulesBuffer13_4[i] = 0x21; + _keyboardMapping[i] = 0x21; // Hack to avoid xlat out of bounds else if (curByte == 0x00) - _rulesBuffer13_4[i] = 0xB4; + _keyboardMapping[i] = 0xB4; else { assert((curByte > 0x40) && (curByte <= 0x41 + 26)); - _rulesBuffer13_4[i] = _rulesXlatArray[curByte - 0x41]; + _keyboardMapping[i] = _rulesXlatArray[curByte - 0x41]; } } f.close(); @@ -2712,7 +2774,7 @@ void LilliputEngine::setCurrentCharacter(int index) { void LilliputEngine::unselectInterfaceButton() { debugC(1, kDebugEngine, "unselectInterfaceButton()"); - _byte12FCE = 0; + _byte12FCE = false; _word15AC2 = 0; _lastInterfaceHotspotButton = 0; unselectInterfaceHotspots(); @@ -2725,7 +2787,7 @@ void LilliputEngine::handleMenu() { if (_byte16F07_menuId == 0) return; - if ((_byte12FCE == 1) && (_byte16F07_menuId != 3)) + if (_byte12FCE && (_byte16F07_menuId != 3)) return; setCurrentCharacter(_word10804); @@ -2877,12 +2939,12 @@ Common::String LilliputEngine::getSavegameFilename(int slot) { return _targetName + Common::String::format("-%02d.SAV", slot); } -Common::KeyState LilliputEngine::_keyboard_getch() { +Common::Event LilliputEngine::_keyboard_getch() { warning("getch()"); while(_keyboard_nextIndex == _keyboard_oldIndex) pollEvent(); - Common::KeyState tmpEvent = _keyboard_buffer[_keyboard_oldIndex]; + Common::Event tmpEvent = _keyboard_buffer[_keyboard_oldIndex]; _keyboard_oldIndex = (_keyboard_oldIndex + 1) % 8; return tmpEvent; diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h index d1878e8afe..74f66ac9f0 100644 --- a/engines/lilliput/lilliput.h +++ b/engines/lilliput/lilliput.h @@ -105,10 +105,11 @@ public: byte _animationTick; Common::Point _nextDisplayCharacterPos; byte _sound_byte16F06; - Common::KeyState _lastKeyPressed; + Common::Event _lastKeyPressed; + Common::EventType _lastEventType; byte _keyboard_nextIndex; byte _keyboard_oldIndex; - Common::KeyState _keyboard_buffer[8]; + Common::Event _keyboard_buffer[8]; byte _byte12A05; byte _byte12A06; byte _byte12A07; @@ -197,7 +198,7 @@ public: byte _rulesBuffer13_1[20]; int16 _interfaceHotspotsX[20]; int16 _interfaceHotspotsY[20]; - byte _rulesBuffer13_4[20]; + byte _keyboardMapping[20]; int16 _array10999PosX[40]; int16 _array109C1PosY[40]; byte _savedSurfaceUnderMouse[16 * 16]; @@ -272,6 +273,7 @@ public: void renderCharacters(byte *buf, Common::Point pos); + void sub147D7(); void sub13156(bool &forceReturnFl); byte sub16799(int index, Common::Point param1); byte getDirection(Common::Point param1, Common::Point param2); @@ -345,7 +347,7 @@ public: int _skipDisplayFlag2; byte _byte16F07_menuId; - byte _byte12FCE; + bool _byte12FCE; int8 _byte129A0; byte _numCharactersToDisplay; byte _byte16C9F; @@ -363,7 +365,7 @@ public: byte *getCharacterVariablesPtr(int16 index); // Temporary stubs - Common::KeyState _keyboard_getch(); + Common::Event _keyboard_getch(); bool _keyboard_checkKeyboard(); void _keyboard_resetKeyboardBuffer(); diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp index 42679b056d..aff323bfb4 100644 --- a/engines/lilliput/script.cpp +++ b/engines/lilliput/script.cpp @@ -2036,7 +2036,7 @@ byte LilliputScript::OC_checkSavedMousePos() { byte LilliputScript::OC_sub179AE() { debugC(1, kDebugScript, "OC_sub179AE()"); - if ((_vm->_byte12FCE == 1) || (_vm->_byte129A0 == -1)) + if (_vm->_byte12FCE || (_vm->_byte129A0 == -1)) return 0; return 1; @@ -2055,11 +2055,13 @@ byte LilliputScript::OC_sub179C2() { byte LilliputScript::OC_checkKeyPressed() { debugC(1, kDebugScript, "OC_checkKeyPressed()"); - static const byte specialKeys[10] = {0x44, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43}; + static const Common::KeyCode specialKeys[10] = { + Common::KEYCODE_F10, Common::KEYCODE_F1, Common::KEYCODE_F2, Common::KEYCODE_F3, Common::KEYCODE_F4, + Common::KEYCODE_F5, Common::KEYCODE_F6, Common::KEYCODE_F7, Common::KEYCODE_F8, Common::KEYCODE_F9}; int8 index = (_currScript->readUint16LE() & 0xFF) - 0x30; - if (specialKeys[index] == _vm->_lastKeyPressed.keycode) + if (specialKeys[index] == _vm->_lastKeyPressed.kbd.keycode) return 1; return 0; @@ -3170,16 +3172,17 @@ void LilliputScript::OC_displayTitleScreen() { _vm->_keyboard_resetKeyboardBuffer(); _vm->_mouseButton = 0; - _vm->_lastKeyPressed = Common::KeyState(); + _vm->_lastKeyPressed = Common::Event(); while (!_vm->_shouldQuit) { _vm->displaySmallAnims(); _vm->update(); _vm->pollEvent(); if (_vm->_keyboard_checkKeyboard()) { - _vm->_lastKeyPressed = _vm->_keyboard_getch(); - // Removed: why asking for 2 keystrikes? - // _vm->_keyboard_getch(); + Common::Event event = _vm->_keyboard_getch(); + _vm->_lastKeyPressed = event; + if (event.type == Common::EVENT_KEYDOWN) + _vm->_keyboard_getch(); break; } |