aboutsummaryrefslogtreecommitdiff
path: root/graphics/sjis.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2009-07-26 14:17:06 +0000
committerJohannes Schickel2009-07-26 14:17:06 +0000
commit0a612f40eb047fc80fafb1a7df4b8788d2c4fe66 (patch)
tree335cc276f7000db293a4006a3e6528ad2b4499b7 /graphics/sjis.cpp
parent712e0c80eaef79870a302749ae3e91c637088f81 (diff)
downloadscummvm-rg350-0a612f40eb047fc80fafb1a7df4b8788d2c4fe66.tar.gz
scummvm-rg350-0a612f40eb047fc80fafb1a7df4b8788d2c4fe66.tar.bz2
scummvm-rg350-0a612f40eb047fc80fafb1a7df4b8788d2c4fe66.zip
Add support for our custom SJIS font.
svn-id: r42813
Diffstat (limited to 'graphics/sjis.cpp')
-rw-r--r--graphics/sjis.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/graphics/sjis.cpp b/graphics/sjis.cpp
index 6f8979bc6e..0fad3fff94 100644
--- a/graphics/sjis.cpp
+++ b/graphics/sjis.cpp
@@ -27,6 +27,7 @@
#ifdef GRAPHICS_SJIS_H
#include "common/debug.h"
+#include "common/archive.h"
namespace Graphics {
@@ -194,6 +195,52 @@ const uint16 *FontTowns::getCharData(uint16 ch) const {
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)