[Scummvm-cvs-logs] SF.net SVN: scummvm: [32603] scummvm/trunk/engines/drascula

sev at users.sourceforge.net sev at users.sourceforge.net
Sat Jun 7 22:47:52 CEST 2008


Revision: 32603
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32603&view=rev
Author:   sev
Date:     2008-06-07 13:47:52 -0700 (Sat, 07 Jun 2008)

Log Message:
-----------
WIP of drascula.dat loading. 
DISCLAIMER: this is too far from finished. From now drascula.dat is required to
run the game, but in the meantime you have to make it by yourself. Do not 
update DRASCULA_DAT_VER as I want it to be version 1 once all loading will
be implemented, but that may lead to some changes similar to r32602.

Modified Paths:
--------------
    scummvm/trunk/engines/drascula/drascula.cpp
    scummvm/trunk/engines/drascula/drascula.h
    scummvm/trunk/engines/drascula/graphics.cpp
    scummvm/trunk/engines/drascula/staticdata.h

Modified: scummvm/trunk/engines/drascula/drascula.cpp
===================================================================
--- scummvm/trunk/engines/drascula/drascula.cpp	2008-06-07 20:40:59 UTC (rev 32602)
+++ scummvm/trunk/engines/drascula/drascula.cpp	2008-06-07 20:47:52 UTC (rev 32603)
@@ -70,6 +70,8 @@
 
 DrasculaEngine::~DrasculaEngine() {
 	delete _rnd;
+
+	free(_charMap);
 }
 
 int DrasculaEngine::init() {
@@ -100,6 +102,9 @@
 		_lang = 0;
 	}
 
+	if (!loadDrasculaDat())
+		return 1;
+
 	setupRoomsTable();
 	loadArchives();
 
@@ -718,4 +723,53 @@
 	updateScreen();
 }
 
+bool DrasculaEngine::loadDrasculaDat() {
+	Common::File in;
+
+	in.open("drascula.dat");
+
+	if (!in.isOpen()) {
+		Common::String errorMessage = "You're missing the 'drascula.dat' file. Get it from the ScummVM website";
+		GUIErrorMessage(errorMessage);
+		warning(errorMessage.c_str());
+
+		return false;
+	}
+
+	char buf[256];
+	int ver;
+
+	in.read(buf, 8);
+	buf[8] = '\0';
+
+	if (strcmp(buf, "DRASCULA")) {
+		Common::String errorMessage = "File 'drascula.dat' is corrupt. Get it from the ScummVM website";
+		GUIErrorMessage(errorMessage);
+		warning(errorMessage.c_str());
+
+		return false;
+	}
+
+	ver = in.readByte();
+	
+	if (ver != DRASCULA_DAT_VER) {
+		snprintf(buf, 256, "File 'drascula.dat' is wrong version. Expected %d but got %d. Get it from the ScummVM website", DRASCULA_DAT_VER, ver);
+		GUIErrorMessage(buf);
+		warning(buf);
+
+		return false;
+	}
+
+	_charMapSize = in.readUint16BE();
+	_charMap = (CharInfo *)malloc(sizeof(CharInfo) * _charMapSize);
+
+	for (int i = 0; i < _charMapSize; i++) {
+		_charMap[i].inChar = in.readByte();
+		_charMap[i].mappedChar = in.readUint16BE();
+		_charMap[i].charType = in.readByte();
+	}
+
+	return true;
+}
+
 } // End of namespace Drascula

