18 August 2009

+ Fix warnings on recent gcc.
+ Audit much of the extisting dos33 code.

19 August 2009
+ Add integer basic detokenizer
+ Implement lock/unlock in dos33
+ Implement undelete in dos33
+ Implement rename in dos33
This commit is contained in:
Vince Weaver 2009-08-19 23:11:00 -04:00
parent 8d670e79c6
commit 8019e4d7dd
27 changed files with 980 additions and 315 deletions

12
CHANGES
View File

@ -22,3 +22,15 @@ RELEASE 0.0.6
+ Create tokenize_asoft
RELEASE 0.0.7
18 August 2009
+ Fix warnings on recent gcc.
+ Audit much of the extisting dos33 code.
19 August 2009
+ Add integer basic detokenizer
+ Implement lock/unlock in dos33
+ Implement undelete in dos33
+ Implement rename in dos33
RELEASE 0.0.8

View File

@ -1,45 +1,59 @@
CC = gcc
C_FLAGS = -O2 -Wall
L_FLAGS =
CFLAGS = -O2 -Wall
LFLAGS =
all: dos33 asoft_detoken mkdos33fs make_b tokenize_asoft
all: dos33 asoft_detoken mkdos33fs make_b tokenize_asoft \
dos33_text2ascii integer_detoken
asoft_detoken: asoft_detoken.o
$(CC) $(L_FLAGS) -o asoft_detoken asoft_detoken.o
$(CC) $(LFLAGS) -o asoft_detoken asoft_detoken.o
asoft_detoken.o: asoft_detoken.c
$(CC) $(C_FLAGS) -c asoft_detoken.c
$(CC) $(CFLAGS) -c asoft_detoken.c
integer_detoken: integer_detoken.o
$(CC) $(LFLAGS) -o integer_detoken integer_detoken.o
integer_detoken.o: integer_detoken.c
$(CC) $(CFLAGS) -c integer_detoken.c
tokenize_asoft: tokenize_asoft.o
$(CC) $(L_FLAGS) -o tokenize_asoft tokenize_asoft.o
$(CC) $(LFLAGS) -o tokenize_asoft tokenize_asoft.o
tokenize_asoft.o: tokenize_asoft.c
$(CC) $(C_FLAGS) -c tokenize_asoft.c
$(CC) $(CFLAGS) -c tokenize_asoft.c
dos33: dos33.o
$(CC) $(L_FLAGS) -o dos33 dos33.o
$(CC) $(LFLAGS) -o dos33 dos33.o
dos33.o: dos33.c dos33.h
$(CC) $(C_FLAGS) -c dos33.c
$(CC) $(CFLAGS) -c dos33.c
dos33_text2ascii: dos33_text2ascii.o
$(CC) $(LFLGAS) -o dos33_text2ascii dos33_text2ascii.o
dos33_text2ascii.o: dos33_text2ascii.c
$(CC) $(CFLAGS) -c dos33_text2ascii.c
make_b: make_b.o
$(CC) $(L_FLAGS) -o make_b make_b.o
$(CC) $(LFLAGS) -o make_b make_b.o
make_b.o: make_b.c
$(CC) $(C_FLAGS) -c make_b.c
$(CC) $(CFLAGS) -c make_b.c
mkdos33fs: mkdos33fs.o
$(CC) $(L_FLAGS) -o mkdos33fs mkdos33fs.o
$(CC) $(LFLAGS) -o mkdos33fs mkdos33fs.o
mkdos33fs.o: mkdos33fs.c dos33.h
$(CC) $(C_FLAGS) -c mkdos33fs.c
$(CC) $(CFLAGS) -c mkdos33fs.c
install:
cp dos33 asoft_detoken mkdos33fs tokenize_asoft make_b /usr/local/bin
cp dos33 asoft_detoken mkdos33fs tokenize_asoft make_b dos33_text2ascii.c integer_detoken /usr/local/bin
clean:
rm -f *~ *.o asoft_detoken dos33 make_b mkdos33fs tokenize_asoft
rm -f *~ *.o asoft_detoken dos33 make_b mkdos33fs tokenize_asoft dos33_text2ascii integer_detoken
cd tests && make clean

