-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmemory.h
More file actions
76 lines (58 loc) · 1.18 KB
/
memory.h
File metadata and controls
76 lines (58 loc) · 1.18 KB
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
66
67
68
69
70
71
72
73
74
75
76
// This file is part of the PiEMU Project
// Licensing information can be found in the LICENSE file
// (C) 2014 Nandor Licker. All rights reserved.
#ifndef __MEMORY_H__
#define __MEMORY_H__
/**
* Emulator foward declaration
*/
class Emulator;
/**
* Memory module
*/
class Memory
{
public:
/**
* Creates a new memory module
*/
Memory(Emulator &emu, uint32_t sdramSize, uint32_t vramSize);
/**
* Destroys the memory module
*/
~Memory();
/**
* Loads an image into RAM
* @param image Path to an image file
* @param start Address of the image file
*/
void LoadImage(const std::string& image, size_t start);
/**
* Returns a word from memory
*/
uint16_t GetInstrWord(uint32_t addr)
{
return *((uint16_t*)(ram + addr));
}
/**
* Returns a long from memory
*/
uint32_t GetLong(uint32_t addr)
{
return *((uint32_t*)(ram + addr));
}
private:
/// Reference to the emulator
Emulator &emu;
/// Size of SDRAM
uint32_t ramSize;
/// RAM
uint8_t *ram;
/// Size of VRAM
uint32_t vramSize;
/// VRAM (pointer inside sdram)
uint8_t *vram;
/// ROM (pointer inside sdram)
uint8_t *rom;
};
#endif /*__MEMORY_H__*/