mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-01-12 15:30:55 +00:00
Merge branch 'master' of git://github.com/deater/dos33fsprogs
This commit is contained in:
commit
e31cdb2620
@ -1,10 +1,14 @@
|
|||||||
|
/* asoft_detoken: detokenize an applesoft BASIC program */
|
||||||
|
/* by Vince Weaver (vince@deater.net) */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h> /* strlen() */
|
#include <string.h> /* strlen() */
|
||||||
|
#include <unistd.h> /* getopt() */
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
/* Starting at 0x80 */
|
/* Starting at 0x80 */
|
||||||
char applesoft_tokens[][8]={
|
char applesoft_tokens[][8]={
|
||||||
|
|
||||||
/* 80 */ "END","FOR","NEXT","DATA","INPUT","DEL","DIM","READ",
|
/* 80 */ "END","FOR","NEXT","DATA","INPUT","DEL","DIM","READ",
|
||||||
/* 88 */ "GR","TEXT","PR #","IN #","CALL","PLOT","HLIN","VLIN",
|
/* 88 */ "GR","TEXT","PR #","IN #","CALL","PLOT","HLIN","VLIN",
|
||||||
/* 90 */ "HGR2","HGR","HCOLOR=","HPLOT","DRAW","XDRAW","HTAB","HOME",
|
/* 90 */ "HGR2","HGR","HCOLOR=","HPLOT","DRAW","XDRAW","HTAB","HOME",
|
||||||
@ -24,61 +28,94 @@ char applesoft_tokens[][8]={
|
|||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
int ch1,i;
|
|
||||||
int size1,size2;
|
|
||||||
int line1,line2;
|
|
||||||
int link1,link2,link;
|
|
||||||
int debug=0;
|
|
||||||
int offset=0x801;
|
|
||||||
|
|
||||||
/* read size, first two bytes */
|
|
||||||
size1=fgetc(stdin);
|
|
||||||
size2=fgetc(stdin);
|
|
||||||
|
|
||||||
if (debug) fprintf(stderr,"File size: %x %x\n",size1,size2);
|
|
||||||
|
|
||||||
while(!feof(stdin)) {
|
int ch1,i;
|
||||||
|
int size1,size2;
|
||||||
/* link points to the next line */
|
int line1,line2;
|
||||||
/* assumes asoft program starts at address $801 */
|
int link1,link2,link;
|
||||||
link1=fgetc(stdin);
|
int debug=0,print_link=0;
|
||||||
link2=fgetc(stdin);
|
int offset=0x801;
|
||||||
link=(link2<<8)|link1;
|
int c;
|
||||||
offset+=2;
|
FILE *fff;
|
||||||
|
|
||||||
/* link==0 indicates EOF */
|
/* Check command line arguments */
|
||||||
if (link==0) goto the_end;
|
while ((c = getopt (argc, argv,"dl"))!=-1) {
|
||||||
|
switch (c) {
|
||||||
/* line number is little endian 16-bit value */
|
|
||||||
line1=fgetc(stdin);
|
case 'd':
|
||||||
line2=fgetc(stdin);
|
debug=1;
|
||||||
if (feof(stdin)) goto the_end;
|
break;
|
||||||
printf("%4d ",((line2)<<8)+line1);
|
case 'l':
|
||||||
offset+=2;
|
print_link=1;
|
||||||
|
break;
|
||||||
/* repeat until EOL character (0) */
|
}
|
||||||
while( (ch1=fgetc(stdin))!=0 ) {
|
}
|
||||||
offset++;
|
|
||||||
/* if > 0x80 it's a token */
|
/* No file specified, used stdin */
|
||||||
if (ch1>=0x80) {
|
if (optind==argc) {
|
||||||
fputc(' ',stdout);
|
fff=stdin;
|
||||||
for(i=0;i<strlen(applesoft_tokens[ch1-0x80]);i++) {
|
}
|
||||||
fputc(applesoft_tokens[ch1-0x80][i],stdout);
|
else {
|
||||||
}
|
fff=fopen(argv[optind],"r");
|
||||||
fputc(' ',stdout);
|
if (fff==NULL) {
|
||||||
}
|
fprintf(stderr,"Error, could not open %s\n",argv[optind]);
|
||||||
/* otherwise it is an ascii char */
|
return -1;
|
||||||
else {
|
}
|
||||||
fputc(ch1,stdout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
offset++;
|
/* read size, first two bytes */
|
||||||
printf("\n");
|
size1=fgetc(fff);
|
||||||
if (link!=offset) fprintf(stderr,"WARNING! link!=offset %x %x\n",
|
size2=fgetc(fff);
|
||||||
link,offset);
|
|
||||||
}
|
if (debug) fprintf(stderr,"File size: %x %x\n",size1,size2);
|
||||||
the_end:;
|
|
||||||
return 0;
|
while(!feof(fff)) {
|
||||||
|
|
||||||
|
/* link points to the next line */
|
||||||
|
/* assumes asoft program starts at address $801 */
|
||||||
|
link1=fgetc(fff);
|
||||||
|
link2=fgetc(fff);
|
||||||
|
link=(link2<<8)|link1;
|
||||||
|
offset+=2;
|
||||||
|
|
||||||
|
if (print_link) printf("*%04X",link);
|
||||||
|
|
||||||
|
/* link==0 indicates EOF */
|
||||||
|
if (link==0) goto the_end;
|
||||||
|
|
||||||
|
/* line number is little endian 16-bit value */
|
||||||
|
line1=fgetc(fff);
|
||||||
|
line2=fgetc(fff);
|
||||||
|
if (feof(fff)) goto the_end;
|
||||||
|
printf("%4d ",((line2)<<8)+line1);
|
||||||
|
offset+=2;
|
||||||
|
|
||||||
|
/* repeat until EOL character (0) */
|
||||||
|
while( (ch1=fgetc(fff))!=0 ) {
|
||||||
|
offset++;
|
||||||
|
/* if > 0x80 it's a token */
|
||||||
|
if (ch1>=0x80) {
|
||||||
|
/* Leading space */
|
||||||
|
fputc(' ',stdout);
|
||||||
|
for(i=0;i<strlen(applesoft_tokens[ch1-0x80]);i++) {
|
||||||
|
fputc(applesoft_tokens[ch1-0x80][i],stdout);
|
||||||
|
}
|
||||||
|
/* Trailing space, but not if REM */
|
||||||
|
if ((ch1-0x80)!=0x32) fputc(' ',stdout);
|
||||||
|
}
|
||||||
|
/* otherwise it is an ascii char */
|
||||||
|
else {
|
||||||
|
fputc(ch1,stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
offset++;
|
||||||
|
printf("\n");
|
||||||
|
if (link!=offset) {
|
||||||
|
fprintf(stderr,"WARNING! link!=offset %x %x\n",link,offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
the_end:;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,27 @@
|
|||||||
|
/* tokenize_asoft: Tokenize an Applesoft BASIC program */
|
||||||
|
/* by Vince Weaver <vince@deater.net> */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h> /* strlen() */
|
#include <string.h> /* strlen() */
|
||||||
#include <stdlib.h> /* exit() */
|
#include <stdlib.h> /* exit() */
|
||||||
|
#include <unistd.h> /* getopt() */
|
||||||
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
static int debug=0;
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
/* match lowercase tokens as well as upper case ones */
|
/* match lowercase tokens as well as upper case ones */
|
||||||
|
|
||||||
/* Info from http://docs.info.apple.com/article.html?coll=ap&artnum=57 */
|
/* Info from http://docs.info.apple.com/article.html?coll=ap&artnum=57 */
|
||||||
|
|
||||||
/* In memory, applesoft file starts at address $801 */
|
/* In memory, applesoft file starts at address $801 */
|
||||||
/* format is <LINE><LINE><LINE>$00$00 */
|
/* format is <LINE><LINE><LINE>$00$00 */
|
||||||
/* Where <LINE> is: */
|
/* Where <LINE> is: */
|
||||||
/* 2 bytes (little endian) of LINK indicating addy of next line */
|
/* 2 bytes (little endian) of LINK indicating addy of next line */
|
||||||
/* 2 bytes (little endian) giving the line number */
|
/* 2 bytes (little endian) giving the line number */
|
||||||
/* a series of bytes either ASCII or tokens (see below) */
|
/* a series of bytes either ASCII or tokens (see below) */
|
||||||
/* a $0 char indicating end of line */
|
/* a $0 char indicating end of line */
|
||||||
|
|
||||||
#define NUM_TOKENS 107
|
#define NUM_TOKENS 107
|
||||||
|
|
||||||
@ -61,13 +67,37 @@ static void show_problem(char *line_ptr) {
|
|||||||
fprintf(stderr,"^\n");
|
fprintf(stderr,"^\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getnum(void) {
|
static int get_line_num(int *linenum, int *custom_offset) {
|
||||||
|
|
||||||
int num=0;
|
int num=0;
|
||||||
|
int offset=0;
|
||||||
|
|
||||||
/* skip any whitespace */
|
/* skip any whitespace */
|
||||||
while((*line_ptr<=' ') && (*line_ptr!=0)) line_ptr++;
|
while((*line_ptr<=' ') && (*line_ptr!=0)) line_ptr++;
|
||||||
|
|
||||||
|
/* Custom Offset */
|
||||||
|
if (*line_ptr=='*') {
|
||||||
|
line_ptr++;
|
||||||
|
while(*line_ptr>' ') {
|
||||||
|
if ((*line_ptr>='0')&&(*line_ptr<='9')) {
|
||||||
|
offset*=16;
|
||||||
|
offset+=(*line_ptr)-'0';
|
||||||
|
} else if ((*line_ptr>='A')&&(*line_ptr<='F')) {
|
||||||
|
offset*=16;
|
||||||
|
offset+=(*line_ptr)-'A'+10;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr,"Invalid offset line %d\n",line);
|
||||||
|
show_problem(line_ptr);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
line_ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skip whitespace */
|
||||||
|
while((*line_ptr<=' ') && (*line_ptr!=0)) line_ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
while (*line_ptr>' ') {
|
while (*line_ptr>' ') {
|
||||||
if ((*line_ptr<'0')||(*line_ptr>'9')) {
|
if ((*line_ptr<'0')||(*line_ptr>'9')) {
|
||||||
fprintf(stderr,"Invalid line number line %d\n",line);
|
fprintf(stderr,"Invalid line number line %d\n",line);
|
||||||
@ -84,6 +114,13 @@ static int getnum(void) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (linenum) *linenum=num;
|
||||||
|
if (custom_offset) {
|
||||||
|
*custom_offset=offset;
|
||||||
|
if (debug) fprintf(stderr,"CO=%x\n",offset);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,13 +203,38 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
int offset=2,i;
|
int offset=2,i;
|
||||||
|
|
||||||
int linenum=0,lastline=0,link_offset;
|
int linenum=0,custom_offset=0,lastline=0,link_offset;
|
||||||
int link_value=0x801; /* start of applesoft program */
|
int link_value=0x801; /* start of applesoft program */
|
||||||
int token;
|
int token;
|
||||||
|
int c;
|
||||||
|
FILE *fff;
|
||||||
|
|
||||||
|
/* Check command line arguments */
|
||||||
|
while ((c = getopt (argc, argv,"d"))!=-1) {
|
||||||
|
switch (c) {
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
debug=1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No file specified, used stdin */
|
||||||
|
if (optind==argc) {
|
||||||
|
fff=stdin;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fff=fopen(argv[optind],"r");
|
||||||
|
if (fff==NULL) {
|
||||||
|
fprintf(stderr,"Error, could not open %s\n",argv[optind]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (debug) fprintf(stderr,"Opened file %s\n",argv[optind]);
|
||||||
|
}
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
/* get line from input file */
|
/* get line from input file */
|
||||||
line_ptr=fgets(input_line,BUFSIZ,stdin);
|
line_ptr=fgets(input_line,BUFSIZ,fff);
|
||||||
line++;
|
line++;
|
||||||
if (line_ptr==NULL) break;
|
if (line_ptr==NULL) break;
|
||||||
|
|
||||||
@ -180,7 +242,7 @@ int main(int argc, char **argv) {
|
|||||||
if (line_ptr[0]=='\'') {
|
if (line_ptr[0]=='\'') {
|
||||||
if (!strncmp(line_ptr,"\'.if 0",6)) {
|
if (!strncmp(line_ptr,"\'.if 0",6)) {
|
||||||
while(1) {
|
while(1) {
|
||||||
line_ptr=fgets(input_line,BUFSIZ,stdin);
|
line_ptr=fgets(input_line,BUFSIZ,fff);
|
||||||
line++;
|
line++;
|
||||||
if (line_ptr==NULL) break;
|
if (line_ptr==NULL) break;
|
||||||
if (!strncmp(line_ptr,"\'.endif",7)) break;
|
if (!strncmp(line_ptr,"\'.endif",7)) break;
|
||||||
@ -192,12 +254,10 @@ int main(int argc, char **argv) {
|
|||||||
/* VMW extension: use leading ' as a comment char */
|
/* VMW extension: use leading ' as a comment char */
|
||||||
if (line_ptr[0]=='\'') continue;
|
if (line_ptr[0]=='\'') continue;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* skip empty lines */
|
/* skip empty lines */
|
||||||
if (line_ptr[0]=='\n') continue;
|
if (line_ptr[0]=='\n') continue;
|
||||||
|
|
||||||
linenum=getnum();
|
get_line_num(&linenum,&custom_offset);
|
||||||
if ((linenum>65535) || (linenum<0)) {
|
if ((linenum>65535) || (linenum<0)) {
|
||||||
fprintf(stderr,"Invalid line number %d\n",linenum);
|
fprintf(stderr,"Invalid line number %d\n",linenum);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
@ -218,6 +278,7 @@ int main(int argc, char **argv) {
|
|||||||
while(1) {
|
while(1) {
|
||||||
token=find_token();
|
token=find_token();
|
||||||
output[offset]=token;
|
output[offset]=token;
|
||||||
|
if (debug) fprintf(stderr,"%2X ",token);
|
||||||
offset++;
|
offset++;
|
||||||
check_oflo(offset);
|
check_oflo(offset);
|
||||||
if (!token) break;
|
if (!token) break;
|
||||||
@ -231,8 +292,14 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
/* point link value to next line */
|
/* point link value to next line */
|
||||||
check_oflo(offset+2);
|
check_oflo(offset+2);
|
||||||
output[link_offset]=LOW(link_value);
|
if (custom_offset) {
|
||||||
output[link_offset+1]=HIGH(link_value);
|
output[link_offset]=LOW(custom_offset);
|
||||||
|
output[link_offset+1]=HIGH(custom_offset);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
output[link_offset]=LOW(link_value);
|
||||||
|
output[link_offset+1]=HIGH(link_value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* set last link field to $00 $00 which indicates EOF */
|
/* set last link field to $00 $00 which indicates EOF */
|
||||||
check_oflo(offset+2);
|
check_oflo(offset+2);
|
||||||
|
14
deceptive_list/Makefile
Normal file
14
deceptive_list/Makefile
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
DOS33 = ../dos33fs-utils/dos33
|
||||||
|
TXT2BAS = ../asoft_basic-utils/tokenize_asoft
|
||||||
|
|
||||||
|
all: deceptive.dsk
|
||||||
|
|
||||||
|
BACKWARD.BAS: backward.basd
|
||||||
|
$(TXT2BAS) < backward.basd > BACKWARD.BAS
|
||||||
|
|
||||||
|
deceptive.dsk: BACKWARD.BAS
|
||||||
|
$(DOS33) -y deceptive.dsk SAVE A BACKWARD.BAS
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *~ *.BAS *.SHAPE sound_test.bas shape_test.bas *.lst
|
||||||
|
|
BIN
deceptive_list/deceptive.dsk
Normal file
BIN
deceptive_list/deceptive.dsk
Normal file
Binary file not shown.
11
deceptive_list/hidden.bas
Normal file
11
deceptive_list/hidden.bas
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
5 REM FUN TIMES
|
||||||
|
7 PRINT
|
||||||
|
10 PRINT "** DECEPTIVE LIST **"
|
||||||
|
20 PRINT " BY "
|
||||||
|
30 PRINT " VINCE WEAVER "
|
||||||
|
40 PRINT "********************"
|
||||||
|
50 PRINT
|
||||||
|
55 PRINT "WHATEVER YOU DO, DON'T TYPE LIST"
|
||||||
|
60 PRINT
|
||||||
|
70 END
|
||||||
|
|
21
deceptive_list/hidden.basd
Normal file
21
deceptive_list/hidden.basd
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
'0811
|
||||||
|
*08BB 5 REM FUN TIMES
|
||||||
|
'0817
|
||||||
|
*0817 7 PRINT
|
||||||
|
'0833
|
||||||
|
*0833 10 PRINT "** DECEPTIVE LIST **"
|
||||||
|
'084F
|
||||||
|
*084F 20 PRINT " BY "
|
||||||
|
'086B
|
||||||
|
*086B 30 PRINT " VINCE WEAVER "
|
||||||
|
'0887
|
||||||
|
*0887 40 PRINT "********************"
|
||||||
|
'088D
|
||||||
|
*088D 50 PRINT
|
||||||
|
'08B5
|
||||||
|
*08B5 55 PRINT "WHATEVER YOU DO, DON'T TYPE LIST"
|
||||||
|
'08BB
|
||||||
|
*08BB 60 PRINT
|
||||||
|
'08C1
|
||||||
|
*08C1 70 END
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user