forked from amhndu/SimpleNES
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainBus.h
47 lines (43 loc) · 1.12 KB
/
MainBus.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef MEMORY_H
#define MEMORY_H
#include <vector>
#include <map>
#include <functional>
#include <memory>
#include "Cartridge.h"
#include "Mapper.h"
namespace sn
{
enum IORegisters
{
PPUCTRL = 0x2000,
PPUMASK,
PPUSTATUS,
OAMADDR,
OAMDATA,
PPUSCROL,
PPUADDR,
PPUDATA,
OAMDMA = 0x4014,
JOY1 = 0x4016,
JOY2 = 0x4017,
};
class MainBus
{
public:
MainBus();
Byte read(Address addr);
void write(Address addr, Byte value);
bool setMapper(Mapper* mapper);
bool setWriteCallback(IORegisters reg, std::function<void(Byte)> callback);
bool setReadCallback(IORegisters reg, std::function<Byte(void)> callback);
const Byte* getPagePtr(Byte page);
private:
std::vector<Byte> m_RAM;
std::vector<Byte> m_extRAM;
Mapper* m_mapper;
std::map<IORegisters, std::function<void(Byte)>> m_writeCallbacks;
std::map<IORegisters, std::function<Byte(void)>> m_readCallbacks;;
};
};
#endif // MEMORY_H