Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
folium-app
GitHub Repository: folium-app/Folium
Path: blob/a-new-beginning/Cherry/Core/include/Cartridge.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 CARTRIDGE_H
21
#define CARTRIDGE_H
22
23
#include <list>
24
#include "definitions.h"
25
#include "log.h"
26
27
class Cartridge
28
{
29
public:
30
enum CartridgeTypes
31
{
32
CartridgeColecoVision,
33
CartridgeMegaCart,
34
CartridgeActivisionCart,
35
CartridgeOCM,
36
CartridgeNotSupported
37
};
38
39
enum CartridgeRegions
40
{
41
CartridgeNTSC,
42
CartridgePAL,
43
CartridgeUnknownRegion
44
};
45
46
struct ForceConfiguration
47
{
48
CartridgeTypes type;
49
CartridgeRegions region;
50
};
51
52
u8* GetEEPROM() const;
53
54
public:
55
Cartridge();
56
~Cartridge();
57
void Init();
58
void Reset();
59
u32 GetCRC() const;
60
bool IsPAL() const;
61
bool HasSRAM() const;
62
bool IsValidROM() const;
63
bool IsReady() const;
64
CartridgeTypes GetType() const;
65
void ForceConfig(ForceConfiguration config);
66
int GetROMSize() const;
67
int GetROMBankCount() const;
68
const char* GetFilePath() const;
69
const char* GetFileName() const;
70
u8* GetROM() const;
71
bool LoadFromFile(const char* path);
72
bool LoadFromBuffer(const u8* buffer, int size);
73
74
private:
75
bool GatherMetadata(u32 crc);
76
void GetInfoFromDB(u32 crc);
77
bool LoadFromZipFile(const u8* buffer, int size);
78
79
private:
80
u8* m_pROM;
81
int m_iROMSize;
82
CartridgeTypes m_Type;
83
bool m_bValidROM;
84
bool m_bReady;
85
char m_szFilePath[512];
86
char m_szFileName[512];
87
int m_iROMBankCount;
88
bool m_bPAL;
89
u32 m_iCRC;
90
bool m_bSRAM;
91
u8* m_pEEPROM;
92
};
93
94
#endif /* CARTRIDGE_H */
95
96