X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp-cpm3.git/blobdiff_plain/ea5293bb6ce484bf1ec9ab70befe10c3a36a70c2..d6829fd3d7227d278aa32049665897a8a1b2d0d5:/cbios/conbuf.180 diff --git a/cbios/conbuf.180 b/cbios/conbuf.180 index e8dfe31..3c846dd 100644 --- a/cbios/conbuf.180 +++ b/cbios/conbuf.180 @@ -6,6 +6,7 @@ ; global ff.init,ff.in,ff.ist,ff.out,ff.ost + extrn ff_empty,ff_get,ff_full,ff_put extrn bufinit,fifolst include config.inc @@ -13,159 +14,73 @@ include z180reg.inc endif - - cseg - - mkbuf co.fifo_id, co.fifo, co.fifo_len + dseg mkbuf ci.fifo_id, ci.fifo, ci.fifo_len + mkbuf co.fifo_id, co.fifo, co.fifo_len -ico equ co.fifo_id * 3 -ici equ ci.fifo_id * 3 +ici equ ci.fifo_id * 2 +ico equ co.fifo_id * 2 ;-------------------------------------------------------------- ; Init Serial I/O for console input and output ; - + dseg ff.init: ld a,(INIDONE) cp INIDONEVAL ret z ld ix,ci.fifo - ld a,ci.fifo.mask call bufinit ld ix,co.fifo - ld a,co.fifo.mask jp bufinit ;-------------------------------------------------------------- +; Input status + dseg ff.ist: push ix ld ix,(fifolst+ici) ; - -buf.empty: - ld a,(ix+o.in_idx) ; - sub (ix+o.out_idx) ; + call ff_empty pop ix - ret z - or 0ffh ret +;-------------------------------------------------------------- +; Get an input character ff.in: push ix ld ix,(fifolst+ici) ; - -buf.get: - ld a,(ix+o.out_idx) ; -bg.wait: - cp (ix+o.in_idx) ; - jr z,bg.wait - - push hl ; - push ix - pop hl - add a,l - ld l,a - jr nc,bg.nc - inc h -bg.nc: - ld l,(hl) - - ld a,(ix+o.out_idx) ; - inc a - and (ix+o.mask) - ld (ix+o.out_idx),a - - ld a,l - pop hl + call ff_get pop ix ret ;-------------------------------------------------------------- +; Output status ff.ost: push ix - ld ix,(fifolst+ico) ; - -buf.full: - ld a,(ix+o.in_idx) ; - inc a - and (ix+o.mask) - sub (ix+o.out_idx) ; + ld ix,(fifolst+ico) ; + call ff_full pop ix - ret z - or 0ffh ret - if 1 -ff.out: - push ix ;15 - ld ix,(fifolst+ico) ; - -buf.put: - push hl ;11 - push bc ;11 - push ix ;15 - pop hl ;10 - ld a,c ;4 - ld c,(ix+o.in_idx) ;19 - ld b,0 ;7 - add hl,bc ;11 - ld (hl),a ;7 - ld b,a ;4 - - ld a,c ;4 - inc a ;4 - and (ix+o.mask) ;19 -bp.wait: - cp (ix+o.out_idx) ;19 - jr z,bp.wait ;12/7 - ld (ix+o.in_idx),a ;19 - - out (AVRINT6),a ;11 - ld a,b ;4 - pop bc ;10 - pop hl ;10 - pop ix ;14 - ret ;10 - - else +;-------------------------------------------------------------- +; put character in c in buffer +; destroys hl, bc +; returns output char in a ff.out: - push ix ;15 - ld ix,co.fifo ;14 - -buf.put: - push hl ;11 - push ix ;15 - pop hl ;10 - ld a,(ix+o.in_idx) ;19 - add a,l ;4 - ld l,a ;4 - jr nc,bp.1 ;12/7 - inc l ;4 - ld (hl),c ;7 - ld a,(ix+o.in_idx) ;19 - inc a ;4 - and (ix+o.mask) ;19 -bp.wait: - cp (ix+o.out_idx) ;19 - jr z,bp.wait ;12/7 - ld (ix+o.in_idx),a ;19 - - out (AVRINT6),a ;11 - ld a,c ;4 - pop hl ;10 - pop ix ;14 - ret ;10 | - - endif - -;-------------------------------------------------------------- + push ix ; + ld ix,(fifolst+ico) ; + call ff_put + out (AVRINT6),a ; tell monitor + pop ix ; + ret end +