15
TODO
View File

@ -1,8 +1,21 @@
check lock before delete
+ Validate that apple filenames are valid in all cases
FUSE driver
+ How to map permissions to file types? LOCK=w
+ How to handle file sizes?
No special cases, just always multiples of 256?
Only truncate if in window?
Enforce in writing "b" type that the fields are correct.
Generic Linux writes are of type "S".
Figure out how to represent in Linux the file types?
defrag utility
test-suite
test mkdosfs copy over DOS functionality
find out why dos33 SAVE puts extra linefeed at end of basic prog?
(turns out that's normal. it is ignored)

View File

@ -1,5 +1,6 @@
#include <stdio.h>
#include <string.h> /* strlen() */
#include "version.h"
/* Starting at 0x80 */
char applesoft_tokens[][8]={

835
dos33.c

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
#include <stdio.h>
#include "version.h"
int main(int argc, char **argv) {
int ch;
@ -7,14 +9,14 @@ int main(int argc, char **argv) {
ch=fgetc(stdin);
if (feof(stdin)) return 0;
/* clear high byte */
ch=ch&0x7f;
/* convert apple carriage-return to unix linefeed */
if (ch=='\r') ch=('\n');
fputc(ch,stdout);
}
return 0;
}

120
integer_detoken.c Normal file
View File

@ -0,0 +1,120 @@
#include <stdio.h>
#include <string.h> /* strlen() */
#include <ctype.h> /* isalnum() */
#include "version.h"
/* with help from code by Paul Schlyter */
/* detokenizes Apple 2 integer basic programs */
/* re-tokenizing is hard, as some with same name */
/* such as PRINT have different tokens depending */
/* on arguments */
/* Integer Basic */
char integer_tokens[128][8]={
/* 00 */ "HIMEM:", "<$01>", "_", ":",
"LOAD ", "SAVE ", "CON ", "RUN", /* direct */
/* 08 */ "RUN", "DEL ", ",", "NEW",
"CLR", "AUTO", ",", "MAN",
/* 10 */ "HIMEM:", "LOMEM:", "+", "-", /* binary */
"*", "/", "=", "#",
/* 18 */ ">=", ">", "<=", "<>",
"<", " AND ", " OR ", " MOD ",
/* 20 */ "^", "+", "(", ",",
" THEN ", " THEN ", ",", ",",
/* 28 */ "\"", "\"", "(", "!",
"!", "(", " PEEK ", "RND",
/* 30 */ "SGN", "ABS", "PDL", "RNDX",
"(", "+", "-", " NOT ", /* unary */
/* 38 */ "(", "=", "#", "LEN(",
"ASC(", "SCRN(", ",", "(",
/* 40 */ "$", "$", "(", ",",
",", ";", ";", ";",
/* 48 */ ",", ",", ",", "TEXT", /* Statements */
"GR", "CALL ", "DIM ", "DIM ",
/* 50 */ "TAB ", "END", "INPUT ", "INPUT ",
"INPUT ", "FOR ", "=", " TO ",
/* 58 */ "STEP ", "NEXT ", ",", "RETURN",
"GOSUB ", "REM ", "LET ", "GOTO ",
/* 60 */ "IF ", "PRINT ", "PRINT ", "PRINT ",
"POKE ", ",", "COLOR=", "PLOT ",
/* 68 */ ",", "HLIN ", ",", " AT ",
"VLIN ", ",", " AT ", "VTAB ",
/* 70 */ "=", "=", ")", ")",
"LIST", ",", "LIST", "POP",
/* 78 */ "NODSP", "DSP", "NOTRACE","DSP",
"DSP", "TRACE", "PR#", "IN#"
};
#define REM_TOKEN 0x5D
#define UNARY_PLUS 0x35
#define UNARY_MINUS 0x36
#define QUOTE_START 0x28
#define QUOTE_END 0x29
int main(int argc, char **argv) {
int ch1;
int size1,size2;
int line_length;
int line1,line2;
int int1,int2;
int in_rem=0,in_quote=0,last_was_alpha=0,last_was_token=0;
/* read size, first two bytes */
size1=fgetc(stdin);
size2=fgetc(stdin);
while(!feof(stdin)) {
in_rem=0;
in_quote=0;
last_was_alpha=0;
last_was_token=0;
line_length=fgetc(stdin);
/* line number is little endian 16-bit value */
line1=fgetc(stdin);
line2=fgetc(stdin);
if (feof(stdin)) goto the_end;
printf("%4d ",((line2)<<8)+line1);
/* repeat until EOL character (1) */
while( (ch1=fgetc(stdin))!=0x1 ) {
/* if < 0x80 it's a token */
if (ch1<0x80) {
printf("%s",integer_tokens[ch1]);
if (ch1==REM_TOKEN) in_rem=1;
if (ch1==QUOTE_START) in_quote=1;
if (ch1==QUOTE_END) in_quote=0;
last_was_alpha=0;
last_was_token=1;
}
/* integer contant */
else if ((!in_rem) && (!in_quote) && (!last_was_alpha) &&
(ch1>=0xb0) && (ch1<=0xb9)) {
int1=fgetc(stdin);
int2=fgetc(stdin);
printf("%d",(int2<<8)+int1);
last_was_token=0;
}
/* otherwise it is an ascii char */
else {
fputc(ch1&0x7f,stdout);
last_was_alpha=isalnum(ch1&0x7f);
last_was_token=0;
}
}
printf("\n");
}
the_end:;
return 0;
}

View File

@ -4,6 +4,8 @@
#include <fcntl.h> /* open() */
#include <unistd.h> /* close() */
#include "version.h"
int main(int argc, char **argv) {
int in_fd,out_fd,offset;
@ -14,7 +16,8 @@ int main(int argc, char **argv) {
struct stat file_info;
if (argc!=4) {
printf("Usage: %s in_file out_file offset\n\n",argv[0]);
printf("MAKE_B version %s\b",VERSION);
printf(" Usage: %s in_file out_file offset\n\n",argv[0]);
printf("\tin_file : input file\n");
printf("\tout_file : output file\n");
printf("\toffset : offset which file should be loaded\n\n");

View File

@ -3,11 +3,10 @@
#include <fcntl.h> /* open() */
#include <unistd.h> /* close() */
#include <stdlib.h> /* strtol() */
#include "version.h"
#include "dos33.h"
#define VERSION "0.0.1"
void usage(char *binary,int help) {
printf("\n%s - version %s\n",binary,VERSION);

BIN
tests/GR

Binary file not shown.

BIN
tests/LL_6502 Normal file

Binary file not shown.

5
tests/Makefile Normal file
View File

@ -0,0 +1,5 @@
all:
clean:
rm -f *.out *~ test.dsk

BIN
tests/TB_6502 Normal file

Binary file not shown.

2
tests/TODO Normal file
View File

@ -0,0 +1,2 @@
Test copy
Test over-writing existing file

BIN
tests/empty.dsk Normal file

Binary file not shown.

BIN
tests/test.int Normal file

Binary file not shown.

24
tests/test.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
echo "Testing dos33..."
cp empty.dsk test.dsk
../dos33 ./test.dsk catalog
../dos33 ./test.dsk save a SINCOS SINCOS
../dos33 ./test.dsk save t YOU.LOGO
../dos33 ./test.dsk save b LL_6502
../dos33 ./test.dsk save b TB_6502
../dos33 ./test.dsk catalog
../dos33 ./test.dsk load SINCOS sincos.out
../dos33 ./test.dsk load YOU.LOGO you.logo.out
../dos33 ./test.dsk load LL_6502 ll_6502.out
../dos33 ./test.dsk load TB_6502 tb_6502.out
diff SINCOS sincos.out
diff YOU.LOGO you.logo.out
diff LL_6502 ll_6502.out
diff TB_6502 tb_6502.out

22
tests/test_delete.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
echo "Testing dos33 Delete..."
cp empty.dsk test.dsk
../dos33 ./test.dsk catalog
../dos33 ./test.dsk save b LL_6502
../dos33 ./test.dsk save b TB_6502
../dos33 ./test.dsk catalog
../dos33 ./test.dsk delete LL_6502
../dos33 ./test.dsk catalog
../dos33 ./test.dsk save a SINCOS
../dos33 ./test.dsk save i test.int
../dos33 ./test.dsk save b LL_6502
../dos33 ./test.dsk catalog

18
tests/test_large_files.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
echo "Testing large files..."
cp empty.dsk test.dsk
dd if=/dev/urandom of=blah.out bs=1k count=116
../dos33 ./test.dsk catalog
../dos33 ./test.dsk save r blah.out big.1
../dos33 ./test.dsk save r blah.out big.2
../dos33 ./test.dsk load big.1 blah2.out
diff blah.out blah2.out
../dos33 ./test.dsk catalog

25
tests/test_lock.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
echo "Testing dos33 Lock/Unlock..."
cp empty.dsk test.dsk
../dos33 ./test.dsk catalog
../dos33 ./test.dsk save b LL_6502
../dos33 ./test.dsk save b TB_6502
../dos33 ./test.dsk save a SINCOS
../dos33 ./test.dsk save i test.int
../dos33 ./test.dsk catalog
../dos33 ./test.dsk lock LL_6502
../dos33 ./test.dsk lock SINCOS
../dos33 ./test.dsk catalog
../dos33 ./test.dsk unlock LL_6502
../dos33 ./test.dsk catalog

29
tests/test_lots_of_files.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
echo "Test lots of files..."
cp empty.dsk test.dsk
../dos33 ./test.dsk catalog
../dos33 ./test.dsk save a SINCOS SIN1
../dos33 ./test.dsk save a SINCOS SIN2
../dos33 ./test.dsk save a SINCOS SIN3
../dos33 ./test.dsk save a SINCOS SIN4
../dos33 ./test.dsk save a SINCOS SIN5
../dos33 ./test.dsk save a SINCOS SIN6
../dos33 ./test.dsk save a SINCOS SIN7
../dos33 ./test.dsk save a SINCOS SIN8
../dos33 ./test.dsk save a SINCOS SIN9
../dos33 ./test.dsk save a SINCOS SIN10
../dos33 ./test.dsk save a SINCOS SIN11
../dos33 ./test.dsk save a SINCOS SIN12
../dos33 ./test.dsk save a SINCOS SIN13
../dos33 ./test.dsk save a SINCOS SIN14
../dos33 ./test.dsk save a SINCOS SIN15
../dos33 ./test.dsk save a SINCOS SIN16
../dos33 ./test.dsk catalog

16
tests/test_odd_filenames.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
echo "Testing odd file names..."
cp empty.dsk test.dsk
../dos33 ./test.dsk catalog
../dos33 ./test.dsk save a ././SINCOS
../dos33 ./test.dsk save a SINCOS this_is_a_very_very_long_filename
../dos33 ./test.dsk save a SINCOS \~CrAzY\%\$F\*\{\(
../dos33 ./test.dsk save a SINCOS 679-8329
../dos33 ./test.dsk save a SINCOS SPACES\ ARE\ OK
../dos33 ./test.dsk save a SINCOS Commas,are,not
../dos33 ./test.dsk catalog

27
tests/test_rename.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
echo "Testing dos33 Rename..."
cp empty.dsk test.dsk
../dos33 ./test.dsk catalog
../dos33 ./test.dsk save b TB_6502
../dos33 ./test.dsk save a SINCOS
../dos33 ./test.dsk save i test.int
../dos33 ./test.dsk save b LL_6502
../dos33 ./test.dsk catalog
../dos33 ./test.dsk rename TB_6502 "tom bombem"
../dos33 ./test.dsk rename test.int "Integer Basic Test"
../dos33 ./test.dsk catalog
../dos33 ./test.dsk rename "tom bombem" "tb1"
../dos33 ./test.dsk catalog
../dos33 ./test.dsk load "tb1" "tb1.out"
diff TB_6502 tb1.out

29
tests/test_undelete.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
echo "Testing dos33 Undelete..."
cp empty.dsk test.dsk
../dos33 ./test.dsk catalog
../dos33 ./test.dsk save b LL_6502
../dos33 ./test.dsk save b TB_6502
../dos33 ./test.dsk save a SINCOS
../dos33 ./test.dsk save i test.int
../dos33 ./test.dsk catalog
../dos33 ./test.dsk delete LL_6502
../dos33 ./test.dsk catalog
../dos33 ./test.dsk undelete LL_6502
../dos33 ./test.dsk catalog
../dos33 ./test.dsk load LL_6502 ll.out
diff LL_6502 ll.out

29
tests/test_undelete2.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
echo "Testing dos33 Undelete..."
cp empty.dsk test.dsk
../dos33 ./test.dsk catalog
../dos33 ./test.dsk save b LL_6502 L123456789012345678901234567890
../dos33 ./test.dsk save b TB_6502
../dos33 ./test.dsk save a SINCOS
../dos33 ./test.dsk save i test.int
../dos33 ./test.dsk catalog
../dos33 ./test.dsk delete L123456789012345678901234567890
../dos33 ./test.dsk catalog
../dos33 ./test.dsk undelete L123456789012345678901234567890
../dos33 ./test.dsk catalog
../dos33 ./test.dsk load L123456789012345678901234567890 ll.out
diff LL_6502 ll.out

View File

@ -2,6 +2,8 @@
#include <string.h> /* strlen() */
#include <stdlib.h> /* exit() */
#include "version.h"
/* TODO */
/* match lowecase tokens as well as upper case ones */
@ -39,29 +41,6 @@ char applesoft_tokens[][8]={
/* F8 */ "","","","","","(","(","("
};
#if 0
/* Integer Basic */
char integer_tokens[][8]={
/* 00 */ "","","",":","LOAD","SAVE","","RUN",
/* 08 */ "","DEL",",","NEW","CLR","AUTO","","MAN",
/* 10 */ "HIMEM:","LOMEM:","+","-","*","/","=","#",
/* 18 */ ">=",">","<=","<>","<"," AND"," OR"," MOD",
/* 20 */ "^","","(",",",""," THEN","",",",
/* 28 */ "\"","\"","(","","","("," PEEK","RND",
/* 30 */ "SGN","ABS","PDL","","(","+","-","NOT",
/* 38 */ "(","=","LEN (","ASC (","SCRN (",","," (",
/* 40 */ "$","(","",",","","",";",
/* 48 */ "",",",",","TEXT","GR","CALL","","DIM",
/* 50 */ "TAB","END","","","INPUT","FOR","=","TO",
/* 58 */ " STEP","NEXT",",","RETURN","GOSUB","REM","LET","GOTO",
/* 60 */ "IF","","PRINT","PRINT"," POKE",",","COLOR=","PLOT",
/* 68 */ ",","HLIN",","," AT","VLIN",","," AT","VTAB",
/* 70 */ "","=",")","","LIST",",","","POP",
/* 78 */ "","NO DSP","NO TRACE","","DSP","TRACE","PR #","IN #"
};
#endif
#define LOW(_x) ((_x)&0xff)
#define HIGH(_x) (((_x)>>8)&0xff)
#define MAXSIZE 65535

1
version.h Normal file
View File

@ -0,0 +1 @@
#define VERSION "0.0.8"