aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
authorPaul Gilbert2019-01-01 00:56:42 -0800
committerPaul Gilbert2019-01-01 00:56:42 -0800
commit9bbd0474fab672ff843caf40305475f856b30f74 (patch)
tree2c731ee853d72d041763a5e6b5312353191e5379 /engines/glk
parent7643382ff4c19bf69ac36c015ca9e8e046c20c77 (diff)
downloadscummvm-rg350-9bbd0474fab672ff843caf40305475f856b30f74.tar.gz
scummvm-rg350-9bbd0474fab672ff843caf40305475f856b30f74.tar.bz2
scummvm-rg350-9bbd0474fab672ff843caf40305475f856b30f74.zip
GLK: FROTZ: Support shorthand abbreviations in earlier Infocom games
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/frotz/frotz.cpp2
-rw-r--r--engines/glk/frotz/processor.h8
-rw-r--r--engines/glk/frotz/processor_text.cpp29
3 files changed, 34 insertions, 5 deletions
diff --git a/engines/glk/frotz/frotz.cpp b/engines/glk/frotz/frotz.cpp
index 3d6bf6c9f9..c2341d4026 100644
--- a/engines/glk/frotz/frotz.cpp
+++ b/engines/glk/frotz/frotz.cpp
@@ -48,8 +48,6 @@ void Frotz::runGame(Common::SeekableReadStream *gameFile) {
story_fp = gameFile;
initialize();
- debug("Game %s an Infocom original", isInfocom() ? "is" : "isn't");
-
// If save was selected from the launcher, handle loading it
int saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
if (saveSlot != -1) {
diff --git a/engines/glk/frotz/processor.h b/engines/glk/frotz/processor.h
index 5b9926bbf4..83d24433cf 100644
--- a/engines/glk/frotz/processor.h
+++ b/engines/glk/frotz/processor.h
@@ -630,8 +630,12 @@ protected:
zword lookup_text(int padding, zword dct);
/**
- * tokenise_text
- *
+ * Handles converting abbreviations that weren't handled by early Infocom games
+ * into their expanded versions
+ */
+ void handleAbbreviations();
+
+ /**
* Translate a single word to a token and append it to the token
* buffer. Every token consists of the address of the dictionary
* entry, the length of the word and the offset of the word from
diff --git a/engines/glk/frotz/processor_text.cpp b/engines/glk/frotz/processor_text.cpp
index 32625f6708..2b82f29e3c 100644
--- a/engines/glk/frotz/processor_text.cpp
+++ b/engines/glk/frotz/processor_text.cpp
@@ -21,6 +21,7 @@
*/
#include "glk/frotz/processor.h"
+#include "common/ustr.h"
namespace Glk {
namespace Frotz {
@@ -192,7 +193,7 @@ void Processor::find_resolution() {
_encoded = (zchar *)malloc(sizeof(zchar) * _resolution);
}
-void Processor::load_string (zword addr, zword length) {
+void Processor::load_string(zword addr, zword length) {
int i = 0;
if (_resolution == 0)
@@ -560,6 +561,29 @@ zword Processor::lookup_text(int padding, zword dct) {
return dct + entry_number * entry_len;
}
+void Processor::handleAbbreviations() {
+ // Construct a unicode string containing the word
+ int wordSize = 0;
+ while (wordSize < (_resolution * 3) && _decoded[wordSize])
+ ++wordSize;
+ Common::U32String word(_decoded, _decoded + wordSize);
+
+ // Check for standard abbreviations
+ if (word == "g")
+ word == "again";
+ else if (word == "o")
+ word = "oops";
+ else if (word == "x")
+ word = "examine";
+ else if (word == "z")
+ word = "wait";
+ else
+ return;
+
+ // Found abbreviation, so copy it's long form into buffer
+ Common::copy(word.c_str(), word.c_str() + MIN((int)word.size() + 1, _resolution * 3), _decoded);
+}
+
void Processor::tokenise_text(zword text, zword length, zword from, zword parse, zword dct, bool flag) {
zword addr;
zbyte token_max, token_count;
@@ -574,6 +598,9 @@ void Processor::tokenise_text(zword text, zword length, zword from, zword parse,
load_string((zword)(text + from), length);
+ if ((from == 1) && isInfocom() && h_version < 5)
+ handleAbbreviations();
+
addr = lookup_text(0x05, dct);
if (addr != 0 || !flag) {