Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decompile Code 8094d28 #373

Merged
merged 3 commits into from
Mar 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
275 changes: 0 additions & 275 deletions asm/code_8094D28.s

This file was deleted.

8 changes: 0 additions & 8 deletions include/code_8094D28.h

This file was deleted.

7 changes: 7 additions & 0 deletions include/random_mersenne_twister.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef GUARD_RANDOM_MERSENNE_TWISTER_H
#define GUARD_RANDOM_MERSENNE_TWISTER_H

void MersenneTwister_InitializeState(u32 seed);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names might be too verbose. Consider mtsrand and mtrand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what do others think? I can rename these functions to mtsrand and mtrand, if that's the only thing blocking the PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way works for me. I don't mind long or short names as long as they're descriptive (which both options are here).

s32 Random32MersenneTwister(void);

#endif // GUARD_RANDOM_MERSENNE_TWISTER_H
5 changes: 2 additions & 3 deletions ld_script.txt
Original file line number Diff line number Diff line change
@@ -290,8 +290,7 @@ SECTIONS {
src/code_809447C.o(.text);
src/code_8092334.o(.text);
src/game_options.o(.text);
src/code_8094D28.o(.text);
asm/code_8094D28.o(.text);
src/random_mersenne_twister.o(.text);
src/play_time.o(.text);
src/code_8094F88.o(.text);
src/code_80958E8.o(.text);
@@ -566,7 +565,7 @@ SECTIONS {
src/pokemon.o(.rodata);
data/data_81076E4.o(.rodata);
src/game_options.o(.rodata);
src/code_8094D28.o(.rodata);
src/random_mersenne_twister.o(.rodata);
src/play_time.o(.rodata);
src/code_8094F88.o(.rodata);
src/code_80958E8.o(.rodata);
20 changes: 0 additions & 20 deletions src/code_8094D28.c

This file was deleted.

6 changes: 3 additions & 3 deletions src/code_8094F88.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "global.h"
#include "globaldata.h"
#include "code_8094D28.h"
#include "random_mersenne_twister.h"
#include "code_8094F88.h"
#include "constants/wonder_mail.h"
#include "dungeon.h"
@@ -277,8 +277,8 @@ void sub_809542C(WonderMailSub *param_1)

gUnknown_203B480->mailType = 1;
gUnknown_203B480->unk4 = *param_1;
sub_8094D28(Rand32Bit());
gUnknown_203B480->unk10.unk10 = sub_8094E4C();
MersenneTwister_InitializeState(Rand32Bit());
gUnknown_203B480->unk10.unk10 = Random32MersenneTwister();
gUnknown_203B480->clientSpecies = GetPlayerPokemonStruct()->speciesNum;
PrintPokeNameToBuffer(buffer, GetPlayerPokemonStruct());
CopyStringtoBuffer(gUnknown_203B480->playerName, buffer);
8 changes: 4 additions & 4 deletions src/personality_test1.c
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
#include "bg_palette_buffer.h"
#include "string_format.h"
#include "code_801602C.h"
#include "code_8094D28.h"
#include "random_mersenne_twister.h"
#include "code_8099360.h"
#include "constants/emotions.h"
#include "game_options.h"
@@ -148,14 +148,14 @@ u32 HandleTestTrackerState(void)
break;
case PERSONALITY_TEST_END:
iVar1 = Rand32Bit() * sPersonalityTestTracker->FrameCounter;
sub_8094D28(Rand32Bit());
MersenneTwister_InitializeState(Rand32Bit());

for (counter = 0; counter < NUM_PERSONALITIES; counter++)
iVar1 *= sPersonalityTestTracker->NatureTotals[counter] + counter + 3;

iVar1 += sub_8094E4C();
iVar1 += Random32MersenneTwister();
while (iVar1 == -1)
iVar1 += sub_8094E4C();
iVar1 += Random32MersenneTwister();

sub_8011C40(iVar1);
return 3;
Loading