-
Notifications
You must be signed in to change notification settings - Fork 0
/
inesi.h
111 lines (97 loc) · 2.74 KB
/
inesi.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* ___________________________
* / /___/ /|
* / /===/ / |
* / _______________ /===/ / /
* /___/______________//___/__/ /
* | | INESI || | | /
* | |_____________||_ _| |/
* \ o I-I I-I |L L| /
* \_________________|___|__/
*/
#ifndef INESI_H_
#define INESI_H_
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#define INES_ROM_SIZE_TOO_BIG UINT64_MAX
typedef enum {
INES_NA_HORIZONTAL = 0,
INES_NA_VERTICAL = 1
} INES_NametableArrangement;
typedef enum {
INES_TVS_NTSC = 0,
INES_TVS_PAL = 1
} INES_TV_System;
typedef enum {
INES_S_NES,
INES_S_VS_SYSTEM,
INES_S_PLAYCHOICE_10,
INES_S_OTHER,
} INES_System;
typedef enum {
INES_HT_UNKNOWN,
//INES_HT_TNES,
INES_HT_INES_ARCHAIC,
//INES_HT_INES_0_7,
INES_HT_INES,
INES_HT_NES_2_0,
} INES_HeaderType;
typedef enum {
INES_T_NTSC,
INES_T_LICENSED_PAL,
INES_T_MULTIREGION,
INES_T_DENDY,
} INES_Timing;
typedef struct {
uint64_t mPRG_ROM_B;
uint64_t mCHR_ROM_B;
INES_NametableArrangement mNametableArrangement;
bool mHasBattery;
bool mHasTrainer;
bool mHasAlternativeNametableLayout;
INES_HeaderType mHeaderType;
union HeaderTypeVariant_t {
struct INES_HT_INES_ARCHAIC_t {
uint32_t mMapper;
int8_t mAuthor[10];
} INES_HT_INES_ARCHAIC;
struct INES_HT_INES_t {
uint32_t mMapper;
INES_TV_System mTV_System;
INES_System mSystem;
uint16_t mPRG_RAM_8kB_Banks;
int8_t mAuthor[7];
} INES_HT_INES;
struct INES_HT_NES_2_0_t {
uint32_t mMapper;
INES_TV_System mTV_System;
INES_System mSystem;
union SystemVariant_t {
struct INES_S_VS_SYSTEM_t {
uint8_t mPPU_Type;
uint8_t mHardwareType;
} INES_S_VS_SYSTEM;
struct INES_S_OTHER_t {
uint8_t mType;
} INES_S_OTHER;
} mSystemVariant;
uint16_t mPRG_VolatileRAM_B;
uint16_t mPRG_NonvolatileRAM_B;
uint16_t mCHR_VolatileRAM_B;
uint16_t mCHR_NonvolatileRAM_B;
uint8_t mMapperVariant;
INES_Timing mTiming;
uint8_t mMiscellaneousROM_Count;
uint8_t mDefaultExpansionDevice;
} INES_HT_NES_2_0;
} mHeaderTypeVariant;
} INES_HeaderInfo;
/**
* Parses file header in INES format.
* @param arHeader Raw Header Data
* @param rrInfo Resulting Parsed Header Info
* @result Returns `true` if parsed successfully.
*/
bool parseHeader(uint8_t const arHeader[static 15], INES_HeaderInfo rrInfo[static 1]);
#endif