diff options
| -rw-r--r-- | engines/agos/agos.cpp | 238 | ||||
| -rw-r--r-- | engines/agos/agos.h | 110 | ||||
| -rw-r--r-- | engines/agos/animation.cpp | 2 | ||||
| -rw-r--r-- | engines/agos/charset.cpp | 42 | ||||
| -rw-r--r-- | engines/agos/debug.cpp | 36 | ||||
| -rw-r--r-- | engines/agos/draw.cpp | 8 | ||||
| -rw-r--r-- | engines/agos/event.cpp | 2 | ||||
| -rw-r--r-- | engines/agos/gfx.cpp | 20 | ||||
| -rw-r--r-- | engines/agos/icons.cpp | 6 | ||||
| -rw-r--r-- | engines/agos/input.cpp | 10 | ||||
| -rw-r--r-- | engines/agos/midi.cpp | 4 | ||||
| -rw-r--r-- | engines/agos/midi.h | 6 | ||||
| -rw-r--r-- | engines/agos/module.mk | 1 | ||||
| -rw-r--r-- | engines/agos/res.cpp | 197 | ||||
| -rw-r--r-- | engines/agos/res_snd.cpp | 443 | ||||
| -rw-r--r-- | engines/agos/script.cpp | 23 | ||||
| -rw-r--r-- | engines/agos/string.cpp | 12 | ||||
| -rw-r--r-- | engines/agos/verb.cpp | 2 | ||||
| -rw-r--r-- | engines/agos/vga.cpp | 28 | ||||
| -rw-r--r-- | engines/agos/vga_s2.cpp | 2 | ||||
| -rw-r--r-- | engines/agos/window.cpp | 6 | ||||
| -rw-r--r-- | engines/agos/zones.cpp | 11 | 
22 files changed, 613 insertions, 596 deletions
| diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index 40f099d57d..b0fa6c6205 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -474,7 +474,7 @@ int AGOSEngine::init() {  	if (!_mixer->isReady())  		warning("Sound initialization failed. "  						"Features of the game that depend on sound synchronization will most likely break"); -	set_volume(ConfMan.getInt("sfx_volume")); +	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));  	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));  	// Setup midi driver @@ -493,11 +493,11 @@ int AGOSEngine::init() {  	midi.mapMT32toGM (getGameType() != GType_SIMON2 && !_native_mt32); -	midi.set_driver(driver); +	midi.setDriver(driver);  	int ret = midi.open();  	if (ret)  		warning ("MIDI Player init failed: \"%s\"", midi.getErrorName (ret)); -	midi.set_volume(ConfMan.getInt("music_volume")); +	midi.setVolume(ConfMan.getInt("music_volume"));  	if (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute") == 1)  		midi.pause(_musicPaused ^= 1); @@ -771,26 +771,6 @@ GUI::Debugger *AGOSEngine::getDebugger() {  	return _debugger;  } -void AGOSEngine::paletteFadeOut(byte *palPtr, uint num, uint size) { -	byte *p = palPtr; - -	do { -		if (p[0] >= size) -			p[0] -= size; -		else -			p[0] = 0; -		if (p[1] >= size) -			p[1] -= size; -		else -			p[1] = 0; -		if (p[2] >= size) -			p[2] -= size; -		else -			p[2] = 0; -		p += 4; -	} while (--num); -} -  void AGOSEngine::pause() {  	_keyPressed = 1;  	_pause = 1; @@ -806,86 +786,9 @@ void AGOSEngine::pause() {  	}  	midi.pause(music_status);  	_sound->ambientPause(ambient_status); - -} - -void AGOSEngine::playSpeech(uint speech_id, uint vgaSpriteId) { -	if (getGameType() == GType_SIMON1) { -		if (speech_id == 9999) { -			if (_subtitles) -				return; -			if (!getBitFlag(14) && !getBitFlag(28)) { -				setBitFlag(14, true); -				_variableArray[100] = 15; -				animate(4, 1, 130, 0, 0, 0); -				waitForSync(130); -			} -			_skipVgaWait = true; -		} else { -			if (_subtitles && _scriptVar2) { -				animate(4, 2, 204, 0, 0, 0); -				waitForSync(204); -				stopAnimateSimon1(204); -			} -			stopAnimateSimon1(vgaSpriteId + 201); -			loadVoice(speech_id); -			animate(4, 2, vgaSpriteId + 201, 0, 0, 0); -		} -	} else { -		if (speech_id == 0xFFFF) { -			if (_subtitles) -				return; -			if (!getBitFlag(14) && !getBitFlag(28)) { -				setBitFlag(14, true); -				_variableArray[100] = 5; -				animate(4, 1, 30, 0, 0, 0); -				waitForSync(130); -			} -			_skipVgaWait = true; -		} else { -			if (getGameType() == GType_SIMON2 && _subtitles && _language != Common::HB_ISR) { -				loadVoice(speech_id); -				return; -			} - -			if (_subtitles && _scriptVar2) { -				animate(4, 2, 5, 0, 0, 0); -				waitForSync(205); -				stopAnimateSimon2(2,5); -			} - -			stopAnimateSimon2(2, vgaSpriteId + 2); -			loadVoice(speech_id); -			animate(4, 2, vgaSpriteId + 2, 0, 0, 0); -		} -	} -} - -void AGOSEngine::skipSpeech() { -	_sound->stopVoice(); -	if (!getBitFlag(28)) { -		setBitFlag(14, true); -		if (getGameType() == GType_FF) { -			_variableArray[103] = 5; -			animate(4, 2, 13, 0, 0, 0); -			waitForSync(213); -			stopAnimateSimon2(2, 1); -		} else if (getGameType() == GType_SIMON2) { -			_variableArray[100] = 5; -			animate(4, 1, 30, 0, 0, 0); -			waitForSync(130); -			stopAnimateSimon2(2, 1); -		} else { -			_variableArray[100] = 15; -			animate(4, 1, 130, 0, 0, 0); -			waitForSync(130); -			stopAnimateSimon1(1); -		} -	}  }  int AGOSEngine::go() { -  	loadGamePcFile();  	addTimeEvent(0, 1); @@ -943,141 +846,6 @@ void AGOSEngine::shutdown() {  	_system->quit();  } -void AGOSEngine::loadMusic(uint music) { -	char buf[4]; - -	if (getPlatform() == Common::kPlatformAtariST) { -		// TODO: Add support for music format used by Elvira 2 -	} else if (getPlatform() == Common::kPlatformAmiga) { -		_modPlayer->stop(); - -		char filename[15]; -		File f; - -		if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) -			sprintf(filename, "elvira2"); -		else -			sprintf(filename, "%dtune", music); - -		f.open(filename); -		if (f.isOpen() == false) { -			error("loadMusic: Can't load module from '%s'", filename); -		} - -		if (!(getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) && -			getFeatures() & GF_CRUNCHED) { -			uint srcSize = f.size(); -			byte *srcBuf = (byte *)malloc(srcSize); -			if (f.read(srcBuf, srcSize) != srcSize) -				error("loadMusic: Read failed"); - -			uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4); -			byte *dstBuf = (byte *)malloc(dstSize); -			decrunchFile(srcBuf, dstBuf, srcSize); -			free(srcBuf); - -			Common::MemoryReadStream stream(dstBuf, dstSize); -			_modPlayer->loadModuleStream(stream); -		} else { -			_modPlayer->loadModuleStream(f); -		} -		_modPlayer->start(); -	} else if (getGameType() == GType_SIMON2) { -		midi.stop(); -		_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET); -		_gameFile->read(buf, 4); -		if (!memcmp(buf, "FORM", 4)) { -			_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET); -			midi.loadXMIDI (_gameFile); -		} else { -			_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET); -			midi.loadMultipleSMF (_gameFile); -		} - -		_lastMusicPlayed = music; -		_nextMusicToPlay = -1; -	} else if (getGameType() == GType_SIMON1) { -		midi.stop(); -		midi.setLoop (true); // Must do this BEFORE loading music. (GMF may have its own override.) - -		if (getFeatures() & GF_TALKIE) { -			// FIXME: The very last music resource, a cymbal crash for when the -			// two demons crash into each other, should NOT be looped like the -			// other music tracks. In simon1dos/talkie the GMF resource includes -			// a loop override that acomplishes this, but there seems to be nothing -			// for this in the SMF resources. -			if (music == 35) -				midi.setLoop (false); - -			_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET); -			_gameFile->read(buf, 4); -			if (!memcmp(buf, "GMF\x1", 4)) { -				_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET); -				midi.loadSMF (_gameFile, music); -			} else { -				_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET); -				midi.loadMultipleSMF (_gameFile); -			} - -		} else { -			char filename[15]; -			File f; -			sprintf(filename, "MOD%d.MUS", music); -			f.open(filename); -			if (f.isOpen() == false) -				error("loadMusic: Can't load music from '%s'", filename); - -			if (getFeatures() & GF_DEMO) -				midi.loadS1D (&f); -			else -				midi.loadSMF (&f, music); -		} - -		midi.startTrack (0); -	} else { -		midi.stop(); -		midi.setLoop (true); // Must do this BEFORE loading music. - -		char filename[15]; -		File f; -		sprintf(filename, "MOD%d.MUS", music); -		f.open(filename); -		if (f.isOpen() == false) -			error("loadMusic: Can't load music from '%s'", filename); - -		midi.loadS1D (&f); -		midi.startTrack (0); -	} -} - -void AGOSEngine::playSting(uint a) { -	if (!midi._enable_sfx) -		return; - -	char filename[15]; - -	File mus_file; -	uint16 mus_offset; - -	sprintf(filename, "STINGS%i.MUS", _soundFileId); -	mus_file.open(filename); -	if (!mus_file.isOpen()) -		error("playSting: Can't load sound effect from '%s'", filename); - -	mus_file.seek(a * 2, SEEK_SET); -	mus_offset = mus_file.readUint16LE(); -	if (mus_file.ioFailed()) -		error("playSting: Can't read sting %d offset", a); - -	mus_file.seek(mus_offset, SEEK_SET); -	midi.loadSMF(&mus_file, a, true); -	midi.startTrack(0); -} - -void AGOSEngine::set_volume(int volume) { -	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volume); -} -  } // End of namespace AGOS  #ifdef PALMOS_68K diff --git a/engines/agos/agos.h b/engines/agos/agos.h index 36c1b26ee5..f8576b0f5e 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -591,12 +591,6 @@ protected:  	int runScript(); -	Item *getNextItemPtr(); -	uint getNextItemID(); -	uint getItem1ID() {return 1;} -	Item *me(); -	Item *actor(); -  	byte getByte();  	int getNextWord(); @@ -608,12 +602,13 @@ protected:  	void writeNextVarContents(uint16 contents);  	void writeVariable(uint variable, uint16 contents); -	void setItemParent(Item *item, Item *parent); - -	uint itemPtrToID(Item *id); -  	Item *derefItem(uint item); -	void setItemState(Item *item, int value); +	Item *getNextItemPtr(); +	uint getNextItemID(); +	uint getItem1ID() {return 1;} +	uint itemPtrToID(Item *id); +	Item *me(); +	Item *actor();  	void showMessageFormat(const char *s, ...);  	const byte *getStringPtrByID(uint stringId); @@ -623,6 +618,11 @@ protected:  	void addTimeEvent(uint timeout, uint subroutine_id);  	void delTimeEvent(TimeEvent *te); +	Item *findInByClass(Item *i, int16 m); +	Item *findMaster(int16 a, int16 n); +	Item *nextMaster(Item *item, int16 a, int16 n); +	int wordMatch(Item *item, int16 a, int16 n); +  	bool isRoom(Item *item);  	bool isObject(Item *item);  	bool isPlayer(Item *item); @@ -631,6 +631,9 @@ protected:  	void unlinkItem(Item *item);  	void linkItem(Item *item, Item *parent); +	void setItemParent(Item *item, Item *parent); +	void setItemState(Item *item, int value); +  	void stopAnimateSimon1(uint a);  	void stopAnimateSimon2(uint a, uint b); @@ -660,6 +663,28 @@ protected:  	TextLocation *getTextLocation(uint a);  	void setup_cond_c_helper(); +	uint16 getBackExit(int n); +	uint16 getDoorOf(Item *item, uint16 d); +	uint16 getDoorState(Item *item, uint16 d); +	uint16 getExitOf_e1(Item *item, uint16 d); +	uint16 getExitOf(Item *item, uint16 d); +	uint16 getExitState(Item *item, uint16 x, uint16 d); +	void changeDoorState(SubRoom *r, uint16 d, uint16 n); +	void setDoorState(Item *i, uint16 d, uint16 n); +	void moveDirn_e1(Item *i, uint x); +	void moveDirn_e2(Item *i, uint x); +	void moveDirn_ww(Item *i, uint x); + +	int canPlace(Item *x, Item *y); +	int contains(Item *a, Item *b); +	int sizeContents(Item *x); +	int sizeOfRec(Item *o, int d); +	int sizeRec(Item *x, int d); +	int weighUp(Item *x); +	int weightRec(Item *x, int d); +	int weightOf(Item *x); +	void xPlace(Item *x, Item *y); +  	uint menuFor_e2(Item *item, uint id);  	uint menuFor_ww(Item *item, uint id);  	void clearMenuStrip(); @@ -764,8 +789,8 @@ protected:  	void permitInput();  	uint getFeebleFontSize(byte chr); -	void showmessage_helper_3(uint a, uint b); -	void showmessage_print_char(byte chr); +	void justifyStart(uint a, uint b); +	void justifyOutPut(byte chr);  	void loadZone(uint zoneNum); @@ -1051,37 +1076,6 @@ public:  	void o_unloadZone();  	void o_unfreezeZones(); -	Item *findInByClass(Item *i, int16 m); -	Item *findMaster(int16 a, int16 n); -	Item *nextMaster(Item *item, int16 a, int16 n); -	int16 levelOf(Item *item); -	int wordMatch(Item *item, int16 a, int16 n); - -	uint16 getBackExit(int n); -	uint16 getDoorOf(Item *item, uint16 d); -	uint16 getDoorState(Item *item, uint16 d); -	uint16 getExitOf_e1(Item *item, uint16 d); -	uint16 getExitOf(Item *item, uint16 d); -	uint16 getExitState(Item *item, uint16 x, uint16 d); -	void changeDoorState(SubRoom *r, uint16 d, uint16 n); -	void setDoorState(Item *i, uint16 d, uint16 n); -	void moveDirn_e1(Item *i, uint x); -	void moveDirn_e2(Item *i, uint x); -	void moveDirn_ww(Item *i, uint x); - -	int contains(Item *a, Item *b); - -	int sizeContents(Item *x); -	int sizeOfRec(Item *o, int d); -	int sizeRec(Item *x, int d); - -	int weighUp(Item *x); -	int weightRec(Item *x, int d); -	int weightOf(Item *x); - -	int canPlace(Item *x, Item *y); -	void xPlace(Item *x, Item *y); -  	// Opcodes, Elvira 1 only  	void oe1_present();  	void oe1_notPresent(); @@ -1277,7 +1271,7 @@ protected:  	bool isSpriteLoaded(uint16 id, uint16 zoneNum);  	void resetWindow(WindowBlock *window); -	void delete_hitarea_by_index(uint index); +	void freeBox(uint index);  	void windowPutChar(uint a); @@ -1310,16 +1304,16 @@ protected:  	void animateSpritesDebug();  	void animateSpritesByY(); -	void dx_clear_surfaces(uint num_lines); -	void dx_update_screen_and_palette(); +	void clearSurfaces(uint num_lines); +	void updateScreen();  	void dumpVideoScript(const byte *src, bool one_opcode_only); -	void dump_vga_file(const byte *vga); -	void dump_vga_script(const byte *ptr, uint res, uint sprite_id); -	void dump_vga_script_always(const byte *ptr, uint res, uint sprite_id); -	void dump_vga_bitmaps(const byte *vga, byte *vga1, int res); -	void dump_single_bitmap(int file, int image, const byte *offs, int w, int h, byte base); -	void dump_bitmap(const char *filename, const byte *offs, int w, int h, int flags, const byte *palette, byte base); +	void dumpVgaFile(const byte *vga); +	void dumpVgaScript(const byte *ptr, uint res, uint sprite_id); +	void dumpVgaScriptAlways(const byte *ptr, uint res, uint sprite_id); +	void dumpVgaBitmaps(const byte *vga, byte *vga1, int res); +	void dumpSingleBitmap(int file, int image, const byte *offs, int w, int h, byte base); +	void dumpBitmap(const char *filename, const byte *offs, int w, int h, int flags, const byte *palette, byte base);  	void clearBackFromTop(uint lines);  	void fillFrontFromBack(uint x, uint y, uint w, uint h); @@ -1343,8 +1337,8 @@ protected:  	void openTextWindow();  	void tidyIconArray(uint i); -	void video_putchar_newline(WindowBlock *window); -	void video_putchar_drawchar(WindowBlock *window, uint x, uint y, byte chr); +	void windowNewLine(WindowBlock *window); +	void windowDrawChar(WindowBlock *window, uint x, uint y, byte chr);  	void loadMusic(uint music);  	void checkTimerCallback(); @@ -1360,11 +1354,7 @@ protected:  	void fastFadeIn();  	void slowFadeIn(); -	void vc_kill_sprite(uint file, uint sprite); - -	void set_dummy_cursor(); - -	void set_volume(int volume); +	void vcStopAnimation(uint file, uint sprite);  	void userGame(bool load);  	void disableFileBoxes(); diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp index f08b7bb1dc..892589bdcc 100644 --- a/engines/agos/animation.cpp +++ b/engines/agos/animation.cpp @@ -148,7 +148,7 @@ void MoviePlayer::play() {  	} else {  		uint8 palette[1024];  		memset(palette, 0, sizeof(palette)); -		_vm->dx_clear_surfaces(480); +		_vm->clearSurfaces(480);  		_vm->_system->setPalette(palette, 0, 256);  	} diff --git a/engines/agos/charset.cpp b/engines/agos/charset.cpp index 56b442dcee..30c27e5b7b 100644 --- a/engines/agos/charset.cpp +++ b/engines/agos/charset.cpp @@ -315,19 +315,27 @@ void AGOSEngine::showMessageFormat(const char *s, ...) {  		if (!_showMessageFlag) {  			_windowArray[0] = _textWindow;  			if (getGameType() == GType_FF || getGameType() == GType_PP) -				showmessage_helper_3(_textWindow->textColumn, _textWindow->width); +				justifyStart(_textWindow->textColumn, _textWindow->width);  			else -				showmessage_helper_3(_textWindow->textLength, _textWindow->textMaxLength); +				justifyStart(_textWindow->textLength, _textWindow->textMaxLength);  		}  		_showMessageFlag = true;  		_fcsData1[_curWindow] = 1;  	}  	for (str = buf; *str; str++) -		showmessage_print_char(*str); +		justifyOutPut(*str);  } -void AGOSEngine::showmessage_print_char(byte chr) { +void AGOSEngine::justifyStart(uint a, uint b) { +	_printCharCurPos = a; +	_printCharMaxPos = b; +	_printCharPixelCount = 0; +	_numLettersToPrint = 0; +	_newLines = 0; +} + +void AGOSEngine::justifyOutPut(byte chr) {  	if (chr == 12) {  		_numLettersToPrint = 0;  		_printCharCurPos = 0; @@ -397,21 +405,13 @@ void AGOSEngine::openTextWindow() {  		_textWindow = openWindow(8, 144, 24, 6, 1, 0, 15);  } -void AGOSEngine::showmessage_helper_3(uint a, uint b) { -	_printCharCurPos = a; -	_printCharMaxPos = b; -	_printCharPixelCount = 0; -	_numLettersToPrint = 0; -	_newLines = 0; -} -  void AGOSEngine::windowPutChar(WindowBlock *window, byte c, byte b) {  	byte width = 6;  	if (c == 12) {  		clearWindow(window);  	} else if (c == 13 || c == 10) { -		video_putchar_newline(window); +		windowNewLine(window);  	} else if ((c == 1 && _language != Common::HB_ISR) || (c == 8)) {  		if (_language == Common::HB_ISR) {  			if (b >= 64 && b < 91) @@ -439,15 +439,15 @@ void AGOSEngine::windowPutChar(WindowBlock *window, byte c, byte b) {  		}  	} else if (c >= 32) {  		if (getGameType() == GType_FF || getGameType() == GType_PP) { -			video_putchar_drawchar(window, window->textColumn + window->x, window->textRow + window->y, c); +			windowDrawChar(window, window->textColumn + window->x, window->textRow + window->y, c);  			window->textColumn += feebleFontSize[c - 32];  			return;  		}  		if (window->textLength == window->textMaxLength) { -			video_putchar_newline(window); +			windowNewLine(window);  		} else if (window->textRow == window->height) { -			video_putchar_newline(window); +			windowNewLine(window);  			window->textRow--;  		} @@ -459,10 +459,10 @@ void AGOSEngine::windowPutChar(WindowBlock *window, byte c, byte b) {  				window->textColumnOffset += 8;  				window->textColumn++;  			} -			video_putchar_drawchar(window, (window->width + window->x - window->textColumn) * 8, window->textRow * 8 + window->y, c); +			windowDrawChar(window, (window->width + window->x - window->textColumn) * 8, window->textRow * 8 + window->y, c);  			window->textLength++;  		} else { -			video_putchar_drawchar(window, (window->textColumn + window->x) * 8, window->textRow * 8 + window->y, c); +			windowDrawChar(window, (window->textColumn + window->x) * 8, window->textRow * 8 + window->y, c);  			window->textLength++;  			window->textColumnOffset += 6; @@ -477,7 +477,7 @@ void AGOSEngine::windowPutChar(WindowBlock *window, byte c, byte b) {  	}  } -void AGOSEngine::video_putchar_newline(WindowBlock *window) { +void AGOSEngine::windowNewLine(WindowBlock *window) {  	if (getGameType() == GType_FF) {  		if (_noOracleScroll == 0) {  			if (window->height < window->textRow + 30) { @@ -1530,7 +1530,7 @@ static const byte feeble_video_font[] = {  	0,0,0,0,0,0,0,0,0,0,0,0,0,  }; -void AGOSEngine::video_putchar_drawchar(WindowBlock *window, uint x, uint y, byte chr) { +void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) {  	const byte *src;  	byte color, *dst;  	uint h, w, i; @@ -1577,7 +1577,7 @@ void AGOSEngine::video_putchar_drawchar(WindowBlock *window, uint x, uint y, byt  			src = video_font + (chr - 0x20) * 8;  			break;  		default: -			error("video_putchar_drawchar: Unknown language %d\n", _language); +			error("windowDrawChar: Unknown language %d\n", _language);  		}  	} diff --git a/engines/agos/debug.cpp b/engines/agos/debug.cpp index db3723964c..c424082d03 100644 --- a/engines/agos/debug.cpp +++ b/engines/agos/debug.cpp @@ -272,7 +272,7 @@ void AGOSEngine::dumpVideoScript(const byte *src, bool one_opcode_only) {  	} while (!one_opcode_only);  } -void AGOSEngine::dump_vga_file(const byte *vga) { +void AGOSEngine::dumpVgaFile(const byte *vga) {  	const byte *pp;  	const byte *p;  	int count; @@ -284,7 +284,7 @@ void AGOSEngine::dump_vga_file(const byte *vga) {  	while (--count >= 0) {  		int id = READ_BE_UINT16(&((const AnimationHeader_Simon *) p)->id); -		dump_vga_script_always(vga + READ_BE_UINT16(&((const AnimationHeader_Simon *) p)->scriptOffs), id / 100, id); +		dumpVgaScriptAlways(vga + READ_BE_UINT16(&((const AnimationHeader_Simon *) p)->scriptOffs), id / 100, id);  		p += sizeof(AnimationHeader_Simon);  	} @@ -296,7 +296,7 @@ void AGOSEngine::dump_vga_file(const byte *vga) {  	while (--count >= 0) {  		int id = READ_BE_UINT16(&((const ImageHeader_Simon *) p)->id); -		dump_vga_script_always(vga + READ_BE_UINT16(&((const ImageHeader_Simon *) p)->scriptOffs), id / 100, id); +		dumpVgaScriptAlways(vga + READ_BE_UINT16(&((const ImageHeader_Simon *) p)->scriptOffs), id / 100, id);  		p += sizeof(ImageHeader_Simon);  	}  } @@ -320,7 +320,7 @@ static const byte bmp_hdr[] = {  	0x00, 0x01, 0x00, 0x00,  }; -void dump_bmp(const char *filename, int w, int h, const byte *bytes, const uint32 *palette) { +void dumpBMP(const char *filename, int w, int h, const byte *bytes, const uint32 *palette) {  	FILE *out = fopen(filename, "wb");  	byte my_hdr[sizeof(bmp_hdr)];  	int i; @@ -355,7 +355,7 @@ void dump_bmp(const char *filename, int w, int h, const byte *bytes, const uint3  	fclose(out);  } -void AGOSEngine::dump_bitmap(const char *filename, const byte *offs, int w, int h, int flags, const byte *palette, +void AGOSEngine::dumpBitmap(const char *filename, const byte *offs, int w, int h, int flags, const byte *palette,  								 byte base) {  	if (getGameType() != GType_FF && getGameType() != GType_PP) @@ -391,11 +391,11 @@ void AGOSEngine::dump_bitmap(const char *filename, const byte *offs, int w, int  		}  	} -	dump_bmp(filename, w, h, b, (const uint32 *)palette); +	dumpBMP(filename, w, h, b, (const uint32 *)palette);  	free(b);  } -void AGOSEngine::dump_single_bitmap(int file, int image, const byte *offs, int w, int h, byte base) { +void AGOSEngine::dumpSingleBitmap(int file, int image, const byte *offs, int w, int h, byte base) {  	char buf[40];  #if !defined(PALMOS_MODE) && !defined(__DC__) && !defined(__PSP__) && !defined(__PLAYSTATION2__)  	struct stat statbuf; @@ -412,10 +412,10 @@ void AGOSEngine::dump_single_bitmap(int file, int image, const byte *offs, int w  		return;  #endif -	dump_bitmap(buf, offs, w, h, 0, _displayPalette, base); +	dumpBitmap(buf, offs, w, h, 0, _displayPalette, base);  } -void pal_load(byte *pal, const byte *vga1, int a, int b) { +void palLoad(byte *pal, const byte *vga1, int a, int b) {  	uint num = (a == 0) ? 0x20 : 0x10;  	byte *palptr;  	const byte *src; @@ -434,7 +434,7 @@ void pal_load(byte *pal, const byte *vga1, int a, int b) {  	} while (--num);  } -void AGOSEngine::dump_vga_bitmaps(const byte *vga, byte *vga1, int res) { +void AGOSEngine::dumpVgaBitmaps(const byte *vga, byte *vga1, int res) {  	int i;  	uint32 offs; @@ -442,10 +442,10 @@ void AGOSEngine::dump_vga_bitmaps(const byte *vga, byte *vga1, int res) {  	byte pal[768];  	memset(pal, 0, sizeof(pal)); -	pal_load(pal, vga1, 2, 0); -	pal_load(pal, vga1, 3, 1); -	pal_load(pal, vga1, 4, 2); -	pal_load(pal, vga1, 5, 3); +	palLoad(pal, vga1, 2, 0); +	palLoad(pal, vga1, 3, 1); +	palLoad(pal, vga1, 4, 2); +	palLoad(pal, vga1, 5, 3);  	int width, height, flags; @@ -474,20 +474,20 @@ void AGOSEngine::dump_vga_bitmaps(const byte *vga, byte *vga1, int res) {  		sprintf(buf, "dumps/Res%d_Image%d.bmp", res, i);  #endif -		dump_bitmap(buf, vga + offs, width, height, flags, pal, 0); +		dumpBitmap(buf, vga + offs, width, height, flags, pal, 0);  	}  } -void AGOSEngine::dump_vga_script_always(const byte *ptr, uint res, uint sprite_id) { +void AGOSEngine::dumpVgaScriptAlways(const byte *ptr, uint res, uint sprite_id) {  	printf("; address=%x, vgafile=%d  vgasprite=%d\n",  					(unsigned int)(ptr - _vgaBufferPointers[res].vgaFile1), res, sprite_id);  	dumpVideoScript(ptr, false);  	printf("; end\n");  } -void AGOSEngine::dump_vga_script(const byte *ptr, uint res, uint sprite_id) { -	dump_vga_script_always(ptr, res, sprite_id); +void AGOSEngine::dumpVgaScript(const byte *ptr, uint res, uint sprite_id) { +	dumpVgaScriptAlways(ptr, res, sprite_id);  }  } // End of namespace AGOS diff --git a/engines/agos/draw.cpp b/engines/agos/draw.cpp index 7a99d69265..4b548d64ba 100644 --- a/engines/agos/draw.cpp +++ b/engines/agos/draw.cpp @@ -328,10 +328,10 @@ void AGOSEngine::displayBoxStars() {  			}  		} while (ha++, --count); -		dx_update_screen_and_palette(); +		updateScreen();  		delay(100);  		animateSprites(); -		dx_update_screen_and_palette(); +		updateScreen();  		delay(100);  	} @@ -401,7 +401,7 @@ void AGOSEngine::clearBackFromTop(uint lines) {  	memset(_backBuf, 0, lines * _screenWidth);  } -void AGOSEngine::dx_clear_surfaces(uint num_lines) { +void AGOSEngine::clearSurfaces(uint num_lines) {  	memset(_backBuf, 0, num_lines * _screenWidth);  	_system->copyRectToScreen(_backBuf, _screenWidth, 0, 0, _screenWidth, num_lines); @@ -440,7 +440,7 @@ void AGOSEngine::fillBackGroundFromBack(uint lines) {  	memcpy(_backGroundBuf, _backBuf, lines * _screenWidth);  } -void AGOSEngine::dx_update_screen_and_palette() { +void AGOSEngine::updateScreen() {  	if (_fastFadeInFlag == 0 && _paletteFlag == 1) {  		_paletteFlag = 0;  		if (memcmp(_displayPalette, _currentPalette, 1024)) { diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp index 4cef41ac54..f5a03ea9e1 100644 --- a/engines/agos/event.cpp +++ b/engines/agos/event.cpp @@ -528,7 +528,7 @@ void AGOSEngine::timer_proc1() {  			}  		}  		handleMouseMoved(); -		dx_update_screen_and_palette(); +		updateScreen();  		_updateScreen = false;  	} diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp index e3f81b4038..cd3b9d09b6 100644 --- a/engines/agos/gfx.cpp +++ b/engines/agos/gfx.cpp @@ -740,4 +740,24 @@ void AGOSEngine::scaleClip(int16 h, int16 w, int16 y, int16 x, int16 scrollY) {  	}  } +void AGOSEngine::paletteFadeOut(byte *palPtr, uint num, uint size) { +	byte *p = palPtr; + +	do { +		if (p[0] >= size) +			p[0] -= size; +		else +			p[0] = 0; +		if (p[1] >= size) +			p[1] -= size; +		else +			p[1] = 0; +		if (p[2] >= size) +			p[2] -= size; +		else +			p[2] = 0; +		p += 4; +	} while (--num); +} +  } // End of namespace AGOS diff --git a/engines/agos/icons.cpp b/engines/agos/icons.cpp index cbccc4495a..7738c8cf25 100644 --- a/engines/agos/icons.cpp +++ b/engines/agos/icons.cpp @@ -681,15 +681,15 @@ void AGOSEngine::removeIconArray(uint num) {  	}  	for (i = 0; window->iconPtr->iconArray[i].item != NULL; i++) { -		delete_hitarea_by_index(window->iconPtr->iconArray[i].boxCode); +		freeBox(window->iconPtr->iconArray[i].boxCode);  	}  	if (window->iconPtr->upArrow != -1) { -		delete_hitarea_by_index(window->iconPtr->upArrow); +		freeBox(window->iconPtr->upArrow);  	}  	if (window->iconPtr->downArrow != -1) { -		delete_hitarea_by_index(window->iconPtr->downArrow); +		freeBox(window->iconPtr->downArrow);  		removeArrows(window, num);  	} diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp index c20d963c92..c07cae713a 100644 --- a/engines/agos/input.cpp +++ b/engines/agos/input.cpp @@ -371,14 +371,14 @@ void AGOSEngine::hitarea_stuff_helper_2() {  void AGOSEngine::permitInput() {  	if (!_mortalFlag) {  		_mortalFlag = true; -		showmessage_print_char(0); +		justifyOutPut(0);  		_curWindow = 0;  		if (_windowArray[0] != 0) {  			_textWindow = _windowArray[0];  			if (getGameType() == GType_FF || getGameType() == GType_PP) -				showmessage_helper_3(_textWindow->textColumn, _textWindow->width); +				justifyStart(_textWindow->textColumn, _textWindow->width);  			else -				showmessage_helper_3(_textWindow->textLength, _textWindow->textMaxLength); +				justifyStart(_textWindow->textLength, _textWindow->textMaxLength);  		}  		_mortalFlag = false;  	} @@ -465,10 +465,10 @@ bool AGOSEngine::processSpecialKeys() {  				_speech ^= 1;  		}  	case '+': -		midi.set_volume(midi.get_volume() + 16); +		midi.setVolume(midi.getVolume() + 16);  		break;  	case '-': -		midi.set_volume(midi.get_volume() - 16); +		midi.setVolume(midi.getVolume() - 16);  		break;  	case 'm':  		midi.pause(_musicPaused ^= 1); diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp index a70668eb98..f054d429a1 100644 --- a/engines/agos/midi.cpp +++ b/engines/agos/midi.cpp @@ -255,7 +255,7 @@ void MidiPlayer::pause(bool b) {  	}  } -void MidiPlayer::set_volume(int volume) { +void MidiPlayer::setVolume(int volume) {  	if (volume < 0)  		volume = 0;  	else if (volume > 255) @@ -277,7 +277,7 @@ void MidiPlayer::set_volume(int volume) {  	}  } -void MidiPlayer::set_driver(MidiDriver *md) { +void MidiPlayer::setDriver(MidiDriver *md) {  	// Don't try to set this more than once.  	if (_driver)  		return; diff --git a/engines/agos/midi.h b/engines/agos/midi.h index 36faf1cbb2..b10460bf3a 100644 --- a/engines/agos/midi.h +++ b/engines/agos/midi.h @@ -101,9 +101,9 @@ public:  	void stop();  	void pause(bool b); -	int  get_volume() { return _masterVolume; } -	void set_volume(int volume); -	void set_driver(MidiDriver *md); +	int  getVolume() { return _masterVolume; } +	void setVolume(int volume); +	void setDriver(MidiDriver *md);  public:  	// MidiDriver interface implementation diff --git a/engines/agos/module.mk b/engines/agos/module.mk index 3fc03a21e3..a311508d47 100644 --- a/engines/agos/module.mk +++ b/engines/agos/module.mk @@ -21,6 +21,7 @@ MODULE_OBJS := \  	oracle.o \  	res.o \  	res_ami.o \ +	res_snd.o \  	rooms.o \  	saveload.o \  	script.o \ diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp index 2b68d3d0ec..68b7ab5fe9 100644 --- a/engines/agos/res.cpp +++ b/engines/agos/res.cpp @@ -756,201 +756,4 @@ void AGOSEngine::loadVGAVideoFile(uint id, uint type) {  	}  } -static const byte elvira1_soundTable[100] = { -	0, 2, 0, 1, 0, 0, 0, 0, 0, 3, -	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -	0, 0, 0, 0, 6, 4, 0, 0, 9, 0, -	0, 2, 0, 0, 0, 0, 0, 0, 0, 0, -	0, 8, 0, 0, 0, 0, 0, 0, 0, 0, -	1, 1, 0, 0, 5, 0, 6, 6, 0, 0, -	0, 5, 0, 0, 6, 0, 0, 0, 0, 8, -	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -bool AGOSEngine::loadVGASoundFile(uint id, uint type) { -	File in; -	char filename[15]; -	byte *dst; -	uint32 srcSize, dstSize; - -	if (getPlatform() == Common::kPlatformAmiga || getPlatform() == Common::kPlatformAtariST) { -		if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) { -			if (id == 20) -				sprintf(filename, "D%d.out", type); -			else if (id == 26) -				sprintf(filename, "J%d.out", type); -			else if (id == 27) -				sprintf(filename, "K%d.out", type); -			else if (id == 33) -				sprintf(filename, "Q%d.out", type); -			else if (id == 34) -				sprintf(filename, "R%d.out", type); -			else -				sprintf(filename, "%.1d%d.out", id, type); -		} else if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2) { -			sprintf(filename, "%.2d%d.out", id, type); -		} else { -			sprintf(filename, "%.3d%d.out", id, type); -		} -	} else { -		if (getGameType() == GType_ELVIRA1) { -			if (elvira1_soundTable[id] == 0) -				return false; - -			sprintf(filename, "%.2d.SND", elvira1_soundTable[id]); -		} else if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) { -			sprintf(filename, "%.2d%d.VGA", id, type); -		} else { -			sprintf(filename, "%.3d%d.VGA", id, type); -		} -	} - -	in.open(filename); -	if (in.isOpen() == false || in.size() == 0) { -		return false; -	} - -	dstSize = srcSize = in.size(); -	if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) { -		byte *srcBuffer = (byte *)malloc(srcSize); -		if (in.read(srcBuffer, srcSize) != srcSize) -			error("loadVGASoundFile: Read failed"); - -		dstSize = READ_BE_UINT32(srcBuffer + srcSize - 4); -		dst = allocBlock (dstSize); -		decrunchFile(srcBuffer, dst, srcSize); -		free(srcBuffer); -	} else { -		dst = allocBlock(dstSize); -		if (in.read(dst, dstSize) != dstSize) -			error("loadVGASoundFile: Read failed"); -	} -	in.close(); - -	return true; -} - -static const char *dimpSoundList[32] = { -	"Beep", -	"Birth", -	"Boiling", -	"Burp", -	"Cough", -	"Die1", -	"Die2", -	"Fart", -	"Inject", -	"Killchik", -	"Puke", -	"Lights", -	"Shock", -	"Snore", -	"Snotty", -	"Whip", -	"Whistle", -	"Work1", -	"Work2", -	"Yawn", -	"And0w", -	"And0x", -	"And0y", -	"And0z", -	"And10", -	"And11", -	"And12", -	"And13", -	"And14", -	"And15", -	"And16", -	"And17", -}; - - -void AGOSEngine::loadSound(uint sound, int pan, int vol, uint type) { -	byte *dst; - -	if (getGameId() == GID_DIMP) { -		File in; -		char filename[15]; - -		assert(sound >= 1 && sound <= 32); -		sprintf(filename, "%s.wav", dimpSoundList[sound - 1]); - -		in.open(filename); -		if (in.isOpen() == false) -			error("loadSound: Can't load %s", filename); - -		uint32 dstSize = in.size(); -		dst = (byte *)malloc(dstSize); -		if (in.read(dst, dstSize) != dstSize) -			error("loadSound: Read failed"); -		in.close(); -	} else if (getFeatures() & GF_ZLIBCOMP) { -		char filename[15]; - -		uint32 file, offset, srcSize, dstSize; -		if (getPlatform() == Common::kPlatformAmiga) { -			loadOffsets((const char*)"sfxindex.dat", _zoneNumber * 22 + sound, file, offset, srcSize, dstSize); -		} else { -			loadOffsets((const char*)"effects.wav", _zoneNumber * 22 + sound, file, offset, srcSize, dstSize); -		} - -		if (getPlatform() == Common::kPlatformAmiga) -			sprintf(filename, "sfx%d.wav", file); -		else -			sprintf(filename, "effects.wav"); - -		dst = (byte *)malloc(dstSize); -		decompressData(filename, dst, offset, srcSize, dstSize); -	} else { -		if (!_curSfxFile) -			error("loadSound: Can't load sound data file '%d3.VGA'", _zoneNumber); - -		dst = _curSfxFile + READ_LE_UINT32(_curSfxFile + sound * 4); -	} - -	if (type == 3) -		_sound->playSfx5Data(dst, sound, pan, vol); -	else if (type == 2) -		_sound->playAmbientData(dst, sound, pan, vol); -	else -		_sound->playSfxData(dst, sound, pan, vol); -} - -void AGOSEngine::loadVoice(uint speechId) { -	if (getGameType() == GType_PP && speechId == 99) { -		_sound->stopVoice(); -		return; -	} - -	if (getFeatures() & GF_ZLIBCOMP) { -		char filename[15]; - -		uint32 file, offset, srcSize, dstSize; -		if (getPlatform() == Common::kPlatformAmiga) { -			loadOffsets((const char*)"spindex.dat", speechId, file, offset, srcSize, dstSize); -		} else { -			loadOffsets((const char*)"speech.wav", speechId, file, offset, srcSize, dstSize); -		} - -		// Voice segment doesn't exist -		if (offset == 0xFFFFFFFF && srcSize == 0xFFFFFFFF && dstSize == 0xFFFFFFFF) { -			debug(0, "loadVoice: speechId %d removed", speechId); -			return; -		} - -		if (getPlatform() == Common::kPlatformAmiga) -			sprintf(filename, "sp%d.wav", file); -		else -			sprintf(filename, "speech.wav"); - -		byte *dst = (byte *)malloc(dstSize); -		decompressData(filename, dst, offset, srcSize, dstSize); -		_sound->playVoiceData(dst, speechId); -	} else { -		_sound->playVoice(speechId); -	} -} -  } // End of namespace AGOS diff --git a/engines/agos/res_snd.cpp b/engines/agos/res_snd.cpp new file mode 100644 index 0000000000..37b34c2269 --- /dev/null +++ b/engines/agos/res_snd.cpp @@ -0,0 +1,443 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001  Ludvig Strigeus + * Copyright (C) 2001-2006 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. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" + +#include "common/config-manager.h" +#include "common/file.h" + +#include "agos/intern.h" +#include "agos/agos.h" +#include "agos/vga.h" + +#include "sound/mididrv.h" +#include "sound/mods/protracker.h" + +using Common::File; + +namespace AGOS { + +void AGOSEngine::playSpeech(uint speech_id, uint vgaSpriteId) { +	if (getGameType() == GType_SIMON1) { +		if (speech_id == 9999) { +			if (_subtitles) +				return; +			if (!getBitFlag(14) && !getBitFlag(28)) { +				setBitFlag(14, true); +				_variableArray[100] = 15; +				animate(4, 1, 130, 0, 0, 0); +				waitForSync(130); +			} +			_skipVgaWait = true; +		} else { +			if (_subtitles && _scriptVar2) { +				animate(4, 2, 204, 0, 0, 0); +				waitForSync(204); +				stopAnimateSimon1(204); +			} +			stopAnimateSimon1(vgaSpriteId + 201); +			loadVoice(speech_id); +			animate(4, 2, vgaSpriteId + 201, 0, 0, 0); +		} +	} else { +		if (speech_id == 0xFFFF) { +			if (_subtitles) +				return; +			if (!getBitFlag(14) && !getBitFlag(28)) { +				setBitFlag(14, true); +				_variableArray[100] = 5; +				animate(4, 1, 30, 0, 0, 0); +				waitForSync(130); +			} +			_skipVgaWait = true; +		} else { +			if (getGameType() == GType_SIMON2 && _subtitles && _language != Common::HB_ISR) { +				loadVoice(speech_id); +				return; +			} + +			if (_subtitles && _scriptVar2) { +				animate(4, 2, 5, 0, 0, 0); +				waitForSync(205); +				stopAnimateSimon2(2,5); +			} + +			stopAnimateSimon2(2, vgaSpriteId + 2); +			loadVoice(speech_id); +			animate(4, 2, vgaSpriteId + 2, 0, 0, 0); +		} +	} +} + +void AGOSEngine::skipSpeech() { +	_sound->stopVoice(); +	if (!getBitFlag(28)) { +		setBitFlag(14, true); +		if (getGameType() == GType_FF) { +			_variableArray[103] = 5; +			animate(4, 2, 13, 0, 0, 0); +			waitForSync(213); +			stopAnimateSimon2(2, 1); +		} else if (getGameType() == GType_SIMON2) { +			_variableArray[100] = 5; +			animate(4, 1, 30, 0, 0, 0); +			waitForSync(130); +			stopAnimateSimon2(2, 1); +		} else { +			_variableArray[100] = 15; +			animate(4, 1, 130, 0, 0, 0); +			waitForSync(130); +			stopAnimateSimon1(1); +		} +	} +} + +void AGOSEngine::loadMusic(uint music) { +	char buf[4]; + +	if (getPlatform() == Common::kPlatformAtariST) { +		// TODO: Add support for music format used by Elvira 2 +	} else if (getPlatform() == Common::kPlatformAmiga) { +		_modPlayer->stop(); + +		char filename[15]; +		File f; + +		if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) +			sprintf(filename, "elvira2"); +		else +			sprintf(filename, "%dtune", music); + +		f.open(filename); +		if (f.isOpen() == false) { +			error("loadMusic: Can't load module from '%s'", filename); +		} + +		if (!(getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) && +			getFeatures() & GF_CRUNCHED) { +			uint srcSize = f.size(); +			byte *srcBuf = (byte *)malloc(srcSize); +			if (f.read(srcBuf, srcSize) != srcSize) +				error("loadMusic: Read failed"); + +			uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4); +			byte *dstBuf = (byte *)malloc(dstSize); +			decrunchFile(srcBuf, dstBuf, srcSize); +			free(srcBuf); + +			Common::MemoryReadStream stream(dstBuf, dstSize); +			_modPlayer->loadModuleStream(stream); +		} else { +			_modPlayer->loadModuleStream(f); +		} +		_modPlayer->start(); +	} else if (getGameType() == GType_SIMON2) { +		midi.stop(); +		_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET); +		_gameFile->read(buf, 4); +		if (!memcmp(buf, "FORM", 4)) { +			_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET); +			midi.loadXMIDI (_gameFile); +		} else { +			_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET); +			midi.loadMultipleSMF (_gameFile); +		} + +		_lastMusicPlayed = music; +		_nextMusicToPlay = -1; +	} else if (getGameType() == GType_SIMON1) { +		midi.stop(); +		midi.setLoop (true); // Must do this BEFORE loading music. (GMF may have its own override.) + +		if (getFeatures() & GF_TALKIE) { +			// FIXME: The very last music resource, a cymbal crash for when the +			// two demons crash into each other, should NOT be looped like the +			// other music tracks. In simon1dos/talkie the GMF resource includes +			// a loop override that acomplishes this, but there seems to be nothing +			// for this in the SMF resources. +			if (music == 35) +				midi.setLoop (false); + +			_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET); +			_gameFile->read(buf, 4); +			if (!memcmp(buf, "GMF\x1", 4)) { +				_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET); +				midi.loadSMF (_gameFile, music); +			} else { +				_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET); +				midi.loadMultipleSMF (_gameFile); +			} + +		} else { +			char filename[15]; +			File f; +			sprintf(filename, "MOD%d.MUS", music); +			f.open(filename); +			if (f.isOpen() == false) +				error("loadMusic: Can't load music from '%s'", filename); + +			if (getFeatures() & GF_DEMO) +				midi.loadS1D (&f); +			else +				midi.loadSMF (&f, music); +		} + +		midi.startTrack (0); +	} else { +		midi.stop(); +		midi.setLoop (true); // Must do this BEFORE loading music. + +		char filename[15]; +		File f; +		sprintf(filename, "MOD%d.MUS", music); +		f.open(filename); +		if (f.isOpen() == false) +			error("loadMusic: Can't load music from '%s'", filename); + +		midi.loadS1D (&f); +		midi.startTrack (0); +	} +} + +void AGOSEngine::playSting(uint a) { +	if (!midi._enable_sfx) +		return; + +	char filename[15]; + +	File mus_file; +	uint16 mus_offset; + +	sprintf(filename, "STINGS%i.MUS", _soundFileId); +	mus_file.open(filename); +	if (!mus_file.isOpen()) +		error("playSting: Can't load sound effect from '%s'", filename); + +	mus_file.seek(a * 2, SEEK_SET); +	mus_offset = mus_file.readUint16LE(); +	if (mus_file.ioFailed()) +		error("playSting: Can't read sting %d offset", a); + +	mus_file.seek(mus_offset, SEEK_SET); +	midi.loadSMF(&mus_file, a, true); +	midi.startTrack(0); +} + +static const byte elvira1_soundTable[100] = { +	0, 2, 0, 1, 0, 0, 0, 0, 0, 3, +	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +	0, 0, 0, 0, 6, 4, 0, 0, 9, 0, +	0, 2, 0, 0, 0, 0, 0, 0, 0, 0, +	0, 8, 0, 0, 0, 0, 0, 0, 0, 0, +	1, 1, 0, 0, 5, 0, 6, 6, 0, 0, +	0, 5, 0, 0, 6, 0, 0, 0, 0, 8, +	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +bool AGOSEngine::loadVGASoundFile(uint id, uint type) { +	File in; +	char filename[15]; +	byte *dst; +	uint32 srcSize, dstSize; + +	if (getPlatform() == Common::kPlatformAmiga || getPlatform() == Common::kPlatformAtariST) { +		if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) { +			if (id == 20) +				sprintf(filename, "D%d.out", type); +			else if (id == 26) +				sprintf(filename, "J%d.out", type); +			else if (id == 27) +				sprintf(filename, "K%d.out", type); +			else if (id == 33) +				sprintf(filename, "Q%d.out", type); +			else if (id == 34) +				sprintf(filename, "R%d.out", type); +			else +				sprintf(filename, "%.1d%d.out", id, type); +		} else if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2) { +			sprintf(filename, "%.2d%d.out", id, type); +		} else { +			sprintf(filename, "%.3d%d.out", id, type); +		} +	} else { +		if (getGameType() == GType_ELVIRA1) { +			if (elvira1_soundTable[id] == 0) +				return false; + +			sprintf(filename, "%.2d.SND", elvira1_soundTable[id]); +		} else if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) { +			sprintf(filename, "%.2d%d.VGA", id, type); +		} else { +			sprintf(filename, "%.3d%d.VGA", id, type); +		} +	} + +	in.open(filename); +	if (in.isOpen() == false || in.size() == 0) { +		return false; +	} + +	dstSize = srcSize = in.size(); +	if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) { +		byte *srcBuffer = (byte *)malloc(srcSize); +		if (in.read(srcBuffer, srcSize) != srcSize) +			error("loadVGASoundFile: Read failed"); + +		dstSize = READ_BE_UINT32(srcBuffer + srcSize - 4); +		dst = allocBlock (dstSize); +		decrunchFile(srcBuffer, dst, srcSize); +		free(srcBuffer); +	} else { +		dst = allocBlock(dstSize); +		if (in.read(dst, dstSize) != dstSize) +			error("loadVGASoundFile: Read failed"); +	} +	in.close(); + +	return true; +} + +static const char *dimpSoundList[32] = { +	"Beep", +	"Birth", +	"Boiling", +	"Burp", +	"Cough", +	"Die1", +	"Die2", +	"Fart", +	"Inject", +	"Killchik", +	"Puke", +	"Lights", +	"Shock", +	"Snore", +	"Snotty", +	"Whip", +	"Whistle", +	"Work1", +	"Work2", +	"Yawn", +	"And0w", +	"And0x", +	"And0y", +	"And0z", +	"And10", +	"And11", +	"And12", +	"And13", +	"And14", +	"And15", +	"And16", +	"And17", +}; + + +void AGOSEngine::loadSound(uint sound, int pan, int vol, uint type) { +	byte *dst; + +	if (getGameId() == GID_DIMP) { +		File in; +		char filename[15]; + +		assert(sound >= 1 && sound <= 32); +		sprintf(filename, "%s.wav", dimpSoundList[sound - 1]); + +		in.open(filename); +		if (in.isOpen() == false) +			error("loadSound: Can't load %s", filename); + +		uint32 dstSize = in.size(); +		dst = (byte *)malloc(dstSize); +		if (in.read(dst, dstSize) != dstSize) +			error("loadSound: Read failed"); +		in.close(); +	} else if (getFeatures() & GF_ZLIBCOMP) { +		char filename[15]; + +		uint32 file, offset, srcSize, dstSize; +		if (getPlatform() == Common::kPlatformAmiga) { +			loadOffsets((const char*)"sfxindex.dat", _zoneNumber * 22 + sound, file, offset, srcSize, dstSize); +		} else { +			loadOffsets((const char*)"effects.wav", _zoneNumber * 22 + sound, file, offset, srcSize, dstSize); +		} + +		if (getPlatform() == Common::kPlatformAmiga) +			sprintf(filename, "sfx%d.wav", file); +		else +			sprintf(filename, "effects.wav"); + +		dst = (byte *)malloc(dstSize); +		decompressData(filename, dst, offset, srcSize, dstSize); +	} else { +		if (!_curSfxFile) +			error("loadSound: Can't load sound data file '%d3.VGA'", _zoneNumber); + +		dst = _curSfxFile + READ_LE_UINT32(_curSfxFile + sound * 4); +	} + +	if (type == 3) +		_sound->playSfx5Data(dst, sound, pan, vol); +	else if (type == 2) +		_sound->playAmbientData(dst, sound, pan, vol); +	else +		_sound->playSfxData(dst, sound, pan, vol); +} + +void AGOSEngine::loadVoice(uint speechId) { +	if (getGameType() == GType_PP && speechId == 99) { +		_sound->stopVoice(); +		return; +	} + +	if (getFeatures() & GF_ZLIBCOMP) { +		char filename[15]; + +		uint32 file, offset, srcSize, dstSize; +		if (getPlatform() == Common::kPlatformAmiga) { +			loadOffsets((const char*)"spindex.dat", speechId, file, offset, srcSize, dstSize); +		} else { +			loadOffsets((const char*)"speech.wav", speechId, file, offset, srcSize, dstSize); +		} + +		// Voice segment doesn't exist +		if (offset == 0xFFFFFFFF && srcSize == 0xFFFFFFFF && dstSize == 0xFFFFFFFF) { +			debug(0, "loadVoice: speechId %d removed", speechId); +			return; +		} + +		if (getPlatform() == Common::kPlatformAmiga) +			sprintf(filename, "sp%d.wav", file); +		else +			sprintf(filename, "speech.wav"); + +		byte *dst = (byte *)malloc(dstSize); +		decompressData(filename, dst, offset, srcSize, dstSize); +		_sound->playVoiceData(dst, speechId); +	} else { +		_sound->playVoice(speechId); +	} +} + +} // End of namespace AGOS diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index 09581ca4bd..22225165f2 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -724,9 +724,9 @@ void AGOSEngine::o_defWindow() {  	if (num == _curWindow) {  		_textWindow = _windowArray[num];  		if (getGameType() == GType_FF || getGameType() == GType_PP) -			showmessage_helper_3(_textWindow->textColumn, _textWindow->width); +			justifyStart(_textWindow->textColumn, _textWindow->width);  		else -			showmessage_helper_3(_textWindow->textLength, _textWindow->textMaxLength); +			justifyStart(_textWindow->textLength, _textWindow->textMaxLength);  	}  } @@ -1506,17 +1506,6 @@ void AGOSEngine::waitForMark(uint i) {  	}  } -void AGOSEngine::freezeBottom() { -	_vgaMemBase = _vgaMemPtr; -	_vgaFrozenBase = _vgaMemPtr; -} - -void AGOSEngine::unfreezeBottom() { -	_vgaMemPtr = _vgaRealBase; -	_vgaMemBase = _vgaRealBase; -	_vgaFrozenBase = _vgaRealBase; -} -  void AGOSEngine::sendSync(uint a) {  	uint16 id = to16Wrapper(a);  	_lockWord |= 0x8000; @@ -1552,12 +1541,4 @@ void AGOSEngine::stopAnimateSimon2(uint a, uint b) {  	_lockWord &= ~0x8000;  } -int16 AGOSEngine::levelOf(Item *item) { -	SubPlayer *p = (SubPlayer *) findChildOfType(item, 3); -	if (p == NULL) -		return 0; - -	return p->level; -} -  } // End of namespace AGOS diff --git a/engines/agos/string.cpp b/engines/agos/string.cpp index 9ab4d4c07a..44ed983bbb 100644 --- a/engines/agos/string.cpp +++ b/engines/agos/string.cpp @@ -726,11 +726,11 @@ void AGOSEngine::printBox() {  	_textWindow->textRow = 0;  	_textWindow->textColumnOffset = 0;  	_textWindow->textLength = 0; -	showmessage_helper_3(_textWindow->textLength, _textWindow->textMaxLength); +	justifyStart(_textWindow->textLength, _textWindow->textMaxLength);  	waitForSync(99);  	BoxBufferPtr = _boxBuffer;  	while (*BoxBufferPtr) -		showmessage_print_char(*BoxBufferPtr++); +		justifyOutPut(*BoxBufferPtr++);  	_boxLineCount = 0;  	BoxBufferPtr = _boxBuffer;  	_lineCounts[0] = 0; @@ -844,13 +844,13 @@ void AGOSEngine::writeChar(WindowBlock *window, int x, int y, int offs, int val)  	// Clear background of first digit  	window->textColumnOffset = offs;  	window->text_color = 0; -	video_putchar_drawchar(window, x * 8, y, 129); +	windowDrawChar(window, x * 8, y, 129);  	if (val != -1) {  		// Print first digit  		chr = val / 10 + 48;  		window->text_color = 15; -		video_putchar_drawchar(window, x * 8, y, chr); +		windowDrawChar(window, x * 8, y, chr);  	}  	offs += 6; @@ -862,13 +862,13 @@ void AGOSEngine::writeChar(WindowBlock *window, int x, int y, int offs, int val)  	// Clear background of second digit  	window->textColumnOffset = offs;  	window->text_color = 0; -	video_putchar_drawchar(window, x * 8, y, 129); +	windowDrawChar(window, x * 8, y, 129);  	if (val != -1) {  		// Print second digit  		chr = val % 10 + 48;  		window->text_color = 15; -		video_putchar_drawchar(window, x * 8, y, chr); +		windowDrawChar(window, x * 8, y, chr);  	}  } diff --git a/engines/agos/verb.cpp b/engines/agos/verb.cpp index 28231bd2f6..188f0ead96 100644 --- a/engines/agos/verb.cpp +++ b/engines/agos/verb.cpp @@ -393,7 +393,7 @@ HitArea *AGOSEngine::findEmptyHitArea() {  	return NULL;  } -void AGOSEngine::delete_hitarea_by_index(uint index) { +void AGOSEngine::freeBox(uint index) {  	CHECK_BOUNDS(index, _hitAreas);  	_hitAreas[index].flags = 0;  } diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp index c27a28cd5e..95587b1753 100644 --- a/engines/agos/vga.cpp +++ b/engines/agos/vga.cpp @@ -641,7 +641,7 @@ void AGOSEngine::vc10_draw() {  		return;  	if (_dumpImages) -		dump_single_bitmap(_vgaCurZoneNum, state.image, state.depack_src, width, height, +		dumpSingleBitmap(_vgaCurZoneNum, state.image, state.depack_src, width, height,  											 state.palette);  	// Check if image is compressed  	if (getGameType() == GType_FF || getGameType() == GType_PP) { @@ -1443,7 +1443,7 @@ void AGOSEngine::vc59_skipIfNotEGA() {  	vcSkipNextInstruction();  } -void AGOSEngine::vc_kill_sprite(uint file, uint sprite) { +void AGOSEngine::vcStopAnimation(uint file, uint sprite) {  	uint16 old_sprite_id, old_cur_file_id;  	VgaSleepStruct *vfs;  	VgaSprite *vsp; @@ -1502,7 +1502,7 @@ void AGOSEngine::vc60_stopAnimation() {  		sprite = vcReadNextWord();  	} -	vc_kill_sprite(zoneNum, sprite); +	vcStopAnimation(zoneNum, sprite);  }  void AGOSEngine::vc61() { @@ -1634,11 +1634,11 @@ void AGOSEngine::vc62_fastFadeOut() {  		// Allow one section of Simon the Sorcerer 1 introduction to be displayed  		// in lower half of screen  		if ((getGameType() == GType_SIMON1) && (_subroutine == 2923 || _subroutine == 2926)) { -			dx_clear_surfaces(200); +			clearSurfaces(200);  		} else if (getGameType() == GType_FF || getGameType() == GType_PP) { -			dx_clear_surfaces(480); +			clearSurfaces(480);  		} else { -			dx_clear_surfaces(_windowNum == 4 ? 134 : 200); +			clearSurfaces(_windowNum == 4 ? 134 : 200);  		}  	}  	if (getGameType() == GType_SIMON2) { @@ -1761,7 +1761,7 @@ void AGOSEngine::animate(uint windowNum, uint zoneNum, uint vgaSpriteId, uint x,  		static bool dumped = false;  		if (res == DUMP_FILE_NR && !dumped) {  			dumped = true; -			dump_vga_file(_curVgaFile1); +			dumpVgaFile(_curVgaFile1);  		}  	}  #endif @@ -1771,18 +1771,18 @@ void AGOSEngine::animate(uint windowNum, uint zoneNum, uint vgaSpriteId, uint x,  		static bool dumped = false;  		if (res == DUMP_BITMAPS_FILE_NR && !dumped) {  			dumped = true; -			dump_vga_bitmaps(_curVgaFile2, _curVgaFile1, zoneNum); +			dumpVgaBitmaps(_curVgaFile2, _curVgaFile1, zoneNum);  		}  	}  #endif  	if (_startVgaScript) {  		if (getGameType() == GType_FF || getGameType() == GType_PP) { -			dump_vga_script(_curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble*)p)->scriptOffs), zoneNum, vgaSpriteId); +			dumpVgaScript(_curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble*)p)->scriptOffs), zoneNum, vgaSpriteId);  		} else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { -			dump_vga_script(_curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_Simon*)p)->scriptOffs), zoneNum, vgaSpriteId); +			dumpVgaScript(_curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_Simon*)p)->scriptOffs), zoneNum, vgaSpriteId);  		} else { -			dump_vga_script(_curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_WW*)p)->scriptOffs), zoneNum, vgaSpriteId); +			dumpVgaScript(_curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_WW*)p)->scriptOffs), zoneNum, vgaSpriteId);  		}  	} @@ -1872,11 +1872,11 @@ void AGOSEngine::setImage(uint16 vga_res_id, bool setZone) {  	if (_startVgaScript) {  		if (getGameType() == GType_FF || getGameType() == GType_PP) { -			dump_vga_script(_curVgaFile1 + READ_LE_UINT16(&((ImageHeader_Feeble*)b)->scriptOffs), zoneNum, vga_res_id); +			dumpVgaScript(_curVgaFile1 + READ_LE_UINT16(&((ImageHeader_Feeble*)b)->scriptOffs), zoneNum, vga_res_id);  		} else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { -			dump_vga_script(_curVgaFile1 + READ_BE_UINT16(&((ImageHeader_Simon*)b)->scriptOffs), zoneNum, vga_res_id); +			dumpVgaScript(_curVgaFile1 + READ_BE_UINT16(&((ImageHeader_Simon*)b)->scriptOffs), zoneNum, vga_res_id);  		} else { -			dump_vga_script(_curVgaFile1 + READ_BE_UINT16(&((ImageHeader_WW*)b)->scriptOffs), zoneNum, vga_res_id); +			dumpVgaScript(_curVgaFile1 + READ_BE_UINT16(&((ImageHeader_WW*)b)->scriptOffs), zoneNum, vga_res_id);  		}  	} diff --git a/engines/agos/vga_s2.cpp b/engines/agos/vga_s2.cpp index 4711b4cc36..4f1bce40ac 100644 --- a/engines/agos/vga_s2.cpp +++ b/engines/agos/vga_s2.cpp @@ -81,7 +81,7 @@ void AGOSEngine::vc59_stopAnimations() {  	uint16 end = vcReadNextWord() + 1;  	do { -		vc_kill_sprite(file, start); +		vcStopAnimation(file, start);  	} while (++start != end);  } diff --git a/engines/agos/window.cpp b/engines/agos/window.cpp index eda2b9d9db..129ad193ba 100644 --- a/engines/agos/window.cpp +++ b/engines/agos/window.cpp @@ -76,13 +76,13 @@ void AGOSEngine::changeWindow(uint a) {  		return;  	_curWindow = a; -	showmessage_print_char(0); +	justifyOutPut(0);  	_textWindow = _windowArray[a];  	if (getGameType() == GType_FF || getGameType() == GType_PP) -		showmessage_helper_3(_textWindow->textColumn, _textWindow->width); +		justifyStart(_textWindow->textColumn, _textWindow->width);  	else -		showmessage_helper_3(_textWindow->textLength, _textWindow->textMaxLength); +		justifyStart(_textWindow->textLength, _textWindow->textMaxLength);  }  void AGOSEngine::closeWindow(uint a) { diff --git a/engines/agos/zones.cpp b/engines/agos/zones.cpp index 7316f15f4f..e8d2077f4b 100644 --- a/engines/agos/zones.cpp +++ b/engines/agos/zones.cpp @@ -31,6 +31,17 @@  namespace AGOS { +void AGOSEngine::freezeBottom() { +	_vgaMemBase = _vgaMemPtr; +	_vgaFrozenBase = _vgaMemPtr; +} + +void AGOSEngine::unfreezeBottom() { +	_vgaMemPtr = _vgaRealBase; +	_vgaMemBase = _vgaRealBase; +	_vgaFrozenBase = _vgaRealBase; +} +  void AGOSEngine::loadZone(uint zoneNum) {  	VgaPointersEntry *vpe; | 
