Skip to content

Commit 823e762

Browse files
committed
Handle title screen and file select screen stuff separately
This makes it so that the checks for drawing the title screen and file select screen stuff is not running every frame.
1 parent 75a5eac commit 823e762

File tree

9 files changed

+95
-30
lines changed

9 files changed

+95
-30
lines changed

ttyd-tools/rel/include/lst/ttyd.eu.lst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
// 80008A54:pressStartGX
8686
// 80008EFC:disp2
8787
// 80009264:disp1
88-
// 800093F0:titleMain
88+
800093F0:titleMain
8989
// 80009CAC:L_titleInit
9090
// 80009E90:N_getDebugMode
9191
// 80009E9C:seq_titleMain
@@ -1668,6 +1668,14 @@
16681668
// 800F1E54:evt_pouch_add_coin
16691669
// 800F1E84:evt_pouch_get_coin
16701670

1671+
// seq_load.o
1672+
// 800F4848:continueGame
1673+
// 800F4D98:loadDraw
1674+
// 800F6940:loadMain
1675+
800F7DD4:seq_loadMain
1676+
// 800F80E8:seq_loadExit
1677+
// 800F8124:seq_loadInit
1678+
16711679
// battle.o
16721680
// text
16731681
// 800F8320:BattleConsumeReserveItem

ttyd-tools/rel/include/lst/ttyd.jp.lst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
// 800087B0:pressStartGX
8686
// 80008C50:disp2
8787
// 80008F68:disp1
88-
// 800090F4:titleMain
88+
800090F4:titleMain
8989
// 80009958:L_titleInit
9090
// 80009B3C:N_getDebugMode
9191
// 80009B48:seq_titleMain
@@ -1664,6 +1664,14 @@
16641664
// 800EC32C:evt_pouch_add_coin
16651665
// 800EC35C:evt_pouch_get_coin
16661666

1667+
// seq_load.o
1668+
// 800EED20:continueGame
1669+
// 800EF270:loadDraw
1670+
// 800F0BE8:loadMain
1671+
800F207C:seq_loadMain
1672+
// 800F2330:seq_loadExit
1673+
// 800F236C:seq_loadInit
1674+
16671675
// battle.o
16681676
// text
16691677
// 800F2568:BattleConsumeReserveItem

ttyd-tools/rel/include/lst/ttyd.us.lst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
// 80008888:pressStartGX
8686
// 80008D30:disp2
8787
// 80009098:disp1
88-
// 80009224:titleMain
88+
80009224:titleMain
8989
// 80009AE8:L_titleInit
9090
// 80009CCC:N_getDebugMode
9191
// 80009CD8:seq_titleMain
@@ -1666,6 +1666,14 @@
16661666
// 800F0FE8:evt_pouch_add_coin
16671667
// 800F1018:evt_pouch_get_coin
16681668

1669+
// seq_load.o
1670+
// 800F39DC:continueGame
1671+
// 800F3F2C:loadDraw
1672+
// 800F5AD4:loadMain
1673+
800F6F68:seq_loadMain
1674+
// 800F727C:seq_loadExit
1675+
// 800F72B8:seq_loadInit
1676+
16691677
// battle.o
16701678
// text
16711679
// 800F74B4:BattleConsumeReserveItem

ttyd-tools/rel/include/mod.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class Mod
4444
void preventViPostCallBackOnPause(uint32_t);
4545
bool disableBGM(int32_t, const char *, uint16_t, uint16_t, bool);
4646
bool disableENVSounds(int32_t, const char *, int32_t, bool);
47+
void displayTitleScreenInfo(ttyd::seqdrv::SeqInfo *);
48+
void displayFileSelectScreenInfo(ttyd::seqdrv::SeqInfo *);
4749

4850
private:
4951
void (*mPFN_marioStMain_trampoline)() = nullptr;
@@ -78,6 +80,8 @@ class Mod
7880
void (*mPFN_viPostCallback_trampoline)(uint32_t) = nullptr;
7981
bool (*mPFN_psndBGMOn_f_d_trampoline)(int32_t, const char *, uint16_t, uint16_t, bool) = nullptr;
8082
bool (*mPFN_psndENVOn_f_d_trampoline)(int32_t, const char *, int32_t, bool) = nullptr;
83+
void (*mPFN_titleMain_trampoline)(ttyd::seqdrv::SeqInfo *) = nullptr;
84+
void (*mPFN_seq_loadMain_trampoline)(ttyd::seqdrv::SeqInfo *) = nullptr;
8185
};
8286

8387
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
3+
#include <ttyd/seqdrv.h>
4+
5+
#include <cstdint>
6+
7+
namespace ttyd::seq_load {
8+
9+
extern "C" {
10+
11+
// continueGame
12+
// loadDraw
13+
// loadMain
14+
void seq_loadMain(ttyd::seqdrv::SeqInfo *seqInfo);
15+
// seq_loadExit
16+
// seq_loadInit
17+
18+
}
19+
20+
}

ttyd-tools/rel/include/ttyd/seq_title.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <ttyd/seqdrv.h>
4+
35
#include <cstdint>
46

