[Scummvm-cvs-logs] CVS: scummvm/scumm charset.cpp,2.135,2.136 resource_v2.cpp,1.50,1.51 script_v2.cpp,2.271,2.272 util.cpp,2.6,2.7 util.h,2.5,2.6

Eugene Sandulenko sev at users.sourceforge.net
Sun Apr 10 02:59:35 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20664

Modified Files:
	charset.cpp resource_v2.cpp script_v2.cpp util.cpp util.h 
Log Message:
Do not hardcode character translation tables and verbs prepositions
in MM NES but extract it directly from ROM. Patch from Quietust


Index: charset.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.cpp,v
retrieving revision 2.135
retrieving revision 2.136
diff -u -d -r2.135 -r2.136
--- charset.cpp	5 Apr 2005 07:53:44 -0000	2.135
+++ charset.cpp	10 Apr 2005 09:58:36 -0000	2.136
@@ -1681,82 +1681,9 @@
 		_str.bottom = shadow.bottom;
 }
 
-static byte trNESEnglishTable[] = {
-	0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
-	0x00, 0x00, 0x00, 0x00, 0x06, 0x0a, 0x07, 0x00,
-	0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
-	0x13, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
-	0x00, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
-	0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
-	0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
-	0x2c, 0x2d, 0x2e, 0x00, 0x00, 0x00, 0x2f, 0x00,
-	0x03, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
-	0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
-	0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
-	0x2c, 0x2d, 0x2e, 0x00, 0x00, 0x00, 0x05, 0x08,
-	0x20, 0x20, 0x21, 0x60, 0x27, 0x7e, 0x2c, 0x2e,
-	0x7f, 0x3f, 0x2d, 0x30, 0x31, 0x32, 0x33, 0x34,
-	0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43,
-	0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
-	0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53,
-	0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5e
-};
-
-static byte trNESFrenchTable[] = {
-	0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x64, 0x04,
-	0x00, 0x00, 0x00, 0x00, 0x06, 0x0a, 0x07, 0x00,
-	0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
-	0x13, 0x14, 0x00, 0x00, 0x15, 0x15, 0x64, 0x09,
-	0x00, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
-	0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
-	0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
-	0x2c, 0x2d, 0x2e, 0x19, 0x19, 0x19, 0x2f, 0x29,
-	0x03, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
-	0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
-	0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
-	0x2c, 0x2d, 0x2e, 0x1d, 0x23, 0x29, 0x05, 0x08,
-	0x20, 0x20, 0x21, 0x60, 0x27, 0x7e, 0x2c, 0x2e,
-	0x7f, 0x3f, 0x2d, 0x30, 0x31, 0x32, 0x33, 0x34,
-	0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43,
-	0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
-	0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53,
-	0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5e
-};
-
-static byte trNESSwedishTable[] = {
-	0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
-	0x00, 0x00, 0x00, 0x00, 0x06, 0x0a, 0x07, 0x00,
-	0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
-	0x13, 0x14, 0x00, 0x00, 0x61, 0x00, 0x64, 0x09,
-	0x00, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
-	0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
-	0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
-	0x2c, 0x2d, 0x2e, 0x62, 0x63, 0x00, 0x2f, 0x00,
-	0x03, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
-	0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
-	0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
-	0x2c, 0x2d, 0x2e, 0x63, 0x64, 0x61, 0x05, 0x08,
-	0x20, 0x20, 0x21, 0x60, 0x27, 0x7e, 0x2c, 0x2e,
-	0x7f, 0x3f, 0x2d, 0x30, 0x31, 0x32, 0x33, 0x34,
-	0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43,
-	0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
-	0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53,
-	0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5e
-};
-
 CharsetRendererNES::CharsetRendererNES(ScummEngine *vm, Common::Language language)
 	: CharsetRendererCommon(vm) {
-	switch (language) {
-	case Common::FR_FRA:
-		_trTable = trNESFrenchTable;
-		break;
-	case Common::SE_SWE:
-		_trTable = trNESSwedishTable;
-		break;
-	default:
-		_trTable = trNESEnglishTable;
-		break;
-	}
+	_trTable = NULL;	// can't init it here, since resources aren't yet loaded!
 }
 
 void CharsetRendererNES::printChar(int chr) {
@@ -1764,6 +1691,9 @@
 	VirtScreen *vs;
 	byte *charPtr, *dst;
 
+	if (!_trTable)		// have to init it here instead
+		_trTable = _vm->getResourceAddress(rtCostume, 77) + 2;
+
 	// HACK: how to set it properly?
 	if (_top == 0)
 		_top = 16;
@@ -1825,6 +1755,9 @@
 	byte *charPtr, *dst;
 	int width, height;
 
+	if (!_trTable)
+		_trTable = _vm->getResourceAddress(rtCostume, 77) + 2;
+
 	charPtr = _vm->_NESPatTable[1] + _trTable[chr - 32] * 16;
 	width = getCharWidth(chr);
 	height = 8;

Index: resource_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v2.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- resource_v2.cpp	10 Apr 2005 01:31:31 -0000	1.50
+++ resource_v2.cpp	10 Apr 2005 09:58:37 -0000	1.51
@@ -38,9 +38,12 @@
 		_numRooms = 55;
 
 		if (_features & GF_NES)
-			// costumes 25-37 are special. see v1MMNEScostTables[] in costume.cpp
-			// costumes 38-77 are room graphics resources, to be referenced in 
-			_numCostumes = 77;
+			// costumes 25-36 are special. see v1MMNEScostTables[] in costume.cpp
+			// costumes 37-76 are room graphics resources
+			// costume 77 is a character set translation table
+			// costume 78 is a preposition list
+			// costume 79 is unused but allocated, so the total is a nice even number :)
+			_numCostumes = 80;
 		else
 			_numCostumes = 35;
 

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.271
retrieving revision 2.272
diff -u -d -r2.271 -r2.272
--- script_v2.cpp	7 Apr 2005 21:13:01 -0000	2.271
+++ script_v2.cpp	10 Apr 2005 09:58:37 -0000	2.272
@@ -413,7 +413,10 @@
 	int textSlot = 0;
 	_string[textSlot].xpos = 0;
 	_string[textSlot].ypos = 0;
-	_string[textSlot].right = 320;
+	if (_features & GF_NES)
+		_string[textSlot].right = 256;
+	else
+		_string[textSlot].right = 320;
 	_string[textSlot].center = false;
 	_string[textSlot].overhead = false;
 
@@ -1022,7 +1025,10 @@
 			{ " ", " in", " with", " on", " to" }	// Korean
 			};
 		int lang = (_language <= 8) ? _language : 0;	// Default to english
