diff --git a/constants/m4a_constants.inc b/constants/m4a_constants.inc index 62ca5bb55..1a744dc7f 100644 --- a/constants/m4a_constants.inc +++ b/constants/m4a_constants.inc @@ -1,12 +1,43 @@ .equiv ID_NUMBER, 0x68736d53 .equiv PCM_DMA_BUF_SIZE, 1584 + .equiv MAX_DIRECTSOUND_CHANNELS, 12 + + .equiv C_V, 0x40 .equiv TONEDATA_TYPE_CGB, 0x07 .equiv TONEDATA_TYPE_FIX, 0x08 + .equiv TONEDATA_TYPE_REV, 0x10 + .equiv TONEDATA_TYPE_CMP, 0x20 .equiv TONEDATA_TYPE_SPL, 0x40 @ key split .equiv TONEDATA_TYPE_RHY, 0x80 @ rhythm + .equiv TONEDATA_P_S_PAN, 0xc0 + + .equiv SOUND_CHANNEL_SF_START, 0x80 + .equiv SOUND_CHANNEL_SF_STOP, 0x40 + .equiv SOUND_CHANNEL_SF_SPECIAL, 0x20 + .equiv SOUND_CHANNEL_SF_LOOP, 0x10 + .equiv SOUND_CHANNEL_SF_IEC, 0x04 + .equiv SOUND_CHANNEL_SF_ENV, 0x03 + .equiv SOUND_CHANNEL_SF_ENV_ATTACK, 0x03 + .equiv SOUND_CHANNEL_SF_ENV_DECAY, 0x02 + .equiv SOUND_CHANNEL_SF_ENV_SUSTAIN, 0x01 + .equiv SOUND_CHANNEL_SF_ENV_RELEASE, 0x00 + .equiv SOUND_CHANNEL_SF_ON, (SOUND_CHANNEL_SF_START | SOUND_CHANNEL_SF_STOP | SOUND_CHANNEL_SF_IEC | SOUND_CHANNEL_SF_ENV) + + .equiv CGB_CHANNEL_MO_PIT, 0x02 + .equiv CGB_CHANNEL_MO_VOL, 0x01 + + .equiv WAVE_DATA_FLAG_LOOP, 0xC0 + + .equiv MPT_FLG_VOLSET, 0x01 + .equiv MPT_FLG_VOLCHG, 0x03 + .equiv MPT_FLG_PITSET, 0x04 + .equiv MPT_FLG_PITCHG, 0x0C + .equiv MPT_FLG_START, 0x40 + .equiv MPT_FLG_EXIST, 0x80 + .macro struct_begin .struct 0 .endm @@ -16,6 +47,28 @@ .struct \name + \size .endm + struct_begin + struct_field o_WaveData_type, 2 + struct_field o_WaveData_d1, 1 + struct_field o_WaveData_flags, 1 + struct_field o_WaveData_freq, 4 + struct_field o_WaveData_loopStart, 4 + struct_field o_WaveData_size, 4 + struct_field o_WaveData_data, 0 + struct_field WaveData_size, 0 + + struct_begin + struct_field o_ToneData_type, 1 + struct_field o_ToneData_key, 1 + struct_field o_ToneData_length, 1 + struct_field o_ToneData_pan_sweep, 1 + struct_field o_ToneData_wav, 4 + struct_field o_ToneData_attack, 1 + struct_field o_ToneData_decay, 1 + struct_field o_ToneData_sustain, 1 + struct_field o_ToneData_release, 1 + struct_field ToneData_size, 0 + struct_begin struct_field o_SoundInfo_ident, 4 struct_field o_SoundInfo_pcmDmaCounter, 1 @@ -32,8 +85,8 @@ 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_MPlayMainHead, 4 + struct_field o_SoundInfo_musicPlayerHead, 4 struct_field o_SoundInfo_CgbSound, 4 struct_field o_SoundInfo_CgbOscOff, 4 struct_field o_SoundInfo_MidiKeyToCgbFreq, 4 @@ -41,12 +94,12 @@ 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_chans, MAX_DIRECTSOUND_CHANNELS * 64 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_statusFlags, 1 struct_field o_SoundChannel_type, 1 struct_field o_SoundChannel_rightVolume, 1 struct_field o_SoundChannel_leftVolume, 1 @@ -54,29 +107,29 @@ 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_key, 1 + struct_field o_SoundChannel_envelopeVolume, 1 + struct_field o_SoundChannel_envelopeVolumeRight, 1 + struct_field o_SoundChannel_envelopeVolumeLeft, 1 + struct_field o_SoundChannel_pseudoEchoVolume, 1 + struct_field o_SoundChannel_pseudoEchoLength, 1 + struct_field o_SoundChannel_dummy1, 1 + struct_field o_SoundChannel_dummy2, 1 + struct_field o_SoundChannel_gateTime, 1 + struct_field o_SoundChannel_midiKey, 1 + struct_field o_SoundChannel_velocity, 1 + struct_field o_SoundChannel_priority, 1 + struct_field o_SoundChannel_rhythmPan, 1 + struct_field o_SoundChannel_dummy3, 3 + struct_field o_SoundChannel_count, 4 struct_field o_SoundChannel_fw, 4 - struct_field o_SoundChannel_freq, 4 + struct_field o_SoundChannel_frequency, 4 struct_field o_SoundChannel_wav, 4 - struct_field o_SoundChannel_cp, 4 + struct_field o_SoundChannel_currentPointer, 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_prevChannelPointer, 4 + struct_field o_SoundChannel_nextChannelPointer, 4 + struct_field o_SoundChannel_dummy4, 4 struct_field o_SoundChannel_xpi, 2 struct_field o_SoundChannel_xpc, 2 struct_field SoundChannel_size, 0 @@ -112,8 +165,8 @@ 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_pseudoEchoVolume, 1 + struct_field o_MusicPlayerTrack_pseudoEchoLength, 1 struct_field o_MusicPlayerTrack_chan, 4 struct_field o_MusicPlayerTrack_ToneData_type, 1 struct_field o_MusicPlayerTrack_ToneData_key, 1 @@ -159,41 +212,41 @@ struct_field MusicPlayerInfo_size, 0 struct_begin - struct_field o_CgbChannel_sf, 1 - struct_field o_CgbChannel_ty, 1 + struct_field o_CgbChannel_statusFlags, 1 + struct_field o_CgbChannel_type, 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_attack, 1 + struct_field o_CgbChannel_decay, 1 + struct_field o_CgbChannel_sustain, 1 + struct_field o_CgbChannel_release, 1 + struct_field o_CgbChannel_key, 1 + struct_field o_CgbChannel_envelopeVolume, 1 + struct_field o_CgbChannel_envelopeGoal, 1 + struct_field o_CgbChannel_envelopeCounter, 1 + struct_field o_CgbChannel_pseudoEchoVolume, 1 + struct_field o_CgbChannel_pseudoEchoLength, 1 + struct_field o_CgbChannel_dummy1, 1 + struct_field o_CgbChannel_dummy2, 1 + struct_field o_CgbChannel_gateTime, 1 + struct_field o_CgbChannel_midiKey, 1 + struct_field o_CgbChannel_velocity, 1 + struct_field o_CgbChannel_priority, 1 + struct_field o_CgbChannel_rhythmPan, 1 + struct_field o_CgbChannel_dummy3, 3 + struct_field o_CgbChannel_dummy5, 1 + struct_field o_CgbChannel_sustainGoal, 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 o_CgbChannel_modify, 1 + struct_field o_CgbChannel_length, 1 + struct_field o_CgbChannel_sweep, 1 + struct_field o_CgbChannel_frequency, 4 + struct_field o_CgbChannel_wavePointer, 4 + struct_field o_CgbChannel_currentPointer, 4 + struct_field o_CgbChannel_track, 4 + struct_field o_CgbChannel_prevChannelPointer, 4 + struct_field o_CgbChannel_nextChannelPointer, 4 + struct_field o_CgbChannel_dummy4, 8 struct_field CgbChannel_size, 0 diff --git a/sound/music_player_table.inc b/sound/music_player_table.inc index 6c74a1352..f54238966 100644 --- a/sound/music_player_table.inc +++ b/sound/music_player_table.inc @@ -1,6 +1,32 @@ + .equiv TRACK_SIZE, 0x50 + .equiv NUM_TRACKS_BGM, 10 + .equiv NUM_TRACKS_SE1, 3 + .equiv NUM_TRACKS_SE2, 9 + .equiv NUM_TRACKS_SE3, 1 + + .bss + +gMPlayTrack_BGM:: + .space TRACK_SIZE * NUM_TRACKS_BGM + .size gMPlayTrack_BGM, .-gMPlayTrack_BGM + +gMPlayTrack_SE1:: + .space TRACK_SIZE * NUM_TRACKS_SE1 + .size gMPlayTrack_SE1, .-gMPlayTrack_SE1 + +gMPlayTrack_SE2:: + .space TRACK_SIZE * NUM_TRACKS_SE2 + .size gMPlayTrack_SE2, .-gMPlayTrack_SE2 + +gMPlayTrack_SE3:: + .space TRACK_SIZE * NUM_TRACKS_SE3 + .size gMPlayTrack_SE3, .-gMPlayTrack_SE3 + + .section .rodata + .align 2 gMPlayTable:: - music_player gMPlayInfo_BGM, gMPlayTrack_BGM, 10, 0 - music_player gMPlayInfo_SE1, gMPlayTrack_SE1, 3, 1 - music_player gMPlayInfo_SE2, gMPlayTrack_SE2, 9, 1 - music_player gMPlayInfo_SE3, gMPlayTrack_SE3, 1, 0 + music_player gMPlayInfo_BGM, gMPlayTrack_BGM, NUM_TRACKS_BGM, 0 + music_player gMPlayInfo_SE1, gMPlayTrack_SE1, NUM_TRACKS_SE1, 1 + music_player gMPlayInfo_SE2, gMPlayTrack_SE2, NUM_TRACKS_SE2, 1 + music_player gMPlayInfo_SE3, gMPlayTrack_SE3, NUM_TRACKS_SE3, 0 diff --git a/src/m4a_1.s b/src/m4a_1.s index 994f8892d..fce796744 100644 --- a/src/m4a_1.s +++ b/src/m4a_1.s @@ -48,10 +48,10 @@ SoundMain_2: adds r1, r2 SoundMain_3: str r1, [sp, 0x14] - ldr r3, [r0, o_SoundInfo_func] + ldr r3, [r0, o_SoundInfo_MPlayMainHead] cmp r3, 0 beq SoundMain_4 - ldr r0, [r0, o_SoundInfo_intp] + ldr r0, [r0, o_SoundInfo_musicPlayerHead] bl _081DD25E ldr r0, [sp, 0x18] SoundMain_4: @@ -169,74 +169,74 @@ _081DCF54: .pool _081DCF60: - ldrb r6, [r4, o_SoundChannel_status] - movs r0, 0xC7 + ldrb r6, [r4, o_SoundChannel_statusFlags] + movs r0, SOUND_CHANNEL_SF_ON tst r0, r6 bne _081DCF6A b _081DD240 _081DCF6A: - movs r0, 0x80 + movs r0, SOUND_CHANNEL_SF_START tst r0, r6 beq _081DCFA0 - movs r0, 0x40 + movs r0, SOUND_CHANNEL_SF_STOP tst r0, r6 bne _081DCFB0 - movs r6, 0x3 - strb r6, [r4, o_SoundChannel_status] + movs r6, SOUND_CHANNEL_SF_ENV_ATTACK + strb r6, [r4, o_SoundChannel_statusFlags] adds r0, r3, 0 - adds r0, 0x10 - ldr r1, [r4, o_SoundChannel_ct] + adds r0, o_WaveData_data + ldr r1, [r4, o_SoundChannel_count] adds r0, r1 - str r0, [r4, o_SoundChannel_cp] - ldr r0, [r3, 0xC] + str r0, [r4, o_SoundChannel_currentPointer] + ldr r0, [r3, o_WaveData_size] subs r0, r1 - str r0, [r4, o_SoundChannel_ct] + str r0, [r4, o_SoundChannel_count] movs r5, 0 - strb r5, [r4, o_SoundChannel_ev] + strb r5, [r4, o_SoundChannel_envelopeVolume] str r5, [r4, o_SoundChannel_fw] - ldrb r2, [r3, 0x3] - movs r0, 0xC0 + ldrb r2, [r3, o_WaveData_flags] + movs r0, WAVE_DATA_FLAG_LOOP tst r0, r2 beq _081DCFF8 - movs r0, 0x10 + movs r0, SOUND_CHANNEL_SF_LOOP orrs r6, r0 - strb r6, [r4, o_SoundChannel_status] + strb r6, [r4, o_SoundChannel_statusFlags] b _081DCFF8 _081DCFA0: - ldrb r5, [r4, o_SoundChannel_ev] - movs r0, 0x4 + ldrb r5, [r4, o_SoundChannel_envelopeVolume] + movs r0, SOUND_CHANNEL_SF_IEC tst r0, r6 beq _081DCFB6 - ldrb r0, [r4, o_SoundChannel_iel] + ldrb r0, [r4, o_SoundChannel_pseudoEchoLength] subs r0, 1 - strb r0, [r4, o_SoundChannel_iel] + strb r0, [r4, o_SoundChannel_pseudoEchoLength] bhi _081DD006 _081DCFB0: movs r0, 0 - strb r0, [r4, o_SoundChannel_status] + strb r0, [r4, o_SoundChannel_statusFlags] b _081DD240 _081DCFB6: - movs r0, 0x40 + movs r0, SOUND_CHANNEL_SF_STOP tst r0, r6 beq _081DCFD6 ldrb r0, [r4, o_SoundChannel_release] muls r5, r0 lsrs r5, 8 - ldrb r0, [r4, o_SoundChannel_iev] + ldrb r0, [r4, o_SoundChannel_pseudoEchoVolume] cmp r5, r0 bhi _081DD006 _081DCFC8: - ldrb r5, [r4, o_SoundChannel_iev] + ldrb r5, [r4, o_SoundChannel_pseudoEchoVolume] cmp r5, 0 beq _081DCFB0 - movs r0, 0x4 + movs r0, SOUND_CHANNEL_SF_IEC orrs r6, r0 - strb r6, [r4, o_SoundChannel_status] + strb r6, [r4, o_SoundChannel_statusFlags] b _081DD006 _081DCFD6: - movs r2, 0x3 + movs r2, SOUND_CHANNEL_SF_ENV ands r2, r6 - cmp r2, 0x2 + cmp r2, SOUND_CHANNEL_SF_ENV_DECAY bne _081DCFF4 ldrb r0, [r4, o_SoundChannel_decay] muls r5, r0 @@ -247,10 +247,10 @@ _081DCFD6: adds r5, r0, 0 beq _081DCFC8 subs r6, 0x1 - strb r6, [r4, o_SoundChannel_status] + strb r6, [r4, o_SoundChannel_statusFlags] b _081DD006 _081DCFF4: - cmp r2, 0x3 + cmp r2, SOUND_CHANNEL_SF_ENV_ATTACK bne _081DD006 _081DCFF8: ldrb r0, [r4, o_SoundChannel_attack] @@ -259,9 +259,9 @@ _081DCFF8: bcc _081DD006 movs r5, 0xFF subs r6, 0x1 - strb r6, [r4, o_SoundChannel_status] + strb r6, [r4, o_SoundChannel_statusFlags] _081DD006: - strb r5, [r4, o_SoundChannel_ev] + strb r5, [r4, o_SoundChannel_envelopeVolume] ldr r0, [sp, 0x18] ldrb r0, [r0, o_SoundChannel_release] adds r0, 0x1 @@ -270,37 +270,37 @@ _081DD006: ldrb r0, [r4, o_SoundChannel_rightVolume] muls r0, r5 lsrs r0, 8 - strb r0, [r4, o_SoundChannel_er] + strb r0, [r4, o_SoundChannel_envelopeVolumeRight] ldrb r0, [r4, o_SoundChannel_leftVolume] muls r0, r5 lsrs r0, 8 - strb r0, [r4, o_SoundChannel_el] - movs r0, 0x10 + strb r0, [r4, o_SoundChannel_envelopeVolumeLeft] + movs r0, SOUND_CHANNEL_SF_LOOP ands r0, r6 str r0, [sp, 0x10] beq _081DD03A adds r0, r3, 0 - adds r0, 0x10 - ldr r1, [r3, 0x8] + adds r0, o_WaveData_data + ldr r1, [r3, o_WaveData_loopStart] adds r0, r1 str r0, [sp, 0xC] - ldr r0, [r3, 0xC] + ldr r0, [r3, o_WaveData_size] subs r0, r1 str r0, [sp, 0x10] _081DD03A: ldr r5, [sp, 0x8] - ldr r2, [r4, o_SoundChannel_ct] - ldr r3, [r4, o_SoundChannel_cp] + ldr r2, [r4, o_SoundChannel_count] + ldr r3, [r4, o_SoundChannel_currentPointer] 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 r10, [r4, o_SoundChannel_envelopeVolumeRight] + ldrb r11, [r4, o_SoundChannel_envelopeVolumeLeft] ldrb r0, [r4, o_SoundChannel_type] - tst r0, 0x30 + tst r0, TONEDATA_TYPE_CMP | TONEDATA_TYPE_REV beq _081DD068 bl SoundMainRAM_Unk1 b _081DD228 @@ -324,7 +324,7 @@ _081DD07C: moveq r2, 0x4 _081DD0A8: ldr r6, [r5] - ldr r7, [r5, 0x630] + ldr r7, [r5, PCM_DMA_BUF_SIZE] _081DD0B0: ldrsb r0, [r3], 0x1 mul r1, r10, r0 @@ -335,7 +335,7 @@ _081DD0B0: add r7, r1, r7, ror 8 adds r5, r5, 0x40000000 bcc _081DD0B0 - str r7, [r5, 0x630] + str r7, [r5, PCM_DMA_BUF_SIZE] str r6, [r5], 0x4 subs r8, r8, 0x4 bgt _081DD0A8 @@ -343,7 +343,7 @@ _081DD0B0: beq _081DD22C _081DD0EC: ldr r6, [r5] - ldr r7, [r5, 0x630] + ldr r7, [r5, PCM_DMA_BUF_SIZE] _081DD0F4: ldrsb r0, [r3], 0x1 mul r1, r10, r0 @@ -357,7 +357,7 @@ _081DD0F4: _081DD118: adds r5, r5, 0x40000000 bcc _081DD0F4 - str r7, [r5, 0x630] + str r7, [r5, PCM_DMA_BUF_SIZE] str r6, [r5], 0x4 subs r8, r8, 0x4 bgt _081DD07C @@ -383,26 +383,26 @@ _081DD164: ldrne r3, [sp, 0xC] bne _081DD118 _081DD174: - strb r2, [r4, o_SoundChannel_status] + strb r2, [r4, o_SoundChannel_statusFlags] 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 r7, [r5, PCM_DMA_BUF_SIZE] str r6, [r5], 0x4 b _081DD234 _081DD19C: push {r4,r12} - ldr r1, [r4, o_SoundChannel_freq] + ldr r1, [r4, o_SoundChannel_frequency] mul r4, r12, r1 ldrsb r0, [r3] ldrsb r1, [r3, 0x1]! sub r1, r1, r0 _081DD1B4: ldr r6, [r5] - ldr r7, [r5, 0x630] + ldr r7, [r5, PCM_DMA_BUF_SIZE] _081DD1BC: mul lr, r9, r1 add lr, r0, lr, asr 23 @@ -427,7 +427,7 @@ _081DD1FC: _081DD208: adds r5, r5, 0x40000000 bcc _081DD1BC - str r7, [r5, 0x630] + str r7, [r5, PCM_DMA_BUF_SIZE] str r6, [r5], 0x4 subs r8, r8, 0x4 bgt _081DD1B4 @@ -436,8 +436,8 @@ _081DD208: _081DD228: str r9, [r4, o_SoundChannel_fw] _081DD22C: - str r2, [r4, o_SoundChannel_ct] - str r3, [r4, o_SoundChannel_cp] + str r2, [r4, o_SoundChannel_count] + str r3, [r4, o_SoundChannel_currentPointer] _081DD234: ldr r8, [sp] add r0, pc, 0x1 @@ -469,42 +469,42 @@ _081DD25E: arm_func_start SoundMainRAM_Unk1 SoundMainRAM_Unk1: ldr r6, [r4, o_SoundChannel_wav] - ldrb r0, [r4, o_SoundChannel_status] - tst r0, 0x20 + ldrb r0, [r4, o_SoundChannel_statusFlags] + tst r0, SOUND_CHANNEL_SF_SPECIAL bne _081DD2B4 - orr r0, r0, 0x20 - strb r0, [r4, o_SoundChannel_status] + orr r0, r0, SOUND_CHANNEL_SF_SPECIAL + strb r0, [r4, o_SoundChannel_statusFlags] ldrb r0, [r4, o_SoundChannel_type] - tst r0, 0x10 + tst r0, TONEDATA_TYPE_REV beq _081DD29C - ldr r1, [r6, 0xC] + ldr r1, [r6, o_WaveData_size] add r1, r1, r6, lsl 1 add r1, r1, 0x20 sub r3, r1, r3 - str r3, [r4, o_SoundChannel_cp] + str r3, [r4, o_SoundChannel_currentPointer] _081DD29C: - ldrh r0, [r6] + ldrh r0, [r6, o_WaveData_type] cmp r0, 0 beq _081DD2B4 sub r3, r3, r6 sub r3, r3, 0x10 - str r3, [r4, o_SoundChannel_cp] + str r3, [r4, o_SoundChannel_currentPointer] _081DD2B4: push {r8,r12,lr} mov r10, r10, lsl 16 mov r11, r11, lsl 16 - ldr r1, [r4, o_SoundChannel_freq] + ldr r1, [r4, o_SoundChannel_frequency] ldrb r0, [r4, o_SoundChannel_type] - tst r0, 0x8 + tst r0, TONEDATA_TYPE_FIX movne r8, 0x800000 muleq r8, r12, r1 - ldrh r0, [r6] + ldrh r0, [r6, o_WaveData_type] cmp r0, 0 beq _081DD468 mov r0, 0xFF000000 str r0, [r4, o_SoundChannel_xpi] ldrb r0, [r4, o_SoundChannel_type] - tst r0, 0x10 + tst r0, TONEDATA_TYPE_REV bne _081DD3C0 bl SoundMainRAM_Unk2 mov r0, r1 @@ -513,7 +513,7 @@ _081DD2B4: sub r1, r1, r0 _081DD308: ldr r6, [r5] - ldr r7, [r5, 0x630] + ldr r7, [r5, PCM_DMA_BUF_SIZE] _081DD310: mul lr, r9, r1 add lr, r0, lr, asr 23 @@ -544,7 +544,7 @@ _081DD364: _081DD370: adds r5, r5, 0x40000000 bcc _081DD310 - str r7, [r5, 0x630] + str r7, [r5, PCM_DMA_BUF_SIZE] str r6, [r5], 0x4 ldr r6, [sp] subs r6, r6, 0x4 @@ -557,7 +557,7 @@ _081DD398: cmp r0, 0 beq _081DD4F4 ldr r3, [r4, o_SoundChannel_wav] - ldr r3, [r3, 0x8] + ldr r3, [r3, o_WaveData_loopStart] rsb lr, r2, 0 _081DD3B0: adds r2, r2, r0 @@ -573,7 +573,7 @@ _081DD3C0: sub r1, r1, r0 _081DD3D8: ldr r6, [r5] - ldr r7, [r5, 0x630] + ldr r7, [r5, PCM_DMA_BUF_SIZE] _081DD3E0: mul lr, r9, r1 add lr, r0, lr, asr 23 @@ -604,7 +604,7 @@ _081DD434: _081DD440: adds r5, r5, 0x40000000 bcc _081DD3E0 - str r7, [r5, 0x630] + str r7, [r5, PCM_DMA_BUF_SIZE] str r6, [r5], 0x4 ldr r6, [sp] subs r6, r6, 0x4 @@ -614,7 +614,7 @@ _081DD440: b _081DD4F0 _081DD468: ldrb r0, [r4, o_SoundChannel_type] - tst r0, 0x10 + tst r0, TONEDATA_TYPE_REV beq _081DD4F0 ldrsb r0, [r3, -0x1]! ldrsb r1, [r3, -0x1] @@ -654,7 +654,7 @@ _081DD4F0: pop {r8,r12,pc} _081DD4F4: mov r2, 0 - strb r2, [r4, o_SoundChannel_status] + strb r2, [r4, o_SoundChannel_statusFlags] mov r0, r5, lsr 30 bic r5, r5, 0xC0000000 rsb r0, r0, 0x3 @@ -725,24 +725,24 @@ SoundMainBTM: thumb_func_start RealClearChain RealClearChain: - ldr r3, [r0, 0x2C] + ldr r3, [r0, o_SoundChannel_track] cmp r3, 0 beq _081DD5E2 - ldr r1, [r0, 0x34] - ldr r2, [r0, 0x30] + ldr r1, [r0, o_SoundChannel_nextChannelPointer] + ldr r2, [r0, o_SoundChannel_prevChannelPointer] cmp r2, 0 beq _081DD5D6 - str r1, [r2, 0x34] + str r1, [r2, o_SoundChannel_nextChannelPointer] b _081DD5D8 _081DD5D6: - str r1, [r3, 0x20] + str r1, [r3, o_MusicPlayerTrack_chan] _081DD5D8: cmp r1, 0 beq _081DD5DE - str r2, [r1, 0x30] + str r2, [r1, o_SoundChannel_prevChannelPointer] _081DD5DE: movs r1, 0 - str r1, [r0, 0x2C] + str r1, [r0, o_SoundChannel_track] _081DD5E2: bx lr thumb_func_end RealClearChain @@ -755,22 +755,22 @@ ply_fine: cmp r4, 0 beq ply_fine_done ply_fine_loop: - ldrb r1, [r4] - movs r0, 0xC7 + ldrb r1, [r4, o_SoundChannel_statusFlags] + movs r0, SOUND_CHANNEL_SF_ON tst r0, r1 beq ply_fine_ok - movs r0, 0x40 + movs r0, SOUND_CHANNEL_SF_STOP orrs r1, r0 - strb r1, [r4] + strb r1, [r4, o_SoundChannel_statusFlags] ply_fine_ok: adds r0, r4, 0 bl RealClearChain - ldr r4, [r4, 0x34] + ldr r4, [r4, o_SoundChannel_nextChannelPointer] cmp r4, 0 bne ply_fine_loop ply_fine_done: movs r0, 0 - strb r0, [r5] + strb r0, [r5, o_MusicPlayerTrack_flags] pop {r4,r5} pop {r0} bx r0 @@ -820,10 +820,10 @@ lt_MPlayJumpTableTemplate: .word gMPlayJumpTableTemplate thumb_func_start ld_r3_tp_adr_i ld_r3_tp_adr_i: - ldr r2, [r1, 0x40] + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] _081DD64A: adds r3, r2, 0x1 - str r3, [r1, 0x40] + str r3, [r1, o_MusicPlayerTrack_cmdPtr] ldrb r3, [r2] b chk_adr_r2 thumb_func_end ld_r3_tp_adr_i @@ -954,13 +954,13 @@ ply_voice: lsls r2, 2 ldr r3, [r0, o_MusicPlayerInfo_tone] adds r2, r3 - ldr r3, [r2] + ldr r3, [r2, o_ToneData_type] bl chk_adr_r2 str r3, [r1, o_MusicPlayerTrack_ToneData_type] - ldr r3, [r2, 0x4] + ldr r3, [r2, o_ToneData_wav] bl chk_adr_r2 str r3, [r1, o_MusicPlayerTrack_ToneData_wav] - ldr r3, [r2, 0x8] + ldr r3, [r2, o_ToneData_attack] bl chk_adr_r2 str r3, [r1, o_MusicPlayerTrack_ToneData_attack] bx r12 @@ -972,7 +972,7 @@ ply_vol: bl ld_r3_tp_adr_i strb r3, [r1, o_MusicPlayerTrack_vol] ldrb r3, [r1, o_MusicPlayerTrack_flags] - movs r2, 0x3 + movs r2, MPT_FLG_VOLCHG orrs r3, r2 strb r3, [r1, o_MusicPlayerTrack_flags] bx r12 @@ -982,10 +982,10 @@ ply_vol: ply_pan: mov r12, lr bl ld_r3_tp_adr_i - subs r3, 0x40 + subs r3, C_V strb r3, [r1, o_MusicPlayerTrack_pan] ldrb r3, [r1, o_MusicPlayerTrack_flags] - movs r2, 0x3 + movs r2, MPT_FLG_VOLCHG orrs r3, r2 strb r3, [r1, o_MusicPlayerTrack_flags] bx r12 @@ -995,10 +995,10 @@ ply_pan: ply_bend: mov r12, lr bl ld_r3_tp_adr_i - subs r3, 0x40 + subs r3, C_V strb r3, [r1, o_MusicPlayerTrack_bend] ldrb r3, [r1, o_MusicPlayerTrack_flags] - movs r2, 0xC + movs r2, MPT_FLG_PITCHG orrs r3, r2 strb r3, [r1, o_MusicPlayerTrack_flags] bx r12 @@ -1010,7 +1010,7 @@ ply_bendr: bl ld_r3_tp_adr_i strb r3, [r1, o_MusicPlayerTrack_bendRange] ldrb r3, [r1, o_MusicPlayerTrack_flags] - movs r2, 0xC + movs r2, MPT_FLG_PITCHG orrs r3, r2 strb r3, [r1, o_MusicPlayerTrack_flags] bx r12 @@ -1033,7 +1033,7 @@ ply_modt: beq _081DD7AA strb r3, [r1, o_MusicPlayerTrack_modT] ldrb r3, [r1, o_MusicPlayerTrack_flags] - movs r2, 0xF + movs r2, MPT_FLG_VOLCHG | MPT_FLG_PITCHG orrs r3, r2 strb r3, [r1, o_MusicPlayerTrack_flags] _081DD7AA: @@ -1044,10 +1044,10 @@ _081DD7AA: ply_tune: mov r12, lr bl ld_r3_tp_adr_i - subs r3, 0x40 + subs r3, C_V strb r3, [r1, o_MusicPlayerTrack_tune] ldrb r3, [r1, o_MusicPlayerTrack_flags] - movs r2, 0xC + movs r2, MPT_FLG_PITCHG orrs r3, r2 strb r3, [r1, o_MusicPlayerTrack_flags] bx r12 @@ -1176,8 +1176,8 @@ _081DD874: movs r3, 0x1 movs r4, 0 _081DD87C: - ldrb r0, [r5] - movs r1, 0x80 + ldrb r0, [r5, o_MusicPlayerTrack_flags] + movs r1, MPT_FLG_EXIST tst r1, r0 bne _081DD886 b _081DD998 @@ -1189,36 +1189,36 @@ _081DD886: cmp r4, 0 beq _081DD8BA _081DD892: - ldrb r1, [r4] - movs r0, 0xC7 + ldrb r1, [r4, o_SoundChannel_statusFlags] + movs r0, SOUND_CHANNEL_SF_ON tst r0, r1 beq _081DD8AE - ldrb r0, [r4, 0x10] + ldrb r0, [r4, o_SoundChannel_gateTime] cmp r0, 0 beq _081DD8B4 subs r0, 0x1 - strb r0, [r4, 0x10] + strb r0, [r4, o_SoundChannel_gateTime] bne _081DD8B4 - movs r0, 0x40 + movs r0, SOUND_CHANNEL_SF_STOP orrs r1, r0 - strb r1, [r4] + strb r1, [r4, o_SoundChannel_statusFlags] b _081DD8B4 _081DD8AE: adds r0, r4, 0 bl ClearChain _081DD8B4: - ldr r4, [r4, 0x34] + ldr r4, [r4, o_SoundChannel_nextChannelPointer] cmp r4, 0 bne _081DD892 _081DD8BA: ldrb r3, [r5, o_MusicPlayerTrack_flags] - movs r0, 0x40 + movs r0, MPT_FLG_START tst r0, r3 beq _081DD938 adds r0, r5, 0 bl Clear64byte - movs r0, 0x80 - strb r0, [r5] + movs r0, MPT_FLG_EXIST + strb r0, [r5, o_MusicPlayerTrack_flags] movs r0, 0x2 strb r0, [r5, o_MusicPlayerTrack_bendRange] movs r0, 0x40 @@ -1321,10 +1321,10 @@ _081DD972: ldrb r1, [r5, o_MusicPlayerTrack_modT] cmp r1, 0 bne _081DD98E - movs r1, 0xC + movs r1, MPT_FLG_PITCHG b _081DD990 _081DD98E: - movs r1, 0x3 + movs r1, MPT_FLG_VOLCHG _081DD990: orrs r0, r1 strb r0, [r5, o_MusicPlayerTrack_flags] @@ -1334,7 +1334,7 @@ _081DD994: _081DD998: subs r6, 0x1 ble _081DD9A4 - movs r0, 0x50 + movs r0, MusicPlayerTrack_size adds r5, r0 lsls r3, 1 b _081DD87C @@ -1351,10 +1351,10 @@ _081DD9A4: _081DD9B6: str r4, [r7, o_MusicPlayerInfo_status] ldrh r0, [r7, o_MusicPlayerInfo_tempoC] - subs r0, 0x96 + subs r0, 150 _081DD9BC: strh r0, [r7, o_MusicPlayerInfo_tempoC] - cmp r0, 0x96 + cmp r0, 150 bcc _081DD9C4 b _081DD874 _081DD9C4: @@ -1365,7 +1365,7 @@ _081DD9C8: movs r1, 0x80 tst r1, r0 beq _081DDA62 - movs r1, 0xF + movs r1, MPT_FLG_VOLCHG | MPT_FLG_PITCHG tst r1, r0 beq _081DDA62 mov r9, r2 @@ -1376,8 +1376,8 @@ _081DD9C8: cmp r4, 0 beq _081DDA58 _081DD9E6: - ldrb r1, [r4, o_SoundChannel_status] - movs r0, 0xC7 + ldrb r1, [r4, o_SoundChannel_statusFlags] + movs r0, SOUND_CHANNEL_SF_ON tst r0, r1 bne _081DD9F6 adds r0, r4, 0 @@ -1385,26 +1385,26 @@ _081DD9E6: b _081DDA52 _081DD9F6: ldrb r0, [r4, o_SoundChannel_type] - movs r6, 0x7 + movs r6, TONEDATA_TYPE_CGB ands r6, r0 ldrb r3, [r5, o_MusicPlayerTrack_flags] - movs r0, 0x3 + movs r0, MPT_FLG_VOLCHG tst r0, r3 beq _081DDA14 bl ChnVolSetAsm cmp r6, 0 beq _081DDA14 - ldrb r0, [r4, o_CgbChannel_mo] + ldrb r0, [r4, o_CgbChannel_modify] movs r1, 0x1 orrs r0, r1 - strb r0, [r4, o_CgbChannel_mo] + strb r0, [r4, o_CgbChannel_modify] _081DDA14: ldrb r3, [r5, o_MusicPlayerTrack_flags] - movs r0, 0xC + movs r0, MPT_FLG_PITCHG tst r0, r3 beq _081DDA52 - ldrb r1, [r4, o_SoundChannel_ky] - movs r0, 0x8 + ldrb r1, [r4, o_SoundChannel_key] + movs r0, o_MusicPlayerTrack_keyM ldrsb r0, [r5, r0] adds r2, r1, r0 bpl _081DDA28 @@ -1418,20 +1418,20 @@ _081DDA28: 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 + str r0, [r4, o_CgbChannel_frequency] + ldrb r0, [r4, o_CgbChannel_modify] + movs r1, CGB_CHANNEL_MO_PIT orrs r0, r1 - strb r0, [r4, o_CgbChannel_mo] + strb r0, [r4, o_CgbChannel_modify] 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] + str r0, [r4, o_SoundChannel_frequency] _081DDA52: - ldr r4, [r4, o_SoundChannel_np] + ldr r4, [r4, o_SoundChannel_nextChannelPointer] cmp r4, 0 bne _081DD9E6 _081DDA58: @@ -1443,7 +1443,7 @@ _081DDA58: _081DDA62: subs r2, 0x1 ble _081DDA6C - movs r0, 0x50 + movs r0, MusicPlayerTrack_size adds r5, r0 bgt _081DD9C8 _081DDA6C: @@ -1470,7 +1470,7 @@ TrackStop: push {r4-r6,lr} adds r5, r1, 0 ldrb r1, [r5, o_MusicPlayerTrack_flags] - movs r0, 0x80 + movs r0, MPT_FLG_EXIST tst r0, r1 beq TrackStop_Done ldr r4, [r5, o_MusicPlayerTrack_chan] @@ -1478,11 +1478,11 @@ TrackStop: beq TrackStop_3 movs r6, 0 TrackStop_Loop: - ldrb r0, [r4, o_SoundChannel_status] + ldrb r0, [r4, o_SoundChannel_statusFlags] cmp r0, 0 beq TrackStop_2 ldrb r0, [r4, o_SoundChannel_type] - movs r3, 0x7 + movs r3, TONEDATA_TYPE_CGB ands r0, r3 beq TrackStop_1 ldr r3, =SOUND_INFO_PTR @@ -1490,10 +1490,10 @@ TrackStop_Loop: ldr r3, [r3, o_SoundInfo_CgbOscOff] bl call_r3 TrackStop_1: - strb r6, [r4, o_SoundChannel_status] + strb r6, [r4, o_SoundChannel_statusFlags] TrackStop_2: str r6, [r4, o_SoundChannel_track] - ldr r4, [r4, o_SoundChannel_np] + ldr r4, [r4, o_SoundChannel_nextChannelPointer] cmp r4, 0 bne TrackStop_Loop TrackStop_3: @@ -1507,31 +1507,31 @@ TrackStop_Done: thumb_func_start ChnVolSetAsm ChnVolSetAsm: - ldrb r1, [r4, 0x12] - movs r0, 0x14 + ldrb r1, [r4, o_SoundChannel_velocity] + movs r0, o_SoundChannel_rhythmPan ldrsb r2, [r4, r0] movs r3, 0x80 adds r3, r2 muls r3, r1 - ldrb r0, [r5, 0x10] + ldrb r0, [r5, o_MusicPlayerTrack_volMR] muls r0, r3 asrs r0, 14 cmp r0, 0xFF bls _081DDAE8 movs r0, 0xFF _081DDAE8: - strb r0, [r4, 0x2] + strb r0, [r4, o_SoundChannel_rightVolume] movs r3, 0x7F subs r3, r2 muls r3, r1 - ldrb r0, [r5, 0x11] + ldrb r0, [r5, o_MusicPlayerTrack_volML] muls r0, r3 asrs r0, 14 cmp r0, 0xFF bls _081DDAFC movs r0, 0xFF _081DDAFC: - strb r0, [r4, 0x3] + strb r0, [r4, o_SoundChannel_leftVolume] bx lr thumb_func_end ChnVolSetAsm @@ -1601,32 +1601,32 @@ _081DDB68: mov r9, r1 mov r6, r9 ldrb r1, [r6] - movs r0, 0xC0 + movs r0, TONEDATA_TYPE_SPL | TONEDATA_TYPE_RHY tst r0, r1 beq _081DDB80 b _081DDCEA _081DDB80: - movs r0, 0x80 + movs r0, TONEDATA_TYPE_RHY tst r0, r2 beq _081DDB9C - ldrb r1, [r6, 0x3] + ldrb r1, [r6, o_ToneData_pan_sweep] movs r0, 0x80 tst r0, r1 beq _081DDB94 - subs r1, 0xC0 + subs r1, TONEDATA_P_S_PAN lsls r1, 1 str r1, [sp, 0x14] _081DDB94: - ldrb r3, [r6, 0x1] + ldrb r3, [r6, o_SoundChannel_type] b _081DDB9C _081DDB98: mov r9, r4 - ldrb r3, [r5, 0x5] + ldrb r3, [r5, o_MusicPlayerTrack_key] _081DDB9C: str r3, [sp, 0x8] ldr r6, [sp] - ldrb r1, [r6, 0x9] - ldrb r0, [r5, 0x1D] + ldrb r1, [r6, o_MusicPlayerInfo_priority] + ldrb r0, [r5, o_MusicPlayerTrack_priority] adds r0, r1 cmp r0, 0xFF bls _081DDBAC @@ -1634,13 +1634,13 @@ _081DDB9C: _081DDBAC: str r0, [sp, 0x10] mov r6, r9 - ldrb r0, [r6] - movs r6, 0x7 + ldrb r0, [r6, o_ToneData_type] + movs r6, TONEDATA_TYPE_CGB ands r6, r0 str r6, [sp, 0xC] beq _081DDBEC ldr r0, [sp, 0x4] - ldr r4, [r0, 0x1C] + ldr r4, [r0, o_SoundInfo_cgbChans] cmp r4, 0 bne _081DDBC4 b _081DDCEA @@ -1648,21 +1648,21 @@ _081DDBC4: subs r6, 0x1 lsls r0, r6, 6 adds r4, r0 - ldrb r1, [r4] - movs r0, 0xC7 + ldrb r1, [r4, o_CgbChannel_statusFlags] + movs r0, SOUND_CHANNEL_SF_ON tst r0, r1 beq _081DDC40 - movs r0, 0x40 + movs r0, SOUND_CHANNEL_SF_STOP tst r0, r1 bne _081DDC40 - ldrb r1, [r4, 0x13] + ldrb r1, [r4, o_CgbChannel_priority] ldr r0, [sp, 0x10] cmp r1, r0 bcc _081DDC40 beq _081DDBE4 b _081DDCEA _081DDBE4: - ldr r0, [r4, 0x2C] + ldr r0, [r4, o_CgbChannel_track] cmp r0, r5 bcs _081DDC40 b _081DDCEA @@ -1672,35 +1672,35 @@ _081DDBEC: movs r2, 0 mov r8, r2 ldr r4, [sp, 0x4] - ldrb r3, [r4, 0x6] - adds r4, 0x50 + ldrb r3, [r4, o_SoundInfo_maxChans] + adds r4, o_SoundInfo_chans _081DDBFA: - ldrb r1, [r4] - movs r0, 0xC7 + ldrb r1, [r4, o_SoundChannel_statusFlags] + movs r0, SOUND_CHANNEL_SF_ON tst r0, r1 beq _081DDC40 - movs r0, 0x40 + movs r0, SOUND_CHANNEL_SF_STOP tst r0, r1 beq _081DDC14 cmp r2, 0 bne _081DDC18 adds r2, 0x1 - ldrb r6, [r4, 0x13] - ldr r7, [r4, 0x2C] + ldrb r6, [r4, o_SoundChannel_priority] + ldr r7, [r4, o_SoundChannel_track] b _081DDC32 _081DDC14: cmp r2, 0 bne _081DDC34 _081DDC18: - ldrb r0, [r4, 0x13] + ldrb r0, [r4, o_SoundChannel_priority] cmp r0, r6 bcs _081DDC24 adds r6, r0, 0 - ldr r7, [r4, 0x2C] + ldr r7, [r4, o_SoundChannel_track] b _081DDC32 _081DDC24: bhi _081DDC34 - ldr r0, [r4, 0x2C] + ldr r0, [r4, o_SoundChannel_track] cmp r0, r7 bls _081DDC30 adds r7, r0, 0 @@ -1710,7 +1710,7 @@ _081DDC30: _081DDC32: mov r8, r4 _081DDC34: - adds r4, 0x40 + adds r4, SoundChannel_size subs r3, 0x1 bgt _081DDBFA mov r4, r8 @@ -1720,17 +1720,17 @@ _081DDC40: adds r0, r4, 0 bl ClearChain movs r1, 0 - str r1, [r4, 0x30] - ldr r3, [r5, 0x20] - str r3, [r4, 0x34] + str r1, [r4, o_SoundChannel_prevChannelPointer] + ldr r3, [r5, o_MusicPlayerTrack_chan] + str r3, [r4, o_SoundChannel_nextChannelPointer] cmp r3, 0 beq _081DDC54 - str r4, [r3, 0x30] + str r4, [r3, o_SoundChannel_prevChannelPointer] _081DDC54: - str r4, [r5, 0x20] - str r5, [r4, 0x2C] - ldrb r0, [r5, 0x1B] - strb r0, [r5, 0x1C] + str r4, [r5, o_MusicPlayerTrack_chan] + str r5, [r4, o_SoundChannel_track] + ldrb r0, [r5, o_MusicPlayerTrack_lfoDelay] + strb r0, [r5, o_MusicPlayerTrack_lfoDelayC] cmp r0, r1 beq _081DDC66 adds r1, r5, 0 @@ -1739,26 +1739,26 @@ _081DDC66: ldr r0, [sp] adds r1, r5, 0 bl TrkVolPitSet - ldr r0, [r5, 0x4] - str r0, [r4, 0x10] + ldr r0, [r5, o_MusicPlayerTrack_gateTime] + str r0, [r4, o_SoundChannel_gateTime] ldr r0, [sp, 0x10] - strb r0, [r4, 0x13] + strb r0, [r4, o_SoundChannel_priority] ldr r0, [sp, 0x8] - strb r0, [r4, 0x8] + strb r0, [r4, o_SoundChannel_key] ldr r0, [sp, 0x14] - strb r0, [r4, 0x14] + strb r0, [r4, o_SoundChannel_rhythmPan] 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] + ldrb r0, [r6, o_ToneData_type] + strb r0, [r4, o_SoundChannel_type] + ldr r7, [r6, o_ToneData_wav] + str r7, [r4, o_SoundChannel_wav] + ldr r0, [r6, o_ToneData_attack] + str r0, [r4, o_SoundChannel_attack] + ldrh r0, [r5, o_MusicPlayerTrack_pseudoEchoVolume] + strh r0, [r4, o_SoundChannel_pseudoEchoVolume] bl ChnVolSetAsm - ldrb r1, [r4, 0x8] - movs r0, 0x8 + ldrb r1, [r4, o_SoundChannel_key] + movs r0, o_MusicPlayerTrack_keyM ldrsb r0, [r5, r0] adds r3, r1, r0 bpl _081DDCA0 @@ -1768,9 +1768,9 @@ _081DDCA0: cmp r6, 0 beq _081DDCCE mov r6, r9 - ldrb r0, [r6, 0x2] - strb r0, [r4, 0x1E] - ldrb r1, [r6, 0x3] + ldrb r0, [r6, o_ToneData_length] + strb r0, [r4, o_CgbChannel_length] + ldrb r1, [r6, o_ToneData_pan_sweep] movs r0, 0x80 tst r0, r1 bne _081DDCBA @@ -1780,29 +1780,29 @@ _081DDCA0: _081DDCBA: movs r1, 0x8 _081DDCBC: - strb r1, [r4, 0x1F] - ldrb r2, [r5, 0x9] + strb r1, [r4, o_CgbChannel_sweep] + ldrb r2, [r5, o_MusicPlayerTrack_pitM] adds r1, r3, 0 ldr r0, [sp, 0xC] ldr r3, [sp, 0x4] - ldr r3, [r3, 0x30] + ldr r3, [r3, o_SoundInfo_MidiKeyToCgbFreq] bl call_r3 b _081DDCDC _081DDCCE: ldr r0, [r5, o_MusicPlayerTrack_unk_3C] - str r0, [r4, 0x18] - ldrb r2, [r5, 0x9] + str r0, [r4, o_SoundChannel_count] + ldrb r2, [r5, o_MusicPlayerTrack_pitM] adds r1, r3, 0 adds r0, r7, 0 bl MidiKeyToFreq _081DDCDC: - str r0, [r4, 0x20] - movs r0, 0x80 - strb r0, [r4] - ldrb r1, [r5] + str r0, [r4, o_SoundChannel_frequency] + movs r0, SOUND_CHANNEL_SF_START + strb r0, [r4, o_SoundChannel_statusFlags] + ldrb r1, [r5, o_MusicPlayerTrack_flags] movs r0, 0xF0 ands r0, r1 - strb r0, [r5] + strb r0, [r5, o_MusicPlayerTrack_flags] _081DDCEA: add sp, 0x18 pop {r0-r7} @@ -1832,23 +1832,23 @@ _081DDD18: ldr r1, [r1, o_MusicPlayerTrack_chan] cmp r1, 0 beq _081DDD40 - movs r4, 0x83 - movs r5, 0x40 + movs r4, SOUND_CHANNEL_SF_START | SOUND_CHANNEL_SF_ENV + movs r5, SOUND_CHANNEL_SF_STOP _081DDD22: - ldrb r2, [r1, o_SoundChannel_status] + ldrb r2, [r1, o_SoundChannel_statusFlags] tst r2, r4 beq _081DDD3A tst r2, r5 bne _081DDD3A - ldrb r0, [r1, o_SoundChannel_mk] + ldrb r0, [r1, o_SoundChannel_midiKey] cmp r0, r3 bne _081DDD3A - movs r0, 0x40 + movs r0, SOUND_CHANNEL_SF_STOP orrs r2, r0 - strb r2, [r1, o_SoundChannel_status] + strb r2, [r1, o_SoundChannel_statusFlags] b _081DDD40 _081DDD3A: - ldr r1, [r1, o_SoundChannel_np] + ldr r1, [r1, o_SoundChannel_nextChannelPointer] cmp r1, 0 bne _081DDD22 _081DDD40: @@ -1864,10 +1864,10 @@ clear_modM: ldrb r2, [r1, o_MusicPlayerTrack_modT] cmp r2, 0 bne _081DDD54 - movs r2, 0xC + movs r2, MPT_FLG_PITCHG b _081DDD56 _081DDD54: - movs r2, 0x3 + movs r2, MPT_FLG_VOLCHG _081DDD56: ldrb r3, [r1, o_MusicPlayerTrack_flags] orrs r3, r2 @@ -1910,28 +1910,8 @@ _081DDD90: .align 2, 0 @ Don't pad with nop. - .bss - .align 3 -sDecodingBuffer: - .space 0x40 - .size sDecodingBuffer, .-sDecodingBuffer - - .global gMPlayTrack_BGM -gMPlayTrack_BGM: - .space 0x320 - .size gMPlayTrack_BGM, .-gMPlayTrack_BGM - - .global gMPlayTrack_SE1 -gMPlayTrack_SE1: - .space 0xF0 - .size gMPlayTrack_SE1, .-gMPlayTrack_SE1 - - .global gMPlayTrack_SE2 -gMPlayTrack_SE2: - .space 0x2D0 - .size gMPlayTrack_SE2, .-gMPlayTrack_SE2 - - .global gMPlayTrack_SE3 -gMPlayTrack_SE3: - .space 0x50 - .size gMPlayTrack_SE3, .-gMPlayTrack_SE3 + .bss + .align 3 +sDecodingBuffer: @ Used as a buffer for audio decoded from compressed DPCM + .space 0x40 + .size sDecodingBuffer, .-sDecodingBuffer diff --git a/sym_bss.txt b/sym_bss.txt index 9f50fd0a7..00c7b1dc6 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -28,6 +28,7 @@ .include "src/ereader_helpers.o" .include "src/digit_obj_util.o" .include "src/m4a_1.o" + .include "data/sound_data.o" .include "src/agb_flash.o" .include "*libgcc.a:dp-bit.o" .include "*libgcc.a:fp-bit.o"