KYRA: (EOB II/PC98) - fix some more text glitches

This commit is contained in:
athrxx 2023-05-12 20:26:51 +02:00
parent 501ed235e3
commit 320c2f6983
6 changed files with 34 additions and 10 deletions

View File

@ -1966,6 +1966,7 @@ private:
void giveKhelbensCoin();
Common::String convertFromJISX0201(const Common::String &src);
Common::String makeTwoByteString(const Common::String &src);
EoBCoreEngine *_vm;
Screen_EoB *_screen;
@ -2227,8 +2228,6 @@ int TransferPartyWiz::selectCharactersMenu() {
return selection;
}
void TransferPartyWiz::drawCharPortraitWithStats(int charIndex, bool enabled) {
int16 x = (charIndex % 2) * 159;
int16 y = (charIndex / 2) * 40;
@ -2296,7 +2295,8 @@ void TransferPartyWiz::convertStats() {
if (_vm->_flags.lang == Common::JA_JPN && _vm->_flags.platform == Common::kPlatformPC98) {
Common::String cname(c->name);
cname = convertFromJISX0201(cname);
Common::strlcpy(c->name, cname.c_str(), cname.size() + 1);
cname = makeTwoByteString(cname);
Common::strlcpy(c->name, cname.c_str(), sizeof(c->name));
}
for (int ii = 0; ii < 25; ii++) {
@ -2553,6 +2553,29 @@ Common::String TransferPartyWiz::convertFromJISX0201(const Common::String &src)
return tmp;
}
Common::String TransferPartyWiz::makeTwoByteString(const Common::String &src) {
Common::String n;
for (const uint8 *s = (const uint8*)src.c_str(); *s; ++s) {
if (*s < 32 || *s == 127) {
n += (char)*s;
} else if (*s < 127) {
uint8 c = (*s - 32) * 2;
assert(c < 190);
n += _vm->_ascii2SjisTables2[0][c];
n += _vm->_ascii2SjisTables2[0][c + 1];
} else if (*s < 212) {
n += '\x83';
n += (char)(*s - 64);
} else {
uint8 c = (*s - 212) * 2;
assert(c < 8);
n += _vm->_ascii2SjisTables2[1][c];
n += _vm->_ascii2SjisTables2[1][c + 1];
}
}
return n;
}
// Start functions
bool EoBCoreEngine::startCharacterGeneration(bool defaultParty) {

View File

@ -2046,7 +2046,7 @@ bool EoBCoreEngine::checkPassword() {
return true;
}
Common::String EoBCoreEngine::convertAsciiToSjis(const Common::String &str) {
Common::String EoBCoreEngine::makeTwoByteString(const Common::String &str) {
if (_flags.platform != Common::kPlatformFMTowns)
return str;

View File

@ -915,7 +915,7 @@ protected:
virtual void seq_segaPausePlayer(bool pause) {}
bool checkPassword();
Common::String convertAsciiToSjis(const Common::String &str);
Common::String makeTwoByteString(const Common::String &str);
virtual int resurrectionSelectDialogue() = 0;
virtual void useHorn(int charIndex, int weaponSlot) {}

View File

@ -500,7 +500,7 @@ void EoBCoreEngine::printFullItemName(Item item) {
int cs = (_flags.platform == Common::kPlatformSegaCD && _flags.lang == Common::JA_JPN && _screen->getNumberOfCharacters((tmpString).c_str()) >= 17) ? _screen->setFontStyles(_screen->_currentFont, Font::kStyleNarrow2) : -1;
_txt->printMessage(convertAsciiToSjis(tmpString).c_str());
_txt->printMessage(makeTwoByteString(tmpString).c_str());
if (cs != -1)
_screen->setFontStyles(_screen->_currentFont, cs);

View File

@ -319,7 +319,7 @@ uint16 Font12x12PC98::convert(uint16 c) const {
}
PC98Font::PC98Font(uint8 shadowColor, bool useOverlay, int scaleV, const uint8 *convTable1, const char *convTable2, const char *convTable3) : OldDOSFont(Common::kRenderVGA, shadowColor),
_convTable1(convTable1), _convTable2(convTable2), _convTable3(convTable3), _outputWidth(0), _outputHeight(0), _type(convTable1 && convTable2 && convTable3 ? kJIS_X0201 : kASCII) {
_convTable1(convTable1), _convTable2(convTable2), _convTable3(convTable3), _outputWidth(0), _outputHeight(0), _type(convTable1 && convTable2 && convTable3 ? kSJIS : kASCII) {
_numGlyphsMax = 256;
_useOverlay = useOverlay;
_scaleV = scaleV;
@ -341,7 +341,7 @@ bool PC98Font::load(Common::SeekableReadStream &file) {
}
uint16 PC98Font::convert(uint16 c) const {
if (_type == kJIS_X0201)
if (_type == kSJIS)
c = makeTwoByte(c);
if (!_convTable1 || c < 128)

View File

@ -2904,7 +2904,7 @@ int GUI_EoB::getTextInput(char *dest, int x, int y, int destMaxLen, int textColo
if (_vm->_flags.platform == Common::kPlatformFMTowns && _keyPressed.ascii > 31 && _keyPressed.ascii < 123) {
Common::String s;
s.insertChar(in & 0xff, 0);
s = _vm->convertAsciiToSjis(s);
s = _vm->makeTwoByteString(s);
if (s.empty()) {
in = 0;
} else {
@ -3966,7 +3966,8 @@ bool GUI_EoB::restParty() {
for (int l = 0; !res && restLoop && !_vm->shouldQuit();) {
l++;
int cs = (_vm->gameFlags().platform == Common::kPlatformSegaCD && _vm->gameFlags().lang == Common::JA_JPN) ? _screen->setFontStyles(_screen->_currentFont, Font::kStyleNarrow1) : -1;
int cs = (_vm->gameFlags().platform == Common::kPlatformSegaCD && _vm->gameFlags().lang == Common::JA_JPN) ? _screen->setFontStyles(_screen->_currentFont, Font::kStyleNarrow1) :
((_vm->gameFlags().platform == Common::kPlatformPC98 && !_vm->gameFlags().use16ColorMode) ? _screen->setFontStyles(_menuFont, Font::kStyleNone) : -1);
// Regenerate spells
for (int i = 0; i < 6; i++) {