From a0e44eeaf1d31081a0269de9180f37c5531ae024 Mon Sep 17 00:00:00 2001 From: MokhaLeee Date: Thu, 7 Mar 2024 09:24:21 +0000 Subject: [PATCH] ekrdragon in process --- asm/banim-ekrdragon.s | 48 ------- include/efxbattle.h | 4 +- include/ekrdragon.h | 6 +- ldscript.txt | 1 + src/banim-ekrdragon-8070710.c | 66 ++++++++++ src/banim-ekrdragon-utils.c | 238 +++------------------------------- src/banim-main.c | 36 +++-- 7 files changed, 114 insertions(+), 285 deletions(-) create mode 100644 src/banim-ekrdragon-8070710.c diff --git a/asm/banim-ekrdragon.s b/asm/banim-ekrdragon.s index f7a11929..5bc0dbd3 100644 --- a/asm/banim-ekrdragon.s +++ b/asm/banim-ekrdragon.s @@ -191,51 +191,3 @@ _08070866: _08070870: .4byte gPaletteBuffer+0xC0 THUMB_FUNC_END sub_80707FC - - THUMB_FUNC_START sub_8070874 -sub_8070874: @ 0x08070874 - push {lr} - bl GetBanimDragonStatusType - cmp r0, #0 - beq _08070898 - bl GetBanimDragonStatusType - cmp r0, #3 - beq _08070898 - ldr r0, _0807089C @ ProcScr_EkrDragon_08758720 - bl Proc_EndEach - movs r0, #0 - bl SetEkrDragonPaletteFront - movs r0, #0 - bl SetEkrDragonPaletteBack -_08070898: - pop {r0} - bx r0 - .align 2, 0 -_0807089C: .4byte ProcScr_EkrDragon_08758720 - - THUMB_FUNC_END sub_8070874 - - THUMB_FUNC_START sub_80708A0 -sub_80708A0: @ 0x080708A0 - push {lr} - bl GetBanimDragonStatusType - cmp r0, #0 - beq _080708BE - bl GetBanimDragonStatusType - cmp r0, #3 - beq _080708BE - ldr r0, _080708C4 @ ProcScr_EkrDragon_08758720 - movs r1, #3 - bl Proc_Start - ldr r1, _080708C8 @ gUnknown_08758740 - str r1, [r0, #0x38] -_080708BE: - pop {r0} - bx r0 - .align 2, 0 -_080708C4: .4byte ProcScr_EkrDragon_08758720 -_080708C8: .4byte gUnknown_08758740 - - THUMB_FUNC_END sub_80708A0 - -.align 2, 0 diff --git a/include/efxbattle.h b/include/efxbattle.h index 536781f1..4a8a272b 100644 --- a/include/efxbattle.h +++ b/include/efxbattle.h @@ -2402,8 +2402,8 @@ extern u32 AnimScr_EfxLokmsunaObjRight[]; extern struct ProcCmd ProcScr_EkrDracoZombie[]; extern struct ProcCmd ProcScr_ekrDragonQuake[]; extern struct ProcCmd ProcScr_ekrWhiteINOUT[]; -// extern ??? ProcScr_EkrDragon_08758720 -// extern ??? gUnknown_08758740 +extern struct ProcCmd ProcScr_EkrDragon_08758720[]; +extern u16 gUnknown_08758740[]; // extern ??? ProcScr_EkrMyrrh extern struct ProcCmd ProcScr_EkrMyrrh[]; extern s16 gUnknown_0875879C[]; diff --git a/include/ekrdragon.h b/include/ekrdragon.h index c7bfd2e6..5f08c603 100644 --- a/include/ekrdragon.h +++ b/include/ekrdragon.h @@ -606,9 +606,9 @@ bool CheckEkrDragonDead(struct Anim *anim); bool CheckEkrDragonRefrain(struct Anim *anim); void InitEkrDragonStatus(void); void sub_807027C(struct Anim *anim); -u16 *GetEkrDragonPalette(void); -// ??? SetEkrDragonPaletteBack(???); -// ??? SetEkrDragonPaletteFront(???); +u16 * GetEkrDragonPalette(void); +void SetEkrDragonPaletteBack(int pos); +void SetEkrDragonPaletteFront(int pos); void BanimSetFrontPaletteForDragon(struct Anim *anim); void NewEkrDragonQuakeTree3(struct EkrDragonQuakePriv *priv, int, int); void NewEkrDragonQuake(struct EkrDragonQuakePriv *priv, int, int, ProcPtr); diff --git a/ldscript.txt b/ldscript.txt index 0da723a8..ed7719c9 100644 --- a/ldscript.txt +++ b/ldscript.txt @@ -470,6 +470,7 @@ SECTIONS src/banim-ekrdragon-dracozombie.o(.text); src/banim-ekrdragon-utils.o(.text); asm/banim-ekrdragon.o(.text); + src/banim-ekrdragon-8070710.o(.text); src/banim-ekrdragon-myrrh.o(.text); src/banim-efxutils.o(.text); src/banim-efxsound.o(.text); diff --git a/src/banim-ekrdragon-8070710.c b/src/banim-ekrdragon-8070710.c new file mode 100644 index 00000000..cd6485c0 --- /dev/null +++ b/src/banim-ekrdragon-8070710.c @@ -0,0 +1,66 @@ +#include "global.h" +#include "proc.h" +#include "hardware.h" +#include "ekrbattle.h" +#include "efxbattle.h" +#include "ekrdragon.h" + +struct ProcEkrDragon_08758720 { + PROC_HEADER; + + STRUCT_PAD(0x29, 0x2C); + + /* 2C */ int unk2C; + /* 30 */ int unk30; + /* 34 */ u16 * unk34; + /* 38 */ const u16 * unk38; + /* 3C */ u8 unk3C; + /* 3D */ u8 unk3D; +}; + +void sub_8070710(u16 * a, u16 * paldst, u16 c, u16 d, u16 e); + +#if 0 +void sub_80707FC(struct ProcEkrDragon_08758720 * proc) +{ + sub_8070710(proc->unk34, + (void *)gPaletteBuffer + 0xC0 + proc->unk3D, + proc->unk38[proc->unk30], + proc->unk3C, + proc->unk3D); + + sub_8070710(proc->unk34, + (void *)gPaletteBuffer + 0x2E0 + proc->unk3D, + proc->unk38[proc->unk30], + proc->unk3C, + proc->unk3D); + + EnablePaletteSync(); + + proc->unk2C++; + proc->unk30++; + + if (proc->unk38[proc->unk30] == 0x8000) + proc->unk30 = 0; +} +#endif + +void sub_8070874(void) +{ + if (GetBanimDragonStatusType() != EKRDRGON_TYPE_NORMAL && GetBanimDragonStatusType() != EKRDRGON_TYPE_MYRRH) + { + Proc_EndEach(ProcScr_EkrDragon_08758720); + SetEkrDragonPaletteFront(POS_L); + SetEkrDragonPaletteBack(POS_L); + } +} + +void sub_80708A0(void) +{ + if (GetBanimDragonStatusType() != EKRDRGON_TYPE_NORMAL && GetBanimDragonStatusType() != EKRDRGON_TYPE_MYRRH) + { + struct ProcEkrDragon_08758720 * proc; + proc = Proc_Start(ProcScr_EkrDragon_08758720, PROC_TREE_3); + proc->unk38 = gUnknown_08758740; + } +} diff --git a/src/banim-ekrdragon-utils.c b/src/banim-ekrdragon-utils.c index d75b4a2e..b1162e81 100644 --- a/src/banim-ekrdragon-utils.c +++ b/src/banim-ekrdragon-utils.c @@ -145,8 +145,6 @@ void NewEkrDragonQuake(struct EkrDragonQuakePriv *priv, int b, int c, ProcPtr pa proc->unk2E = b; } -/* https://decomp.me/scratch/kpj5y */ -#if NONMATCHING void EkrDragonQuakeMain(struct ProcEkrDragonQuake * proc) { s16 x1, y1; @@ -154,21 +152,23 @@ void EkrDragonQuakeMain(struct ProcEkrDragonQuake * proc) struct EkrDragonQuakePriv * priv = proc->priv; - BG_SetPosition(BG_2, gEkrBg2QuakeVec.x, gEkrBg2QuakeVec.y); - BG_SetPosition( - BG_0, - gEkrBg2QuakeVec.x + gEkrBg0QuakeVec.x, - gEkrBg2QuakeVec.y + gEkrBg0QuakeVec.y); - - EkrGauge_Setxy323A( - -(gEkrBg2QuakeVec.x + gEkrBg0QuakeVec.x), - -(gEkrBg2QuakeVec.y + gEkrBg0QuakeVec.y)); - - EkrDispUP_SetPositionSync( - -(gEkrBg2QuakeVec.x + gEkrBg0QuakeVec.x), - -(gEkrBg2QuakeVec.y + gEkrBg0QuakeVec.y)); - - BG_SetPosition(BG_3, gEkrBg2QuakeVec.x, gEkrBg2QuakeVec.y); + do { + BG_SetPosition(BG_2, gEkrBg2QuakeVec.x, gEkrBg2QuakeVec.y); + BG_SetPosition( + BG_0, + gEkrBg2QuakeVec.x + gEkrBg0QuakeVec.x, + gEkrBg2QuakeVec.y + gEkrBg0QuakeVec.y); + + EkrGauge_Setxy323A( + -(gEkrBg2QuakeVec.x + gEkrBg0QuakeVec.x), + -(gEkrBg2QuakeVec.y + gEkrBg0QuakeVec.y)); + + EkrDispUP_SetPositionSync( + -(gEkrBg2QuakeVec.x + gEkrBg0QuakeVec.x), + -(gEkrBg2QuakeVec.y + gEkrBg0QuakeVec.y)); + + BG_SetPosition(BG_3, gEkrBg2QuakeVec.x, gEkrBg2QuakeVec.y); + } while (0); x1 = (gEkrXPosReal[POS_L] - gEkrBg2QuakeVec.x) - gEkrBgPosition; y1 = gEkrYPosReal[POS_L] - gEkrBg2QuakeVec.y; @@ -213,210 +213,6 @@ void EkrDragonQuakeMain(struct ProcEkrDragonQuake * proc) } } -#else - -NAKEDFUNC -void EkrDragonQuakeMain(struct ProcEkrDragonQuake * proc) -{ -asm("\ - .syntax unified\n\ - push {r4, r5, r6, r7, lr}\n\ - mov r7, sl\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5, r6, r7}\n\ - mov sl, r0\n\ - ldr r0, [r0, #0x5c]\n\ - mov r9, r0\n\ - ldr r4, _08070554 @ gEkrBg2QuakeVec\n\ - ldrh r1, [r4]\n\ - ldrh r2, [r4, #2]\n\ - movs r0, #2\n\ - bl BG_SetPosition\n\ - ldr r6, _08070558 @ gEkrBg0QuakeVec\n\ - ldrh r1, [r6]\n\ - ldrh r2, [r4]\n\ - adds r1, r1, r2\n\ - lsls r1, r1, #0x10\n\ - lsrs r1, r1, #0x10\n\ - ldrh r2, [r6, #2]\n\ - ldrh r3, [r4, #2]\n\ - adds r2, r2, r3\n\ - lsls r2, r2, #0x10\n\ - lsrs r2, r2, #0x10\n\ - movs r0, #0\n\ - bl BG_SetPosition\n\ - ldrh r0, [r6]\n\ - ldrh r7, [r4]\n\ - adds r0, r0, r7\n\ - negs r0, r0\n\ - lsls r0, r0, #0x10\n\ - asrs r0, r0, #0x10\n\ - ldrh r1, [r6, #2]\n\ - ldrh r2, [r4, #2]\n\ - adds r1, r1, r2\n\ - negs r1, r1\n\ - lsls r1, r1, #0x10\n\ - asrs r1, r1, #0x10\n\ - bl EkrGauge_Setxy323A\n\ - ldrh r0, [r6]\n\ - ldrh r3, [r4]\n\ - adds r0, r0, r3\n\ - negs r0, r0\n\ - lsls r0, r0, #0x10\n\ - lsrs r0, r0, #0x10\n\ - ldrh r1, [r6, #2]\n\ - ldrh r7, [r4, #2]\n\ - adds r1, r1, r7\n\ - negs r1, r1\n\ - lsls r1, r1, #0x10\n\ - lsrs r1, r1, #0x10\n\ - bl EkrDispUP_SetPositionSync\n\ - ldrh r1, [r4]\n\ - ldrh r2, [r4, #2]\n\ - movs r0, #3\n\ - bl BG_SetPosition\n\ - ldr r0, _0807055C @ gEkrXPosReal\n\ - ldrh r1, [r0]\n\ - ldrh r0, [r4]\n\ - subs r1, r1, r0\n\ - ldr r2, _08070560 @ gEkrBgPosition\n\ - ldr r5, [r2]\n\ - subs r1, r1, r5\n\ - lsls r1, r1, #0x10\n\ - ldr r3, _08070564 @ gEkrYPosReal\n\ - ldrh r2, [r3]\n\ - ldrh r3, [r4, #2]\n\ - subs r2, r2, r3\n\ - lsls r2, r2, #0x10\n\ - ldr r4, _0807055C @ gEkrXPosReal\n\ - ldrh r4, [r4, #2]\n\ - adds r0, r0, r4\n\ - subs r0, r0, r5\n\ - lsls r0, r0, #0x10\n\ - lsrs r5, r0, #0x10\n\ - ldr r7, _08070564 @ gEkrYPosReal\n\ - ldrh r0, [r7, #2]\n\ - subs r0, r0, r3\n\ - lsls r0, r0, #0x10\n\ - lsrs r4, r0, #0x10\n\ - lsrs r0, r1, #0x10\n\ - mov r8, r0\n\ - asrs r1, r1, #0x10\n\ - lsrs r7, r2, #0x10\n\ - asrs r2, r2, #0x10\n\ - movs r0, #0\n\ - bl SetEkrFrontAnimPostion\n\ - lsls r1, r5, #0x10\n\ - asrs r1, r1, #0x10\n\ - lsls r2, r4, #0x10\n\ - asrs r2, r2, #0x10\n\ - movs r0, #1\n\ - bl SetEkrFrontAnimPostion\n\ - mov r1, r9\n\ - cmp r1, #0\n\ - beq _08070498\n\ - mov r2, r8\n\ - strh r2, [r1, #0x32]\n\ - strh r7, [r1, #0x3a]\n\ -_08070498:\n\ - mov r3, sl\n\ - ldrh r0, [r3, #0x2c]\n\ - adds r0, #1\n\ - strh r0, [r3, #0x2c]\n\ - lsls r0, r0, #0x10\n\ - asrs r0, r0, #0x10\n\ - movs r4, #0x2e\n\ - ldrsh r1, [r3, r4]\n\ - cmp r0, r1\n\ - ble _08070544\n\ - movs r0, #2\n\ - movs r1, #0\n\ - movs r2, #0\n\ - bl BG_SetPosition\n\ - ldrh r1, [r6]\n\ - ldrh r2, [r6, #2]\n\ - movs r0, #0\n\ - bl BG_SetPosition\n\ - ldrh r0, [r6]\n\ - negs r0, r0\n\ - lsls r0, r0, #0x10\n\ - asrs r0, r0, #0x10\n\ - ldrh r1, [r6, #2]\n\ - negs r1, r1\n\ - lsls r1, r1, #0x10\n\ - asrs r1, r1, #0x10\n\ - bl EkrGauge_Setxy323A\n\ - ldrh r0, [r6]\n\ - negs r0, r0\n\ - lsls r0, r0, #0x10\n\ - lsrs r0, r0, #0x10\n\ - ldrh r1, [r6, #2]\n\ - negs r1, r1\n\ - lsls r1, r1, #0x10\n\ - lsrs r1, r1, #0x10\n\ - bl EkrDispUP_SetPositionSync\n\ - movs r0, #3\n\ - movs r1, #0\n\ - movs r2, #0\n\ - bl BG_SetPosition\n\ - ldr r7, _08070560 @ gEkrBgPosition\n\ - ldr r2, [r7]\n\ - ldr r0, _0807055C @ gEkrXPosReal\n\ - ldrh r1, [r0]\n\ - subs r1, r1, r2\n\ - lsls r1, r1, #0x10\n\ - ldrh r0, [r0, #2]\n\ - subs r0, r0, r2\n\ - lsls r0, r0, #0x10\n\ - lsrs r5, r0, #0x10\n\ - ldr r2, _08070564 @ gEkrYPosReal\n\ - ldrh r4, [r2, #2]\n\ - lsrs r3, r1, #0x10\n\ - mov r8, r3\n\ - asrs r1, r1, #0x10\n\ - ldrh r7, [r2]\n\ - movs r0, #0\n\ - ldrsh r2, [r2, r0]\n\ - movs r0, #0\n\ - bl SetEkrFrontAnimPostion\n\ - lsls r1, r5, #0x10\n\ - asrs r1, r1, #0x10\n\ - lsls r2, r4, #0x10\n\ - asrs r2, r2, #0x10\n\ - movs r0, #1\n\ - bl SetEkrFrontAnimPostion\n\ - mov r1, r9\n\ - cmp r1, #0\n\ - beq _08070536\n\ - mov r2, r8\n\ - strh r2, [r1, #0x32]\n\ - strh r7, [r1, #0x3a]\n\ -_08070536:\n\ - mov r3, sl\n\ - ldr r0, [r3, #0x60]\n\ - bl Proc_End\n\ - mov r0, sl\n\ - bl Proc_Break\n\ -_08070544:\n\ - pop {r3, r4, r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov sl, r5\n\ - pop {r4, r5, r6, r7}\n\ - pop {r0}\n\ - bx r0\n\ - .align 2, 0\n\ -_08070554: .4byte gEkrBg2QuakeVec\n\ -_08070558: .4byte gEkrBg0QuakeVec\n\ -_0807055C: .4byte gEkrXPosReal\n\ -_08070560: .4byte gEkrBgPosition\n\ -_08070564: .4byte gEkrYPosReal\n\ - .syntax divided\n\ -"); -} -#endif - struct ProcCmd CONST_DATA ProcScr_ekrWhiteINOUT[] = { PROC_NAME("ekrWhiteINOUT"), PROC_REPEAT(EkrWhiteINOUT_Loop1), diff --git a/src/banim-main.c b/src/banim-main.c index cc4ebf2b..1f146e4d 100644 --- a/src/banim-main.c +++ b/src/banim-main.c @@ -274,7 +274,8 @@ void BattleAIS_ExecCommands(void) case ANIM_ROUND_NONCRIT_FAR: case ANIM_ROUND_CRIT_FAR: case ANIM_ROUND_MISS_CLOSE: - if (type != -1) { + if (type != -1) + { anim1->nextRoundId = anim1->nextRoundId + 1; anim2->nextRoundId = anim2->nextRoundId + 1; @@ -315,8 +316,10 @@ void BattleAIS_ExecCommands(void) } #endif - if (gBanimForceUnitChgDebug[GetAnimPosition(anim)] == NULL) { - if (gpImgSheet[GetAnimPosition(anim1)] != anim1->pImgSheet) { + if (gBanimForceUnitChgDebug[GetAnimPosition(anim)] == NULL) + { + if (gpImgSheet[GetAnimPosition(anim1)] != anim1->pImgSheet) + { NewEkrChienCHR(anim1); gpImgSheet[GetAnimPosition(anim1)] = anim1->pImgSheet; } @@ -697,9 +700,11 @@ void BattleAIS_ExecCommands(void) if (!(type & ANIM_BIT2_STOP) && gCtrlC01Blocking != 1) continue; - if (anim->state3 & ANIM_BIT3_NEXT_ROUND_START) { + if (anim->state3 & ANIM_BIT3_NEXT_ROUND_START) + { type = GetAnimNextRoundType(anim); - if (type != ANIM_ROUND_INVALID) { + if (type != ANIM_ROUND_INVALID) + { anim1 = gAnims[GetAnimPosition(anim) * 2]; SwitchAISFrameDataFromBARoundType(anim1, type); anim1->state3 &= ~ANIM_BIT3_NEXT_ROUND_START; @@ -715,17 +720,23 @@ void BattleAIS_ExecCommands(void) AnimScrAdvance(anim1); AnimScrAdvance(anim2); - } else { + } + else + { anim1 = gAnims[GetAnimPosition(anim) * 2 + 0]; anim1->state3 &= ~ANIM_BIT3_NEXT_ROUND_START; anim2 = gAnims[GetAnimPosition(anim) * 2 + 1]; anim2->state3 &= ~ANIM_BIT3_NEXT_ROUND_START; } /* ANIM_ROUND_INVALID */ - } else { - if (anim->state3 & ANIM_BIT3_NEW_ROUND_START) { + } + else + { + if (anim->state3 & ANIM_BIT3_NEW_ROUND_START) + { type = GetAnimNextRoundType(anim); - if (type != ANIM_ROUND_INVALID) { + if (type != ANIM_ROUND_INVALID) + { anim1 = gAnims[GetAnimPosition(anim) * 2]; SwitchAISFrameDataFromBARoundType(anim1, type); anim1->state3 &= ~ANIM_BIT3_NEW_ROUND_START; @@ -742,8 +753,11 @@ void BattleAIS_ExecCommands(void) AnimScrAdvance(anim1); AnimScrAdvance(anim2); } - } else { - if (GetAISLayerId(anim) == 0) { + } + else + { + if (GetAISLayerId(anim) == 0) + { type = GetBattleAnimRoundType(anim->nextRoundId * 2 + GetAnimPosition(anim)); if (type == ANIM_ROUND_INVALID) gBanimDoneFlag[GetAnimPosition(anim)] = 1;