[Scummvm-cvs-logs] SF.net SVN: scummvm: [21843] scummvm/trunk/engines/simon

kirben at users.sourceforge.net kirben at users.sourceforge.net
Thu Apr 13 07:28:02 CEST 2006


Revision: 21843
Author:   kirben
Date:     2006-04-13 07:26:46 -0700 (Thu, 13 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21843&view=rev

Log Message:
-----------
Add code for save game interface in FF

Modified Paths:
--------------
    scummvm/trunk/engines/simon/charset.cpp
    scummvm/trunk/engines/simon/items.cpp
    scummvm/trunk/engines/simon/oracle.cpp
    scummvm/trunk/engines/simon/saveload.cpp
    scummvm/trunk/engines/simon/simon.cpp
    scummvm/trunk/engines/simon/simon.h
    scummvm/trunk/engines/simon/verb.cpp
Modified: scummvm/trunk/engines/simon/charset.cpp
===================================================================
--- scummvm/trunk/engines/simon/charset.cpp	2006-04-13 13:55:10 UTC (rev 21842)
+++ scummvm/trunk/engines/simon/charset.cpp	2006-04-13 14:26:46 UTC (rev 21843)
@@ -283,6 +283,10 @@
 	8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
 };
 
+uint SimonEngine::getFeebleFontSize(byte chr) {
+	return feebleFontSize[chr - 32];
+}
+
 void SimonEngine::showMessageFormat(const char *s, ...) {
 	char buf[STRINGBUFLEN];
 	char *str;
@@ -382,7 +386,7 @@
 	_newLines = 0;
 }
 
-void SimonEngine::videoPutchar(WindowBlock *window, byte c, byte b) {
+void SimonEngine::windowPutChar(WindowBlock *window, byte c, byte b) {
 	byte width = 6;
 
 	if (c == 12) {

Modified: scummvm/trunk/engines/simon/items.cpp
===================================================================
--- scummvm/trunk/engines/simon/items.cpp	2006-04-13 13:55:10 UTC (rev 21842)
+++ scummvm/trunk/engines/simon/items.cpp	2006-04-13 14:26:46 UTC (rev 21843)
@@ -321,6 +321,7 @@
 		opcode_table[124] = &SimonEngine::o3_ifTime;
 		opcode_table[127] = &SimonEngine::o3_playTune;
 		opcode_table[131] = &SimonEngine::o3_setTime;
+		opcode_table[132] = &SimonEngine::o3_saveUserGame,
 		opcode_table[133] = &SimonEngine::o3_loadUserGame;
 		opcode_table[134] = &SimonEngine::o3_listSaveGames;
 		opcode_table[135] = &SimonEngine::o3_checkCD;
@@ -1823,6 +1824,12 @@
 	_timeStore -= _gameStoppedClock;
 }
 
+void SimonEngine::o3_saveUserGame() {
+	// 132: save game
+	_noOracleScroll = 0;
+	saveUserGame(countSaveGames() + 1 - readVariable(55));
+}
+
 void SimonEngine::o3_loadUserGame() {
 	// 133: load game
 	loadGame(readVariable(55));

Modified: scummvm/trunk/engines/simon/oracle.cpp
===================================================================
--- scummvm/trunk/engines/simon/oracle.cpp	2006-04-13 13:55:10 UTC (rev 21842)
+++ scummvm/trunk/engines/simon/oracle.cpp	2006-04-13 14:26:46 UTC (rev 21843)
@@ -154,73 +154,6 @@
 	}
 }
 
-void SimonEngine::listSaveGames(int n) {
-	char b[108];
-	Common::InSaveFile *in;
-	uint16 j, k, z, maxFiles;
-	int OK;
-	memset(b, 0, 108);
-
-	maxFiles = countSaveGames() - 1;
-	j = maxFiles - n + 1;
-	k = maxFiles - j + 1;
-	z = maxFiles;
-	if (getBitFlag(95)) {
-		j++;
-		z++;
-	}
-
-	while(1) {
-		OK=1;
-		if (getBitFlag(93) || getBitFlag(94)) {
-			OK = 0;
-			if(j > z)
-				break;
-		}
-
-		if (getBitFlag(93)) {
-			if (((_newLines + 1) >= _textWindow->scrollY) && ((_newLines + 1) < (_textWindow->scrollY + 3)))
-				OK = 1;
-		}
-
-		if (getBitFlag(94)) {
-			if ((_newLines + 1) == (_textWindow->scrollY + 7))
-				OK = 1;
-		}
-
-
-		if (OK == 1) {
-			if (j == maxFiles + 1) {
-				showMessageFormat("\n");
-				hyperLinkOn(j + 400);
-				setTextColor(116);
-	    			showMessageFormat(" %d. ",1);
-				hyperLinkOff();
-				setTextColor(113);
-				k++;
-				j--;
-			}
-
-			if (!(in = _saveFileMan->openForLoading(gen_savename(j))))
-				break;
-			in->read(b, 100);
-			delete in;
-		}
-
-		showMessageFormat("\n");
-		hyperLinkOn(j + 400);
-		setTextColor(116);
-		if (k < 10)
-			showMessageFormat(" ");
-		showMessageFormat("%d. ",k);
-		setTextColor(113);
-		showMessageFormat("%s ",b);
-		hyperLinkOff();
-		j--;
-		k++;
-	}
-}
-
 void SimonEngine::scrollOracleUp() {
 	byte *src, *dst;
 	uint16 w, h;
@@ -360,4 +293,157 @@
 	}
 }
 
