X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp-cpm3.git/blobdiff_plain/4cd9d9817858107c42aaebd868942f882a6dcd6a..afbcea2d821d1166ae347338ae52a64f3ee51e57:/cbios/utils.180
diff --git a/cbios/utils.180 b/cbios/utils.180
index bbe5ac3..08c5fd0 100644
--- a/cbios/utils.180
+++ b/cbios/utils.180
@@ -6,21 +6,24 @@
; math
+ public ijphl ; vectored CALL point
public add_hla ; add a to hl
public div32_16,div32_r ; divide 32 bit by 16 bit number (rounded)
; print utils
public ?pmsg ; print message
+ public pr.idx ; print message from table indexed by
public pr.inln,pr.crlf ; print message inline, print newline
- public phex2,phex4 ; print 2 digit hex (A) or 4 digit hex (HL)
+ public phex2,phex4 ; print 2 digit hex or 4 digit hex
public pr.dec,pr.decl ; print 16 or 32 bit decimal number
- public ?pderr ; print BIOS disk error message header
+ public pr.errors ; print BIOS disk error message header
- extrn ?cono
+ extrn ?const,?conin,?cono
extrn @adrv,@trk,@sect ; used by disk error message
+ extrn @op,@ermde
;-------------------------------------------------------------------------------
@@ -82,6 +85,16 @@ io1_nxt:
pop bc
ret
+ cseg
+
+;--------------------------------------------------------------------
+; vectored CALL point
+
+ijphl:
+ jp (hl)
+
+ dseg
+
;--------------------------------------------------------------------
; add a to hl
;
@@ -221,6 +234,36 @@ pmsg$exit:
pop bc
ret
+;-------------------------------------------------------------------------------
+; print message from table @, indexed by
+; saves &
+
+pr.idx:
+ push bc
+ push de
+ push hl ; put pointer to first message on stack
+ ld e,a ; save message number
+ xor a
+ ld b,a
+ ld c,a
+ inc e
+pdc_nxt_str:
+ dec e
+ ex (sp),hl
+ jr z,pdc_found
+ ex (sp),hl
+ cpir
+ cp (hl)
+ jr nz,pdc_nxt_str
+ ; End of List, msg not found.
+ ; Print first msg.
+pdc_found:
+ pop hl
+ call ?pmsg
+ pop de
+ pop bc
+ ret
+
;-------------------------------------------------------------------------------
; print message inline up to a null
; saves all registers
@@ -379,10 +422,85 @@ prd_out:
ld hl,sector$msg
call ?pmsg ; sector header
ld hl,(@sect)
- call pr.dec ; sector number
- ret
+ jp pr.dec ; sector number
; error message components
drive$msg: db cr,lf,bell,'BIOS Error on ',0
track$msg: db ': T-',0
sector$msg: db ', S-',0
+
+
+;-------------------------------------------------------------------------------
+; get console input, echo it, and shift to upper case
+; save hl,de,bc
+
+uciecho:
+ push hl
+ push de
+ push bc
+u$c0:
+ call ?const
+ or a
+ jr z,u$c1 ; see if any char already struck
+ call ?conin
+ jr u$c0 ; yes, eat it and try again
+u$c1:
+ call ?conin
+ push af
+ ld c,a
+ cp ' '-1
+ call nc,?cono
+ pop af
+ pop bc
+ pop de
+ pop hl
+ cp 'a'
+ ret c
+ sub 'a'-'A' ; make upper case
+ ret
+
+;-------------------------------------------------------------------------------
+;
+
+pr.errors:
+
+ ; suppress error message if BDOS
+ ; is returning errors to application...
+
+ ld a,(@ermde)
+ inc a
+ jr nz,pre1
+ dec a ;return NZ, if @ermde == 0FFH
+ ret
+pre1:
+ push hl
+ ld hl,pre2
+ ex (sp),hl
+ push hl
+
+ ; Had permanent error, print message like:
+ ; BIOS Err on d: T-nn, S-mm, , Retry ?
+
+ call ?pderr ; print message header
+
+ ld hl,op$msg
+ ld a,(@op)
+ jp pr.idx ; last function (read or write)
+
+pre2:
+ ; prompt for retry
+ call pr.inln
+ db ' Retry (Y/N) ? ',0
+
+ call uciecho ; get operator response
+ cp 'Y'
+ ret ; return Z-flag for yes
+
+
+op$msg:
+ db ', Unknown op, ',0
+ db ', Read, ',0
+ db ', Write, ',0
+ db 0
+
+ end