diff options
Diffstat (limited to 'engines/mohawk/riven_scripts.cpp')
-rw-r--r-- | engines/mohawk/riven_scripts.cpp | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index 30d1d727eb..8d0743340c 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -23,6 +23,7 @@ * */ +#include "mohawk/cursors.h" #include "mohawk/graphics.h" #include "mohawk/riven.h" #include "mohawk/riven_external.h" @@ -157,18 +158,18 @@ void RivenScript::setupOpcodes() { static void printTabs(byte tabs) { for (byte i = 0; i < tabs; i++) - printf ("\t"); + debugN("\t"); } -void RivenScript::dumpScript(Common::StringArray varNames, Common::StringArray xNames, byte tabs) { +void RivenScript::dumpScript(const Common::StringArray &varNames, const Common::StringArray &xNames, byte tabs) { if (_stream->pos() != 0) _stream->seek(0); - printTabs(tabs); printf ("Stream Type %d:\n", _scriptType); + printTabs(tabs); debugN("Stream Type %d:\n", _scriptType); dumpCommands(varNames, xNames, tabs + 1); } -void RivenScript::dumpCommands(Common::StringArray varNames, Common::StringArray xNames, byte tabs) { +void RivenScript::dumpCommands(const Common::StringArray &varNames, const Common::StringArray &xNames, byte tabs) { uint16 commandCount = _stream->readUint16BE(); for (uint16 i = 0; i < commandCount; i++) { @@ -178,50 +179,50 @@ void RivenScript::dumpCommands(Common::StringArray varNames, Common::StringArray if (_stream->readUint16BE() != 2) warning ("if-then-else unknown value is not 2"); uint16 var = _stream->readUint16BE(); - printTabs(tabs); printf("switch (%s) {\n", varNames[var].c_str()); + printTabs(tabs); debugN("switch (%s) {\n", varNames[var].c_str()); uint16 logicBlockCount = _stream->readUint16BE(); for (uint16 j = 0; j < logicBlockCount; j++) { uint16 varCheck = _stream->readUint16BE(); printTabs(tabs + 1); if (varCheck == 0xFFFF) - printf("default:\n"); + debugN("default:\n"); else - printf("case %d:\n", varCheck); + debugN("case %d:\n", varCheck); dumpCommands(varNames, xNames, tabs + 2); - printTabs(tabs + 2); printf("break;\n"); + printTabs(tabs + 2); debugN("break;\n"); } - printTabs(tabs); printf("}\n"); + printTabs(tabs); debugN("}\n"); } else if (command == 7) { // Use the variable name _stream->readUint16BE(); // Skip the opcode var count printTabs(tabs); uint16 var = _stream->readUint16BE(); - printf("%s = %d;\n", varNames[var].c_str(), _stream->readUint16BE()); + debugN("%s = %d;\n", varNames[var].c_str(), _stream->readUint16BE()); } else if (command == 17) { // Use the external command name _stream->readUint16BE(); // Skip the opcode var count printTabs(tabs); - printf("%s(", xNames[_stream->readUint16BE()].c_str()); + debugN("%s(", xNames[_stream->readUint16BE()].c_str()); uint16 varCount = _stream->readUint16BE(); for (uint16 j = 0; j < varCount; j++) { - printf("%d", _stream->readUint16BE()); + debugN("%d", _stream->readUint16BE()); if (j != varCount - 1) - printf(", "); + debugN(", "); } - printf (");\n"); + debugN(");\n"); } else if (command == 24) { // Use the variable name _stream->readUint16BE(); // Skip the opcode var count printTabs(tabs); uint16 var = _stream->readUint16BE(); - printf ("%s += %d;\n", varNames[var].c_str(), _stream->readUint16BE()); + debugN("%s += %d;\n", varNames[var].c_str(), _stream->readUint16BE()); } else { printTabs(tabs); uint16 varCount = _stream->readUint16BE(); - printf("%s(", _opcodes[command].desc); + debugN("%s(", _opcodes[command].desc); for (uint16 j = 0; j < varCount; j++) { - printf("%d", _stream->readUint16BE()); + debugN("%d", _stream->readUint16BE()); if (j != varCount - 1) - printf(", "); + debugN(", "); } - printf(");\n"); + debugN(");\n"); } } } @@ -344,6 +345,11 @@ void RivenScript::playScriptSLST(uint16 op, uint16 argc, uint16 *argv) { // Play the requested sound list _vm->_sound->playSLST(slstRecord); _vm->_activatedSLST = true; + + delete[] slstRecord.sound_ids; + delete[] slstRecord.volumes; + delete[] slstRecord.balances; + delete[] slstRecord.u2; } // Command 4: play local tWAV resource (twav_id, volume, block) @@ -396,7 +402,7 @@ void RivenScript::clearSLST(uint16 op, uint16 argc, uint16 *argv) { // Command 13: set mouse cursor (cursor_id) void RivenScript::changeCursor(uint16 op, uint16 argc, uint16 *argv) { debug(2, "Change to cursor %d", argv[0]); - _vm->_gfx->changeCursor(argv[0]); + _vm->_cursor->setCursor(argv[0]); } // Command 14: pause script execution (delay in ms, u1) @@ -513,14 +519,14 @@ void RivenScript::fadeAmbientSounds(uint16 op, uint16 argc, uint16 *argv) { // Command 38: Play a movie with extra parameters (movie id, delay high, delay low, record type, record id) void RivenScript::complexPlayMovie(uint16 op, uint16 argc, uint16 *argv) { warning("STUB: complexPlayMovie"); - printf ("\tMovie ID = %d\n", argv[0]); - printf ("\tDelay = %d\n", (argv[1] << 16) + argv[2]); + debugN("\tMovie ID = %d\n", argv[0]); + debugN("\tDelay = %d\n", (argv[1] << 16) + argv[2]); if (argv[3] == 0) { - printf ("\tDraw PLST %d\n", argv[4]); + debugN("\tDraw PLST %d\n", argv[4]); } else if (argv[3] == 40) { - printf ("\tPlay SLST %d\n", argv[4]); + debugN("\tPlay SLST %d\n", argv[4]); } else { - error ("Unknown complexPlayMovie record type %d", argv[3]); + error("Unknown complexPlayMovie record type %d", argv[3]); } } @@ -552,7 +558,7 @@ void RivenScript::activateMLSTAndPlay(uint16 op, uint16 argc, uint16 *argv) { // Command 43: activate BLST record (card hotspot enabling lists) void RivenScript::activateBLST(uint16 op, uint16 argc, uint16 *argv) { - Common::SeekableReadStream* blst = _vm->getRawData(ID_BLST, _vm->getCurCard()); + Common::SeekableReadStream* blst = _vm->getResource(ID_BLST, _vm->getCurCard()); uint16 recordCount = blst->readUint16BE(); for (uint16 i = 0; i < recordCount; i++) { @@ -571,7 +577,7 @@ void RivenScript::activateBLST(uint16 op, uint16 argc, uint16 *argv) { // Command 44: activate FLST record (information on which SFXE resource this card should use) void RivenScript::activateFLST(uint16 op, uint16 argc, uint16 *argv) { - Common::SeekableReadStream* flst = _vm->getRawData(ID_FLST, _vm->getCurCard()); + Common::SeekableReadStream* flst = _vm->getResource(ID_FLST, _vm->getCurCard()); uint16 recordCount = flst->readUint16BE(); for (uint16 i = 0; i < recordCount; i++) { |