82#define STALL_THRESHOLD 256
95#define PRINT_CMD_IS_PUT(cmd) ((cmd) & 0x80)
96#define PRINT_LEN_MAX 256
97#define KBD_CMD_LINE 0x40
98#define KBD_CMD_CHAR 0x41
107#define LP_CMD_WRITE 0x42
108#define IS_OUTPUT_CMD(cmd) (PRINT_CMD_IS_PUT(cmd) || (cmd) == LP_CMD_WRITE)
112#define Z_CHANNEL2_BIT 0x01
113#define ORDER_IS_CHANNEL2(ge, base) (((ge)->mem[(uint16_t)(base)] & Z_CHANNEL2_BIT) != 0)
115#define STDIO_STATUS_ADDR 0x0030
116#define STDIO_COUNT_ADDR 0x0032
117#define LP_CMD_SINGLE_SPACE 0x2E
118#define LP_CMD_TRIPLE_SPACE 0x5A
128 if (p->out_len >= (
int)
sizeof(p->out) - 1)
130 p->out[p->out_len++] = c;
131 p->out[p->out_len] =
'\0';
136 for (
int i = 0; i < count; i++)
154static int kbd_ready(
const struct ge_integrated_printer *p)
156 return p->kbd_head != p->kbd_tail;
161 for (
int i = p->kbd_head; i != p->kbd_tail; i = (i + 1) % (
int)
sizeof(p->kbd)) {
162 if (p->kbd[i] ==
'\n' || p->kbd[i] ==
'\r')
168static uint8_t
kbd_pop(
struct ge_integrated_printer *p)
170 uint8_t c = p->kbd[p->kbd_head];
171 p->kbd_head = (p->kbd_head + 1) % (
int)
sizeof(p->kbd);
178 int max = (len > 0) ? len - 1 : 0;
211 return len > 0 ? 1 : 0;
257 return ge->
rSO == 0xb8 &&
284 if (p->out_remaining > 0) {
293 ge->
rSO = p->out_saved_so;
294 if (p->out_line_mode)
299 p->out_line_mode = 0;
308 if (
ge->
rSO == 0xc8) {
323 uint8_t cmd =
ge->
mem[(uint16_t)(base + 1)];
324 int len = (
ge->
mem[(uint16_t)(base + 2)] << 8) |
325 ge->
mem[(uint16_t)(base + 3)];
326 uint16_t buf = (
ge->
mem[(uint16_t)(base + 4)] << 8) |
327 ge->
mem[(uint16_t)(base + 5)];
368 int control_ready =
ge->
RC00 &&
372 if (write_ready || input_ready || control_ready) {
473 int next = (p->kbd_tail + 1) % (
int)
sizeof(p->kbd);
474 if (next == p->kbd_head)
476 p->
kbd[p->kbd_tail] = c;
void ge_mem_store8(struct ge *ge, uint16_t addr, uint8_t val)
Store a byte with generated odd parity + mark-written (for the hybrid ALU/SS write paths that write g...
int ge_register_peri(struct ge *ge, struct ge_peri *p)
uint8_t ge_code(uint8_t c)
static void printer_capture_control(struct ge_integrated_printer *p, uint8_t cmd)
#define STDIO_STATUS_ADDR
static int service_input_char(struct ge *ge, uint16_t buf, int len)
int printer_output_len(struct ge *ge)
static int printer_on_clock(struct ge *ge, void *opaque)
static void printer_capture_breaks(struct ge_integrated_printer *p, int count)
static void store16(struct ge *ge, uint16_t addr, uint16_t value)
#define LP_CMD_SINGLE_SPACE
static void printer_capture_char(struct ge_integrated_printer *p, char c)
static int in_channel2_print_wait(struct ge *ge)
void printer_begin_output(struct ge *ge, uint16_t buffer, int length, int line_mode)
int printer_register(struct ge *ge)
const char * printer_output(struct ge *ge)
static int input_order_ready(struct ge *ge, uint8_t cmd)
static int printer_deinit(struct ge *ge, void *opaque)
void printer_feed_key(struct ge *ge, uint8_t c)
static uint8_t kbd_pop(struct ge_integrated_printer *p)
#define ORDER_IS_CHANNEL2(ge, base)
#define IS_OUTPUT_CMD(cmd)
static int kbd_has_complete_line(const struct ge_integrated_printer *p)
void printer_output_clear(struct ge *ge)
static void printer_sink(struct ge *ge, struct ge_channel *ch, uint8_t c)
#define LP_CMD_TRIPLE_SPACE
static int kbd_ready(const struct ge_integrated_printer *p)
static int service_input_line(struct ge *ge, uint16_t buf, int len)
static int channel1_reader_owns_the_order(struct ge *ge)
int(* on_pulse)(struct ge *, void *)
int(* init)(struct ge *, void *)
int(* deinit)(struct ge *, void *)
int(* on_clock)(struct ge *, void *)
The entire state of the emulated system, including registers, memory, peripherals and timings.
struct ge_integrated_reader integrated_reader
The I/O interface for the integrated reader (RI)
uint16_t rV1
Addresser for the first operand.
uint8_t rSO
Main sequencer.
uint8_t PUC2
Channel 2 in transfer.
uint8_t RC00
Asynchronous CPU Cycle Request.
uint8_t mem[MEM_SIZE]
The memory of the emulated system.
struct ge_channel channel2
Integrated channel 2 (CAN2) line bundle — shared by the integrated reader (input),...
uint16_t rV4
Addresser for external instructions using channel 2.
uint8_t rSA
Future state configuration.
uint8_t RC02
Asynchronous Channel 2 Cycle Request.
uint8_t rSI
Peripheral unit sequencer.
struct ge::ge_integrated_printer integrated_printer