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

Commit

Permalink
port Random_GetControl
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Nov 16, 2023
1 parent ebd4306 commit 45f78c9
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 13 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.
4 changes: 2 additions & 2 deletions docs/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2708,7 +2708,7 @@ typedef enum GAME_OBJECT_ID {
0044C670 00000006 *R int32_t __cdecl LevelCompleteSequence(void);
0044C680 000001C2 -R int32_t __cdecl LevelStats(int32_t levelID);
0044C850 00000113 -R int32_t __cdecl GameStats(int32_t levelID);
0044C970 0000001E * int32_t __cdecl Random_GetControl(void);
0044C970 0000001E + int32_t __cdecl Random_GetControl(void);
0044C990 0000000A + void __cdecl Random_SeedControl(int32_t seed);
0044C9A0 0000001E - int32_t __cdecl Random_GetDraw(void);
0044C9C0 0000000A + void __cdecl Random_SeedDraw(int32_t seed);
Expand Down Expand Up @@ -2952,7 +2952,7 @@ typedef enum GAME_OBJECT_ID {
004662E0 - int8_t g_TextASCIIMap[];
00466480 - double g_GameSizer = 1.0;
00466488 - double g_GameSizerCopy = 1.0;
00466BB0 - int32_t g_RandControl;
00466BB0 + int32_t g_RandControl;
00466BB4 - int32_t g_RandDraw;
00466F70 - struct CONTROL_LAYOUT g_Layout[2];
00467DD0 + const int32_t g_AtanBaseTable[8];
Expand Down
1 change: 1 addition & 0 deletions src/game/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "game/matrix.h"
#include "game/music.h"
#include "game/output.h"
#include "game/random.h"
#include "global/const.h"
#include "global/funcs.h"
#include "global/vars.h"
Expand Down
10 changes: 9 additions & 1 deletion src/game/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@

#include <time.h>

static int32_t m_RandControl = 0xD371F947;

void __cdecl Random_SeedControl(const int32_t seed)
{
g_RandControl = seed;
m_RandControl = seed;
}

void __cdecl Random_SeedDraw(const int32_t seed)
{
g_RandDraw = seed;
}

int32_t __cdecl Random_GetControl(void)
{
m_RandControl = 0x41C64E6D * m_RandControl + 12345;
return (m_RandControl >> 10) & 0x7FFF;
}

void __cdecl Random_Seed(void)
{
time_t lt = time(0);
Expand Down
1 change: 1 addition & 0 deletions src/game/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

void __cdecl Random_SeedControl(int32_t seed);
void __cdecl Random_SeedDraw(int32_t seed);
int32_t __cdecl Random_GetControl(void);
void __cdecl Random_Seed(void);
1 change: 0 additions & 1 deletion src/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,6 @@
#define LevelCompleteSequence ((int32_t __cdecl (*)(void))0x0044C670)
#define LevelStats ((int32_t __cdecl (*)(int32_t levelID))0x0044C680)
#define GameStats ((int32_t __cdecl (*)(int32_t levelID))0x0044C850)
#define Random_GetControl ((int32_t __cdecl (*)(void))0x0044C970)
#define Random_GetDraw ((int32_t __cdecl (*)(void))0x0044C9A0)
#define GetValidLevelsList ((void __cdecl (*)(REQUEST_INFO *req))0x0044C9D0)
#define GetSavedGamesList ((void __cdecl (*)(REQUEST_INFO *req))0x0044CA20)
Expand Down
1 change: 0 additions & 1 deletion src/global/vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#define g_TextASCIIMap (*(int8_t(*)[])0x004662E0)
#define g_GameSizer (*(double*)0x00466480) // = 1.0
#define g_GameSizerCopy (*(double*)0x00466488) // = 1.0
#define g_RandControl (*(int32_t*)0x00466BB0)
#define g_RandDraw (*(int32_t*)0x00466BB4)
#define g_Layout (*(struct CONTROL_LAYOUT(*)[2])0x00466F70)
#define g_MidSort (*(int32_t*)0x0046C300) // = 0
Expand Down
1 change: 1 addition & 0 deletions src/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ static void Inject_Sound(void)

static void Inject_Random(void)
{
INJECT(1, 0x0044C970, Random_GetControl);
INJECT(1, 0x0044C990, Random_SeedControl);
INJECT(1, 0x0044C9C0, Random_SeedDraw);
INJECT(1, 0x0044D870, Random_Seed);
Expand Down

0 comments on commit 45f78c9

Please sign in to comment.