+void SimonEngine::listSaveGames(int n) {
+	char b[108];
+	Common::InSaveFile *in;
+	uint16 j, k, z, maxFiles;
+	int OK;
+	memset(b, 0, 108);
+
+	maxFiles = countSaveGames() - 1;
+	j = maxFiles - n + 1;
+	k = maxFiles - j + 1;
+	z = maxFiles;
+	if (getBitFlag(95)) {
+		j++;
+		z++;
+	}
+
+	while(1) {
+		OK=1;
+		if (getBitFlag(93) || getBitFlag(94)) {
+			OK = 0;
+			if(j > z)
+				break;
+		}
+
+		if (getBitFlag(93)) {
+			if (((_newLines + 1) >= _textWindow->scrollY) && ((_newLines + 1) < (_textWindow->scrollY + 3)))
+				OK = 1;
+		}
+
+		if (getBitFlag(94)) {
+			if ((_newLines + 1) == (_textWindow->scrollY + 7))
+				OK = 1;
+		}
+
+
+		if (OK == 1) {
+			if (j == maxFiles + 1) {
+				showMessageFormat("\n");
+				hyperLinkOn(j + 400);
+				setTextColor(116);
+	    			showMessageFormat(" %d. ",1);
+				hyperLinkOff();
+				setTextColor(113);
+				k++;
+				j--;
+			}
+
+			if (!(in = _saveFileMan->openForLoading(gen_savename(j))))
+				break;
+			in->read(b, 100);
+			delete in;
+		}
+
+		showMessageFormat("\n");
+		hyperLinkOn(j + 400);
+		setTextColor(116);
+		if (k < 10)
+			showMessageFormat(" ");
+		showMessageFormat("%d. ",k);
+		setTextColor(113);
+		showMessageFormat("%s ",b);
+		hyperLinkOff();
+		j--;
+		k++;
+	}
+}
+
+void SimonEngine::saveUserGame(int slot) {
+	WindowBlock *window;
+	Common::InSaveFile *in;
+	char name[108];
+	int len;
+	memset(name, 0, 108);
+
+	window = _windowArray[3];
+
+	window->textRow = (slot + 1 - window->scrollY) * 15;
+	window->textColumn = 26;
+
+	if ((in = _saveFileMan->openForLoading(gen_savename(readVariable(55))))) {
+		in->read(name, 100);
+		delete in;
+	}
+
+	len = 0;
+	while (name[len]) {
+		byte chr = name[len - 32];
+		window->textColumn += getFeebleFontSize(chr);
+		len++;
+	}
+
+	windowPutChar(window, 0x7f);
+	for (;;) {
+		_keyPressed = 0;
+		delay(1);
+
+		if (_keyPressed == 0 || _keyPressed >= 127)
+			continue;
+
+		window->textColumn -= getFeebleFontSize(127);
+		name[len] = 0;
+		windowBackSpace(_windowArray[3]);
+
+		if (_keyPressed == 27) {
+			writeVariable(55, _keyPressed);
+			break;
+		}
+
+		if (_keyPressed == 10 || _keyPressed == 13) {
+			if (!saveGame(readVariable(55), name))
+				writeVariable(55, 0xFFFF);
+			else
+				writeVariable(55, 0);
+			break;
+		}
+		if (_keyPressed == 8 && len != 0) {
+			len--;
+			byte chr = name[len];
+			window->textColumn -= getFeebleFontSize(chr);
+			name[len] = 0;
+			windowBackSpace(_windowArray[3]);
+			windowPutChar(window, 0x7f);
+		}
+		if (_keyPressed >= 32 && window->textColumn + 26 <= window->width) {
+			name[len++] = _keyPressed;
+			windowPutChar(_windowArray[3], _keyPressed);
+			windowPutChar(window, 0x7f);
+		}
+	}
+}
+
+void SimonEngine::windowBackSpace(WindowBlock *window) {
+	byte *dst;
+	uint x, y, h, w;
+
+	_lockWord |= 0x8000;
+
+	x = window->x + window->textColumn;
+	y = window->y + window->textRow;
+
+	dst = getFrontBuf() + _dxSurfacePitch * y + x;
+
+	for (h = 0; h < 13; h++) {
+		for (w = 0; w < 8; w++) {
+			if (dst[w] == 113  || dst[w] == 116 || dst[w] == 252)
+				dst[w] = 0;
+		}
+		dst += _screenWidth;
+	}
+
+	_lockWord &= ~0x8000;
+}
+
 } // End of namespace Simon

