-
Notifications
You must be signed in to change notification settings - Fork 0
/
Memory.h
65 lines (49 loc) · 1.28 KB
/
Memory.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
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
#include "Types.h"
#include "Controller.h"
#include <iostream>
#include <fstream>
class GB;
class Serializer;
class Memory {
private:
byte *m_MMU;
byte *m_Cartridge;
byte *m_CartridgeRAM;
byte *m_VRAM;
byte *m_WRAM;
byte *m_PaletteData;
GB *gb;
const char *rom_fpath;
int currentROMBank;
byte currentRAMBank;
byte currentWRAMBank;
bool ramEnabled;
bool ramBankingMode;
byte MBCMode;
bool HDMAActive;
word HDMASrc;
word HDMADest;
int HDMALength;
Controller &controller;
void ToggleRAMEnabled(const word& address, const byte& val);
void ChangeBanks(const word& address, const byte& val);
public:
Memory(GB *gb, Controller &controller);
~Memory();
void Reset();
void Serialize(Serializer & s);
void Deserialize(Serializer & s);
void LoadROM(const char* fname);
byte ReadByte(const word& address);
word ReadWord(const word& address);
void WriteByte(const word& address, const byte& val);
void WriteWord(const word& address, const word& val);
void WriteByteDirect(const word& address, const byte& data);
byte ReadVRAM(const word& address, const int& bankNumber);
word GetPaletteData(const word& address);
void InitiateDMATransfer(const byte& params);
void HandleHBlank();
void SaveRAM();
void LoadRAM();
};