aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-08 14:18:28 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-08 14:18:28 -0400
commit96354d1cace50a70322f96418677a2ab2a8333c0 (patch)
treeccd8aa52ee9ca5fb9833e6204cbab360fcb15aa3
parent8b31cda23ae3a6b06dde59fa2d1bf6988a778451 (diff)
downloadbw-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.c45
1 files changed, 37 insertions, 8 deletions
diff --git a/whichbas.c b/whichbas.c
index a61013e..8a0b335 100644
--- a/whichbas.c
+++ b/whichbas.c
@@ -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) {