From 85e0c6e7aa2345622c9c92e0cd6eeb58ab1f88bc Mon Sep 17 00:00:00 2001 From: David Griffith Date: Sun, 9 Aug 2015 14:25:05 -0700 Subject: [PATCH] Truncate trailing question mark for those Infocom games that expect it. This is otherwise a divergence from the Z-Machine Standard. --- src/common/fastmem.c | 72 ++++++++++++++++++++++++++++++++++++++++++++ src/common/frotz.h | 18 +++++++++++ src/common/input.c | 48 ++++++++++++++++++++++++++++- 3 files changed, 137 insertions(+), 1 deletion(-) diff --git a/src/common/fastmem.c b/src/common/fastmem.c index 7a519bf..0796403 100644 --- a/src/common/fastmem.c +++ b/src/common/fastmem.c @@ -210,6 +210,8 @@ void restart_header (void) * * Allocate memory and load the story file. * + * Data collected from http://www.russotto.net/zplet/ivl.html + * */ void init_memory (void) { @@ -223,6 +225,76 @@ void init_memory (void) zword release; zbyte serial[6]; } records[] = { + { ZORK1, 2, "AS000C" }, + { ZORK1, 5, "" }, + { ZORK1, 15, "UG3AU5" }, + { ZORK1, 23, "820428" }, + { ZORK1, 25, "820515" }, + { ZORK1, 26, "820803" }, + { ZORK1, 28, "821013" }, + { ZORK1, 30, "830330" }, + { ZORK1, 75, "830929" }, + { ZORK1, 76, "840509" }, + { ZORK1, 88, "840726" }, + { ZORK1, 52, "871125" }, + { ZORK1G, 3, "880113" }, + { ZORK2, 7, "UG3AU5" }, + { ZORK2, 15, "820308" }, + { ZORK2, 17, "820427" }, + { ZORK2, 18, "820512" }, + { ZORK2, 18, "820517" }, + { ZORK2, 19, "820721" }, + { ZORK2, 22, "830331" }, + { ZORK2, 23, "830411" }, + { ZORK2, 48, "840904" }, + { ZORK3, 10, "820818" }, + { ZORK3, 12, "821025" }, + { ZORK3, 15, "830331" }, + { ZORK3, 15, "840518" }, + { ZORK3, 16, "830410" }, + { ZORK3, 17, "840727" }, + { MINIZORK, 34, "871124" }, + { SAMPLER1, 26, "840731" }, + { SAMPLER1, 53, "850407" }, + { SAMPLER1, 55, "850823" }, + { SAMPLER2, 97, "870601" }, + { ENCHANTER, 10, "830810" }, + { ENCHANTER, 15, "831107" }, + { ENCHANTER, 16, "831118" }, + { ENCHANTER, 24, "851118" }, + { ENCHANTER, 29, "860820" }, + { SORCERER, 4, "840131" }, + { SORCERER, 6, "840508" }, + { SORCERER, 13, "851021" }, + { SORCERER, 15, "851108" }, + { SORCERER, 18, "860904" }, + { SORCERER, 67, "0" }, + { SORCERER, 63, "850916" }, + { SORCERER, 87, "860904" }, + { SPELLBREAKER, 63, "850916" }, + { SPELLBREAKER, 87, "860904" }, + { PLANETFALL, 20, "830708" }, + { PLANETFALL, 26, "831014" }, + { PLANETFALL, 29, "840118" }, + { PLANETFALL, 37, "851003" }, + { PLANETFALL, 10, "880531" }, + { STATIONFALL, 107, "870430" }, + { BALLYHOO, 97, "851218" }, + { BORDER_ZONE, 9, "871008" }, + { AMFV, 77, "850814" }, + { AMFV, 79, "851122" }, + { HHGG, 47, "840914" }, + { HHGG, 56, "841221" }, + { HHGG, 58, "851002" }, + { HHGG, 59, "851108" }, + { HHGG, 31, "871119" }, + { LGOP, 0, "BLOWN!" }, + { LGOP, 50, "860711" }, + { LGOP, 59, "860730" }, + { LGOP, 59, "861114" }, + { LGOP, 118, "860325" }, + { LGOP, 4, "880405" }, + { SUSPECT, 14, "841005" }, { SHERLOCK, 21, "871214" }, { SHERLOCK, 26, "880127" }, { BEYOND_ZORK, 47, "870915" }, diff --git a/src/common/frotz.h b/src/common/frotz.h index a3c70c7..1fa208b 100644 --- a/src/common/frotz.h +++ b/src/common/frotz.h @@ -55,6 +55,24 @@ typedef unsigned short zchar; typedef unsigned char zchar; enum story { + ZORK1, + ZORK2, + ZORK3, + ZORK1G, + MINIZORK, + SAMPLER1, + SAMPLER2, + ENCHANTER, + SORCERER, + SPELLBREAKER, + PLANETFALL, + STATIONFALL, + BALLYHOO, + BORDER_ZONE, + AMFV, + HHGG, + LGOP, + SUSPECT, BEYOND_ZORK, SHERLOCK, ZORK_ZERO, diff --git a/src/common/input.c b/src/common/input.c index 88fd87f..50cf52c 100644 --- a/src/common/input.c +++ b/src/common/input.c @@ -27,6 +27,8 @@ extern zchar stream_read_input (int, zchar *, zword, zword, bool, bool); extern void tokenise_line (zword, zword, zword, bool); +static bool truncate_question_mark(void); + /* * is_terminator * @@ -233,7 +235,6 @@ void z_read (void) for (i = 0; buffer[i] != 0; i++) { if (key == ZC_RETURN) { - if (buffer[i] >= 'A' && buffer[i] <= 'Z') buffer[i] += 'a' - 'A'; if (buffer[i] >= 0xc0 && buffer[i] <= 0xde && buffer[i] != 0xd7) @@ -241,6 +242,11 @@ void z_read (void) } + if (truncate_question_mark()) { + if (buffer[i] == '?') + buffer[i] = ' '; + } + storeb ((zword) (zargs[0] + ((h_version <= V4) ? 1 : 2) + i), translate_to_zscii (buffer[i])); } @@ -330,3 +336,43 @@ void z_read_mouse (void) storew ((zword) (zargs[0] + 6), 0); /* menu selection */ }/* z_read_mouse */ + +/* + * truncate_question_mark + * + * check if this game is one that expects theinterpreter to truncate a + * trailing question mark from the input buffer. + * + * For some games, Infocom modified the interpreter to truncate trailing + * question marks. Presumably this was to make it easier to deal with + * questions asked of the narrator or interpreter, such as "WHAT IS A + * GRUE?". This is a deviation from the Z-Machine Standard (written + * after Infocom's demise). Some interpreters written later + * incorrectly truncate aswell. In the interest of making sure the + * original Infocom games play exactly as they did with Infocom's own + * interpreters, this function checks for those games that expect the + * trailing question mark to be truncated. + * + */ +static bool truncate_question_mark(void) +{ + if (story_id == ZORK1) return TRUE; + if (story_id == ZORK2) return TRUE; + if (story_id == ZORK3) return TRUE; + if (story_id == MINIZORK) return TRUE; + if (story_id == SAMPLER1) return TRUE; + if (story_id == SAMPLER2) return TRUE; + if (story_id == ENCHANTER) return TRUE; + if (story_id == SORCERER) return TRUE; + if (story_id == SPELLBREAKER) return TRUE; + if (story_id == PLANETFALL) return TRUE; + if (story_id == STATIONFALL) return TRUE; + if (story_id == BALLYHOO) return TRUE; + if (story_id == BORDER_ZONE) return TRUE; + if (story_id == AMFV) return TRUE; + if (story_id == HHGG) return TRUE; + if (story_id == LGOP) return TRUE; + if (story_id == SUSPECT) return TRUE; + + return FALSE; +} -- 2.34.1