Ported libmks4agb from pokeruby (#12)

* Port agb_flash from pokeruby

* use ramscrgen

* formatting

* delete ewram_syms.txt and iwram_syms.txt

* Finish port of agb_flash

* Ported libmks4agb from pokeruby

* Reordered declarations to match pokeruby
This commit is contained in:
Diegoisawesome 2016-11-01 22:03:16 -05:00 committed by YamaArashi
parent 2db94cf5eb
commit 69c734c9a8
35 changed files with 4735 additions and 5571 deletions

View File

@ -8,7 +8,7 @@
thumb_func_start sub_807F738 thumb_func_start sub_807F738
sub_807F738: @ 807F738 sub_807F738: @ 807F738
push {lr} push {lr}
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
ldr r2, =gUnknown_020322A4 ldr r2, =gUnknown_020322A4
ldr r2, [r2] ldr r2, [r2]
@ -18,7 +18,7 @@ sub_807F738: @ 807F738
subs r2, 0x80 subs r2, 0x80
lsls r2, 17 lsls r2, 17
asrs r2, 16 asrs r2, 16
bl MPlayPitchControl bl m4aMPlayPitchControl
pop {r0} pop {r0}
bx r0 bx r0
.pool .pool
@ -3564,15 +3564,15 @@ _08081678:
adds r1, r0 adds r1, r0
lsls r1, 16 lsls r1, 16
lsrs r1, 16 lsrs r1, 16
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl MPlayTempoControl bl m4aMPlayTempoControl
b _080816D2 b _080816D2
.pool .pool
_080816C8: _080816C8:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
movs r1, 0x80 movs r1, 0x80
lsls r1, 1 lsls r1, 1
bl MPlayTempoControl bl m4aMPlayTempoControl
_080816D2: _080816D2:
ldr r1, [sp] ldr r1, [sp]
adds r1, 0x2 adds r1, 0x2
@ -4768,10 +4768,10 @@ _08082004:
.4byte _08082430 .4byte _08082430
.4byte _0808246C .4byte _0808246C
_08082038: _08082038:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
movs r1, 0x80 movs r1, 0x80
lsls r1, 1 lsls r1, 1
bl MPlayTempoControl bl m4aMPlayTempoControl
movs r4, 0 movs r4, 0
b _08082064 b _08082064
.pool .pool
@ -4829,8 +4829,8 @@ _080820B6:
ldr r1, [r0] ldr r1, [r0]
movs r0, 0 movs r0, 0
strb r0, [r1] strb r0, [r1]
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
bl MPlayStop_rev01 bl m4aMPlayStop
_080820C6: _080820C6:
bl sub_807F738 bl sub_807F738
b _0808249E b _0808249E

View File

@ -8891,7 +8891,7 @@ _080DC226:
ble _080DC284 ble _080DC284
movs r0, 0x60 movs r0, 0x60
bl audio_play bl audio_play
ldr r4, =gUnknown_030075F0 ldr r4, =gMPlay_SE1
adds r0, r4, 0 adds r0, r4, 0
bl m4aMPlayImmInit bl m4aMPlayImmInit
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
@ -8899,7 +8899,7 @@ _080DC226:
lsls r2, r0, 24 lsls r2, r0, 24
asrs r2, 16 asrs r2, 16
adds r0, r4, 0 adds r0, r4, 0
bl MPlayPitchControl bl m4aMPlayPitchControl
b _080DC28A b _080DC28A
.pool .pool
_080DC284: _080DC284:

View File

@ -602,7 +602,7 @@ _080717EC:
bl ResetAllObjectData bl ResetAllObjectData
bl ResetTasks bl ResetTasks
bl remove_some_task bl remove_some_task
bl SoundVSyncOn_rev01 bl m4aSoundVSyncOn
b _080719A6 b _080719A6
.pool .pool
_080718B8: _080718B8:

View File

@ -326,7 +326,7 @@ _0816CEE2:
ldrb r0, [r0, 0x15] ldrb r0, [r0, 0x15]
lsls r0, 31 lsls r0, 31
lsrs r0, 31 lsrs r0, 31
bl sub_82E1810 bl SetPokemonCryStereo
ldr r0, =0x02000000 ldr r0, =0x02000000
movs r1, 0xE0 movs r1, 0xE0
lsls r1, 9 lsls r1, 9

File diff suppressed because it is too large Load Diff

View File

@ -3342,12 +3342,12 @@ c2_800ACD4: @ 800AF30
movs r0, 0 movs r0, 0
movs r1, 0 movs r1, 0
bl SetGpuReg bl SetGpuReg
ldr r0, =gUnknown_030075F0 ldr r0, =gMPlay_SE1
bl MPlayStop_rev01 bl m4aMPlayStop
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
bl MPlayStop_rev01 bl m4aMPlayStop
ldr r0, =gUnknown_03007800 ldr r0, =gMPlay_SE3
bl MPlayStop_rev01 bl m4aMPlayStop
ldr r0, =0x02000000 ldr r0, =0x02000000
movs r1, 0xE0 movs r1, 0xE0
lsls r1, 9 lsls r1, 9
@ -32621,7 +32621,7 @@ sub_801A43C: @ 801A43C
bl ResetAllObjectData bl ResetAllObjectData
bl ResetTasks bl ResetTasks
bl remove_some_task bl remove_some_task
bl SoundVSyncOn_rev01 bl m4aSoundVSyncOn
ldr r0, =sub_801A418 ldr r0, =sub_801A418
bl SetVBlankCallback bl SetVBlankCallback
ldr r0, =sub_801A6C0 ldr r0, =sub_801A6C0

1909
asm/m4a_1.s Normal file

File diff suppressed because it is too large Load Diff

574
asm/m4a_3.s Normal file
View File

@ -0,0 +1,574 @@
.include "asm/macros.inc"
.include "constants/gba_constants.inc"
.include "constants/m4a_constants.inc"
.syntax unified
.text
thumb_func_start CgbSound
CgbSound: @ 81DEA70
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x1C
ldr r0, =SOUND_INFO_PTR
ldr r0, [r0]
str r0, [sp, 0x4]
ldrb r0, [r0, 0xA]
cmp r0, 0
beq _081DEA94
subs r0, 0x1
ldr r1, [sp, 0x4]
strb r0, [r1, 0xA]
b _081DEA9A
.pool
_081DEA94:
movs r0, 0xE
ldr r2, [sp, 0x4]
strb r0, [r2, 0xA]
_081DEA9A:
movs r6, 0x1
ldr r0, [sp, 0x4]
ldr r4, [r0, 0x1C]
_081DEAA0:
ldrb r1, [r4]
movs r0, 0xC7
ands r0, r1
adds r2, r6, 0x1
mov r10, r2
movs r2, 0x40
adds r2, r4
mov r9, r2
cmp r0, 0
bne _081DEAB6
b _081DEEA0
_081DEAB6:
cmp r6, 0x2
beq _081DEAE8
cmp r6, 0x2
bgt _081DEAC4
cmp r6, 0x1
beq _081DEACA
b _081DEB20
_081DEAC4:
cmp r6, 0x3
beq _081DEB00
b _081DEB20
_081DEACA:
ldr r0, =REG_NR10
str r0, [sp, 0x8]
ldr r7, =REG_NR11
ldr r2, =REG_NR12
str r2, [sp, 0xC]
adds r0, 0x4
str r0, [sp, 0x10]
adds r2, 0x2
b _081DEB30
.pool
_081DEAE8:
ldr r0, =REG_NR10 + 1
str r0, [sp, 0x8]
ldr r7, =REG_NR21
ldr r2, =REG_NR22
b _081DEB28
.pool
_081DEB00:
ldr r0, =REG_NR30
str r0, [sp, 0x8]
ldr r7, =REG_NR31
ldr r2, =REG_NR32
str r2, [sp, 0xC]
adds r0, 0x4
str r0, [sp, 0x10]
adds r2, 0x2
b _081DEB30
.pool
_081DEB20:
ldr r0, =REG_NR30 + 1
str r0, [sp, 0x8]
ldr r7, =REG_NR41
ldr r2, =REG_NR42
_081DEB28:
str r2, [sp, 0xC]
adds r0, 0xB
str r0, [sp, 0x10]
adds r2, 0x4
_081DEB30:
str r2, [sp, 0x14]
ldr r0, [sp, 0x4]
ldrb r0, [r0, 0xA]
str r0, [sp]
ldr r2, [sp, 0xC]
ldrb r0, [r2]
mov r8, r0
adds r2, r1, 0
movs r0, 0x80
ands r0, r2
cmp r0, 0
beq _081DEC26
movs r3, 0x40
adds r0, r3, 0
ands r0, r2
lsls r0, 24
lsrs r5, r0, 24
adds r0, r6, 0x1
mov r10, r0
movs r1, 0x40
adds r1, r4
mov r9, r1
cmp r5, 0
bne _081DEC4A
movs r0, 0x3
strb r0, [r4]
strb r0, [r4, 0x1D]
adds r0, r4, 0
str r3, [sp, 0x18]
bl CgbModVol
ldr r3, [sp, 0x18]
cmp r6, 0x2
beq _081DEB98
cmp r6, 0x2
bgt _081DEB8C
cmp r6, 0x1
beq _081DEB92
b _081DEBEC
.pool
_081DEB8C:
cmp r6, 0x3
beq _081DEBA4
b _081DEBEC
_081DEB92:
ldrb r0, [r4, 0x1F]
ldr r2, [sp, 0x8]
strb r0, [r2]
_081DEB98:
ldr r0, [r4, 0x24]
lsls r0, 6
ldrb r1, [r4, 0x1E]
adds r0, r1, r0
strb r0, [r7]
b _081DEBF8
_081DEBA4:
ldr r1, [r4, 0x24]
ldr r0, [r4, 0x28]
cmp r1, r0
beq _081DEBCC
ldr r2, [sp, 0x8]
strb r3, [r2]
ldr r1, =REG_WAVE_RAM
ldr r2, [r4, 0x24]
ldr r0, [r2]
str r0, [r1]
adds r1, 0x4
ldr r0, [r2, 0x4]
str r0, [r1]
adds r1, 0x4
ldr r0, [r2, 0x8]
str r0, [r1]
adds r1, 0x4
ldr r0, [r2, 0xC]
str r0, [r1]
str r2, [r4, 0x28]
_081DEBCC:
ldr r0, [sp, 0x8]
strb r5, [r0]
ldrb r0, [r4, 0x1E]
strb r0, [r7]
ldrb r0, [r4, 0x1E]
cmp r0, 0
beq _081DEBE4
movs r0, 0xC0
b _081DEC06
.pool
_081DEBE4:
movs r1, 0x80
negs r1, r1
strb r1, [r4, 0x1A]
b _081DEC08
_081DEBEC:
ldrb r0, [r4, 0x1E]
strb r0, [r7]
ldr r0, [r4, 0x24]
lsls r0, 3
ldr r2, [sp, 0x10]
strb r0, [r2]
_081DEBF8:
ldrb r0, [r4, 0x4]
adds r0, 0x8
mov r8, r0
ldrb r0, [r4, 0x1E]
cmp r0, 0
beq _081DEC06
movs r0, 0x40
_081DEC06:
strb r0, [r4, 0x1A]
_081DEC08:
ldrb r1, [r4, 0x4]
movs r2, 0
strb r1, [r4, 0xB]
movs r0, 0xFF
ands r0, r1
adds r1, r6, 0x1
mov r10, r1
movs r1, 0x40
adds r1, r4
mov r9, r1
cmp r0, 0
bne _081DEC22
b _081DED5E
_081DEC22:
strb r2, [r4, 0x9]
b _081DED8C
_081DEC26:
movs r0, 0x4
ands r0, r2
cmp r0, 0
beq _081DEC58
ldrb r0, [r4, 0xD]
subs r0, 0x1
strb r0, [r4, 0xD]
movs r2, 0xFF
ands r0, r2
lsls r0, 24
adds r1, r6, 0x1
mov r10, r1
movs r2, 0x40
adds r2, r4
mov r9, r2
cmp r0, 0
ble _081DEC4A
b _081DED9E
_081DEC4A:
lsls r0, r6, 24
lsrs r0, 24
bl CgbOscOff
movs r0, 0
strb r0, [r4]
b _081DEE9C
_081DEC58:
movs r0, 0x40
ands r0, r1
adds r2, r6, 0x1
mov r10, r2
movs r2, 0x40
adds r2, r4
mov r9, r2
cmp r0, 0
beq _081DEC98
movs r0, 0x3
ands r0, r1
cmp r0, 0
beq _081DEC98
movs r0, 0xFC
ands r0, r1
movs r2, 0
strb r0, [r4]
ldrb r1, [r4, 0x7]
strb r1, [r4, 0xB]
movs r0, 0xFF
ands r0, r1
cmp r0, 0
beq _081DECCA
movs r0, 0x1
ldrb r1, [r4, 0x1D]
orrs r0, r1
strb r0, [r4, 0x1D]
cmp r6, 0x3
beq _081DED8C
ldrb r2, [r4, 0x7]
mov r8, r2
b _081DED8C
_081DEC98:
ldrb r0, [r4, 0xB]
cmp r0, 0
bne _081DED8C
cmp r6, 0x3
bne _081DECAA
movs r0, 0x1
ldrb r1, [r4, 0x1D]
orrs r0, r1
strb r0, [r4, 0x1D]
_081DECAA:
adds r0, r4, 0
bl CgbModVol
movs r0, 0x3
ldrb r2, [r4]
ands r0, r2
cmp r0, 0
bne _081DECFE
ldrb r0, [r4, 0x9]
subs r0, 0x1
strb r0, [r4, 0x9]
movs r1, 0xFF
ands r0, r1
lsls r0, 24
cmp r0, 0
bgt _081DECFA
_081DECCA:
ldrb r2, [r4, 0xC]
ldrb r1, [r4, 0xA]
adds r0, r2, 0
muls r0, r1
adds r0, 0xFF
asrs r0, 8
movs r1, 0
strb r0, [r4, 0x9]
lsls r0, 24
cmp r0, 0
beq _081DEC4A
movs r0, 0x4
ldrb r2, [r4]
orrs r0, r2
strb r0, [r4]
movs r0, 0x1
ldrb r1, [r4, 0x1D]
orrs r0, r1
strb r0, [r4, 0x1D]
cmp r6, 0x3
beq _081DED9E
movs r2, 0x8
mov r8, r2
b _081DED9E
_081DECFA:
ldrb r0, [r4, 0x7]
b _081DED8A
_081DECFE:
cmp r0, 0x1
bne _081DED0A
_081DED02:
ldrb r0, [r4, 0x19]
strb r0, [r4, 0x9]
movs r0, 0x7
b _081DED8A
_081DED0A:
cmp r0, 0x2
bne _081DED4E
ldrb r0, [r4, 0x9]
subs r0, 0x1
strb r0, [r4, 0x9]
movs r1, 0xFF
ands r0, r1
lsls r0, 24
ldrb r2, [r4, 0x19]
lsls r1, r2, 24
cmp r0, r1
bgt _081DED4A
_081DED22:
ldrb r0, [r4, 0x6]
cmp r0, 0
bne _081DED32
movs r0, 0xFC
ldrb r1, [r4]
ands r0, r1
strb r0, [r4]
b _081DECCA
_081DED32:
ldrb r0, [r4]
subs r0, 0x1
strb r0, [r4]
movs r0, 0x1
ldrb r2, [r4, 0x1D]
orrs r0, r2
strb r0, [r4, 0x1D]
cmp r6, 0x3
beq _081DED02
movs r0, 0x8
mov r8, r0
b _081DED02
_081DED4A:
ldrb r0, [r4, 0x5]
b _081DED8A
_081DED4E:
ldrb r0, [r4, 0x9]
adds r0, 0x1
strb r0, [r4, 0x9]
movs r1, 0xFF
ands r0, r1
ldrb r2, [r4, 0xA]
cmp r0, r2
bcc _081DED88
_081DED5E:
ldrb r0, [r4]
subs r0, 0x1
movs r2, 0
strb r0, [r4]
ldrb r1, [r4, 0x5]
strb r1, [r4, 0xB]
movs r0, 0xFF
ands r0, r1
cmp r0, 0
beq _081DED22
movs r0, 0x1
ldrb r1, [r4, 0x1D]
orrs r0, r1
strb r0, [r4, 0x1D]
ldrb r0, [r4, 0xA]
strb r0, [r4, 0x9]
cmp r6, 0x3
beq _081DED8C
ldrb r2, [r4, 0x5]
mov r8, r2
b _081DED8C
_081DED88:
ldrb r0, [r4, 0x4]
_081DED8A:
strb r0, [r4, 0xB]
_081DED8C:
ldrb r0, [r4, 0xB]
subs r0, 0x1
strb r0, [r4, 0xB]
ldr r0, [sp]
cmp r0, 0
bne _081DED9E
subs r0, 0x1
str r0, [sp]
b _081DEC98
_081DED9E:
movs r0, 0x2
ldrb r1, [r4, 0x1D]
ands r0, r1
cmp r0, 0
beq _081DEE16
cmp r6, 0x3
bgt _081DEDDE
movs r0, 0x8
ldrb r2, [r4, 0x1]
ands r0, r2
cmp r0, 0
beq _081DEDDE
ldr r0, =REG_SOUNDBIAS + 1
ldrb r0, [r0]
cmp r0, 0x3F
bgt _081DEDD0
ldr r0, [r4, 0x20]
adds r0, 0x2
ldr r1, =0x000007fc
b _081DEDDA
.pool
_081DEDD0:
cmp r0, 0x7F
bgt _081DEDDE
ldr r0, [r4, 0x20]
adds r0, 0x1
ldr r1, =0x000007fe
_081DEDDA:
ands r0, r1
str r0, [r4, 0x20]
_081DEDDE:
cmp r6, 0x4
beq _081DEDF0
ldr r0, [r4, 0x20]
ldr r1, [sp, 0x10]
strb r0, [r1]
b _081DEDFE
.pool
_081DEDF0:
ldr r2, [sp, 0x10]
ldrb r0, [r2]
movs r1, 0x8
ands r1, r0
ldr r0, [r4, 0x20]
orrs r0, r1
strb r0, [r2]
_081DEDFE:
movs r0, 0xC0
ldrb r1, [r4, 0x1A]
ands r0, r1
adds r1, r4, 0
adds r1, 0x21
ldrb r1, [r1]
adds r0, r1, r0
strb r0, [r4, 0x1A]
movs r2, 0xFF
ands r0, r2
ldr r1, [sp, 0x14]
strb r0, [r1]
_081DEE16:
movs r0, 0x1
ldrb r2, [r4, 0x1D]
ands r0, r2
cmp r0, 0
beq _081DEE9C
ldr r1, =REG_NR51
ldrb r0, [r1]
ldrb r2, [r4, 0x1C]
bics r0, r2
ldrb r2, [r4, 0x1B]
orrs r0, r2
strb r0, [r1]
cmp r6, 0x3
bne _081DEE68
ldr r0, =gCgb3Vol
ldrb r1, [r4, 0x9]
adds r0, r1, r0
ldrb r0, [r0]
ldr r2, [sp, 0xC]
strb r0, [r2]
movs r1, 0x80
adds r0, r1, 0
ldrb r2, [r4, 0x1A]
ands r0, r2
cmp r0, 0
beq _081DEE9C
ldr r0, [sp, 0x8]
strb r1, [r0]
ldrb r0, [r4, 0x1A]
ldr r1, [sp, 0x14]
strb r0, [r1]
movs r0, 0x7F
ldrb r2, [r4, 0x1A]
ands r0, r2
strb r0, [r4, 0x1A]
b _081DEE9C
.pool
_081DEE68:
movs r0, 0xF
mov r1, r8
ands r1, r0
mov r8, r1
ldrb r2, [r4, 0x9]
lsls r0, r2, 4
add r0, r8
ldr r1, [sp, 0xC]
strb r0, [r1]
movs r2, 0x80
ldrb r0, [r4, 0x1A]
orrs r0, r2
ldr r1, [sp, 0x14]
strb r0, [r1]
cmp r6, 0x1
bne _081DEE9C
ldr r0, [sp, 0x8]
ldrb r1, [r0]
movs r0, 0x8
ands r0, r1
cmp r0, 0
bne _081DEE9C
ldrb r0, [r4, 0x1A]
orrs r0, r2
ldr r1, [sp, 0x14]
strb r0, [r1]
_081DEE9C:
movs r0, 0
strb r0, [r4, 0x1D]
_081DEEA0:
mov r6, r10
mov r4, r9
cmp r6, 0x4
bgt _081DEEAA
b _081DEAA0
_081DEEAA:
add sp, 0x1C
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end CgbSound
.align 2, 0 @ Don't pad with nop.

View File

@ -477,7 +477,7 @@ _08000782:
bl CopyBufferedValuesToGpuRegs bl CopyBufferedValuesToGpuRegs
bl ProcessDma3Requests bl ProcessDma3Requests
ldr r1, =gUnknown_03002F50 ldr r1, =gUnknown_03002F50
ldr r0, =gUnknown_03006380 ldr r0, =gSoundInfo
ldrb r0, [r0, 0x4] ldrb r0, [r0, 0x4]
strb r0, [r1] strb r0, [r1]
bl m4aSoundMain bl m4aSoundMain
@ -562,7 +562,7 @@ VCountIntr: @ 8000844
beq _08000852 beq _08000852
bl _call_via_r0 bl _call_via_r0
_08000852: _08000852:
bl SoundVSync_rev01 bl m4aSoundVSync
ldr r2, =gUnknown_03007FF8 ldr r2, =gUnknown_03007FF8
ldrh r0, [r2] ldrh r0, [r2]
movs r1, 0x4 movs r1, 0x4
@ -661,7 +661,7 @@ Reset: @ 80008F4
ldr r1, =0x04000208 ldr r1, =0x04000208
movs r0, 0 movs r0, 0
strh r0, [r1] strh r0, [r1]
bl SoundVSyncOff_rev01 bl m4aSoundVSyncOff
bl remove_some_task bl remove_some_task
ldr r1, =0x040000bc ldr r1, =0x040000bc
ldrh r2, [r1, 0xA] ldrh r2, [r1, 0xA]
@ -709,7 +709,7 @@ sub_8000964: @ 8000964
mov r1, sp mov r1, sp
movs r0, 0 movs r0, 0
strh r0, [r1] strh r0, [r1]
ldr r1, =gUnknown_03007330 ldr r1, =gPokemonCrySongs
ldr r2, =0x01000034 ldr r2, =0x01000034
mov r0, sp mov r0, sp
bl CpuSet bl CpuSet

View File

@ -965,12 +965,12 @@ _08120850:
lsls r1, 1 lsls r1, 1
adds r0, r1 adds r0, r1
strh r0, [r6, 0x6] strh r0, [r6, 0x6]
ldr r4, =gUnknown_03007630 ldr r4, =gMPlay_SE2
ldr r5, =0x0000ffff ldr r5, =0x0000ffff
ldrh r2, [r6, 0x6] ldrh r2, [r6, 0x6]
adds r0, r4, 0 adds r0, r4, 0
adds r1, r5, 0 adds r1, r5, 0
bl MPlayVolumeControl bl m4aMPlayVolumeControl
ldrb r1, [r6, 0x1] ldrb r1, [r6, 0x1]
lsls r1, 2 lsls r1, 2
adds r1, r6, r1 adds r1, r6, r1
@ -984,7 +984,7 @@ _08120850:
ldrsh r2, [r6, r3] ldrsh r2, [r6, r3]
adds r0, r4, 0 adds r0, r4, 0
adds r1, r5, 0 adds r1, r5, 0
bl MPlayPitchControl bl m4aMPlayPitchControl
b _08120938 b _08120938
.pool .pool
_081208A0: _081208A0:
@ -1008,17 +1008,17 @@ _081208BC:
subs r0, 0x40 subs r0, 0x40
_081208C0: _081208C0:
strh r0, [r6, 0x8] strh r0, [r6, 0x8]
ldr r4, =gUnknown_03007630 ldr r4, =gMPlay_SE2
ldr r5, =0x0000ffff ldr r5, =0x0000ffff
ldrh r2, [r6, 0x6] ldrh r2, [r6, 0x6]
adds r0, r4, 0 adds r0, r4, 0
adds r1, r5, 0 adds r1, r5, 0
bl MPlayVolumeControl bl m4aMPlayVolumeControl
movs r0, 0x8 movs r0, 0x8
ldrsh r2, [r6, r0] ldrsh r2, [r6, r0]
adds r0, r4, 0 adds r0, r4, 0
adds r1, r5, 0 adds r1, r5, 0
bl MPlayPitchControl bl m4aMPlayPitchControl
ldrh r0, [r6, 0xA] ldrh r0, [r6, 0xA]
adds r0, 0x1 adds r0, 0x1
strh r0, [r6, 0xA] strh r0, [r6, 0xA]
@ -1059,8 +1059,8 @@ _08120922:
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
bne _08120938 bne _08120938
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
bl MPlayStop_rev01 bl m4aMPlayStop
movs r0, 0x4 movs r0, 0x4
_08120936: _08120936:
strb r0, [r6, 0x3] strb r0, [r6, 0x3]
@ -1228,9 +1228,9 @@ _08120A7E:
bne _08120AB0 bne _08120AB0
movs r0, 0x6 movs r0, 0x6
bl sub_80A3228 bl sub_80A3228
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
movs r1, 0x2 movs r1, 0x2
bl sub_82E0308 bl m4aMPlayFadeOutTemporarily
bl script_env_2_enable_and_set_ctx_running bl script_env_2_enable_and_set_ctx_running
adds r0, r6, 0 adds r0, r6, 0
bl DestroyTask bl DestroyTask

View File

@ -1101,7 +1101,7 @@ sub_80BADD8: @ 80BADD8
movs r4, 0x1 movs r4, 0x1
eors r5, r4 eors r5, r4
adds r0, r5, 0 adds r0, r5, 0
bl sub_82E1810 bl SetPokemonCryStereo
ldr r0, =gUnknown_02039B48 ldr r0, =gUnknown_02039B48
strb r4, [r0] strb r4, [r0]
_080BADF8: _080BADF8:

View File

@ -497,10 +497,10 @@ _080BB71C:
adds r1, r2 adds r1, r2
ldrb r1, [r1] ldrb r1, [r1]
bl sub_80BC8D4 bl sub_80BC8D4
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
bl MPlayVolumeControl bl m4aMPlayVolumeControl
_080BB74C: _080BB74C:
add sp, 0x8 add sp, 0x8
pop {r3} pop {r3}
@ -1246,11 +1246,11 @@ _080BBE18:
bl DestroyTask bl DestroyTask
ldr r0, =sub_8086194 ldr r0, =sub_8086194
bl SetMainCallback2 bl SetMainCallback2
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
ldr r0, [r5] ldr r0, [r5]
bl Free bl Free
_080BBE4A: _080BBE4A:
@ -7228,8 +7228,8 @@ _080BF2A8:
beq _080BF2B6 beq _080BF2B6
b _080BF5B2 b _080BF5B2
_080BF2B6: _080BF2B6:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl MPlayStop_rev01 bl m4aMPlayStop
ldr r5, =gUnknown_02039B4C ldr r5, =gUnknown_02039B4C
ldr r0, [r5] ldr r0, [r5]
ldr r3, =0x0000064a ldr r3, =0x0000064a
@ -7592,7 +7592,7 @@ _080BF636:
movs r2, 0 movs r2, 0
movs r3, 0x10 movs r3, 0x10
bl pal_fade_maybe bl pal_fade_maybe
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl m4aMPlayContinue bl m4aMPlayContinue
ldr r0, =gUnknown_02039B4C ldr r0, =gUnknown_02039B4C
ldr r0, [r0] ldr r0, [r0]
@ -7634,7 +7634,7 @@ _080BF6B0:
movs r2, 0 movs r2, 0
movs r3, 0x10 movs r3, 0x10
bl pal_fade_maybe bl pal_fade_maybe
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl m4aMPlayContinue bl m4aMPlayContinue
ldr r0, =gUnknown_02039B4C ldr r0, =gUnknown_02039B4C
ldr r0, [r0] ldr r0, [r0]
@ -7689,7 +7689,7 @@ _080BF73C:
movs r2, 0 movs r2, 0
movs r3, 0x10 movs r3, 0x10
bl pal_fade_maybe bl pal_fade_maybe
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl m4aMPlayContinue bl m4aMPlayContinue
ldr r0, =gUnknown_02039B4C ldr r0, =gUnknown_02039B4C
ldr r0, [r0] ldr r0, [r0]

View File

@ -239,7 +239,7 @@ sub_8145534: @ 8145534
lsls r0, 16 lsls r0, 16
lsrs r4, r0, 16 lsrs r4, r0, 16
adds r5, r4, 0 adds r5, r4, 0
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r0, [r0, 0x4] ldr r0, [r0, 0x4]
cmp r0, 0 cmp r0, 0
bge _08145582 bge _08145582
@ -300,11 +300,11 @@ sub_81455A8: @ 81455A8
ldrsb r0, [r3, r0] ldrsb r0, [r3, r0]
cmp r0, 0x1 cmp r0, 0x1
bgt _081455C0 bgt _081455C0
ldr r0, =gUnknown_030066D0 ldr r0, =gSoundInfo + 0x350
b _081455D8 b _081455D8
.pool .pool
_081455C0: _081455C0:
ldr r2, =gUnknown_03006380 ldr r2, =gSoundInfo
ldrb r1, [r2, 0xB] ldrb r1, [r2, 0xB]
movs r0, 0 movs r0, 0
ldrsb r0, [r3, r0] ldrsb r0, [r3, r0]

View File

@ -6299,10 +6299,10 @@ sub_80384E4: @ 80384E4
ands r0, r1 ands r0, r1
cmp r0, 0 cmp r0, 0
bne _08038512 bne _08038512
ldr r0, =gUnknown_030075F0 ldr r0, =gMPlay_SE1
bl MPlayStop_rev01 bl m4aMPlayStop
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
bl MPlayStop_rev01 bl m4aMPlayStop
bl sub_803849C bl sub_803849C
bl FreeAllWindowBuffers bl FreeAllWindowBuffers
ldr r0, =gUnknown_030022C0 ldr r0, =gUnknown_030022C0
@ -48662,18 +48662,18 @@ _0804FCA2:
b _0804FD70 b _0804FD70
.pool .pool
_0804FCC4: _0804FCC4:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x55 movs r2, 0x55
bl MPlayVolumeControl bl m4aMPlayVolumeControl
b _0804FD70 b _0804FD70
.pool .pool
_0804FCD8: _0804FCD8:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
b _0804FD70 b _0804FD70
.pool .pool
_0804FCF0: _0804FCF0:
@ -65202,16 +65202,16 @@ _08058C82:
ands r0, r1 ands r0, r1
cmp r0, 0x42 cmp r0, 0x42
bne _08058D08 bne _08058D08
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl m4aMPlayContinue bl m4aMPlayContinue
b _08058D14 b _08058D14
.pool .pool
_08058D08: _08058D08:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
_08058D14: _08058D14:
ldr r0, =gUnknown_020244D0 ldr r0, =gUnknown_020244D0
ldr r2, [r0] ldr r2, [r0]
@ -65528,11 +65528,11 @@ sub_8058FC0: @ 8058FC0
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
bne _0805900E bne _0805900E
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
ldr r2, =gUnknown_0202406E ldr r2, =gUnknown_0202406E
ldrb r1, [r4] ldrb r1, [r4]
lsls r0, r1, 1 lsls r0, r1, 1
@ -65648,11 +65648,11 @@ c3_0802FDF4: @ 8059100
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
bne _08059122 bne _08059122
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
adds r0, r4, 0 adds r0, r4, 0
bl DestroyTask bl DestroyTask
_08059122: _08059122:
@ -74118,10 +74118,10 @@ mplay_80342A4: @ 805DB90
ldrb r0, [r0, 0x8] ldrb r0, [r0, 0x8]
cmp r0, 0x1D cmp r0, 0x1D
bls _0805DBDC bls _0805DBDC
ldr r0, =gUnknown_030075F0 ldr r0, =gMPlay_SE1
bl MPlayStop_rev01 bl m4aMPlayStop
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
bl MPlayStop_rev01 bl m4aMPlayStop
_0805DBD8: _0805DBD8:
cmp r5, 0 cmp r5, 0
beq _0805DBF0 beq _0805DBF0
@ -77341,16 +77341,16 @@ _0805F6D0:
lsrs r0, 24 lsrs r0, 24
cmp r0, 0x1 cmp r0, 0x1
bne _0805F774 bne _0805F774
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl m4aMPlayContinue bl m4aMPlayContinue
b _0805F774 b _0805F774
.pool .pool
_0805F768: _0805F768:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
_0805F774: _0805F774:
ldr r0, =gUnknown_020244D0 ldr r0, =gUnknown_020244D0
ldr r2, [r0] ldr r2, [r0]
@ -77957,11 +77957,11 @@ bx_803AEDC: @ 805FC80
cmp r1, r0 cmp r1, r0
bne _0805FCDA bne _0805FCDA
_0805FCCA: _0805FCCA:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
bl dp01_tbl7_exec_completed bl dp01_tbl7_exec_completed
_0805FCDA: _0805FCDA:
pop {r4} pop {r4}
@ -86796,16 +86796,16 @@ _08064898:
lsrs r0, 24 lsrs r0, 24
cmp r0, 0x1 cmp r0, 0x1
bne _0806493C bne _0806493C
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl m4aMPlayContinue bl m4aMPlayContinue
b _0806493C b _0806493C
.pool .pool
_08064930: _08064930:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
_0806493C: _0806493C:
ldr r0, =gUnknown_020244D0 ldr r0, =gUnknown_020244D0
ldr r2, [r0] ldr r2, [r0]
@ -87368,11 +87368,11 @@ sub_8064DD0: @ 8064DD0
cmp r1, r0 cmp r1, r0
bne _08064E2A bne _08064E2A
_08064E1A: _08064E1A:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
bl sub_8065068 bl sub_8065068
_08064E2A: _08064E2A:
pop {r4} pop {r4}

View File

@ -7165,15 +7165,15 @@ _08075E00:
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _08075E56 beq _08075E56
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl MPlayStop_rev01 bl m4aMPlayStop
b _08075E56 b _08075E56
.pool .pool
_08075E4C: _08075E4C:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
bl MPlayVolumeControl bl m4aMPlayVolumeControl
_08075E56: _08075E56:
bl battle_type_is_double bl battle_type_is_double
lsls r0, 24 lsls r0, 24

View File

@ -260,9 +260,9 @@ _080A3BAA:
beq _080A3BC2 beq _080A3BC2
cmp r8, r0 cmp r8, r0
bne _080A3BA8 bne _080A3BA8
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
movs r2, 0x80 movs r2, 0x80
bl MPlayVolumeControl bl m4aMPlayVolumeControl
_080A3BC2: _080A3BC2:
ldr r0, =gUnknown_02022E24 ldr r0, =gUnknown_02022E24
movs r1, 0 movs r1, 0
@ -804,10 +804,10 @@ _080A401E:
b _080A40A2 b _080A40A2
.pool .pool
_080A4030: _080A4030:
ldr r0, =gUnknown_030075F0 ldr r0, =gMPlay_SE1
bl MPlayStop_rev01 bl m4aMPlayStop
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
bl MPlayStop_rev01 bl m4aMPlayStop
_080A403C: _080A403C:
ldr r1, =gUnknown_0203842E ldr r1, =gUnknown_0203842E
movs r0, 0 movs r0, 0
@ -841,11 +841,11 @@ _080A406E:
mov r1, r8 mov r1, r8
cmp r1, 0 cmp r1, 0
bne _080A40A2 bne _080A40A2
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
bl sub_80A4DF0 bl sub_80A4DF0
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
@ -3737,10 +3737,10 @@ ma20_wait_for_something: @ 80A586C
lsrs r0, 16 lsrs r0, 16
cmp r0, 0x5A cmp r0, 0x5A
bls _080A58BA bls _080A58BA
ldr r0, =gUnknown_030075F0 ldr r0, =gMPlay_SE1
bl MPlayStop_rev01 bl m4aMPlayStop
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
bl MPlayStop_rev01 bl m4aMPlayStop
strh r5, [r4] strh r5, [r4]
b _080A58DE b _080A58DE
.pool .pool
@ -4189,10 +4189,10 @@ _080A5C38:
thumb_func_start ma2F_stop_music thumb_func_start ma2F_stop_music
ma2F_stop_music: @ 80A5C44 ma2F_stop_music: @ 80A5C44
push {lr} push {lr}
ldr r0, =gUnknown_030075F0 ldr r0, =gMPlay_SE1
bl MPlayStop_rev01 bl m4aMPlayStop
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
bl MPlayStop_rev01 bl m4aMPlayStop
ldr r1, =gUnknown_020383F0 ldr r1, =gUnknown_020383F0
ldr r0, [r1] ldr r0, [r1]
adds r0, 0x1 adds r0, 0x1

View File

@ -1828,7 +1828,7 @@ _0817014C:
ldrb r0, [r0, 0x15] ldrb r0, [r0, 0x15]
lsls r0, 31 lsls r0, 31
lsrs r0, 31 lsrs r0, 31
bl sub_82E1810 bl SetPokemonCryStereo
ldr r0, =0x02000000 ldr r0, =0x02000000
movs r1, 0xE0 movs r1, 0xE0
lsls r1, 9 lsls r1, 9
@ -10091,11 +10091,11 @@ _081747B8:
cmp r0, 0 cmp r0, 0
beq _081747D2 beq _081747D2
bl sub_80A369C bl sub_80A369C
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
_081747D2: _081747D2:
ldr r0, =sub_8174898 ldr r0, =sub_8174898
str r0, [r4] str r0, [r4]
@ -10111,11 +10111,11 @@ _081747E4:
cmp r0, 0 cmp r0, 0
beq _08174806 beq _08174806
bl sub_80A369C bl sub_80A369C
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
_08174806: _08174806:
ldr r0, =gTasks ldr r0, =gTasks
lsls r1, r6, 2 lsls r1, r6, 2

View File

@ -1402,11 +1402,11 @@ sub_817A2C0: @ 817A2C0
bne _0817A304 bne _0817A304
bl ResetAllObjectData bl ResetAllObjectData
bl ResetObjectPaletteAllocator bl ResetObjectPaletteAllocator
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
ldr r0, =gUnknown_030022C0 ldr r0, =gUnknown_030022C0
ldr r0, [r0, 0x8] ldr r0, [r0, 0x8]
bl SetMainCallback2 bl SetMainCallback2

View File

@ -3369,16 +3369,16 @@ _081869AE:
lsrs r0, 24 lsrs r0, 24
cmp r0, 0x1 cmp r0, 0x1
bne _08186A4C bne _08186A4C
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl m4aMPlayContinue bl m4aMPlayContinue
b _08186A4C b _08186A4C
.pool .pool
_08186A40: _08186A40:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
_08186A4C: _08186A4C:
ldr r0, =gUnknown_020244D0 ldr r0, =gUnknown_020244D0
ldr r2, [r0] ldr r2, [r0]
@ -3956,11 +3956,11 @@ sub_8186F14: @ 8186F14
cmp r1, r0 cmp r1, r0
bne _08186F6E bne _08186F6E
_08186F5E: _08186F5E:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
bl sub_81871AC bl sub_81871AC
_08186F6E: _08186F6E:
pop {r4} pop {r4}
@ -9392,16 +9392,16 @@ _08189EA2:
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
bne _08189F44 bne _08189F44
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl m4aMPlayContinue bl m4aMPlayContinue
b _08189F44 b _08189F44
.pool .pool
_08189F38: _08189F38:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
_08189F44: _08189F44:
ldr r0, =gUnknown_020244D0 ldr r0, =gUnknown_020244D0
ldr r2, [r0] ldr r2, [r0]
@ -61438,11 +61438,11 @@ _081A54D4:
bl sub_8056A3C bl sub_8056A3C
movs r0, 0 movs r0, 0
bl CopyBgTilemapBufferToVram bl CopyBgTilemapBufferToVram
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
ldr r0, =0x7fffff1c ldr r0, =0x7fffff1c
movs r1, 0 movs r1, 0
str r1, [sp] str r1, [sp]

View File

@ -7976,7 +7976,7 @@ sub_81BF384: @ 81BF384
bl DisableInterrupts bl DisableInterrupts
movs r0, 0x1 movs r0, 0x1
bl EnableInterrupts bl EnableInterrupts
bl SoundVSyncOff_rev01 bl m4aSoundVSyncOff
movs r0, 0 movs r0, 0
bl SetVBlankCallback bl SetVBlankCallback
bl ResetAllObjectData bl ResetAllObjectData
@ -9827,11 +9827,11 @@ sub_81C0484: @ 81C0484
bl ResetAllObjectData bl ResetAllObjectData
bl ResetObjectPaletteAllocator bl ResetObjectPaletteAllocator
bl sub_80A369C bl sub_80A369C
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
ldr r0, =gUnknown_020244D4 ldr r0, =gUnknown_020244D4
ldr r0, [r0] ldr r0, [r0]
cmp r0, 0 cmp r0, 0

View File

@ -6815,19 +6815,19 @@ _08143BEA:
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _08143C74 beq _08143C74
ldr r0, =gUnknown_030075F0 ldr r0, =gMPlay_SE1
ldr r4, =0x0000ffff ldr r4, =0x0000ffff
ldrh r2, [r7, 0x24] ldrh r2, [r7, 0x24]
lsls r2, 24 lsls r2, 24
asrs r2, 24 asrs r2, 24
adds r1, r4, 0 adds r1, r4, 0
bl MPlayPanpotControl bl m4aMPlayPanpotControl
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
ldrh r2, [r7, 0x24] ldrh r2, [r7, 0x24]
lsls r2, 24 lsls r2, 24
asrs r2, 24 asrs r2, 24
adds r1, r4, 0 adds r1, r4, 0
bl MPlayPanpotControl bl m4aMPlayPanpotControl
_08143C74: _08143C74:
pop {r3} pop {r3}
mov r8, r3 mov r8, r3
@ -9294,17 +9294,17 @@ sub_81450D8: @ 81450D8
adds r4, r0 adds r4, r0
asrs r4, 1 asrs r4, 1
negs r4, r4 negs r4, r4
ldr r0, =gUnknown_030075F0 ldr r0, =gMPlay_SE1
ldr r5, =0x0000ffff ldr r5, =0x0000ffff
lsls r4, 24 lsls r4, 24
asrs r4, 24 asrs r4, 24
adds r1, r5, 0 adds r1, r5, 0
adds r2, r4, 0 adds r2, r4, 0
bl MPlayPanpotControl bl m4aMPlayPanpotControl
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
adds r1, r5, 0 adds r1, r5, 0
adds r2, r4, 0 adds r2, r4, 0
bl MPlayPanpotControl bl m4aMPlayPanpotControl
b _08145208 b _08145208
.pool .pool
_0814516C: _0814516C:

View File

@ -297,8 +297,8 @@ pause_music_for_sound_maybe: @ 80A3060
adds r4, r0, 0 adds r4, r0, 0
lsls r4, 24 lsls r4, 24
lsrs r4, 24 lsrs r4, 24
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl MPlayStop_rev01 bl m4aMPlayStop
ldr r0, =gUnknown_085248BC ldr r0, =gUnknown_085248BC
lsls r4, 2 lsls r4, 2
adds r4, r0 adds r4, r0
@ -330,7 +330,7 @@ ducking_tick: @ 80A3094
_080A30B0: _080A30B0:
cmp r1, 0 cmp r1, 0
bne _080A30C0 bne _080A30C0
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl m4aMPlayContinue bl m4aMPlayContinue
b _080A30C6 b _080A30C6
.pool .pool
@ -422,7 +422,7 @@ task50_overworld_fanfare: @ 80A3140
b _080A3164 b _080A3164
.pool .pool
_080A3158: _080A3158:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl m4aMPlayContinue bl m4aMPlayContinue
adds r0, r4, 0 adds r0, r4, 0
bl DestroyTask bl DestroyTask
@ -474,18 +474,18 @@ _080A31A8:
_080A31B0: _080A31B0:
adds r0, r5, 0 adds r0, r5, 0
bl m4aSongNumStart bl m4aSongNumStart
ldr r4, =gUnknown_03007420 ldr r4, =gMPlay_BGM
adds r0, r4, 0 adds r0, r4, 0
bl m4aMPlayImmInit bl m4aMPlayImmInit
adds r0, r4, 0 adds r0, r4, 0
adds r1, r6, 0 adds r1, r6, 0
movs r2, 0 movs r2, 0
bl MPlayVolumeControl bl m4aMPlayVolumeControl
adds r0, r5, 0 adds r0, r5, 0
bl m4aSongNumStop bl m4aSongNumStop
adds r0, r4, 0 adds r0, r4, 0
adds r1, r7, 0 adds r1, r7, 0
bl sub_82E0328 bl m4aMPlayFadeIn
pop {r4-r7} pop {r4-r7}
pop {r0} pop {r0}
bx r0 bx r0
@ -498,8 +498,8 @@ sub_80A31E8: @ 80A31E8
adds r1, r0, 0 adds r1, r0, 0
lsls r1, 24 lsls r1, 24
lsrs r1, 24 lsrs r1, 24
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl sub_82E0308 bl m4aMPlayFadeOutTemporarily
pop {r0} pop {r0}
bx r0 bx r0
.pool .pool
@ -508,7 +508,7 @@ sub_80A31E8: @ 80A31E8
thumb_func_start sub_80A3200 thumb_func_start sub_80A3200
sub_80A3200: @ 80A3200 sub_80A3200: @ 80A3200
push {lr} push {lr}
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, [r0, 0x4] ldr r1, [r0, 0x4]
cmp r1, 0 cmp r1, 0
blt _080A3220 blt _080A3220
@ -532,8 +532,8 @@ sub_80A3228: @ 80A3228
adds r1, r0, 0 adds r1, r0, 0
lsls r1, 24 lsls r1, 24
lsrs r1, 24 lsrs r1, 24
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl sub_82E0328 bl m4aMPlayFadeIn
pop {r0} pop {r0}
bx r0 bx r0
.pool .pool
@ -546,7 +546,7 @@ play_sound_effect: @ 80A3240
adds r1, r0, 0 adds r1, r0, 0
lsls r1, 24 lsls r1, 24
lsrs r1, 24 lsrs r1, 24
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl m4aMPlayFadeOut bl m4aMPlayFadeOut
pop {r0} pop {r0}
bx r0 bx r0
@ -556,7 +556,7 @@ play_sound_effect: @ 80A3240
thumb_func_start sub_80A3258 thumb_func_start sub_80A3258
sub_80A3258: @ 80A3258 sub_80A3258: @ 80A3258
push {lr} push {lr}
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldrh r0, [r0, 0x4] ldrh r0, [r0, 0x4]
cmp r0, 0 cmp r0, 0
beq _080A326C beq _080A326C
@ -580,10 +580,10 @@ cry_related: @ 80A3274
lsrs r5, 16 lsrs r5, 16
lsls r4, 24 lsls r4, 24
lsrs r4, 24 lsrs r4, 24
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x55 movs r2, 0x55
bl MPlayVolumeControl bl m4aMPlayVolumeControl
lsls r4, 24 lsls r4, 24
asrs r4, 24 asrs r4, 24
movs r0, 0 movs r0, 0
@ -646,10 +646,10 @@ sub_80A32E4: @ 80A32E4
bl sub_80A344C bl sub_80A344C
b _080A332E b _080A332E
_080A330A: _080A330A:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x55 movs r2, 0x55
bl MPlayVolumeControl bl m4aMPlayVolumeControl
lsls r1, r5, 24 lsls r1, r5, 24
asrs r1, 24 asrs r1, 24
str r4, [sp] str r4, [sp]
@ -698,10 +698,10 @@ _080A336E:
ands r0, r1 ands r0, r1
cmp r0, 0 cmp r0, 0
bne _080A3384 bne _080A3384
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x55 movs r2, 0x55
bl MPlayVolumeControl bl m4aMPlayVolumeControl
_080A3384: _080A3384:
lsls r1, r5, 24 lsls r1, r5, 24
asrs r1, 24 asrs r1, 24
@ -739,10 +739,10 @@ play_cry_maybe: @ 80A33A8
bl sub_80A344C bl sub_80A344C
b _080A33EE b _080A33EE
_080A33CE: _080A33CE:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x55 movs r2, 0x55
bl MPlayVolumeControl bl m4aMPlayVolumeControl
lsls r1, r5, 24 lsls r1, r5, 24
asrs r1, 24 asrs r1, 24
str r4, [sp] str r4, [sp]
@ -771,10 +771,10 @@ sub_80A3404: @ 80A3404
lsrs r5, 16 lsrs r5, 16
lsls r4, 24 lsls r4, 24
lsrs r4, 24 lsrs r4, 24
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x55 movs r2, 0x55
bl MPlayVolumeControl bl m4aMPlayVolumeControl
str r4, [sp] str r4, [sp]
adds r0, r5, 0 adds r0, r5, 0
movs r1, 0 movs r1, 0
@ -922,25 +922,25 @@ _080A3560:
ldr r4, =0x00003a98 ldr r4, =0x00003a98
_080A3562: _080A3562:
adds r0, r2, 0 adds r0, r2, 0
bl sub_82E1744 bl SetPokemonCryVolume
mov r1, r10 mov r1, r10
lsls r0, r1, 24 lsls r0, r1, 24
asrs r0, 24 asrs r0, 24
bl sub_82E1758 bl SetPokemonCryPanpot
adds r0, r4, 0 adds r0, r4, 0
bl sub_82E1770 bl SetPokemonCryPitch
adds r0, r6, 0 adds r0, r6, 0
bl sub_82E17A8 bl SetPokemonCryLength
movs r0, 0 movs r0, 0
bl sub_82E17C0 bl SetPokemonCryProgress
adds r0, r5, 0 adds r0, r5, 0
bl sub_82E17B4 bl SetPokemonCryRelease
mov r3, r8 mov r3, r8
lsls r0, r3, 24 lsls r0, r3, 24
asrs r0, 24 asrs r0, 24
bl sub_82E17E4 bl SetPokemonCryChorus
ldr r0, [sp] ldr r0, [sp]
bl sub_82E1850 bl SetPokemonCryPriority
adds r0, r7, 0 adds r0, r7, 0
bl speciesid_conv bl speciesid_conv
adds r7, r0, 0 adds r7, r0, 0
@ -1032,7 +1032,7 @@ _080A364C:
ldr r1, =gUnknown_0869EEF4 ldr r1, =gUnknown_0869EEF4
_080A3654: _080A3654:
adds r0, r1 adds r0, r1
bl sub_82E1674 bl SetPokemonCryTone
ldr r1, =gUnknown_020383E8 ldr r1, =gUnknown_020383E8
str r0, [r1] str r0, [r1]
_080A365E: _080A365E:
@ -1072,7 +1072,7 @@ sub_80A369C: @ 80A369C
push {lr} push {lr}
ldr r0, =gUnknown_020383E8 ldr r0, =gUnknown_020383E8
ldr r0, [r0] ldr r0, [r0]
bl MPlayStop_rev01 bl m4aMPlayStop
bl sub_8000964 bl sub_8000964
pop {r0} pop {r0}
bx r0 bx r0
@ -1084,7 +1084,7 @@ sub_80A36B4: @ 80A36B4
push {lr} push {lr}
ldr r0, =gUnknown_020383E8 ldr r0, =gUnknown_020383E8
ldr r0, [r0] ldr r0, [r0]
bl MPlayStop_rev01 bl m4aMPlayStop
pop {r0} pop {r0}
bx r0 bx r0
.pool .pool
@ -1095,7 +1095,7 @@ sub_80A36C8: @ 80A36C8
push {lr} push {lr}
ldr r0, =gUnknown_020383E8 ldr r0, =gUnknown_020383E8
ldr r0, [r0] ldr r0, [r0]
bl sub_82E17CC bl IsPokemonCryPlaying
cmp r0, 0 cmp r0, 0
bne _080A36E4 bne _080A36E4
bl sub_8000964 bl sub_8000964
@ -1114,7 +1114,7 @@ sub_80A36EC: @ 80A36EC
push {lr} push {lr}
ldr r0, =gUnknown_020383E8 ldr r0, =gUnknown_020383E8
ldr r0, [r0] ldr r0, [r0]
bl sub_82E17CC bl IsPokemonCryPlaying
cmp r0, 0 cmp r0, 0
bne _080A3704 bne _080A3704
movs r0, 0 movs r0, 0
@ -1143,14 +1143,14 @@ sub_80A370C: @ 80A370C
_080A3724: _080A3724:
ldr r0, =gUnknown_020383E8 ldr r0, =gUnknown_020383E8
ldr r0, [r0] ldr r0, [r0]
bl sub_82E17CC bl IsPokemonCryPlaying
cmp r0, 0 cmp r0, 0
bne _080A3742 bne _080A3742
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1
bl MPlayVolumeControl bl m4aMPlayVolumeControl
adds r0, r4, 0 adds r0, r4, 0
bl DestroyTask bl DestroyTask
_080A3742: _080A3742:
@ -1224,10 +1224,10 @@ audio_play_and_stuff: @ 80A37B4
lsls r4, 24 lsls r4, 24
lsrs r4, 24 lsrs r4, 24
bl m4aSongNumStart bl m4aSongNumStart
ldr r6, =gUnknown_030075F0 ldr r6, =gMPlay_SE1
adds r0, r6, 0 adds r0, r6, 0
bl m4aMPlayImmInit bl m4aMPlayImmInit
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
mov r8, r0 mov r8, r0
bl m4aMPlayImmInit bl m4aMPlayImmInit
ldr r5, =0x0000ffff ldr r5, =0x0000ffff
@ -1236,11 +1236,11 @@ audio_play_and_stuff: @ 80A37B4
adds r0, r6, 0 adds r0, r6, 0
adds r1, r5, 0 adds r1, r5, 0
adds r2, r4, 0 adds r2, r4, 0
bl MPlayPanpotControl bl m4aMPlayPanpotControl
mov r0, r8 mov r0, r8
adds r1, r5, 0 adds r1, r5, 0
adds r2, r4, 0 adds r2, r4, 0
bl MPlayPanpotControl bl m4aMPlayPanpotControl
pop {r3} pop {r3}
mov r8, r3 mov r8, r3
pop {r4-r6} pop {r4-r6}
@ -1258,7 +1258,7 @@ sub_80A3808: @ 80A3808
lsls r4, 24 lsls r4, 24
lsrs r4, 24 lsrs r4, 24
bl m4aSongNumStart bl m4aSongNumStart
ldr r5, =gUnknown_030075F0 ldr r5, =gMPlay_SE1
adds r0, r5, 0 adds r0, r5, 0
bl m4aMPlayImmInit bl m4aMPlayImmInit
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
@ -1266,7 +1266,7 @@ sub_80A3808: @ 80A3808
asrs r4, 24 asrs r4, 24
adds r0, r5, 0 adds r0, r5, 0
adds r2, r4, 0 adds r2, r4, 0
bl MPlayPanpotControl bl m4aMPlayPanpotControl
pop {r4,r5} pop {r4,r5}
pop {r0} pop {r0}
bx r0 bx r0
@ -1282,7 +1282,7 @@ sub_80A383C: @ 80A383C
lsls r4, 24 lsls r4, 24
lsrs r4, 24 lsrs r4, 24
bl m4aSongNumStart bl m4aSongNumStart
ldr r5, =gUnknown_03007630 ldr r5, =gMPlay_SE2
adds r0, r5, 0 adds r0, r5, 0
bl m4aMPlayImmInit bl m4aMPlayImmInit
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
@ -1290,7 +1290,7 @@ sub_80A383C: @ 80A383C
asrs r4, 24 asrs r4, 24
adds r0, r5, 0 adds r0, r5, 0
adds r2, r4, 0 adds r2, r4, 0
bl MPlayPanpotControl bl m4aMPlayPanpotControl
pop {r4,r5} pop {r4,r5}
pop {r0} pop {r0}
bx r0 bx r0
@ -1301,17 +1301,17 @@ sub_80A383C: @ 80A383C
sub_80A3870: @ 80A3870 sub_80A3870: @ 80A3870
push {r4,r5,lr} push {r4,r5,lr}
adds r4, r0, 0 adds r4, r0, 0
ldr r0, =gUnknown_030075F0 ldr r0, =gMPlay_SE1
ldr r5, =0x0000ffff ldr r5, =0x0000ffff
lsls r4, 24 lsls r4, 24
asrs r4, 24 asrs r4, 24
adds r1, r5, 0 adds r1, r5, 0
adds r2, r4, 0 adds r2, r4, 0
bl MPlayPanpotControl bl m4aMPlayPanpotControl
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
adds r1, r5, 0 adds r1, r5, 0
adds r2, r4, 0 adds r2, r4, 0
bl MPlayPanpotControl bl m4aMPlayPanpotControl
pop {r4,r5} pop {r4,r5}
pop {r0} pop {r0}
bx r0 bx r0
@ -1321,14 +1321,14 @@ sub_80A3870: @ 80A3870
thumb_func_start mplay_has_finished_maybe thumb_func_start mplay_has_finished_maybe
mplay_has_finished_maybe: @ 80A38A0 mplay_has_finished_maybe: @ 80A38A0
push {lr} push {lr}
ldr r0, =gUnknown_030075F0 ldr r0, =gMPlay_SE1
ldr r1, [r0, 0x4] ldr r1, [r0, 0x4]
movs r2, 0x80 movs r2, 0x80
lsls r2, 24 lsls r2, 24
adds r3, r0, 0 adds r3, r0, 0
cmp r1, 0 cmp r1, 0
bge _080A38BA bge _080A38BA
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
ldr r0, [r0, 0x4] ldr r0, [r0, 0x4]
ands r0, r2 ands r0, r2
cmp r0, 0 cmp r0, 0
@ -1338,7 +1338,7 @@ _080A38BA:
ldrh r0, [r3, 0x4] ldrh r0, [r3, 0x4]
cmp r0, 0 cmp r0, 0
bne _080A38DC bne _080A38DC
ldr r0, =gUnknown_03007630 ldr r0, =gMPlay_SE2
ldr r0, [r0, 0x4] ldr r0, [r0, 0x4]
ands r0, r1 ands r0, r1
cmp r0, 0 cmp r0, 0
@ -1357,7 +1357,7 @@ _080A38DE:
thumb_func_start sub_80A38E4 thumb_func_start sub_80A38E4
sub_80A38E4: @ 80A38E4 sub_80A38E4: @ 80A38E4
push {lr} push {lr}
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, [r0, 0x4] ldr r1, [r0, 0x4]
cmp r1, 0 cmp r1, 0
blt _080A3904 blt _080A3904
@ -1378,7 +1378,7 @@ _080A3906:
thumb_func_start sub_80A390C thumb_func_start sub_80A390C
sub_80A390C: @ 80A390C sub_80A390C: @ 80A390C
push {lr} push {lr}
ldr r0, =gUnknown_03007800 ldr r0, =gMPlay_SE3
ldr r1, [r0, 0x4] ldr r1, [r0, 0x4]
cmp r1, 0 cmp r1, 0
blt _080A392C blt _080A392C

View File

@ -2796,12 +2796,12 @@ _08005ABA:
strb r0, [r6, 0x9] strb r0, [r6, 0x9]
b _08005A0A b _08005A0A
_08005ABE: _08005ABE:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl MPlayStop_rev01 bl m4aMPlayStop
b _08005A0A b _08005A0A
.pool .pool
_08005ACC: _08005ACC:
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
bl m4aMPlayContinue bl m4aMPlayContinue
b _08005A0A b _08005A0A
.pool .pool

View File

@ -1169,7 +1169,7 @@ _080AAE30:
_080AAE72: _080AAE72:
ldrb r0, [r3, 0x8] ldrb r0, [r3, 0x8]
bl title_screen_update_rayquaza_ring_palette bl title_screen_update_rayquaza_ring_palette
ldr r0, =gUnknown_03007420 ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff ldr r1, =0x0000ffff
ldrh r0, [r0, 0x4] ldrh r0, [r0, 0x4]
cmp r0, 0 cmp r0, 0

12
common_syms/m4a_2.txt Normal file
View File

@ -0,0 +1,12 @@
gSoundInfo
gPokemonCrySongs
gPokemonCryMusicPlayers
gMPlay_BGM
gMPlayJumpTable
gCgbChans
gMPlay_SE1
gMPlay_SE2
gPokemonCryTracks
gPokemonCrySong
gMPlayMemAccArea
gMPlay_SE3

View File

@ -15,7 +15,20 @@
.set IWRAM_START, 0x03000000 .set IWRAM_START, 0x03000000
.set IWRAM_END, IWRAM_START + 0x8000 .set IWRAM_END, IWRAM_START + 0x8000
.set INTR_VECTOR, IWRAM_END - 0x4 .set PLTT, 0x5000000
.set BG_PLTT, PLTT
.set OBJ_PLTT, PLTT + 0x200
.set VRAM, 0x6000000
.set BG_VRAM, VRAM
.set OBJ_VRAM0, VRAM + 0x10000 @ text-mode BG
.set OBJ_VRAM1, VRAM + 0x14000 @ bitmap-mode BG
.set OAM, 0x7000000
.set SOUND_INFO_PTR, 0x3007FF0
.set INTR_CHECK, 0x3007FF8
.set INTR_VECTOR, 0x3007FFC
.set INTR_FLAG_VBLANK, 1 << 0 .set INTR_FLAG_VBLANK, 1 << 0
.set INTR_FLAG_HBLANK, 1 << 1 .set INTR_FLAG_HBLANK, 1 << 1
@ -32,6 +45,9 @@
.set INTR_FLAG_KEYPAD, 1 << 12 .set INTR_FLAG_KEYPAD, 1 << 12
.set INTR_FLAG_GAMEPAK, 1 << 13 .set INTR_FLAG_GAMEPAK, 1 << 13
.set VCOUNT_VBLANK, 160
.set TOTAL_SCANLINES, 228
.set REG_BASE, 0x4000000 @ I/O register base address .set REG_BASE, 0x4000000 @ I/O register base address
@ I/O register offsets @ I/O register offsets
@ -79,22 +95,43 @@
.set OFFSET_REG_SOUND1CNT, 0x60 .set OFFSET_REG_SOUND1CNT, 0x60
.set OFFSET_REG_SOUND1CNT_L, 0x60 .set OFFSET_REG_SOUND1CNT_L, 0x60
.set OFFSET_REG_NR10, 0x60
.set OFFSET_REG_SOUND1CNT_H, 0x62 .set OFFSET_REG_SOUND1CNT_H, 0x62
.set OFFSET_REG_NR11, 0x62
.set OFFSET_REG_NR12, 0x63
.set OFFSET_REG_SOUND1CNT_X, 0x64 .set OFFSET_REG_SOUND1CNT_X, 0x64
.set OFFSET_REG_NR13, 0x64
.set OFFSET_REG_NR14, 0x65
.set OFFSET_REG_SOUND2CNT, 0x68 .set OFFSET_REG_SOUND2CNT, 0x68
.set OFFSET_REG_SOUND2CNT_L, 0x68 .set OFFSET_REG_SOUND2CNT_L, 0x68
.set OFFSET_REG_NR21, 0x68
.set OFFSET_REG_NR22, 0x69
.set OFFSET_REG_SOUND2CNT_H, 0x6c .set OFFSET_REG_SOUND2CNT_H, 0x6c
.set OFFSET_REG_NR23, 0x6c
.set OFFSET_REG_NR24, 0x6d
.set OFFSET_REG_SOUND3CNT, 0x70 .set OFFSET_REG_SOUND3CNT, 0x70
.set OFFSET_REG_SOUND3CNT_L, 0x70 .set OFFSET_REG_SOUND3CNT_L, 0x70
.set OFFSET_REG_NR30, 0x70
.set OFFSET_REG_SOUND3CNT_H, 0x72 .set OFFSET_REG_SOUND3CNT_H, 0x72
.set OFFSET_REG_NR31, 0x72
.set OFFSET_REG_NR32, 0x73
.set OFFSET_REG_SOUND3CNT_X, 0x74 .set OFFSET_REG_SOUND3CNT_X, 0x74
.set OFFSET_REG_NR33, 0x74
.set OFFSET_REG_NR34, 0x75
.set OFFSET_REG_SOUND4CNT, 0x78 .set OFFSET_REG_SOUND4CNT, 0x78
.set OFFSET_REG_SOUND4CNT_L, 0x78 .set OFFSET_REG_SOUND4CNT_L, 0x78
.set OFFSET_REG_NR41, 0x78
.set OFFSET_REG_NR42, 0x79
.set OFFSET_REG_SOUND4CNT_H, 0x7c .set OFFSET_REG_SOUND4CNT_H, 0x7c
.set OFFSET_REG_NR43, 0x7c
.set OFFSET_REG_NR44, 0x7d
.set OFFSET_REG_SOUNDCNT, 0x80 .set OFFSET_REG_SOUNDCNT, 0x80
.set OFFSET_REG_SOUNDCNT_L, 0x80 .set OFFSET_REG_SOUNDCNT_L, 0x80
.set OFFSET_REG_NR50, 0x80
.set OFFSET_REG_NR51, 0x81
.set OFFSET_REG_SOUNDCNT_H, 0x82 .set OFFSET_REG_SOUNDCNT_H, 0x82
.set OFFSET_REG_SOUNDCNT_X, 0x84 .set OFFSET_REG_SOUNDCNT_X, 0x84
.set OFFSET_REG_NR52, 0x84
.set OFFSET_REG_SOUNDBIAS, 0x88 .set OFFSET_REG_SOUNDBIAS, 0x88
.set OFFSET_REG_WAVE_RAM, 0x90 .set OFFSET_REG_WAVE_RAM, 0x90
.set OFFSET_REG_WAVE_RAM0, 0x90 .set OFFSET_REG_WAVE_RAM0, 0x90
@ -246,22 +283,43 @@
.set REG_SOUND1CNT, REG_BASE + OFFSET_REG_SOUND1CNT .set REG_SOUND1CNT, REG_BASE + OFFSET_REG_SOUND1CNT
.set REG_SOUND1CNT_L, REG_BASE + OFFSET_REG_SOUND1CNT_L .set REG_SOUND1CNT_L, REG_BASE + OFFSET_REG_SOUND1CNT_L
.set REG_NR10, REG_BASE + OFFSET_REG_NR10
.set REG_SOUND1CNT_H, REG_BASE + OFFSET_REG_SOUND1CNT_H .set REG_SOUND1CNT_H, REG_BASE + OFFSET_REG_SOUND1CNT_H
.set REG_NR11, REG_BASE + OFFSET_REG_NR11
.set REG_NR12, REG_BASE + OFFSET_REG_NR12
.set REG_SOUND1CNT_X, REG_BASE + OFFSET_REG_SOUND1CNT_X .set REG_SOUND1CNT_X, REG_BASE + OFFSET_REG_SOUND1CNT_X
.set REG_NR13, REG_BASE + OFFSET_REG_NR13
.set REG_NR14, REG_BASE + OFFSET_REG_NR14
.set REG_SOUND2CNT, REG_BASE + OFFSET_REG_SOUND2CNT .set REG_SOUND2CNT, REG_BASE + OFFSET_REG_SOUND2CNT
.set REG_SOUND2CNT_L, REG_BASE + OFFSET_REG_SOUND2CNT_L .set REG_SOUND2CNT_L, REG_BASE + OFFSET_REG_SOUND2CNT_L
.set REG_NR21, REG_BASE + OFFSET_REG_NR21
.set REG_NR22, REG_BASE + OFFSET_REG_NR22
.set REG_SOUND2CNT_H, REG_BASE + OFFSET_REG_SOUND2CNT_H .set REG_SOUND2CNT_H, REG_BASE + OFFSET_REG_SOUND2CNT_H
.set REG_NR23, REG_BASE + OFFSET_REG_NR23
.set REG_NR24, REG_BASE + OFFSET_REG_NR24
.set REG_SOUND3CNT, REG_BASE + OFFSET_REG_SOUND3CNT .set REG_SOUND3CNT, REG_BASE + OFFSET_REG_SOUND3CNT
.set REG_SOUND3CNT_L, REG_BASE + OFFSET_REG_SOUND3CNT_L .set REG_SOUND3CNT_L, REG_BASE + OFFSET_REG_SOUND3CNT_L
.set REG_NR30, REG_BASE + OFFSET_REG_NR30
.set REG_SOUND3CNT_H, REG_BASE + OFFSET_REG_SOUND3CNT_H .set REG_SOUND3CNT_H, REG_BASE + OFFSET_REG_SOUND3CNT_H
.set REG_NR31, REG_BASE + OFFSET_REG_NR31
.set REG_NR32, REG_BASE + OFFSET_REG_NR32
.set REG_SOUND3CNT_X, REG_BASE + OFFSET_REG_SOUND3CNT_X .set REG_SOUND3CNT_X, REG_BASE + OFFSET_REG_SOUND3CNT_X
.set REG_NR33, REG_BASE + OFFSET_REG_NR33
.set REG_NR34, REG_BASE + OFFSET_REG_NR34
.set REG_SOUND4CNT, REG_BASE + OFFSET_REG_SOUND4CNT .set REG_SOUND4CNT, REG_BASE + OFFSET_REG_SOUND4CNT
.set REG_SOUND4CNT_L, REG_BASE + OFFSET_REG_SOUND4CNT_L .set REG_SOUND4CNT_L, REG_BASE + OFFSET_REG_SOUND4CNT_L
.set REG_NR41, REG_BASE + OFFSET_REG_NR41
.set REG_NR42, REG_BASE + OFFSET_REG_NR42
.set REG_SOUND4CNT_H, REG_BASE + OFFSET_REG_SOUND4CNT_H .set REG_SOUND4CNT_H, REG_BASE + OFFSET_REG_SOUND4CNT_H
.set REG_NR43, REG_BASE + OFFSET_REG_NR43
.set REG_NR44, REG_BASE + OFFSET_REG_NR44
.set REG_SOUNDCNT, REG_BASE + OFFSET_REG_SOUNDCNT .set REG_SOUNDCNT, REG_BASE + OFFSET_REG_SOUNDCNT
.set REG_SOUNDCNT_L, REG_BASE + OFFSET_REG_SOUNDCNT_L .set REG_SOUNDCNT_L, REG_BASE + OFFSET_REG_SOUNDCNT_L
.set REG_NR50, REG_BASE + OFFSET_REG_NR50
.set REG_NR51, REG_BASE + OFFSET_REG_NR51
.set REG_SOUNDCNT_H, REG_BASE + OFFSET_REG_SOUNDCNT_H .set REG_SOUNDCNT_H, REG_BASE + OFFSET_REG_SOUNDCNT_H
.set REG_SOUNDCNT_X, REG_BASE + OFFSET_REG_SOUNDCNT_X .set REG_SOUNDCNT_X, REG_BASE + OFFSET_REG_SOUNDCNT_X
.set REG_NR52, REG_BASE + OFFSET_REG_NR52
.set REG_SOUNDBIAS, REG_BASE + OFFSET_REG_SOUNDBIAS .set REG_SOUNDBIAS, REG_BASE + OFFSET_REG_SOUNDBIAS
.set REG_WAVE_RAM, REG_BASE + OFFSET_REG_WAVE_RAM .set REG_WAVE_RAM, REG_BASE + OFFSET_REG_WAVE_RAM
.set REG_WAVE_RAM0, REG_BASE + OFFSET_REG_WAVE_RAM0 .set REG_WAVE_RAM0, REG_BASE + OFFSET_REG_WAVE_RAM0
@ -368,6 +426,26 @@
.set REG_WAITCNT, REG_BASE + OFFSET_REG_WAITCNT .set REG_WAITCNT, REG_BASE + OFFSET_REG_WAITCNT
@ DMA register constants
.set DMA_DEST_INC, 0x0000
.set DMA_DEST_DEC, 0x0020
.set DMA_DEST_FIXED, 0x0040
.set DMA_DEST_RELOAD, 0x0060
.set DMA_SRC_INC, 0x0000
.set DMA_SRC_DEC, 0x0080
.set DMA_SRC_FIXED, 0x0100
.set DMA_REPEAT, 0x0200
.set DMA_16BIT, 0x0000
.set DMA_32BIT, 0x0400
.set DMA_DREQ_ON, 0x0800
.set DMA_START_NOW, 0x0000
.set DMA_START_VBLANK, 0x1000
.set DMA_START_HBLANK, 0x2000
.set DMA_START_SPECIAL, 0x3000
.set DMA_INTR_ENABLE, 0x4000
.set DMA_ENABLE, 0x8000
@ OAM attribute constants @ OAM attribute constants
.set OAM_OBJ_NORMAL, 0x00000000 .set OAM_OBJ_NORMAL, 0x00000000

199
constants/m4a_constants.inc Normal file
View File

@ -0,0 +1,199 @@
.equiv ID_NUMBER, 0x68736d53
.equiv PCM_DMA_BUF_SIZE, 1584
.equiv TONEDATA_TYPE_CGB, 0x07
.equiv TONEDATA_TYPE_FIX, 0x08
.equiv TONEDATA_TYPE_SPL, 0x40 @ key split
.equiv TONEDATA_TYPE_RHY, 0x80 @ rhythm
.macro struct_begin
.struct 0
.endm
.macro struct_field name, size
\name:
.struct \name + \size
.endm
struct_begin
struct_field o_SoundInfo_ident, 4
struct_field o_SoundInfo_pcmDmaCounter, 1
struct_field o_SoundInfo_reverb, 1
struct_field o_SoundInfo_maxChans, 1
struct_field o_SoundInfo_masterVolume, 1
struct_field o_SoundInfo_freq, 1
struct_field o_SoundInfo_mode, 1
struct_field o_SoundInfo_c15, 1
struct_field o_SoundInfo_pcmDmaPeriod, 1
struct_field o_SoundInfo_maxLines, 1
struct_field o_SoundInfo_gap, 3
struct_field o_SoundInfo_pcmSamplesPerVBlank, 4
struct_field o_SoundInfo_pcmFreq, 4
struct_field o_SoundInfo_divFreq, 4
struct_field o_SoundInfo_cgbChans, 4
struct_field o_SoundInfo_func, 4
struct_field o_SoundInfo_intp, 4
struct_field o_SoundInfo_CgbSound, 4
struct_field o_SoundInfo_CgbOscOff, 4
struct_field o_SoundInfo_MidiKeyToCgbFreq, 4
struct_field o_SoundInfo_MPlayJumpTable, 4
struct_field o_SoundInfo_plynote, 4
struct_field o_SoundInfo_ExtVolPit, 4
struct_field o_SoundInfo_gap2, 16
struct_field o_SoundInfo_chans, 768
struct_field o_SoundInfo_pcmBuffer, PCM_DMA_BUF_SIZE * 2
struct_field SoundInfo_size, 0
struct_begin
struct_field o_SoundChannel_status, 1
struct_field o_SoundChannel_type, 1
struct_field o_SoundChannel_rightVolume, 1
struct_field o_SoundChannel_leftVolume, 1
struct_field o_SoundChannel_attack, 1
struct_field o_SoundChannel_decay, 1
struct_field o_SoundChannel_sustain, 1
struct_field o_SoundChannel_release, 1
struct_field o_SoundChannel_ky, 1
struct_field o_SoundChannel_ev, 1
struct_field o_SoundChannel_er, 1
struct_field o_SoundChannel_el, 1
struct_field o_SoundChannel_iev, 1
struct_field o_SoundChannel_iel, 1
struct_field o_SoundChannel_d1, 1
struct_field o_SoundChannel_d2, 1
struct_field o_SoundChannel_gt, 1
struct_field o_SoundChannel_mk, 1
struct_field o_SoundChannel_ve, 1
struct_field o_SoundChannel_pr, 1
struct_field o_SoundChannel_rp, 1
struct_field o_SoundChannel_d3, 3
struct_field o_SoundChannel_ct, 4
struct_field o_SoundChannel_fw, 4
struct_field o_SoundChannel_freq, 4
struct_field o_SoundChannel_wav, 4
struct_field o_SoundChannel_cp, 4
struct_field o_SoundChannel_track, 4
struct_field o_SoundChannel_pp, 4
struct_field o_SoundChannel_np, 4
struct_field o_SoundChannel_d4, 4
struct_field o_SoundChannel_xpi, 2
struct_field o_SoundChannel_xpc, 2
struct_field SoundChannel_size, 0
struct_begin
struct_field o_MusicPlayerTrack_flags, 1
struct_field o_MusicPlayerTrack_wait, 1
struct_field o_MusicPlayerTrack_patternLevel, 1
struct_field o_MusicPlayerTrack_repN, 1
struct_field o_MusicPlayerTrack_gateTime, 1
struct_field o_MusicPlayerTrack_key, 1
struct_field o_MusicPlayerTrack_velocity, 1
struct_field o_MusicPlayerTrack_runningStatus, 1
struct_field o_MusicPlayerTrack_keyM, 1
struct_field o_MusicPlayerTrack_pitM, 1
struct_field o_MusicPlayerTrack_keyShift, 1
struct_field o_MusicPlayerTrack_keyShiftX, 1
struct_field o_MusicPlayerTrack_tune, 1
struct_field o_MusicPlayerTrack_pitX, 1
struct_field o_MusicPlayerTrack_bend, 1
struct_field o_MusicPlayerTrack_bendRange, 1
struct_field o_MusicPlayerTrack_volMR, 1
struct_field o_MusicPlayerTrack_volML, 1
struct_field o_MusicPlayerTrack_vol, 1
struct_field o_MusicPlayerTrack_volX, 1
struct_field o_MusicPlayerTrack_pan, 1
struct_field o_MusicPlayerTrack_panX, 1
struct_field o_MusicPlayerTrack_modM, 1
struct_field o_MusicPlayerTrack_mod, 1
struct_field o_MusicPlayerTrack_modT, 1
struct_field o_MusicPlayerTrack_lfoSpeed, 1
struct_field o_MusicPlayerTrack_lfoSpeedC, 1
struct_field o_MusicPlayerTrack_lfoDelay, 1
struct_field o_MusicPlayerTrack_lfoDelayC, 1
struct_field o_MusicPlayerTrack_priority, 1
struct_field o_MusicPlayerTrack_echoVolume, 1
struct_field o_MusicPlayerTrack_echoLength, 1
struct_field o_MusicPlayerTrack_chan, 4
struct_field o_MusicPlayerTrack_ToneData_type, 1
struct_field o_MusicPlayerTrack_ToneData_key, 1
struct_field o_MusicPlayerTrack_ToneData_length, 1
struct_field o_MusicPlayerTrack_ToneData_pan_sweep, 1
struct_field o_MusicPlayerTrack_ToneData_wav, 4
struct_field o_MusicPlayerTrack_ToneData_attack, 1
struct_field o_MusicPlayerTrack_ToneData_decay, 1
struct_field o_MusicPlayerTrack_ToneData_sustain, 1
struct_field o_MusicPlayerTrack_ToneData_release, 1
struct_field o_MusicPlayerTrack_gap, 10
struct_field o_MusicPlayerTrack_unk_3A, 2
struct_field o_MusicPlayerTrack_unk_3C, 4
struct_field o_MusicPlayerTrack_cmdPtr, 4
struct_field o_MusicPlayerTrack_patternStack, 12
struct_field MusicPlayerTrack_size, 0
.equiv o_MusicPlayerTrack_ToneData_keySplitTable, o_MusicPlayerTrack_ToneData_attack
struct_begin
struct_field o_MusicPlayerInfo_songHeader, 4
struct_field o_MusicPlayerInfo_status, 4
struct_field o_MusicPlayerInfo_trackCount, 1
struct_field o_MusicPlayerInfo_priority, 1
struct_field o_MusicPlayerInfo_cmd, 1
struct_field o_MusicPlayerInfo_unk_B, 1
struct_field o_MusicPlayerInfo_clock, 4
struct_field o_MusicPlayerInfo_gap, 8
struct_field o_MusicPlayerInfo_memAccArea, 4
struct_field o_MusicPlayerInfo_tempoD, 2
struct_field o_MusicPlayerInfo_tempoU, 2
struct_field o_MusicPlayerInfo_tempoI, 2
struct_field o_MusicPlayerInfo_tempoC, 2
struct_field o_MusicPlayerInfo_fadeOI, 2
struct_field o_MusicPlayerInfo_fadeOC, 2
struct_field o_MusicPlayerInfo_fadeOV, 2
struct_field o_MusicPlayerInfo_padding, 2
struct_field o_MusicPlayerInfo_tracks, 4
struct_field o_MusicPlayerInfo_tone, 4
struct_field o_MusicPlayerInfo_ident, 4
struct_field o_MusicPlayerInfo_func, 4
struct_field o_MusicPlayerInfo_intp, 4
struct_field MusicPlayerInfo_size, 0
struct_begin
struct_field o_CgbChannel_sf, 1
struct_field o_CgbChannel_ty, 1
struct_field o_CgbChannel_rightVolume, 1
struct_field o_CgbChannel_leftVolume, 1
struct_field o_CgbChannel_at, 1
struct_field o_CgbChannel_de, 1
struct_field o_CgbChannel_su, 1
struct_field o_CgbChannel_re, 1
struct_field o_CgbChannel_ky, 1
struct_field o_CgbChannel_ev, 1
struct_field o_CgbChannel_eg, 1
struct_field o_CgbChannel_ec, 1
struct_field o_CgbChannel_echoVolume, 1
struct_field o_CgbChannel_echoLength, 1
struct_field o_CgbChannel_d1, 1
struct_field o_CgbChannel_d2, 1
struct_field o_CgbChannel_gt, 1
struct_field o_CgbChannel_mk, 1
struct_field o_CgbChannel_ve, 1
struct_field o_CgbChannel_pr, 1
struct_field o_CgbChannel_rp, 1
struct_field o_CgbChannel_d3, 3
struct_field o_CgbChannel_d5, 1
struct_field o_CgbChannel_sg, 1
struct_field o_CgbChannel_n4, 1
struct_field o_CgbChannel_pan, 1
struct_field o_CgbChannel_panMask, 1
struct_field o_CgbChannel_mo, 1
struct_field o_CgbChannel_le, 1
struct_field o_CgbChannel_sw, 1
struct_field o_CgbChannel_fr, 4
struct_field o_CgbChannel_wp, 4
struct_field o_CgbChannel_cp, 4
struct_field o_CgbChannel_tp, 4
struct_field o_CgbChannel_pp, 4
struct_field o_CgbChannel_np, 4
struct_field o_CgbChannel_d4, 8
struct_field CgbChannel_size, 0

View File

@ -1,37 +0,0 @@
.section .rodata
gUnknown_086759E0:: @ 86759E0
.incbin "baserom.gba", 0x6759e0, 0x90
gUnknown_08675A70:: @ 8675A70
.incbin "baserom.gba", 0x675a70, 0x10
gUnknown_08675A80:: @ 8675A80
.incbin "baserom.gba", 0x675a80, 0xb4
gUnknown_08675B34:: @ 8675B34
.incbin "baserom.gba", 0x675b34, 0x30
gUnknown_08675B64:: @ 8675B64
.incbin "baserom.gba", 0x675b64, 0x18
gUnknown_08675B7C:: @ 8675B7C
.incbin "baserom.gba", 0x675b7c, 0x84
gUnknown_08675C00:: @ 8675C00
.incbin "baserom.gba", 0x675c00, 0x18
gUnknown_08675C18:: @ 8675C18
.incbin "baserom.gba", 0x675c18, 0x3c
gUnknown_08675C54:: @ 8675C54
.incbin "baserom.gba", 0x675c54, 0x10
gUnknown_08675C64:: @ 8675C64
.incbin "baserom.gba", 0x675c64, 0x34
gUnknown_08675C98:: @ 8675C98
.incbin "baserom.gba", 0x675c98, 0x34
gUnknown_08675CCC:: @ 8675CCC
.incbin "baserom.gba", 0x675ccc, 0x38

View File

@ -1,6 +1,6 @@
.section .rodata .section .rodata
gUnknown_08675D04:: @ 8675D04 voicegroup_8675D04:: @ 8675D04
.incbin "baserom.gba", 0x675D04, 0x27FF0 .incbin "baserom.gba", 0x675D04, 0x27FF0
gUnknown_0869DCF4:: @ 869DCF4 gUnknown_0869DCF4:: @ 869DCF4
@ -27,8 +27,8 @@ gUnknown_0869FB24:: @ 869FB24
gUnknown_086A0124:: @ 86A0124 gUnknown_086A0124:: @ 86A0124
.incbin "baserom.gba", 0x6a0124, 0x1489c .incbin "baserom.gba", 0x6a0124, 0x1489c
gUnknown_086B49C0:: @ 86B49C0 gMPlayTable:: @ 86B49C0
.incbin "baserom.gba", 0x6b49c0, 0x30 .incbin "baserom.gba", 0x6b49c0, 0x30
gUnknown_086B49F0:: @ 86B49F0 gSongTable:: @ 86B49F0
.incbin "baserom.gba", 0x6b49f0, 0x2ee660 .incbin "baserom.gba", 0x6b49f0, 0x2ee660

View File

@ -365,7 +365,7 @@ extern const u8 gNoiseTable[];
extern const struct PokemonCrySong gPokemonCrySongTemplate; extern const struct PokemonCrySong gPokemonCrySongTemplate;
extern const struct ToneData voicegroup_842FC88; extern const struct ToneData voicegroup_8675D04;
extern char gNumMusicPlayers[]; extern char gNumMusicPlayers[];
extern char gMaxLines[]; extern char gMaxLines[];

View File

@ -1,7 +1,7 @@
ENTRY(Start) ENTRY(Start)
gNumMusicPlayers = 4; gNumMusicPlayers = 4;
gMaxLines = 60; gMaxLines = 0;
SECTIONS { SECTIONS {
. = 0x2000000; . = 0x2000000;
@ -25,7 +25,7 @@ SECTIONS {
<BSS> <BSS>
/* .bss.code starts at 0x3001AA8 */ /* .bss.code starts at 0x3001AA8 */
. += 0x800; src/m4a_2.o(.bss.code);
/* COMMON starts at 0x30022A8 */ /* COMMON starts at 0x30022A8 */
<COMMON> <COMMON>
@ -208,7 +208,10 @@ SECTIONS {
ALIGN(4) ALIGN(4)
{ {
asm/libgcnmultiboot.o(.text); asm/libgcnmultiboot.o(.text);
asm/libmks4agb.o(.text); asm/m4a_1.o(.text);
src/m4a_2.o(.text);
asm/m4a_3.o(.text);
src/m4a_4.o(.text);
src/agb_flash.o(.text); src/agb_flash.o(.text);
src/agb_flash_1m.o(.text); src/agb_flash_1m.o(.text);
src/agb_flash_mx.o(.text); src/agb_flash_mx.o(.text);
@ -237,7 +240,7 @@ SECTIONS {
ALIGN(4) ALIGN(4)
{ {
data/data2.o(.rodata); data/data2.o(.rodata);
data/m4a_tables.o(.rodata); src/m4a_tables.o(.rodata);
data/sound_data.o(.rodata); data/sound_data.o(.rodata);
} =0 } =0

912
src/m4a_2.c Normal file
View File

@ -0,0 +1,912 @@
#include "gba/m4a_internal.h"
#define BSS_CODE __attribute__((section(".bss.code")))
BSS_CODE ALIGNED(4) char SoundMainRAM_Buffer[0x800] = {0};
struct SoundInfo gSoundInfo;
struct PokemonCrySong gPokemonCrySongs[MAX_POKEMON_CRIES];
struct MusicPlayerInfo gPokemonCryMusicPlayers[MAX_POKEMON_CRIES];
void *gMPlayJumpTable[36];
struct CgbChannel gCgbChans[4];
struct MusicPlayerTrack gPokemonCryTracks[MAX_POKEMON_CRIES * 2];
struct PokemonCrySong gPokemonCrySong;
struct MusicPlayerInfo gMPlay_BGM;
struct MusicPlayerInfo gMPlay_SE1;
struct MusicPlayerInfo gMPlay_SE2;
struct MusicPlayerInfo gMPlay_SE3;
u8 gMPlayMemAccArea[0x10];
u32 MidiKeyToFreq(struct WaveData *wav, u8 key, u8 fineAdjust)
{
u32 val1;
u32 val2;
u32 fineAdjustShifted = fineAdjust << 24;
if (key > 178)
{
key = 178;
fineAdjustShifted = 255 << 24;
}
val1 = gScaleTable[key];
val1 = gFreqTable[val1 & 0xF] >> (val1 >> 4);
val2 = gScaleTable[key + 1];
val2 = gFreqTable[val2 & 0xF] >> (val2 >> 4);
return umul3232H32(wav->freq, val1 + umul3232H32(val2 - val1, fineAdjustShifted));
}
void UnusedDummyFunc()
{
}
void MPlayContinue(struct MusicPlayerInfo *mplayInfo)
{
if (mplayInfo->ident == ID_NUMBER)
{
mplayInfo->ident++;
mplayInfo->status &= ~MUSICPLAYER_STATUS_PAUSE;
mplayInfo->ident = ID_NUMBER;
}
}
void MPlayFadeOut(struct MusicPlayerInfo *mplayInfo, u16 speed)
{
if (mplayInfo->ident == ID_NUMBER)
{
mplayInfo->ident++;
mplayInfo->fadeOC = speed;
mplayInfo->fadeOI = speed;
mplayInfo->fadeOV = (64 << FADE_VOL_SHIFT);
mplayInfo->ident = ID_NUMBER;
}
}
void m4aSoundInit(void)
{
s32 i;
CpuCopy32((void *)((s32)SoundMainRAM & ~1), SoundMainRAM_Buffer, sizeof(SoundMainRAM_Buffer));
SoundInit(&gSoundInfo);
MPlayExtender(gCgbChans);
m4aSoundMode(SOUND_MODE_DA_BIT_8
| SOUND_MODE_FREQ_13379
| (12 << SOUND_MODE_MASVOL_SHIFT)
| (5 << SOUND_MODE_MAXCHN_SHIFT));
for (i = 0; i < NUM_MUSIC_PLAYERS; i++)
{
struct MusicPlayerInfo *mplayInfo = gMPlayTable[i].info;
MPlayOpen(mplayInfo, gMPlayTable[i].track, gMPlayTable[i].unk_8);
mplayInfo->unk_B = gMPlayTable[i].unk_A;
mplayInfo->memAccArea = gMPlayMemAccArea;
}
memcpy(&gPokemonCrySong, &gPokemonCrySongTemplate, sizeof(struct PokemonCrySong));
for (i = 0; i < MAX_POKEMON_CRIES; i++)
{
struct MusicPlayerInfo *mplayInfo = &gPokemonCryMusicPlayers[i];
struct MusicPlayerTrack *track = &gPokemonCryTracks[i * 2];
MPlayOpen(mplayInfo, track, 2);
track->chan = 0;
}
}
void m4aSoundMain(void)
{
SoundMain();
}
void m4aSongNumStart(u16 n)
{
const struct MusicPlayer *mplayTable = gMPlayTable;
const struct Song *songTable = gSongTable;
const struct Song *song = &songTable[n];
const struct MusicPlayer *mplay = &mplayTable[song->ms];
MPlayStart(mplay->info, song->header);
}
void m4aSongNumStartOrChange(u16 n)
{
const struct MusicPlayer *mplayTable = gMPlayTable;
const struct Song *songTable = gSongTable;
const struct Song *song = &songTable[n];
const struct MusicPlayer *mplay = &mplayTable[song->ms];
if (mplay->info->songHeader != song->header)
{
MPlayStart(mplay->info, song->header);
}
else
{
if ((mplay->info->status & MUSICPLAYER_STATUS_TRACK) == 0
|| (mplay->info->status & MUSICPLAYER_STATUS_PAUSE))
{
MPlayStart(mplay->info, song->header);
}
}
}
void m4aSongNumStartOrContinue(u16 n)
{
const struct MusicPlayer *mplayTable = gMPlayTable;
const struct Song *songTable = gSongTable;
const struct Song *song = &songTable[n];
const struct MusicPlayer *mplay = &mplayTable[song->ms];
if (mplay->info->songHeader != song->header)
MPlayStart(mplay->info, song->header);
else if ((mplay->info->status & MUSICPLAYER_STATUS_TRACK) == 0)
MPlayStart(mplay->info, song->header);
else if (mplay->info->status & MUSICPLAYER_STATUS_PAUSE)
MPlayContinue(mplay->info);
}
void m4aSongNumStop(u16 n)
{
const struct MusicPlayer *mplayTable = gMPlayTable;
const struct Song *songTable = gSongTable;
const struct Song *song = &songTable[n];
const struct MusicPlayer *mplay = &mplayTable[song->ms];
if (mplay->info->songHeader == song->header)
m4aMPlayStop(mplay->info);
}
void m4aSongNumContinue(u16 n)
{
const struct MusicPlayer *mplayTable = gMPlayTable;
const struct Song *songTable = gSongTable;
const struct Song *song = &songTable[n];
const struct MusicPlayer *mplay = &mplayTable[song->ms];
if (mplay->info->songHeader == song->header)
MPlayContinue(mplay->info);
}
void m4aMPlayAllStop(void)
{
s32 i;
for (i = 0; i < NUM_MUSIC_PLAYERS; i++)
m4aMPlayStop(gMPlayTable[i].info);
for (i = 0; i < MAX_POKEMON_CRIES; i++)
m4aMPlayStop(&gPokemonCryMusicPlayers[i]);
}
void m4aMPlayContinue(struct MusicPlayerInfo *mplayInfo)
{
MPlayContinue(mplayInfo);
}
void m4aMPlayAllContinue(void)
{
s32 i;
for (i = 0; i < NUM_MUSIC_PLAYERS; i++)
MPlayContinue(gMPlayTable[i].info);
for (i = 0; i < MAX_POKEMON_CRIES; i++)
MPlayContinue(&gPokemonCryMusicPlayers[i]);
}
void m4aMPlayFadeOut(struct MusicPlayerInfo *mplayInfo, u16 speed)
{
MPlayFadeOut(mplayInfo, speed);
}
void m4aMPlayFadeOutTemporarily(struct MusicPlayerInfo *mplayInfo, u16 speed)
{
if (mplayInfo->ident == ID_NUMBER)
{
mplayInfo->ident++;
mplayInfo->fadeOC = speed;
mplayInfo->fadeOI = speed;
mplayInfo->fadeOV = (64 << FADE_VOL_SHIFT) | TEMPORARY_FADE;
mplayInfo->ident = ID_NUMBER;
}
}
void m4aMPlayFadeIn(struct MusicPlayerInfo *mplayInfo, u16 speed)
{
if (mplayInfo->ident == ID_NUMBER)
{
mplayInfo->ident++;
mplayInfo->fadeOC = speed;
mplayInfo->fadeOI = speed;
mplayInfo->fadeOV = (0 << FADE_VOL_SHIFT) | FADE_IN;
mplayInfo->status &= ~MUSICPLAYER_STATUS_PAUSE;
mplayInfo->ident = ID_NUMBER;
}
}
void m4aMPlayImmInit(struct MusicPlayerInfo *mplayInfo)
{
s32 trackCount = mplayInfo->trackCount;
struct MusicPlayerTrack *track = mplayInfo->tracks;
while (trackCount > 0)
{
if (track->flags & MPT_FLG_EXIST)
{
if (track->flags & MPT_FLG_START)
{
Clear64byte(track);
track->flags = MPT_FLG_EXIST;
track->bendRange = 2;
track->volX = 64;
track->lfoSpeed = 22;
track->tone.type = 1;
}
}
trackCount--;
track++;
}
}
void MPlayExtender(struct CgbChannel *cgbChans)
{
struct SoundInfo *soundInfo;
u32 ident;
REG_SOUNDCNT_X = SOUND_MASTER_ENABLE
| SOUND_4_ON
| SOUND_3_ON
| SOUND_2_ON
| SOUND_1_ON;
REG_SOUNDCNT_L = 0; // set master volume to zero
REG_NR12 = 0x8;
REG_NR22 = 0x8;
REG_NR42 = 0x8;
REG_NR14 = 0x80;
REG_NR24 = 0x80;
REG_NR44 = 0x80;
REG_NR30 = 0;
REG_NR50 = 0x77;
soundInfo = SOUND_INFO_PTR;
ident = soundInfo->ident;
if (ident != ID_NUMBER)
return;
soundInfo->ident++;
gMPlayJumpTable[8] = ply_memacc;
gMPlayJumpTable[17] = ply_lfos;
gMPlayJumpTable[19] = ply_mod;
gMPlayJumpTable[28] = ply_xcmd;
gMPlayJumpTable[29] = ply_endtie;
gMPlayJumpTable[30] = SampleFreqSet;
gMPlayJumpTable[31] = TrackStop;
gMPlayJumpTable[32] = FadeOutBody;
gMPlayJumpTable[33] = TrkVolPitSet;
soundInfo->cgbChans = (struct CgbChannel *)cgbChans;
soundInfo->CgbSound = CgbSound;
soundInfo->CgbOscOff = CgbOscOff;
soundInfo->MidiKeyToCgbFreq = MidiKeyToCgbFreq;
soundInfo->maxLines = MAX_LINES;
CpuFill32(0, cgbChans, sizeof(struct CgbChannel) * 4);
cgbChans[0].ty = 1;
cgbChans[0].panMask = 0x11;
cgbChans[1].ty = 2;
cgbChans[1].panMask = 0x22;
cgbChans[2].ty = 3;
cgbChans[2].panMask = 0x44;
cgbChans[3].ty = 4;
cgbChans[3].panMask = 0x88;
soundInfo->ident = ident;
}
void MusicPlayerJumpTableCopy(void)
{
asm("swi 0x2A");
}
void ClearChain(void *x)
{
void (*func)(void *) = *(&gMPlayJumpTable[34]);
func(x);
}
void Clear64byte(void *x)
{
void (*func)(void *) = *(&gMPlayJumpTable[35]);
func(x);
}
void SoundInit(struct SoundInfo *soundInfo)
{
soundInfo->ident = 0;
if (REG_DMA1CNT & (DMA_REPEAT << 16))
REG_DMA1CNT = ((DMA_ENABLE | DMA_START_NOW | DMA_32BIT | DMA_SRC_INC | DMA_DEST_FIXED) << 16) | 4;
if (REG_DMA2CNT & (DMA_REPEAT << 16))
REG_DMA2CNT = ((DMA_ENABLE | DMA_START_NOW | DMA_32BIT | DMA_SRC_INC | DMA_DEST_FIXED) << 16) | 4;
REG_DMA1CNT_H = DMA_32BIT;
REG_DMA2CNT_H = DMA_32BIT;
REG_SOUNDCNT_X = SOUND_MASTER_ENABLE
| SOUND_4_ON
| SOUND_3_ON
| SOUND_2_ON
| SOUND_1_ON;
REG_SOUNDCNT_H = SOUND_B_FIFO_RESET | SOUND_B_TIMER_0 | SOUND_B_LEFT_OUTPUT
| SOUND_A_FIFO_RESET | SOUND_A_TIMER_0 | SOUND_A_RIGHT_OUTPUT
| SOUND_ALL_MIX_FULL;
REG_SOUNDBIAS_H = (REG_SOUNDBIAS_H & 0x3F) | 0x40;
REG_DMA1SAD = (s32)soundInfo->pcmBuffer;
REG_DMA1DAD = (s32)&REG_FIFO_A;
REG_DMA2SAD = (s32)soundInfo->pcmBuffer + PCM_DMA_BUF_SIZE;
REG_DMA2DAD = (s32)&REG_FIFO_B;
SOUND_INFO_PTR = soundInfo;
CpuFill32(0, soundInfo, sizeof(struct SoundInfo));
soundInfo->maxChans = 8;
soundInfo->masterVolume = 15;
soundInfo->plynote = (u32)ply_note;
soundInfo->CgbSound = DummyFunc;
soundInfo->CgbOscOff = (void (*)(u8))DummyFunc;
soundInfo->MidiKeyToCgbFreq = (u32 (*)(u8, u8, u8))DummyFunc;
soundInfo->ExtVolPit = (u32)DummyFunc;
MPlayJumpTableCopy(gMPlayJumpTable);
soundInfo->MPlayJumpTable = (u32)gMPlayJumpTable;
SampleFreqSet(SOUND_MODE_FREQ_13379);
soundInfo->ident = ID_NUMBER;
}
void SampleFreqSet(u32 freq)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
freq = (freq & 0xF0000) >> 16;
soundInfo->freq = freq;
soundInfo->pcmSamplesPerVBlank = gPcmSamplesPerVBlankTable[freq - 1];
soundInfo->pcmDmaPeriod = PCM_DMA_BUF_SIZE / soundInfo->pcmSamplesPerVBlank;
// LCD refresh rate 59.7275Hz
soundInfo->pcmFreq = (597275 * soundInfo->pcmSamplesPerVBlank + 5000) / 10000;
// CPU frequency 16.78Mhz
soundInfo->divFreq = (16777216 / soundInfo->pcmFreq + 1) >> 1;
// Turn off timer 0.
REG_TM0CNT_H = 0;
// cycles per LCD fresh 280896
REG_TM0CNT_L = -(280896 / soundInfo->pcmSamplesPerVBlank);
m4aSoundVSyncOn();
while (*(vu8 *)REG_ADDR_VCOUNT == 159)
;
while (*(vu8 *)REG_ADDR_VCOUNT != 159)
;
REG_TM0CNT_H = TIMER_ENABLE | TIMER_1CLK;
}
void m4aSoundMode(u32 mode)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
u32 temp;
if (soundInfo->ident != ID_NUMBER)
return;
soundInfo->ident++;
temp = mode & (SOUND_MODE_REVERB_SET | SOUND_MODE_REVERB_VAL);
if (temp)
soundInfo->reverb = temp & SOUND_MODE_REVERB_VAL;
temp = mode & SOUND_MODE_MAXCHN;
if (temp)
{
struct SoundChannel *chan;
soundInfo->maxChans = temp >> SOUND_MODE_MAXCHN_SHIFT;
temp = MAX_DIRECTSOUND_CHANNELS;
chan = &soundInfo->chans[0];
while (temp != 0)
{
chan->status = 0;
temp--;
chan++;
}
}
temp = mode & SOUND_MODE_MASVOL;
if (temp)
soundInfo->masterVolume = temp >> SOUND_MODE_MASVOL_SHIFT;
temp = mode & SOUND_MODE_DA_BIT;
if (temp)
{
temp = (temp & 0x300000) >> 14;
REG_SOUNDBIAS_H = (REG_SOUNDBIAS_H & 0x3F) | temp;
}
temp = mode & SOUND_MODE_FREQ;
if (temp)
{
m4aSoundVSyncOff();
SampleFreqSet(temp);
}
soundInfo->ident = ID_NUMBER;
}
void SoundClear(void)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
s32 i;
void *chan;
if (soundInfo->ident != ID_NUMBER)
return;
soundInfo->ident++;
i = MAX_DIRECTSOUND_CHANNELS;
chan = &soundInfo->chans[0];
while (i > 0)
{
((struct SoundChannel *)chan)->status = 0;
i--;
chan = (void *)((s32)chan + sizeof(struct SoundChannel));
}
chan = soundInfo->cgbChans;
if (chan)
{
i = 1;
while (i <= 4)
{
soundInfo->CgbOscOff(i);
((struct CgbChannel *)chan)->sf = 0;
i++;
chan = (void *)((s32)chan + sizeof(struct CgbChannel));
}
}
soundInfo->ident = ID_NUMBER;
}
void m4aSoundVSyncOff(void)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
if (soundInfo->ident >= ID_NUMBER && soundInfo->ident <= ID_NUMBER + 1)
{
soundInfo->ident += 10;
if (REG_DMA1CNT & (DMA_REPEAT << 16))
REG_DMA1CNT = ((DMA_ENABLE | DMA_START_NOW | DMA_32BIT | DMA_SRC_INC | DMA_DEST_FIXED) << 16) | 4;
if (REG_DMA2CNT & (DMA_REPEAT << 16))
REG_DMA2CNT = ((DMA_ENABLE | DMA_START_NOW | DMA_32BIT | DMA_SRC_INC | DMA_DEST_FIXED) << 16) | 4;
REG_DMA1CNT_H = DMA_32BIT;
REG_DMA2CNT_H = DMA_32BIT;
CpuFill32(0, soundInfo->pcmBuffer, sizeof(soundInfo->pcmBuffer));
}
}
void m4aSoundVSyncOn(void)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
u32 ident = soundInfo->ident;
if (ident == ID_NUMBER)
return;
REG_DMA1CNT_H = DMA_ENABLE | DMA_START_SPECIAL | DMA_32BIT | DMA_REPEAT;
REG_DMA2CNT_H = DMA_ENABLE | DMA_START_SPECIAL | DMA_32BIT | DMA_REPEAT;
soundInfo->pcmDmaCounter = 0;
soundInfo->ident = ident - 10;
}
void MPlayOpen(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *tracks, u8 trackCount)
{
struct SoundInfo *soundInfo;
if (trackCount == 0)
return;
if (trackCount > MAX_MUSICPLAYER_TRACKS)
trackCount = MAX_MUSICPLAYER_TRACKS;
soundInfo = SOUND_INFO_PTR;
if (soundInfo->ident != ID_NUMBER)
return;
soundInfo->ident++;
Clear64byte(mplayInfo);
mplayInfo->tracks = tracks;
mplayInfo->trackCount = trackCount;
mplayInfo->status = MUSICPLAYER_STATUS_PAUSE;
while (trackCount != 0)
{
tracks->flags = 0;
trackCount--;
tracks++;
}
if (soundInfo->func != 0)
{
mplayInfo->func = soundInfo->func;
mplayInfo->intp = soundInfo->intp;
soundInfo->func = 0;
}
soundInfo->intp = (u32)mplayInfo;
soundInfo->func = (u32)MPlayMain;
soundInfo->ident = ID_NUMBER;
mplayInfo->ident = ID_NUMBER;
}
void MPlayStart(struct MusicPlayerInfo *mplayInfo, struct SongHeader *songHeader)
{
s32 i;
u8 unk_B;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
unk_B = mplayInfo->unk_B;
if (!unk_B
|| ((!mplayInfo->songHeader || !(mplayInfo->tracks[0].flags & MPT_FLG_START))
&& ((mplayInfo->status & MUSICPLAYER_STATUS_TRACK) == 0
|| (mplayInfo->status & MUSICPLAYER_STATUS_PAUSE)))
|| (mplayInfo->priority <= songHeader->priority))
{
mplayInfo->ident++;
mplayInfo->status = 0;
mplayInfo->songHeader = songHeader;
mplayInfo->tone = songHeader->tone;
mplayInfo->priority = songHeader->priority;
mplayInfo->clock = 0;
mplayInfo->tempoD = 150;
mplayInfo->tempoI = 150;
mplayInfo->tempoU = 0x100;
mplayInfo->tempoC = 0;
mplayInfo->fadeOI = 0;
i = 0;
track = mplayInfo->tracks;
while (i < songHeader->trackCount && i < mplayInfo->trackCount)
{
TrackStop(mplayInfo, track);
track->flags = MPT_FLG_EXIST | MPT_FLG_START;
track->chan = 0;
track->cmdPtr = songHeader->part[i];
i++;
track++;
}
while (i < mplayInfo->trackCount)
{
TrackStop(mplayInfo, track);
track->flags = 0;
i++;
track++;
}
if (songHeader->reverb & 0x80)
m4aSoundMode(songHeader->reverb);
mplayInfo->ident = ID_NUMBER;
}
}
void m4aMPlayStop(struct MusicPlayerInfo *mplayInfo)
{
s32 i;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
mplayInfo->ident++;
mplayInfo->status |= MUSICPLAYER_STATUS_PAUSE;
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
while (i > 0)
{
TrackStop(mplayInfo, track);
i--;
track++;
}
mplayInfo->ident = ID_NUMBER;
}
void FadeOutBody(struct MusicPlayerInfo *mplayInfo)
{
s32 i;
struct MusicPlayerTrack *track;
u16 fadeOI = mplayInfo->fadeOI;
register u32 temp asm("r3");
register u16 mask asm("r2");
if (fadeOI == 0)
return;
mplayInfo->fadeOC--;
temp = 0xFFFF;
mask = temp;
if (mplayInfo->fadeOC != 0)
return;
mplayInfo->fadeOC = fadeOI;
if (mplayInfo->fadeOV & FADE_IN)
{
mplayInfo->fadeOV += (4 << FADE_VOL_SHIFT);
if ((u16)(mplayInfo->fadeOV & mask) >= (64 << FADE_VOL_SHIFT))
{
mplayInfo->fadeOV = (64 << FADE_VOL_SHIFT);
mplayInfo->fadeOI = 0;
}
}
else
{
mplayInfo->fadeOV -= (4 << FADE_VOL_SHIFT);
if ((s16)(mplayInfo->fadeOV & mask) <= 0)
{
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
while (i > 0)
{
register u32 fadeOV asm("r7");
u32 val;
TrackStop(mplayInfo, track);
val = TEMPORARY_FADE;
fadeOV = mplayInfo->fadeOV;
val &= fadeOV;
if (!val)
track->flags = 0;
i--;
track++;
}
if (mplayInfo->fadeOV & TEMPORARY_FADE)
mplayInfo->status |= MUSICPLAYER_STATUS_PAUSE;
else
mplayInfo->status = MUSICPLAYER_STATUS_PAUSE;
mplayInfo->fadeOI = 0;
return;
}
}
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
while (i > 0)
{
if (track->flags & MPT_FLG_EXIST)
{
track->volX = (mplayInfo->fadeOV >> FADE_VOL_SHIFT);
track->flags |= MPT_FLG_VOLCHG;
}
i--;
track++;
}
}
void TrkVolPitSet(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
if (track->flags & MPT_FLG_VOLSET)
{
s32 x;
s32 y;
x = (u32)(track->vol * track->volX) >> 5;
if (track->modT == 1)
x = (u32)(x * (track->modM + 128)) >> 7;
y = 2 * track->pan + track->panX;
if (track->modT == 2)
y += track->modM;
if (y < -128)
y = -128;
else if (y > 127)
y = 127;
track->volMR = (u32)((y + 128) * x) >> 8;
track->volML = (u32)((127 - y) * x) >> 8;
}
if (track->flags & MPT_FLG_PITSET)
{
s32 bend = track->bend * track->bendRange;
register s32 x asm("r1") = track->tune;
x += bend;
x *= 4;
x += (track->keyShift << 8);
x += (track->keyShiftX << 8);
x += track->pitX;
if (track->modT == 0)
x += 16 * track->modM;
track->keyM = x >> 8;
track->pitM = x;
}
track->flags &= ~(MPT_FLG_PITSET | MPT_FLG_VOLSET);
}
u32 MidiKeyToCgbFreq(u8 chanNum, u8 key, u8 fineAdjust)
{
if (chanNum == 4)
{
if (key <= 20)
{
key = 0;
}
else
{
key -= 21;
if (key > 59)
key = 59;
}
return gNoiseTable[key];
}
else
{
s32 val1;
s32 val2;
if (key <= 35)
{
fineAdjust = 0;
key = 0;
}
else
{
key -= 36;
if (key > 130)
{
key = 130;
fineAdjust = 255;
}
}
val1 = gCgbScaleTable[key];
val1 = gCgbFreqTable[val1 & 0xF] >> (val1 >> 4);
val2 = gCgbScaleTable[key + 1];
val2 = gCgbFreqTable[val2 & 0xF] >> (val2 >> 4);
return val1 + ((fineAdjust * (val2 - val1)) >> 8) + 2048;
}
}
void CgbOscOff(u8 chanNum)
{
switch (chanNum)
{
case 1:
REG_NR12 = 8;
REG_NR14 = 0x80;
break;
case 2:
REG_NR22 = 8;
REG_NR24 = 0x80;
break;
case 3:
REG_NR30 = 0;
break;
default:
REG_NR42 = 8;
REG_NR44 = 0x80;
}
}
static inline int CgbPan(struct CgbChannel *chan)
{
u32 rightVolume = chan->rightVolume;
u32 leftVolume = chan->leftVolume;
if ((rightVolume = (u8)rightVolume) >= (leftVolume = (u8)leftVolume))
{
if (rightVolume / 2 >= leftVolume)
{
chan->pan = 0x0F;
return 1;
}
}
else
{
if (leftVolume / 2 >= rightVolume)
{
chan->pan = 0xF0;
return 1;
}
}
return 0;
}
void CgbModVol(struct CgbChannel *chan)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
if ((soundInfo->mode & 1) || !CgbPan(chan))
{
chan->pan = 0xFF;
chan->eg = (u32)(chan->rightVolume + chan->leftVolume) >> 4;
}
else
{
// Force chan->rightVolume and chan->leftVolume to be read from memory again,
// even though there is no reason to do so.
// The command line option "-fno-gcse" achieves the same result as this.
asm("" : : : "memory");
chan->eg = (u32)(chan->rightVolume + chan->leftVolume) >> 4;
if (chan->eg > 15)
chan->eg = 15;
}
chan->sg = (chan->eg * chan->su + 15) >> 4;
chan->pan &= chan->panMask;
}

545
src/m4a_4.c Normal file
View File

@ -0,0 +1,545 @@
#include "gba/m4a_internal.h"
void m4aMPlayTempoControl(struct MusicPlayerInfo *mplayInfo, u16 tempo)
{
if (mplayInfo->ident == ID_NUMBER)
{
mplayInfo->ident++;
mplayInfo->tempoU = tempo;
mplayInfo->tempoI = (mplayInfo->tempoD * mplayInfo->tempoU) >> 8;
mplayInfo->ident = ID_NUMBER;
}
}
void m4aMPlayVolumeControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u16 volume)
{
s32 i;
u32 bit;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
mplayInfo->ident++;
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
bit = 1;
while (i > 0)
{
if (trackBits & bit)
{
if (track->flags & MPT_FLG_EXIST)
{
track->volX = volume / 4;
track->flags |= MPT_FLG_VOLCHG;
}
}
i--;
track++;
bit <<= 1;
}
mplayInfo->ident = ID_NUMBER;
}
void m4aMPlayPitchControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u16 pitch)
{
s32 i;
u32 bit;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
mplayInfo->ident++;
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
bit = 1;
while (i > 0)
{
if (trackBits & bit)
{
if (track->flags & MPT_FLG_EXIST)
{
track->keyShiftX = (s16)pitch >> 8;
track->pitX = pitch;
track->flags |= MPT_FLG_PITCHG;
}
}
i--;
track++;
bit <<= 1;
}
mplayInfo->ident = ID_NUMBER;
}
void m4aMPlayPanpotControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, s8 pan)
{
s32 i;
u32 bit;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
mplayInfo->ident++;
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
bit = 1;
while (i > 0)
{
if (trackBits & bit)
{
if (track->flags & MPT_FLG_EXIST)
{
track->panX = pan;
track->flags |= MPT_FLG_VOLCHG;
}
}
i--;
track++;
bit <<= 1;
}
mplayInfo->ident = ID_NUMBER;
}
void ClearModM(struct MusicPlayerTrack *track)
{
track->lfoSpeedC = 0;
track->modM = 0;
if (track->modT == 0)
track->flags |= MPT_FLG_PITCHG;
else
track->flags |= MPT_FLG_VOLCHG;
}
void m4aMPlayModDepthSet(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u8 modDepth)
{
s32 i;
u32 bit;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
mplayInfo->ident++;
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
bit = 1;
while (i > 0)
{
if (trackBits & bit)
{
if (track->flags & MPT_FLG_EXIST)
{
track->mod = modDepth;
if (!track->mod)
ClearModM(track);
}
}
i--;
track++;
bit <<= 1;
}
mplayInfo->ident = ID_NUMBER;
}
void m4aMPlayLFOSpeedSet(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u8 lfoSpeed)
{
s32 i;
u32 bit;
struct MusicPlayerTrack *track;
if (mplayInfo->ident != ID_NUMBER)
return;
mplayInfo->ident++;
i = mplayInfo->trackCount;
track = mplayInfo->tracks;
bit = 1;
while (i > 0)
{
if (trackBits & bit)
{
if (track->flags & MPT_FLG_EXIST)
{
track->lfoSpeed = lfoSpeed;
if (!track->lfoSpeed)
ClearModM(track);
}
}
i--;
track++;
bit <<= 1;
}
mplayInfo->ident = ID_NUMBER;
}
#define MEMACC_COND_JUMP(cond) \
if (cond) \
goto cond_true; \
else \
goto cond_false; \
void ply_memacc(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
u32 op;
u8 *addr;
u8 data;
op = *track->cmdPtr;
track->cmdPtr++;
addr = mplayInfo->memAccArea + *track->cmdPtr;
track->cmdPtr++;
data = *track->cmdPtr;
track->cmdPtr++;
switch (op)
{
case 0:
*addr = data;
return;
case 1:
*addr += data;
return;
case 2:
*addr -= data;
return;
case 3:
*addr = mplayInfo->memAccArea[data];
return;
case 4:
*addr += mplayInfo->memAccArea[data];
return;
case 5:
*addr -= mplayInfo->memAccArea[data];
return;
case 6:
MEMACC_COND_JUMP(*addr == data)
return;
case 7:
MEMACC_COND_JUMP(*addr != data)
return;
case 8:
MEMACC_COND_JUMP(*addr > data)
return;
case 9:
MEMACC_COND_JUMP(*addr >= data)
return;
case 10:
MEMACC_COND_JUMP(*addr <= data)
return;
case 11:
MEMACC_COND_JUMP(*addr < data)
return;
case 12:
MEMACC_COND_JUMP(*addr == mplayInfo->memAccArea[data])
return;
case 13:
MEMACC_COND_JUMP(*addr != mplayInfo->memAccArea[data])
return;
case 14:
MEMACC_COND_JUMP(*addr > mplayInfo->memAccArea[data])
return;
case 15:
MEMACC_COND_JUMP(*addr >= mplayInfo->memAccArea[data])
return;
case 16:
MEMACC_COND_JUMP(*addr <= mplayInfo->memAccArea[data])
return;
case 17:
MEMACC_COND_JUMP(*addr < mplayInfo->memAccArea[data])
return;
default:
return;
}
cond_true:
{
void (*func)(struct MusicPlayerInfo *, struct MusicPlayerTrack *) = *(&gMPlayJumpTable[1]);
func(mplayInfo, track);
return;
}
cond_false:
track->cmdPtr += 4;
}
void ply_xcmd(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
u32 n = *track->cmdPtr;
track->cmdPtr++;
gXcmdTable[n](mplayInfo, track);
}
void ply_xxx(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
void (*func)(struct MusicPlayerInfo *, struct MusicPlayerTrack *) = *(&gMPlayJumpTable[0]);
func(mplayInfo, track);
}
#define READ_XCMD_BYTE(var, n) \
{ \
u32 byte = track->cmdPtr[(n)]; \
byte <<= n * 8; \
(var) &= ~(0xFF << (n * 8)); \
(var) |= byte; \
}
void ply_xwave(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
u32 wav;
READ_XCMD_BYTE(wav, 0) // UB: uninitialized variable
READ_XCMD_BYTE(wav, 1)
READ_XCMD_BYTE(wav, 2)
READ_XCMD_BYTE(wav, 3)
track->tone.wav = (struct WaveData *)wav;
track->cmdPtr += 4;
}
void ply_xtype(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.type = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xatta(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.attack = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xdeca(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.decay = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xsust(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.sustain = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xrele(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.release = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xiecv(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->echoVolume = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xiecl(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->echoLength = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xleng(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.length = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xswee(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
track->tone.pan_sweep = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xcmd_0C(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
u32 unk;
READ_XCMD_BYTE(unk, 0) // UB: uninitialized variable
READ_XCMD_BYTE(unk, 1)
if (track->unk_3A < (u16)unk)
{
track->unk_3A++;
track->cmdPtr -= 2;
track->wait = 1;
}
else
{
track->unk_3A = 0;
track->cmdPtr += 2;
}
}
void ply_xcmd_0D(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
u32 unk;
READ_XCMD_BYTE(unk, 0) // UB: uninitialized variable
READ_XCMD_BYTE(unk, 1)
READ_XCMD_BYTE(unk, 2)
READ_XCMD_BYTE(unk, 3)
track->unk_3C = unk;
track->cmdPtr += 4;
}
void DummyFunc(void)
{
}
struct MusicPlayerInfo *SetPokemonCryTone(struct ToneData *tone)
{
u32 maxClock = 0;
s32 maxClockIndex = 0;
s32 i;
struct MusicPlayerInfo *mplayInfo;
for (i = 0; i < MAX_POKEMON_CRIES; i++)
{
struct MusicPlayerTrack *track = &gPokemonCryTracks[i * 2];
if (!track->flags && (!track->chan || track->chan->track != track))
goto start_song;
if (maxClock < gPokemonCryMusicPlayers[i].clock)
{
maxClock = gPokemonCryMusicPlayers[i].clock;
maxClockIndex = i;
}
}
i = maxClockIndex;
start_song:
mplayInfo = &gPokemonCryMusicPlayers[i];
mplayInfo->ident++;
#define CRY ((s32)&gPokemonCrySongs + i * sizeof(struct PokemonCrySong))
#define CRY_OFS(field) offsetof(struct PokemonCrySong, field)
memcpy((void *)CRY, &gPokemonCrySong, sizeof(struct PokemonCrySong));
*(u32 *)(CRY + CRY_OFS(tone)) = (u32)tone;
*(u32 *)(CRY + CRY_OFS(part)) = CRY + CRY_OFS(part0);
*(u32 *)(CRY + CRY_OFS(part) + 4) = CRY + CRY_OFS(part1);
*(u32 *)(CRY + CRY_OFS(gotoTarget)) = CRY + CRY_OFS(cont);
#undef CRY_OFS
#undef CRY
mplayInfo->ident = ID_NUMBER;
MPlayStart(mplayInfo, (struct SongHeader *)(&gPokemonCrySongs[i]));
return mplayInfo;
}
void SetPokemonCryVolume(u8 val)
{
gPokemonCrySong.volumeValue = val & 0x7F;
}
void SetPokemonCryPanpot(s8 val)
{
gPokemonCrySong.panValue = (val + C_V) & 0x7F;
}
void SetPokemonCryPitch(s16 val)
{
s16 b = val + 0x80;
u8 a = gPokemonCrySong.tuneValue2 - gPokemonCrySong.tuneValue;
gPokemonCrySong.tieKeyValue = (b >> 8) & 0x7F;
gPokemonCrySong.tuneValue = (b >> 1) & 0x7F;
gPokemonCrySong.tuneValue2 = (a + ((b >> 1) & 0x7F)) & 0x7F;
}
void SetPokemonCryLength(u16 val)
{
gPokemonCrySong.unkCmd0CParam = val;
}
void SetPokemonCryRelease(u8 val)
{
gPokemonCrySong.releaseValue = val;
}
void SetPokemonCryProgress(u32 val)
{
gPokemonCrySong.unkCmd0DParam = val;
}
int IsPokemonCryPlaying(struct MusicPlayerInfo *mplayInfo)
{
struct MusicPlayerTrack *track = mplayInfo->tracks;
if (track->chan && track->chan->track == track)
return 1;
else
return 0;
}
void SetPokemonCryChorus(s8 val)
{
if (val)
{
gPokemonCrySong.trackCount = 2;
gPokemonCrySong.tuneValue2 = (val + gPokemonCrySong.tuneValue) & 0x7F;
}
else
{
gPokemonCrySong.trackCount = 1;
}
}
void SetPokemonCryStereo(u32 val)
{
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
if (val)
{
REG_SOUNDCNT_H = SOUND_B_TIMER_0 | SOUND_B_LEFT_OUTPUT
| SOUND_A_TIMER_0 | SOUND_A_RIGHT_OUTPUT
| SOUND_ALL_MIX_FULL;
soundInfo->mode &= ~1;
}
else
{
REG_SOUNDCNT_H = SOUND_B_TIMER_0 | SOUND_B_LEFT_OUTPUT | SOUND_B_RIGHT_OUTPUT
| SOUND_A_TIMER_0 | SOUND_A_LEFT_OUTPUT | SOUND_A_RIGHT_OUTPUT
| SOUND_B_MIX_HALF | SOUND_A_MIX_HALF | SOUND_CGB_MIX_FULL;
soundInfo->mode |= 1;
}
}
void SetPokemonCryPriority(u8 val)
{
gPokemonCrySong.priority = val;
}

307
src/m4a_tables.c Normal file
View File

@ -0,0 +1,307 @@
#include "gba/m4a_internal.h"
// Some of these functions have different signatures, so we need to make this
// an array of void pointers or a struct. It's simpler to just make it an array
// for now.
void * const gMPlayJumpTableTemplate[] =
{
ply_fine,
ply_goto,
ply_patt,
ply_pend,
ply_rept,
ply_fine,
ply_fine,
ply_fine,
ply_fine,
ply_prio,
ply_tempo,
ply_keysh,
ply_voice,
ply_vol,
ply_pan,
ply_bend,
ply_bendr,
ply_lfos,
ply_lfodl,
ply_mod,
ply_modt,
ply_fine,
ply_fine,
ply_tune,
ply_fine,
ply_fine,
ply_fine,
ply_port,
ply_fine,
ply_endtie,
SampleFreqSet,
TrackStop,
FadeOutBody,
TrkVolPitSet,
RealClearChain,
SoundMainBTM,
};
// This is a table of deltas between sample values in compressed PCM data.
const s8 gDeltaEncodingTable[] =
{
0,
1,
4,
9,
16,
25,
36,
49,
-64,
-49,
-36,
-25,
-16,
-9,
-4,
-1,
};
const u8 gScaleTable[] =
{
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
};
const u32 gFreqTable[] =
{
2147483648u,
2275179671u,
2410468894u,
2553802834u,
2705659852u,
2866546760u,
3037000500u,
3217589947u,
3408917802u,
3611622603u,
3826380858u,
4053909305u,
};
const u16 gPcmSamplesPerVBlankTable[] =
{
96,
132,
176,
224,
264,
304,
352,
448,
528,
608,
672,
704,
};
const u8 gCgbScaleTable[] =
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB,
};
const s16 gCgbFreqTable[] =
{
-2004,
-1891,
-1785,
-1685,
-1591,
-1501,
-1417,
-1337,
-1262,
-1192,
-1125,
-1062,
};
const u8 gNoiseTable[] =
{
0xD7, 0xD6, 0xD5, 0xD4,
0xC7, 0xC6, 0xC5, 0xC4,
0xB7, 0xB6, 0xB5, 0xB4,
0xA7, 0xA6, 0xA5, 0xA4,
0x97, 0x96, 0x95, 0x94,
0x87, 0x86, 0x85, 0x84,
0x77, 0x76, 0x75, 0x74,
0x67, 0x66, 0x65, 0x64,
0x57, 0x56, 0x55, 0x54,
0x47, 0x46, 0x45, 0x44,
0x37, 0x36, 0x35, 0x34,
0x27, 0x26, 0x25, 0x24,
0x17, 0x16, 0x15, 0x14,
0x07, 0x06, 0x05, 0x04,
0x03, 0x02, 0x01, 0x00,
};
const u8 gCgb3Vol[] =
{
0x00, 0x00,
0x60, 0x60, 0x60, 0x60,
0x40, 0x40, 0x40, 0x40,
0x80, 0x80, 0x80, 0x80,
0x20, 0x20,
};
const u8 gClockTable[] =
{
0x00,
0x01,
0x02,
0x03,
0x04,
0x05,
0x06,
0x07,
0x08,
0x09,
0x0A,
0x0B,
0x0C,
0x0D,
0x0E,
0x0F,
0x10,
0x11,
0x12,
0x13,
0x14,
0x15,
0x16,
0x17,
0x18,
0x1C,
0x1E,
0x20,
0x24,
0x28,
0x2A,
0x2C,
0x30,
0x34,
0x36,
0x38,
0x3C,
0x40,
0x42,
0x44,
0x48,
0x4C,
0x4E,
0x50,
0x54,
0x58,
0x5A,
0x5C,
0x60,
};
#define FINE 0xb1
#define GOTO 0xb2
#define PATT 0xb3
#define PEND 0xb4
#define REPT 0xb5
#define MEMACC 0xb9
#define PRIO 0xba
#define TEMPO 0xbb
#define KEYSH 0xbc
#define VOICE 0xbd
#define VOL 0xbe
#define PAN 0xbf
#define BEND 0xc0
#define BENDR 0xc1
#define LFOS 0xc2
#define LFODL 0xc3
#define MOD 0xc4
#define MODT 0xc5
#define TUNE 0xc8
#define XCMD 0xcd
#define xRELE 0x07
#define xIECV 0x08
#define xIECL 0x09
#define EOT 0xce
#define TIE 0xcf
const struct PokemonCrySong gPokemonCrySongTemplate =
{
1, // track count
0, // block count
255, // priority
0, // reverb
(struct ToneData *)&voicegroup_8675D04,
NULL,
NULL,
0,
TUNE, // part 0
C_V, // TUNE value
GOTO,
0, // GOTO target address
TUNE, // part 1
C_V + 16, // TUNE value
{VOICE, 0}, // part 0 jumps here with GOTO
VOL,
127, // volume
{XCMD, 0x0D},
0, // unk value
{XCMD, xRELE},
0, // release
PAN,
C_V, // PAN value
TIE,
60, // TIE key (default is Cn3)
127, // TIE velocity
{XCMD, 0x0C},
60, // unk value
{EOT, FINE} // end
};
const XcmdFunc gXcmdTable[] =
{
ply_xxx,
ply_xwave,
ply_xtype,
ply_xxx,
ply_xatta,
ply_xdeca,
ply_xsust,
ply_xrele,
ply_xiecv,
ply_xiecl,
ply_xleng,
ply_xswee,
ply_xcmd_0C,
ply_xcmd_0D,
};

View File

@ -500,53 +500,7 @@ gUnknown_03006328: @ 3006328
gUnknown_03006370: @ 3006370 gUnknown_03006370: @ 3006370
.space 0x10 .space 0x10
gUnknown_03006380: @ 3006380 .include "m4a_2.o"
.space 0x350
gUnknown_030066D0: @ 30066D0
.space 0xC60
gUnknown_03007330: @ 3007330
.space 0x70
gUnknown_030073A0: @ 30073A0
.space 0x80
gUnknown_03007420: @ 3007420
.space 0x40
gUnknown_03007460: @ 3007460
.space 0x4
gUnknown_03007464: @ 3007464
.space 0x84
gUnknown_030074E8: @ 30074E8
.space 0x4
gUnknown_030074EC: @ 30074EC
.space 0x4
gUnknown_030074F0: @ 30074F0
.space 0x100
gUnknown_030075F0: @ 30075F0
.space 0x40
gUnknown_03007630: @ 3007630
.space 0x40
gUnknown_03007670: @ 3007670
.space 0x140
gUnknown_030077B0: @ 30077B0
.space 0x40
gUnknown_030077F0: @ 30077F0
.space 0x10
gUnknown_03007800: @ 3007800
.space 0x40
.include "agb_flash.o" .include "agb_flash.o"