[Scummvm-cvs-logs] CVS: scummvm/gob inter_v1.cpp,NONE,1.1 inter_v2.cpp,NONE,1.1 gob.cpp,1.29,1.30 gob.h,1.13,1.14 inter.cpp,1.28,1.29 inter.h,1.6,1.7 module.mk,1.5,1.6

Eugene Sandulenko sev at users.sourceforge.net
Thu Jan 5 08:08:02 CET 2006


Update of /cvsroot/scummvm/scummvm/gob
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19696

Modified Files:
	gob.cpp gob.h inter.cpp inter.h module.mk 
Added Files:
	inter_v1.cpp inter_v2.cpp 
Log Message:
Slighty modified patch #1397672 "GobEngine script functions splitted"


--- NEW FILE: inter_v1.cpp ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2004 Ivan Dubrov
 * Copyright (C) 2004-2005 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/gob/inter_v1.cpp,v 1.1 2006/01/05 16:06:55 sev Exp $
[...1574 lines suppressed...]
	_vm->_draw->blitInvalidated();
	_vm->_util->waitEndFrame();
	animPalette();
	storeKey(_vm->_game->checkKeys(&_vm->_global->_inter_mouseX,
		&_vm->_global->_inter_mouseY, &_vm->_game->mouseButtons, 0));
	return false;
}

bool Inter_v1::o1_animateCursor(char &cmdCount, int16 &counter, int16 &retFlag) {
	_vm->_draw->animateCursor(1);
	return false;
}

bool Inter_v1::o1_blitCursor(char &cmdCount, int16 &counter, int16 &retFlag) {
	_vm->_draw->blitCursor();
	return false;
}


} // End of namespace Gob

--- NEW FILE: inter_v2.cpp ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2004 Ivan Dubrov
 * Copyright (C) 2004-2005 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/gob/inter_v2.cpp,v 1.1 2006/01/05 16:06:55 sev Exp $
 *
 */
#include "gob/gob.h"
#include "gob/global.h"
#include "gob/inter.h"
#include "gob/util.h"
#include "gob/scenery.h"
#include "gob/parse.h"
#include "gob/game.h"
#include "gob/draw.h"
#include "gob/mult.h"
#include "gob/goblin.h"
#include "gob/cdrom.h"

namespace Gob {

#define OPCODE(x) _OPCODE(Inter_v2, x)

Inter_v2::Inter_v2(GobEngine *vm) : Inter_v1(vm) {
	setupOpcodes();
}

void Inter_v2::setupOpcodes(void) {
	static const OpcodeDrawEntryV2 opcodesDraw[256] = {
		/* 00 */
		OPCODE(o1_loadMult),
		OPCODE(o1_playMult),
		OPCODE(o1_freeMult),
		{NULL, ""},
		/* 04 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		OPCODE(o1_initCursor),
		/* 08 */
		OPCODE(o1_initCursorAnim),
		OPCODE(o1_clearCursorAnim),
		OPCODE(o1_setRenderFlags),
		{NULL, ""},
		/* 0C */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 10 */
		OPCODE(o1_loadAnim),
		OPCODE(o1_freeAnim),
		OPCODE(o1_updateAnim),
		OPCODE(o2_drawStub),
		/* 14 */
		OPCODE(o1_initMult),
		OPCODE(o1_multFreeMult),
		OPCODE(o1_animate),
		OPCODE(o1_multLoadMult),
		/* 18 */
		OPCODE(o1_storeParams),
		OPCODE(o1_getObjAnimSize),
		OPCODE(o1_loadStatic),
		OPCODE(o1_freeStatic),
		/* 1C */
		OPCODE(o1_renderStatic),
		OPCODE(o1_loadCurLayer),
		{NULL, ""},
		{NULL, ""},
		/* 20 */
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		/* 24 */
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		{NULL, ""},
		{NULL, ""},
		/* 28 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 2C */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 30 */
		OPCODE(o1_loadFontToSprite),
		OPCODE(o1_freeFontToSprite),
		{NULL, ""},
		{NULL, ""},
		/* 34 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 38 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 3C */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 40 */
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		/* 44 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 48 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 4C */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 50 */
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		/* 54 */
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		{NULL, ""},
		/* 58 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 5C */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 60 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 64 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 68 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 6C */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 70 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 74 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 78 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 7C */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 80 */
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		/* 84 */
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		OPCODE(o2_drawStub),
		/* 88 */
		OPCODE(o2_drawStub),
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 8C */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 90 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 94 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 98 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 9C */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* A0 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* A4 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* A8 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* AC */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* B0 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* B4 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* B8 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* BC */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* C0 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* C4 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* C8 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* CC */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* D0 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* D4 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* D8 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* DC */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* E0 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* E4 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* E8 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* EC */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* F0 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* F4 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* F8 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* FC */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""}
	};

