From ef7b3f76f0c57e78a237e6dc5690974eac1d4a66 Mon Sep 17 00:00:00 2001 From: John Winans Date: Thu, 4 May 2023 21:48:53 -0500 Subject: [PATCH] If valid, use current drive after WBOOT else A --- retro/disk_callgate.asm | 13 ++++++++----- retro/retro.asm | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/retro/disk_callgate.asm b/retro/disk_callgate.asm index 8f7bd3d..dd089a1 100644 --- a/retro/disk_callgate.asm +++ b/retro/disk_callgate.asm @@ -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 @@ -183,7 +185,7 @@ if 0 call hexdump endif - pop hl + pop hl ; HL = DPH ret @@ -193,7 +195,8 @@ endif ld (disk_dph),hl ld (.cur_disk_read),hl ld (.cur_disk_write),hl - ret + + ret ; HL = 0 = fail ;**************************************************************************** diff --git a/retro/retro.asm b/retro/retro.asm index 4f75678..fdb59e2 100644 --- a/retro/retro.asm +++ b/retro/retro.asm @@ -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!