Reformat boot5x, fix #2, and shorten code all at the same time

This commit is contained in:
mgcaret 2017-04-08 19:20:36 -07:00
parent 740044802d
commit 34ff8a48bf

View File

@ -31,14 +31,13 @@ btc4: cmp #$04 ; RX diags
jmp swrts2 ; otherwise jump to monitor jmp swrts2 ; otherwise jump to monitor
dordiag: jmp $db3a ; diags dordiag: jmp $db3a ; diags
btc5: cmp #$05 ; boot smartport btc5: cmp #$05 ; boot smartport
beq boot5 beq bootcx
; fall through if none of the above cmp #$06 ; boot 5.25
boot4: lda #rx_mslot ; boot slot 4 beq bootcx
bra bootsl ; fall through to default boot if none of the above
boot5: lda #$c5 ; boot slot 5 boot4: lda #rx_mslot ; boot slot 4 (should be, anyway)
bra bootsl bootcx: ora #$c0 ; convert to slot addr high byte if needed
boot6: lda #$c6 ; boot slot 6 ldx #$00 ; low byte of slot
bootsl: ldx #$00 ; low byte of slot
bootadr: stx $0 ; store address bootadr: stx $0 ; store address
sta $1 ; return to bank 0 does jmp (0) sta $1 ; return to bank 0 does jmp (0)
endbt4x: lda #>(bt5xrtn-1) endbt4x: lda #>(bt5xrtn-1)
@ -47,30 +46,34 @@ endbt4x: lda #>(bt5xrtn-1)
pha pha
lda $1 lda $1
jmp swrts2 jmp swrts2
rdrecov: jsr rdinit ; init ramcard ; try to recover RAM disk
.proc rdrecov
jsr rdinit ; init ramcard
lda pwrup,y ; get power up flag lda pwrup,y ; get power up flag
cmp #pwrbyte ; already initialized? cmp #pwrbyte ; already initialized?
beq recovdn ; exit if initialized beq :+ ; exit if initialized
jsr testsize ; does not wreck x or y jsr testsize ; does not wreck x or y
lda numbanks,y ; get discovered # banks lda numbanks,y ; get discovered # banks
beq recovdn ; no mem beq :+ ; no mem
stz addrl,x ; set slinky address 0 stz addrl,x ; set slinky address 0
stz addrm,x stz addrm,x
stz addrh,x stz addrh,x
lda data,x ; start check for bootable ramdisk lda data,x ; start check for bootable ramdisk
cmp #$01 cmp #$01
bne recovdn ; not bootable bne :+ ; not bootable
lda data,x ; next byte should be nonzero and not $ff lda data,x ; next byte should be nonzero and not $ff
beq recovdn ; not bootable beq :+ ; not bootable
cmp #$ff cmp #$ff
beq recovdn ; not bootable beq :+ ; not bootable
lda #pwrbyte lda #pwrbyte
sta pwrup,y ; set power byte sta pwrup,y ; set power byte
lda #'R' ; tell user lda #'R' ; tell user
sta $7d0 ; on screen sta $7d0 ; on screen
recovdn: rts : rts
.endproc
; zero ram card space ; zero ram card space
rdclear: jsr rdinit ; init ramcard .proc rdclear
jsr rdinit ; init ramcard
jsr testsize ; get size jsr testsize ; get size
lda numbanks,y ; # of 64Ks to write lda numbanks,y ; # of 64Ks to write
beq clrdone ; no memory beq clrdone ; no memory
@ -98,9 +101,10 @@ clrdone: ldx #rx_mslot
lda #$a0 ; ' ' lda #$a0 ; ' '
sta $400 ; clear progress sta $400 ; clear progress
rts rts
rdinit: bit rx_mslot*$100 ; activate registers .endproc
.proc rdinit
bit rx_mslot*$100 ; activate registers
ldy #rx_mslot ; slot offset ldy #rx_mslot ; slot offset
ldx #rx_devno ; register offset ldx #rx_devno ; register offset
rts rts
.endproc