skip reads when sector number already matches

This commit is contained in:
Nero 2020-12-17 00:10:02 +00:00
parent e096745c13
commit bd3b27362d
1 changed files with 17 additions and 12 deletions

View File

@ -38,10 +38,15 @@ dskrst: call flush
; log in drive
; currently only supports 18 sectors 2 heads floppies
; IN dl drive number
logdrv: mov [biosnum], dl
logdrv: push dx
call dskrst
pop dx
mov [biosnum], dl
xor ax, ax
xor dx, dx
call read
call mapabs
; copy bios parameter block
lea si, [dskbuf+BPBOFF]
@ -49,7 +54,7 @@ logdrv: mov [biosnum], dl
mov cx, BPBSIZ4
rep movsb
; make sure partition offset is force zero
; make sure partition offset is forced zero
xor ax, ax
mov [bpb+BPBHS], ax
mov [bpb+BPBHS+2], ax
@ -97,17 +102,17 @@ mapfat: ; counting from beginning of FAT
add ax, [bpb+BPBRSC]
adc dx, 0
map: ; count from partition start
;add ax, [BPBHS]
;add dx, [BPBHS+2]
; absolute sector count
mapabs: call read
add ax, [bpb+BPBHS]
add dx, [bpb+BPBHS+2]
mapabs: ; absolute sector count
; skip doing a read if sector number matches
cmp ax, [dskseek]
jne read
cmp dx, [dskseek+2]
jne read
ret
; hard read, absolute disk offset
; TODO: retries on error
; IN dx:ax
read: ; flush previous data if necessary
push ax
read: push ax
push dx
call flush
pop dx