diff options
| author | Max Horn | 2006-04-29 16:24:39 +0000 | 
|---|---|---|
| committer | Max Horn | 2006-04-29 16:24:39 +0000 | 
| commit | c4df5037dc19a053cb0a3f66a4cf0775ffc09183 (patch) | |
| tree | 7e68680a343cd0a471f19209d86790b053a2fd86 | |
| parent | ad5a89a04b3ccc847cb022b125d2a555c10839b6 (diff) | |
| download | scummvm-rg350-c4df5037dc19a053cb0a3f66a4cf0775ffc09183.tar.gz scummvm-rg350-c4df5037dc19a053cb0a3f66a4cf0775ffc09183.tar.bz2 scummvm-rg350-c4df5037dc19a053cb0a3f66a4cf0775ffc09183.zip | |
* 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
svn-id: r22227
| -rw-r--r-- | engines/scumm/actor.cpp | 2 | ||||
| -rw-r--r-- | engines/scumm/cursor.cpp | 4 | ||||
| -rw-r--r-- | engines/scumm/dialogs.cpp | 2 | ||||
| -rw-r--r-- | engines/scumm/he/intern_he.h | 18 | ||||
| -rw-r--r-- | engines/scumm/he/script_v60he.cpp | 2 | ||||
| -rw-r--r-- | engines/scumm/input.cpp | 2 | ||||
| -rw-r--r-- | engines/scumm/intern.h | 30 | ||||
| -rw-r--r-- | engines/scumm/object.cpp | 20 | ||||
| -rw-r--r-- | engines/scumm/palette.cpp | 65 | ||||
| -rw-r--r-- | engines/scumm/room.cpp | 14 | ||||
| -rw-r--r-- | engines/scumm/saveload.cpp | 51 | ||||
| -rw-r--r-- | engines/scumm/script_v5.cpp | 2 | ||||
| -rw-r--r-- | engines/scumm/script_v6.cpp | 10 | ||||
| -rw-r--r-- | engines/scumm/script_v8.cpp | 4 | ||||
| -rw-r--r-- | engines/scumm/scumm.cpp | 177 | ||||
| -rw-r--r-- | engines/scumm/scumm.h | 55 | ||||
| -rw-r--r-- | engines/scumm/vars.cpp | 38 | 
17 files changed, 238 insertions, 258 deletions
| diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index a741b9bbad..903d5d007b 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -862,7 +862,7 @@ static const int v1MMActorTalkColor[25] = {  	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++) { diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 21e1b6a746..aabcbee482 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -73,10 +73,6 @@ static const byte default_v6_cursor[] = {  	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)) { diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 3c9abeff06..cab98503f6 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -748,8 +748,6 @@ void ConfigDialog::close() {  	}  	GUI_OptionsDialog::close(); - -	_vm->setupVolumes();  }  void ConfigDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h index f06214e1fc..47cb1cd374 100644 --- a/engines/scumm/he/intern_he.h +++ b/engines/scumm/he/intern_he.h @@ -66,7 +66,7 @@ public:  	ScummEngine_v60he(OSystem *syst, const DetectorResult &dr);  	~ScummEngine_v60he(); -	virtual void scummInit(); +	virtual void resetScumm();  protected:  	virtual void setupOpcodes(); @@ -144,7 +144,7 @@ protected:  	virtual const char *getOpcodeDesc(byte i);  	virtual void setupScummVars(); -	virtual void initScummVars(); +	virtual void resetScummVars();  	virtual void saveOrLoad(Serializer *s); @@ -251,7 +251,7 @@ protected:  public:  	ScummEngine_v72he(OSystem *syst, const DetectorResult &dr); -	virtual void scummInit(); +	virtual void resetScumm();  protected:  	virtual void setupOpcodes(); @@ -259,7 +259,7 @@ protected:  	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 @@ protected:  	virtual const char *getOpcodeDesc(byte i);  	virtual void setupScummVars(); -	virtual void initScummVars(); +	virtual void resetScummVars();  	virtual void initCharset(int charset); @@ -436,7 +436,7 @@ public:  	ScummEngine_v90he(OSystem *syst, const DetectorResult &dr);  	~ScummEngine_v90he(); -	virtual void scummInit(); +	virtual void resetScumm();  	LogicHE *_logicHE;  	Sprite *_sprite; @@ -450,7 +450,7 @@ protected:  	virtual void scummLoop_handleDrawing();  	virtual void setupScummVars(); -	virtual void initScummVars(); +	virtual void resetScummVars();  	virtual void saveOrLoad(Serializer *s); @@ -534,10 +534,10 @@ class ScummEngine_v99he : public ScummEngine_v90he {  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); diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp index 8c4324b6c7..d8fe03f702 100644 --- a/engines/scumm/he/script_v60he.cpp +++ b/engines/scumm/he/script_v60he.cpp @@ -548,7 +548,7 @@ void ScummEngine_v60he::o60_roomOps() {  		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 diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index d29aeec4ef..760482c183 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -435,7 +435,7 @@ void ScummEngine::processKbd(bool smushMode) {  			vol = Audio::Mixer::kMaxMixerVolume;  		ConfMan.setInt("music_volume", vol); -		setupVolumes(); +		updateVolumes();  	} else if (_lastKeyHit == '-' || _lastKeyHit == '+') { // Change text speed  		if (_lastKeyHit == '+' && _defaultTalkDelay > 0)  			_defaultTalkDelay--; diff --git a/engines/scumm/intern.h b/engines/scumm/intern.h index 7be7bf3761..2318aae4c1 100644 --- a/engines/scumm/intern.h +++ b/engines/scumm/intern.h @@ -67,7 +67,7 @@ protected:  	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 @@ class ScummEngine_v4 : public ScummEngine_v5 {  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 @@ public:  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 @@ protected:  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 @@ protected:  	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 @@ protected:  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 @@ protected:  public:  	ScummEngine_v6(OSystem *syst, const DetectorResult &dr); -	virtual void scummInit(); +	virtual void resetScumm();  protected:  	virtual void setupOpcodes(); @@ -838,7 +838,7 @@ protected:  	virtual void scummLoop_handleDrawing();  	virtual void setupScummVars(); -	virtual void initScummVars(); +	virtual void resetScummVars();  	virtual void akos_processQueue(); @@ -890,7 +890,7 @@ protected:  	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(); diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp index 9cee5b48b8..a8cf836a21 100644 --- a/engines/scumm/object.cpp +++ b/engines/scumm/object.cpp @@ -543,7 +543,7 @@ void ScummEngine::restoreFlObjects() {  	_numStoredFlObjects = 0;  } -void ScummEngine::loadRoomObjects() { +void ScummEngine::resetRoomObjects() {  	int i, j;  	ObjectData *od;  	const byte *ptr; @@ -611,13 +611,13 @@ void ScummEngine::loadRoomObjects() {  	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 @@ void ScummEngine_v3old::loadRoomObjects() {  			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 @@ void ScummEngine_v3old::loadRoomObjects() {  	CHECK_HEAP  } -void ScummEngine_v4::loadRoomObjects() { +void ScummEngine_v4::resetRoomObjects() {  	int i, j;  	ObjectData *od;  	const byte *ptr; @@ -711,14 +711,14 @@ void ScummEngine_v4::loadRoomObjects() {  	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 @@ void ScummEngine_c64::setupRoomObject(ObjectData *od, const byte *room, const by  	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_v4::setupRoomObject(ObjectData *od, const byte *room, const byt  	}  } -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 @@ void ScummEngine::loadFlObject(uint object, uint room) {  		res.unlock(rtRoomScripts, room);  	// Setup local object flags -	setupRoomObject(od, flob, flob); +	resetRoomObject(od, flob, flob);  	od->fl_object_index = slot;  } diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index bb53e788c7..1ab065394c 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -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 @@ void ScummEngine::setupC64Palette() {  	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 @@ void ScummEngine::setupNESPalette() {  	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 @@ void ScummEngine::setupAmigaPalette() {  	setPalColor(15, 255, 255, 255);  } -void ScummEngine::setupHercPalette() { +void ScummEngine::setHercPalette() {  	setPalColor( 0,   0,   0,   0);  	if (_renderMode == Common::kRenderHercA) @@ -155,7 +196,7 @@ void ScummEngine::setupHercPalette() {  	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 @@ void ScummEngine::setupCGAPalette() {  	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 @@ void ScummEngine::setupEGAPalette() {  	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 @@ void ScummEngine::palManipulate() {  	_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 @@ static inline uint colorWeight(int red, int green, int blue) {  	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 @@ void ScummEngine::setupShadowPalette(int redScale, int greenScale, int blueScale  	// 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 diff --git a/engines/scumm/room.cpp b/engines/scumm/room.cpp index b2df1e993d..5a657e216c 100644 --- a/engines/scumm/room.cpp +++ b/engines/scumm/room.cpp @@ -143,12 +143,12 @@ void ScummEngine::startScene(int room, Actor *a, int objectNr) {  		return;  	} -	loadRoomSubBlocks(); -	initRoomSubBlocks(); +	setupRoomSubBlocks(); +	resetRoomSubBlocks();  	initBGBuffers(_roomHeight); -	loadRoomObjects(); +	resetRoomObjects();  	restoreFlObjects();  	if (VAR_ROOM_WIDTH != 0xFF && VAR_ROOM_HEIGHT != 0xFF) { @@ -225,7 +225,7 @@ void ScummEngine::startScene(int room, Actor *a, int objectNr) {   * 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 @@ void ScummEngine::loadRoomSubBlocks() {   * 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::initRoomSubBlocks() {  } -void ScummEngine_v3old::loadRoomSubBlocks() { +void ScummEngine_v3old::setupRoomSubBlocks() {  	const byte *ptr;  	byte *roomptr, *searchptr = 0;  	const RoomHeader *rmhd; @@ -697,7 +697,7 @@ void ScummEngine_v3old::loadRoomSubBlocks() {  	gdi.roomChanged(roomptr, _IM00_offs, 255);  } -void ScummEngine_v3old::initRoomSubBlocks() { +void ScummEngine_v3old::resetRoomSubBlocks() {  	int i;  	const byte *ptr;  	byte *roomptr; diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index 92cd9881fd..d6594f1a55 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -257,7 +257,7 @@ bool ScummEngine::loadState(int slot, bool compat) {  				res.nukeResource(i, j);  			} -	initScummVars(); +	resetScummVars();  	if (_game.features & GF_OLD_BUNDLE)  		loadCharset(0); // FIXME - HACK ? @@ -270,7 +270,7 @@ bool ScummEngine::loadState(int slot, bool compat) {  	delete in;  	// Update volume settings -	setupVolumes(); +	updateVolumes();  	// Init NES costume data  	if (_game.platform == Common::kPlatformNES) { @@ -331,53 +331,14 @@ bool ScummEngine::loadState(int slot, bool compat) {  		}  	} -	// 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; - -		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); - +	// Reset the palette. +	resetPalette();  	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; diff --git a/engines/scumm/script_v5.cpp b/engines/scumm/script_v5.cpp index 2163be1958..8c8b62f738 100644 --- a/engines/scumm/script_v5.cpp +++ b/engines/scumm/script_v5.cpp @@ -1946,7 +1946,7 @@ void ScummEngine_v5::o5_roomOps() {  		_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 diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp index cb1bcf4de7..64b43c4ec5 100644 --- a/engines/scumm/script_v6.cpp +++ b/engines/scumm/script_v6.cpp @@ -1727,7 +1727,7 @@ void ScummEngine_v6::o6_roomOps() {  		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 @@ void ScummEngine_v6::o6_kernelSetFunctions() {  			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 @@ void ScummEngine_v6::o6_kernelSetFunctions() {  			// 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 @@ void ScummEngine_v6::o6_kernelSetFunctions() {  			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 diff --git a/engines/scumm/script_v8.cpp b/engines/scumm/script_v8.cpp index d5515719fc..c3be9a4af0 100644 --- a/engines/scumm/script_v8.cpp +++ b/engines/scumm/script_v8.cpp @@ -1292,10 +1292,10 @@ void ScummEngine_v8::o8_kernelSetFunctions() {  			_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); diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index e380f9d313..fca23f4e28 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -955,6 +955,25 @@ int ScummEngine::init() {  		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 @@ int ScummEngine::init() {  	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 @@ int ScummEngine::init() {  		_bootParam = -1;  	} -	readIndexFile(); -  #ifdef PALMOS_68K  	if (_game.features & GF_NEW_COSTUMES)  		res._maxHeapThreshold = gVars->memory[kMemScummNewCostGames]; @@ -1076,16 +1070,6 @@ int ScummEngine::init() {  #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 @@ int ScummEngine::init() {  	// 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 @@ void ScummEngine::scummInit() {  	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 @@ void ScummEngine::scummInit() {  		loadCharset(0);  	setShake(0); -	setupCursor(); +	_cursor.animate = 1;  	// Allocate and Initialize actors  	Actor::initActorClass(this); @@ -1184,7 +1162,7 @@ void ScummEngine::scummInit() {  	}  	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 @@ void ScummEngine::scummInit() {  	_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 @@ void ScummEngine_v2::scummInit() {  	_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_v4::scummInit() {  	}  } -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 @@ void ScummEngine_v60he::scummInit() {  }  #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_v90he::scummInit() {  	}  } -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 @@ void ScummEngine::setupMusic(int midi) {  		}  	} -	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 @@ void ScummEngine::restart() {  	readIndexFile();  	// Reinit scumm variables -	scummInit(); -	initScummVars(); +	resetScumm(); +	resetScummVars();  	if (_imuse) {  		_imuse->setBase(res.address[rtSound]); @@ -2078,6 +2056,7 @@ void ScummEngine::mainMenuDialog() {  	if (!_mainMenuDialog)  		_mainMenuDialog = new MainMenuDialog(this);  	runDialog(*_mainMenuDialog); +	updateVolumes();  }  void ScummEngine::confirmExitDialog() { diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 1f40edc344..eef0254cf1 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -457,17 +457,19 @@ public:  	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,12 +788,16 @@ protected:  	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; @@ -823,7 +829,6 @@ public:  	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 @@ protected:  	void setActorRedrawFlags();  	void putActors();  	void showActors(); -	void setupV1ActorTalkColor(); +	void resetV1ActorTalkColor();  	void resetActorBgs();  	virtual void processActors();  	void processUpperActors(); @@ -1030,13 +1035,17 @@ protected:  	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 @@ public:  	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 @@ protected:  	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 diff --git a/engines/scumm/vars.cpp b/engines/scumm/vars.cpp index fd81443cc8..0c0d06b9ea 100644 --- a/engines/scumm/vars.cpp +++ b/engines/scumm/vars.cpp @@ -536,7 +536,7 @@ void ScummEngine_v8::setupScummVars() {  }  #endif -void ScummEngine_c64::initScummVars() { +void ScummEngine_c64::resetScummVars() {  	_activeInventory = 0;  	_activeObject = 0;  	_activeVerb = 13; @@ -547,7 +547,7 @@ void ScummEngine_c64::initScummVars() {  	_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 @@ void ScummEngine_v2::initScummVars() {  		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 @@ void ScummEngine_v5::initScummVars() {  }  #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 @@ void ScummEngine_v7::initScummVars() {  	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 @@ void ScummEngine_v8::initScummVars() {  #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 @@ void ScummEngine_v70he::initScummVars() {  	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 @@ void ScummEngine_v72he::initScummVars() {  	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 @@ void ScummEngine_v80he::initScummVars() {  	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_v90he::initScummVars() {  	}  } -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: | 
