improved 32-bit (well, smartport is 24-bit) block support

This commit is contained in:
Kelvin Sherlock 2021-08-11 22:10:11 -04:00
parent 7fc041289f
commit 44a6544242
2 changed files with 132 additions and 43 deletions

View File

@ -68,7 +68,7 @@ blockNumber ds.b 2
buffer equ $2000 buffer equ $2000
entry read_block, read_block_abs, read_extent_block entry read_block_abs, read_extent_block
entry vector entry vector
entry extent_to_extent entry extent_to_extent
@ -151,6 +151,7 @@ ok
lda #buffer lda #buffer
sta pro.dataBuffer sta pro.dataBuffer
endif endif
ldx #0
lda #2 lda #2
jsr read_block_abs jsr read_block_abs
@ -350,8 +351,8 @@ blockNumber dc.l 1 ; actually 24-bit
endif endif
read_block proc read_block_abs proc
entry read_block_abs entry read_block_abs_long
entry vector entry vector
; input ; input
@ -359,17 +360,19 @@ read_block proc
; will be adjusted for allocation block offset ; will be adjusted for allocation block offset
; ;
with zp with zp
clc ; clc
adc startingBlock ; adc startingBlock
read_block_abs ;read_block_abs
if __smartport__ then if __smartport__ then
sta sp.blockNumber sta sp.blockNumber
stx sp.blockNumber+2
else else
sta pro.blockNumber sta pro.blockNumber
endif endif
read_block_abs_long
php php
sec sec
xce xce
@ -387,36 +390,61 @@ vector dc.w $ffff
@fail brk $ea @fail brk $ea
endp endp
macro
ifcs &p1,&p2
bcc @0
&p1 &p2
@0
mend
read_extent_block proc read_extent_block proc
; a = block # ; a = block #
; This doesn't check beyond the 3rd extent ; This doesn't check beyond the 3rd extent
with zp,ExtendedExtent import read_block_abs_long
; TODO - not yet 32-bit clean. with zp,ExtendedExtent
@0 @0
cmp extents+(sizeof*0)+blockCount cmp extents+(sizeof*0)+blockCount
bcs @1 bcs @1
; clc ; clc
adc extents+(sizeof*0)+startBlock ldx #sizeof*0+startBlock
bra read_block bra found
@1 sbc extents+(sizeof*0)+blockCount @1 sbc extents+(sizeof*0)+blockCount
cmp extents+(sizeof*1)+blockCount cmp extents+(sizeof*1)+blockCount
bcs @2 bcs @2
; clc ; clc
adc extents+(sizeof*1)+startBlock ldx #sizeof*1+startBlock
bra read_block bra found
@2 sbc extents+(sizeof*1)+blockCount @2 sbc extents+(sizeof*1)+blockCount
cmp extents+(sizeof*2)+blockCount cmp extents+(sizeof*2)+blockCount
bcs @3 bcs @3
adc extents+(sizeof*2)+startBlock ldx #sizeof*2+startBlock
bra read_block bra found
@3 brk $ea @3 brk $ea
found ;
clc
adc extents,x
sta sp.blockNumber
lda #0
adc extents+2,x
sta sp.blockNumber+2
clc
lda startingBlock
adc sp.blockNumber
sta sp.blockNumber
lda #0
adc sp.blockNumber+2
sta sp.blockNumber+2
bra read_block_abs_long
endp endp
@ -457,7 +485,8 @@ rts rts
extent_to_extent proc extent_to_extent proc
; y = offset into buffer. ; y = offset into buffer.
; clobbers x, y ; clobbers x, y
with zp with zp,ExtendedExtent
import multiply import multiply
ldx #0 ldx #0
@ -472,15 +501,15 @@ loop1
inx inx
inx inx
inx inx
cpx #3*4*2 cpx #sizeof*3
blt loop1 blt loop1
; now multiply... ; now multiply...
lda blockMultiplier lda blockMultiplier
dec a dec a
beq rts beq offset
ldx #3*4*2-4 ldx #sizeof*3-4
loop2 loop2
lda blockMultiplier lda blockMultiplier
sta m1 sta m1
@ -500,7 +529,35 @@ loop2
bpl loop2 bpl loop2
rts rts offset
if 0 then
; now add the block offset to the starting block.
lda startingBlock
clc
adc extents+(ExtendedExtent.sizeof*0)+startBlock
sta extents+(ExtendedExtent.sizeof*0)+startBlock
lda #0
adc extents+(ExtendedExtent.sizeof*0)+startBlock+2
sta extents+(ExtendedExtent.sizeof*0)+startBlock+2
lda startingBlock
clc
adc extents+(ExtendedExtent.sizeof*1)+startBlock
sta extents+(ExtendedExtent.sizeof*1)+startBlock
lda #0
adc extents+(ExtendedExtent.sizeof*1)+startBlock+2
sta extents+(ExtendedExtent.sizeof*1)+startBlock+2
lda startingBlock
clc
adc extents+(ExtendedExtent.sizeof*2)+startBlock
sta extents+(ExtendedExtent.sizeof*2)+startBlock
lda #0
adc extents+(ExtendedExtent.sizeof*2)+startBlock+2
sta extents+(ExtendedExtent.sizeof*2)+startBlock+2
endif
rts
endp endp

