Skip to content

Commit 61e0a37

Browse files
committed
Bug Fix
Fixed a black screen occuring if the player hit a save block at the same time as either warping or reloading the room.
1 parent d7059e3 commit 61e0a37

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

ttyd-tools/rel/include/codes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ void saveAnywhere();
1111
void setTextStorage();
1212
void setTimeStopTextStorage();
1313
void speedUpMario();
14+
void checkIfSystemLevelShouldBeLowered();
1415
void reloadRoomMain();
1516
void reloadRoom();
1617
void levitate();

ttyd-tools/rel/include/global.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ struct SaveAnywhereStruct
393393

394394
struct ReloadRoomStruct
395395
{
396+
bool SystemLevelShouldBeLowered;
396397
char NewBero[32]; // 31 bytes for NextBero, 1 byte for NULL
397398
char NewMap[9]; // 8 bytes for NextMap, 1 byte for NULL
398399
};

ttyd-tools/rel/source/codes.cpp

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,30 @@ bool Mod::infiniteItemUsage(int16_t item, uint32_t index)
315315
return mPFN_pouchRemoveItemIndex_trampoline(item, index);
316316
}
317317

318+
void checkIfSystemLevelShouldBeLowered()
319+
{
320+
// Only run when the player has either reloaded the room or warped
321+
if (!ReloadRoom.SystemLevelShouldBeLowered)
322+
{
323+
return;
324+
}
325+
326+
// Keep lowering the system level until the seq changes to Game
327+
if (!checkForSpecificSeq(ttyd::seqdrv::SeqIndex::kGame))
328+
{
329+
// Only lower the system level if it's not currently at 0
330+
uint32_t SystemLevel = getSystemLevel();
331+
if (SystemLevel > 0)
332+
{
333+
setSystemLevel(0);
334+
}
335+
}
336+
else
337+
{
338+
ReloadRoom.SystemLevelShouldBeLowered = false;
339+
}
340+
}
341+
318342
void reloadRoomMain()
319343
{
320344
ttyd::seqdrv::SeqIndex NextSeq = ttyd::seqdrv::seqGetNextSeq();
@@ -374,6 +398,7 @@ void reloadRoomMain()
374398
ttyd::pmario_sound::psndClearFlag(0x80);
375399
ttyd::mario_cam::marioSetCamId(4);
376400
setSystemLevel(0);
401+
ReloadRoom.SystemLevelShouldBeLowered = true;
377402
}
378403

379404
void reloadRoom()
@@ -401,12 +426,7 @@ void reloadRoom()
401426
if ((player->currentMotionId == ReceivingItem) && (NextSeq == MapChange))
402427
{
403428
// Reset the System Level
404-
// Only lower the system level if it's not currently at 0
405-
uint32_t SystemLevel = getSystemLevel();
406-
if (SystemLevel > 0)
407-
{
408-
setSystemLevel(0);
409-
}
429+
ReloadRoom.SystemLevelShouldBeLowered = true;
410430

411431
// Reset the camera - mainly for the black bars at the top and bottom of the screen
412432
uint32_t CameraPointer = reinterpret_cast<uint32_t>(ttyd::camdrv::camGetPtr(8));

ttyd-tools/rel/source/draw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2737,7 +2737,7 @@ void drawTitleScreenInfo()
27372737
PosX += 113;
27382738
PosY -= 14;
27392739

2740-
const char *String = "Practice Codes v3.0.5\nCreated by Zephiles";
2740+
const char *String = "Practice Codes v3.0.6\nCreated by Zephiles";
27412741
drawText(String, PosX, PosY, Alpha, TextColor, Scale);
27422742
}
27432743

ttyd-tools/rel/source/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ void Mod::run()
552552
reloadRoom(); // Needs to always run due to the extra code that always does some failsafe checking
553553
bobberyEarly();
554554
checkIfAreaFlagsShouldBeCleared();
555+
checkIfSystemLevelShouldBeLowered();
555556

556557
// Run each display function
557558
// Only run if the mod menu isn't currently open

0 commit comments

Comments
 (0)