[Scummvm-cvs-logs] SF.net SVN: scummvm: [23531] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Thu Jul 20 22:52:18 CEST 2006


Revision: 23531
          http://svn.sourceforge.net/scummvm/?rev=23531&view=rev
Author:   lordhoto
Date:     2006-07-16 12:44:39 -0700 (Sun, 16 Jul 2006)

Log Message:
-----------
- don't error on CHAPTER1.VRM miss anymore
- nicer error messages when no font files are found
- implements nicer way to load fonts

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra.cpp
    scummvm/trunk/engines/kyra/kyra3.cpp
    scummvm/trunk/engines/kyra/resource.cpp
    scummvm/trunk/engines/kyra/screen.cpp
    scummvm/trunk/engines/kyra/screen.h
    scummvm/trunk/engines/kyra/sequences_v1.cpp

Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp	2006-07-16 08:40:28 UTC (rev 23530)
+++ scummvm/trunk/engines/kyra/kyra.cpp	2006-07-16 19:44:39 UTC (rev 23531)
@@ -390,12 +390,11 @@
 
 int KyraEngine::go() {
 	_quitFlag = false;
-	uint32 sz;
 
 	if (_features & GF_FLOPPY && !(_features & GF_AMIGA)) {
-		_screen->loadFont(Screen::FID_6_FNT, _res->fileData("6.FNT", &sz));
+		_screen->loadFont(Screen::FID_6_FNT, "6.FNT");
 	}
-	_screen->loadFont(Screen::FID_8_FNT, _res->fileData("8FAT.FNT", &sz));
+	_screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT");
 	_screen->setScreenDim(0);
 
 	_abortIntroFlag = false;

Modified: scummvm/trunk/engines/kyra/kyra3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra3.cpp	2006-07-16 08:40:28 UTC (rev 23530)
+++ scummvm/trunk/engines/kyra/kyra3.cpp	2006-07-16 19:44:39 UTC (rev 23531)
@@ -85,9 +85,8 @@
 	if (!_soundDigital->init())
 		error("_soundDigital->init() failed");
 	
-	uint32 sz;
-	_screen->loadFont(Screen::FID_6_FNT, _res->fileData("6.FNT", &sz));
-	_screen->loadFont(Screen::FID_8_FNT, _res->fileData("8FAT.FNT", &sz));
+	_screen->loadFont(Screen::FID_6_FNT, "6.FNT");
+	_screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT");
 	_screen->setScreenDim(0);
 	
 	return 0;

Modified: scummvm/trunk/engines/kyra/resource.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource.cpp	2006-07-16 08:40:28 UTC (rev 23530)
+++ scummvm/trunk/engines/kyra/resource.cpp	2006-07-16 19:44:39 UTC (rev 23531)
@@ -51,8 +51,7 @@
 
 		// only VRM file we need in the *whole* game for kyra1
 		if (_engine->features() & GF_TALKIE) {
-			if (!loadPakFile("CHAPTER1.VRM"))
-				error("couldn't open pakfile 'CHAPTER1.VRM'");
+			loadPakFile("CHAPTER1.VRM");
 		}
 	} else if (_engine->game() == GI_KYRA3) {
 		// load the installation package file for kyra3

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2006-07-16 08:40:28 UTC (rev 23530)
+++ scummvm/trunk/engines/kyra/screen.cpp	2006-07-16 19:44:39 UTC (rev 23531)
@@ -612,20 +612,34 @@
 	}
 }
 
-void Screen::loadFont(FontId fontId, uint8 *fontData) {
-	debugC(9, kDebugLevelScreen, "Screen::loadFont(%d, %p)", fontId, (const void *)fontData);
+bool Screen::loadFont(FontId fontId, const char *filename) {
+	debugC(9, kDebugLevelScreen, "Screen::loadFont(%d, '%s')", fontId, filename);
 	Font *fnt = &_fonts[fontId];
-	assert(fontData && !fnt->fontData);
-	fnt->fontData = fontData;
+
+	if (!fnt)
+		error("fontId %d is invalid", fontId);
+
+	if (fnt->fontData)
+		delete [] fnt->fontData;
+
+	uint32 sz = 0;
+	uint8 *fontData = fnt->fontData = _vm->resource()->fileData(filename, &sz);
+
+	if (!fontData || !sz)
+		error("couldn't load font file '%s'", filename);
+
 	uint16 fontSig = READ_LE_UINT16(fontData + 2);
-	if (fontSig != 0x500) {
-		error("Invalid font data");
-	}
+
+	if (fontSig != 0x500)
+		error("Invalid font data (file '%s')", filename);
+
 	fnt->charWidthTable = fontData + READ_LE_UINT16(fontData + 8);
 	fnt->charSizeOffset = READ_LE_UINT16(fontData + 4);
 	fnt->charBitmapOffset = READ_LE_UINT16(fontData + 6);
 	fnt->charWidthTableOffset = READ_LE_UINT16(fontData + 8);
 	fnt->charHeightTableOffset = READ_LE_UINT16(fontData + 0xC);
+
+	return true;
 }
 
 Screen::FontId Screen::setFont(FontId fontId) {

Modified: scummvm/trunk/engines/kyra/screen.h
===================================================================
--- scummvm/trunk/engines/kyra/screen.h	2006-07-16 08:40:28 UTC (rev 23530)
+++ scummvm/trunk/engines/kyra/screen.h	2006-07-16 19:44:39 UTC (rev 23531)
@@ -119,7 +119,7 @@
 	void setAnimBlockPtr(int size);
 	void setTextColorMap(const uint8 *cmap);
 	void setTextColor(const uint8 *cmap, int a, int b);
-	void loadFont(FontId fontId, uint8 *fontData);
+	bool loadFont(FontId fontId, const char *filename);
 	FontId setFont(FontId fontId);
 	int getFontHeight() const;
 	int getFontWidth() const;

Modified: scummvm/trunk/engines/kyra/sequences_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sequences_v1.cpp	2006-07-16 08:40:28 UTC (rev 23530)
+++ scummvm/trunk/engines/kyra/sequences_v1.cpp	2006-07-16 19:44:39 UTC (rev 23531)
@@ -1040,10 +1040,9 @@
 	memset(strings, 0, sizeof(strings));
 	
 	_screen->hideMouse();
-	uint32 sz = 0;
 	if (_features & GF_FLOPPY) {
-		_screen->loadFont(Screen::FID_CRED6_FNT, _res->fileData("CREDIT6.FNT", &sz));
-		_screen->loadFont(Screen::FID_CRED8_FNT, _res->fileData("CREDIT8.FNT", &sz));
+		_screen->loadFont(Screen::FID_CRED6_FNT, "CREDIT6.FNT");
+		_screen->loadFont(Screen::FID_CRED8_FNT, "CREDIT8.FNT");
 	} else
 		_screen->setFont(Screen::FID_8_FNT);
 	






More information about the Scummvm-git-logs mailing list