[Scummvm-cvs-logs] SF.net SVN: scummvm: [22227] scummvm/trunk/engines/scumm

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Apr 29 09:26:01 CEST 2006


Revision: 22227
Author:   fingolfin
Date:     2006-04-29 09:24:39 -0700 (Sat, 29 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22227&view=rev

Log Message:
-----------
* Renamed several methods in favor of a somewhat more uniform naming scheme: setupFOO for stuff that inits static data (i.e. will be called only once, or after loading savegames), vs. resetFOO / updateFOO methods which are called frequently and (re)set dynamic data.
* Doing this, split scummInit into setupScumm and resetScumm methods
* Moved some init code to new methods (huuuuge init methods are hard to read, and hard to customize using subclassing)
* Renmaed various setup???Palette methods to set???Palette
* Some minor cleanup / tweaks

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/actor.cpp
    scummvm/trunk/engines/scumm/cursor.cpp
    scummvm/trunk/engines/scumm/dialogs.cpp
    scummvm/trunk/engines/scumm/he/intern_he.h
    scummvm/trunk/engines/scumm/he/script_v60he.cpp
    scummvm/trunk/engines/scumm/input.cpp
    scummvm/trunk/engines/scumm/intern.h
    scummvm/trunk/engines/scumm/object.cpp
    scummvm/trunk/engines/scumm/palette.cpp
    scummvm/trunk/engines/scumm/room.cpp
    scummvm/trunk/engines/scumm/saveload.cpp
    scummvm/trunk/engines/scumm/script_v5.cpp
    scummvm/trunk/engines/scumm/script_v6.cpp
    scummvm/trunk/engines/scumm/script_v8.cpp
    scummvm/trunk/engines/scumm/scumm.cpp
    scummvm/trunk/engines/scumm/scumm.h
    scummvm/trunk/engines/scumm/vars.cpp
Modified: scummvm/trunk/engines/scumm/actor.cpp
===================================================================
--- scummvm/trunk/engines/scumm/actor.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/actor.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -862,7 +862,7 @@
 	1, 7, 2, 14, 8, 1, 3, 7, 7, 12, 1, 13, 1, 4, 5, 5, 4, 3, 1, 5, 1, 1, 1, 7, 7
 };
 
