diff options
-rw-r--r-- | engines/groovie/groovie.cpp | 7 | ||||
-rw-r--r-- | engines/groovie/script.cpp | 98 | ||||
-rw-r--r-- | engines/groovie/script.h | 7 |
3 files changed, 72 insertions, 40 deletions
diff --git a/engines/groovie/groovie.cpp b/engines/groovie/groovie.cpp index c2f13e4f74..039efd2c49 100644 --- a/engines/groovie/groovie.cpp +++ b/engines/groovie/groovie.cpp @@ -218,13 +218,18 @@ Common::Error GroovieEngine::run() { case Common::EVENT_LBUTTONDOWN: // Send the event to the scripts - _script.setMouseClick(); + _script.setMouseClick(1); // Continue the script execution to handle // the click _waitingForInput = false; break; + case Common::EVENT_RBUTTONDOWN: + // Send the event to the scripts (to skip the video) + _script.setMouseClick(2); + break; + case Common::EVENT_QUIT: quitGame(); break; diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp index 934400fb15..6dd1124fce 100644 --- a/engines/groovie/script.cpp +++ b/engines/groovie/script.cpp @@ -101,6 +101,7 @@ Script::Script(GroovieEngine *vm, EngineVersion version) : _hotspotSlot = (uint16)-1; _oldInstruction = (uint16)-1; + _videoSkipAddress = 0; } Script::~Script() { @@ -230,8 +231,8 @@ void Script::step() { (this->*op)(); } -void Script::setMouseClick() { - _eventMouseClicked = true; +void Script::setMouseClick(uint8 button) { + _eventMouseClicked = button; } void Script::setKbdChar(uint8 c) { @@ -525,7 +526,6 @@ void Script::o_videofromref() { // 0x09 bool Script::playvideofromref(uint32 fileref) { // It isn't the current video, open it if (fileref != _videoRef) { - // Debug bitflags debugScript(1, false, "Play video 0x%04X (bitflags:", fileref); for (int i = 15; i >= 0; i--) { @@ -554,6 +554,21 @@ bool Script::playvideofromref(uint32 fileref) { } _bitflags = 0; + + // Reset the clicked mouse events + _eventMouseClicked = 0; + } + + // Check if the user wants to skip the video + if ((_eventMouseClicked == 2) && (_videoSkipAddress != 0)) { + // Jump to the given address + _currentInstruction = _videoSkipAddress; + + // Reset the skip address + _videoSkipAddress = 0; + + // End the playback + return true; } // Video available, play one frame @@ -567,7 +582,7 @@ bool Script::playvideofromref(uint32 fileref) { _videoRef = 0; // Clear the input events while playing the video - _eventMouseClicked = false; + _eventMouseClicked = 0; _eventKbdChar = 0; // Newline @@ -598,8 +613,8 @@ void Script::o_inputloopstart() { //0x0B _inputLoopAddress = _currentInstruction - 1; // Save the current mouse state for the whole loop - _mouseClicked = _eventMouseClicked; - _eventMouseClicked = false; + _mouseClicked = (_eventMouseClicked == 1); + _eventMouseClicked = 0; // Save the current pressed character for the whole loop _kbdChar = _eventKbdChar; @@ -1378,7 +1393,7 @@ void Script::o_sub() { void Script::o_cellmove() { uint16 arg = readScript8bits(); byte *scriptBoard = &_variables[0x19]; - byte *board = (byte*) malloc (BOARDSIZE * BOARDSIZE * sizeof(byte)); + byte *board = (byte *) malloc (BOARDSIZE * BOARDSIZE * sizeof(byte)); byte startX, startY, endX, endY; debugScript(1, true, "CELL MOVE var[0x%02X]", arg); @@ -1396,14 +1411,13 @@ void Script::o_cellmove() { debugScript(1, false, "\n"); } - CellGame staufsMove((byte*) board); - staufsMove.calcMove((byte*) board, CELL_GREEN, 2); + CellGame staufsMove((byte *) board); + staufsMove.calcMove((byte *) board, CELL_GREEN, 2); startX = staufsMove.getStartX(); startY = staufsMove.getStartY(); endX = staufsMove.getEndX(); endY = staufsMove.getEndY(); - // Set the movement origin setVariable(0, startY); // y setVariable(1, startX); // x @@ -1411,7 +1425,7 @@ void Script::o_cellmove() { setVariable(2, endY); setVariable(3, endX); - free (board); + free(board); } void Script::o_returnscript() { @@ -1535,20 +1549,19 @@ void Script::o_stub59() { debugScript(1, true, "STUB59: 0x%04X 0x%02X", val1, val2); } -void Script::o2_playsong(){ +void Script::o2_playsong() { uint32 fileref = readScript32bits(); debugScript(1, true, "PlaySong(0x%08X): Play xmidi file", fileref); _vm->_musicPlayer->playSong(fileref); - } -void Script::o2_setbackgroundsong(){ +void Script::o2_setbackgroundsong() { uint32 fileref = readScript32bits(); debugScript(1, true, "SetBackgroundSong(0x%08X)", fileref); _vm->_musicPlayer->setBackgroundSong(fileref); } -void Script::o2_videofromref(){ +void Script::o2_videofromref() { uint32 fileref = readScript32bits(); // Show the debug information just when starting the playback @@ -1556,6 +1569,7 @@ void Script::o2_videofromref(){ debugScript(1, true, "VIDEOFROMREF(0x%08X) (Not fully imp): Play video file from ref", fileref); debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Playing video 0x%08X via 0x09", fileref); } + // Play the video if (!playvideofromref(fileref)) { // Move _currentInstruction back @@ -1563,7 +1577,7 @@ void Script::o2_videofromref(){ } } -void Script::o2_vdxtransition(){ +void Script::o2_vdxtransition() { uint32 fileref = readScript32bits(); // Show the debug information just when starting the playback @@ -1587,11 +1601,21 @@ void Script::o2_vdxtransition(){ } } -void Script::o2_stub52(){ +void Script::o2_setvideoskip() { + _videoSkipAddress = readScript16bits(); + debugScript(1, true, "SetVideoSkip (0x%04X)", _videoSkipAddress); +} + +void Script::o2_stub52() { uint8 arg = readScript8bits(); debugScript(1, true, "STUB52 (0x%02X)", arg); } +void Script::o2_setscriptend() { + uint16 arg = readScript16bits(); + debugScript(1, true, "SetScriptEnd (0x%04X)", arg); +} + Script::OpcodeFunc Script::_opcodesT7G[NUM_OPCODES] = { &Script::o_nop, // 0x00 &Script::o_nop, @@ -1692,11 +1716,11 @@ Script::OpcodeFunc Script::_opcodesV2[NUM_OPCODES] = { &Script::o_invalid, // 0x00 &Script::o_nop, &Script::o2_playsong, - &Script::o_bf9on, - &Script::o_palfadeout, // 0x04 - &Script::o_bf8on, - &Script::o_bf6on, - &Script::o_bf7on, + &Script::o_nop, + &Script::o_nop, // 0x04 + &Script::o_nop, + &Script::o_nop, + &Script::o_nop, &Script::o2_setbackgroundsong, // 0x08 &Script::o2_videofromref, &Script::o_bf5on, @@ -1719,7 +1743,7 @@ Script::OpcodeFunc Script::_opcodesV2[NUM_OPCODES] = { &Script::o_xor_obfuscate, &Script::o2_vdxtransition, // 0x1C &Script::o_swap, - &Script::o_nop8, + &Script::o_invalid, &Script::o_inc, &Script::o_dec, // 0x20 &Script::o_strcmpnejmp_var, @@ -1729,10 +1753,10 @@ Script::OpcodeFunc Script::_opcodesV2[NUM_OPCODES] = { &Script::o_add, &Script::o_videofromstring1, &Script::o_videofromstring2, - &Script::o_nop16, // 0x28 - &Script::o_stopmidi, - &Script::o_endscript, + &Script::o_invalid, // 0x28 &Script::o_nop, + &Script::o_endscript, + &Script::o_invalid, &Script::o_sethotspottop, // 0x2C &Script::o_sethotspotbottom, &Script::o_loadgame, @@ -1759,22 +1783,22 @@ Script::OpcodeFunc Script::_opcodesV2[NUM_OPCODES] = { &Script::o_returnscript, &Script::o_sethotspotright, // 0x44 &Script::o_sethotspotleft, - &Script::o_nop, - &Script::o_nop, - &Script::o_nop8, // 0x48 - &Script::o_nop, - &Script::o_nop16, - &Script::o_nop8, - &Script::o_getcd, // 0x4C - &Script::o_playcd, + &Script::o_invalid, + &Script::o_invalid, + &Script::o_invalid, // 0x48 + &Script::o_invalid, &Script::o_nop16, + &Script::o_invalid, + &Script::o_invalid, // 0x4C + &Script::o_invalid, + &Script::o_invalid, &Script::o_nop16, &Script::o_nop16, // 0x50 - &Script::o_nop16, + &Script::o2_setvideoskip, &Script::o2_stub52, &Script::o_hotspot_outrect, - &Script::o_nop, // 0x54 - &Script::o_nop16, + &Script::o_invalid, // 0x54 + &Script::o2_setscriptend, &Script::o_stub56, &Script::o_invalid, &Script::o_invalid, // 0x58 diff --git a/engines/groovie/script.h b/engines/groovie/script.h index 664cac82d8..8a95f093ce 100644 --- a/engines/groovie/script.h +++ b/engines/groovie/script.h @@ -57,7 +57,7 @@ public: void directGameLoad(int slot); void step(); - void setMouseClick(); + void setMouseClick(uint8 button); void setKbdChar(uint8 c); Common::String &getContext(); @@ -95,7 +95,7 @@ private: // Input bool _mouseClicked; - bool _eventMouseClicked; + uint8 _eventMouseClicked; uint8 _kbdChar; uint8 _eventKbdChar; uint16 _inputLoopAddress; @@ -114,6 +114,7 @@ private: Common::SeekableReadStream *_videoFile; uint32 _videoRef; uint16 _bitflags; + uint16 _videoSkipAddress; // Debugging Debugger *_debugger; @@ -224,7 +225,9 @@ private: void o2_setbackgroundsong(); void o2_videofromref(); void o2_vdxtransition(); + void o2_setvideoskip(); void o2_stub52(); + void o2_setscriptend(); }; } // End of Groovie namespace |