forked from czajowaty/ad_resources_dumper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdDefinitions.hpp
169 lines (142 loc) · 2.93 KB
/
AdDefinitions.hpp
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#ifndef ADDEFINITIONS_HPP
#define ADDEFINITIONS_HPP
#include "PsxRamAddress.hpp"
#include <QRect>
enum class GameMode : uint16_t
{
None = 0,
InTown = 1,
InTower = 2,
TitleScreen = 3
};
struct PortraitData
{
PsxRamAddress portraitMemoryLoadInfoAddress;
PsxRamAddress animationAddress;
};
struct MemoryLoadInfo
{
uint32_t address : 23;
uint32_t sectorsNumber : 9;
uint32_t sector;
};
struct GameModeData
{
PsxRamAddress loopFunctionAddress;
PsxRamAddress memoryLoadInfoAddress;
};
enum class ResourceType : uint16_t
{
None = 0,
VRamLoadablePackedImage = 1,
Palette = 2,
PackedImage = 3
};
struct ResourceHeader
{
ResourceType type;
uint16_t headerSize;
uint32_t dataStartOffset;
};
struct Rect
{
uint16_t x;
uint16_t y;
uint16_t width;
uint16_t height;
QRect toQRect() const
{ return QRect(x, y, width, height); }
};
struct ResourceType1Header : ResourceHeader
{
Rect rect;
};
struct PaletteResourcePosition
{
uint16_t x : 6;
uint16_t yOffsetFromY448 : 6;
uint16_t xShiftFlag : 1;
bool isXShiftFlagSet() const
{ return xShiftFlag != 0; }
};
struct PaletteResourceFlags
{
uint16_t value;
bool shouldCopyToVRam() const
{ return (value & 1) == 0; }
};
struct ResourceType2Header : ResourceHeader
{
PaletteResourcePosition position;
uint16_t numberOf4BppPalettes;
PaletteResourceFlags flags;
};
struct ResourceType3Header : ResourceHeader
{
uint32_t unpackedDataOffset;
};
enum class AnimationFrameType : uint16_t
{
NoAnimation = 0,
LastFrame = 1,
NotLastFrame = 2,
};
struct Animation
{
uint8_t duration;
uint8_t padding;
AnimationFrameType frameType;
PsxRamAddress graphicAddress;
};
struct Clut
{
uint16_t x : 6;
uint16_t y : 9;
};
enum class TexpageBpp : uint16_t
{
BPP_4 = 0,
BPP_8 = 1,
BPP_15 = 2
};
struct Texpage
{
uint16_t x : 4;
uint16_t y : 1;
uint16_t semiTransparency : 2;
uint16_t bpp : 2;
uint16_t ditherEnabled : 1;
uint16_t drawingToDisplayAreaAllowed : 1;
uint16_t textureDisable : 1;
uint16_t xFlip : 1;
uint16_t yFlip : 1;
TexpageBpp texpageBpp() const
{ return static_cast<TexpageBpp>(bpp); }
};
enum class GraphicFlags : uint8_t
{
None = 0x0,
FlipHorizontally = 0x1,
FlipVertically = 0x2,
PartOfSeries = 0x40,
SeriesEnd = 0x80
};
GraphicFlags operator|(GraphicFlags one, GraphicFlags other);
GraphicFlags operator&(GraphicFlags one, GraphicFlags other);
GraphicFlags operator^(GraphicFlags one, GraphicFlags other);
struct Graphic
{
GraphicFlags flags;
uint8_t padding;
int8_t xOffset;
int8_t yOffset;
Texpage texpage;
Clut clut;
uint8_t xOffsetInTexpage;
uint8_t yOffsetInTexpage;
uint8_t width;
uint8_t height;
bool hasFlags(GraphicFlags expectedflags) const
{ return (flags & expectedflags) == expectedflags; }
};
#endif // ADDEFINITIONS_HPP