This commit is contained in:
Kelvin Sherlock 1998-09-01 12:00:00 -04:00
commit 8ea9e65aab
8 changed files with 1816 additions and 0 deletions

34
ASoft.rez Normal file
View File

@ -0,0 +1,34 @@
#include "types.rez"
#include "bfish.rez"
resource rVersion(TrVersion)
{
{1, 0, 0, release, 0},
$0000,
"AppleSoft Translator",
"by Kelvin Sherlock\nCopyright 1998 Kelvin Sherlock"
};
resource rComment(TrAbout)
{
"AppleSoft BASIC BabelFish translator"
};
resource rTrData(TrData)
{
bf320+bf640,
bfCanImport,
{1,0,0,0,0,0,0,0},
0,
{0,0,0,0,0,0,0,0}
};
read rCodeResource(TrFilter, locked, convert) "Filter";
read rCodeResource(TrInit, locked, convert) "Init";
resource rText(TrImportInfo)
{
"Import AppleSoft BASIC files.\n\n"
"by Kelvin W. Sherlock."
};

43
bfish.equ Normal file
View File

@ -0,0 +1,43 @@
offset_ParmCount gequ $00
offset_Status gequ $02
offset_MiscFlags gequ $04
offset_DataKinds gequ $06
offset_TransNum gequ $0e
offset_UserID gequ $10
offset_ProgressAction gequ $12
offset_FullTherm gequ $14
offset_CurrentTherm gequ $16
offset_MsgPtr gequ $18
offset_DataRecordPtr gequ $1c
offset_FilePathPtr gequ $20
offset_FileNamePtr gequ $24
offset_Text_ActionCode gequ $02
offset_Text_Length gequ $06
offset_Text_Ptr gequ $0A
offset_Text_Hnd gequ $0E
offset_Text_FamilyID gequ $12
offset_Text_FontSize gequ $14
offset_Text_FontStyle gequ $16
offset_Text_ForeColor gequ $18
offset_Text_BackColor gequ $1A
TrStartUp gequ $9101
TrShutDown gequ $9102
TrRead gequ $9103
BFProgress gequ $9018
bffText gequ 1
bfContinue gequ 0
bfDone gequ $8000
bfUserAbort gequ $8001
bfBadFileErr gequ $8002
bfReadErr gequ $8003
bfWriteErr gequ $8004
bfMemErr gequ $8005

44
bfish.rez Normal file
View File

@ -0,0 +1,44 @@
#define rTrData $5472
// Flags
#define bf320 $0001
#define bf640 $0002
#define bfCanImport $0001
#define bfCanExport $0001
#define bfImportOptions $0002
#define bfExportOptions $0002
// DataKinds
#define bffNoData $00
#define bggText $01
//Translator IDs
#define TrVersion $0001 //rVersion
#define TrAbout $0001 //rComment
#define TrCantLauch $0002
#define TrData $0001 //rTrData
#define TrInit $0001 //rCodeResource
#define TrImportOptions $0002 //rCodeResource
#define TrExportOptions $0003
#define TrFilter $0004
#define TrImportInfo $0002 //rText
#define TrExportInfo $0003 //rText
type rTrData
{
_mybase_ integer = 0; //revision
_mybase_ integer; //general flags
_mybase_ integer; //Import Flags
array[8]
{
hex byte; //Import Kinds
};
_mybase_ integer; //Export Flags
array[8]
{
hex byte; //Export Kinds
};
};

103
filter.asm Normal file
View File