Modified: scummvm/trunk/engines/drascula/drascula.h
===================================================================
--- scummvm/trunk/engines/drascula/drascula.h	2008-06-07 20:40:59 UTC (rev 32602)
+++ scummvm/trunk/engines/drascula/drascula.h	2008-06-07 20:47:52 UTC (rev 32603)
@@ -46,6 +46,9 @@
 
 namespace Drascula {
 
+// Do not update this yet. The file is not loaded fully
+#define DRASCULA_DAT_VER 1
+
 enum DrasculaGameFeatures {
 	GF_PACKED = (1 << 0)
 };
@@ -174,12 +177,11 @@
 };
 
 struct CharInfo {
-	int inChar;
-	int mappedChar;
-	int charType;	// 0 - letters, 1 - signs, 2 - accented
+	byte inChar;
+	uint16 mappedChar;
+	byte charType;	// 0 - letters, 1 - signs, 2 - accented
 };
 
-#define CHARMAP_SIZE	93
 #define NUM_SAVES		10
 #define NUM_FLAGS		50
 #define DIF_MASK		55
@@ -356,6 +358,8 @@
 	int leftMouseButton;
 	int rightMouseButton;
 
+	bool loadDrasculaDat();
+
 	bool runCurrentChapter();
 	void black();
 	void pickObject(int);
@@ -671,6 +675,9 @@
 
 private:
 	int _lang;
+
+	CharInfo *_charMap;
+	int _charMapSize;
 };
 
 extern const char *_text[][501];
@@ -695,8 +702,6 @@
 extern const int verbBarX[];
 extern const int x1d_menu[], y1d_menu[];
 
-extern const CharInfo charMap[];
-
 } // End of namespace Drascula
 
 #endif /* DRASCULA_H */

