diff --git a/src/emulation.c b/src/emulation.c index 97ba34d..a342d95 100644 --- a/src/emulation.c +++ b/src/emulation.c @@ -280,6 +280,7 @@ void emul_stp(rk65c02emu_t *e, void *id, instruction_t *i) { e->state = STOPPED; + e->stopreason = STP; } /* STA - store accumulator */ diff --git a/src/rk65c02.c b/src/rk65c02.c index 77be08b..b2b59d7 100644 --- a/src/rk65c02.c +++ b/src/rk65c02.c @@ -45,6 +45,7 @@ rk65c02_start(rk65c02emu_t *e) { printf("unimplemented opcode %X @ %X\n", i.opcode, e->regs.PC); e->state = STOPPED; + e->stopreason = EMUERROR; } } } diff --git a/src/rk65c02.h b/src/rk65c02.h index 265080b..a21128e 100644 --- a/src/rk65c02.h +++ b/src/rk65c02.h @@ -6,9 +6,17 @@ typedef enum { STOPPED, RUNNING, - STEPPING + STEPPING /* XXX: how to implement? */ } emu_state_t; +typedef enum + STP, /* due to 65C02 STP instruction */ + BREAKPOINT, /* due to breakpoint set */ + WATCHPOINT, /* due to watchpoint set */ + HOST, /* due to host stop function called */ + EMUERROR /* due to emulator error */ +} emu_stop_reason_t; + struct reg_state { uint8_t A; /* accumulator */ uint8_t X; /* index X */ @@ -41,6 +49,7 @@ struct rk65c02emu { emu_state_t state; bus_t *bus; reg_state_t regs; + emu_stop_reason_t stopreason; }; typedef struct rk65c02emu rk65c02emu_t;