[Scummvm-cvs-logs] SF.net SVN: scummvm:[42815] scummvm/trunk

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Jul 26 16:17:40 CEST 2009


Revision: 42815
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42815&view=rev
Author:   lordhoto
Date:     2009-07-26 14:17:40 +0000 (Sun, 26 Jul 2009)

Log Message:
-----------
Change the way the font data for SJIS fonts is load.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/screen.cpp
    scummvm/trunk/graphics/sjis.cpp
    scummvm/trunk/graphics/sjis.h

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2009-07-26 14:17:21 UTC (rev 42814)
+++ scummvm/trunk/engines/kyra/screen.cpp	2009-07-26 14:17:40 UTC (rev 42815)
@@ -95,33 +95,27 @@
 		}
 
 		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);
 		}
 	}

Modified: scummvm/trunk/graphics/sjis.cpp
===================================================================
--- scummvm/trunk/graphics/sjis.cpp	2009-07-26 14:17:21 UTC (rev 42814)
+++ scummvm/trunk/graphics/sjis.cpp	2009-07-26 14:17:40 UTC (rev 42815)
@@ -101,10 +101,19 @@
 	}
 }
 
-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 {

Modified: scummvm/trunk/graphics/sjis.h
===================================================================
--- scummvm/trunk/graphics/sjis.h	2009-07-26 14:17:21 UTC (rev 42814)
+++ scummvm/trunk/graphics/sjis.h	2009-07-26 14:17:40 UTC (rev 42815)
@@ -50,6 +50,11 @@
 	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 @@
 	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 @@
 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 @@
 	~FontSjisSVM() { delete[] _fontData; }
 
 	/**
-	 * Load the ROM data from "SJIS.FNT".
+	 * Load the font data from "SJIS.FNT".
 	 */
 	bool loadData();
 


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