summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorRoman971 <32455037+Roman971@users.noreply.github.com>2022-07-30 02:35:09 +0200
committerGitHub <noreply@github.com>2022-07-29 20:35:09 -0400
commit1652b7e5d76f4fb71495194f24572010ebf6c961 (patch)
treec206ceaf8f4a5310affddd6fb336f74dca5e05ca /src/code
parent7254adec9f893db7b9d55f6ca0f3667f6b6335e7 (diff)
Fix audio strings with -use_readwrite_const and -signed (#1324)
* Fix audio strings with -use_readwrite_const and -signed * Add comments for audio flags in makefile
Diffstat (limited to 'src/code')
-rw-r--r--src/code/audio_external_data.c69
-rw-r--r--src/code/code_800EC960.c8
-rw-r--r--src/code/code_800F7260.c94
-rw-r--r--src/code/code_800F9280.c27
4 files changed, 96 insertions, 102 deletions
diff --git a/src/code/audio_external_data.c b/src/code/audio_external_data.c
new file mode 100644
index 000000000..25aacdd8a
--- /dev/null
+++ b/src/code/audio_external_data.c
@@ -0,0 +1,69 @@
+#include "ultra64.h"
+#include "global.h"
+
+// sSoundRequests ring buffer endpoints. read index <= write index, wrapping around mod 256.
+u8 gSoundRequestWriteIndex = 0;
+u8 gSoundRequestReadIndex = 0;
+
+/**
+ * Array of pointers to arrays of SoundBankEntry of sizes: 9, 12, 22, 20, 8, 3, 5
+ *
+ * 0 : Player Bank size 9
+ * 1 : Item Bank size 12
+ * 2 : Environment Bank size 22
+ * 3 : Enemy Bank size 20
+ * 4 : System Bank size 8
+ * 5 : Ocarina Bank size 3
+ * 6 : Voice Bank size 5
+ */
+SoundBankEntry* gSoundBanks[7] = {
+ D_8016BAD0, D_8016BC80, D_8016BEC0, D_8016C2E0, D_8016C6A0, D_8016C820, D_8016C8B0,
+};
+
+u8 gSoundBankSizes[ARRAY_COUNT(gSoundBanks)] = {
+ ARRAY_COUNT(D_8016BAD0), ARRAY_COUNT(D_8016BC80), ARRAY_COUNT(D_8016BEC0), ARRAY_COUNT(D_8016C2E0),
+ ARRAY_COUNT(D_8016C6A0), ARRAY_COUNT(D_8016C820), ARRAY_COUNT(D_8016C8B0),
+};
+
+u8 gSfxChannelLayout = 0;
+
+u16 D_801333D0 = 0;
+
+// The center of the screen in projected coordinates.
+// Gives the impression that the sfx has no specific location
+Vec3f gSfxDefaultPos = { 0.0f, 0.0f, 0.0f };
+
+// Reused as either frequency or volume multiplicative scaling factor
+// Does not alter or change frequency or volume
+f32 gSfxDefaultFreqAndVolScale = 1.0f;
+
+s32 D_801333E4 = 0; // unused
+
+// Adds no reverb to the existing reverb
+s8 gSfxDefaultReverb = 0;
+
+s32 D_801333EC = 0; // unused
+
+u8 D_801333F0 = 0;
+
+u8 gAudioSfxSwapOff = 0;
+
+u8 D_801333F8 = 0;
+
+s32 D_801333FC = 0; // unused
+
+u8 gSeqCmdWrPos = 0;
+u8 gSeqCmdRdPos = 0;
+u8 D_80133408 = 0;
+u8 D_8013340C = 1;
+
+u8 gSoundModeList[] = {
+ SOUNDMODE_STEREO,
+ SOUNDMODE_HEADSET,
+ SOUNDMODE_SURROUND,
+ SOUNDMODE_MONO,
+};
+
+u8 gAudioSpecId = 0;
+
+u8 D_80133418 = 0;
diff --git a/src/code/code_800EC960.c b/src/code/code_800EC960.c
index 631014d09..94e1bd417 100644
--- a/src/code/code_800EC960.c
+++ b/src/code/code_800EC960.c
@@ -1225,7 +1225,7 @@ s8 D_8016B7DC;
f32 D_8016B7E0;
u16 D_8016B7E4;
struct {
- s8 str[5];
+ char str[5];
u16 num;
} sAudioScrPrtBuf[SCROLL_PRINT_BUF_SIZE];
u8 sRiverSoundMainBgmVol;
@@ -3586,18 +3586,18 @@ void AudioDebug_ProcessInput_SfxParamChg(void) {
}
}
-void AudioDebug_ScrPrt(const s8* str, u16 num) {
+void AudioDebug_ScrPrt(const char* str, u16 num) {
u8 i = 0;
sAudioScrPrtBuf[sAudioScrPrtInd].num = num;
- while (str[i] != 0) {
+ while (str[i] != '\0') {
sAudioScrPrtBuf[sAudioScrPrtInd].str[i] = str[i];
i++;
}
while (i < 5) {
- sAudioScrPrtBuf[sAudioScrPrtInd].str[i] = 0;
+ sAudioScrPrtBuf[sAudioScrPrtInd].str[i] = '\0';
i++;
}
diff --git a/src/code/code_800F7260.c b/src/code/code_800F7260.c
index 680648138..d86bef6b2 100644
--- a/src/code/code_800F7260.c
+++ b/src/code/code_800F7260.c
@@ -18,20 +18,6 @@ typedef struct {
/* 0x0C */ u16 remainingFrames;
} UnusedBankLerp; // size = 0x10
-// rodata for Audio_ProcessSoundRequest (this file)
-// (probably moved to .data due to -use_readwrite_const)
-char D_80133340[] = "SE";
-
-// rodata for Audio_ChooseActiveSounds (this file)
-char D_80133344[] = VT_COL(RED, WHITE) "<INAGAKI CHECK> dist over! flag:%04X ptr:%08X pos:%f-%f-%f" VT_RST "\n";
-
-// file padding
-s32 D_8013338C = 0;
-
-// rodata for Audio_ProcessSeqCmd (code_800F9280.c)
-char D_80133390[] = "SEQ H";
-char D_80133398[] = " L";
-
SoundBankEntry D_8016BAD0[9];
SoundBankEntry D_8016BC80[12];
SoundBankEntry D_8016BEC0[22];
@@ -51,55 +37,6 @@ u16 gAudioSfxSwapSource[10];
u16 gAudioSfxSwapTarget[10];
u8 gAudioSfxSwapMode[10];
-// sSoundRequests ring buffer endpoints. read index <= write index, wrapping around mod 256.
-u8 sSoundRequestWriteIndex = 0;
-u8 sSoundRequestReadIndex = 0;
-
-/**
- * Array of pointers to arrays of SoundBankEntry of sizes: 9, 12, 22, 20, 8, 3, 5
- *
- * 0 : Player Bank size 9
- * 1 : Item Bank size 12
- * 2 : Environment Bank size 22
- * 3 : Enemy Bank size 20
- * 4 : System Bank size 8
- * 5 : Ocarina Bank size 3
- * 6 : Voice Bank size 5
- */
-SoundBankEntry* gSoundBanks[7] = {
- D_8016BAD0, D_8016BC80, D_8016BEC0, D_8016C2E0, D_8016C6A0, D_8016C820, D_8016C8B0,
-};
-
-u8 sBankSizes[ARRAY_COUNT(gSoundBanks)] = {
- ARRAY_COUNT(D_8016BAD0), ARRAY_COUNT(D_8016BC80), ARRAY_COUNT(D_8016BEC0), ARRAY_COUNT(D_8016C2E0),
- ARRAY_COUNT(D_8016C6A0), ARRAY_COUNT(D_8016C820), ARRAY_COUNT(D_8016C8B0),
-};
-
-u8 gSfxChannelLayout = 0;
-
-u16 D_801333D0 = 0;
-
-// The center of the screen in projected coordinates.
-// Gives the impression that the sfx has no specific location
-Vec3f gSfxDefaultPos = { 0.0f, 0.0f, 0.0f };
-
-// Reused as either frequency or volume multiplicative scaling factor
-// Does not alter or change frequency or volume
-f32 gSfxDefaultFreqAndVolScale = 1.0f;
-
-s32 D_801333E4 = 0; // unused
-
-// Adds no reverb to the existing reverb
-s8 gSfxDefaultReverb = 0;
-
-s32 D_801333EC = 0; // unused
-
-u8 D_801333F0 = 0;
-
-u8 gAudioSfxSwapOff = 0;
-
-u8 D_801333F8 = 0;
-
void Audio_SetSoundBanksMute(u16 muteMask) {
u8 bankId;
@@ -132,7 +69,7 @@ void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32
SoundRequest* req;
if (!gSoundBankMuted[SFX_BANK_SHIFT(sfxId)]) {
- req = &sSoundRequests[sSoundRequestWriteIndex];
+ req = &sSoundRequests[gSoundRequestWriteIndex];
if (!gAudioSfxSwapOff) {
for (i = 0; i < 10; i++) {
if (sfxId == gAudioSfxSwapSource[i]) {
@@ -145,8 +82,8 @@ void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32
req->freqScale = freqScale;
req->vol = vol;
req->reverbAdd = reverbAdd;
- sSoundRequestWriteIndex++;
- req = &sSoundRequests[sSoundRequestWriteIndex];
+ gSoundRequestWriteIndex++;
+ req = &sSoundRequests[gSoundRequestWriteIndex];
}
i = 10; // "break;"
}
@@ -158,16 +95,16 @@ void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32
req->freqScale = freqScale;
req->vol = vol;
req->reverbAdd = reverbAdd;
- sSoundRequestWriteIndex++;
+ gSoundRequestWriteIndex++;
}
}
void Audio_RemoveMatchingSoundRequests(u8 aspect, SoundBankEntry* cmp) {
SoundRequest* req;
s32 remove;
- u8 i = sSoundRequestReadIndex;
+ u8 i = gSoundRequestReadIndex;
- for (; i != sSoundRequestWriteIndex; i++) {
+ for (; i != gSoundRequestWriteIndex; i++) {
remove = false;
req = &sSoundRequests[i];
switch (aspect) {
@@ -219,14 +156,14 @@ void Audio_ProcessSoundRequest(void) {
u8 evictImportance;
u8 evictIndex;
- req = &sSoundRequests[sSoundRequestReadIndex];
+ req = &sSoundRequests[gSoundRequestReadIndex];
evictIndex = 0x80;
if (req->sfxId == 0) {
return;
}
bankId = SFX_BANK(req->sfxId);
if ((1 << bankId) & D_801333F0) {
- AudioDebug_ScrPrt((const s8*)D_80133340, req->sfxId);
+ AudioDebug_ScrPrt("SE", req->sfxId);
bankId = SFX_BANK(req->sfxId);
}
count = 0;
@@ -387,8 +324,9 @@ void Audio_ChooseActiveSounds(u8 bankId) {
} else {
if (entry->dist > 0x7FFFFFD0) {
entry->dist = 0x70000008;
- osSyncPrintf(D_80133344, entry->sfxId, entry->posX, entry->posZ, *entry->posX, *entry->posY,
- *entry->posZ);
+ osSyncPrintf(VT_COL(RED, WHITE) "<INAGAKI CHECK> dist over! "
+ "flag:%04X ptr:%08X pos:%f-%f-%f" VT_RST "\n",
+ entry->sfxId, entry->posX, entry->posZ, *entry->posX, *entry->posY, *entry->posZ);
}
temp3 = entry->sfxId; // fake
entry->priority = (u32)entry->dist + (SQ(0xFF - sfxImportance) * SQ(76)) + temp3 - temp3;
@@ -694,9 +632,9 @@ void Audio_StopSfxById(u32 sfxId) {
}
void Audio_ProcessSoundRequests(void) {
- while (sSoundRequestWriteIndex != sSoundRequestReadIndex) {
+ while (gSoundRequestWriteIndex != gSoundRequestReadIndex) {
Audio_ProcessSoundRequest();
- sSoundRequestReadIndex++;
+ gSoundRequestReadIndex++;
}
}
@@ -752,8 +690,8 @@ void Audio_ResetSounds(void) {
u8 i;
u8 entryIndex;
- sSoundRequestWriteIndex = 0;
- sSoundRequestReadIndex = 0;
+ gSoundRequestWriteIndex = 0;
+ gSoundRequestReadIndex = 0;
D_801333D0 = 0;
for (bankId = 0; bankId < ARRAY_COUNT(gSoundBanks); bankId++) {
sSoundBankListEnd[bankId] = 0;
@@ -771,7 +709,7 @@ void Audio_ResetSounds(void) {
for (bankId = 0; bankId < ARRAY_COUNT(gSoundBanks); bankId++) {
gSoundBanks[bankId][0].prev = 0xFF;
gSoundBanks[bankId][0].next = 0xFF;
- for (i = 1; i < sBankSizes[bankId] - 1; i++) {
+ for (i = 1; i < gSoundBankSizes[bankId] - 1; i++) {
gSoundBanks[bankId][i].prev = i - 1;
gSoundBanks[bankId][i].next = i + 1;
}
diff --git a/src/code/code_800F9280.c b/src/code/code_800F9280.c
index a139b254f..86ca22831 100644
--- a/src/code/code_800F9280.c
+++ b/src/code/code_800F9280.c
@@ -12,19 +12,6 @@ u8 D_8016E348[4];
u32 sAudioSeqCmds[0x100];
unk_D_8016E750 D_8016E750[4];
-u8 sSeqCmdWrPos = 0;
-u8 sSeqCmdRdPos = 0;
-u8 D_80133408 = 0;
-u8 D_8013340C = 1;
-u8 sSoundModeList[] = {
- SOUNDMODE_STEREO,
- SOUNDMODE_HEADSET,
- SOUNDMODE_SURROUND,
- SOUNDMODE_MONO,
-};
-u8 gAudioSpecId = 0;
-u8 D_80133418 = 0;
-
// TODO: clean up these macros. They are similar to ones in code_800EC960.c but without casts.
#define Audio_StartSeq(playerIdx, fadeTimer, seqId) \
Audio_QueueSeqCmd(0x00000000 | ((playerIdx) << 24) | ((fadeTimer) << 16) | (seqId))
@@ -122,8 +109,8 @@ void Audio_ProcessSeqCmd(u32 cmd) {
f32 freqScale;
if (D_8013340C && (cmd & 0xF0000000) != 0x70000000) {
- AudioDebug_ScrPrt((const s8*)D_80133390, (cmd >> 16) & 0xFFFF); // "SEQ H"
- AudioDebug_ScrPrt((const s8*)D_80133398, cmd & 0xFFFF); // " L"
+ AudioDebug_ScrPrt("SEQ H", (cmd >> 16) & 0xFFFF);
+ AudioDebug_ScrPrt(" L", cmd & 0xFFFF);
}
op = cmd >> 28;
@@ -347,7 +334,7 @@ void Audio_ProcessSeqCmd(u32 cmd) {
switch (subOp) {
case 0:
// set sound mode
- Audio_QueueCmdS32(0xF0000000, sSoundModeList[val]);
+ Audio_QueueCmdS32(0xF0000000, gSoundModeList[val]);
break;
case 1:
// set sequence starting disabled?
@@ -370,12 +357,12 @@ void Audio_ProcessSeqCmd(u32 cmd) {
}
void Audio_QueueSeqCmd(u32 cmd) {
- sAudioSeqCmds[sSeqCmdWrPos++] = cmd;
+ sAudioSeqCmds[gSeqCmdWrPos++] = cmd;
}
void Audio_ProcessSeqCmds(void) {
- while (sSeqCmdWrPos != sSeqCmdRdPos) {
- Audio_ProcessSeqCmd(sAudioSeqCmds[sSeqCmdRdPos++]);
+ while (gSeqCmdWrPos != gSeqCmdRdPos) {
+ Audio_ProcessSeqCmd(sAudioSeqCmds[gSeqCmdRdPos++]);
}
}
@@ -389,7 +376,7 @@ u16 func_800FA0B4(u8 playerIdx) {
s32 func_800FA11C(u32 arg0, u32 arg1) {
u8 i;
- for (i = sSeqCmdRdPos; i != sSeqCmdWrPos; i++) {
+ for (i = gSeqCmdRdPos; i != gSeqCmdWrPos; i++) {
if (arg0 == (sAudioSeqCmds[i] & arg1)) {
return false;
}