Skip to content

Commit

Permalink
decomp spin-rotation
Browse files Browse the repository at this point in the history
MokhaLeee committed Jun 17, 2024
1 parent 0e1e244 commit f2cf2a7
Showing 6 changed files with 76 additions and 112 deletions.
2 changes: 2 additions & 0 deletions FireEmblem7J.lds
Original file line number Diff line number Diff line change
@@ -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)
82 changes: 0 additions & 82 deletions asm/savedrawfx.s
Original file line number Diff line number Diff line change
@@ -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
18 changes: 0 additions & 18 deletions data/savedrawfx.s
Original file line number Diff line number Diff line change
@@ -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
25 changes: 22 additions & 3 deletions include/gbafe/savemenu.h
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions src/savedrawfx.c
Original file line number Diff line number Diff line change
@@ -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;
}
18 changes: 9 additions & 9 deletions src/sysutil.c
Original file line number Diff line number Diff line change
@@ -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];

0 comments on commit f2cf2a7

Please sign in to comment.