forked from amhndu/SimpleNES
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mapper.h
53 lines (43 loc) · 1.27 KB
/
Mapper.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
48
49
50
51
52
53
#ifndef MAPPER_H
#define MAPPER_H
#include "Cartridge.h"
#include <memory>
#include <functional>
namespace sn
{
enum NameTableMirroring
{
Horizontal = 0,
Vertical = 1,
FourScreen = 8,
OneScreenLower,
OneScreenHigher,
};
class Mapper
{
public:
enum Type
{
NROM = 0,
SxROM = 1,
UxROM = 2,
CNROM = 3,
};
Mapper(Cartridge& cart, Type t) : m_cartridge(cart), m_type(t) {};
virtual void writePRG (Address addr, Byte value) = 0;
virtual Byte readPRG (Address addr) = 0;
virtual const Byte* getPagePtr (Address addr) = 0; //for DMAs
virtual Byte readCHR (Address addr) = 0;
virtual void writeCHR (Address addr, Byte value) = 0;
virtual NameTableMirroring getNameTableMirroring();
bool inline hasExtendedRAM()
{
return m_cartridge.hasExtendedRAM();
}
static std::unique_ptr<Mapper> createMapper (Type mapper_t, Cartridge& cart, std::function<void(void)> mirroring_cb);
protected:
Cartridge& m_cartridge;
Type m_type;
};
}
#endif //MAPPER_H