Skip to content

Commit

Permalink
port AddAssaultTime
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 5, 2024
1 parent 9e8c9d5 commit 60a106a
Show file tree
Hide file tree
Showing 7 changed files with 38 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 @@ -3248,7 +3248,7 @@ typedef enum {
0x00426100 0x00C0 + void __cdecl Requester_ChangeItem(REQUEST_INFO *req, int32_t item, const char *text1, uint32_t flags1, const char *text2, uint32_t flags2);
0x004261C0 0x00AC + void __cdecl Requester_AddItem(REQUEST_INFO *req, const char *text1, uint32_t flags1, const char *text2, uint32_t flags2);
0x00426270 0x0039 + void __cdecl Requester_SetSize(REQUEST_INFO *req, int32_t maxlines, int32_t ypos);
0x004262B0 0x0081 -R int32_t __cdecl AddAssaultTime(uint32_t time);
0x004262B0 0x0081 +R int32_t __cdecl AddAssaultTime(uint32_t time);
0x00426340 0x01D6 +R void __cdecl ShowGymStatsText(char *time_str, int32_t type);
0x00426520 0x0397 +R void __cdecl ShowStatsText(char *time_str, int32_t type);
0x004268C0 0x0425 +R void __cdecl ShowEndStatsText(void);
Expand Down
26 changes: 26 additions & 0 deletions src/decomp/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,29 @@ int32_t __cdecl GameStats(const int32_t level_num)
S_DontDisplayPicture();
return 0;
}

int32_t __cdecl AddAssaultTime(uint32_t time)
{
ASSAULT_STATS *const stats = &g_Assault;

int32_t insert_idx = -1;
for (int32_t i = 0; i < MAX_ASSAULT_TIMES; i++) {
if (stats->best_time[i] == 0 || time < stats->best_time[i]) {
insert_idx = i;
break;
}
}
if (insert_idx == -1) {
return false;
}

for (int32_t i = MAX_ASSAULT_TIMES - 1; i > insert_idx; i--) {
stats->best_finish[i] = stats->best_finish[i - 1];
stats->best_time[i] = stats->best_time[i - 1];
}

stats->finish_count++;
stats->best_time[insert_idx] = time;
stats->best_finish[insert_idx] = stats->finish_count;
return true;
}
1 change: 1 addition & 0 deletions src/decomp/stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ void __cdecl ShowEndStatsText(void);

int32_t __cdecl LevelStats(int32_t level_num);
int32_t __cdecl GameStats(int32_t level_num);
int32_t __cdecl AddAssaultTime(uint32_t time);
1 change: 1 addition & 0 deletions src/global/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#define MAX_DEMO_SIZE 9000
#define MAX_REQUESTER_ITEMS 24
#define MAX_SAVE_SLOTS 16
#define MAX_ASSAULT_TIMES 10

#define TEXTURE_PAGE_WIDTH 256
#define TEXTURE_PAGE_HEIGHT 256
Expand Down
1 change: 0 additions & 1 deletion src/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
#define Inv_Ring_MotionCameraPitch ((void __cdecl (*)(RING_INFO *ring, int16_t target))0x004254B0)
#define Inv_Ring_MotionItemSelect ((void __cdecl (*)(RING_INFO *ring, INVENTORY_ITEM *inv_item))0x004254D0)
#define Inv_Ring_MotionItemDeselect ((void __cdecl (*)(RING_INFO *ring, INVENTORY_ITEM *inv_item))0x00425530)
#define AddAssaultTime ((int32_t __cdecl (*)(uint32_t time))0x004262B0)
#define HarpoonBolt_Control ((void __cdecl (*)(int16_t item_num))0x0042C0F0)
#define Rocket_Control ((void __cdecl (*)(int16_t item_num))0x0042C530)
#define Flare_DoLight ((int32_t __cdecl (*)(XYZ_32 *pos, int32_t flare_age))0x0042F7A0)
Expand Down
1 change: 1 addition & 0 deletions src/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ static void Inject_Decomp_General(const bool enable)

static void Inject_Decomp_Stats(const bool enable)
{
INJECT(enable, 0x004262B0, AddAssaultTime);
INJECT(enable, 0x00426340, ShowGymStatsText);
INJECT(enable, 0x00426520, ShowStatsText);
INJECT(enable, 0x004268C0, ShowEndStatsText);
Expand Down

0 comments on commit 60a106a

Please sign in to comment.