[Scummvm-git-logs] scummvm master -> d123cb9cb168e3c2a4e315067575eec3135f770a
dreammaster
paulfgilbert at gmail.com
Fri Dec 11 06:29:50 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
84cce138f6 GLK: COMPREHEND: Talisman specific font class
6d3ea68840 GLK: COMPREHEND: Implement Talisman strings loading
d123cb9cb1 GLK: COMPREHEND: Added Talisman copyright message
Commit: 84cce138f65e69fefdf346ccaf1f79db13252c4b
https://github.com/scummvm/scummvm/commit/84cce138f65e69fefdf346ccaf1f79db13252c4b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-12-10T22:28:59-08:00
Commit Message:
GLK: COMPREHEND: Talisman specific font class
Changed paths:
engines/glk/comprehend/charset.cpp
engines/glk/comprehend/charset.h
engines/glk/comprehend/pics.cpp
diff --git a/engines/glk/comprehend/charset.cpp b/engines/glk/comprehend/charset.cpp
index eb0790c4e8..04f4eac534 100644
--- a/engines/glk/comprehend/charset.cpp
+++ b/engines/glk/comprehend/charset.cpp
@@ -22,12 +22,33 @@
#include "glk/comprehend/charset.h"
#include "common/file.h"
+#include "common/md5.h"
#include "graphics/surface.h"
namespace Glk {
namespace Comprehend {
-CharSet::CharSet() : Graphics::Font() {
+void FixedFont::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const {
+ assert(dst->format.bytesPerPixel == 4);
+ assert(chr >= 32 && chr < 128);
+
+ for (int yp = 0; yp < 8; ++yp) {
+ if ((y + yp) < 0 || (y + yp) >= dst->h)
+ continue;
+
+ uint32 *lineP = (uint32 *)dst->getBasePtr(x, y + yp);
+ byte bits = _data[chr - 32][yp];
+
+ for (int xp = x; xp < (x + 8); ++xp, ++lineP, bits >>= 1) {
+ if ((xp >= 0) && (xp < dst->w) && (bits & 1))
+ *lineP = color;
+ }
+ }
+}
+
+/*-------------------------------------------------------*/
+
+CharSet::CharSet() : FixedFont() {
Common::File f;
if (!f.open("charset.gda"))
error("Could not open char set");
@@ -43,22 +64,24 @@ CharSet::CharSet() : Graphics::Font() {
f.close();
}
-void CharSet::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const {
- assert(dst->format.bytesPerPixel == 4);
- assert(chr >= 32 && chr < 128);
+/*-------------------------------------------------------*/
- for (int yp = 0; yp < 8; ++yp) {
- if ((y + yp) < 0 || (y + yp) >= dst->h)
- continue;
+TalismanFont::TalismanFont() : FixedFont() {
+ // Extra strings are (annoyingly) stored in the game binary
+ Common::File f;
+ if (!f.open("novel.exe"))
+ error("novel.exe is a required file");
- uint32 *lineP = (uint32 *)dst->getBasePtr(x, y + yp);
- byte bits = _data[chr - 32][yp];
+ Common::String md5 = Common::computeStreamMD5AsString(f, 1024);
- for (int xp = x; xp < (x + 8); ++xp, ++lineP, bits >>= 1) {
- if ((xp >= 0) && (xp < dst->w) && (bits & 1))
- *lineP = color;
- }
+ if (md5 == "0e7f002971acdb055f439020363512ce") {
+ for (int idx = 0; idx < 128 - 32; ++idx)
+ f.read(&_data[idx][0], 8);
+ } else {
+ error("Unrecognised novel.exe encountered");
}
+
+ f.close();
}
} // namespace Comprehend
diff --git a/engines/glk/comprehend/charset.h b/engines/glk/comprehend/charset.h
index 98585ed9f6..05b22ad259 100644
--- a/engines/glk/comprehend/charset.h
+++ b/engines/glk/comprehend/charset.h
@@ -28,12 +28,15 @@
namespace Glk {
namespace Comprehend {
-class CharSet : public Graphics::Font {
-private:
+/**
+ * Fixed width base font
+ */
+class FixedFont : public Graphics::Font {
+protected:
byte _data[128 - 32][8];
public:
- CharSet();
+ ~FixedFont() override {}
/**
*/
@@ -77,6 +80,24 @@ public:
void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
};
+/**
+ * Font loaded from charset.gda
+ */
+class CharSet : public FixedFont {
+public:
+ CharSet();
+ ~CharSet() override {}
+};
+
+/**
+ * Talisman font directly from the executable
+ */
+class TalismanFont : public FixedFont {
+public:
+ TalismanFont();
+ ~TalismanFont() override {}
+};
+
} // End of namespace Comprehend
} // End of namespace Glk
diff --git a/engines/glk/comprehend/pics.cpp b/engines/glk/comprehend/pics.cpp
index 412d2f26f7..638c3bf9ed 100644
--- a/engines/glk/comprehend/pics.cpp
+++ b/engines/glk/comprehend/pics.cpp
@@ -319,6 +319,8 @@ uint16 Pics::ImageFile::imageGetOperand(ImageContext *ctx) const {
Pics::Pics() : _font(nullptr) {
if (Common::File::exists("charset.gda"))
_font = new CharSet();
+ else if (g_comprehend->getGameID() == "talisman")
+ _font = new TalismanFont();
}
Pics::~Pics() {
Commit: 6d3ea688408d6ed5c44380873bedfb97d9db0d7e
https://github.com/scummvm/scummvm/commit/6d3ea688408d6ed5c44380873bedfb97d9db0d7e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-12-10T22:28:59-08:00
Commit Message:
GLK: COMPREHEND: Implement Talisman strings loading
Changed paths:
engines/glk/comprehend/file_buf.cpp
engines/glk/comprehend/file_buf.h
engines/glk/comprehend/game_data.cpp
engines/glk/comprehend/game_data.h
engines/glk/comprehend/game_tm.cpp
engines/glk/comprehend/game_tm.h
diff --git a/engines/glk/comprehend/file_buf.cpp b/engines/glk/comprehend/file_buf.cpp
index c2d4e43465..6a9b7c7ab4 100644
--- a/engines/glk/comprehend/file_buf.cpp
+++ b/engines/glk/comprehend/file_buf.cpp
@@ -38,6 +38,13 @@ FileBuffer::FileBuffer(const Common::String &filename) : _pos(0) {
f.read(&_data[0], f.size());
}
+FileBuffer::FileBuffer(Common::ReadStream *stream, size_t size) : _pos(0) {
+ _data.resize(size);
+ _readBytes.resize(size);
+ stream->read(&_data[0], size);
+}
+
+
bool FileBuffer::exists(const Common::String &filename) {
return Common::File::exists(filename);
}
diff --git a/engines/glk/comprehend/file_buf.h b/engines/glk/comprehend/file_buf.h
index 769634ed80..e7e5e1e3d6 100644
--- a/engines/glk/comprehend/file_buf.h
+++ b/engines/glk/comprehend/file_buf.h
@@ -39,6 +39,7 @@ private:
public:
FileBuffer() : _pos(0) {}
FileBuffer(const Common::String &filename);
+ FileBuffer(Common::ReadStream *stream, size_t size);
static bool exists(const Common::String &filename);
void close();
diff --git a/engines/glk/comprehend/game_data.cpp b/engines/glk/comprehend/game_data.cpp
index 1d77a5a4e0..f702f8ca4e 100644
--- a/engines/glk/comprehend/game_data.cpp
+++ b/engines/glk/comprehend/game_data.cpp
@@ -699,9 +699,8 @@ void GameData::loadGameData() {
parse_items(&fb);
parse_dictionary(&fb);
parse_word_map(&fb);
- parse_string_table(&fb, _header.addr_strings,
- _header.addr_strings_end,
- &_strings);
+ if (g_comprehend->getGameID() != "talisman")
+ parse_string_table(&fb, _header.addr_strings, _header.addr_strings_end, &_strings);
load_extra_string_files();
parse_vm(&fb);
parse_action_tables(&fb);
diff --git a/engines/glk/comprehend/game_data.h b/engines/glk/comprehend/game_data.h
index 7a8f929a52..098e508346 100644
--- a/engines/glk/comprehend/game_data.h
+++ b/engines/glk/comprehend/game_data.h
@@ -432,6 +432,15 @@ private:
uint64 string_get_chunk(uint8 *string);
char decode_string_elem(uint8 c, bool capital, bool special);
+ void parse_string_table(FileBuffer *fb, uint start_addr,
+ uint32 end_addr, StringTable *table);
+ void parse_variables(FileBuffer *fb);
+ void parse_flags(FileBuffer *fb);
+ void parse_replace_words(FileBuffer *fb);
+
+ void loadGameData();
+
+protected:
/**
* Game strings are stored using 5-bit characters. By default a character
* value maps to the lower-case letter table. If a character has the value 0x1e
@@ -442,15 +451,6 @@ private:
*/
Common::String parseString(FileBuffer *fb);
- void parse_string_table(FileBuffer *fb, uint start_addr,
- uint32 end_addr, StringTable *table);
- void parse_variables(FileBuffer *fb);
- void parse_flags(FileBuffer *fb);
- void parse_replace_words(FileBuffer *fb);
-
- void loadGameData();
-
-protected:
/**
* The main game data file header has the offsets for where each bit of
* game data is. The offsets have a magic constant value added to them.
diff --git a/engines/glk/comprehend/game_tm.cpp b/engines/glk/comprehend/game_tm.cpp
index 0e4e3052e5..1620113179 100644
--- a/engines/glk/comprehend/game_tm.cpp
+++ b/engines/glk/comprehend/game_tm.cpp
@@ -23,6 +23,7 @@
#include "glk/comprehend/comprehend.h"
#include "glk/comprehend/game_tm.h"
#include "glk/comprehend/pics.h"
+#include "common/md5.h"
namespace Glk {
namespace Comprehend {
@@ -45,7 +46,43 @@ TalismanGame::TalismanGame() : ComprehendGameV2() {
_titleGraphicFile = "t0";
}
+#define STRINGS_SEGMENT 0x16490
+#define BANKS_COUNT 15
+#define STRINGS_PER_BANK 64
+
+void TalismanGame::loadStrings() {
+ uint16 bankOffsets[BANKS_COUNT];
+ uint16 stringOffsets[STRINGS_PER_BANK + 1];
+
+ Common::File f;
+ if (!f.open("novel.exe"))
+ error("novel.exe is a required file");
+
+ Common::String md5 = Common::computeStreamMD5AsString(f, 1024);
+ if (md5 != "0e7f002971acdb055f439020363512ce")
+ error("Unrecognised novel.exe encountered");
+
+ f.seek(STRINGS_SEGMENT);
+ for (int bank = 0; bank < BANKS_COUNT; ++bank)
+ bankOffsets[bank] = f.readUint16LE();
+
+ // Iterate through the banks loading the strings
+ for (int bank = 0; bank < BANKS_COUNT; ++bank) {
+ f.seek(STRINGS_SEGMENT + bankOffsets[bank]);
+ for (int strNum = 0; strNum <= STRINGS_PER_BANK; ++strNum)
+ stringOffsets[strNum] = f.readUint16LE();
+
+ for (int strNum = 0; strNum < STRINGS_PER_BANK; ++strNum) {
+ f.seek(STRINGS_SEGMENT + bankOffsets[bank] + stringOffsets[strNum]);
+ FileBuffer fb(&f, stringOffsets[strNum + 1] - stringOffsets[strNum]);
+ _strings.push_back(parseString(&fb));
+ }
+ }
+}
+
void TalismanGame::beforeGame() {
+ loadStrings();
+
// Draw the title
g_comprehend->drawPicture(TITLE_IMAGE);
diff --git a/engines/glk/comprehend/game_tm.h b/engines/glk/comprehend/game_tm.h
index b8c2dacb53..4ac5ca4090 100644
--- a/engines/glk/comprehend/game_tm.h
+++ b/engines/glk/comprehend/game_tm.h
@@ -29,6 +29,11 @@ namespace Glk {
namespace Comprehend {
class TalismanGame : public ComprehendGameV2 {
+private:
+ /**
+ * Load strings from the executable
+ */
+ void loadStrings();
public:
TalismanGame();
~TalismanGame() override {}
Commit: d123cb9cb168e3c2a4e315067575eec3135f770a
https://github.com/scummvm/scummvm/commit/d123cb9cb168e3c2a4e315067575eec3135f770a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-12-10T22:28:59-08:00
Commit Message:
GLK: COMPREHEND: Added Talisman copyright message
Changed paths:
engines/glk/comprehend/game_tm.cpp
diff --git a/engines/glk/comprehend/game_tm.cpp b/engines/glk/comprehend/game_tm.cpp
index 1620113179..caa9b328a2 100644
--- a/engines/glk/comprehend/game_tm.cpp
+++ b/engines/glk/comprehend/game_tm.cpp
@@ -87,6 +87,9 @@ void TalismanGame::beforeGame() {
g_comprehend->drawPicture(TITLE_IMAGE);
// Print game information
+ console_println("Story by Bruce X.Hoffman. Graphics by Ray Redlich and Brian Poff");
+ console_println("Project managed and IBM version by Jeffrey A. Jay. "
+ "Copyright 1987 POLARWARE Inc.");
g_comprehend->readChar();
g_comprehend->glk_window_clear(g_comprehend->_bottomWindow);
More information about the Scummvm-git-logs
mailing list