	static const OpcodeFuncEntryV2 opcodesFunc[80] = {
		/* 00 */
		OPCODE(o1_callSub),
		OPCODE(o1_callSub),
		OPCODE(o1_drawPrintText),
		OPCODE(o1_loadCursor),
		/* 04 */
		{NULL, ""},
		OPCODE(o1_call),
		OPCODE(o1_repeatUntil),
		OPCODE(o1_whileDo),
		/* 08 */
		OPCODE(o1_callBool),
		OPCODE(o1_evaluateStore),
		OPCODE(o1_loadSpriteToPos),
		{NULL, ""},
		/* 0C */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 10 */
		{NULL, ""},
		OPCODE(o1_printText),
		OPCODE(o1_loadTot),
		OPCODE(o1_palLoad),
		/* 14 */
		OPCODE(o1_keyFunc),
		OPCODE(o1_capturePush),
		OPCODE(o1_capturePop),
		OPCODE(o1_animPalInit),
		/* 18 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 1C */
		{NULL, ""},
		{NULL, ""},
		OPCODE(o1_drawOperations),
		OPCODE(o1_setcmdCount),
		/* 20 */
		OPCODE(o1_return),
		OPCODE(o1_renewTimeInVars),
		OPCODE(o1_speakerOn),
		OPCODE(o1_speakerOff),
		/* 24 */
		OPCODE(o1_putPixel),
		OPCODE(o1_func),
		OPCODE(o1_createSprite),
		OPCODE(o1_freeSprite),
		/* 28 */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 2C */
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		{NULL, ""},
		/* 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(o1_stopSound),
		OPCODE(o1_loadSound),
		OPCODE(o1_freeSoundSlot),
		/* 3C */
		OPCODE(o1_waitEndPlay),
		OPCODE(o1_playComposition),
		OPCODE(o1_getFreeMem),
		OPCODE(o1_checkData),
		/* 40 */
		{NULL, ""},
		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(o1_readData),
		OPCODE(o1_writeData),
		OPCODE(o1_manageDataFile),
	};

	_opcodesDrawV2 = opcodesDraw;
	_opcodesFuncV2 = opcodesFunc;
}

void Inter_v2::executeDrawOpcode(byte i) {
	debug(4, "opcodeDraw %d (%s)", i, getOpcodeDrawDesc(i));

	OpcodeDrawProcV2 op = _opcodesDrawV2[i].proc;

	if (op == NULL)
		warning("unimplemented opcodeDraw: %d", i);
	else
		(this->*op) ();
}

bool Inter_v2::executeFuncOpcode(byte i, byte j, char &cmdCount, int16 &counter, int16 &retFlag) {
	debug(4, "opcodeFunc %d (%s)", i, getOpcodeFuncDesc(i, j));

	if ((i > 4) || (j > 15)) {
		warning("unimplemented opcodeFunc: %d.%d", i, j);
		return false;
	}

	OpcodeFuncProcV2 op = _opcodesFuncV2[i*16 + j].proc;

	if (op == NULL)
		warning("unimplemented opcodeFunc: %d.%d", i, j);
	else
		return (this->*op) (cmdCount, counter, retFlag);
	return false;
}

const char *Inter_v2::getOpcodeDrawDesc(byte i) {
	return _opcodesDrawV2[i].desc;
}

const char *Inter_v2::getOpcodeFuncDesc(byte i, byte j)
{
	if ((i > 4) || (j > 15))
		return "";

	return _opcodesFuncV2[i*16 + j].desc;
}


} // End of namespace Gob

