diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/toltecs/module.mk | 1 | ||||
-rw-r--r-- | engines/toltecs/saveload.cpp | 17 | ||||
-rw-r--r-- | engines/toltecs/script.cpp | 37 | ||||
-rw-r--r-- | engines/toltecs/toltecs.cpp | 96 | ||||
-rw-r--r-- | engines/toltecs/toltecs.h | 8 |
5 files changed, 127 insertions, 32 deletions
diff --git a/engines/toltecs/module.mk b/engines/toltecs/module.mk index 1f249a8220..541bf6be70 100644 --- a/engines/toltecs/module.mk +++ b/engines/toltecs/module.mk @@ -3,7 +3,6 @@ MODULE := engines/toltecs MODULE_OBJS = \ animation.o \ detection.o \ - input.o \ palette.o \ toltecs.o \ resource.o \ diff --git a/engines/toltecs/saveload.cpp b/engines/toltecs/saveload.cpp index 3da15f4a07..18dd2377e7 100644 --- a/engines/toltecs/saveload.cpp +++ b/engines/toltecs/saveload.cpp @@ -34,7 +34,6 @@ #include "toltecs/toltecs.h" #include "toltecs/animation.h" -#include "toltecs/input.h" #include "toltecs/palette.h" #include "toltecs/resource.h" #include "toltecs/script.h" @@ -80,9 +79,9 @@ void ToltecsEngine::savegame(const char *filename) { out->writeByte(_movieSceneFlag ? 1 : 0); out->writeByte(_flag01); - out->writeUint16LE(_input->_mouseX); - out->writeUint16LE(_input->_mouseY); - out->writeUint16LE(_input->_mouseDisabled); + out->writeUint16LE(_mouseX); + out->writeUint16LE(_mouseY); + out->writeUint16LE(_mouseDisabled); _palette->saveState(out); _script->saveState(out); @@ -140,12 +139,12 @@ void ToltecsEngine::loadgame(const char *filename) { _movieSceneFlag = in->readByte() != 0; _flag01 = in->readByte(); - _input->_mouseX = in->readUint16LE(); - _input->_mouseY = in->readUint16LE(); - _input->_mouseDisabled = in->readUint16LE(); + _mouseX = in->readUint16LE(); + _mouseY = in->readUint16LE(); + _mouseDisabled = in->readUint16LE(); - _system->warpMouse(_input->_mouseX, _input->_mouseY); - _system->showMouse(_input->_mouseDisabled == 0); + _system->warpMouse(_mouseX, _mouseY); + _system->showMouse(_mouseDisabled == 0); _palette->loadState(in); _script->loadState(in); diff --git a/engines/toltecs/script.cpp b/engines/toltecs/script.cpp index 481c8a8bf2..495b981011 100644 --- a/engines/toltecs/script.cpp +++ b/engines/toltecs/script.cpp @@ -36,7 +36,6 @@ #include "toltecs/toltecs.h" #include "toltecs/animation.h" -#include "toltecs/input.h" #include "toltecs/palette.h" #include "toltecs/resource.h" #include "toltecs/script.h" @@ -95,7 +94,7 @@ void ScriptInterpreter::runScript(uint slotIndex) { while (1) { if (_vm->_movieSceneFlag) - _vm->_input->_mouseButton = 0; + _vm->_mouseButton = 0; if (_switchLocalDataNear) { _switchLocalDataNear = false; @@ -459,9 +458,9 @@ void ScriptInterpreter::execKernelOpcode(uint16 kernelOpcode) { return; if (!_vm->_movieSceneFlag) - _vm->_input->update(); + _vm->updateInput(); else - _vm->_input->_mouseButton = 0; + _vm->_mouseButton = 0; // TODO? Check keyb @@ -486,8 +485,8 @@ void ScriptInterpreter::execKernelOpcode(uint16 kernelOpcode) { case 5:// ok { - debug(0, "o2_mouseDeltaStuff(%d)", arg16(3)); - localWrite16(arg16(5), _vm->_input->getMouseDeltaStuff(arg16(3))); + debug(0, "o2_getRandomNumber(%d)", arg16(3)); + localWrite16(arg16(5), _vm->_rnd->getRandomNumber(arg16(3) - 1)); break; } @@ -616,10 +615,10 @@ void ScriptInterpreter::execKernelOpcode(uint16 kernelOpcode) { { debug(0, "o2_findMouseInRectIndex1(offset: %d; slot: %d; elemSize: %d; var: %d; index: %d)", arg16(3), arg16(5), arg16(7), arg16(9), arg16(11)); int16 index = -1; - if (_vm->_input->_mouseY < _vm->_cameraHeight) { + if (_vm->_mouseY < _vm->_cameraHeight) { index = _vm->findRectAtPoint(getSlotData(arg16(5)) + arg16(3), - _vm->_input->_mouseX + _vm->_cameraX, - _vm->_input->_mouseY + _vm->_cameraY, + _vm->_mouseX + _vm->_cameraX, + _vm->_mouseY + _vm->_cameraY, arg16(11) + 1, arg16(7)); } localWrite16(arg16(9), index); @@ -631,7 +630,7 @@ void ScriptInterpreter::execKernelOpcode(uint16 kernelOpcode) { debug(0, "o2_findMouseInRectIndex2(offset: %d, slot: %d, elemSize: %d, var: %d)", arg16(3), arg16(5), arg16(7), arg16(9)); int16 index = -1; - debug(0, "_vm->_input->_mouseDisabled = %d", _vm->_input->_mouseDisabled); + debug(0, "_vm->_mouseDisabled = %d", _vm->_mouseDisabled); /* FIXME: This opcode is called after the Revistronic logo at the beginning, but at the slot/offset there's bytecode and not a rect array as expected. @@ -640,10 +639,10 @@ void ScriptInterpreter::execKernelOpcode(uint16 kernelOpcode) { Needs some more checking. */ if (_vm->_sceneResIndex != 215) { - if (_vm->_input->_mouseY < _vm->_cameraHeight) { + if (_vm->_mouseY < _vm->_cameraHeight) { index = _vm->findRectAtPoint(getSlotData(arg16(5)) + arg16(3), - _vm->_input->_mouseX + _vm->_cameraX, - _vm->_input->_mouseY + _vm->_cameraY, + _vm->_mouseX + _vm->_cameraX, + _vm->_mouseY + _vm->_cameraY, 0, arg16(7)); } } @@ -993,16 +992,16 @@ int16 ScriptInterpreter::getGameVar(uint variable) { switch (variable) { case 0: - value = _vm->_input->_mouseDisabled; + value = _vm->_mouseDisabled; break; case 1: - value = _vm->_input->_mouseY; + value = _vm->_mouseY; break; case 2: - value = _vm->_input->_mouseX; + value = _vm->_mouseX; break; case 3: - value = _vm->_input->_mouseButton; + value = _vm->_mouseButton; break; case 4: value = _vm->_screen->_verbLineY; @@ -1073,11 +1072,11 @@ void ScriptInterpreter::setGameVar(uint variable, int16 value) { switch (variable) { case 0: - _vm->_input->_mouseDisabled = value; + _vm->_mouseDisabled = value; _vm->_system->showMouse(value == 0); break; case 3: - _vm->_input->_mouseButton = value; + _vm->_mouseButton = value; break; case 4: _vm->_screen->_verbLineY = value; diff --git a/engines/toltecs/toltecs.cpp b/engines/toltecs/toltecs.cpp index d4b1a34cca..9aa5ad375c 100644 --- a/engines/toltecs/toltecs.cpp +++ b/engines/toltecs/toltecs.cpp @@ -39,7 +39,6 @@ #include "toltecs/toltecs.h" #include "toltecs/animation.h" -#include "toltecs/input.h" #include "toltecs/palette.h" #include "toltecs/resource.h" #include "toltecs/script.h" @@ -111,6 +110,15 @@ int ToltecsEngine::go() { _walkSpeedY = 5; _walkSpeedX = 1; + _mouseX = 0; + _mouseY = 0; + _mouseCounter = 0; + _mouseButtonPressedFlag = false; + _mouseButton = 0; + _mouseDisabled = 0; + _leftButtonDown = false; + _rightButtonDown = false; + _arc = new ArchiveReader(); _arc->openArchive("WESTERN"); @@ -122,7 +130,6 @@ int ToltecsEngine::go() { _anim = new AnimationPlayer(this); _palette = new Palette(this); _segmap = new SegmentMap(this); - _input = new Input(this); _system->showMouse(true); @@ -140,7 +147,6 @@ int ToltecsEngine::go() { delete _anim; delete _palette; delete _segmap; - delete _input; return 0; } @@ -203,6 +209,90 @@ void ToltecsEngine::updateScreen() { updateCamera(); } +void ToltecsEngine::updateInput() { + + Common::Event event; + Common::EventManager *eventMan = _system->getEventManager(); + while (eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_KEYDOWN: + + // FIXME: This is just for debugging + switch (event.kbd.keycode) { + case Common::KEYCODE_F6: + savegame("toltecs.001"); + break; + case Common::KEYCODE_F9: + loadgame("toltecs.001"); + break; + default: + break; + } + + break; + case Common::EVENT_QUIT: + // FIXME: Find a nicer way to quit + _system->quit(); + break; + case Common::EVENT_MOUSEMOVE: + _mouseX = event.mouse.x; + _mouseY = event.mouse.y; + break; + case Common::EVENT_LBUTTONDOWN: + _mouseX = event.mouse.x; + _mouseY = event.mouse.y; + _leftButtonDown = true; + break; + case Common::EVENT_LBUTTONUP: + _mouseX = event.mouse.x; + _mouseY = event.mouse.y; + _leftButtonDown = false; + break; + case Common::EVENT_RBUTTONDOWN: + _mouseX = event.mouse.x; + _mouseY = event.mouse.y; + _rightButtonDown = true; + break; + case Common::EVENT_RBUTTONUP: + _mouseX = event.mouse.x; + _mouseY = event.mouse.y; + _rightButtonDown = false; + break; + default: + break; + } + } + + if (_mouseDisabled == 0) { + + if (_mouseCounter > 0) + _mouseCounter--; + + byte mouseButtons = 0; + if (_leftButtonDown) + mouseButtons |= 1; + if (_rightButtonDown) + mouseButtons |= 2; + + if (mouseButtons != 0) { + if (!_mouseButtonPressedFlag) { + _mouseButton = mouseButtons; + if (_mouseCounter != 0) + _mouseButton |= 0x80; + _mouseCounter = 30; // maybe TODO + _mouseButtonPressedFlag = true; + } else { + _mouseButton = 0; + } + } else { + _mouseButtonPressedFlag = false; + _mouseButton = 0; + } + + } + +} + void ToltecsEngine::setCamera(int16 x, int16 y) { // TODO font_sub_4B5BB() diff --git a/engines/toltecs/toltecs.h b/engines/toltecs/toltecs.h index 3b5bd67cfa..3b38baff78 100644 --- a/engines/toltecs/toltecs.h +++ b/engines/toltecs/toltecs.h @@ -78,6 +78,7 @@ public: void loadScene(uint resIndex); void updateScreen(); + void updateInput(); void setCamera(int16 x, int16 y); void setGuiHeight(int16 guiHeight); @@ -125,6 +126,13 @@ public: int16 _walkSpeedY, _walkSpeedX; + int16 _mouseX, _mouseY; + int16 _mouseCounter; + bool _mouseButtonPressedFlag; + byte _mouseButton; + int16 _mouseDisabled; + bool _leftButtonDown, _rightButtonDown; + }; } // End of namespace Toltecs |