Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
folium-app
GitHub Repository: folium-app/Folium
Path: blob/a-new-beginning/Cherry/Core/include/StandardMapper.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 STANDARDMAPPER_H
21
#define STANDARDMAPPER_H
22
23
#include "Mapper.h"
24
#include "Cartridge.h"
25
26
class StandardMapper : public Mapper
27
{
28
public:
29
StandardMapper(Cartridge* pCartridge);
30
virtual ~StandardMapper();
31
32
virtual void Reset();
33
virtual u8 Read(u16 address);
34
virtual void Write(u16 address, u8 value);
35
virtual void SaveState(std::ostream& stream);
36
virtual void LoadState(std::istream& stream);
37
};
38
39
inline StandardMapper::StandardMapper(Cartridge* pCartridge) : Mapper(pCartridge)
40
{
41
}
42
43
inline StandardMapper::~StandardMapper()
44
{
45
}
46
47
inline void StandardMapper::Reset()
48
{
49
}
50
51
inline u8 StandardMapper::Read(u16 address)
52
{
53
u8* pRom = m_pCartridge->GetROM();
54
int romSize = m_pCartridge->GetROMSize();
55
56
if (address >= (romSize + 0x8000))
57
{
58
Debug("--> ** Attempting to read from outer ROM: %X. ROM Size: %X", address, romSize);
59
return 0xFF;
60
}
61
62
return pRom[address & 0x7FFF];
63
}
64
65
inline void StandardMapper::Write(u16 address, u8 value)
66
{
67
if (m_pCartridge->HasSRAM() && (address >= 0xE000) && (address < 0xE800))
68
{
69
u8* pRom = m_pCartridge->GetROM();
70
pRom[(address + 0x800) & 0x7FFF] = value;
71
}
72
else
73
{
74
Debug("--> ** Attempting to write on ROM: %X %X", address, value);
75
}
76
}
77
78
inline void StandardMapper::SaveState(std::ostream& stream)
79
{
80
(void)stream;
81
}
82
83
inline void StandardMapper::LoadState(std::istream& stream)
84
{
85
(void)stream;
86
}
87
88
#endif /* STANDARDMAPPER_H */
89
90