2020-05-08 21:02:27 +02:00
|
|
|
|
NEW
|
|
|
|
|
AUTO 3,1
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* prodos universal boot loader. this is the second stage boot
|
|
|
|
|
* for all apple manufactured apple ii disk drives.
|
|
|
|
|
* it is located at block zero (0) of a prodos or sos formatted
|
|
|
|
|
* disk(ette). if booted in apple /// native mode, the regular
|
|
|
|
|
* sos boot will be attempted.
|
|
|
|
|
*--------------------------------------
|
2020-05-12 17:17:25 +02:00
|
|
|
|
dcmd .EQ $42 disk command (=1 for read)
|
|
|
|
|
unit .EQ $43 (16*slot)+(128*(drive-1))
|
|
|
|
|
buff .EQ $44 ram address
|
|
|
|
|
blok .EQ $46 disk address
|
|
|
|
|
dent .EQ $48 device call entry address
|
|
|
|
|
idxl .EQ $4a pointer to low page of index block
|
|
|
|
|
idxh .EQ $4c pointer to high page of index block
|
|
|
|
|
idxp .EQ $4e index byte pointer
|
2020-05-13 19:00:37 +02:00
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
iobuff .EQ $60
|
|
|
|
|
* the following are for disk ii only
|
|
|
|
|
dbuf .EQ $26
|
|
|
|
|
slotz .EQ $2b
|
|
|
|
|
oddbits .EQ $3c
|
|
|
|
|
sector .EQ $3d
|
|
|
|
|
|
2020-05-13 19:00:37 +02:00
|
|
|
|
BB.RetryCnt .EQ $40
|
2020-05-12 17:17:25 +02:00
|
|
|
|
BB.TargetTrk .EQ $41
|
|
|
|
|
|
2020-05-13 19:00:37 +02:00
|
|
|
|
BB.CurQTrk .EQ $50
|
2020-05-12 17:17:25 +02:00
|
|
|
|
BB.TargetQTrk .EQ $51
|
2020-05-13 19:00:37 +02:00
|
|
|
|
|
|
|
|
|
BB.HdrPtr .EQ $52
|
2020-05-12 17:17:25 +02:00
|
|
|
|
|
|
|
|
|
BB.Hdr .EQ $54
|
|
|
|
|
BB.HdrTrk .EQ $55
|
|
|
|
|
BB.HdrVol .EQ $56
|
|
|
|
|
BB.Hdr96 .EQ $57
|
|
|
|
|
|
|
|
|
|
nbuf1 .EQ $300
|
|
|
|
|
dnib .EQ $2d6
|
|
|
|
|
|
|
|
|
|
clrscrn .EQ $fc58
|
|
|
|
|
scrn .EQ $5b6
|
|
|
|
|
sosid .EQ $c00
|
|
|
|
|
entlen .EQ sosid+$23
|
|
|
|
|
kernel .EQ $2000
|
2020-05-08 21:02:27 +02:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.PH $800
|
|
|
|
|
xboot .DA #1
|
2020-05-13 19:00:37 +02:00
|
|
|
|
sec apple iii enters xboot 'ora $38'
|
|
|
|
|
bcs BB.AppleII branch if not apple iii native mode
|
2020-05-12 17:17:25 +02:00
|
|
|
|
*--------------------------------------
|
2020-05-13 19:00:37 +02:00
|
|
|
|
BB.AppleIII lda #$9f make apple iii boot using block 1
|
2020-05-12 17:17:25 +02:00
|
|
|
|
pha the return address is $a000
|
|
|
|
|
lda #$ff
|
|
|
|
|
pha
|
|
|
|
|
|
2020-05-13 19:00:37 +02:00
|
|
|
|
inc
|
|
|
|
|
tax ldx #0
|
|
|
|
|
|
|
|
|
|
inc lda #1 (read block 1)
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
jmp $f479
|
|
|
|
|
*--------------------------------------
|
2020-05-13 19:00:37 +02:00
|
|
|
|
BB.AppleII stx unit save unit number
|
2020-05-12 17:17:25 +02:00
|
|
|
|
cmp #$03 for disk ii
|
|
|
|
|
php save result, it may be irrelevant
|
|
|
|
|
txa find out if disk ii
|
|
|
|
|
and #$70 strip drive # if any
|
|
|
|
|
lsr
|
|
|
|
|
lsr get slot address
|
|
|
|
|
lsr
|
2020-05-08 21:02:27 +02:00
|
|
|
|
lsr
|
|
|
|
|
ora #$c0
|
2020-05-12 17:17:25 +02:00
|
|
|
|
sta dent+1
|
|
|
|
|
ldy #$ff look at last byte
|
2020-05-08 21:02:27 +02:00
|
|
|
|
sty dent
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
plp restore carry (if disk ii & sect 0&2 read)
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
iny make y=0
|
|
|
|
|
lda (dent),y get device entry addr
|
|
|
|
|
bne ndsk2 branch if not disk ii (16 sector)
|
|
|
|
|
|
|
|
|
|
bcs isdsk2 branch if it is disk ii, but block 0 read
|
|
|
|
|
|
|
|
|
|
lda #3 make rom read only sector 2
|
|
|
|
|
sta xboot to complete block 0
|
2020-05-08 21:02:27 +02:00
|
|
|
|
inc sector was = 1
|
2020-05-13 19:00:37 +02:00
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
lda dent+1 do rts to re-enter rom
|
|
|
|
|
pha
|
2020-05-08 21:02:27 +02:00
|
|
|
|
lda #$5b
|
|
|
|
|
pha
|
|
|
|
|
rts go read sector 2 into $900
|
|
|
|
|
*--------------------------------------
|
2020-05-12 17:17:25 +02:00
|
|
|
|
isdsk2 sta BB.HdrTrk A=0, make sure previous track =0
|
2020-05-08 21:02:27 +02:00
|
|
|
|
sta dent and dent points at beginning of slot
|
2020-05-12 17:17:25 +02:00
|
|
|
|
|
2020-05-08 21:02:27 +02:00
|
|
|
|
ldy #$63 move code from card to ram
|
|
|
|
|
|
|
|
|
|
mvboot lda (dent),y
|
|
|
|
|
sta zzstart-$5e,y
|
|
|
|
|
iny
|
|
|
|
|
cpy #$eb have we moved enough?
|
|
|
|
|
bne mvboot
|
|
|
|
|
|
2020-05-13 19:00:37 +02:00
|
|
|
|
ldx #mods.cnt-1 now modify code to handle errors.
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
|
|
|
|
modboot ldy mods,x
|
|
|
|
|
lda chgs,x
|
|
|
|
|
sta zzstart,y
|
|
|
|
|
dex
|
|
|
|
|
bpl modboot
|
2020-05-12 17:17:25 +02:00
|
|
|
|
|
|
|
|
|
ldx #7
|
|
|
|
|
|
|
|
|
|
modboot2 lda endcode-1,x
|
|
|
|
|
sta zzzend-1,x
|
|
|
|
|
dex
|
|
|
|
|
bne modboot2
|
|
|
|
|
|
|
|
|
|
lda #BB.Hdr
|
|
|
|
|
sta BB.HdrPtr
|
2020-05-13 19:00:37 +02:00
|
|
|
|
stx BB.HdrPtr+1 X=0
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
lda /d2io reset device entry
|
2020-05-08 21:02:27 +02:00
|
|
|
|
sta dent+1 to point at disk ii routines.
|
2020-05-12 17:17:25 +02:00
|
|
|
|
lda #d2io get low addr (must be <$80)
|
2020-05-13 19:00:37 +02:00
|
|
|
|
*--------------------------------------
|
2020-05-08 21:02:27 +02:00
|
|
|
|
ndsk2 ldy #0 make sure y=0 again.
|
|
|
|
|
cmp #$f9
|
|
|
|
|
bcs bterr1 branch if not bootable device.
|
|
|
|
|
|
|
|
|
|
sta dent save low adr of device call entry.
|
|
|
|
|
sty iobuff
|
|
|
|
|
sty idxl
|
|
|
|
|
sty idxh y=0
|
|
|
|
|
sty idxp
|
|
|
|
|
sty blok+1
|
|
|
|
|
iny
|
2020-05-12 17:17:25 +02:00
|
|
|
|
sty dcmd set read command.
|
2020-05-08 21:02:27 +02:00
|
|
|
|
iny
|
|
|
|
|
sty blok to read directory blocks
|
|
|
|
|
lda #$c 2-5 at $c00
|
|
|
|
|
sta iobuff+1
|
|
|
|
|
sta idxl+1
|
|
|
|
|
|
|
|
|
|
rddir jsr goread call read block routine.
|
|
|
|
|
bcs bterr2 give up on error.
|
|
|
|
|
|
|
|
|
|
inc iobuff+1
|
|
|
|
|
inc iobuff+1
|
|
|
|
|
inc blok
|
|
|
|
|
lda blok have all directory blocks been read?
|
|
|
|
|
cmp #6
|
|
|
|
|
bcc rddir loop if not.
|
|
|
|
|
|
|
|
|
|
lda sosid is it a prodos (sos) directory?
|
|
|
|
|
ora sosid+1
|
|
|
|
|
bterr1 bne booterr branch if not.
|
|
|
|
|
|
|
|
|
|
lda #4 begin look-up with first entry past header.
|
|
|
|
|
bne nxdent1 branch always
|
|
|
|
|
|
|
|
|
|
nxdent lda idxl
|
|
|
|
|
nxdent1 clc
|
|
|
|
|
adc entlen bump to next directory entry.
|
|
|
|
|
tay save in y for now.
|
|
|
|
|
bcc nxdent2 branch if not a page cross.
|
|
|
|
|
|
|
|
|
|
inc idxl+1
|
|
|
|
|
lda idxl+1 check for new block.
|
|
|
|
|
lsr if even then new block.
|
|
|
|
|
bcs nxdent2
|
|
|
|
|
|
|
|
|
|
cmp #$a have all file names been compared?
|
2020-05-12 17:17:25 +02:00
|
|
|
|
beq booterr branch if no pro.kernel.
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
|
|
|
|
ldy #4 else, begin at block beginning.
|
|
|
|
|
|
|
|
|
|
nxdent2 sty idxl note: this method treats garbage at
|
2020-05-13 19:00:37 +02:00
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
ldy #0
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
|
|
|
|
lookpro lda (idxl),y look for matching name.
|
2020-05-13 19:00:37 +02:00
|
|
|
|
cmp BB.ProDOS,y
|
2020-05-08 21:02:27 +02:00
|
|
|
|
bne nxdent branch if no match.
|
|
|
|
|
|
2020-05-13 19:00:37 +02:00
|
|
|
|
iny
|
|
|
|
|
cpy #7
|
2020-05-12 17:17:25 +02:00
|
|
|
|
bne lookpro
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
|
|
|
|
ldy #$10 get file type & index block addr.
|
|
|
|
|
lda (idxl),y
|
2020-05-12 17:17:25 +02:00
|
|
|
|
cmp #S.FI.T.SYS is it a system file?
|
2020-05-08 21:02:27 +02:00
|
|
|
|
bne booterr
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (idxl),y
|
|
|
|
|
sta blok
|
|
|
|
|
iny
|
|
|
|
|
lda (idxl),y
|
|
|
|
|
sta blok+1
|
2020-05-12 17:17:25 +02:00
|
|
|
|
|
2020-05-08 21:02:27 +02:00
|
|
|
|
lda #0 now set up to read kernel.
|
|
|
|
|
sta idxl
|
2020-05-12 17:17:25 +02:00
|
|
|
|
|
2020-05-08 21:02:27 +02:00
|
|
|
|
ldy #$1e read index block at $1e00 and
|
|
|
|
|
sty idxl+1 kernel at $2000
|
|
|
|
|
sty iobuff+1
|
|
|
|
|
iny
|
|
|
|
|
sty idxh+1
|
|
|
|
|
|
|
|
|
|
rdkernl jsr goread read index block.
|
|
|
|
|
bterr2 bcs booterr
|
|
|
|
|
|
|
|
|
|
inc iobuff+1
|
|
|
|
|
inc iobuff+1
|
2020-05-12 17:17:25 +02:00
|
|
|
|
|
2020-05-08 21:02:27 +02:00
|
|
|
|
ldy idxp get index pointer
|
|
|
|
|
inc idxp bump for next time.
|
|
|
|
|
lda (idxl),y
|
|
|
|
|
sta blok
|
|
|
|
|
lda (idxh),y high disk addr.
|
|
|
|
|
sta blok+1
|
|
|
|
|
ora (idxl),y if both=0 then done.
|
|
|
|
|
bne rdkernl branch if more to read.
|
|
|
|
|
|
|
|
|
|
jmp kernel go execute kernel code.
|
2020-05-12 17:17:25 +02:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
booterr jsr clrscrn clear video
|
2020-05-13 19:00:37 +02:00
|
|
|
|
ldy #BB.MSG.ERR.Len-1
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
2020-05-13 19:00:37 +02:00
|
|
|
|
.1 lda BB.MSG.ERR,y
|
2020-05-12 17:17:25 +02:00
|
|
|
|
sta scrn,y
|
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
|
|
|
|
|
2020-05-14 13:47:46 +02:00
|
|
|
|
jmp $ff69
|
2020-05-12 17:17:25 +02:00
|
|
|
|
*--------------------------------------
|
2020-05-08 21:02:27 +02:00
|
|
|
|
goread lda iobuff
|
|
|
|
|
sta buff
|
|
|
|
|
lda iobuff+1
|
|
|
|
|
sta buff+1
|
|
|
|
|
jmp (dent)
|
|
|
|
|
*--------------------------------------
|
2020-05-12 17:17:25 +02:00
|
|
|
|
mods .DA #mod1,#mod2,#mod3,#mod4,#mod5,#mod6,#mod7,#mod8,#mod8+1,#mod9
|
2020-05-13 19:00:37 +02:00
|
|
|
|
mods.cnt .EQ *-mods
|
2020-05-12 17:17:25 +02:00
|
|
|
|
chgs .DA #chg1,#chg2,#chg3,#chg4,#chg5,#chg6,#chg7,#$91,#BB.HdrPtr,#BB.HdrTrk
|
|
|
|
|
|
|
|
|
|
endcode ldx slotz
|
2020-05-08 21:02:27 +02:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
jmp seek
|
|
|
|
|
*--------------------------------------
|
2020-05-19 15:00:17 +02:00
|
|
|
|
BB.MSG.ERR .AS -"ERROR"
|
2020-05-13 19:00:37 +02:00
|
|
|
|
BB.MSG.ERR.Len .EQ *-BB.MSG.ERR
|
|
|
|
|
BB.ProDOS .DA #$26 $20 = storage type + 6 = "PRODOS" len
|
|
|
|
|
.AS "PRODOS"
|
2020-05-08 21:02:27 +02:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
d2io lda blok figure out track & sector.
|
|
|
|
|
and #7 strip track for now.
|
|
|
|
|
cmp #4
|
|
|
|
|
and #3
|
|
|
|
|
php
|
|
|
|
|
asl
|
|
|
|
|
plp
|
|
|
|
|
rol now we have the first sector of block.
|
|
|
|
|
sta sector
|
2020-05-12 17:17:25 +02:00
|
|
|
|
|
2020-05-08 21:02:27 +02:00
|
|
|
|
lda blok+1 get high block #
|
|
|
|
|
lsr shift hi addr to carry.
|
|
|
|
|
lda blok now figure track #
|
|
|
|
|
ror
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
2020-05-12 17:17:25 +02:00
|
|
|
|
sta BB.TargetTrk
|
|
|
|
|
|
|
|
|
|
jsr BB.Trk2Qtrk
|
|
|
|
|
sta BB.TargetQTrk
|
|
|
|
|
|
2020-05-08 21:02:27 +02:00
|
|
|
|
lda buff+1
|
2020-05-12 17:17:25 +02:00
|
|
|
|
sta dbuf+1
|
|
|
|
|
|
2020-05-08 21:02:27 +02:00
|
|
|
|
ldx slotz
|
2020-05-12 17:17:25 +02:00
|
|
|
|
lda IO.D2.DrvOn,x
|
|
|
|
|
|
2020-05-08 21:02:27 +02:00
|
|
|
|
jsr rdsector go read sector.
|
2020-05-12 17:17:25 +02:00
|
|
|
|
|
2020-05-08 21:02:27 +02:00
|
|
|
|
inc dbuf+1 bump address
|
|
|
|
|
inc sector
|
|
|
|
|
inc sector and sector #
|
|
|
|
|
bcs quitrd branch if error.
|
2020-05-12 17:17:25 +02:00
|
|
|
|
|
2020-05-08 21:02:27 +02:00
|
|
|
|
jsr rdsector
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
quitrd ldy IO.D2.DrvOff,x
|
2020-05-08 21:02:27 +02:00
|
|
|
|
erretrn rts return error status in carry.
|
2020-05-12 17:17:25 +02:00
|
|
|
|
*--------------------------------------
|
2020-05-08 21:02:27 +02:00
|
|
|
|
rdsector .EQ * do seek then read sector.
|
|
|
|
|
*
|
2020-05-12 17:17:25 +02:00
|
|
|
|
seek lda BB.HdrTrk get track we're on
|
|
|
|
|
jsr BB.Trk2Qtrk
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
sta BB.CurQTrk
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
.1 lda BB.CurQTrk
|
|
|
|
|
cmp BB.TargetQTrk
|
|
|
|
|
beq seekend
|
|
|
|
|
|
|
|
|
|
bcs .2 move out, not in
|
|
|
|
|
|
|
|
|
|
inc
|
|
|
|
|
|
|
|
|
|
.HS B0 BCS
|
|
|
|
|
|
|
|
|
|
.2 dec
|
|
|
|
|
|
|
|
|
|
sta BB.CurQTrk
|
|
|
|
|
|
|
|
|
|
jsr BB.PhaseOn
|
|
|
|
|
|
2020-05-19 22:53:03 +02:00
|
|
|
|
lda #35
|
2020-05-12 17:17:25 +02:00
|
|
|
|
jsr BB.MSWait Trash X
|
|
|
|
|
|
|
|
|
|
ldx slotz
|
|
|
|
|
lda IO.D2.Ph0Off,x
|
|
|
|
|
lda IO.D2.Ph1Off,x
|
|
|
|
|
lda IO.D2.Ph2Off,x
|
|
|
|
|
lda IO.D2.Ph3Off,x
|
2020-05-19 15:00:17 +02:00
|
|
|
|
bra .1 65c02
|
2020-05-12 17:17:25 +02:00
|
|
|
|
*--------------------------------------
|
2020-05-19 15:00:17 +02:00
|
|
|
|
BB.PhaseOn bit #1 1,3,5,7 ?
|
|
|
|
|
beq .7
|
|
|
|
|
|
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
bcs .1 move out,start by+1
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
jsr .7
|
2020-05-19 15:00:17 +02:00
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
pla
|
2020-05-19 15:00:17 +02:00
|
|
|
|
|
|
|
|
|
.1 inc 2,4,6,0
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
2020-05-19 15:00:17 +02:00
|
|
|
|
jsr .7
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
2020-05-19 15:00:17 +02:00
|
|
|
|
bcc BB.MSWait.RTS
|
|
|
|
|
|
|
|
|
|
pla
|
2020-05-12 17:17:25 +02:00
|
|
|
|
|
|
|
|
|
.7 and #6 mask for 0,2,4,6
|
|
|
|
|
ora slotz Slot $n0
|
|
|
|
|
tax
|
|
|
|
|
lda IO.D2.Ph0On,x turn on one phase
|
2020-05-19 15:00:17 +02:00
|
|
|
|
lda #1
|
2020-05-12 17:17:25 +02:00
|
|
|
|
*--------------------------------------
|
2020-05-19 15:00:17 +02:00
|
|
|
|
BB.MSWait php
|
|
|
|
|
sec (6) JSR (2)
|
2020-05-12 17:17:25 +02:00
|
|
|
|
|
2020-05-19 15:00:17 +02:00
|
|
|
|
.1 ldx #19 (2)
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
2020-05-13 19:00:37 +02:00
|
|
|
|
.2 dex (2) delay 86 usec.
|
|
|
|
|
bne .2 (2+) 2 + 5x16 + 2 + 2
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
2020-05-13 19:00:37 +02:00
|
|
|
|
sbc #1 (2) done 'n' intervals?
|
2020-05-12 17:17:25 +02:00
|
|
|
|
bne .1 (2+) a-reg counts
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
2020-05-19 15:00:17 +02:00
|
|
|
|
plp
|
|
|
|
|
|
|
|
|
|
BB.MSWait.RTS rts (6)
|
2020-05-12 17:17:25 +02:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
BB.Trk2Qtrk asl x2
|
|
|
|
|
sta .1+1
|
|
|
|
|
|
|
|
|
|
bit BB.HdrVol
|
|
|
|
|
bmi .1 x4
|
|
|
|
|
|
|
|
|
|
lsr x3
|
|
|
|
|
|
|
|
|
|
.1 adc #$ff SELF MODIFIED
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
seekend ldx slotz
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
ldy #$7f allow 127 mistakes.
|
2020-05-13 19:00:37 +02:00
|
|
|
|
sty BB.RetryCnt
|
2020-05-08 21:02:27 +02:00
|
|
|
|
php
|
|
|
|
|
|
|
|
|
|
tryread plp fix stack.
|
|
|
|
|
|
|
|
|
|
rdhead sec anticipate error.
|
2020-05-13 19:00:37 +02:00
|
|
|
|
dec BB.RetryCnt if = 0 then give up!
|
2020-05-08 21:02:27 +02:00
|
|
|
|
beq erretrn branch if can't fine/read sector.
|
|
|
|
|
clc indicate reading header.
|
|
|
|
|
rddata php carry set if reading sector.
|
|
|
|
|
|
|
|
|
|
rd0 dey every time y=0 decrement find count.
|
|
|
|
|
beq tryread
|
2020-05-12 17:17:25 +02:00
|
|
|
|
*--------------------------------------
|
2020-05-08 21:02:27 +02:00
|
|
|
|
* from zzstart to zzend code is moved from rom and modified to match this code...
|
2020-05-12 17:17:25 +02:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
zzstart .EQ *
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
rd1 lda IO.D2.RData,x read a byte from the state machine.
|
|
|
|
|
bpl rd1 loop until ready.
|
|
|
|
|
|
|
|
|
|
.DUMMY
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
|
|
|
|
rd1a eor #$d5 mark 1?
|
|
|
|
|
mod1 .EQ *-zzstart+1
|
|
|
|
|
bne rd0 branch if not.
|
|
|
|
|
|
|
|
|
|
chg1 .EQ rd0-*
|
2020-05-12 17:17:25 +02:00
|
|
|
|
rd2 lda IO.D2.RData,x
|
2020-05-08 21:02:27 +02:00
|
|
|
|
bpl rd2
|
|
|
|
|
|
|
|
|
|
cmp #$aa mark 2?
|
|
|
|
|
bne rd1a
|
|
|
|
|
nop waste a little time.
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
rd3 lda IO.D2.RData,x
|
2020-05-08 21:02:27 +02:00
|
|
|
|
bpl rd3
|
|
|
|
|
|
|
|
|
|
cmp #$96 header mark 3?
|
|
|
|
|
beq rdhd1 branch if it is.
|
|
|
|
|
|
|
|
|
|
plp were we looking for data mark 3?
|
|
|
|
|
mod2 .EQ *-zzstart+1
|
|
|
|
|
bcc rdhead branch if not.
|
|
|
|
|
|
|
|
|
|
chg2 .EQ rdhead-*
|
|
|
|
|
eor #$ad data mark 3?
|
|
|
|
|
beq rddt1 go read data field if true...
|
|
|
|
|
|
|
|
|
|
mod3 .EQ *-zzstart+1
|
|
|
|
|
rdhd0 bne rdhead otherwise, start over.
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
chg3 .EQ rdhead-*
|
|
|
|
|
|
2020-05-08 21:02:27 +02:00
|
|
|
|
rdhd1 ldy #3 read in trk,sect,&volume #.
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
mod8 .EQ *-zzstart
|
|
|
|
|
rdhd2 sta (BB.HdrPtr),y save last result in .. , BB.HdrTrk , BB.HdrVol , ..
|
|
|
|
|
|
|
|
|
|
rdhd3 lda IO.D2.RData,x
|
2020-05-08 21:02:27 +02:00
|
|
|
|
bpl rdhd3
|
|
|
|
|
|
|
|
|
|
rol
|
|
|
|
|
sta oddbits save odd bits (7,5,3,1)
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
rdhd4 lda IO.D2.RData,x
|
2020-05-08 21:02:27 +02:00
|
|
|
|
bpl rdhd4
|
|
|
|
|
|
|
|
|
|
and oddbits combine even and odd to form value.
|
|
|
|
|
dey
|
|
|
|
|
bne rdhd2 read in next pair.
|
|
|
|
|
|
|
|
|
|
plp
|
|
|
|
|
cmp sector last byte formed is sector#
|
|
|
|
|
|
|
|
|
|
mod4 .EQ *-zzstart+1
|
|
|
|
|
bne rdhead branch if target sector not found.
|
|
|
|
|
|
|
|
|
|
chg4 .EQ rdhead-*
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
mod9 .EQ *-zzstart+1
|
|
|
|
|
lda BB.HdrTrk previous result is track #
|
|
|
|
|
cmp BB.TargetTrk is desired track found?
|
2020-05-08 21:02:27 +02:00
|
|
|
|
|
|
|
|
|
mod5 .EQ *-zzstart+1
|
|
|
|
|
bne goseek re-seek if mismatch.
|
2020-05-12 17:17:25 +02:00
|
|
|
|
|
2020-05-08 21:02:27 +02:00
|
|
|
|
chg5a .EQ *
|
|
|
|
|
mod6 .EQ *-zzstart+1
|
|
|
|
|
bcs rddata branch if proper track always.
|
|
|
|
|
chg6 .EQ rddata-*
|
2020-05-12 17:17:25 +02:00
|
|
|
|
*--------------------------------------
|
2020-05-08 21:02:27 +02:00
|
|
|
|
rddt1 ldy #$56 read 2 bit groupings first.
|
|
|
|
|
rddt1a sty oddbits
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
rddt2 ldy IO.D2.RData,x
|
2020-05-08 21:02:27 +02:00
|
|
|
|
bpl rddt2
|
|
|
|
|
|
|
|
|
|
eor dnib,y denibblize using table left from boot rom.
|
|
|
|
|
ldy oddbits save in nbuf1
|
|
|
|
|
dey
|
|
|
|
|
sta nbuf1,y
|
|
|
|
|
bne rddt1a loop until all 86 groups are read.
|
|
|
|
|
|
|
|
|
|
rddt3 sty oddbits now count up for 6-bit groups.
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
rddt4 ldy IO.D2.RData,x
|
2020-05-08 21:02:27 +02:00
|
|
|
|
bpl rddt4
|
|
|
|
|
|
|
|
|
|
eor dnib,y
|
|
|
|
|
ldy oddbits save result to specified buffer.
|
|
|
|
|
sta (dbuf),y
|
|
|
|
|
iny
|
|
|
|
|
bne rddt3 loop for 256 bytes.
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
rdchk ldy IO.D2.RData,x now verify checksum...
|
2020-05-08 21:02:27 +02:00
|
|
|
|
bpl rdchk
|
|
|
|
|
|
|
|
|
|
eor dnib,y must be equal...
|
|
|
|
|
mod7 .EQ *-zzstart+1
|
|
|
|
|
bne rdhd0 branch if error.
|
|
|
|
|
|
|
|
|
|
chg7 .EQ rdhd0-*
|
|
|
|
|
ldy #0 make y=0
|
|
|
|
|
|
|
|
|
|
nxttwo ldx #$56 now combine 2-bit group with 6 bit group
|
|
|
|
|
|
|
|
|
|
twobit dex all done with this group?
|
|
|
|
|
bmi nxttwo branch if so.
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
lda (dbuf),y
|
2020-05-08 21:02:27 +02:00
|
|
|
|
lsr nbuf1,x
|
|
|
|
|
rol
|
|
|
|
|
lsr nbuf1,x
|
|
|
|
|
rol
|
2020-05-12 17:17:25 +02:00
|
|
|
|
sta (dbuf),y
|
2020-05-08 21:02:27 +02:00
|
|
|
|
iny
|
|
|
|
|
bne twobit
|
2020-05-12 17:17:25 +02:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
zzzend ldx slotz
|
2020-05-08 21:02:27 +02:00
|
|
|
|
clc indicate good read.
|
|
|
|
|
rts
|
|
|
|
|
|
2020-05-12 17:17:25 +02:00
|
|
|
|
chg5 .EQ *-chg5a
|
|
|
|
|
goseek jmp seek
|
|
|
|
|
.ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.LIST ON
|
|
|
|
|
BB.End .EQ *
|
|
|
|
|
BB.Free .EQ $a00-*
|
|
|
|
|
.BS BB.Free
|
|
|
|
|
.LIST OFF
|
2020-05-08 21:02:27 +02:00
|
|
|
|
.EP
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE USR/SRC/LIB/LIBBLKDEV.S.BB
|
|
|
|
|
LOAD USR/SRC/LIB/LIBBLKDEV.S
|
|
|
|
|
ASM
|