diff options
| author | octorock <79596758+octorock@users.noreply.github.com> | 2022-02-22 09:17:17 +0100 |
|---|---|---|
| committer | octorock <79596758+octorock@users.noreply.github.com> | 2022-03-06 00:31:54 +0100 |
| commit | abb02729633091d8f02efda99a9cbb8b71674e89 (patch) | |
| tree | e7f9996a5569a24e648efab90651983af902e165 /src | |
| parent | 6206ff831a25330b1887d4d8cfa8435166fe7fa8 (diff) | |
Decompile rest of objectUtils
Diffstat (limited to 'src')
| -rw-r--r-- | src/enemy/bladeTrap.c | 4 | ||||
| -rw-r--r-- | src/enemy/bombarossa.c | 4 | ||||
| -rw-r--r-- | src/enemy/lakituCloud.c | 2 | ||||
| -rw-r--r-- | src/object/lavaPlatform.c | 6 | ||||
| -rw-r--r-- | src/object/lightableSwitch.c | 4 | ||||
| -rw-r--r-- | src/object/lilypadSmall.c | 6 | ||||
| -rw-r--r-- | src/objectUtils.c | 144 |
7 files changed, 152 insertions, 18 deletions
diff --git a/src/enemy/bladeTrap.c b/src/enemy/bladeTrap.c index f5531def..d534242a 100644 --- a/src/enemy/bladeTrap.c +++ b/src/enemy/bladeTrap.c @@ -14,7 +14,7 @@ void BladeTrap(Entity* this) { if (this->action == 0) { this->action = 1; this->child = GetCurrentRoomProperty(this->type); - sub_080A2CC0(this, &this->child, &this->field_0x74.HWORD); + sub_080A2CC0(this, (u16**)&this->child, &this->field_0x74.HWORD); } if (!(this->direction & 0x80)) { LinearMoveUpdate(this); @@ -24,6 +24,6 @@ void BladeTrap(Entity* this) { if (!(this->direction & 0x80)) { EnqueueSFX(SFX_METAL_CLINK); } - sub_080A2CC0(this, &this->child, &this->field_0x74.HWORD); + sub_080A2CC0(this, (u16**)&this->child, &this->field_0x74.HWORD); } } diff --git a/src/enemy/bombarossa.c b/src/enemy/bombarossa.c index f3455a21..4004edb5 100644 --- a/src/enemy/bombarossa.c +++ b/src/enemy/bombarossa.c @@ -27,7 +27,7 @@ void Bombarossa_OnTick(BombarossaEntity* this) { InitializeAnimation(super, 0); if (super->type != 0) { super->child = GetCurrentRoomProperty(super->type); - sub_080A2CC0(super, &super->child, &this->unk_0x76); + sub_080A2CC0(super, (u16**)&super->child, &this->unk_0x76); } } @@ -68,7 +68,7 @@ void sub_0803350C(BombarossaEntity* this) { } if (--this->unk_0x76 == 0) { - sub_080A2CC0(super, &super->child, &this->unk_0x76); + sub_080A2CC0(super, (u16**)&super->child, &this->unk_0x76); } } diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c index dda0a902..25616556 100644 --- a/src/enemy/lakituCloud.c +++ b/src/enemy/lakituCloud.c @@ -118,7 +118,7 @@ void sub_0803CDD8(Entity* this) { void sub_0803CE14(Entity* this) { u8 direction; - sub_080A2CC0(this, &this->child, &this->field_0x74.HWORD); + sub_080A2CC0(this, (u16**)&this->child, &this->field_0x74.HWORD); direction = this->direction; if (direction & 0x80) { diff --git a/src/object/lavaPlatform.c b/src/object/lavaPlatform.c index 61811673..8576cfa8 100644 --- a/src/object/lavaPlatform.c +++ b/src/object/lavaPlatform.c @@ -32,8 +32,6 @@ typedef struct { /*0x0e*/ u8 unk_e[2]; } LavaPlatformEntry; -extern void sub_080A2CC0(Entity*, Entity**, u16*); - void sub_08092278(LavaPlatformEntity*); void sub_08092344(LavaPlatformEntity*); void LavaPlatform_SpawnPlatforms(LavaPlatformEntity*); @@ -248,7 +246,7 @@ void LavaPlatform_SpawnPlatforms(LavaPlatformEntity* this) { platform->respawnTime = entry->respawnTime; platform->unk_78 = entry->unk_78; UpdateSpriteForCollisionLayer((Entity*)platform); - sub_080A2CC0(&platform->base, &platform->unk_78, &platform->unk_76); + sub_080A2CC0(&platform->base, (u16**)&platform->unk_78, &platform->unk_76); } entry++; } @@ -302,6 +300,6 @@ void sub_080926E4(LavaPlatformEntity* this) { (super->parent)->y.HALF.HI = super->y.HALF.HI; } if (--this->unk_76 == 0) { - sub_080A2CC0(super, &this->unk_78, &this->unk_76); + sub_080A2CC0(super, (u16**)&this->unk_78, &this->unk_76); } } diff --git a/src/object/lightableSwitch.c b/src/object/lightableSwitch.c index ca63ad85..ec5fdad5 100644 --- a/src/object/lightableSwitch.c +++ b/src/object/lightableSwitch.c @@ -65,7 +65,7 @@ void sub_0809EAD8(Entity* this) { if (this->type2 != 0) { this->child = GetCurrentRoomProperty(this->type2); - sub_080A2CC0(this, &this->child, &this->field_0x74.HWORD); + sub_080A2CC0(this, (u16**)&this->child, &this->field_0x74.HWORD); } else { SetTile(0x4050, COORD_TO_TILE(this), this->collisionLayer); @@ -82,7 +82,7 @@ void sub_0809EB30(Entity* this) { } puVar2 = &this->field_0x74.HWORD; if (!--*puVar2) { - sub_080A2CC0(this, &this->child, puVar2); + sub_080A2CC0(this, (u16**)&this->child, puVar2); } } } diff --git a/src/object/lilypadSmall.c b/src/object/lilypadSmall.c index 5ec5fb84..c8cf76f1 100644 --- a/src/object/lilypadSmall.c +++ b/src/object/lilypadSmall.c @@ -1,8 +1,6 @@ #include "object.h" #include "functions.h" -extern void sub_080A2CC0(Entity*, Entity**, u16*); - extern u16 gUnk_08123318[]; static void sub_08097B24(Entity* this); @@ -21,13 +19,13 @@ void LilypadSmall(Entity* this) { this->spriteSettings.draw = TRUE; this->spritePriority.b0 = 7; this->child = GetCurrentRoomProperty(this->type2); - sub_080A2CC0(this, &this->child, &this->field_0x70.HALF.LO); + sub_080A2CC0(this, (u16**)&this->child, &this->field_0x70.HALF.LO); } sub_080A2BE4(this, sub_08097ADC(this)); sub_08097B24(this); psVar4 = (u16*)&this->field_0x70; if (--*psVar4 == 0) { - sub_080A2CC0(this, &this->child, psVar4); + sub_080A2CC0(this, (u16**)&this->child, psVar4); } } diff --git a/src/objectUtils.c b/src/objectUtils.c index f394b912..6fdbe902 100644 --- a/src/objectUtils.c +++ b/src/objectUtils.c @@ -12,6 +12,10 @@ u32 LoadObjectSprite(Entity* this, s32 type, const ObjectDefinition* definition) extern const ObjectDefinition gObjectDefinitions[]; extern Entity* sub_0805E744(void); +Entity* CreateWaterTrace(Entity*); + +Entity* CreateSpeechBubble(Entity*, u32, s32, s32); + Entity* sub_080A276C(Entity* parent, u32 type, u32 type2) { Entity* e = sub_0805E744(); if (e != NULL) { @@ -206,11 +210,145 @@ void CreateRandomWaterTrace(Entity* parent, int range) { } Entity* CreateLargeWaterTrace(Entity* parent) { - Entity* ent; - - ent = CreateFx(parent, FX_RIPPLE_LARGE, 0); + Entity* ent = CreateFx(parent, FX_RIPPLE_LARGE, 0); if (ent != NULL) { ent->spritePriority.b0 = 7; } return ent; } + +NONMATCH("asm/non_matching/objectUtils/sub_080A2AF4.inc", void sub_080A2AF4(Entity* parent, s32 param_2, s32 param_3)) { + Entity* entity; + s32 rand; + s32 radius; + u32 angle; + s32 tmp; + + entity = CreateLargeWaterTrace(parent); + if (entity != NULL) { + rand = Random(); + radius = (rand % (param_3 - param_2 + 1)) + param_2; + angle = rand >> 0x10 & 0xff; + radius *= 0x100; + tmp = FixedMul(gSineTable[angle], radius); + tmp = FixedDiv(tmp, 0x100); + entity->x.WORD += ((tmp << 0x10) >> 8); + tmp = FixedMul(gSineTable[angle + 0x40], radius); + tmp = FixedDiv(tmp, 0x100); + entity->y.WORD -= ((tmp << 0x10) >> 8); + } +} +END_NONMATCH + +void CreateSparkle(Entity* entity) { + Entity* sparkle; + u32 rand; + s32 y; + s32 x; + + sparkle = CreateObject(SPECIAL_FX, 0x26, 0); + if (sparkle != NULL) { + rand = Random(); + x = rand & 0xf; + if ((rand & 0x80) != 0) { + x = -x; + } + y = rand >> 8 & 0xf; + if (4 < y) { + y = -y; + } + PositionRelative(entity, sparkle, x << 0x10, y << 0x10); + SortEntityAbove(entity, sparkle); + sparkle->spriteOffsetX = entity->spriteOffsetX; + sparkle->spriteOffsetY = entity->spriteOffsetY; + } +} + +NONMATCH("asm/non_matching/objectUtils/sub_080A2BE4.inc", void sub_080A2BE4(Entity* this, u32 param_2)) { + s16 oldValue; + s32 diff; + u16 newValue; + + if ((this->direction & 0x80) == 0) { + switch (this->direction >> 3) { + case 0: + oldValue = this->y.HALF_U.HI; + LinearMoveUpdate(this); + newValue = this->y.HALF_U.HI; + diff = ((oldValue - newValue) << 0x10) >> 0x10; + if ((diff != 0) && (param_2 != 0)) { + sub_080044AE(&gPlayerEntity, diff << 8, 0); + } + break; + case 1: + oldValue = this->x.HALF_U.HI; + LinearMoveUpdate(this); + diff = ((this->x.HALF_U.HI - oldValue) * 0x10000) >> 0x10; + if ((diff != 0) && (param_2 != 0)) { + sub_080044AE(&gPlayerEntity, diff << 8, 8); + } + break; + case 2: + oldValue = this->y.HALF_U.HI; + LinearMoveUpdate(this); + diff = ((this->y.HALF_U.HI - oldValue) * 0x10000) >> 0x10; + if ((diff != 0) && (param_2 != 0)) { + sub_080044AE(&gPlayerEntity, diff << 8, 0x10); + } + break; + case 3: + oldValue = this->x.HALF_U.HI; + LinearMoveUpdate(this); + newValue = this->x.HALF_U.HI; + diff = ((oldValue - newValue) << 0x10) >> 0x10; + if ((diff != 0) && (param_2 != 0)) { + sub_080044AE(&gPlayerEntity, diff << 8, 0x18); + } + break; + } + } +} +END_NONMATCH + +void sub_080A2CC0(Entity* this, u16** param_2, u16* param_3) { + u16* ptr = *param_2; + if (ptr != NULL) { + if (*ptr == 0xfe) { + ptr = ptr + (u32)ptr[1] * -3; + } + if (*ptr == 0xff) { + this->direction = 0xff; + this->speed = 0; + } else { + this->direction = (u8)*ptr; + this->speed = ptr[2]; + } + *param_3 = ptr[1]; + *param_2 = ptr + 3; + } +} + +Entity* CreateSpeechBubbleExclamationMark(Entity* parent, s32 offsetX, s32 offsetY) { + return CreateSpeechBubble(parent, 0, offsetX, offsetY); +} + +Entity* CreateSpeechBubbleQuestionMark(Entity* parent, s32 offsetX, s32 offsetY) { + return CreateSpeechBubble(parent, 1, offsetX, offsetY); +} + +Entity* CreateSpeechBubbleSleep(Entity* parent, s32 offsetX, s32 offsetY) { + return CreateSpeechBubble(parent, 2, offsetX, offsetY); +} + +Entity* CreateSpeechBubble(Entity* parent, u32 type2, s32 xOffset, s32 yOffset) { + Entity* obj = CreateObject(THOUGHT_BUBBLE, 0, type2); + if (obj != NULL) { + CopyPosition(parent, obj); + SortEntityAbove(parent, obj); + obj->parent = parent; + obj->spriteOffsetX = xOffset; + obj->spriteOffsetY = yOffset; + SetDefaultPriority(obj, parent->updatePriority); + } + return obj; +} |
