1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-01 19:10:56 +11:00
collapseos/emul/z80/acia.h
Virgil Dupras 475caf35f4 Make KEY non-blocking
... and rename it to KEY?. Then, add KEY from KEY? for its blocking
version.

I need this for an upcoming Remote Shell feature. If a Collapse OS
system remotely controls another shell, it needs to be able to poll
both the remote system and the local keyboard at the same time. A
blocking KEY is incompatible with this.

In some places, the polling mechanism doesn't make sense, so this
new KEY? always returns a character. In some places, I just haven't
implemented the mechanism yet, so I kept the old blocking code and
added a "always 1" flag as a temporary shim.

I have probably broken something, but in emulators, Collapse OS runs
fine. It's an important reminder of what will be lost with the new
"dogfooding" approach (see recent mailing list message): without
emulators, it's much harder to to sweeping changes like this without
breaking stuff.

It's fine, I don't expect many more of these core changes to the
system. It's nearly feature-complete.
2021-01-01 08:23:59 -05:00

40 lines
1.3 KiB
C

#include <stdint.h>
#include <stdbool.h>
typedef struct {
// Bit 7: interrupt status, low when interrupt request pending.
// Bit 6: Parity error
// Bit 5: Receiver overrun
// Bit 4: Framing error
// Bit 3: Clear To Send
// Bit 2: Data Carrier Detected
// Bit 1: Transmit Data Register Empty (TDRE)
// Bit 0: Receive Data Register Full (RDRF)
// We care about bits 7, 1, 0, maybe 5 later.
uint8_t status;
// Bit 7: interrupt enable
// Bits 6:5: RTS + transmit interrupt enable
// Bits 4:2: parity + stop bit
// Bits 1:0: speed divider
// We don't actually care about any of those except the interrupt enable
// bits.
uint8_t control;
uint8_t rx;
uint8_t tx;
// Will be set to true the first time acia_has_irq() is called when IRQ is
// set. Then, as long as it stays true, acia_has_irq() will return false.
// When IRQ status is reset, so is in_int.
bool in_int;
} ACIA;
void acia_init(ACIA *acia);
bool acia_has_irq(ACIA *acia);
bool acia_cantransmit(ACIA *acia);
bool acia_hastx(ACIA *acia);
uint8_t acia_read(ACIA *acia);
void acia_write(ACIA *acia, uint8_t val);
uint8_t acia_ctl_rd(ACIA *acia);
void acia_ctl_wr(ACIA *acia, uint8_t val);
uint8_t acia_data_rd(ACIA *acia);
void acia_data_wr(ACIA *acia, uint8_t val);