mirror of
https://github.com/wwarthen/RomWBW.git
synced 2026-02-06 22:43:15 -06:00
Fix CP/M 3 floppy disk access
This commit is contained in:
@@ -36,6 +36,8 @@
|
|||||||
extrn ?const ; get console status
|
extrn ?const ; get console status
|
||||||
|
|
||||||
extrn ?bnkxlt
|
extrn ?bnkxlt
|
||||||
|
|
||||||
|
;extrn phex8, cout
|
||||||
|
|
||||||
|
|
||||||
; CP/M 3 Disk definition macros
|
; CP/M 3 Disk definition macros
|
||||||
@@ -365,6 +367,9 @@ dsk$login:
|
|||||||
; simple single density only environment.
|
; simple single density only environment.
|
||||||
|
|
||||||
|
|
||||||
|
;ld a,'L'
|
||||||
|
;call cout
|
||||||
|
|
||||||
push de ; save DPH ptr
|
push de ; save DPH ptr
|
||||||
|
|
||||||
; check media
|
; check media
|
||||||
@@ -372,7 +377,8 @@ dsk$login:
|
|||||||
;halt
|
;halt
|
||||||
ld c,a ; put in C
|
ld c,a ; put in C
|
||||||
ld b,18h ; HBIOS Media function
|
ld b,18h ; HBIOS Media function
|
||||||
ld e,1 ; Enabled media check/discovery
|
ld e,1 ; Enable media check/discovery
|
||||||
|
;rst 08
|
||||||
call 0FFF0H ; HBIOS call
|
call 0FFF0H ; HBIOS call
|
||||||
ld a,e ; Resultant media id to accum
|
ld a,e ; Resultant media id to accum
|
||||||
or a ; Set flags
|
or a ; Set flags
|
||||||
@@ -380,8 +386,11 @@ dsk$login:
|
|||||||
;
|
;
|
||||||
; !!! Need to do something on error !!!
|
; !!! Need to do something on error !!!
|
||||||
;
|
;
|
||||||
ret z ; Bail out on error
|
jr nz,dsk$login0 ; continue if OK
|
||||||
|
pop de ; else error
|
||||||
|
ret ; return
|
||||||
|
|
||||||
|
dsk$login0:
|
||||||
ld hl,dpb$start - dpb$sz
|
ld hl,dpb$start - dpb$sz
|
||||||
ld de,dpb$sz
|
ld de,dpb$sz
|
||||||
ld b,a ; loop count
|
ld b,a ; loop count
|
||||||
@@ -422,6 +431,9 @@ dsk$read:
|
|||||||
; ld ix,30H
|
; ld ix,30H
|
||||||
; halt
|
; halt
|
||||||
|
|
||||||
|
;ld a,'R'
|
||||||
|
;call cout
|
||||||
|
|
||||||
push de ; save XDPH pointer
|
push de ; save XDPH pointer
|
||||||
call dsk$seek ; disk seek
|
call dsk$seek ; disk seek
|
||||||
pop hl ; restore pointer to HL
|
pop hl ; restore pointer to HL
|
||||||
@@ -440,8 +452,10 @@ dsk$read:
|
|||||||
endif
|
endif
|
||||||
ld d,a ; set desk bank
|
ld d,a ; set desk bank
|
||||||
ld e,1 ; 1 sector
|
ld e,1 ; 1 sector
|
||||||
;rst 08 ; do it
|
rst 08 ; do it
|
||||||
call 0FFF0H
|
;call 0FFF0H
|
||||||
|
|
||||||
|
;call phex8
|
||||||
ret ; return
|
ret ; return
|
||||||
|
|
||||||
; lxi h,read$msg ; point at " Read "
|
; lxi h,read$msg ; point at " Read "
|
||||||
@@ -470,8 +484,8 @@ dsk$write:
|
|||||||
endif
|
endif
|
||||||
ld d,a ; set desk bank
|
ld d,a ; set desk bank
|
||||||
ld e,1 ; 1 sector
|
ld e,1 ; 1 sector
|
||||||
;rst 08 ; do it
|
rst 08 ; do it
|
||||||
call 0FFF0H
|
;call 0FFF0H
|
||||||
ret ; return
|
ret ; return
|
||||||
|
|
||||||
; lxi h,write$msg ; point at " Write "
|
; lxi h,write$msg ; point at " Write "
|
||||||
@@ -485,34 +499,44 @@ dsk$seek:
|
|||||||
ld c,a ; BIOS Disk Unit in C
|
ld c,a ; BIOS Disk Unit in C
|
||||||
ld b,12H ; HBIOS SEEK function
|
ld b,12H ; HBIOS SEEK function
|
||||||
push bc ; save it
|
push bc ; save it
|
||||||
|
push de ; save XDPH pointer
|
||||||
|
ld b,17h ; HBIOS DEVICE function
|
||||||
|
rst 08 ; Do it, D=device type
|
||||||
|
ld a,d ; put in accum
|
||||||
|
and 0F0h ; isolate high bits
|
||||||
|
ld b,1 ; assume it is floppy, 1 head bit
|
||||||
|
ld c,01h ; 1 bit head mask
|
||||||
|
cp 10h ; floppy?
|
||||||
|
jr z,seek0 ; yup, skip ahead
|
||||||
|
ld b,4 ; must be hard disk, 4 head bits
|
||||||
|
ld c,0Fh ; 4 bit head mask
|
||||||
|
seek0:
|
||||||
|
pop de ; recover XDPH pointer
|
||||||
|
push bc ; save bc
|
||||||
inc de ; point to slice field of XDPH
|
inc de ; point to slice field of XDPH
|
||||||
ld a,(de) ; get it
|
ld a,(de) ; get it
|
||||||
ld e,a ; slice to E
|
ld e,a ; slice to E
|
||||||
ld h,65 ; number of tracks per slice
|
ld h,65 ; number of tracks per slice
|
||||||
call mult8 ; HL now has track offset for slice
|
call mult8 ; HL now has track offset for slice
|
||||||
push hl ; save it for now
|
pop bc ; recover bc
|
||||||
|
push hl ; save track offset for now
|
||||||
ld hl,(@trk) ; get track value
|
ld hl,(@trk) ; get track value
|
||||||
ld a,l ; lsb of track to a
|
ld a,l ; lsb of track to a
|
||||||
and 0FH ; isolate head in low 4 bits
|
and c ; apply mask
|
||||||
ld d,a ; stuff it in d
|
ld d,a ; save in d
|
||||||
ld a,(@sect) ; get sector
|
|
||||||
ld e,a ; stuff it in e
|
|
||||||
ld b,4 ; prepare to shift out 4 bit head value
|
|
||||||
seek1:
|
seek1:
|
||||||
srl h ; shift one bit out
|
srl h ; shift one bit out
|
||||||
rr l ; ... of hl
|
rr l ; ... of hl
|
||||||
djnz seek1 ; do all 4 bits
|
djnz seek1 ; do all bits
|
||||||
|
ld a,(@sect) ; get sector
|
||||||
|
ld e,a ; stuff it in e
|
||||||
ex de,hl ; de=track, hl=head/sect
|
ex de,hl ; de=track, hl=head/sect
|
||||||
ex (sp),hl ; save head/sect, hl = offset
|
ex (sp),hl ; save head/sect, hl = offset
|
||||||
add hl,de ; hl has final track value
|
add hl,de ; hl has final track value
|
||||||
pop de ; recover head/sect to de
|
pop de ; recover head/sect to de
|
||||||
|
|
||||||
pop bc ; recover function & unit
|
pop bc ; recover function & unit
|
||||||
;rst 08 ; perform seek
|
rst 08 ; perform seek
|
||||||
call 0FFF0H
|
;call 0FFF0H
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user