Skip to content

Commit

Permalink
Fix DSKIO driver error check in DOS 1, page 1 transfers
Browse files Browse the repository at this point in the history
The code in drv.mac was assuming that the call to the driver routine
DEV_RW/DSKIO was setting Cy=1 to signal an error, however this is true
only for drive-based drivers, but not for device-based drivers.
This incorrect behavior was happening only in DOS 1 mode and only
for transfers to page 1.
  • Loading branch information
Konamiman committed Nov 14, 2023
1 parent 181d3e0 commit 4dcfa14
Showing 1 changed file with 46 additions and 27 deletions.
73 changes: 46 additions & 27 deletions source/kernel/drv.mac
Expand Up @@ -259,8 +259,6 @@ CAPSOFF:
ret




ALIGN 781Fh
;-----------------------------------------------------------------------------
;
Expand All @@ -277,6 +275,18 @@ null_message:
db "2 - Double side",13,10
db 0


; Moved here due to space constraints

DO_DIRCALL:
pop ix
push bc
ld bc,DV_D0##-DIRCALL-3
add ix,bc
pop bc
jp DO_CALBNK


;-----------------------------------------------------------------------------
;
; Entries for direct calls.
Expand All @@ -292,13 +302,27 @@ DIRCALL:
call DO_DIRCALL
call DO_DIRCALL

DO_DIRCALL:
pop ix
push bc
ld bc,DV_D0##-DIRCALL-3
add ix,bc
pop bc
jp DO_CALBNK

; Process the output of DSKIO so that Cy is set
; if an error has been returned.

DIO_SET_ERR_FLAG::
push af
ld a,(KSLOT##)
or a
jr z,DIO_SET_ERR_FLAG_END

;Device-based: set Cy if error code is not 0
pop af
or a
ret z
scf
ret

;Drive-based driver: result will already have Cy set on error
DIO_SET_ERR_FLAG_END:
pop af
ret


;-----------------------------------------------------------------------------
Expand Down Expand Up @@ -478,14 +502,8 @@ DIO_RD_LOOP:
push de ;with a simple call to the driver
push hl

ld hl,($SECBUF##)
ld b,1
or a

ld ix,DV_DSKIO## ;Or DEV_RW (they are at the same address)
ex af,af'
ld a,DV_BANK##
call CALBNK##
call DIO_DO_CALDRV
jr nc,DIO_RD_OK

pop hl ;On disk error, just return
Expand Down Expand Up @@ -532,14 +550,8 @@ DIO_WR_LOOP:
push bc
push de

ld hl,($SECBUF##)
ld b,1
scf

ld ix,DV_DSKIO##
ex af,af'
ld a,DV_BANK##
call CALBNK##
call DIO_DO_CALDRV
jr nc,DIO_WR_OK

pop de ;On disk error, just return
Expand All @@ -562,6 +574,17 @@ DIO_WR_OK:
ret


DIO_DO_CALDRV:
ld hl,($SECBUF##)
ld b,1

ld ix,DV_DSKIO##
ex af,af'
ld a,DV_BANK##
call CALBNK##
jp DIO_SET_ERR_FLAG


; Jump here when the transfer can be done in a single step
; (no page 1 involved)

Expand Down Expand Up @@ -975,10 +998,6 @@ POP_CONV_ERR:
CONV_ERR:
or a
ret z
;jr c,CONVE2
;xor a
;ret
CONVE2:

push bc
ld b,0
Expand Down

0 comments on commit 4dcfa14

Please sign in to comment.