28#define TAPE_IMAGE_MAX (1u << 20)
81 t->
pos += 2 + (size_t)len;
100 uint8_t *buf, uint16_t *len, uint16_t cap)
124 const uint8_t *rec = t->
image + t->
pos + 2;
126 for (
long i = 0; i < rl && (size_t)(t->
pos + 2 + i) < t->
nbytes
127 && n + 2 <= cap; i++) {
128 buf[n++] = (uint8_t)(rec[i] >> 4);
129 buf[n++] = (uint8_t)(rec[i] & 0x0F);
134 t->
pos += 2 + (size_t)rl;
141 struct tape_ctx *t = calloc(1,
sizeof(*t));
157 FILE *f = fopen(image_path,
"rb");
164 ge_log(
LOG_ERR,
"tape: cannot open %s (blank reel)\n", image_path);
int connector34_init(struct ge *ge)
int connector34_attach(struct ge *ge, struct ge_std_device *dev, uint8_t connector)
void ge_log(ge_log_type type, const char *format,...)
Log message.
@ LOG_ERR
Emulator unrecoverable condition.
@ LOG_PERI
Peripherals IO.
void(* tick)(struct ge *, void *ctx)
int(* claims)(void *ctx, struct std_unitname un)
std_reaction(* command)(struct ge *, void *ctx, struct std_unitname un, uint8_t order)
std_reaction(* transfer)(struct ge *, void *ctx, struct std_unitname un, int dir, uint8_t *buf, uint16_t *len, uint16_t cap)
The entire state of the emulated system, including registers, memory, peripherals and timings.
static std_reaction tape_command(struct ge *ge, void *opaque, struct std_unitname un, uint8_t order)
static int tape_claims(void *opaque, struct std_unitname un)
static long record_len(struct tape_ctx *t, size_t pos)
int tape_register(struct ge *ge, const char *image_path, uint8_t connector, uint8_t unit)
static std_reaction tape_transfer(struct ge *ge, void *opaque, struct std_unitname un, int dir, uint8_t *buf, uint16_t *len, uint16_t cap)