Modified: scummvm/trunk/engines/simon/saveload.cpp
===================================================================
--- scummvm/trunk/engines/simon/saveload.cpp	2006-04-13 13:55:10 UTC (rev 21842)
+++ scummvm/trunk/engines/simon/saveload.cpp	2006-04-13 14:26:46 UTC (rev 21843)
@@ -263,7 +263,7 @@
 
 		// do_3_start
 		for (;;) {
-			videoPutchar(window, 0x7f);
+			windowPutChar(window, 0x7f);
 
 			_saveLoadFlag = true;
 
@@ -314,7 +314,7 @@
 			} else if (i >= 32 && name_len != 17) {
 				name[name_len++] = i;
 
-				videoPutchar(_windowArray[5], i);
+				windowPutChar(_windowArray[5], i);
 			}
 		}
 
@@ -410,7 +410,7 @@
 void SimonEngine::clearCharacter(WindowBlock *window, int x, byte b) {
 	byte old_text;
 
-	videoPutchar(window, x, b);
+	windowPutChar(window, x, b);
 	old_text = window->text_color;
 	window->text_color = window->fill_color;
 
@@ -423,10 +423,10 @@
 
 	}
 
-	videoPutchar(window, x);
+	windowPutChar(window, x);
 
 	window->text_color = old_text;
-	videoPutchar(window, 8);
+	windowPutChar(window, 8);
 }
 
 void SimonEngine::fileError(WindowBlock *window, bool save_error) {
@@ -441,11 +441,11 @@
 		string2 = "\r     File not found.";
 	}
 
-	videoPutchar(window, 0xC);
+	windowPutChar(window, 0xC);
 	for (; *string; string++)
-		videoPutchar(window, *string);
+		windowPutChar(window, *string);
 	for (; *string2; string2++)
-		videoPutchar(window, *string2);
+		windowPutChar(window, *string2);
 
 	window->textColumn = (window->width / 2) - 3;
 	window->textRow = window->height - 1;
@@ -453,7 +453,7 @@
 
 	string = "[ OK ]";
 	for (; *string; string++)
-		videoPutchar(window, *string);
+		windowPutChar(window, *string);
 
 	ha = findEmptyHitArea();
 	ha->x = ((window->width >> 1) + (window->x - 3)) * 8;

Modified: scummvm/trunk/engines/simon/simon.cpp
===================================================================
--- scummvm/trunk/engines/simon/simon.cpp	2006-04-13 13:55:10 UTC (rev 21842)
+++ scummvm/trunk/engines/simon/simon.cpp	2006-04-13 14:26:46 UTC (rev 21843)
@@ -2886,7 +2886,7 @@
 
 void SimonEngine::windowPutChar(uint a) {
 	if (_textWindow != _windowArray[0])
-		videoPutchar(_textWindow, a);
+		windowPutChar(_textWindow, a);
 }
 
 void SimonEngine::clearWindow(WindowBlock *window) {

Modified: scummvm/trunk/engines/simon/simon.h
===================================================================
--- scummvm/trunk/engines/simon/simon.h	2006-04-13 13:55:10 UTC (rev 21842)
+++ scummvm/trunk/engines/simon/simon.h	2006-04-13 14:26:46 UTC (rev 21843)
@@ -592,9 +592,11 @@
  	void hyperLinkOff();
 	void linksUp();
 	void linksDown();
-	void listSaveGames(int n);
 	void oracleTextUp();
 	void oracleTextDown();
+	void listSaveGames(int n);
+	void saveUserGame(int slot);
+	void windowBackSpace(WindowBlock *window);
 
 	void bltOracleText();
 	void oracleLogo();
@@ -636,7 +638,7 @@
 	HitArea *findHitAreaByID(uint hitarea_id);
 
 	void showActionString(const byte *string);
-	void videoPutchar(WindowBlock *window, byte c, byte b = 0);
+	void windowPutChar(WindowBlock *window, byte c, byte b = 0);
 	void clearWindow(WindowBlock *window);
 	void video_toggle_colors(HitArea * ha, byte a, byte b, byte c, byte d);
 
@@ -671,6 +673,8 @@
 	void hitarea_stuff_helper();
 
 	void permitInput();
+
+	uint getFeebleFontSize(byte chr);
 	void showmessage_helper_3(uint a, uint b);
 	void showmessage_print_char(byte chr);
 
@@ -958,6 +962,7 @@
 	void o3_ifTime();
 	void o3_playTune();
 	void o3_setTime();
+	void o3_saveUserGame();
 	void o3_loadUserGame();
 	void o3_listSaveGames();
 	void o3_checkCD();

Modified: scummvm/trunk/engines/simon/verb.cpp
===================================================================
--- scummvm/trunk/engines/simon/verb.cpp	2006-04-13 13:55:10 UTC (rev 21842)
+++ scummvm/trunk/engines/simon/verb.cpp	2006-04-13 14:26:46 UTC (rev 21843)
@@ -301,7 +301,7 @@
 	window->textColumnOffset = x & 7;
 
 	for (; *string; string++)
-		videoPutchar(window, *string);
+		windowPutChar(window, *string);
 }
 
 void SimonEngine::resetNameWindow() {


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