File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2495,32 +2495,49 @@ util_get_cluster_offset:
24952495
24962496;-------------------------------------------------------------------------------
24972497util_cluster_entry_to_block:
2498- ld e , a
2499- xor a , a
2500- ld bc , 128
2501- call ti._ldivu
2502- ld bc , (yf at .fat_pos)
2498+ ; input:
2499+ ; - A:UHL
2500+ ; output:
2501+ ; - A:UHL = floor(A:UHL / 128) + (yfat.fat_pos)
2502+ ; destroys:
2503+ ; - BC, flags
2504+ push hl
2505+ pop bc
2506+ ld l , 7
2507+ call ti._lshru
2508+ ld hl , (yf at .fat_pos)
25032509 add hl , bc
2504- adc a , e
2510+ adc a , 0
25052511 ret
25062512
25072513;-------------------------------------------------------------------------------
25082514util_ceil_byte_size_to_block_size:
2515+ ; input:
2516+ ; - A:UHL
2517+ ; output:
2518+ ; - A:UHL = ceil(A:UHL / 512)
2519+ ; - A = 0
2520+ ; destroys:
2521+ ; - BC, flags
25092522 compare_auhl_zero
25102523 ret z
2511- ld e , a
2512- push hl , de
2513- xor a , a
2514- ld bc , 512
2515- push bc
2516- call ti._lremu
2517- compare_hl_zero
2518- pop bc , de , hl
2524+ ; test if the low 9 bits are non-zero
2525+ inc l
2526+ dec l
2527+ jr nz , .round_up
2528+ bit 0 , h
2529+ .round_up:
25192530 push af
2520- xor a , a
2521- call ti._ldivu
2531+ push hl
2532+ pop bc
2533+ ld l , 9
2534+ call ti._lshru
2535+ push bc
2536+ pop hl
25222537 pop af
2538+ ld a , 0
25232539 ret z
2540+ ; round up
25242541 inc hl
25252542 ret
25262543
You can’t perform that action at this time.
0 commit comments