Index: gob.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/gob.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- gob.cpp	4 Jan 2006 01:48:14 -0000	1.29
+++ gob.cpp	5 Jan 2006 16:06:53 -0000	1.30
@@ -20,7 +20,6 @@
  */
 #include "common/stdafx.h"
 
-#include "base/gameDetector.h"
 #include "base/plugins.h"
 #include "backends/fs/fs.h"
 #include "common/md5.h"
@@ -50,18 +49,7 @@
 	kMD5FileSizeLimit = 1024 * 1024
 };
 
-struct GobGameSettings {
-	const char *name;
-	const char *description;
-	uint32 features;
-	const char *md5sum;
-	GameSettings toGameSettings() const {
-		GameSettings dummy = { name, description, features };
-		return dummy;
-	}
-};
-
-static const GobGameSettings gob_games[] = {
+static const Gob::GobGameSettings gob_games[] = {
 	// Supplied by Florian Zeitz on scummvm-devel
 	{"gob1", "Gobliiins (DOS EGA)", Gob::GF_GOB1, "82aea70ef26f41fa963dfae270993e49"},
 	{"gob1", "Gobliiins (DOS EGA)", Gob::GF_GOB1, "1f499458837008058b8ba6ae07057214"},
@@ -144,7 +132,7 @@
 
 DetectedGameList Engine_GOB_detectGames(const FSList &fslist) {
 	DetectedGameList detectedGames;
-	const GobGameSettings *g;
+	const Gob::GobGameSettings *g;
 	FSList::const_iterator file;
 
 	// Iterate over all files in the given directory
@@ -186,26 +174,6 @@
 }
 
 Engine *Engine_GOB_create(GameDetector * detector, OSystem *syst) {
-	return new Gob::GobEngine(detector, syst);
-}
-
-REGISTER_PLUGIN(GOB, "Gob Engine")
-
-namespace Gob {
-#define MAX_TIME_DELTA 100
-GobEngine *_vm = NULL;
-
-GobEngine::GobEngine(GameDetector *detector, OSystem * syst) : Engine(syst) {
-	// Setup mixer
-	if (!_mixer->isReady()) {
-		warning("Sound initialization failed.");
-	}
-
-	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
-	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
-
-	_vm = this;
-
 	// Detect game features based on MD5
 	uint8 md5sum[16];
 	char md5str[32 + 1];
@@ -215,20 +183,20 @@
 			sprintf(md5str + j*2, "%02x", (int)md5sum[j]);
 		}
 	} else {
-		error("GobEngine::GobEngine(): Cannot find intro.stk");
+		error("Engine_GOB_create(): Cannot find intro.stk");
 	}
 
-	const GobGameSettings *g;
+	const Gob::GobGameSettings *g;
 	bool found = false;
 
 	// TODO
 	// Fallback. Maybe we will be able to determine game type from game
 	// data contents
-	_features = GF_GOB1;
+	uint32 features = Gob::GF_GOB1;
 
 	for (g = gob_games; g->name; g++) {
 		if (strcmp(g->md5sum, (char *)md5str) == 0) {
-			_features = g->features;
+			features = g->features;
 
 			if (g->description)
 				g_system->setWindowCaption(g->description);
@@ -241,6 +209,27 @@
 	if (!found) {
 		printf("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5str);
 	}
+
+	return new Gob::GobEngine(detector, syst, features);
+}
+
+REGISTER_PLUGIN(GOB, "Gob Engine")
+
+namespace Gob {
+#define MAX_TIME_DELTA 100
+//GobEngine *_vm = NULL;
+
+GobEngine::GobEngine(GameDetector *detector, OSystem * syst, uint32 features)
+ : Engine(syst) {
+	// Setup mixer
+	if (!_mixer->isReady()) {
+		warning("Sound initialization failed.");
+	}
+
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
+	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
+
+	_features = features;
 }
 
 GobEngine::~GobEngine() {
@@ -263,12 +252,23 @@
 	delete _scenery;
 	delete _gtimer;
 	delete _util;
+	delete _inter;
 }
 
 void GobEngine::errorString(const char *buf1, char *buf2) {
 	strcpy(buf2, buf1);
 }
 
+int GobEngine::go() {
+	_init->initGame(0);
+
+	return 0;
+}
+
+void GobEngine::shutdown() {
+	_system->quit();
+}
+
 int GobEngine::init(GameDetector &detector) {
 	_game = new Game(this);
 	_snd = new Snd(this);
@@ -280,7 +280,6 @@
 	_dataio = new DataIO(this);
 	_goblin = new Goblin(this);
 	_init = new Init(this);
-	_inter = new Inter(this);
 	_map = new Map(this);
 	_mult = new Mult(this);
 	_pack = new Pack();
@@ -289,6 +288,12 @@
 	_scenery = new Scenery(this);
 	_gtimer = new GTimer();
 	_util = new Util(this);
+	if (_features & Gob::GF_GOB1)
+		_inter = new Inter_v1(this);
+	else if (_features & Gob::GF_GOB2)
+		_inter = new Inter_v2(this);
+	else
+		error("GobEngine::init(): Unknown version of game engine");
 
 	_system->beginGFXTransaction();
 		initCommonGFX(detector);
@@ -338,14 +343,4 @@
 	return 0;
 }
 
-int GobEngine::go() {
-	_init->initGame(0);
-
-	return 0;
-}
-
-void GobEngine::shutdown() {
-	_system->quit();
-}
-
 } // End of namespace Gob

Index: gob.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/gob.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- gob.h	4 Jan 2006 01:48:14 -0000	1.13
+++ gob.h	5 Jan 2006 16:06:55 -0000	1.14
@@ -28,6 +28,7 @@
 #include "common/config-manager.h"
 
 #include "base/engine.h"
+#include "base/gameDetector.h"
 
 #include "gob/dataio.h"
 #include "gob/video.h"
@@ -70,6 +71,17 @@
 	GF_CD = 1 << 4
 };
 
+typedef struct GobGameSettings {
+	const char *name;
+	const char *description;
+	uint32 features;
+	const char *md5sum;
+	GameSettings toGameSettings() const {
+		GameSettings dummy = { name, description, features };
+		return dummy;
+	}
+} GobGameSettings;
+
 class GobEngine : public Engine {
 	void errorString(const char *buf_input, char *buf_output);
 
@@ -78,7 +90,7 @@
 	int init(GameDetector &detector);
 
 public:
-	GobEngine(GameDetector * detector, OSystem * syst);
+	GobEngine(GameDetector * detector, OSystem * syst, uint32 features);
 	virtual ~GobEngine();
 
 	void shutdown();
@@ -96,7 +108,6 @@
 	DataIO *_dataio;
 	Goblin *_goblin;
 	Init *_init;
-	Inter *_inter;
 	Map *_map;
 	Mult *_mult;
 	Pack *_pack;
@@ -105,9 +116,8 @@
 	Scenery *_scenery;
 	GTimer *_gtimer;
 	Util *_util;
+	Inter *_inter;
 };
 
-extern GobEngine *_vm;
-
 } // End of namespace Gob
 #endif

Index: inter.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/inter.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- inter.cpp	4 Jan 2006 01:48:15 -0000	1.28
+++ inter.cpp	5 Jan 2006 16:06:55 -0000	1.29
@@ -51,13 +51,6 @@
 	return tmp;
 }
 
-void Inter::setMousePos(void) {
-	_vm->_global->_inter_mouseX = _vm->_parse->parseValExpr();
-	_vm->_global->_inter_mouseY = _vm->_parse->parseValExpr();
-	if (_vm->_global->_useMouse != 0)
-		_vm->_util->setMousePos(_vm->_global->_inter_mouseX, _vm->_global->_inter_mouseY);
-}
-
 char Inter::evalExpr(int16 *pRes) {
[...1519 lines suppressed...]
-		}
-	}
+void Inter::renewTimeInVars(void) {
+	struct tm *t;
+	time_t now = time(NULL);
 
-	if ((char *)_vm->_global->_inter_execPtr == _vm->_game->totFileData)
-		_terminate = true;
+	t = localtime(&now);
+
+	WRITE_VAR(5, 1900 + t->tm_year);
+	WRITE_VAR(6, t->tm_mon);
+	WRITE_VAR(7, 0);
+	WRITE_VAR(8, t->tm_mday);
+	WRITE_VAR(9, t->tm_hour);
+	WRITE_VAR(10, t->tm_min);
+	WRITE_VAR(11, t->tm_sec);
 }
 
 } // End of namespace Gob

