aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/inter_v4.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/gob/inter_v4.cpp')
-rw-r--r--engines/gob/inter_v4.cpp707
1 files changed, 25 insertions, 682 deletions
diff --git a/engines/gob/inter_v4.cpp b/engines/gob/inter_v4.cpp
index 6ab55d70af..48378a5987 100644
--- a/engines/gob/inter_v4.cpp
+++ b/engines/gob/inter_v4.cpp
@@ -32,689 +32,32 @@
#include "gob/global.h"
#include "gob/draw.h"
#include "gob/game.h"
-#include "gob/parse.h"
+#include "gob/script.h"
#include "gob/videoplayer.h"
#include "gob/sound/sound.h"
namespace Gob {
-#define OPCODE(x) _OPCODE(Inter_v4, x)
-
-const int Inter_v4::_goblinFuncLookUp[][2] = {
- {0, 0},
- {1, 1},
- {2, 2},
- {4, 3},
- {5, 4},
- {6, 5},
- {7, 6},
- {8, 7},
- {9, 8},
- {10, 9},
- {12, 10},
- {13, 11},
- {14, 12},
- {15, 13},
- {16, 14},
- {21, 15},
- {22, 16},
- {23, 17},
- {24, 18},
- {25, 19},
- {26, 20},
- {27, 21},
- {28, 22},
- {29, 23},
- {30, 24},
- {32, 25},
- {33, 26},
- {34, 27},
- {35, 28},
- {36, 29},
- {37, 30},
- {40, 31},
- {41, 32},
- {42, 33},
- {43, 34},
- {44, 35},
- {50, 36},
- {52, 37},
- {53, 38},
- {100, 39},
- {152, 40},
- {200, 41},
- {201, 42},
- {202, 43},
- {203, 44},
- {204, 45},
- {250, 46},
- {251, 47},
- {252, 48},
- {500, 49},
- {502, 50},
- {503, 51},
- {600, 52},
- {601, 53},
- {602, 54},
- {603, 55},
- {604, 56},
- {605, 57},
- {1000, 58},
- {1001, 59},
- {1002, 60},
- {1003, 61},
- {1004, 62},
- {1005, 63},
- {1006, 64},
- {1008, 65},
- {1009, 66},
- {1010, 67},
- {1011, 68},
- {1015, 69},
- {2005, 70}
-};
+#define OPCODEVER Inter_v4
+#define OPCODEDRAW(i, x) _opcodesDraw[i]._OPCODEDRAW(OPCODEVER, x)
+#define OPCODEFUNC(i, x) _opcodesFunc[i]._OPCODEFUNC(OPCODEVER, x)
+#define OPCODEGOB(i, x) _opcodesGob[i]._OPCODEGOB(OPCODEVER, x)
Inter_v4::Inter_v4(GobEngine *vm) : Inter_v3(vm) {
- setupOpcodes();
}
-void Inter_v4::setupOpcodes() {
- static const OpcodeDrawEntryV4 opcodesDraw[256] = {
- /* 00 */
- OPCODE(o1_loadMult),
- OPCODE(o2_playMult),
- OPCODE(o2_freeMultKeys),
- {0, ""},
- /* 04 */
- {0, ""},
- {0, ""},
- {0, ""},
- OPCODE(o1_initCursor),
- /* 08 */
- OPCODE(o1_initCursorAnim),
- OPCODE(o1_clearCursorAnim),
- OPCODE(o2_setRenderFlags),
- {0, ""},
- /* 0C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 10 */
- OPCODE(o1_loadAnim),
- OPCODE(o1_freeAnim),
- OPCODE(o1_updateAnim),
- OPCODE(o2_multSub),
- /* 14 */
- OPCODE(o2_initMult),
- OPCODE(o1_freeMult),
- OPCODE(o1_animate),
- OPCODE(o2_loadMultObject),
- /* 18 */
- OPCODE(o1_getAnimLayerInfo),
- OPCODE(o1_getObjAnimSize),
- OPCODE(o1_loadStatic),
- OPCODE(o1_freeStatic),
- /* 1C */
- OPCODE(o2_renderStatic),
- OPCODE(o2_loadCurLayer),
- {0, ""},
- {0, ""},
- /* 20 */
- OPCODE(o2_playCDTrack),
- OPCODE(o2_waitCDTrackEnd),
- OPCODE(o2_stopCD),
- OPCODE(o2_readLIC),
- /* 24 */
- OPCODE(o2_freeLIC),
- OPCODE(o2_getCDTrackPos),
- {0, ""},
- {0, ""},
- /* 28 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 2C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 30 */
- OPCODE(o2_loadFontToSprite),
- OPCODE(o1_freeFontToSprite),
- {0, ""},
- {0, ""},
- /* 34 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 38 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 3C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 40 */
- OPCODE(o2_totSub),
- OPCODE(o2_switchTotSub),
- OPCODE(o2_pushVars),
- OPCODE(o2_popVars),
- /* 44 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 48 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 4C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 50 */
- OPCODE(o2_loadMapObjects),
- OPCODE(o2_freeGoblins),
- OPCODE(o2_moveGoblin),
- OPCODE(o2_writeGoblinPos),
- /* 54 */
- OPCODE(o2_stopGoblin),
- OPCODE(o2_setGoblinState),
- OPCODE(o2_placeGoblin),
- {0, ""},
- /* 58 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 5C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 60 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 64 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 68 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 6C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 70 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 74 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 78 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 7C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 80 */
- OPCODE(o4_initScreen),
- OPCODE(o2_scroll),
- OPCODE(o2_setScrollOffset),
- OPCODE(o4_playVmdOrMusic),
- /* 84 */
- OPCODE(o2_getImdInfo),
- OPCODE(o2_openItk),
- OPCODE(o2_closeItk),
- OPCODE(o2_setImdFrontSurf),
- /* 88 */
- OPCODE(o2_resetImdFrontSurf),
- {0, ""},
- {0, ""},
- {0, ""},
- /* 8C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 90 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 94 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 98 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 9C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* A0 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* A4 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* A8 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* AC */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* B0 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* B4 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* B8 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* BC */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* C0 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* C4 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* C8 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* CC */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* D0 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* D4 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* D8 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* DC */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* E0 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* E4 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* E8 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* EC */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* F0 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* F4 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* F8 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* FC */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""}
- };
-
- static const OpcodeFuncEntryV4 opcodesFunc[80] = {
- /* 00 */
- OPCODE(o1_callSub),
- OPCODE(o1_callSub),
- OPCODE(o1_printTotText),
- OPCODE(o1_loadCursor),
- /* 04 */
- {0, ""},
- OPCODE(o1_switch),
- OPCODE(o1_repeatUntil),
- OPCODE(o1_whileDo),
- /* 08 */
- OPCODE(o1_if),
- OPCODE(o2_assign),
- OPCODE(o1_loadSpriteToPos),
- {0, ""},
- /* 0C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 10 */
- {0, ""},
- OPCODE(o2_printText),
- OPCODE(o1_loadTot),
- OPCODE(o1_palLoad),
- /* 14 */
- OPCODE(o1_keyFunc),
- OPCODE(o1_capturePush),
- OPCODE(o1_capturePop),
- OPCODE(o2_animPalInit),
- /* 18 */
- OPCODE(o2_addCollision),
- OPCODE(o2_freeCollision),
- OPCODE(o3_getTotTextItemPart),
- {0, ""},
- /* 1C */
- {0, ""},
- {0, ""},
- OPCODE(o1_drawOperations),
- OPCODE(o1_setcmdCount),
- /* 20 */
- OPCODE(o1_return),
- OPCODE(o1_renewTimeInVars),
- OPCODE(o1_speakerOn),
- OPCODE(o1_speakerOff),
- /* 24 */
- OPCODE(o1_putPixel),
- OPCODE(o2_goblinFunc),
- OPCODE(o1_createSprite),
- OPCODE(o1_freeSprite),
- /* 28 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 2C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 30 */
- OPCODE(o1_returnTo),
- OPCODE(o1_loadSpriteContent),
- OPCODE(o1_copySprite),
- OPCODE(o1_fillRect),
- /* 34 */
- OPCODE(o1_drawLine),
- OPCODE(o1_strToLong),
- OPCODE(o1_invalidate),
- OPCODE(o1_setBackDelta),
- /* 38 */
- OPCODE(o1_playSound),
- OPCODE(o2_stopSound),
- OPCODE(o2_loadSound),
- OPCODE(o1_freeSoundSlot),
- /* 3C */
- OPCODE(o1_waitEndPlay),
- OPCODE(o1_playComposition),
- OPCODE(o2_getFreeMem),
- OPCODE(o2_checkData),
- /* 40 */
- {0, ""},
- OPCODE(o1_prepareStr),
- OPCODE(o1_insertStr),
- OPCODE(o1_cutStr),
- /* 44 */
- OPCODE(o1_strstr),
- OPCODE(o1_istrlen),
- OPCODE(o1_setMousePos),
- OPCODE(o1_setFrameRate),
- /* 48 */
- OPCODE(o1_animatePalette),
- OPCODE(o1_animateCursor),
- OPCODE(o1_blitCursor),
- OPCODE(o1_loadFont),
- /* 4C */
- OPCODE(o1_freeFont),
- OPCODE(o2_readData),
- OPCODE(o2_writeData),
- OPCODE(o1_manageDataFile),
- };
-
- static const OpcodeGoblinEntryV4 opcodesGoblin[71] = {
- /* 00 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 04 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 08 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 0C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 10 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 14 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 18 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 1C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 20 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 24 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 28 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 2C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 30 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 34 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 38 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 3C */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 40 */
- {0, ""},
- {0, ""},
- {0, ""},
- {0, ""},
- /* 44 */
- {0, ""},
- {0, ""},
- {0, ""},
- };
-
- _opcodesDrawV4 = opcodesDraw;
- _opcodesFuncV4 = opcodesFunc;
- _opcodesGoblinV4 = opcodesGoblin;
-}
-
-void Inter_v4::executeDrawOpcode(byte i) {
- debugC(1, kDebugDrawOp, "opcodeDraw %d [0x%X] (%s)",
- i, i, getOpcodeDrawDesc(i));
-
- OpcodeDrawProcV4 op = _opcodesDrawV4[i].proc;
-
- if (op == 0)
- warning("unimplemented opcodeDraw: %d", i);
- else
- (this->*op) ();
-}
-
-bool Inter_v4::executeFuncOpcode(byte i, byte j, OpFuncParams &params) {
- debugC(1, kDebugFuncOp, "opcodeFunc %d.%d [0x%X.0x%X] (%s) - %s, %d, %d",
- i, j, i, j, getOpcodeFuncDesc(i, j), _vm->_game->_curTotFile,
- (uint) (_vm->_global->_inter_execPtr - _vm->_game->_totFileData),
- (uint) (_vm->_global->_inter_execPtr - _vm->_game->_totFileData - params.counter - 4));
-
- if ((i > 4) || (j > 15)) {
- warning("unimplemented opcodeFunc: %d.%d", i, j);
- return false;
- }
-
- OpcodeFuncProcV4 op = _opcodesFuncV4[i*16 + j].proc;
-
- if (op == 0)
- warning("unimplemented opcodeFunc: %d.%d", i, j);
- else
- return (this->*op) (params);
+void Inter_v4::setupOpcodesDraw() {
+ Inter_v3::setupOpcodesDraw();
- return false;
+ OPCODEDRAW(0x80, o4_initScreen);
+ OPCODEDRAW(0x83, o4_playVmdOrMusic);
}
-void Inter_v4::executeGoblinOpcode(int i, OpGobParams &params) {
- debugC(1, kDebugGobOp, "opcodeGoblin %d [0x%X] (%s)",
- i, i, getOpcodeGoblinDesc(i));
-
- OpcodeGoblinProcV4 op = 0;
-
- for (int j = 0; j < ARRAYSIZE(_goblinFuncLookUp); j++)
- if (_goblinFuncLookUp[j][0] == i) {
- op = _opcodesGoblinV4[_goblinFuncLookUp[j][1]].proc;
- break;
- }
-
- if (op == 0) {
- warning("unimplemented opcodeGoblin: %d", i);
-
- int16 val;
-
- _vm->_global->_inter_execPtr -= 2;
- val = load16();
- _vm->_global->_inter_execPtr += val << 1;
- } else
- (this->*op) (params);
-}
-
-const char *Inter_v4::getOpcodeDrawDesc(byte i) {
- return _opcodesDrawV4[i].desc;
-}
-
-const char *Inter_v4::getOpcodeFuncDesc(byte i, byte j) {
- if ((i > 4) || (j > 15))
- return "";
-
- return _opcodesFuncV4[i*16 + j].desc;
+void Inter_v4::setupOpcodesFunc() {
+ Inter_v3::setupOpcodesFunc();
}
-const char *Inter_v4::getOpcodeGoblinDesc(int i) {
- for (int j = 0; j < ARRAYSIZE(_goblinFuncLookUp); j++)
- if (_goblinFuncLookUp[j][0] == i)
- return _opcodesGoblinV4[_goblinFuncLookUp[j][1]].desc;
- return "";
+void Inter_v4::setupOpcodesGob() {
}
void Inter_v4::o4_initScreen() {
@@ -722,13 +65,13 @@ void Inter_v4::o4_initScreen() {
int16 videoMode;
int16 width, height;
- offY = load16();
+ offY = _vm->_game->_script->readInt16();
videoMode = offY & 0xFF;
offY = (offY >> 8) & 0xFF;
- width = _vm->_parse->parseValExpr();
- height = _vm->_parse->parseValExpr();
+ width = _vm->_game->_script->readValExpr();
+ height = _vm->_game->_script->readValExpr();
_vm->_video->clearScreen();
@@ -809,8 +152,8 @@ void Inter_v4::o4_playVmdOrMusic() {
uint16 palCmd;
bool close;
- evalExpr(0);
- strncpy0(fileName, _vm->_global->_inter_resStr, 127);
+ _vm->_game->_script->evalExpr(0);
+ strncpy0(fileName, _vm->_game->_script->getResultStr(), 127);
// WORKAROUND: The nut rolling animation in the administration center
// in Woodruff is called "noixroul", but the scripts think it's "noixroule".
@@ -818,14 +161,14 @@ void Inter_v4::o4_playVmdOrMusic() {
(!scumm_stricmp(fileName, "noixroule")))
strcpy(fileName, "noixroul");
- x = _vm->_parse->parseValExpr();
- y = _vm->_parse->parseValExpr();
- startFrame = _vm->_parse->parseValExpr();
- lastFrame = _vm->_parse->parseValExpr();
- breakKey = _vm->_parse->parseValExpr();
- flags = _vm->_parse->parseValExpr();
- palStart = _vm->_parse->parseValExpr();
- palEnd = _vm->_parse->parseValExpr();
+ x = _vm->_game->_script->readValExpr();
+ y = _vm->_game->_script->readValExpr();
+ startFrame = _vm->_game->_script->readValExpr();
+ lastFrame = _vm->_game->_script->readValExpr();
+ breakKey = _vm->_game->_script->readValExpr();
+ flags = _vm->_game->_script->readValExpr();
+ palStart = _vm->_game->_script->readValExpr();
+ palEnd = _vm->_game->_script->readValExpr();
palCmd = 1 << (flags & 0x3F);
debugC(1, kDebugVideo, "Playing video \"%s\" @ %d+%d, frames %d - %d, "