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.
vor 3 Jahren |
123456789101112131415161718192021222324252627282930313233343536373839 |
- #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);
|