mirror of
https://github.com/pret/pmd-red.git
synced 2026-08-22 00:34:40 -05:00
Merge pull request #482 from AnonymousRandomPerson/master
Some checks are pending
GithubCI / build (push) Waiting to run
Some checks are pending
GithubCI / build (push) Waiting to run
Label dungeon RNG preseed
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
|
||||
#include "structs/dungeon_entity.h"
|
||||
|
||||
void sub_808408C(u32 param_1);
|
||||
u32 YetAnotherRandom24(void);
|
||||
void SetDungeonRNGPreseed23Bit(u32 preseed23);
|
||||
u32 GenerateDungeonRNGSeed(void);
|
||||
void InitDungeonRNG(u32 value);
|
||||
s32 DungeonRand16Bit(void);
|
||||
s32 DungeonRandInt(s32 cap);
|
||||
|
||||
@@ -284,7 +284,7 @@ typedef struct unkDungeon644
|
||||
/* 0x35 */ u8 emptyBellyAlert; // which alert message to show when belly gets empty.
|
||||
/* 0x36 */ u8 windPhase;
|
||||
/* 0x37 */ s8 unk37;
|
||||
/* 0x38 */ u32 unk38;
|
||||
/* 0x38 */ u32 prngPreseed23Bit;
|
||||
/* 0x3C */ u32 unk3C;
|
||||
/* 0x40 */ s16 unk40;
|
||||
/* 0x42 */ s16 unk42;
|
||||
|
||||
@@ -1934,7 +1934,9 @@ static void AssignGridCellConnections(struct GridCell grid[GRID_CELL_LEN][GRID_C
|
||||
if (!ok)
|
||||
continue;
|
||||
|
||||
// This section retains the original functionality
|
||||
// BUG: the wrong grid index is used for the validity check for CARDINAL_DIR_UP, CARDINAL_DIR_LEFT, and CARDINAL_DIR_DOWN
|
||||
// This can potentially read out-of-bounds grid data, which contains uninitialized garbage.
|
||||
// This makes the dungeon gen occasionally inconsistent even when using the same seed.
|
||||
switch (cardinalDirection & CARDINAL_DIRECTION_MASK) {
|
||||
case CARDINAL_DIR_RIGHT:
|
||||
if (!grid[x + 1][y].isInvalid) {
|
||||
@@ -1944,7 +1946,6 @@ static void AssignGridCellConnections(struct GridCell grid[GRID_CELL_LEN][GRID_C
|
||||
more = TRUE;
|
||||
}
|
||||
break;
|
||||
// BUG: the wrong grid index is used for the validity check
|
||||
case CARDINAL_DIR_UP:
|
||||
if (!grid[x + 1][y].isInvalid) {
|
||||
grid[x][y].connectedToTop = TRUE;
|
||||
@@ -1953,7 +1954,6 @@ static void AssignGridCellConnections(struct GridCell grid[GRID_CELL_LEN][GRID_C
|
||||
more = TRUE;
|
||||
}
|
||||
break;
|
||||
// BUG: the wrong grid index is used for the validity check
|
||||
case CARDINAL_DIR_LEFT:
|
||||
if (!grid[x + 1][y].isInvalid) {
|
||||
grid[x][y].connectedToLeft = TRUE;
|
||||
@@ -1962,7 +1962,6 @@ static void AssignGridCellConnections(struct GridCell grid[GRID_CELL_LEN][GRID_C
|
||||
more = TRUE;
|
||||
}
|
||||
break;
|
||||
// BUG: the wrong grid index is used for the validity check
|
||||
case CARDINAL_DIR_DOWN:
|
||||
if (!grid[x + 1][y].isInvalid) {
|
||||
grid[x][y].connectedToBottom = TRUE;
|
||||
|
||||
@@ -589,7 +589,7 @@ static bool8 sub_8052DC0(Entity *entity)
|
||||
return ShouldDisplayEntity(entity);
|
||||
}
|
||||
|
||||
static inline bool32 DislayTutorialMsg(Entity *leader, const TutorialFlagMsg *tutorial, bool32 unkFunctionCall)
|
||||
static inline bool32 DisplayTutorialMsg(Entity *leader, const TutorialFlagMsg *tutorial, bool32 unkFunctionCall)
|
||||
{
|
||||
const u8 *str;
|
||||
s32 flag = tutorial->flagId;
|
||||
@@ -612,14 +612,14 @@ void TryDisplayGeneralTutorialMessage(void)
|
||||
{
|
||||
Entity *leader = GetLeader();
|
||||
|
||||
if (DislayTutorialMsg(leader, &gUnknown_80FF020, TRUE)) return;
|
||||
if (DislayTutorialMsg(leader, &gUnknown_80FF080, TRUE)) return;
|
||||
if (DislayTutorialMsg(leader, &gUnknown_80FF0D8, TRUE)) return;
|
||||
if (DisplayTutorialMsg(leader, &gUnknown_80FF020, TRUE)) return;
|
||||
if (DisplayTutorialMsg(leader, &gUnknown_80FF080, TRUE)) return;
|
||||
if (DisplayTutorialMsg(leader, &gUnknown_80FF0D8, TRUE)) return;
|
||||
if (gDungeon->unk644.dungeonLocation.id == DUNGEON_THUNDERWAVE_CAVE) {
|
||||
if (DislayTutorialMsg(leader, &gUnknown_80FF13C, TRUE)) return;
|
||||
if (DislayTutorialMsg(leader, &gUnknown_80FF1B4, TRUE)) return;
|
||||
if (DislayTutorialMsg(leader, &gMovementTutorial, TRUE)) return;
|
||||
if (DislayTutorialMsg(leader, &gHungerTutorial, TRUE)) return;
|
||||
if (DisplayTutorialMsg(leader, &gUnknown_80FF13C, TRUE)) return;
|
||||
if (DisplayTutorialMsg(leader, &gUnknown_80FF1B4, TRUE)) return;
|
||||
if (DisplayTutorialMsg(leader, &gMovementTutorial, TRUE)) return;
|
||||
if (DisplayTutorialMsg(leader, &gHungerTutorial, TRUE)) return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,28 +628,28 @@ void DisplayItemTip(u8 itemId)
|
||||
u32 itemCategory = GetItemCategory(itemId);
|
||||
|
||||
if (itemCategory == CATEGORY_FOOD_GUMMIES) {
|
||||
DislayTutorialMsg(NULL, &gFoodTutorial, FALSE);
|
||||
DisplayTutorialMsg(NULL, &gFoodTutorial, FALSE);
|
||||
}
|
||||
else if (itemId == ITEM_ORAN_BERRY) {
|
||||
DislayTutorialMsg(NULL, &gOranTutorial, FALSE);
|
||||
DisplayTutorialMsg(NULL, &gOranTutorial, FALSE);
|
||||
}
|
||||
else if (itemId == ITEM_CHERI_BERRY) {
|
||||
DislayTutorialMsg(NULL, &gCheriTutorial, FALSE);
|
||||
DisplayTutorialMsg(NULL, &gCheriTutorial, FALSE);
|
||||
}
|
||||
else if (itemId == ITEM_BLAST_SEED) {
|
||||
DislayTutorialMsg(NULL, &gBlastSeedTutorial, FALSE);
|
||||
DisplayTutorialMsg(NULL, &gBlastSeedTutorial, FALSE);
|
||||
}
|
||||
else if (itemId == ITEM_GRAVELEROCK) {
|
||||
DislayTutorialMsg(NULL, &gUnknown_80FF4A0, FALSE);
|
||||
DisplayTutorialMsg(NULL, &gUnknown_80FF4A0, FALSE);
|
||||
}
|
||||
else if (itemId == ITEM_PECHA_BERRY) {
|
||||
DislayTutorialMsg(NULL, &gPechaTutorial, FALSE);
|
||||
DisplayTutorialMsg(NULL, &gPechaTutorial, FALSE);
|
||||
}
|
||||
else if (itemId == ITEM_SLEEP_SEED) {
|
||||
DislayTutorialMsg(NULL, &gSleepSeedTutorial, FALSE);
|
||||
DisplayTutorialMsg(NULL, &gSleepSeedTutorial, FALSE);
|
||||
}
|
||||
else if (itemId == ITEM_POKE) {
|
||||
DislayTutorialMsg(NULL, &gMoneyTutorial, FALSE);
|
||||
DisplayTutorialMsg(NULL, &gMoneyTutorial, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,24 +9,24 @@
|
||||
#include "dungeon_util.h"
|
||||
|
||||
EWRAM_INIT u32 gDungeonRngState = {1};
|
||||
EWRAM_INIT u32 gUnknown_203B458 = {1};
|
||||
EWRAM_INIT u32 gDungeonRngPreseedState = {1};
|
||||
|
||||
void sub_808408C(u32 param_1)
|
||||
void SetDungeonRNGPreseed23Bit(u32 preseed23)
|
||||
{
|
||||
gUnknown_203B458 = (1 | param_1) & 0xffffff;
|
||||
gDungeonRngPreseedState = (1 | preseed23) & 0xffffff;
|
||||
}
|
||||
|
||||
u32 YetAnotherRandom24(void)
|
||||
u32 GenerateDungeonRNGSeed(void)
|
||||
{
|
||||
u32 r0;
|
||||
u32 r1;
|
||||
|
||||
r1 = gUnknown_203B458 * 0x5d588b65;
|
||||
r1 = gDungeonRngPreseedState * 0x5d588b65;
|
||||
r1++;
|
||||
r0 = r1 >> 16;
|
||||
r1 *= 0x5d588b65;
|
||||
r1++;
|
||||
gUnknown_203B458 = r1;
|
||||
gDungeonRngPreseedState = r1;
|
||||
r1 &= 0xffff0000;
|
||||
r0 |= r1;
|
||||
r0 &= 0x0ffffff;
|
||||
|
||||
@@ -187,12 +187,12 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr)
|
||||
}
|
||||
if (!r6) {
|
||||
if (gDungeon->unk644.missionKind == DUNGEON_MISSION_OUTONRESCUE) {
|
||||
gDungeon->unk644.unk38 = setupPtr->info.dungeonSeed.seed;
|
||||
gDungeon->unk644.prngPreseed23Bit = setupPtr->info.dungeonSeed.seed;
|
||||
}
|
||||
else {
|
||||
gDungeon->unk644.unk38 = Rand32Bit() & 0xFFFFFF;
|
||||
gDungeon->unk644.prngPreseed23Bit = Rand32Bit() & 0xFFFFFF;
|
||||
}
|
||||
sub_808408C(gDungeon->unk644.unk38);
|
||||
SetDungeonRNGPreseed23Bit(gDungeon->unk644.prngPreseed23Bit);
|
||||
}
|
||||
if (!r6) {
|
||||
if (!sub_80980A4() && gDungeon->unk644.dungeonLocation.id == DUNGEON_TINY_WOODS) {
|
||||
@@ -248,7 +248,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr)
|
||||
gLeaderPointer = NULL;
|
||||
gDungeon->unk0 = 0;
|
||||
if (!r6) {
|
||||
gDungeon->unk644.unk3C = YetAnotherRandom24();
|
||||
gDungeon->unk644.unk3C = GenerateDungeonRNGSeed();
|
||||
gDungeon->unk644.unk24 = 10;
|
||||
InitDungeonRNG(gDungeon->unk644.unk3C);
|
||||
}
|
||||
@@ -620,7 +620,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr)
|
||||
memset(&setupPtr->info.unk84, 0, sizeof(setupPtr->info.unk84));
|
||||
setupPtr->info.unk80 = gDungeon->unk644.dungeonLocation;
|
||||
setupPtr->info.unk84.location = gDungeon->unk644.dungeonLocation;
|
||||
setupPtr->info.unk84.seed = gDungeon->unk644.unk38;
|
||||
setupPtr->info.unk84.seed = gDungeon->unk644.prngPreseed23Bit;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user