1#pragma once
2#include "common.hpp"
3#include <Nes_Apu.h>
4
5namespace CPU {
6
7
8enum IntType { NMI, RESET, IRQ, BRK }; // Interrupt type.
9typedef u16 (*Mode)(void); // Addressing mode.
10
11/* Processor flags */
12enum Flag {C, Z, I, D, V, N};
13class 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
25void set_nmi(bool v = true);
26void set_irq(bool v = true);
27int dmc_read(void*, cpu_addr_t addr);
28void power();
29void run_frame();
30
31
32}
33