diff --git a/asm/ground_effect.s b/asm/ground_effect.s index 1c501e18b..88c6350c7 100644 --- a/asm/ground_effect.s +++ b/asm/ground_effect.s @@ -5,69 +5,6 @@ .text - thumb_func_start GroundEffect_CancelBlank -GroundEffect_CancelBlank: - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - ldr r1, _080ACD7C - movs r0, 0 - bl Log - movs r6, 0 - ldr r0, _080ACD80 - ldr r4, [r0] - movs r0, 0x1 - negs r0, r0 - mov r8, r0 - movs r1, 0x92 - lsls r1, 1 - adds r5, r4, r1 - mov r7, sp -_080ACD2C: - movs r1, 0x6 - ldrsh r0, [r4, r1] - cmp r0, r8 - beq _080ACD5C - ldr r0, [r5] - ldr r1, [r4, 0x14] - adds r0, r1 - str r0, [sp] - ldr r0, [r5, 0x4] - ldr r1, [r4, 0x18] - adds r0, r1 - str r0, [r7, 0x4] - movs r1, 0xA2 - lsls r1, 1 - adds r0, r4, r1 - mov r1, sp - bl IsOnscreen_80A675C - lsls r0, 24 - cmp r0, 0 - bne _080ACD5C - adds r0, r6, 0 - bl GroundEffect_Delete -_080ACD5C: - adds r0, r6, 0x1 - lsls r0, 16 - asrs r6, r0, 16 - movs r0, 0xE2 - lsls r0, 1 - adds r5, r0 - adds r4, r0 - cmp r6, 0xF - ble _080ACD2C - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080ACD7C: .4byte gUnknown_8118658 -_080ACD80: .4byte gGroundEffects - thumb_func_end GroundEffect_CancelBlank - thumb_func_start sub_80ACD84 sub_80ACD84: push {r4-r7,lr} diff --git a/src/ground_effect.c b/src/ground_effect.c index 337a74de3..0b02de4cf 100644 --- a/src/ground_effect.c +++ b/src/ground_effect.c @@ -1,5 +1,6 @@ #include "global.h" #include "ground_script.h" +#include "ground_sprite.h" #include "debug.h" #include "memory.h" @@ -11,7 +12,13 @@ typedef struct GroundEffect { s16 unk6; s16 unk8; s8 unkA; - u8 fillB[0x1c4 - 0xB]; + u8 fillB[0x14 - 0xB]; + s32 unk14; // some x? + s32 unk18; // some y? + u8 fill1C[0x124 - 0x1C]; + PixelPos unkPixelPos; // 0x124 + u8 fill12C[0x144 - 0x12C]; + struct UnkGroundSpriteStruct unk144; } GroundEffect; IWRAM_INIT GroundEffect* gGroundEffects = NULL; // size 16 array @@ -100,7 +107,7 @@ void GroundEffect_Cancel(s32 scriptID, s32 sector) index = 0; ptr = &gGroundEffects[0]; - for(; index < 0x10; index = (s16)(index + 1), ptr++) + for(; index < 16; index = (s16)(index + 1), ptr++) { if((ptr->unk6 != -1) && (ptr->unk8 == scriptID_s32)) if(sector_s32 < 0 || ptr->unkA == sector_s32) @@ -108,3 +115,28 @@ void GroundEffect_Cancel(s32 scriptID, s32 sector) } } +extern const char gUnknown_8118658[]; + +void GroundEffect_CancelBlank() +{ + s32 index; + GroundEffect *ptr; + PixelPos pos; + + Log(0, gUnknown_8118658); // "GroundEffect CancelBlank" + + index = 0; + ptr = &gGroundEffects[0]; + for (; index < 16; index = (s16)(index + 1), ptr++) + { + if (ptr->unk6 != -1) + { + pos.x = ptr->unkPixelPos.x + ptr->unk14; + pos.y = ptr->unkPixelPos.y + ptr->unk18; + if (!IsOnscreen_80A675C(&ptr->unk144, &pos)) + { + GroundEffect_Delete(index); + } + } + } +}