X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/6a4e9540b950d871ea8fa072b195490a231b251d..ad9bc17c8ecab1f0bbd26f2270d4d396f4bc5e52:/z180/conbuf-a.180 diff --git a/z180/conbuf-a.180 b/z180/conbuf-a.180 index 3ec84d4..0a35195 100644 --- a/z180/conbuf-a.180 +++ b/z180/conbuf-a.180 @@ -1,24 +1,26 @@ page 255 .z80 - + ; ; FIFO channels for communication with avr ; - global ff.init,ff.in,ff.out,ff.i.st + global ff.init,ff.in,ff.out,ff.i.st,ff.o.st extrn buf.init include config.inc + if CPU_Z180 include z180reg.inc + endif ;-------------------------------------------------------------- dseg - - mkbuf co.fifo,co.fifo_len - mkbuf ci.fifo,ci.fifo_len + + mkbuf ci.fifo_id, ci.fifo, ci.fifo_len + mkbuf co.fifo_id, co.fifo, co.fifo_len ;-------------------------------------------------------------- @@ -48,7 +50,7 @@ buf.empty: ret z or 0ffh ret - + ff.in: push ix @@ -69,12 +71,12 @@ bg.wait: 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 pop ix @@ -96,35 +98,68 @@ buf.full: ret + if 1 ff.out: - push ix - ld ix,co.fifo ; + push ix ;15 + ld ix,co.fifo ;14 buf.put: - push hl ; - push bc - push ix - pop hl - ld c,(ix+o.in_idx) ; - ld b,0 - add hl,bc - ld b,a + 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 - ld a,c ; - inc a - and (ix+o.mask) + out (AVRINT6),a ;11 + ld a,b ;4 + pop bc ;10 + pop hl ;10 + pop ix ;14 + ret ;10 + + else + +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) ; - jr z,bp.wait - ld (hl),b - ld (ix+o.in_idx),a - - out (AVRINT6),a - ld a,b - pop bc - pop hl - pop ix - ret + cp (ix+o.out_idx) ;19 + jr z,bp.wait ;12/7 + ld (ix+o.in_idx),a ;19 - end + out (AVRINT6),a ;11 + ld a,c ;4 + pop hl ;10 + pop ix ;14 + ret ;10 | + + endif + end