Skip to content

Commit

Permalink
If valid, use current drive after WBOOT else A
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwinans committed May 5, 2023
1 parent 57353a3 commit ef7b3f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
13 changes: 8 additions & 5 deletions retro/disk_callgate.asm
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,20 @@ endif
;****************************************************************************
;****************************************************************************
disk_seldsk:
ld a,c
ld (disk_disk),a

if .disk_debug >= 2
push bc
call iputs
db "disk_seldsk entered\r\n\0"
ld a,(disk_disk) ; restore the drive number
pop bc
endif
; check if the disk is valid
ld a,c
cp dph_vec_num
jr nc,.seldsk_fail ; if (a >= dph_vec_num) then error

ld (disk_disk),a

; disk is valid, find the DPH
ld hl,dph_vec ; default = invalid
sla a ; A = A * 2
Expand Down Expand Up @@ -183,7 +185,7 @@ if 0
call hexdump
endif

pop hl
pop hl ; HL = DPH
ret


Expand All @@ -193,7 +195,8 @@ endif
ld (disk_dph),hl
ld (.cur_disk_read),hl
ld (.cur_disk_write),hl
ret

ret ; HL = 0 = fail


;****************************************************************************
Expand Down
13 changes: 8 additions & 5 deletions retro/retro.asm
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,14 @@ if .debug >= 3
call hexdump
endif

if 0
; This is not quite right because it include the user number and
; can get us stuck re-selesting an invalid disk drive!
ld a,(4) ; load the current disk # from page-zero into a/c
and 0x0f ; the drive number is in the 4 lsbs
if 1
ld c,0 ; default = drive A (if previous was invalid)
ld a,(4) ; load the current disk # from page-zero into A
and 0x0f ; the drive number is in the 4 lsbs
cp dph_vec_num
jp nc,CPM_BASE ; if A >= dph_vec_num then bad drive (use 0)

ld a,(4) ; load the current disk # from page-zero into a/c
ld c,a
else
ld c,0 ; The ONLY valid drive WE have is A!
Expand Down

0 comments on commit ef7b3f7

Please sign in to comment.