57
namespace ttyd::seq_title {
@@ -9,7 +11,7 @@ extern "C" {
911
// pressStartGX
1012
// disp2
1113
// disp1
12-
// titleMain
14+
void titleMain(ttyd::seqdrv::SeqInfo *seqInfo);
1315
// L_titleInit
1416
// N_getDebugMode
1517
// seq_titleMain

ttyd-tools/rel/source/codes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ void levitate()
637637
}
638638

639639
ttyd::mario::Player *player = ttyd::mario::marioGetPtr();
640-
player->wJumpVelocityY = 4.540000915527344;
640+
player->wJumpVelocityY = 4.540000915527344f;
641641
}
642642

643643
uint32_t autoMashText(uint32_t controllerPort)

ttyd-tools/rel/source/main.cpp

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -277,33 +277,37 @@ void *jumpOnWater(void *ptr)
277277
}
278278
}
279279

280-
void displayTitleScreenAndFileSelectScreenInfo()
280+
void Mod::displayTitleScreenInfo(ttyd::seqdrv::SeqInfo *seqInfo)
281281
{
282-
if (checkForSpecificSeq(ttyd::seqdrv::SeqIndex::kTitle))
282+
// Check to see if the title screen is ready
283+
// Check to see if the curtain is fully displayed or not
284+
uint32_t TitleMainCheck = *reinterpret_cast<uint32_t *>(
285+
reinterpret_cast<uint32_t>(ttyd::seq_title::seqTitleWorkPointer2) + 0x8);
286+
287+
if ((TitleMainCheck >= 2) && (TitleMainCheck < 12))
283288
{
284-
// Check to see if the title screen is ready
285-
// Check to see if the curtain is fully displayed or not
286-
uint32_t TitleMainCheck = *reinterpret_cast<uint32_t *>(
287-
reinterpret_cast<uint32_t>(ttyd::seq_title::seqTitleWorkPointer2) + 0x8);
288-
289-
if ((TitleMainCheck >= 2) && (TitleMainCheck < 12))
290-
{
291-
// Curtain is not fully displayed
292-
// Draw the title screen info
293-
drawFunctionOn2DLayerWithOrder(drawTitleScreenInfo, -1.f);
294-
}
289+
// Curtain is not fully displayed
290+
// Draw the title screen info
291+
drawFunctionOn2DLayerWithOrder(drawTitleScreenInfo, -1.f);
295292
}
296-
else if (checkForSpecificSeq(ttyd::seqdrv::SeqIndex::kLoad))
293+
294+
// Call original function
295+
mPFN_titleMain_trampoline(seqInfo);
296+
}
297+
298+
void Mod::displayFileSelectScreenInfo(ttyd::seqdrv::SeqInfo *seqInfo)
299+
{
300+
// Check to see if the curtain is down or not
301+
uint32_t SeqMainCheck = ttyd::seqdrv::seqWork.wFileSelectScreenProgress;
302+
303+
if (SeqMainCheck == 2)
297304
{
298-
// Check to see if the curtain is down or not
299-
uint32_t SeqMainCheck = ttyd::seqdrv::seqWork.wFileSelectScreenProgress;
300-
301-
if (SeqMainCheck == 2)
302-
{
303-
// Draw the file select screen info
304-
drawFunctionOn2DLayerWithOrder(drawFileSelectScreenInfo, -1.f);
305-
}
305+
// Draw the file select screen info
306+
drawFunctionOn2DLayerWithOrder(drawFileSelectScreenInfo, -1.f);
306307
}
308+
309+
// Call original function
310+
mPFN_seq_loadMain_trampoline(seqInfo);
307311
}
308312

309313
int32_t Mod::pauseMenuPreventUnpause(void *pauseMenuPointer)
@@ -1013,9 +1017,6 @@ void initAddressOverwrites()
10131017

10141018
void Mod::run()
10151019
{
1016-
// Display the title screen and file select screen info
1017-
displayTitleScreenAndFileSelectScreenInfo();
1018-
10191020
// Update the On-Screen Timer variables if the display is on
10201021
updateOnScreenTimerVars();
10211022

ttyd-tools/rel/source/mod.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <ttyd/seqdrv.h>
2828
#include <ttyd/pmario_sound.h>
2929
#include <ttyd/fontmgr.h>
30+
#include <ttyd/seq_title.h>
31+
#include <ttyd/seq_load.h>
3032
#include <ttyd/windowdrv.h>
3133
#include <ttyd/seq_logo.h>
3234

@@ -207,6 +209,18 @@ void Mod::init()
207209
return gMod->disableENVSounds(flags, envName, wFadeTime, unused);
208210
});
209211

212+
mPFN_titleMain_trampoline = patch::hookFunction(
213+
ttyd::seq_title::titleMain, [](ttyd::seqdrv::SeqInfo *seqInfo)
214+
{
215+
gMod->displayTitleScreenInfo(seqInfo);
216+
});
217+
218+
mPFN_seq_loadMain_trampoline = patch::hookFunction(
219+
ttyd::seq_load::seq_loadMain, [](ttyd::seqdrv::SeqInfo *seqInfo)
220+
{
221+
gMod->displayFileSelectScreenInfo(seqInfo);
222+
});
223+
210224
// Initialize typesetting early
211225
ttyd::fontmgr::fontmgrTexSetup();
212226
patch::hookFunction(ttyd::fontmgr::fontmgrTexSetup, [](){});

0 commit comments

Comments
 (0)