-		strcat(sentence, prepositions[lang][VAR(VAR_SENTENCE_PREPOSITION)]);
+		if (_features & GF_NES) {
+			strcat(sentence, (const char *)(getResourceAddress(rtCostume, 78) + VAR(VAR_SENTENCE_PREPOSITION) * 8 + 2));
+		} else
+			strcat(sentence, prepositions[lang][VAR(VAR_SENTENCE_PREPOSITION)]);
 	}
 
 	if (VAR(VAR_SENTENCE_OBJECT2) > 0) {
@@ -1058,12 +1064,14 @@
 		ptr++;
 	}
 
-	sentenceline.top = virtscr[2].topline;
-	sentenceline.bottom = virtscr[2].topline + 8;
-	if (_features & GF_NES) {
+	if (_features & GF_NES) {	// TODO - get multiline sentences working
+		sentenceline.top = virtscr[2].topline;
+		sentenceline.bottom = virtscr[2].topline + 16;
 		sentenceline.left = 16;
 		sentenceline.right = 255;
 	} else {
+		sentenceline.top = virtscr[2].topline;
+		sentenceline.bottom = virtscr[2].topline + 8;
 		sentenceline.left = 0;
 		sentenceline.right = 319;
 	}

Index: util.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/util.cpp,v
retrieving revision 2.6
retrieving revision 2.7
diff -u -d -r2.6 -r2.7
--- util.cpp	30 Mar 2005 23:25:49 -0000	2.6
+++ util.cpp	10 Apr 2005 09:58:37 -0000	2.7
@@ -715,13 +715,18 @@
 	{ {0x0BFEA,0x0BEF3,0x0BF4C,0x07F32}, {0x000C,0x000C,0x000C,0x000C}, NES_SPROFFS }
 };
 
-
 // sprite data sets (packed NES sprite data)
 static ScummNESFile::t_resource res_sprdata[2] = {
 	{ {0x2CE11,0x2CE11,0x2C401,0x2CA28}, {0x2BE0,0x2BE0,0x2BE0,0x2BE0}, NES_SPRDATA },
 	{ {0x07F6B,0x0BE28,0x0FE6B,0x07E48}, {0x008A,0x008A,0x008A,0x008A}, NES_SPRDATA }
 };
 
