Skip to content

Commit 624c0d7

Browse files
committed
Added a display for Bridge Skip
An additional feature is that Bridge Skip will be possible in the PAL version of the game when the Bridge Skip display is active. Also renamed displayMarioCoordinatesBoolCheck to displayMarioCoordinates.
1 parent 6b4f131 commit 624c0d7

File tree

10 files changed

+272
-11
lines changed

10 files changed

+272
-11
lines changed

ttyd-tools/rel/include/assembly.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ void StartFixEvtMapBlendSetFlagPartnerCrash();
2424
void StartFixEvtMapBlendSetFlagFollowerCrash();
2525
void StartFallThroughMostObjectsStandard();
2626
void StartFallThroughMostObjectsBowser();
27+
void StartJumpOnWater();
2728

2829
// Functions accessed by assembly overwrites
2930
// main.cpp
@@ -34,6 +35,7 @@ void preventTextboxOptionSelection(char *currentText, void *storeAddress, int32_
3435
void *fixEvtMapBlendSetFlagPartnerCrash(void *partnerPtr);
3536
void *fixEvtMapBlendSetFlagFollowerCrash(void *followerPtr);
3637
const char *replaceJumpFallAnim(char *jumpFallString);
38+
void *jumpOnWater(void *ptr);
3739

3840
// codes.cpp
3941
uint32_t allowRunningFromBattles(void *ptr);

ttyd-tools/rel/include/codes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void lockFlags();
2525
void displaySequenceInPauseMenu();
2626
void displayOnScreenTimer();
2727
void displayFrameCounter();
28-
void displayMarioCoordinatesBoolCheck();
28+
void displayMarioCoordinates();
2929
void displayMarioSpeedXZ();
3030
void displayJumpStorageDetails();
3131
void displayButtonInputs();
@@ -34,6 +34,7 @@ void displayMemoryWatches();
3434

3535
void displayYoshiSkipDetails();
3636
void displayPalaceSkipDetails();
37+
void displayBridgeSkipDetails();
3738
void displayBlimpTicketSkipDetails();
3839
void displayActionCommandsTiming();
3940

ttyd-tools/rel/include/draw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ void drawMemoryWatchesOnOverworld();
119119

120120
void drawYoshiSkipDetails();
121121
void drawPalaceSkipDetails();
122+
void drawBridgeSkipDetails();
122123
void drawBlimpTicketSkipDetails();
123124
void drawActionCommandsTiming();
124125
void drawSettingsCurrentWork();

ttyd-tools/rel/include/global.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ enum DISPLAYS_OPTIONS
348348
ART_ATTACK_HITBOXES,
349349
YOSHI_SKIP,
350350
PALACE_SKIP,
351+
BRIDGE_SKIP,
351352
BLIMP_TICKET_SKIP,
352353
};
353354

@@ -669,6 +670,21 @@ struct TrickDisplay
669670
}
670671
};
671672

673+
struct BridgeSkipStruct
674+
{
675+
uint32_t MainTimer;
676+
uint32_t ResetTimer;
677+
bool PressedEarly;
678+
bool PressedEarlyShouldDisable;
679+
bool TimerPaused;
680+
bool TimerStopped;
681+
682+
BridgeSkipStruct()
683+
{
684+
TimerStopped = true;
685+
}
686+
};
687+
672688
struct BlimpTicketSkipStruct
673689
{
674690
uint32_t UpRightTimer;
@@ -848,7 +864,7 @@ struct NpcNameToPtrErrorStruct
848864
extern MenuVars MenuVar;
849865
extern Menus Menu[31];
850866
extern Cheats Cheat[25];
851-
extern bool Displays[13];
867+
extern bool Displays[14];
852868
extern char DisplayBuffer[256];
853869
extern char HeapBuffer[512];
854870
extern MemoryWatchStruct MemoryWatch[60];
@@ -868,6 +884,7 @@ extern ClearCacheForBattlesStruct ClearCacheForBattles;
868884
extern LockFlagsStruct LockFlags;
869885
extern TrickDisplay YoshiSkip;
870886
extern TrickDisplay PalaceSkip;
887+
extern BridgeSkipStruct BridgeSkip;
871888
extern BlimpTicketSkipStruct BlimpTicketSkip;
872889
extern OnScreenTimerDisplay OnScreenTimer;
873890
extern OnScreenTimerDisplayFrameCounter FrameCounter;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.global StartJumpOnWater
2+
3+
StartJumpOnWater:
4+
stwu %sp,-0x10(%sp)
5+
mflr %r0
6+
stw %r0,0x14(%sp)
7+
8+
# r3 already contains ptr
9+
bl jumpOnWater
10+
11+
lwz %r0,0x14(%sp)
12+
mtlr %r0
13+
addi %sp,%sp,0x10
14+
15+
# Restore the overwritten instruction
16+
cmplwi %r3,0
17+
blr

ttyd-tools/rel/source/codes.cpp

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ void displayFrameCounter()
992992
drawFunctionOnDebugLayer(drawFrameCounter);
993993
}
994994

