1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2025-08-07 11:26:57 +00:00

Add struct with info about reason for stopping emulation.

This commit is contained in:
Radosław Kujawa
2017-01-26 12:52:40 +01:00
parent 13ef3e2d08
commit 941e89173a
3 changed files with 12 additions and 1 deletions

View File

@@ -280,6 +280,7 @@ void
emul_stp(rk65c02emu_t *e, void *id, instruction_t *i) emul_stp(rk65c02emu_t *e, void *id, instruction_t *i)
{ {
e->state = STOPPED; e->state = STOPPED;
e->stopreason = STP;
} }
/* STA - store accumulator */ /* STA - store accumulator */

View File

@@ -45,6 +45,7 @@ rk65c02_start(rk65c02emu_t *e) {
printf("unimplemented opcode %X @ %X\n", i.opcode, printf("unimplemented opcode %X @ %X\n", i.opcode,
e->regs.PC); e->regs.PC);
e->state = STOPPED; e->state = STOPPED;
e->stopreason = EMUERROR;
} }
} }
} }

View File

@@ -6,9 +6,17 @@
typedef enum { typedef enum {
STOPPED, STOPPED,
RUNNING, RUNNING,
STEPPING STEPPING /* XXX: how to implement? */
} emu_state_t; } 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 { struct reg_state {
uint8_t A; /* accumulator */ uint8_t A; /* accumulator */
uint8_t X; /* index X */ uint8_t X; /* index X */
@@ -41,6 +49,7 @@ struct rk65c02emu {
emu_state_t state; emu_state_t state;
bus_t *bus; bus_t *bus;
reg_state_t regs; reg_state_t regs;
emu_stop_reason_t stopreason;
}; };
typedef struct rk65c02emu rk65c02emu_t; typedef struct rk65c02emu rk65c02emu_t;