-
Notifications
You must be signed in to change notification settings - Fork 1
/
Cartridge.h
67 lines (53 loc) · 1.53 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
#pragma once
#include "Types.h"
class Cartridge
{
public:
enum class MirroringType : byte
{
Horizontal = 0,
Vertical,
Count
};
static constexpr const char* MirroringTypeString [ static_cast< size_t >( MirroringType::Count ) ] =
{
"Horizontal",
"Vertical"
};
struct Header
{
u32 prgRomSizeKB;
u32 chrRomSizeKB;
Cartridge::MirroringType mirroringType;
bool hasPersistentMemory;
bool hasPRGRam;
bool has512BTrainer;
bool ignoreMirroring;
byte mapper;
Header()
: prgRomSizeKB( 0 )
, chrRomSizeKB( 0 )
, mirroringType( Cartridge::MirroringType::Horizontal )
, hasPersistentMemory( false )
, hasPRGRam( false )
, has512BTrainer( false )
, ignoreMirroring( false )
, mapper( 0x00 )
{
}
};
Cartridge( const char *fileName );
~Cartridge();
void PrintDetails() const;
bool IsLoaded() const;
const Header& GetHeader() const;
const byte * const GetRom() const;
private:
u32 cartridgeSize;
const char* romFileName;
byte* rom;
bool isLoaded;
Cartridge::Header header;
bool TryLoad( const char *romFile );
bool TryLoadHeader();
};