995-
void displayMarioCoordinatesBoolCheck()
995+
void displayMarioCoordinates()
996996
{
997997
if (!Displays[MARIO_COORDINATES])
998998
{
@@ -1117,7 +1117,7 @@ void displayYoshiSkipDetails()
11171117
else
11181118
{
11191119
ttyd::mario::Player *player = ttyd::mario::marioGetPtr();
1120-
bool MarioControl = player->flags1 & (1 << 0); // Check if 0 bit is active
1120+
bool MarioControl = player->flags1 & (1 << 0); // Check if 0 bit is set
11211121

11221122
if (MarioControl && YoshiSkip.TimerPaused)
11231123
{
@@ -1204,6 +1204,113 @@ void displayPalaceSkipDetails()
12041204
drawFunctionOnDebugLayer(drawPalaceSkipDetails);
12051205
}
12061206

1207+
void displayBridgeSkipDetails()
1208+
{
1209+
if (!Displays[BRIDGE_SKIP])
1210+
{
1211+
return;
1212+
}
1213+
1214+
ttyd::mario::Player *player = ttyd::mario::marioGetPtr();
1215+
bool unkNoLongerOnGround = player->flags2 & (1 << 28); // Check if 28 bit is set
1216+
bool unkNotAbleToJump = player->flags2 & (1 << 16); // Check if 16 bit is set
1217+
1218+
if (!unkNoLongerOnGround && unkNotAbleToJump) // Done falling, now starting to stand up
1219+
{
1220+
if (!BridgeSkip.PressedEarly)
1221+
{
1222+
// Reset the timer upon landing and while not pressing A
1223+
BridgeSkip.MainTimer = 0;
1224+
1225+
// Check if A was pressed too early
1226+
if (BridgeSkip.TimerPaused && BridgeSkip.TimerStopped)
1227+
{
1228+
// Pressed A too early, so start the timer
1229+
BridgeSkip.PressedEarly = true;
1230+
BridgeSkip.TimerPaused = false;
1231+
BridgeSkip.TimerStopped = false;
1232+
}
1233+
else
1234+
{
1235+
// Stop the timer
1236+
BridgeSkip.TimerPaused = true;
1237+
BridgeSkip.TimerStopped = false;
1238+
}
1239+
}
1240+
else if (BridgeSkip.PressedEarlyShouldDisable)
1241+
{
1242+
// Reset the early state
1243+
BridgeSkip.TimerPaused = true;
1244+
BridgeSkip.PressedEarly = false;
1245+
BridgeSkip.PressedEarlyShouldDisable = false;
1246+
BridgeSkip.TimerStopped = false;
1247+
}
1248+
else
1249+
{
1250+
// The timer is currently running
1251+
}
1252+
}
1253+
else if (!unkNoLongerOnGround && !unkNotAbleToJump) // A timing, start timer
1254+
{
1255+
if (!BridgeSkip.PressedEarly)
1256+
{
1257+
if (BridgeSkip.TimerPaused) // Prevents running when the display is initially enabled
1258+
{
1259+
if (!BridgeSkip.TimerStopped)
1260+
{
1261+
// Didn't press A, so start the timer
1262+
BridgeSkip.TimerPaused = false;
1263+
}
1264+
else if (!(player->flags2 & (1 << 17))) // Check if 17 bit is not set; unkCurrentlyJumping
1265+
{
1266+
// Pressed A one frame early
1267+
BridgeSkip.PressedEarly = true;
1268+
BridgeSkip.PressedEarlyShouldDisable = true;
1269+
}
1270+
else
1271+
{
1272+
// Pressed A on the correct frame, so leave the timer paused
1273+
}
1274+
}
1275+
}
1276+
else
1277+
{
1278+
// Stop the timer
1279+
BridgeSkip.TimerPaused = true;
1280+
BridgeSkip.PressedEarlyShouldDisable = true;
1281+
}
1282+
}
1283+
1284+
if (checkButtonCombo(PAD_A))
1285+
{
1286+
// Stop when A is pressed
1287+
BridgeSkip.TimerStopped = true;
1288+
}
1289+
1290+
if (checkButtonComboEveryFrame(PAD_Y))
1291+
{
1292+
// Hold Y to increment the reset counter
1293+
BridgeSkip.ResetTimer++;
1294+
}
1295+
else
1296+
{
1297+
BridgeSkip.ResetTimer = 0;
1298+
}
1299+
1300+
if (BridgeSkip.ResetTimer > secondsToFrames(2))
1301+
{
1302+
// Reset the timer when button is held for 2 seconds
1303+
BridgeSkip.MainTimer = 0;
1304+
BridgeSkip.ResetTimer = 0;
1305+
BridgeSkip.PressedEarly = false;
1306+
BridgeSkip.PressedEarlyShouldDisable = false;
1307+
BridgeSkip.TimerPaused = false;
1308+
BridgeSkip.TimerStopped = true;
1309+
}
1310+
1311+
drawFunctionOnDebugLayer(drawBridgeSkipDetails);
1312+
}
1313+
12071314
void displayBlimpTicketSkipDetails()
12081315
{
12091316
if (!Displays[BLIMP_TICKET_SKIP])

ttyd-tools/rel/source/draw.cpp

Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3790,8 +3790,9 @@ void drawOnScreenTimer()
37903790
if (!Displays[BUTTON_INPUT_DISPLAY])
37913791
{
37923792
if (Displays[MARIO_COORDINATES] ||
3793+
Displays[YOSHI_SKIP] ||
37933794
Displays[PALACE_SKIP] ||
3794-
Displays[YOSHI_SKIP])
3795+
Displays[BRIDGE_SKIP])
37953796
{
37963797
PosY += 20;
37973798
}
@@ -3837,8 +3838,9 @@ void drawFrameCounter()
38373838
if (!Displays[BUTTON_INPUT_DISPLAY])
38383839
{
38393840
if (Displays[MARIO_COORDINATES] ||
3841+
Displays[YOSHI_SKIP] ||
38403842
Displays[PALACE_SKIP] ||
3841-
Displays[YOSHI_SKIP])
3843+
Displays[BRIDGE_SKIP])
38423844
{
38433845
PosY += 20;
38443846
}
@@ -3902,8 +3904,9 @@ void drawMarioSpeedXZ()
39023904

39033905
// Move the text up if the Mario coordinates display is active
39043906
if (Displays[MARIO_COORDINATES] ||
3907+
Displays[YOSHI_SKIP] ||
39053908
Displays[PALACE_SKIP] ||
3906-
Displays[YOSHI_SKIP])
3909+
Displays[BRIDGE_SKIP])
39073910
{
39083911
PosY += 20;
39093912
}
@@ -4005,8 +4008,10 @@ void drawStickAngle()
40054008
PosY += 20;
40064009
}
40074010

4008-
// Move the text up if Mario's Coordinates are displayed, or if the Palace Skip display is active
4009-
if (Displays[MARIO_COORDINATES] || Displays[PALACE_SKIP])
4011+
// Move the text up if the Mario coordinates display is active
4012+
if (Displays[MARIO_COORDINATES] ||
4013+
Displays[PALACE_SKIP] ||
4014+
Displays[BRIDGE_SKIP])
40104015
{
40114016
PosY += 20;
40124017
}
@@ -4238,6 +4243,84 @@ void drawPalaceSkipDetails()
42384243
}
42394244
}
42404245

