diff --git a/lib/DSE/asm/include/main_020723C0.inc b/lib/DSE/asm/include/main_020723C0.inc deleted file mode 100644 index e6797521..00000000 --- a/lib/DSE/asm/include/main_020723C0.inc +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -.public _s32_div_f diff --git a/lib/DSE/asm/include/main_02072668.inc b/lib/DSE/asm/include/main_02072668.inc deleted file mode 100644 index e6797521..00000000 --- a/lib/DSE/asm/include/main_02072668.inc +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -.public _s32_div_f diff --git a/lib/DSE/asm/main_020723C0.s b/lib/DSE/asm/main_020723C0.s deleted file mode 100644 index 3ce64b19..00000000 --- a/lib/DSE/asm/main_020723C0.s +++ /dev/null @@ -1,32 +0,0 @@ - .include "asm/macros.inc" - .include "include/main_020723C0.inc" - - .text - - arm_func_start DseTrackEvent_VolumeFade -DseTrackEvent_VolumeFade: ; 0x020723C0 - stmdb sp!, {r4, r5, r6, lr} - mov r5, r0 - ldrsb r1, [r5, #2] - ldrb r2, [r5] - ldrb r0, [r5, #1] - mov r4, r3 - mov r1, r1, lsl #0x10 - add r0, r2, r0, lsl #8 - mov r0, r0, lsl #0x10 - str r1, [r4, #0x34] - movs r6, r0, lsr #0x10 - streq r1, [r4, #0x2c] - beq _02072410 - ldr r0, [r4, #0x2c] - subs r0, r1, r0 - moveq r6, #0 - beq _02072410 - mov r1, r6 - bl _s32_div_f - str r0, [r4, #0x30] -_02072410: - strh r6, [r4, #0x38] - add r0, r5, #3 - ldmia sp!, {r4, r5, r6, pc} - arm_func_end DseTrackEvent_VolumeFade diff --git a/lib/DSE/asm/main_02072668.s b/lib/DSE/asm/main_02072668.s deleted file mode 100644 index 11dbf561..00000000 --- a/lib/DSE/asm/main_02072668.s +++ /dev/null @@ -1,32 +0,0 @@ - .include "asm/macros.inc" - .include "include/main_02072668.inc" - - .text - - arm_func_start DseTrackEvent_PanFade -DseTrackEvent_PanFade: ; 0x02072668 - stmdb sp!, {r4, r5, r6, lr} - mov r5, r0 - ldrsb r1, [r5, #2] - ldrb r2, [r5] - ldrb r0, [r5, #1] - mov r4, r3 - mov r1, r1, lsl #0x10 - add r0, r2, r0, lsl #8 - mov r0, r0, lsl #0x10 - str r1, [r4, #0x44] - movs r6, r0, lsr #0x10 - streq r1, [r4, #0x3c] - beq _020726B8 - ldr r0, [r4, #0x3c] - subs r0, r1, r0 - moveq r6, #0 - beq _020726B8 - mov r1, r6 - bl _s32_div_f - str r0, [r4, #0x40] -_020726B8: - strh r6, [r4, #0x48] - add r0, r5, #3 - ldmia sp!, {r4, r5, r6, pc} - arm_func_end DseTrackEvent_PanFade diff --git a/lib/DSE/include/main_020723C0.h b/lib/DSE/include/main_020723C0.h new file mode 100644 index 00000000..4d76871a --- /dev/null +++ b/lib/DSE/include/main_020723C0.h @@ -0,0 +1,8 @@ +#ifndef PMDSKY_MAIN_020723C0_H +#define PMDSKY_MAIN_020723C0_H + +#include "dse.h" + +u8* DseTrackEvent_VolumeFade(u8 *ptr_next_byte, struct dse_sequence *sequence, struct dse_track *track, struct dse_channel *channel); + +#endif diff --git a/lib/DSE/include/main_02072668.h b/lib/DSE/include/main_02072668.h new file mode 100644 index 00000000..291c4839 --- /dev/null +++ b/lib/DSE/include/main_02072668.h @@ -0,0 +1,8 @@ +#ifndef PMDSKY_MAIN_02072668_H +#define PMDSKY_MAIN_02072668_H + +#include "dse.h" + +u8* DseTrackEvent_PanFade(u8 *ptr_next_byte, struct dse_sequence *sequence, struct dse_track *track, struct dse_channel *channel); + +#endif diff --git a/lib/DSE/src/main_020723C0.c b/lib/DSE/src/main_020723C0.c new file mode 100644 index 00000000..a4478bb6 --- /dev/null +++ b/lib/DSE/src/main_020723C0.c @@ -0,0 +1,22 @@ +#include "main_020723C0.h" + +u8* DseTrackEvent_VolumeFade(u8 *ptr_next_byte, struct dse_sequence *sequence, struct dse_track *track, struct dse_channel *channel) +{ + u16 ticks = ptr_next_byte[0] + (ptr_next_byte[1] << 8); + s32 target = *(s8 *)&ptr_next_byte[2] << 16; + + channel->volume.target = target; + if (ticks == 0) { + channel->volume.current = target; + } else { + s32 diff = target - channel->volume.current; + + if (diff == 0) { + ticks = 0; + } else { + channel->volume.delta = diff / ticks; + } + } + channel->volume.ticks_remaining = ticks; + return ptr_next_byte + 3; +} diff --git a/lib/DSE/src/main_02072668.c b/lib/DSE/src/main_02072668.c new file mode 100644 index 00000000..9f7f2cf1 --- /dev/null +++ b/lib/DSE/src/main_02072668.c @@ -0,0 +1,22 @@ +#include "main_02072668.h" + +u8* DseTrackEvent_PanFade(u8 *ptr_next_byte, struct dse_sequence *sequence, struct dse_track *track, struct dse_channel *channel) +{ + u16 ticks = ptr_next_byte[0] + (ptr_next_byte[1] << 8); + s32 target = *(s8 *)&ptr_next_byte[2] << 16; + + channel->pan.target = target; + if (ticks == 0) { + channel->pan.current = target; + } else { + s32 diff = target - channel->pan.current; + + if (diff == 0) { + ticks = 0; + } else { + channel->pan.delta = diff / ticks; + } + } + channel->pan.ticks_remaining = ticks; + return ptr_next_byte + 3; +} diff --git a/main.lsf b/main.lsf index df23a2ef..01ea5a6c 100644 --- a/main.lsf +++ b/main.lsf @@ -387,13 +387,13 @@ Static main Object lib/DSE/src/main_0207222C.o Object lib/DSE/src/main_0207227C.o Object lib/DSE/src/main_02072310.o - Object lib/DSE/asm/main_020723C0.o + Object lib/DSE/src/main_020723C0.o Object lib/DSE/src/main_0207241C.o Object lib/DSE/src/main_020724A8.o Object lib/DSE/src/main_02072504.o Object lib/DSE/src/main_02072554.o Object lib/DSE/src/main_020725D4.o - Object lib/DSE/asm/main_02072668.o + Object lib/DSE/src/main_02072668.o Object lib/DSE/src/main_020726C4.o Object lib/DSE/src/main_02072720.o Object lib/DSE/src/main_02072770.o