Skip to content

Commit ed65a7d

Browse files
authored
Merge pull request #158 from grauw/rootdir-rounding
partit: Correct rounding of root directory size.
2 parents eeca10e + a1895f0 commit ed65a7d

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

source/kernel/bank4/partit.mac

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,21 +1656,13 @@ CHECK_FAT_BOOT:
16561656

16571657
ld c,(iy+UPB_NUM_ROOT_DIR_ENTRIES##)
16581658
ld b,(iy+UPB_NUM_ROOT_DIR_ENTRIES##+1) ;BC=Num of root dir entries
1659-
ld a,c
1660-
and 11111b
1661-
ld hl,0
1662-
jr z,NO_ODD_ENTRIES
1663-
ld hl,1
1664-
NO_ODD_ENTRIES:
1665-
srl b ;Divide by 32
1666-
rr c
1667-
srl b
1668-
rr c
1669-
srl b
1670-
rr c
1671-
srl b
1672-
rr c
1673-
add hl,bc ;HL=Num of root dir sectors
1659+
ld hl,15
1660+
add hl,bc
1661+
ld b,4
1662+
CALC_SECDIR:
1663+
srl h ;Divide by 16, round up
1664+
rr l
1665+
djnz CALC_SECDIR ;HL=Num of root dir sectors
16741666

16751667
ld c,(iy+UPB_RESERVED_SECTORS##)
16761668
ld b,(iy+UPB_RESERVED_SECTORS##+1)
@@ -1947,11 +1939,13 @@ CALC_1SECDIR:
19471939
ld (iy+17),h
19481940
ex de,hl
19491941

1950-
;1er data sector =(Reserved sectors+Num FATs*Sectors per FAT)+
1942+
;1st data sector =(Reserved sectors+Num FATs*Sectors per FAT)+
19511943
; (32*Directory entries/512)
19521944

1953-
ld l,(ix+17) ;Calculate directory entries/16
1945+
ld l,(ix+17) ;Calculate directory entries/16, round up
19541946
ld h,(ix+18)
1947+
ld bc,15
1948+
add hl,bc
19551949
ld b,4
19561950
CALC_1SECDAT:
19571951
srl h
@@ -1965,7 +1959,7 @@ CALC_1SECDAT:
19651959
;Num clusters+1=((Total sectors-1st data sector)/Sectors per cluster)+1
19661960

19671961
push hl
1968-
pop bc ;DE=1st data sector
1962+
pop bc ;BC=1st data sector
19691963
ld l,(ix+19)
19701964
ld h,(ix+20)
19711965
ld de,0

0 commit comments

Comments
 (0)