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

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


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

Log Message:
-----------
Add support for our custom SJIS font.

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

Modified: scummvm/trunk/graphics/sjis.cpp
===================================================================
--- scummvm/trunk/graphics/sjis.cpp	2009-07-26 14:16:51 UTC (rev 42812)
+++ scummvm/trunk/graphics/sjis.cpp	2009-07-26 14:17:06 UTC (rev 42813)
@@ -27,6 +27,7 @@
 #ifdef GRAPHICS_SJIS_H
 
 #include "common/debug.h"
+#include "common/archive.h"
 
 namespace Graphics {
 
@@ -194,6 +195,52 @@
 	return _fontData + (((chunk_f + chunk) * 32 + (s - base)) + cr) * 16;
 }
 
+// ScummVM SJIS font
+
+bool FontSjisSVM::loadData() {
+	Common::SeekableReadStream *data = SearchMan.createReadStreamForMember("SJIS.FNT");
+	if (!data)
+		return false;
+
+	uint32 version = data->readUint32BE();
+	if (version != 1) {
+		delete data;
+		return false;
+	}
+	uint numChars = data->readUint16BE();
+
+	_fontData = new uint16[numChars * 16];
+	assert(_fontData);
+
+	for (uint i = 0; i < numChars * 16; ++i)
+		_fontData[i] = data->readUint16BE();
+	
+	bool retValue = !data->err();
+	delete data;
+	return retValue;
+}
+
+const uint16 *FontSjisSVM::getCharData(uint16 c) const {
+	const uint8 fB = c & 0xFF;
+	const uint8 sB = c >> 8;
+
+	// We only allow 2 byte SJIS characters.
+	if (fB <= 0x80 || fB >= 0xF0 || (fB >= 0xA0 && fB <= 0xDF) || sB == 0x7F)
+		return 0;
+
+	int base = fB;
+	base -= 0x81;
+	if (base >= 0x5F)
+		base -= 0x40;
+
+	int index = sB;
+	index -= 0x40;
+	if (index >= 0x3F)
+		--index;
+
+	return _fontData + (base * 0xBC + index) * 16;
+}
+
 } // end of namespace Graphics
 
 #endif // defined(GRAPHICS_SJIS_H)

Modified: scummvm/trunk/graphics/sjis.h
===================================================================
--- scummvm/trunk/graphics/sjis.h	2009-07-26 14:16:51 UTC (rev 42812)
+++ scummvm/trunk/graphics/sjis.h	2009-07-26 14:17:06 UTC (rev 42813)
@@ -133,6 +133,25 @@
 	const uint16 *getCharData(uint16 c) const;
 };
 
+/**
+ * Our custom SJIS FNT.
+ */
+class FontSjisSVM : public FontSJIS16x16 {
+public:
+	FontSjisSVM() : _fontData(0) {}
+	~FontSjisSVM() { delete[] _fontData; }
+
+	/**
+	 * Load the ROM data from "SJIS.FNT".
+	 */
+	bool loadData();
+
+private:
+	uint16 *_fontData;
+
+	const uint16 *getCharData(uint16 c) const;
+};
+
 // TODO: Consider adding support for PC98 ROM
 
 } // end of namespace Graphics


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