diff --git a/FireEmblem7J.lds b/FireEmblem7J.lds index 4ce2d86..1185ae5 100644 --- a/FireEmblem7J.lds +++ b/FireEmblem7J.lds @@ -269,6 +269,7 @@ SECTIONS src/savemenu.o(.text); asm/savemenu.o(.text); asm/savedraw.o(.text); + src/savedrawfx.o(.text); asm/savedrawfx.o(.text); asm/savemenu_difficulty.o(.text); src/scrolling_util.o(.text); @@ -360,6 +361,7 @@ SECTIONS . = ALIGN(4); src/save_core.o(.data) . = ALIGN(4); data/data_08DAD284.o(.data) . = ALIGN(4); data/savemenu.o(.data) + . = ALIGN(4); src/savedrawfx.o(.data) . = ALIGN(4); data/savedrawfx.o(.data) . = ALIGN(4); src/sysutil.o(.data) . = ALIGN(4); data/data_08DAE4C4.o(.data) diff --git a/asm/savedrawfx.s b/asm/savedrawfx.s index a18cdef..5353f9b 100644 --- a/asm/savedrawfx.s +++ b/asm/savedrawfx.s @@ -1,88 +1,6 @@ .include "macro.inc" .syntax unified - thumb_func_start SpinRotation_Init -SpinRotation_Init: @ 0x080A691C - adds r2, r0, #0 - adds r1, r2, #0 - adds r1, #0x39 - movs r0, #0 - strb r0, [r1] - movs r1, #0 - strh r0, [r2, #0x2a] - adds r0, r2, #0 - adds r0, #0x35 - strb r1, [r0] - adds r0, #1 - strb r1, [r0] - adds r0, #1 - strb r1, [r0] - adds r0, #1 - strb r1, [r0] - adds r0, #2 - strb r1, [r0] - adds r0, #1 - strb r1, [r0] - adds r0, #2 - strb r1, [r0] - subs r0, #9 - strb r1, [r0] - bx lr - .align 2, 0 - - thumb_func_start SpinRotation_Loop -SpinRotation_Loop: @ 0x080A6950 - push {lr} - sub sp, #8 - ldrh r1, [r0, #0x2a] - adds r1, #1 - strh r1, [r0, #0x2a] - ldr r1, [r0, #0x2c] - subs r1, #4 - str r1, [r0, #0x2c] - lsls r1, r1, #0x10 - asrs r1, r1, #0x10 - movs r0, #0xc0 - lsls r0, r0, #1 - str r0, [sp] - str r0, [sp, #4] - movs r0, #2 - movs r2, #0 - movs r3, #0 - bl sub_80AACB0 - movs r1, #0x80 - lsls r1, r1, #2 - movs r2, #0x80 - lsls r2, r2, #1 - movs r0, #2 - bl sub_80AAD44 - movs r0, #0x4c - str r0, [sp] - movs r0, #2 - movs r1, #0x78 - movs r2, #0xa0 - movs r3, #0x4c - bl sub_80AAD94 - bl SyncDispIo - add sp, #8 - pop {r0} - bx r0 - .align 2, 0 - - thumb_func_start StartSpinRotation -StartSpinRotation: @ 0x080A69A0 - push {r4, lr} - adds r4, r0, #0 - ldr r0, _080A69B4 @ =ProcScr_SpinRotation - movs r1, #0 - bl Proc_Start - str r4, [r0, #0x30] - pop {r4} - pop {r1} - bx r1 - .align 2, 0 -_080A69B4: .4byte ProcScr_SpinRotation - thumb_func_start SaveDrawCursor_Init SaveDrawCursor_Init: @ 0x080A69B8 adds r2, r0, #0 diff --git a/data/savedrawfx.s b/data/savedrawfx.s index 6d2bd45..9c86168 100644 --- a/data/savedrawfx.s +++ b/data/savedrawfx.s @@ -1,23 +1,5 @@ .section .data - .global ProcScr_SpinRotation -ProcScr_SpinRotation: @ 0x08DADA64 - @ PROC_19 - .short 0x19, 0x0 - .word 0x0 - @ PROC_MARK - .short 0xf, 0xd - .word 0x0 - @ PROC_CALL - .short 0x2, 0x0 - .word SpinRotation_Init - @ PROC_REPEAT - .short 0x3, 0x0 - .word SpinRotation_Loop - @ PROC_END - .short 0x0, 0x0 - .word 0x0 - .global ProcScr_SaveDrawCursor ProcScr_SaveDrawCursor: @ 0x08DADA8C @ PROC_19 diff --git a/include/gbafe/savemenu.h b/include/gbafe/savemenu.h index 49cbf0d..0ddb530 100644 --- a/include/gbafe/savemenu.h +++ b/include/gbafe/savemenu.h @@ -138,9 +138,28 @@ void SaveMenu_StartHelpBox(struct SaveMenuProc * proc); // ??? StartSaveDraw /* savedrawfx */ -// ??? SpinRotation_Init -// ??? SpinRotation_Loop -// ??? StartSpinRotation +struct ProcSpinRotation { + PROC_HEADER; + + /* 2A */ u16 ro; + /* 2C */ int angle; + /* 30 */ ProcPtr savedraw; + + /* 34 */ u8 unk_34; + /* 34 */ u8 unk_35; + /* 34 */ u8 unk_36; + /* 34 */ u8 unk_37; + /* 34 */ u8 unk_38; + /* 34 */ u8 unk_39; + /* 34 */ u8 unk_3A; + /* 34 */ u8 unk_3B; + /* 34 */ u8 unk_3C_unused; + /* 34 */ u8 unk_3D; +}; + +void SpinRotation_Init(struct ProcSpinRotation * proc); +void SpinRotation_Loop(struct ProcSpinRotation * proc); +ProcPtr StartSpinRotation(ProcPtr parent); // ??? SaveDrawCursor_Init // ??? SaveDrawCursor_Loop // ??? sub_80A6B4C diff --git a/src/savedrawfx.c b/src/savedrawfx.c new file mode 100644 index 0000000..6128c80 --- /dev/null +++ b/src/savedrawfx.c @@ -0,0 +1,43 @@ +#include "gbafe.h" + +void SpinRotation_Init(struct ProcSpinRotation * proc) +{ + proc->unk_39 = 0; + proc->ro = 0; + proc->unk_35 = 0; + proc->unk_36 = 0; + proc->unk_37 = 0; + proc->unk_38 = 0; + proc->unk_3A = 0; + proc->unk_3B = 0; + proc->unk_3D = 0; + proc->unk_34 = 0; +} + +void SpinRotation_Loop(struct ProcSpinRotation * proc) +{ + proc->ro++; + proc->angle -= 4; + + sub_80AACB0(2, proc->angle, 0, 0, 0x180, 0x180); + sub_80AAD44(2, 0x200, 0x100); + sub_80AAD94(2, 0x78, 0xA0, 0x4C, 0x4C); + + SyncDispIo(); +} + +struct ProcCmd CONST_DATA ProcScr_SpinRotation[] = { + PROC_NAME_DEBUG("SpinRotation"), + PROC_MARK(13), + PROC_CALL(SpinRotation_Init), + PROC_REPEAT(SpinRotation_Loop), + PROC_END, +}; + +ProcPtr StartSpinRotation(ProcPtr parent) +{ + struct ProcSpinRotation * proc; + proc = Proc_Start(ProcScr_SpinRotation, PROC_TREE_VSYNC); + proc->savedraw = parent; + return proc; +} diff --git a/src/sysutil.c b/src/sysutil.c index c6fba49..3b5b654 100644 --- a/src/sysutil.c +++ b/src/sysutil.c @@ -929,23 +929,23 @@ void sub_80AAD94(u8 layer, s16 a, s16 b, s16 c, s16 d) affin->dy = affin->pc * (-a) + affin->pd * (-b) + d * 0x100; } -void sub_80AADFC(u8 layer, int angle, int a, int b, int c, int d) +void sub_80AADFC(u8 layer, int angle, int texX, int texY, int x_scaling, int y_scaling) { struct BgAffineSrcData data; struct BgAffineDstData * dst; - if (c <= 0x400) - c = 0x400; + if (x_scaling <= 0x400) + x_scaling = 0x400; - if (d <= 0x400) - d = 0x400; + if (y_scaling <= 0x400) + y_scaling = 0x400; - data.texX = a; - data.texY = b; + data.texX = texX; + data.texY = texY; data.scrX = 0; data.scrY = 0; - data.sx = 0x1000000 / c; - data.sy = 0x1000000 / d; + data.sx = 0x1000000 / x_scaling; + data.sy = 0x1000000 / y_scaling; data.alpha = angle >> 4; dst = &gOpAnimBgAffineDstData[1];