aboutsummaryrefslogtreecommitdiff
path: root/unprotbas.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-05-29 15:00:43 -0400
committerB. Watson <urchlay@slackware.uk>2024-05-29 15:00:43 -0400
commit74f632203d187148b3d063b7023051138e872d4c (patch)
tree5ba65301e63afae1e4cb4a54a1e81c628b25e4e4 /unprotbas.c
parentc84cedb3337c2cdabb5f3ff91aa44810d9661091 (diff)
downloadbw-atari8-tools-74f632203d187148b3d063b7023051138e872d4c.tar.gz
unprotbas: add -s option.
Diffstat (limited to 'unprotbas.c')
-rw-r--r--unprotbas.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/unprotbas.c b/unprotbas.c
index b2b3d98..8c8651f 100644
--- a/unprotbas.c
+++ b/unprotbas.c
@@ -58,6 +58,9 @@ unsigned char badcode[] = {
/* for -p/-pv */
int varname_char = 0x9b;
+/* for -s */
+int shrinktable = 0;
+
/* for the -r option */
#define MAP_FILE "varnames.txt"
unsigned char varnames[BUFSIZE];
@@ -634,6 +637,11 @@ void scramble_vars(void) {
exit(2);
}
+ if(shrinktable) {
+ if(verbose) fprintf(stderr, "shrinking variable name table\n");
+ adjust_vntable_size((vvstart - 1) - vnstart, (codestart - vvstart) / 8);
+ }
+
if(varname_char == -1) srand(time(NULL));
for(i = vnstart; i < vvstart - 1; i++)
@@ -652,7 +660,8 @@ void scramble_vars(void) {
}
void print_help(void) {
- fprintf(stderr, "Usage: %s [-v] [[-f] [-n] [-g] [-c] [-r|-w] | [-p|-pc|-pv]] <inputfile> <outputfile>\n", self);
+ fprintf(stderr, "Usage: %s [-v] [-f] [-n] [-g] [-c] [-r|-w] <inputfile> <outputfile>\n", self);
+ fprintf(stderr, " %s [-v] [-p|-pc|-pv] [-xr|-xNN] [-s] <inputfile> <outputfile>\n", self);
fprintf(stderr, "-v: verbose\n");
fprintf(stderr, "-f: force variable name table rebuild\n");
fprintf(stderr, "-n: do not rebuild variable name table, even if it's invalid\n");
@@ -661,8 +670,8 @@ void print_help(void) {
fprintf(stderr, "-w: write variable names to varnames.txt\n");
fprintf(stderr, "-r: read variable names from varnames.txt\n");
fprintf(stderr, "-pc/-pv/-p: protect code/variables/both\n");
- fprintf(stderr, "-xXX: hex code XX for variable names, with -p/-pc\n");
- fprintf(stderr, "-xr: random variable names, with -p/-pc\n");
+ fprintf(stderr, "-xNN: hex code NN for variable names, with -p/-pv\n");
+ fprintf(stderr, "-xr: random variable names, with -p/-pv\n");
fprintf(stderr, "Use - as a filename to read from stdin and/or write to stdout\n");
}
@@ -773,11 +782,12 @@ void parse_args(int argc, char **argv) {
char *e;
varname_char = (int)strtol(&(*argv)[2], &e, 16);
if(*e != 0 || varname_char > 0xff)
- die("invalid hex character for -x option (range is 0 to ff)");
+ die("invalid hex value for -x option (range is 0 to ff)");
}
}
}
break;
+ case 's': shrinktable = 1; break;
case 0:
if(!input_file)
open_input(NULL);
@@ -809,6 +819,8 @@ void parse_args(int argc, char **argv) {
}
if(xopt_used && !protect_vars)
die("-x option requires -p or -pv");
+ if(shrinktable && !protect_vars)
+ die("-s option requires -p or -pv");
}
int main(int argc, char **argv) {