Skip to content

Commit 1f29cf4

Browse files
committed
Cheats - Add menu for disabling background music and environment sounds
Disable Pause Menu/Z Menu Sounds was also moved to this menu.
1 parent 857446a commit 1f29cf4

File tree

12 files changed

+290
-122
lines changed

12 files changed

+290
-122
lines changed

ttyd-tools/rel/include/draw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void drawButtonCombo(uint32_t buttonCombo, int32_t posY, const char *description
109109
void drawChangeButtonCombo(uint16_t *currentButtonCombo);
110110
void drawCheatsGenerateLagSpike(uint16_t currentButtonCombo);
111111
void drawCheatsFrameAdvance();
112+
void drawCheatsDisableCertainSounds();
112113
void drawCheatsForcedDropItem();
113114
void drawCheatsResolveFades();
114115
void drawCheatsLockFlags();

ttyd-tools/rel/include/global.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum MENU_NAMES
2727
CHEATS_NO_BUTTON_COMBO,
2828
CHEATS_FRAME_ADVANCE,
2929
CHEATS_GENERATE_LAG_SPIKE,
30+
CHEATS_DISABLE_CERTAIN_SOUNDS,
3031
CHEATS_NPC_FORCE_DROP,
3132
CHEATS_RESOLVE_FADES,
3233
CHEATS_LOCK_FLAGS,
@@ -94,8 +95,8 @@ enum CHEATS_OPTIONS
9495
GENERATE_LAG_SPIKE,
9596
LOCK_MARIO_HP_TO_MAX,
9697
RUN_FROM_BATTLES,
97-
DISABLE_MENU_SOUNDS,
9898
BOBBERY_EARLY,
99+
DISABLE_MENU_SOUNDS,
99100
FORCE_ITEM_DROP,
100101
RESOLVE_FADES,
101102
LOCK_FLAGS,
@@ -120,6 +121,13 @@ enum CHEATS_FORCE_ITEM_DROP_SELECTION
120121
ITEM_DROP_CHANGE_BY_ID,
121122
};
122123

124+
enum CHEATS_DISABLE_CERTAIN_SOUNDS_SELECTION
125+
{
126+
PAUSE_Z_MENU_SOUND_TURN_ON_OR_OFF = 1,
127+
BGM_TURN_ON_OR_OFF,
128+
ENV_TURN_ON_OR_OFF,
129+
};
130+
123131
// Fades return values
124132
#define FADE_NOT_ACTIVE -2
125133
#define FADE_DONT_RESOLVE -1
@@ -565,6 +573,7 @@ struct MenuVars
565573
bool SystemLevelIsSet;
566574
bool ResetMarioProperties;
567575
bool MarioFreeze;
576+
bool DisableCertainSounds[2];
568577
uint16_t LagSpikeDuration; // Milliseconds
569578
int16_t ForcedNPCItemDrop;
570579
uint16_t JumpStorageSetCounter;
@@ -1069,7 +1078,7 @@ struct UnusedMapStruct
10691078
};
10701079

10711080
extern MenuVars MenuVar;
1072-
extern Menus Menu[36];
1081+
extern Menus Menu[37];
10731082
extern Cheats Cheat[27];
10741083
extern bool Displays[18];
10751084
extern char DisplayBuffer[256];

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,9 +1209,9 @@
12091209

12101210
// pmario_sound.o
12111211
// 800D8224:psndENV_LPF
1212-
// 800D826C:psndENVOff_f_d
1213-
// 800D84B4:psndENVOff
1214-
// 800D84DC:psndENVOn_f_d
1212+
800D826C:psndENVOff_f_d
1213+
800D84B4:psndENVOff
1214+
800D84DC:psndENVOn_f_d
12151215
// 800D8938:psndENVOn
12161216
// 800D8960:psndENVMain
12171217
// 800D9FE4:psndENV_stop
@@ -1234,9 +1234,9 @@
12341234
// 800DB8E8:psndBGMScope
12351235
// 800DB940:psndBGMChkSilent
12361236
// 800DB980:psndBGMChk
1237-
// 800DB9A8:psndBGMOff_f_d
1238-
// 800DBCF8:psndBGMOff
1239-
// 800DBD20:psndBGMOn_f_d
1237+
800DB9A8:psndBGMOff_f_d
1238+
800DBCF8:psndBGMOff
1239+
800DBD20:psndBGMOn_f_d
12401240
// 800DC59C:psndBGMOn
12411241
// 800DC5C8:psndBGMMain
12421242
// 800DCA5C:psndBGM_rate

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,9 +1205,9 @@
12051205

