forked from usineur/hode
-
Notifications
You must be signed in to change notification settings - Fork 1
/
level6_pwr2.cpp
205 lines (183 loc) · 4.79 KB
/
level6_pwr2.cpp
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
// pwr2_hod - "caverns of doom"
#include "game.h"
#include "level.h"
#include "paf.h"
#include "video.h"
static const CheckpointData _pwr2_checkpointData[3] = {
{ 127, 121, 0x300c, 232, 0, 2 },
{ 10, 132, 0x300c, 232, 3, 2 },
{ 104, 129, 0x300c, 232, 7, 2 }
};
static const uint8_t _pwr2_screenStartData[32] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
struct Level_pwr2: Level {
virtual const CheckpointData *getCheckpointData(int num) const { return &_pwr2_checkpointData[num]; }
virtual const uint8_t *getScreenRestartData() const { return _pwr2_screenStartData; }
virtual void initialize();
virtual void terminate();
virtual void tick();
virtual void preScreenUpdate(int screenNum);
virtual void postScreenUpdate(int screenNum);
//virtual void setupScreenCheckpoint(int screenNum);
void postScreenUpdate_pwr2_screen2();
void postScreenUpdate_pwr2_screen3();
void postScreenUpdate_pwr2_screen5();
void postScreenUpdate_pwr2_screen8();
void preScreenUpdate_pwr2_screen2();
void preScreenUpdate_pwr2_screen3();
void preScreenUpdate_pwr2_screen5();
void preScreenUpdate_pwr2_screen7();
};
Level *Level_pwr2_create() {
return new Level_pwr2;
}
void Level_pwr2::postScreenUpdate_pwr2_screen2() {
uint8_t mask;
switch (_res->_screensState[2].s0) {
case 1:
mask = 1;
break;
case 2:
mask = 2;
break;
default:
mask = 0;
break;
}
_res->_resLvlScreenBackgroundDataTable[2].currentMaskId = mask;
if (_res->_screensState[2].s3 != mask) {
_g->setupScreenMask(2);
}
}
void Level_pwr2::postScreenUpdate_pwr2_screen3() {
if (_res->_currentScreenResourceNum == 3) {
if ((_andyObject->flags1 & 0x30) == 0) {
AndyLvlObjectData *data = (AndyLvlObjectData *)_g->getLvlObjectDataPtr(_andyObject, kObjectDataTypeAndy);
BoundingBox b = { 115, 27, 127, 55 };
if (_g->clipBoundingBox(&b, &data->boundingBox)) {
const uint8_t flags = _andyObject->flags0;
if ((flags & 0x1F) == 0 && (flags & 0xE0) == 0xE0) {
LvlObject *o = _g->findLvlObject2(0, 0, 3);
if (o) {
o->objectUpdateType = 7;
}
} else {
LvlObject *o = _g->findLvlObject2(0, 0, 3);
if (o) {
if (o->objectUpdateType == 4) {
_res->_screensState[2].s0 = 2;
} else {
_g->setAndySpecialAnimation(3);
}
}
}
}
}
}
}
void Level_pwr2::postScreenUpdate_pwr2_screen5() {
if (_res->_screensState[5].s0 == 1) {
_res->_screensState[5].s0 = 2;
if (_checkpoint == 1) {
_checkpoint = 2;
}
if (!_paf->_skipCutscenes) {
_paf->play(9);
_paf->unload(9);
}
_video->clearPalette();
_g->restartLevel();
}
}
void Level_pwr2::postScreenUpdate_pwr2_screen8() {
if (_res->_screensState[8].s0 != 0) {
if (!_paf->_skipCutscenes) {
_paf->play(10);
_paf->unload(10);
}
_video->clearPalette();
_g->_endLevel = true;
}
}
void Level_pwr2::postScreenUpdate(int num) {
switch (num) {
case 2:
postScreenUpdate_pwr2_screen2();
break;
case 3:
postScreenUpdate_pwr2_screen3();
break;
case 5:
postScreenUpdate_pwr2_screen5();
break;
case 8:
case 9:
case 10:
case 11:
postScreenUpdate_pwr2_screen8();
break;
}
}
void Level_pwr2::preScreenUpdate_pwr2_screen2() {
if (_checkpoint == 1) {
if (_res->_screensState[2].s0 == 0) {
_res->_screensState[2].s0 = 2;
_res->_resLvlScreenBackgroundDataTable[2].currentMaskId = 2;
}
}
}
void Level_pwr2::preScreenUpdate_pwr2_screen3() {
if (_res->_currentScreenResourceNum == 3 && _checkpoint == 0) {
AndyLvlObjectData *data = (AndyLvlObjectData *)_g->getLvlObjectDataPtr(_andyObject, kObjectDataTypeAndy);
BoundingBox b = { 0, 103, 122, 191 };
if (_g->clipBoundingBox(&b, &data->boundingBox)) {
_checkpoint = 1;
}
}
}
void Level_pwr2::preScreenUpdate_pwr2_screen5() {
if (_res->_currentScreenResourceNum == 5) {
if (!_paf->_skipCutscenes) {
_paf->preload(9);
}
}
}
void Level_pwr2::preScreenUpdate_pwr2_screen7() {
if (_res->_currentScreenResourceNum == 7) {
_res->_screensState[5].s0 = 2;
if (!_paf->_skipCutscenes) {
_paf->preload(10);
}
}
}
void Level_pwr2::preScreenUpdate(int num) {
switch (num) {
case 2:
preScreenUpdate_pwr2_screen2();
break;
case 3:
preScreenUpdate_pwr2_screen3();
break;
case 5:
preScreenUpdate_pwr2_screen5();
break;
case 7:
preScreenUpdate_pwr2_screen7();
break;
}
}
void Level_pwr2::initialize() {
_g->loadTransformLayerData(Game::_pwr1_screenTransformData);
}
void Level_pwr2::terminate() {
_g->unloadTransformLayerData();
}
const uint8_t Game::_pwr2_screenTransformLut[] = {
0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
void Level_pwr2::tick() {
_video->_displayShadowLayer = Game::_pwr2_screenTransformLut[_res->_currentScreenResourceNum * 2] != 0;
}