aboutsummaryrefslogtreecommitdiff
path: root/engines/groovie
diff options
context:
space:
mode:
authorJordi Vilalta Prat2009-03-10 00:19:44 +0000
committerJordi Vilalta Prat2009-03-10 00:19:44 +0000
commit940f19dc232b61092cc60f118053a4ad1551bee4 (patch)
tree3de148a3f6bef90456a1d1550b3413ace26358ad /engines/groovie
parent52b52d3c5e28d46b279f35be37920130a85ca2de (diff)
downloadscummvm-rg350-940f19dc232b61092cc60f118053a4ad1551bee4.tar.gz
scummvm-rg350-940f19dc232b61092cc60f118053a4ad1551bee4.tar.bz2
scummvm-rg350-940f19dc232b61092cc60f118053a4ad1551bee4.zip
Groovie: Initial support for different opcode sets
svn-id: r39282
Diffstat (limited to 'engines/groovie')
-rw-r--r--engines/groovie/groovie.cpp2
-rw-r--r--engines/groovie/groovie.h9
-rw-r--r--engines/groovie/script.cpp107
-rw-r--r--engines/groovie/script.h11
4 files changed, 117 insertions, 12 deletions
diff --git a/engines/groovie/groovie.cpp b/engines/groovie/groovie.cpp
index 8c1fd476f0..6e18b86062 100644
--- a/engines/groovie/groovie.cpp
+++ b/engines/groovie/groovie.cpp
@@ -35,7 +35,7 @@
namespace Groovie {
GroovieEngine::GroovieEngine(OSystem *syst, const GroovieGameDescription *gd) :
- Engine(syst), _gameDescription(gd), _debugger(NULL), _script(this),
+ Engine(syst), _gameDescription(gd), _debugger(NULL), _script(this, gd->version),
_resMan(NULL), _grvCursorMan(NULL), _videoPlayer(NULL), _musicPlayer(NULL),
_graphicsMan(NULL), _waitingForInput(false) {
diff --git a/engines/groovie/groovie.h b/engines/groovie/groovie.h
index 55f1829822..a137193adf 100644
--- a/engines/groovie/groovie.h
+++ b/engines/groovie/groovie.h
@@ -41,7 +41,7 @@ namespace Groovie {
class MusicPlayer;
-enum kDebugLevels {
+enum DebugLevels {
kGroovieDebugAll = 1 << 0,
kGroovieDebugVideo = 1 << 1,
kGroovieDebugResource = 1 << 2,
@@ -56,15 +56,10 @@ enum kDebugLevels {
// the current limitation is 32 debug levels (1 << 31 is the last one)
};
-enum kEngineVersion {
- kGroovieT7G,
- kGroovieV2
-};
-
struct GroovieGameDescription {
ADGameDescription desc;
- kEngineVersion version; // Version of the engine
+ EngineVersion version; // Version of the engine
int indexEntry; // The index of the entry in disk.1 for V2 games
};
diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index 7cc13c5736..14fcfdb786 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -56,10 +56,20 @@ void debugScript(int level, bool nl, const char *s, ...) {
debugN(level, "%s", buf);
}
-Script::Script(GroovieEngine *vm) :
+Script::Script(GroovieEngine *vm, EngineVersion version) :
_code(NULL), _savedCode(NULL), _stacktop(0),
_debugger(NULL), _vm(vm),
_videoFile(NULL), _videoRef(0), _font(NULL) {
+ // Initialize the opcode set depending on the engine version
+ switch (version) {
+ case kGroovieT7G:
+ _opcodes = _opcodesT7G;
+ break;
+ case kGroovieV2:
+ _opcodes = _opcodesV2;
+ break;
+ }
+
// Initialize the random source
_vm->_system->getEventManager()->registerRandomSource(_random, "GroovieScripts");
@@ -1515,7 +1525,7 @@ void Script::o_stub59() {
debugScript(1, true, "STUB59: 0x%04X 0x%02X", val1, val2);
}
-Script::OpcodeFunc Script::_opcodes[NUM_OPCODES] = {
+Script::OpcodeFunc Script::_opcodesT7G[NUM_OPCODES] = {
&Script::o_nop, // 0x00
&Script::o_nop,
&Script::o_playsong,
@@ -1611,4 +1621,97 @@ Script::OpcodeFunc Script::_opcodes[NUM_OPCODES] = {
&Script::o_stub59
};
+Script::OpcodeFunc Script::_opcodesV2[NUM_OPCODES] = {
+ &Script::o_nop, // 0x00
+ &Script::o_nop,
+ &Script::o_playsong,
+ &Script::o_bf9on,
+ &Script::o_palfadeout, // 0x04
+ &Script::o_bf8on,
+ &Script::o_bf6on,
+ &Script::o_bf7on,
+ &Script::o_setbackgroundsong, // 0x08
+ &Script::o_videofromref,
+ &Script::o_bf5on,
+ &Script::o_inputloopstart,
+ &Script::o_keyboardaction, // 0x0C
+ &Script::o_hotspot_rect,
+ &Script::o_hotspot_left,
+ &Script::o_hotspot_right,
+ &Script::o_hotspot_center, // 0x10
+ &Script::o_hotspot_center,
+ &Script::o_hotspot_current,
+ &Script::o_inputloopend,
+ &Script::o_random, // 0x14
+ &Script::o_jmp,
+ &Script::o_loadstring,
+ &Script::o_ret,
+ &Script::o_call, // 0x18
+ &Script::o_sleep,
+ &Script::o_strcmpnejmp,
+ &Script::o_xor_obfuscate,
+ &Script::o_vdxtransition, // 0x1C
+ &Script::o_swap,
+ &Script::o_nop8,
+ &Script::o_inc,
+ &Script::o_dec, // 0x20
+ &Script::o_strcmpnejmp_var,
+ &Script::o_copybgtofg,
+ &Script::o_strcmpeqjmp,
+ &Script::o_mov, // 0x24
+ &Script::o_add,
+ &Script::o_videofromstring1,
+ &Script::o_videofromstring2,
+ &Script::o_nop16, // 0x28
+ &Script::o_stopmidi,
+ &Script::o_endscript,
+ &Script::o_nop,
+ &Script::o_sethotspottop, // 0x2C
+ &Script::o_sethotspotbottom,
+ &Script::o_loadgame,
+ &Script::o_savegame,
+ &Script::o_hotspotbottom_4, // 0x30
+ &Script::o_midivolume,
+ &Script::o_jne,
+ &Script::o_loadstringvar,
+ &Script::o_chargreatjmp, // 0x34
+ &Script::o_bf7off,
+ &Script::o_charlessjmp,
+ &Script::o_copyrecttobg,
+ &Script::o_restorestkpnt, // 0x38
+ &Script::o_obscureswap,
+ &Script::o_printstring,
+ &Script::o_hotspot_slot,
+ &Script::o_checkvalidsaves, // 0x3C
+ &Script::o_resetvars,
+ &Script::o_mod,
+ &Script::o_loadscript,
+ &Script::o_setvideoorigin, // 0x40
+ &Script::o_sub,
+ &Script::o_cellmove,
+ &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_nop16,
+ &Script::o_nop16,
+ &Script::o_nop16, // 0x50
+ &Script::o_nop16,
+ &Script::o_invalid,
+ &Script::o_hotspot_outrect,
+ &Script::o_nop, // 0x54
+ &Script::o_nop16,
+ &Script::o_stub56,
+ &Script::o_invalid,
+ &Script::o_invalid, // 0x58
+ &Script::o_stub59
+};
+
} // End of Groovie namespace
diff --git a/engines/groovie/script.h b/engines/groovie/script.h
index 3df5674ae4..14b0ef88fd 100644
--- a/engines/groovie/script.h
+++ b/engines/groovie/script.h
@@ -34,13 +34,18 @@
namespace Groovie {
+enum EngineVersion {
+ kGroovieT7G,
+ kGroovieV2
+};
+
class GroovieEngine;
class Script {
friend class Debugger;
public:
- Script(GroovieEngine *vm);
+ Script(GroovieEngine *vm, EngineVersion version);
~Script();
void setDebugger(Debugger *debugger);
@@ -132,7 +137,9 @@ private:
// Opcodes
typedef void (Script::*OpcodeFunc)();
- static OpcodeFunc _opcodes[];
+ OpcodeFunc *_opcodes;
+ static OpcodeFunc _opcodesT7G[];
+ static OpcodeFunc _opcodesV2[];
void o_invalid();