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
1 changed files with 106 additions and 102 deletions

View File

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