Retirando os externs
[NesEmulator.git] / nes6502.h
blobd31bf4856a7ac520201373a0bcbde5a95495823d
1 #ifndef __NES6502_H
2 #define __NES6502_H
4 #include "types.h"
6 #define NES6502_NUMBANKS 16
7 #define NES6502_BANKSHIFT 12
8 #define NES6502_BANKSIZE (0x10000 / NES6502_NUMBANKS)
9 #define NES6502_BANKMASK (NES6502_BANKSIZE - 1)
11 /* Stack base address (page 1) */
12 #define NES6502_STACK_OFFSET 0x100
14 /* Vector addresses */
15 #define NES6502_NMI_VECTOR 0xFFFA
16 #define NES6502_RESET_VECTOR 0xFFFC
17 #define NES6502_IRQ_VECTOR 0xFFFE
19 /* cycle counts for interrupts */
20 #define NES6502_INT_CYCLES 7
21 #define NES6502_RESET_CYCLES 6
24 /* P (flag) register bitmasks */
25 #define NES6502_C_FLAG 1
26 #define NES6502_Z_FLAG 2
27 #define NES6502_I_FLAG 4
28 #define NES6502_D_FLAG 8
29 #define NES6502_B_FLAG 16
30 #define NES6502_R_FLAG 32
31 #define NES6502_V_FLAG 64
32 #define NES6502_N_FLAG 128
34 typedef struct
36 uint32 min_range, max_range;
37 uint8 (*read_func) (uint32 address);
38 } nes6502_memread;
40 typedef struct
42 uint32 min_range, max_range;
43 void (*write_func) (uint32 address, uint8 value);
44 } nes6502_memwrite;
46 #ifdef DEBUGGER_ENABLED
47 #define NES6502_MAX_BREAKPOINTS 8
48 #define NES6502_DEBUG_READ 1
49 #define NES6502_DEBUG_WRITE 2
50 #define NES6502_DEBUG_DISABLED 128
51 typedef void (*nes6502_debugf) (int first_insn);
52 #endif
54 typedef struct
56 uint8 *mem_page[NES6502_NUMBANKS]; /* memory page pointers */
58 nes6502_memread *read_handler;
59 nes6502_memwrite *write_handler;
61 uint32 pc_reg;
62 uint32 a_reg, p_reg;
63 uint32 x_reg, y_reg;
64 uint32 s_reg;
66 int32 total_cycles;
67 int32 remaining_cycles;
68 int32 burn_cycles;
70 int halted;
71 int int_pending;
73 #ifdef DEBUGGER_ENABLED
74 nes6502_debugf debug_handler;
76 uint32 num_bp;
77 uint32 bp_addr[NES6502_MAX_BREAKPOINTS];
78 uint32 bp_mask[NES6502_MAX_BREAKPOINTS];
79 int32 bp_flags[NES6502_MAX_BREAKPOINTS];
81 #endif
82 } nes6502_context;
86 void nes6502_power (void);
87 void nes6502_reset (void);
88 void nes6502_halt (void);
89 int nes6502_ishalted (void);
90 int32 nes6502_execute (int32 cycles);
92 uint8 nes6502_readbyte (uint32 address);
93 void nes6502_writebyte (uint32 address, uint8 value);
94 uint8 nes6502_getbyte (uint32 address);
95 void nes6502_putbyte (uint32 address, uint8 value);
97 void nes6502_nmi (void);
98 void nes6502_irq (void);
99 void nes6502_burn (int32 cycles);
100 void nes6502_release (void);
102 void nes6502_setcontext (nes6502_context *cpu);
103 void nes6502_getcontext (nes6502_context *cpu);
105 #ifdef DEBUGGER_ENABLED
106 int nes6502_addbreakpoint (uint32 address, uint32 mask, int32 flags);
107 void nes6502_editbreakpoint (uint32 bp, uint32 address, uint32 mask, int32 flags);
108 void nes6502_getbreakpoint (uint32 bp, uint32 *address, uint32 *mask, int32 *flags);
109 void nes6502_removebreakpoint (uint32 bp);
110 uint32 nes6502_numbreakpoints (void);
111 #endif
113 #endif /* __NES6502_H */