diff options
author | B. Watson <urchlay@slackware.uk> | 2024-07-17 04:40:53 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-07-17 04:40:53 -0400 |
commit | c150802bc351b221f380e295afe1239ad70de50b (patch) | |
tree | e822b7d2e48ae4f634e7dab00e7d655e00d809b3 | |
parent | 944b59a1e25f254694e5c58fddcb461d5a05a5a4 (diff) | |
download | bw-atari8-tools-c150802bc351b221f380e295afe1239ad70de50b.tar.gz |
listbas: support all 256 variable names in Turbo BASIC.
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | bas.c | 5 | ||||
-rw-r--r-- | listbas.c | 56 |
3 files changed, 37 insertions, 25 deletions
@@ -1,7 +1,6 @@ for now: listbas: -- Turbo BASIC tokens for variables 128-255 not recognized. - A+/BXL/BXE indentation not supported at all. These may need library (xex.c) changes: @@ -394,6 +394,11 @@ void walk_code(unsigned int startlineno, unsigned int endlineno) { while(pos < end) { /* loop over operators */ tok = program[pos]; switch(tok) { + case 0: /* Turbo variables numbered >= $80 */ + CALL(on_exp_token); + /* on_exp_token callback better know what to do with $00! */ + pos += 2; + break; case OP_NUMCONST: CALL(on_exp_token); pos++; @@ -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. */ |