]> cloudbase.mooo.com Git - z180-stamp.git/blame - z180/conbuf-a.180
Adaptions for fatfs R0.12b
[z180-stamp.git] / z180 / conbuf-a.180
CommitLineData
6a4e9540
L
1 page 255\r
2 .z80\r
e4c4b148 3\r
6a4e9540
L
4;\r
5; FIFO channels for communication with avr\r
6;\r
30d1329e 7 global ff.init,ff.in,ff.out,ff.i.st,ff.o.st\r
6a4e9540 8\r
8bbf185e 9 extrn bufinit\r
6a4e9540
L
10\r
11 include config.inc\r
64cc2207 12 if CPU_Z180\r
6a4e9540 13 include z180reg.inc\r
64cc2207 14 endif\r
6a4e9540
L
15\r
16\r
17;--------------------------------------------------------------\r
18\r
19 dseg\r
6a4e9540 20\r
e4c4b148 21\r
e4c4b148 22 mkbuf ci.fifo_id, ci.fifo, ci.fifo_len\r
ad9bc17c 23 mkbuf co.fifo_id, co.fifo, co.fifo_len\r
6a4e9540
L
24\r
25\r
26;--------------------------------------------------------------\r
27\r
28 cseg\r
29\r
30; Init Serial I/O for console input and output\r
31;\r
32\r
33ff.init:\r
34 ld ix,ci.fifo\r
8bbf185e 35 call bufinit\r
6a4e9540 36 ld ix,co.fifo\r
8bbf185e 37 jp bufinit\r
6a4e9540
L
38\r
39\r
40ff.i.st:\r
41 push ix\r
42 ld ix,ci.fifo ;\r
43\r
44buf.empty:\r
45 ld a,(ix+o.in_idx) ;\r
46 sub (ix+o.out_idx) ;\r
47 pop ix\r
48 ret z\r
49 or 0ffh\r
50 ret\r
e4c4b148 51\r
6a4e9540
L
52\r
53ff.in:\r
54 push ix\r
55 ld ix,ci.fifo ;\r
56\r
57buf.get:\r
58 ld a,(ix+o.out_idx) ;\r
59bg.wait:\r
60 cp (ix+o.in_idx) ;\r
61 jr z,bg.wait\r
62\r
63 push hl ;\r
64 push ix\r
65 pop hl\r
66 add a,l\r
67 ld l,a\r
68 jr nc,bg.nc\r
69 inc h\r
70bg.nc:\r
71 ld l,(hl)\r
e4c4b148 72\r
6a4e9540
L
73 ld a,(ix+o.out_idx) ;\r
74 inc a\r
75 and (ix+o.mask)\r
76 ld (ix+o.out_idx),a\r
e4c4b148 77\r
6a4e9540
L
78 ld a,l\r
79 pop hl\r
80 pop ix\r
81 ret\r
82\r
83\r
84ff.o.st:\r
85 push ix\r
86 ld ix,co.fifo ;\r
87\r
88buf.full:\r
89 ld a,(ix+o.in_idx) ;\r
90 inc a\r
91 and (ix+o.mask)\r
92 sub (ix+o.out_idx) ;\r
93 pop ix\r
94 ret z\r
95 or 0ffh\r
96 ret\r
97\r
98\r
64cc2207 99 if 1\r
6a4e9540 100ff.out:\r
64cc2207
L
101 push ix ;15\r
102 ld ix,co.fifo ;14\r
6a4e9540
L
103\r
104buf.put:\r
64cc2207
L
105 push hl ;11\r
106 push bc ;11\r
107 push ix ;15\r
108 pop hl ;10\r
109 ld a,c ;4\r
110 ld c,(ix+o.in_idx) ;19\r
111 ld b,0 ;7\r
112 add hl,bc ;11\r
113 ld (hl),a ;7\r
114 ld b,a ;4\r
115\r
116 ld a,c ;4\r
117 inc a ;4\r
118 and (ix+o.mask) ;19\r
6a4e9540 119bp.wait:\r
64cc2207
L
120 cp (ix+o.out_idx) ;19\r
121 jr z,bp.wait ;12/7\r
122 ld (ix+o.in_idx),a ;19\r
e4c4b148 123\r
64cc2207
L
124 out (AVRINT6),a ;11\r
125 ld a,b ;4\r
126 pop bc ;10\r
127 pop hl ;10\r
128 pop ix ;14\r
129 ret ;10\r
130\r
131 else\r
132\r
133ff.out:\r
134 push ix ;15\r
135 ld ix,co.fifo ;14\r
136\r
137buf.put:\r
138 push hl ;11\r
139 push ix ;15\r
140 pop hl ;10\r
141 ld a,(ix+o.in_idx) ;19\r
142 add a,l ;4\r
143 ld l,a ;4\r
144 jr nc,bp.1 ;12/7\r
145 inc l ;4\r
146 ld (hl),c ;7\r
147 ld a,(ix+o.in_idx) ;19\r
148 inc a ;4\r
149 and (ix+o.mask) ;19\r
150bp.wait:\r
151 cp (ix+o.out_idx) ;19\r
152 jr z,bp.wait ;12/7\r
153 ld (ix+o.in_idx),a ;19\r
154\r
155 out (AVRINT6),a ;11\r
156 ld a,c ;4\r
157 pop hl ;10\r
158 pop ix ;14\r
159 ret ;10 |\r
160\r
161 endif\r
6a4e9540
L
162\r
163 end\r