[Coco] ML Disk I/O examples?
Bob Devries
devries.bob at gmail.com
Tue Apr 17 00:06:14 EDT 2007
Here's the companion READ routine:
;routine to read $1800 bytes from a disk file "GRAPHICS.DAT"
;some equates
DNAMBF equ $094C
DEXTBF equ $0954
DFLTYP equ $0957
DASCFL equ $0958
OPENO equ $CA04
OPENI equ $CA07
CONSOUT equ $CC24
CONSIN equ $C5C4
FCLOSE equ $CAF9
ERRVEC equ $018E
;end of equates
ORG $6000
dskread lda [ERRVEC]
sta errvec1,pcr
ldx [ERRVEC+1]
stx errvec2,pcr
lda #$7E ;jump instruction
sta ERRVEC
leax error,pcr
stx ERRVEC+1
picfil leax filename,pcr ;point to filename
ldb #8 ;8 characters
ldy #DNAMBF
namlop lda ,x+
sta ,y+
decb
bne namlop
leax exten,pcr ;point to extension
ldb #3 ;3 characters
ldy #DEXTBF
extlop lda ,x+
sta ,y+
decb
bne extlop
;name is now stored
jsr OPENI
;the file number will be stored in DEVNUM ($006E)
ldx #$0E00
ldy #$1800
readlop jsr CONSIN
sta ,x+
leay -1,y
bne readlop
;file data has been read
error jsr FCLOSE
;and file is closed
lda errvec1,pcr
sta ERRVEC
ldx errvec2,pcr
stx ERRVEC+1
;restored error vector
rts
;return to BASIC
filename fcc /GRAPHICS/
exten fcc /DAT/
errvec1 rmb 1
errvec2 rmb 2
end dskread
--
Regards, Bob Devries, Dalby, Queensland, Australia
Isaiah 50:4 The sovereign Lord has given me
the capacity to be his spokesman,
so that I know how to help the weary.
website: http://www.home.gil.com.au/~bdevasl
my blog: http://bdevries.invigorated.org/
More information about the Coco
mailing list