aboutsummaryrefslogtreecommitdiff
path: root/whichbas.c
diff options
context:
space:
mode:
Diffstat (limited to 'whichbas.c')
-rw-r--r--whichbas.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/whichbas.c b/whichbas.c
index ef2c55b..ddea7a7 100644
--- a/whichbas.c
+++ b/whichbas.c
@@ -124,6 +124,11 @@ void remove_type(int type) {
print_result();
}
+void set_type(int type) {
+ bas_type = type;
+ if(!keep_going) print_result();
+}
+
CALLBACK(handle_cmd) {
int has_args = 0, has_var_arg = 0, vartype = -1;
unsigned char nexttok;
@@ -151,8 +156,7 @@ CALLBACK(handle_cmd) {
case CMD_CLOSE:
case CMD_SOUND:
if(!has_args) {
- bas_type = BT_TURBO;
- print_result();
+ set_type(BT_TURBO);
}
break;
case CMD_INPUT:
@@ -183,8 +187,7 @@ CALLBACK(handle_cmd) {
/* TB uses the same tokens for GET and PUT as Atari/BXL/BXE, but it allows
the argument to be a variable without a # in front of it. */
if(nexttok != OP_HASH) {
- bas_type = BT_TURBO;
- print_result();
+ set_type(BT_TURBO);
}
/* PARTIAL: we really should detect GET #1,A$. this is Turbo-only, but
probably nobody ever uses it because it doesn't seem to *work*,
@@ -194,8 +197,7 @@ CALLBACK(handle_cmd) {
case CMD_TRAP:
/* TB allows RESTORE #LABEL and TRAP #LABEL */
if(nexttok == OP_HASH) {
- bas_type = BT_TURBO;
- print_result();
+ set_type(BT_TURBO);
}
break;
default: break;
@@ -207,8 +209,8 @@ CALLBACK(handle_cmd) {
if(tok >= 0x65) {
fprintf(stderr, "handle_cmd: invalid command %02x at line %d\n", tok, lineno);
- bas_type = BT_INVALID;
- print_result();
+ keep_going = 0;
+ set_type(BT_INVALID);
}
/* we have tokens 0x3a to 0x68 in both TB and BXE, or 47
@@ -269,8 +271,7 @@ CALLBACK(handle_cmd) {
*/
/* So, if we see this token, it *has* to be Turbo's TRACE, whether
or not it has an argument. */
- bas_type = BT_TURBO;
- print_result();
+ set_type(BT_TURBO);
break;
case 0x59: /* TEXT or PROCEDURE */
/* COMPLETE */
@@ -305,7 +306,7 @@ CALLBACK(handle_cmd) {
}
break;
case 0x4a: /* UNLOCK (req'd arg) or DIR (optional arg) */
- /* PARTIAL: without args means TB, but with arg,
+ /* PARTIAL: without args means BXL/BXE, but with arg,
it could be either */
if(!has_args) {
remove_type(BT_TURBO);
@@ -365,8 +366,7 @@ CALLBACK(handle_cmd) {
it get LISTed as a line of 30 dashes.
The explanation is a lot longer than the code... */
if(program[pos - 1] == 0x05 || nexttok == 0x9b) {
- bas_type = BT_TURBO;
- print_result();
+ set_type(BT_TURBO);
} else {
remove_type(BT_TURBO);
}
@@ -428,8 +428,7 @@ CALLBACK(handle_op) {
/* Turbo allows 256 variables, tokenizes the first 128 normally ($80-$FF).
The extra ones above $FF are tokenized as $00, varnum - $80. None of
our other BASICs uses $00 as an operator token, so.. */
- bas_type = BT_TURBO;
- print_result();
+ set_type(BT_TURBO);
}
/* attempt to detect BXL/BXE DIM for 2D string arrays.
@@ -465,8 +464,8 @@ CALLBACK(handle_op) {
if(tok >= 0x6E) {
fprintf(stderr, "handle_op: invalid operator %02x at line %d\n", tok, lineno);
- bas_type = BT_INVALID;
- print_result();
+ keep_going = 0;
+ set_type(BT_INVALID);
}
/* There are 25 extra operators in Turbo, and 20 of them are shared with
@@ -555,8 +554,7 @@ CALLBACK(handle_op) {
has2 = (get_vartype(nexttok2) == TYPE_SCALAR);
}
if(has2) {
- bas_type = BT_BXE;
- print_result();
+ set_type(BT_BXE);
}
}
break;
@@ -574,8 +572,7 @@ CALLBACK(handle_op) {
case 0x63: /* RND (pseudo-func, no arg) or ERR (func, 1 num arg) */
/* COMPLETE */
if(nexttok != OP_FUNC_LPAR) {
- bas_type = BT_TURBO;
- print_result();
+ set_type(BT_TURBO);
}
case 0x66: /* %0 in TB, LEFT$( (pseudo-func, takes string) in BXL/BXE */
case 0x67: /* %1 in TB, RIGHT$( (pseudo-func, takes string) in BXL/BXE */
@@ -789,8 +786,7 @@ void check_variables(void) {
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();
+ set_type(BT_TURBO);
}
}