1 | #pragma once |
2 | #include "common.hpp" |
3 | #include <Nes_Apu.h> |
4 | |
5 | namespace CPU { |
6 | |
7 | |
8 | enum IntType { NMI, RESET, IRQ, BRK }; // Interrupt type. |
9 | typedef u16 (*Mode)(void); // Addressing mode. |
10 | |
11 | /* Processor flags */ |
12 | enum Flag {C, Z, I, D, V, N}; |
13 | class Flags |
14 | { |
15 | bool f[6]; |
16 | |
17 | public: |
18 | bool& operator[] (const int i) { return f[i]; } |
19 | |
20 | u8 get() { return f[C] | f[Z] << 1 | f[I] << 2 | f[D] << 3 | 1 << 5 | f[V] << 6 | f[N] << 7; } |
21 | void set(u8 p) { f[C] = NTH_BIT(p, 0); f[Z] = NTH_BIT(p, 1); f[I] = NTH_BIT(p, 2); |
22 | f[D] = NTH_BIT(p, 3); f[V] = NTH_BIT(p, 6); f[N] = NTH_BIT(p, 7); } |
23 | }; |
24 | |
25 | void set_nmi(bool v = true); |
26 | void set_irq(bool v = true); |
27 | int dmc_read(void*, cpu_addr_t addr); |
28 | void power(); |
29 | void run_frame(); |
30 | |
31 | |
32 | } |
33 | |