DOS partition size checking.

This commit is contained in:
Eric Smith 2021-04-09 13:26:04 -06:00
parent 2e8396f8ca
commit d3e64080a7

View File

@ -192,15 +192,15 @@ hw_reg_offset equ $88
; use. ; use.
; BEWARE: Even scratch use is questionable if interrupts are in use, ; BEWARE: Even scratch use is questionable if interrupts are in use,
; because an interrupt hander might use these. ; because an interrupt hander might use these.
shg_0478 equ $0478 shg_cur_part_size_high equ $0478
shg_04f8 equ $04f8 shg_cur_part_size_low equ $04f8
shg_0578 equ $0578 shg_0578 equ $0578
shg_05f8 equ $05f8 shg_05f8 equ $05f8
mslot1088 equ $0778 ; stores (slot*$10)+hw_reg_offset mslot1088 equ $0778 ; stores (slot*$10)+hw_reg_offset
; mslot appears to be the only global screen hole for which Apple ; mslot appears to be the only global screen hole for which Apple
; has defined a function. ; has defined a function.
mslot equ $07f8 ; stores $Cn, where n is the slot number mslot equ $07f8 ; stores $Cn, where n is the slot number
; screen holes, indexed by $Cn, where n is slot number (1 through 7) ; screen holes, indexed by $Cn, where n is slot number (1 through 7)
shs_card_block_count equ $0478-$c0 ; # blocks of whole card, divided by 256 shs_card_block_count equ $0478-$c0 ; # blocks of whole card, divided by 256
@ -508,7 +508,7 @@ Lc818: lda (Z45),y
inc D010c,x inc D010c,x
Lc825: dey Lc825: dey
bne Lc818 bne Lc818
sty shg_04f8 sty shg_cur_part_size_low
sty shg_0578 sty shg_0578
sty shg_05f8 sty shg_05f8
tax tax
@ -546,7 +546,7 @@ ret_err_bad_cmd:
skip2 skip2
ret_err_bad_pcnt: ret_err_bad_pcnt:
lda #err_bad_pcnt lda #err_bad_pcnt
LC863: sta shg_04f8 LC863: sta shg_cur_part_size_low
Lc866: ldx #$00 Lc866: ldx #$00
Lc868: pla Lc868: pla
sta Z42,x sta Z42,x
@ -555,7 +555,7 @@ Lc868: pla
bcc Lc868 bcc Lc868
ldy shg_05f8 ldy shg_05f8
ldx shg_0578 ldx shg_0578
lda shg_04f8 lda shg_cur_part_size_low
bne Lc87c bne Lc87c
clc clc
Lc87c: rts Lc87c: rts
@ -1040,9 +1040,9 @@ Lcc0c: tya
prodos_status: prodos_status:
ldy mslot ldy mslot
jsr Scfe4 jsr copy_s2g_part_size
ldy shg_0478 ldy shg_cur_part_size_high
ldx shg_04f8 ldx shg_cur_part_size_low
prodos_format prodos_format
: lda #$00 : lda #$00
clc clc
@ -1169,12 +1169,14 @@ Lccf5: tya
sta (Z48),y sta (Z48),y
rts rts
; check DOS parition size
Sccfb: ldy mslot Sccfb: ldy mslot
ldx #$03 ldx #$03
Lcd00: lda shs_cur_part_size_low,y Lcd00: lda shs_cur_part_size_low,y
cmp Dcd31,x cmp valid_dos_part_size_low,x
lda shs_cur_part_size_high,y lda shs_cur_part_size_high,y
sbc Dcd2d,x sbc valid_dos_part_size_high,x
bcs Lcd12 bcs Lcd12
dex dex
bpl Lcd00 bpl Lcd00
@ -1195,48 +1197,68 @@ Scd16: clc
sta shs_part_base_high,y sta shs_part_base_high,y
rts rts
Dcd2d: fcb $02,$04,$06,$0c ; valid DOS parition sizes
Dcd31: fcb $30,$60,$40,$80 valid_dos_part_size_high:
fcb (140*4)>>8
fcb (280*4)>>8
fcb (400*4)>>8
fcb (800*4)>>8
valid_dos_part_size_low:
fcb (140*4)&$ff
fcb (280*4)&$ff
fcb (400*4)&$ff
fcb (800*4)&$ff
Dcd35: fcb $23,$32 Dcd35: fcb $23,$32
Dcd37: fcb $10,$20 Dcd37: fcb $10,$20
Dcd39: fcb $02,$06 Dcd39: fcb $02,$06
Dcd3b: fcb $30,$40 Dcd3b: fcb $30,$40
Scd3d: ldy mslot Scd3d:
jsr Scfe4 ; is partition size at least 4KB?
; return:
; carry clear if paritition too small
; carry set, zero clear if size OK but unknwon OS
; carry set, zero set if size and OS both OK, A = OS
ldy mslot
jsr copy_s2g_part_size
cmp #$10 cmp #$10
bcs Lcd4c bcs Lcd4c
lda shg_0478 lda shg_cur_part_size_high
beq Lcd55 beq Lcd55
Lcd4c: lda shs_os_check,y Lcd4c: lda shs_os_check,y
eor #check_xor_val eor #check_xor_val
cmp shs_os_code,y cmp shs_os_code,y
sec sec
Lcd55: rts Lcd55: rts
Scd56: jsr Scd3d
bcc Lcd97 Scd56: jsr Scd3d ; check parition size and OS
bne Lcd63 bcc Lcd97 ; parititon too small
cmp #$33 bne Lcd63 ; parition size OK, but OS unknown
bne Lcd97 cmp #os_dos
bne Lcd97 ; not a DOS partition
clc clc
rts rts
Lcd63: lda #$33 Lcd63: lda #os_dos ; set OS to DOS (but don't yet set OS check)
sta shs_os_code,y sta shs_os_code,y
jsr Sccfb jsr Sccfb ; check DOS parition size
bmi Lcd97 bmi Lcd97
bcc Lcd91 bcc Lcd91
lda shs_part_base_mid,y lda shs_part_base_mid,y
pha pha
lda shs_part_base_high,y lda shs_part_base_high,y
pha pha
stx shg_04f8 stx shg_cur_part_size_low
jsr Scd16 jsr Scd16
ldy Dcfe2,x ldy Dcfe2,x
jsr Scdfb jsr Scdfb
ldx shg_04f8 ldx shg_cur_part_size_low
ldy mslot ldy mslot
pla pla
sta shs_part_base_high,y sta shs_part_base_high,y
@ -1313,9 +1335,9 @@ Sce06: lda #$00
Lce0c: tya Lce0c: tya
pha pha
lda shg_04f8 lda shg_cur_part_size_low
cmp #$01 cmp #$01
lda shg_0478 lda shg_cur_part_size_high
sbc #$00 sbc #$00
lsr lsr
lsr lsr
@ -1417,9 +1439,9 @@ Lceaf: pha
bne Lceaf bne Lceaf
rts rts
Lcec5: lda shg_04f8 Lcec5: lda shg_cur_part_size_low
sta hw_reg_data-hw_reg_offset,x sta hw_reg_data-hw_reg_offset,x
lda shg_0478 lda shg_cur_part_size_high
Lcece: sta hw_reg_data-hw_reg_offset,x Lcece: sta hw_reg_data-hw_reg_offset,x
rts rts
@ -1443,7 +1465,7 @@ Lced9: lda #$00
Lcef4: tya Lcef4: tya
pha pha
ldy shg_0478 ldy shg_cur_part_size_high
beq Lcf08 beq Lcf08
nop nop
Lcefc: tya Lcefc: tya
@ -1454,7 +1476,7 @@ Lcefc: tya
tay tay
dey dey
bne Lcefc bne Lcefc
Lcf08: lda shg_04f8 Lcf08: lda shg_cur_part_size_low
pha pha
lsr lsr
lsr lsr
@ -1510,12 +1532,14 @@ Dcf30: fcb $01,$00,$00,$02,$02,$01,$02,$00
Dcfe2: fcb $30,$5c Dcfe2: fcb $30,$5c
Scfe4: lda shs_cur_part_size_high,y
copy_s2g_part_size:
lda shs_cur_part_size_high,y
lsr lsr
sta shg_0478 sta shg_cur_part_size_high
lda shs_cur_part_size_low,y lda shs_cur_part_size_low,y
ror ror
sta shg_04f8 sta shg_cur_part_size_low ; leaves part_size_low in A
rts rts
fillto $d000,$ff fillto $d000,$ff