summaryrefslogtreecommitdiff
path: root/z180
diff options
context:
space:
mode:
authorLeo C2014-10-20 13:19:34 +0200
committerLeo C2014-10-20 13:19:34 +0200
commitbad2d92d98f9990ee5ccf509c0eafe5b3af9f4dc (patch)
tree5f40467c58dc2aa6aad35c96575506a4784e0444 /z180
parent6dc26e92c20eedcfcba9e0b75a015a5b160748c5 (diff)
downloadz180-stamp-bad2d92d98f9990ee5ccf509c0eafe5b3af9f4dc.zip
Define fifos: msg_tx_fifo, msg_rx_fifo
Diffstat (limited to 'z180')
-rw-r--r--z180/Tupfile3
-rw-r--r--z180/config.inc11
-rw-r--r--z180/console.18016
-rw-r--r--z180/msgfifo.180260
-rw-r--r--z180/r3init.18060
5 files changed, 299 insertions, 51 deletions
diff --git a/z180/Tupfile b/z180/Tupfile
index ebdb1d1..fc926de 100644
--- a/z180/Tupfile
+++ b/z180/Tupfile
@@ -5,7 +5,8 @@ PROG = hdrom
SRC = r3init.180
SRC += ddtz.180
#SRC += fifoio.180 msgbuf.180 ser1-i.180 console.180
-SRC += ser1-i.180 console.180
+SRC += msgfifo.180 ser1-i.180 console.180
+#SRC += ser1-i.180 console.180
SRC += romend.180
diff --git a/z180/config.inc b/z180/config.inc
index b5df1cc..652b5ae 100644
--- a/z180/config.inc
+++ b/z180/config.inc
@@ -41,17 +41,16 @@ CWAITROM equ 2 shl MWI0
DRSTNUM equ 30h ;DDTZ Restart vector (breakpoints)
-msg_fb_len equ 256
-rx.buf_len equ 20h
-tx.buf_len equ 80h
-rx.buf_len equ 20h
-tx.buf_len equ 80h
+msg_rx_fifo_len equ 256
+msg_tx_fifo_len equ 256
s1.rx_len equ 256 ;Serial 1 (ASCI1) buffers
s1.tx_len equ 256 ;
-PMSG equ 80h
+AVRINT5 equ 40h
+AVRINT6 equ 50h
+;PMSG equ 80h
;-----------------------------------------------------
; Definition of (locical) top 2 memory pages
diff --git a/z180/console.180 b/z180/console.180
index d7b5ef6..9b0d519 100644
--- a/z180/console.180
+++ b/z180/console.180
@@ -8,8 +8,8 @@
extrn ser.init,ser.instat,ser.in,ser.out
-; extrn f.init,f.in,f.out,f.i.st
-; extrn msg.co
+ extrn msginit,msg.in,msg.out,msgi.st
+ extrn msg.co
include config.inc
@@ -20,19 +20,19 @@
;
$coninit:
-; call f.init
+ call msginit
call ser.init
ret
$cists:
-; call f.i.st
-; ret nz
+ call msgi.st
+ ret nz
call ser.instat
ret
$ci:
-; call f.i.st
-; jp nz,f.in
+ call msgi.st
+ jp nz,msg.in
call ser.instat
jp nz,ser.in
jr $ci
@@ -41,7 +41,7 @@ $ci:
; jp f.o.st
$co:
-; call msg.co
+ call msg.co
jp ser.out
end
diff --git a/z180/msgfifo.180 b/z180/msgfifo.180
new file mode 100644
index 0000000..582c219
--- /dev/null
+++ b/z180/msgfifo.180
@@ -0,0 +1,260 @@
+ page 255
+ .z80
+
+ global msg_rx_fifo,msg_tx_fifo
+
+ global msginit,msgi.st,msg.in,msgo.st,msg.out
+ global msg.sout,msg.co
+
+ extrn buf.init
+
+ include config.inc
+ include z180reg.inc
+
+;--------------------------------------------------------------
+
+ dseg
+
+ mkbuf msg_rx_fifo,msg_rx_fifo_len
+ mkbuf msg_tx_fifo,msg_tx_fifo_len
+
+
+
+;--------------------------------------------------------------
+
+ cseg
+
+;
+; Init buffer
+;
+
+msginit:
+ ld ix,msg_rx_fifo
+ ld a,msg_rx_fifo.mask
+ call buf.init
+ ld ix,msg_tx_fifo
+ ld a,msg_tx_fifo.mask
+ jp buf.init
+
+;--------------------------------------------------------------
+
+msgi.st:
+ push ix
+ ld ix,msg_rx_fifo ;
+
+buf.empty:
+ ld a,(ix+o.in_idx) ;
+ sub (ix+o.out_idx) ;
+ pop ix
+ ret z
+ or 0ffh
+ ret
+
+;--------------------------------------------------------------
+
+msg.in:
+ push ix
+ ld ix,msg_rx_fifo ;
+
+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
+ pop ix
+ ret
+
+;--------------------------------------------------------------
+
+msgo.st:
+ push ix
+ ld ix,msg_tx_fifo ;
+
+buf.full:
+ ld a,(ix+o.in_idx) ;
+ inc a
+ and (ix+o.mask)
+ sub (ix+o.out_idx) ;
+ pop ix
+ ret z
+ or 0ffh
+ ret
+
+;--------------------------------------------------------------
+
+msg.out:
+ push ix
+ ld ix,msg_tx_fifo ;
+
+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
+
+ ld a,c ;
+ inc a
+ and (ix+o.mask)
+bp.wait:
+ cp (ix+o.out_idx) ;
+ jr z,bp.wait
+ ld (hl),b
+ ld (ix+o.in_idx),a
+
+ ld a,b
+ out0 (AVRINT5),a
+ pop bc
+ pop hl
+ pop ix
+ ret
+
+
+;--------------------------------------------------------------
+;--------------------------------------------------------------
+;--------------------------------------------------------------
+
+if 0
+msg.out:
+ push ix
+ ld ix,msg_fifo ;
+
+ push bc
+ ld b,a ;save char
+ ld a,(ix+o.in_idx) ;
+ inc a
+ and (ix+o.mask)
+bp.wait:
+ cp (ix+o.out_idx) ;
+ jr z,bp.wait
+ ld c,a
+ ld a,b
+ out (PMSG),a
+ ld (ix+o.in_idx),c
+
+ pop bc
+ pop ix
+ ret
+endif
+
+;--------------------------------------------------------------
+;
+; (hl): data
+
+msg.sout:
+ push ix
+ ld ix,msg_tx_fifo ;
+
+ 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 a,c ;
+ inc a
+ and (ix+o.mask)
+ms.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
+ pop bc
+ pop ix
+ ret
+
+;--------------------------------------------------------------
+
+if 0
+msg.sout:
+ push ix
+ ld ix,msg_fifo ;
+ push bc
+
+ ld b,(hl) ;count
+ inc hl
+obs_1:
+ ld a,(ix+o.out_idx) ;
+ sub (ix+o.in_idx) ;
+ dec a
+ and (ix+o.mask)
+ cp b
+ jr c,obs_1
+
+ ld c,(hl) ;port address
+ inc hl
+ ld a,b
+ otir
+ add (ix+o.in_idx)
+ and (ix+o.mask)
+ ld (ix+o.in_idx),a
+ pop bc
+ pop ix
+ ret
+
+;----------------------------------------------------------------------
+endif
+
+msg.co:
+ push af
+ push hl
+ ld (buf_char),a
+ ld hl,buf
+ call msg.sout
+ pop hl
+ pop af
+ ret
+
+
+buf:
+ db buf_end - $ - 1 ;output string length
+ db 081h ; message start token
+ db buf_end - $ - 1 ; message length
+ db 1 ; command
+ db 1 ; subcommand
+buf_char:
+ db 0 ; pay load
+buf_end:
+
+;----------------------------------------------------------------------
+
+ end
+
diff --git a/z180/r3init.180 b/z180/r3init.180
index 0d3e5be..1936c9b 100644
--- a/z180/r3init.180
+++ b/z180/r3init.180
@@ -94,8 +94,8 @@ start:
ld a,M_NCD ;No Clock Divide
out0 (ccr),a
- ld a,M_X2CM ;X2 Clock Multiplier
- out0 (cmr),a
+; ld a,M_X2CM ;X2 Clock Multiplier
+; out0 (cmr),a
; search warm start mark
@@ -280,12 +280,9 @@ wstart:
call prt0_init
-
-;;; call bufferinit
-
-
call $coninit
+ call bufferinit
@@ -301,7 +298,6 @@ wstart:
ld e,a ;
jp ddtz ;0290
-
;
;----------------------------------------------------------------------
;
@@ -317,56 +313,48 @@ buf.init:
ret
;----------------------------------------------------------------------
-if 0
- extrn msginit,msg.sout,msg_fifo
- extrn tx.buf,rx.buf
+ extrn msginit,msg_tx_fifo,msg_rx_fifo
+ extrn msg.sout
bufferinit:
- call msginit
- ld hl,buffers
- ld bc,0300h
-bfi_1:
- ld e,(hl)
- inc hl
- ld d,(hl)
- inc hl
- push hl
+ ld de,msg_tx_fifo
in0 a,cbr
call log2phys
ld (40h+0),hl
ld (40h+2),a
- ld a,c
+
+ ld (bufdat+1),hl
+ ld (bufdat+3),a
+ xor a
ld (bufdat+0),a
ld hl,inimsg
call msg.sout
- pop hl
- inc c
- djnz bfi_1
- ret
- rept 20
- db 0
- endm
+ ld de,msg_rx_fifo
+ in0 a,cbr
+ call log2phys
+ ld (bufdat+1),hl
+ ld (bufdat+3),a
+ ld a,1
+ ld (bufdat+0),a
+ ld hl,inimsg
+ call msg.sout
-buffers:
- dw msg_fifo
- dw tx.buf
- dw rx.buf
+ ret
inimsg:
- db inimsg_e - $ -2
- db PMSG
+ db inimsg_e - $ - 1
db 81h
- db inimsg_e - $ -1
+ db inimsg_e - $ - 1
db 0
bufdat:
db 0
dw 0
db 0
inimsg_e:
-endif
+
;----------------------------------------------------------------------
;
if 0
@@ -379,7 +367,7 @@ bufferinit:
call msginit
ld hl,buffers
- ld bc,0300h
+ ld bc,0300h ; b:count, c:buffer nr
bfi_1:
ld e,(hl)
inc hl