diff options
author | Travis Howell | 2003-12-05 00:02:01 +0000 |
---|---|---|
committer | Travis Howell | 2003-12-05 00:02:01 +0000 |
commit | 83bf2e25932ca991af8a190bbd4c6d7a8b410107 (patch) | |
tree | addea610c21786491f60ee258242e821e2dd7646 /scumm | |
parent | 98b5f371430439e9f072adf3b13b6834c21cc658 (diff) | |
download | scummvm-rg350-83bf2e25932ca991af8a190bbd4c6d7a8b410107.tar.gz scummvm-rg350-83bf2e25932ca991af8a190bbd4c6d7a8b410107.tar.bz2 scummvm-rg350-83bf2e25932ca991af8a190bbd4c6d7a8b410107.zip |
Add keyboard support for derby in FT and cannon battle in COMI, patch #853099
svn-id: r11496
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/script_v6.cpp | 109 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 16 | ||||
-rw-r--r-- | scumm/scumm.h | 3 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 23 |
4 files changed, 135 insertions, 16 deletions
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 011bf28045..f4fc51b16f 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -2726,6 +2726,13 @@ void ScummEngine_v6::o6_kernelGetFunctions() { 333 = right */ + // FIXME: I guess this is applicable to all engines, but lets avoid + // regressions + if (_gameId == GID_FT) { + push(getKeyState(args[1])); + return; + } + if ((args[1] == 27) && (_lastKeyHit == 27)) { push(1); // abort @@ -2776,6 +2783,108 @@ void ScummEngine_v6::o6_kernelGetFunctions() { } } +// FIXME: check either some warning will trigger. I am not sure that those +// keys are queried in scripts at all +int ScummEngine::getKeyState(int key) { + switch(key) { + case 0x145: + warning("ScummEngine::getKeyState(%x) 'numlock' is probed", key); + return 0; + break; + case 0x164: + warning("ScummEngine::getKeyState(%x) 'left shift' is probed", key); + return 0; + break; + case 0x165: + warning("ScummEngine::getKeyState(%x) 'right shift' is probed", key); + return 0; + break; + case 0x166: + case 0x167: + warning("ScummEngine::getKeyState(%x) 'alt' is probed", key); + return 0; + break; + case 0x168: + warning("ScummEngine::getKeyState(%x) 'left ctrl' is probed", key); + return 0; + break; + case 0x202a: + warning("ScummEngine::getKeyState(%x) 'gray *' is probed", key); + return 0; + break; + case 0x202d: + warning("ScummEngine::getKeyState(%x) 'gray -' is probed", key); + return 0; + break; + case 0x147: // Home + return (_keyDownMap[0x107] || _keyDownMap[0x115]) ? 1 : 0; + break; + case 0x148: // Up + return (_keyDownMap[0x108] || _keyDownMap[0x111] || + _keyDownMap[0x38]) ? 1 : 0; + break; + case 0x149: // PgUp + return (_keyDownMap[0x109] || _keyDownMap[0x118]) ? 1 : 0; + break; + case 0x14A: // Gray- + return (_keyDownMap[0x10d] || _keyDownMap[0x2d]) ? 1 : 0; + break; + case 0x14B: // Left + return (_keyDownMap[0x104] || _keyDownMap[0x114] || + _keyDownMap[0x34]) ? 1 : 0; + break; + case 0x14C: // 5 + return (_keyDownMap[0x105]) ? 1 : 0; + break; + case 0x14D: // Right + return (_keyDownMap[0x106] || _keyDownMap[0x113] || + _keyDownMap[0x36]) ? 1 : 0; + break; + case 0x14E: // Gray+ + return (_keyDownMap[0x10e] || + (_keyDownMap[0x13d] && _keyDownMap[0x12f])) ? 1 : 0; + break; + case 0x14F: // End + return (_keyDownMap[0x101] || _keyDownMap[0x117]) ? 1 : 0; + break; + case 0x150: // Down + return (_keyDownMap[0x102] || _keyDownMap[0x112] || + _keyDownMap[0x32]) ? 1 : 0; + break; + case 0x151: // PgDn + return (_keyDownMap[0x103] || _keyDownMap[0x119]) ? 1 : 0; + break; + case 0x152: // Ins + return (_keyDownMap[0x100] || _keyDownMap[0x115]) ? 1 : 0; + break; + case 0x153: // Del + return (_keyDownMap[0x10a] || _keyDownMap[0x7f]) ? 1 : 0; + break; + default: + break; + } + + if (key >= 0x13b && key <= 0x144) { // F1-F10 + key -= 0x13b - 0x11a; + } else if (key >= 0x154 && key <= 0x15d) { // Shift+F1-F10 + key -= 0x154 - 0x11a; // map it to just F1-F10 + + warning("ScummEngine::getKeyState(%x) 'Shift-F%d' is probed", key, key-0x153); + } else if (key > 0x8000) { // Alt + key -= 0x8000; + key += 154; // see ScummEngine::parseEvents() + } else if (key > 0x4000) { // Ctrl + key -= 0x4000; + key -= 0x40; + } else if (key > 0x2000) { // Gray keys + key -= 0x2000; + warning("ScummEngine::getKeyState(%x) 'gray key' is probed", key); + } + + return (_keyDownMap[key]) ? 1 : 0; +} + + void ScummEngine_v6::o6_delayFrames() { ScriptSlot *ss = &vm.slot[_currentScript]; if (ss->delayFrameCount == 0) { diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index a0a5242d03..5a45b9f8eb 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -1401,21 +1401,7 @@ void ScummEngine_v8::o8_kernelGetFunctions() { push(checkXYInBoxBounds(args[3], args[1], args[2])); break; case 0xD3: // getKeyState - switch(args[1]) { - // Stub out a few specific cases, just to make things less noisy - - // To actually implement this, we may need a new OSystem call to do - // asyncronous keyboard state checking... - case 0x14B: // Left Arrow depressed? - case 0x14D: // Right Arrow depressed? - case 0x09: // Tab depressed (fire in ship combat) - push(0); - break; - default: - warning("getKeyState(0x%X)", args[1]); - push(0); - break; - } + push(getKeyState(args[1])); break; case 0xCE: // getRGBSlot case 0xD7: // getBox diff --git a/scumm/scumm.h b/scumm/scumm.h index d4d67d8dc2..eee621be66 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -420,6 +420,7 @@ public: protected: int _keyPressed; uint16 _lastKeyHit; + bool _keyDownMap[512]; // FIXME - 512 is a guess. it's max(kbd.ascii) Common::Point _mouse; Common::Point _virtualMouse; @@ -460,6 +461,8 @@ protected: void saveLoadResource(Serializer *ser, int type, int index); void makeSavegameName(char *out, int slot, bool compatible); + int getKeyState(int key); + public: bool getSavegameName(int slot, char *desc, SaveFileManager *mgr); void listSavegames(bool *marks, int num, SaveFileManager *mgr); diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index f6026dd65f..647e479876 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -1099,6 +1099,10 @@ void ScummEngine::scummInit() { _string[i].t_charset = 0; } + // all keys are released + for (i = 0; i < 512; i++) + _keyDownMap[i] = false; + _numInMsgStack = 0; createResource(rtTemp, 6, 500); @@ -1588,13 +1592,30 @@ void ScummEngine::parseEvents() { 327, 328, 329 }; _keyPressed = numpad[event.kbd.ascii - '0']; - } else if (event.kbd.ascii < 273 || event.kbd.ascii > 276) { + } else if (event.kbd.ascii < 273 || event.kbd.ascii > 276 || _gameId == GID_FT) { // don't let game have arrow keys as we currently steal them // for keyboard cursor control // this fixes bug with up arrow (273) corresponding to // "instant win" cheat in MI2 mentioned above + // + // This is not applicable to Full Throttle as it processes keyboard + // cursor control by itself. Also it fixes derby scene _keyPressed = event.kbd.ascii; // Normal key press, pass on to the game. } + + if (_keyPressed >= 512) + warning("_keyPressed > 512 (%d)", _keyPressed); + else + _keyDownMap[_keyPressed] = true; + break; + + case OSystem::EVENT_KEYUP: + // FIXME: for some reason OSystem::KBD_ALT is set sometimes + // possible to a bug in sdl-common.cpp + if (event.kbd.ascii >= 512) + warning("keyPressed > 512 (%d)", event.kbd.ascii); + else + _keyDownMap[event.kbd.ascii] = false; break; case OSystem::EVENT_MOUSEMOVE: |