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

View File

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