mirror of
https://github.com/gungwald/prodos-more.git
synced 2024-11-26 04:49:17 +00:00
Added reading from file
This commit is contained in:
parent
c044ae5548
commit
36e58cde89
2
Makefile
2
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)
|
||||
|
55
more.s
55
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
|
||||
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
|
||||
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user