summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenny022p <info@henny022.de>2021-03-23 00:33:29 +0100
committerHenny022p <info@henny022.de>2021-03-23 00:33:29 +0100
commitcc206a73abd20eac777914a095963bb1395ceea4 (patch)
tree6ebc120adbe4f12926a8247bf821b30e4945c707 /src
parent5cebf089fd0b34e017aeb36d540bfce051a4969c (diff)
naming and moving stuff
Diffstat (limited to 'src')
-rw-r--r--src/audio.c (renamed from src/sound.c)111
-rw-r--r--src/enemy/rope.c1
-rw-r--r--src/enemy/spinyChuchu.c1
-rw-r--r--src/enemy/vaatiBall.c1
-rw-r--r--src/ezloNag.c3
-rw-r--r--src/gba/m4a.c17
-rw-r--r--src/item.c2
-rw-r--r--src/manager/manager3.c2
-rw-r--r--src/manager/managerB.c1
-rw-r--r--src/manager/managerE.c1
-rw-r--r--src/npc/bigGoron.c1
-rw-r--r--src/npc/bladeBrothers.c1
-rw-r--r--src/npc/ezloCap.c3
-rw-r--r--src/npc/melari.c1
-rw-r--r--src/npc/rem.c3
-rw-r--r--src/npc/smith.c1
-rw-r--r--src/object/button.c1
-rw-r--r--src/object/houseDoorExterior.c3
-rw-r--r--src/object/jailBars.c2
-rw-r--r--src/object/metalDoor.c1
-rw-r--r--src/object/objectA2.c1
-rw-r--r--src/object/thoughtBubble.c1
-rw-r--r--src/save.c12
-rw-r--r--src/script.c15
24 files changed, 153 insertions, 33 deletions
diff --git a/src/sound.c b/src/audio.c
index fe061a80..6d512858 100644
--- a/src/sound.c
+++ b/src/audio.c
@@ -1,4 +1,115 @@
+#include "global.h"
+#include "main.h"
#include "gba/m4a.h"
+#include "audio.h"
+#include "structures.h"
+
+extern void sub_080A35A0(u32);
+extern void sub_080A35C8(void);
+extern void sub_080A353C(u32);
+extern void sub_080A3234(u32);
+extern void sub_080A35B4(u32);
+
+#define IS_BGM(song) (song) - 1 <= NUM_BGM - 1
+#define IS_SFX(song) (song) - 1 > NUM_BGM - 1
+
+void SoundReq(u32 arg) {
+ u32 song;
+ struct_02021EE0* ptr;
+ if (gMain.field_0x7)
+ return;
+ ptr = &gUnk_02021EE0;
+ song = arg & 0xffff;
+ switch (arg & 0xffff0000) {
+ case SOUND_REQ_ALL_STOP:
+ ptr->currentBgm = 0;
+ m4aMPlayAllStop();
+ return;
+ case 0x80020000:
+ sub_080A3234(0);
+ return;
+ case 0x80030000:
+ sub_080A35C8();
+ ptr->unk_12 = 0x100;
+ sub_080A353C(ptr->currentBgm);
+ return;
+ case 0x80080000:
+ sub_080A35B4(ptr->currentBgm);
+ return;
+ case 0x80090000:
+ if (song == 0)
+ song = ptr->currentBgm;
+ if (IS_SFX(song))
+ return;
+ ptr->currentBgm = song;
+ m4aSongNumStart(song);
+ sub_080A35A0(song);
+ return;
+ case 0x800a0000:
+ if (IS_SFX(song))
+ return;
+ ptr->currentBgm = song;
+ m4aSongNumStartOrContinue(song);
+ sub_080A35A0(song);
+ return;
+ case 0x800c0000:
+ m4aMPlayTempoControl(gMPlayTable[gSongTable[ptr->currentBgm].ms].info, song);
+ return;
+ case 0x80040000:
+ m4aMPlayAllStop();
+ m4aSoundVSyncOff();
+ return;
+ case 0x80050000:
+ if (ptr->currentBgm == 0)
+ return;
+ m4aSongNumStop(ptr->currentBgm);
+ return;
+ case 0x80060000:
+ m4aSoundVSyncOn();
+ case 0x80070000:
+ if (ptr->currentBgm == 0)
+ return;
+ m4aSongNumStartOrContinue(ptr->currentBgm);
+ sub_080A353C(ptr->currentBgm);
+ return;
+ case 0x800b0000:
+ if (IS_SFX(song))
+ return;
+ ptr->currentBgm = song;
+ m4aSongNumStartOrContinue(song);
+ sub_080A35C8();
+ sub_080A353C(song);
+ return;
+ case 0x800d0000:
+ ptr->unk_10 = 0;
+ return;
+ case 0x80100000:
+ ptr->unk_10 = 0;
+ ptr->unk_02 = 1;
+ return;
+ case 0x800e0000:
+ ptr->unk_10 = 0x100;
+ return;
+ case 0x800f0000:
+ sub_080A35C8();
+ return;
+ case 0x80110000:
+ ptr->currentBgm = 0;
+ return;
+ default:
+ if (song != 0) {
+ if (IS_BGM(song)) {
+ ptr->currentBgm = song;
+ m4aSongNumStart(song);
+ sub_080A35C8();
+ } else {
+ m4aSongNumStart(song);
+ }
+ sub_080A353C(song);
+ }
+ return;
+ }
+}
extern const SongHeader song_08DCC48C;
extern const SongHeader song_08DCC6CC;
diff --git a/src/enemy/rope.c b/src/enemy/rope.c
index 0859bae6..5033ae4c 100644
--- a/src/enemy/rope.c
+++ b/src/enemy/rope.c
@@ -2,6 +2,7 @@
#include "entity.h"
#include "enemy.h"
#include "random.h"
+#include "audio.h"
#include "functions.h"
extern void (*const gRope[6])(Entity*);
diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c
index 21396115..71ffc191 100644
--- a/src/enemy/spinyChuchu.c
+++ b/src/enemy/spinyChuchu.c
@@ -1,6 +1,7 @@
#include "enemy.h"
#include "entity.h"
#include "random.h"
+#include "audio.h"
#include "functions.h"
extern void sub_08001318(Entity*);
diff --git a/src/enemy/vaatiBall.c b/src/enemy/vaatiBall.c
index 3907e270..0c74ffb0 100644
--- a/src/enemy/vaatiBall.c
+++ b/src/enemy/vaatiBall.c
@@ -2,6 +2,7 @@
#include "player.h"
#include "screen.h"
#include "createObject.h"
+#include "audio.h"
#include "functions.h"
typedef struct {
diff --git a/src/ezloNag.c b/src/ezloNag.c
index 0ad98db7..5d3ec162 100644
--- a/src/ezloNag.c
+++ b/src/ezloNag.c
@@ -1,6 +1,5 @@
-#include "audio.h"
#include "global.h"
-#include "functions.h"
+#include "audio.h"
#include "textbox.h"
#include "structures.h"
diff --git a/src/gba/m4a.c b/src/gba/m4a.c
index 1123ac51..79b7dc35 100644
--- a/src/gba/m4a.c
+++ b/src/gba/m4a.c
@@ -286,10 +286,7 @@ u32 MidiKeyToCgbFreq(u8, u8, u8);
void nullsub_141(void);
void MPlayJumpTableCopy(void** mplayJumpTable);
void SampleFreqSet(u32 freq);
-void m4aSoundVSyncOn(void);
-void m4aSoundVSyncOff(void);
-void m4aMPlayTempoControl(MusicPlayerInfo* mplayInfo, u16 tempo);
void m4aMPlayVolumeControl(MusicPlayerInfo* mplayInfo, u16 trackBits, u16 volume);
void m4aMPlayPitchControl(MusicPlayerInfo* mplayInfo, u16 trackBits, s16 pitch);
void m4aMPlayPanpotControl(MusicPlayerInfo* mplayInfo, u16 trackBits, s8 pan);
@@ -1152,27 +1149,26 @@ void CgbOscOff(u8 chanNum) {
}
}
-// CgbModVol does not match because of this
static inline int CgbPan(CgbChannel* chan) {
u32 rightVolume = chan->rightVolume;
u32 leftVolume = chan->leftVolume;
- // regalloc
- if ((rightVolume = (u8)rightVolume) >= (leftVolume = (u8)leftVolume)) {
- if (rightVolume / 2 >= leftVolume) {
+ u8 rightVolume2 = rightVolume;
+ u8 leftVolume2 = leftVolume;
+ if (rightVolume2 >= leftVolume2) {
+ if (rightVolume2 / 2 >= leftVolume2) {
chan->pan = 0x0F;
return 1;
}
} else {
- if (leftVolume / 2 >= rightVolume) {
+ if (leftVolume2 / 2 >= rightVolume2) {
chan->pan = 0xF0;
return 1;
}
}
-
return 0;
}
-NONMATCH("asm/non_matching/m4a/CgbModVol.inc", void CgbModVol(CgbChannel* chan)) {
+void CgbModVol(CgbChannel* chan) {
SoundInfo* soundInfo = SOUND_INFO_PTR;
if (!CgbPan(chan)) {
@@ -1194,7 +1190,6 @@ NONMATCH("asm/non_matching/m4a/CgbModVol.inc", void CgbModVol(CgbChannel* chan))
chan->sustainGoal = (chan->envelopeGoal * chan->sustain + 15) >> 4;
chan->pan &= chan->panMask;
}
-END_NONMATCH
NONMATCH("asm/non_matching/m4a/CgbSound.inc", void CgbSound(void)) {
s32 ch;
diff --git a/src/item.c b/src/item.c
index fa23bd31..46ae7cc9 100644
--- a/src/item.c
+++ b/src/item.c
@@ -1,7 +1,7 @@
#include "global.h"
#include "entity.h"
#include "item.h"
-#include "functions.h"
+#include "audio.h"
// TODO - How does this relate to PlayerItemFunctions? Is this just a lookup table?
void (*const gItemFunctions[])(ItemBehavior*, u32) = {
diff --git a/src/manager/manager3.c b/src/manager/manager3.c
index acd83825..bd15e45c 100644
--- a/src/manager/manager3.c
+++ b/src/manager/manager3.c
@@ -5,7 +5,7 @@
#include "room.h"
#include "player.h"
#include "random.h"
-#include "functions.h"
+#include "audio.h"
// Facilitates the usage of minish portals.
diff --git a/src/manager/managerB.c b/src/manager/managerB.c
index ca298178..ae0ea131 100644
--- a/src/manager/managerB.c
+++ b/src/manager/managerB.c
@@ -5,6 +5,7 @@
#include "room.h"
#include "area.h"
#include "utils.h"
+#include "audio.h"
#include "functions.h"
/*
diff --git a/src/manager/managerE.c b/src/manager/managerE.c
index 44bfb5a7..200a52d5 100644
--- a/src/manager/managerE.c
+++ b/src/manager/managerE.c
@@ -3,6 +3,7 @@
#include "manager.h"
#include "flags.h"
#include "room.h"
+#include "audio.h"
#include "functions.h"
void sub_08058E60(ManagerE* this) {
diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c
index 3123b036..c3032d54 100644
--- a/src/npc/bigGoron.c
+++ b/src/npc/bigGoron.c
@@ -4,6 +4,7 @@
#include "structures.h"
#include "script.h"
#include "random.h"
+#include "audio.h"
#include "functions.h"
extern void (*gUnk_081140D4[])(Entity*);
diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c
index 49a86dfc..223000f2 100644
--- a/src/npc/bladeBrothers.c
+++ b/src/npc/bladeBrothers.c
@@ -7,6 +7,7 @@
#include "save.h"
#include "script.h"
#include "npc.h"
+#include "audio.h"
#include "functions.h"
extern void (*gUnk_081115C0[])(Entity*);
diff --git a/src/npc/ezloCap.c b/src/npc/ezloCap.c
index a7b5593e..6f483b66 100644
--- a/src/npc/ezloCap.c
+++ b/src/npc/ezloCap.c
@@ -1,9 +1,10 @@
#include "global.h"
#include "entity.h"
-#include "functions.h"
#include "flags.h"
#include "save.h"
#include "script.h"
+#include "audio.h"
+#include "functions.h"
extern Hitbox gUnk_080FD170;
extern void script_08016030; // Cutscene data type?
diff --git a/src/npc/melari.c b/src/npc/melari.c
index a62b837b..1e911439 100644
--- a/src/npc/melari.c
+++ b/src/npc/melari.c
@@ -4,6 +4,7 @@
#include "textbox.h"
#include "script.h"
#include "random.h"
+#include "audio.h"
#include "functions.h"
extern void sub_08068780(Entity*);
diff --git a/src/npc/rem.c b/src/npc/rem.c
index a6059865..0498c6db 100644
--- a/src/npc/rem.c
+++ b/src/npc/rem.c
@@ -1,7 +1,8 @@
#include "global.h"
-#include "functions.h"
#include "entity.h"
#include "script.h"
+#include "audio.h"
+#include "functions.h"
extern void sub_0806A8C8(Entity*);
diff --git a/src/npc/smith.c b/src/npc/smith.c
index 6b55c1f7..c15b1219 100644
--- a/src/npc/smith.c
+++ b/src/npc/smith.c
@@ -5,6 +5,7 @@
#include "script.h"
#include "random.h"
#include "npc.h"
+#include "audio.h"
#include "functions.h"
extern void sub_08078850(Entity*, u32, u32, u32*);
diff --git a/src/object/button.c b/src/object/button.c
index e545953c..ca180856 100644
--- a/src/object/button.c
+++ b/src/object/button.c
@@ -2,6 +2,7 @@
#include "entity.h"
#include "flags.h"
#include "room.h"
+#include "audio.h"
#include "functions.h"
extern void (*const gUnk_0811EE38[])(Entity*);
diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c
index 2b6edaae..9e8ffba2 100644
--- a/src/object/houseDoorExterior.c
+++ b/src/object/houseDoorExterior.c
@@ -1,9 +1,10 @@
#include "global.h"
#include "entity.h"
#include "flags.h"
-#include "functions.h"
#include "room.h"
#include "script.h"
+#include "audio.h"
+#include "functions.h"
typedef struct {
/*0x00*/ u16 unk0;
diff --git a/src/object/jailBars.c b/src/object/jailBars.c
index 505ca8e2..74fcfeae 100644
--- a/src/object/jailBars.c
+++ b/src/object/jailBars.c
@@ -2,7 +2,7 @@
#include "entity.h"
#include "flags.h"
#include "room.h"
-#include "functions.h"
+#include "audio.h"
extern void sub_080A0960(Entity*, u32);
extern void sub_0801AF18(u8*, u32, u32);
diff --git a/src/object/metalDoor.c b/src/object/metalDoor.c
index a2a18bff..c56d0014 100644
--- a/src/object/metalDoor.c
+++ b/src/object/metalDoor.c
@@ -2,6 +2,7 @@
#include "entity.h"
#include "room.h"
#include "flags.h"
+#include "audio.h"
#include "functions.h"
extern u32 sub_08083734(Entity*, u32);
diff --git a/src/object/objectA2.c b/src/object/objectA2.c
index 0c3307d3..87c75e4e 100644
--- a/src/object/objectA2.c
+++ b/src/object/objectA2.c
@@ -2,6 +2,7 @@
#include "object.h"
#include "menu.h"
#include "random.h"
+#include "audio.h"
#include "structures.h"
#include "functions.h"
diff --git a/src/object/thoughtBubble.c b/src/object/thoughtBubble.c
index 5e77d9e1..70ad3c73 100644
--- a/src/object/thoughtBubble.c
+++ b/src/object/thoughtBubble.c
@@ -1,5 +1,6 @@
#include "global.h"
#include "entity.h"
+#include "audio.h"
#include "functions.h"
extern void (*const ThoughtBubble_Behaviors[])(Entity*);
diff --git a/src/save.c b/src/save.c
index 7cbf89aa..be070f98 100644
--- a/src/save.c
+++ b/src/save.c
@@ -58,8 +58,6 @@ const SaveFileEEPROMAddresses gSaveFileEEPROMAddresses[] = { { 0x500, 0x30, 0x10
{ 0x20, 0x60, 0x1060, 0xf80, 0x1f80 },
{ 0x8, 0xfa0, 0x1fa0, 0xfa0, 0x1fa0 } };
-extern s16 gUnk_02021EE0[6];
-
void sub_0807CD9C() {
sub_080530C8();
}
@@ -69,8 +67,8 @@ SaveResult HandleSave(u32 arg0) {
}
SaveResult HandleSaveInit(u32 arg0) {
- gUnk_02021EE0[5] -= 8;
- if (gUnk_02021EE0[4] <= 0) {
+ gUnk_02021EE0.unk_0a -= 8;
+ if (gUnk_02021EE0.unk_08 <= 0) {
gMenu.field_0xa = 8;
gMenu.storyPanelIndex = SAVE_IN_PROGRESS;
}
@@ -107,9 +105,9 @@ SaveResult HandleSaveDone(u32 arg0) {
SaveResult result;
result = SAVE_BUSY;
- gUnk_02021EE0[5] += 8;
- if (gUnk_02021EE0[3] <= gUnk_02021EE0[5]) {
- gUnk_02021EE0[5] = gUnk_02021EE0[3];
+ gUnk_02021EE0.unk_0a += 8;
+ if (gUnk_02021EE0.unk_06 <= gUnk_02021EE0.unk_0a) {
+ gUnk_02021EE0.unk_0a = gUnk_02021EE0.unk_06;
sub_08050384();
gMenu.storyPanelIndex = SAVE_INIT;
if (gMenu.field_0xa == 1) {
diff --git a/src/script.c b/src/script.c
index 0710080c..ea063d28 100644
--- a/src/script.c
+++ b/src/script.c
@@ -9,6 +9,7 @@
#include "utils.h"
#include "save.h"
#include "random.h"
+#include "audio.h"
#include "functions.h"
void InitScriptForEntity(Entity*, ScriptExecutionContext*, u16*);
@@ -137,9 +138,9 @@ void ScriptCommand_0807EEF4(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_0807EF3C(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_DoPostScriptAction(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_DoPostScriptAction2(Entity* entity, ScriptExecutionContext* context);
+void ScriptCommand_PlaySound(Entity* entity, ScriptExecutionContext* context);
+void ScriptCommand_PlayBgm(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_SoundReq(Entity* entity, ScriptExecutionContext* context);
-void ScriptCommand_SoundReq2(Entity* entity, ScriptExecutionContext* context);
-void ScriptCommand_SoundReq3(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_SoundReq0x80100000(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_ModRupees(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_ModHealth(Entity* entity, ScriptExecutionContext* context);
@@ -283,9 +284,9 @@ const ScriptCommand gScriptCommands[] = { ScriptCommandNop,
ScriptCommand_0807EF3C,
ScriptCommand_DoPostScriptAction,
ScriptCommand_DoPostScriptAction2,
+ ScriptCommand_PlaySound,
+ ScriptCommand_PlayBgm,
ScriptCommand_SoundReq,
- ScriptCommand_SoundReq2,
- ScriptCommand_SoundReq3,
ScriptCommand_SoundReq0x80100000,
ScriptCommand_ModRupees,
ScriptCommand_ModHealth,
@@ -1450,11 +1451,11 @@ void ScriptCommand_DoPostScriptAction2(Entity* entity, ScriptExecutionContext* c
context->postScriptActions |= 1 << context->scriptInstructionPointer[1];
}
-void ScriptCommand_SoundReq(Entity* entity, ScriptExecutionContext* context) {
+void ScriptCommand_PlaySound(Entity* entity, ScriptExecutionContext* context) {
SoundReq(context->scriptInstructionPointer[1]);
}
-void ScriptCommand_SoundReq2(Entity* entity, ScriptExecutionContext* context) {
+void ScriptCommand_PlayBgm(Entity* entity, ScriptExecutionContext* context) {
if (context->scriptInstructionPointer[1] >= 100) {
SoundReq(gArea.musicIndex);
} else {
@@ -1462,7 +1463,7 @@ void ScriptCommand_SoundReq2(Entity* entity, ScriptExecutionContext* context) {
}
}
-void ScriptCommand_SoundReq3(Entity* entity, ScriptExecutionContext* context) {
+void ScriptCommand_SoundReq(Entity* entity, ScriptExecutionContext* context) {
SoundReq(GetNextScriptCommandWordAfterCommandMetadata(context->scriptInstructionPointer));
}