-
Notifications
You must be signed in to change notification settings - Fork 124
/
Scene.hpp
263 lines (223 loc) · 6.55 KB
/
Scene.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#ifndef SCENE_H
#define SCENE_H
#define LAYER_COUNT (9)
#define DEFORM_STORE (256)
#define DEFORM_SIZE (320)
#define DEFORM_COUNT (DEFORM_STORE + DEFORM_SIZE)
#define PARALLAX_COUNT (0x100)
#define TILE_COUNT (0x400)
#define TILE_SIZE (0x10)
#define CHUNK_SIZE (0x80)
#define TILE_DATASIZE (TILE_SIZE * TILE_SIZE)
#define TILESET_SIZE (TILE_COUNT * TILE_DATASIZE)
#define TILELAYER_CHUNK_W (0x100)
#define TILELAYER_CHUNK_H (0x100)
#define TILELAYER_CHUNK_COUNT (TILELAYER_CHUNK_W * TILELAYER_CHUNK_H)
#define TILELAYER_SCROLL_COUNT (TILELAYER_CHUNK_H * CHUNK_SIZE)
#define CHUNKTILE_COUNT (0x200 * (8 * 8))
#define CPATH_COUNT (2)
enum StageListNames {
STAGELIST_PRESENTATION,
STAGELIST_REGULAR,
STAGELIST_BONUS,
STAGELIST_SPECIAL,
STAGELIST_MAX, // StageList size
};
enum TileLayerTypes {
LAYER_NOSCROLL,
LAYER_HSCROLL,
LAYER_VSCROLL,
LAYER_3DFLOOR,
LAYER_3DSKY,
};
enum StageModes {
STAGEMODE_LOAD,
STAGEMODE_NORMAL,
STAGEMODE_PAUSED,
};
enum TileInfo {
TILEINFO_INDEX,
TILEINFO_DIRECTION,
TILEINFO_VISUALPLANE,
TILEINFO_SOLIDITYA,
TILEINFO_SOLIDITYB,
TILEINFO_FLAGSA,
TILEINFO_ANGLEA,
TILEINFO_FLAGSB,
TILEINFO_ANGLEB,
};
enum DeformationModes {
DEFORM_FG,
DEFORM_FG_WATER,
DEFORM_BG,
DEFORM_BG_WATER,
};
enum CameraStyles {
CAMERASTYLE_FOLLOW,
CAMERASTYLE_EXTENDED,
CAMERASTYLE_EXTENDED_OFFSET_L,
CAMERASTYLE_EXTENDED_OFFSET_R,
CAMERASTYLE_HLOCKED,
};
struct SceneInfo {
char name[0x40];
char folder[0x40];
char id[0x40];
bool highlighted;
};
struct CollisionMasks {
sbyte floorMasks[TILE_COUNT * TILE_SIZE];
sbyte lWallMasks[TILE_COUNT * TILE_SIZE];
sbyte rWallMasks[TILE_COUNT * TILE_SIZE];
sbyte roofMasks[TILE_COUNT * TILE_SIZE];
uint angles[TILE_COUNT];
byte flags[TILE_COUNT];
};
struct TileLayer {
ushort tiles[TILELAYER_CHUNK_COUNT];
byte lineScroll[TILELAYER_SCROLL_COUNT];
int parallaxFactor;
int scrollSpeed;
int scrollPos;
int angle;
int XPos;
int YPos;
int ZPos;
int deformationOffset;
int deformationOffsetW;
byte type;
byte xsize;
byte ysize;
};
struct LineScroll {
int parallaxFactor[PARALLAX_COUNT];
int scrollSpeed[PARALLAX_COUNT];
int scrollPos[PARALLAX_COUNT];
int linePos[PARALLAX_COUNT];
int deform[PARALLAX_COUNT];
byte entryCount;
};
struct Tiles128x128 {
int gfxDataPos[CHUNKTILE_COUNT];
ushort tileIndex[CHUNKTILE_COUNT];
byte direction[CHUNKTILE_COUNT];
byte visualPlane[CHUNKTILE_COUNT];
byte collisionFlags[CPATH_COUNT][CHUNKTILE_COUNT];
};
extern int stageListCount[STAGELIST_MAX];
extern char stageListNames[STAGELIST_MAX][0x20];
extern SceneInfo stageList[STAGELIST_MAX][0x100];
extern int stageMode;
extern int cameraTarget;
extern int cameraStyle;
extern int cameraEnabled;
extern int cameraAdjustY;
extern int xScrollOffset;
extern int yScrollOffset;
extern int yScrollA;
extern int yScrollB;
extern int xScrollA;
extern int xScrollB;
extern int yScrollMove;
extern int cameraShakeX;
extern int cameraShakeY;
extern int cameraLag;
extern int cameraLagStyle;
extern int xBoundary1;
extern int newXBoundary1;
extern int yBoundary1;
extern int newYBoundary1;
extern int xBoundary2;
extern int yBoundary2;
extern int waterLevel;
extern int waterDrawPos;
extern int newXBoundary2;
extern int newYBoundary2;
extern int SCREEN_SCROLL_LEFT;
extern int SCREEN_SCROLL_RIGHT;
#define SCREEN_SCROLL_UP ((SCREEN_YSIZE / 2) - 16)
#define SCREEN_SCROLL_DOWN ((SCREEN_YSIZE / 2) + 16)
extern int lastXSize;
extern int lastYSize;
extern bool pauseEnabled;
extern bool timeEnabled;
extern bool debugMode;
extern int frameCounter;
extern int stageMilliseconds;
extern int stageSeconds;
extern int stageMinutes;
// Category and Scene IDs
extern int activeStageList;
extern int stageListPosition;
extern char currentStageFolder[0x100];
extern int actID;
extern char titleCardText[0x100];
extern byte titleCardWord2;
extern byte activeTileLayers[4];
extern byte tLayerMidPoint;
extern TileLayer stageLayouts[LAYER_COUNT];
extern int bgDeformationData0[DEFORM_COUNT];
extern int bgDeformationData1[DEFORM_COUNT];
extern int bgDeformationData2[DEFORM_COUNT];
extern int bgDeformationData3[DEFORM_COUNT];
extern LineScroll hParallax;
extern LineScroll vParallax;
extern Tiles128x128 tiles128x128;
extern CollisionMasks collisionMasks[2];
extern byte tilesetGFXData[TILESET_SIZE];
extern ushort tile3DFloorBuffer[0x100 * 0x100];
extern bool drawStageGFXHQ;
void InitFirstStage();
void ProcessStage();
void ResetBackgroundSettings();
inline void ResetCurrentStageFolder() { strcpy(currentStageFolder, ""); }
inline bool CheckCurrentStageFolder(int stage)
{
if (strcmp(currentStageFolder, stageList[activeStageList][stage].folder) == 0) {
return true;
}
else {
strcpy(currentStageFolder, stageList[activeStageList][stage].folder);
return false;
}
}
void LoadStageFiles();
int LoadActFile(const char *ext, int stageID, FileInfo *info);
int LoadStageFile(const char *filePath, int stageID, FileInfo *info);
void LoadActLayout();
void LoadStageBackground();
void LoadStageChunks();
void LoadStageCollisions();
void LoadStageGIFFile(int stageID);
void LoadStageGFXFile(int stageID);
inline void Init3DFloorBuffer(int layerID)
{
for (int y = 0; y < TILELAYER_CHUNK_H; ++y) {
for (int x = 0; x < TILELAYER_CHUNK_W; ++x) {
int c = stageLayouts[layerID].tiles[(x >> 3) + (y >> 3 << 8)] << 6;
int tx = x & 7;
tile3DFloorBuffer[x + (y << 8)] = c + tx + ((y & 7) << 3);
}
}
}
inline void Copy16x16Tile(ushort dest, ushort src)
{
if (renderType == RENDER_SW) {
byte *destPtr = &tilesetGFXData[TILELAYER_CHUNK_W * dest];
byte *srcPtr = &tilesetGFXData[TILELAYER_CHUNK_W * src];
int cnt = TILE_DATASIZE;
while (cnt--) *destPtr++ = *srcPtr++;
}
else if (renderType == RENDER_HW) {
tileUVArray[4 * dest + 0] = tileUVArray[4 * src + 0];
tileUVArray[4 * dest + 1] = tileUVArray[4 * src + 1];
tileUVArray[4 * dest + 2] = tileUVArray[4 * src + 2];
tileUVArray[4 * dest + 3] = tileUVArray[4 * src + 3];
}
}
void SetLayerDeformation(int selectedDef, int waveLength, int waveType, int deformType, int YPos, int waveSize);
void SetPlayerScreenPosition(Player *player);
void SetPlayerScreenPositionCDStyle(Player *player);
void SetPlayerHLockedScreenPosition(Player *player);
void SetPlayerLockedScreenPosition(Player *player);
#endif // !SCENE_H