Skip to content

Commit

Permalink
inject: fix non-oneshot music triggers (#940)
Browse files Browse the repository at this point in the history
Added an injection function to support converting triggers to one shot.
Added injections for each level identified as needing trigger updates.

Resolves #939.
  • Loading branch information
lahm86 authored Aug 24, 2023
1 parent 96822a1 commit e88e698
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- fixed jump-twist animations at times being interrupted (#932, regression from 2.15.1)
- fixed walk-run-jump at times breaking when TR2 jumping is enabled (OG bug in TR2+) (#934)
- fixed the reset and unbind progress bars in the controls menu for non-default bar scaling (#930)
- fixed original data issues where music triggers are not set as one shot (#939)
- improve spanish localization and added translation for rotated pickups

## [2.15.3](https://github.com/rr-/Tomb1Main/compare/2.15.2...2.15.3) - 2023-08-15
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,19 @@ Not all options are turned on by default. Refer to `Tomb1Main_ConfigTool.exe` fo
- fixed underwater ambient sound effect not playing
- fixed sound effects playing rapidly in sound menu if input held down
- fixed sounds stopping instead of pausing when using the inventory or pausing
- fixed the following music triggers:
- **Caves**: converted track 9 in room 34 to one shot
- **Tomb of Qualopec**: converted track 17 in room 25 to one shot
- **St. Francis' Folly**: converted track 7 in room 18 to one shot
- **Obelisk of Khamoon**: converted track 3 in room 12 and track 4 in room 32 to one shot
- **Sanctuary of the Scion**: converted track 10 in room 0 to one shot
- **Natla's Mines**: converted track 3 in room 86 to one shot
- **Atlantis**: converted track 8 in room 59 to one shot
- **The Great Pyramid**: converted track 8 in room 36 to one shot
- **Return to Egypt**: converted track 19 in room 0, track 14 in room 15, track 15 in room 19, track 16 in room 22, track 6 in room 61, and track 11 in room 93 to one shot
- **Temple of the Cat**: converted track 12 in room 14, track 7 in room 98, and track 20 in room 100 to one shot
- **Atlantean Stronghold**: converted track 20 in room 4, track 19 in room 13, track 11 in room 17, track 15 in room 20, and track 12 in room 25 to one shot
- **The Hive**: converted track 9 in room 8, track 6 in room 18, track 12 in room 30, track 18 in room 31, track 3 in room 32, and track 20 in room 35 to one shot

#### Mods
- added ability to adjust Lara's starting health (easy no damage mod)
Expand Down
7 changes: 7 additions & 0 deletions bin/cfg/Tomb1Main_gameflow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"type": "normal",
"music": 57,
"injections": [
"data/caves_fd.bin",
"data/caves_itemrots.bin",
"data/caves_textures.bin",
],
Expand Down Expand Up @@ -176,6 +177,7 @@
"music": 57,
"injections": [
"data/larson_textures.bin",
"data/qualopec_fd.bin",
"data/qualopec_itemrots.bin",
"data/qualopec_textures.bin",
],
Expand All @@ -195,6 +197,7 @@
"type": "normal",
"music": 59,
"injections": [
"data/folly_fd.bin",
"data/folly_itemrots.bin",
"data/folly_textures.bin",
],
Expand Down Expand Up @@ -336,6 +339,7 @@
"type": "normal",
"music": 59,
"injections": [
"data/obelisk_fd.bin",
"data/obelisk_itemrots.bin",
],
"sequence": [
Expand All @@ -361,6 +365,7 @@
"type": "normal",
"music": 59,
"injections": [
"data/sanctuary_fd.bin",
"data/sanctuary_itemrots.bin",
"data/sanctuary_textures.bin",
],
Expand All @@ -387,6 +392,7 @@
"injections": [
"data/cowboy_textures.bin",
"data/kold_textures.bin",
"data/mines_fd.bin",
"data/mines_itemrots.bin",
"data/mines_textures.bin",
"data/skateboardkid_textures.bin"
Expand Down Expand Up @@ -414,6 +420,7 @@
"type": "normal",
"music": 60,
"injections": [
"data/atlantis_fd.bin",
"data/atlantis_textures.bin",
],
"sequence": [
Expand Down
4 changes: 4 additions & 0 deletions bin/cfg/Tomb1Main_gameflow_ub.json5
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"type": "normal",
"music": 59,
"injections": [
"data/egypt_fd.bin",
"data/egypt_textures.bin",
],
"sequence": [
Expand All @@ -46,6 +47,7 @@
"type": "normal",
"music": 59,
"injections": [
"data/cat_fd.bin",
"data/cat_itemrots.bin",
"data/cat_textures.bin",
],
Expand All @@ -67,6 +69,7 @@
"type": "normal",
"music": 60,
"injections": [
"data/stronghold_fd.bin",
"data/stronghold_itemrots.bin",
"data/stronghold_textures.bin",
],
Expand All @@ -88,6 +91,7 @@
"type": "normal",
"music": 60,
"injections": [
"data/hive_fd.bin",
"data/hive_itemrots.bin",
"data/hive_textures.bin",
],
Expand Down
Binary file added bin/data/atlantis_fd.bin
Binary file not shown.
Binary file added bin/data/cat_fd.bin
Binary file not shown.
Binary file added bin/data/caves_fd.bin
Binary file not shown.
Binary file added bin/data/egypt_fd.bin
Binary file not shown.
Binary file added bin/data/folly_fd.bin
Binary file not shown.
Binary file added bin/data/hive_fd.bin
Binary file not shown.
Binary file added bin/data/mines_fd.bin
Binary file not shown.
Binary file added bin/data/obelisk_fd.bin
Binary file not shown.
Binary file modified bin/data/pyramid_fd.bin
Binary file not shown.
Binary file added bin/data/qualopec_fd.bin
Binary file not shown.
Binary file added bin/data/sanctuary_fd.bin
Binary file not shown.
Binary file added bin/data/stronghold_fd.bin
Binary file not shown.
62 changes: 62 additions & 0 deletions src/game/inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ typedef struct MESH_EDIT {

typedef enum FLOOR_EDIT_TYPE {
FET_TRIGGER_PARAM = 0,
FET_MUSIC_ONESHOT = 1,
} FLOOR_EDIT_TYPE;

typedef enum ROOM_MESH_EDIT_TYPE {
Expand Down Expand Up @@ -122,6 +123,7 @@ static void Inject_TextureOverwrites(
static void Inject_FloorDataEdits(INJECTION *injection);
static void Inject_TriggerParameterChange(
INJECTION *injection, FLOOR_INFO *floor);
static void Inject_SetMusicOneShot(FLOOR_INFO *floor);

static void Inject_RoomMeshEdits(INJECTION *injection);
static void Inject_TextureRoomFace(INJECTION *injection);
Expand Down Expand Up @@ -993,6 +995,9 @@ static void Inject_FloorDataEdits(INJECTION *injection)
case FET_TRIGGER_PARAM:
Inject_TriggerParameterChange(injection, floor);
break;
case FET_MUSIC_ONESHOT:
Inject_SetMusicOneShot(floor);
break;
default:
LOG_WARNING("Unknown floor data edit type: %d", edit_type);
break;
Expand Down Expand Up @@ -1076,6 +1081,63 @@ static void Inject_TriggerParameterChange(
}
}

static void Inject_SetMusicOneShot(FLOOR_INFO *floor)
{
if (!floor) {
return;
}

uint16_t fd_index = floor->index;
if (!fd_index) {
return;
}

while (1) {
uint16_t data = g_FloorData[fd_index++];
switch (data & DATA_TYPE) {
case FT_DOOR:
case FT_ROOF:
case FT_TILT:
fd_index++;
break;

case FT_LAVA:
break;

case FT_TRIGGER: {
uint16_t trig_type = TRIG_TYPE(data);
int16_t *flags = &g_FloorData[fd_index++];

if (trig_type == TT_SWITCH || trig_type == TT_KEY
|| trig_type == TT_PICKUP) {
fd_index++; // skip entity reference
}

while (1) {
int16_t *command = &g_FloorData[fd_index++];
if (TRIG_BITS(*command) == TO_CD) {
*flags |= IF_ONESHOT;
return;
}

if (TRIG_BITS(*command) == TO_CAMERA) {
fd_index++; // skip camera setup
}

if (*command & END_BIT) {
break;
}
}
return;
}
}

if (data & END_BIT) {
break;
}
}
}

uint32_t Inject_GetExtraRoomMeshSize(int32_t room_index)
{
uint32_t size = 0;
Expand Down
1 change: 1 addition & 0 deletions src/global/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
#define DATA_TYPE 0x00FF
#define VALUE_BITS 0x03FF
#define TRIG_BITS(T) ((T & 0x3C00) >> 10)
#define TRIG_TYPE(T) ((T & 0x3F00) >> 8)

#define MIN_SQUARE SQUARE(WALL_L / 4) // = 65536
#define GROUND_SHIFT (STEP_L)
Expand Down

0 comments on commit e88e698

Please sign in to comment.