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

Commit

Permalink
port Random_GetDraw
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Nov 16, 2023
1 parent 45f78c9 commit 9f11231
Show file tree
Hide file tree
Showing 7 changed files with 20 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 @@ -2710,7 +2710,7 @@ typedef enum GAME_OBJECT_ID {
0044C850 00000113 -R int32_t __cdecl GameStats(int32_t levelID);
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);
0044C9A0 0000001E + int32_t __cdecl Random_GetDraw(void);
0044C9C0 0000000A + void __cdecl Random_SeedDraw(int32_t seed);
0044C9D0 00000044 -R void __cdecl GetValidLevelsList(REQUEST_INFO *req);
0044CA20 0000004C -R void __cdecl GetSavedGamesList(REQUEST_INFO *req);
Expand Down Expand Up @@ -2953,7 +2953,7 @@ typedef enum GAME_OBJECT_ID {
00466480 - double g_GameSizer = 1.0;
00466488 - double g_GameSizerCopy = 1.0;
00466BB0 + int32_t g_RandControl;
00466BB4 - int32_t g_RandDraw;
00466BB4 + int32_t g_RandDraw;
00466F70 - struct CONTROL_LAYOUT g_Layout[2];
00467DD0 + const int32_t g_AtanBaseTable[8];
00467DF0 + const int16_t g_AtanAngleTable[0x800];
Expand Down
9 changes: 8 additions & 1 deletion src/game/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <time.h>

static int32_t m_RandControl = 0xD371F947;
static int32_t m_RandDraw = 0xD371F947;

void __cdecl Random_SeedControl(const int32_t seed)
{
Expand All @@ -14,7 +15,7 @@ void __cdecl Random_SeedControl(const int32_t seed)

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

int32_t __cdecl Random_GetControl(void)
Expand All @@ -23,6 +24,12 @@ int32_t __cdecl Random_GetControl(void)
return (m_RandControl >> 10) & 0x7FFF;
}

int32_t __cdecl Random_GetDraw(void)
{
m_RandDraw = 0x41C64E6D * m_RandDraw + 12345;
return (m_RandDraw >> 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 @@ -5,4 +5,5 @@
void __cdecl Random_SeedControl(int32_t seed);
void __cdecl Random_SeedDraw(int32_t seed);
int32_t __cdecl Random_GetControl(void);
int32_t __cdecl Random_GetDraw(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_GetDraw ((int32_t __cdecl (*)(void))0x0044C9A0)
#define GetValidLevelsList ((void __cdecl (*)(REQUEST_INFO *req))0x0044C9D0)
#define GetSavedGamesList ((void __cdecl (*)(REQUEST_INFO *req))0x0044CA20)
#define DisplayCredits ((void __cdecl (*)(void))0x0044CA70)
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_RandDraw (*(int32_t*)0x00466BB4)
#define g_Layout (*(struct CONTROL_LAYOUT(*)[2])0x00466F70)
#define g_MidSort (*(int32_t*)0x0046C300) // = 0
#define g_ViewportAspectRatio (*(float*)0x0046C304) // = 0.0f
Expand Down
1 change: 1 addition & 0 deletions src/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ static void Inject_Random(void)
{
INJECT(1, 0x0044C970, Random_GetControl);
INJECT(1, 0x0044C990, Random_SeedControl);
INJECT(1, 0x0044C9A0, Random_GetDraw);
INJECT(1, 0x0044C9C0, Random_SeedDraw);
INJECT(1, 0x0044D870, Random_Seed);
}
Expand Down

0 comments on commit 9f11231

Please sign in to comment.