Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
port Box_TargetBox
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Apr 14, 2024
1 parent 859c2a4 commit b5981f6
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
16 changes: 8 additions & 8 deletions docs/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/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ typedef enum GAME_OBJECT_ID {
0040E230 00000242 + void __cdecl Creature_AIInfo(struct ITEM_INFO *item, struct AI_INFO *info);
0040E490 000001F3 + int32_t __cdecl Box_SearchLOT(struct LOT_INFO *lot, int32_t expansion);
0040E690 0000006F + int32_t __cdecl Box_UpdateLOT(struct LOT_INFO *lot, int32_t expansion);
0040E700 00000095 - void __cdecl Box_TargetBox(struct LOT_INFO *lot, int16_t box_num);
0040E700 00000095 + void __cdecl Box_TargetBox(struct LOT_INFO *lot, int16_t box_num);
0040E7A0 000000F2 - int32_t __cdecl Box_StalkBox(struct ITEM_INFO *item, struct ITEM_INFO *enemy, int16_t box_num);
0040E8A0 000000A4 - int32_t __cdecl Box_EscapeBox(struct ITEM_INFO *item, struct ITEM_INFO *enemy, int16_t box_num);
0040E950 000000A7 - int32_t __cdecl Box_ValidBox(struct ITEM_INFO *item, int16_t zone_num, int16_t box_num);
Expand Down
20 changes: 20 additions & 0 deletions src/game/box.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "game/box.h"

#include "game/random.h"
#include "global/const.h"
#include "global/vars.h"

Expand Down Expand Up @@ -109,3 +110,22 @@ int32_t __cdecl Box_UpdateLOT(
end:
return Box_SearchLOT(lot, expansion);
}

void __cdecl Box_TargetBox(struct LOT_INFO *const lot, const int16_t box_num)
{
const struct BOX_INFO *const box = &g_Boxes[box_num & BOX_NUM_BITS];

lot->target.z = ((box->right - box->left - 1) >> (15 - WALL_SHIFT))
* Random_GetControl()
+ (box->left << WALL_SHIFT) + WALL_L / 2;
lot->target.x = ((box->bottom - box->top - 1) >> (15 - WALL_SHIFT))
* Random_GetControl()
+ (box->top << WALL_SHIFT) + WALL_L / 2;
lot->required_box = box_num & BOX_NUM_BITS;

if (lot->fly != 0) {
lot->target.y = box->height - STEP_L * 3 / 2;
} else {
lot->target.y = box->height;
}
}
1 change: 1 addition & 0 deletions src/game/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@

int32_t __cdecl Box_SearchLOT(struct LOT_INFO *lot, int32_t expansion);
int32_t __cdecl Box_UpdateLOT(struct LOT_INFO *lot, int32_t expansion);
void __cdecl Box_TargetBox(struct LOT_INFO *lot, int16_t box_num);
1 change: 0 additions & 1 deletion src/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#define Boat_Animation ((void __cdecl (*)(struct ITEM_INFO *boat, int32_t collide))0x0040D950)
#define Boat_Control ((void __cdecl (*)(int16_t item_num))0x0040DAC0)
#define Gondola_Control ((void __cdecl (*)(int16_t item_num))0x0040E0F0)
#define Box_TargetBox ((void __cdecl (*)(struct LOT_INFO *lot, int16_t box_num))0x0040E700)
#define Box_StalkBox ((int32_t __cdecl (*)(struct ITEM_INFO *item, struct ITEM_INFO *enemy, int16_t box_num))0x0040E7A0)
#define Box_EscapeBox ((int32_t __cdecl (*)(struct ITEM_INFO *item, struct ITEM_INFO *enemy, int16_t box_num))0x0040E8A0)
#define Box_ValidBox ((int32_t __cdecl (*)(struct ITEM_INFO *item, int16_t zone_num, int16_t box_num))0x0040E950)
Expand Down
1 change: 1 addition & 0 deletions src/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ static void Inject_Box(void)
{
INJECT(1, 0x0040E490, Box_SearchLOT);
INJECT(1, 0x0040E690, Box_UpdateLOT);
INJECT(1, 0x0040E700, Box_TargetBox);
}

static void Inject_Objects(void)
Expand Down

0 comments on commit b5981f6

Please sign in to comment.