Skip to content

Commit

Permalink
Merge pull request #581 from MokhaLeee/EventSpriteAnim
Browse files Browse the repository at this point in the history
decomp EventSpriteAnim
  • Loading branch information
RevoSucks authored Feb 26, 2024
2 parents c80a433 + a20e519 commit bf0175f
Show file tree
Hide file tree
Showing 17 changed files with 128 additions and 162 deletions.
109 changes: 0 additions & 109 deletions asm/scene.s
Original file line number Diff line number Diff line change
Expand Up @@ -280,112 +280,3 @@ _08009194: .4byte gUnknown_0859163C

THUMB_FUNC_END sub_800915C

THUMB_FUNC_START sub_8009198
sub_8009198: @ 0x08009198
push {r4, r5, r6, lr}
mov r6, r8
push {r6}
sub sp, #0x18
mov r8, r0
ldr r1, _080091F8 @ gBmSt
movs r2, #0xc
ldrsh r0, [r1, r2]
mov r5, r8
ldr r3, [r5, #0x2c]
subs r3, r3, r0
adds r3, #8
movs r2, #0xe
ldrsh r0, [r1, r2]
ldr r4, [r5, #0x30]
subs r4, r4, r0
adds r4, #8
ldr r6, [r5, #0x38]
ldr r0, [r6, #4]
ldr r1, [r6]
ldr r2, [r6, #8]
ldr r5, _080091FC @ 0x000001FF
ands r3, r5
movs r5, #0xff
ands r4, r5
ldrh r5, [r6, #0xc]
adds r4, r4, r5
str r4, [sp]
movs r4, #0
str r4, [sp, #4]
ldrb r4, [r6, #0x10]
str r4, [sp, #8]
ldrb r4, [r6, #0x11]
str r4, [sp, #0xc]
ldrh r4, [r6, #0xe]
str r4, [sp, #0x10]
movs r4, #4
str r4, [sp, #0x14]
bl sub_80AE9B0
mov r1, r8
str r0, [r1, #0x34]
add sp, #0x18
pop {r3}
mov r8, r3
pop {r4, r5, r6}
pop {r0}
bx r0
.align 2, 0
_080091F8: .4byte gBmSt
_080091FC: .4byte 0x000001FF

THUMB_FUNC_END sub_8009198

THUMB_FUNC_START sub_8009200
sub_8009200: @ 0x08009200
push {r4, r5, r6, lr}
adds r4, r0, #0
ldr r6, [r4, #0x34]
ldr r5, [r6]
cmp r5, #0
beq _08009240
ldr r2, _08009238 @ gBmSt
movs r1, #0xc
ldrsh r0, [r2, r1]
ldr r1, [r4, #0x2c]
subs r1, r1, r0
adds r1, #8
movs r3, #0xe
ldrsh r0, [r2, r3]
ldr r2, [r4, #0x30]
subs r2, r2, r0
adds r2, #8
ldr r0, _0800923C @ 0x000001FF
ands r1, r0
movs r0, #0xff
ands r2, r0
movs r3, #1
negs r3, r3
adds r0, r6, #0
bl APProc_SetParameters
b _08009248
.align 2, 0
_08009238: .4byte gBmSt
_0800923C: .4byte 0x000001FF
_08009240:
adds r0, r4, #0
bl Proc_Break
str r5, [r4, #0x34]
_08009248:
pop {r4, r5, r6}
pop {r0}
bx r0

THUMB_FUNC_END sub_8009200

THUMB_FUNC_START sub_8009250
sub_8009250: @ 0x08009250
push {lr}
ldr r0, [r0, #0x34]
cmp r0, #0
beq _0800925C
bl APProc_Delete
_0800925C:
pop {r0}
bx r0

THUMB_FUNC_END sub_8009250
2 changes: 1 addition & 1 deletion include/ap.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct APHandle * AP_Find(const u16 * definition);
ProcPtr APProc_Create(const void * apDefinition, int xPos, int yPos, int tileBase, int anim, u16 aObjNode);
// ??? APProc_OnUpdate(???);
// ??? APProc_OnEnd(???);
// ??? APProc_SetParameters(???);
void APProc_SetParameters(struct APProc * proc, int x, int y, int tileBase);
void APProc_Delete(struct APProc * proc);
void APProc_DeleteAll(void);
bool APProc_Exists(void);
Expand Down
4 changes: 2 additions & 2 deletions include/efxbattle.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,10 @@ extern s16 gUnknown_02017764[2];
extern s16 gUnknown_02017768[2];

extern s16 gEkrHitEfxBool[]; /* [0] for left and [1] for right, if in hit routine, 1, otherwise 0 */
extern u8 gEkrBuf1[];
extern u8 gSpellAnimBgfx[];
extern u16 gEkrBarfxBuf[];
extern u16 gEkrTsaBuffer[0x1000 / 2];
extern u8 gEkrBuf2[];
extern u8 gSpellAnimObjfx[];

extern u16 gPalBackupEkrUnitMaybe[0x40 / sizeof(u16)];
extern u16 gEfxBuf_0201C8D0[0xB58 / sizeof(u16)];
Expand Down
4 changes: 2 additions & 2 deletions include/ekrbattle.h
Original file line number Diff line number Diff line change
Expand Up @@ -906,8 +906,8 @@ int GetAISLayerId(struct Anim * anim);
int CheckRound1(s16);
int CheckRound2(s16);
int CheckRoundCrit(struct Anim * anim);
struct Anim *GetAnimAnotherSide(struct Anim * anim);
// ??? GetAnimRoundType(???);
struct Anim * GetAnimAnotherSide(struct Anim * anim);
s16 GetAnimRoundType(struct Anim * anim);
s16 GetAnimNextRoundType(struct Anim * anim);
s16 GetAnimRoundTypeAnotherSide(struct Anim * anim);
s16 GetAnimNextRoundTypeAnotherSide(struct Anim * anim);
Expand Down
6 changes: 2 additions & 4 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ void CallARM_FillMovementMap(void);
// ??? sub_800904C(???);
// ??? sub_8009100(???);
void sub_800915C(int, int, int, int, int, int, int, ProcPtr);
// ??? sub_8009198(???);
// ??? sub_8009200(???);
// ??? sub_8009250(???);

const char * GetStrPrefix(s8 * str, bool capital);
void InsertPrefix(char * str, const char * prefix, bool capital);
void SetMsgTerminator(signed char * str);
Expand Down Expand Up @@ -501,7 +499,7 @@ void EndUiSpinningArrows(void);
// ??? sub_80AE938(???);
// ??? sub_80AE964(???);
// ??? sub_80AE99C(???);
// ??? sub_80AE9B0(???);
ProcPtr StartSpriteAnimfx(const u8 * gfx, const u16 * pal, const void * apDef, int x, int y, int animId, int palId, int palCount, u16 chr, int aObjNode);
int GetBgXOffset(int);
// ??? GetBgYOffset(???);
char* AppendTextBuffer_80AEABC(const char*, char*);
Expand Down
1 change: 1 addition & 0 deletions include/gbafe.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,4 @@
#include "trapfx.h"
#include "statscreen.h"
#include "cp_data.h"
#include "sprite-animfx.h"
28 changes: 28 additions & 0 deletions include/sprite-animfx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "global.h"
#include "proc.h"

struct EventSpriteAnimConf {
/* 00 */ const u16 * pal;
/* 04 */ const u8 * img;
/* 08 */ const u8 * ap_conf;
/* 0C */ u16 oam0, oam2;
/* 10 */ u8 pal_bank, pal_size;

/* 12 */ u8 _pad_[2];
};

struct ProcEventSpriteAnim {
PROC_HEADER;

/* 2C */ int x, y;
/* 34 */ ProcPtr approc;
/* 38 */ const struct EventSpriteAnimConf * priv;
};

void EventSpriteAnim_Init(struct ProcEventSpriteAnim * proc);
void EventSpriteAnim_Loop(struct ProcEventSpriteAnim * proc);
void EventSpriteAnim_End(struct ProcEventSpriteAnim * proc);

extern struct ProcCmd CONST_DATA ProcScr_EventSpriteAnim[];
7 changes: 4 additions & 3 deletions include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,10 @@ extern u16 gUnknown_08589A9C[];
extern struct Glyph *TextGlyphs_System[];
extern struct Glyph *TextGlyphs_Talk[];
extern struct Glyph *TextGlyphs_Special[];
// extern ??? gUnknown_0859160C
// extern ??? gUnknown_08591624
// extern ??? gUnknown_0859163C
extern struct ProcCmd CONST_DATA gProcScr_TalkPutSpriteText_Unused[];
extern struct ProcCmd CONST_DATA gUnknown_0859160C[];
extern struct ProcCmd CONST_DATA gUnknown_0859163C[];

extern const char *gStrPrefix[][2];
//extern struct {u32 *unk0; u32 *unk4; u32 *unk8;} gStrPrefix;
// extern ??? gUnknown_08591AB4
Expand Down
2 changes: 2 additions & 0 deletions ldscript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ SECTIONS
src/face.o(.text);
src/scene.o(.text);
asm/scene.o(.text);
src/sprite-animfx.o(.text);
src/ap.o(.text);
src/gamecontrol.o(.text);
src/msg.o(.text);
Expand Down Expand Up @@ -618,6 +619,7 @@ SECTIONS
. = ALIGN(4); src/ctc.o(.data);
. = ALIGN(4); src/face.o(.data);
. = ALIGN(4); src/scene.o(.data);
. = ALIGN(4); src/sprite-animfx.o(.data);
. = ALIGN(4); src/ap.o(.data);
. = ALIGN(4); src/gamecontrol.o(.data);
. = ALIGN(4); src/msg.o(.data);
Expand Down
8 changes: 4 additions & 4 deletions src/banim-ekrlvup.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,14 @@ void EkrLvup_InitLevelUpBox(struct ProcEkrLevelup *proc)
struct BattleUnit *bu2 = gpEkrBattleUnitRight;
struct Anim *anim = proc->ais_main;

LZ77UnCompWram(Img_LevelUpBoxFrame, gEkrBuf1);
LZ77UnCompWram(Img_LevelUpBoxFrame, gSpellAnimBgfx);
LZ77UnCompWram(Tsa_LevelUpBoxFrame, gEkrTsaBuffer);
EfxTmCpyBG(gEkrTsaBuffer, TILEMAP_LOCATED(gBG1TilemapBuffer, 0, 0x6), 0x20, 0x14, 1, 0x100);
RegisterDataMove(gEkrBuf1, (void *)BG_VRAM + 0x2000, 0x8C0);
RegisterDataMove(gSpellAnimBgfx, (void *)BG_VRAM + 0x2000, 0x8C0);
CpuFastCopy(Pal_LevelUpBoxFrame, PAL_BG(1), 0x20);

LZ77UnCompWram(Img_LvupApfx, gEkrBuf2);
RegisterDataMove(gEkrBuf2, OBJ_VRAM0 + 0x1400, 0xC00);
LZ77UnCompWram(Img_LvupApfx, gSpellAnimObjfx);
RegisterDataMove(gSpellAnimObjfx, OBJ_VRAM0 + 0x1400, 0xC00);
CpuFastCopy(Pal_LvupApfx, PAL_OBJ(1), 0x20);

EnablePaletteSync();
Expand Down
26 changes: 13 additions & 13 deletions src/banim-ekrtriangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ void NewEkrTriPegasusKnightBG(struct Anim * anim, u32 pos, u32 etype, u32 ewtype
proc->tsalut_left = TsaLut_EkrTriPegagusBG;
proc->tsalut_right = TsaLut_EkrTriPegagusBG;

LZ77UnCompWram(pal, gEkrBuf1);
SpellFx_RegisterBgPal((u16 *)gEkrBuf1, 0x20);
LZ77UnCompWram(pal, gSpellAnimBgfx);
SpellFx_RegisterBgPal((u16 *)gSpellAnimBgfx, 0x20);

img = Img_TriPegasusKnightBG;
if (etype != EKR_TRI_JTYPE_DEFAULT)
Expand Down Expand Up @@ -368,8 +368,8 @@ void NewEkrTriPegasusKnightOBJ(struct Anim * anim, u32 pos, u32 etype, u32 ewtyp
}

proc->anim2 = EfxCreateFrontAnim(anim, scr, scr, scr, scr);
LZ77UnCompWram(pal, gEkrBuf2);
SpellFx_RegisterObjPal((u16 *)gEkrBuf2, 0x20);
LZ77UnCompWram(pal, gSpellAnimObjfx);
SpellFx_RegisterObjPal((u16 *)gSpellAnimObjfx, 0x20);

img = Img_TriPegasusKnightOBJ;
if (etype != EKR_TRI_JTYPE_DEFAULT)
Expand Down Expand Up @@ -503,9 +503,9 @@ void NewEkrTriArmorKnightOBJ(struct Anim *anim, u32 etype1, u32 etype2, u32 ewty
proc->anim2 = anim2;
anim2->oam2Base = OAM2_PAL(0x8) + OAM2_LAYER(0x2) + OAM2_CHR(0x0800 / 0x20);

LZ77UnCompWram(pal, gEkrBuf2);
CpuFastCopy(gEkrBuf2, PAL_OBJ(0x8), 0x20);
LZ77UnCompWram(img, gEkrBuf2);
LZ77UnCompWram(pal, gSpellAnimObjfx);
CpuFastCopy(gSpellAnimObjfx, PAL_OBJ(0x8), 0x20);
LZ77UnCompWram(img, gSpellAnimObjfx);

pal = gBanimTriAtkPalettes[1];
if (etype2 == EKR_TRI_JTYPE_DEFAULT)
Expand Down Expand Up @@ -539,13 +539,13 @@ void NewEkrTriArmorKnightOBJ(struct Anim *anim, u32 etype1, u32 etype2, u32 ewty
proc->anim3 = anim2;
anim2->oam2Base = OAM2_PAL(0xA) + OAM2_LAYER(0x2) + OAM2_CHR(0x1000 / 0x20);

LZ77UnCompWram(pal, &gEkrBuf2[0x800]);
CpuFastCopy(&gEkrBuf2[0x800], PAL_OBJ(0xA), 0x20);
LZ77UnCompWram(img, &gEkrBuf2[0x800]);
LZ77UnCompWram(pal, &gSpellAnimObjfx[0x800]);
CpuFastCopy(&gSpellAnimObjfx[0x800], PAL_OBJ(0xA), 0x20);
LZ77UnCompWram(img, &gSpellAnimObjfx[0x800]);

{
u16 * dst = OBJ_VRAM0 + 0x800;
RegisterDataMove(gEkrBuf2, dst, 0x1000);
RegisterDataMove(gSpellAnimObjfx, dst, 0x1000);
}
EnablePaletteSync();

Expand Down Expand Up @@ -649,8 +649,8 @@ void NewEkrTriArmorKnightOBJ2(struct Anim * anim, u32 pos, u32 etype, u32 ewtype
proc->anim2->xPosition = proc->unk32;
}

LZ77UnCompWram(pal, gEkrBuf2);
SpellFx_RegisterObjPal((u16 *)gEkrBuf2, 0x20);
LZ77UnCompWram(pal, gSpellAnimObjfx);
SpellFx_RegisterObjPal((u16 *)gSpellAnimObjfx, 0x20);
SpellFx_RegisterObjGfx(buf, 0x1000);
}

Expand Down
8 changes: 4 additions & 4 deletions src/banim-ekrutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ void SpellFx_WriteBgMapExt(struct Anim * anim, const u16 * src, int width, int h
void SpellFx_RegisterObjGfx(const u16 * img, u32 size)
{
u16 * dst = OBJ_VRAM0 + VRAMOFF_BANIM_SPELL_OBJ;
LZ77UnCompWram(img, gEkrBuf2);
RegisterDataMove(gEkrBuf2, dst, size);
LZ77UnCompWram(img, gSpellAnimObjfx);
RegisterDataMove(gSpellAnimObjfx, dst, size);
}

void SpellFx_RegisterObjPal(const u16 * pal, u32 size)
Expand All @@ -356,8 +356,8 @@ void SpellFx_RegisterObjPal(const u16 * pal, u32 size)
void SpellFx_RegisterBgGfx(const u16 * img, u32 size)
{
u16 *dst = (void *)BG_VRAM + VRAMOFF_BANIM_SPELL_BG;
LZ77UnCompWram(img, gEkrBuf1);
RegisterDataMove(gEkrBuf1, dst, size);
LZ77UnCompWram(img, gSpellAnimBgfx);
RegisterDataMove(gSpellAnimBgfx, dst, size);
}

void SpellFx_RegisterBgPal(const u16 * pal, u32 size)
Expand Down
4 changes: 2 additions & 2 deletions src/classchg-sel.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,9 @@ void sub_80CD47C(int a, int b, int c, int d, int e) {
gUnknown_030053E0.u0c = 0x4;
gUnknown_030053E0.u12 = 0x1;
gUnknown_030053E0.buf = gBG1TilemapBuffer;
gUnknown_030053E0.u18 = gEkrBuf1;
gUnknown_030053E0.u18 = gSpellAnimBgfx;
gUnknown_030053E0.u1c = (void *)gEkrTsaBuffer;
gUnknown_030053E0.u20 = gEkrBuf2;
gUnknown_030053E0.u20 = gSpellAnimObjfx;
gUnknown_030053E0.u24 = sub_80CD34C;

ResetClassReelSpell();
Expand Down
2 changes: 1 addition & 1 deletion src/code_80AE86C.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void sub_80AE99C(void)
}

//! FE8U = 0x080AE9B0
ProcPtr sub_80AE9B0(u8 * gfx, u16 * pal, const void * apDef, int x, int y, int animId, int palId, int palCount, u16 chr, int aObjNode)
ProcPtr StartSpriteAnimfx(const u8 * gfx, const u16 * pal, const void * apDef, int x, int y, int animId, int palId, int palCount, u16 chr, int aObjNode)
{
if (gfx != NULL)
{
Expand Down
15 changes: 0 additions & 15 deletions src/scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ void sub_8008FB4(ProcPtr);
void sub_800903C(ProcPtr);
void sub_800904C(ProcPtr);
void sub_8009100(ProcPtr);
void sub_8009250(ProcPtr);
void sub_8009198(ProcPtr);
void sub_8009200(ProcPtr);

// rearrange!!!

Expand Down Expand Up @@ -339,18 +336,6 @@ struct ProcCmd CONST_DATA gUnknown_0859163C[] =
PROC_END,
};

struct ProcCmd CONST_DATA gUnused_0859166C[] =
{
PROC_SLEEP(0),

PROC_SET_END_CB(sub_8009250),

PROC_CALL(sub_8009198),
PROC_REPEAT(sub_8009200),

PROC_END,
};

extern u16 gUnknown_089E84D4[];

extern u16 gUnknown_0859F000[];
Expand Down
Loading

0 comments on commit bf0175f

Please sign in to comment.