Merge pull request #433 from octorock/objectUtils

Decompile rest of objectUtils
This commit is contained in:
notyourav
2022-03-06 22:36:16 -08:00
committed by GitHub
12 changed files with 333 additions and 364 deletions
+2 -2
View File
@@ -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);
}
}
+2 -2
View File
@@ -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);
}
}
+1 -1
View File
@@ -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) {
+2 -4
View File
@@ -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);
}
}
+2 -2
View File
@@ -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);
}
}
}
+2 -4
View File
@@ -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);
}
}
+141 -3
View File
@@ -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;
}