; ; AppleSoft BASIC BabelFish importer 1.0 ; by Kelvin Sherlock ; ; For educational purposes only ; ; case off mcopy init.mac copy 13:Ainclude:e16.gsos copy bfish.equ BAS_FTYPE gequ $FC BAS_ATYPE gequ $0801 SHASTON_ID gequ $fffe ; ; This is the entry point. ; init START using global phb phk plb ; ; Get my memory manager ID ; pha _MMStartUp pla sta MyID ; ; convert it to english & tack on to the end of my request name ; pha ;; MyID pea MyName|-16 pea MyName+28 pea 4 _Int2Hex ; ; Accept Requests ; pea MyName|-16 pea MyName lda MyID pha pea RequestH|-16 pea RequestH _AcceptRequests ; ; leave (for now) ; plb rtl init END global DATA MyName pstr "Babelfish~Kelvin~ASoftTransXXXX" BName pstr "Seven Hills~Babelfish~" CalcStr pstr "Calculating Space Requirements" TokeStr pstr "Detokenizing file" DoneStr pstr "Done!" InRec ds 4 OutRec ds 4 ;; space for BFProgress MyID ds 2 Active ds 2 Done ds 2 FileHandle ds 4 ; ; Text Record ; Text_pCount dc i2'10' Text_ActionCode ds 2 Text_ResponseCode ds 2 Text_Length ds 4 Text_Ptr ds 4 Text_Hnd ds 4 Text_FamilyID dc i2'SHASTON_ID' Text_FontSize dc i2'8' Text_FontStyle dc i2'0' Text_ForeColor dc i2'0' Text_BackColor dc i2'$ffff' OpenDCB anop OpenDCB_pcount dc i2'15' OpenDCB_refNum ds 2 OpenDCB_pathName dc i4'0' OpenDCB_requestAccess ds 2 OpenDCB_resourceNumber dc i2'0' OpenDCB_access ds 2 OpenDCB_fileType ds 2 OpenDCB_auxtype ds 4 OpenDCB_storageType ds 2 OpenDCB_createDateTime ds 8 OpenDCB_modDateTime ds 8 OpenDCB_optionList ds 4 OpenDCB_dataEOF ds 4 OpenDCB_blocksUsed ds 4 OpenDCB_resourceEOF ds 4 OpenDCB_resourceBlocks ds 4 ; ; for reading/writing data ; IODCB anop IODCB_pcount dc i2'5' IODCB_refNum ds 2 IODCB_dataBuffer ds 4 IODCB_requestCount ds 4 IODCB_transferCount ds 4 IODCB_cachePriority dc i4'0' CloseDCB dc i2'1' CloseDCB_refnum ds 2 global END ; ; Request Handler (called by application via bfish via toolbox) ; ; in stack out stack ; |------------ |----------- ; | result | result 0 = not accepted, $8000 = accepted ; |------------ |----------- ; | request ; |------------ ; | ; | DataIn ; | ; |------------ ; | ; | DataOut ; | ; |------------ ; | ; | rtl ; |------------ RequestH START using Global result equ 17 reqCode equ 15 dataIn equ 11 dataOut equ 7 _rtlb equ 3 _d equ 1 phb phk plb phd tsc tcd ; ; this should be zeroed already, but better safe than sorry ; stz Ptr ; ldy #2 lda [OutPtr],y tax lda [OutPtr] stax $7f, is a token, ; byte 0 - eol CalcLength START _d equ 1 size equ 3 _rts equ 7 Ptr equ 9 pha pha phd tsc tcd stz destination, NOT including the NULL char ; CopyT START _d equ 1 _rts equ 3 dest equ 5 src equ 9 phd tsc tcd ldy #0 short m loop lda [src],y beq done sta [dest],y iny bra loop done anop long m tya pld rts END ; ; Tack 4 0 bytes to the end of a ptr ; a = length of the ptr ; stack (4 bytes) = ptr itself. Append0 START _d equ 1 _rts equ 3 Ptr equ 5 tax ;;save phd tsc tcd txa ;;restore clc adc