aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-06-27 01:48:48 -0400
committerB. Watson <urchlay@slackware.uk>2024-06-27 01:48:48 -0400
commit370beba9411917d85df64a1af7aa02340e3e0476 (patch)
treec7ed3a4f128eb086c5eccaac4c5bbc71bef84eae
parent3b02bdbbf657cb407d2cd9ec348aa9da6ced9c89 (diff)
downloadbw-atari8-tools-370beba9411917d85df64a1af7aa02340e3e0476.tar.gz
bas.h: minor cleanup.
-rw-r--r--bas.h69
1 files changed, 36 insertions, 33 deletions
diff --git a/bas.h b/bas.h
index 6996b35..211004e 100644
--- a/bas.h
+++ b/bas.h
@@ -1,30 +1,30 @@
/* bas.h - API for writing standalone programs that deal with
- tokenized Atari 8-bit BASIC program. */
+ tokenized Atari 8-bit BASIC program. */
/* maximum size of the program in memory. 64KB is actually way overkill. */
#define BUFSIZE 65536
/* the difference between the VVTP and VNTP values in the file, and the
- actual file positions of the variable names and values. */
+ actual file positions of the variable names and values. */
#define TBL_OFFSET 0xf2
/* minimum program size, for a program that has no variables and
- only one line of code (the immediate line 32768, consisting only of
- one token, which would be CSAVE). anything smaller than this, we
- can't process. */
+ only one line of code (the immediate line 32768, consisting only of
+ one token, which would be CSAVE). anything smaller than this, we
+ can't process. */
#define MIN_PROG_SIZE 21
/* maximum practical size for a BASIC program. if a file exceeds this
- size, we warn about it, but otherwise process it normally.
- this value is derived by subtracting the default LOMEM without DOS
- ($0700) from the start of the display list in GR.0 ($9c20, on a 48K Atari).
+ size, we warn about it, but otherwise process it normally.
+ this value is derived by subtracting the default LOMEM without DOS
+ ($0700) from the start of the display list in GR.0 ($9c20, on a 48K Atari).
*/
#define MAX_PROG_SIZE 38176
/* maximum number of variables in the variable name and value tables. this
- could be 128, but "ERROR- 4" still expands the tables. Entries >128
- don't have tokens, can't be referred to in code, but we'll preserve
- them anyway. */
+ could be 128, but "ERROR- 4" still expands the tables. Entries >128
+ don't have tokens, can't be referred to in code, but we'll preserve
+ them anyway. */
#define MAXVARS 256
/* BASIC tokens. Full set, taken from Chapter 10 of De Re Atari.
@@ -170,27 +170,6 @@
#define TYPE_ARRAY 1
#define TYPE_STRING 2
-/* callbacks */
-#define CALLBACK(x) void x(unsigned int lineno, unsigned int pos, unsigned int tok, unsigned int end)
-#define CALLBACK_PTR(x) void (*x)(unsigned int lineno, unsigned int pos, unsigned int tok, unsigned int end)
-#define walk_all_code() walk_code(0, 32768)
-
-void walk_code(unsigned int startlineno, unsigned int endlineno);
-unsigned char get_vartype(unsigned char tok);
-
-extern CALLBACK_PTR(on_start_line);
-extern CALLBACK_PTR(on_bad_line_length);
-extern CALLBACK_PTR(on_end_line);
-extern CALLBACK_PTR(on_start_stmt);
-extern CALLBACK_PTR(on_end_stmt);
-extern CALLBACK_PTR(on_cmd_token);
-extern CALLBACK_PTR(on_text);
-extern CALLBACK_PTR(on_exp_token);
-extern CALLBACK_PTR(on_var_token);
-extern CALLBACK_PTR(on_string_const);
-extern CALLBACK_PTR(on_num_const);
-extern CALLBACK_PTR(on_trailing_garbage);
-
/* BASIC 14-byte header values */
extern unsigned short lomem;
extern unsigned short vntp;
@@ -201,7 +180,7 @@ extern unsigned short stmcur;
extern unsigned short starp;
/* positions where various parts of the file start,
- derived from the header vars above. */
+ derived from the header vars above. */
extern unsigned short codestart;
extern unsigned short code_end;
extern unsigned short vnstart;
@@ -235,7 +214,31 @@ extern void update_header(void);
extern void move_code(int offset);
extern void adjust_vntable_size(int oldsize, int newsize);
extern int vntable_ok(void);
+extern unsigned char get_vartype(unsigned char tok);
extern void invalid_args(const char *arg);
extern FILE *open_file(const char *name, const char *mode);
extern void open_input(const char *name);
extern void open_output(const char *name);
+
+/* callback API begins here.
+ callbacks for walk_code(): */
+#define CALLBACK(x) void x(unsigned int lineno, unsigned int pos, unsigned int tok, unsigned int end)
+#define CALLBACK_PTR(x) void (*x)(unsigned int lineno, unsigned int pos, unsigned int tok, unsigned int end)
+
+/* main entry point for callback API: */
+void walk_code(unsigned int startlineno, unsigned int endlineno);
+#define walk_all_code() walk_code(0, 32768)
+
+/* available callbacks: */
+extern CALLBACK_PTR(on_start_line);
+extern CALLBACK_PTR(on_bad_line_length);
+extern CALLBACK_PTR(on_end_line);
+extern CALLBACK_PTR(on_start_stmt);
+extern CALLBACK_PTR(on_end_stmt);
+extern CALLBACK_PTR(on_cmd_token);
+extern CALLBACK_PTR(on_text);
+extern CALLBACK_PTR(on_exp_token);
+extern CALLBACK_PTR(on_var_token);
+extern CALLBACK_PTR(on_string_const);
+extern CALLBACK_PTR(on_num_const);
+extern CALLBACK_PTR(on_trailing_garbage);