Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
folium-app
GitHub Repository: folium-app/Folium
Path: blob/a-new-beginning/Cherry/Core/include/CVMemory.h
2 views
1
/*
2
* Gearcoleco - ColecoVision Emulator
3
* Copyright (C) 2021 Ignacio Sanchez
4
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* any later version.
9
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see http://www.gnu.org/licenses/
17
*
18
*/
19
20
#ifndef MEMORY_H
21
#define MEMORY_H
22
23
#include "definitions.h"
24
#include <vector>
25
26
class Processor;
27
class Cartridge;
28
class Mapper;
29
30
class CVMemory
31
{
32
public:
33
struct stDisassembleRecord
34
{
35
u16 address;
36
char segment[5];
37
char name[32];
38
char bytes[16];
39
int size;
40
int bank;
41
u8 opcodes[4];
42
bool jump;
43
u16 jump_address;
44
};
45
46
struct stMemoryBreakpoint
47
{
48
u16 address1;
49
u16 address2;
50
bool read;
51
bool write;
52
bool range;
53
};
54
55
public:
56
CVMemory(Cartridge* pCartridge);
57
~CVMemory();
58
void SetProcessor(Processor* pProcessor);
59
void Init();
60
void Reset();
61
void SetupMapper();
62
u8 Read(u16 address);
63
void Write(u16 address, u8 value);
64
u8* GetRam();
65
u8* GetSGMRam();
66
u8* GetBios();
67
u8 GetRomBank();
68
u32 GetRomBankAddress();
69
void LoadBios(const char* szFilePath);
70
bool IsBiosLoaded();
71
void SaveState(std::ostream& stream);
72
void LoadState(std::istream& stream);
73
void ResetRomDisassembledMemory();
74
stDisassembleRecord* GetDisassembleRecord(u16 address, bool createIfNotFound);
75
stDisassembleRecord** GetDisassembledRomMemoryMap();
76
stDisassembleRecord** GetDisassembledRamMemoryMap();
77
stDisassembleRecord** GetDisassembledBiosMemoryMap();
78
stDisassembleRecord** GetDisassembledSGMRamMemoryMap();
79
std::vector<stDisassembleRecord*>* GetBreakpointsCPU();
80
std::vector<stMemoryBreakpoint>* GetBreakpointsMem();
81
stDisassembleRecord* GetRunToBreakpoint();
82
void SetRunToBreakpoint(stDisassembleRecord* pBreakpoint);
83
void EnableSGMUpper(bool enable);
84
void EnableSGMLower(bool enable);
85
void Tick(unsigned int cycles) { m_iTotalCycles += cycles; }
86
u64 GetTotalCycles() const { return m_iTotalCycles; }
87
88
private:
89
void CheckBreakpoints(u16 address, bool write);
90
91
private:
92
Processor* m_pProcessor;
93
Cartridge* m_pCartridge;
94
Mapper* m_pMapper;
95
stDisassembleRecord** m_pDisassembledRomMap;
96
stDisassembleRecord** m_pDisassembledRamMap;
97
stDisassembleRecord** m_pDisassembledBiosMap;
98
stDisassembleRecord** m_pDisassembledSGMRamMap;
99
std::vector<stDisassembleRecord*> m_BreakpointsCPU;
100
std::vector<stMemoryBreakpoint> m_BreakpointsMem;
101
stDisassembleRecord* m_pRunToBreakpoint;
102
bool m_bBiosLoaded;
103
bool m_bSGMUpper;
104
bool m_bSGMLower;
105
u8* m_pBios;
106
u8* m_pRam;
107
u8* m_pSGMRam;
108
u64 m_iTotalCycles;
109
};
110
111
#include "CVMemory_inline.h"
112
113
#endif /* MEMORY_H */
114
115