42#define STALL_THRESHOLD 256
55#define PRINT_CMD_IS_PUT(cmd) ((cmd) & 0x80)
56#define PRINT_LEN_MAX 256
57#define KBD_CMD_LINE 0x40
58#define KBD_CMD_CHAR 0x41
67#define LP_CMD_WRITE 0x42
68#define IS_OUTPUT_CMD(cmd) (PRINT_CMD_IS_PUT(cmd) || (cmd) == LP_CMD_WRITE)
70#define STDIO_STATUS_ADDR 0x0030
71#define STDIO_COUNT_ADDR 0x0032
72#define LP_CMD_SINGLE_SPACE 0x2E
73#define LP_CMD_TRIPLE_SPACE 0x5A
75static void store16(
struct ge *
ge, uint16_t addr, uint16_t value)
83 if (p->out_len >= (
int)
sizeof(p->out) - 1)
85 p->out[p->out_len++] = c;
86 p->out[p->out_len] =
'\0';
91 for (
int i = 0; i < count; i++)
109static int kbd_ready(
const struct ge_integrated_printer *p)
111 return p->kbd_head != p->kbd_tail;
116 for (
int i = p->kbd_head; i != p->kbd_tail; i = (i + 1) % (
int)
sizeof(p->kbd)) {
117 if (p->kbd[i] ==
'\n' || p->kbd[i] ==
'\r')
123static uint8_t
kbd_pop(
struct ge_integrated_printer *p)
125 uint8_t c = p->kbd[p->kbd_head];
126 p->kbd_head = (p->kbd_head + 1) % (
int)
sizeof(p->kbd);
133 int max = (len > 0) ? len - 1 : 0;
166 return len > 0 ? 1 : 0;
184 return ge->
rSO == 0xb8 &&
211 if (p->out_remaining > 0) {
220 ge->
rSO = p->out_saved_so;
221 if (p->out_line_mode)
226 p->out_line_mode = 0;
235 if (
ge->
rSO == 0xc8) {
246 uint8_t cmd =
ge->
mem[(uint16_t)(base + 1)];
247 int len = (
ge->
mem[(uint16_t)(base + 2)] << 8) |
248 ge->
mem[(uint16_t)(base + 3)];
249 uint16_t buf = (
ge->
mem[(uint16_t)(base + 4)] << 8) |
250 ge->
mem[(uint16_t)(base + 5)];
281 int control_ready =
ge->
RC00 &&
285 if (write_ready || input_ready || control_ready) {
386 int next = (p->kbd_tail + 1) % (
int)
sizeof(p->kbd);
387 if (next == p->kbd_head)
389 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 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)
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