aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2006-07-16 19:44:39 +0000
committerJohannes Schickel2006-07-16 19:44:39 +0000
commit73869dca9f91d26b0c01d1835e63c3703a9f4203 (patch)
treeff88e911f57935ec0dca5fc04e90e05e25d68ecf
parentd5e45271d131417f6cfe943e3e88e7890d6f5a2c (diff)
downloadscummvm-rg350-73869dca9f91d26b0c01d1835e63c3703a9f4203.tar.gz
scummvm-rg350-73869dca9f91d26b0c01d1835e63c3703a9f4203.tar.bz2
scummvm-rg350-73869dca9f91d26b0c01d1835e63c3703a9f4203.zip
- don't error on CHAPTER1.VRM miss anymore
- nicer error messages when no font files are found - implements nicer way to load fonts svn-id: r23531
-rw-r--r--engines/kyra/kyra.cpp5
-rw-r--r--engines/kyra/kyra3.cpp5
-rw-r--r--engines/kyra/resource.cpp3
-rw-r--r--engines/kyra/screen.cpp28
-rw-r--r--engines/kyra/screen.h2
-rw-r--r--engines/kyra/sequences_v1.cpp5
6 files changed, 29 insertions, 19 deletions
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp
index d8b0cfc1a4..cc2b866220 100644
--- a/engines/kyra/kyra.cpp
+++ b/engines/kyra/kyra.cpp
@@ -390,12 +390,11 @@ void KyraEngine::errorString(const char *buf1, char *buf2) {
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;
diff --git a/engines/kyra/kyra3.cpp b/engines/kyra/kyra3.cpp
index f254ddb285..258330e4c5 100644
--- a/engines/kyra/kyra3.cpp
+++ b/engines/kyra/kyra3.cpp
@@ -85,9 +85,8 @@ int KyraEngine_v3::init() {
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;
diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp
index fd6e8cab2b..8771fc6543 100644
--- a/engines/kyra/resource.cpp
+++ b/engines/kyra/resource.cpp
@@ -51,8 +51,7 @@ Resource::Resource(KyraEngine *engine) {
// 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
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index c3e7715dbb..ea164f2d1c 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -612,20 +612,34 @@ void Screen::setTextColor(const uint8 *cmap, int a, int b) {
}
}
-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) {
diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h
index 0c8b36ca0e..d1928e89fb 100644
--- a/engines/kyra/screen.h
+++ b/engines/kyra/screen.h
@@ -119,7 +119,7 @@ public:
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;
diff --git a/engines/kyra/sequences_v1.cpp b/engines/kyra/sequences_v1.cpp
index 17e85942a1..8d527b09ad 100644
--- a/engines/kyra/sequences_v1.cpp
+++ b/engines/kyra/sequences_v1.cpp
@@ -1040,10 +1040,9 @@ void KyraEngine::seq_playCredits() {
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);