-void ScummEngine::setupV1ActorTalkColor() {
+void ScummEngine::resetV1ActorTalkColor() {
 	int i;
 
 	for (i = 1; i < _numActors; i++) {

Modified: scummvm/trunk/engines/scumm/cursor.cpp
===================================================================
--- scummvm/trunk/engines/scumm/cursor.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/cursor.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -73,10 +73,6 @@
 	0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x00,0x0F,0x00, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 };
 
-void ScummEngine::setupCursor() {
-	_cursor.animate = 1;
-}
-
 void ScummEngine_v5::animateCursor() {
 	if (_cursor.animate) {
 		if (!(_cursor.animateIndex & 0x1)) {

Modified: scummvm/trunk/engines/scumm/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/scumm/dialogs.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/dialogs.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -748,8 +748,6 @@
 	}
 
 	GUI_OptionsDialog::close();
-
-	_vm->setupVolumes();
 }
 
 void ConfigDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {

Modified: scummvm/trunk/engines/scumm/he/intern_he.h
===================================================================
--- scummvm/trunk/engines/scumm/he/intern_he.h	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/he/intern_he.h	2006-04-29 16:24:39 UTC (rev 22227)
@@ -66,7 +66,7 @@
 	ScummEngine_v60he(OSystem *syst, const DetectorResult &dr);
 	~ScummEngine_v60he();
 
-	virtual void scummInit();
+	virtual void resetScumm();
 
 protected:
 	virtual void setupOpcodes();
@@ -144,7 +144,7 @@
 	virtual const char *getOpcodeDesc(byte i);
 
 	virtual void setupScummVars();
-	virtual void initScummVars();
+	virtual void resetScummVars();
 
 	virtual void saveOrLoad(Serializer *s);
 
@@ -251,7 +251,7 @@
 public:
 	ScummEngine_v72he(OSystem *syst, const DetectorResult &dr);
 
-	virtual void scummInit();
+	virtual void resetScumm();
 
 protected:
 	virtual void setupOpcodes();
@@ -259,7 +259,7 @@
 	virtual const char *getOpcodeDesc(byte i);
 
 	virtual void setupScummVars();
-	virtual void initScummVars();
+	virtual void resetScummVars();
 	virtual void readArrayFromIndexFile();
 
 	virtual byte *getStringAddress(int i);
@@ -368,7 +368,7 @@
 	virtual const char *getOpcodeDesc(byte i);
 
 	virtual void setupScummVars();
-	virtual void initScummVars();
+	virtual void resetScummVars();
 
 	virtual void initCharset(int charset);
 
@@ -436,7 +436,7 @@
 	ScummEngine_v90he(OSystem *syst, const DetectorResult &dr);
 	~ScummEngine_v90he();
 
-	virtual void scummInit();
+	virtual void resetScumm();
 
 	LogicHE *_logicHE;
 	Sprite *_sprite;
@@ -450,7 +450,7 @@
 	virtual void scummLoop_handleDrawing();
 
 	virtual void setupScummVars();
-	virtual void initScummVars();
+	virtual void resetScummVars();
 
 	virtual void saveOrLoad(Serializer *s);
 
@@ -534,10 +534,10 @@
 public:
 	ScummEngine_v99he(OSystem *syst, const DetectorResult &dr) : ScummEngine_v90he(syst, dr) {}
 
-	virtual void scummInit();
+	virtual void resetScumm();
 
 protected:
-	virtual void initScummVars();
+	virtual void resetScummVars();
 
 	virtual void readMAXS(int blockSize);
 

Modified: scummvm/trunk/engines/scumm/he/script_v60he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v60he.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/he/script_v60he.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -548,7 +548,7 @@
 		b = pop();
 		a = pop();
 		if (_game.heversion == 60)
-			setupShadowPalette(a, b, c, d, e, 0, 256);
+			setShadowPalette(a, b, c, d, e, 0, 256);
 		break;
 
 	case 186:		// SO_ROOM_TRANSFORM

Modified: scummvm/trunk/engines/scumm/input.cpp
===================================================================
--- scummvm/trunk/engines/scumm/input.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/input.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -435,7 +435,7 @@
 			vol = Audio::Mixer::kMaxMixerVolume;
 
 		ConfMan.setInt("music_volume", vol);
-		setupVolumes();
+		updateVolumes();
 	} else if (_lastKeyHit == '-' || _lastKeyHit == '+') { // Change text speed
 		if (_lastKeyHit == '+' && _defaultTalkDelay > 0)
 			_defaultTalkDelay--;

Modified: scummvm/trunk/engines/scumm/intern.h
===================================================================
--- scummvm/trunk/engines/scumm/intern.h	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/intern.h	2006-04-29 16:24:39 UTC (rev 22227)
@@ -67,7 +67,7 @@
 	virtual void scummLoop_handleActors();
 
 	virtual void setupScummVars();
-	virtual void initScummVars();
+	virtual void resetScummVars();
 	virtual void decodeParseString();
 
 	virtual void saveOrLoad(Serializer *s);
@@ -206,16 +206,16 @@
 public:
 	ScummEngine_v4(OSystem *syst, const DetectorResult &dr);
 
-	virtual void scummInit();
+	virtual void resetScumm();
 
 protected:
 	virtual void readIndexFile();
 	virtual void loadCharset(int no);
-	virtual void loadRoomObjects();
+	virtual void resetRoomObjects();
 	virtual void readMAXS(int blockSize);
 	virtual void readGlobalObjects();
 
-	virtual void setupRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL);
+	virtual void resetRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL);
 };
 
 /**
@@ -240,9 +240,9 @@
 protected:
 	virtual void readResTypeList(int id, const char *name);
 	virtual void readIndexFile();
-	virtual void loadRoomSubBlocks();
-	virtual void initRoomSubBlocks();
-	virtual void loadRoomObjects();
+	virtual void setupRoomSubBlocks();
+	virtual void resetRoomSubBlocks();
+	virtual void resetRoomObjects();
 };
 
 /**
@@ -270,7 +270,7 @@
 public:
 	ScummEngine_v2(OSystem *syst, const DetectorResult &dr);
 
-	virtual void scummInit();
+	virtual void resetScumm();
 
 	void checkV2MouseOver(Common::Point pos);
 	void checkV2Inventory(int x, int y);
@@ -282,7 +282,7 @@
 	virtual const char *getOpcodeDesc(byte i);
 
 	virtual void setupScummVars();
-	virtual void initScummVars();
+	virtual void resetScummVars();
 	virtual void decodeParseString();
 
 	virtual void readIndexFile();
@@ -416,17 +416,17 @@
 public:
 	ScummEngine_c64(OSystem *syst, const DetectorResult &dr);
 
-	virtual void scummInit();
+	virtual void resetScumm();
 
 protected:
-	virtual void setupRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL);
+	virtual void resetRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL);
 
 	virtual void setupOpcodes();
 	virtual void executeOpcode(byte i);
 	virtual const char *getOpcodeDesc(byte i);
 
 	virtual void setupScummVars();
-	virtual void initScummVars();
+	virtual void resetScummVars();
 	virtual void decodeParseString();
 
 	virtual void saveOrLoad(Serializer *s);
@@ -568,7 +568,7 @@
 public:
 	ScummEngine_v6(OSystem *syst, const DetectorResult &dr);
 
-	virtual void scummInit();
+	virtual void resetScumm();
 
 protected:
 	virtual void setupOpcodes();
@@ -838,7 +838,7 @@
 	virtual void scummLoop_handleDrawing();
 
 	virtual void setupScummVars();
-	virtual void initScummVars();
+	virtual void resetScummVars();
 
 	virtual void akos_processQueue();
 
@@ -890,7 +890,7 @@
 	virtual const char *getOpcodeDesc(byte i);
 
 	virtual void setupScummVars();
-	virtual void initScummVars();
+	virtual void resetScummVars();
 	virtual void decodeParseString(int m, int n);
 	virtual void readArrayFromIndexFile();
 

Modified: scummvm/trunk/engines/scumm/object.cpp
===================================================================
--- scummvm/trunk/engines/scumm/object.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/object.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -543,7 +543,7 @@
 	_numStoredFlObjects = 0;
 }
 
-void ScummEngine::loadRoomObjects() {
+void ScummEngine::resetRoomObjects() {
 	int i, j;
 	ObjectData *od;
 	const byte *ptr;
@@ -611,13 +611,13 @@
 
 	for (i = 1; i < _numLocalObjects; i++) {
 		if (_objs[i].obj_nr && !_objs[i].fl_object_index)
-			setupRoomObject(&_objs[i], room);
+			resetRoomObject(&_objs[i], room);
 	}
 
 	CHECK_HEAP
 }
 
-void ScummEngine_v3old::loadRoomObjects() {
+void ScummEngine_v3old::resetRoomObjects() {
 	int i;
 	ObjectData *od;
 	const byte *room, *ptr;
@@ -648,7 +648,7 @@
 			od->OBIMoffset = READ_LE_UINT16(ptr);
 
 		od->OBCDoffset = READ_LE_UINT16(ptr + 2 * _numObjectsInRoom);
-		setupRoomObject(od, room);
+		resetRoomObject(od, room);
 
 		ptr += 2;
 
@@ -662,7 +662,7 @@
 	CHECK_HEAP
 }
 
-void ScummEngine_v4::loadRoomObjects() {
+void ScummEngine_v4::resetRoomObjects() {
 	int i, j;
 	ObjectData *od;
 	const byte *ptr;
@@ -711,14 +711,14 @@
 
 	for (i = 1; i < _numLocalObjects; i++) {
 		if (_objs[i].obj_nr && !_objs[i].fl_object_index) {
-			setupRoomObject(&_objs[i], room);
+			resetRoomObject(&_objs[i], room);
 		}
 	}
 
 	CHECK_HEAP
 }
 
-void ScummEngine_c64::setupRoomObject(ObjectData *od, const byte *room, const byte *searchptr) {
+void ScummEngine_c64::resetRoomObject(ObjectData *od, const byte *room, const byte *searchptr) {
 	assert(room);
 	const byte *ptr = room + od->OBCDoffset;
 	ptr -= 2;
@@ -742,7 +742,7 @@
 	od->height = *(ptr + 14) & 0xf8;
 }
 
-void ScummEngine_v4::setupRoomObject(ObjectData *od, const byte *room, const byte *searchptr) {
+void ScummEngine_v4::resetRoomObject(ObjectData *od, const byte *room, const byte *searchptr) {
 	assert(room);
 	const byte *ptr = room + od->OBCDoffset;
 
@@ -775,7 +775,7 @@
 	}
 }
 
-void ScummEngine::setupRoomObject(ObjectData *od, const byte *room, const byte *searchptr) {
+void ScummEngine::resetRoomObject(ObjectData *od, const byte *room, const byte *searchptr) {
 	const CodeHeader *cdhd = NULL;
 	const ImageHeader *imhd = NULL;
 
@@ -1784,7 +1784,7 @@
 		res.unlock(rtRoomScripts, room);
 
 	// Setup local object flags
-	setupRoomObject(od, flob, flob);
+	resetRoomObject(od, flob, flob);
 
 	od->fl_object_index = slot;
 }

Modified: scummvm/trunk/engines/scumm/palette.cpp
===================================================================
--- scummvm/trunk/engines/scumm/palette.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/palette.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -31,7 +31,45 @@
 
 namespace Scumm {
 
-void ScummEngine::setupC64Palette() {
+void ScummEngine::resetPalette() {
+	if (_game.version == 1) {
+		if (_game.platform == Common::kPlatformC64) {
+			setC64Palette();
+		} else if (_game.platform == Common::kPlatformNES) {
+			setNESPalette();
+		} else {
+			setV1Palette();
+		}
+	} else if (_game.features & GF_16COLOR) {
+		switch (_renderMode) {
+		case Common::kRenderEGA:
+			setEGAPalette();
+			break;
+
+		case Common::kRenderAmiga:
+			setAmigaPalette();
+			break;
+
+		case Common::kRenderCGA:
+			setCGAPalette();
+			break;
+
+		case Common::kRenderHercA:
+		case Common::kRenderHercG:
+			setHercPalette();
+			break;
+
+		default:
+			if ((_game.platform == Common::kPlatformAmiga) || (_game.platform == Common::kPlatformAtariST))
+				setAmigaPalette();
+			else
+				setEGAPalette();
+		}
+	} else
+		setDirtyColors(0, 255);
+}
+
+void ScummEngine::setC64Palette() {
 	setPalColor( 0, 0x00, 0x00, 0x00);
 	setPalColor( 1, 0xFD, 0xFE, 0xFC);
 	setPalColor( 2, 0xBE, 0x1A, 0x24);
@@ -49,10 +87,13 @@
 	setPalColor(14, 0x5F, 0x53, 0xFE);
 	setPalColor(15, 0xA4, 0xA7, 0xA2);
 
+	// Use 17 color table for v1 games to allow correct color for inventory and
+	// sentence line Original games used some kind of dynamic color table
+	// remapping between rooms.
 	setPalColor(16, 255,  85, 255);
 }
 
-void ScummEngine::setupNESPalette() {
+void ScummEngine::setNESPalette() {
 	setPalColor(0x00,0x24,0x24,0x24); // 0x1D
 	setPalColor(0x01,0x00,0x24,0x92);
 	setPalColor(0x02,0x00,0x00,0xDB);
@@ -122,7 +163,7 @@
 	setPalColor(0x3F,0x00,0x00,0x00);
 }
 
-void ScummEngine::setupAmigaPalette() {
+void ScummEngine::setAmigaPalette() {
 	setPalColor( 0,   0,   0,   0);
 	setPalColor( 1,   0,   0, 187);
 	setPalColor( 2,   0, 187,   0);
@@ -141,7 +182,7 @@
 	setPalColor(15, 255, 255, 255);
 }
 
-void ScummEngine::setupHercPalette() {
+void ScummEngine::setHercPalette() {
 	setPalColor( 0,   0,   0,   0);
 
 	if (_renderMode == Common::kRenderHercA)
@@ -155,7 +196,7 @@
 	setPalColor(15, 255, 255, 255);
 }
 
-void ScummEngine::setupCGAPalette() {
+void ScummEngine::setCGAPalette() {
 	setPalColor( 0,   0,   0,   0);
 	setPalColor( 1,   0, 168, 168);
 	setPalColor( 2, 168,   0, 168);
@@ -167,7 +208,7 @@
 	setPalColor(15, 255, 255, 255);
 }
 
-void ScummEngine::setupEGAPalette() {
+void ScummEngine::setEGAPalette() {
 	setPalColor( 0,   0,   0,   0);
 	setPalColor( 1,   0,   0, 170);
 	setPalColor( 2,   0, 170,   0);
@@ -186,7 +227,7 @@
 	setPalColor(15, 255, 255, 255);
 }
 
-void ScummEngine::setupV1Palette() {
+void ScummEngine::setV1Palette() {
 	setPalColor( 0,   0,   0,   0);
 	setPalColor( 1, 255, 255, 255);
 	setPalColor( 2, 170,   0,   0);
@@ -530,16 +571,16 @@
 	_palManipCounter--;
 }
 
-void ScummEngine::setupShadowPalette(int slot, int redScale, int greenScale, int blueScale, int startColor, int endColor) {
+void ScummEngine::setShadowPalette(int slot, int redScale, int greenScale, int blueScale, int startColor, int endColor) {
 	byte *table;
 	int i;
 	byte *curpal;
 
 	if (slot < 0 || slot >= NUM_SHADOW_PALETTE)
-		error("setupShadowPalette: invalid slot %d", slot);
+		error("setShadowPalette: invalid slot %d", slot);
 
 	if (startColor < 0 || startColor > 255 || endColor < 0 || startColor > 255 || endColor < startColor)
-		error("setupShadowPalette: invalid range from %d to %d", startColor, endColor);
+		error("setShadowPalette: invalid range from %d to %d", startColor, endColor);
 
 	table = _shadowPalette + slot * 256;
 	for (i = 0; i < 256; i++)
@@ -560,7 +601,7 @@
 	return 3 * red * red + 6 * green * green + 2 * blue * blue;
 }
 
-void ScummEngine::setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor, int start, int end) {
+void ScummEngine::setShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor, int start, int end) {
 	const byte *basepal = getPalettePtr(_curPalIndex, _roomResource);
 	const byte *compareptr;
 	const byte *pal = basepal + start * 3;
@@ -569,7 +610,7 @@
 
 	// This is an implementation based on the original games code.
 	//
-	// The four known rooms where setupShadowPalette is used in atlantis are:
+	// The four known rooms where setShadowPalette is used in atlantis are:
 	//
 	// 1) FOA Room 53: subway departing Knossos for Atlantis.
 	// 2) FOA Room 48: subway crashing into the Atlantis entrance area

Modified: scummvm/trunk/engines/scumm/room.cpp
===================================================================
--- scummvm/trunk/engines/scumm/room.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/room.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -143,12 +143,12 @@
 		return;
 	}
 
-	loadRoomSubBlocks();
-	initRoomSubBlocks();
+	setupRoomSubBlocks();
+	resetRoomSubBlocks();
 
 	initBGBuffers(_roomHeight);
 
-	loadRoomObjects();
+	resetRoomObjects();
 	restoreFlObjects();
 
 	if (VAR_ROOM_WIDTH != 0xFF && VAR_ROOM_HEIGHT != 0xFF) {
@@ -225,7 +225,7 @@
  * late on.
  * So it is possible to call this after loading a savegame.
  */
-void ScummEngine::loadRoomSubBlocks() {
+void ScummEngine::setupRoomSubBlocks() {
 	int i;
 	const byte *ptr;
 	byte *roomptr, *searchptr, *roomResPtr = 0;
@@ -449,7 +449,7 @@
  * All of the things setup in here can be modified later on by scripts.
  * So it is not appropriate to call it after loading a savegame.
  */
-void ScummEngine::initRoomSubBlocks() {
+void ScummEngine::resetRoomSubBlocks() {
 	int i;
 	const byte *ptr;
 	byte *roomptr;
@@ -561,7 +561,7 @@
 }
 
 
-void ScummEngine_v3old::loadRoomSubBlocks() {
+void ScummEngine_v3old::setupRoomSubBlocks() {
 	const byte *ptr;
 	byte *roomptr, *searchptr = 0;
 	const RoomHeader *rmhd;
@@ -697,7 +697,7 @@
 	gdi.roomChanged(roomptr, _IM00_offs, 255);
 }
 
-void ScummEngine_v3old::initRoomSubBlocks() {
+void ScummEngine_v3old::resetRoomSubBlocks() {
 	int i;
 	const byte *ptr;
 	byte *roomptr;

Modified: scummvm/trunk/engines/scumm/saveload.cpp
===================================================================
--- scummvm/trunk/engines/scumm/saveload.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/saveload.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -257,7 +257,7 @@
 				res.nukeResource(i, j);
 			}
 
-	initScummVars();
+	resetScummVars();
 
 	if (_game.features & GF_OLD_BUNDLE)
 		loadCharset(0); // FIXME - HACK ?
@@ -270,7 +270,7 @@
 	delete in;
 
 	// Update volume settings
-	setupVolumes();
+	updateVolumes();
 
 	// Init NES costume data
 	if (_game.platform == Common::kPlatformNES) {
@@ -331,53 +331,14 @@
 		}
 	}
 
-	// We could simply dirty colours 0-15 for 16-colour games -- nowadays
-	// they handle their palette pretty much like the more recent games
-	// anyway. There was a time, though, when re-initializing was necessary
-	// for backwards compatibility, and it may still prove useful if we
-	// ever add options for using different 16-colour palettes.
-	if (_game.version == 1) {
-		if (_game.platform == Common::kPlatformC64) {
-			setupC64Palette();
-		} else if (_game.platform == Common::kPlatformNES) {
-			setupNESPalette();
-		} else {
-			setupV1Palette();
-		}
-	} else if (_game.features & GF_16COLOR) {
-		switch (_renderMode) {
-		case Common::kRenderEGA:
-			setupEGAPalette();
-			break;
+	// Reset the palette.
+	resetPalette();
 
-		case Common::kRenderAmiga:
-			setupAmigaPalette();
-			break;
-
-		case Common::kRenderCGA:
-			setupCGAPalette();
-			break;
-
-		case Common::kRenderHercA:
-		case Common::kRenderHercG:
-			setupHercPalette();
-			break;
-
-		default:
-			if ((_game.platform == Common::kPlatformAmiga) || (_game.platform == Common::kPlatformAtariST))
-				setupAmigaPalette();
-			else
-				setupEGAPalette();
-		}
-	} else
-		setDirtyColors(0, 255);
-
-
 	if (hdr.ver < VER(35) && _game.id == GID_MANIAC && _game.version == 1)
-		setupV1ActorTalkColor();
+		resetV1ActorTalkColor();
 
 	// Load the static room data
-	loadRoomSubBlocks();
+	setupRoomSubBlocks();
 
 	if (!(_game.features & GF_NEW_CAMERA)) {
 		camera._last.x = camera._cur.x;

Modified: scummvm/trunk/engines/scumm/script_v5.cpp
===================================================================
--- scummvm/trunk/engines/scumm/script_v5.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/script_v5.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -1946,7 +1946,7 @@
 		_opcode = fetchScriptByte();
 		d = getVarOrDirectByte(PARAM_1);
 		e = getVarOrDirectByte(PARAM_2);
-		setupShadowPalette(a, b, c, d, e, 0, 256);
+		setShadowPalette(a, b, c, d, e, 0, 256);
 		break;
 
 	case 13:	// SO_SAVE_STRING

Modified: scummvm/trunk/engines/scumm/script_v6.cpp
===================================================================
--- scummvm/trunk/engines/scumm/script_v6.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/script_v6.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -1727,7 +1727,7 @@
 		c = pop();
 		b = pop();
 		a = pop();
-		setupShadowPalette(a, b, c, d, e, 0, 256);
+		setShadowPalette(a, b, c, d, e, 0, 256);
 		break;
 
 	case 184:		// SO_SAVE_STRING
@@ -2571,10 +2571,10 @@
 			a->setScale((unsigned char)args[2], -1);
 			break;
 		case 108:
-			setupShadowPalette(args[1], args[2], args[3], args[4], args[5], args[6]);
+			setShadowPalette(args[1], args[2], args[3], args[4], args[5], args[6]);
 			break;
 		case 109:
-			setupShadowPalette(0, args[1], args[2], args[3], args[4], args[5]);
+			setShadowPalette(0, args[1], args[2], args[3], args[4], args[5]);
 			break;
 		case 114:
 			error("o6_kernelSetFunctions: stub114()");
@@ -2634,7 +2634,7 @@
 			// Case 108 and 109 share the same function
 			if (num != 6)
 				error("o6_kernelSetFunctions sub op %d: expected 6 params but got %d", args[0], num);
-			setupShadowPalette(args[3], args[4], args[5], args[1], args[2], 0, 256);
+			setShadowPalette(args[3], args[4], args[5], args[1], args[2], 0, 256);
 			break;
 		case 110:
 			_charset->clearCharsetMask();
@@ -2644,7 +2644,7 @@
 			a->_shadowMode = args[2] + args[3];
 			break;
 		case 112:									/* palette shift? */
-			setupShadowPalette(args[3], args[4], args[5], args[1], args[2], args[6], args[7]);
+			setShadowPalette(args[3], args[4], args[5], args[1], args[2], args[6], args[7]);
 			break;
 		case 114:
 			// Sam & Max film noir mode

Modified: scummvm/trunk/engines/scumm/script_v8.cpp
===================================================================
--- scummvm/trunk/engines/scumm/script_v8.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/script_v8.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -1292,10 +1292,10 @@
 			_quit = true;
 		break;
 	case 108:	// buildPaletteShadow
-		setupShadowPalette(args[1], args[2], args[3], args[4], args[5], args[6]);
+		setShadowPalette(args[1], args[2], args[3], args[4], args[5], args[6]);
 		break;
 	case 109:	// setPaletteShadow
-		setupShadowPalette(0, args[1], args[2], args[3], args[4], args[5]);
+		setShadowPalette(0, args[1], args[2], args[3], args[4], args[5]);
 		break;
 	case 118:	// blastShadowObject
 		enqueueObject(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], 3);

Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/scumm.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -955,6 +955,25 @@
 		initCommonGFX(defaultTo1XScaler);
 	_system->endGFXTransaction();
 
+	setupScumm();
+
+	readIndexFile();
+
+	resetScumm();
+	resetScummVars();
+
+	if (_imuse) {
+		_imuse->setBase(res.address[rtSound]);
+	}
+
+	if (_game.version >= 5)
+		_sound->setupSound();
+
+	return 0;
+}
+
+
+void ScummEngine::setupScumm() {
 	// On some systems it's not safe to run CD audio games from the CD.
 	if (_game.features & GF_AUDIOTRACKS) {
 		checkCD();
@@ -980,33 +999,10 @@
 	loadCJKFont();
 
 	// Create the charset renderer
-	if (_game.platform == Common::kPlatformNES)
-		_charset = new CharsetRendererNES(this);
-	else if (_game.version <= 2)
-		_charset = new CharsetRendererV2(this, _language);
-	else if (_game.version == 3)
-		_charset = new CharsetRendererV3(this);
-#ifndef DISABLE_SCUMM_7_8
-	else if (_game.version == 8)
-		_charset = new CharsetRendererNut(this);
-#endif
-	else
-		_charset = new CharsetRendererClassic(this);
+	setupCharsetRenderer();
 
 	// Create the costume renderer
-	if (_game.features & GF_NEW_COSTUMES) {
-		_costumeRenderer = new AkosRenderer(this);
-		_costumeLoader = new AkosCostumeLoader(this);
-	} else if (_game.platform == Common::kPlatformC64 && _game.id == GID_MANIAC) {
-		_costumeRenderer = new C64CostumeRenderer(this);
-		_costumeLoader = new C64CostumeLoader(this);
-	} else if (_game.platform == Common::kPlatformNES) {
-		_costumeRenderer = new NESCostumeRenderer(this);
-		_costumeLoader = new NESCostumeLoader(this);
-	} else {
-		_costumeRenderer = new ClassicCostumeRenderer(this);
-		_costumeLoader = new ClassicCostumeLoader(this);
-	}
+	setupCostumeRenderer();
 
 #ifndef DISABLE_SCUMM_7_8
 	// Create FT INSANE object
@@ -1058,8 +1054,6 @@
 		_bootParam = -1;
 	}
 
-	readIndexFile();
-
 #ifdef PALMOS_68K
 	if (_game.features & GF_NEW_COSTUMES)
 		res._maxHeapThreshold = gVars->memory[kMemScummNewCostGames];
@@ -1076,16 +1070,6 @@
 #endif
 	res._minHeapThreshold = 400000;
 
-	scummInit();
-	initScummVars();
-
-	if (_imuse) {
-		_imuse->setBase(res.address[rtSound]);
-	}
-
-	if (_game.version >= 5)
-		_sound->setupSound();
-
 #if (defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
 	Graphics::initfonts();
 #endif
@@ -1093,15 +1077,44 @@
 	// Create debugger
 	if (!_debugger)
 		_debugger = new ScummDebugger(this);
+}
 
-	return 0;
+void ScummEngine::setupCharsetRenderer() {
+	if (_game.platform == Common::kPlatformNES)
+		_charset = new CharsetRendererNES(this);
+	else if (_game.version <= 2)
+		_charset = new CharsetRendererV2(this, _language);
+	else if (_game.version == 3)
+		_charset = new CharsetRendererV3(this);
+#ifndef DISABLE_SCUMM_7_8
+	else if (_game.version == 8)
+		_charset = new CharsetRendererNut(this);
+#endif
+	else
+		_charset = new CharsetRendererClassic(this);
 }
 
-void ScummEngine::scummInit() {
+void ScummEngine::setupCostumeRenderer() {
+	if (_game.features & GF_NEW_COSTUMES) {
+		_costumeRenderer = new AkosRenderer(this);
+		_costumeLoader = new AkosCostumeLoader(this);
+	} else if (_game.platform == Common::kPlatformC64 && _game.id == GID_MANIAC) {
+		_costumeRenderer = new C64CostumeRenderer(this);
+		_costumeLoader = new C64CostumeLoader(this);
+	} else if (_game.platform == Common::kPlatformNES) {
+		_costumeRenderer = new NESCostumeRenderer(this);
+		_costumeLoader = new NESCostumeLoader(this);
+	} else {
+		_costumeRenderer = new ClassicCostumeRenderer(this);
+		_costumeLoader = new ClassicCostumeLoader(this);
+	}
+}
+
+void ScummEngine::resetScumm() {
 	int i;
 
 	_tempMusic = 0;
-	debug(9, "scummInit");
+	debug(9, "resetScumm");
 
 	if ((_game.id == GID_MANIAC) && (_game.version == 1) && !(_game.platform == Common::kPlatformNES)) {
 		if (_game.platform == Common::kPlatformC64)
@@ -1118,47 +1131,12 @@
 
 	for (i = 0; i < 256; i++)
 		_roomPalette[i] = i;
+
+	resetPalette();
 	if (_game.version == 1) {
-		// Use 17 color table for v1 games to allow
-		// correct color for inventory and sentence
-		// line
-		// Original games used some kind of dynamic
-		// color table remapping between rooms
-		if (_game.platform == Common::kPlatformC64) {
-			setupC64Palette();
-		} else if (_game.platform == Common::kPlatformNES) {
-			setupNESPalette();
-		} else {
-			setupV1Palette();
-		}
 	} else if (_game.features & GF_16COLOR) {
 		for (i = 0; i < 16; i++)
 			_shadowPalette[i] = i;
-
-		switch (_renderMode) {
-		case Common::kRenderEGA:
-			setupEGAPalette();
-			break;
-
-		case Common::kRenderAmiga:
-			setupAmigaPalette();
-			break;
-
-		case Common::kRenderCGA:
-			setupCGAPalette();
-			break;
-
-		case Common::kRenderHercA:
-		case Common::kRenderHercG:
-			setupHercPalette();
-			break;
-
-		default:
-			if ((_game.platform == Common::kPlatformAmiga) || (_game.platform == Common::kPlatformAtariST))
-				setupAmigaPalette();
-			else
-				setupEGAPalette();
-		}
 	}
 
 	if (_game.version >= 4 && _game.version <= 7)
@@ -1168,7 +1146,7 @@
 		loadCharset(0);
 
 	setShake(0);
-	setupCursor();
+	_cursor.animate = 1;
 
 	// Allocate and Initialize actors
 	Actor::initActorClass(this);
@@ -1184,7 +1162,7 @@
 	}
 
 	if (_game.id == GID_MANIAC && _game.version == 1) {
-		setupV1ActorTalkColor();
+		resetV1ActorTalkColor();
 	} else if (_game.id == GID_MANIAC && _game.version == 2 && (_game.features & GF_DEMO)) {
 		// HACK Some palette changes needed for demo script
 		// in Maniac Mansion (Enhanced)
@@ -1293,13 +1271,13 @@
 	_lastSaveTime = _system->getMillis();
 }
 
-void ScummEngine_c64::scummInit() {
-	ScummEngine_v2::scummInit();
+void ScummEngine_c64::resetScumm() {
+	ScummEngine_v2::resetScumm();
 	initC64Verbs();
 }
 
-void ScummEngine_v2::scummInit() {
-	ScummEngine::scummInit();
+void ScummEngine_v2::resetScumm() {
+	ScummEngine::resetScumm();
 
 	if (_game.platform == Common::kPlatformNES) {
 		initNESMouseOver();
@@ -1315,8 +1293,8 @@
 	_inventoryOffset = 0;
 }
 
-void ScummEngine_v4::scummInit() {
-	ScummEngine::scummInit();
+void ScummEngine_v4::resetScumm() {
+	ScummEngine::resetScumm();
 
 	// WORKAROUND for bug in boot script of Loom (CD)
 	// The boot script sets the characters of string 21, 
@@ -1326,13 +1304,13 @@
 	}
 }
 
-void ScummEngine_v6::scummInit() {
-	ScummEngine::scummInit();
+void ScummEngine_v6::resetScumm() {
+	ScummEngine::resetScumm();
 	setDefaultCursor();
 }
 
-void ScummEngine_v60he::scummInit() {
-	ScummEngine_v6::scummInit();
+void ScummEngine_v60he::resetScumm() {
+	ScummEngine_v6::resetScumm();
 
 	// HACK cursor hotspot is wrong
 	// Original games used
@@ -1342,15 +1320,15 @@
 }
 
 #ifndef DISABLE_HE
-void ScummEngine_v72he::scummInit() {
-	ScummEngine_v60he::scummInit();
+void ScummEngine_v72he::resetScumm() {
+	ScummEngine_v60he::resetScumm();
 
 	_stringLength = 1;
 	memset(_stringBuffer, 0, sizeof(_stringBuffer));
 }
 
-void ScummEngine_v90he::scummInit() {
-	ScummEngine_v72he::scummInit();
+void ScummEngine_v90he::resetScumm() {
+	ScummEngine_v72he::resetScumm();
 
 	_heObject = 0;
 	_heObjectNum = 0;
@@ -1384,8 +1362,8 @@
 	}
 }
 
-void ScummEngine_v99he::scummInit() {
-	ScummEngine_v90he::scummInit();
+void ScummEngine_v99he::resetScumm() {
+	ScummEngine_v90he::resetScumm();
 
 	_hePalettes = (uint8 *)malloc((_numPalettes + 1) * 1024);
 	memset(_hePalettes, 0, (_numPalettes + 1) * 1024);
@@ -1493,10 +1471,10 @@
 		}
 	}
 
-	setupVolumes();
+	updateVolumes();
 }
 
-void ScummEngine::setupVolumes() {
+void ScummEngine::updateVolumes() {
 
 	// Sync the engine with the config manager
 	int soundVolumeMusic = ConfMan.getInt("music_volume");
@@ -2006,8 +1984,8 @@
 	readIndexFile();
 
 	// Reinit scumm variables
-	scummInit();
-	initScummVars();
+	resetScumm();
+	resetScummVars();
 
 	if (_imuse) {
 		_imuse->setBase(res.address[rtSound]);
@@ -2078,6 +2056,7 @@
 	if (!_mainMenuDialog)
 		_mainMenuDialog = new MainMenuDialog(this);
 	runDialog(*_mainMenuDialog);
+	updateVolumes();
 }
 
 void ScummEngine::confirmExitDialog() {

Modified: scummvm/trunk/engines/scumm/scumm.h
===================================================================
--- scummvm/trunk/engines/scumm/scumm.h	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/scumm.h	2006-04-29 16:24:39 UTC (rev 22227)
@@ -457,17 +457,19 @@
 	int init();
 
 protected:
+	virtual void setupScumm();
+	virtual void resetScumm();
+
 	virtual void setupScummVars();
-	virtual void initScummVars();
+	virtual void resetScummVars();
 
-	virtual void scummInit();
+	void setupCharsetRenderer();
+	void setupCostumeRenderer();
 
+	virtual void loadLanguageBundle() {}
 	void loadCJKFont();
 	void setupMusic(int midi);
-public:
-	// The following is called by ConfigDialog::close
-	// TODO: Simply move that call to ScummEngine::mainMenuDialog to fix this
-	void setupVolumes();
+	void updateVolumes();
 
 protected:
 	// Scumm main loop & helper functions.
@@ -786,13 +788,17 @@
 	void convertADResource(int type, int index, byte *ptr, int size);
 	int readSoundResourceSmallHeader(int type, int index);
 	bool isResourceInUse(int type, int i) const;
-	virtual void loadRoomSubBlocks();
-	virtual void initRoomSubBlocks();
-	void clearRoomObjects();
+
+	virtual void setupRoomSubBlocks();
+	virtual void resetRoomSubBlocks();
+
 	void storeFlObject(int slot);
 	void restoreFlObjects();
-	virtual void loadRoomObjects();
 
+	void clearRoomObjects();
+	virtual void resetRoomObjects();
+	virtual void resetRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL);
+
 	virtual void readArrayFromIndexFile();
 	virtual void readMAXS(int blockSize) = 0;
 	virtual void readGlobalObjects();
@@ -823,7 +829,6 @@
 	uint32 *_classData;
 
 protected:
-	virtual void setupRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL);
 	void markObjectRectAsDirty(int obj);
 	void loadFlObject(uint object, uint room);
 	void nukeFlObjects(int min, int max);
@@ -917,7 +922,7 @@
 	void setActorRedrawFlags();
 	void putActors();
 	void showActors();
-	void setupV1ActorTalkColor();
+	void resetV1ActorTalkColor();
 	void resetActorBgs();
 	virtual void processActors();
 	void processUpperActors();
@@ -1030,13 +1035,17 @@
 	void actorFollowCamera(int act);
 
 	const byte *getPalettePtr(int palindex, int room);
-	void setupC64Palette();
-	void setupNESPalette();
-	void setupAmigaPalette();
-	void setupHercPalette();
-	void setupCGAPalette();
-	void setupEGAPalette();
-	void setupV1Palette();
+
+	void setC64Palette();
+	void setNESPalette();
+	void setAmigaPalette();
+	void setHercPalette();
+	void setCGAPalette();
+	void setEGAPalette();
+	void setV1Palette();
+
+	void resetPalette();
+
 	void setPalette(int pal);
 	void setRoomPalette(int pal, int room);
 	virtual void setPaletteFromPtr(const byte *ptr, int numcolor = -1);
@@ -1053,12 +1062,10 @@
 	int remapPaletteColor(int r, int g, int b, int threshold);		// Used by Actor::remapActorPalette
 protected:
 	void moveMemInPalRes(int start, int end, byte direction);
-	void setupShadowPalette(int slot, int redScale, int greenScale, int blueScale, int startColor, int endColor);
-	void setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor, int start, int end);
+	void setShadowPalette(int slot, int redScale, int greenScale, int blueScale, int startColor, int endColor);
+	void setShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor, int start, int end);
 	virtual void darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
 
-	void setupCursor();
-
 	void setCursorFromBuffer(const byte *ptr, int width, int height, int pitch);
 
 public:
@@ -1223,8 +1230,6 @@
 	int convertNameMessage(byte *dst, int dstSize, int var);
 	int convertStringMessage(byte *dst, int dstSize, int var);
 
-	virtual void loadLanguageBundle() {}
-
 public:
 	Common::Language _language;	// Accessed by a hack in NutRenderer::loadFont
 

Modified: scummvm/trunk/engines/scumm/vars.cpp
===================================================================
--- scummvm/trunk/engines/scumm/vars.cpp	2006-04-29 14:29:57 UTC (rev 22226)
+++ scummvm/trunk/engines/scumm/vars.cpp	2006-04-29 16:24:39 UTC (rev 22227)
@@ -536,7 +536,7 @@
 }
 #endif
 
-void ScummEngine_c64::initScummVars() {
+void ScummEngine_c64::resetScummVars() {
 	_activeInventory = 0;
 	_activeObject = 0;
 	_activeVerb = 13;
@@ -547,7 +547,7 @@
 	_currentLights = LIGHTMODE_actor_use_base_palette | LIGHTMODE_actor_use_colors | LIGHTMODE_room_lights_on;
 }
 
-void ScummEngine_v2::initScummVars() {
+void ScummEngine_v2::resetScummVars() {
 	// This needs to be at least greater than 40 to get the more
 	// elaborate version of the EGA Zak into. I don't know where
 	// else it makes any difference.
@@ -555,8 +555,8 @@
 		VAR(VAR_MACHINE_SPEED) = 0x7FFF;
 }
 
-void ScummEngine_v5::initScummVars() {
-	ScummEngine::initScummVars();
+void ScummEngine_v5::resetScummVars() {
+	ScummEngine::resetScummVars();
 
 	if (_game.version >= 4 && _game.version <= 5)
 		VAR(VAR_V5_TALK_STRING_Y) = -0x50;
@@ -569,8 +569,8 @@
 }
 
 #ifndef DISABLE_SCUMM_7_8
-void ScummEngine_v7::initScummVars() {
-	ScummEngine::initScummVars();
+void ScummEngine_v7::resetScummVars() {
+	ScummEngine::resetScummVars();
 
 	if (_game.version != 8) {
 		VAR(VAR_V6_EMSSPACE) = 10000;
@@ -581,8 +581,8 @@
 	VAR(VAR_VOICE_MODE) = ConfMan.getBool("subtitles");
 }
 
-void ScummEngine_v8::initScummVars() {
-	ScummEngine_v7::initScummVars();
+void ScummEngine_v8::resetScummVars() {
+	ScummEngine_v7::resetScummVars();
 
 	// FIXME: How do we deal with non-cd installs?
 	VAR(VAR_CURRENTDISK) = 1;
@@ -624,8 +624,8 @@
 #endif
 
 #ifndef DISABLE_HE
-void ScummEngine_v70he::initScummVars() {
-	ScummEngine::initScummVars();
+void ScummEngine_v70he::resetScummVars() {
+	ScummEngine::resetScummVars();
 
 	if (VAR_MACHINE_SPEED != 0xFF)
 		VAR(VAR_MACHINE_SPEED) = 13;
@@ -635,8 +635,8 @@
 	VAR(VAR_TALK_CHANNEL) = 2;
 }
 
-void ScummEngine_v72he::initScummVars() {
-	ScummEngine_v70he::initScummVars();
+void ScummEngine_v72he::resetScummVars() {
+	ScummEngine_v70he::resetScummVars();
 
 	VAR(VAR_VIDEO_PERFORMANCE) = 26;
 
@@ -649,8 +649,8 @@
 	VAR(VAR_NUM_GLOBAL_OBJS) = _numGlobalObjects - 1;
 }
 
-void ScummEngine_v80he::initScummVars() {
-	ScummEngine_v72he::initScummVars();
+void ScummEngine_v80he::resetScummVars() {
+	ScummEngine_v72he::resetScummVars();
 
 	if (_game.platform == Common::kPlatformMacintosh) {
 		VAR(VAR_PLATFORM) = 2;
@@ -662,8 +662,8 @@
 	VAR(VAR_COLOR_DEPTH) = 256;
 }
 
-void ScummEngine_v90he::initScummVars() {
-	ScummEngine_v80he::initScummVars();
+void ScummEngine_v90he::resetScummVars() {
+	ScummEngine_v80he::resetScummVars();
 
 	VAR(VAR_SCRIPT_CYCLE) = 1;
 	VAR(VAR_NUM_SCRIPT_CYCLES) = 1;
@@ -680,15 +680,15 @@
 	}
 }
 
-void ScummEngine_v99he::initScummVars() {
-	ScummEngine_v90he::initScummVars();
+void ScummEngine_v99he::resetScummVars() {
+	ScummEngine_v90he::resetScummVars();
 
 	VAR(VAR_NUM_PALETTES) = _numPalettes;
 	VAR(VAR_NUM_UNK) = _numUnk;
 }
 #endif
 
-void ScummEngine::initScummVars() {
+void ScummEngine::resetScummVars() {
 	if (_game.heversion < 70 && _game.version <= 6) {
 		switch (_musicType) {
 		case MDT_NONE:


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list