From 69c734c9a8b7fbc405d0d6e81bf7e2bcf783883d Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Tue, 1 Nov 2016 22:03:16 -0500 Subject: [PATCH] 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 --- asm/berry_blender.s | 20 +- asm/contest.s | 4 +- asm/egg_hatch.s | 2 +- asm/intro.s | 2 +- asm/libmks4agb.s | 5292 ----------------------------------- asm/link.s | 14 +- asm/m4a_1.s | 1909 +++++++++++++ asm/m4a_3.s | 574 ++++ asm/main.s | 8 +- asm/mauville_old_man.s | 20 +- asm/option_menu.s | 2 +- asm/pokedex.s | 18 +- asm/pokedex_cry_screen.s | 6 +- asm/rom_8034C54.s | 58 +- asm/rom_8072304.s | 8 +- asm/rom_80A3934.s | 32 +- asm/rom_816F318.s | 10 +- asm/rom_81795E8.s | 4 +- asm/rom_8184DA4.s | 20 +- asm/rom_81BAD84.s | 6 +- asm/roulette.s | 16 +- asm/sound.s | 114 +- asm/text.s | 6 +- asm/title_screen.s | 2 +- common_syms/m4a_2.txt | 12 + constants/gba_constants.inc | 80 +- constants/m4a_constants.inc | 199 ++ data/m4a_tables.s | 37 - data/sound_data.s | 6 +- include/gba/m4a_internal.h | 2 +- ld_script.txt | 11 +- src/m4a_2.c | 912 ++++++ src/m4a_4.c | 545 ++++ src/m4a_tables.c | 307 ++ sym_common.txt | 48 +- 35 files changed, 4735 insertions(+), 5571 deletions(-) delete mode 100644 asm/libmks4agb.s create mode 100644 asm/m4a_1.s create mode 100644 asm/m4a_3.s create mode 100644 common_syms/m4a_2.txt create mode 100644 constants/m4a_constants.inc delete mode 100644 data/m4a_tables.s create mode 100644 src/m4a_2.c create mode 100644 src/m4a_4.c create mode 100644 src/m4a_tables.c diff --git a/asm/berry_blender.s b/asm/berry_blender.s index db6378c6a5..3dcd0e3cb1 100644 --- a/asm/berry_blender.s +++ b/asm/berry_blender.s @@ -8,7 +8,7 @@ thumb_func_start sub_807F738 sub_807F738: @ 807F738 push {lr} - ldr r0, =gUnknown_03007630 + ldr r0, =gMPlay_SE2 ldr r1, =0x0000ffff ldr r2, =gUnknown_020322A4 ldr r2, [r2] @@ -18,7 +18,7 @@ sub_807F738: @ 807F738 subs r2, 0x80 lsls r2, 17 asrs r2, 16 - bl MPlayPitchControl + bl m4aMPlayPitchControl pop {r0} bx r0 .pool @@ -3564,15 +3564,15 @@ _08081678: adds r1, r0 lsls r1, 16 lsrs r1, 16 - ldr r0, =gUnknown_03007420 - bl MPlayTempoControl + ldr r0, =gMPlay_BGM + bl m4aMPlayTempoControl b _080816D2 .pool _080816C8: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM movs r1, 0x80 lsls r1, 1 - bl MPlayTempoControl + bl m4aMPlayTempoControl _080816D2: ldr r1, [sp] adds r1, 0x2 @@ -4768,10 +4768,10 @@ _08082004: .4byte _08082430 .4byte _0808246C _08082038: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM movs r1, 0x80 lsls r1, 1 - bl MPlayTempoControl + bl m4aMPlayTempoControl movs r4, 0 b _08082064 .pool @@ -4829,8 +4829,8 @@ _080820B6: ldr r1, [r0] movs r0, 0 strb r0, [r1] - ldr r0, =gUnknown_03007630 - bl MPlayStop_rev01 + ldr r0, =gMPlay_SE2 + bl m4aMPlayStop _080820C6: bl sub_807F738 b _0808249E diff --git a/asm/contest.s b/asm/contest.s index 4ec37314e7..fd6f47cb3a 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -8891,7 +8891,7 @@ _080DC226: ble _080DC284 movs r0, 0x60 bl audio_play - ldr r4, =gUnknown_030075F0 + ldr r4, =gMPlay_SE1 adds r0, r4, 0 bl m4aMPlayImmInit ldr r1, =0x0000ffff @@ -8899,7 +8899,7 @@ _080DC226: lsls r2, r0, 24 asrs r2, 16 adds r0, r4, 0 - bl MPlayPitchControl + bl m4aMPlayPitchControl b _080DC28A .pool _080DC284: diff --git a/asm/egg_hatch.s b/asm/egg_hatch.s index 69ba8fef02..8f675adb79 100644 --- a/asm/egg_hatch.s +++ b/asm/egg_hatch.s @@ -602,7 +602,7 @@ _080717EC: bl ResetAllObjectData bl ResetTasks bl remove_some_task - bl SoundVSyncOn_rev01 + bl m4aSoundVSyncOn b _080719A6 .pool _080718B8: diff --git a/asm/intro.s b/asm/intro.s index 3d9d129459..41e9547fc5 100644 --- a/asm/intro.s +++ b/asm/intro.s @@ -326,7 +326,7 @@ _0816CEE2: ldrb r0, [r0, 0x15] lsls r0, 31 lsrs r0, 31 - bl sub_82E1810 + bl SetPokemonCryStereo ldr r0, =0x02000000 movs r1, 0xE0 lsls r1, 9 diff --git a/asm/libmks4agb.s b/asm/libmks4agb.s deleted file mode 100644 index a5d10f639e..0000000000 --- a/asm/libmks4agb.s +++ /dev/null @@ -1,5292 +0,0 @@ - .include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start umul3232H32 -umul3232H32: @ 82DF04C - adr r2, _082DF050 - bx r2 - .arm -_082DF050: - umull r2, r3, r0, r1 - add r0, r3, 0 - bx lr - thumb_func_end umul3232H32 - - thumb_func_start SoundMain -SoundMain: @ 82DF05C - ldr r0, _082DF0C8 - ldr r0, [r0] - ldr r2, _082DF0CC - ldr r3, [r0] - cmp r2, r3 - beq _082DF06A - bx lr -_082DF06A: - adds r3, 0x1 - str r3, [r0] - push {r4-r7,lr} - mov r1, r8 - mov r2, r9 - mov r3, r10 - mov r4, r11 - push {r0-r4} - sub sp, 0x18 - ldrb r1, [r0, 0xC] - cmp r1, 0 - beq _082DF08E - ldr r2, _082DF0D4 - ldrb r2, [r2] - cmp r2, 0xA0 - bcs _082DF08C - adds r2, 0xE4 -_082DF08C: - adds r1, r2 -_082DF08E: - str r1, [sp, 0x14] - ldr r3, [r0, 0x20] - cmp r3, 0 - beq _082DF09E - ldr r0, [r0, 0x24] - bl _082DF496 - ldr r0, [sp, 0x18] -_082DF09E: - ldr r3, [r0, 0x28] - bl _082DF496 - ldr r0, [sp, 0x18] - ldr r3, [r0, 0x10] - mov r8, r3 - ldr r5, _082DF0D8 - adds r5, r0 - ldrb r4, [r0, 0x4] - subs r7, r4, 0x1 - bls _082DF0BE - ldrb r1, [r0, 0xB] - subs r1, r7 - mov r2, r8 - muls r2, r1 - adds r5, r2 -_082DF0BE: - str r5, [sp, 0x8] - ldr r6, _082DF0DC - ldr r3, _082DF0D0 - bx r3 - .align 2, 0 -_082DF0C8: .4byte gUnknown_03007FF0 -_082DF0CC: .4byte 0x68736d53 -_082DF0D0: .4byte 0x03001aa9 -_082DF0D4: .4byte 0x04000006 -_082DF0D8: .4byte 0x00000350 -_082DF0DC: .4byte 0x00000630 - thumb_func_end SoundMain - - thumb_func_start SoundMainRAM -SoundMainRAM: @ 82DF0E0 - ldrb r3, [r0, 0x5] - cmp r3, 0 - beq _082DF140 - adr r1, _082DF0EC - bx r1 - .arm -_082DF0EC: - cmp r4, 0x2 - addeq r7, r0, 0x350 - addne r7, r5, r8 - mov r4, r8 -_082DF0FC: - ldrsb r0, [r5, r6] - ldrsb r1, [r5] - add r0, r0, r1 - ldrsb r1, [r7, r6] - add r0, r0, r1 - ldrsb r1, [r7], 0x1 - add r0, r0, r1 - mul r1, r0, r3 - mov r0, r1, asr 9 - tst r0, 0x80 - addne r0, r0, 0x1 - strb r0, [r5, r6] - strb r0, [r5], 0x1 - subs r4, r4, 0x1 - bgt _082DF0FC - add r0, pc, 0x2F - bx r0 - .thumb -_082DF140: - movs r0, 0 - mov r1, r8 - adds r6, r5 - lsrs r1, 3 - bcc _082DF14E - stm r5!, {r0} - stm r6!, {r0} -_082DF14E: - lsrs r1, 1 - bcc _082DF15A - stm r5!, {r0} - stm r6!, {r0} - stm r5!, {r0} - stm r6!, {r0} -_082DF15A: - stm r5!, {r0} - stm r6!, {r0} - stm r5!, {r0} - stm r6!, {r0} - stm r5!, {r0} - stm r6!, {r0} - stm r5!, {r0} - stm r6!, {r0} - subs r1, 0x1 - bgt _082DF15A - ldr r4, [sp, 0x18] - ldr r0, [r4, 0x18] - mov r12, r0 - ldrb r0, [r4, 0x6] - adds r4, 0x50 -_082DF178: - str r0, [sp, 0x4] - ldr r3, [r4, 0x24] - ldr r0, [sp, 0x14] - cmp r0, 0 - beq _082DF198 - ldr r1, _082DF194 - ldrb r1, [r1] - cmp r1, 0xA0 - bcs _082DF18C - adds r1, 0xE4 -_082DF18C: - cmp r1, r0 - bcc _082DF198 - b _082DF482 - .align 2, 0 -_082DF194: .4byte 0x04000006 -_082DF198: - ldrb r6, [r4] - movs r0, 0xC7 - tst r0, r6 - bne _082DF1A2 - b _082DF478 -_082DF1A2: - movs r0, 0x80 - tst r0, r6 - beq _082DF1D8 - movs r0, 0x40 - tst r0, r6 - bne _082DF1E8 - movs r6, 0x3 - strb r6, [r4] - adds r0, r3, 0 - adds r0, 0x10 - ldr r1, [r4, 0x18] - adds r0, r1 - str r0, [r4, 0x28] - ldr r0, [r3, 0xC] - subs r0, r1 - str r0, [r4, 0x18] - movs r5, 0 - strb r5, [r4, 0x9] - str r5, [r4, 0x1C] - ldrb r2, [r3, 0x3] - movs r0, 0xC0 - tst r0, r2 - beq _082DF230 - movs r0, 0x10 - orrs r6, r0 - strb r6, [r4] - b _082DF230 -_082DF1D8: - ldrb r5, [r4, 0x9] - movs r0, 0x4 - tst r0, r6 - beq _082DF1EE - ldrb r0, [r4, 0xD] - subs r0, 0x1 - strb r0, [r4, 0xD] - bhi _082DF23E -_082DF1E8: - movs r0, 0 - strb r0, [r4] - b _082DF478 -_082DF1EE: - movs r0, 0x40 - tst r0, r6 - beq _082DF20E - ldrb r0, [r4, 0x7] - muls r5, r0 - lsrs r5, 8 - ldrb r0, [r4, 0xC] - cmp r5, r0 - bhi _082DF23E -_082DF200: - ldrb r5, [r4, 0xC] - cmp r5, 0 - beq _082DF1E8 - movs r0, 0x4 - orrs r6, r0 - strb r6, [r4] - b _082DF23E -_082DF20E: - movs r2, 0x3 - ands r2, r6 - cmp r2, 0x2 - bne _082DF22C - ldrb r0, [r4, 0x5] - muls r5, r0 - lsrs r5, 8 - ldrb r0, [r4, 0x6] - cmp r5, r0 - bhi _082DF23E - adds r5, r0, 0 - beq _082DF200 - subs r6, 0x1 - strb r6, [r4] - b _082DF23E -_082DF22C: - cmp r2, 0x3 - bne _082DF23E -_082DF230: - ldrb r0, [r4, 0x4] - adds r5, r0 - cmp r5, 0xFF - bcc _082DF23E - movs r5, 0xFF - subs r6, 0x1 - strb r6, [r4] -_082DF23E: - strb r5, [r4, 0x9] - ldr r0, [sp, 0x18] - ldrb r0, [r0, 0x7] - adds r0, 0x1 - muls r0, r5 - lsrs r5, r0, 4 - ldrb r0, [r4, 0x2] - muls r0, r5 - lsrs r0, 8 - strb r0, [r4, 0xA] - ldrb r0, [r4, 0x3] - muls r0, r5 - lsrs r0, 8 - strb r0, [r4, 0xB] - movs r0, 0x10 - ands r0, r6 - str r0, [sp, 0x10] - beq _082DF272 - adds r0, r3, 0 - adds r0, 0x10 - ldr r1, [r3, 0x8] - adds r0, r1 - str r0, [sp, 0xC] - ldr r0, [r3, 0xC] - subs r0, r1 - str r0, [sp, 0x10] -_082DF272: - ldr r5, [sp, 0x8] - ldr r2, [r4, 0x18] - ldr r3, [r4, 0x28] - adr r0, _082DF27C - bx r0 - .arm -_082DF27C: - str r8, [sp] - ldr r9, [r4, 0x1C] - ldrb r10, [r4, 0xA] - ldrb r11, [r4, 0xB] - ldrb r0, [r4, 0x1] - tst r0, 0x30 - beq _082DF2A0 - bl sub_82DF49C - b _082DF460 -_082DF2A0: - mov r10, r10, lsl 16 - mov r11, r11, lsl 16 - ldrb r0, [r4, 0x1] - tst r0, 0x8 - beq _082DF3D4 -_082DF2B4: - cmp r2, 0x4 - ble _082DF324 - subs r2, r2, r8 - movgt r9, 0 - bgt _082DF2E0 - mov r9, r8 - add r2, r2, r8 - sub r8, r2, 0x4 - sub r9, r9, r8 - ands r2, r2, 0x3 - moveq r2, 0x4 -_082DF2E0: - ldr r6, [r5] - ldr r7, [r5, 0x630] -_082DF2E8: - ldrsb r0, [r3], 0x1 - mul r1, r10, r0 - bic r1, r1, 0xFF0000 - add r6, r1, r6, ror 8 - mul r1, r11, r0 - bic r1, r1, 0xFF0000 - add r7, r1, r7, ror 8 - adds r5, r5, 0x40000000 - bcc _082DF2E8 - str r7, [r5, 0x630] - str r6, [r5], 0x4 - subs r8, r8, 0x4 - bgt _082DF2E0 - adds r8, r8, r9 - beq _082DF464 -_082DF324: - ldr r6, [r5] - ldr r7, [r5, 0x630] -_082DF32C: - ldrsb r0, [r3], 0x1 - mul r1, r10, r0 - bic r1, r1, 0xFF0000 - add r6, r1, r6, ror 8 - mul r1, r11, r0 - bic r1, r1, 0xFF0000 - add r7, r1, r7, ror 8 - subs r2, r2, 0x1 - beq _082DF39C -_082DF350: - adds r5, r5, 0x40000000 - bcc _082DF32C - str r7, [r5, 0x630] - str r6, [r5], 0x4 - subs r8, r8, 0x4 - bgt _082DF2B4 - b _082DF464 -_082DF36C: - ldr r0, [sp, 0x18] - cmp r0, 0 - beq _082DF390 - ldr r3, [sp, 0x14] - rsb lr, r2, 0 -_082DF380: - adds r2, r0, r2 - bgt _082DF434 - sub lr, lr, r0 - b _082DF380 -_082DF390: - ldmia sp!, {r4,r12} - mov r2, 0 - b _082DF3AC -_082DF39C: - ldr r2, [sp, 0x10] - cmp r2, 0 - ldrne r3, [sp, 0xC] - bne _082DF350 -_082DF3AC: - strb r2, [r4] - mov r0, r5, lsr 30 - bic r5, r5, 0xC0000000 - rsb r0, r0, 0x3 - mov r0, r0, lsl 3 - mov r6, r6, ror r0 - mov r7, r7, ror r0 - str r7, [r5, 0x630] - str r6, [r5], 0x4 - b _082DF46C -_082DF3D4: - stmdb sp!, {r4,r12} - ldr r1, [r4, 0x20] - mul r4, r12, r1 - ldrsb r0, [r3] - ldrsb r1, [r3, 0x1]! - sub r1, r1, r0 -_082DF3EC: - ldr r6, [r5] - ldr r7, [r5, 0x630] -_082DF3F4: - mul lr, r9, r1 - add lr, r0, lr, asr 23 - mul r12, r10, lr - bic r12, r12, 0xFF0000 - add r6, r12, r6, ror 8 - mul r12, r11, lr - bic r12, r12, 0xFF0000 - add r7, r12, r7, ror 8 - add r9, r9, r4 - movs lr, r9, lsr 23 - beq _082DF440 - bic r9, r9, 0x3F800000 - subs r2, r2, lr - ble _082DF36C - subs lr, lr, 0x1 - addeq r0, r0, r1 -_082DF434: - ldrsbne r0, [r3, lr]! - ldrsb r1, [r3, 0x1]! - sub r1, r1, r0 -_082DF440: - adds r5, r5, 0x40000000 - bcc _082DF3F4 - str r7, [r5, 0x630] - str r6, [r5], 0x4 - subs r8, r8, 0x4 - bgt _082DF3EC - sub r3, r3, 0x1 - ldmia sp!, {r4,r12} -_082DF460: - str r9, [r4, 0x1C] -_082DF464: - str r2, [r4, 0x18] - str r3, [r4, 0x28] -_082DF46C: - ldr r8, [sp] - add r0, pc, 0x1 - bx r0 - .thumb -_082DF478: - ldr r0, [sp, 0x4] - subs r0, 0x1 - ble _082DF482 - adds r4, 0x40 - b _082DF178 -_082DF482: - ldr r0, [sp, 0x18] - ldr r3, _082DF498 - str r3, [r0] - add sp, 0x1C - pop {r0-r7} - mov r8, r0 - mov r9, r1 - mov r10, r2 - mov r11, r3 - pop {r3} -_082DF496: - bx r3 - .align 2, 0 -_082DF498: .4byte 0x68736d53 - thumb_func_end SoundMainRAM - - arm_func_start sub_82DF49C -sub_82DF49C: @ 82DF49C - ldr r6, [r4, 0x24] - ldrb r0, [r4] - tst r0, 0x20 - bne _082DF4EC - orr r0, r0, 0x20 - strb r0, [r4] - ldrb r0, [r4, 0x1] - tst r0, 0x10 - beq _082DF4D4 - ldr r1, [r6, 0xC] - add r1, r1, r6, lsl 1 - add r1, r1, 0x20 - sub r3, r1, r3 - str r3, [r4, 0x28] -_082DF4D4: - ldrh r0, [r6] - cmp r0, 0 - beq _082DF4EC - sub r3, r3, r6 - sub r3, r3, 0x10 - str r3, [r4, 0x28] -_082DF4EC: - stmdb sp!, {r8,r12,lr} - mov r10, r10, lsl 16 - mov r11, r11, lsl 16 - ldr r1, [r4, 0x20] - ldrb r0, [r4, 0x1] - tst r0, 0x8 - movne r8, 0x800000 - muleq r8, r12, r1 - ldrh r0, [r6] - cmp r0, 0 - beq _082DF6A0 - mov r0, 0xFF000000 - str r0, [r4, 0x3C] - ldrb r0, [r4, 0x1] - tst r0, 0x10 - bne _082DF5F8 - bl sub_82DF758 - mov r0, r1 - add r3, r3, 0x1 - bl sub_82DF758 - sub r1, r1, r0 -_082DF540: - ldr r6, [r5] - ldr r7, [r5, 0x630] -_082DF548: - mul lr, r9, r1 - add lr, r0, lr, asr 23 - mul r12, r10, lr - bic r12, r12, 0xFF0000 - add r6, r12, r6, ror 8 - mul r12, r11, lr - bic r12, r12, 0xFF0000 - add r7, r12, r7, ror 8 - add r9, r9, r8 - movs lr, r9, lsr 23 - beq _082DF5A8 - bic r9, r9, 0x3F800000 - subs r2, r2, lr - ble _082DF5D0 - subs lr, lr, 0x1 - bne _082DF590 - add r0, r0, r1 - b _082DF59C -_082DF590: - add r3, r3, lr - bl sub_82DF758 - mov r0, r1 -_082DF59C: - add r3, r3, 0x1 - bl sub_82DF758 - sub r1, r1, r0 -_082DF5A8: - adds r5, r5, 0x40000000 - bcc _082DF548 - str r7, [r5, 0x630] - str r6, [r5], 0x4 - ldr r6, [sp] - subs r6, r6, 0x4 - str r6, [sp] - bgt _082DF540 - sub r3, r3, 0x1 - b _082DF728 -_082DF5D0: - ldr r0, [sp, 0x1C] - cmp r0, 0 - beq _082DF72C - ldr r3, [r4, 0x24] - ldr r3, [r3, 0x8] - rsb lr, r2, 0 -_082DF5E8: - adds r2, r2, r0 - bgt _082DF590 - sub lr, lr, r0 - b _082DF5E8 -_082DF5F8: - sub r3, r3, 0x1 - bl sub_82DF758 - mov r0, r1 - sub r3, r3, 0x1 - bl sub_82DF758 - sub r1, r1, r0 -_082DF610: - ldr r6, [r5] - ldr r7, [r5, 0x630] -_082DF618: - mul lr, r9, r1 - add lr, r0, lr, asr 23 - mul r12, r10, lr - bic r12, r12, 0xFF0000 - add r6, r12, r6, ror 8 - mul r12, r11, lr - bic r12, r12, 0xFF0000 - add r7, r12, r7, ror 8 - add r9, r9, r8 - movs lr, r9, lsr 23 - beq _082DF678 - bic r9, r9, 0x3F800000 - subs r2, r2, lr - ble _082DF72C - subs lr, lr, 0x1 - bne _082DF660 - add r0, r0, r1 - b _082DF66C -_082DF660: - sub r3, r3, lr - bl sub_82DF758 - mov r0, r1 -_082DF66C: - sub r3, r3, 0x1 - bl sub_82DF758 - sub r1, r1, r0 -_082DF678: - adds r5, r5, 0x40000000 - bcc _082DF618 - str r7, [r5, 0x630] - str r6, [r5], 0x4 - ldr r6, [sp] - subs r6, r6, 0x4 - str r6, [sp] - bgt _082DF610 - add r3, r3, 0x2 - b _082DF728 -_082DF6A0: - ldrb r0, [r4, 0x1] - tst r0, 0x10 - beq _082DF728 - ldrsb r0, [r3, -0x1]! - ldrsb r1, [r3, -0x1] - sub r1, r1, r0 -_082DF6B8: - ldr r6, [r5] - ldr r7, [r5, 0x630] -_082DF6C0: - mul lr, r9, r1 - add lr, r0, lr, asr 23 - mul r12, r10, lr - bic r12, r12, 0xFF0000 - add r6, r12, r6, ror 8 - mul r12, r11, lr - bic r12, r12, 0xFF0000 - add r7, r12, r7, ror 8 - add r9, r9, r8 - movs lr, r9, lsr 23 - beq _082DF704 - bic r9, r9, 0x3F800000 - subs r2, r2, lr - ble _082DF72C - ldrsb r0, [r3, -lr]! - ldrsb r1, [r3, -0x1] - sub r1, r1, r0 -_082DF704: - adds r5, r5, 0x40000000 - bcc _082DF6C0 - str r7, [r5, 0x630] - str r6, [r5], 0x4 - ldr r6, [sp] - subs r6, r6, 0x4 - str r6, [sp] - bgt _082DF6B8 - add r3, r3, 0x1 -_082DF728: - ldmia sp!, {r8,r12,pc} -_082DF72C: - mov r2, 0 - strb r2, [r4] - mov r0, r5, lsr 30 - bic r5, r5, 0xC0000000 - rsb r0, r0, 0x3 - mov r0, r0, lsl 3 - mov r6, r6, ror r0 - mov r7, r7, ror r0 - str r7, [r5, 0x630] - str r6, [r5], 0x4 - ldmia sp!, {r8,r12,pc} - arm_func_end sub_82DF49C - - arm_func_start sub_82DF758 -sub_82DF758: @ 82DF758 - stmdb sp!, {r0,r2,r5-r7,lr} - mov r0, r3, lsr 6 - ldr r1, [r4, 0x3C] - cmp r0, r1 - beq _082DF7CC - str r0, [r4, 0x3C] - mov r1, 0x21 - mul r2, r1, r0 - ldr r1, [r4, 0x24] - add r2, r2, r1 - add r2, r2, 0x10 - ldr r5, _082DF7DC - ldr r6, _082DF7E0 - mov r7, 0x40 - ldrb lr, [r2], 0x1 - strb lr, [r5], 0x1 - ldrb r1, [r2], 0x1 - b _082DF7B4 -_082DF7A0: - ldrb r1, [r2], 0x1 - mov r0, r1, lsr 4 - ldrsb r0, [r6, r0] - add lr, lr, r0 - strb lr, [r5], 0x1 -_082DF7B4: - and r0, r1, 0xF - ldrsb r0, [r6, r0] - add lr, lr, r0 - strb lr, [r5], 0x1 - subs r7, r7, 0x2 - bgt _082DF7A0 -_082DF7CC: - ldr r5, _082DF7DC - and r0, r3, 0x3F - ldrsb r1, [r5, r0] - ldmia sp!, {r0,r2,r5-r7,pc} - .align 2, 0 -_082DF7DC: .4byte gUnknown_03001300 -_082DF7E0: .4byte gUnknown_08675A70 - arm_func_end sub_82DF758 - - thumb_func_start SoundMainBTM -SoundMainBTM: @ 82DF7E4 - mov r12, r4 - movs r1, 0 - movs r2, 0 - movs r3, 0 - movs r4, 0 - stm r0!, {r1-r4} - stm r0!, {r1-r4} - stm r0!, {r1-r4} - stm r0!, {r1-r4} - mov r4, r12 - bx lr - thumb_func_end SoundMainBTM - - thumb_func_start ClearChain -ClearChain: @ 82DF7FC - ldr r3, [r0, 0x2C] - cmp r3, 0 - beq _082DF81A - ldr r1, [r0, 0x34] - ldr r2, [r0, 0x30] - cmp r2, 0 - beq _082DF80E - str r1, [r2, 0x34] - b _082DF810 -_082DF80E: - str r1, [r3, 0x20] -_082DF810: - cmp r1, 0 - beq _082DF816 - str r2, [r1, 0x30] -_082DF816: - movs r1, 0 - str r1, [r0, 0x2C] -_082DF81A: - bx lr - thumb_func_end ClearChain - - thumb_func_start ply_fine -ply_fine: @ 82DF81C - push {r4,r5,lr} - adds r5, r1, 0 - ldr r4, [r5, 0x20] - cmp r4, 0 - beq _082DF840 -_082DF826: - ldrb r1, [r4] - movs r0, 0xC7 - tst r0, r1 - beq _082DF834 - movs r0, 0x40 - orrs r1, r0 - strb r1, [r4] -_082DF834: - adds r0, r4, 0 - bl ClearChain - ldr r4, [r4, 0x34] - cmp r4, 0 - bne _082DF826 -_082DF840: - movs r0, 0 - strb r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end ply_fine - - thumb_func_start MPlyJmpTblCopy -MPlyJmpTblCopy: @ 82DF84C - mov r12, lr - movs r1, 0x24 - ldr r2, _082DF87C -_082DF852: - ldr r3, [r2] - bl chk_adr_r2 - stm r0!, {r3} - adds r2, 0x4 - subs r1, 0x1 - bgt _082DF852 - bx r12 - thumb_func_end MPlyJmpTblCopy - - thumb_func_start ldrb_r3_r2 -ldrb_r3_r2: @ 82DF864 - ldrb r3, [r2] - thumb_func_end ldrb_r3_r2 - - non_word_aligned_thumb_func_start chk_adr_r2 -chk_adr_r2: @ 82DF866 - push {r0} - lsrs r0, r2, 25 - bne _082DF878 - ldr r0, _082DF87C - cmp r2, r0 - bcc _082DF876 - lsrs r0, r2, 14 - beq _082DF878 -_082DF876: - movs r3, 0 -_082DF878: - pop {r0} - bx lr - .align 2, 0 -_082DF87C: .4byte gUnknown_086759E0 - thumb_func_end chk_adr_r2 - - thumb_func_start ld_r3_tp_adr_i -ld_r3_tp_adr_i: @ 82DF880 - ldr r2, [r1, 0x40] -_082DF882: - adds r3, r2, 0x1 - str r3, [r1, 0x40] - ldrb r3, [r2] - b chk_adr_r2 - thumb_func_end ld_r3_tp_adr_i - - thumb_func_start ply_goto -ply_goto: @ 82DF88C - push {lr} -_082DF88E: - ldr r2, [r1, 0x40] - ldrb r0, [r2, 0x3] - lsls r0, 8 - ldrb r3, [r2, 0x2] - orrs r0, r3 - lsls r0, 8 - ldrb r3, [r2, 0x1] - orrs r0, r3 - lsls r0, 8 - bl ldrb_r3_r2 - orrs r0, r3 - str r0, [r1, 0x40] - pop {r0} - bx r0 - thumb_func_end ply_goto - - thumb_func_start ply_patt -ply_patt: @ 82DF8AC - ldrb r2, [r1, 0x2] - cmp r2, 0x3 - bcs _082DF8C4 - lsls r2, 2 - adds r3, r1, r2 - ldr r2, [r1, 0x40] - adds r2, 0x4 - str r2, [r3, 0x44] - ldrb r2, [r1, 0x2] - adds r2, 0x1 - strb r2, [r1, 0x2] - b ply_goto -_082DF8C4: - b ply_fine - thumb_func_end ply_patt - - thumb_func_start play_pend -play_pend: @ 82DF8C8 - ldrb r2, [r1, 0x2] - cmp r2, 0 - beq _082DF8DA - subs r2, 0x1 - strb r2, [r1, 0x2] - lsls r2, 2 - adds r3, r1, r2 - ldr r2, [r3, 0x44] - str r2, [r1, 0x40] -_082DF8DA: - bx lr - thumb_func_end play_pend - - thumb_func_start ply_rept -ply_rept: @ 82DF8DC - push {lr} - ldr r2, [r1, 0x40] - ldrb r3, [r2] - cmp r3, 0 - bne _082DF8EC - adds r2, 0x1 - str r2, [r1, 0x40] - b _082DF88E -_082DF8EC: - ldrb r3, [r1, 0x3] - adds r3, 0x1 - strb r3, [r1, 0x3] - mov r12, r3 - bl ld_r3_tp_adr_i - cmp r12, r3 - bcs _082DF8FE - b _082DF88E -_082DF8FE: - movs r3, 0 - strb r3, [r1, 0x3] - adds r2, 0x5 - str r2, [r1, 0x40] - pop {r0} - bx r0 - thumb_func_end ply_rept - - thumb_func_start ply_prio -ply_prio: @ 82DF90C - mov r12, lr - bl ld_r3_tp_adr_i - strb r3, [r1, 0x1D] - bx r12 - thumb_func_end ply_prio - - thumb_func_start ply_tempo -ply_tempo: @ 82DF918 - mov r12, lr - bl ld_r3_tp_adr_i - lsls r3, 1 - strh r3, [r0, 0x1C] - ldrh r2, [r0, 0x1E] - muls r3, r2 - lsrs r3, 8 - strh r3, [r0, 0x20] - bx r12 - thumb_func_end ply_tempo - - thumb_func_start ply_keysh -ply_keysh: @ 82DF92C - mov r12, lr - bl ld_r3_tp_adr_i - strb r3, [r1, 0xA] - ldrb r3, [r1] - movs r2, 0xC - orrs r3, r2 - strb r3, [r1] - bx r12 - thumb_func_end ply_keysh - - thumb_func_start ply_voice -ply_voice: @ 82DF940 - mov r12, lr - ldr r2, [r1, 0x40] - ldrb r3, [r2] - adds r2, 0x1 - str r2, [r1, 0x40] - lsls r2, r3, 1 - adds r2, r3 - lsls r2, 2 - ldr r3, [r0, 0x30] - adds r2, r3 - ldr r3, [r2] - bl chk_adr_r2 - str r3, [r1, 0x24] - ldr r3, [r2, 0x4] - bl chk_adr_r2 - str r3, [r1, 0x28] - ldr r3, [r2, 0x8] - bl chk_adr_r2 - str r3, [r1, 0x2C] - bx r12 - thumb_func_end ply_voice - - thumb_func_start ply_vol -ply_vol: @ 82DF970 - mov r12, lr - bl ld_r3_tp_adr_i - strb r3, [r1, 0x12] - ldrb r3, [r1] - movs r2, 0x3 - orrs r3, r2 - strb r3, [r1] - bx r12 - thumb_func_end ply_vol - - thumb_func_start ply_pan -ply_pan: @ 82DF984 - mov r12, lr - bl ld_r3_tp_adr_i - subs r3, 0x40 - strb r3, [r1, 0x14] - ldrb r3, [r1] - movs r2, 0x3 - orrs r3, r2 - strb r3, [r1] - bx r12 - thumb_func_end ply_pan - - thumb_func_start ply_bend -ply_bend: @ 82DF998 - mov r12, lr - bl ld_r3_tp_adr_i - subs r3, 0x40 - strb r3, [r1, 0xE] - ldrb r3, [r1] - movs r2, 0xC - orrs r3, r2 - strb r3, [r1] - bx r12 - thumb_func_end ply_bend - - thumb_func_start ply_bendr -ply_bendr: @ 82DF9AC - mov r12, lr - bl ld_r3_tp_adr_i - strb r3, [r1, 0xF] - ldrb r3, [r1] - movs r2, 0xC - orrs r3, r2 - strb r3, [r1] - bx r12 - thumb_func_end ply_bendr - - thumb_func_start ply_lfodl -ply_lfodl: @ 82DF9C0 - mov r12, lr - bl ld_r3_tp_adr_i - strb r3, [r1, 0x1B] - bx r12 - thumb_func_end ply_lfodl - - thumb_func_start ply_modt -ply_modt: @ 82DF9CC - mov r12, lr - bl ld_r3_tp_adr_i - ldrb r0, [r1, 0x18] - cmp r0, r3 - beq _082DF9E2 - strb r3, [r1, 0x18] - ldrb r3, [r1] - movs r2, 0xF - orrs r3, r2 - strb r3, [r1] -_082DF9E2: - bx r12 - thumb_func_end ply_modt - - thumb_func_start ply_tune -ply_tune: @ 82DF9E4 - mov r12, lr - bl ld_r3_tp_adr_i - subs r3, 0x40 - strb r3, [r1, 0xC] - ldrb r3, [r1] - movs r2, 0xC - orrs r3, r2 - strb r3, [r1] - bx r12 - thumb_func_end ply_tune - - thumb_func_start ply_port -ply_port: @ 82DF9F8 - mov r12, lr - ldr r2, [r1, 0x40] - ldrb r3, [r2] - adds r2, 0x1 - ldr r0, _082DFA0C - adds r0, r3 - bl _082DF882 - strb r3, [r0] - bx r12 - .align 2, 0 -_082DFA0C: .4byte 0x04000060 - thumb_func_end ply_port - - thumb_func_start SoundVSync_rev01 -SoundVSync_rev01: @ 82DFA10 - ldr r0, _082DFCBC - ldr r0, [r0] - ldr r2, _082DFCC0 - ldr r3, [r0] - subs r3, r2 - cmp r3, 0x1 - bhi _082DFA50 - ldrb r1, [r0, 0x4] - subs r1, 0x1 - strb r1, [r0, 0x4] - bgt _082DFA50 - ldrb r1, [r0, 0xB] - strb r1, [r0, 0x4] - ldr r2, _082DFA54 - ldr r1, [r2, 0x8] - lsls r1, 7 - bcc _082DFA36 - ldr r1, _082DFA58 - str r1, [r2, 0x8] -_082DFA36: - ldr r1, [r2, 0x14] - lsls r1, 7 - bcc _082DFA40 - ldr r1, _082DFA58 - str r1, [r2, 0x14] -_082DFA40: - movs r1, 0x4 - lsls r1, 8 - strh r1, [r2, 0xA] - strh r1, [r2, 0x16] - movs r1, 0xB6 - lsls r1, 8 - strh r1, [r2, 0xA] - strh r1, [r2, 0x16] -_082DFA50: - bx lr - .align 2, 0 -_082DFA54: .4byte 0x040000bc -_082DFA58: .4byte 0x84400004 - thumb_func_end SoundVSync_rev01 - - thumb_func_start MPlayMain_rev01 -MPlayMain_rev01: @ 82DFA5C - ldr r2, _082DFCC0 - ldr r3, [r0, 0x34] - cmp r2, r3 - beq _082DFA66 - bx lr -_082DFA66: - adds r3, 0x1 - str r3, [r0, 0x34] - push {r0,lr} - ldr r3, [r0, 0x38] - cmp r3, 0 - beq _082DFA78 - ldr r0, [r0, 0x3C] - bl _082DFCB4 -_082DFA78: - pop {r0} - push {r4-r7} - mov r4, r8 - mov r5, r9 - mov r6, r10 - mov r7, r11 - push {r4-r7} - adds r7, r0, 0 - ldr r0, [r7, 0x4] - cmp r0, 0 - bge _082DFA90 - b _082DFCA4 -_082DFA90: - ldr r0, _082DFCBC - ldr r0, [r0] - mov r8, r0 - adds r0, r7, 0 - bl FadeOutBody_rev01 - ldr r0, [r7, 0x4] - cmp r0, 0 - bge _082DFAA4 - b _082DFCA4 -_082DFAA4: - ldrh r0, [r7, 0x22] - ldrh r1, [r7, 0x20] - adds r0, r1 - b _082DFBF4 -_082DFAAC: - ldrb r6, [r7, 0x8] - ldr r5, [r7, 0x2C] - movs r3, 0x1 - movs r4, 0 -_082DFAB4: - ldrb r0, [r5] - movs r1, 0x80 - tst r1, r0 - bne _082DFABE - b _082DFBD0 -_082DFABE: - mov r10, r3 - orrs r4, r3 - mov r11, r4 - ldr r4, [r5, 0x20] - cmp r4, 0 - beq _082DFAF2 -_082DFACA: - ldrb r1, [r4] - movs r0, 0xC7 - tst r0, r1 - beq _082DFAE6 - ldrb r0, [r4, 0x10] - cmp r0, 0 - beq _082DFAEC - subs r0, 0x1 - strb r0, [r4, 0x10] - bne _082DFAEC - movs r0, 0x40 - orrs r1, r0 - strb r1, [r4] - b _082DFAEC -_082DFAE6: - adds r0, r4, 0 - bl ClearChain_rev -_082DFAEC: - ldr r4, [r4, 0x34] - cmp r4, 0 - bne _082DFACA -_082DFAF2: - ldrb r3, [r5] - movs r0, 0x40 - tst r0, r3 - beq _082DFB70 - adds r0, r5, 0 - bl Clear64byte_rev - movs r0, 0x80 - strb r0, [r5] - movs r0, 0x2 - strb r0, [r5, 0xF] - movs r0, 0x40 - strb r0, [r5, 0x13] - movs r0, 0x16 - strb r0, [r5, 0x19] - movs r0, 0x1 - adds r1, r5, 0x6 - strb r0, [r1, 0x1E] - b _082DFB70 -_082DFB18: - ldr r2, [r5, 0x40] - ldrb r1, [r2] - cmp r1, 0x80 - bcs _082DFB24 - ldrb r1, [r5, 0x7] - b _082DFB2E -_082DFB24: - adds r2, 0x1 - str r2, [r5, 0x40] - cmp r1, 0xBD - bcc _082DFB2E - strb r1, [r5, 0x7] -_082DFB2E: - cmp r1, 0xCF - bcc _082DFB44 - mov r0, r8 - ldr r3, [r0, 0x38] - adds r0, r1, 0 - subs r0, 0xCF - adds r1, r7, 0 - adds r2, r5, 0 - bl _082DFCB4 - b _082DFB70 -_082DFB44: - cmp r1, 0xB0 - bls _082DFB66 - adds r0, r1, 0 - subs r0, 0xB1 - strb r0, [r7, 0xA] - mov r3, r8 - ldr r3, [r3, 0x34] - lsls r0, 2 - ldr r3, [r3, r0] - adds r0, r7, 0 - adds r1, r5, 0 - bl _082DFCB4 - ldrb r0, [r5] - cmp r0, 0 - beq _082DFBCC - b _082DFB70 -_082DFB66: - ldr r0, _082DFCB8 - subs r1, 0x80 - adds r1, r0 - ldrb r0, [r1] - strb r0, [r5, 0x1] -_082DFB70: - ldrb r0, [r5, 0x1] - cmp r0, 0 - beq _082DFB18 - subs r0, 0x1 - strb r0, [r5, 0x1] - ldrb r1, [r5, 0x19] - cmp r1, 0 - beq _082DFBCC - ldrb r0, [r5, 0x17] - cmp r0, 0 - beq _082DFBCC - ldrb r0, [r5, 0x1C] - cmp r0, 0 - beq _082DFB92 - subs r0, 0x1 - strb r0, [r5, 0x1C] - b _082DFBCC -_082DFB92: - ldrb r0, [r5, 0x1A] - adds r0, r1 - strb r0, [r5, 0x1A] - adds r1, r0, 0 - subs r0, 0x40 - lsls r0, 24 - bpl _082DFBA6 - lsls r2, r1, 24 - asrs r2, 24 - b _082DFBAA -_082DFBA6: - movs r0, 0x80 - subs r2, r0, r1 -_082DFBAA: - ldrb r0, [r5, 0x17] - muls r0, r2 - asrs r2, r0, 6 - ldrb r0, [r5, 0x16] - eors r0, r2 - lsls r0, 24 - beq _082DFBCC - strb r2, [r5, 0x16] - ldrb r0, [r5] - ldrb r1, [r5, 0x18] - cmp r1, 0 - bne _082DFBC6 - movs r1, 0xC - b _082DFBC8 -_082DFBC6: - movs r1, 0x3 -_082DFBC8: - orrs r0, r1 - strb r0, [r5] -_082DFBCC: - mov r3, r10 - mov r4, r11 -_082DFBD0: - subs r6, 0x1 - ble _082DFBDC - movs r0, 0x50 - adds r5, r0 - lsls r3, 1 - b _082DFAB4 -_082DFBDC: - ldr r0, [r7, 0xC] - adds r0, 0x1 - str r0, [r7, 0xC] - cmp r4, 0 - bne _082DFBEE - movs r0, 0x80 - lsls r0, 24 - str r0, [r7, 0x4] - b _082DFCA4 -_082DFBEE: - str r4, [r7, 0x4] - ldrh r0, [r7, 0x22] - subs r0, 0x96 -_082DFBF4: - strh r0, [r7, 0x22] - cmp r0, 0x96 - bcc _082DFBFC - b _082DFAAC -_082DFBFC: - ldrb r2, [r7, 0x8] - ldr r5, [r7, 0x2C] -_082DFC00: - ldrb r0, [r5] - movs r1, 0x80 - tst r1, r0 - beq _082DFC9A - movs r1, 0xF - tst r1, r0 - beq _082DFC9A - mov r9, r2 - adds r0, r7, 0 - adds r1, r5, 0 - bl TrkVolPitSet_rev01 - ldr r4, [r5, 0x20] - cmp r4, 0 - beq _082DFC90 -_082DFC1E: - ldrb r1, [r4] - movs r0, 0xC7 - tst r0, r1 - bne _082DFC2E - adds r0, r4, 0 - bl ClearChain_rev - b _082DFC8A -_082DFC2E: - ldrb r0, [r4, 0x1] - movs r6, 0x7 - ands r6, r0 - ldrb r3, [r5] - movs r0, 0x3 - tst r0, r3 - beq _082DFC4C - bl ChnVolSetAsm - cmp r6, 0 - beq _082DFC4C - ldrb r0, [r4, 0x1D] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r4, 0x1D] -_082DFC4C: - ldrb r3, [r5] - movs r0, 0xC - tst r0, r3 - beq _082DFC8A - ldrb r1, [r4, 0x8] - movs r0, 0x8 - ldrsb r0, [r5, r0] - adds r2, r1, r0 - bpl _082DFC60 - movs r2, 0 -_082DFC60: - cmp r6, 0 - beq _082DFC7E - mov r0, r8 - ldr r3, [r0, 0x30] - adds r1, r2, 0 - ldrb r2, [r5, 0x9] - adds r0, r6, 0 - bl _082DFCB4 - str r0, [r4, 0x20] - ldrb r0, [r4, 0x1D] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4, 0x1D] - b _082DFC8A -_082DFC7E: - adds r1, r2, 0 - ldrb r2, [r5, 0x9] - ldr r0, [r4, 0x24] - bl MidiKey2fr - str r0, [r4, 0x20] -_082DFC8A: - ldr r4, [r4, 0x34] - cmp r4, 0 - bne _082DFC1E -_082DFC90: - ldrb r0, [r5] - movs r1, 0xF0 - ands r0, r1 - strb r0, [r5] - mov r2, r9 -_082DFC9A: - subs r2, 0x1 - ble _082DFCA4 - movs r0, 0x50 - adds r5, r0 - bgt _082DFC00 -_082DFCA4: - ldr r0, _082DFCC0 - str r0, [r7, 0x34] - pop {r0-r7} - mov r8, r0 - mov r9, r1 - mov r10, r2 - mov r11, r3 - pop {r3} -_082DFCB4: - bx r3 - .align 2, 0 -_082DFCB8: .4byte gUnknown_08675C64 -_082DFCBC: .4byte gUnknown_03007FF0 -_082DFCC0: .4byte 0x68736d53 - thumb_func_end MPlayMain_rev01 - - thumb_func_start TrackStop_rev01 -TrackStop_rev01: @ 82DFCC4 - push {r4-r6,lr} - adds r5, r1, 0 - ldrb r1, [r5] - movs r0, 0x80 - tst r0, r1 - beq _082DFCFC - ldr r4, [r5, 0x20] - cmp r4, 0 - beq _082DFCFA - movs r6, 0 -_082DFCD8: - ldrb r0, [r4] - cmp r0, 0 - beq _082DFCF2 - ldrb r0, [r4, 0x1] - movs r3, 0x7 - ands r0, r3 - beq _082DFCF0 - ldr r3, _082DFD04 - ldr r3, [r3] - ldr r3, [r3, 0x2C] - bl _082DFCB4 -_082DFCF0: - strb r6, [r4] -_082DFCF2: - str r6, [r4, 0x2C] - ldr r4, [r4, 0x34] - cmp r4, 0 - bne _082DFCD8 -_082DFCFA: - str r4, [r5, 0x20] -_082DFCFC: - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_082DFD04: .4byte gUnknown_03007FF0 - thumb_func_end TrackStop_rev01 - - thumb_func_start ChnVolSetAsm -ChnVolSetAsm: @ 82DFD08 - ldrb r1, [r4, 0x12] - movs r0, 0x14 - ldrsb r2, [r4, r0] - movs r3, 0x80 - adds r3, r2 - muls r3, r1 - ldrb r0, [r5, 0x10] - muls r0, r3 - asrs r0, 14 - cmp r0, 0xFF - bls _082DFD20 - movs r0, 0xFF -_082DFD20: - strb r0, [r4, 0x2] - movs r3, 0x7F - subs r3, r2 - muls r3, r1 - ldrb r0, [r5, 0x11] - muls r0, r3 - asrs r0, 14 - cmp r0, 0xFF - bls _082DFD34 - movs r0, 0xFF -_082DFD34: - strb r0, [r4, 0x3] - bx lr - thumb_func_end ChnVolSetAsm - - thumb_func_start ply_note_rev01 -ply_note_rev01: @ 82DFD38 - push {r4-r7,lr} - mov r4, r8 - mov r5, r9 - mov r6, r10 - mov r7, r11 - push {r4-r7} - sub sp, 0x18 - str r1, [sp] - adds r5, r2, 0 - ldr r1, _082DFF34 - ldr r1, [r1] - str r1, [sp, 0x4] - ldr r1, _082DFF38 - adds r0, r1 - ldrb r0, [r0] - strb r0, [r5, 0x4] - ldr r3, [r5, 0x40] - ldrb r0, [r3] - cmp r0, 0x80 - bcs _082DFD7E - strb r0, [r5, 0x5] - adds r3, 0x1 - ldrb r0, [r3] - cmp r0, 0x80 - bcs _082DFD7C - strb r0, [r5, 0x6] - adds r3, 0x1 - ldrb r0, [r3] - cmp r0, 0x80 - bcs _082DFD7C - ldrb r1, [r5, 0x4] - adds r1, r0 - strb r1, [r5, 0x4] - adds r3, 0x1 -_082DFD7C: - str r3, [r5, 0x40] -_082DFD7E: - movs r0, 0 - str r0, [sp, 0x14] - adds r4, r5, 0 - adds r4, 0x24 - ldrb r2, [r4] - movs r0, 0xC0 - tst r0, r2 - beq _082DFDD0 - ldrb r3, [r5, 0x5] - movs r0, 0x40 - tst r0, r2 - beq _082DFD9E - ldr r1, [r5, 0x2C] - adds r1, r3 - ldrb r0, [r1] - b _082DFDA0 -_082DFD9E: - adds r0, r3, 0 -_082DFDA0: - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - ldr r0, [r5, 0x28] - adds r1, r0 - mov r9, r1 - mov r6, r9 - ldrb r1, [r6] - movs r0, 0xC0 - tst r0, r1 - beq _082DFDB8 - b _082DFF22 -_082DFDB8: - movs r0, 0x80 - tst r0, r2 - beq _082DFDD4 - ldrb r1, [r6, 0x3] - movs r0, 0x80 - tst r0, r1 - beq _082DFDCC - subs r1, 0xC0 - lsls r1, 1 - str r1, [sp, 0x14] -_082DFDCC: - ldrb r3, [r6, 0x1] - b _082DFDD4 -_082DFDD0: - mov r9, r4 - ldrb r3, [r5, 0x5] -_082DFDD4: - str r3, [sp, 0x8] - ldr r6, [sp] - ldrb r1, [r6, 0x9] - ldrb r0, [r5, 0x1D] - adds r0, r1 - cmp r0, 0xFF - bls _082DFDE4 - movs r0, 0xFF -_082DFDE4: - str r0, [sp, 0x10] - mov r6, r9 - ldrb r0, [r6] - movs r6, 0x7 - ands r6, r0 - str r6, [sp, 0xC] - beq _082DFE24 - ldr r0, [sp, 0x4] - ldr r4, [r0, 0x1C] - cmp r4, 0 - bne _082DFDFC - b _082DFF22 -_082DFDFC: - subs r6, 0x1 - lsls r0, r6, 6 - adds r4, r0 - ldrb r1, [r4] - movs r0, 0xC7 - tst r0, r1 - beq _082DFE78 - movs r0, 0x40 - tst r0, r1 - bne _082DFE78 - ldrb r1, [r4, 0x13] - ldr r0, [sp, 0x10] - cmp r1, r0 - bcc _082DFE78 - beq _082DFE1C - b _082DFF22 -_082DFE1C: - ldr r0, [r4, 0x2C] - cmp r0, r5 - bcs _082DFE78 - b _082DFF22 -_082DFE24: - ldr r6, [sp, 0x10] - adds r7, r5, 0 - movs r2, 0 - mov r8, r2 - ldr r4, [sp, 0x4] - ldrb r3, [r4, 0x6] - adds r4, 0x50 -_082DFE32: - ldrb r1, [r4] - movs r0, 0xC7 - tst r0, r1 - beq _082DFE78 - movs r0, 0x40 - tst r0, r1 - beq _082DFE4C - cmp r2, 0 - bne _082DFE50 - adds r2, 0x1 - ldrb r6, [r4, 0x13] - ldr r7, [r4, 0x2C] - b _082DFE6A -_082DFE4C: - cmp r2, 0 - bne _082DFE6C -_082DFE50: - ldrb r0, [r4, 0x13] - cmp r0, r6 - bcs _082DFE5C - adds r6, r0, 0 - ldr r7, [r4, 0x2C] - b _082DFE6A -_082DFE5C: - bhi _082DFE6C - ldr r0, [r4, 0x2C] - cmp r0, r7 - bls _082DFE68 - adds r7, r0, 0 - b _082DFE6A -_082DFE68: - bcc _082DFE6C -_082DFE6A: - mov r8, r4 -_082DFE6C: - adds r4, 0x40 - subs r3, 0x1 - bgt _082DFE32 - mov r4, r8 - cmp r4, 0 - beq _082DFF22 -_082DFE78: - adds r0, r4, 0 - bl ClearChain_rev - movs r1, 0 - str r1, [r4, 0x30] - ldr r3, [r5, 0x20] - str r3, [r4, 0x34] - cmp r3, 0 - beq _082DFE8C - str r4, [r3, 0x30] -_082DFE8C: - str r4, [r5, 0x20] - str r5, [r4, 0x2C] - ldrb r0, [r5, 0x1B] - strb r0, [r5, 0x1C] - cmp r0, r1 - beq _082DFE9E - adds r1, r5, 0 - bl clear_modM -_082DFE9E: - ldr r0, [sp] - adds r1, r5, 0 - bl TrkVolPitSet_rev01 - ldr r0, [r5, 0x4] - str r0, [r4, 0x10] - ldr r0, [sp, 0x10] - strb r0, [r4, 0x13] - ldr r0, [sp, 0x8] - strb r0, [r4, 0x8] - ldr r0, [sp, 0x14] - strb r0, [r4, 0x14] - mov r6, r9 - ldrb r0, [r6] - strb r0, [r4, 0x1] - ldr r7, [r6, 0x4] - str r7, [r4, 0x24] - ldr r0, [r6, 0x8] - str r0, [r4, 0x4] - ldrh r0, [r5, 0x1E] - strh r0, [r4, 0xC] - bl ChnVolSetAsm - ldrb r1, [r4, 0x8] - movs r0, 0x8 - ldrsb r0, [r5, r0] - adds r3, r1, r0 - bpl _082DFED8 - movs r3, 0 -_082DFED8: - ldr r6, [sp, 0xC] - cmp r6, 0 - beq _082DFF06 - mov r6, r9 - ldrb r0, [r6, 0x2] - strb r0, [r4, 0x1E] - ldrb r1, [r6, 0x3] - movs r0, 0x80 - tst r0, r1 - bne _082DFEF2 - movs r0, 0x70 - tst r0, r1 - bne _082DFEF4 -_082DFEF2: - movs r1, 0x8 -_082DFEF4: - strb r1, [r4, 0x1F] - ldrb r2, [r5, 0x9] - adds r1, r3, 0 - ldr r0, [sp, 0xC] - ldr r3, [sp, 0x4] - ldr r3, [r3, 0x30] - bl _082DFCB4 - b _082DFF14 -_082DFF06: - ldr r0, [r5, 0x3C] - str r0, [r4, 0x18] - ldrb r2, [r5, 0x9] - adds r1, r3, 0 - adds r0, r7, 0 - bl MidiKey2fr -_082DFF14: - str r0, [r4, 0x20] - movs r0, 0x80 - strb r0, [r4] - ldrb r1, [r5] - movs r0, 0xF0 - ands r0, r1 - strb r0, [r5] -_082DFF22: - add sp, 0x18 - pop {r0-r7} - mov r8, r0 - mov r9, r1 - mov r10, r2 - mov r11, r3 - pop {r0} - bx r0 - .align 2, 0 -_082DFF34: .4byte gUnknown_03007FF0 -_082DFF38: .4byte gUnknown_08675C64 - thumb_func_end ply_note_rev01 - - thumb_func_start ply_endtie_rev01 -ply_endtie_rev01: @ 82DFF3C - push {r4,r5} - ldr r2, [r1, 0x40] - ldrb r3, [r2] - cmp r3, 0x80 - bcs _082DFF4E - strb r3, [r1, 0x5] - adds r2, 0x1 - str r2, [r1, 0x40] - b _082DFF50 -_082DFF4E: - ldrb r3, [r1, 0x5] -_082DFF50: - ldr r1, [r1, 0x20] - cmp r1, 0 - beq _082DFF78 - movs r4, 0x83 - movs r5, 0x40 -_082DFF5A: - ldrb r2, [r1] - tst r2, r4 - beq _082DFF72 - tst r2, r5 - bne _082DFF72 - ldrb r0, [r1, 0x11] - cmp r0, r3 - bne _082DFF72 - movs r0, 0x40 - orrs r2, r0 - strb r2, [r1] - b _082DFF78 -_082DFF72: - ldr r1, [r1, 0x34] - cmp r1, 0 - bne _082DFF5A -_082DFF78: - pop {r4,r5} - bx lr - thumb_func_end ply_endtie_rev01 - - thumb_func_start clear_modM -clear_modM: @ 82DFF7C - movs r2, 0 - strb r2, [r1, 0x16] - strb r2, [r1, 0x1A] - ldrb r2, [r1, 0x18] - cmp r2, 0 - bne _082DFF8C - movs r2, 0xC - b _082DFF8E -_082DFF8C: - movs r2, 0x3 -_082DFF8E: - ldrb r3, [r1] - orrs r3, r2 - strb r3, [r1] - bx lr - thumb_func_end clear_modM - - thumb_func_start ld_r3_tp_adr_i_rev -ld_r3_tp_adr_i_rev: @ 82DFF98 - ldr r2, [r1, 0x40] - adds r3, r2, 0x1 - str r3, [r1, 0x40] - ldrb r3, [r2] - bx lr - thumb_func_end ld_r3_tp_adr_i_rev - - thumb_func_start ply_lfos_rev01 -ply_lfos_rev01: @ 82DFFA4 - mov r12, lr - bl ld_r3_tp_adr_i_rev - strb r3, [r1, 0x19] - cmp r3, 0 - bne _082DFFB4 - bl clear_modM -_082DFFB4: - bx r12 - thumb_func_end ply_lfos_rev01 - - thumb_func_start ply_mod_rev01 -ply_mod_rev01: @ 82DFFB8 - mov r12, lr - bl ld_r3_tp_adr_i_rev - strb r3, [r1, 0x17] - cmp r3, 0 - bne _082DFFC8 - bl clear_modM -_082DFFC8: - bx r12 - thumb_func_end ply_mod_rev01 - - thumb_func_start MidiKey2fr -MidiKey2fr: @ 82DFFCC - push {r4-r7,lr} - mov r12, r0 - lsls r1, 24 - lsrs r6, r1, 24 - lsls r7, r2, 24 - cmp r6, 0xB2 - bls _082DFFE0 - movs r6, 0xB2 - movs r7, 0xFF - lsls r7, 24 -_082DFFE0: - ldr r3, _082E0028 - adds r0, r6, r3 - ldrb r5, [r0] - ldr r4, _082E002C - movs r2, 0xF - adds r0, r5, 0 - ands r0, r2 - lsls r0, 2 - adds r0, r4 - lsrs r1, r5, 4 - ldr r5, [r0] - lsrs r5, r1 - adds r0, r6, 0x1 - adds r0, r3 - ldrb r1, [r0] - adds r0, r1, 0 - ands r0, r2 - lsls r0, 2 - adds r0, r4 - lsrs r1, 4 - ldr r0, [r0] - lsrs r0, r1 - mov r1, r12 - ldr r4, [r1, 0x4] - subs r0, r5 - adds r1, r7, 0 - bl umul3232H32 - adds r1, r0, 0 - adds r1, r5, r1 - adds r0, r4, 0 - bl umul3232H32 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_082E0028: .4byte gUnknown_08675A80 -_082E002C: .4byte gUnknown_08675B34 - thumb_func_end MidiKey2fr - - thumb_func_start DummyFunc -DummyFunc: @ 82E0030 - bx lr - thumb_func_end DummyFunc - - thumb_func_start MPlayContinue -MPlayContinue: @ 82E0034 - adds r2, r0, 0 - ldr r3, [r2, 0x34] - ldr r0, _082E0048 - cmp r3, r0 - bne _082E0046 - ldr r0, [r2, 0x4] - ldr r1, _082E004C - ands r0, r1 - str r0, [r2, 0x4] -_082E0046: - bx lr - .align 2, 0 -_082E0048: .4byte 0x68736d53 -_082E004C: .4byte 0x7fffffff - thumb_func_end MPlayContinue - - thumb_func_start MPlayFadeOut -@ void MPlayFadeOut(mplay_table_entry *a1, s16 a2) -MPlayFadeOut: @ 82E0050 - adds r2, r0, 0 - lsls r1, 16 - lsrs r1, 16 - ldr r3, [r2, 0x34] - ldr r0, _082E006C - cmp r3, r0 - bne _082E0068 - strh r1, [r2, 0x26] - strh r1, [r2, 0x24] - movs r0, 0x80 - lsls r0, 1 - strh r0, [r2, 0x28] -_082E0068: - bx lr - .align 2, 0 -_082E006C: .4byte 0x68736d53 - thumb_func_end MPlayFadeOut - - thumb_func_start m4aSoundInit -m4aSoundInit: @ 82E0070 - push {r4-r6,lr} - ldr r0, _082E00F0 - movs r1, 0x2 - negs r1, r1 - ands r0, r1 - ldr r1, _082E00F4 - ldr r2, _082E00F8 - bl CpuSet - ldr r0, _082E00FC - bl SoundInit_rev01 - ldr r0, _082E0100 - bl MPlayExtender - ldr r0, _082E0104 - bl SoundMode_rev01 - ldr r0, _082E0108 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0 - beq _082E00BE - ldr r6, _082E010C - adds r5, r0, 0 -_082E00A2: - ldr r4, [r6] - ldr r1, [r6, 0x4] - ldrb r2, [r6, 0x8] - adds r0, r4, 0 - bl MPlayOpen_rev01 - ldrh r0, [r6, 0xA] - strb r0, [r4, 0xB] - ldr r0, _082E0110 - str r0, [r4, 0x18] - adds r6, 0xC - subs r5, 0x1 - cmp r5, 0 - bne _082E00A2 -_082E00BE: - ldr r0, _082E0114 - ldr r1, _082E0118 - movs r2, 0x34 - bl memcpy - movs r5, 0 - movs r6, 0 -_082E00CC: - lsls r0, r5, 6 - ldr r1, _082E011C - adds r0, r1 - ldr r4, _082E0120 - adds r4, r6, r4 - adds r1, r4, 0 - movs r2, 0x2 - bl MPlayOpen_rev01 - movs r0, 0 - str r0, [r4, 0x20] - adds r6, 0xA0 - adds r5, 0x1 - cmp r5, 0x1 - ble _082E00CC - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_082E00F0: .4byte SoundMainRAM -_082E00F4: .4byte 0x03001aa8 -_082E00F8: .4byte 0x04000200 -_082E00FC: .4byte gUnknown_03006380 -_082E0100: .4byte gUnknown_030074F0 -_082E0104: .4byte 0x0094c500 -_082E0108: .4byte 0x00000004 -_082E010C: .4byte gUnknown_086B49C0 -_082E0110: .4byte gUnknown_030077F0 -_082E0114: .4byte gUnknown_030077B0 -_082E0118: .4byte gUnknown_08675C98 -_082E011C: .4byte gUnknown_030073A0 -_082E0120: .4byte gUnknown_03007670 - thumb_func_end m4aSoundInit - - thumb_func_start m4aSoundMain -m4aSoundMain: @ 82E0124 - push {lr} - bl SoundMain - pop {r0} - bx r0 - thumb_func_end m4aSoundMain - - thumb_func_start m4aSongNumStart -m4aSongNumStart: @ 82E0130 - push {lr} - lsls r0, 16 - ldr r2, _082E0154 - ldr r1, _082E0158 - lsrs r0, 13 - adds r0, r1 - ldrh r3, [r0, 0x4] - lsls r1, r3, 1 - adds r1, r3 - lsls r1, 2 - adds r1, r2 - ldr r2, [r1] - ldr r1, [r0] - adds r0, r2, 0 - bl MPlayStart_rev01 - pop {r0} - bx r0 - .align 2, 0 -_082E0154: .4byte gUnknown_086B49C0 -_082E0158: .4byte gUnknown_086B49F0 - thumb_func_end m4aSongNumStart - - thumb_func_start m4aSongNumStartOrChange -m4aSongNumStartOrChange: @ 82E015C - push {lr} - lsls r0, 16 - ldr r2, _082E0188 - ldr r1, _082E018C - lsrs r0, 13 - adds r0, r1 - ldrh r3, [r0, 0x4] - lsls r1, r3, 1 - adds r1, r3 - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - ldr r3, [r1] - ldr r2, [r0] - cmp r3, r2 - beq _082E0190 - adds r0, r1, 0 - adds r1, r2, 0 - bl MPlayStart_rev01 - b _082E01A4 - .align 2, 0 -_082E0188: .4byte gUnknown_086B49C0 -_082E018C: .4byte gUnknown_086B49F0 -_082E0190: - ldr r2, [r1, 0x4] - ldrh r0, [r1, 0x4] - cmp r0, 0 - beq _082E019C - cmp r2, 0 - bge _082E01A4 -_082E019C: - adds r0, r1, 0 - adds r1, r3, 0 - bl MPlayStart_rev01 -_082E01A4: - pop {r0} - bx r0 - thumb_func_end m4aSongNumStartOrChange - - thumb_func_start m4aSongNumStartOrContinue -m4aSongNumStartOrContinue: @ 82E01A8 - push {lr} - lsls r0, 16 - ldr r2, _082E01D4 - ldr r1, _082E01D8 - lsrs r0, 13 - adds r0, r1 - ldrh r3, [r0, 0x4] - lsls r1, r3, 1 - adds r1, r3 - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - ldr r3, [r1] - ldr r2, [r0] - cmp r3, r2 - beq _082E01DC - adds r0, r1, 0 - adds r1, r2, 0 - bl MPlayStart_rev01 - b _082E01F8 - .align 2, 0 -_082E01D4: .4byte gUnknown_086B49C0 -_082E01D8: .4byte gUnknown_086B49F0 -_082E01DC: - ldr r2, [r1, 0x4] - ldrh r0, [r1, 0x4] - cmp r0, 0 - bne _082E01EE - adds r0, r1, 0 - adds r1, r3, 0 - bl MPlayStart_rev01 - b _082E01F8 -_082E01EE: - cmp r2, 0 - bge _082E01F8 - adds r0, r1, 0 - bl MPlayContinue -_082E01F8: - pop {r0} - bx r0 - thumb_func_end m4aSongNumStartOrContinue - - thumb_func_start m4aSongNumStop -m4aSongNumStop: @ 82E01FC - push {lr} - lsls r0, 16 - ldr r2, _082E0228 - ldr r1, _082E022C - lsrs r0, 13 - adds r0, r1 - ldrh r3, [r0, 0x4] - lsls r1, r3, 1 - adds r1, r3 - lsls r1, 2 - adds r1, r2 - ldr r2, [r1] - ldr r1, [r2] - ldr r0, [r0] - cmp r1, r0 - bne _082E0222 - adds r0, r2, 0 - bl MPlayStop_rev01 -_082E0222: - pop {r0} - bx r0 - .align 2, 0 -_082E0228: .4byte gUnknown_086B49C0 -_082E022C: .4byte gUnknown_086B49F0 - thumb_func_end m4aSongNumStop - - thumb_func_start m4aSongNumContinue -m4aSongNumContinue: @ 82E0230 - push {lr} - lsls r0, 16 - ldr r2, _082E025C - ldr r1, _082E0260 - lsrs r0, 13 - adds r0, r1 - ldrh r3, [r0, 0x4] - lsls r1, r3, 1 - adds r1, r3 - lsls r1, 2 - adds r1, r2 - ldr r2, [r1] - ldr r1, [r2] - ldr r0, [r0] - cmp r1, r0 - bne _082E0256 - adds r0, r2, 0 - bl MPlayContinue -_082E0256: - pop {r0} - bx r0 - .align 2, 0 -_082E025C: .4byte gUnknown_086B49C0 -_082E0260: .4byte gUnknown_086B49F0 - thumb_func_end m4aSongNumContinue - - thumb_func_start m4aMPlayAllStop -m4aMPlayAllStop: @ 82E0264 - push {r4,r5,lr} - ldr r0, _082E029C - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0 - beq _082E0282 - ldr r5, _082E02A0 - adds r4, r0, 0 -_082E0274: - ldr r0, [r5] - bl MPlayStop_rev01 - adds r5, 0xC - subs r4, 0x1 - cmp r4, 0 - bne _082E0274 -_082E0282: - ldr r5, _082E02A4 - movs r4, 0x1 -_082E0286: - adds r0, r5, 0 - bl MPlayStop_rev01 - adds r5, 0x40 - subs r4, 0x1 - cmp r4, 0 - bge _082E0286 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_082E029C: .4byte 0x00000004 -_082E02A0: .4byte gUnknown_086B49C0 -_082E02A4: .4byte gUnknown_030073A0 - thumb_func_end m4aMPlayAllStop - - thumb_func_start m4aMPlayContinue -m4aMPlayContinue: @ 82E02A8 - push {lr} - bl MPlayContinue - pop {r0} - bx r0 - thumb_func_end m4aMPlayContinue - - thumb_func_start m4aMPlayAllContinue -m4aMPlayAllContinue: @ 82E02B2 - push {r4,r5,lr} - ldr r0, _082E02EC - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0 - beq _082E02D2 - ldr r5, _082E02F0 - adds r4, r0, 0 -_082E02C4: - ldr r0, [r5] - bl MPlayContinue - adds r5, 0xC - subs r4, 0x1 - cmp r4, 0 - bne _082E02C4 -_082E02D2: - ldr r5, _082E02F4 - movs r4, 0x1 -_082E02D6: - adds r0, r5, 0 - bl MPlayContinue - adds r5, 0x40 - subs r4, 0x1 - cmp r4, 0 - bge _082E02D6 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_082E02EC: .4byte 0x00000004 -_082E02F0: .4byte gUnknown_086B49C0 -_082E02F4: .4byte gUnknown_030073A0 - thumb_func_end m4aMPlayAllContinue - - thumb_func_start m4aMPlayFadeOut -@ void m4aMPlayFadeOut(mplay_table_entry *a1, u16 a2) -m4aMPlayFadeOut: @ 82E02F8 - push {lr} - lsls r1, 16 - lsrs r1, 16 - bl MPlayFadeOut - pop {r0} - bx r0 - thumb_func_end m4aMPlayFadeOut - - thumb_func_start sub_82E0308 -sub_82E0308: @ 82E0308 - adds r2, r0, 0 - lsls r1, 16 - lsrs r1, 16 - ldr r3, [r2, 0x34] - ldr r0, _082E0320 - cmp r3, r0 - bne _082E031E - strh r1, [r2, 0x26] - strh r1, [r2, 0x24] - ldr r0, _082E0324 - strh r0, [r2, 0x28] -_082E031E: - bx lr - .align 2, 0 -_082E0320: .4byte 0x68736d53 -_082E0324: .4byte 0x00000101 - thumb_func_end sub_82E0308 - - thumb_func_start sub_82E0328 -sub_82E0328: @ 82E0328 - adds r2, r0, 0 - lsls r1, 16 - lsrs r1, 16 - ldr r3, [r2, 0x34] - ldr r0, _082E0348 - cmp r3, r0 - bne _082E0346 - strh r1, [r2, 0x26] - strh r1, [r2, 0x24] - movs r0, 0x2 - strh r0, [r2, 0x28] - ldr r0, [r2, 0x4] - ldr r1, _082E034C - ands r0, r1 - str r0, [r2, 0x4] -_082E0346: - bx lr - .align 2, 0 -_082E0348: .4byte 0x68736d53 -_082E034C: .4byte 0x7fffffff - thumb_func_end sub_82E0328 - - thumb_func_start m4aMPlayImmInit -m4aMPlayImmInit: @ 82E0350 - push {r4-r7,lr} - ldrb r5, [r0, 0x8] - ldr r4, [r0, 0x2C] - cmp r5, 0 - ble _082E0392 - movs r7, 0x80 -_082E035C: - ldrb r1, [r4] - adds r0, r7, 0 - ands r0, r1 - cmp r0, 0 - beq _082E038A - movs r6, 0x40 - adds r0, r6, 0 - ands r0, r1 - cmp r0, 0 - beq _082E038A - adds r0, r4, 0 - bl Clear64byte_rev - strb r7, [r4] - movs r0, 0x2 - strb r0, [r4, 0xF] - strb r6, [r4, 0x13] - movs r0, 0x16 - strb r0, [r4, 0x19] - adds r1, r4, 0 - adds r1, 0x24 - movs r0, 0x1 - strb r0, [r1] -_082E038A: - subs r5, 0x1 - adds r4, 0x50 - cmp r5, 0 - bgt _082E035C -_082E0392: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end m4aMPlayImmInit - - thumb_func_start MPlayExtender -@ int MPlayExtender(void *dest) -MPlayExtender: @ 82E0398 - push {r4-r6,lr} - sub sp, 0x4 - adds r5, r0, 0 - ldr r1, _082E0460 - movs r0, 0x8F - strh r0, [r1] - ldr r3, _082E0464 - movs r2, 0 - strh r2, [r3] - ldr r0, _082E0468 - movs r1, 0x8 - strb r1, [r0] - adds r0, 0x6 - strb r1, [r0] - adds r0, 0x10 - strb r1, [r0] - subs r0, 0x14 - movs r1, 0x80 - strb r1, [r0] - adds r0, 0x8 - strb r1, [r0] - adds r0, 0x10 - strb r1, [r0] - subs r0, 0xD - strb r2, [r0] - movs r0, 0x77 - strb r0, [r3] - ldr r0, _082E046C - ldr r4, [r0] - ldr r6, [r4] - ldr r0, _082E0470 - cmp r6, r0 - bne _082E0458 - adds r0, r6, 0x1 - str r0, [r4] - ldr r1, _082E0474 - ldr r0, _082E0478 - str r0, [r1, 0x20] - ldr r0, _082E047C - str r0, [r1, 0x44] - ldr r0, _082E0480 - str r0, [r1, 0x4C] - ldr r0, _082E0484 - str r0, [r1, 0x70] - ldr r0, _082E0488 - str r0, [r1, 0x74] - ldr r0, _082E048C - str r0, [r1, 0x78] - ldr r0, _082E0490 - str r0, [r1, 0x7C] - adds r2, r1, 0 - adds r2, 0x80 - ldr r0, _082E0494 - str r0, [r2] - adds r1, 0x84 - ldr r0, _082E0498 - str r0, [r1] - str r5, [r4, 0x1C] - ldr r0, _082E049C - str r0, [r4, 0x28] - ldr r0, _082E04A0 - str r0, [r4, 0x2C] - ldr r0, _082E04A4 - str r0, [r4, 0x30] - ldr r0, _082E04A8 - movs r1, 0 - strb r0, [r4, 0xC] - str r1, [sp] - ldr r2, _082E04AC - mov r0, sp - adds r1, r5, 0 - bl CpuSet - movs r0, 0x1 - strb r0, [r5, 0x1] - movs r0, 0x11 - strb r0, [r5, 0x1C] - adds r1, r5, 0 - adds r1, 0x41 - movs r0, 0x2 - strb r0, [r1] - adds r1, 0x1B - movs r0, 0x22 - strb r0, [r1] - adds r1, 0x25 - movs r0, 0x3 - strb r0, [r1] - adds r1, 0x1B - movs r0, 0x44 - strb r0, [r1] - adds r1, 0x24 - movs r0, 0x4 - strb r0, [r1, 0x1] - movs r0, 0x88 - strb r0, [r1, 0x1C] - str r6, [r4] -_082E0458: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_082E0460: .4byte 0x04000084 -_082E0464: .4byte 0x04000080 -_082E0468: .4byte 0x04000063 -_082E046C: .4byte gUnknown_03007FF0 -_082E0470: .4byte 0x68736d53 -_082E0474: .4byte gUnknown_03007460 -_082E0478: .4byte ply_memacc -_082E047C: .4byte ply_lfos_rev01 -_082E0480: .4byte ply_mod_rev01 -_082E0484: .4byte ply_xcmd -_082E0488: .4byte ply_endtie_rev01 -_082E048C: .4byte SampFreqSet_rev01 -_082E0490: .4byte TrackStop_rev01 -_082E0494: .4byte FadeOutBody_rev01 -_082E0498: .4byte TrkVolPitSet_rev01 -_082E049C: .4byte CgbSound -_082E04A0: .4byte CgbOscOff -_082E04A4: .4byte MidiKey2CgbFr -_082E04A8: .4byte 0x00000000 -_082E04AC: .4byte 0x05000040 - thumb_func_end MPlayExtender - - thumb_func_start MusicPlayerJumpTableCopy -MusicPlayerJumpTableCopy: @ 82E04B0 - swi 0x2A - bx lr - thumb_func_end MusicPlayerJumpTableCopy - - thumb_func_start ClearChain_rev -ClearChain_rev: @ 82E04B4 - push {lr} - ldr r1, _082E04C4 - ldr r1, [r1] - bl _call_via_r1 - pop {r0} - bx r0 - .align 2, 0 -_082E04C4: .4byte gUnknown_030074E8 - thumb_func_end ClearChain_rev - - thumb_func_start Clear64byte_rev -Clear64byte_rev: @ 82E04C8 - push {lr} - ldr r1, _082E04D8 - ldr r1, [r1] - bl _call_via_r1 - pop {r0} - bx r0 - .align 2, 0 -_082E04D8: .4byte gUnknown_030074EC - thumb_func_end Clear64byte_rev - - thumb_func_start SoundInit_rev01 -@ int SoundInit_rev01(void *dest) -SoundInit_rev01: @ 82E04DC - push {r4,r5,lr} - sub sp, 0x4 - adds r5, r0, 0 - movs r3, 0 - str r3, [r5] - ldr r1, _082E0594 - ldr r0, [r1] - movs r2, 0x80 - lsls r2, 18 - ands r0, r2 - cmp r0, 0 - beq _082E04F8 - ldr r0, _082E0598 - str r0, [r1] -_082E04F8: - ldr r1, _082E059C - ldr r0, [r1] - ands r0, r2 - cmp r0, 0 - beq _082E0506 - ldr r0, _082E0598 - str r0, [r1] -_082E0506: - ldr r0, _082E05A0 - movs r2, 0x80 - lsls r2, 3 - adds r1, r2, 0 - strh r1, [r0] - adds r0, 0xC - strh r1, [r0] - ldr r1, _082E05A4 - movs r0, 0x8F - strh r0, [r1] - subs r1, 0x2 - ldr r2, _082E05A8 - adds r0, r2, 0 - strh r0, [r1] - ldr r2, _082E05AC - ldrb r1, [r2] - movs r0, 0x3F - ands r0, r1 - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - ldr r1, _082E05B0 - movs r2, 0xD4 - lsls r2, 2 - adds r0, r5, r2 - str r0, [r1] - adds r1, 0x4 - ldr r0, _082E05B4 - str r0, [r1] - adds r1, 0x8 - movs r2, 0x98 - lsls r2, 4 - adds r0, r5, r2 - str r0, [r1] - adds r1, 0x4 - ldr r0, _082E05B8 - str r0, [r1] - ldr r0, _082E05BC - str r5, [r0] - str r3, [sp] - ldr r2, _082E05C0 - mov r0, sp - adds r1, r5, 0 - bl CpuSet - movs r0, 0x8 - strb r0, [r5, 0x6] - movs r0, 0xF - strb r0, [r5, 0x7] - ldr r0, _082E05C4 - str r0, [r5, 0x38] - ldr r0, _082E05C8 - str r0, [r5, 0x28] - str r0, [r5, 0x2C] - str r0, [r5, 0x30] - str r0, [r5, 0x3C] - ldr r4, _082E05CC - adds r0, r4, 0 - bl MPlyJmpTblCopy - str r4, [r5, 0x34] - movs r0, 0x80 - lsls r0, 11 - bl SampFreqSet_rev01 - ldr r0, _082E05D0 - str r0, [r5] - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_082E0594: .4byte 0x040000c4 -_082E0598: .4byte 0x84400004 -_082E059C: .4byte 0x040000d0 -_082E05A0: .4byte 0x040000c6 -_082E05A4: .4byte 0x04000084 -_082E05A8: .4byte 0x0000a90e -_082E05AC: .4byte 0x04000089 -_082E05B0: .4byte 0x040000bc -_082E05B4: .4byte 0x040000a0 -_082E05B8: .4byte 0x040000a4 -_082E05BC: .4byte gUnknown_03007FF0 -_082E05C0: .4byte 0x050003ec -_082E05C4: .4byte ply_note_rev01 -_082E05C8: .4byte DummyFunc_rev -_082E05CC: .4byte gUnknown_03007460 -_082E05D0: .4byte 0x68736d53 - thumb_func_end SoundInit_rev01 - - thumb_func_start SampFreqSet_rev01 -SampFreqSet_rev01: @ 82E05D4 - push {r4-r6,lr} - adds r2, r0, 0 - ldr r0, _082E0654 - ldr r4, [r0] - movs r0, 0xF0 - lsls r0, 12 - ands r0, r2 - lsrs r2, r0, 16 - movs r6, 0 - strb r2, [r4, 0x8] - ldr r1, _082E0658 - subs r0, r2, 0x1 - lsls r0, 1 - adds r0, r1 - ldrh r5, [r0] - str r5, [r4, 0x10] - movs r0, 0xC6 - lsls r0, 3 - adds r1, r5, 0 - bl __divsi3 - strb r0, [r4, 0xB] - ldr r0, _082E065C - muls r0, r5 - ldr r1, _082E0660 - adds r0, r1 - ldr r1, _082E0664 - bl __divsi3 - adds r1, r0, 0 - str r1, [r4, 0x14] - movs r0, 0x80 - lsls r0, 17 - bl __divsi3 - adds r0, 0x1 - asrs r0, 1 - str r0, [r4, 0x18] - ldr r0, _082E0668 - strh r6, [r0] - ldr r4, _082E066C - ldr r0, _082E0670 - adds r1, r5, 0 - bl __divsi3 - negs r0, r0 - strh r0, [r4] - bl SoundVSyncOn_rev01 - ldr r1, _082E0674 -_082E0638: - ldrb r0, [r1] - cmp r0, 0x9F - beq _082E0638 - ldr r1, _082E0674 -_082E0640: - ldrb r0, [r1] - cmp r0, 0x9F - bne _082E0640 - ldr r1, _082E0668 - movs r0, 0x80 - strh r0, [r1] - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_082E0654: .4byte gUnknown_03007FF0 -_082E0658: .4byte gUnknown_08675B64 -_082E065C: .4byte 0x00091d1b -_082E0660: .4byte 0x00001388 -_082E0664: .4byte 0x00002710 -_082E0668: .4byte 0x04000102 -_082E066C: .4byte 0x04000100 -_082E0670: .4byte 0x00044940 -_082E0674: .4byte 0x04000006 - thumb_func_end SampFreqSet_rev01 - - thumb_func_start SoundMode_rev01 -SoundMode_rev01: @ 82E0678 - push {r4,r5,lr} - adds r3, r0, 0 - ldr r0, _082E0704 - ldr r5, [r0] - ldr r1, [r5] - ldr r0, _082E0708 - cmp r1, r0 - bne _082E06FE - adds r0, r1, 0x1 - str r0, [r5] - movs r4, 0xFF - ands r4, r3 - cmp r4, 0 - beq _082E069A - movs r0, 0x7F - ands r4, r0 - strb r4, [r5, 0x5] -_082E069A: - movs r4, 0xF0 - lsls r4, 4 - ands r4, r3 - cmp r4, 0 - beq _082E06BA - lsrs r0, r4, 8 - strb r0, [r5, 0x6] - movs r4, 0xC - adds r0, r5, 0 - adds r0, 0x50 - movs r1, 0 -_082E06B0: - strb r1, [r0] - subs r4, 0x1 - adds r0, 0x40 - cmp r4, 0 - bne _082E06B0 -_082E06BA: - movs r4, 0xF0 - lsls r4, 8 - ands r4, r3 - cmp r4, 0 - beq _082E06C8 - lsrs r0, r4, 12 - strb r0, [r5, 0x7] -_082E06C8: - movs r4, 0xB0 - lsls r4, 16 - ands r4, r3 - cmp r4, 0 - beq _082E06E6 - movs r0, 0xC0 - lsls r0, 14 - ands r0, r4 - lsrs r4, r0, 14 - ldr r2, _082E070C - ldrb r1, [r2] - movs r0, 0x3F - ands r0, r1 - orrs r0, r4 - strb r0, [r2] -_082E06E6: - movs r4, 0xF0 - lsls r4, 12 - ands r4, r3 - cmp r4, 0 - beq _082E06FA - bl SoundVSyncOff_rev01 - adds r0, r4, 0 - bl SampFreqSet_rev01 -_082E06FA: - ldr r0, _082E0708 - str r0, [r5] -_082E06FE: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_082E0704: .4byte gUnknown_03007FF0 -_082E0708: .4byte 0x68736d53 -_082E070C: .4byte 0x04000089 - thumb_func_end SoundMode_rev01 - - thumb_func_start SoundClear_rev01 -SoundClear_rev01: @ 82E0710 - push {r4-r7,lr} - ldr r0, _082E075C - ldr r6, [r0] - ldr r1, [r6] - ldr r0, _082E0760 - cmp r1, r0 - bne _082E0756 - adds r0, r1, 0x1 - str r0, [r6] - movs r5, 0xC - adds r4, r6, 0 - adds r4, 0x50 - movs r0, 0 -_082E072A: - strb r0, [r4] - subs r5, 0x1 - adds r4, 0x40 - cmp r5, 0 - bgt _082E072A - ldr r4, [r6, 0x1C] - cmp r4, 0 - beq _082E0752 - movs r5, 0x1 - movs r7, 0 -_082E073E: - lsls r0, r5, 24 - lsrs r0, 24 - ldr r1, [r6, 0x2C] - bl _call_via_r1 - strb r7, [r4] - adds r5, 0x1 - adds r4, 0x40 - cmp r5, 0x4 - ble _082E073E -_082E0752: - ldr r0, _082E0760 - str r0, [r6] -_082E0756: - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_082E075C: .4byte gUnknown_03007FF0 -_082E0760: .4byte 0x68736d53 - thumb_func_end SoundClear_rev01 - - thumb_func_start SoundVSyncOff_rev01 -SoundVSyncOff_rev01: @ 82E0764 - push {lr} - sub sp, 0x4 - ldr r0, _082E07C4 - ldr r2, [r0] - ldr r1, [r2] - ldr r3, _082E07C8 - adds r0, r1, r3 - cmp r0, 0x1 - bhi _082E07BC - adds r0, r1, 0 - adds r0, 0xA - str r0, [r2] - ldr r1, _082E07CC - ldr r0, [r1] - movs r3, 0x80 - lsls r3, 18 - ands r0, r3 - cmp r0, 0 - beq _082E078E - ldr r0, _082E07D0 - str r0, [r1] -_082E078E: - ldr r1, _082E07D4 - ldr r0, [r1] - ands r0, r3 - cmp r0, 0 - beq _082E079C - ldr r0, _082E07D0 - str r0, [r1] -_082E079C: - ldr r0, _082E07D8 - movs r3, 0x80 - lsls r3, 3 - adds r1, r3, 0 - strh r1, [r0] - adds r0, 0xC - strh r1, [r0] - movs r0, 0 - str r0, [sp] - movs r0, 0xD4 - lsls r0, 2 - adds r1, r2, r0 - ldr r2, _082E07DC - mov r0, sp - bl CpuSet -_082E07BC: - add sp, 0x4 - pop {r0} - bx r0 - .align 2, 0 -_082E07C4: .4byte gUnknown_03007FF0 -_082E07C8: .4byte 0x978c92ad -_082E07CC: .4byte 0x040000c4 -_082E07D0: .4byte 0x84400004 -_082E07D4: .4byte 0x040000d0 -_082E07D8: .4byte 0x040000c6 -_082E07DC: .4byte 0x05000318 - thumb_func_end SoundVSyncOff_rev01 - - thumb_func_start SoundVSyncOn_rev01 -SoundVSyncOn_rev01: @ 82E07E0 - push {r4,lr} - ldr r0, _082E0810 - ldr r2, [r0] - ldr r3, [r2] - ldr r0, _082E0814 - cmp r3, r0 - beq _082E0808 - ldr r0, _082E0818 - movs r4, 0xB6 - lsls r4, 8 - adds r1, r4, 0 - strh r1, [r0] - adds r0, 0xC - strh r1, [r0] - ldrb r0, [r2, 0x4] - movs r0, 0 - strb r0, [r2, 0x4] - adds r0, r3, 0 - subs r0, 0xA - str r0, [r2] -_082E0808: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_082E0810: .4byte gUnknown_03007FF0 -_082E0814: .4byte 0x68736d53 -_082E0818: .4byte 0x040000c6 - thumb_func_end SoundVSyncOn_rev01 - - thumb_func_start MPlayOpen_rev01 -MPlayOpen_rev01: @ 82E081C - push {r4-r7,lr} - adds r7, r0, 0 - adds r6, r1, 0 - lsls r2, 24 - lsrs r4, r2, 24 - cmp r4, 0 - beq _082E0880 - cmp r4, 0x10 - bls _082E0830 - movs r4, 0x10 -_082E0830: - ldr r0, _082E0888 - ldr r5, [r0] - ldr r1, [r5] - ldr r0, _082E088C - cmp r1, r0 - bne _082E0880 - adds r0, r1, 0x1 - str r0, [r5] - adds r0, r7, 0 - bl Clear64byte_rev - str r6, [r7, 0x2C] - strb r4, [r7, 0x8] - movs r0, 0x80 - lsls r0, 24 - str r0, [r7, 0x4] - cmp r4, 0 - beq _082E0864 - movs r1, 0 -_082E0856: - strb r1, [r6] - subs r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, 0x50 - cmp r4, 0 - bne _082E0856 -_082E0864: - ldr r0, [r5, 0x20] - cmp r0, 0 - beq _082E0874 - str r0, [r7, 0x38] - ldr r0, [r5, 0x24] - str r0, [r7, 0x3C] - movs r0, 0 - str r0, [r5, 0x20] -_082E0874: - str r7, [r5, 0x24] - ldr r0, _082E0890 - str r0, [r5, 0x20] - ldr r0, _082E088C - str r0, [r5] - str r0, [r7, 0x34] -_082E0880: - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_082E0888: .4byte gUnknown_03007FF0 -_082E088C: .4byte 0x68736d53 -_082E0890: .4byte MPlayMain_rev01 - thumb_func_end MPlayOpen_rev01 - - thumb_func_start MPlayStart_rev01 -MPlayStart_rev01: @ 82E0894 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r5, r0, 0 - adds r7, r1, 0 - ldr r1, [r5, 0x34] - ldr r0, _082E0974 - cmp r1, r0 - bne _082E096A - ldrb r0, [r5, 0xB] - ldrb r2, [r7, 0x2] - cmp r0, 0 - beq _082E08D6 - ldr r0, [r5] - cmp r0, 0 - beq _082E08C0 - ldr r1, [r5, 0x2C] - movs r0, 0x40 - ldrb r1, [r1] - ands r0, r1 - cmp r0, 0 - bne _082E08CC -_082E08C0: - ldr r1, [r5, 0x4] - ldrh r0, [r5, 0x4] - cmp r0, 0 - beq _082E08D6 - cmp r1, 0 - blt _082E08D6 -_082E08CC: - ldrb r0, [r7, 0x2] - adds r2, r0, 0 - ldrb r0, [r5, 0x9] - cmp r0, r2 - bhi _082E096A -_082E08D6: - ldr r0, [r5, 0x34] - adds r0, 0x1 - str r0, [r5, 0x34] - movs r1, 0 - str r1, [r5, 0x4] - str r7, [r5] - ldr r0, [r7, 0x4] - str r0, [r5, 0x30] - strb r2, [r5, 0x9] - str r1, [r5, 0xC] - movs r0, 0x96 - strh r0, [r5, 0x1C] - strh r0, [r5, 0x20] - adds r0, 0x6A - strh r0, [r5, 0x1E] - strh r1, [r5, 0x22] - strh r1, [r5, 0x24] - movs r6, 0 - ldr r4, [r5, 0x2C] - ldrb r1, [r7] - cmp r6, r1 - bge _082E0936 - ldrb r0, [r5, 0x8] - cmp r6, r0 - bge _082E0956 - mov r8, r6 -_082E090A: - adds r0, r5, 0 - adds r1, r4, 0 - bl TrackStop_rev01 - movs r0, 0xC0 - strb r0, [r4] - mov r1, r8 - str r1, [r4, 0x20] - lsls r1, r6, 2 - adds r0, r7, 0 - adds r0, 0x8 - adds r0, r1 - ldr r0, [r0] - str r0, [r4, 0x40] - adds r6, 0x1 - adds r4, 0x50 - ldrb r0, [r7] - cmp r6, r0 - bge _082E0936 - ldrb r1, [r5, 0x8] - cmp r6, r1 - blt _082E090A -_082E0936: - ldrb r0, [r5, 0x8] - cmp r6, r0 - bge _082E0956 - movs r1, 0 - mov r8, r1 -_082E0940: - adds r0, r5, 0 - adds r1, r4, 0 - bl TrackStop_rev01 - mov r0, r8 - strb r0, [r4] - adds r6, 0x1 - adds r4, 0x50 - ldrb r1, [r5, 0x8] - cmp r6, r1 - blt _082E0940 -_082E0956: - movs r0, 0x80 - ldrb r1, [r7, 0x3] - ands r0, r1 - cmp r0, 0 - beq _082E0966 - ldrb r0, [r7, 0x3] - bl SoundMode_rev01 -_082E0966: - ldr r0, _082E0974 - str r0, [r5, 0x34] -_082E096A: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_082E0974: .4byte 0x68736d53 - thumb_func_end MPlayStart_rev01 - - thumb_func_start MPlayStop_rev01 -MPlayStop_rev01: @ 82E0978 - push {r4-r6,lr} - adds r6, r0, 0 - ldr r1, [r6, 0x34] - ldr r0, _082E09B4 - cmp r1, r0 - bne _082E09AE - adds r0, r1, 0x1 - str r0, [r6, 0x34] - ldr r0, [r6, 0x4] - movs r1, 0x80 - lsls r1, 24 - orrs r0, r1 - str r0, [r6, 0x4] - ldrb r4, [r6, 0x8] - ldr r5, [r6, 0x2C] - cmp r4, 0 - ble _082E09AA -_082E099A: - adds r0, r6, 0 - adds r1, r5, 0 - bl TrackStop_rev01 - subs r4, 0x1 - adds r5, 0x50 - cmp r4, 0 - bgt _082E099A -_082E09AA: - ldr r0, _082E09B4 - str r0, [r6, 0x34] -_082E09AE: - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_082E09B4: .4byte 0x68736d53 - thumb_func_end MPlayStop_rev01 - - thumb_func_start FadeOutBody_rev01 -FadeOutBody_rev01: @ 82E09B8 - push {r4-r7,lr} - adds r6, r0, 0 - ldrh r1, [r6, 0x24] - cmp r1, 0 - beq _082E0A7A - ldrh r0, [r6, 0x26] - subs r0, 0x1 - strh r0, [r6, 0x26] - ldr r3, _082E09F8 - adds r2, r3, 0 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0 - bne _082E0A7A - strh r1, [r6, 0x26] - ldrh r1, [r6, 0x28] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _082E09FC - adds r0, r1, 0 - adds r0, 0x10 - strh r0, [r6, 0x28] - ands r0, r2 - cmp r0, 0xFF - bls _082E0A4E - movs r0, 0x80 - lsls r0, 1 - strh r0, [r6, 0x28] - strh r3, [r6, 0x24] - b _082E0A4E - .align 2, 0 -_082E09F8: .4byte 0x0000ffff -_082E09FC: - adds r0, r1, 0 - subs r0, 0x10 - strh r0, [r6, 0x28] - ands r0, r2 - lsls r0, 16 - cmp r0, 0 - bgt _082E0A4E - ldrb r5, [r6, 0x8] - ldr r4, [r6, 0x2C] - cmp r5, 0 - ble _082E0A2E -_082E0A12: - adds r0, r6, 0 - adds r1, r4, 0 - bl TrackStop_rev01 - movs r0, 0x1 - ldrh r7, [r6, 0x28] - ands r0, r7 - cmp r0, 0 - bne _082E0A26 - strb r0, [r4] -_082E0A26: - subs r5, 0x1 - adds r4, 0x50 - cmp r5, 0 - bgt _082E0A12 -_082E0A2E: - movs r0, 0x1 - ldrh r1, [r6, 0x28] - ands r0, r1 - cmp r0, 0 - beq _082E0A42 - ldr r0, [r6, 0x4] - movs r1, 0x80 - lsls r1, 24 - orrs r0, r1 - b _082E0A46 -_082E0A42: - movs r0, 0x80 - lsls r0, 24 -_082E0A46: - str r0, [r6, 0x4] - movs r0, 0 - strh r0, [r6, 0x24] - b _082E0A7A -_082E0A4E: - ldrb r5, [r6, 0x8] - ldr r4, [r6, 0x2C] - cmp r5, 0 - ble _082E0A7A - movs r3, 0x80 - movs r7, 0 - movs r2, 0x3 -_082E0A5C: - ldrb r1, [r4] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _082E0A72 - ldrh r7, [r6, 0x28] - lsrs r0, r7, 2 - strb r0, [r4, 0x13] - adds r0, r1, 0 - orrs r0, r2 - strb r0, [r4] -_082E0A72: - subs r5, 0x1 - adds r4, 0x50 - cmp r5, 0 - bgt _082E0A5C -_082E0A7A: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end FadeOutBody_rev01 - - thumb_func_start TrkVolPitSet_rev01 -TrkVolPitSet_rev01: @ 82E0A80 - push {r4,lr} - adds r2, r1, 0 - movs r0, 0x1 - ldrb r1, [r2] - ands r0, r1 - cmp r0, 0 - beq _082E0AE4 - ldrb r3, [r2, 0x13] - ldrb r1, [r2, 0x12] - adds r0, r3, 0 - muls r0, r1 - lsrs r3, r0, 5 - ldrb r4, [r2, 0x18] - cmp r4, 0x1 - bne _082E0AA8 - movs r0, 0x16 - ldrsb r0, [r2, r0] - adds r0, 0x80 - muls r0, r3 - lsrs r3, r0, 7 -_082E0AA8: - movs r0, 0x14 - ldrsb r0, [r2, r0] - lsls r0, 1 - movs r1, 0x15 - ldrsb r1, [r2, r1] - adds r1, r0, r1 - cmp r4, 0x2 - bne _082E0ABE - movs r0, 0x16 - ldrsb r0, [r2, r0] - adds r1, r0 -_082E0ABE: - movs r0, 0x80 - negs r0, r0 - cmp r1, r0 - bge _082E0ACA - adds r1, r0, 0 - b _082E0AD0 -_082E0ACA: - cmp r1, 0x7F - ble _082E0AD0 - movs r1, 0x7F -_082E0AD0: - adds r0, r1, 0 - adds r0, 0x80 - muls r0, r3 - lsrs r0, 8 - strb r0, [r2, 0x10] - movs r0, 0x7F - subs r0, r1 - muls r0, r3 - lsrs r0, 8 - strb r0, [r2, 0x11] -_082E0AE4: - ldrb r1, [r2] - movs r0, 0x4 - ands r0, r1 - adds r3, r1, 0 - cmp r0, 0 - beq _082E0B28 - movs r0, 0xE - ldrsb r0, [r2, r0] - ldrb r1, [r2, 0xF] - muls r0, r1 - movs r1, 0xC - ldrsb r1, [r2, r1] - adds r1, r0 - lsls r1, 2 - movs r0, 0xA - ldrsb r0, [r2, r0] - lsls r0, 8 - adds r1, r0 - movs r0, 0xB - ldrsb r0, [r2, r0] - lsls r0, 8 - adds r1, r0 - ldrb r0, [r2, 0xD] - adds r1, r0, r1 - ldrb r0, [r2, 0x18] - cmp r0, 0 - bne _082E0B22 - movs r0, 0x16 - ldrsb r0, [r2, r0] - lsls r0, 4 - adds r1, r0 -_082E0B22: - asrs r0, r1, 8 - strb r0, [r2, 0x8] - strb r1, [r2, 0x9] -_082E0B28: - movs r0, 0xFA - ands r0, r3 - strb r0, [r2] - pop {r4} - pop {r0} - bx r0 - thumb_func_end TrkVolPitSet_rev01 - - thumb_func_start MidiKey2CgbFr -MidiKey2CgbFr: @ 82E0B34 - push {r4-r7,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r5, r1, 24 - lsls r2, 24 - lsrs r2, 24 - mov r12, r2 - cmp r0, 0x4 - bne _082E0B6C - cmp r5, 0x14 - bhi _082E0B50 - movs r5, 0 - b _082E0B5E -_082E0B50: - adds r0, r5, 0 - subs r0, 0x15 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3B - bls _082E0B5E - movs r5, 0x3B -_082E0B5E: - ldr r0, _082E0B68 - adds r0, r5, r0 - ldrb r0, [r0] - b _082E0BCE - .align 2, 0 -_082E0B68: .4byte gUnknown_08675C18 -_082E0B6C: - cmp r5, 0x23 - bhi _082E0B78 - movs r0, 0 - mov r12, r0 - movs r5, 0 - b _082E0B8A -_082E0B78: - adds r0, r5, 0 - subs r0, 0x24 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x82 - bls _082E0B8A - movs r5, 0x82 - movs r1, 0xFF - mov r12, r1 -_082E0B8A: - ldr r3, _082E0BD4 - adds r0, r5, r3 - ldrb r6, [r0] - ldr r4, _082E0BD8 - movs r2, 0xF - adds r0, r6, 0 - ands r0, r2 - lsls r0, 1 - adds r0, r4 - movs r7, 0 - ldrsh r1, [r0, r7] - asrs r0, r6, 4 - adds r6, r1, 0 - asrs r6, r0 - adds r0, r5, 0x1 - adds r0, r3 - ldrb r1, [r0] - adds r0, r1, 0 - ands r0, r2 - lsls r0, 1 - adds r0, r4 - movs r2, 0 - ldrsh r0, [r0, r2] - asrs r1, 4 - asrs r0, r1 - subs r0, r6 - mov r7, r12 - muls r7, r0 - adds r0, r7, 0 - asrs r0, 8 - adds r0, r6, r0 - movs r1, 0x80 - lsls r1, 4 - adds r0, r1 -_082E0BCE: - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_082E0BD4: .4byte gUnknown_08675B7C -_082E0BD8: .4byte gUnknown_08675C00 - thumb_func_end MidiKey2CgbFr - - thumb_func_start CgbOscOff -CgbOscOff: @ 82E0BDC - lsls r0, 24 - lsrs r0, 24 - adds r1, r0, 0 - cmp r0, 0x2 - beq _082E0C04 - cmp r0, 0x2 - bgt _082E0BF0 - cmp r0, 0x1 - beq _082E0BF6 - b _082E0C18 -_082E0BF0: - cmp r1, 0x3 - beq _082E0C0C - b _082E0C18 -_082E0BF6: - ldr r1, _082E0C00 - movs r0, 0x8 - strb r0, [r1] - adds r1, 0x2 - b _082E0C20 - .align 2, 0 -_082E0C00: .4byte 0x04000063 -_082E0C04: - ldr r1, _082E0C08 - b _082E0C1A - .align 2, 0 -_082E0C08: .4byte 0x04000069 -_082E0C0C: - ldr r1, _082E0C14 - movs r0, 0 - b _082E0C22 - .align 2, 0 -_082E0C14: .4byte 0x04000070 -_082E0C18: - ldr r1, _082E0C28 -_082E0C1A: - movs r0, 0x8 - strb r0, [r1] - adds r1, 0x4 -_082E0C20: - movs r0, 0x80 -_082E0C22: - strb r0, [r1] - bx lr - .align 2, 0 -_082E0C28: .4byte 0x04000079 - thumb_func_end CgbOscOff - - thumb_func_start CgbModVol -CgbModVol: @ 82E0C2C - push {r4,lr} - adds r2, r0, 0 - ldr r0, _082E0C5C - ldr r1, [r0] - movs r0, 0x1 - ldrb r1, [r1, 0x9] - ands r0, r1 - cmp r0, 0 - bne _082E0C6C - ldrb r0, [r2, 0x2] - lsls r1, r0, 24 - lsrs r4, r1, 24 - ldrb r3, [r2, 0x3] - lsls r0, r3, 24 - lsrs r3, r0, 24 - cmp r4, r3 - bcc _082E0C60 - lsrs r0, r1, 25 - cmp r0, r3 - bcc _082E0C6C - movs r0, 0xF - strb r0, [r2, 0x1B] - b _082E0C7A - .align 2, 0 -_082E0C5C: .4byte gUnknown_03007FF0 -_082E0C60: - lsrs r0, 25 - cmp r0, r4 - bcc _082E0C6C - movs r0, 0xF0 - strb r0, [r2, 0x1B] - b _082E0C7A -_082E0C6C: - movs r0, 0xFF - strb r0, [r2, 0x1B] - ldrb r1, [r2, 0x3] - ldrb r3, [r2, 0x2] - adds r0, r1, r3 - lsrs r0, 4 - b _082E0C8A -_082E0C7A: - ldrb r1, [r2, 0x3] - ldrb r3, [r2, 0x2] - adds r0, r1, r3 - lsrs r0, 4 - strb r0, [r2, 0xA] - cmp r0, 0xF - bls _082E0C8C - movs r0, 0xF -_082E0C8A: - strb r0, [r2, 0xA] -_082E0C8C: - ldrb r1, [r2, 0x6] - ldrb r3, [r2, 0xA] - adds r0, r1, 0 - muls r0, r3 - adds r0, 0xF - asrs r0, 4 - strb r0, [r2, 0x19] - ldrb r0, [r2, 0x1C] - ldrb r1, [r2, 0x1B] - ands r0, r1 - strb r0, [r2, 0x1B] - pop {r4} - pop {r0} - bx r0 - thumb_func_end CgbModVol - - thumb_func_start CgbSound -CgbSound: @ 82E0CA8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - ldr r0, _082E0CC8 - ldr r0, [r0] - str r0, [sp, 0x4] - ldrb r0, [r0, 0xA] - cmp r0, 0 - beq _082E0CCC - subs r0, 0x1 - ldr r1, [sp, 0x4] - strb r0, [r1, 0xA] - b _082E0CD2 - .align 2, 0 -_082E0CC8: .4byte gUnknown_03007FF0 -_082E0CCC: - movs r0, 0xE - ldr r2, [sp, 0x4] - strb r0, [r2, 0xA] -_082E0CD2: - movs r6, 0x1 - ldr r0, [sp, 0x4] - ldr r4, [r0, 0x1C] -_082E0CD8: - 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 _082E0CEE - b _082E10D8 -_082E0CEE: - cmp r6, 0x2 - beq _082E0D20 - cmp r6, 0x2 - bgt _082E0CFC - cmp r6, 0x1 - beq _082E0D02 - b _082E0D58 -_082E0CFC: - cmp r6, 0x3 - beq _082E0D38 - b _082E0D58 -_082E0D02: - ldr r0, _082E0D14 - str r0, [sp, 0x8] - ldr r7, _082E0D18 - ldr r2, _082E0D1C - str r2, [sp, 0xC] - adds r0, 0x4 - str r0, [sp, 0x10] - adds r2, 0x2 - b _082E0D68 - .align 2, 0 -_082E0D14: .4byte 0x04000060 -_082E0D18: .4byte 0x04000062 -_082E0D1C: .4byte 0x04000063 -_082E0D20: - ldr r0, _082E0D2C - str r0, [sp, 0x8] - ldr r7, _082E0D30 - ldr r2, _082E0D34 - b _082E0D60 - .align 2, 0 -_082E0D2C: .4byte 0x04000061 -_082E0D30: .4byte 0x04000068 -_082E0D34: .4byte 0x04000069 -_082E0D38: - ldr r0, _082E0D4C - str r0, [sp, 0x8] - ldr r7, _082E0D50 - ldr r2, _082E0D54 - str r2, [sp, 0xC] - adds r0, 0x4 - str r0, [sp, 0x10] - adds r2, 0x2 - b _082E0D68 - .align 2, 0 -_082E0D4C: .4byte 0x04000070 -_082E0D50: .4byte 0x04000072 -_082E0D54: .4byte 0x04000073 -_082E0D58: - ldr r0, _082E0DB8 - str r0, [sp, 0x8] - ldr r7, _082E0DBC - ldr r2, _082E0DC0 -_082E0D60: - str r2, [sp, 0xC] - adds r0, 0xB - str r0, [sp, 0x10] - adds r2, 0x4 -_082E0D68: - 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 _082E0E5E - 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 _082E0E82 - 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 _082E0DD0 - cmp r6, 0x2 - bgt _082E0DC4 - cmp r6, 0x1 - beq _082E0DCA - b _082E0E24 - .align 2, 0 -_082E0DB8: .4byte 0x04000071 -_082E0DBC: .4byte 0x04000078 -_082E0DC0: .4byte 0x04000079 -_082E0DC4: - cmp r6, 0x3 - beq _082E0DDC - b _082E0E24 -_082E0DCA: - ldrb r0, [r4, 0x1F] - ldr r2, [sp, 0x8] - strb r0, [r2] -_082E0DD0: - ldr r0, [r4, 0x24] - lsls r0, 6 - ldrb r1, [r4, 0x1E] - adds r0, r1, r0 - strb r0, [r7] - b _082E0E30 -_082E0DDC: - ldr r1, [r4, 0x24] - ldr r0, [r4, 0x28] - cmp r1, r0 - beq _082E0E04 - ldr r2, [sp, 0x8] - strb r3, [r2] - ldr r1, _082E0E18 - 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] -_082E0E04: - ldr r0, [sp, 0x8] - strb r5, [r0] - ldrb r0, [r4, 0x1E] - strb r0, [r7] - ldrb r0, [r4, 0x1E] - cmp r0, 0 - beq _082E0E1C - movs r0, 0xC0 - b _082E0E3E - .align 2, 0 -_082E0E18: .4byte 0x04000090 -_082E0E1C: - movs r1, 0x80 - negs r1, r1 - strb r1, [r4, 0x1A] - b _082E0E40 -_082E0E24: - ldrb r0, [r4, 0x1E] - strb r0, [r7] - ldr r0, [r4, 0x24] - lsls r0, 3 - ldr r2, [sp, 0x10] - strb r0, [r2] -_082E0E30: - ldrb r0, [r4, 0x4] - adds r0, 0x8 - mov r8, r0 - ldrb r0, [r4, 0x1E] - cmp r0, 0 - beq _082E0E3E - movs r0, 0x40 -_082E0E3E: - strb r0, [r4, 0x1A] -_082E0E40: - 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 _082E0E5A - b _082E0F96 -_082E0E5A: - strb r2, [r4, 0x9] - b _082E0FC4 -_082E0E5E: - movs r0, 0x4 - ands r0, r2 - cmp r0, 0 - beq _082E0E90 - 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 _082E0E82 - b _082E0FD6 -_082E0E82: - lsls r0, r6, 24 - lsrs r0, 24 - bl CgbOscOff - movs r0, 0 - strb r0, [r4] - b _082E10D4 -_082E0E90: - 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 _082E0ED0 - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _082E0ED0 - 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 _082E0F02 - movs r0, 0x1 - ldrb r1, [r4, 0x1D] - orrs r0, r1 - strb r0, [r4, 0x1D] - cmp r6, 0x3 - beq _082E0FC4 - ldrb r2, [r4, 0x7] - mov r8, r2 - b _082E0FC4 -_082E0ED0: - ldrb r0, [r4, 0xB] - cmp r0, 0 - bne _082E0FC4 - cmp r6, 0x3 - bne _082E0EE2 - movs r0, 0x1 - ldrb r1, [r4, 0x1D] - orrs r0, r1 - strb r0, [r4, 0x1D] -_082E0EE2: - adds r0, r4, 0 - bl CgbModVol - movs r0, 0x3 - ldrb r2, [r4] - ands r0, r2 - cmp r0, 0 - bne _082E0F36 - ldrb r0, [r4, 0x9] - subs r0, 0x1 - strb r0, [r4, 0x9] - movs r1, 0xFF - ands r0, r1 - lsls r0, 24 - cmp r0, 0 - bgt _082E0F32 -_082E0F02: - 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 _082E0E82 - 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 _082E0FD6 - movs r2, 0x8 - mov r8, r2 - b _082E0FD6 -_082E0F32: - ldrb r0, [r4, 0x7] - b _082E0FC2 -_082E0F36: - cmp r0, 0x1 - bne _082E0F42 -_082E0F3A: - ldrb r0, [r4, 0x19] - strb r0, [r4, 0x9] - movs r0, 0x7 - b _082E0FC2 -_082E0F42: - cmp r0, 0x2 - bne _082E0F86 - 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 _082E0F82 -_082E0F5A: - ldrb r0, [r4, 0x6] - cmp r0, 0 - bne _082E0F6A - movs r0, 0xFC - ldrb r1, [r4] - ands r0, r1 - strb r0, [r4] - b _082E0F02 -_082E0F6A: - 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 _082E0F3A - movs r0, 0x8 - mov r8, r0 - b _082E0F3A -_082E0F82: - ldrb r0, [r4, 0x5] - b _082E0FC2 -_082E0F86: - 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 _082E0FC0 -_082E0F96: - 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 _082E0F5A - 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 _082E0FC4 - ldrb r2, [r4, 0x5] - mov r8, r2 - b _082E0FC4 -_082E0FC0: - ldrb r0, [r4, 0x4] -_082E0FC2: - strb r0, [r4, 0xB] -_082E0FC4: - ldrb r0, [r4, 0xB] - subs r0, 0x1 - strb r0, [r4, 0xB] - ldr r0, [sp] - cmp r0, 0 - bne _082E0FD6 - subs r0, 0x1 - str r0, [sp] - b _082E0ED0 -_082E0FD6: - movs r0, 0x2 - ldrb r1, [r4, 0x1D] - ands r0, r1 - cmp r0, 0 - beq _082E104E - cmp r6, 0x3 - bgt _082E1016 - movs r0, 0x8 - ldrb r2, [r4, 0x1] - ands r0, r2 - cmp r0, 0 - beq _082E1016 - ldr r0, _082E1000 - ldrb r0, [r0] - cmp r0, 0x3F - bgt _082E1008 - ldr r0, [r4, 0x20] - adds r0, 0x2 - ldr r1, _082E1004 - b _082E1012 - .align 2, 0 -_082E1000: .4byte 0x04000089 -_082E1004: .4byte 0x000007fc -_082E1008: - cmp r0, 0x7F - bgt _082E1016 - ldr r0, [r4, 0x20] - adds r0, 0x1 - ldr r1, _082E1024 -_082E1012: - ands r0, r1 - str r0, [r4, 0x20] -_082E1016: - cmp r6, 0x4 - beq _082E1028 - ldr r0, [r4, 0x20] - ldr r1, [sp, 0x10] - strb r0, [r1] - b _082E1036 - .align 2, 0 -_082E1024: .4byte 0x000007fe -_082E1028: - ldr r2, [sp, 0x10] - ldrb r0, [r2] - movs r1, 0x8 - ands r1, r0 - ldr r0, [r4, 0x20] - orrs r0, r1 - strb r0, [r2] -_082E1036: - 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] -_082E104E: - movs r0, 0x1 - ldrb r2, [r4, 0x1D] - ands r0, r2 - cmp r0, 0 - beq _082E10D4 - ldr r1, _082E1098 - ldrb r0, [r1] - ldrb r2, [r4, 0x1C] - bics r0, r2 - ldrb r2, [r4, 0x1B] - orrs r0, r2 - strb r0, [r1] - cmp r6, 0x3 - bne _082E10A0 - ldr r0, _082E109C - 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 _082E10D4 - 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 _082E10D4 - .align 2, 0 -_082E1098: .4byte 0x04000081 -_082E109C: .4byte gUnknown_08675C54 -_082E10A0: - 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 _082E10D4 - ldr r0, [sp, 0x8] - ldrb r1, [r0] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - bne _082E10D4 - ldrb r0, [r4, 0x1A] - orrs r0, r2 - ldr r1, [sp, 0x14] - strb r0, [r1] -_082E10D4: - movs r0, 0 - strb r0, [r4, 0x1D] -_082E10D8: - mov r6, r10 - mov r4, r9 - cmp r6, 0x4 - bgt _082E10E2 - b _082E0CD8 -_082E10E2: - 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 - - thumb_func_start MPlayTempoControl -MPlayTempoControl: @ 82E10F4 - push {r4,lr} - adds r2, r0, 0 - lsls r1, 16 - lsrs r1, 16 - ldr r3, [r2, 0x34] - ldr r0, _082E1118 - cmp r3, r0 - bne _082E1110 - strh r1, [r2, 0x1E] - ldrh r4, [r2, 0x1C] - adds r0, r1, 0 - muls r0, r4 - asrs r0, 8 - strh r0, [r2, 0x20] -_082E1110: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_082E1118: .4byte 0x68736d53 - thumb_func_end MPlayTempoControl - - thumb_func_start MPlayVolumeControl -MPlayVolumeControl: @ 82E111C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r4, r0, 0 - lsls r1, 16 - lsrs r7, r1, 16 - lsls r6, r2, 16 - ldr r3, [r4, 0x34] - ldr r0, _082E1180 - cmp r3, r0 - bne _082E1174 - adds r0, r3, 0x1 - str r0, [r4, 0x34] - ldrb r2, [r4, 0x8] - ldr r1, [r4, 0x2C] - movs r5, 0x1 - cmp r2, 0 - ble _082E1170 - movs r0, 0x80 - mov r8, r0 - lsrs r6, 18 - movs r0, 0x3 - mov r12, r0 -_082E114C: - adds r0, r7, 0 - ands r0, r5 - cmp r0, 0 - beq _082E1166 - ldrb r3, [r1] - mov r0, r8 - ands r0, r3 - cmp r0, 0 - beq _082E1166 - strb r6, [r1, 0x13] - mov r0, r12 - orrs r0, r3 - strb r0, [r1] -_082E1166: - subs r2, 0x1 - adds r1, 0x50 - lsls r5, 1 - cmp r2, 0 - bgt _082E114C -_082E1170: - ldr r0, _082E1180 - str r0, [r4, 0x34] -_082E1174: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_082E1180: .4byte 0x68736d53 - thumb_func_end MPlayVolumeControl - - thumb_func_start MPlayPitchControl -MPlayPitchControl: @ 82E1184 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r4, r0, 0 - lsls r1, 16 - lsrs r1, 16 - mov r12, r1 - lsls r2, 16 - lsrs r6, r2, 16 - ldr r3, [r4, 0x34] - ldr r0, _082E11F4 - cmp r3, r0 - bne _082E11E6 - adds r0, r3, 0x1 - str r0, [r4, 0x34] - ldrb r2, [r4, 0x8] - ldr r3, [r4, 0x2C] - movs r5, 0x1 - cmp r2, 0 - ble _082E11E2 - movs r0, 0x80 - mov r9, r0 - lsls r0, r6, 16 - asrs r7, r0, 24 - movs r0, 0xC - mov r8, r0 -_082E11BC: - mov r0, r12 - ands r0, r5 - cmp r0, 0 - beq _082E11D8 - ldrb r1, [r3] - mov r0, r9 - ands r0, r1 - cmp r0, 0 - beq _082E11D8 - strb r7, [r3, 0xB] - strb r6, [r3, 0xD] - mov r0, r8 - orrs r0, r1 - strb r0, [r3] -_082E11D8: - subs r2, 0x1 - adds r3, 0x50 - lsls r5, 1 - cmp r2, 0 - bgt _082E11BC -_082E11E2: - ldr r0, _082E11F4 - str r0, [r4, 0x34] -_082E11E6: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_082E11F4: .4byte 0x68736d53 - thumb_func_end MPlayPitchControl - - thumb_func_start MPlayPanpotControl -MPlayPanpotControl: @ 82E11F8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r4, r0, 0 - lsls r1, 16 - lsrs r7, r1, 16 - lsls r2, 24 - lsrs r6, r2, 24 - ldr r3, [r4, 0x34] - ldr r0, _082E125C - cmp r3, r0 - bne _082E1250 - adds r0, r3, 0x1 - str r0, [r4, 0x34] - ldrb r2, [r4, 0x8] - ldr r1, [r4, 0x2C] - movs r5, 0x1 - cmp r2, 0 - ble _082E124C - movs r0, 0x80 - mov r8, r0 - movs r0, 0x3 - mov r12, r0 -_082E1228: - adds r0, r7, 0 - ands r0, r5 - cmp r0, 0 - beq _082E1242 - ldrb r3, [r1] - mov r0, r8 - ands r0, r3 - cmp r0, 0 - beq _082E1242 - strb r6, [r1, 0x15] - mov r0, r12 - orrs r0, r3 - strb r0, [r1] -_082E1242: - subs r2, 0x1 - adds r1, 0x50 - lsls r5, 1 - cmp r2, 0 - bgt _082E1228 -_082E124C: - ldr r0, _082E125C - str r0, [r4, 0x34] -_082E1250: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_082E125C: .4byte 0x68736d53 - thumb_func_end MPlayPanpotControl - - thumb_func_start MP_clear_modM -MP_clear_modM: @ 82E1260 - adds r1, r0, 0 - movs r2, 0 - movs r0, 0 - strb r0, [r1, 0x1A] - strb r0, [r1, 0x16] - ldrb r0, [r1, 0x18] - cmp r0, 0 - bne _082E1274 - movs r0, 0xC - b _082E1276 -_082E1274: - movs r0, 0x3 -_082E1276: - ldrb r2, [r1] - orrs r0, r2 - strb r0, [r1] - bx lr - thumb_func_end MP_clear_modM - - thumb_func_start MPlayModDepthSet -MPlayModDepthSet: @ 82E1280 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r6, r0, 0 - lsls r1, 16 - lsrs r1, 16 - mov r10, r1 - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - ldr r1, [r6, 0x34] - ldr r0, _082E12F0 - cmp r1, r0 - bne _082E12E0 - adds r0, r1, 0x1 - str r0, [r6, 0x34] - ldrb r5, [r6, 0x8] - ldr r4, [r6, 0x2C] - movs r7, 0x1 - cmp r5, 0 - ble _082E12DC - mov r9, r8 -_082E12B0: - mov r0, r10 - ands r0, r7 - cmp r0, 0 - beq _082E12D2 - movs r0, 0x80 - ldrb r1, [r4] - ands r0, r1 - cmp r0, 0 - beq _082E12D2 - mov r0, r8 - strb r0, [r4, 0x17] - mov r1, r9 - cmp r1, 0 - bne _082E12D2 - adds r0, r4, 0 - bl MP_clear_modM -_082E12D2: - subs r5, 0x1 - adds r4, 0x50 - lsls r7, 1 - cmp r5, 0 - bgt _082E12B0 -_082E12DC: - ldr r0, _082E12F0 - str r0, [r6, 0x34] -_082E12E0: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_082E12F0: .4byte 0x68736d53 - thumb_func_end MPlayModDepthSet - - thumb_func_start MPlayLFOSpeedSet -MPlayLFOSpeedSet: @ 82E12F4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r6, r0, 0 - lsls r1, 16 - lsrs r1, 16 - mov r10, r1 - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - ldr r1, [r6, 0x34] - ldr r0, _082E1364 - cmp r1, r0 - bne _082E1354 - adds r0, r1, 0x1 - str r0, [r6, 0x34] - ldrb r5, [r6, 0x8] - ldr r4, [r6, 0x2C] - movs r7, 0x1 - cmp r5, 0 - ble _082E1350 - mov r9, r8 -_082E1324: - mov r0, r10 - ands r0, r7 - cmp r0, 0 - beq _082E1346 - movs r0, 0x80 - ldrb r1, [r4] - ands r0, r1 - cmp r0, 0 - beq _082E1346 - mov r0, r8 - strb r0, [r4, 0x19] - mov r1, r9 - cmp r1, 0 - bne _082E1346 - adds r0, r4, 0 - bl MP_clear_modM -_082E1346: - subs r5, 0x1 - adds r4, 0x50 - lsls r7, 1 - cmp r5, 0 - bgt _082E1324 -_082E1350: - ldr r0, _082E1364 - str r0, [r6, 0x34] -_082E1354: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_082E1364: .4byte 0x68736d53 - thumb_func_end MPlayLFOSpeedSet - - thumb_func_start ply_memacc -ply_memacc: @ 82E1368 - push {r4-r6,lr} - adds r4, r0, 0 - adds r6, r1, 0 - ldr r1, [r6, 0x40] - ldrb r5, [r1] - adds r2, r1, 0x1 - str r2, [r6, 0x40] - ldr r0, [r4, 0x18] - ldrb r1, [r1, 0x1] - adds r3, r1, r0 - adds r0, r2, 0x1 - str r0, [r6, 0x40] - ldrb r2, [r2, 0x1] - adds r0, 0x1 - str r0, [r6, 0x40] - cmp r5, 0x11 - bls _082E138C - b _082E14BA -_082E138C: - lsls r0, r5, 2 - ldr r1, _082E1398 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_082E1398: .4byte _082E139C - .align 2, 0 -_082E139C: - .4byte _082E13E4 - .4byte _082E13E8 - .4byte _082E13F0 - .4byte _082E13F8 - .4byte _082E1402 - .4byte _082E1410 - .4byte _082E141E - .4byte _082E1426 - .4byte _082E142E - .4byte _082E1436 - .4byte _082E143E - .4byte _082E1446 - .4byte _082E144E - .4byte _082E145C - .4byte _082E146A - .4byte _082E1478 - .4byte _082E1486 - .4byte _082E1494 -_082E13E4: - strb r2, [r3] - b _082E14BA -_082E13E8: - ldrb r1, [r3] - adds r0, r1, r2 - strb r0, [r3] - b _082E14BA -_082E13F0: - ldrb r1, [r3] - subs r0, r1, r2 - strb r0, [r3] - b _082E14BA -_082E13F8: - ldr r0, [r4, 0x18] - adds r0, r2 - ldrb r0, [r0] - strb r0, [r3] - b _082E14BA -_082E1402: - ldr r0, [r4, 0x18] - adds r0, r2 - ldrb r1, [r3] - ldrb r0, [r0] - adds r0, r1, r0 - strb r0, [r3] - b _082E14BA -_082E1410: - ldr r0, [r4, 0x18] - adds r0, r2 - ldrb r1, [r3] - ldrb r0, [r0] - subs r0, r1, r0 - strb r0, [r3] - b _082E14BA -_082E141E: - ldrb r3, [r3] - cmp r3, r2 - beq _082E14A0 - b _082E14B4 -_082E1426: - ldrb r3, [r3] - cmp r3, r2 - bne _082E14A0 - b _082E14B4 -_082E142E: - ldrb r3, [r3] - cmp r3, r2 - bhi _082E14A0 - b _082E14B4 -_082E1436: - ldrb r3, [r3] - cmp r3, r2 - bcs _082E14A0 - b _082E14B4 -_082E143E: - ldrb r3, [r3] - cmp r3, r2 - bls _082E14A0 - b _082E14B4 -_082E1446: - ldrb r3, [r3] - cmp r3, r2 - bcc _082E14A0 - b _082E14B4 -_082E144E: - ldr r0, [r4, 0x18] - adds r0, r2 - ldrb r3, [r3] - ldrb r0, [r0] - cmp r3, r0 - beq _082E14A0 - b _082E14B4 -_082E145C: - ldr r0, [r4, 0x18] - adds r0, r2 - ldrb r3, [r3] - ldrb r0, [r0] - cmp r3, r0 - bne _082E14A0 - b _082E14B4 -_082E146A: - ldr r0, [r4, 0x18] - adds r0, r2 - ldrb r3, [r3] - ldrb r0, [r0] - cmp r3, r0 - bhi _082E14A0 - b _082E14B4 -_082E1478: - ldr r0, [r4, 0x18] - adds r0, r2 - ldrb r3, [r3] - ldrb r0, [r0] - cmp r3, r0 - bcs _082E14A0 - b _082E14B4 -_082E1486: - ldr r0, [r4, 0x18] - adds r0, r2 - ldrb r3, [r3] - ldrb r0, [r0] - cmp r3, r0 - bls _082E14A0 - b _082E14B4 -_082E1494: - ldr r0, [r4, 0x18] - adds r0, r2 - ldrb r3, [r3] - ldrb r0, [r0] - cmp r3, r0 - bcs _082E14B4 -_082E14A0: - ldr r0, _082E14B0 - ldr r2, [r0] - adds r0, r4, 0 - adds r1, r6, 0 - bl _call_via_r2 - b _082E14BA - .align 2, 0 -_082E14B0: .4byte gUnknown_03007464 -_082E14B4: - ldr r0, [r6, 0x40] - adds r0, 0x4 - str r0, [r6, 0x40] -_082E14BA: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end ply_memacc - - thumb_func_start ply_xcmd -ply_xcmd: @ 82E14C0 - push {lr} - ldr r2, [r1, 0x40] - ldrb r3, [r2] - adds r2, 0x1 - str r2, [r1, 0x40] - ldr r2, _082E14DC - lsls r3, 2 - adds r3, r2 - ldr r2, [r3] - bl _call_via_r2 - pop {r0} - bx r0 - .align 2, 0 -_082E14DC: .4byte gUnknown_08675CCC - thumb_func_end ply_xcmd - - thumb_func_start ply_xxx -ply_xxx: @ 82E14E0 - push {lr} - ldr r2, _082E14F0 - ldr r2, [r2] - bl _call_via_r2 - pop {r0} - bx r0 - .align 2, 0 -_082E14F0: .4byte gUnknown_03007460 - thumb_func_end ply_xxx - - thumb_func_start ply_xwave -ply_xwave: @ 82E14F4 - push {r4,lr} - ldr r2, [r1, 0x40] - ldr r0, _082E152C - ands r4, r0 - ldrb r0, [r2] - orrs r4, r0 - ldrb r0, [r2, 0x1] - lsls r3, r0, 8 - ldr r0, _082E1530 - ands r4, r0 - orrs r4, r3 - ldrb r0, [r2, 0x2] - lsls r3, r0, 16 - ldr r0, _082E1534 - ands r4, r0 - orrs r4, r3 - ldrb r0, [r2, 0x3] - lsls r3, r0, 24 - ldr r0, _082E1538 - ands r4, r0 - orrs r4, r3 - str r4, [r1, 0x28] - adds r2, 0x4 - str r2, [r1, 0x40] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_082E152C: .4byte 0xffffff00 -_082E1530: .4byte 0xffff00ff -_082E1534: .4byte 0xff00ffff -_082E1538: .4byte 0x00ffffff - thumb_func_end ply_xwave - - thumb_func_start ply_xtype -ply_xtype: @ 82E153C - ldr r0, [r1, 0x40] - ldrb r2, [r0] - adds r0, r1, 0 - adds r0, 0x24 - strb r2, [r0] - ldr r0, [r1, 0x40] - adds r0, 0x1 - str r0, [r1, 0x40] - bx lr - thumb_func_end ply_xtype - - thumb_func_start ply_xatta -ply_xatta: @ 82E1550 - ldr r0, [r1, 0x40] - ldrb r2, [r0] - adds r0, r1, 0 - adds r0, 0x2C - strb r2, [r0] - ldr r0, [r1, 0x40] - adds r0, 0x1 - str r0, [r1, 0x40] - bx lr - thumb_func_end ply_xatta - - thumb_func_start ply_xdeca -ply_xdeca: @ 82E1564 - ldr r0, [r1, 0x40] - ldrb r0, [r0] - adds r2, r1, 0 - adds r2, 0x2D - strb r0, [r2] - ldr r0, [r1, 0x40] - adds r0, 0x1 - str r0, [r1, 0x40] - bx lr - thumb_func_end ply_xdeca - - thumb_func_start ply_xsust -ply_xsust: @ 82E1578 - ldr r0, [r1, 0x40] - ldrb r0, [r0] - adds r2, r1, 0 - adds r2, 0x2E - strb r0, [r2] - ldr r0, [r1, 0x40] - adds r0, 0x1 - str r0, [r1, 0x40] - bx lr - thumb_func_end ply_xsust - - thumb_func_start ply_xrele -ply_xrele: @ 82E158C - ldr r0, [r1, 0x40] - ldrb r0, [r0] - adds r2, r1, 0 - adds r2, 0x2F - strb r0, [r2] - ldr r0, [r1, 0x40] - adds r0, 0x1 - str r0, [r1, 0x40] - bx lr - thumb_func_end ply_xrele - - thumb_func_start ply_xiecv -ply_xiecv: @ 82E15A0 - ldr r0, [r1, 0x40] - ldrb r2, [r0] - strb r2, [r1, 0x1E] - adds r0, 0x1 - str r0, [r1, 0x40] - bx lr - thumb_func_end ply_xiecv - - thumb_func_start ply_xiecl -ply_xiecl: @ 82E15AC - ldr r0, [r1, 0x40] - ldrb r2, [r0] - strb r2, [r1, 0x1F] - adds r0, 0x1 - str r0, [r1, 0x40] - bx lr - thumb_func_end ply_xiecl - - thumb_func_start ply_xleng -ply_xleng: @ 82E15B8 - ldr r0, [r1, 0x40] - ldrb r0, [r0] - adds r2, r1, 0 - adds r2, 0x26 - strb r0, [r2] - ldr r0, [r1, 0x40] - adds r0, 0x1 - str r0, [r1, 0x40] - bx lr - thumb_func_end ply_xleng - - thumb_func_start ply_xswee -ply_xswee: @ 82E15CC - ldr r0, [r1, 0x40] - ldrb r0, [r0] - adds r2, r1, 0 - adds r2, 0x27 - strb r0, [r2] - ldr r0, [r1, 0x40] - adds r0, 0x1 - str r0, [r1, 0x40] - bx lr - thumb_func_end ply_xswee - - thumb_func_start ply_xcmd0C -ply_xcmd0C: @ 82E15E0 - push {r4,lr} - adds r3, r1, 0 - ldr r4, [r3, 0x40] - ldr r0, _082E1610 - ands r2, r0 - ldrb r0, [r4] - orrs r2, r0 - ldrb r0, [r4, 0x1] - lsls r1, r0, 8 - ldr r0, _082E1614 - ands r2, r0 - orrs r2, r1 - ldrh r1, [r3, 0x3A] - lsls r0, r2, 16 - lsrs r0, 16 - cmp r1, r0 - bcs _082E1618 - adds r0, r1, 0x1 - strh r0, [r3, 0x3A] - subs r0, r4, 0x2 - str r0, [r3, 0x40] - movs r0, 0x1 - strb r0, [r3, 0x1] - b _082E1620 - .align 2, 0 -_082E1610: .4byte 0xffffff00 -_082E1614: .4byte 0xffff00ff -_082E1618: - movs r0, 0 - strh r0, [r3, 0x3A] - adds r0, r4, 0x2 - str r0, [r3, 0x40] -_082E1620: - pop {r4} - pop {r0} - bx r0 - thumb_func_end ply_xcmd0C - - thumb_func_start ply_xcmd0D -ply_xcmd0D: @ 82E1628 - push {r4,lr} - ldr r2, [r1, 0x40] - ldr r0, _082E1660 - ands r4, r0 - ldrb r0, [r2] - orrs r4, r0 - ldrb r0, [r2, 0x1] - lsls r3, r0, 8 - ldr r0, _082E1664 - ands r4, r0 - orrs r4, r3 - ldrb r0, [r2, 0x2] - lsls r3, r0, 16 - ldr r0, _082E1668 - ands r4, r0 - orrs r4, r3 - ldrb r0, [r2, 0x3] - lsls r3, r0, 24 - ldr r0, _082E166C - ands r4, r0 - orrs r4, r3 - str r4, [r1, 0x3C] - adds r2, 0x4 - str r2, [r1, 0x40] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_082E1660: .4byte 0xffffff00 -_082E1664: .4byte 0xffff00ff -_082E1668: .4byte 0xff00ffff -_082E166C: .4byte 0x00ffffff - thumb_func_end ply_xcmd0D - - thumb_func_start DummyFunc_rev -DummyFunc_rev: @ 82E1670 - bx lr - thumb_func_end DummyFunc_rev - - thumb_func_start sub_82E1674 -sub_82E1674: @ 82E1674 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - mov r9, r0 - movs r6, 0 - movs r1, 0 - movs r4, 0 - ldr r0, _082E1730 - mov r8, r0 - ldr r7, _082E1734 - ldr r0, _082E1738 - mov r10, r0 - mov r5, r8 - adds r5, 0xC - movs r3, 0 - ldr r0, _082E173C - mov r12, r0 -_082E169A: - mov r0, r12 - adds r2, r3, r0 - ldrb r0, [r2] - cmp r0, 0 - bne _082E16B0 - ldr r0, [r2, 0x20] - cmp r0, 0 - beq _082E16C6 - ldr r0, [r0, 0x2C] - cmp r0, r2 - bne _082E16C6 -_082E16B0: - ldr r0, [r5] - cmp r6, r0 - bcs _082E16BA - adds r6, r0, 0 - adds r1, r4, 0 -_082E16BA: - adds r5, 0x40 - adds r3, 0xA0 - adds r4, 0x1 - cmp r4, 0x1 - ble _082E169A - adds r4, r1, 0 -_082E16C6: - lsls r5, r4, 6 - add r5, r8 - ldr r0, [r5, 0x34] - adds r0, 0x1 - str r0, [r5, 0x34] - movs r0, 0x34 - muls r4, r0 - adds r6, r4, r7 - adds r0, r6, 0 - mov r1, r10 - movs r2, 0x34 - bl memcpy - adds r0, r7, 0x4 - adds r0, r4, r0 - mov r1, r9 - str r1, [r0] - adds r1, r7, 0 - adds r1, 0x8 - adds r1, r4, r1 - adds r0, r7, 0 - adds r0, 0x11 - adds r0, r4, r0 - str r0, [r1] - adds r1, r7, 0 - adds r1, 0xC - adds r1, r4, r1 - adds r0, r7, 0 - adds r0, 0x18 - adds r0, r4, r0 - str r0, [r1] - adds r0, r7, 0 - adds r0, 0x14 - adds r0, r4, r0 - adds r1, r7, 0 - adds r1, 0x1A - adds r4, r1 - str r4, [r0] - ldr r0, _082E1740 - str r0, [r5, 0x34] - adds r0, r5, 0 - adds r1, r6, 0 - bl MPlayStart_rev01 - adds r0, r5, 0 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_082E1730: .4byte gUnknown_030073A0 -_082E1734: .4byte gUnknown_03007330 -_082E1738: .4byte gUnknown_030077B0 -_082E173C: .4byte gUnknown_03007670 -_082E1740: .4byte 0x68736d53 - thumb_func_end sub_82E1674 - - thumb_func_start sub_82E1744 -sub_82E1744: @ 82E1744 - lsls r0, 24 - lsrs r0, 24 - ldr r2, _082E1754 - movs r1, 0x7F - ands r0, r1 - strb r0, [r2, 0x1D] - bx lr - .align 2, 0 -_082E1754: .4byte gUnknown_030077B0 - thumb_func_end sub_82E1744 - - thumb_func_start sub_82E1758 -sub_82E1758: @ 82E1758 - ldr r2, _082E176C - lsls r0, 24 - asrs r0, 24 - adds r0, 0x40 - movs r1, 0x7F - ands r0, r1 - adds r2, 0x28 - strb r0, [r2] - bx lr - .align 2, 0 -_082E176C: .4byte gUnknown_030077B0 - thumb_func_end sub_82E1758 - - thumb_func_start sub_82E1770 -sub_82E1770: @ 82E1770 - push {r4-r6,lr} - lsls r0, 16 - ldr r3, _082E17A4 - ldrb r2, [r3, 0x19] - ldrb r4, [r3, 0x12] - subs r1, r2, r4 - lsls r1, 24 - lsrs r1, 24 - movs r6, 0x80 - lsls r6, 16 - adds r0, r6 - asrs r2, r0, 24 - movs r5, 0x7F - movs r4, 0x7F - ands r2, r4 - movs r6, 0x2A - strb r2, [r6, r3] - asrs r0, 17 - ands r0, r4 - strb r0, [r3, 0x12] - adds r1, r0 - ands r1, r5 - strb r1, [r3, 0x19] - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_082E17A4: .4byte gUnknown_030077B0 - thumb_func_end sub_82E1770 - - thumb_func_start sub_82E17A8 -sub_82E17A8: @ 82E17A8 - ldr r1, _082E17B0 - strh r0, [r1, 0x2E] - bx lr - .align 2, 0 -_082E17B0: .4byte gUnknown_030077B0 - thumb_func_end sub_82E17A8 - - thumb_func_start sub_82E17B4 -sub_82E17B4: @ 82E17B4 - ldr r1, _082E17BC - adds r1, 0x26 - strb r0, [r1] - bx lr - .align 2, 0 -_082E17BC: .4byte gUnknown_030077B0 - thumb_func_end sub_82E17B4 - - thumb_func_start sub_82E17C0 -sub_82E17C0: @ 82E17C0 - ldr r1, _082E17C8 - str r0, [r1, 0x20] - bx lr - .align 2, 0 -_082E17C8: .4byte gUnknown_030077B0 - thumb_func_end sub_82E17C0 - - thumb_func_start sub_82E17CC -sub_82E17CC: @ 82E17CC - ldr r1, [r0, 0x2C] - ldr r0, [r1, 0x20] - cmp r0, 0 - beq _082E17DE - ldr r0, [r0, 0x2C] - cmp r0, r1 - bne _082E17DE - movs r0, 0x1 - b _082E17E0 -_082E17DE: - movs r0, 0 -_082E17E0: - bx lr - thumb_func_end sub_82E17CC - - thumb_func_start sub_82E17E4 -sub_82E17E4: @ 82E17E4 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r0, 0 - beq _082E1804 - ldr r2, _082E1800 - movs r0, 0x2 - strb r0, [r2] - ldrb r3, [r2, 0x12] - adds r0, r3, r1 - movs r1, 0x7F - ands r0, r1 - strb r0, [r2, 0x19] - b _082E180A - .align 2, 0 -_082E1800: .4byte gUnknown_030077B0 -_082E1804: - ldr r1, _082E180C - movs r0, 0x1 - strb r0, [r1] -_082E180A: - bx lr - .align 2, 0 -_082E180C: .4byte gUnknown_030077B0 - thumb_func_end sub_82E17E4 - - thumb_func_start sub_82E1810 -sub_82E1810: @ 82E1810 - ldr r1, _082E1828 - ldr r2, [r1] - cmp r0, 0 - beq _082E1834 - ldr r1, _082E182C - ldr r3, _082E1830 - adds r0, r3, 0 - strh r0, [r1] - movs r0, 0xFE - ldrb r1, [r2, 0x9] - ands r0, r1 - b _082E1842 - .align 2, 0 -_082E1828: .4byte gUnknown_03007FF0 -_082E182C: .4byte 0x04000082 -_082E1830: .4byte 0x0000210e -_082E1834: - ldr r1, _082E1848 - ldr r3, _082E184C - adds r0, r3, 0 - strh r0, [r1] - movs r0, 0x1 - ldrb r1, [r2, 0x9] - orrs r0, r1 -_082E1842: - strb r0, [r2, 0x9] - bx lr - .align 2, 0 -_082E1848: .4byte 0x04000082 -_082E184C: .4byte 0x00003302 - thumb_func_end sub_82E1810 - - thumb_func_start sub_82E1850 -sub_82E1850: @ 82E1850 - ldr r1, _082E1858 - strb r0, [r1, 0x2] - bx lr - .align 2, 0 -_082E1858: .4byte gUnknown_030077B0 - thumb_func_end sub_82E1850 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/link.s b/asm/link.s index ed6db63fd7..5a6798e591 100644 --- a/asm/link.s +++ b/asm/link.s @@ -3342,12 +3342,12 @@ c2_800ACD4: @ 800AF30 movs r0, 0 movs r1, 0 bl SetGpuReg - ldr r0, =gUnknown_030075F0 - bl MPlayStop_rev01 - ldr r0, =gUnknown_03007630 - bl MPlayStop_rev01 - ldr r0, =gUnknown_03007800 - bl MPlayStop_rev01 + ldr r0, =gMPlay_SE1 + bl m4aMPlayStop + ldr r0, =gMPlay_SE2 + bl m4aMPlayStop + ldr r0, =gMPlay_SE3 + bl m4aMPlayStop ldr r0, =0x02000000 movs r1, 0xE0 lsls r1, 9 @@ -32621,7 +32621,7 @@ sub_801A43C: @ 801A43C bl ResetAllObjectData bl ResetTasks bl remove_some_task - bl SoundVSyncOn_rev01 + bl m4aSoundVSyncOn ldr r0, =sub_801A418 bl SetVBlankCallback ldr r0, =sub_801A6C0 diff --git a/asm/m4a_1.s b/asm/m4a_1.s new file mode 100644 index 0000000000..0afc8aad45 --- /dev/null +++ b/asm/m4a_1.s @@ -0,0 +1,1909 @@ + .include "asm/macros.inc" + .include "constants/gba_constants.inc" + .include "constants/m4a_constants.inc" + + .syntax unified + + .text + + thumb_func_start umul3232H32 +umul3232H32: + adr r2, __umul3232H32 + bx r2 + .arm +__umul3232H32: + umull r2, r3, r0, r1 + add r0, r3, 0 + bx lr + thumb_func_end umul3232H32 + + thumb_func_start SoundMain +SoundMain: + ldr r0, lt_SOUND_INFO_PTR + ldr r0, [r0] + ldr r2, lt_ID_NUMBER + ldr r3, [r0, o_SoundInfo_ident] + cmp r2, r3 + beq SoundMain_1 + bx lr @ Exit the function if ident doesn't match ID_NUMBER. +SoundMain_1: + adds r3, 1 + str r3, [r0, o_SoundInfo_ident] + push {r4-r7,lr} + mov r1, r8 + mov r2, r9 + mov r3, r10 + mov r4, r11 + push {r0-r4} + sub sp, 0x18 + ldrb r1, [r0, o_SoundInfo_maxLines] + cmp r1, 0 @ if maxLines is 0, there is no maximum + beq SoundMain_3 + ldr r2, lt_REG_VCOUNT + ldrb r2, [r2] + cmp r2, VCOUNT_VBLANK + bhs SoundMain_2 + adds r2, TOTAL_SCANLINES +SoundMain_2: + adds r1, r2 +SoundMain_3: + str r1, [sp, 0x14] + ldr r3, [r0, o_SoundInfo_func] + cmp r3, 0 + beq SoundMain_4 + ldr r0, [r0, o_SoundInfo_intp] + bl _081DD25E + ldr r0, [sp, 0x18] +SoundMain_4: + ldr r3, [r0, o_SoundInfo_CgbSound] + bl _081DD25E + ldr r0, [sp, 0x18] + ldr r3, [r0, o_SoundInfo_pcmSamplesPerVBlank] + mov r8, r3 + ldr r5, lt_o_SoundInfo_pcmBuffer + adds r5, r0 + ldrb r4, [r0, o_SoundInfo_pcmDmaCounter] + subs r7, r4, 1 + bls SoundMain_5 + ldrb r1, [r0, o_SoundInfo_pcmDmaPeriod] + subs r1, r7 + mov r2, r8 + muls r2, r1 + adds r5, r2 +SoundMain_5: + str r5, [sp, 0x8] + ldr r6, lt_PCM_DMA_BUF_SIZE + ldr r3, lt_SoundMainRAM_Buffer + bx r3 + + .align 2, 0 +lt_SOUND_INFO_PTR: .word SOUND_INFO_PTR +lt_ID_NUMBER: .word ID_NUMBER +lt_SoundMainRAM_Buffer: .word SoundMainRAM_Buffer + 1 +lt_REG_VCOUNT: .word REG_VCOUNT +lt_o_SoundInfo_pcmBuffer: .word o_SoundInfo_pcmBuffer +lt_PCM_DMA_BUF_SIZE: .word PCM_DMA_BUF_SIZE + thumb_func_end SoundMain + + thumb_func_start SoundMainRAM +SoundMainRAM: + ldrb r3, [r0, o_SoundInfo_reverb] + cmp r3, 0 + beq SoundMainRAM_NoReverb + adr r1, SoundMainRAM_Reverb + bx r1 + .arm +SoundMainRAM_Reverb: + cmp r4, 0x2 + addeq r7, r0, o_SoundInfo_pcmBuffer + addne r7, r5, r8 + mov r4, r8 +_081DCEC4: + ldrsb r0, [r5, r6] + ldrsb r1, [r5] + add r0, r0, r1 + ldrsb r1, [r7, r6] + add r0, r0, r1 + ldrsb r1, [r7], 0x1 + add r0, r0, r1 + mul r1, r0, r3 + mov r0, r1, asr 9 + tst r0, 0x80 + addne r0, r0, 0x1 + strb r0, [r5, r6] + strb r0, [r5], 0x1 + subs r4, r4, 0x1 + bgt _081DCEC4 + adr r0, _081DCF36 + 1 @ plus 1 because THUMB + bx r0 + .thumb +SoundMainRAM_NoReverb: + movs r0, 0 + mov r1, r8 + adds r6, r5 + lsrs r1, 3 + bcc SoundMainRAM_NoReverb_Ok + stm r5!, {r0} + stm r6!, {r0} +SoundMainRAM_NoReverb_Ok: + lsrs r1, 1 + bcc SoundMainRAM_NoReverb_Loop + stm r5!, {r0} + stm r6!, {r0} + stm r5!, {r0} + stm r6!, {r0} +SoundMainRAM_NoReverb_Loop: + stm r5!, {r0} + stm r6!, {r0} + stm r5!, {r0} + stm r6!, {r0} + stm r5!, {r0} + stm r6!, {r0} + stm r5!, {r0} + stm r6!, {r0} + subs r1, 1 + bgt SoundMainRAM_NoReverb_Loop +_081DCF36: + ldr r4, [sp, 0x18] + ldr r0, [r4, o_SoundInfo_divFreq] + mov r12, r0 + ldrb r0, [r4, o_SoundInfo_maxChans] + adds r4, o_SoundInfo_chans + +SoundMainRAM_ChanLoop: + str r0, [sp, 0x4] + ldr r3, [r4, o_SoundChannel_wav] + ldr r0, [sp, 0x14] + cmp r0, 0 + beq _081DCF60 + ldr r1, =REG_VCOUNT + ldrb r1, [r1] + cmp r1, VCOUNT_VBLANK + bhs _081DCF54 + adds r1, TOTAL_SCANLINES +_081DCF54: + cmp r1, r0 + blo _081DCF60 + b _081DD24A + + .pool + +_081DCF60: + ldrb r6, [r4, o_SoundChannel_status] + movs r0, 0xC7 + tst r0, r6 + bne _081DCF6A + b _081DD240 +_081DCF6A: + movs r0, 0x80 + tst r0, r6 + beq _081DCFA0 + movs r0, 0x40 + tst r0, r6 + bne _081DCFB0 + movs r6, 0x3 + strb r6, [r4, o_SoundChannel_status] + adds r0, r3, 0 + adds r0, 0x10 + ldr r1, [r4, o_SoundChannel_ct] + adds r0, r1 + str r0, [r4, o_SoundChannel_cp] + ldr r0, [r3, 0xC] + subs r0, r1 + str r0, [r4, o_SoundChannel_ct] + movs r5, 0 + strb r5, [r4, o_SoundChannel_ev] + str r5, [r4, o_SoundChannel_fw] + ldrb r2, [r3, 0x3] + movs r0, 0xC0 + tst r0, r2 + beq _081DCFF8 + movs r0, 0x10 + orrs r6, r0 + strb r6, [r4, o_SoundChannel_status] + b _081DCFF8 +_081DCFA0: + ldrb r5, [r4, o_SoundChannel_ev] + movs r0, 0x4 + tst r0, r6 + beq _081DCFB6 + ldrb r0, [r4, o_SoundChannel_iel] + subs r0, 1 + strb r0, [r4, o_SoundChannel_iel] + bhi _081DD006 +_081DCFB0: + movs r0, 0 + strb r0, [r4, o_SoundChannel_status] + b _081DD240 +_081DCFB6: + movs r0, 0x40 + tst r0, r6 + beq _081DCFD6 + ldrb r0, [r4, o_SoundChannel_release] + muls r5, r0 + lsrs r5, 8 + ldrb r0, [r4, o_SoundChannel_iev] + cmp r5, r0 + bhi _081DD006 +_081DCFC8: + ldrb r5, [r4, o_SoundChannel_iev] + cmp r5, 0 + beq _081DCFB0 + movs r0, 0x4 + orrs r6, r0 + strb r6, [r4, o_SoundChannel_status] + b _081DD006 +_081DCFD6: + movs r2, 0x3 + ands r2, r6 + cmp r2, 0x2 + bne _081DCFF4 + ldrb r0, [r4, o_SoundChannel_decay] + muls r5, r0 + lsrs r5, 8 + ldrb r0, [r4, o_SoundChannel_sustain] + cmp r5, r0 + bhi _081DD006 + adds r5, r0, 0 + beq _081DCFC8 + subs r6, 0x1 + strb r6, [r4, o_SoundChannel_status] + b _081DD006 +_081DCFF4: + cmp r2, 0x3 + bne _081DD006 +_081DCFF8: + ldrb r0, [r4, o_SoundChannel_attack] + adds r5, r0 + cmp r5, 0xFF + bcc _081DD006 + movs r5, 0xFF + subs r6, 0x1 + strb r6, [r4, o_SoundChannel_status] +_081DD006: + strb r5, [r4, o_SoundChannel_ev] + ldr r0, [sp, 0x18] + ldrb r0, [r0, o_SoundChannel_release] + adds r0, 0x1 + muls r0, r5 + lsrs r5, r0, 4 + ldrb r0, [r4, o_SoundChannel_rightVolume] + muls r0, r5 + lsrs r0, 8 + strb r0, [r4, o_SoundChannel_er] + ldrb r0, [r4, o_SoundChannel_leftVolume] + muls r0, r5 + lsrs r0, 8 + strb r0, [r4, o_SoundChannel_el] + movs r0, 0x10 + ands r0, r6 + str r0, [sp, 0x10] + beq _081DD03A + adds r0, r3, 0 + adds r0, 0x10 + ldr r1, [r3, 0x8] + adds r0, r1 + str r0, [sp, 0xC] + ldr r0, [r3, 0xC] + subs r0, r1 + str r0, [sp, 0x10] +_081DD03A: + ldr r5, [sp, 0x8] + ldr r2, [r4, o_SoundChannel_ct] + ldr r3, [r4, o_SoundChannel_cp] + adr r0, _081DD044 + bx r0 + .arm +_081DD044: + str r8, [sp] + ldr r9, [r4, o_SoundChannel_fw] + ldrb r10, [r4, o_SoundChannel_er] + ldrb r11, [r4, o_SoundChannel_el] + ldrb r0, [r4, o_SoundChannel_type] + tst r0, 0x30 + beq _081DD068 + bl sub_81DD264 + b _081DD228 +_081DD068: + mov r10, r10, lsl 16 + mov r11, r11, lsl 16 + ldrb r0, [r4, o_SoundChannel_type] + tst r0, 0x8 + beq _081DD19C +_081DD07C: + cmp r2, 0x4 + ble _081DD0EC + subs r2, r2, r8 + movgt r9, 0 + bgt _081DD0A8 + mov r9, r8 + add r2, r2, r8 + sub r8, r2, 0x4 + sub r9, r9, r8 + ands r2, r2, 0x3 + moveq r2, 0x4 +_081DD0A8: + ldr r6, [r5] + ldr r7, [r5, 0x630] +_081DD0B0: + ldrsb r0, [r3], 0x1 + mul r1, r10, r0 + bic r1, r1, 0xFF0000 + add r6, r1, r6, ror 8 + mul r1, r11, r0 + bic r1, r1, 0xFF0000 + add r7, r1, r7, ror 8 + adds r5, r5, 0x40000000 + bcc _081DD0B0 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + subs r8, r8, 0x4 + bgt _081DD0A8 + adds r8, r8, r9 + beq _081DD22C +_081DD0EC: + ldr r6, [r5] + ldr r7, [r5, 0x630] +_081DD0F4: + ldrsb r0, [r3], 0x1 + mul r1, r10, r0 + bic r1, r1, 0xFF0000 + add r6, r1, r6, ror 8 + mul r1, r11, r0 + bic r1, r1, 0xFF0000 + add r7, r1, r7, ror 8 + subs r2, r2, 0x1 + beq _081DD164 +_081DD118: + adds r5, r5, 0x40000000 + bcc _081DD0F4 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + subs r8, r8, 0x4 + bgt _081DD07C + b _081DD22C +_081DD134: + ldr r0, [sp, 0x18] + cmp r0, 0 + beq _081DD158 + ldr r3, [sp, 0x14] + rsb lr, r2, 0 +_081DD148: + adds r2, r0, r2 + bgt _081DD1FC + sub lr, lr, r0 + b _081DD148 +_081DD158: + pop {r4,r12} + mov r2, 0 + b _081DD174 +_081DD164: + ldr r2, [sp, 0x10] + cmp r2, 0 + ldrne r3, [sp, 0xC] + bne _081DD118 +_081DD174: + strb r2, [r4, o_SoundChannel_status] + mov r0, r5, lsr 30 + bic r5, r5, 0xC0000000 + rsb r0, r0, 0x3 + mov r0, r0, lsl 3 + mov r6, r6, ror r0 + mov r7, r7, ror r0 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + b _081DD234 +_081DD19C: + push {r4,r12} + ldr r1, [r4, o_SoundChannel_freq] + mul r4, r12, r1 + ldrsb r0, [r3] + ldrsb r1, [r3, 0x1]! + sub r1, r1, r0 +_081DD1B4: + ldr r6, [r5] + ldr r7, [r5, 0x630] +_081DD1BC: + mul lr, r9, r1 + add lr, r0, lr, asr 23 + mul r12, r10, lr + bic r12, r12, 0xFF0000 + add r6, r12, r6, ror 8 + mul r12, r11, lr + bic r12, r12, 0xFF0000 + add r7, r12, r7, ror 8 + add r9, r9, r4 + movs lr, r9, lsr 23 + beq _081DD208 + bic r9, r9, 0x3F800000 + subs r2, r2, lr + ble _081DD134 + subs lr, lr, 0x1 + addeq r0, r0, r1 +_081DD1FC: + ldrsbne r0, [r3, lr]! + ldrsb r1, [r3, 0x1]! + sub r1, r1, r0 +_081DD208: + adds r5, r5, 0x40000000 + bcc _081DD1BC + str r7, [r5, 0x630] + str r6, [r5], 0x4 + subs r8, r8, 0x4 + bgt _081DD1B4 + sub r3, r3, 0x1 + pop {r4,r12} +_081DD228: + str r9, [r4, o_SoundChannel_fw] +_081DD22C: + str r2, [r4, o_SoundChannel_ct] + str r3, [r4, o_SoundChannel_cp] +_081DD234: + ldr r8, [sp] + add r0, pc, 0x1 + bx r0 + .thumb +_081DD240: + ldr r0, [sp, 0x4] + subs r0, 1 + ble _081DD24A + adds r4, SoundChannel_size + b SoundMainRAM_ChanLoop +_081DD24A: + ldr r0, [sp, 0x18] + ldr r3, =ID_NUMBER + str r3, [r0] + add sp, 0x1C + pop {r0-r7} + mov r8, r0 + mov r9, r1 + mov r10, r2 + mov r11, r3 + pop {r3} +_081DD25E: + bx r3 + .pool + thumb_func_end SoundMainRAM + + arm_func_start sub_81DD264 +sub_81DD264: + ldr r6, [r4, o_SoundChannel_wav] + ldrb r0, [r4, o_SoundChannel_status] + tst r0, 0x20 + bne _081DD2B4 + orr r0, r0, 0x20 + strb r0, [r4, o_SoundChannel_status] + ldrb r0, [r4, o_SoundChannel_type] + tst r0, 0x10 + beq _081DD29C + ldr r1, [r6, 0xC] + add r1, r1, r6, lsl 1 + add r1, r1, 0x20 + sub r3, r1, r3 + str r3, [r4, o_SoundChannel_cp] +_081DD29C: + ldrh r0, [r6] + cmp r0, 0 + beq _081DD2B4 + sub r3, r3, r6 + sub r3, r3, 0x10 + str r3, [r4, o_SoundChannel_cp] +_081DD2B4: + push {r8,r12,lr} + mov r10, r10, lsl 16 + mov r11, r11, lsl 16 + ldr r1, [r4, o_SoundChannel_freq] + ldrb r0, [r4, o_SoundChannel_type] + tst r0, 0x8 + movne r8, 0x800000 + muleq r8, r12, r1 + ldrh r0, [r6] + cmp r0, 0 + beq _081DD468 + mov r0, 0xFF000000 + str r0, [r4, o_SoundChannel_xpi] + ldrb r0, [r4, o_SoundChannel_type] + tst r0, 0x10 + bne _081DD3C0 + bl sub_81DD520 + mov r0, r1 + add r3, r3, 0x1 + bl sub_81DD520 + sub r1, r1, r0 +_081DD308: + ldr r6, [r5] + ldr r7, [r5, 0x630] +_081DD310: + mul lr, r9, r1 + add lr, r0, lr, asr 23 + mul r12, r10, lr + bic r12, r12, 0xFF0000 + add r6, r12, r6, ror 8 + mul r12, r11, lr + bic r12, r12, 0xFF0000 + add r7, r12, r7, ror 8 + add r9, r9, r8 + movs lr, r9, lsr 23 + beq _081DD370 + bic r9, r9, 0x3F800000 + subs r2, r2, lr + ble _081DD398 + subs lr, lr, 0x1 + bne _081DD358 + add r0, r0, r1 + b _081DD364 +_081DD358: + add r3, r3, lr + bl sub_81DD520 + mov r0, r1 +_081DD364: + add r3, r3, 0x1 + bl sub_81DD520 + sub r1, r1, r0 +_081DD370: + adds r5, r5, 0x40000000 + bcc _081DD310 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + ldr r6, [sp] + subs r6, r6, 0x4 + str r6, [sp] + bgt _081DD308 + sub r3, r3, 0x1 + b _081DD4F0 +_081DD398: + ldr r0, [sp, 0x1C] + cmp r0, 0 + beq _081DD4F4 + ldr r3, [r4, o_SoundChannel_wav] + ldr r3, [r3, 0x8] + rsb lr, r2, 0 +_081DD3B0: + adds r2, r2, r0 + bgt _081DD358 + sub lr, lr, r0 + b _081DD3B0 +_081DD3C0: + sub r3, r3, 0x1 + bl sub_81DD520 + mov r0, r1 + sub r3, r3, 0x1 + bl sub_81DD520 + sub r1, r1, r0 +_081DD3D8: + ldr r6, [r5] + ldr r7, [r5, 0x630] +_081DD3E0: + mul lr, r9, r1 + add lr, r0, lr, asr 23 + mul r12, r10, lr + bic r12, r12, 0xFF0000 + add r6, r12, r6, ror 8 + mul r12, r11, lr + bic r12, r12, 0xFF0000 + add r7, r12, r7, ror 8 + add r9, r9, r8 + movs lr, r9, lsr 23 + beq _081DD440 + bic r9, r9, 0x3F800000 + subs r2, r2, lr + ble _081DD4F4 + subs lr, lr, 0x1 + bne _081DD428 + add r0, r0, r1 + b _081DD434 +_081DD428: + sub r3, r3, lr + bl sub_81DD520 + mov r0, r1 +_081DD434: + sub r3, r3, 0x1 + bl sub_81DD520 + sub r1, r1, r0 +_081DD440: + adds r5, r5, 0x40000000 + bcc _081DD3E0 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + ldr r6, [sp] + subs r6, r6, 0x4 + str r6, [sp] + bgt _081DD3D8 + add r3, r3, 0x2 + b _081DD4F0 +_081DD468: + ldrb r0, [r4, o_SoundChannel_type] + tst r0, 0x10 + beq _081DD4F0 + ldrsb r0, [r3, -0x1]! + ldrsb r1, [r3, -0x1] + sub r1, r1, r0 +_081DD480: + ldr r6, [r5] + ldr r7, [r5, 0x630] +_081DD488: + mul lr, r9, r1 + add lr, r0, lr, asr 23 + mul r12, r10, lr + bic r12, r12, 0xFF0000 + add r6, r12, r6, ror 8 + mul r12, r11, lr + bic r12, r12, 0xFF0000 + add r7, r12, r7, ror 8 + add r9, r9, r8 + movs lr, r9, lsr 23 + beq _081DD4CC + bic r9, r9, 0x3F800000 + subs r2, r2, lr + ble _081DD4F4 + ldrsb r0, [r3, -lr]! + ldrsb r1, [r3, -0x1] + sub r1, r1, r0 +_081DD4CC: + adds r5, r5, 0x40000000 + bcc _081DD488 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + ldr r6, [sp] + subs r6, r6, 0x4 + str r6, [sp] + bgt _081DD480 + add r3, r3, 0x1 +_081DD4F0: + pop {r8,r12,pc} +_081DD4F4: + mov r2, 0 + strb r2, [r4, o_SoundChannel_status] + mov r0, r5, lsr 30 + bic r5, r5, 0xC0000000 + rsb r0, r0, 0x3 + mov r0, r0, lsl 3 + mov r6, r6, ror r0 + mov r7, r7, ror r0 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + pop {r8,r12,pc} + arm_func_end sub_81DD264 + + arm_func_start sub_81DD520 +sub_81DD520: + push {r0,r2,r5-r7,lr} + mov r0, r3, lsr 6 + ldr r1, [r4, o_SoundChannel_xpi] + cmp r0, r1 + beq _081DD594 + str r0, [r4, o_SoundChannel_xpi] + mov r1, 0x21 + mul r2, r1, r0 + ldr r1, [r4, o_SoundChannel_wav] + add r2, r2, r1 + add r2, r2, 0x10 + ldr r5, =gUnknown_03001300 + ldr r6, =gDeltaEncodingTable + mov r7, 0x40 + ldrb lr, [r2], 1 + strb lr, [r5], 1 + ldrb r1, [r2], 1 + b _081DD57C +_081DD568: + ldrb r1, [r2], 1 + mov r0, r1, lsr 4 + ldrsb r0, [r6, r0] + add lr, lr, r0 + strb lr, [r5], 1 +_081DD57C: + and r0, r1, 0xF + ldrsb r0, [r6, r0] + add lr, lr, r0 + strb lr, [r5], 1 + subs r7, r7, 2 + bgt _081DD568 +_081DD594: + ldr r5, =gUnknown_03001300 + and r0, r3, 0x3F + ldrsb r1, [r5, r0] + pop {r0,r2,r5-r7,pc} + .pool + arm_func_end sub_81DD520 + + thumb_func_start SoundMainBTM +SoundMainBTM: + mov r12, r4 + movs r1, 0 + movs r2, 0 + movs r3, 0 + movs r4, 0 + stm r0!, {r1-r4} + stm r0!, {r1-r4} + stm r0!, {r1-r4} + stm r0!, {r1-r4} + mov r4, r12 + bx lr + thumb_func_end SoundMainBTM + + thumb_func_start RealClearChain +RealClearChain: + ldr r3, [r0, 0x2C] + cmp r3, 0 + beq _081DD5E2 + ldr r1, [r0, 0x34] + ldr r2, [r0, 0x30] + cmp r2, 0 + beq _081DD5D6 + str r1, [r2, 0x34] + b _081DD5D8 +_081DD5D6: + str r1, [r3, 0x20] +_081DD5D8: + cmp r1, 0 + beq _081DD5DE + str r2, [r1, 0x30] +_081DD5DE: + movs r1, 0 + str r1, [r0, 0x2C] +_081DD5E2: + bx lr + thumb_func_end RealClearChain + + thumb_func_start ply_fine +ply_fine: + push {r4,r5,lr} + adds r5, r1, 0 + ldr r4, [r5, o_MusicPlayerTrack_chan] + cmp r4, 0 + beq ply_fine_done +ply_fine_loop: + ldrb r1, [r4] + movs r0, 0xC7 + tst r0, r1 + beq ply_fine_ok + movs r0, 0x40 + orrs r1, r0 + strb r1, [r4] +ply_fine_ok: + adds r0, r4, 0 + bl RealClearChain + ldr r4, [r4, 0x34] + cmp r4, 0 + bne ply_fine_loop +ply_fine_done: + movs r0, 0 + strb r0, [r5] + pop {r4,r5} + pop {r0} + bx r0 + thumb_func_end ply_fine + + thumb_func_start MPlayJumpTableCopy +MPlayJumpTableCopy: + mov r12, lr + movs r1, 0x24 + ldr r2, lt_MPlayJumpTableTemplate +MPlayJumpTableCopy_Loop: + ldr r3, [r2] + bl chk_adr_r2 + stm r0!, {r3} + adds r2, 0x4 + subs r1, 0x1 + bgt MPlayJumpTableCopy_Loop + bx r12 + thumb_func_end MPlayJumpTableCopy + + .align 2, 0 + .thumb_func +ldrb_r3_r2: + ldrb r3, [r2] + +@ This attempts to protect against reading anything from the BIOS ROM +@ besides the jump table template. +@ It assumes that the jump table template is located at the end of the ROM. + .thumb_func +chk_adr_r2: + push {r0} + lsrs r0, r2, 25 + bne chk_adr_r2_done @ if adr >= 0x2000000 (i.e. not in BIOS ROM), accept it + ldr r0, lt_MPlayJumpTableTemplate + cmp r2, r0 + blo chk_adr_r2_reject @ if adr < gMPlayJumpTableTemplate, reject it + lsrs r0, r2, 14 + beq chk_adr_r2_done @ if adr < 0x40000 (i.e. in BIOS ROM), accept it +chk_adr_r2_reject: + movs r3, 0 +chk_adr_r2_done: + pop {r0} + bx lr + + .align 2, 0 +lt_MPlayJumpTableTemplate: .word gMPlayJumpTableTemplate + + thumb_func_start ld_r3_tp_adr_i +ld_r3_tp_adr_i: + ldr r2, [r1, 0x40] +_081DD64A: + adds r3, r2, 0x1 + str r3, [r1, 0x40] + ldrb r3, [r2] + b chk_adr_r2 + thumb_func_end ld_r3_tp_adr_i + + thumb_func_start ply_goto +ply_goto: + push {lr} +ply_goto_1: + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + ldrb r0, [r2, 0x3] + lsls r0, 8 + ldrb r3, [r2, 0x2] + orrs r0, r3 + lsls r0, 8 + ldrb r3, [r2, 0x1] + orrs r0, r3 + lsls r0, 8 + bl ldrb_r3_r2 + orrs r0, r3 + str r0, [r1, o_MusicPlayerTrack_cmdPtr] + pop {r0} + bx r0 + thumb_func_end ply_goto + + thumb_func_start ply_patt +ply_patt: + ldrb r2, [r1, o_MusicPlayerTrack_patternLevel] + cmp r2, 3 + bhs ply_patt_done + lsls r2, 2 + adds r3, r1, r2 + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + adds r2, 0x4 + str r2, [r3, o_MusicPlayerTrack_patternStack] + ldrb r2, [r1, o_MusicPlayerTrack_patternLevel] + adds r2, 1 + strb r2, [r1, o_MusicPlayerTrack_patternLevel] + b ply_goto +ply_patt_done: + b ply_fine + thumb_func_end ply_patt + + thumb_func_start ply_pend +ply_pend: + ldrb r2, [r1, o_MusicPlayerTrack_patternLevel] + cmp r2, 0 + beq ply_pend_done + subs r2, 1 + strb r2, [r1, o_MusicPlayerTrack_patternLevel] + lsls r2, 2 + adds r3, r1, r2 + ldr r2, [r3, o_MusicPlayerTrack_patternStack] + str r2, [r1, o_MusicPlayerTrack_cmdPtr] +ply_pend_done: + bx lr + thumb_func_end ply_pend + + thumb_func_start ply_rept +ply_rept: + push {lr} + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + ldrb r3, [r2] + cmp r3, 0 + bne ply_rept_1 + adds r2, 1 + str r2, [r1, o_MusicPlayerTrack_cmdPtr] + b ply_goto_1 +ply_rept_1: + ldrb r3, [r1, o_MusicPlayerTrack_repN] + adds r3, 1 + strb r3, [r1, o_MusicPlayerTrack_repN] + mov r12, r3 + bl ld_r3_tp_adr_i + cmp r12, r3 + bhs ply_rept_2 + b ply_goto_1 +ply_rept_2: + movs r3, 0 + strb r3, [r1, o_MusicPlayerTrack_repN] + adds r2, 5 + str r2, [r1, o_MusicPlayerTrack_cmdPtr] + pop {r0} + bx r0 + thumb_func_end ply_rept + + thumb_func_start ply_prio +ply_prio: + mov r12, lr + bl ld_r3_tp_adr_i + strb r3, [r1, o_MusicPlayerTrack_priority] + bx r12 + thumb_func_end ply_prio + + thumb_func_start ply_tempo +ply_tempo: + mov r12, lr + bl ld_r3_tp_adr_i + lsls r3, 1 + strh r3, [r0, o_MusicPlayerInfo_tempoD] + ldrh r2, [r0, o_MusicPlayerInfo_tempoU] + muls r3, r2 + lsrs r3, 8 + strh r3, [r0, o_MusicPlayerInfo_tempoI] + bx r12 + thumb_func_end ply_tempo + + thumb_func_start ply_keysh +ply_keysh: + mov r12, lr + bl ld_r3_tp_adr_i + strb r3, [r1, o_MusicPlayerTrack_keyShift] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0xC + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx r12 + thumb_func_end ply_keysh + + thumb_func_start ply_voice +ply_voice: + mov r12, lr + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + ldrb r3, [r2] + adds r2, 1 + str r2, [r1, o_MusicPlayerTrack_cmdPtr] + lsls r2, r3, 1 + adds r2, r3 + lsls r2, 2 + ldr r3, [r0, o_MusicPlayerInfo_tone] + adds r2, r3 + ldr r3, [r2] + bl chk_adr_r2 + str r3, [r1, o_MusicPlayerTrack_ToneData_type] + ldr r3, [r2, 0x4] + bl chk_adr_r2 + str r3, [r1, o_MusicPlayerTrack_ToneData_wav] + ldr r3, [r2, 0x8] + bl chk_adr_r2 + str r3, [r1, o_MusicPlayerTrack_ToneData_attack] + bx r12 + thumb_func_end ply_voice + + thumb_func_start ply_vol +ply_vol: + mov r12, lr + bl ld_r3_tp_adr_i + strb r3, [r1, o_MusicPlayerTrack_vol] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0x3 + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx r12 + thumb_func_end ply_vol + + thumb_func_start ply_pan +ply_pan: + mov r12, lr + bl ld_r3_tp_adr_i + subs r3, 0x40 + strb r3, [r1, o_MusicPlayerTrack_pan] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0x3 + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx r12 + thumb_func_end ply_pan + + thumb_func_start ply_bend +ply_bend: + mov r12, lr + bl ld_r3_tp_adr_i + subs r3, 0x40 + strb r3, [r1, o_MusicPlayerTrack_bend] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0xC + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx r12 + thumb_func_end ply_bend + + thumb_func_start ply_bendr +ply_bendr: + mov r12, lr + bl ld_r3_tp_adr_i + strb r3, [r1, o_MusicPlayerTrack_bendRange] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0xC + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx r12 + thumb_func_end ply_bendr + + thumb_func_start ply_lfodl +ply_lfodl: + mov r12, lr + bl ld_r3_tp_adr_i + strb r3, [r1, o_MusicPlayerTrack_lfoDelay] + bx r12 + thumb_func_end ply_lfodl + + thumb_func_start ply_modt +ply_modt: + mov r12, lr + bl ld_r3_tp_adr_i + ldrb r0, [r1, o_MusicPlayerTrack_modT] + cmp r0, r3 + beq _081DD7AA + strb r3, [r1, o_MusicPlayerTrack_modT] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0xF + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] +_081DD7AA: + bx r12 + thumb_func_end ply_modt + + thumb_func_start ply_tune +ply_tune: + mov r12, lr + bl ld_r3_tp_adr_i + subs r3, 0x40 + strb r3, [r1, o_MusicPlayerTrack_tune] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0xC + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx r12 + thumb_func_end ply_tune + + thumb_func_start ply_port +ply_port: + mov r12, lr + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + ldrb r3, [r2] + adds r2, 1 + ldr r0, =REG_SOUND1CNT_L @ sound register base address + adds r0, r3 + bl _081DD64A + strb r3, [r0] + bx r12 + .pool + thumb_func_end ply_port + + thumb_func_start m4aSoundVSync +m4aSoundVSync: + ldr r0, lt2_SOUND_INFO_PTR + ldr r0, [r0] + + @ Exit the function if ident is not ID_NUMBER or ID_NUMBER+1. + ldr r2, lt2_ID_NUMBER + ldr r3, [r0, o_SoundInfo_ident] + subs r3, r2 + cmp r3, 1 + bhi m4aSoundVSync_Done + + @ Decrement the PCM DMA counter. If it reaches 0, we need to do a DMA. + ldrb r1, [r0, o_SoundInfo_pcmDmaCounter] + subs r1, 1 + strb r1, [r0, o_SoundInfo_pcmDmaCounter] + bgt m4aSoundVSync_Done + + @ Reload the PCM DMA counter. + ldrb r1, [r0, o_SoundInfo_pcmDmaPeriod] + strb r1, [r0, o_SoundInfo_pcmDmaCounter] + + ldr r2, =REG_DMA1 + + ldr r1, [r2, 0x8] @ DMA1CNT + lsls r1, 7 + bcc m4aSoundVSync_SkipDMA1 @ branch if repeat bit isn't set + + ldr r1, =((DMA_ENABLE | DMA_START_NOW | DMA_32BIT | DMA_SRC_INC | DMA_DEST_FIXED) << 16) | 4 + str r1, [r2, 0x8] @ DMA1CNT + +m4aSoundVSync_SkipDMA1: + ldr r1, [r2, 0xC + 0x8] @ DMA2CNT + lsls r1, 7 + bcc m4aSoundVSync_SkipDMA2 @ branch if repeat bit isn't set + + ldr r1, =((DMA_ENABLE | DMA_START_NOW | DMA_32BIT | DMA_SRC_INC | DMA_DEST_FIXED) << 16) | 4 + str r1, [r2, 0xC + 0x8] @ DMA2CNT + +m4aSoundVSync_SkipDMA2: + + @ turn off DMA1/DMA2 + movs r1, DMA_32BIT >> 8 + lsls r1, 8 + strh r1, [r2, 0xA] @ DMA1CNT_H + strh r1, [r2, 0xC + 0xA] @ DMA2CNT_H + + @ turn on DMA1/DMA2 direct-sound FIFO mode + movs r1, (DMA_ENABLE | DMA_START_SPECIAL | DMA_32BIT | DMA_REPEAT) >> 8 + lsls r1, 8 @ LSB is 0, so DMA_SRC_INC is used (destination is always fixed in FIFO mode) + strh r1, [r2, 0xA] @ DMA1CNT_H + strh r1, [r2, 0xC + 0xA] @ DMA2CNT_H + +m4aSoundVSync_Done: + bx lr + + .pool + thumb_func_end m4aSoundVSync + + thumb_func_start MPlayMain +MPlayMain: + ldr r2, lt2_ID_NUMBER + ldr r3, [r0, o_MusicPlayerInfo_ident] + cmp r2, r3 + beq _081DD82E + bx lr +_081DD82E: + adds r3, 0x1 + str r3, [r0, o_MusicPlayerInfo_ident] + push {r0,lr} + ldr r3, [r0, o_MusicPlayerInfo_func] + cmp r3, 0 + beq _081DD840 + ldr r0, [r0, o_MusicPlayerInfo_intp] + bl call_r3 +_081DD840: + pop {r0} + push {r4-r7} + mov r4, r8 + mov r5, r9 + mov r6, r10 + mov r7, r11 + push {r4-r7} + adds r7, r0, 0 + ldr r0, [r7, o_MusicPlayerInfo_status] + cmp r0, 0 + bge _081DD858 + b _081DDA6C +_081DD858: + ldr r0, lt2_SOUND_INFO_PTR + ldr r0, [r0] + mov r8, r0 + adds r0, r7, 0 + bl FadeOutBody + ldr r0, [r7, o_MusicPlayerInfo_status] + cmp r0, 0 + bge _081DD86C + b _081DDA6C +_081DD86C: + ldrh r0, [r7, o_MusicPlayerInfo_tempoC] + ldrh r1, [r7, o_MusicPlayerInfo_tempoI] + adds r0, r1 + b _081DD9BC +_081DD874: + ldrb r6, [r7, o_MusicPlayerInfo_trackCount] + ldr r5, [r7, o_MusicPlayerInfo_tracks] + movs r3, 0x1 + movs r4, 0 +_081DD87C: + ldrb r0, [r5] + movs r1, 0x80 + tst r1, r0 + bne _081DD886 + b _081DD998 +_081DD886: + mov r10, r3 + orrs r4, r3 + mov r11, r4 + ldr r4, [r5, o_MusicPlayerTrack_chan] + cmp r4, 0 + beq _081DD8BA +_081DD892: + ldrb r1, [r4] + movs r0, 0xC7 + tst r0, r1 + beq _081DD8AE + ldrb r0, [r4, 0x10] + cmp r0, 0 + beq _081DD8B4 + subs r0, 0x1 + strb r0, [r4, 0x10] + bne _081DD8B4 + movs r0, 0x40 + orrs r1, r0 + strb r1, [r4] + b _081DD8B4 +_081DD8AE: + adds r0, r4, 0 + bl ClearChain +_081DD8B4: + ldr r4, [r4, 0x34] + cmp r4, 0 + bne _081DD892 +_081DD8BA: + ldrb r3, [r5, o_MusicPlayerTrack_flags] + movs r0, 0x40 + tst r0, r3 + beq _081DD938 + adds r0, r5, 0 + bl Clear64byte + movs r0, 0x80 + strb r0, [r5] + movs r0, 0x2 + strb r0, [r5, o_MusicPlayerTrack_bendRange] + movs r0, 0x40 + strb r0, [r5, o_MusicPlayerTrack_volX] + movs r0, 0x16 + strb r0, [r5, o_MusicPlayerTrack_lfoSpeed] + movs r0, 0x1 + adds r1, r5, 0x6 + strb r0, [r1, o_MusicPlayerTrack_ToneData_type - 0x6] + b _081DD938 +_081DD8E0: + ldr r2, [r5, o_MusicPlayerTrack_cmdPtr] + ldrb r1, [r2] + cmp r1, 0x80 + bhs _081DD8EC + ldrb r1, [r5, o_MusicPlayerTrack_runningStatus] + b _081DD8F6 +_081DD8EC: + adds r2, 0x1 + str r2, [r5, o_MusicPlayerTrack_cmdPtr] + cmp r1, 0xBD + bcc _081DD8F6 + strb r1, [r5, o_MusicPlayerTrack_runningStatus] +_081DD8F6: + cmp r1, 0xCF + bcc _081DD90C + mov r0, r8 + ldr r3, [r0, o_SoundInfo_plynote] + adds r0, r1, 0 + subs r0, 0xCF + adds r1, r7, 0 + adds r2, r5, 0 + bl call_r3 + b _081DD938 +_081DD90C: + cmp r1, 0xB0 + bls _081DD92E + adds r0, r1, 0 + subs r0, 0xB1 + strb r0, [r7, o_MusicPlayerInfo_cmd] + mov r3, r8 + ldr r3, [r3, o_SoundInfo_MPlayJumpTable] + lsls r0, 2 + ldr r3, [r3, r0] + adds r0, r7, 0 + adds r1, r5, 0 + bl call_r3 + ldrb r0, [r5, o_MusicPlayerTrack_flags] + cmp r0, 0 + beq _081DD994 + b _081DD938 +_081DD92E: + ldr r0, lt_gClockTable + subs r1, 0x80 + adds r1, r0 + ldrb r0, [r1] + strb r0, [r5, o_MusicPlayerTrack_wait] +_081DD938: + ldrb r0, [r5, o_MusicPlayerTrack_wait] + cmp r0, 0 + beq _081DD8E0 + subs r0, 0x1 + strb r0, [r5, o_MusicPlayerTrack_wait] + ldrb r1, [r5, o_MusicPlayerTrack_lfoSpeed] + cmp r1, 0 + beq _081DD994 + ldrb r0, [r5, o_MusicPlayerTrack_mod] + cmp r0, 0 + beq _081DD994 + ldrb r0, [r5, o_MusicPlayerTrack_lfoDelayC] + cmp r0, 0 + beq _081DD95A + subs r0, 0x1 + strb r0, [r5, o_MusicPlayerTrack_lfoDelayC] + b _081DD994 +_081DD95A: + ldrb r0, [r5, o_MusicPlayerTrack_lfoSpeedC] + adds r0, r1 + strb r0, [r5, o_MusicPlayerTrack_lfoSpeedC] + adds r1, r0, 0 + subs r0, 0x40 + lsls r0, 24 + bpl _081DD96E + lsls r2, r1, 24 + asrs r2, 24 + b _081DD972 +_081DD96E: + movs r0, 0x80 + subs r2, r0, r1 +_081DD972: + ldrb r0, [r5, o_MusicPlayerTrack_mod] + muls r0, r2 + asrs r2, r0, 6 + ldrb r0, [r5, o_MusicPlayerTrack_modM] + eors r0, r2 + lsls r0, 24 + beq _081DD994 + strb r2, [r5, o_MusicPlayerTrack_modM] + ldrb r0, [r5] + ldrb r1, [r5, o_MusicPlayerTrack_modT] + cmp r1, 0 + bne _081DD98E + movs r1, 0xC + b _081DD990 +_081DD98E: + movs r1, 0x3 +_081DD990: + orrs r0, r1 + strb r0, [r5, o_MusicPlayerTrack_flags] +_081DD994: + mov r3, r10 + mov r4, r11 +_081DD998: + subs r6, 0x1 + ble _081DD9A4 + movs r0, 0x50 + adds r5, r0 + lsls r3, 1 + b _081DD87C +_081DD9A4: + ldr r0, [r7, o_MusicPlayerInfo_clock] + adds r0, 0x1 + str r0, [r7, o_MusicPlayerInfo_clock] + cmp r4, 0 + bne _081DD9B6 + movs r0, 0x80 + lsls r0, 24 + str r0, [r7, o_MusicPlayerInfo_status] + b _081DDA6C +_081DD9B6: + str r4, [r7, o_MusicPlayerInfo_status] + ldrh r0, [r7, o_MusicPlayerInfo_tempoC] + subs r0, 0x96 +_081DD9BC: + strh r0, [r7, o_MusicPlayerInfo_tempoC] + cmp r0, 0x96 + bcc _081DD9C4 + b _081DD874 +_081DD9C4: + ldrb r2, [r7, o_MusicPlayerInfo_trackCount] + ldr r5, [r7, o_MusicPlayerInfo_tracks] +_081DD9C8: + ldrb r0, [r5, o_MusicPlayerTrack_flags] + movs r1, 0x80 + tst r1, r0 + beq _081DDA62 + movs r1, 0xF + tst r1, r0 + beq _081DDA62 + mov r9, r2 + adds r0, r7, 0 + adds r1, r5, 0 + bl TrkVolPitSet + ldr r4, [r5, o_MusicPlayerTrack_chan] + cmp r4, 0 + beq _081DDA58 +_081DD9E6: + ldrb r1, [r4, o_SoundChannel_status] + movs r0, 0xC7 + tst r0, r1 + bne _081DD9F6 + adds r0, r4, 0 + bl ClearChain + b _081DDA52 +_081DD9F6: + ldrb r0, [r4, o_SoundChannel_type] + movs r6, 0x7 + ands r6, r0 + ldrb r3, [r5, o_MusicPlayerTrack_flags] + movs r0, 0x3 + tst r0, r3 + beq _081DDA14 + bl ChnVolSetAsm + cmp r6, 0 + beq _081DDA14 + ldrb r0, [r4, o_CgbChannel_mo] + movs r1, 0x1 + orrs r0, r1 + strb r0, [r4, o_CgbChannel_mo] +_081DDA14: + ldrb r3, [r5, o_MusicPlayerTrack_flags] + movs r0, 0xC + tst r0, r3 + beq _081DDA52 + ldrb r1, [r4, o_SoundChannel_ky] + movs r0, 0x8 + ldrsb r0, [r5, r0] + adds r2, r1, r0 + bpl _081DDA28 + movs r2, 0 +_081DDA28: + cmp r6, 0 + beq _081DDA46 + mov r0, r8 + ldr r3, [r0, o_SoundInfo_MidiKeyToCgbFreq] + adds r1, r2, 0 + ldrb r2, [r5, o_MusicPlayerTrack_pitM] + adds r0, r6, 0 + bl call_r3 + str r0, [r4, o_CgbChannel_fr] + ldrb r0, [r4, o_CgbChannel_mo] + movs r1, 0x2 + orrs r0, r1 + strb r0, [r4, o_CgbChannel_mo] + b _081DDA52 +_081DDA46: + adds r1, r2, 0 + ldrb r2, [r5, o_MusicPlayerTrack_pitM] + ldr r0, [r4, o_SoundChannel_wav] + bl MidiKeyToFreq + str r0, [r4, o_SoundChannel_freq] +_081DDA52: + ldr r4, [r4, o_SoundChannel_np] + cmp r4, 0 + bne _081DD9E6 +_081DDA58: + ldrb r0, [r5, o_MusicPlayerTrack_flags] + movs r1, 0xF0 + ands r0, r1 + strb r0, [r5, o_MusicPlayerTrack_flags] + mov r2, r9 +_081DDA62: + subs r2, 0x1 + ble _081DDA6C + movs r0, 0x50 + adds r5, r0 + bgt _081DD9C8 +_081DDA6C: + ldr r0, lt2_ID_NUMBER + str r0, [r7, o_MusicPlayerInfo_ident] + pop {r0-r7} + mov r8, r0 + mov r9, r1 + mov r10, r2 + mov r11, r3 + pop {r3} + +call_r3: + bx r3 + + .align 2, 0 +lt_gClockTable: .word gClockTable +lt2_SOUND_INFO_PTR: .word SOUND_INFO_PTR +lt2_ID_NUMBER: .word ID_NUMBER + thumb_func_end MPlayMain + + thumb_func_start TrackStop +TrackStop: + push {r4-r6,lr} + adds r5, r1, 0 + ldrb r1, [r5, o_MusicPlayerTrack_flags] + movs r0, 0x80 + tst r0, r1 + beq TrackStop_Done + ldr r4, [r5, o_MusicPlayerTrack_chan] + cmp r4, 0 + beq TrackStop_3 + movs r6, 0 +TrackStop_Loop: + ldrb r0, [r4, o_SoundChannel_status] + cmp r0, 0 + beq TrackStop_2 + ldrb r0, [r4, o_SoundChannel_type] + movs r3, 0x7 + ands r0, r3 + beq TrackStop_1 + ldr r3, =SOUND_INFO_PTR + ldr r3, [r3] + ldr r3, [r3, o_SoundInfo_CgbOscOff] + bl call_r3 +TrackStop_1: + strb r6, [r4, o_SoundChannel_status] +TrackStop_2: + str r6, [r4, o_SoundChannel_track] + ldr r4, [r4, o_SoundChannel_np] + cmp r4, 0 + bne TrackStop_Loop +TrackStop_3: + str r4, [r5, o_MusicPlayerTrack_chan] +TrackStop_Done: + pop {r4-r6} + pop {r0} + bx r0 + .pool + thumb_func_end TrackStop + + thumb_func_start ChnVolSetAsm +ChnVolSetAsm: + ldrb r1, [r4, 0x12] + movs r0, 0x14 + ldrsb r2, [r4, r0] + movs r3, 0x80 + adds r3, r2 + muls r3, r1 + ldrb r0, [r5, 0x10] + muls r0, r3 + asrs r0, 14 + cmp r0, 0xFF + bls _081DDAE8 + movs r0, 0xFF +_081DDAE8: + strb r0, [r4, 0x2] + movs r3, 0x7F + subs r3, r2 + muls r3, r1 + ldrb r0, [r5, 0x11] + muls r0, r3 + asrs r0, 14 + cmp r0, 0xFF + bls _081DDAFC + movs r0, 0xFF +_081DDAFC: + strb r0, [r4, 0x3] + bx lr + thumb_func_end ChnVolSetAsm + + thumb_func_start ply_note +ply_note: + push {r4-r7,lr} + mov r4, r8 + mov r5, r9 + mov r6, r10 + mov r7, r11 + push {r4-r7} + sub sp, 0x18 + str r1, [sp] + adds r5, r2, 0 + ldr r1, =SOUND_INFO_PTR + ldr r1, [r1] + str r1, [sp, 0x4] + ldr r1, =gClockTable + adds r0, r1 + ldrb r0, [r0] + strb r0, [r5, o_MusicPlayerTrack_gateTime] + ldr r3, [r5, o_MusicPlayerTrack_cmdPtr] + ldrb r0, [r3] + cmp r0, 0x80 + bhs _081DDB46 + strb r0, [r5, o_MusicPlayerTrack_key] + adds r3, 0x1 + ldrb r0, [r3] + cmp r0, 0x80 + bhs _081DDB44 + strb r0, [r5, o_MusicPlayerTrack_velocity] + adds r3, 0x1 + ldrb r0, [r3] + cmp r0, 0x80 + bhs _081DDB44 + ldrb r1, [r5, o_MusicPlayerTrack_gateTime] + adds r1, r0 + strb r1, [r5, o_MusicPlayerTrack_gateTime] + adds r3, 0x1 +_081DDB44: + str r3, [r5, o_MusicPlayerTrack_cmdPtr] +_081DDB46: + movs r0, 0 + str r0, [sp, 0x14] + adds r4, r5, 0 + adds r4, o_MusicPlayerTrack_ToneData_type + ldrb r2, [r4] + movs r0, TONEDATA_TYPE_RHY | TONEDATA_TYPE_SPL + tst r0, r2 + beq _081DDB98 + ldrb r3, [r5, o_MusicPlayerTrack_key] + movs r0, TONEDATA_TYPE_SPL + tst r0, r2 + beq _081DDB66 + ldr r1, [r5, o_MusicPlayerTrack_ToneData_keySplitTable] + adds r1, r3 + ldrb r0, [r1] + b _081DDB68 +_081DDB66: + adds r0, r3, 0 +_081DDB68: + lsls r1, r0, 1 + adds r1, r0 + lsls r1, 2 + ldr r0, [r5, o_MusicPlayerTrack_ToneData_wav] + adds r1, r0 + mov r9, r1 + mov r6, r9 + ldrb r1, [r6] + movs r0, 0xC0 + tst r0, r1 + beq _081DDB80 + b _081DDCEA +_081DDB80: + movs r0, 0x80 + tst r0, r2 + beq _081DDB9C + ldrb r1, [r6, 0x3] + movs r0, 0x80 + tst r0, r1 + beq _081DDB94 + subs r1, 0xC0 + lsls r1, 1 + str r1, [sp, 0x14] +_081DDB94: + ldrb r3, [r6, 0x1] + b _081DDB9C +_081DDB98: + mov r9, r4 + ldrb r3, [r5, 0x5] +_081DDB9C: + str r3, [sp, 0x8] + ldr r6, [sp] + ldrb r1, [r6, 0x9] + ldrb r0, [r5, 0x1D] + adds r0, r1 + cmp r0, 0xFF + bls _081DDBAC + movs r0, 0xFF +_081DDBAC: + str r0, [sp, 0x10] + mov r6, r9 + ldrb r0, [r6] + movs r6, 0x7 + ands r6, r0 + str r6, [sp, 0xC] + beq _081DDBEC + ldr r0, [sp, 0x4] + ldr r4, [r0, 0x1C] + cmp r4, 0 + bne _081DDBC4 + b _081DDCEA +_081DDBC4: + subs r6, 0x1 + lsls r0, r6, 6 + adds r4, r0 + ldrb r1, [r4] + movs r0, 0xC7 + tst r0, r1 + beq _081DDC40 + movs r0, 0x40 + tst r0, r1 + bne _081DDC40 + ldrb r1, [r4, 0x13] + ldr r0, [sp, 0x10] + cmp r1, r0 + bcc _081DDC40 + beq _081DDBE4 + b _081DDCEA +_081DDBE4: + ldr r0, [r4, 0x2C] + cmp r0, r5 + bcs _081DDC40 + b _081DDCEA +_081DDBEC: + ldr r6, [sp, 0x10] + adds r7, r5, 0 + movs r2, 0 + mov r8, r2 + ldr r4, [sp, 0x4] + ldrb r3, [r4, 0x6] + adds r4, 0x50 +_081DDBFA: + ldrb r1, [r4] + movs r0, 0xC7 + tst r0, r1 + beq _081DDC40 + movs r0, 0x40 + tst r0, r1 + beq _081DDC14 + cmp r2, 0 + bne _081DDC18 + adds r2, 0x1 + ldrb r6, [r4, 0x13] + ldr r7, [r4, 0x2C] + b _081DDC32 +_081DDC14: + cmp r2, 0 + bne _081DDC34 +_081DDC18: + ldrb r0, [r4, 0x13] + cmp r0, r6 + bcs _081DDC24 + adds r6, r0, 0 + ldr r7, [r4, 0x2C] + b _081DDC32 +_081DDC24: + bhi _081DDC34 + ldr r0, [r4, 0x2C] + cmp r0, r7 + bls _081DDC30 + adds r7, r0, 0 + b _081DDC32 +_081DDC30: + bcc _081DDC34 +_081DDC32: + mov r8, r4 +_081DDC34: + adds r4, 0x40 + subs r3, 0x1 + bgt _081DDBFA + mov r4, r8 + cmp r4, 0 + beq _081DDCEA +_081DDC40: + adds r0, r4, 0 + bl ClearChain + movs r1, 0 + str r1, [r4, 0x30] + ldr r3, [r5, 0x20] + str r3, [r4, 0x34] + cmp r3, 0 + beq _081DDC54 + str r4, [r3, 0x30] +_081DDC54: + str r4, [r5, 0x20] + str r5, [r4, 0x2C] + ldrb r0, [r5, 0x1B] + strb r0, [r5, 0x1C] + cmp r0, r1 + beq _081DDC66 + adds r1, r5, 0 + bl clear_modM +_081DDC66: + ldr r0, [sp] + adds r1, r5, 0 + bl TrkVolPitSet + ldr r0, [r5, 0x4] + str r0, [r4, 0x10] + ldr r0, [sp, 0x10] + strb r0, [r4, 0x13] + ldr r0, [sp, 0x8] + strb r0, [r4, 0x8] + ldr r0, [sp, 0x14] + strb r0, [r4, 0x14] + mov r6, r9 + ldrb r0, [r6] + strb r0, [r4, 0x1] + ldr r7, [r6, 0x4] + str r7, [r4, 0x24] + ldr r0, [r6, 0x8] + str r0, [r4, 0x4] + ldrh r0, [r5, 0x1E] + strh r0, [r4, 0xC] + bl ChnVolSetAsm + ldrb r1, [r4, 0x8] + movs r0, 0x8 + ldrsb r0, [r5, r0] + adds r3, r1, r0 + bpl _081DDCA0 + movs r3, 0 +_081DDCA0: + ldr r6, [sp, 0xC] + cmp r6, 0 + beq _081DDCCE + mov r6, r9 + ldrb r0, [r6, 0x2] + strb r0, [r4, 0x1E] + ldrb r1, [r6, 0x3] + movs r0, 0x80 + tst r0, r1 + bne _081DDCBA + movs r0, 0x70 + tst r0, r1 + bne _081DDCBC +_081DDCBA: + movs r1, 0x8 +_081DDCBC: + strb r1, [r4, 0x1F] + ldrb r2, [r5, 0x9] + adds r1, r3, 0 + ldr r0, [sp, 0xC] + ldr r3, [sp, 0x4] + ldr r3, [r3, 0x30] + bl call_r3 + b _081DDCDC +_081DDCCE: + ldr r0, [r5, o_MusicPlayerTrack_unk_3C] + str r0, [r4, 0x18] + ldrb r2, [r5, 0x9] + adds r1, r3, 0 + adds r0, r7, 0 + bl MidiKeyToFreq +_081DDCDC: + str r0, [r4, 0x20] + movs r0, 0x80 + strb r0, [r4] + ldrb r1, [r5] + movs r0, 0xF0 + ands r0, r1 + strb r0, [r5] +_081DDCEA: + add sp, 0x18 + pop {r0-r7} + mov r8, r0 + mov r9, r1 + mov r10, r2 + mov r11, r3 + pop {r0} + bx r0 + .pool + thumb_func_end ply_note + + thumb_func_start ply_endtie +ply_endtie: + push {r4,r5} + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + ldrb r3, [r2] + cmp r3, 0x80 + bhs _081DDD16 + strb r3, [r1, o_MusicPlayerTrack_key] + adds r2, 0x1 + str r2, [r1, o_MusicPlayerTrack_cmdPtr] + b _081DDD18 +_081DDD16: + ldrb r3, [r1, o_MusicPlayerTrack_key] +_081DDD18: + ldr r1, [r1, o_MusicPlayerTrack_chan] + cmp r1, 0 + beq _081DDD40 + movs r4, 0x83 + movs r5, 0x40 +_081DDD22: + ldrb r2, [r1, o_SoundChannel_status] + tst r2, r4 + beq _081DDD3A + tst r2, r5 + bne _081DDD3A + ldrb r0, [r1, o_SoundChannel_mk] + cmp r0, r3 + bne _081DDD3A + movs r0, 0x40 + orrs r2, r0 + strb r2, [r1, o_SoundChannel_status] + b _081DDD40 +_081DDD3A: + ldr r1, [r1, o_SoundChannel_np] + cmp r1, 0 + bne _081DDD22 +_081DDD40: + pop {r4,r5} + bx lr + thumb_func_end ply_endtie + + thumb_func_start clear_modM +clear_modM: + movs r2, 0 + strb r2, [r1, o_MusicPlayerTrack_modM] + strb r2, [r1, o_MusicPlayerTrack_lfoSpeedC] + ldrb r2, [r1, o_MusicPlayerTrack_modT] + cmp r2, 0 + bne _081DDD54 + movs r2, 0xC + b _081DDD56 +_081DDD54: + movs r2, 0x3 +_081DDD56: + ldrb r3, [r1, o_MusicPlayerTrack_flags] + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx lr + thumb_func_end clear_modM + + thumb_func_start ld_r3_tp_adr_i +ld_r3_tp_adr_i_unchecked: + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + adds r3, r2, 1 + str r3, [r1, o_MusicPlayerTrack_cmdPtr] + ldrb r3, [r2] + bx lr + thumb_func_end ld_r3_tp_adr_i + + thumb_func_start ply_lfos +ply_lfos: + mov r12, lr + bl ld_r3_tp_adr_i_unchecked + strb r3, [r1, o_MusicPlayerTrack_lfoSpeed] + cmp r3, 0 + bne _081DDD7C + bl clear_modM +_081DDD7C: + bx r12 + thumb_func_end ply_lfos + + thumb_func_start ply_mod +ply_mod: + mov r12, lr + bl ld_r3_tp_adr_i_unchecked + strb r3, [r1, o_MusicPlayerTrack_mod] + cmp r3, 0 + bne _081DDD90 + bl clear_modM +_081DDD90: + bx r12 + thumb_func_end ply_mod + + .align 2, 0 @ Don't pad with nop. diff --git a/asm/m4a_3.s b/asm/m4a_3.s new file mode 100644 index 0000000000..a842ae925a --- /dev/null +++ b/asm/m4a_3.s @@ -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. diff --git a/asm/main.s b/asm/main.s index a5ec6f5c62..d70b1ff966 100644 --- a/asm/main.s +++ b/asm/main.s @@ -477,7 +477,7 @@ _08000782: bl CopyBufferedValuesToGpuRegs bl ProcessDma3Requests ldr r1, =gUnknown_03002F50 - ldr r0, =gUnknown_03006380 + ldr r0, =gSoundInfo ldrb r0, [r0, 0x4] strb r0, [r1] bl m4aSoundMain @@ -562,7 +562,7 @@ VCountIntr: @ 8000844 beq _08000852 bl _call_via_r0 _08000852: - bl SoundVSync_rev01 + bl m4aSoundVSync ldr r2, =gUnknown_03007FF8 ldrh r0, [r2] movs r1, 0x4 @@ -661,7 +661,7 @@ Reset: @ 80008F4 ldr r1, =0x04000208 movs r0, 0 strh r0, [r1] - bl SoundVSyncOff_rev01 + bl m4aSoundVSyncOff bl remove_some_task ldr r1, =0x040000bc ldrh r2, [r1, 0xA] @@ -709,7 +709,7 @@ sub_8000964: @ 8000964 mov r1, sp movs r0, 0 strh r0, [r1] - ldr r1, =gUnknown_03007330 + ldr r1, =gPokemonCrySongs ldr r2, =0x01000034 mov r0, sp bl CpuSet diff --git a/asm/mauville_old_man.s b/asm/mauville_old_man.s index 38e66b0f55..260182dd19 100644 --- a/asm/mauville_old_man.s +++ b/asm/mauville_old_man.s @@ -965,12 +965,12 @@ _08120850: lsls r1, 1 adds r0, r1 strh r0, [r6, 0x6] - ldr r4, =gUnknown_03007630 + ldr r4, =gMPlay_SE2 ldr r5, =0x0000ffff ldrh r2, [r6, 0x6] adds r0, r4, 0 adds r1, r5, 0 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl ldrb r1, [r6, 0x1] lsls r1, 2 adds r1, r6, r1 @@ -984,7 +984,7 @@ _08120850: ldrsh r2, [r6, r3] adds r0, r4, 0 adds r1, r5, 0 - bl MPlayPitchControl + bl m4aMPlayPitchControl b _08120938 .pool _081208A0: @@ -1008,17 +1008,17 @@ _081208BC: subs r0, 0x40 _081208C0: strh r0, [r6, 0x8] - ldr r4, =gUnknown_03007630 + ldr r4, =gMPlay_SE2 ldr r5, =0x0000ffff ldrh r2, [r6, 0x6] adds r0, r4, 0 adds r1, r5, 0 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl movs r0, 0x8 ldrsh r2, [r6, r0] adds r0, r4, 0 adds r1, r5, 0 - bl MPlayPitchControl + bl m4aMPlayPitchControl ldrh r0, [r6, 0xA] adds r0, 0x1 strh r0, [r6, 0xA] @@ -1059,8 +1059,8 @@ _08120922: lsls r0, 24 cmp r0, 0 bne _08120938 - ldr r0, =gUnknown_03007630 - bl MPlayStop_rev01 + ldr r0, =gMPlay_SE2 + bl m4aMPlayStop movs r0, 0x4 _08120936: strb r0, [r6, 0x3] @@ -1228,9 +1228,9 @@ _08120A7E: bne _08120AB0 movs r0, 0x6 bl sub_80A3228 - ldr r0, =gUnknown_03007630 + ldr r0, =gMPlay_SE2 movs r1, 0x2 - bl sub_82E0308 + bl m4aMPlayFadeOutTemporarily bl script_env_2_enable_and_set_ctx_running adds r0, r6, 0 bl DestroyTask diff --git a/asm/option_menu.s b/asm/option_menu.s index 8fff8e3942..4983212265 100644 --- a/asm/option_menu.s +++ b/asm/option_menu.s @@ -1101,7 +1101,7 @@ sub_80BADD8: @ 80BADD8 movs r4, 0x1 eors r5, r4 adds r0, r5, 0 - bl sub_82E1810 + bl SetPokemonCryStereo ldr r0, =gUnknown_02039B48 strb r4, [r0] _080BADF8: diff --git a/asm/pokedex.s b/asm/pokedex.s index 80b33886dc..a5e987f3c6 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -497,10 +497,10 @@ _080BB71C: adds r1, r2 ldrb r1, [r1] bl sub_80BC8D4 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl _080BB74C: add sp, 0x8 pop {r3} @@ -1246,11 +1246,11 @@ _080BBE18: bl DestroyTask ldr r0, =sub_8086194 bl SetMainCallback2 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl ldr r0, [r5] bl Free _080BBE4A: @@ -7228,8 +7228,8 @@ _080BF2A8: beq _080BF2B6 b _080BF5B2 _080BF2B6: - ldr r0, =gUnknown_03007420 - bl MPlayStop_rev01 + ldr r0, =gMPlay_BGM + bl m4aMPlayStop ldr r5, =gUnknown_02039B4C ldr r0, [r5] ldr r3, =0x0000064a @@ -7592,7 +7592,7 @@ _080BF636: movs r2, 0 movs r3, 0x10 bl pal_fade_maybe - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM bl m4aMPlayContinue ldr r0, =gUnknown_02039B4C ldr r0, [r0] @@ -7634,7 +7634,7 @@ _080BF6B0: movs r2, 0 movs r3, 0x10 bl pal_fade_maybe - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM bl m4aMPlayContinue ldr r0, =gUnknown_02039B4C ldr r0, [r0] @@ -7689,7 +7689,7 @@ _080BF73C: movs r2, 0 movs r3, 0x10 bl pal_fade_maybe - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM bl m4aMPlayContinue ldr r0, =gUnknown_02039B4C ldr r0, [r0] diff --git a/asm/pokedex_cry_screen.s b/asm/pokedex_cry_screen.s index 357a300ad7..fddf568161 100644 --- a/asm/pokedex_cry_screen.s +++ b/asm/pokedex_cry_screen.s @@ -239,7 +239,7 @@ sub_8145534: @ 8145534 lsls r0, 16 lsrs r4, r0, 16 adds r5, r4, 0 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r0, [r0, 0x4] cmp r0, 0 bge _08145582 @@ -300,11 +300,11 @@ sub_81455A8: @ 81455A8 ldrsb r0, [r3, r0] cmp r0, 0x1 bgt _081455C0 - ldr r0, =gUnknown_030066D0 + ldr r0, =gSoundInfo + 0x350 b _081455D8 .pool _081455C0: - ldr r2, =gUnknown_03006380 + ldr r2, =gSoundInfo ldrb r1, [r2, 0xB] movs r0, 0 ldrsb r0, [r3, r0] diff --git a/asm/rom_8034C54.s b/asm/rom_8034C54.s index 6560c85e13..9fe4f9b7b5 100644 --- a/asm/rom_8034C54.s +++ b/asm/rom_8034C54.s @@ -6299,10 +6299,10 @@ sub_80384E4: @ 80384E4 ands r0, r1 cmp r0, 0 bne _08038512 - ldr r0, =gUnknown_030075F0 - bl MPlayStop_rev01 - ldr r0, =gUnknown_03007630 - bl MPlayStop_rev01 + ldr r0, =gMPlay_SE1 + bl m4aMPlayStop + ldr r0, =gMPlay_SE2 + bl m4aMPlayStop bl sub_803849C bl FreeAllWindowBuffers ldr r0, =gUnknown_030022C0 @@ -48662,18 +48662,18 @@ _0804FCA2: b _0804FD70 .pool _0804FCC4: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x55 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl b _0804FD70 .pool _0804FCD8: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl b _0804FD70 .pool _0804FCF0: @@ -65202,16 +65202,16 @@ _08058C82: ands r0, r1 cmp r0, 0x42 bne _08058D08 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM bl m4aMPlayContinue b _08058D14 .pool _08058D08: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl _08058D14: ldr r0, =gUnknown_020244D0 ldr r2, [r0] @@ -65528,11 +65528,11 @@ sub_8058FC0: @ 8058FC0 lsls r0, 24 cmp r0, 0 bne _0805900E - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl ldr r2, =gUnknown_0202406E ldrb r1, [r4] lsls r0, r1, 1 @@ -65648,11 +65648,11 @@ c3_0802FDF4: @ 8059100 lsls r0, 24 cmp r0, 0 bne _08059122 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl adds r0, r4, 0 bl DestroyTask _08059122: @@ -74118,10 +74118,10 @@ mplay_80342A4: @ 805DB90 ldrb r0, [r0, 0x8] cmp r0, 0x1D bls _0805DBDC - ldr r0, =gUnknown_030075F0 - bl MPlayStop_rev01 - ldr r0, =gUnknown_03007630 - bl MPlayStop_rev01 + ldr r0, =gMPlay_SE1 + bl m4aMPlayStop + ldr r0, =gMPlay_SE2 + bl m4aMPlayStop _0805DBD8: cmp r5, 0 beq _0805DBF0 @@ -77341,16 +77341,16 @@ _0805F6D0: lsrs r0, 24 cmp r0, 0x1 bne _0805F774 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM bl m4aMPlayContinue b _0805F774 .pool _0805F768: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl _0805F774: ldr r0, =gUnknown_020244D0 ldr r2, [r0] @@ -77957,11 +77957,11 @@ bx_803AEDC: @ 805FC80 cmp r1, r0 bne _0805FCDA _0805FCCA: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl bl dp01_tbl7_exec_completed _0805FCDA: pop {r4} @@ -86796,16 +86796,16 @@ _08064898: lsrs r0, 24 cmp r0, 0x1 bne _0806493C - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM bl m4aMPlayContinue b _0806493C .pool _08064930: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl _0806493C: ldr r0, =gUnknown_020244D0 ldr r2, [r0] @@ -87368,11 +87368,11 @@ sub_8064DD0: @ 8064DD0 cmp r1, r0 bne _08064E2A _08064E1A: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl bl sub_8065068 _08064E2A: pop {r4} diff --git a/asm/rom_8072304.s b/asm/rom_8072304.s index 632c29aa6e..a04cc995ea 100644 --- a/asm/rom_8072304.s +++ b/asm/rom_8072304.s @@ -7165,15 +7165,15 @@ _08075E00: lsls r0, 24 cmp r0, 0 beq _08075E56 - ldr r0, =gUnknown_03007420 - bl MPlayStop_rev01 + ldr r0, =gMPlay_BGM + bl m4aMPlayStop b _08075E56 .pool _08075E4C: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl _08075E56: bl battle_type_is_double lsls r0, 24 diff --git a/asm/rom_80A3934.s b/asm/rom_80A3934.s index f87102c032..252688e015 100644 --- a/asm/rom_80A3934.s +++ b/asm/rom_80A3934.s @@ -260,9 +260,9 @@ _080A3BAA: beq _080A3BC2 cmp r8, r0 bne _080A3BA8 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM movs r2, 0x80 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl _080A3BC2: ldr r0, =gUnknown_02022E24 movs r1, 0 @@ -804,10 +804,10 @@ _080A401E: b _080A40A2 .pool _080A4030: - ldr r0, =gUnknown_030075F0 - bl MPlayStop_rev01 - ldr r0, =gUnknown_03007630 - bl MPlayStop_rev01 + ldr r0, =gMPlay_SE1 + bl m4aMPlayStop + ldr r0, =gMPlay_SE2 + bl m4aMPlayStop _080A403C: ldr r1, =gUnknown_0203842E movs r0, 0 @@ -841,11 +841,11 @@ _080A406E: mov r1, r8 cmp r1, 0 bne _080A40A2 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl bl sub_80A4DF0 lsls r0, 24 cmp r0, 0 @@ -3737,10 +3737,10 @@ ma20_wait_for_something: @ 80A586C lsrs r0, 16 cmp r0, 0x5A bls _080A58BA - ldr r0, =gUnknown_030075F0 - bl MPlayStop_rev01 - ldr r0, =gUnknown_03007630 - bl MPlayStop_rev01 + ldr r0, =gMPlay_SE1 + bl m4aMPlayStop + ldr r0, =gMPlay_SE2 + bl m4aMPlayStop strh r5, [r4] b _080A58DE .pool @@ -4189,10 +4189,10 @@ _080A5C38: thumb_func_start ma2F_stop_music ma2F_stop_music: @ 80A5C44 push {lr} - ldr r0, =gUnknown_030075F0 - bl MPlayStop_rev01 - ldr r0, =gUnknown_03007630 - bl MPlayStop_rev01 + ldr r0, =gMPlay_SE1 + bl m4aMPlayStop + ldr r0, =gMPlay_SE2 + bl m4aMPlayStop ldr r1, =gUnknown_020383F0 ldr r0, [r1] adds r0, 0x1 diff --git a/asm/rom_816F318.s b/asm/rom_816F318.s index 8037a2185b..a685d5d28a 100644 --- a/asm/rom_816F318.s +++ b/asm/rom_816F318.s @@ -1828,7 +1828,7 @@ _0817014C: ldrb r0, [r0, 0x15] lsls r0, 31 lsrs r0, 31 - bl sub_82E1810 + bl SetPokemonCryStereo ldr r0, =0x02000000 movs r1, 0xE0 lsls r1, 9 @@ -10091,11 +10091,11 @@ _081747B8: cmp r0, 0 beq _081747D2 bl sub_80A369C - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl _081747D2: ldr r0, =sub_8174898 str r0, [r4] @@ -10111,11 +10111,11 @@ _081747E4: cmp r0, 0 beq _08174806 bl sub_80A369C - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl _08174806: ldr r0, =gTasks lsls r1, r6, 2 diff --git a/asm/rom_81795E8.s b/asm/rom_81795E8.s index e3e8b4e95e..9a873cce60 100644 --- a/asm/rom_81795E8.s +++ b/asm/rom_81795E8.s @@ -1402,11 +1402,11 @@ sub_817A2C0: @ 817A2C0 bne _0817A304 bl ResetAllObjectData bl ResetObjectPaletteAllocator - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl ldr r0, =gUnknown_030022C0 ldr r0, [r0, 0x8] bl SetMainCallback2 diff --git a/asm/rom_8184DA4.s b/asm/rom_8184DA4.s index c11a12a976..6956a15885 100644 --- a/asm/rom_8184DA4.s +++ b/asm/rom_8184DA4.s @@ -3369,16 +3369,16 @@ _081869AE: lsrs r0, 24 cmp r0, 0x1 bne _08186A4C - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM bl m4aMPlayContinue b _08186A4C .pool _08186A40: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl _08186A4C: ldr r0, =gUnknown_020244D0 ldr r2, [r0] @@ -3956,11 +3956,11 @@ sub_8186F14: @ 8186F14 cmp r1, r0 bne _08186F6E _08186F5E: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl bl sub_81871AC _08186F6E: pop {r4} @@ -9392,16 +9392,16 @@ _08189EA2: lsls r0, 24 cmp r0, 0 bne _08189F44 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM bl m4aMPlayContinue b _08189F44 .pool _08189F38: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl _08189F44: ldr r0, =gUnknown_020244D0 ldr r2, [r0] @@ -61438,11 +61438,11 @@ _081A54D4: bl sub_8056A3C movs r0, 0 bl CopyBgTilemapBufferToVram - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl ldr r0, =0x7fffff1c movs r1, 0 str r1, [sp] diff --git a/asm/rom_81BAD84.s b/asm/rom_81BAD84.s index 329a2814e3..2bdbb32ec8 100644 --- a/asm/rom_81BAD84.s +++ b/asm/rom_81BAD84.s @@ -7976,7 +7976,7 @@ sub_81BF384: @ 81BF384 bl DisableInterrupts movs r0, 0x1 bl EnableInterrupts - bl SoundVSyncOff_rev01 + bl m4aSoundVSyncOff movs r0, 0 bl SetVBlankCallback bl ResetAllObjectData @@ -9827,11 +9827,11 @@ sub_81C0484: @ 81C0484 bl ResetAllObjectData bl ResetObjectPaletteAllocator bl sub_80A369C - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl ldr r0, =gUnknown_020244D4 ldr r0, [r0] cmp r0, 0 diff --git a/asm/roulette.s b/asm/roulette.s index fbd5facba2..08bcd5bf21 100644 --- a/asm/roulette.s +++ b/asm/roulette.s @@ -6815,19 +6815,19 @@ _08143BEA: lsls r0, 24 cmp r0, 0 beq _08143C74 - ldr r0, =gUnknown_030075F0 + ldr r0, =gMPlay_SE1 ldr r4, =0x0000ffff ldrh r2, [r7, 0x24] lsls r2, 24 asrs r2, 24 adds r1, r4, 0 - bl MPlayPanpotControl - ldr r0, =gUnknown_03007630 + bl m4aMPlayPanpotControl + ldr r0, =gMPlay_SE2 ldrh r2, [r7, 0x24] lsls r2, 24 asrs r2, 24 adds r1, r4, 0 - bl MPlayPanpotControl + bl m4aMPlayPanpotControl _08143C74: pop {r3} mov r8, r3 @@ -9294,17 +9294,17 @@ sub_81450D8: @ 81450D8 adds r4, r0 asrs r4, 1 negs r4, r4 - ldr r0, =gUnknown_030075F0 + ldr r0, =gMPlay_SE1 ldr r5, =0x0000ffff lsls r4, 24 asrs r4, 24 adds r1, r5, 0 adds r2, r4, 0 - bl MPlayPanpotControl - ldr r0, =gUnknown_03007630 + bl m4aMPlayPanpotControl + ldr r0, =gMPlay_SE2 adds r1, r5, 0 adds r2, r4, 0 - bl MPlayPanpotControl + bl m4aMPlayPanpotControl b _08145208 .pool _0814516C: diff --git a/asm/sound.s b/asm/sound.s index 981a6df4df..bdcb85e160 100644 --- a/asm/sound.s +++ b/asm/sound.s @@ -297,8 +297,8 @@ pause_music_for_sound_maybe: @ 80A3060 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - ldr r0, =gUnknown_03007420 - bl MPlayStop_rev01 + ldr r0, =gMPlay_BGM + bl m4aMPlayStop ldr r0, =gUnknown_085248BC lsls r4, 2 adds r4, r0 @@ -330,7 +330,7 @@ ducking_tick: @ 80A3094 _080A30B0: cmp r1, 0 bne _080A30C0 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM bl m4aMPlayContinue b _080A30C6 .pool @@ -422,7 +422,7 @@ task50_overworld_fanfare: @ 80A3140 b _080A3164 .pool _080A3158: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM bl m4aMPlayContinue adds r0, r4, 0 bl DestroyTask @@ -474,18 +474,18 @@ _080A31A8: _080A31B0: adds r0, r5, 0 bl m4aSongNumStart - ldr r4, =gUnknown_03007420 + ldr r4, =gMPlay_BGM adds r0, r4, 0 bl m4aMPlayImmInit adds r0, r4, 0 adds r1, r6, 0 movs r2, 0 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl adds r0, r5, 0 bl m4aSongNumStop adds r0, r4, 0 adds r1, r7, 0 - bl sub_82E0328 + bl m4aMPlayFadeIn pop {r4-r7} pop {r0} bx r0 @@ -498,8 +498,8 @@ sub_80A31E8: @ 80A31E8 adds r1, r0, 0 lsls r1, 24 lsrs r1, 24 - ldr r0, =gUnknown_03007420 - bl sub_82E0308 + ldr r0, =gMPlay_BGM + bl m4aMPlayFadeOutTemporarily pop {r0} bx r0 .pool @@ -508,7 +508,7 @@ sub_80A31E8: @ 80A31E8 thumb_func_start sub_80A3200 sub_80A3200: @ 80A3200 push {lr} - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, [r0, 0x4] cmp r1, 0 blt _080A3220 @@ -532,8 +532,8 @@ sub_80A3228: @ 80A3228 adds r1, r0, 0 lsls r1, 24 lsrs r1, 24 - ldr r0, =gUnknown_03007420 - bl sub_82E0328 + ldr r0, =gMPlay_BGM + bl m4aMPlayFadeIn pop {r0} bx r0 .pool @@ -546,7 +546,7 @@ play_sound_effect: @ 80A3240 adds r1, r0, 0 lsls r1, 24 lsrs r1, 24 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM bl m4aMPlayFadeOut pop {r0} bx r0 @@ -556,7 +556,7 @@ play_sound_effect: @ 80A3240 thumb_func_start sub_80A3258 sub_80A3258: @ 80A3258 push {lr} - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldrh r0, [r0, 0x4] cmp r0, 0 beq _080A326C @@ -580,10 +580,10 @@ cry_related: @ 80A3274 lsrs r5, 16 lsls r4, 24 lsrs r4, 24 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x55 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl lsls r4, 24 asrs r4, 24 movs r0, 0 @@ -646,10 +646,10 @@ sub_80A32E4: @ 80A32E4 bl sub_80A344C b _080A332E _080A330A: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x55 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl lsls r1, r5, 24 asrs r1, 24 str r4, [sp] @@ -698,10 +698,10 @@ _080A336E: ands r0, r1 cmp r0, 0 bne _080A3384 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x55 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl _080A3384: lsls r1, r5, 24 asrs r1, 24 @@ -739,10 +739,10 @@ play_cry_maybe: @ 80A33A8 bl sub_80A344C b _080A33EE _080A33CE: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x55 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl lsls r1, r5, 24 asrs r1, 24 str r4, [sp] @@ -771,10 +771,10 @@ sub_80A3404: @ 80A3404 lsrs r5, 16 lsls r4, 24 lsrs r4, 24 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x55 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl str r4, [sp] adds r0, r5, 0 movs r1, 0 @@ -922,25 +922,25 @@ _080A3560: ldr r4, =0x00003a98 _080A3562: adds r0, r2, 0 - bl sub_82E1744 + bl SetPokemonCryVolume mov r1, r10 lsls r0, r1, 24 asrs r0, 24 - bl sub_82E1758 + bl SetPokemonCryPanpot adds r0, r4, 0 - bl sub_82E1770 + bl SetPokemonCryPitch adds r0, r6, 0 - bl sub_82E17A8 + bl SetPokemonCryLength movs r0, 0 - bl sub_82E17C0 + bl SetPokemonCryProgress adds r0, r5, 0 - bl sub_82E17B4 + bl SetPokemonCryRelease mov r3, r8 lsls r0, r3, 24 asrs r0, 24 - bl sub_82E17E4 + bl SetPokemonCryChorus ldr r0, [sp] - bl sub_82E1850 + bl SetPokemonCryPriority adds r0, r7, 0 bl speciesid_conv adds r7, r0, 0 @@ -1032,7 +1032,7 @@ _080A364C: ldr r1, =gUnknown_0869EEF4 _080A3654: adds r0, r1 - bl sub_82E1674 + bl SetPokemonCryTone ldr r1, =gUnknown_020383E8 str r0, [r1] _080A365E: @@ -1072,7 +1072,7 @@ sub_80A369C: @ 80A369C push {lr} ldr r0, =gUnknown_020383E8 ldr r0, [r0] - bl MPlayStop_rev01 + bl m4aMPlayStop bl sub_8000964 pop {r0} bx r0 @@ -1084,7 +1084,7 @@ sub_80A36B4: @ 80A36B4 push {lr} ldr r0, =gUnknown_020383E8 ldr r0, [r0] - bl MPlayStop_rev01 + bl m4aMPlayStop pop {r0} bx r0 .pool @@ -1095,7 +1095,7 @@ sub_80A36C8: @ 80A36C8 push {lr} ldr r0, =gUnknown_020383E8 ldr r0, [r0] - bl sub_82E17CC + bl IsPokemonCryPlaying cmp r0, 0 bne _080A36E4 bl sub_8000964 @@ -1114,7 +1114,7 @@ sub_80A36EC: @ 80A36EC push {lr} ldr r0, =gUnknown_020383E8 ldr r0, [r0] - bl sub_82E17CC + bl IsPokemonCryPlaying cmp r0, 0 bne _080A3704 movs r0, 0 @@ -1143,14 +1143,14 @@ sub_80A370C: @ 80A370C _080A3724: ldr r0, =gUnknown_020383E8 ldr r0, [r0] - bl sub_82E17CC + bl IsPokemonCryPlaying cmp r0, 0 bne _080A3742 - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff movs r2, 0x80 lsls r2, 1 - bl MPlayVolumeControl + bl m4aMPlayVolumeControl adds r0, r4, 0 bl DestroyTask _080A3742: @@ -1224,10 +1224,10 @@ audio_play_and_stuff: @ 80A37B4 lsls r4, 24 lsrs r4, 24 bl m4aSongNumStart - ldr r6, =gUnknown_030075F0 + ldr r6, =gMPlay_SE1 adds r0, r6, 0 bl m4aMPlayImmInit - ldr r0, =gUnknown_03007630 + ldr r0, =gMPlay_SE2 mov r8, r0 bl m4aMPlayImmInit ldr r5, =0x0000ffff @@ -1236,11 +1236,11 @@ audio_play_and_stuff: @ 80A37B4 adds r0, r6, 0 adds r1, r5, 0 adds r2, r4, 0 - bl MPlayPanpotControl + bl m4aMPlayPanpotControl mov r0, r8 adds r1, r5, 0 adds r2, r4, 0 - bl MPlayPanpotControl + bl m4aMPlayPanpotControl pop {r3} mov r8, r3 pop {r4-r6} @@ -1258,7 +1258,7 @@ sub_80A3808: @ 80A3808 lsls r4, 24 lsrs r4, 24 bl m4aSongNumStart - ldr r5, =gUnknown_030075F0 + ldr r5, =gMPlay_SE1 adds r0, r5, 0 bl m4aMPlayImmInit ldr r1, =0x0000ffff @@ -1266,7 +1266,7 @@ sub_80A3808: @ 80A3808 asrs r4, 24 adds r0, r5, 0 adds r2, r4, 0 - bl MPlayPanpotControl + bl m4aMPlayPanpotControl pop {r4,r5} pop {r0} bx r0 @@ -1282,7 +1282,7 @@ sub_80A383C: @ 80A383C lsls r4, 24 lsrs r4, 24 bl m4aSongNumStart - ldr r5, =gUnknown_03007630 + ldr r5, =gMPlay_SE2 adds r0, r5, 0 bl m4aMPlayImmInit ldr r1, =0x0000ffff @@ -1290,7 +1290,7 @@ sub_80A383C: @ 80A383C asrs r4, 24 adds r0, r5, 0 adds r2, r4, 0 - bl MPlayPanpotControl + bl m4aMPlayPanpotControl pop {r4,r5} pop {r0} bx r0 @@ -1301,17 +1301,17 @@ sub_80A383C: @ 80A383C sub_80A3870: @ 80A3870 push {r4,r5,lr} adds r4, r0, 0 - ldr r0, =gUnknown_030075F0 + ldr r0, =gMPlay_SE1 ldr r5, =0x0000ffff lsls r4, 24 asrs r4, 24 adds r1, r5, 0 adds r2, r4, 0 - bl MPlayPanpotControl - ldr r0, =gUnknown_03007630 + bl m4aMPlayPanpotControl + ldr r0, =gMPlay_SE2 adds r1, r5, 0 adds r2, r4, 0 - bl MPlayPanpotControl + bl m4aMPlayPanpotControl pop {r4,r5} pop {r0} bx r0 @@ -1321,14 +1321,14 @@ sub_80A3870: @ 80A3870 thumb_func_start mplay_has_finished_maybe mplay_has_finished_maybe: @ 80A38A0 push {lr} - ldr r0, =gUnknown_030075F0 + ldr r0, =gMPlay_SE1 ldr r1, [r0, 0x4] movs r2, 0x80 lsls r2, 24 adds r3, r0, 0 cmp r1, 0 bge _080A38BA - ldr r0, =gUnknown_03007630 + ldr r0, =gMPlay_SE2 ldr r0, [r0, 0x4] ands r0, r2 cmp r0, 0 @@ -1338,7 +1338,7 @@ _080A38BA: ldrh r0, [r3, 0x4] cmp r0, 0 bne _080A38DC - ldr r0, =gUnknown_03007630 + ldr r0, =gMPlay_SE2 ldr r0, [r0, 0x4] ands r0, r1 cmp r0, 0 @@ -1357,7 +1357,7 @@ _080A38DE: thumb_func_start sub_80A38E4 sub_80A38E4: @ 80A38E4 push {lr} - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, [r0, 0x4] cmp r1, 0 blt _080A3904 @@ -1378,7 +1378,7 @@ _080A3906: thumb_func_start sub_80A390C sub_80A390C: @ 80A390C push {lr} - ldr r0, =gUnknown_03007800 + ldr r0, =gMPlay_SE3 ldr r1, [r0, 0x4] cmp r1, 0 blt _080A392C diff --git a/asm/text.s b/asm/text.s index b543cd3d07..7b1e9c53c2 100644 --- a/asm/text.s +++ b/asm/text.s @@ -2796,12 +2796,12 @@ _08005ABA: strb r0, [r6, 0x9] b _08005A0A _08005ABE: - ldr r0, =gUnknown_03007420 - bl MPlayStop_rev01 + ldr r0, =gMPlay_BGM + bl m4aMPlayStop b _08005A0A .pool _08005ACC: - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM bl m4aMPlayContinue b _08005A0A .pool diff --git a/asm/title_screen.s b/asm/title_screen.s index 50e30a36b6..ef95185b6c 100644 --- a/asm/title_screen.s +++ b/asm/title_screen.s @@ -1169,7 +1169,7 @@ _080AAE30: _080AAE72: ldrb r0, [r3, 0x8] bl title_screen_update_rayquaza_ring_palette - ldr r0, =gUnknown_03007420 + ldr r0, =gMPlay_BGM ldr r1, =0x0000ffff ldrh r0, [r0, 0x4] cmp r0, 0 diff --git a/common_syms/m4a_2.txt b/common_syms/m4a_2.txt new file mode 100644 index 0000000000..b9281c718b --- /dev/null +++ b/common_syms/m4a_2.txt @@ -0,0 +1,12 @@ +gSoundInfo +gPokemonCrySongs +gPokemonCryMusicPlayers +gMPlay_BGM +gMPlayJumpTable +gCgbChans +gMPlay_SE1 +gMPlay_SE2 +gPokemonCryTracks +gPokemonCrySong +gMPlayMemAccArea +gMPlay_SE3 diff --git a/constants/gba_constants.inc b/constants/gba_constants.inc index 46dfdcc2f9..9d59c8fcdd 100644 --- a/constants/gba_constants.inc +++ b/constants/gba_constants.inc @@ -15,7 +15,20 @@ .set IWRAM_START, 0x03000000 .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_HBLANK, 1 << 1 @@ -32,6 +45,9 @@ .set INTR_FLAG_KEYPAD, 1 << 12 .set INTR_FLAG_GAMEPAK, 1 << 13 + .set VCOUNT_VBLANK, 160 + .set TOTAL_SCANLINES, 228 + .set REG_BASE, 0x4000000 @ I/O register base address @ I/O register offsets @@ -79,22 +95,43 @@ .set OFFSET_REG_SOUND1CNT, 0x60 .set OFFSET_REG_SOUND1CNT_L, 0x60 + .set OFFSET_REG_NR10, 0x60 .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_NR13, 0x64 + .set OFFSET_REG_NR14, 0x65 .set OFFSET_REG_SOUND2CNT, 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_NR23, 0x6c + .set OFFSET_REG_NR24, 0x6d .set OFFSET_REG_SOUND3CNT, 0x70 .set OFFSET_REG_SOUND3CNT_L, 0x70 + .set OFFSET_REG_NR30, 0x70 .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_NR33, 0x74 + .set OFFSET_REG_NR34, 0x75 .set OFFSET_REG_SOUND4CNT, 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_NR43, 0x7c + .set OFFSET_REG_NR44, 0x7d .set OFFSET_REG_SOUNDCNT, 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_X, 0x84 + .set OFFSET_REG_NR52, 0x84 .set OFFSET_REG_SOUNDBIAS, 0x88 .set OFFSET_REG_WAVE_RAM, 0x90 .set OFFSET_REG_WAVE_RAM0, 0x90 @@ -246,22 +283,43 @@ .set REG_SOUND1CNT, REG_BASE + OFFSET_REG_SOUND1CNT .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_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_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_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_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_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_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_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_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_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_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_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_WAVE_RAM, REG_BASE + OFFSET_REG_WAVE_RAM .set REG_WAVE_RAM0, REG_BASE + OFFSET_REG_WAVE_RAM0 @@ -368,6 +426,26 @@ .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 .set OAM_OBJ_NORMAL, 0x00000000 diff --git a/constants/m4a_constants.inc b/constants/m4a_constants.inc new file mode 100644 index 0000000000..62ca5bb55b --- /dev/null +++ b/constants/m4a_constants.inc @@ -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 diff --git a/data/m4a_tables.s b/data/m4a_tables.s deleted file mode 100644 index b254543b45..0000000000 --- a/data/m4a_tables.s +++ /dev/null @@ -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 diff --git a/data/sound_data.s b/data/sound_data.s index b90c6f4492..a6f3fde26c 100644 --- a/data/sound_data.s +++ b/data/sound_data.s @@ -1,6 +1,6 @@ .section .rodata -gUnknown_08675D04:: @ 8675D04 +voicegroup_8675D04:: @ 8675D04 .incbin "baserom.gba", 0x675D04, 0x27FF0 gUnknown_0869DCF4:: @ 869DCF4 @@ -27,8 +27,8 @@ gUnknown_0869FB24:: @ 869FB24 gUnknown_086A0124:: @ 86A0124 .incbin "baserom.gba", 0x6a0124, 0x1489c -gUnknown_086B49C0:: @ 86B49C0 +gMPlayTable:: @ 86B49C0 .incbin "baserom.gba", 0x6b49c0, 0x30 -gUnknown_086B49F0:: @ 86B49F0 +gSongTable:: @ 86B49F0 .incbin "baserom.gba", 0x6b49f0, 0x2ee660 diff --git a/include/gba/m4a_internal.h b/include/gba/m4a_internal.h index 84b4482433..c6cff3b6fc 100644 --- a/include/gba/m4a_internal.h +++ b/include/gba/m4a_internal.h @@ -365,7 +365,7 @@ extern const u8 gNoiseTable[]; extern const struct PokemonCrySong gPokemonCrySongTemplate; -extern const struct ToneData voicegroup_842FC88; +extern const struct ToneData voicegroup_8675D04; extern char gNumMusicPlayers[]; extern char gMaxLines[]; diff --git a/ld_script.txt b/ld_script.txt index 34c159440f..d22d0ddc95 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -1,7 +1,7 @@ ENTRY(Start) gNumMusicPlayers = 4; -gMaxLines = 60; +gMaxLines = 0; SECTIONS { . = 0x2000000; @@ -25,7 +25,7 @@ SECTIONS { /* .bss.code starts at 0x3001AA8 */ - . += 0x800; + src/m4a_2.o(.bss.code); /* COMMON starts at 0x30022A8 */ @@ -208,7 +208,10 @@ SECTIONS { ALIGN(4) { 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_1m.o(.text); src/agb_flash_mx.o(.text); @@ -237,7 +240,7 @@ SECTIONS { ALIGN(4) { data/data2.o(.rodata); - data/m4a_tables.o(.rodata); + src/m4a_tables.o(.rodata); data/sound_data.o(.rodata); } =0 diff --git a/src/m4a_2.c b/src/m4a_2.c new file mode 100644 index 0000000000..2d3c658488 --- /dev/null +++ b/src/m4a_2.c @@ -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)®_FIFO_A; + REG_DMA2SAD = (s32)soundInfo->pcmBuffer + PCM_DMA_BUF_SIZE; + REG_DMA2DAD = (s32)®_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; +} diff --git a/src/m4a_4.c b/src/m4a_4.c new file mode 100644 index 0000000000..99195ec006 --- /dev/null +++ b/src/m4a_4.c @@ -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; +} diff --git a/src/m4a_tables.c b/src/m4a_tables.c new file mode 100644 index 0000000000..e064b6ccf1 --- /dev/null +++ b/src/m4a_tables.c @@ -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, +}; diff --git a/sym_common.txt b/sym_common.txt index d7d605314b..0c23abe97f 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -500,53 +500,7 @@ gUnknown_03006328: @ 3006328 gUnknown_03006370: @ 3006370 .space 0x10 -gUnknown_03006380: @ 3006380 - .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 "m4a_2.o" .include "agb_flash.o"