A2osX/ProDOS.FX/ProDOS.S.ILDR.txt
2023-11-04 15:42:28 +01:00

433 lines
7.8 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
*--------------------------------------
devid .EQ $12
src .EQ $12
dst .EQ $14
*--------------------------------------
ILDR.DBuf .EQ $0C00
ILDR.IOBuf .EQ $1400
*--------------------------------------
ILDR.START .PH ILDR
ILDR.START1 jsr MLI check for file 'atinit'
.DA #MLI.GFINFO
.DA ILDR.GFINFO
bcs ILDR.ENUMPM
lda ILDR.GFINFO+S.FI.T
cmp #$E2 is 'atinit' correct file type?
bne ILDR.ENUMPM error - wrong file type
ldy #ILDR.ATINIT
lda /ILDR.ATINIT
jsr ILDR.LoadFile
bcc .1
.9 jmp ILDR.MLIERR
.1 lda IO.RROMBNK2 enable ROM
jsr $2000 execute ATinit
*--------------------------------------
* BOOT block read 4 directory blocks at dbuf=$C00 -> $13FF
*--------------------------------------
ILDR.ENUMPM .DO READCAT=1
lda LDR.MLIOL.P+1 Boot ZP.UNITNUM
sta ILDR.MLIRB.P+1
stz dst
lda /ILDR.DBuf
ldy #$02 read directory into buffer
ldx #0
.22 sta dst+1
sta ILDR.MLIRB.P+3 Data buf HI
sty ILDR.MLIRB.P+4 Blk Num LO
stx ILDR.MLIRB.P+5 Blk Num HI
jsr MLI
.DA #MLI.READBLOCK
.DA ILDR.MLIRB.P
bcc .23
jmp ILDR.MLIERR
.23 ldy #$03 get next block# from link
lda (dst),y
tax
dey
ora (dst),y 00 00 -> Last Block
beq .28
lda (dst),y
tay
lda dst+1
inc
inc add $200 to buffer pointer
cmp /ILDR.DBuf+$800 until it points past end of buffer.
bcc .22 if ok, read next block.
.28 .FIN
*--------------------------------------
.DO M.PM=1
jsr ILDR.EnumInit
.1 ldx #S.FI.T.BIN
ldy #ILDR.PMPFX
lda /ILDR.PMPFX
clc prefix
jsr ILDR.EnumNext
bcs .8
jsr ILDR.LoadFilePBuf
bcs ILDR.MLIERR
ldx #3
.2 lda idxl,x
pha
dex
bpl .2
jsr $2000
bit IO.RROMBNK2 enable ROM
ldx #0
.3 pla
sta idxl,x
inx
cpx #4
bne .3
>DEBUGOA
bra .1
.8 .FIN
*--------------------------------------
jsr ILDR.EnumInit
ldx #S.FI.T.SYS
ldy #ILDR.SYSTEMSFX
lda /ILDR.SYSTEMSFX
sec suffix
jsr ILDR.EnumNext
bcs .9
jsr ILDR.LoadFilePBuf
bcs ILDR.MLIERR
bit IO.RROMBNK2 enable ROM
bit IO.RDIOUDIS
sta IO.SETIOUDIS
sta IO.CLRDHIRES
bmi .5
sta IO.CLRIOUDIS
.5 sta IO.CLR80DISP
sta IO.CLR80STORE
sta IO.SETTEXT
sta IO.CLRMIXED
jsr ROM.INIT
jsr ROM.SETVID
jsr ROM.SETKBD
jsr ROM.HOME
jmp $2000 go run interpreter
.9 jsr MLI no .SYSTEM found, so quit.
.DA #MLI.QUIT
.DA ILDR.QUIT
*--------------------------------------
ILDR.MLIERR cmp #MLI.E.BADBUF
bne .1
ldx #ILDR.MSG.SYSTOOLARG-ILDR.MSG
.HS 2C BIT ABS
.1 ldx #ILDR.MSG.SYSLOADERR-ILDR.MSG
bit IO.RROMBNK2
jsr ROM.SETINV
.2 lda ILDR.MSG,x
pha
ora #$80
jsr ROM.COUT
inx
pla
bpl .2
lda #$A0
jsr ROM.COUT
ldy #0
.3 iny
lda LDR.PBuf,y
jsr ROM.COUT
cpy LDR.PBuf
bne .3
bra *
*--------------------------------------
ILDR.EnumInit lda /ILDR.DBuf search directory buffer
sta idxl+1
lda #ILDR.DBuf+4 skip Prev/next Block Ptr
sta idxl
lda ILDR.DBuf+35 EL
sta ILDR.EL
lda ILDR.DBuf+36 EPB
sta ILDR.EPB
sta ILDR.EITB
lda ILDR.DBuf+37 FCLO
eor #$ff
sta ILDR.nFC
lda ILDR.DBuf+38 FCHI
eor #$ff
sta ILDR.nFC+1
ILDR.EnumInit.RTS
rts
*--------------------------------------
* X = expected FileType
* Y,A = expected prefix/suffix
*--------------------------------------
ILDR.EnumNext stx ILDR.FT
sty src
sta src+1
ror ILDR.bPFXSFX
.1 inc ILDR.nFC
bne .2
inc ILDR.nFC+1
sec
beq ILDR.EnumInit.RTS
.2 dec ILDR.EITB
beq .3
lda idxl
clc
adc ILDR.EL
sta idxl
bcc .4 same page
inc idxl+1 512b block, 2nd page
bra .4
.3 inc idxl+1
lda idxl+1
cmp #$14 last block read at $0C00-$13FF
bcs ILDR.EnumInit.RTS
lda #4
sta idxl
lda ILDR.EPB
sta ILDR.EITB
.4 lda (idxl)
beq .2 deleted / empty
bmi .1 $D, $E, or $F...
and #$0F
sta LDR.PBuf filename Len
tay
.5 lda (idxl),y
sta LDR.PBuf,y
dey
bne .5
ldy #16
lda (idxl),y
cmp ILDR.FT expected file type
bne .1
lda (src) expected prefix/suffix len
cmp LDR.PBuf
bcs .1 filename LE prefix/suffix
bit ILDR.bPFXSFX
bpl .12 go check prefix
tay
ldx LDR.PBuf
.11 lda LDR.PBuf,x
eor (src),y
asl
bne .1
dex
dey
bne .11
bra .15
.12 lda (src) expected prefix/suffix len
tay
.13 lda LDR.PBuf,y
eor (src),y
asl
bne .1
dey
bne .13
.15 ldy #$1D MIN_VERSION
lda (idxl),y
bpl .10 no lowercase information
ldx LDR.PBuf
.6 cpx #8 CS if MIN_VERSION to use
bcs .7
ldy #$1D MIN_VERSION
lda (idxl),y
and ILDR.LCBits,x
bne .8
bra .9
.7 ldy #$1C VERSION
lda (idxl),y
and ILDR.LCBits-8,x
beq .9
.8 lda LDR.PBuf,x
eor #$20 to lowercase
sta LDR.PBuf,x
.9 dex
bne .6
.10 clc
rts
*--------------------------------------
ILDR.LoadFilePBuf
ldy #LDR.PBuf
lda /LDR.PBuf
ILDR.LoadFile sty ILDR.OPEN+1 Filename
sta ILDR.OPEN+2
jsr MLI
.DA #MLI.OPEN
.DA ILDR.OPEN
bcs .9
jsr MLI
.DA #MLI.GETEOF
.DA ILDR.GETEOF
bcs .9
lda ILDR.GETEOF+4
bne .99
lda ILDR.GETEOF+3
cmp #$9F
bcc .1
bne .99 more than $9Fxx
lda ILDR.GETEOF+2
bne .99 more than $9F00
.1
jsr MLI
.DA #MLI.READ
.DA ILDR.READ
bcs .9
jsr MLI
.DA #MLI.CLOSE
.DA ILDR.CLOSE
.9 rts
.99 lda #MLI.E.BADBUF
sec
rts
*--------------------------------------
ILDR.MSG .EQ *
ILDR.MSG.SYSLOADERR .AT "Unable to load"
ILDR.MSG.SYSTOOLARG .AT "Too Large"
ILDR.LCBits .HS 8040201008040201
*--------------------------------------
ILDR.GFINFO .DA #10 PARAM CNT
.DA ILDR.ATINIT
.BS S.FI-3
*--------------------------------------
.DO READCAT=1
ILDR.MLIRB.P .DA #3
.DA #0 unit number
.DA 0 2 byte data buffer
.DA 0 2 byte block number
.FIN
*--------------------------------------
ILDR.OPEN .DA #3 PARAM CNT
.BS 2 Filename
.DA ILDR.IOBuf
.HS 01 REF
*--------------------------------------
ILDR.GETEOF .DA #2 PARAM CNT
.DA #01 REF
.HS 000000
*--------------------------------------
ILDR.READ .DA #4 PARAM CNT
.HS 01 REF
.DA $2000
.DA $9F00 Max file size
.HS 0000
*--------------------------------------
ILDR.CLOSE .DA #1 PARAM CNT
.HS 01 REF
*--------------------------------------
ILDR.QUIT .DA #4 PARAM CNT
.HS 00
.HS 0000
.HS 00
.HS 0000
*--------------------------------------
ILDR.ATINIT .PS "ATINIT"
.DO M.PM=1
ILDR.PMPFX .PS "PM."
.FIN
ILDR.SYSTEMSFX .PS ".SYSTEM"
*--------------------------------------
.DUMMY
ILDR.EPB .BS 1
ILDR.EL .BS 1
ILDR.nFC .BS 2
ILDR.FT .BS 1
ILDR.EITB .BS 1
ILDR.bPFXSFX .BS 1
.ED
*--------------------------------------
.EP
*--------------------------------------
ILDR.LEN .EQ *-ILDR.START
*--------------------------------------
MAN
SAVE usr/src/prodos.fx/prodos.s.ildr
LOAD usr/src/prodos.fx/pdos8m.s
ASM