3 public ff_empty,ff_get,ff_full,ff_put
4 public ff_puth,ff_cnt,ff_gech
14 ;--------------------------------------------------------------------
23 ;--------------------------------------------------------------------
28 ld (ix+o.in_idx),0 ;reset pointers (empty fifo)
47 call hwl2phy ;get phys. address of fifo
49 ld a,(ix+o.id) ;fifo id
56 ; TODO: move to better place
59 push bc ;c: bank-addr, b: ignored
62 push bc ;c: function, b:subf
73 ;--------------------------------------------------------------
74 ; Check if characters in fifo
75 ; Fifo is empty, if output index and input index are the same
84 ;--------------------------------------------------------------
85 ; get character from fifo
108 ;--------------------------------------------------------------
109 ; get character and ramaining count from fifo
110 ; halt cpu, while buffer is empty
114 ; c,a: next character
115 ; b: number of charachters in fifo
120 ld c,(ix+o.out_idx) ;
130 adc (ix+o.mask) ; mask+carry == buffer size
141 ;--------------------------------------------------------------
142 ; Check if room in fifo
143 ; buffer is full, if output index is one behind input index
146 ; a = 0 and z if buffer full
147 ; a = ff and nz if buffer not full
159 ;--------------------------------------------------------------
160 ; put character in c in buffer
162 ; returns output char in a
166 pop hl ; get buffer start address
169 ld c,(ix+o.in_idx) ; add input index
172 ld (hl),a ; one place is allways free
175 ld a,c ; bump input index
180 jr z,bp.wait ; while new input idx == ouput idx
185 ;--------------------------------------------------------------
186 ; put character in c in buffer
187 ; halt cpu, while buffer is is full
189 ; returns output char in a
193 pop hl ; get buffer start address
196 ld c,(ix+o.in_idx) ; add input index
199 ld (hl),a ; one place is allways free
202 ld a,c ; bump input index
209 jr z,bph.wait ; while new input idx == ouput idx
214 ;--------------------------------------------------------------
215 ; Return number of characters in fifo
222 adc (ix+o.mask) ; mask+carry == buffer size
225 ;--------------------------------------------------------------