From: Leo C Date: Fri, 7 Dec 2018 20:58:24 +0000 (+0100) Subject: Replace BDOS console i/o X-Git-Tag: v0.5~33 X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/commitdiff_plain/12eea40b2a19262bffbb570149ef9a6c68c3d8b5 Replace BDOS console i/o --- diff --git a/ddt180.z80 b/ddt180.z80 index 2763329..3ab5b88 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -29,9 +29,12 @@ current_cseg defl $ ; Some greneral definitions -TAB equ 9 -LF equ 10 -CR equ 13 +BS equ 08h +TAB equ 09h +CR equ 0dh +LF equ 0ah +DEL equ 7fh +CNTRX equ 'X'-'@' ; CP/M memory layout @@ -43,11 +46,7 @@ TPA equ 0100h ; BDOS function calls -BDOS_CIN equ 1 ;Console Input -BDOS_COUT equ 2 ;Console Output BDOS_PSTR equ 9 ;Print String -BDOS_CBUF equ 10 ;Read Console Buffer -BDOS_CSTAT equ 11 ;Get Console Status BDOS_OPEN equ 15 ;Open File BDOS_CLOSE equ 16 ;Close File BDOS_DELETE equ 19 ;Delete File @@ -167,6 +166,11 @@ l0093h: ;------------------------------------------------------------------------------- +?const: +?conin: +?cono: + ret + CMDTAB: dw ERROR ;cmd_@ ;examine/substitute the displacement register @ dw ERROR ;cmd_A ;Assemble @@ -371,9 +375,8 @@ outchar: push bc push af and 07fh - ld e,a - ld c,BDOS_COUT - call ddtz_bdos + ld c,a + call ?cono ld hl,con_col inc (hl) pop af @@ -410,41 +413,142 @@ p_goto_col: ;------------------------------------------------------------------------------- +$ci: + push hl + push de + push bc + call ?conin + pop bc + pop de + pop hl + ret + +$co: + push hl + push de + push bc + ld c,a + call ?cono + pop bc + pop de + pop hl + ret + +;------------------------------------------------------------------------------- + inchar: push ix push hl push de push bc - ld c,BDOS_CSTAT - call ddtz_bdos + call ?const and a - jr z,l0284h - ld c,BDOS_CIN - call ddtz_bdos + jr z,inch1 + call ?conin scf -l0284h: +inch1: pop bc pop de pop hl pop ix ret +;------------------------------------------------------------------------------- + +DELC: + ld a,b + or a + ret z + call DELC1 + dec hl + dec b + inc c + ld a,(hl) + cp ' ' + ret nc +DELC1: + push de + push hl + push bc + ld c,BS + call ?cono + ld c,' ' + call ?cono + ld c,BS + call ?cono + pop bc + pop hl + pop de + ret + +DELL: + ld a,b ; + or a ; + ret z ; + call DELC ; + jr DELL ; + +;------------------------------------------------------------------------------- + get_line: - push hl - ld de,conbuf - ld c,BDOS_CBUF - call ddtz_bdos - call crlf - ld hl,conbuf+1 - ld e,(hl) - xor a - ld d,a + push hl ; + ld hl,conbuf ; + ld c,(hl) ; + inc hl ; + ld b,000h ; + inc hl ; +inlnxtch: + ld a,c ; + or a ; + jr z,inl_e ; + call $ci ; + cp CR ; + jr z,inl_e ;Accept line + cp LF ; + jr z,inl_e ;Accept line + cp BS ; + jr nz,gl_1 ; + call DELC ;Delete Char + jr inlnxtch ; +gl_1: + cp DEL ; + jr nz,gl_2 ; + call DELC ;Delete Char + jr inlnxtch ; +gl_2: + cp CNTRX ; + jr nz,gl_3 ; + call DELL ;Delete Line + jr inlnxtch ; +gl_3: + cp TAB ; + jr nz,gl_4 ; + ld a,' ' ; +gl_4: + ld (hl),a ; + cp ' ' ; + jr nc,gl_5 ; + ld a,'^' ;Controll characters + call $co ; + ld a,(hl) ; + add a,'@' ; +gl_5: + call $co ; + inc hl ; + inc b ; + dec c ; + jr inlnxtch ; + +inl_e: + ld (hl),0 + ld hl,conbuf+1 ; + ld (hl),b ; + call CRLF ; + inc hl ex de,hl - add hl,de - ld (hl),a - pop hl - ret + pop hl ; + ret ; ;-------------------------------------------------------------------------------