Skip to content

Commit ce1e555

Browse files
committed
Merge 'Custom Audio Improvements' (OoTRandomizer#1966)
2 parents b7c034f + c7969b0 commit ce1e555

14 files changed

+28656
-28215
lines changed

ASM/build/asm_symbols.txt

+1,193-1,186
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ASM/src/audio.asm

+19
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@ AUDIO_THREAD_INFO_MEM_START:
2525
AUDIO_THREAD_INFO_MEM_SIZE:
2626
.word AUDIO_THREAD_MEM_SIZE
2727

28+
.align 0x10
29+
AUDIOBANK_TABLE_EXTENDED:
30+
.area 0x800, 0
31+
.endarea
32+
33+
FONTLOADSTATUS_EXTENDED:
34+
.area 0x80, 0
35+
.endarea
36+
37+
.align 0x10
38+
; Hack for when AudioLoad_SyncLoadFont checks fontLoadStatus
39+
; Put the address to load into T6
40+
AudioLoad_SyncLoadFont_StatusHack:
41+
addiu a1, a1, 0x5630 ; Replaced code
42+
li t6, FONTLOADSTATUS_EXTENDED
43+
jr ra
44+
addu t6, t6, v0
45+
46+
2847
//used to calculate the remaining free size of the audio thread heap
2948
get_audio_pointers:
3049
li t9, @fanfare_audioseq_size

ASM/src/config.asm

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
COSMETIC_CONTEXT:
88

99
COSMETIC_FORMAT_VERSION:
10-
.word 0x1F073FDC
10+
.word 0x1F073FDD
1111
CFG_MAGIC_COLOR:
1212
.halfword 0x0000, 0x00C8, 0x0000
1313
CFG_HEART_COLOR:
@@ -77,6 +77,8 @@ CFG_RAINBOW_TUNIC_ENABLED:
7777
CFG_TUNIC_COLORS:
7878
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
7979

80+
CFG_AUDIOBANK_TABLE_EXTENDED_ADDR:
81+
.word AUDIOBANK_TABLE_EXTENDED
8082

8183
CFG_SHOW_SETTING_INFO:
8284
.byte 0x00

ASM/src/hacks.asm

+116
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,114 @@ Gameplay_InitSkybox:
7070
nop
7171
.endarea
7272

73+
;==================================================================================================
74+
; Increase Number of Audio Banks, and Audiotable (samples)
75+
;==================================================================================================
76+
77+
.org 0x800B8888
78+
lui t2, hi(AUDIOBANK_TABLE_EXTENDED)
79+
.org 0x800B8898
80+
addiu t2, t2, lo(AUDIOBANK_TABLE_EXTENDED)
81+
82+
; Hacks to increase the number of audio banks from 0x30 to 0x80
83+
; Hacks in AudioHeap_ResetLoadStatus
84+
; This loop is annoying because it hardcodes the start and end addresses of fontLoadStatus array instead of calculating it.
85+
; v0 - start of array
86+
; v1 - end of array
87+
.org 0x800B3540
88+
; Replaces
89+
; lui v1, 0x8012
90+
; lui v0, 0x8012
91+
; addiu v0, v0 0x5660
92+
; addiu v1, v1, 0x5630
93+
li v1, FONTLOADSTATUS_EXTENDED
94+
li v0, FONTLOADSTATUS_EXTENDED + 0x80
95+
96+
.org 0x800B3554
97+
; Replaces:
98+
; lbu t6, 0x3468(v1)
99+
lbu t6, 0x00(v1)
100+
101+
.org 0x800B3560
102+
; Replaces:
103+
; sb r0, 0x3468(v1)
104+
sb r0, 0x00(v1)
105+
106+
; Hacks in AudioHeap_PopPersistentCache (I think)
107+
.org 0x800B3AB8
108+
; Replaces:
109+
; lui t7, 0x8013
110+
; addiu t7, t7, 0x8A98
111+
li t7, FONTLOADSTATUS_EXTENDED
112+
113+
; Hacks in AudioHeap_AllocCached (I think)
114+
.org 0x800B3F00
115+
; Replaces:
116+
; lui t3, 0x8013
117+
lui t3, hi(FONTLOADSTATUS_EXTENDED)
118+
.org 0x800B3F0C
119+
; Replaces:
120+
; addiu t3, t3, 0x8A98
121+
addiu t3, t3, lo(FONTLOADSTATUS_EXTENDED)
122+
123+
; Hacks in AudioLoad_IsFontLoadComplete
124+
.org 0x800B6E8C
125+
; Replaces:
126+
; lui t6, 0x8013
127+
; addu t6, t6, a1
128+
; lbu t6, 0x8A98(t6)
129+
lui t6, hi(FONTLOADSTATUS_EXTENDED)
130+
addu t6, t6, a1
131+
lbu t6, lo(FONTLOADSTATUS_EXTENDED)(t6)
132+
.org 0x800B6EB4
133+
; Replaces:
134+
; lui t7, 0x8013
135+
; addu t7, t7, v0
136+
; lbu t7, 0x8A98(t7)
137+
lui t7, hi(FONTLOADSTATUS_EXTENDED)
138+
addu t7, t7, v0
139+
lbu t7, lo(FONTLOADSTATUS_EXTENDED)(t7)
140+
141+
; Hacks in AudioLoad_SetFontLoadStatus
142+
.org 0x800B6FE0
143+
; Replaces:
144+
; lui t6, 0x8012
145+
; addiu t6, t6, 0x5630
146+
; skip
147+
; lbu t7, 0x3468(v0)
148+
; skip
149+
; skip
150+
; skip
151+
; sb a1, 0x3468(v0)
152+
li t6, FONTLOADSTATUS_EXTENDED
153+
.skip 4
154+
lbu t7, 0x00(v0)
155+
.skip 12
156+
sb a1, 0x00(v0)
157+
158+
; Hacks in AudioLoad_SyncLoadFont
159+
.org 0x800B7A2C
160+
; Replaces:
161+
; lui a1, 0x8012
162+
; addiu a1, a1, 0x5630
163+
; addu t6, a1, v0
164+
jal AudioLoad_SyncLoadFont_StatusHack
165+
lui a1, 0x8012
166+
nop
167+
lbu t7, 0x00(t6)
168+
169+
; Hacks in AudioLoad_AsyncLoadInner
170+
.org 0x800B82D0
171+
; Replaces:
172+
; lui t7, 0x8013
173+
lui t7, hi(FONTLOADSTATUS_EXTENDED)
174+
.org 0x800B8310
175+
; Replaces:
176+
; addu t7, t7, v0
177+
; lbu t7, 0x8A98(t7)
178+
addu t7, t7, v0
179+
lbu t7, lo(FONTLOADSTATUS_EXTENDED)(t7)
180+
73181
;==================================================================================================
74182
; Don't Use Sandstorm Transition if gameplay_field_keep is not loaded
75183
;==================================================================================================
@@ -2616,6 +2724,14 @@ courtyard_guards_kill:
26162724
.orga 0xB2E82C ; in memory 0x800B88CC
26172725
lw a1, 0x8000B188
26182726

2727+
;==================================================================================================
2728+
; Load Audiobank using dmadata
2729+
;==================================================================================================
2730+
; Replaces: lui a1, 0x0001
2731+
; addiu a1, a1, 0xD390
2732+
.orga 0xB2E840 ; in memory 0x800B88E0
2733+
lw a1, 0x8000B178
2734+
26192735
;==================================================================================================
26202736
; Load Audiotable using dmadata
26212737
;==================================================================================================

Cosmetics.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def patch_music(rom: Rom, settings: Settings, log: CosmeticsLog, symbols: dict[s
4949
# patch music
5050
if settings.background_music != 'normal' or settings.fanfares != 'normal' or log.src_dict.get('bgm', {}):
5151
Music.restore_music(rom)
52-
Music.randomize_music(rom, settings, log)
52+
Music.randomize_music(rom, settings, log, symbols)
5353
else:
5454
Music.restore_music(rom)
5555
# Remove battle music
@@ -1097,11 +1097,19 @@ def patch_music_changes(rom: Rom, settings: Settings, log: CosmeticsLog, symbols
10971097
**patch_sets[0x1F073FDB]["symbols"],
10981098
"CFG_SPEEDUP_MUSIC_FOR_LAST_TRIFORCE_PIECE": 0x0058,
10991099
"CFG_SLOWDOWN_MUSIC_WHEN_LOWHP": 0x0059,
1100-
"CFG_RAINBOW_TUNIC_ENABLED": 0x005A,
1101-
"CFG_TUNIC_COLORS": 0x005B,
11021100
}
11031101
}
11041102

1103+
# 7.1.123
1104+
patch_sets[0x1F073FDD] = {
1105+
"patches": patch_sets[0x1F073FDC]["patches"] + [
1106+
patch_music, # Patch music needs to be moved into a versioned patch after introducing custom instrument sets in order for older patches to still work. This should work because when running the global patches we make sure they're not in the versioned patch set.
1107+
],
1108+
"symbols": {
1109+
**patch_sets[0x1F073FDC]["symbols"],
1110+
"CFG_AUDIOBANK_TABLE_EXTENDED_ADDR": 0x0064
1111+
}
1112+
}
11051113

11061114
def patch_cosmetics(settings: Settings, rom: Rom) -> CosmeticsLog:
11071115
# re-seed for aesthetic effects. They shouldn't be affected by the generation seed
@@ -1168,6 +1176,8 @@ def __init__(self, settings: Settings) -> None:
11681176
self.sfx: dict[str, str] = {}
11691177
self.bgm: dict[str, str] = {}
11701178
self.bgm_groups: dict[str, list | dict] = {}
1179+
self.bank_dma_index: Optional[int] = None
1180+
self.instr_dma_index: Optional[int] = None
11711181

11721182
self.src_dict: dict = {}
11731183
self.errors: list[str] = []

0 commit comments

Comments
 (0)