X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/2fa1a7069a9709f8d61a198cec1b1d9b2e275fe1..31f423d23267efa289e032e5b98d9760727381b4:/z180/msgbuf-a.180 diff --git a/z180/msgbuf-a.180 b/z180/msgbuf-a.180 index ddb2d93..3575569 100644 --- a/z180/msgbuf-a.180 +++ b/z180/msgbuf-a.180 @@ -1,12 +1,13 @@ page 255 .z80 - global mrx.fifo,mtx.fifo + public mrx.fifo,mtx.fifo - global msginit,msgi.st,msg.in,msgo.st,msg.out - global msg.sout + public msginit,msgi.st,msg.in,msgo.st + public msg.sm,msg.sout - extrn buf.init + extrn bufinit,hwl2phy + extrn fifolst include config.inc if CPU_Z180 @@ -17,8 +18,8 @@ dseg - mkbuf mrx.fifo,mrx.fifo_len - mkbuf mtx.fifo,mtx.fifo_len + mkbuf mtx.fifo_id, mtx.fifo, mtx.fifo_len + mkbuf mrx.fifo_id, mrx.fifo, mrx.fifo_len ;-------------------------------------------------------------- @@ -29,12 +30,25 @@ ; msginit: - ld ix,mrx.fifo - ld a,mrx.fifo.mask - call buf.init + ld a,(043h) +;TODO: value should be 0 ld ix,mtx.fifo - ld a,mtx.fifo.mask - jp buf.init + call bufinit + push ix + pop hl + call hwl2phy + ld (040h),hl + ld (040h+2),a + ld a,0ffh + ld (043h),a + out (AVRINT5),a +wait: + ld a,(043h) + or a + jr nz,wait + + ld ix,mrx.fifo + jp bufinit ;-------------------------------------------------------------- @@ -136,7 +150,7 @@ bp.wait: ;-------------------------------------------------------------- - + if 0 msg.out: push ix @@ -165,6 +179,36 @@ bp.wait: pop ix ret + endif + +;---------------------------------------------------------------------- +; +; Put char in message buffer: +; ix: buffer to put into +; c: char + +buf.put: + push ix ;15 + push bc ;11 + ld a,(ix+o.in_idx) ;19 + ld c,a ;4 + ld b,0 ;7 + add ix,bc ;11 + pop bc ;10 + ld (ix),c ;7 + pop ix ;14 + + inc a ;4 + and (ix+o.mask) ;19 =121 +bufp.wait: + cp (ix+o.out_idx) ;19 + jr z,bufp.wait ;12/7 + ld (ix+o.in_idx),a ;19 + + out (AVRINT5),a ;11 + ld a,c ;4 + ret ;10 =191 + ;-------------------------------------------------------------- @@ -305,4 +349,26 @@ buf_end: ;---------------------------------------------------------------------- +;---------------------------------------------------------------------- +; Send message MEMORY +; +; hl: pointer to message (netto) +; b: msg length + +msg.sm: + push ix + ld ix,mtx.fifo + ld c,0AEh + call buf.put + ld c,b + call buf.put +msm_l: + ld c,(hl) + inc hl + call buf.put + djnz msm_l + pop ix + ret + + end