12061206
// pmario_sound.o
12071207
// 800D31EC:psndENV_LPF
1208-
// 800D3234:psndENVOff_f_d
1209-
// 800D33D4:psndENVOff
1210-
// 800D33FC:psndENVOn_f_d
1208+
800D3234:psndENVOff_f_d
1209+
800D33D4:psndENVOff
1210+
800D33FC:psndENVOn_f_d
12111211
// 800D37C0:psndENVOn
12121212
// 800D37E8:psndENVMain
12131213
// 800D4DEC:psndENV_stop
@@ -1230,9 +1230,9 @@
12301230
// 800D66D4:psndBGMScope
12311231
// 800D672C:psndBGMChkSilent
12321232
// 800D676C:psndBGMChk
1233-
// 800D6794:psndBGMOff_f_d
1234-
// 800D6A6C:psndBGMOff
1235-
// 800D6A94:psndBGMOn_f_d
1233+
800D6794:psndBGMOff_f_d
1234+
800D6A6C:psndBGMOff
1235+
800D6A94:psndBGMOn_f_d
12361236
// 800D7298:psndBGMOn
12371237
// 800D72C4:psndBGMMain
12381238
// 800D7758:psndBGM_rate

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,9 +1207,9 @@
12071207

12081208
// pmario_sound.o
12091209
// 800D7428:psndENV_LPF
1210-
// 800D7470:psndENVOff_f_d
1211-
// 800D76B8:psndENVOff
1212-
// 800D76E0:psndENVOn_f_d
1210+
800D7470:psndENVOff_f_d
1211+
800D76B8:psndENVOff
1212+
800D76E0:psndENVOn_f_d
12131213
// 800D7B3C:psndENVOn
12141214
// 800D7B64:psndENVMain
12151215
// 800D91E8:psndENV_stop
@@ -1232,9 +1232,9 @@
12321232
// 800DAAEC:psndBGMScope
12331233
// 800DAB44:psndBGMChkSilent
12341234
// 800DAB84:psndBGMChk
1235-
// 800DABAC:psndBGMOff_f_d
1236-
// 800DAEFC:psndBGMOff
1237-
// 800DAF24:psndBGMOn_f_d
1235+
800DABAC:psndBGMOff_f_d
1236+
800DAEFC:psndBGMOff
1237+
800DAF24:psndBGMOn_f_d
12381238
// 800DB7A0:psndBGMOn
12391239
// 800DB7CC:psndBGMMain
12401240
// 800DBC60:psndBGM_rate

ttyd-tools/rel/include/mod.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class Mod
4242
void preventBattlesOnReload(ttyd::seqdrv::SeqIndex, const char *, const char *);
4343
void frameAdvance();
4444
void preventViPostCallBackOnPause(uint32_t);
45+
bool disableBGM(int32_t, const char *, uint16_t, uint16_t, bool);
46+
bool disableENVSounds(int32_t, const char *, int32_t, bool);
4547

4648
private:
4749
void (*mPFN_marioStMain_trampoline)() = nullptr;
@@ -74,6 +76,8 @@ class Mod
7476
void (*mPFN_seqSetSeq_trampoline)(ttyd::seqdrv::SeqIndex, const char *, const char *) = nullptr;
7577
void (*mPFN_DEMOPadRead_trampoline)() = nullptr;
7678
void (*mPFN_viPostCallback_trampoline)(uint32_t) = nullptr;
79+
bool (*mPFN_psndBGMOn_f_d_trampoline)(int32_t, const char *, uint16_t, uint16_t, bool) = nullptr;
80+
bool (*mPFN_psndENVOn_f_d_trampoline)(int32_t, const char *, int32_t, bool) = nullptr;
7781
};
7882

