Make logging in drive a no-op if drive already logged in

This commit is contained in:
Nero 2020-12-17 00:41:53 +00:00
parent bd3b27362d
commit de04b5ca01
2 changed files with 16 additions and 19 deletions

View File

@ -29,10 +29,7 @@ print_banner: mov si, banner
sub dl, (0x80-2)
.k: mov [defdrv], dl
call dskrst
mov dl, [defdrv]
call logdrv
call logdrv.force
xor ax, ax
xor dx, dx

View File

@ -28,38 +28,38 @@ bpb: resb BPBSIZ4
section .text
dskrst: call flush
mov ax, 0xFFFF
mov [dsknum], al
mov [dskseek], ax
mov [dskseek+2], ax
ret
; log in drive
; currently only supports 18 sectors 2 heads floppies
; IN dl drive number
logdrv: push dx
call dskrst
logdrv: ; dont do anything if drive already selected
cmp dl, [dsknum]
je .ret
; clear out current contents
.force: push dx
call flush
mov ax, 0xFFFF
mov [dskseek], ax
mov [dskseek+2], ax
mov byte [dskflag], 0
pop dx
; set current drive number
mov [dsknum], dl
; save info for bios
mov [biosnum], dl
; load boot sector
xor ax, ax
xor dx, dx
call mapabs
; copy bios parameter block
lea si, [dskbuf+BPBOFF]
mov di, bpb
mov cx, BPBSIZ4
rep movsb
; make sure partition offset is forced zero
xor ax, ax
mov [bpb+BPBHS], ax
mov [bpb+BPBHS+2], ax
ret
.ret: ret
calchs: mov bx, (18*2)
; dx:ax = linear count, bx = sectors / cylinder