@ -0,0 +1,103 @@
;
; BabelFish AppleSoft Translator
;
; by Kelvin W Sherlock September 1998
;
;
offset_fType gequ 16
offset_eof gequ 18
offset_aType gequ 44
BAS_FTYPE gequ $FC
BAS_ATYPE gequ $0801
; SFFilter
;
; in stack:
;
; (3) |rtl
; |----
; (4) |DirEntryRecPtr
; |----
; (2) |returnval
; |----
; |.........
; out stack:
;
; |returnval
; |----
; |.........
;
; Returns 0 if it's not an Applesoft File, or 4 if it is.
;
SFFilter START
_d equ 1
_rtlb equ 3
DirPtr equ 7
retval equ 11
phb ;even up the stack
phd
tsc
tcd
stz <retval ;; assume no
;
; Check the FileType
;
ldy #offset_fType
lda [<DirPtr],y
cmp #BAS_FTYPE
bne exit
;
; Check the size (s/b < 65,536 bytes
;
ldy #offset_eof+2
lda [<DirPtr],y
bne exit
;
; Make sure it HAS a size (must be >2 :-)
;
dey
dey
lda [<DirPtr],y
cmp #3
bcc exit
;
; Check the auxtype
;
ldy #offset_aType+2
lda [<DirPtr],y
cmp #^BAS_ATYPE
bne exit
dey
dey
lda [<DirPtr],y
cmp #BAS_ATYPE
bne exit
lda #4
sta <retval ;; I handle it
exit pld
pla
sta 3,s
pla
sta 3,s
plb
rtl
END

1402
init.asm Normal file

File diff suppressed because it is too large Load Diff

7
install Normal file
View File

@ -0,0 +1,7 @@
compile token.c keep=token
compile init.asm keep=init
link init token keep=init
cmpl filter.asm keep=filter
compile asoft.rez keep=AppleSoft
filetype AppleSoft $be $4003
copy -C AppleSoft *:system:SHS.Babelfish:

10
src.notes Normal file
View File

@ -0,0 +1,10 @@
creating the applesoft translator requires:
ORCA/C (used ONLY to facilitate data creation)
ORCA/M
REZ
It should be VERY trivial to convert this into an Integer Basic importer.
Importing GSoft Basic files is slightly more complex, but not much. See
the GSoft book Appendices.
the "install" script will compile & install translator.

173
token.c Normal file
View File

@ -0,0 +1,173 @@
#pragma noroot
/*
* Structure for holding the length of the token
* and a pointer to the token (a cstring)
*
* this is in C because it is MUCH easier to do the data storage this way.
* MUCH easier.
*
*/
struct info
{
unsigned long length; /* by being a long, */
char *token; /* indexing the array = multiplying by 8 */
}; /* simple! */
/*
* Macro for extracting the length of a string and
* storing a pointer to it.
*
* sizeof(string) includes the trailing NULL character,
* so subtracting 1 accounts for that
*/
#define LIST(x) \
{ \
sizeof(x) - 1, \
x \
}
/*
* Here it is - all the tokens !
*
*/
struct info TOKENS[] =
{
/* $80 */
LIST(" END "),
LIST(" FOR "),
LIST(" NEXT "),
LIST(" DATA "),
LIST(" INPUT "),
LIST(" DEL "),
LIST(" DIM "),
LIST(" READ "),
LIST(" GR "),
LIST(" TEXT "),
LIST(" PR# "),
LIST(" IN# "),
LIST(" CALL "),
LIST(" PLOT "),
LIST(" HLIN "),
LIST(" VLIN "),
/* $90 */
LIST(" HGR2 "),
LIST(" HGR "),
LIST(" HCOLOR= "),
LIST(" HPLOT "),
LIST(" DRAW "),
LIST(" XDRAW "),
LIST(" HTAB "),
LIST(" HOME "),
LIST(" ROT= "),
LIST(" SCALE= "),
LIST(" SHLOAD "),
LIST(" TRACE "),
LIST(" NOTRACE "),
LIST(" NORMAL "),
LIST(" INVERSE "),
LIST(" FLASH "),
/* $A0 */
LIST(" COLOR= "),
LIST(" POP "),
LIST(" VTAB "),
LIST(" HIMEM: "),
LIST(" LOMEM: "),
LIST(" ONERR "),
LIST(" RESUME "),
LIST(" RECALL "),
LIST(" STORE "),
LIST(" SPEED= "),
LIST(" LET "),
LIST(" GOTO "),
LIST(" RUN "),
LIST(" IF "),
LIST(" RESTORE "),
LIST(" & "),
/* $B0 */
LIST(" GOSUB "),
LIST(" RETURN "),
LIST(" REM "),
LIST(" STOP "),
LIST(" ON "),
LIST(" WAIT "),
LIST(" LIST "),
LIST(" SAVE "),
LIST(" DEF "),
LIST(" POKE "),
LIST(" PRINT "),
LIST(" CONT "),
LIST(" LIST "),
LIST(" CLEAR "),
LIST(" GET "),
LIST(" NEW "),
/* $C0 */
LIST(" TAB( "),
LIST(" TO "),
LIST(" FN "),
LIST(" SPC( "),
LIST(" THEN "),
LIST(" AT "),
LIST(" NOT "),
LIST(" STEP "),
LIST(" + "),
LIST(" - "),
LIST(" * "),
LIST(" / "),
LIST(" ^ "),
LIST(" AND "),
LIST(" OR "),
LIST(" > "),
/* $D0 */
LIST(" = "),
LIST(" < "),
LIST(" SGN "),
LIST(" INT "),
LIST(" ABS "),
LIST(" USR "),
LIST(" FRE "),
LIST(" SCRN( "),
LIST(" PDL "),
LIST(" POS "),
LIST(" SQR "),
LIST(" RND "),
LIST(" LOG "),
LIST(" EXP "),
LIST(" COS "),
LIST(" SIN "),
/* $E0 */
LIST(" TAN "),
LIST(" ATN "),
LIST(" PEEK "),
LIST(" LEN "),
LIST(" STR$ "),
LIST(" VAL "),
LIST(" ASC "),
LIST(" CHR$ "),
LIST(" LEFT$ "),
LIST(" RIGHT$ "),
LIST(" MID$ "),
/* $EB */
LIST(" ???? "), /* these aren't used by AppleSoft */
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
LIST(" ???? "),
};