diff --git a/asm/scene.s b/asm/scene.s index 402dec12..5dc72760 100644 --- a/asm/scene.s +++ b/asm/scene.s @@ -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 diff --git a/include/ap.h b/include/ap.h index acbfc276..fbc43704 100644 --- a/include/ap.h +++ b/include/ap.h @@ -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); diff --git a/include/efxbattle.h b/include/efxbattle.h index a64454e8..13750191 100644 --- a/include/efxbattle.h +++ b/include/efxbattle.h @@ -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)]; diff --git a/include/ekrbattle.h b/include/ekrbattle.h index 34710231..0e14f898 100644 --- a/include/ekrbattle.h +++ b/include/ekrbattle.h @@ -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); diff --git a/include/functions.h b/include/functions.h index 26e3242a..70e0012c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -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); @@ -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*); diff --git a/include/gbafe.h b/include/gbafe.h index 7c16a0e0..9c91bbe9 100644 --- a/include/gbafe.h +++ b/include/gbafe.h @@ -133,3 +133,4 @@ #include "trapfx.h" #include "statscreen.h" #include "cp_data.h" +#include "sprite-animfx.h" diff --git a/include/sprite-animfx.h b/include/sprite-animfx.h new file mode 100644 index 00000000..db86d97d --- /dev/null +++ b/include/sprite-animfx.h @@ -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[]; diff --git a/include/variables.h b/include/variables.h index 826e5605..351349ae 100644 --- a/include/variables.h +++ b/include/variables.h @@ -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 diff --git a/ldscript.txt b/ldscript.txt index e8dba985..81ac9c13 100644 --- a/ldscript.txt +++ b/ldscript.txt @@ -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); @@ -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); diff --git a/src/banim-ekrlvup.c b/src/banim-ekrlvup.c index ae86e891..6c9e03b6 100644 --- a/src/banim-ekrlvup.c +++ b/src/banim-ekrlvup.c @@ -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(); diff --git a/src/banim-ekrtriangle.c b/src/banim-ekrtriangle.c index 561b2d80..3f49f797 100644 --- a/src/banim-ekrtriangle.c +++ b/src/banim-ekrtriangle.c @@ -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) @@ -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) @@ -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) @@ -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(); @@ -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); } diff --git a/src/banim-ekrutils.c b/src/banim-ekrutils.c index f643010f..17b434c7 100644 --- a/src/banim-ekrutils.c +++ b/src/banim-ekrutils.c @@ -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) @@ -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) diff --git a/src/classchg-sel.c b/src/classchg-sel.c index d8c524de..4eafd4f0 100644 --- a/src/classchg-sel.c +++ b/src/classchg-sel.c @@ -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(); diff --git a/src/code_80AE86C.c b/src/code_80AE86C.c index 3b758a44..0ee5bd88 100644 --- a/src/code_80AE86C.c +++ b/src/code_80AE86C.c @@ -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) { diff --git a/src/scene.c b/src/scene.c index cd3acc56..b4067040 100644 --- a/src/scene.c +++ b/src/scene.c @@ -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!!! @@ -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[]; diff --git a/src/sprite-animfx.c b/src/sprite-animfx.c new file mode 100644 index 00000000..dc830a1c --- /dev/null +++ b/src/sprite-animfx.c @@ -0,0 +1,60 @@ +#include "global.h" +#include "proc.h" +#include "ap.h" +#include "ctc.h" +#include "sprite-animfx.h" + +struct ProcCmd CONST_DATA ProcScr_EventSpriteAnim[] = +{ + PROC_SLEEP(0), + + PROC_SET_END_CB(EventSpriteAnim_End), + + PROC_CALL(EventSpriteAnim_Init), + PROC_REPEAT(EventSpriteAnim_Loop), + + PROC_END, +}; + +void EventSpriteAnim_Init(struct ProcEventSpriteAnim * proc) +{ + int x = proc->x - gBmSt.camera.x + 8; + int y = proc->y - gBmSt.camera.y + 8; + const struct EventSpriteAnimConf * priv = proc->priv; + + proc->approc = StartSpriteAnimfx( + priv->img, + priv->pal, + priv->ap_conf, + OAM1_X(x), + OAM0_Y(y) + priv->oam0, + 0, + priv->pal_bank, + priv->pal_size, + priv->oam2, + 4 + ); +} + +void EventSpriteAnim_Loop(struct ProcEventSpriteAnim * proc) +{ + struct Proc * approc = proc->approc; + if (approc->proc_script != NULL) + { + int x = proc->x - gBmSt.camera.x + 8; + int y = proc->y - gBmSt.camera.y + 8; + + APProc_SetParameters((ProcPtr)approc, OAM1_X(x), OAM0_Y(y), -1); + } + else + { + Proc_Break(proc); + proc->approc = NULL; + } +} + +void EventSpriteAnim_End(struct ProcEventSpriteAnim * proc) +{ + if (proc->approc != NULL) + APProc_Delete(proc->approc); +} diff --git a/sym_ewram.txt b/sym_ewram.txt index 2d94957b..1666b596 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -160,11 +160,11 @@ . = 0x017778; gpProcEfxSpellCast = .; . = 0x01777C; gpProcEfxHPBarColorChange = .; . = 0x017780; gEkrHitEfxBool = .; -. = 0x017790; gEkrBuf1 = .; +. = 0x017790; gSpellAnimBgfx = .; . = 0x019490; gEkrBarfxBuf = .; . = 0x019790; gEkrTsaBuffer = .; . = 0x019D00; gUnknown_02019D00 = .; -. = 0x01A790; gEkrBuf2 = .; +. = 0x01A790; gSpellAnimObjfx = .; . = 0x01AFC0; gFont_0201AFC0 = .; . = 0x01AFF0; gUnknown_0201AFF0 = .; . = 0x01B0D8; gUnknown_0201B0D8 = .;