Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decompile skidoo #1733

Merged
merged 22 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/tr2/ship/cfg/TR2X_gameflow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"O_BANDIT_2": "Mercenary 2",
"O_BANDIT_2B": "Mercenary 3",
"O_SKIDOO_ARMED": "Black Snowmobile",
"O_SKIDMAN": "Black Snowmobile Driver",
"O_SKIDOO_DRIVER": "Black Snowmobile Driver",
"O_MONK_1": "Monk 1",
"O_MONK_2": "Monk 2",
"O_FALLING_BLOCK_1": "Falling Block 1",
Expand Down Expand Up @@ -174,7 +174,7 @@
"O_BELL": "Bell",
"O_WATER_SPRITE": "Boat Wake",
"O_SNOW_SPRITE": "Snowmobile Wale",
"O_SKIDOO_LARA": "Snowmobile Animation",
"O_SKIDOO_TRACK": "Snowmobile Track",
"O_SWITCH_TYPE_AIRLOCK": "Airlock Switch",
"O_SWITCH_TYPE_SMALL": "Small Switch",
"O_PROPELLER_2": "Underwater Propeller",
Expand Down
92 changes: 46 additions & 46 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.
70 changes: 47 additions & 23 deletions docs/tr2/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,18 @@ typedef enum {
GAMEMODE_IN_CUTSCENE
} GAMEMODE;

typedef enum {
TRAP_SET = 0,
TRAP_ACTIVATE = 1,
TRAP_WORKING = 2,
TRAP_FINISHED = 3,
} TRAP_ANIM;

typedef enum {
DOOR_CLOSED = 0,
DOOR_OPEN = 1,
} DOOR_ANIM;

