From 36e58cde89061aec1ac634a1b9c4496a67a436da Mon Sep 17 00:00:00 2001 From: Bill Chatfield Date: Mon, 28 Jan 2019 01:00:09 -0500 Subject: [PATCH] Added reading from file --- Makefile | 2 +- more.s | 55 ++++++++++++++++++++++++++++++++++++++---- prodos-2.0.3-boot.dsk | Bin 143360 -> 143360 bytes 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 6f019ba..fd1f62f 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ DSK=$(PGM).dsk $(DSK): $(PGM) $(COPY) $(BASE_DSK) $(DSK) - $(AC) -p $(DSK) $(PGM) BIN 0x0800 < $(PGM) + $(AC) -p $(DSK) $(PGM) BIN 0x8000 < $(PGM) $(PGM): $(SRC) Makefile merlin32 --verbose $(SRC) diff --git a/more.s b/more.s index 2b78756..3265362 100644 --- a/more.s +++ b/more.s @@ -24,11 +24,14 @@ MLI equ $bf00 * ProDOS system call command codes OPEN equ $c8 +READ equ $ca CLOSE equ $cc * Constants +EOF equ $4c ; End of file ADDR equ $06 MAX_EC equ $5a ; The largest error code +CR equ $0d ; Carriage return WRITE_CHAR mac @@ -86,20 +89,47 @@ COPY_BYTE mac sta ]2 eom +* Starting at $9000 because: +* $800 overwrites Applesoft +* $803 is where Applesoft programs start +* $2000 is where the current .SYSTEM program is loaded mainProgram - org $800 + org $8000 lda #fileName sta oPathPtr+1 - jsr MLI +openFile jsr MLI db OPEN da openParams bne openErrorHandler - pmc COPY_BYTE,fileNum;closeNum + +readFile pmc COPY_BYTE,fileNum;readNum +readNext jsr MLI + db READ + da readParams + cmp #EOF + beq closeFile + cmp #0 + bne readErrorHandler + +writeScreen + ldy #0 + sty lineCount + sty charCount +nextChar lda readIoBuf,y + jsr COUT + cmp $0d + bne continue + inc lineCount +continue inc charCount + iny + jmp nextChar + +closeFile pmc COPY_BYTE,fileNum;closeNum jsr MLI db CLOSE dw closeParams @@ -109,6 +139,10 @@ openErrorHandler sta errorCode pmc WRITE_ASC,openFailureText jmp errorHandler +readErrorHandler + sta errorCode + pmc WRITE_ASC,readFailureText + jmp errorHandler closeErrorHandler sta errorCode pmc WRITE_ASC,closeFailureText @@ -152,17 +186,26 @@ endMain openParams db 3 ; Parameter count oPathPtr ds 2 ; Input param - file to open -oBufPtr da inBuf ; Input param - I/O buffer +oBufPtr da openIoBuf ; Input param - I/O buffer fileNum ds 1 ; Output param - file ref num +readParams db 4 +readNum ds 1 + da readIoBuf +reqCount dw 512 +transCount ds 2 + closeParams db 1 ; Parameter count closeNum db 0 ; Input param - ref num to close fileName db 4 asc "BLAH" +charCount ds 2 + errorCode db 0 openFailureText asc "FAILED TO OPEN FILE ",00 +readFailureText asc "FAILED TO READ FILE ",00 closeFailureText asc "FAILED TO CLOSE FILE ",00 errorCodeText asc "(ERROR CODE ",00 @@ -265,6 +308,7 @@ ec3d da $0000 ec3e da $0000 ec3f da $0000 ec40 da em40 +ec41 da $0000 ec42 da em42 ec43 da $0000 ec44 da em44 @@ -297,5 +341,6 @@ filler ds \,$00 * * Must start on page boundary * -inBuf ds 1024 +openIoBuf ds 1024 +readIoBuf ds 512 diff --git a/prodos-2.0.3-boot.dsk b/prodos-2.0.3-boot.dsk index 6a298cacc32590d527f068fcf83e8c4301b91be9..b3aa6369f11dc940b40af4b8517bcbaaaa2fabee 100644 GIT binary patch delta 133 zcmZp8z|ru4V*?vAqy1)fW;qTFmnu W66)>h$Ge?zBI8-6rh;V!j0XTB1Rk;g delta 382 zcmZp8z|ru4V*?vAWBq1!W;qT<=E-W@RjLgBemm z0*JBsD7STjnsO`0iJg|pt(+@YD7^hU!(#!%MvjvVAJ~DM6Fx$U87o$<1Tv>9er8mh zEWot0UV&l%QFWyc%s$%`R;stMtyFAfU#q8dQs4r!&sGJXX10?IaHeL1gck&4GWKdK zfn+rcKmxrw5DtH@uF}fOK=aq?C`n{)05Vpt0TD+)LfSB)1wh^chBLZK7kEz8Z)8(A zprFwA*Jp{s%Jm=##*J*84L}A^{sYSipNSyJcX~=o*(5RrTG=KrJ!AI~R!9J8vic8{ zO6b*BTEwt`VXeN>T|?y$`Y%qLcvGol@B!}qoheFi|36U3SOHY1aO*EP6nxYanRZ$( OPW;ByRIsdo@c;mOu$M~!