mirror of
https://github.com/zeldaret/tmc
synced 2026-08-18 05:38:50 -04:00
Merge remote-tracking branch 'upstream/master' into interaction-stuff
This commit is contained in:
+119
-14
@@ -76,6 +76,7 @@ void sub_080620F4(Entity*);
|
||||
void sub_08062130(Entity*);
|
||||
void sub_08062194(Entity*);
|
||||
void (*const gUnk_0810BE0C[])(Entity*) = { sub_080620F4, sub_08062130, sub_08062194 };
|
||||
extern s32 sub_080041E8(s32 x1, s32 y1, s32 x2, s32 y2);
|
||||
|
||||
void sub_08062194(Entity*);
|
||||
const Dialog gUnk_0810BE10[] = {
|
||||
@@ -182,17 +183,21 @@ void sub_080622F4(Entity*);
|
||||
void sub_0806265C(Entity*, ScriptExecutionContext*);
|
||||
void sub_0806252C(Entity*);
|
||||
|
||||
typedef struct {
|
||||
u16 x;
|
||||
u16 y;
|
||||
u16 z;
|
||||
u8 framestate;
|
||||
u8 animationState : 6;
|
||||
u8 collisionLayer : 2;
|
||||
typedef union {
|
||||
struct {
|
||||
s16 x;
|
||||
s16 y;
|
||||
s16 z;
|
||||
u8 framestate;
|
||||
u8 animationState : 6;
|
||||
u8 collisionLayer : 2;
|
||||
} FIELDS;
|
||||
u64 DWORD;
|
||||
} KidHeapItem;
|
||||
|
||||
#define KID_HEAP_COUNT 0x14
|
||||
typedef KidHeapItem KidHeap[KID_HEAP_COUNT];
|
||||
#define KID_HEAP ((KidHeapItem*)this->myHeap)
|
||||
|
||||
void Kid(Entity* this) {
|
||||
if ((this->flags & ENT_SCRIPTED) != 0) {
|
||||
@@ -307,7 +312,107 @@ void sub_080621AC(Entity* this) {
|
||||
}
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/kid/sub_080622F4.inc", void sub_080622F4(Entity* this))
|
||||
#define KID_HEAP_SHIFT_RIGHT \
|
||||
heapPtr = KID_HEAP; \
|
||||
heapPtr += (KID_HEAP_COUNT - 2); \
|
||||
for (i = 0; i < (KID_HEAP_COUNT - 1); i++) { \
|
||||
heapPtr[1] = heapPtr[0]; \
|
||||
heapPtr--; \
|
||||
}
|
||||
|
||||
void sub_080622F4(Entity* this) {
|
||||
s32 dx;
|
||||
s32 dy;
|
||||
s32 dist;
|
||||
s32 i;
|
||||
|
||||
u32 animIndex; // used as 2nd param of InitAnimationForceUpdate
|
||||
u32 animIndexTmp;
|
||||
|
||||
KidHeapItem* heapPtr;
|
||||
KidHeapItem item;
|
||||
|
||||
// Prepended heap item is initialized from player's current state.
|
||||
item.FIELDS.x = gPlayerEntity.x.HALF_U.HI;
|
||||
item.FIELDS.y = gPlayerEntity.y.HALF_U.HI;
|
||||
item.FIELDS.z = gPlayerEntity.z.HALF_U.HI;
|
||||
item.FIELDS.framestate = gPlayerState.framestate;
|
||||
item.FIELDS.animationState = gPlayerEntity.animationState;
|
||||
item.FIELDS.collisionLayer = gPlayerEntity.collisionLayer;
|
||||
|
||||
heapPtr = this->myHeap;
|
||||
if (heapPtr->FIELDS.framestate == 0x16 && item.FIELDS.framestate != 0x16) {
|
||||
dx = this->x.HALF.HI - gPlayerEntity.x.HALF.HI;
|
||||
dy = this->y.HALF.HI - gPlayerEntity.y.HALF.HI;
|
||||
|
||||
if (dx < 0)
|
||||
dx = -dx;
|
||||
if (dy < 0)
|
||||
dy = -dy;
|
||||
|
||||
if (dx > 120 || dy > 80) {
|
||||
this->field_0x68.HALF.LO = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
sub_0806252C(this);
|
||||
}
|
||||
|
||||
animIndex = 0;
|
||||
|
||||
if (item.DWORD != heapPtr->DWORD) {
|
||||
KID_HEAP_SHIFT_RIGHT;
|
||||
heapPtr = KID_HEAP;
|
||||
heapPtr[0] = item;
|
||||
|
||||
animIndex = 0x4;
|
||||
if ((s8)this->field_0x68.HALF.HI > 0) {
|
||||
this->field_0x68.HALF.HI = this->field_0x68.HALF.HI - 1;
|
||||
}
|
||||
} else {
|
||||
heapPtr += KID_HEAP_COUNT - 1;
|
||||
if (heapPtr->FIELDS.z < 0) {
|
||||
KID_HEAP_SHIFT_RIGHT;
|
||||
animIndex = 0x4;
|
||||
} else {
|
||||
dist = sub_080041E8(gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, (u16)heapPtr->FIELDS.x,
|
||||
(u16)heapPtr->FIELDS.y);
|
||||
dist = ((u32)dist) >> 0x4;
|
||||
if (dist > 0x18) {
|
||||
|
||||
KID_HEAP_SHIFT_RIGHT;
|
||||
animIndex = 0x4;
|
||||
}
|
||||
}
|
||||
}
|
||||
heapPtr = KID_HEAP;
|
||||
heapPtr += +KID_HEAP_COUNT - 1;
|
||||
this->x.HALF.HI = heapPtr->FIELDS.x;
|
||||
this->y.HALF.HI = heapPtr->FIELDS.y;
|
||||
this->z.HALF.HI = heapPtr->FIELDS.z;
|
||||
this->animationState = heapPtr->FIELDS.animationState;
|
||||
this->collisionLayer = heapPtr->FIELDS.collisionLayer;
|
||||
|
||||
if (((s8)this->field_0x68.HALF.HI) > 0) {
|
||||
this->field_0x68.HALF.HI = this->field_0x68.HALF.HI - 1;
|
||||
}
|
||||
|
||||
animIndexTmp = animIndex;
|
||||
animIndex += this->animationState >> 1;
|
||||
if (this->type == OBJECT) {
|
||||
animIndex += 0x10;
|
||||
}
|
||||
|
||||
if (!(animIndex == this->animIndex || (animIndexTmp == 0 && ((s8)this->field_0x68.HALF.HI) > 0))) {
|
||||
InitAnimationForceUpdate(this, animIndex);
|
||||
this->field_0x68.HALF.HI = 0x1e;
|
||||
} else {
|
||||
UpdateAnimationSingleFrame(this);
|
||||
}
|
||||
|
||||
sub_0800451C(this);
|
||||
return;
|
||||
}
|
||||
|
||||
void sub_08062500(Entity* this) {
|
||||
this->myHeap = zMalloc(sizeof(KidHeap));
|
||||
@@ -388,12 +493,12 @@ void sub_0806252C(Entity* this) {
|
||||
x = 0;
|
||||
|
||||
for (loopVar = KID_HEAP_COUNT - 1; loopVar >= 0; loopVar--) {
|
||||
item->x = r5 - (x >> 8);
|
||||
item->y = (r5 >> 0x10) - (y >> 8);
|
||||
item->z = r6;
|
||||
item->framestate = r6 >> 0x10;
|
||||
item->animationState = this->animationState & 0x3f;
|
||||
item->collisionLayer = this->collisionLayer;
|
||||
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;
|
||||
|
||||
+125
-16
@@ -2,16 +2,36 @@
|
||||
#include "entity.h"
|
||||
#include "functions.h"
|
||||
|
||||
typedef struct {
|
||||
u16 x;
|
||||
u16 y;
|
||||
u16 z;
|
||||
u8 framestate;
|
||||
u8 animationState : 6;
|
||||
u8 collisionLayer : 2;
|
||||
extern s32 sub_080041E8(s32 x1, s32 y1, s32 x2, s32 y2);
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
u16 x;
|
||||
u16 y;
|
||||
u16 z;
|
||||
u8 framestate;
|
||||
u8 animationState : 6;
|
||||
u8 collisionLayer : 2;
|
||||
} FIELDS;
|
||||
u64 DWORD;
|
||||
} ZeldaFollowerItem;
|
||||
|
||||
typedef ZeldaFollowerItem ZeldaFollowerHeap[20];
|
||||
#define ZELDA_FOLLOWER_HEAP_LEN 20
|
||||
|
||||
#define ZELDA_FOLLOWER_HEAP ((ZeldaFollowerItem *)this->myHeap)
|
||||
#define ZELDA_FOLLOWER_HEAP_END ((ZeldaFollowerItem *)this->myHeap + (ZELDA_FOLLOWER_HEAP_LEN - 1))
|
||||
|
||||
#define ZELDA_FOLLOWER_HEAP_SHIFT_RIGHT(this, heapPtr) \
|
||||
do { \
|
||||
int i; \
|
||||
heapPtr = ((ZeldaFollowerItem*)this->myHeap); \
|
||||
heapPtr += (ZELDA_FOLLOWER_HEAP_LEN - 2); \
|
||||
for ( i = 0; i < (ZELDA_FOLLOWER_HEAP_LEN - 1); i++) { \
|
||||
heapPtr[1] = heapPtr[0]; \
|
||||
heapPtr--; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
void sub_08068318(Entity*);
|
||||
void sub_0806854C(Entity*, u32*);
|
||||
@@ -35,10 +55,99 @@ void ZeldaFollower(Entity* this) {
|
||||
}
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/zeldaFollower/sub_08068318.inc", void sub_08068318(Entity* this))
|
||||
void sub_08068318(Entity* this) {
|
||||
s32 dist;
|
||||
s16 z;
|
||||
|
||||
u32 animIndex;
|
||||
u32 animIndexTmp;
|
||||
|
||||
ZeldaFollowerItem* heapPtr;
|
||||
ZeldaFollowerItem item;
|
||||
|
||||
item.FIELDS.x = gPlayerEntity.x.HALF_U.HI;
|
||||
item.FIELDS.y = gPlayerEntity.y.HALF_U.HI;
|
||||
item.FIELDS.z = gPlayerEntity.z.HALF_U.HI;
|
||||
item.FIELDS.framestate = gPlayerState.framestate;
|
||||
item.FIELDS.animationState = gPlayerEntity.animationState;
|
||||
item.FIELDS.collisionLayer = gPlayerEntity.collisionLayer;
|
||||
|
||||
heapPtr = this->myHeap;
|
||||
|
||||
if ( (heapPtr->FIELDS.framestate == 0xa && item.FIELDS.framestate != 0xa) ||
|
||||
(heapPtr->FIELDS.framestate == 0x16 && item.FIELDS.framestate != 0x16)) {
|
||||
this->x.HALF.HI = gPlayerEntity.x.HALF.HI;
|
||||
this->y.HALF.HI = gPlayerEntity.y.HALF.HI;
|
||||
this->spriteSettings.draw = 1;
|
||||
sub_08068578(this);
|
||||
}
|
||||
|
||||
animIndex = 0;
|
||||
if (item.DWORD != heapPtr->DWORD || item.FIELDS.framestate == 0x16 || item.FIELDS.framestate == 0xa ) {
|
||||
ZELDA_FOLLOWER_HEAP_SHIFT_RIGHT(this, heapPtr);
|
||||
heapPtr = ZELDA_FOLLOWER_HEAP;
|
||||
heapPtr[0] = item;
|
||||
animIndex = 0x4;
|
||||
|
||||
if ((s8)this->field_0x68.HALF.HI > 0) {
|
||||
this->field_0x68.HALF.HI = this->field_0x68.HALF.HI - 1;
|
||||
}
|
||||
} else {
|
||||
heapPtr += ZELDA_FOLLOWER_HEAP_LEN - 1;
|
||||
z = heapPtr->FIELDS.z;
|
||||
|
||||
if (z < 0) {
|
||||
ZELDA_FOLLOWER_HEAP_SHIFT_RIGHT(this, heapPtr);
|
||||
animIndex = 0x4;
|
||||
} else {
|
||||
dist = sub_080041E8(
|
||||
gPlayerEntity.x.HALF.HI,
|
||||
gPlayerEntity.y.HALF.HI,
|
||||
(u16) heapPtr->FIELDS.x,
|
||||
(u16) heapPtr->FIELDS.y
|
||||
);
|
||||
dist = ((u32)dist) >> 0x4;
|
||||
if (dist > 0x18) {
|
||||
ZELDA_FOLLOWER_HEAP_SHIFT_RIGHT(this, heapPtr);
|
||||
animIndex = 0x4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
heapPtr = ZELDA_FOLLOWER_HEAP;
|
||||
heapPtr += ZELDA_FOLLOWER_HEAP_LEN - 1;
|
||||
this->x.HALF.HI = heapPtr->FIELDS.x;
|
||||
this->y.HALF.HI = heapPtr->FIELDS.y;
|
||||
this->z.HALF.HI = heapPtr->FIELDS.z;
|
||||
this->animationState = heapPtr->FIELDS.animationState;
|
||||
this->collisionLayer = heapPtr->FIELDS.collisionLayer;
|
||||
|
||||
if (heapPtr->FIELDS.framestate == 0x16 || heapPtr->FIELDS.framestate == 0xa) {
|
||||
this->spriteSettings.draw = 0;
|
||||
}
|
||||
|
||||
if (((s8)this->field_0x68.HALF.HI) > 0) {
|
||||
this->field_0x68.HALF.HI = this->field_0x68.HALF.HI - 1;
|
||||
}
|
||||
|
||||
animIndexTmp = animIndex;
|
||||
animIndex += this->animationState >> 1;
|
||||
|
||||
if (!(animIndex == this->animIndex || (animIndexTmp == 0 && ((s8)this->field_0x68.HALF.HI) > 0))) {
|
||||
InitAnimationForceUpdate(this, animIndex);
|
||||
this->field_0x68.HALF.HI = 0x1e;
|
||||
} else {
|
||||
UpdateAnimationSingleFrame(this);
|
||||
}
|
||||
|
||||
sub_0800451C(this);
|
||||
if (this->z.HALF.HI < 0) {
|
||||
sub_0806F854(this, 0x0, -0xc);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0806854C(Entity* this, u32* none) {
|
||||
this->myHeap = zMalloc(sizeof(ZeldaFollowerHeap));
|
||||
this->myHeap = zMalloc(sizeof(ZeldaFollowerItem[ZELDA_FOLLOWER_HEAP_LEN]));
|
||||
if (this->myHeap != NULL) {
|
||||
this->field_0x68.HALF.LO = 1;
|
||||
RemoveInteractableObject(this);
|
||||
@@ -156,12 +265,12 @@ void sub_08068578(Entity* this) {
|
||||
// Down here the u32 are suddendly accessed correctly as u16 and bitfields?
|
||||
// How are the results of above u32 calculations used?
|
||||
for (index = 0x13; index >= 0; index--) {
|
||||
item->x = r5 - (x >> 8);
|
||||
item->y = (r5 >> 0x10) - (y >> 8);
|
||||
item->z = r6;
|
||||
item->framestate = r6 >> 0x10;
|
||||
item->animationState = this->animationState & 0x3f;
|
||||
item->collisionLayer = this->collisionLayer;
|
||||
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;
|
||||
|
||||
+26
-20
@@ -169,70 +169,76 @@ void sub_080AC560(Entity* this) {
|
||||
this->y.WORD = entity->y.WORD - gSineTable[entity->direction + 0x40] * factor;
|
||||
}
|
||||
|
||||
NONMATCH("asm/non_matching/gyorgTail/sub_080AC5E4.inc", bool32 sub_080AC5E4(Entity* this)) {
|
||||
bool32 sub_080AC5E4(Entity* this) {
|
||||
// TODO regalloc
|
||||
Entity* entity;
|
||||
Entity* new_var2;
|
||||
Entity* entity2;
|
||||
Entity* entity3;
|
||||
Entity* entity4;
|
||||
u8 uVar3;
|
||||
|
||||
if (this->type == 0) {
|
||||
if (0x43 < gEntCount) {
|
||||
if (gEntCount > 0x43) {
|
||||
return FALSE;
|
||||
}
|
||||
this->field_0x78.HALF.HI = 0x11;
|
||||
entity = CreateProjectile(0x22);
|
||||
entity = CreateProjectile(GYORG_TAIL);
|
||||
entity->type = this->type;
|
||||
entity->type2 = 1;
|
||||
entity->parent = this->parent;
|
||||
entity->field_0x78.HALF.HI = 0x12;
|
||||
this->child = entity;
|
||||
entity2 = CreateProjectile(0x22);
|
||||
|
||||
entity2 = CreateProjectile(GYORG_TAIL);
|
||||
entity2->type = this->type;
|
||||
entity2->type2 = 2;
|
||||
entity2->parent = this->parent;
|
||||
entity2->field_0x78.HALF.HI = 0x14;
|
||||
uVar3 = entity2->field_0x78.HALF.HI;
|
||||
entity2->field_0x78.HALF.HI = uVar3;
|
||||
entity->child = entity2;
|
||||
entity3 = CreateProjectile(0x22);
|
||||
|
||||
entity3 = CreateProjectile(GYORG_TAIL);
|
||||
entity3->type = this->type;
|
||||
entity3->type2 = 3;
|
||||
entity3->parent = this->parent;
|
||||
entity3->child = NULL;
|
||||
entity3->field_0x78.HALF.HI = 0;
|
||||
entity2->child = entity3;
|
||||
|
||||
entity = CreateProjectile(GYORG_TAIL);
|
||||
entity->type = this->type;
|
||||
entity->type2 = 4;
|
||||
entity->parent = this->parent;
|
||||
entity->child = this;
|
||||
entity->field_0x78.HALF.HI = 0x14;
|
||||
} else {
|
||||
if (0x44 < gEntCount) {
|
||||
if (gEntCount > 0x44) {
|
||||
return FALSE;
|
||||
}
|
||||
this->field_0x78.HALF.HI = 0xf;
|
||||
entity = CreateProjectile(0x22);
|
||||
entity = CreateProjectile(GYORG_TAIL);
|
||||
entity->type = this->type;
|
||||
entity->type2 = 1;
|
||||
entity->parent = this->parent;
|
||||
entity->field_0x78.HALF.HI = 0x10;
|
||||
uVar3 = entity->field_0x78.HALF.HI;
|
||||
entity->field_0x78.HALF.HI = uVar3;
|
||||
this->child = entity;
|
||||
entity2 = CreateProjectile(0x22);
|
||||
|
||||
entity2 = CreateProjectile(GYORG_TAIL);
|
||||
entity2->type = this->type;
|
||||
entity2->type2 = 2;
|
||||
entity2->parent = this->parent;
|
||||
entity2->child = NULL;
|
||||
entity2->field_0x78.HALF.HI = 0x20;
|
||||
entity->child = entity2;
|
||||
|
||||
entity = CreateProjectile(GYORG_TAIL);
|
||||
entity->type = this->type;
|
||||
entity->type2 = 4;
|
||||
entity->parent = this->parent;
|
||||
entity->child = this;
|
||||
entity->field_0x78.HALF.HI = 0x10;
|
||||
}
|
||||
entity = CreateProjectile(0x22);
|
||||
entity->type = this->type;
|
||||
entity->type2 = 4;
|
||||
entity->parent = this->parent;
|
||||
entity->child = this;
|
||||
entity->field_0x78.HALF.HI = uVar3;
|
||||
return TRUE;
|
||||
}
|
||||
END_NONMATCH
|
||||
|
||||
void sub_080AC6F0(Entity* this) {
|
||||
static const u8 gUnk_0812A9C0[] = { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
|
||||
|
||||
Reference in New Issue
Block a user