diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-05-06 12:06:02 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-05-06 12:13:00 +0100 |
commit | 2f50827c3d2bb48e79f202cd084de08b5ad65732 (patch) | |
tree | 3027a753af4ae891d5de4baa997846f11b28f58c /vm.c | |
parent | dd194bf4de0d54cef7e14aeb7576d799acb61840 (diff) | |
download | tr8vm-2f50827c3d2bb48e79f202cd084de08b5ad65732.tar.gz tr8vm-2f50827c3d2bb48e79f202cd084de08b5ad65732.zip |
Implement hardware blitter
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -69,12 +69,6 @@ static uint8_t flags(uint8_t *f, uint16_t v, uint8_t mask) return v; } -static uint8_t port(uint8_t p, uint8_t v) -{ - /* TODO */ - return p ^ v; -} - static void dump(Tr8 *vm) { uint8_t i; @@ -113,11 +107,12 @@ static void dump(Tr8 *vm) fprintf(stderr, "****\n"); } -void tr8_init(Tr8 *vm, void (*write_m)(uint16_t, uint8_t), uint8_t (*read_m)(uint16_t)) +void tr8_init(Tr8 *vm, void (*write_m)(uint16_t, uint8_t), uint8_t (*read_m)(uint16_t), uint8_t (*port)(uint8_t, uint8_t)) { memset(vm, 0, sizeof(Tr8)); vm->write_m = write_m; vm->read_m = read_m; + vm->port = port; vm->f = IF; } @@ -181,7 +176,7 @@ uint8_t tr8_eval(Tr8 *vm) return 1; } /* PORT r1, r3 */ - vm->regs[R1(instr)] = port(vm->regs[R1(instr)], vm->regs[R3(instr)]); + vm->regs[R1(instr)] = vm->port(vm->regs[R1(instr)], vm->regs[R3(instr)]); } else { @@ -329,7 +324,8 @@ uint8_t tr8_eval(Tr8 *vm) /* BIT r1, im */ flags(&vm->f, vm->regs[R1(instr)] & (1 << (IMM(instr) & 7)) ? 0 : 1, ZF); } - else { + else + { if (FHL(instr)) /* SHL r1, im */ vm->regs[R1(instr)] = flags(&vm->f, vm->regs[R1(instr)] << (IMM(instr) & 7), ZF | CF | SF); @@ -481,6 +477,12 @@ uint8_t read_m(uint16_t addr) return ram[addr]; } +uint8_t port(uint8_t p, uint8_t v) +{ + (void)p; + return v; +} + int main(int argc, char *argv[]) { FILE *fd; @@ -517,7 +519,7 @@ int main(int argc, char *argv[]) } fclose(fd); - tr8_init(&vm, write_m, read_m); + tr8_init(&vm, write_m, read_m, port); return tr8_eval(&vm); } |