Skip to content

Commit

Permalink
tr2: port Trapdoor_Ceiling
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Oct 24, 2024
1 parent 41c7942 commit c7296db
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
16 changes: 8 additions & 8 deletions docs/tr2/progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/tr2/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3752,7 +3752,7 @@ typedef enum {
0x00442110 0x0155 -R void __cdecl SpikeCollision(int16_t item_num, ITEM *litem, COLL_INFO *coll);
0x00442270 0x004F + void __cdecl Trapdoor_Control(int16_t item_num);
0x004422C0 0x003A + void __cdecl Trapdoor_Floor(const ITEM *item, int32_t x, int32_t y, int32_t z, int32_t *out_height);
0x00442300 0x003F - void __cdecl Trapdoor_Ceiling(const ITEM *item, int32_t x, int32_t y, int32_t z, int32_t *out_height);
0x00442300 0x003F + void __cdecl Trapdoor_Ceiling(const ITEM *item, int32_t x, int32_t y, int32_t z, int32_t *out_height);
0x00442340 0x00A3 + int32_t __cdecl Trapdoor_IsItemOnTop(const ITEM *item, int32_t x, int32_t z);
0x004423F0 0x010A -R void __cdecl Pendulum(int16_t item_num);
0x00442500 0x0105 -R void __cdecl FallingBlock(int16_t item_num);
Expand Down
15 changes: 15 additions & 0 deletions src/tr2/game/objects/general/trapdoor.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ void __cdecl Trapdoor_Floor(
*out_height = item->pos.y;
}

void __cdecl Trapdoor_Ceiling(
const ITEM *const item, const int32_t x, const int32_t y, const int32_t z,
int32_t *const out_height)
{
if (!Trapdoor_IsItemOnTop(item, x, z)) {
return;
} else if (item->current_anim_state != TRAPDOOR_STATE_CLOSED) {
return;
} else if (y <= item->pos.y || item->pos.y <= *out_height) {
return;
} else {
*out_height = item->pos.y + STEP_L;
}
}

void __cdecl Trapdoor_Control(const int16_t item_num)
{
ITEM *const item = Item_Get(item_num);
Expand Down
2 changes: 2 additions & 0 deletions src/tr2/game/objects/general/trapdoor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ int32_t __cdecl Trapdoor_IsItemOnTop(const ITEM *item, int32_t x, int32_t z);

void __cdecl Trapdoor_Floor(
const ITEM *item, int32_t x, int32_t y, int32_t z, int32_t *out_height);
void __cdecl Trapdoor_Ceiling(
const ITEM *item, int32_t x, int32_t y, int32_t z, int32_t *out_height);
void __cdecl Trapdoor_Control(int16_t item_num);
1 change: 0 additions & 1 deletion src/tr2/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@
#define RollingBallControl ((void __cdecl (*)(int16_t item_num))0x00441B70)
#define RollingBallCollision ((void __cdecl (*)(int16_t item_num, ITEM *litem, COLL_INFO *coll))0x00441EC0)
#define SpikeCollision ((void __cdecl (*)(int16_t item_num, ITEM *litem, COLL_INFO *coll))0x00442110)
#define Trapdoor_Ceiling ((void __cdecl (*)(const ITEM *item, int32_t x, int32_t y, int32_t z, int32_t *out_height))0x00442300)
#define Pendulum ((void __cdecl (*)(int16_t item_num))0x004423F0)
#define FallingBlock ((void __cdecl (*)(int16_t item_num))0x00442500)
#define FallingBlockFloor ((void __cdecl (*)(const ITEM *item, int32_t x, int32_t y, int32_t z, int32_t *out_height))0x00442610)
Expand Down
1 change: 1 addition & 0 deletions src/tr2/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ static void M_Objects(const bool enable)
INJECT(enable, 0x0043F2F0, SkidooArmed_Collision);
INJECT(enable, 0x00442270, Trapdoor_Control);
INJECT(enable, 0x004422C0, Trapdoor_Floor);
INJECT(enable, 0x00442300, Trapdoor_Ceiling);
INJECT(enable, 0x00442340, Trapdoor_IsItemOnTop);
INJECT(enable, 0x00442B30, FlameEmitter_Control);
INJECT(enable, 0x00442BC0, Flame_Control);
Expand Down

0 comments on commit c7296db

Please sign in to comment.