X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=interpreters%2Fglulxe%2Fstring.c;h=f33d311e415f71d2e115e56a42e8752a160ecaaa;hb=eec3f2cefd211052c2cc19a0a3add4fbef171459;hp=1f3b6f0d6c1c2fdf64b207d89da9248bbc7f44c3;hpb=5f927b0d7c728e389f3295ac39acb85ecb3a6ef0;p=projects%2Fchimara%2Fchimara.git diff --git a/interpreters/glulxe/string.c b/interpreters/glulxe/string.c index 1f3b6f0..f33d311 100644 --- a/interpreters/glulxe/string.c +++ b/interpreters/glulxe/string.c @@ -28,8 +28,6 @@ typedef struct cacheblock_struct { } u; } cacheblock_t; -static int never_cache_stringtable = FALSE; - /* The current string-decoding tables, broken out into a fast and easy-to-use form. */ static int tablecache_valid = FALSE; @@ -163,7 +161,8 @@ void stream_num(glsi32 val, int inmiddle, int charnum) switch (iosys_mode) { case iosys_Glk: - while (ix) { + ix -= charnum; + while (ix > 0) { ix--; glk_put_char(buf[ix]); } @@ -172,17 +171,14 @@ void stream_num(glsi32 val, int inmiddle, int charnum) case iosys_Filter: if (!inmiddle) { push_callstub(0x11, 0); + inmiddle = TRUE; } - if (charnum >= ix) { - res = pop_callstub_string(&jx); - if (res) - fatal_error("String-on-string call stub while printing number."); - } - else { + if (charnum < ix) { ival = buf[(ix-1)-charnum] & 0xFF; pc = val; push_callstub(0x12, charnum+1); enter_function(iosys_rock, 1, &ival); + return; } break; @@ -190,6 +186,12 @@ void stream_num(glsi32 val, int inmiddle, int charnum) break; } + + if (inmiddle) { + res = pop_callstub_string(&jx); + if (res) + fatal_error("String-on-string call stub while printing number."); + } } /* stream_string(): @@ -698,7 +700,10 @@ void stream_set_table(glui32 addr) /* Build cache. We can only do this if the table is entirely in ROM. */ glui32 tablelen = Mem4(stringtable); glui32 rootaddr = Mem4(stringtable+8); - if (stringtable+tablelen <= ramstart && !never_cache_stringtable) { + int cache_stringtable = (stringtable+tablelen <= ramstart); + /* cache_stringtable = TRUE; ...for testing only */ + /* cache_stringtable = FALSE; ...for testing only */ + if (cache_stringtable) { buildcache(&tablecache, rootaddr, CACHEBITS, 0); /* dumpcache(&tablecache, 1, 0); */ tablecache_valid = TRUE; @@ -815,7 +820,7 @@ char *make_temp_string(glui32 addr) { int ix, len; glui32 addr2; - char *res, *cx; + char *res; if (Mem1(addr) != 0xE0) fatal_error("String argument to a Glk call must be unencoded."); @@ -844,7 +849,7 @@ glui32 *make_temp_ustring(glui32 addr) { int ix, len; glui32 addr2; - glui32 *res, *cx; + glui32 *res; if (Mem1(addr) != 0xE2) fatal_error("Ustring argument to a Glk call must be unencoded.");