#ifndef F6502_H_ #define F6502_H_ #include "serdes.h" #include #include #include "memory.h" typedef enum { f6502_Status_C = 0b00000001, f6502_Status_Z = 0b00000010, f6502_Status_I = 0b00000100, f6502_Status_D = 0b00001000, f6502_Status_B = 0b00010000, f6502_Status_1 = 0b00100000, f6502_Status_V = 0b01000000, f6502_Status_N = 0b10000000, } f6502_Status_Flag; #define f6502_Base_Stack (0x0100U) #define f6502_Vector_IRQ (0xFFFEU) #define f6502_Vector_Reset (0xFFFCU) #define f6502_Vector_NMI (0xFFFAU) typedef struct __attribute__ ((__packed__)) { uint16_t PC; uint8_t S; uint8_t A; uint8_t X; uint8_t Y; uint8_t P; } f6502_Registers; typedef enum { f6502_Int_NMI = 0b00000001, f6502_Int_IRQ = 0b00000010, f6502_Int_NMI_Serviced = 0b10000000, } f6502_Interrupt; struct f6502_Core { // Static f6502_Registers registers; f6502_Interrupt interrupts; // Specific nes_Memory memory; // Don't care uint64_t clocks; }; typedef struct f6502_Core f6502_Core; void f6502_init(f6502_Core*); void f6502_reset(f6502_Core*); int f6502_step(f6502_Core*, int clocks); void f6502_set_NMI(f6502_Core*, bool active); void f6502_set_IRQ(f6502_Core*, bool active); extern const Serdes_Item f6502_serdes[]; #endif // F6502_H_