aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-05-31 23:02:55 -0400
committerB. Watson <urchlay@slackware.uk>2024-05-31 23:02:55 -0400
commit5ac12ff56d29180adb40e203a598ece23b9133e1 (patch)
treed0ec0576fef02d861a59549ce2c63ec7b3abe84e
parent8b785b5296c388fda5f56b0916bb69797d01049e (diff)
downloadbw-atari8-tools-5ac12ff56d29180adb40e203a598ece23b9133e1.tar.gz
unprotbas: add MAX_PROG_SIZE constant.
-rw-r--r--unprotbas.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/unprotbas.c b/unprotbas.c
index a4a2129..3486ac4 100644
--- a/unprotbas.c
+++ b/unprotbas.c
@@ -16,6 +16,9 @@
or whatever), we "fix" that by making up new variable names.
*/
+/* 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. */
#define TBL_OFFSET 0xf2
@@ -26,8 +29,12 @@
can't process. */
#define MIN_PROG_SIZE 21
-/* maximum size of the program in memory. 64KB is actually way overkill. */
-#define BUFSIZE 65536
+/* 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).
+ */
+#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
@@ -115,7 +122,7 @@ int readfile(void) {
if(verbose) fprintf(stderr, "Read %d bytes.\n", got);
if(!feof(input_file))
fprintf(stderr, "Warning: file is >64KB, way too big for a BASIC program.\n");
- else if(got > 38176)
+ else if(got > MAX_PROG_SIZE)
fprintf(stderr, "Warning: file is %d bytes, suspiciously large for a BASIC program.\n", got);
fclose(input_file);
if(got < MIN_PROG_SIZE)