From c150802bc351b221f380e295afe1239ad70de50b Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 17 Jul 2024 04:40:53 -0400 Subject: listbas: support all 256 variable names in Turbo BASIC. --- listbas.c | 56 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 24 deletions(-) (limited to 'listbas.c') diff --git a/listbas.c b/listbas.c index 33f6202..11455e5 100644 --- a/listbas.c +++ b/listbas.c @@ -599,10 +599,42 @@ void op_color_on(unsigned char tok) { color_on(color_op); /* in case of bad token when bas_type == B_BASIC */ } +void print_varname(unsigned char varnum) { + int i, count; + unsigned char c; + + if(color) color_on(color_varnames); + + for(i = vnstart, count = 0; count < varnum; i++) { + if(program[i] & 0x80) count++; + if(i == codestart) { + fprintf(outfh, "(bad var tok $%02x)", varnum | 0x80); + return; + } + } + + do { + c = program[i++]; + if(color && c == ('(' | 0x80)) { + if(color) color_on(color_op); + } + outchr(c & 0x7f); + } while (c < 0x80); + if(color) color_off(); +} + CALLBACK(print_op) { const char *name; switch(tok) { + case 0: /* Turbo variables numbered >= $80 */ + if(bas_type == B_TURBO) { + print_varname(program[pos + 1] | 0x80); + return; + } else { + fprintf(stderr, "%s: got Turbo ext var tok at line %d, in non-Turbo program!\n", self, lineno); + } + break; case OP_HEXCONST: if(color) color_on(color_op); outchr('$'); @@ -633,30 +665,6 @@ CALLBACK(print_op) { if(color) color_off(); } -void print_varname(unsigned char varnum) { - int i, count; - unsigned char c; - - if(color) color_on(color_varnames); - - for(i = vnstart, count = 0; count < varnum; i++) { - if(program[i] & 0x80) count++; - if(i == codestart) { - fprintf(outfh, "(bad var tok $%02x)", varnum | 0x80); - return; - } - } - - do { - c = program[i++]; - if(color && c == ('(' | 0x80)) { - if(color) color_on(color_op); - } - outchr(c & 0x7f); - } while (c < 0x80); - if(color) color_off(); -} - /* for normal BASIC/A+/XL/XE variable tokens, $80-$FF. Turbo uses these, too, but it supports 256 variables, so it only uses $80-$FF for the first 128 vars. */ -- cgit v1.2.3