-
Notifications
You must be signed in to change notification settings - Fork 0
/
MMU.h
57 lines (48 loc) · 1.29 KB
/
MMU.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
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <time.h>
#ifndef MMU_H
#define MMU_H
class MMU {
public:
MMU ();
uint8_t GetByteAt (uint16_t Address);
void SetByteAt (uint16_t Address, uint8_t Value);
uint16_t GetWordAt (uint16_t Address);
void SetWordAt (uint16_t Address, uint16_t Value);
/* Memory Layout:
Interrupt Register: 0xFFFF
Internal RAM: 0xFF80
Empty, unusable for I/O: 0xFF4C
Memory Mapped I/O: 0xFF00
Empty, unusable for I/O: 0xFEA0
Sprite Attrib Memory (OAM): 0xFE00
8KB Internal RAM Mirrored: 0xE000
8KB Internal RAM: 0xC000
8KB switchable RAM bank: 0xA000
8KB VRAM: 0x8000
16KB Switchable ROM bank: 0x4000
16KB ROM bank #0: 0x0000
*/
// ROM Config
uint8_t ROM [8 * 1024 * 1024]; // 8MB Max
uint8_t ExternalRAM [16 * 0x2000]; // 16 RAM Banks Max
uint8_t ROMType = 0;
uint8_t ROMBattery = 0;
uint8_t ROMRAM = 0;
// ROM Status
uint8_t ExternalRAMEnabled = 0;
uint8_t CurrentRAMBank = 0;
uint8_t CurrentROMBank = 1; // Default
uint8_t SelectRAMBank = 0;
uint8_t RTCRegister [0x0D];
uint8_t ExternalRAMSize = 0;
// VRAM Status
uint8_t CurrentPPUMode = 1;
// Convenience Pointers
uint8_t* IOMap = Memory + 0xFF00;
uint8_t Memory[0x10000];
};
#endif