Modified: scummvm/trunk/engines/drascula/graphics.cpp
===================================================================
--- scummvm/trunk/engines/drascula/graphics.cpp	2008-06-07 20:40:59 UTC (rev 32602)
+++ scummvm/trunk/engines/drascula/graphics.cpp	2008-06-07 20:47:52 UTC (rev 32603)
@@ -234,17 +234,18 @@
 
 void DrasculaEngine::print_abc(const char *said, int screenX, int screenY) {
 	int textPos[8];
-	int letterY = 0, letterX = 0, c, i;
+	int letterY = 0, letterX = 0, i;
 	uint len = strlen(said);
+	byte c;
 
 	for (uint h = 0; h < len; h++) {
 		c = toupper(said[h]);
 
-		for (i = 0; i < CHARMAP_SIZE; i++) {
-			if (c == charMap[i].inChar) {
-				letterX = charMap[i].mappedChar;
+		for (i = 0; i < _charMapSize; i++) {
+			if (c == _charMap[i].inChar) {
+				letterX = _charMap[i].mappedChar;
 
-				switch (charMap[i].charType) {
+				switch (_charMap[i].charType) {
 					case 0:		// letters
 						letterY = (_lang == kSpanish) ? 149 : 158;
 						break;
@@ -301,16 +302,16 @@
 			if (c == '\'')
 				c = '\244';
 
-		for (int i = 0; i < CHARMAP_SIZE; i++) {
-			if (c == charMap[i].inChar) {
+		for (int i = 0; i < _charMapSize; i++) {
+			if (c == _charMap[i].inChar) {
 				// Convert the mapped char of the normal font to the
 				// mapped char of the dialogue font
 
-				int multiplier = (charMap[i].mappedChar - 6) / 9;
+				int multiplier = (_charMap[i].mappedChar - 6) / 9;
 
 				letterX = multiplier * 7 + 10;
 
-				if (charMap[i].charType > 0)
+				if (_charMap[i].charType > 0)
 					letterY = signY;
 				break;
 			}	// if

Modified: scummvm/trunk/engines/drascula/staticdata.h
===================================================================
--- scummvm/trunk/engines/drascula/staticdata.h	2008-06-07 20:40:59 UTC (rev 32602)
+++ scummvm/trunk/engines/drascula/staticdata.h	2008-06-07 20:47:52 UTC (rev 32603)
@@ -30,63 +30,6 @@
 
 namespace Drascula {
 
-const CharInfo charMap[CHARMAP_SIZE] = {
-	//               Letters
-	// ---------------------------------------
-	{    'A',   6,   0 }, {    'B',  15,   0 },
-	{    'C',  24,   0 }, {    'D',  33,   0 },
-	{    'E',  42,   0 }, {    'F',  51,   0 },
-	{    'G',  60,   0 }, {    'H',  69,   0 },
-	{    'I',  78,   0 }, {    'J',  87,   0 },
-	{    'K',  96,   0 }, {    'L', 105,   0 },
-	{    'M', 114,   0 }, {    'N', 123,   0 },
-	{ '\244', 132,   0 }, { '\245', 132,   0 },	// special Spanish char
-	{    'O', 141,   0 }, {    'P', 150,   0 },
-	{    'Q', 159,   0 }, {    'R', 168,   0 },
-	{    'S', 177,   0 }, {    'T', 186,   0 },
-	{    'U', 195,   0 }, {    'V', 204,   0 },
-	{    'W', 213,   0 }, {    'X', 222,   0 },
-	{    'Y', 231,   0 }, {    'Z', 240,   0 },
-	// ---------------------------------------
-	{   0xa7, 250,   0 }, {    ' ', 250,   0 },
-	//               Signs
-	// ---------------------------------------
-	{    '.',   6,   1 }, {    ',',  15,   1 },
-	{    '-',  24,   1 }, {    '?',  33,   1 },
-	{ '\250',  42,   1 }, {    '"',  51,   1 },
-	{    '!',  60,   1 }, { '\255',  69,   1 },
-	{    ';',  78,   1 }, {    '>',  87,   1 },
-	{    '<',  96,   1 }, {    '$', 105,   1 },
-	{    '%', 114,   1 }, {    ':', 123,   1 },
-	{    '&', 132,   1 }, {    '/', 141,   1 },
-	{    '(', 150,   1 }, {    ')', 159,   1 },
-	{    '*', 168,   1 }, {    '+', 177,   1 },
-	{    '1', 186,   1 }, {    '2', 195,   1 },
-	{    '3', 204,   1 }, {    '4', 213,   1 },
-	{    '5', 222,   1 }, {    '6', 231,   1 },
-	{    '7', 240,   1 }, {    '8', 249,   1 },
-	{    '9', 258,   1 }, {    '0', 267,   1 },
-	//               Accented
-	// ---------------------------------------
-	{ '\240',   6,   2 }, { '\202',  15,   2 },	// A, B
-	{ '\241',  24,   2 }, { '\242',  33,   2 },	// C, D
-	{ '\243',  42,   2 }, { '\205',  51,   2 },	// E, F
-	{ '\212',  60,   2 }, { '\215',  69,   2 },	// G, H
-	{ '\225',  78,   2 }, { '\227',  87,   2 },	// I, J
-	{ '\203',  96,   2 }, { '\210', 105,   2 },	// K, L
-	{ '\214', 114,   2 }, { '\223', 123,   2 },	// M, N
-	{ '\226', 132,   2 }, { '\'',   141,   2 }, // special Spanish char, O
-	{ '\200', 150,   2 }, { '\207', 150,   2 },	// P, P
-	{ '\265',   6,   2 }, { '\220',  15,   2 },	// A, B
-	{ '\326',  24,   2 }, { '\340',  33,   2 },	// C, D
-	{ '\351',  42,   2 }, { '\267',  51,   2 },	// E, F
-	{ '\324',  60,   2 }, { '\336',  69,   2 },	// G, H
-	{ '\343',  78,   2 }, { '\353',  87,   2 },	// I, J
-	{ '\266',  96,   2 }, { '\322', 105,   2 },	// K, L
-	{ '\327', 114,   2 }, { '\342', 123,   2 },	// M, N
-	{ '\352', 132,   2 }						// special Spanish char
-};
-
 const ItemLocation itemLocations[] = {
 	{   0,   0 },							  // empty
 	{   5,  10 }, {  50,  10 }, {  95,  10 }, // 1-3


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