summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAECX <maurice.henke@protonmail.com>2021-02-20 16:28:54 +0100
committerGitHub <noreply@github.com>2021-02-20 16:28:54 +0100
commitf0a56756b68c157a971f28902f28ec58b0d94b35 (patch)
treec626367b66126e2c8e1170bf8b96b709768cbb2b
parent77fc0213cabc3420e90f6de909716c87fc0f67d2 (diff)
parente0f7687c216ae63c7b3d9f4c76c5551cc1930fd2 (diff)
Merge pull request #3 from jdflyer/stable
Option to disable enemy BGM
-rw-r--r--include/musicRando.h1
-rw-r--r--include/tp.eu.lst3
-rw-r--r--include/tp.jp.lst3
-rw-r--r--include/tp.us.lst3
-rw-r--r--include/tp/Z2SeqMgr.h9
-rw-r--r--source/mod.cpp1
-rw-r--r--source/musicRando.cpp12
7 files changed, 32 insertions, 0 deletions
diff --git a/include/musicRando.h b/include/musicRando.h
index 7870a05..c05204f 100644
--- a/include/musicRando.h
+++ b/include/musicRando.h
@@ -3,5 +3,6 @@
namespace mod::musicrando {
extern u8 musicRandoEnabled;
+ extern u8 enemyBgmEnabled;
void initMusicRando();
} \ No newline at end of file
diff --git a/include/tp.eu.lst b/include/tp.eu.lst
index b250747..fab4338 100644
--- a/include/tp.eu.lst
+++ b/include/tp.eu.lst
@@ -182,3 +182,6 @@
//Z2SceneMgr
802BA968:sceneChange
+
+//Z2SeqMgr
+802B5CB0:startBattleBgm
diff --git a/include/tp.jp.lst b/include/tp.jp.lst
index 0ee2a64..2fd907b 100644
--- a/include/tp.jp.lst
+++ b/include/tp.jp.lst
@@ -183,3 +183,6 @@
//Z2SceneMgr
802BBFA8:sceneChange
+
+//Z2SeqMgr
+802B72F0:startBattleBgm
diff --git a/include/tp.us.lst b/include/tp.us.lst
index 3a58939..e6ea2ab 100644
--- a/include/tp.us.lst
+++ b/include/tp.us.lst
@@ -197,3 +197,6 @@
//Z2SceneMgr
802B9B68:sceneChange
+
+//Z2SeqMgr
+802B4EB0:startBattleBgm
diff --git a/include/tp/Z2SeqMgr.h b/include/tp/Z2SeqMgr.h
new file mode 100644
index 0000000..f636ef5
--- /dev/null
+++ b/include/tp/Z2SeqMgr.h
@@ -0,0 +1,9 @@
+#pragma once
+
+struct Z2SeqMgr;
+
+namespace tp::Z2AudioLib::SeqMgr {
+ extern "C" {
+ void startBattleBgm(Z2SeqMgr* seqMgr, bool param_1);
+ }
+} \ No newline at end of file
diff --git a/source/mod.cpp b/source/mod.cpp
index e030760..2993a32 100644
--- a/source/mod.cpp
+++ b/source/mod.cpp
@@ -281,6 +281,7 @@ hudConsole->addWatch(page, "throw:", &throwResult, 'x', WatchInterpretation::_u1
//Bgm Options
page = hudConsole->addPage("BGM");
hudConsole->addOption(page, "BGM Rando: ",&musicrando::musicRandoEnabled,0x1);
+ hudConsole->addOption(page, "Enemy BGM: ",&musicrando::enemyBgmEnabled,0x1);
// local area
/*page = hudConsole->addPage("Local Area 1");
diff --git a/source/musicRando.cpp b/source/musicRando.cpp
index ac8ed16..bdb21b0 100644
--- a/source/musicRando.cpp
+++ b/source/musicRando.cpp
@@ -2,6 +2,7 @@
#include "tools.h"
#include "patch.h"
#include "tp/Z2SceneMgr.h"
+#include "tp/Z2SeqMgr.h"
struct BGM { //Struct to store info about the source of BGM and the waves required to play correctly. Not using full Ids here to save memory
u8 id = 0x0;
@@ -110,6 +111,7 @@ const u8 bgmSource_length = sizeof(bgmSource)/sizeof(BGM);
static u8 randomizedBGMs[bgmSource_length];
void (*sceneChange_trampoline)(Z2SceneMgr* sceneMgr, JAISoundID id,u8 SeWave1,u8 SeWave2,u8 BgmWave1,u8 BgmWave2,u8 DemoWave,bool param_7) = nullptr;
+void (*startBattleBgm_trampoline)(Z2SeqMgr* seqMgr, bool param_1) = nullptr;
void sceneChangeHook(Z2SceneMgr* sceneMgr, JAISoundID BGMId,u8 SeWave1,u8 SeWave2,u8 BgmWave1,u8 BgmWave2,u8 DemoWave,bool param_7) {
u32 id = BGMId.id;
@@ -138,8 +140,15 @@ void sceneChangeHook(Z2SceneMgr* sceneMgr, JAISoundID BGMId,u8 SeWave1,u8 SeWave
}
}
+void startBattleBgmHook(Z2SeqMgr* seqMgr, bool param_1) {
+ if (mod::musicrando::enemyBgmEnabled) {
+ startBattleBgm_trampoline(seqMgr,param_1);
+ }
+}
+
namespace mod::musicrando {
u8 musicRandoEnabled = 0;
+ u8 enemyBgmEnabled = 1;
void initMusicRando() {
for(u8 i = 0; i<bgmSource_length; i++){ //Fills in the randomizedBGMs array with random ids
bool gotUnique = false;
@@ -161,5 +170,8 @@ namespace mod::musicrando {
if (sceneChange_trampoline == nullptr) {
sceneChange_trampoline = mod::patch::hookFunction(tp::Z2AudioLib::SceneMgr::sceneChange,sceneChangeHook);
}
+ if (startBattleBgm_trampoline == nullptr) {
+ startBattleBgm_trampoline = mod::patch::hookFunction(tp::Z2AudioLib::SeqMgr::startBattleBgm,startBattleBgmHook);
+ }
}
} //namespace mod::musicrando