diff options
Diffstat (limited to 'avr/z80-if.c')
-rw-r--r-- | avr/z80-if.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/avr/z80-if.c b/avr/z80-if.c index d14d9d7..414582e 100644 --- a/avr/z80-if.c +++ b/avr/z80-if.c @@ -518,8 +518,7 @@ int z80_memfifo_is_empty(const fifo_t f) { int rc = 1; - if (((Stat & S_MSG_PENDING) || f != fifo_in) && fifo_dsc[f].base != 0) - { + if (fifo_dsc[f].base != 0) { uint32_t adr = fifo_dsc[f].base + FIFO_INDEX_IN; uint8_t idx; @@ -546,7 +545,8 @@ int z80_memfifo_is_full(const fifo_t f) return rc; } -uint8_t z80_memfifo_getc(const fifo_t f) + +uint8_t z80_memfifo_getc_wait(const fifo_t f) { uint8_t rc, idx; @@ -563,6 +563,24 @@ uint8_t z80_memfifo_getc(const fifo_t f) return rc; } +int z80_memfifo_getc(const fifo_t f) +{ + int rc = -1; + + if (fifo_dsc[f].base != 0) { + uint8_t idx = fifo_dsc[f].idx_out; + z80_bus_cmd(Request); + if (idx != z80_read(fifo_dsc[f].base + FIFO_INDEX_IN)) { + rc = z80_read(fifo_dsc[f].base+idx); + fifo_dsc[f].idx_out = ++idx & fifo_dsc[f].mask; + z80_write(fifo_dsc[f].base+FIFO_INDEX_OUT, fifo_dsc[f].idx_out); + } + z80_bus_cmd(Release); + } + + return rc; +} + void z80_memfifo_putc(fifo_t f, uint8_t val) { |