From 5ac12ff56d29180adb40e203a598ece23b9133e1 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 31 May 2024 23:02:55 -0400 Subject: unprotbas: add MAX_PROG_SIZE constant. --- unprotbas.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'unprotbas.c') 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) -- cgit v1.2.3