typedef enum {
GFD_START_GAME = 0x0000,
GFD_START_SAVED_GAME = 0x0100,
Expand Down Expand Up @@ -2017,7 +2029,7 @@ typedef enum { // decompiled
LGT_M16 = 5,
LGT_GRENADE = 6,
LGT_HARPOON = 7,
LGT_FLARE = 8 ,
LGT_FLARE = 8,
LGT_SKIDOO = 9,
NUM_WEAPONS = 10,
} LARA_GUN_TYPE;
Expand Down Expand Up @@ -2095,7 +2107,7 @@ typedef enum { // decompiled
O_BANDIT_2 = 49,
O_BANDIT_2B = 50,
O_SKIDOO_ARMED = 51,
O_SKIDMAN = 52,
O_SKIDOO_DRIVER = 52,
O_MONK_1 = 53,
O_MONK_2 = 54,
O_FALLING_BLOCK_1 = 55,
Expand Down Expand Up @@ -2134,7 +2146,7 @@ typedef enum { // decompiled
O_BELL = 88,
O_WATER_SPRITE = 89,
O_SNOW_SPRITE = 90,
O_SKIDOO_LARA = 91,
O_SKIDOO_TRACK = 91,
O_SWITCH_TYPE_AIRLOCK = 92,
O_SWITCH_TYPE_SMALL = 93,
O_PROPELLER_2 = 94,
Expand Down Expand Up @@ -2631,6 +2643,16 @@ typedef struct __unaligned {
int32_t pitch;
} BOAT_INFO;

typedef struct __unaligned {
int16_t track_mesh;
int32_t skidoo_turn;
int32_t left_fallspeed;
int32_t right_fallspeed;
int16_t momentum_angle;
int16_t extra_rotation;
int32_t pitch;
} SKIDOO_INFO;

typedef struct __unaligned {
struct {
XYZ_16 min;
Expand Down Expand Up @@ -2940,7 +2962,7 @@ typedef enum {

# game/boat.c
0x0040CB30 0x003C + void __cdecl Boat_Initialise(int16_t item_num);
0x0040CB70 0x0170 + int32_t __cdecl Boat_CheckGeton(int16_t item_num, COLL_INFO *coll);
0x0040CB70 0x0170 + int32_t __cdecl Boat_CheckGetOn(int16_t item_num, COLL_INFO *coll);
0x0040CCE0 0x015E + void __cdecl Boat_Collision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
0x0040CE40 0x00F8 + int32_t __cdecl Boat_TestWaterHeight(ITEM *item, int32_t z_off, int32_t x_off, XYZ_32 *pos);
0x0040CF40 0x01C1 + void __cdecl Boat_DoShift(int32_t boat_num);
Expand Down Expand Up @@ -3634,28 +3656,28 @@ typedef enum {
0x0043CBA0 0x027C -R void __cdecl Shark_Control(int16_t item_num);

# game/skidoo.c
0x0043CE30 0x0040 -R void __cdecl InitialiseSkidoo(int16_t item_num);
0x0043CE70 0x00E1 -R int32_t __cdecl SkidooCheckGeton(int16_t item_num, COLL_INFO *coll);
0x0043CF60 0x00F8 -R void __cdecl SkidooCollision(int16_t item_num, ITEM *litem, COLL_INFO *coll);
0x0043D060 0x01F9 -R void __cdecl SkidooBaddieCollision(ITEM *skidoo);
0x0043D260 0x00B2 -R int32_t __cdecl TestHeight(ITEM *item, int32_t z_off, int32_t x_off, XYZ_32 *pos);
0x0043CE30 0x0040 +R void __cdecl Skidoo_Initialise(int16_t item_num);
0x0043CE70 0x00E1 +R int32_t __cdecl Skidoo_CheckGetOn(int16_t item_num, COLL_INFO *coll);
0x0043CF60 0x00F8 +R void __cdecl Skidoo_Collision(int16_t item_num, ITEM *litem, COLL_INFO *coll);
0x0043D060 0x01F9 +R void __cdecl Skidoo_BaddieCollision(const ITEM *skidoo);
0x0043D260 0x00B2 +R int32_t __cdecl Skidoo_TestHeight(const ITEM *item, int32_t z_off, int32_t x_off, XYZ_32 *pos);
0x0043D320 0x027C -R int32_t __cdecl DoShift(ITEM *skidoo, XYZ_32 *pos, XYZ_32 *old);
0x0043D5A0 0x0054 -R int32_t __cdecl DoDynamics(int32_t height, int32_t fall_speed, int32_t *y);
0x0043D600 0x0090 -R int32_t __cdecl GetCollisionAnim(ITEM *skidoo, XYZ_32 *moved);
0x0043D690 0x0140 -R void __cdecl DoSnowEffect(ITEM *skidoo);
0x0043D7D0 0x049E -R int32_t __cdecl SkidooDynamics(ITEM *skidoo);
0x0043DC70 0x01B6 -R int32_t __cdecl SkidooUserControl(ITEM *skidoo, int32_t height, int32_t *pitch);
0x0043DE30 0x0106 -R int32_t __cdecl SkidooCheckGetOffOK(int32_t direction);
0x0043DF40 0x02B9 -R void __cdecl SkidooAnimation(ITEM *skidoo, int32_t collide, int32_t dead);
0x0043E220 0x007C -R void __cdecl SkidooExplode(ITEM *skidoo);
0x0043E2A0 0x0233 -R int32_t __cdecl SkidooCheckGetOff(void);
0x0043E4E0 0x011B -R void __cdecl SkidooGuns(void);
0x0043E600 0x0440 -R int32_t __cdecl SkidooControl(void);
0x0043EA60 0x02D5 -R void __cdecl SkidooArmed_Draw(const ITEM *item);
0x0043ED40 0x007F -R void __cdecl SkidooDriver_Initialise(int16_t item_num);
0x0043EDD0 0x03E2 - void __cdecl SkidooDriver_Control(int16_t rider_num);
0x0043F1D0 0x0119 -R void __cdecl SkidmanPush(ITEM *item, ITEM *lara_item, int32_t radius);
0x0043F2F0 0x0081 - void __cdecl SkidooDriver_Collision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
0x0043D690 0x0140 +R void __cdecl Skidoo_DoSnowEffect(ITEM *skidoo);
0x0043D7D0 0x049E +R int32_t __cdecl Skidoo_Dynamics(ITEM *skidoo);
0x0043DC70 0x01B6 +R int32_t __cdecl Skidoo_UserControl(ITEM *skidoo, int32_t height, int32_t *pitch);
0x0043DE30 0x0106 +R int32_t __cdecl Skidoo_CheckGetOffOK(int32_t direction);
0x0043DF40 0x02B9 +R void __cdecl Skidoo_Animation(ITEM *skidoo, int32_t collide, int32_t dead);
0x0043E220 0x007C +R void __cdecl Skidoo_Explode(const ITEM *skidoo);
0x0043E2A0 0x0233 +R int32_t __cdecl Skidoo_CheckGetOff(void);
0x0043E4E0 0x011B +R void __cdecl Skidoo_Guns(void);
0x0043E600 0x0440 +R int32_t __cdecl Skidoo_Control(void);
0x0043EA60 0x02D5 +R void __cdecl Skidoo_Draw(const ITEM *item);
0x0043ED40 0x007F + void __cdecl SkidooDriver_Initialise(int16_t item_num);
0x0043EDD0 0x03E2 + void __cdecl SkidooDriver_Control(int16_t rider_num);
0x0043F1D0 0x0119 + void __cdecl SkidooArmed_Push(const ITEM *item, ITEM *lara_item, int32_t radius);
0x0043F2F0 0x0081 + void __cdecl SkidooArmed_Collision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll);

# game/sound.c
0x0043F380 0x0031 * int32_t __cdecl Music_GetRealTrack(int32_t track);
Expand Down Expand Up @@ -4720,6 +4742,8 @@ typedef enum {
0x004645A8 - const uint16_t g_Requester_UnselectionGour1[];
0x005216E0 - uint16_t g_InvColors[17]; // INV_COLOR_NUMBER_OF
0x00464150 + BITE g_DragonMouth;
0x00466230 + BITE g_SkidooLeftGun;
0x00466240 + BITE g_SkidooRightGun;
0x00465F40 - int16_t g_MovableBlockBounds[];
0x00465F58 - int16_t g_ZiplineHandleBounds[];
0x00465FF0 - int16_t g_PickupBounds[];
Expand Down
23 changes: 23 additions & 0 deletions src/libtrx/game/rooms/common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "game/rooms/common.h"

#include <stddef.h>

int32_t Room_GetAdjoiningRooms(
int16_t init_room_num, int16_t out_room_nums[],
const int32_t max_room_num_count)
{
int32_t count = 0;
if (max_room_num_count >= 1) {
out_room_nums[count++] = init_room_num;
}

const PORTALS *const portals = Room_Get(init_room_num)->portals;
if (portals != NULL) {
for (int32_t i = 0; i < portals->count; i++) {
const int16_t room_num = portals->portal[i].room_num;
out_room_nums[count++] = room_num;
}
}

return count;
}
4 changes: 2 additions & 2 deletions src/libtrx/include/libtrx/game/objects/ids_tr2.def
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ OBJ_ID_DEFINE(O_BANDIT_1, 48)
OBJ_ID_DEFINE(O_BANDIT_2, 49)
OBJ_ID_DEFINE(O_BANDIT_2B, 50)
OBJ_ID_DEFINE(O_SKIDOO_ARMED, 51)
OBJ_ID_DEFINE(O_SKIDMAN, 52)
OBJ_ID_DEFINE(O_SKIDOO_DRIVER, 52)
OBJ_ID_DEFINE(O_MONK_1, 53)
OBJ_ID_DEFINE(O_MONK_2, 54)
OBJ_ID_DEFINE(O_FALLING_BLOCK_1, 55)
Expand Down Expand Up @@ -89,7 +89,7 @@ OBJ_ID_DEFINE(O_CEILING_SPIKES, 87)
OBJ_ID_DEFINE(O_BELL, 88)
OBJ_ID_DEFINE(O_WATER_SPRITE, 89)
OBJ_ID_DEFINE(O_SNOW_SPRITE, 90)
OBJ_ID_DEFINE(O_SKIDOO_LARA, 91)
OBJ_ID_DEFINE(O_SKIDOO_TRACK, 91)
OBJ_ID_DEFINE(O_SWITCH_TYPE_AIRLOCK, 92)
OBJ_ID_DEFINE(O_SWITCH_TYPE_SMALL, 93)
OBJ_ID_DEFINE(O_PROPELLER_2, 94)
Expand Down
4 changes: 2 additions & 2 deletions src/libtrx/include/libtrx/game/objects/names_tr2.def
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ OBJ_NAME_DEFINE(O_BANDIT_1, "Mercenary 1")
OBJ_NAME_DEFINE(O_BANDIT_2, "Mercenary 2")
OBJ_NAME_DEFINE(O_BANDIT_2B, "Mercenary 3")
OBJ_NAME_DEFINE(O_SKIDOO_ARMED, "Black Snowmobile")
OBJ_NAME_DEFINE(O_SKIDMAN, "Black Snowmobile Driver")
OBJ_NAME_DEFINE(O_SKIDOO_DRIVER, "Black Snowmobile Driver")
OBJ_NAME_DEFINE(O_MONK_1, "Monk 1")
OBJ_NAME_DEFINE(O_MONK_2, "Monk 2")
OBJ_NAME_DEFINE(O_FALLING_BLOCK_1, "Falling Block 1")
Expand Down Expand Up @@ -89,7 +89,7 @@ OBJ_NAME_DEFINE(O_CEILING_SPIKES, "Spiky Ceiling")
OBJ_NAME_DEFINE(O_BELL, "Bell")
OBJ_NAME_DEFINE(O_WATER_SPRITE, "Boat Wake")
OBJ_NAME_DEFINE(O_SNOW_SPRITE, "Snowmobile Wale")
OBJ_NAME_DEFINE(O_SKIDOO_LARA, "Snowmobile Animation")
OBJ_NAME_DEFINE(O_SKIDOO_TRACK, "Snowmobile Track")
OBJ_NAME_DEFINE(O_SWITCH_TYPE_AIRLOCK, "Airlock Switch")
OBJ_NAME_DEFINE(O_SWITCH_TYPE_SMALL, "Small Switch")
OBJ_NAME_DEFINE(O_PROPELLER_2, "Underwater Propeller")
Expand Down
4 changes: 4 additions & 0 deletions src/libtrx/include/libtrx/game/rooms/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ extern ROOM *Room_Get(int32_t room_num);

extern void Room_FlipMap(void);
extern bool Room_GetFlipStatus(void);

int32_t Room_GetAdjoiningRooms(
int16_t init_room_num, int16_t out_room_nums[],
const int32_t max_room_num_count);
1 change: 1 addition & 0 deletions src/libtrx/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ sources = [
'game/objects/common.c',
'game/objects/names.c',
'game/objects/vars.c',
'game/rooms/common.c',
'game/ui/common.c',
'game/ui/events.c',
'game/ui/widgets/console.c',
Expand Down
21 changes: 4 additions & 17 deletions src/tr1/game/lara/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include <stddef.h>
#include <stdint.h>

#define MAX_BADDIE_COLLISION 12

static int32_t m_OpenDoorsCheatCooldown = 0;

static void M_WaterCurrent(COLL_INFO *coll);
Expand Down Expand Up @@ -117,22 +115,11 @@ static void M_BaddieCollision(ITEM *lara_item, COLL_INFO *coll)
return;
}

int16_t numroom = 0;
int16_t roomies[MAX_BADDIE_COLLISION];

roomies[numroom++] = lara_item->room_num;

PORTALS *portals = g_RoomInfo[lara_item->room_num].portals;
if (portals != NULL) {
for (int i = 0; i < portals->count; i++) {
if (numroom >= MAX_BADDIE_COLLISION) {
break;
}
roomies[numroom++] = portals->portal[i].room_num;
}
}
int16_t roomies[12];
const int32_t roomies_count =
Room_GetAdjoiningRooms(lara_item->room_num, roomies, 12);

for (int i = 0; i < numroom; i++) {
for (int32_t i = 0; i < roomies_count; i++) {
int16_t item_num = g_RoomInfo[roomies[i]].item_num;
while (item_num != NO_ITEM) {
ITEM *item = &g_Items[item_num];
Expand Down
Loading
Loading