summaryrefslogtreecommitdiff
path: root/z180/msgbuf-a.180
diff options
context:
space:
mode:
authorLeo C2015-06-11 17:43:28 +0200
committerLeo C2015-06-11 17:43:28 +0200
commit1157e75889d3d6d23d1e2514f401cd5b354bd149 (patch)
treeedad2bcaddaec49a18a1b4bac2b813ce9e5a36bf /z180/msgbuf-a.180
parent8506d791786eea8ee55db5418a8f646bb2dd3a6d (diff)
parent057817cb1dc71416bc798b5cd592acfcea87efaa (diff)
downloadz180-stamp-1157e75889d3d6d23d1e2514f401cd5b354bd149.zip
Merge branch 'master' into cmdline_edit
Diffstat (limited to 'z180/msgbuf-a.180')
-rw-r--r--z180/msgbuf-a.180277
1 files changed, 225 insertions, 52 deletions
diff --git a/z180/msgbuf-a.180 b/z180/msgbuf-a.180
index 36e0871..3575569 100644
--- a/z180/msgbuf-a.180
+++ b/z180/msgbuf-a.180
@@ -1,22 +1,25 @@
page 255
.z80
-
- global mrx.fifo,mtx.fifo
- global msginit,msgi.st,msg.in,msgo.st,msg.out
- global msg.sout
-
- extrn buf.init
+ public mrx.fifo,mtx.fifo
+
+ public msginit,msgi.st,msg.in,msgo.st
+ public msg.sm,msg.sout
+
+ extrn bufinit,hwl2phy
+ extrn fifolst
include config.inc
+ if CPU_Z180
include z180reg.inc
+ endif
;--------------------------------------------------------------
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
;--------------------------------------------------------------
@@ -25,14 +28,27 @@
;
; Init buffer
;
-
+
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
;--------------------------------------------------------------
@@ -47,7 +63,7 @@ buf.empty:
ret z
or 0ffh
ret
-
+
;--------------------------------------------------------------
msg.in:
@@ -69,12 +85,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
@@ -98,6 +114,8 @@ buf.full:
;--------------------------------------------------------------
+ if 0
+
msg.out:
push ix
ld ix,mtx.fifo ;
@@ -120,58 +138,192 @@ bp.wait:
jr z,bp.wait
ld (hl),b
ld (ix+o.in_idx),a
-
+
ld a,b
- out0 (AVRINT5),a
+ out (AVRINT5),a
pop bc
pop hl
pop ix
ret
+ endif
;--------------------------------------------------------------
-;
-; (hl): data
-msg.sout:
+ if 0
+
+msg.out:
push ix
ld ix,mtx.fifo ;
+buf.put:
push bc
- push de
- ld b,(hl) ;
- inc hl
- ex de,hl
-
-ms.ol:
- push ix
- pop hl
ld c,(ix+o.in_idx) ;
- ld a,c
- add l
- ld l,a
- jr nc,ms.on
- inc h
-ms.on:
+ ld b,0
+ push ix ;14
+ add ix,bc ;10
+ ld (ix+0),a ;15
+ pop ix ;12 / 51
+ ld b,a ; 4
ld a,c ;
- inc a
- and (ix+o.mask)
-ms.wait:
+ inc a ;
+ and (ix+o.mask) ;
+bp.wait:
cp (ix+o.out_idx) ;
- jr z,ms.wait
- ld c,a
- ld a,(de)
- inc de
- ld (hl),a
- ld (ix+o.in_idx),c
- djnz ms.ol
- out0 (AVRINT5),a
- ex de,hl
- pop de
+ jr z,bp.wait ;
+ ld (ix+o.in_idx),a ;
+
+ ld a,b
+ out (AVRINT5),a
pop bc
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
+
+
+;--------------------------------------------------------------
+
+ if 0
+ ; Works only, if buffer size < (128 - 3)
+ ; --> mask must be 03fh or less
+
+msg.out:
+ push ix
+ ld ix,mtx.fifo ;
+
+buf.put:
+ push bc
+ ld b,a ; 4
+ ld a,(ix+o.in_idx) ;14
+ ld ($ + 3 + 2),a ;15
+ ld (ix+0),b ;15
+ inc a ;
+ and (ix+o.mask) ;
+bp.wait:
+ cp (ix+o.out_idx) ;
+ jr z,bp.wait ;
+ ld (ix+o.in_idx),a ;
+
+ ld a,b
+ out (AVRINT5),a
+ pop bc
+ pop ix
+ ret
+
+ endif
+
+;--------------------------------------------------------------
+;
+; (hl): data
+
+msg.sout:
+ push ix ;14
+ ld ix,mtx.fifo ;12
+ push bc ;11
+ push de ;11
+ ld c,(hl) ; 6
+ ld b,0 ; 6
+ inc hl ; 7
+ms.ol: ; \
+ ld a,low mtx.fifo ; 6
+ add a,(ix+o.in_idx) ;14
+ ld e,a ; 4
+ ld a,high mtx.fifo ; 6
+ adc a,b ; 4
+ ld d,a ; 4
+
+ ld a,(ix+o.in_idx) ;14
+ inc a ; 4
+ and (ix+o.mask) ;14
+ms.wait:
+ cp (ix+o.out_idx) ;14
+ jr z,ms.wait ; 6/8
+
+ ldi ;12
+ ld (ix+o.in_idx),a ;15
+ jp pe,ms.ol ; 6/9 -- 126
+
+ out (AVRINT5),a ;10
+ pop de ; 9
+ pop bc ; 9
+ pop ix ;12
+ ret ; 9
+
+;--------------------------------------------------------------
+;
+; (hl): data
+
+ if 0
+
+msg.sout:
+ push ix ;14
+ ld ix,mtx.fifo ;12
+ push bc ;11
+ push de ;11
+ ld b,(hl) ; 6
+ inc hl ; 4
+ ex de,hl ; 3
+ms.ol: ; \
+ push ix ;14
+ pop hl ; 9
+ ld c,(ix+o.in_idx) ;14
+ ld a,c ; 4
+ add l ; 4
+ ld l,a ; 4
+ jr nc,ms.on ; 6/8
+ inc h ; 4
+ms.on:
+ ld a,c ; 4
+ inc a ; 4
+ and (ix+o.mask) ;14
+ms.wait:
+ cp (ix+o.out_idx) ;14
+ jr z,ms.wait ; 6/8
+ ld c,a ; 4
+ ld a,(de) ; 6
+ inc de ; 4
+ ld (hl),a ; 7
+ ld (ix+o.in_idx),c ;15
+ djnz ms.ol ; 7/9 -- 130
+
+ out (AVRINT5),a ;10
+ ex de,hl ; 3
+ pop de ; 9
+ pop bc ; 9
+ pop ix ;12
+ ret ; 9
+
+ endif
+
;--------------------------------------------------------------
msg.co:
@@ -183,8 +335,8 @@ msg.co:
pop hl
pop af
ret
-
-
+
+
buf:
db buf_end - $ - 1 ;output string length
db 0AEh ; message start token
@@ -197,5 +349,26 @@ buf_end:
;----------------------------------------------------------------------
- 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