Index: inter.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/inter.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- inter.h	4 Jan 2006 01:23:20 -0000	1.6
+++ inter.h	5 Jan 2006 16:06:55 -0000	1.7
@@ -24,6 +24,14 @@
 
 namespace Gob {
 
+// This is to help devices with small memory (PDA, smartphones, ...)
+// to save abit of memory used by opcode names in the Scumm engine.
+#ifndef REDUCE_MEMORY_USAGE
+# define _OPCODE(ver, x)  { &ver::x, #x }
+#else
+# define _OPCODE(ver, x)  { &ver::x, "" }
+#endif
+
 class Inter {
 public:
 	int16 _animPalLowIndex;
@@ -40,66 +48,164 @@
 	int16 peek16(char *ptr);
 	int32 peek32(char *ptr);
 
-	void setMousePos(void);
 	char evalExpr(int16 *pRes);
 	char evalBoolResult(void);
-	void storeResult(void);
-	void printText(void);
 	void animPalette(void);
-	void animPalInit(void);
-	void loadMult(void);
-	void playMult(void);
-	void freeMult(void);
-	void initCursor(void);
-	void initCursorAnim(void);
-	void clearCursorAnim(void);
-	void drawOperations(void);
-	void getFreeMem(void);
-	void manageDataFile(void);
-	void writeData(void);
-	void checkData(void);
-	void readData(void);
-	void loadFont(void);
-	void freeFont(void);
-	void prepareStr(void);
-	void insertStr(void);
-	void cutStr(void);
-	void strstr(void);
-	void setFrameRate(void);
-	void istrlen(void);
-	void strToLong(void);
-	void invalidate(void);
-	void loadSpriteContent(void);
-	void copySprite(void);
-	void putPixel(void);
-	void fillRect(void);
-	void drawLine(void);
-	void createSprite(void);
-	void freeSprite(void);
-	void renewTimeInVars(void);
-	void playComposition(void);
-	void stopSound(void);
-	void playSound(void);
-	void loadCursor(void);
-	void loadSpriteToPos(void);
 	void funcBlock(int16 retFlag);
-	void loadTot(void);
 	void storeKey(int16 key);
-	void keyFunc(void);
 	void checkSwitchTable(char **ppExec);
-	void repeatUntil(void);
-	void whileDo(void);
 	void callSub(int16 retFlag);
 	void initControlVars(void);
+	void renewTimeInVars(void);
 
 	Inter(GobEngine *vm);
+	virtual ~Inter() {};
 
 protected:
 	GobEngine *_vm;
 
-	void evaluateStore(void);
-	void capturePush(void);
-	void capturePop(void);
+	virtual void setupOpcodes(void) = 0;
+	virtual void executeDrawOpcode(byte i) = 0;
+	virtual bool executeFuncOpcode(byte i, byte j, char &cmdCount, int16 &counter, int16 &retFlag) = 0;
+	virtual const char *getOpcodeDrawDesc(byte i) = 0;
+	virtual const char *getOpcodeFuncDesc(byte i, byte j) = 0;
+};
+
+class Inter_v1 : public Inter {
+public:
+	Inter_v1(GobEngine *vm);
+	virtual ~Inter_v1() {};
+
+protected:
+	typedef void (Inter_v1::*OpcodeDrawProcV1)(void);
+	typedef bool (Inter_v1::*OpcodeFuncProcV1)(char &, int16 &, int16 &);
+  struct OpcodeDrawEntryV1 {
+		OpcodeDrawProcV1 proc;
+		const char *desc;
+		};
+  struct OpcodeFuncEntryV1 {
+		OpcodeFuncProcV1 proc;
+		const char *desc;
+		};
+	const OpcodeDrawEntryV1 *_opcodesDrawV1;
+	const OpcodeFuncEntryV1 *_opcodesFuncV1;
+
+	virtual void setupOpcodes(void);
+	virtual void executeDrawOpcode(byte i);
+	virtual bool executeFuncOpcode(byte i, byte j, char &cmdCount, int16 &counter, int16 &retFlag);
+	virtual const char *getOpcodeDrawDesc(byte i);
+	virtual const char *getOpcodeFuncDesc(byte i, byte j);
+
+	void o1_loadMult(void);
+	void o1_playMult(void);
+	void o1_freeMult(void);
+	void o1_initCursor(void);
+	void o1_initCursorAnim(void);
+	void o1_clearCursorAnim(void);
+	void o1_setRenderFlags(void);
+	void o1_loadAnim(void);
+	void o1_freeAnim(void);
+	void o1_updateAnim(void);
+	void o1_initMult(void);
+	void o1_multFreeMult(void);
+	void o1_animate(void);
+	void o1_multLoadMult(void);
+	void o1_storeParams(void);
+	void o1_getObjAnimSize(void);
+	void o1_loadStatic(void);
+	void o1_freeStatic(void);
+	void o1_renderStatic(void);
+	void o1_loadCurLayer(void);
+	void o1_playCDTrack(void);
+	void o1_getCDTrackPos(void);
+	void o1_stopCD(void);
+	void o1_loadFontToSprite(void);
+	void o1_freeFontToSprite(void);
+	bool o1_callSub(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_drawPrintText(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_call(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_callBool(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_loadCursor(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_repeatUntil(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_whileDo(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_evaluateStore(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_loadSpriteToPos(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_printText(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_loadTot(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_palLoad(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_keyFunc(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_capturePush(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_capturePop(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_animPalInit(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_drawOperations(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_renewTimeInVars(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_putPixel(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_createSprite(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_freeSprite(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_loadSpriteContent(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_copySprite(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_fillRect(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_drawLine(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_strToLong(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_invalidate(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_playSound(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_stopSound(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_playComposition(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_getFreeMem(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_checkData(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_prepareStr(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_insertStr(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_cutStr(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_strstr(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_istrlen(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_setMousePos(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_setFrameRate(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_loadFont(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_freeFont(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_readData(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_writeData(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_manageDataFile(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_setcmdCount(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_return(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_speakerOn(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_speakerOff(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_func(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_returnTo(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_setBackDelta(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_loadSound(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_freeSoundSlot(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_waitEndPlay(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_animatePalette(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_animateCursor(char &cmdCount, int16 &counter, int16 &retFlag);
+	bool o1_blitCursor(char &cmdCount, int16 &counter, int16 &retFlag);
+};
+
+class Inter_v2 : public Inter_v1 {
+public:
+	Inter_v2(GobEngine *vm);
+	virtual ~Inter_v2() {};
+
+protected:
+	typedef void (Inter_v2::*OpcodeDrawProcV2)(void);
+	typedef bool (Inter_v2::*OpcodeFuncProcV2)(char &, int16 &, int16 &);
+  struct OpcodeDrawEntryV2 {
+		OpcodeDrawProcV2 proc;
+		const char *desc;
+		};
+  struct OpcodeFuncEntryV2 {
+		OpcodeFuncProcV2 proc;
+		const char *desc;
+		};
+	const OpcodeDrawEntryV2 *_opcodesDrawV2;
+	const OpcodeFuncEntryV2 *_opcodesFuncV2;
+
+	virtual void setupOpcodes(void);
+	virtual void executeDrawOpcode(byte i);
+	virtual bool executeFuncOpcode(byte i, byte j, char &cmdCount, int16 &counter, int16 &retFlag);
+	virtual const char *getOpcodeDrawDesc(byte i);
+	virtual const char *getOpcodeFuncDesc(byte i, byte j);
+
+	void o2_drawStub(void) { warning("Gob2 stub"); }
 };
 
 }				// End of namespace Gob

Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/module.mk,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- module.mk	1 Nov 2005 11:18:50 -0000	1.5
+++ module.mk	5 Jan 2006 16:06:55 -0000	1.6
@@ -12,6 +12,8 @@
 	gob/goblin.o \
 	gob/init.o \
 	gob/inter.o \
+	gob/inter_v1.o \
+	gob/inter_v2.o \
 	gob/map.o \
 	gob/mult.o \
 	gob/pack.o \





More information about the Scummvm-git-logs mailing list