Skip to content

Commit

Permalink
tr2: port Object_SetupAllObjects
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Oct 15, 2024
1 parent 8b01389 commit 07e23d2
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 31 deletions.
36 changes: 18 additions & 18 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.
12 changes: 6 additions & 6 deletions docs/tr2/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3088,8 +3088,8 @@ typedef enum {
0x004195B0 0x00B4 + void __cdecl Room_DrawSingleRoomGeometry(int16_t room_num);
0x00419670 0x0218 + void __cdecl Room_DrawSingleRoomObjects(int16_t room_num);
0x00419890 0x0147 + void __cdecl Effect_Draw(int16_t fx_num);
0x004199E0 0x0083 - void __cdecl Object_DrawSpriteItem(ITEM *item);
0x00419A70 0x0378 - void __cdecl Object_DrawAnimatingItem(ITEM *item);
0x004199E0 0x0083 - void __cdecl Object_DrawSpriteItem(const ITEM *item);
0x00419A70 0x0378 - void __cdecl Object_DrawAnimatingItem(const ITEM *item);
0x00419DF0 0x0D02 + void __cdecl Lara_Draw(const ITEM *item);
0x0041AB20 0x0BC6 + void __cdecl Lara_Draw_I(const ITEM *item, const FRAME_INFO *frame1, const FRAME_INFO *frame2, int32_t frac, int32_t rate);
0x0041B710 0x0034 + void __cdecl Matrix_InitInterpolate(int32_t frac, int32_t rate);
Expand Down Expand Up @@ -3622,10 +3622,10 @@ typedef enum {
0x0043A280 0x015F + int32_t __cdecl Level_Initialise(int32_t level_num, int32_t level_type);
0x0043A3E0 0x0061 -R void __cdecl InitialiseGameFlags(void);
0x0043A450 0x0027 -R void __cdecl InitialiseLevelFlags(void);
0x0043A480 0x103B -R void __cdecl BaddyObjects(void);
0x0043B4C0 0x05FD -R void __cdecl TrapObjects(void);
0x0043BAC0 0x0C4C -R void __cdecl ObjectObjects(void);
0x0043C710 0x0068 -R void __cdecl InitialiseObjects(void);
0x0043A480 0x103B - void __cdecl Object_SetupBaddyObjects(void);
0x0043B4C0 0x05FD - void __cdecl Object_SetupTrapObjects(void);
0x0043BAC0 0x0C4C - void __cdecl Object_SetupGeneralObjects(void);
0x0043C710 0x0068 + void __cdecl Object_SetupAllObjects(void);
0x0043C780 0x00CE -R void __cdecl GetCarriedItems(void);

# game/shark.c
Expand Down
4 changes: 3 additions & 1 deletion src/tr2/game/level.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "game/hwr.h"
#include "game/items.h"
#include "game/objects/setup.h"
#include "game/shell.h"
#include "global/const.h"
#include "global/funcs.h"
Expand Down Expand Up @@ -894,7 +895,8 @@ bool __cdecl Level_Load(const char *const file_name, const int32_t level_num)
Memory_FreePointer(&frame_pointers);

M_LoadObjects(file);
InitialiseObjects();
Object_SetupAllObjects();

M_LoadStaticObjects(file);
M_LoadTextures(file);

Expand Down
37 changes: 37 additions & 0 deletions src/tr2/game/objects/setup.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "game/objects/setup.h"

#include "game/objects/common.h"
#include "global/funcs.h"
#include "global/types.h"

#define DEFAULT_RADIUS 10

void __cdecl Object_SetupAllObjects(void)
{
for (int32_t i = 0; i < O_NUMBER_OF; i++) {
OBJECT *const object = Object_GetObject(i);
object->initialise = NULL;
object->control = NULL;
object->floor = NULL;
object->ceiling = NULL;
object->draw_routine = Object_DrawAnimatingItem;
object->collision = NULL;
object->hit_points = DONT_TARGET;
object->pivot_length = 0;
object->radius = DEFAULT_RADIUS;
object->shadow_size = 0;

object->save_position = 0;
object->save_hitpoints = 0;
object->save_flags = 0;
object->save_anim = 0;
object->intelligent = 0;
object->water_creature = 0;
}

Object_SetupBaddyObjects();
Object_SetupTrapObjects();
Object_SetupGeneralObjects();

InitialiseHair();
}
3 changes: 3 additions & 0 deletions src/tr2/game/objects/setup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void __cdecl Object_SetupAllObjects(void);
11 changes: 5 additions & 6 deletions src/tr2/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#define Dog_Control ((void __cdecl (*)(int16_t item_num))0x00417160)
#define Tiger_Control ((void __cdecl (*)(int16_t item_num))0x00417510)
#define DinoControl ((void __cdecl (*)(int16_t item_num))0x004186A0)
#define Object_DrawSpriteItem ((void __cdecl (*)(ITEM *item))0x004199E0)
#define Object_DrawAnimatingItem ((void __cdecl (*)(ITEM *item))0x00419A70)
#define Object_DrawSpriteItem ((void __cdecl (*)(const ITEM *item))0x004199E0)
#define Object_DrawAnimatingItem ((void __cdecl (*)(const ITEM *item))0x00419A70)
#define Gun_DrawFlash ((void __cdecl (*)(LARA_GUN_TYPE weapon_type, int32_t clip))0x0041BD30)
#define Output_CalculateObjectLighting ((void __cdecl (*)(const ITEM *item, const FRAME_INFO *frame))0x0041BEA0)
#define AddDynamicLight ((void __cdecl (*)(int32_t x, int32_t y, int32_t z, int32_t intensity, int32_t falloff))0x0041C0F0)
Expand Down Expand Up @@ -171,10 +171,9 @@
#define ReadSG ((void __cdecl (*)(void *pointer, int32_t size))0x0043A240)
#define InitialiseGameFlags ((void __cdecl (*)(void))0x0043A3E0)
#define InitialiseLevelFlags ((void __cdecl (*)(void))0x0043A450)
#define BaddyObjects ((void __cdecl (*)(void))0x0043A480)
#define TrapObjects ((void __cdecl (*)(void))0x0043B4C0)
#define ObjectObjects ((void __cdecl (*)(void))0x0043BAC0)
#define InitialiseObjects ((void __cdecl (*)(void))0x0043C710)
#define Object_SetupBaddyObjects ((void __cdecl (*)(void))0x0043A480)
#define Object_SetupTrapObjects ((void __cdecl (*)(void))0x0043B4C0)
#define Object_SetupGeneralObjects ((void __cdecl (*)(void))0x0043BAC0)
#define GetCarriedItems ((void __cdecl (*)(void))0x0043C780)
#define JellyControl ((void __cdecl (*)(int16_t item_num))0x0043C850)
#define BaracuddaControl ((void __cdecl (*)(int16_t item_num))0x0043C970)
Expand Down
2 changes: 2 additions & 0 deletions src/tr2/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "game/objects/general/pickup.h"
#include "game/objects/general/puzzle_hole.h"
#include "game/objects/general/switch.h"
#include "game/objects/setup.h"
#include "game/objects/traps/ember_emitter.h"
#include "game/objects/traps/flame_emitter.h"
#include "game/objects/vehicles/boat.h"
Expand Down Expand Up @@ -980,6 +981,7 @@ static void M_Objects(const bool enable)
INJECT(enable, 0x00438D80, Switch_Trigger);
INJECT(enable, 0x00438E40, Keyhole_Trigger);
INJECT(enable, 0x00438E80, Pickup_Trigger);
INJECT(enable, 0x0043C710, Object_SetupAllObjects);
INJECT(enable, 0x00442B30, FlameEmitter_Control);
INJECT(enable, 0x00442BC0, Flame_Control);
INJECT(enable, 0x00442E70, EmberEmitter_Control);
Expand Down
1 change: 1 addition & 0 deletions src/tr2/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ dll_sources = [
'game/objects/general/pickup.c',
'game/objects/general/puzzle_hole.c',
'game/objects/general/switch.c',
'game/objects/setup.c',
'game/objects/traps/ember_emitter.c',
'game/objects/traps/flame_emitter.c',
'game/objects/vars.c',
Expand Down

0 comments on commit 07e23d2

Please sign in to comment.