diff options
Diffstat (limited to 'engines/agi')
| -rw-r--r-- | engines/agi/agi.cpp | 16 | ||||
| -rw-r--r-- | engines/agi/agi.h | 3 | ||||
| -rw-r--r-- | engines/agi/cycle.cpp | 8 | ||||
| -rw-r--r-- | engines/agi/detection.cpp | 33 | ||||
| -rw-r--r-- | engines/agi/loader_v3.cpp | 4 | ||||
| -rw-r--r-- | engines/agi/op_cmd.cpp | 8 | ||||
| -rw-r--r-- | engines/agi/op_test.cpp | 3 | ||||
| -rw-r--r-- | engines/agi/preagi.cpp | 3 | ||||
| -rw-r--r-- | engines/agi/preagi_common.cpp | 7 | ||||
| -rw-r--r-- | engines/agi/preagi_mickey.cpp | 14 | ||||
| -rw-r--r-- | engines/agi/preagi_troll.cpp | 11 | ||||
| -rw-r--r-- | engines/agi/preagi_winnie.cpp | 11 | ||||
| -rw-r--r-- | engines/agi/saveload.cpp | 5 | 
13 files changed, 79 insertions, 47 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 9d88dd73ef..d67e16d196 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -25,7 +25,6 @@  #include "common/md5.h" -#include "common/events.h"  #include "common/file.h"  #include "common/savefile.h"  #include "common/config-manager.h" @@ -61,9 +60,6 @@ void AgiEngine::processEvents() {  	while (_eventMan->pollEvent(event)) {  		switch (event.type) { -		case Common::EVENT_QUIT: -			_game.quitProgNow = true; -			break;  		case Common::EVENT_PREDICTIVE_DIALOG:  			if (_predictiveDialogRunning)  				break; @@ -809,7 +805,17 @@ int AgiEngine::go() {  	runGame(); -	return 0; +	return _eventMan->shouldRTL(); +} + +void AgiEngine::syncSoundSettings() { +	int soundVolumeMusic = ConfMan.getInt("music_volume"); +	int soundVolumeSFX = ConfMan.getInt("music_volume"); +	int soundVolumeSpeech = ConfMan.getInt("music_volume"); + +	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic); +	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolumeSFX); +	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech);  }  } // End of namespace Agi diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 9240d562af..ec290b812d 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -530,7 +530,6 @@ struct AgiGame {  	/* internal flags */  	int playerControl;		/**< player is in control */ -	int quitProgNow;		/**< quit now */  	int statusLine;		/**< status line on/off */  	int clockEnabled;		/**< clock is on/off */  	int exitAllLogics;	/**< break cycle after new.room */ @@ -754,6 +753,8 @@ public:  		return _gameId;  	} +	virtual void syncSoundSettings(); +  private:  	int _keyQueue[KEY_QUEUE_SIZE]; diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp index e0babdf926..3ceaaa8c90 100644 --- a/engines/agi/cycle.cpp +++ b/engines/agi/cycle.cpp @@ -24,7 +24,6 @@   */ -  #include "agi/agi.h"  #include "agi/sprite.h"  #include "agi/graphics.h" @@ -116,7 +115,7 @@ void AgiEngine::interpretCycle() {  	oldSound = getflag(fSoundOn);  	_game.exitAllLogics = false; -	while (runLogic(0) == 0 && !_game.quitProgNow) { +	while (runLogic(0) == 0 && !quit()) {  		_game.vars[vWordNotFound] = 0;  		_game.vars[vBorderTouchObj] = 0;  		_game.vars[vBorderCode] = 0; @@ -314,7 +313,6 @@ int AgiEngine::playGame() {  	setvar(vTimeDelay, 2);	/* "normal" speed */  	_game.gfxMode = true; -	_game.quitProgNow = false;  	_game.clockEnabled = true;  	_game.lineUserInput = 22; @@ -354,10 +352,10 @@ int AgiEngine::playGame() {  			_game.vars[vKey] = 0;  		} -		if (_game.quitProgNow == 0xff) +		if (quit() == 0xff)  			ec = errRestartGame; -	} while (_game.quitProgNow == 0); +	} while (quit() == 0);  	_sound->stopSound(); diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index cd6942f9c0..8ddeae1b17 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -2123,7 +2123,7 @@ public:  	}  	virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const; - +	virtual SaveStateList listSaves(const char *target) const;  	const Common::ADGameDescription *fallbackDetect(const FSList *fslist) const;  }; @@ -2147,6 +2147,37 @@ bool AgiMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common:  	return res;  } +SaveStateList AgiMetaEngine::listSaves(const char *target) const { +	const uint32 AGIflag = MKID_BE('AGI:'); +	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); +	Common::StringList filenames; +	char saveDesc[31]; +	Common::String pattern = target; +	pattern += ".???"; + +	filenames = saveFileMan->listSavefiles(pattern.c_str()); +	sort(filenames.begin(), filenames.end());	// Sort (hopefully ensuring we are sorted numerically..) + +	SaveStateList saveList; +	for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { +		// Obtain the last 3 digits of the filename, since they correspond to the save slot +		int slotNum = atoi(file->c_str() + file->size() - 3); +		 +		if (slotNum >= 0 && slotNum <= 999) { +			Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str()); +			if (in) { +				uint32 type = in->readUint32BE(); +				if (type == AGIflag) +					in->read(saveDesc, 31); +				saveList.push_back(SaveStateDescriptor(slotNum, Common::String(saveDesc), *file)); +				delete in; +			} +		} +	} + +	return saveList; +} +  const Common::ADGameDescription *AgiMetaEngine::fallbackDetect(const FSList *fslist) const {  	typedef Common::HashMap<Common::String, int32> IntMap;  	IntMap allFiles; diff --git a/engines/agi/loader_v3.cpp b/engines/agi/loader_v3.cpp index dcf7d83809..9f1255a43a 100644 --- a/engines/agi/loader_v3.cpp +++ b/engines/agi/loader_v3.cpp @@ -230,8 +230,8 @@ uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) {  			debugC(3, kDebugLevelResources, "offset = %d", agid->offset);  			debugC(3, kDebugLevelResources, "x = %x %x", x[0], x[1]);  			error("ACK! BAD RESOURCE"); - -			g_system->quit(); +			 +			_vm->quitGame();  		}  		agid->len = READ_LE_UINT16((uint8 *) x + 3);	/* uncompressed size */ diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp index 7ecedfbc8c..758bff0cb6 100644 --- a/engines/agi/op_cmd.cpp +++ b/engines/agi/op_cmd.cpp @@ -1213,11 +1213,11 @@ cmd(quit) {  	g_sound->stopSound();  	if (p0) { -		game.quitProgNow = true; +		g_agi->quitGame();  	} else {  		if (g_agi->selectionBox  				(" Quit the game, or continue? \n\n\n", buttons) == 0) { -			game.quitProgNow = true; +			g_agi->quitGame();  		}  	}  } @@ -1231,7 +1231,7 @@ cmd(restart_game) {  		g_agi->selectionBox(" Restart game, or continue? \n\n\n", buttons);  	if (sel == 0) { -		game.quitProgNow = 0xff; +		g_agi->quitGame();  		g_agi->setflag(fRestartGame, true);  		g_agi->_menu->enableAll();  	} @@ -1739,7 +1739,7 @@ int AgiEngine::runLogic(int n) {  	curLogic->cIP = curLogic->sIP;  	timerHack = 0; -	while (ip < _game.logics[n].size && !_game.quitProgNow) { +	while (ip < _game.logics[n].size && !quit()) {  		if (_debug.enabled) {  			if (_debug.steps > 0) {  				if (_debug.logic0 || n) { diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp index 7ba3e625bf..393057ed9c 100644 --- a/engines/agi/op_test.cpp +++ b/engines/agi/op_test.cpp @@ -24,7 +24,6 @@   */ -  #include "agi/agi.h"  #include "agi/keyboard.h"  #include "agi/opcodes.h" @@ -232,7 +231,7 @@ int AgiEngine::testIfCode(int lognum) {  	uint8 p[16] = { 0 };  	bool end_test = false; -	while (retval && !game.quitProgNow && !end_test) { +	while (retval && !quit() && !end_test) {  		if (_debug.enabled && (_debug.logic0 || lognum))  			debugConsole(lognum, lTEST_MODE, NULL); diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp index f2301e012a..f391cd974a 100644 --- a/engines/agi/preagi.cpp +++ b/engines/agi/preagi.cpp @@ -23,7 +23,6 @@   *   */ -#include "common/events.h"  #include "common/file.h"  #include "common/savefile.h"  #include "common/config-manager.h" @@ -228,7 +227,7 @@ FIXME (Fingolfin asks): Why are Mickey, Winnie and Troll standalone classes  		error("Unknown preagi engine");  		break;  	} -	return 0; +	return _eventMan->shouldRTL();  }  } // End of namespace Agi diff --git a/engines/agi/preagi_common.cpp b/engines/agi/preagi_common.cpp index 5d99dfa7f9..3cd04351f7 100644 --- a/engines/agi/preagi_common.cpp +++ b/engines/agi/preagi_common.cpp @@ -23,8 +23,6 @@   *   */ -#include "common/events.h" -  #include "agi/preagi.h"  #include "agi/font.h"  #include "agi/graphics.h" @@ -122,11 +120,12 @@ void PreAgiEngine::printStrXOR(char *szMsg) {  int PreAgiEngine::getSelection(SelectionTypes type) {  	Common::Event event; -	for (;;) { +	while (!quit()) {  		while (_eventMan->pollEvent(event)) {  			switch(event.type) { +			case Common::EVENT_RTL:  			case Common::EVENT_QUIT: -				_system->quit(); +				return 0;  			case Common::EVENT_RBUTTONUP:  				return 0;  			case Common::EVENT_LBUTTONUP: diff --git a/engines/agi/preagi_mickey.cpp b/engines/agi/preagi_mickey.cpp index 08f8969ca3..5d89e96d59 100644 --- a/engines/agi/preagi_mickey.cpp +++ b/engines/agi/preagi_mickey.cpp @@ -23,7 +23,6 @@   *   */ -#include "common/events.h"  #include "common/savefile.h"  #include "common/stream.h" @@ -343,11 +342,12 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {  	drawMenu(menu, *sel0, *sel1); -	for (;;) { +	while (!_vm->quit()) {  		while (_vm->_system->getEventManager()->pollEvent(event)) {  			switch(event.type) { +			case Common::EVENT_RTL:  			case Common::EVENT_QUIT: -				exit(0); +				return 0;  			case Common::EVENT_MOUSEMOVE:  				if (iRow < 2) {  					x = event.mouse.x / 8; @@ -640,8 +640,8 @@ void Mickey::playSound(ENUM_MSA_SOUND iSound) {  			if (iSound == IDI_MSA_SND_THEME) {  				while (_vm->_system->getEventManager()->pollEvent(event)) {  					switch(event.type) { +					case Common::EVENT_RTL:  					case Common::EVENT_QUIT: -						_vm->_system->quit();  					case Common::EVENT_LBUTTONUP:  					case Common::EVENT_RBUTTONUP:  					case Common::EVENT_KEYDOWN: @@ -1214,7 +1214,7 @@ void Mickey::gameOver() {  	}  	waitAnyKey(); -	exit(0); +	_vm->quitGame();  }  void Mickey::flipSwitch() { @@ -2053,8 +2053,8 @@ void Mickey::waitAnyKey(bool anim) {  	for (;;) {  		while (_vm->_system->getEventManager()->pollEvent(event)) {  			switch(event.type) { +			case Common::EVENT_RTL:  			case Common::EVENT_QUIT: -				_vm->_system->quit();  			case Common::EVENT_KEYDOWN:  			case Common::EVENT_LBUTTONUP:  			case Common::EVENT_RBUTTONUP: @@ -2153,7 +2153,7 @@ void Mickey::run() {  	intro();  	// Game loop -	for (;;) { +	while (!_vm->quit()) {  		drawRoom();  		if (_game.fIntro) { diff --git a/engines/agi/preagi_troll.cpp b/engines/agi/preagi_troll.cpp index 7502c63c6c..beff721fda 100644 --- a/engines/agi/preagi_troll.cpp +++ b/engines/agi/preagi_troll.cpp @@ -30,8 +30,6 @@  #include "graphics/cursorman.h" -#include "common/events.h" -  namespace Agi {  Troll::Troll(PreAgiEngine* vm) : _vm(vm) { @@ -58,11 +56,12 @@ bool Troll::getMenuSel(const char *szMenu, int *iSel, int nSel) {  	drawMenu(szMenu, *iSel); -	for (;;) { +	while (!_vm->quit()) {  		while (_vm->_system->getEventManager()->pollEvent(event)) {  			switch(event.type) { +			case Common::EVENT_RTL:  			case Common::EVENT_QUIT: -				_vm->_system->quit(); +				return 0;  			case Common::EVENT_MOUSEMOVE:  				y = event.mouse.y / 8; @@ -205,8 +204,8 @@ void Troll::waitAnyKeyIntro() {  	for (;;) {  		while (_vm->_system->getEventManager()->pollEvent(event)) {  			switch(event.type) { +			case Common::EVENT_RTL:  			case Common::EVENT_QUIT: -				_vm->_system->quit();  			case Common::EVENT_LBUTTONUP:  			case Common::EVENT_KEYDOWN:  				return; @@ -269,7 +268,7 @@ void Troll::tutorial() {  	int iSel = 0;  	//char szTreasure[16] = {0}; -	for (;;) { +	while (!_vm->quit()) {  		_vm->clearScreen(0xFF);  		_vm->printStr(IDS_TRO_TUTORIAL_0); diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp index 87d13bff3d..bf023fe5e5 100644 --- a/engines/agi/preagi_winnie.cpp +++ b/engines/agi/preagi_winnie.cpp @@ -29,7 +29,6 @@  #include "graphics/cursorman.h" -#include "common/events.h"  #include "common/savefile.h"  #include "common/stream.h" @@ -241,7 +240,7 @@ int Winnie::parser(int pc, int index, uint8 *buffer) {  	// extract header from buffer  	parseRoomHeader(&hdr, buffer, sizeof(WTP_ROOM_HDR)); -	for (;;) { +	while (!_vm->quit()) {  		pc = startpc;  		// check if block is to be run @@ -797,12 +796,12 @@ void Winnie::getMenuSel(char *szMenu, int *iSel, int fCanSel[]) {  	// Show the mouse cursor for the menu  	CursorMan.showMouse(true); -	for (;;) { +	while (!_vm->quit()) {  		while (_vm->_system->getEventManager()->pollEvent(event)) {  			switch(event.type) { +			case Common::EVENT_RTL:  			case Common::EVENT_QUIT: -				_vm->_system->quit(); -				break; +				return;  			case Common::EVENT_MOUSEMOVE:  				x = event.mouse.x / 8;  				y = event.mouse.y / 8; @@ -1014,7 +1013,7 @@ phase2:  		if (parser(hdr.ofsDesc[iBlock] - _roomOffset, iBlock, roomdata) == IDI_WTP_PAR_BACK)  			goto phase1;  	} -	for (;;) { +	while (!_vm->quit()) {  		for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {  			switch(parser(hdr.ofsBlock[iBlock] - _roomOffset, iBlock, roomdata)) {  			case IDI_WTP_PAR_GOTO: diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index db7bba13e4..1589611c01 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -91,7 +91,7 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {  	out->writeSint16BE((int16)_game.lognum);  	out->writeSint16BE((int16)_game.playerControl); -	out->writeSint16BE((int16)_game.quitProgNow); +	out->writeSint16BE((int16)quit());  	out->writeSint16BE((int16)_game.statusLine);  	out->writeSint16BE((int16)_game.clockEnabled);  	out->writeSint16BE((int16)_game.exitAllLogics); @@ -281,7 +281,8 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {  	_game.lognum = in->readSint16BE();  	_game.playerControl = in->readSint16BE(); -	_game.quitProgNow = in->readSint16BE(); +	if (in->readSint16BE()) +		quitGame();  	_game.statusLine = in->readSint16BE();  	_game.clockEnabled = in->readSint16BE();  	_game.exitAllLogics = in->readSint16BE();  | 