View File

@ -85,7 +85,7 @@ blockNumber ds.b 2
endif endif
entry read_block, read_block_abs entry read_block_abs, read_block_abs_long
entry prepare_path, cat_lookup entry prepare_path, cat_lookup
entry read_cat_block, read_file_block entry read_cat_block, read_file_block
entry extent_to_extent entry extent_to_extent
@ -181,6 +181,7 @@ getbootname proc
sta pro.dataBuffer sta pro.dataBuffer
endif endif
lda #2 lda #2
ldx #0
jsr read_block_abs jsr read_block_abs
; restore the stack. does not affect a/carry ; restore the stack. does not affect a/carry
@ -518,33 +519,50 @@ read_file_block proc
cmp file_extents+(sizeof*0)+blockCount cmp file_extents+(sizeof*0)+blockCount
bcs @1 bcs @1
; clc ; clc
adc file_extents+(sizeof*0)+startBlock ldx #sizeof*0+startBlock
bra read_block bra found
@1 sbc file_extents+(sizeof*0)+blockCount @1 sbc file_extents+(sizeof*0)+blockCount
cmp file_extents+(sizeof*1)+blockCount cmp file_extents+(sizeof*1)+blockCount
bcs @2 bcs @2
; clc ; clc
adc file_extents+(sizeof*1)+startBlock ldx #sizeof*1+startBlock
bra read_block bra found
@2 sbc file_extents+(sizeof*1)+blockCount @2 sbc file_extents+(sizeof*1)+blockCount
cmp file_extents+(sizeof*2)+blockCount cmp file_extents+(sizeof*2)+blockCount
bcs @3 bcs @3
adc file_extents+(sizeof*2)+startBlock ldx #sizeof*2+startBlock
bra read_block bra found
@3 @3
lda #outOfRange ; too big lda #outOfRange ; too big
sec sec
rts rts
found ;
clc
adc file_extents,x
sta sp.blockNumber
lda #0
adc file_extents+2,x
sta sp.blockNumber+2
clc
lda startingBlock
adc sp.blockNumber
sta sp.blockNumber
lda #0
adc sp.blockNumber+2
sta sp.blockNumber+2
bra read_block_abs_long
endp endp
read_cat_block proc read_cat_block proc
; a = block # ; a = block #
; TODO - not 32-bit clean yet.
with data,ExtendedExtent with data,ExtendedExtent
@ -552,52 +570,68 @@ read_cat_block proc
cmp cat_extents+(sizeof*0)+blockCount cmp cat_extents+(sizeof*0)+blockCount
bcs @1 bcs @1
; clc ; clc
adc cat_extents+(sizeof*0)+startBlock ldx #sizeof*0+startBlock
bra read_block bra found
@1 sbc cat_extents+(sizeof*0)+blockCount @1 sbc cat_extents+(sizeof*0)+blockCount
cmp cat_extents+(sizeof*1)+blockCount cmp cat_extents+(sizeof*1)+blockCount
bcs @2 bcs @2
; clc ; clc
adc cat_extents+(sizeof*1)+startBlock ldx #sizeof*1+startBlock
bra read_block bra found
@2 sbc cat_extents+(sizeof*1)+blockCount @2 sbc cat_extents+(sizeof*1)+blockCount
cmp cat_extents+(sizeof*2)+blockCount cmp cat_extents+(sizeof*2)+blockCount
bcs @3 bcs @3
adc cat_extents+(sizeof*2)+startBlock ldx #sizeof*2+startBlock
bra read_block bra found
@3 @3
lda #outOfRange ; too big lda #outOfRange ; too big
sec sec
rts rts
found ;
clc
adc cat_extents,x
sta sp.blockNumber
lda #0
adc cat_extents+2,x
sta sp.blockNumber+2
clc
lda startingBlock
adc sp.blockNumber
sta sp.blockNumber
lda #0
adc sp.blockNumber+2
sta sp.blockNumber+2
bra read_block_abs_long
endp endp
read_block proc read_block_abs proc
entry read_block_abs entry read_block_abs_long
entry vector entry vector
; input ; input
; a = hfs block # ; a = hfs block #
; will be adjusted for allocation block offset ; will be adjusted for allocation block offset
; ;
clc ; clc
adc data.startingBlock ; adc data.startingBlock
read_block_abs
if __smartport__ then if __smartport__ then
sta sp.blockNumber sta sp.blockNumber
stx sp.blockNumber+2
else else
sta pro.blockNumber sta pro.blockNumber
endif endif
read_block_abs_long
php php
sec sec
xce xce
@ -623,8 +657,6 @@ vector dc.w $ffff
sec sec
rts rts
_stack ds.w 1
endp endp
@ -1031,6 +1063,7 @@ startup proc
with HFSMasterDirectoryBlock with HFSMasterDirectoryBlock
lda #2 lda #2
ldx #0
jsr read_block_abs jsr read_block_abs
; shouldn't fail. ; shouldn't fail.
lda buffer+drAlBlSt lda buffer+drAlBlSt
@ -1058,7 +1091,6 @@ startup proc
; find the root node. ; find the root node.
lda #0 lda #0
ldx #0
jsr read_cat_block jsr read_cat_block
with BTHeaderRec with BTHeaderRec