From f7ebd8c0980ab09d02f25b69ab519f7e9df87011 Mon Sep 17 00:00:00 2001 From: MokhaLeee Date: Fri, 7 Oct 2022 00:44:48 +0800 Subject: [PATCH] (minfx) complete --- asm/minefx.s | 83 -------------------------------- data/data_59B358.s | 12 ----- data/data_59E8E0.s | 12 ++--- include/constants/video-global.h | 2 + include/functions.h | 4 +- include/variables.h | 9 ++-- ldscript.txt | 3 +- src/bmusemind.c | 4 +- src/minefx.c | 48 ++++++++++++++++++ 9 files changed, 67 insertions(+), 110 deletions(-) delete mode 100644 asm/minefx.s create mode 100644 src/minefx.c diff --git a/asm/minefx.s b/asm/minefx.s deleted file mode 100644 index f9588c0a..00000000 --- a/asm/minefx.s +++ /dev/null @@ -1,83 +0,0 @@ - .INCLUDE "macro.inc" - - .SYNTAX UNIFIED - - @ Map effect happening when a mine is being set - - THUMB_FUNC_START sub_80222E0 -sub_80222E0: @ 0x080222E0 - push {lr} - ldr r0, _080222F8 @ gRAMChapterData - adds r0, #0x41 - ldrb r0, [r0] - lsls r0, r0, #0x1e - cmp r0, #0 - blt _080222F4 - ldr r0, _080222FC @ 0x000002F9 - bl m4aSongNumStart -_080222F4: - pop {r0} - bx r0 - .align 2, 0 -_080222F8: .4byte gRAMChapterData -_080222FC: .4byte 0x000002F9 - - THUMB_FUNC_END sub_80222E0 - - THUMB_FUNC_START sub_8022300 -sub_8022300: @ 0x08022300 - push {r4, r5, r6, lr} - sub sp, #8 - adds r4, r0, #0 - adds r5, r1, #0 - adds r6, r2, #0 - lsls r0, r5, #4 - ldr r2, _08022364 @ gGameState - movs r3, #0xc - ldrsh r1, [r2, r3] - subs r0, r0, r1 - adds r5, r0, #0 - adds r5, #8 - lsls r0, r6, #4 - movs r3, #0xe - ldrsh r1, [r2, r3] - subs r0, r0, r1 - adds r6, r0, #4 - adds r0, r4, #0 - movs r1, #0x20 - bl NewBlockingTimer - ldr r0, _08022368 @ gUnknown_085A7CC0 - ldr r1, _0802236C @ 0x06013000 - bl CopyDataWithPossibleUncomp - ldr r0, _08022370 @ gUnknown_085A7EC8 - movs r1, #0xa8 - lsls r1, r1, #2 - movs r2, #0x20 - bl CopyToPaletteBuffer - ldr r0, _08022374 @ gUnknown_085A7E34 - movs r3, #0xa3 - lsls r3, r3, #7 - movs r1, #0 - str r1, [sp] - str r1, [sp, #4] - adds r1, r5, #0 - adds r2, r6, #0 - bl APProc_Create - ldr r0, _08022378 @ gUnknown_0859B560 - adds r1, r4, #0 - bl Proc_Start - add sp, #8 - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 -_08022364: .4byte gGameState -_08022368: .4byte gUnknown_085A7CC0 -_0802236C: .4byte 0x06013000 -_08022370: .4byte gUnknown_085A7EC8 -_08022374: .4byte gUnknown_085A7E34 -_08022378: .4byte gUnknown_0859B560 - - THUMB_FUNC_END sub_8022300 - -.align 2, 0 diff --git a/data/data_59B358.s b/data/data_59B358.s index a488cb0d..bdd27438 100644 --- a/data/data_59B358.s +++ b/data/data_59B358.s @@ -1,17 +1,5 @@ .section .data - .global gUnknown_0859B560 -gUnknown_0859B560: @ 0x0859B560 - @ PROC_SLEEP - .short 0xe, 0x18 - .word 0x0 - @ PROC_CALL - .short 0x2, 0x0 - .word sub_80222E0 - @ PROC_END - .short 0x0, 0x0 - .word 0x0 - .global gUnknown_0859B578 gUnknown_0859B578: @ 0x0859B578 diff --git a/data/data_59E8E0.s b/data/data_59E8E0.s index 9a7c2a9e..94e59326 100644 --- a/data/data_59E8E0.s +++ b/data/data_59E8E0.s @@ -272,16 +272,16 @@ Tsa_DanceringFx: @ 0x085A7A64 Pal_DanceringFx: @ 0x085A7CA0 .incbin "baserom.gba", 0x5A7CA0, 0x20 - .global gUnknown_085A7CC0 -gUnknown_085A7CC0: @ 0x085A7CC0 + .global Img_MineFx +Img_MineFx: @ 0x085A7CC0 .incbin "baserom.gba", 0x5A7CC0, 0x174 - .global gUnknown_085A7E34 -gUnknown_085A7E34: @ 0x085A7E34 + .global SpritAnim_MineFx +SpritAnim_MineFx: @ 0x085A7E34 .incbin "baserom.gba", 0x5A7E34, 0x94 - .global gUnknown_085A7EC8 -gUnknown_085A7EC8: @ 0x085A7EC8 + .global Pal_MineFx +Pal_MineFx: @ 0x085A7EC8 .incbin "baserom.gba", 0x5A7EC8, 0x20 .global gUnknown_085A7EE8 diff --git a/include/constants/video-global.h b/include/constants/video-global.h index 8b5564da..4c1a4fa9 100644 --- a/include/constants/video-global.h +++ b/include/constants/video-global.h @@ -107,6 +107,7 @@ enum OBJCHR_TRAPFX = 0x240, OBJCHR_EMITSTARTS = 0x200, + OBJCHR_MINEFX = 0x180, OBJCHR_TRADEMENU_240 = 0x240, @@ -131,6 +132,7 @@ enum OBJPAL_1 = 1, OBJPAL_TRAPFX = 2, + OBJPAL_MINEFX = 0x15, OBJPAL_STATUSHEAL_UNITSPRITE = 2, diff --git a/include/functions.h b/include/functions.h index 83c35fee..f0b4f85c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -940,8 +940,8 @@ void StartDanceringAnim(ProcPtr parent); // ??? StartEmitStarsAnim(???); // ??? ClearEmitedStars(???); // ??? EndEmitStars(???); -// ??? sub_80222E0(???); -// ??? sub_8022300(???); +// ??? ProcMineFxFunc(???); +// ??? StartMineAnim(???); // ??? sub_802237C(???); // ??? sub_80224EC(???); // ??? sub_8022528(???); diff --git a/include/variables.h b/include/variables.h index 304b099f..215b097f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1449,7 +1449,7 @@ extern u16 CONST_DATA obj_0859AEC8[]; // extern ??? ProcScr_EmitSingleStar // extern ??? ProcScr_EmitStars // extern ??? Img_EmitedStar -// extern ??? gUnknown_0859B560 +// extern ??? ProcScr_MineFx // extern ??? gUnknown_0859B668 // extern ??? gUnknown_0859B66C // extern ??? gUnknown_0859B67C @@ -1589,9 +1589,10 @@ extern u16 CONST_DATA Img_DanceringFx[]; extern u16 CONST_DATA Tsa_DanceringFx[]; extern u16 CONST_DATA Pal_DanceringFx[]; -// extern ??? gUnknown_085A7CC0 -// extern ??? gUnknown_085A7E34 -// extern ??? gUnknown_085A7EC8 +extern u16 CONST_DATA Img_MineFx[]; +extern u16 CONST_DATA SpritAnim_MineFx[]; +extern u16 CONST_DATA Pal_MineFx[]; + // extern ??? gUnknown_085A7EE8 // extern ??? gProcScr_CpPhase // extern ??? gProcScr_BerserkCpPhase diff --git a/ldscript.txt b/ldscript.txt index 45297959..c92a56a6 100644 --- a/ldscript.txt +++ b/ldscript.txt @@ -81,7 +81,7 @@ SECTIONS src/eventwarpfx.o(.text); src/whitecircularfadefx.o(.text); src/emitstarfx.o(.text); - asm/minefx.o(.text); + src/minefx.o(.text); asm/chapterintrofx_title.o(.text); src/bmmenu.o(.text); src/bmphase.o(.text); @@ -306,6 +306,7 @@ SECTIONS . = ALIGN(4); src/eventwarpfx.o(.data); . = ALIGN(4); src/whitecircularfadefx.o(.data); . = ALIGN(4); src/emitstarfx.o(.data); + . = ALIGN(4); src/minefx.o(.data); . = ALIGN(4); data/data_59B358.o(.data); . = ALIGN(4); src/bmmenu.o(.data); . = ALIGN(4); data/data_59B668.o(.data); diff --git a/src/bmusemind.c b/src/bmusemind.c index 5a1159d3..eecaba8c 100644 --- a/src/bmusemind.c +++ b/src/bmusemind.c @@ -60,7 +60,7 @@ void StartLightRuneAnim(ProcPtr, int, int); void StartLightRuneAnim2(ProcPtr, int, int); // minefx.s -void sub_8022300(ProcPtr, int, int); +void StartMineAnim(ProcPtr, int, int); // ev_triggercheck.s void sub_80831C8(s8, s8); @@ -818,7 +818,7 @@ void ExecMine(ProcPtr proc) { gBattleTarget.statusOut = -1; - sub_8022300(proc, gActionData.xOther, gActionData.yOther); + StartMineAnim(proc, gActionData.xOther, gActionData.yOther); return; } diff --git a/src/minefx.c b/src/minefx.c new file mode 100644 index 00000000..fe0841b9 --- /dev/null +++ b/src/minefx.c @@ -0,0 +1,48 @@ +#include "global.h" +#include "functions.h" +#include "variables.h" +#include "hardware.h" +#include "proc.h" +#include "hardware.h" +#include "constants/video-global.h" +#include "bmfx.h" +#include "ap.h" +#include "soundwrapper.h" + +/** + * Map effect happening when a mine is being set + */ + +struct ProcMineFx { + PROC_HEADER; + + /* 29 */ u8 _pad_29[0x41 - 0x29]; + + /* 41 */ s16 counter; +}; + +void ProcMineFxFunc(struct ProcMineFx *proc); + +struct ProcCmd CONST_DATA ProcScr_MineFx[] = { + PROC_SLEEP(0x18), + PROC_CALL(ProcMineFxFunc), + PROC_END +}; + + +void ProcMineFxFunc(struct ProcMineFx *proc) +{ + PlaySoundEffect(0x2F9); +} + +void StartMineAnim(ProcPtr parent, int x, int y) +{ + x = x * 0x10 - gGameState.camera.x + 8; + y = y * 0x10 - gGameState.camera.y + 4; + + NewBlockingTimer(parent, 0x20); + CopyDataWithPossibleUncomp(Img_MineFx, OBJ_CHR_ADDR(OBJCHR_MINEFX)); + ApplyPalette(Pal_MineFx, OBJPAL_MINEFX); + APProc_Create(SpritAnim_MineFx, x, y, 0x5180, 0, 0); + Proc_Start(ProcScr_MineFx, parent); +} \ No newline at end of file