+static ScummNESFile::t_resource res_charset =
+	{ {0x3F6EE,0x3F724,0x3F739,0x3F739}, {0x0090,0x0090,0x0090,0x0090}, NES_CHARSET };
+
+static ScummNESFile::t_resource res_preplist =
+	{ {0x3FB5A,0x3FB90,0x3FBA9,0x3FBAF}, {0x000E,0x000E,0x000E,0x0010}, NES_PREPLIST };
+
 uint16 write_byte(Common::MemoryWriteStream *out, byte val) {
 	val ^= 0xFF;
 	if (out != 0)
@@ -822,6 +827,14 @@
 			reslen += write_word(output, len);
 			reslen += write_byte(output, val);
 			reslen += write_byte(output, cnt);
+
+			cnt = FileReadByte();
+			reslen += write_byte(output, cnt);
+			for (i = 0; i < cnt; i++)
+				reslen += write_byte(output, FileReadByte());
+			for (i = 0; i < cnt; i++)
+				reslen += write_byte(output, FileReadByte());
+
 			while (1) {
 				reslen += write_byte(output, val = FileReadByte());
 				if (val >= 0xFE)
@@ -860,6 +873,7 @@
 	case NES_SPRLENS:
 	case NES_SPROFFS:
 	case NES_SPRDATA:
+	case NES_CHARSET:
 		len = resLength(res);
 		reslen += write_word(output, (uint16)(len + 2));
 
@@ -868,6 +882,24 @@
 
 		break;
 
+	case NES_PREPLIST:
+		len = resLength(res);
+                reslen += write_word(output, 0x002A);
+
+		reslen += write_byte(output, ' ');
+		for (i = 1; i < 8; i++)
+			reslen += write_byte(output, 0);
+
+		for (j = 0; j < 4; j++)
+		{
+			reslen += write_byte(output,' ');
+			for (i = 1; val = FileReadByte(); i++)
+				reslen += write_byte(output, val);
+			for (; i < 8; i++)
+				reslen += write_byte(output, 0);
+		}
+		break;
+
 	default:
 		error("extract_resource - unknown resource type %d specified!", res->type);
 	}
@@ -933,7 +965,7 @@
 /*	remaining 'standard' resources (not used by any of the original LFL files) */
 static ScummNESFile::p_resource lfl_53[] = { &res_rooms[53], &res_scripts[177], &res_scripts[178], &res_sounds[70], &res_sounds[71], &res_sounds[72], &res_sounds[73], &res_sounds[74], &res_sounds[75], &res_sounds[76], &res_sounds[77], &res_sounds[78], &res_sounds[79], &res_sounds[80], &res_sounds[81], NULL };
 /*	all 'non-standard' resources (the costume-related stuff) */
-static ScummNESFile::p_resource lfl_54[] = { &res_rooms[54], &res_sprdesc[0], &res_sprdesc[1], &res_sprlens[0], &res_sprlens[1], &res_sproffs[0], &res_sproffs[1], &res_sprdata[0], &res_sprdata[1], &res_costumegfx[0], &res_costumegfx[1], &res_sprpals[0], &res_sprpals[1], NULL };
+static ScummNESFile::p_resource lfl_54[] = { &res_rooms[54], &res_sprdesc[0], &res_sprdesc[1], &res_sprlens[0], &res_sprlens[1], &res_sproffs[0], &res_sproffs[1], &res_sprdata[0], &res_sprdata[1], &res_costumegfx[0], &res_costumegfx[1], &res_sprpals[0], &res_sprpals[1], &res_charset, &res_preplist, NULL };
 
 typedef	struct _lfl {
 	int num;
@@ -1002,8 +1034,8 @@
 struct _lfl_index {
 	byte	room_lfl[55];
 	uint16	room_addr[55];
-	byte	costume_lfl[77];
-	uint16	costume_addr[77];
+	byte	costume_lfl[80];
+	uint16	costume_addr[80];
 	byte	script_lfl[200];
 	uint16	script_addr[200];
 	byte	sound_lfl[100];
@@ -1095,6 +1127,14 @@
 				lfl_index.sound_lfl[entry - res_sounds] = lfl->num;
 				lfl_index.sound_addr[entry - res_sounds] = TO_LE_16(respos);
 				break;
+			case NES_CHARSET:
+				lfl_index.costume_lfl[77] = lfl->num;
+				lfl_index.costume_addr[77] = TO_LE_16(respos);
+				break;
+			case NES_PREPLIST:
+				lfl_index.costume_lfl[78] = lfl->num;
+				lfl_index.costume_addr[78] = TO_LE_16(respos);
+				break;
 			default:
 				error("Unindexed entry found!");
 				break;
@@ -1118,9 +1158,6 @@
 
 	extractResource(&out, &res_globdata);
 
-	for (i = res_globdata.length[_ROMset]; i < 775; i++)
-		write_byte(&out, 0);
-
 	for (i = 0; i < (int)sizeof(lfl_index); i++)
 		write_byte(&out, ((byte *)&lfl_index)[i]);
 

Index: util.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/util.h,v
retrieving revision 2.5
retrieving revision 2.6
diff -u -d -r2.5 -r2.6
--- util.h	4 Apr 2005 06:09:04 -0000	2.5
+++ util.h	10 Apr 2005 09:58:37 -0000	2.6
@@ -65,7 +65,6 @@
 	uint32 write(const void *ptr, uint32 size);
 };
 
-
 typedef enum _res_type {
 	NES_UNKNOWN,
 	NES_GLOBDATA,
@@ -79,7 +78,9 @@
 	NES_SPRDESC,
 	NES_SPRLENS,
 	NES_SPROFFS,
-	NES_SPRDATA 
+	NES_SPRDATA,
+	NES_CHARSET,
+	NES_PREPLIST 
 } res_type;
 
 class ScummNESFile : public BaseScummFile {





More information about the Scummvm-git-logs mailing list