aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2009-07-26 14:17:40 +0000
committerJohannes Schickel2009-07-26 14:17:40 +0000
commitcb960ad976bf523704beb71641bc242501a67a53 (patch)
treeb3c3b481c752c3dbdb3c177f942fd36dd8af477e
parent0a03ae8265a894270f2bd299bde1c0b22d935490 (diff)
downloadscummvm-rg350-cb960ad976bf523704beb71641bc242501a67a53.tar.gz
scummvm-rg350-cb960ad976bf523704beb71641bc242501a67a53.tar.bz2
scummvm-rg350-cb960ad976bf523704beb71641bc242501a67a53.zip
Change the way the font data for SJIS fonts is load.
svn-id: r42815
-rw-r--r--engines/kyra/screen.cpp40
-rw-r--r--graphics/sjis.cpp15
-rw-r--r--graphics/sjis.h14
3 files changed, 40 insertions, 29 deletions
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index c1ab409e17..53df4bbbd9 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -95,33 +95,27 @@ bool Screen::init() {
}
if (_useSJIS) {
- // First we try to use ScummVM's own SJIS font.
- Graphics::FontSjisSVM *font = new Graphics::FontSjisSVM();
- if (!font || !font->loadData()) {
- delete font;
- } else {
- _sjisFont = font;
+ // First of all try to load the original ROM
+ if (_vm->gameFlags().platform == Common::kPlatformFMTowns) {
+ _sjisFont = new Graphics::FontTowns();
+ if (_sjisFont && !_sjisFont->loadData()) {
+ delete _sjisFont;
+ _sjisFont = 0;
+ }
}
+ // If we were not able to load any system ROM, we'll try the
+ // ScummVM SJIS font.
if (!_sjisFont) {
- // we use the FM-TOWNS font rom for PC-98, too, until we feel
- // like adding support for the PC-98 font
- //if (_vm->gameFlags().platform == Common::kPlatformFMTowns) {
- // FM-TOWNS
- Common::SeekableReadStream *rom = _vm->resource()->createReadStream("FMT_FNT.ROM");
- Graphics::FontTowns *townsFont = new Graphics::FontTowns();
- if (!rom || !townsFont || !townsFont->loadFromStream(*rom))
- error("Could not load font rom ('FMT_FNT.ROM') required for this version");
- _sjisFont = townsFont;
- delete rom;
- /*} else {
- // PC-98
- _sjisFontData = _vm->resource()->fileData("FONT.ROM", 0);
- if (!_sjisFontData)
- error("missing font rom ('FONT.ROM') required for this version");
- }*/
+ _sjisFont = new Graphics::FontSjisSVM();
+ if (_sjisFont && !_sjisFont->loadData()) {
+ delete _sjisFont;
+ _sjisFont = 0;
+ }
}
-
+
+ if (!_sjisFont)
+ error("Could not load any SJIS font, neither the original nor ScummVM's 'SJIS.FNT'");
_sjisFont->enableOutline(!_use16ColorMode);
}
}
diff --git a/graphics/sjis.cpp b/graphics/sjis.cpp
index 0fad3fff94..a00fdc83cb 100644
--- a/graphics/sjis.cpp
+++ b/graphics/sjis.cpp
@@ -101,10 +101,19 @@ void FontSJIS16x16::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1
}
}
-bool FontTowns::loadFromStream(Common::ReadStream &stream) {
+// FM-TOWNS ROM font
+
+bool FontTowns::loadData() {
+ Common::SeekableReadStream *data = SearchMan.createReadStreamForMember("FMT_FNT.ROM");
+ if (!data)
+ return false;
+
for (uint i = 0; i < (kFontRomSize / 2); ++i)
- _fontData[i] = stream.readUint16BE();
- return !stream.err();
+ _fontData[i] = data->readUint16BE();
+
+ bool retValue = !data->err();
+ delete data;
+ return retValue;
}
const uint16 *FontTowns::getCharData(uint16 ch) const {
diff --git a/graphics/sjis.h b/graphics/sjis.h
index 661a8834b0..141a1ed13a 100644
--- a/graphics/sjis.h
+++ b/graphics/sjis.h
@@ -50,6 +50,11 @@ public:
virtual ~FontSJIS() {}
/**
+ * Load the font data.
+ */
+ virtual bool loadData() = 0;
+
+ /**
* Enable outline drawing.
*
* After changing outline state, getFontHeight and getFontWidth might return
@@ -87,6 +92,9 @@ public:
virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2) const = 0;
};
+/**
+ * A base class to render 16x16 monochrome SJIS fonts.
+ */
class FontSJIS16x16 : public FontSJIS {
public:
FontSJIS16x16() : _outlineEnabled(false) {}
@@ -119,9 +127,9 @@ protected:
class FontTowns : public FontSJIS16x16 {
public:
/**
- * Loads the ROM data from the given read stream.
+ * Loads the ROM data from "FMT_FNT.ROM".
*/
- bool loadFromStream(Common::ReadStream &stream);
+ bool loadData();
private:
enum {
@@ -142,7 +150,7 @@ public:
~FontSjisSVM() { delete[] _fontData; }
/**
- * Load the ROM data from "SJIS.FNT".
+ * Load the font data from "SJIS.FNT".
*/
bool loadData();