forked from drhelius/Gearboy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCartridge.h
95 lines (85 loc) · 2.39 KB
/
Cartridge.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* Gearboy - Nintendo Game Boy Emulator
* Copyright (C) 2012 Ignacio Sanchez
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
*
*/
#ifndef CARTRIDGE_H
#define CARTRIDGE_H
#include "definitions.h"
class Cartridge
{
public:
enum CartridgeTypes
{
CartridgeNoMBC,
CartridgeMBC1,
CartridgeMBC2,
CartridgeMBC3,
CartridgeMBC5,
CartridgeMBC1Multi,
CartridgeNotSupported
};
public:
Cartridge();
~Cartridge();
void Init();
void Reset();
bool IsValidROM() const;
bool IsLoadedROM() const;
CartridgeTypes GetType() const;
int GetRAMSize() const;
int GetROMSize() const;
int GetROMBankCount() const;
int GetRAMBankCount() const;
const char* GetName() const;
const char* GetFilePath() const;
const char* GetFileName() const;
int GetTotalSize() const;
bool HasBattery() const;
u8* GetTheROM() const;
bool LoadFromFile(const char* path);
bool LoadFromBuffer(const u8* buffer, int size);
int GetVersion() const;
bool IsSGB() const;
bool IsCGB() const;
void UpdateCurrentRTC();
time_t GetCurrentRTC();
bool IsRTCPresent() const;
bool IsRumblePresent() const;
private:
unsigned int Pow2Ceil(unsigned int n);
bool GatherMetadata();
bool LoadFromZipFile(const u8* buffer, int size);
void CheckCartridgeType(int type);
private:
u8* m_pTheROM;
int m_iTotalSize;
char m_szName[16];
int m_iROMSize;
int m_iRAMSize;
CartridgeTypes m_Type;
bool m_bValidROM;
bool m_bCGB;
bool m_bSGB;
int m_iVersion;
bool m_bLoaded;
time_t m_RTCCurrentTime;
bool m_bBattery;
char m_szFilePath[512];
char m_szFileName[512];
bool m_bRTCPresent;
bool m_bRumblePresent;
int m_iRAMBankCount;
int m_iROMBankCount;
};
#endif /* CARTRIDGE_H */