[Scummvm-git-logs] scummvm master -> e8504616abb4e5ac2ad5d611d7af9a8e2b558f54
yuv422
noreply at scummvm.org
Thu Jan 2 02:07:59 UTC 2025
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
34e7899101 DARKSEED: Add detection entry for Chinese DOS floppy version with unpacked TOS.EXE.
e8504616ab DARKSEED: Add support for chinese big5 tos strings.
Commit: 34e7899101e690bec6be16dc3bb7ef75140c89b1
https://github.com/scummvm/scummvm/commit/34e7899101e690bec6be16dc3bb7ef75140c89b1
Author: Eric Fry (yuv422 at reversedgames.com)
Date: 2025-01-01T18:59:41-07:00
Commit Message:
DARKSEED: Add detection entry for Chinese DOS floppy version with unpacked TOS.EXE.
Changed paths:
engines/darkseed/detection_tables.h
diff --git a/engines/darkseed/detection_tables.h b/engines/darkseed/detection_tables.h
index fcc3641b2c7..b983f76f1e9 100644
--- a/engines/darkseed/detection_tables.h
+++ b/engines/darkseed/detection_tables.h
@@ -45,6 +45,15 @@ const ADGameDescription gameDescriptions[] = {
ADGF_UNSTABLE,
GUIO1(GUIO_NONE)
},
+ { // unpacked exe
+ "darkseed",
+ "unpacked",
+ AD_ENTRY1s("TOS.EXE", "0fc2751aa16cac26ad3aa9d1cbbb5c7b", 209208),
+ Common::ZH_ANY,
+ Common::kPlatformDOS,
+ ADGF_UNSTABLE,
+ GUIO1(GUIO_NONE)
+ },
{
"darkseed",
"CD",
Commit: e8504616abb4e5ac2ad5d611d7af9a8e2b558f54
https://github.com/scummvm/scummvm/commit/e8504616abb4e5ac2ad5d611d7af9a8e2b558f54
Author: Eric Fry (yuv422 at reversedgames.com)
Date: 2025-01-01T18:59:41-07:00
Commit Message:
DARKSEED: Add support for chinese big5 tos strings.
Changed paths:
A engines/darkseed/big5font.cpp
A engines/darkseed/big5font.h
engines/darkseed/console.cpp
engines/darkseed/console.h
engines/darkseed/gamefont.cpp
engines/darkseed/gamefont.h
engines/darkseed/module.mk
diff --git a/engines/darkseed/big5font.cpp b/engines/darkseed/big5font.cpp
new file mode 100644
index 00000000000..4536c8395ad
--- /dev/null
+++ b/engines/darkseed/big5font.cpp
@@ -0,0 +1,58 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "darkseed/darkseed.h"
+#include "darkseed/big5font.h"
+
+namespace Darkseed {
+
+Big5Font::Big5Font() {
+ Common::File tosFile;
+ if (!tosFile.open("tos.exe")) { // TODO handle packed tos.exe
+ error("Error: failed to open tos.exe");
+ }
+ tosFile.seek(0x2701);
+ _big5.loadPrefixedRaw(tosFile, 15);
+ tosFile.close();
+}
+
+int Big5Font::getFontHeight() const {
+ return 15;
+}
+
+int Big5Font::getMaxCharWidth() const {
+ return 17;
+}
+
+int Big5Font::getCharWidth(uint32 chr) const {
+ return getMaxCharWidth();
+}
+
+void Big5Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const {
+ Common::Point charPos = {(int16)x, (int16)y};
+ if (_big5.drawBig5Char(g_engine->_screen->surfacePtr(), chr, charPos, 0xf)) {
+ charPos.x++;
+ _big5.drawBig5Char(g_engine->_screen->surfacePtr(), chr, charPos, 0xc);
+ charPos.x += Graphics::Big5Font::kChineseTraditionalWidth + 1;
+ }
+}
+
+} // namespace Darkseed
diff --git a/engines/darkseed/big5font.h b/engines/darkseed/big5font.h
new file mode 100644
index 00000000000..eee97ac3618
--- /dev/null
+++ b/engines/darkseed/big5font.h
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef DARKSEED_BIG5FONT_H
+#define DARKSEED_BIG5FONT_H
+
+#include "graphics/font.h"
+#include "graphics/big5.h"
+#include "graphics/surface.h"
+
+namespace Darkseed {
+
+class Big5Font : public Graphics::Font {
+private:
+ Graphics::Big5Font _big5;
+
+public:
+ Big5Font();
+
+ int getFontHeight() const override;
+ int getMaxCharWidth() const override;
+ int getCharWidth(uint32 chr) const override;
+ void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
+};
+
+} // namespace Darkseed
+
+#endif // DARKSEED_BIG5FONT_H
diff --git a/engines/darkseed/console.cpp b/engines/darkseed/console.cpp
index 474766a2cdb..8a6f036d2dd 100644
--- a/engines/darkseed/console.cpp
+++ b/engines/darkseed/console.cpp
@@ -20,31 +20,46 @@
*/
#include "common/debug.h"
+#include "darkseed/big5font.h"
#include "darkseed/console.h"
#include "darkseed/darkseed.h"
namespace Darkseed {
-static constexpr Common::Rect consoleArea = {{0x70, 280}, 416, 44};
+static constexpr Common::Rect consoleArea = {{0x70, 279}, 416, 49};
Console::Console(TosText *tosText, Sound *sound) : _tosText(tosText), _sound(sound) {
- if (!_font.load()) {
- error("Error loading tosfont.nsp");
+ if (g_engine->getLanguage() == Common::ZH_ANY) {
+ _font = new Big5Font();
+ _isBig5 = true;
+ } else {
+ _font = new GameFont();
}
+
+ _numLines = _isBig5 ? 3 : 4;
+
_text.resize(10);
}
void Console::printTosText(int tosIndex) {
const Common::String &text = _tosText->getText(tosIndex);
+ // debugN("tos %d: ", tosIndex);
+ // for (int i = 0; i < text.size(); i++) {
+ // debugN("%02x,", (unsigned char)text[i]);
+ // }
+ // debug("");
debug("%s", text.c_str());
- addLine(" ");
addTextLine(text);
_sound->playTosSpeech(tosIndex);
}
void Console::addTextLine(const Common::String &text) {
Common::StringArray lines;
- _font.wordWrapText(text, consoleArea.width(), lines);
+ if (_isBig5) {
+ big5WordWrap(text, 23, lines);
+ } else {
+ _font->wordWrapText(text, consoleArea.width(), lines);
+ }
for (auto &line : lines) {
addLine(line);
}
@@ -68,9 +83,9 @@ void Console::draw(bool forceRedraw) {
g_engine->_screen->fillRect(consoleArea, 0);
int curIdx = _startIdx == 0 ? _text.size() - 1 : _startIdx - 1;
int y = 0x139;
- for (int i = 0; i < 4 && curIdx != _startIdx && !_text[curIdx].empty(); i++) {
- _font.drawString(g_engine->_screen, _text[curIdx], 0x70, y, consoleArea.width(), 0);
- y -= 11;
+ for (int i = 0; i < _numLines && curIdx != _startIdx && !_text[curIdx].empty(); i++) {
+ drawStringAt(0x70, y, _text[curIdx]);
+ y -= _isBig5 ? 17 : 11;
curIdx = curIdx == 0 ? _text.size() - 1 : curIdx - 1;
}
_redrawRequired = false;
@@ -78,7 +93,21 @@ void Console::draw(bool forceRedraw) {
}
void Console::drawStringAt(const int x, const int y, const Common::String &text) const {
- _font.drawString(g_engine->_screen, text, x, y, _font.getStringWidth(text), 0);
+ if (_isBig5) {
+ Common::Point charPos = {(int16)x, (int16)y};
+ for (const char *curCharPtr = text.c_str(); *curCharPtr; ++curCharPtr) {
+ byte curChar = *curCharPtr;
+ byte nextChar = curCharPtr[1];
+ if ((curChar & 0x80) && nextChar) {
+ curCharPtr++;
+ uint16 point = (curChar << 8) | nextChar;
+ _font->drawChar(g_engine->_screen, point, charPos.x, charPos.y, 0);
+ charPos.x += (int16)_font->getCharWidth(point) + 1;
+ }
+ }
+ } else {
+ _font->drawString(g_engine->_screen, text, x, y, consoleArea.width(), 0);
+ }
}
void Console::addLine(const Common::String &line) {
@@ -87,4 +116,30 @@ void Console::addLine(const Common::String &line) {
_redrawRequired = true;
}
+void Console::big5WordWrap(const Common::String &str, int maxWidth, Common::StringArray &lines) {
+ Common::String line;
+ int charCount = 0;
+ for (const char *curCharPtr = str.c_str(); *curCharPtr; ++curCharPtr) {
+ byte curChar = *curCharPtr;
+ byte nextChar = curCharPtr[1];
+ if ((curChar & 0x80) && nextChar) {
+ curCharPtr++;
+ if (charCount < maxWidth) {
+ line += (char)curChar;
+ line += (char)nextChar;
+ charCount++;
+ } else {
+ lines.push_back(line);
+ line.clear();
+ line += (char)curChar;
+ line += (char)nextChar;
+ charCount = 1;
+ }
+ }
+ }
+ if (!line.empty()) {
+ lines.push_back(line);
+ }
+}
+
} // End of namespace Darkseed
diff --git a/engines/darkseed/console.h b/engines/darkseed/console.h
index b9b8d990dc5..760c6fa2df2 100644
--- a/engines/darkseed/console.h
+++ b/engines/darkseed/console.h
@@ -22,6 +22,7 @@
#ifndef DARKSEED_CONSOLE_H
#define DARKSEED_CONSOLE_H
+#include "graphics/big5.h"
#include "darkseed/gamefont.h"
#include "darkseed/sound.h"
#include "darkseed/tostext.h"
@@ -32,12 +33,14 @@ namespace Darkseed {
class Console {
private:
TosText *_tosText;
- GameFont _font;
+ Graphics::Font *_font;
+ bool _isBig5 = false;
Sound *_sound;
Common::StringArray _text;
int _startIdx = 0;
bool _redrawRequired = false;
+ int _numLines = 4;
public:
Console(TosText *tostext, Sound *sound);
@@ -53,6 +56,7 @@ public:
private:
void addLine(const Common::String &line);
+ void big5WordWrap(const Common::String &str, int maxWidth, Common::StringArray &lines);
};
} // End of namespace Darkseed
diff --git a/engines/darkseed/gamefont.cpp b/engines/darkseed/gamefont.cpp
index 3876f18f5b7..41100527bd9 100644
--- a/engines/darkseed/gamefont.cpp
+++ b/engines/darkseed/gamefont.cpp
@@ -25,15 +25,12 @@
namespace Darkseed {
extern DarkseedEngine *g_engine;
-Darkseed::GameFont::GameFont() {
-}
-
-bool GameFont::load() {
+GameFont::GameFont() {
if (_letters.load("tosfont.nsp")) {
_maxWidth = _letters.getMaxSpriteWidth() + 1;
- return true;
+ } else {
+ error("Error loading tosfont.nsp");
}
- return false;
}
const Sprite *GameFont::getCharacterSprite(char c) const {
diff --git a/engines/darkseed/gamefont.h b/engines/darkseed/gamefont.h
index 2cc10066b8a..85c37a20399 100644
--- a/engines/darkseed/gamefont.h
+++ b/engines/darkseed/gamefont.h
@@ -35,7 +35,6 @@ private:
public:
GameFont();
- bool load();
int getFontHeight() const override;
int getMaxCharWidth() const override;
diff --git a/engines/darkseed/module.mk b/engines/darkseed/module.mk
index 19a90034ceb..51cbd04c03f 100644
--- a/engines/darkseed/module.mk
+++ b/engines/darkseed/module.mk
@@ -4,6 +4,7 @@ MODULE_OBJS = \
adlib_worx.o \
animation.o \
anm.o \
+ big5font.o \
console.o \
cursor.o \
cutscene.o \
More information about the Scummvm-git-logs
mailing list