diff options
| author | octorock <79596758+octorock@users.noreply.github.com> | 2023-12-28 14:59:23 +0100 |
|---|---|---|
| committer | octorock <79596758+octorock@users.noreply.github.com> | 2023-12-28 14:59:23 +0100 |
| commit | 768efa50b308be03737d7eae2a1069627ea48b79 (patch) | |
| tree | 447c266172ef82df68bfd6d4737acb499f2b1a9d /src/projectile/removableDust.c | |
| parent | b6a94d5062076ce53a00609e1e661b9da9e7ee5b (diff) | |
| parent | dae4c669913c3dc4248291f2d843ac39525b2738 (diff) | |
Merge branch 'master' into tilemap-docs
Diffstat (limited to 'src/projectile/removableDust.c')
| -rw-r--r-- | src/projectile/removableDust.c | 107 |
1 files changed, 63 insertions, 44 deletions
diff --git a/src/projectile/removableDust.c b/src/projectile/removableDust.c index 72b10cf4..d7b46a6a 100644 --- a/src/projectile/removableDust.c +++ b/src/projectile/removableDust.c @@ -1,67 +1,81 @@ -#include "entity.h" +/** + * @file removableDust.c + * @ingroup Projectiles + * + * @brief Removable Dust Projectile + */ +#define NENT_DEPRECATED #include "enemy.h" -#include "physics.h" +#include "entity.h" #include "functions.h" #include "object.h" +#include "physics.h" #include "room.h" #include "tiles.h" -extern void (*const RemovableDust_Functions[])(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ EntityData* unk_68; + /*0x6c*/ u8 unused[26]; + /*0x86*/ u16 unk_86; +} RemovableDustEntity; + +extern void (*const RemovableDust_Functions[])(RemovableDustEntity*); extern const u16 gUnk_08129FD0[]; extern const u16 gUnk_08129FE4[]; extern const s8 gUnk_08129FF8[]; extern const u8 gUnk_0812A004[]; -void sub_080AA494(Entity*); +void sub_080AA494(RemovableDustEntity*); void sub_080AA534(Entity*); -void sub_080AA464(Entity*); -void sub_080AA544(Entity*); -void sub_080AA654(Entity*, u32); +void RemovableDust_OnGrabbed(RemovableDustEntity*); +void sub_080AA544(RemovableDustEntity*); +void sub_080AA654(RemovableDustEntity*, u32); -void RemovableDust(Entity* this) { - RemovableDust_Functions[GetNextFunction(this)](this); +void RemovableDust(RemovableDustEntity* this) { + RemovableDust_Functions[GetNextFunction(super)](this); } -void RemovableDust_OnTick(Entity* this) { - if (this->action == 0) { - this->action = 1; - this->frameIndex = this->type; - this->gustJarFlags = 1; - this->speed = this->field_0x86.HWORD; - if (this->type == 0) { +void RemovableDust_OnTick(RemovableDustEntity* this) { + if (super->action == 0) { + super->action = 1; + super->frameIndex = super->type; + super->gustJarFlags = 1; + super->speed = this->unk_86; + if (super->type == 0) { sub_080AA494(this); } else { - sub_080AA534(this); + sub_080AA534(super); } } } -void sub_080AA450(Entity* this) { - if (this->contactFlags == 0x96) { - sub_080AA464(this); +void RemovableDust_OnCollision(RemovableDustEntity* this) { + if (super->contactFlags == 0x96) { + RemovableDust_OnGrabbed(this); } } -void sub_080AA464(Entity* this) { +void RemovableDust_OnGrabbed(RemovableDustEntity* this) { Entity* entity; - if (this->type == 0) { + if (super->type == 0) { sub_080AA544(this); } entity = CreateObject(DIRT_PARTICLE, 3, 0); if (entity != NULL) { - CopyPosition(this, entity); + CopyPosition(super, entity); } - DeleteEntity(this); + DeleteEntity(super); } -void sub_080AA494(Entity* this) { +void sub_080AA494(RemovableDustEntity* this) { u32 tileType; const u16* iterator; u32 index; index = 0; - tileType = GetMetaTileTypeByEntity(this); + tileType = GetMetaTileTypeByEntity(super); iterator = gUnk_08129FD0; while (*iterator != 0) { if (*(iterator++) == tileType) { @@ -69,15 +83,15 @@ void sub_080AA494(Entity* this) { } index++; } - if (CheckFlags((u16)this->speed) != 0) { + if (CheckFlags((u16)super->speed) != 0) { if (index == 4) { - sub_080AA654(this, TILE(this->x.HALF.HI, this->y.HALF.HI)); + sub_080AA654(this, TILE(super->x.HALF.HI, super->y.HALF.HI)); } DeleteThisEntity(); } - this->type2 = index; - this->spritePriority.b0 = 7; - SetMetaTile(SPECIAL_META_TILE_104, TILE(this->x.HALF.HI, this->y.HALF.HI), this->collisionLayer); + super->type2 = index; + super->spritePriority.b0 = 7; + SetMetaTile(SPECIAL_META_TILE_104, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); } void sub_080AA534(Entity* this) { @@ -85,7 +99,7 @@ void sub_080AA534(Entity* this) { UpdateSpriteForCollisionLayer(this); } -void sub_080AA544(Entity* this) { +void sub_080AA544(RemovableDustEntity* this) { u8* pbVar1; s32 vvv; u32 uVar3; @@ -94,13 +108,13 @@ void sub_080AA544(Entity* this) { u32 param; const s8* tmp; - if (this->type2 < 9) { + if (super->type2 < 9) { tmp = gUnk_08129FF8; - param = TILE(this->x.HALF.HI, this->y.HALF.HI) + tmp[this->type2]; + param = TILE(super->x.HALF.HI, super->y.HALF.HI) + tmp[super->type2]; uVar3 = 0; iVar4 = 0; do { - vvv = GetVvvAtMetaTilePos((param - tmp[uVar3]) & 0xffff, this->collisionLayer); + vvv = GetVvvAtMetaTilePos((param - tmp[uVar3]) & 0xffff, super->collisionLayer); if (vvv == VVV_62) { iVar4++; } @@ -111,24 +125,24 @@ void sub_080AA544(Entity* this) { uVar3 = 0; puVar5 = gUnk_08129FD0; do { - sub_0807B7D8((u32)*puVar5, param - tmp[uVar3], this->collisionLayer); + sub_0807B7D8((u32)*puVar5, param - tmp[uVar3], super->collisionLayer); puVar5++; uVar3++; } while (uVar3 < 9); sub_080AA654(this, param); - SetFlag((u16)this->speed); + SetFlag((u16)super->speed); } else { - sub_0807B7D8(gUnk_08129FE4[this->type2], param - tmp[this->type2], this->collisionLayer); + sub_0807B7D8(gUnk_08129FE4[super->type2], param - tmp[super->type2], super->collisionLayer); } } else { - RestorePrevTileEntity(TILE(this->x.HALF.HI, this->y.HALF.HI), this->collisionLayer); - SetFlag((u16)this->speed); + RestorePrevTileEntity(TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); + SetFlag((u16)super->speed); } } -void sub_080AA654(Entity* this, u32 param) { +void sub_080AA654(RemovableDustEntity* this, u32 param) { EntityData* entityData; - entityData = (EntityData*)&this->field_0x68; + entityData = (EntityData*)&this->unk_68; MemCopy(&gUnk_0812A004, entityData, 0x10); @@ -138,8 +152,13 @@ void sub_080AA654(Entity* this, u32 param) { LoadRoomEntity(entityData); } -void (*const RemovableDust_Functions[])(Entity*) = { - RemovableDust_OnTick, sub_080AA450, DeleteEntity, DeleteEntity, DeleteEntity, sub_080AA464, +void (*const RemovableDust_Functions[])(RemovableDustEntity*) = { + RemovableDust_OnTick, + RemovableDust_OnCollision, + (void (*)(RemovableDustEntity*))DeleteEntity, + (void (*)(RemovableDustEntity*))DeleteEntity, + (void (*)(RemovableDustEntity*))DeleteEntity, + RemovableDust_OnGrabbed, }; const u16 gUnk_08129FD0[] = { 387, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 0 }; const u16 gUnk_08129FE4[] = { 388, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 0 }; |