4246+
void drawBridgeSkipDetails()
4247+
{
4248+
uint32_t TextColor = 0xFFFFFFFF;
4249+
uint8_t Alpha = 0xFF;
4250+
int32_t PosX = -232;
4251+
int32_t PosY = -117;
4252+
float Scale = 0.75;
4253+
4254+
// Move the text up if the input display is active
4255+
if (Displays[BUTTON_INPUT_DISPLAY])
4256+
{
4257+
PosY += 20;
4258+
}
4259+
4260+
// Move the text up if the Mario Speed XZ display is active
4261+
if (Displays[MARIO_SPEED_XZ])
4262+
{
4263+
PosY += 20;
4264+
}
4265+
4266+
// Move the text up if the Stick Angle display is active
4267+
if (Displays[STICK_ANGLE])
4268+
{
4269+
PosY += 20;
4270+
}
4271+
4272+
uint32_t MainTimer = BridgeSkip.MainTimer;
4273+
4274+
// Check whether A was pressed early or late
4275+
const char *EarlyOrLate;
4276+
if (!BridgeSkip.PressedEarly)
4277+
{
4278+
EarlyOrLate = "Late";
4279+
}
4280+
else
4281+
{
4282+
// Increment the timer by 1 to account for being early by X frames
4283+
MainTimer += 1;
4284+
EarlyOrLate = "Early";
4285+
}
4286+
4287+
// Check if the Frames text should be plural
4288+
const char *FramesPlural;
4289+
if (MainTimer == 1)
4290+
{
4291+
FramesPlural = "";
4292+
}
4293+
else
4294+
{
4295+
FramesPlural = "s";
4296+
}
4297+
4298+
// Draw the text
4299+
char *tempDisplayBuffer = DisplayBuffer;
4300+
ttyd::mario::Player *player = ttyd::mario::marioGetPtr();
4301+
4302+
sprintf(tempDisplayBuffer,
4303+
"%" PRIu32 " Frame%s %s\nHRP: 0x%08" PRIX32,
4304+
MainTimer,
4305+
FramesPlural,
4306+
EarlyOrLate,
4307+
reinterpret_cast<uint32_t>(player->wObjHazardRespawn));
4308+
4309+
drawText(tempDisplayBuffer, PosX, PosY, Alpha, TextColor, Scale);
4310+
4311+
// Draw Mario's coordinates if they're not already drawn
4312+
if (!Displays[MARIO_COORDINATES])
4313+
{
4314+
drawMarioCoordinates();
4315+
}
4316+
4317+
// Increment the main timer
4318+
if (!BridgeSkip.TimerPaused && !BridgeSkip.TimerStopped)
4319+
{
4320+
BridgeSkip.MainTimer++;
4321+
}
4322+
}
4323+
42414324
void drawBlimpTicketSkipDetails()
42424325
{
42434326
uint32_t TextColor = 0xFFFFFFFF;

0 commit comments

Comments
 (0)