diff options
author | Benjamin Haisch | 2008-05-21 10:07:33 +0000 |
---|---|---|
committer | Benjamin Haisch | 2008-05-21 10:07:33 +0000 |
commit | 4074d49844d6851d377374f1d04d43fb9fdad6a8 (patch) | |
tree | 4c8d8e059958223ded9d44a345a4b8ded1c62124 | |
parent | 529800e1728b9d1ce89bf7faf4dfd86d6cb25e5f (diff) | |
download | scummvm-rg350-4074d49844d6851d377374f1d04d43fb9fdad6a8.tar.gz scummvm-rg350-4074d49844d6851d377374f1d04d43fb9fdad6a8.tar.bz2 scummvm-rg350-4074d49844d6851d377374f1d04d43fb9fdad6a8.zip |
- Moved event polling from sfPollEvent to runScript
- LGOP2: Fixed problem where Barth's gun was drawn at the wrong position
svn-id: r32205
-rw-r--r-- | engines/made/made.cpp | 64 | ||||
-rw-r--r-- | engines/made/made.h | 6 | ||||
-rw-r--r-- | engines/made/screen.cpp | 34 | ||||
-rw-r--r-- | engines/made/screen.h | 14 | ||||
-rw-r--r-- | engines/made/script.cpp | 4 | ||||
-rw-r--r-- | engines/made/scriptfuncs.cpp | 67 |
6 files changed, 108 insertions, 81 deletions
diff --git a/engines/made/made.cpp b/engines/made/made.cpp index 76482b03bb..08d00af9f4 100644 --- a/engines/made/made.cpp +++ b/engines/made/made.cpp @@ -171,6 +171,64 @@ Common::String MadeEngine::getSavegameFilename(int16 saveNum) { return filename; } +void MadeEngine::handleEvents() { + + Common::Event event; + Common::EventManager *eventMan = _system->getEventManager(); + + // NOTE: Don't reset _eventNum to 0 here or no events will come through to the scripts. + + while (eventMan->pollEvent(event)) { + switch (event.type) { + + case Common::EVENT_MOUSEMOVE: + _eventMouseX = event.mouse.x; + _eventMouseY = event.mouse.y; + break; + + case Common::EVENT_LBUTTONDOWN: + _eventNum = 1; + break; + + /* + case Common::EVENT_LBUTTONUP: + _eventNum = 2; // TODO: Is this correct? + break; + */ + + case Common::EVENT_RBUTTONDOWN: + _eventNum = 3; + break; + + /* + case Common::EVENT_RBUTTONUP: + eventNum = 4; // TODO: Is this correct? + break; + */ + + case Common::EVENT_KEYDOWN: + _eventKey = event.kbd.ascii; + // For unknown reasons, the game accepts ASCII code + // 9 as backspace + if (_eventKey == Common::KEYCODE_BACKSPACE) + _eventKey = 9; + _eventNum = 5; + break; + + case Common::EVENT_QUIT: + _quit = true; + break; + + default: + break; + + } + } + + _system->updateScreen(); + +} + int MadeEngine::go() { for (int i = 0; i < ARRAYSIZE(_timers); i++) @@ -205,7 +263,11 @@ int MadeEngine::go() { error ("Unknown MADE game"); } - _eventKey = _eventMouseX = _eventMouseY = 0; + // FIXME: This should make things a little faster until proper dirty rectangles + // are implemented. + _system->setFeatureState(OSystem::kFeatureAutoComputeDirtyRects, true); + + _eventNum = _eventKey = _eventMouseX = _eventMouseY = 0; #ifdef DUMP_SCRIPTS _script->dumpAllScripts(); diff --git a/engines/made/made.h b/engines/made/made.h index 5491e8132f..5ee3828557 100644 --- a/engines/made/made.h +++ b/engines/made/made.h @@ -93,7 +93,6 @@ public: uint32 getFeatures() const; uint16 getVersion() const; Common::Platform getPlatform() const; - void update_events(); private: public: @@ -106,6 +105,7 @@ public: bool _quit; + uint16 _eventNum; int _eventMouseX, _eventMouseY; uint16 _eventKey; int _soundRate; @@ -124,7 +124,9 @@ public: const Common::String getTargetName() { return _targetName; } Common::String getSavegameFilename(int16 saveNum); - + + void handleEvents(); + }; } // End of namespace Made diff --git a/engines/made/screen.cpp b/engines/made/screen.cpp index 4802908c05..e85ca71c59 100644 --- a/engines/made/screen.cpp +++ b/engines/made/screen.cpp @@ -266,7 +266,6 @@ uint16 Screen::setChannelLocation(uint16 channelIndex, int16 x, int16 y) { uint16 Screen::setChannelContent(uint16 channelIndex, uint16 index) { if (channelIndex < 1 || channelIndex >= 100 || _channels[channelIndex - 1].type == 0) return 0; - //debug(2, "setChannelContent(%d, %04X)\n", channelIndex, index); fflush(stdout); g_system->delayMillis(5000); _channels[channelIndex - 1].index = index; return updateChannel(channelIndex - 1) + 1; } @@ -277,20 +276,6 @@ void Screen::setChannelUseMask(uint16 channelIndex) { _channels[channelIndex - 1].mask = _mask; } -void Screen::setChannelOffsets(uint16 channelIndex, int16 xofs, int16 yofs) { - if (channelIndex < 1 || channelIndex >= 100) - return; - _channels[channelIndex - 1].xofs = xofs; - _channels[channelIndex - 1].yofs = yofs; -} - -void Screen::getChannelOffsets(uint16 channelIndex, int16 &xofs, int16 &yofs) { - if (channelIndex < 1 || channelIndex >= 100) - return; - xofs = _channels[channelIndex - 1].xofs; - yofs = _channels[channelIndex - 1].yofs; -} - void Screen::drawSpriteChannels(const ClipInfo &clipInfo, int16 includeStateMask, int16 excludeStateMask) { for (int i = 0; i <= 3; i++) @@ -481,8 +466,6 @@ uint16 Screen::placeSprite(uint16 channelIndex, uint16 flexIndex, int16 x, int16 _channels[channelIndex].x2 = x2; _channels[channelIndex].y2 = y2; _channels[channelIndex].area = (x2 - x1) * (y2 - y1); - _channels[channelIndex].xofs = 0; - _channels[channelIndex].yofs = 0; if (_channelsUsedCount <= channelIndex) _channelsUsedCount = channelIndex + 1; @@ -824,4 +807,21 @@ void Screen::updateScreenAndWait(int delay) { _vm->_system->delayMillis(delay); } +int16 Screen::addToSpriteList(int16 index, int16 xofs, int16 yofs) { + SpriteListItem item; + item.index = index; + item.xofs = xofs; + item.yofs = yofs; + _spriteList.push_back(item); + return _spriteList.size(); +} + +SpriteListItem Screen::getFromSpriteList(int16 index) { + return _spriteList[index - 1]; +} + +void Screen::clearSpriteList() { + _spriteList.clear(); +} + } // End of namespace Made diff --git a/engines/made/screen.h b/engines/made/screen.h index 910096cacd..d0df3bf080 100644 --- a/engines/made/screen.h +++ b/engines/made/screen.h @@ -42,7 +42,7 @@ struct SpriteChannel { int16 state; int16 needRefresh; uint16 index; - int16 x, y, xofs, yofs; + int16 x, y; int16 x1, y1, x2, y2; uint32 area; uint16 fontNum; @@ -56,6 +56,10 @@ struct ClipInfo { Graphics::Surface *destSurface; }; +struct SpriteListItem { + int16 index, xofs, yofs; +}; + class MadeEngine; class Screen { @@ -120,8 +124,6 @@ public: uint16 setChannelLocation(uint16 channelIndex, int16 x, int16 y); uint16 setChannelContent(uint16 channelIndex, uint16 index); void setChannelUseMask(uint16 channelIndex); - void setChannelOffsets(uint16 channelIndex, int16 xofs, int16 yofs); - void getChannelOffsets(uint16 channelIndex, int16 &xofs, int16 &yofs); void drawSpriteChannels(const ClipInfo &clipInfo, int16 includeStateMask, int16 excludeStateMask); void updateSprites(); void clearChannels(); @@ -161,6 +163,10 @@ public: void showWorkScreen(); void updateScreenAndWait(int delay); + int16 addToSpriteList(int16 index, int16 xofs, int16 yofs); + SpriteListItem getFromSpriteList(int16 index); + void clearSpriteList(); + protected: MadeEngine *_vm; ScreenEffects *_fx; @@ -194,6 +200,8 @@ protected: uint16 _channelsUsedCount; SpriteChannel _channels[100]; + Common::Array<SpriteListItem> _spriteList; + }; } // End of namespace Made diff --git a/engines/made/script.cpp b/engines/made/script.cpp index e5fdf5a109..4bda35dcc3 100644 --- a/engines/made/script.cpp +++ b/engines/made/script.cpp @@ -196,6 +196,9 @@ void ScriptInterpreter::runScript(int16 scriptObjectIndex) { _codeIp = _codeBase; while (!_vm->_quit) { + + _vm->handleEvents(); + byte opcode = readByte(); if (opcode >= 1 && opcode <= _commandsMax) { debug(4, "[%04X:%04X] %s", _runningScriptObjectIndex, (uint) (_codeIp - _codeBase), _commands[opcode - 1].desc); @@ -203,6 +206,7 @@ void ScriptInterpreter::runScript(int16 scriptObjectIndex) { } else { warning("ScriptInterpreter::runScript(%d) Unknown opcode %02X", _runningScriptObjectIndex, opcode); } + } } diff --git a/engines/made/scriptfuncs.cpp b/engines/made/scriptfuncs.cpp index d627be38d4..f068e2619b 100644 --- a/engines/made/scriptfuncs.cpp +++ b/engines/made/scriptfuncs.cpp @@ -195,61 +195,8 @@ int16 ScriptFunctions::sfShowPage(int16 argc, int16 *argv) { } int16 ScriptFunctions::sfPollEvent(int16 argc, int16 *argv) { - - Common::Event event; - Common::EventManager *eventMan = g_system->getEventManager(); - - int16 eventNum = 0; - - if (eventMan->pollEvent(event)) { - switch (event.type) { - - case Common::EVENT_MOUSEMOVE: - _vm->_eventMouseX = event.mouse.x; - _vm->_eventMouseY = event.mouse.y; - break; - - case Common::EVENT_LBUTTONDOWN: - eventNum = 1; - break; - - /* - case Common::EVENT_LBUTTONUP: - eventNum = 2; // TODO: Is this correct? - break; - */ - - case Common::EVENT_RBUTTONDOWN: - eventNum = 3; - break; - - /* - case Common::EVENT_RBUTTONUP: - eventNum = 4; // TODO: Is this correct? - break; - */ - - case Common::EVENT_KEYDOWN: - _vm->_eventKey = event.kbd.ascii; - // For unknown reasons, the game accepts ASCII code - // 9 as backspace - if (_vm->_eventKey == Common::KEYCODE_BACKSPACE) - _vm->_eventKey = 9; - eventNum = 5; - break; - - case Common::EVENT_QUIT: - _vm->_quit = true; - break; - - default: - break; - - } - } - - _vm->_system->updateScreen(); - + int16 eventNum = _vm->_eventNum; + _vm->_eventNum = 0; return eventNum; } @@ -382,7 +329,7 @@ int16 ScriptFunctions::sfAddSprite(int16 argc, int16 *argv) { // Unused in RTZ return 0; } if (_vm->getGameID() == GID_LGOP2 || _vm->getGameID() == GID_MANHOLE) { - return argv[2]; + return _vm->_screen->addToSpriteList(argv[2], argv[1], argv[0]); } else { return 0; } @@ -390,6 +337,9 @@ int16 ScriptFunctions::sfAddSprite(int16 argc, int16 *argv) { int16 ScriptFunctions::sfFreeAnim(int16 argc, int16 *argv) { _vm->_screen->clearChannels(); + if (_vm->getGameID() == GID_LGOP2 || _vm->getGameID() == GID_MANHOLE) { + _vm->_screen->clearSpriteList(); + } return 0; } @@ -397,8 +347,9 @@ int16 ScriptFunctions::sfDrawSprite(int16 argc, int16 *argv) { if (_vm->getGameID() == GID_RTZ) { return _vm->_screen->drawSprite(argv[2], argv[1], argv[0]); } if (_vm->getGameID() == GID_LGOP2 || _vm->getGameID() == GID_MANHOLE) { - int16 channel = _vm->_screen->drawSprite(argv[2], argv[1], argv[0]); - _vm->_screen->setChannelUseMask(channel); + SpriteListItem item = _vm->_screen->getFromSpriteList(argv[2]); + int16 channelIndex = _vm->_screen->drawSprite(item.index, argv[1] - item.xofs, argv[0] - item.yofs); + _vm->_screen->setChannelUseMask(channelIndex); return 0; } else { return 0; |