Skip to content

Commit 35c23d6

Browse files
committed
fix Pyramid secret trigger
1 parent 1378b67 commit 35c23d6

File tree

6 files changed

+87
-7
lines changed

6 files changed

+87
-7
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ Currently the following configuration options are supported:
4141
- <kbd>4</kbd>: draw UZI
4242
- <kbd>8</kbd>: use small medpack
4343
- <kbd>9</kbd>: use large medpack
44-
- `healthbar_showing_mode`: change when the healthbar is displayed. Possible values:
44+
- `healthbar_showing_mode`: change when the healthbar is displayed.
45+
Possible values:
4546
- `always`: always show the healthbar
4647
- `flashing`: show the healthbar only when Lara's health is 20% or below
4748
- `default`: show the healthbar at the beginning of a level, after
@@ -50,6 +51,8 @@ Currently the following configuration options are supported:
5051
Action key held.
5152
- `fix_tihocan_secret_sound`: disable the secret sound incorrectly playing
5253
during using the golden key in Tomb of Tihocan.
54+
- `fix_pyramid_secret_trigger`: fix the secret trigger in the final level not
55+
working.
5356
- `fix_hardcoded_secret_counts`: calculate the number of secrets based on a
5457
trigger count within a file rather than using hardcoded values.
5558

Tomb1Main.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"healthbar_showing_mode": "flashing",
1414
"fix_end_of_level_freeze": true,
1515
"fix_tihocan_secret_sound": true,
16+
"fix_pyramid_secret_trigger": true,
1617
"fix_hardcoded_secret_counts": true
1718
}

src/main.c

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ static int Tomb1MReadConfig()
107107
tr1m_json_get_boolean_value(json, "fix_end_of_level_freeze");
108108
Tomb1MConfig.fix_tihocan_secret_sound =
109109
tr1m_json_get_boolean_value(json, "fix_tihocan_secret_sound");
110+
Tomb1MConfig.fix_pyramid_secret_trigger =
111+
tr1m_json_get_boolean_value(json, "fix_pyramid_secret_trigger");
110112
Tomb1MConfig.fix_hardcoded_secret_counts =
111113
tr1m_json_get_boolean_value(json, "fix_hardcoded_secret_counts");
112114

src/mod.c

+75-6
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ int Tomb1MGetSecretCount()
160160

161161
for (int i = 0; i < RoomCount; i++) {
162162
ROOM_INFO* r = &RoomInfo[i];
163-
for (int j = 0; j < r->y_size * r->x_size; j++) {
164-
FLOOR_INFO* floor = &r->floor[j];
165-
163+
FLOOR_INFO* floor = &r->floor[0];
164+
for (int j = 0; j < r->y_size * r->x_size; j++, floor++) {
166165
int k = floor->index;
167166
if (!k) {
168167
continue;
@@ -194,9 +193,7 @@ int Tomb1MGetSecretCount()
194193
int16_t command = FloorData[k++];
195194
if (TRIG_BITS(command) == TO_CAMERA) {
196195
k++;
197-
}
198-
199-
if (TRIG_BITS(command) == TO_SECRET) {
196+
} else if (TRIG_BITS(command) == TO_SECRET) {
200197
int16_t number = command & VALUE_BITS;
201198
if (!(secrets & (1 << number))) {
202199
secrets |= (1 << number);
@@ -221,3 +218,75 @@ int Tomb1MGetSecretCount()
221218

222219
return count;
223220
}
221+
222+
void Tomb1MFixPyramidSecretTrigger()
223+
{
224+
if (CurrentLevel != LV_LEVEL10C) {
225+
return;
226+
}
227+
228+
uint32_t global_secrets = 0;
229+
230+
for (int i = 0; i < RoomCount; i++) {
231+
uint32_t room_secrets = 0;
232+
ROOM_INFO* r = &RoomInfo[i];
233+
FLOOR_INFO* floor = &r->floor[0];
234+
for (int j = 0; j < r->y_size * r->x_size; j++, floor++) {
235+
int k = floor->index;
236+
if (!k) {
237+
continue;
238+
}
239+
240+
while (k < FloorDataSize) {
241+
uint16_t floor = FloorData[k++];
242+
243+
switch (floor & DATA_TYPE) {
244+
case FT_DOOR:
245+
case FT_ROOF:
246+
case FT_TILT:
247+
k++;
248+
break;
249+
250+
case FT_LAVA:
251+
break;
252+
253+
case FT_TRIGGER: {
254+
uint16_t trig_type = (floor & 0x3F00) >> 8;
255+
k++; // skip basic trigger stuff
256+
257+
if (trig_type == TT_SWITCH || trig_type == TT_KEY
258+
|| trig_type == TT_PICKUP) {
259+
k++;
260+
}
261+
262+
while (1) {
263+
int16_t* command = &FloorData[k++];
264+
if (TRIG_BITS(*command) == TO_CAMERA) {
265+
k++;
266+
} else if (TRIG_BITS(*command) == TO_SECRET) {
267+
int16_t number = *command & VALUE_BITS;
268+
if (global_secrets & (1 << number) && number == 0) {
269+
// the secret number was already used.
270+
// update the number to 2.
271+
*command |= 2;
272+
} else {
273+
room_secrets |= (1 << number);
274+
}
275+
}
276+
277+
if (*command & END_BIT) {
278+
break;
279+
}
280+
}
281+
break;
282+
}
283+
}
284+
285+
if (floor & END_BIT) {
286+
break;
287+
}
288+
}
289+
}
290+
global_secrets |= room_secrets;
291+
}
292+
}

src/mod.h

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct {
3131
int8_t healthbar_showing_mode;
3232
int8_t fix_end_of_level_freeze;
3333
int8_t fix_tihocan_secret_sound;
34+
int8_t fix_pyramid_secret_trigger;
3435
int8_t fix_hardcoded_secret_counts;
3536
} Tomb1MConfig;
3637

@@ -50,5 +51,6 @@ int Tomb1MGetRenderWidthDownscaled();
5051
int Tomb1MGetRenderHeight();
5152
int Tomb1MGetRenderWidth();
5253
int Tomb1MGetSecretCount();
54+
void Tomb1MFixPyramidSecretTrigger();
5355

5456
#endif

src/specific/file.c

+3
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ int32_t __cdecl S_LoadLevel(int level_id)
290290
}
291291
}
292292

293+
if (Tomb1MConfig.fix_pyramid_secret_trigger) {
294+
Tomb1MFixPyramidSecretTrigger();
295+
}
293296
if (Tomb1MConfig.fix_hardcoded_secret_counts) {
294297
SecretTotals[level_id] = Tomb1MGetSecretCount();
295298
}

0 commit comments

Comments
 (0)