#ifndef MOS6502_H #define MOS6502_H #include #include #define FLAG_C_BIT 0 #define FLAG_Z_BIT 1 #define FLAG_I_BIT 2 #define FLAG_D_BIT 3 #define FLAG_B_BIT 4 #define FLAG_U_BIT 5 #define FLAG_N_BIT 6 #define FLAG_V_BIT 7 #define FLAG_GET(f) ((cpu->flags & (1 << FLAG_##f##_BIT)) >> FLAG_##f##_BIT) #define FLAG_SET(f, v) (cpu->flags = (cpu->flags & ~(1 << FLAG_##f##_BIT)) | ((v) << FLAG_##f##_BIT)) extern uint8_t bus_read(uint16_t addr, uint8_t cycle); extern void bus_write(uint16_t addr, uint8_t v, uint8_t cycle); typedef struct cpu_s { uint16_t pc; uint8_t a; uint8_t x; uint8_t y; uint8_t sp; uint8_t flags; bool irq; bool nmi; bool jammed; } cpu_t; void cpu_reset(cpu_t *cpu); uint8_t cpu_step(cpu_t *cpu); #endif