diff options
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/detection.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/saveload.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/screen.cpp | 287 | ||||
-rw-r--r-- | engines/kyra/screen.h | 14 | ||||
-rw-r--r-- | engines/kyra/sequences_hof.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/sequences_lok.cpp | 2 |
6 files changed, 42 insertions, 277 deletions
diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp index 63d15419d2..3199a043e7 100644 --- a/engines/kyra/detection.cpp +++ b/engines/kyra/detection.cpp @@ -230,7 +230,7 @@ const KYRAGameDescription adGameDescs[] = { KYRA1_FLOPPY_FLAGS }, - { // FM-Towns version + { // FM-TOWNS version { "kyra1", 0, @@ -638,7 +638,7 @@ const KYRAGameDescription adGameDescs[] = { KYRA2_DEMO_FLAGS }, - { // FM-Towns + { // FM-TOWNS { "kyra2", 0, diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp index ecd6bbe450..a1aaf77d51 100644 --- a/engines/kyra/saveload.cpp +++ b/engines/kyra/saveload.cpp @@ -168,7 +168,7 @@ Common::SeekableReadStream *KyraEngine_v1::openSaveForReading(const char *filena delete in; return 0; } else if ((header.flags & GF_FMTOWNS) && !(_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)) { - warning("Can not load FM-Towns/PC98 savefile for this (non FM-Towns/PC98) gameversion"); + warning("Can not load FM-TOWNS/PC98 savefile for this (non FM-TOWNS/PC98) gameversion"); delete in; return 0; } diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index 963dc3f4d6..426907c871 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -26,7 +26,10 @@ #include "common/endian.h" #include "common/system.h" + #include "graphics/cursorman.h" +#include "graphics/sjis.h" + #include "kyra/screen.h" #include "kyra/kyra_v1.h" #include "kyra/resource.h" @@ -43,6 +46,8 @@ Screen::Screen(KyraEngine_v1 *vm, OSystem *system) _drawShapeVar3 = 1; _drawShapeVar4 = 0; _drawShapeVar5 = 0; + + _sjisFont = 0; } Screen::~Screen() { @@ -56,8 +61,7 @@ Screen::~Screen() { _fonts[f].fontData = NULL; } - delete[] _sjisFontData; - delete[] _sjisTempPage; + delete _sjisFont; delete _screenPalette; delete _internFadePalette; delete[] _decodeShapeBuffer; @@ -78,8 +82,6 @@ bool Screen::init() { _useSJIS = false; _use16ColorMode = _vm->gameFlags().use16ColorMode; - _sjisTempPage = _sjisFontData = 0; - if (_vm->gameFlags().useHiResOverlay) { _useOverlays = true; _useSJIS = (_vm->gameFlags().lang == Common::JA_JPN); @@ -94,14 +96,17 @@ bool Screen::init() { } if (_useSJIS) { - if (!_sjisFontData) { - // we use the FM-Towns font rom for PC-98, too, until we feel + 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 - _sjisFontData = _vm->resource()->fileData("FMT_FNT.ROM", 0); - if (!_sjisFontData) - error("missing font rom ('FMT_FNT.ROM') required for this version"); + // 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); @@ -109,16 +114,12 @@ bool Screen::init() { error("missing font rom ('FONT.ROM') required for this version"); }*/ } - - if (!_sjisTempPage) { - _sjisTempPage = new uint8[420]; - assert(_sjisTempPage); - _sjisTempPage2 = _sjisTempPage + 60; - _sjisSourceChar = _sjisTempPage + 384; - } + + _sjisFont->enableOutline(!_use16ColorMode); } } + _curPage = 0; uint8 *pagePtr = new uint8[SCREEN_PAGE_SIZE * 8]; for (int pageNum = 0; pageNum < SCREEN_PAGE_NUM; pageNum += 2) @@ -657,7 +658,7 @@ void Screen::copyToPage0(int y, int h, uint8 page, uint8 *seqBuf) { } addDirtyRect(0, y, SCREEN_W, h); // This would remove the text in the end sequence of - // the (Kyrandia 1) FM-Towns version. + // the (Kyrandia 1) FM-TOWNS version. // Since this method is just used for the Seqplayer // this shouldn't be a problem anywhere else, so it's // safe to disable the call here. @@ -1027,8 +1028,8 @@ int Screen::getCharWidth(uint16 c) const { if (_vm->gameFlags().platform == Common::kPlatformAmiga) return 0; - if (c & 0xFF00) - return SJIS_CHARSIZE >> 1; + if ((c & 0xFF00) && _sjisFont) + return _sjisFont->getFontWidth() >> 1; if (_fonts[_currentFont].lastGlyph < c) return 0; @@ -1115,7 +1116,7 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2 c = READ_LE_UINT16(str - 1); ++str; charWidth = getCharWidth(c); - charHeight = SJIS_CHARSIZE >> 1; + charHeight = _sjisFont->getFontHeight() >> 1; drawCharSJIS(c, x, y); } @@ -3007,93 +3008,6 @@ void Screen::copyOverlayRegion(int x, int y, int x2, int y2, int w, int h, int s } } -// SJIS rendering - -namespace { -int SJIStoFMTChunk(int f, int s) { // copied from scumm\charset.cpp - enum { - KANA = 0, - KANJI = 1, - EKANJI = 2 - }; - int base = s - ((s + 1) % 32); - int c = 0, p = 0, chunk_f = 0, chunk = 0, cr = 0, kanjiType = KANA; - - if (f >= 0x81 && f <= 0x84) kanjiType = KANA; - if (f >= 0x88 && f <= 0x9f) kanjiType = KANJI; - if (f >= 0xe0 && f <= 0xea) kanjiType = EKANJI; - - if ((f > 0xe8 || (f == 0xe8 && base >= 0x9f)) || (f > 0x90 || (f == 0x90 && base >= 0x9f))) { - c = 48; //correction - p = -8; //correction - } - - if (kanjiType == KANA) {//Kana - chunk_f = (f - 0x81) * 2; - } else if (kanjiType == KANJI) {//Standard Kanji - p += f - 0x88; - chunk_f = c + 2 * p; - } else if (kanjiType == EKANJI) {//Enhanced Kanji - p += f - 0xe0; - chunk_f = c + 2 * p; - } - - // Base corrections - if (base == 0x7f && s == 0x7f) - base -= 0x20; - if (base == 0x9f && s == 0xbe) - base += 0x20; - if (base == 0xbf && s == 0xde) - base += 0x20; - //if (base == 0x7f && s == 0x9e) - // base += 0x20; - - switch (base) { - case 0x3f: - cr = 0; //3f - if (kanjiType == KANA) chunk = 1; - else if (kanjiType == KANJI) chunk = 31; - else if (kanjiType == EKANJI) chunk = 111; - break; - case 0x5f: - cr = 0; //5f - if (kanjiType == KANA) chunk = 17; - else if (kanjiType == KANJI) chunk = 47; - else if (kanjiType == EKANJI) chunk = 127; - break; - case 0x7f: - cr = -1; //80 - if (kanjiType == KANA) chunk = 9; - else if (kanjiType == KANJI) chunk = 63; - else if (kanjiType == EKANJI) chunk = 143; - break; - case 0x9f: - cr = 1; //9e - if (kanjiType == KANA) chunk = 2; - else if (kanjiType == KANJI) chunk = 32; - else if (kanjiType == EKANJI) chunk = 112; - break; - case 0xbf: - cr = 1; //be - if (kanjiType == KANA) chunk = 18; - else if (kanjiType == KANJI) chunk = 48; - else if (kanjiType == EKANJI) chunk = 128; - break; - case 0xdf: - cr = 1; //de - if (kanjiType == KANA) chunk = 10; - else if (kanjiType == KANJI) chunk = 64; - else if (kanjiType == EKANJI) chunk = 144; - break; - default: - debug(4, "Invalid Char! f %x s %x base %x c %d p %d", f, s, base, c, p); - } - - debug(6, "Kanji: %c%c f 0x%x s 0x%x base 0x%x c %d p %d chunk %d cr %d index %d", f, s, f, s, base, c, p, chunk, cr, ((chunk_f + chunk) * 32 + (s - base)) + cr); - return ((chunk_f + chunk) * 32 + (s - base)) + cr; -} -} // end of anonymous namespace - void Screen::drawCharSJIS(uint16 c, int x, int y) { int color1, color2; @@ -3105,14 +3019,13 @@ void Screen::drawCharSJIS(uint16 c, int x, int y) { } else { color1 = _textColorsMap[1]; color2 = _textColorsMap[0]; - } - memset(_sjisTempPage2, _sjisInvisibleColor, 324); - memset(_sjisSourceChar, 0, 36); - memcpy(_sjisSourceChar, _sjisFontData + 0x20 * SJIStoFMTChunk(c & 0xff, c >> 8), 0x20); + if (color2 == _sjisInvisibleColor) + _sjisFont->enableOutline(false); + } if (_curPage == 0 || _curPage == 1) - addDirtyRect(x, y, SJIS_CHARSIZE >> 1, SJIS_CHARSIZE >> 1); + addDirtyRect(x, y, _sjisFont->getFontWidth() >> 1, _sjisFont->getFontHeight() >> 1); x <<= 1; y <<= 1; @@ -3124,154 +3037,10 @@ void Screen::drawCharSJIS(uint16 c, int x, int y) { } destPage += y * 640 + x; - uint8 *src = 0, *dst = 0; - - if (color2 != _sjisInvisibleColor) { - // draw color2 shadow - src = _sjisSourceChar; - dst = _sjisTempPage2; - - for (int i = 0; i < SJIS_CHARSIZE; i++) { - *((uint16*)dst) = READ_LE_UINT16(src); - dst += 2; src += 2; - *dst++ = 0; - } - - src = _sjisTempPage2; - dst = _sjisTempPage; - memset(dst, 0, 60); - for (int i = 0; i < 48; i++) - *dst++ |= *src++; - - src = _sjisTempPage2; - dst = _sjisTempPage + 3; - for (int i = 0; i < 48; i++) - *dst++ |= *src++; - - src = _sjisTempPage2; - dst = _sjisTempPage + 6; - for (int i = 0; i < 48; i++) - *dst++ |= *src++; - - for (int i = 0; i < 2; i++) { - src = _sjisTempPage; - for (int ii = 0; ii < SJIS_CHARSIZE; ii++) { - uint8 cy2 = 0; - uint8 cy1 = 0; - for (int iii = 0; iii < 3; iii++) { - cy1 = *src & 1; - *src |= ((*src >> 1) | (cy2 << 7)); - cy2 = cy1; - src++; - } - } - } - - src = _sjisTempPage2; - for (int i = 0; i < SJIS_CHARSIZE; i++) { - uint8 cy2 = 0; - uint8 cy1 = 0; - for (int ii = 0; ii < 3; ii++) { - cy1 = *src & 1; - *src = ((*src >> 1) | (cy2 << 7)); - cy2 = cy1; - src++; - } - } - src = _sjisTempPage2; - dst = _sjisTempPage + 3; - for (int i = 0; i < 48; i++) - *dst++ ^= *src++; - - memset(_sjisTempPage2, _sjisInvisibleColor, 324); - src = _sjisTempPage; - dst = _sjisTempPage2; - - uint8 height = SJIS_CHARSIZE * 3; - uint8 width = SJIS_CHARSIZE; - if (color2 & 0xff00) { - height -= 3; - width--; - dst += 0x13; - } - - for (int i = 0; i < height; i++) { - uint8 rs = *src++; - for (int ii = 0; ii < 8; ii++) { - if (rs & 0x80) - *dst = (color2 & 0xff); - rs <<= 1; - dst++; - - if (!--width) { - width = SJIS_CHARSIZE; - if (color2 & 0xff00) { - width--; - dst++; - } - break; - } - } - } - } - - // draw color1 char - src = _sjisSourceChar; - dst = _sjisTempPage; - - for (int i = 0; i < SJIS_CHARSIZE; i++) { - *(uint16*)dst = READ_LE_UINT16(src); - dst += 2; src += 2; - *dst++ = 0; - } + _sjisFont->drawChar(destPage, c, 640, 1, color1, color2); - src = _sjisTempPage; - dst = _sjisTempPage2; - if (color2 != _sjisInvisibleColor) - color1 = (color1 & 0xff) | 0x100; - - uint8 height = SJIS_CHARSIZE * 3; - uint8 width = SJIS_CHARSIZE; - if (color1 & 0xff00) { - height -= 3; - width--; - dst += 0x13; - } - - for (int i = 0; i < height; i++) { - uint8 rs = *src++; - for (int ii = 0; ii < 8; ii++) { - if (rs & 0x80) - *dst = (color1 & 0xff); - rs <<= 1; - dst++; - - if (!--width) { - width = SJIS_CHARSIZE; - if (color1 & 0xff00) { - width--; - dst++; - } - break; - } - } - } - - // copy char to surface - src = _sjisTempPage2; - dst = destPage; - int pitch = 640 - SJIS_CHARSIZE; - - for (int i = 0; i < SJIS_CHARSIZE; i++) { - for (int ii = 0; ii < SJIS_CHARSIZE; ii++) { - if (*src != _sjisInvisibleColor) - *dst = *src; - src++; - dst++; - } - dst += pitch; - } + _sjisFont->enableOutline(!_use16ColorMode); } #pragma mark - diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h index 956bd7107e..a7a7efa7ca 100644 --- a/engines/kyra/screen.h +++ b/engines/kyra/screen.h @@ -35,6 +35,10 @@ class OSystem; +namespace Graphics { +class FontSJIS; +} // end of namespace Graphics + namespace Kyra { typedef Common::Functor0<void> UpdateFunctor; @@ -360,11 +364,6 @@ protected: void drawCharANSI(uint8 c, int x, int y); void drawCharSJIS(uint16 c, int x, int y); - enum { - SJIS_CHARSIZE = 18, - SJIS_CHARS = 8192 - }; - int16 encodeShapeAndCalculateSize(uint8 *from, uint8 *to, int size); template<bool noXor> static void wrapped_decodeFrameDelta(uint8 *dst, const uint8 *src); @@ -377,10 +376,7 @@ protected: bool _useSJIS; bool _use16ColorMode; - uint8 *_sjisFontData; - uint8 *_sjisTempPage; - uint8 *_sjisTempPage2; - uint8 *_sjisSourceChar; + Graphics::FontSJIS *_sjisFont; uint8 _sjisInvisibleColor; Palette *_screenPalette; diff --git a/engines/kyra/sequences_hof.cpp b/engines/kyra/sequences_hof.cpp index 90b2fdd580..81ab237e0f 100644 --- a/engines/kyra/sequences_hof.cpp +++ b/engines/kyra/sequences_hof.cpp @@ -770,12 +770,12 @@ int KyraEngine_HoF::seq_introDragon(WSAMovie_v2 *wsaObj, int x, int y, int frm) } int KyraEngine_HoF::seq_introDarm(WSAMovie_v2 *wsaObj, int x, int y, int frm) { - //NULLSUB (at least in fm-towns version) + //NULLSUB (at least in FM-TOWNS version) return frm; } int KyraEngine_HoF::seq_introLibrary2(WSAMovie_v2 *wsaObj, int x, int y, int frm) { - //NULLSUB (at least in fm-towns version) + //NULLSUB (at least in FM-TOWNS version) return frm; } @@ -788,7 +788,7 @@ int KyraEngine_HoF::seq_introMarco(WSAMovie_v2 *wsaObj, int x, int y, int frm) { } int KyraEngine_HoF::seq_introHand1a(WSAMovie_v2 *wsaObj, int x, int y, int frm) { - //NULLSUB (at least in fm-towns version) + //NULLSUB (at least in FM-TOWNS version) return frm; } @@ -805,12 +805,12 @@ int KyraEngine_HoF::seq_introHand1c(WSAMovie_v2 *wsaObj, int x, int y, int frm) } int KyraEngine_HoF::seq_introHand2(WSAMovie_v2 *wsaObj, int x, int y, int frm) { - //NULLSUB (at least in fm-towns version) + //NULLSUB (at least in FM-TOWNS version) return frm; } int KyraEngine_HoF::seq_introHand3(WSAMovie_v2 *wsaObj, int x, int y, int frm) { - //NULLSUB (at least in fm-towns version) + //NULLSUB (at least in FM-TOWNS version) return frm; } diff --git a/engines/kyra/sequences_lok.cpp b/engines/kyra/sequences_lok.cpp index d483409090..0279831c9d 100644 --- a/engines/kyra/sequences_lok.cpp +++ b/engines/kyra/sequences_lok.cpp @@ -1049,7 +1049,7 @@ void KyraEngine_LoK::seq_playCredits() { _screen->setTextColorMap(colorMap); _screen->_charWidth = -1; - // we only need this for the fm-towns version + // we only need this for the FM-TOWNS version if (_flags.platform == Common::kPlatformFMTowns && _configMusic == 1) snd_playWanderScoreViaMap(53, 1); |