[Scummvm-cvs-logs] SF.net SVN: scummvm: [27192] scummvm/branches/branch-0-10-0/engines/agos

Kirben at users.sourceforge.net Kirben at users.sourceforge.net
Fri Jun 8 09:51:45 CEST 2007


Revision: 27192
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27192&view=rev
Author:   Kirben
Date:     2007-06-08 00:51:44 -0700 (Fri, 08 Jun 2007)

Log Message:
-----------
Fix load/save interface in Elvira 1.

Modified Paths:
--------------
    scummvm/branches/branch-0-10-0/engines/agos/agos.h
    scummvm/branches/branch-0-10-0/engines/agos/event.cpp
    scummvm/branches/branch-0-10-0/engines/agos/saveload.cpp
    scummvm/branches/branch-0-10-0/engines/agos/script_e1.cpp
    scummvm/branches/branch-0-10-0/engines/agos/script_e2.cpp

Modified: scummvm/branches/branch-0-10-0/engines/agos/agos.h
===================================================================
--- scummvm/branches/branch-0-10-0/engines/agos/agos.h	2007-06-08 07:50:28 UTC (rev 27191)
+++ scummvm/branches/branch-0-10-0/engines/agos/agos.h	2007-06-08 07:51:44 UTC (rev 27192)
@@ -1054,9 +1054,10 @@
 	int16 levelOf(Item *item); 
 	int16 moreText(Item *i);
 	void lobjFunc(Item *i, const char *f);
-	uint confirmQuit();
+	uint confirmYesOrNo(uint16 x, uint16 y);
 	uint continueOrQuit();
 	void printScroll();
+	virtual void printStats();
 	void synchChain(Item *i);
 
 protected:
@@ -1211,10 +1212,10 @@
 
 	virtual void vcStopAnimation(uint zone, uint sprite);
 
+	bool confirmOverWrite(WindowBlock *window);
+	int16 matchSaveGame(const char *name, uint16 max);
 	void disableFileBoxes();
-	virtual void listSaveGames(char *dst);
 	virtual void userGame(bool load);
-	virtual int userGameGetKey(bool *b, char *buf, uint maxChar);
 	void userGameBackSpace(WindowBlock *window, int x, byte b = 0);
 	void fileError(WindowBlock *window, bool save_error);
 
@@ -1282,8 +1283,6 @@
 	void oe1_bitSet();
 	void oe1_bitTest();
 	void oe1_zoneDisk();
-	void oe1_saveUserGame();
-	void oe1_loadUserGame();
 	void oe1_printStats();
 	void oe1_stopTune();
 	void oe1_printPlayerDamage();
@@ -1355,6 +1354,7 @@
 	void oe2_b2Zero();
 	void oe2_b2NotZero();
 
+	virtual void printStats();
 protected:
 	typedef void (AGOSEngine_Elvira2::*OpcodeProcElvira2) ();
 	struct OpcodeEntryElvira2 {
@@ -1378,6 +1378,10 @@
 	uint16 getExitState(Item *item, uint16 x, uint16 d);
 	void setExitState(Item *i, uint16 n, uint16 d, uint16 s);
 	void setSRExit(Item *i, int n, int d, uint16 s);
+
+	virtual void listSaveGames(char *dst);
+	virtual void userGame(bool load);
+	virtual int userGameGetKey(bool *b, char *buf, uint maxChar);
 };
 
 class AGOSEngine_Waxworks : public AGOSEngine_Elvira2 {

Modified: scummvm/branches/branch-0-10-0/engines/agos/event.cpp
===================================================================
--- scummvm/branches/branch-0-10-0/engines/agos/event.cpp	2007-06-08 07:50:28 UTC (rev 27191)
+++ scummvm/branches/branch-0-10-0/engines/agos/event.cpp	2007-06-08 07:51:44 UTC (rev 27192)
@@ -465,6 +465,7 @@
 					if (_saveLoadSlot == 0)
 						_saveLoadSlot = 10;
 
+					memset(_saveLoadName, 0, sizeof(_saveLoadName));
 					sprintf(_saveLoadName, "Quick %d", _saveLoadSlot);
 					_saveLoadType = (event.kbd.flags == Common::KBD_ALT) ? 1 : 2;
 

Modified: scummvm/branches/branch-0-10-0/engines/agos/saveload.cpp
===================================================================
--- scummvm/branches/branch-0-10-0/engines/agos/saveload.cpp	2007-06-08 07:50:28 UTC (rev 27191)
+++ scummvm/branches/branch-0-10-0/engines/agos/saveload.cpp	2007-06-08 07:51:44 UTC (rev 27192)
@@ -109,7 +109,7 @@
 			setBitFlag(7, false);
 			sub = getSubroutineByID(19);
 			startSubroutine(sub);
-			//oe2_printStats();
+			printStats();
 			sub = getSubroutineByID(28);
 			startSubroutine(sub);
 			setBitFlag(17, false);
@@ -146,8 +146,169 @@
 	_saveLoadType = 0;
 }
 
