[Scummvm-cvs-logs] SF.net SVN: scummvm:[34065] scummvm/trunk/engines/cine
buddha_ at users.sourceforge.net
buddha_ at users.sourceforge.net
Wed Aug 20 19:31:37 CEST 2008
Revision: 34065
http://scummvm.svn.sourceforge.net/scummvm/?rev=34065&view=rev
Author: buddha_
Date: 2008-08-20 17:31:35 +0000 (Wed, 20 Aug 2008)
Log Message:
-----------
Fix font loading:
Fixes bug #2058539: OS: Assert starting demo (regression).
May possibly also fix bug #2019344: FW: crash with Amiga Italian version (photocopy room),
but not sure about that because I couldn't reproduce the bug myself.
Modified Paths:
--------------
scummvm/trunk/engines/cine/gfx.cpp
scummvm/trunk/engines/cine/texte.cpp
scummvm/trunk/engines/cine/texte.h
Modified: scummvm/trunk/engines/cine/gfx.cpp
===================================================================
--- scummvm/trunk/engines/cine/gfx.cpp 2008-08-20 16:14:10 UTC (rev 34064)
+++ scummvm/trunk/engines/cine/gfx.cpp 2008-08-20 17:31:35 UTC (rev 34065)
@@ -368,7 +368,7 @@
x += 5;
} else if ((width = g_cine->_textHandler.fontParamTable[(unsigned char)character].characterWidth)) {
idx = g_cine->_textHandler.fontParamTable[(unsigned char)character].characterIdx;
- drawSpriteRaw(g_cine->_textHandler.textTable[idx][0], g_cine->_textHandler.textTable[idx][1], 16, 8, _backBuffer, x, y);
+ drawSpriteRaw(g_cine->_textHandler.textTable[idx][FONT_DATA], g_cine->_textHandler.textTable[idx][FONT_MASK], FONT_WIDTH, FONT_HEIGHT, _backBuffer, x, y);
x += width + 1;
}
@@ -1040,7 +1040,7 @@
x += 5;
} else if ((width = g_cine->_textHandler.fontParamTable[(unsigned char)character].characterWidth)) {
idx = g_cine->_textHandler.fontParamTable[(unsigned char)character].characterIdx;
- drawSpriteRaw2(g_cine->_textHandler.textTable[idx][0], 0, 16, 8, _backBuffer, x, y);
+ drawSpriteRaw2(g_cine->_textHandler.textTable[idx][FONT_DATA], 0, FONT_WIDTH, FONT_HEIGHT, _backBuffer, x, y);
x += width + 1;
}
Modified: scummvm/trunk/engines/cine/texte.cpp
===================================================================
--- scummvm/trunk/engines/cine/texte.cpp 2008-08-20 16:14:10 UTC (rev 34064)
+++ scummvm/trunk/engines/cine/texte.cpp 2008-08-20 17:31:35 UTC (rev 34065)
@@ -39,6 +39,13 @@
void generateMask(const byte *sprite, byte *mask, uint16 size, byte transparency);
+/*! \brief Loads font data from the given file.
+ * The number of characters used in the font varies between game versions:
+ * 78 (Most PC, Amiga and Atari ST versions of Future Wars, but also Operation Stealth's Amiga demo),
+ * 85 (All observed versions of German Future Wars (Amiga and PC), possibly Spanish Future Wars too),
+ * 90 (Most PC, Amiga and Atari ST versions of Operation Stealth),
+ * 93 (All observed versions of German Operation Stealth (Amiga and PC)).
+ */
void loadTextData(const char *filename) {
Common::File fileHandle;
assert(filename);
@@ -46,30 +53,29 @@
if (!fileHandle.open(filename))
error("loadTextData(): Cannot open file %s", filename);
- uint entrySize = fileHandle.readUint16BE();
- uint numEntry = fileHandle.readUint16BE();
+ static const uint headerSize = 2 + 2; // The entry size (16-bit) and entry count (16-bit).
+ const uint entrySize = fileHandle.readUint16BE(); // Observed values: 8.
+ const uint entryCount = fileHandle.readUint16BE(); // Observed values: 624, 680, 720, 744.
+ const uint fontDataSize = entryCount * entrySize; // Observed values: 4992, 5440, 5760, 5952.
+ const uint numChars = entryCount / entrySize; // Observed values: 78, 85, 90, 93.
+ const uint bytesPerChar = fontDataSize / numChars; // Observed values: 64.
+ static const uint bytesPerRow = FONT_WIDTH / 2; // The input font data is 4-bit so it takes only half the space
- uint sourceSize = numEntry * entrySize;
+ if (headerSize + fontDataSize != fileHandle.size()) {
+ warning("loadTextData: file '%s' (entrySize = %d, entryCount = %d) is of incorrect size %d", filename, entrySize, entryCount, fileHandle.size());
+ }
+
Common::Array<byte> source;
- source.resize(sourceSize);
- fileHandle.read(source.begin(), sourceSize);
+ source.resize(fontDataSize);
+ fileHandle.read(source.begin(), fontDataSize);
- const int fontHeight = 8;
- const int fontWidth = (g_cine->getGameType() == Cine::GType_FW) ? 16 : 8;
- uint numCharacters;
- uint bytesPerCharacter;
if (g_cine->getGameType() == Cine::GType_FW) {
- numCharacters = (g_cine->getFeatures() & GF_ALT_FONT) ? 85 : 78;
- bytesPerCharacter = sourceSize / numCharacters; // TODO: Check if this could be replaced with fontWidth * fontHeight
loadRelatedPalette(filename);
- } else {
- numCharacters = 90;
- bytesPerCharacter = fontWidth * fontHeight;
}
- for (uint i = 0; i < numCharacters; i++) {
- gfxConvertSpriteToRaw(g_cine->_textHandler.textTable[i][0], &source[i * bytesPerCharacter], fontWidth, fontHeight);
- generateMask(g_cine->_textHandler.textTable[i][0], g_cine->_textHandler.textTable[i][1], fontWidth * fontHeight, 0);
+ for (uint i = 0; i < numChars; i++) {
+ gfxConvertSpriteToRaw(g_cine->_textHandler.textTable[i][FONT_DATA], &source[i * bytesPerChar], bytesPerRow, FONT_HEIGHT);
+ generateMask(g_cine->_textHandler.textTable[i][FONT_DATA], g_cine->_textHandler.textTable[i][FONT_MASK], FONT_WIDTH * FONT_HEIGHT, 0);
}
fileHandle.close();
Modified: scummvm/trunk/engines/cine/texte.h
===================================================================
--- scummvm/trunk/engines/cine/texte.h 2008-08-20 16:14:10 UTC (rev 34064)
+++ scummvm/trunk/engines/cine/texte.h 2008-08-20 17:31:35 UTC (rev 34065)
@@ -36,13 +36,20 @@
// Number of characters in a font
#define NUM_FONT_CHARS 256
+#define FONT_WIDTH 16
+#define FONT_HEIGHT 8
+
+// Used for choosing between font's data and font's mask
+#define FONT_DATA 0
+#define FONT_MASK 1
+
struct CharacterEntry {
byte characterIdx;
byte characterWidth;
};
struct TextHandler {
- byte textTable[NUM_FONT_CHARS][2][16 * 8];
+ byte textTable[NUM_FONT_CHARS][2][FONT_WIDTH * FONT_HEIGHT];
CharacterEntry fontParamTable[NUM_FONT_CHARS];
};
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