diff options
author | B. Watson <urchlay@slackware.uk> | 2024-07-08 14:18:28 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-07-08 14:18:28 -0400 |
commit | 96354d1cace50a70322f96418677a2ab2a8333c0 (patch) | |
tree | ccd8aa52ee9ca5fb9833e6204cbab360fcb15aa3 | |
parent | 8b31cda23ae3a6b06dde59fa2d1bf6988a778451 (diff) | |
download | bw-atari8-tools-96354d1cace50a70322f96418677a2ab2a8333c0.tar.gz |
whichbas: check variable table for underscores (Turbo/BXE only) or var type with high 2 bits set (Turbo PROC/# labels).
-rw-r--r-- | whichbas.c | 45 |
1 files changed, 37 insertions, 8 deletions
@@ -58,24 +58,30 @@ void add_type(int type) { void print_result(void) { const char *name; + if(verbose) fprintf(stderr, " final bas_type %02x\n", bas_type); + if(bas_type == BT_INVALID) { name = "Unknown variant: Not Atari BASIC, Turbo, BXL, or BXE"; } else if(bas_type & BT_ATARI) { name = "Atari BASIC"; + } else if(bas_type == BT_TURBO) { + name = "Turbo BASIC XL"; + } else if(bas_type & BT_TURBO) { + if(bas_type & BT_BXL) { + name = "Either Turbo BASIC XL or OSS BASIC XL"; + } else if(bas_type & BT_BXE) { + name = "Either Turbo BASIC XL or OSS BASIC XE"; + } } else if(bas_type == BT_BXL || bas_type == (BT_BXL | BT_BXE)) { name = "OSS BASIC XL"; } else if(bas_type == BT_BXE) { name = "OSS BASIC XE"; - } else if(bas_type == BT_TURBO) { - name = "Turbo BASIC XL"; } else { - name = "Not Atari BASIC; probably either Turbo or BXL/BXE"; + /* this one should never happen: */ + name = "Either Turbo BASIC XL, OSS BASIC XL, or OSS BASIC XE"; } - if(verbose) fprintf(stderr, " final bas_type %02x\n", bas_type); - - fputs(name, stdout); - putchar('\n'); + puts(name); exit(bas_type == BT_ATARI ? 0 : bas_type + 8); } @@ -540,7 +546,30 @@ void detect_foreign(void) { } void check_variables(void) { - /* Turbo variables can have _ in the name, and have 3 for the type. */ + int pos; + + if(vntp == vntd) return; + + /* Unlike Atari BASIC, Turbo variables can have _ in the names. + So can BASIC XE, though it's not documented in the BASIC XE + Reference Manual that I have. + BXL can't have _ in variable names. */ + for(pos = vnstart; pos < vvstart; pos++) { + if((program[pos] & 0x7f) == '_') { + remove_type(BT_ATARI | BT_BXL); + } + } + + /* Also, Turbo line labels (for PROC/EXEC and #/GO#) are variables + with a type that's illegal in Atari/BXL/BXE. */ + for(pos = vvstart; pos < codestart; pos += 8) { + if((program[pos] & 0xc0) == 0xc0) { + bas_type = BT_TURBO; + print_result(); + } + /* TODO: check for BXL/BXE string arrays, if I can ever + figure out how to do it. */ + } } int main(int argc, char **argv) { |