-void AGOSEngine::listSaveGames(char *dst) {
+bool AGOSEngine::confirmOverWrite(WindowBlock *window) {
+	if (getGameType() == GType_WW) {
+		Subroutine *sub = getSubroutineByID(80);
+		if (sub != NULL)
+			startSubroutineEx(sub);
+
+		if (_variableArray[253] == 0)
+			return true;
+	} else if (getGameType() == GType_ELVIRA2) {
+		// Original verison never confirmed
+		return true;
+	} else if (getGameType() == GType_ELVIRA1) {
+		const char *message1, *message2, *message3;
+
+		switch (_language) {
+		case Common::FR_FRA:
+			message1 = "\rFichier d/j; existant.\r\r";
+			message2 = "  Ecrire pardessus ?\r\r";
+			message3 = "     Oui      Non";
+			break;
+		case Common::DE_DEU:
+			message1 = "\rDatei existiert bereits.\r\r";
+			message2 = "     berschreiben ?\r\r";
+			message3 = "     Ja        Nein";
+			break;
+		default:
+			message1 = "\r File already exists.\r\r";
+			message2 = "    Overwrite it ?\r\r";
+			message3 = "     Yes       No";
+			break;
+		}
+
+		printScroll();
+		window->textColumn = 0;
+		window->textRow = 0;
+		window->textColumnOffset = 0;
+		window->textLength = 0;		// Difference
+
+		for (; *message1; message1++)
+			windowPutChar(window, *message1);
+		for (; *message2; message2++)
+			windowPutChar(window, *message2);
+		for (; *message3; message3++)
+			windowPutChar(window, *message3);
+
+		if (confirmYesOrNo(120, 78) == 0x7FFF)
+			return true;
+	}
+
+	return false;
+}
+
+int16 AGOSEngine::matchSaveGame(const char *name, uint16 max) {
 	Common::InSaveFile *in;
+	char dst[8];
+	uint16 slot;
+
+	for (slot = 0; slot < max; slot++) {
+		if ((in = _saveFileMan->openForLoading(genSaveName(slot)))) {
+			in->read(dst, 8);
+			delete in;
+
+			if (!scumm_stricmp(name, dst)) {
+				return slot;
+			}
+		}
+	}
+
+	return -1;
+}
+
+void AGOSEngine::userGame(bool load) {
+	WindowBlock *window = _windowArray[4];
+	const char *message1;
+	int i, numSaveGames;
+	char *name;
+	char buf[8];
+
+	numSaveGames = countSaveGames();
+	
+	time_t saveTime = time(NULL);
+	haltAnimation();
+
+restart:
+	printScroll();
+	window->textColumn = 0;
+	window->textRow = 0;
+	window->textColumnOffset = 0;
+	window->textLength = 0;		// Difference
+
+	switch (_language) {
+	case Common::FR_FRA:
+		message1 = "\rIns/rez disquette de\rsauvegarde de jeux &\rentrez nom de fichier:\r\r   ";
+		break;
+	case Common::DE_DEU:
+		message1 = "\rLege Spielstandsdiskette ein. Dateinamen eingeben:\r\r   ";
+		break;
+	default:
+		message1 = "\r Insert savegame data disk & enter filename:\r\r   ";
+		break;
+	}
+
+	for (; *message1; message1++)
+		windowPutChar(window, *message1);
+
+	memset(buf, 0, 8);
+	name = buf;
+	_saveGameNameLen = 0;
+
+	for (;;) {
+		windowPutChar(window, 128);
+		_keyPressed = 0;
+
+		for (;;) {
+			delay(10);
+			if (_keyPressed && _keyPressed < 128) {
+				i = _keyPressed;
+				break;
+			}
+		}
+
+		userGameBackSpace(_windowArray[4], 8);
+		if (i == 10 || i == 13) {
+			break;
+		} else if (i == 8) {
+			// do_backspace
+			if (_saveGameNameLen) {
+				_saveGameNameLen--;
+				name[_saveGameNameLen] = 0;
+				userGameBackSpace(_windowArray[4], 8);
+			}
+		} else if (i >= 32 && _saveGameNameLen != 8) {
+			name[_saveGameNameLen++] = i;
+			windowPutChar(_windowArray[4], i);
+		}
+	}
+
+	int16 slot = matchSaveGame(name, numSaveGames);
+	if (!load) {
+		if (slot >= 0 && !confirmOverWrite(window))
+			goto restart;
+
+		if (slot < 0)
+			slot =  numSaveGames;
+
+		if (!saveGame(slot, name))
+			fileError(_windowArray[4], true);
+	} else {
+		if (slot < 0) {
+			fileError(_windowArray[4], false);
+		} else {
+			if (!loadGame(genSaveName(slot)))
+				fileError(_windowArray[4], false);
+		}
+	}
+
+	printStats();
+	restartAnimation();
+	_gameStoppedClock = time(NULL) - saveTime + _gameStoppedClock;
+}
+
+void AGOSEngine_Elvira2::listSaveGames(char *dst) {
+	Common::InSaveFile *in;
 	uint y, slot;
 
 	const uint8 num = (getGameType() == GType_WW) ? 3 : 4;
@@ -226,7 +387,7 @@
 	_saveGameNameLen = 0;
 }
 
-void AGOSEngine::userGame(bool load) {
+void AGOSEngine_Elvira2::userGame(bool load) {
 	time_t saveTime;
 	int i, numSaveGames;
 	char *name;
@@ -251,6 +412,8 @@
 
 	if (!load) {
 		WindowBlock *window = _windowArray[num];
+		int16 slot = -1;
+
 		name = buf + 192;
 
 		for (;;) {
@@ -261,15 +424,9 @@
 			i = userGameGetKey(&b, buf, 128);
 			if (b) {
 				if (i <= 223) {
-					if (getGameType() == GType_WW) {
-						Subroutine *sub = getSubroutineByID(80);
-						if (sub != NULL)
-							startSubroutineEx(sub);
-
-						if (_variableArray[253] != 0) {
-							listSaveGames(buf);
-							continue;
-						}
+					if (!confirmOverWrite(window)) {
+						listSaveGames(buf);
+						continue;
 					}
 
 					if (!saveGame(_saveLoadRowCurPos + i, buf + i * 8))
@@ -280,9 +437,16 @@
 			}
 
 			userGameBackSpace(_windowArray[num], 8);
-			if (i == 10 || i == 13)
+			if (i == 10 || i == 13) {
+				slot = matchSaveGame(name, numSaveGames);
+				if (slot >= 0) {
+					if (!confirmOverWrite(window)) {
+						listSaveGames(buf);
+						continue;
+					}
+				}
 				break;
-			if (i == 8) {
+			} else if (i == 8) {
 				// do_backspace
 				if (_saveGameNameLen) {
 					_saveGameNameLen--;
@@ -295,7 +459,10 @@
 			}
 		}
 
-		if (!saveGame(numSaveGames, buf + 192))
+		if (slot < 0)
+			slot = numSaveGames;
+
+		if (!saveGame(slot, buf + 192))
 			fileError(_windowArray[num], true);
 	} else {
 		i = userGameGetKey(&b, buf, 128);
@@ -314,7 +481,7 @@
 		restartAnimation();
 }
 
-int AGOSEngine::userGameGetKey(bool *b, char *buf, uint maxChar) {
+int AGOSEngine_Elvira2::userGameGetKey(bool *b, char *buf, uint maxChar) {
 	HitArea *ha;
 	*b = true;
 
@@ -537,9 +704,9 @@
 			}
 
 			userGameBackSpace(_windowArray[5], 8);
-			if (i == 10 || i == 13)
+			if (i == 10 || i == 13) {
 				break;
-			if (i == 8) {
+			} else if (i == 8) {
 				// do_backspace
 				if (_saveGameNameLen) {
 					byte m, x;
@@ -737,7 +904,16 @@
 		}
 	}
 
-	windowPutChar(window, 0xC);
+	if (getGameType() == GType_ELVIRA1) {
+		printScroll();
+		window->textColumn = 0;
+		window->textRow = 0;
+		window->textColumnOffset = 0;
+		window->textLength = 0;		// Difference
+	} else {
+		windowPutChar(window, 12);
+	}
+
 	for (; *message1; message1++)
 		windowPutChar(window, *message1);
 	for (; *message2; message2++)

Modified: scummvm/branches/branch-0-10-0/engines/agos/script_e1.cpp
===================================================================
--- scummvm/branches/branch-0-10-0/engines/agos/script_e1.cpp	2007-06-08 07:50:28 UTC (rev 27191)
+++ scummvm/branches/branch-0-10-0/engines/agos/script_e1.cpp	2007-06-08 07:51:44 UTC (rev 27192)
@@ -370,8 +370,8 @@
 		OPCODE(o_setAdjNoun),
 		OPCODE(oe1_zoneDisk),
 		/* 268 */
-		OPCODE(oe1_saveUserGame),
-		OPCODE(oe1_loadUserGame),
+		OPCODE(o_saveUserGame),
+		OPCODE(o_loadUserGame),
 		OPCODE(oe1_printStats),
 		OPCODE(oe1_stopTune),
 		/* 272 */
@@ -863,72 +863,9 @@
 	getVarOrWord();
 }
 
-void AGOSEngine_Elvira1::oe1_saveUserGame() {
-	// TODO
-}
-
-void AGOSEngine_Elvira1::oe1_loadUserGame() {
-	// TODO
-}
-
 void AGOSEngine_Elvira1::oe1_printStats() {
 	// 270: print stats
-	WindowBlock *window = _dummyWindow;
-	int val;
-
-	window->flags = 1;
-
-	mouseOff();
-
-	// Strength
-	val = _variableArray[0];
-	if (val < -99)
-		val = -99;
-	if (val > 99)
-		val = 99;	
-	writeChar(window, 5, 133, 6, val);
-
-	// Resolution
-	val = _variableArray[1];
-	if (val < -99)
-		val = -99;
-	if (val > 99)
-		val = 99;	
-	writeChar(window, 11, 133, 6, val);
-
-	// Dexterity
-	val = _variableArray[2];
-	if (val < -99)
-		val = -99;
-	if (val > 99)
-		val = 99;	
-	writeChar(window, 18, 133, 0, val);
-
-	// Skill
-	val = _variableArray[3];
-	if (val < -99)
-		val = -99;
-	if (val > 99)
-		val = 99;	
-	writeChar(window, 24, 133, 0, val);
-
-	// Life
-	val = _variableArray[5];
-	if (val < -99)
-		val = -99;
-	if (val > 99)
-		val = 99;	
-	writeChar(window, 30, 133, 2, val);
-
-	// Experience
-	val = _variableArray[6];
-	if (val < -99)
-		val = -99;
-	if (val > 99)
-		val = 99;	
-	writeChar(window, 36, 133, 4, val);
-
-	mouseOn();
+	printStats();
 }
 
 void AGOSEngine_Elvira1::oe1_stopTune() {
@@ -1017,7 +954,7 @@
 		for (; *message2; message2++)
 			windowPutChar(window, *message2);
 
-		if (confirmQuit() == 0x7FFF) {
+		if (confirmYesOrNo(120, 62) == 0x7FFF) {
 			shutdown();
 		} else {
 			goto restart;
@@ -1104,12 +1041,12 @@
 	}
 }
 
-uint AGOSEngine::confirmQuit() {
+uint AGOSEngine::confirmYesOrNo(uint16 x, uint16 y) {
 	HitArea *ha;
 
 	ha = findEmptyHitArea();
-	ha->x = 120;
-	ha->y = 62;
+	ha->x = x;
+	ha->y = y;
 	ha->width = 30;
 	ha->height = 12;
 	ha->flags = kBFBoxInUse;
@@ -1118,8 +1055,8 @@
 	ha->window = 0;
 
 	ha = findEmptyHitArea();
-	ha->x = 180;
-	ha->y = 62;
+	ha->x = x + 60;
+	ha->y = y;
 	ha->width = 24;
 	ha->height = 12;
 	ha->flags = kBFBoxInUse;
@@ -1213,4 +1150,63 @@
 	_curVgaFile2 = curVgaFile2Orig;
 }
 
+void AGOSEngine::printStats() {
+	WindowBlock *window = _dummyWindow;
+	int val;
+
+	window->flags = 1;
+
+	mouseOff();
+
+	// Strength
+	val = _variableArray[0];
+	if (val < -99)
+		val = -99;
+	if (val > 99)
+		val = 99;	
+	writeChar(window, 5, 133, 6, val);
+
+	// Resolution
+	val = _variableArray[1];
+	if (val < -99)
+		val = -99;
+	if (val > 99)
+		val = 99;	
+	writeChar(window, 11, 133, 6, val);
+
+	// Dexterity
+	val = _variableArray[2];
+	if (val < -99)
+		val = -99;
+	if (val > 99)
+		val = 99;	
+	writeChar(window, 18, 133, 0, val);
+
+	// Skill
+	val = _variableArray[3];
+	if (val < -99)
+		val = -99;
+	if (val > 99)
+		val = 99;	
+	writeChar(window, 24, 133, 0, val);
+
+	// Life
+	val = _variableArray[5];
+	if (val < -99)
+		val = -99;
+	if (val > 99)
+		val = 99;	
+	writeChar(window, 30, 133, 2, val);
+
+	// Experience
+	val = _variableArray[6];
+	if (val < -99)
+		val = -99;
+	if (val > 99)
+		val = 99;	
+	writeChar(window, 36, 133, 4, val);
+
+	mouseOn();
+}
+
 } // End of namespace AGOS

Modified: scummvm/branches/branch-0-10-0/engines/agos/script_e2.cpp
===================================================================
--- scummvm/branches/branch-0-10-0/engines/agos/script_e2.cpp	2007-06-08 07:50:28 UTC (rev 27191)
+++ scummvm/branches/branch-0-10-0/engines/agos/script_e2.cpp	2007-06-08 07:51:44 UTC (rev 27192)
@@ -509,48 +509,7 @@
 
 void AGOSEngine_Elvira2::oe2_printStats() {
 	// 161: print stats
-	WindowBlock *window = _dummyWindow;
-	int val;
-	const uint8 y = (getPlatform() == Common::kPlatformAtariST) ? 131 : 134;
-
-	window->flags = 1;
-
-	mouseOff();
-
-	// Level
-	val = _variableArray[20];
-	if (val < -99)
-		val = -99;
-	if (val > 99)
-		val = 99;	
-	writeChar(window, 10, y, 0, val);
-
-	// PP
-	val = _variableArray[22];
-	if (val < -99)
-		val = -99;
-	if (val > 99)
-		val = 99;	
-	writeChar(window, 16, y, 6, val);
-
-	// HP
-	val = _variableArray[23];
-	if (val < -99)
-		val = -99;
-	if (val > 99)
-		val = 99;	
-	writeChar(window, 23, y, 4, val);
-
-	// Experience
-	val = _variableArray[21];
-	if (val < -99)
-		val = -99;
-	if (val > 9999)
-		val = 9999;	
-	writeChar(window, 30, y, 6, val / 100);
-	writeChar(window, 32, y, 2, val / 10);
-
-	mouseOn();
+	printStats();
 }
 
 void AGOSEngine_Elvira2::oe2_setSuperRoom() {
@@ -708,4 +667,49 @@
 	setScriptCondition((_bitArrayTwo[bit / 16] & (1 << (bit & 15))) != 0);
 }
 
+void AGOSEngine_Elvira2::printStats() {
+	WindowBlock *window = _dummyWindow;
+	int val;
+	const uint8 y = (getPlatform() == Common::kPlatformAtariST) ? 131 : 134;
+
+	window->flags = 1;
+
+	mouseOff();
+
+	// Level
+	val = _variableArray[20];
+	if (val < -99)
+		val = -99;
+	if (val > 99)
+		val = 99;	
+	writeChar(window, 10, y, 0, val);
+
+	// PP
+	val = _variableArray[22];
+	if (val < -99)
+		val = -99;
+	if (val > 99)
+		val = 99;	
+	writeChar(window, 16, y, 6, val);
+
+	// HP
+	val = _variableArray[23];
+	if (val < -99)
+		val = -99;
+	if (val > 99)
+		val = 99;	
+	writeChar(window, 23, y, 4, val);
+
+	// Experience
+	val = _variableArray[21];
+	if (val < -99)
+		val = -99;
+	if (val > 9999)
+		val = 9999;	
+	writeChar(window, 30, y, 6, val / 100);
+	writeChar(window, 32, y, 2, val / 10);
+
+	mouseOn();
+}
+
 } // End of namespace AGOS


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




More information about the Scummvm-git-logs mailing list