Match all of music_wrappers.h

This commit is contained in:
Bolu 2024-02-19 23:54:16 +01:00
parent 132b91feb7
commit f0129a6589
7 changed files with 76 additions and 2119 deletions

View File

@ -608,8 +608,8 @@ lbl_08004b44: .4byte gMusicInfo
lbl_08004b48: .4byte sDma1ControlPointer
lbl_08004b4c: .4byte sDma1ControlValue
thumb_func_start sub_08004b50
sub_08004b50: @ 0x08004b50
thumb_func_start InitTrack
InitTrack: @ 0x08004b50
push {r4, r5, r6, r7, lr}
sub sp, #4
adds r4, r0, #0
@ -756,7 +756,7 @@ lbl_08004c4e:
ands r1, r3
subs r1, #1
adds r0, r4, #0
bl sub_080024c0
bl ClearRegistersForPsg
movs r3, #0
strb r3, [r4]
str r3, [r4, #0x24]
@ -820,7 +820,7 @@ lbl_08004cbc:
ands r1, r3
subs r1, #1
adds r0, r4, #0
bl sub_080024c0
bl ClearRegistersForPsg
movs r3, #0
strb r3, [r4]
str r3, [r4, #0x24]
@ -914,7 +914,7 @@ lbl_08004d5c:
beq lbl_08004d52
ldr r0, [r4]
ldr r1, [r6, #4]
bl sub_08004b50
bl InitTrack
movs r0, #0
str r0, [r6]
str r0, [r6, #4]
@ -1222,7 +1222,7 @@ sub_08004f8c: @ 0x08004f8c
movs r2, #2
orrs r1, r2
strb r1, [r4, #0x13]
bl sub_080020a4
bl unk_20a4
ldr r0, [r5, #0x48]
cmp r0, #0
beq lbl_08004fa8

View File

@ -371,7 +371,7 @@ lbl_08001354:
b lbl_080013d4
lbl_0800137c:
adds r0, r4, #0
bl sub_080020a4
bl unk_20a4
b lbl_080013d4
lbl_08001384:
ldrb r0, [r4, #0xd]
@ -383,7 +383,7 @@ lbl_08001384:
bne lbl_0800139a
strb r0, [r4]
adds r0, r4, #0
bl sub_080020a4
bl unk_20a4
lbl_0800139a:
strb r5, [r4, #0x10]
lsls r1, r5, #0x10
@ -949,7 +949,7 @@ lbl_080017ae:
lbl_080017b6:
adds r0, r4, #0
mov r1, r8
bl sub_080024c0
bl ClearRegistersForPsg
b lbl_08001834
lbl_080017c0:
lsls r0, r2, #0x18
@ -958,7 +958,7 @@ lbl_080017c0:
bne lbl_08001834
adds r0, r4, #0
mov r1, r8
bl sub_080024c0
bl ClearRegistersForPsg
strb r5, [r4]
b lbl_08001834
lbl_080017d4:
@ -1508,7 +1508,7 @@ lbl_08001bc8:
cmp r0, #0
beq lbl_08001bde
ldrb r0, [r6]
bl sub_08003d4c
bl ReplayQueuedMusic
lbl_08001bde:
mov r2, sl
strb r4, [r2]
@ -2189,8 +2189,8 @@ lbl_0800207a:
pop {r0}
bx r0
thumb_func_start sub_080020a4
sub_080020a4: @ 0x080020a4
thumb_func_start unk_20a4
unk_20a4: @ 0x080020a4
push {lr}
adds r2, r0, #0
ldr r0, [r2, #0x28]
@ -2296,7 +2296,7 @@ sub_08002140: @ 0x08002140
lsls r1, r1, #0x18
lsrs r1, r1, #0x18
adds r0, r2, #0
bl sub_080024c0
bl ClearRegistersForPsg
ldr r0, [r4, #0x4c]
movs r1, #0
strb r1, [r0]
@ -2357,7 +2357,7 @@ sub_080021b0: @ 0x080021b0
lsls r1, r1, #0x18
lsrs r1, r1, #0x18
adds r0, r2, #0
bl sub_080024c0
bl ClearRegistersForPsg
ldr r0, [r4, #0x4c]
movs r1, #0
strb r1, [r0]
@ -2809,8 +2809,8 @@ Music_EmptyCommand: @ 0x080024bc
bx lr
.align 2, 0
thumb_func_start sub_080024c0
sub_080024c0: @ 0x080024c0
thumb_func_start ClearRegistersForPsg
ClearRegistersForPsg: @ 0x080024c0
push {lr}
lsls r1, r1, #0x18
lsrs r1, r1, #0x18

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@ void unk_378c(u16 musicTrack);
void CheckPlayTransitionMusicTrack(void);
void unk_38d8(void);
void UpdateMusicAfterAlarmDisable(void);
u16 DetermineNewMusicTrack(u16 musicTrack);
u32 DetermineNewMusicTrack(u16 musicTrack);
void unk_39c8(void);
void PlayMusic(u16 musicTrack, u8 priority);
void unk_3a6c(void);
@ -42,4 +42,4 @@ void ReplaySoundTest(u16 musicTrack);
void CheckReplayFileSelectMusic(u16 timer);
void unk_42bc(u16 musicTrack);
#endif /* MUSIC_WRAPPERS_H */
#endif /* MUSIC_WRAPPERS_H */

View File

@ -409,6 +409,9 @@ SECTIONS {
asm/disasm_0x080010c4.o(.text);
asm/disasm_0x08002a58.o(.text);
src/music_wrappers.o(.text);
asm/audio_internal.o(.text);
asm/syscalls.o(.text);

View File

@ -530,7 +530,7 @@ void PlayFadingSound(u16 sound, u16 timer)
*/
void InitFadingMusic(struct TrackData* pTrack, const u8* pHeader, u16 timer)
{
init_track(pTrack, pHeader);
InitTrack(pTrack, pHeader);
if (timer != 0 && !pTrack->occupied)
{
@ -686,7 +686,7 @@ void unk_2f00(u16 musicTrack1, u16 musicTrack2, u16 timer)
pTrack2->unk_24 = 0;
pTrack2->maxSoundChannels = gMusicInfo.maxSoundChannels;
init_track(pTrack1, pHeader);
InitTrack(pTrack1, pHeader);
pTrack1->flags = 0x40 | 0x2;
pTrack1->maybe_volume = 0;
pTrack1->fadingTimer = pTrack2->fadingTimer;

View File

@ -1,4 +1,5 @@
#include "music_wrappers.h"
#include "audio.h"
#include "audio_wrappers.h"
#include "syscalls.h"
#include "gba.h"
@ -130,7 +131,7 @@ void unk_34ac(u8 param_1)
{
if (pVariables->pSoundPSG != NULL)
{
clear_registers_for_psg(pVariables->pSoundPSG, (u8)((pVariables->channel & 7) - 1));
ClearRegistersForPsg(pVariables->pSoundPSG, (u8)((pVariables->channel & 7) - 1));
}
if (pVariables->pChannel == NULL)
@ -214,10 +215,13 @@ void unk_35d0(u8 param_1)
}
}
/**
* @brief 36d0 | bc | Checks if r0 is a new music track
*
* @param musicTrack Music Track
*/
void CheckSetNewMusicTrack(u16 musicTrack)
{
// https://decomp.me/scratch/HGig0
struct TrackData* pTrack;
u32 newTrack;
@ -245,7 +249,8 @@ void CheckSetNewMusicTrack(u16 musicTrack)
gSoundQueue[6].exists = 0;
if (gSoundQueue[8].exists & 3)
gSoundQueue[8].exists = 0;
// The following line is written like that to produce matching code:
do { gSoundQueue[8].exists = 0; } while (0);
pTrack = sMusicTrackDataRom[0].pTrack;
@ -263,10 +268,13 @@ void CheckSetNewMusicTrack(u16 musicTrack)
gMusicInfo.occupied = FALSE;
}
/**
* @brief 378c | ec | To document
*
* @param musicTrack Music Track
*/
void unk_378c(u16 musicTrack)
{
// https://decomp.me/scratch/ETNx6
u16 newTrack;
struct TrackData* pTrack;
s32 var_0;
@ -304,7 +312,11 @@ void unk_378c(u16 musicTrack)
{
newTrack = musicTrack - 0x5A;
if (newTrack >= 10)
{
// The following line is needed to produce matching code:
gSoundQueue[8].exists += 0;
var_0 = FALSE;
}
else
var_0 = TRUE;
}
@ -324,7 +336,7 @@ void unk_378c(u16 musicTrack)
if (var_0)
{
pTrack = sMusicTrackDataRom[0].pTrack;
if (sSoundDataEntries[DetermineNewMusicTrack(musicTrack)].pHeader != pTrack->pHeader)
if (sSoundDataEntries[(u16)DetermineNewMusicTrack(musicTrack)].pHeader != pTrack->pHeader)
{
ApplyMusicSoundFading(pTrack, 30);
gMusicInfo.musicTrackOnTransition = musicTrack;
@ -350,7 +362,7 @@ void CheckPlayTransitionMusicTrack(void)
if (gMusicInfo.priority == 0 && gMusicInfo.musicTrackOnTransition != MUSIC_NONE)
{
init_track(sMusicTrackDataRom[0].pTrack, sSoundDataEntries[gMusicInfo.musicTrackOnTransition].pHeader);
InitTrack(sMusicTrackDataRom[0].pTrack, sSoundDataEntries[gMusicInfo.musicTrackOnTransition].pHeader);
gMusicInfo.unk_20 = 0;
gMusicInfo.musicTrack = gMusicInfo.musicTrackOnTransition;
@ -367,8 +379,8 @@ void unk_38d8(void)
{
if (!(gMusicInfo.priority & 0x40) && gMusicInfo.musicTrackOnTransition != MUSIC_NONE)
{
init_track(sMusicTrackDataRom[0].pTrack,
sSoundDataEntries[DetermineNewMusicTrack(gMusicInfo.musicTrackOnTransition)].pHeader);
InitTrack(sMusicTrackDataRom[0].pTrack,
sSoundDataEntries[(u16)DetermineNewMusicTrack(gMusicInfo.musicTrackOnTransition)].pHeader);
gMusicInfo.unk_20 = 0;
gMusicInfo.musicTrack = gMusicInfo.musicTrackOnTransition;
}
@ -403,9 +415,9 @@ void UpdateMusicAfterAlarmDisable(void)
* @brief 3980 | 48 | Determines a new music track based on something?
*
* @param musicTrack Music track
* @return u16 New music track
* @return u32 New music track
*/
u16 DetermineNewMusicTrack(u16 musicTrack)
u32 DetermineNewMusicTrack(u16 musicTrack)
{
switch (musicTrack)
{
@ -474,7 +486,7 @@ void PlayMusic(u16 musicTrack, u8 priority)
gMusicInfo.unk_20 = 0;
gMusicInfo.musicTrack = musicTrack;
gMusicInfo.occupied = FALSE;
init_track(pTrack, pHeader);
InitTrack(pTrack, pHeader);
}
}
@ -695,7 +707,7 @@ void InsertMusicAndQueueCurrent(u16 musicTrack, u8 param_2)
gMusicInfo.unk_20 = 1;
gMusicInfo.occupied = FALSE;
init_track(pTrack, pHeader);
InitTrack(pTrack, pHeader);
}
}
@ -725,13 +737,13 @@ void ReplayQueuedMusic(u8 queueFlags)
gMusicInfo.unk_20 = 0;
if ((u16)(gMusicInfo.musicTrack - 0x5A) < 0xA)
music = DetermineNewMusicTrack(gMusicInfo.musicTrack);
music = (u16)DetermineNewMusicTrack(gMusicInfo.musicTrack);
else
music = gMusicInfo.musicTrack;
pHeader = sSoundDataEntries[music].pHeader;
gMusicInfo.occupied = FALSE;
init_track(pTrack, pHeader);
InitTrack(pTrack, pHeader);
if (queueFlags & 0x40)
DelayMusicStart(pTrack, 60);
@ -810,12 +822,12 @@ void PlayCurrentMusicTrack(void)
currTrack = gMusicInfo.musicTrack;
musicTrack = currTrack - 0x5A;
if (musicTrack < 10)
pHeader = sSoundDataEntries[DetermineNewMusicTrack(currTrack)].pHeader;
pHeader = sSoundDataEntries[(u16)DetermineNewMusicTrack(currTrack)].pHeader;
else
pHeader = sSoundDataEntries[currTrack].pHeader;
gMusicInfo.occupied = FALSE;
init_track(pTrack, pHeader);
InitTrack(pTrack, pHeader);
gMusicInfo.occupied = FALSE;
}
@ -958,7 +970,7 @@ void BackupTrackData2SoundChannels(void)
if (!(pVariables->channel & 0xC0))
{
if (pVariables->pSoundPSG)
clear_registers_for_psg(pVariables->pSoundPSG, (pVariables->channel & 7) - 1); // Undefined, definition required
ClearRegistersForPsg(pVariables->pSoundPSG, (pVariables->channel & 7) - 1);
if (pVariables->pChannel)
{
@ -1136,7 +1148,7 @@ void unk_42bc(u16 musicTrack)
if (musicTrack == MUSIC_NONE)
musicTrack = 0x12B;
init_track(sMusicTrackDataRom[0].pTrack, sSoundDataEntries[musicTrack].pHeader);
InitTrack(sMusicTrackDataRom[0].pTrack, sSoundDataEntries[musicTrack].pHeader);
gMusicInfo.unk_20 = 0;
gMusicInfo.musicTrack = musicTrack;