X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=interpreters%2Fglulxe%2Fstring.c;fp=interpreters%2Fglulxe%2Fstring.c;h=b3f119dc3dcaa2d9d0e5dda4c3f345682ffe52db;hb=75009f8f40bbb580194e1722db76f4644bf18641;hp=1f3b6f0d6c1c2fdf64b207d89da9248bbc7f44c3;hpb=89081782541e85e079f64839ffb26b4e74273eb7;p=projects%2Fchimara%2Fchimara.git diff --git a/interpreters/glulxe/string.c b/interpreters/glulxe/string.c index 1f3b6f0..b3f119d 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;