7983
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ namespace ttyd::pmario_sound {
77
extern "C" {
88

99
// psndENV_LPF
10-
// psndENVOff_f_d
11-
// psndENVOff
12-
// psndENVOn_f_d
10+
bool psndENVOff_f_d(int32_t flags, int32_t wFadeTime, bool unused);
11+
bool psndENVOff(int32_t flags);
12+
bool psndENVOn_f_d(int32_t flags, const char *envName, int32_t wFadeTime, bool unused);
1313
// psndENVOn
1414
// psndENVMain
1515
// psndENV_stop
@@ -32,9 +32,9 @@ extern "C" {
3232
// psndBGMScope
3333
// psndBGMChkSilent
3434
// psndBGMChk
35-
// psndBGMOff_f_d
36-
// psndBGMOff
37-
// psndBGMOn_f_d
35+
bool psndBGMOff_f_d(int32_t flags, uint16_t fadeTime, bool unkSwitch);
36+
bool psndBGMOff(int32_t flags);
37+
bool psndBGMOn_f_d(int32_t flags, const char *bgmName, uint16_t wFadeTime, uint16_t wFadeTime2, bool unused);
3838
// psndBGMOn
3939
// psndBGMMain
4040
// psndBGM_rate

ttyd-tools/rel/source/codes.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,28 @@ int32_t Mod::preventMenuSounds(int32_t soundId, uint32_t unk1, uint32_t unk2, ui
16371637
return mPFN_SoundEfxPlayEx_trampoline(soundId, unk1, unk2, unk3);
16381638
}
16391639

1640+
bool Mod::disableBGM(int32_t flags, const char *bgmName, uint16_t wFadeTime, uint16_t wFadeTime2, bool unused)
1641+
{
1642+
if (MenuVar.DisableCertainSounds[BGM_TURN_ON_OR_OFF - 2])
1643+
{
1644+
return false;
1645+
}
1646+
1647+
// Call original function
1648+
return mPFN_psndBGMOn_f_d_trampoline(flags, bgmName, wFadeTime, wFadeTime2, unused);
1649+
}
1650+
1651+
bool Mod::disableENVSounds(int32_t flags, const char *envName, int32_t wFadeTime, bool unused)
1652+
{
1653+
if (MenuVar.DisableCertainSounds[ENV_TURN_ON_OR_OFF - 2])
1654+
{
1655+
return false;
1656+
}
1657+
1658+
// Call original function
1659+
return mPFN_psndENVOn_f_d_trampoline(flags, envName, wFadeTime, unused);
1660+
}
1661+
16401662
int32_t Mod::displayActionCommandsTimingHook(void *battleUnitPtr, ttyd::battle_unit::AttackParams *attackParams)
16411663
{
16421664
// Credits to Jdaster64 for writing the original code for this function

ttyd-tools/rel/source/draw.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3786,6 +3786,31 @@ void drawCheatsGenerateLagSpike(uint16_t currentButtonCombo)
37863786
drawText(tempDisplayBuffer, PosX, PosY, Color, Scale);
37873787
}
37883788

3789+
void drawCheatsDisableCertainSounds()
3790+
{
3791+
// uint32_t Color = 0xFFFFFFFF;
3792+
// uint8_t Alpha = 0xFF;
3793+
// int32_t PosX = -232;
3794+
int32_t PosY = 100;
3795+
// float Scale = 0.6f;
3796+
3797+
// Draw the bool for Disable Pause Menu/Z Menu Sounds
3798+
drawCheatsBool(PosY);
3799+
PosY -= 60;
3800+
3801+
// Draw the bools for the additional options
3802+
bool *Bools = MenuVar.DisableCertainSounds;
3803+
const char** Lines = Menu[CHEATS_DISABLE_CERTAIN_SOUNDS].Line;
3804+
uint32_t TotalLines = Menu[CHEATS_DISABLE_CERTAIN_SOUNDS].TotalMenuOptions;
3805+
3806+
for (uint32_t i = 0; i < (TotalLines - 1); i++)
3807+
{
3808+
// Skip the first line, as it's used for Disable Pause Menu/Z Menu Sounds
3809+
drawBoolOnOrOff(Bools[i], Lines[i + 1], PosY);
3810+
PosY -= 60;
3811+
}
3812+
}
3813+
37893814
void drawCheatsForcedDropItem()
37903815
{
37913816
uint8_t Alpha = 0xFF;

0 commit comments

Comments
 (0)