True match sub_0806252C

Co-authored-by: KEKW555 <152369890+KEKW555@users.noreply.github.com>
This commit is contained in:
Elmyr de Hory 2023-12-31 00:55:02 -08:00
parent bd1be092aa
commit b199773a12
1 changed files with 37 additions and 84 deletions

View File

@ -199,13 +199,13 @@ const FrameStruct gUnk_0810C0A0[] = {
void sub_080621AC(KidEntity* this); void sub_080621AC(KidEntity* this);
void sub_080622F4(KidEntity* this); void sub_080622F4(KidEntity* this);
void sub_0806265C(Entity* this, ScriptExecutionContext* context); void sub_0806265C(KidEntity* this, ScriptExecutionContext* context);
void sub_0806252C(Entity* this); void sub_0806252C(KidEntity* this);
typedef union { typedef union {
struct { struct {
s16 x; u16 x;
s16 y; u16 y;
s16 z; s16 z;
u8 framestate; u8 framestate;
u8 animationState : 6; u8 animationState : 6;
@ -306,7 +306,7 @@ void sub_080621AC(KidEntity* this) {
return; return;
} }
} }
sub_0806265C(super, this->context); sub_0806265C(this, this->context);
tmp = super->animIndex; tmp = super->animIndex;
} }
this->unk_6b = super->animIndex; this->unk_6b = super->animIndex;
@ -375,7 +375,7 @@ void sub_080622F4(KidEntity* this) {
return; return;
} }
sub_0806252C(super); sub_0806252C(this);
} }
animIndex = 0; animIndex = 0;
@ -440,88 +440,41 @@ void sub_08062500(KidEntity* this) {
this->unk_68 = 1; this->unk_68 = 1;
RemoveInteractableObject(super); RemoveInteractableObject(super);
super->hitbox = NULL; super->hitbox = NULL;
sub_0806252C(super); sub_0806252C(this);
} }
} }
void sub_0806252C(Entity* this) { void sub_0806252C(KidEntity* this) {
s16 sVar1; s32 dx, dy;
s16 sVar2; s32 i;
u16 uVar3;
u8 uVar4;
s16 sVar5;
s16 sVar6;
u8 bVar7;
KidHeapItem* item;
s32 loopVar;
FORCE_REGISTER(u32 r5, r5);
FORCE_REGISTER(u32 r6, r6);
FORCE_REGISTER(u32 r0, r0);
FORCE_REGISTER(u32 r1, r1);
FORCE_REGISTER(u32 r2, r2);
u32 r3;
FORCE_REGISTER(s32 r8, r8);
s32 y;
s32 r10;
FORCE_REGISTER(s32 x, r12);
r1 = gPlayerEntity.base.x.HALF_U.HI; KidHeapItem *heapPtr, item;
r3 = 0xffff0000;
r0 = r3;
r0 &= r5;
r0 |= r1;
r1 = gPlayerEntity.base.y.HALF_U.HI; // Copy from the player's position/state.
r1 <<= 0x10; item.FIELDS.x = gPlayerEntity.base.x.HALF_U.HI;
r2 = 0x0000ffff; item.FIELDS.y = gPlayerEntity.base.y.HALF_U.HI;
r0 &= r2; item.FIELDS.z = gPlayerEntity.base.z.HALF_U.HI;
r0 |= r1; item.FIELDS.framestate = gPlayerState.framestate;
r5 = r0; item.FIELDS.animationState = gPlayerEntity.base.animationState;
item.FIELDS.collisionLayer = gPlayerEntity.base.collisionLayer;
r0 = gPlayerEntity.base.z.HALF_U.HI; // Compute the distance between the kid and the player.
r3 &= r6; dx = gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI;
r3 |= r0; dy = gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI;
r0 = gPlayerState.framestate; // Divide it into KID_HEAP_COUNT increments.
r0 <<= 0x10; dx = FixedDiv(dx, KID_HEAP_COUNT);
r2 = 0xff00ffff; dy = FixedDiv(dy, KID_HEAP_COUNT);
r2 &= r3;
r2 |= r0;
r1 = gPlayerEntity.base.animationState; heapPtr = KID_HEAP;
r0 = 0x3f; for (i = 0; i < KID_HEAP_COUNT; i++) {
r1 &= r0; heapPtr->FIELDS.x = item.FIELDS.x - ((i * dx) >> 8);
r1 <<= 0x18; heapPtr->FIELDS.y = item.FIELDS.y - ((i * dy) >> 8);
r0 = 0xc0ffffff; heapPtr->FIELDS.z = item.FIELDS.z;
r0 &= r2; heapPtr->FIELDS.framestate = item.FIELDS.framestate;
r0 |= r1; heapPtr->FIELDS.animationState = super->animationState;
heapPtr->FIELDS.collisionLayer = super->collisionLayer;
r1 = gPlayerEntity.base.collisionLayer; heapPtr++;
r1 <<= 0x1e;
r2 = 0x3fffffff;
r0 &= r2;
r0 |= r1;
r6 = r0;
r10 = r0 = gPlayerEntity.base.x.HALF.HI - this->x.HALF.HI;
r8 = r0 = gPlayerEntity.base.y.HALF.HI - this->y.HALF.HI;
r10 = FixedDiv(r10, KID_HEAP_COUNT);
r8 = FixedDiv(r8, KID_HEAP_COUNT);
item = (KidHeapItem*)this->myHeap;
y = 0;
x = 0;
for (loopVar = KID_HEAP_COUNT - 1; loopVar >= 0; loopVar--) {
item->FIELDS.x = r5 - (x >> 8);
item->FIELDS.y = (r5 >> 0x10) - (y >> 8);
item->FIELDS.z = r6;
item->FIELDS.framestate = r6 >> 0x10;
item->FIELDS.animationState = this->animationState & 0x3f;
item->FIELDS.collisionLayer = this->collisionLayer;
item++;
y = y + r8;
x = x + r10;
} }
} }
@ -531,13 +484,13 @@ void sub_08062634(Entity* this) {
MessageNoOverlap(gUnk_0810BDE8[a][b], this); MessageNoOverlap(gUnk_0810BDE8[a][b], this);
} }
void sub_0806265C(Entity* this, ScriptExecutionContext* context) { void sub_0806265C(KidEntity* this, ScriptExecutionContext* context) {
if (gSave.global_progress == 0) { if (gSave.global_progress == 0) {
MessageNoOverlap(0, this); MessageNoOverlap(0, super);
} else { } else {
const Dialog* pDialog = &gUnk_0810BE10[this->type * 9 - 1]; const Dialog* pDialog = &gUnk_0810BE10[super->type * 9 - 1];
pDialog += gSave.global_progress; pDialog += gSave.global_progress;
ShowNPCDialogue(this, pDialog); ShowNPCDialogue(super, pDialog);
} }
} }