aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2010-04-20 16:46:26 +0000
committerMartin Kiewitz2010-04-20 16:46:26 +0000
commit1e62e44fb6f5c5c1f764ec6535c3845eb7f2fc28 (patch)
treef47fe0034918b886aa9378024f6f5392a923b3ae /engines/sci
parentad24968f56a4dc0d36d6d21c096b1b302558f03d (diff)
downloadscummvm-rg350-1e62e44fb6f5c5c1f764ec6535c3845eb7f2fc28.tar.gz
scummvm-rg350-1e62e44fb6f5c5c1f764ec6535c3845eb7f2fc28.tar.bz2
scummvm-rg350-1e62e44fb6f5c5c1f764ec6535c3845eb7f2fc28.zip
SCI: the pc98 rom has to display kanji directly, because of the bad behaviour of GetLongest() we will actually put more chars in each line as actually fit. That way the scripts will only show most of the chars, but actually leave out some of the pixels of the far right characters. We now show kanji chars directly, sort of reproducing pc98 rom behaviour
svn-id: r48748
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/graphics/text16.cpp35
-rw-r--r--engines/sci/graphics/text16.h2
2 files changed, 31 insertions, 6 deletions
diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp
index 15cc3fd5a2..aedb91b0b9 100644
--- a/engines/sci/graphics/text16.cpp
+++ b/engines/sci/graphics/text16.cpp
@@ -33,6 +33,7 @@
#include "sci/graphics/ports.h"
#include "sci/graphics/paint16.h"
#include "sci/graphics/font.h"
+#include "sci/graphics/screen.h"
#include "sci/graphics/text16.h"
namespace Sci {
@@ -363,23 +364,28 @@ void GfxText16::Show(const char *text, int16 from, int16 len, GuiResourceId orgF
// Draws a text in rect.
void GfxText16::Box(const char *text, int16 bshow, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) {
- int16 textWidth, textHeight, charCount;
+ int16 textWidth, maxTextWidth, textHeight, charCount;
int16 offset = 0;
int16 hline = 0;
GuiResourceId orgFontId = GetFontId();
int16 orgPenColor = _ports->_curPort->penClr;
+ bool doubleByteMode = false;
if (fontId != -1)
SetFont(fontId);
- if (g_sci->getLanguage() == Common::JA_JPN)
- SwitchToFont900OnSjis(text);
+ if (g_sci->getLanguage() == Common::JA_JPN) {
+ if (SwitchToFont900OnSjis(text))
+ doubleByteMode = true;
+ }
+ maxTextWidth = 0;
while (*text) {
charCount = GetLongest(text, rect.width(), orgFontId);
if (charCount == 0)
break;
Width(text, 0, charCount, orgFontId, textWidth, textHeight);
+ maxTextWidth = MAX<int16>(maxTextWidth, textWidth);
switch (alignment) {
case SCI_TEXT16_ALIGNMENT_RIGHT:
offset = rect.width() - textWidth;
@@ -407,6 +413,22 @@ void GfxText16::Box(const char *text, int16 bshow, const Common::Rect &rect, Tex
}
SetFont(orgFontId);
_ports->penColor(orgPenColor);
+
+ if (doubleByteMode) {
+ // kanji is written by pc98 rom to screen directly. Because of GetLongest() behaviour (not cutting off the last
+ // char, that causes a new line), results in the script thinking that the text would need less space. The coordinate
+ // adjustment in fontsjis.cpp handles the incorrect centering because of that and this code actually shows all of
+ // the chars - if we don't do this, the scripts will only show most of the chars, but the last few pixels won't get
+ // shown most of the time.
+ Common::Rect kanjiRect = rect;
+ _ports->offsetRect(kanjiRect);
+ kanjiRect.left &= 0xFFC;
+ kanjiRect.right = kanjiRect.left + maxTextWidth;
+ kanjiRect.bottom = kanjiRect.top + hline;
+ kanjiRect.left *= 2; kanjiRect.right *= 2;
+ kanjiRect.top *= 2; kanjiRect.bottom *= 2;
+ _screen->copyDisplayRectToScreen(kanjiRect);
+ }
}
void GfxText16::Draw_String(const char *text) {
@@ -419,10 +441,13 @@ void GfxText16::Draw_String(const char *text) {
}
// Sierra did this in their PC98 interpreter only, they identify a text as being sjis and then switch to font 900
-void GfxText16::SwitchToFont900OnSjis(const char *text) {
+bool GfxText16::SwitchToFont900OnSjis(const char *text) {
byte firstChar = (*(const byte *)text++);
- if (((firstChar >= 0x81) && (firstChar <= 0x9F)) || ((firstChar >= 0xE0) && (firstChar <= 0xEF)))
+ if (((firstChar >= 0x81) && (firstChar <= 0x9F)) || ((firstChar >= 0xE0) && (firstChar <= 0xEF))) {
SetFont(900);
+ return true;
+ }
+ return false;
}
} // End of namespace Sci
diff --git a/engines/sci/graphics/text16.h b/engines/sci/graphics/text16.h
index f1ce39f8df..2885fc928b 100644
--- a/engines/sci/graphics/text16.h
+++ b/engines/sci/graphics/text16.h
@@ -69,7 +69,7 @@ public:
private:
void init();
- void SwitchToFont900OnSjis(const char *text);
+ bool SwitchToFont900OnSjis(const char *text);
ResourceManager *_resMan;
GfxCache *_cache;