mirror of
https://github.com/zeldaret/tmc
synced 2026-08-20 06:06:54 -04:00
Decompile itemOnGround.c
This commit is contained in:
+73
-2
@@ -5,10 +5,12 @@
|
||||
#include "room.h"
|
||||
|
||||
extern void sub_0805E5A8();
|
||||
extern void sub_08080BC4(void);
|
||||
|
||||
extern RoomControls gRoomControls;
|
||||
extern u32 gUnk_0200B650;
|
||||
extern u32 gUnk_02025EB0;
|
||||
extern u8 gUnk_02000070;
|
||||
|
||||
extern void DoExitTransition(ScreenTransitionData*);
|
||||
extern void sub_080809D4();
|
||||
@@ -53,7 +55,6 @@ void sub_08080930(void)
|
||||
}
|
||||
|
||||
u32* GetLayerByIndex(u32 param_1)
|
||||
|
||||
{
|
||||
|
||||
if (param_1 == 2) {
|
||||
@@ -64,9 +65,79 @@ u32* GetLayerByIndex(u32 param_1)
|
||||
}
|
||||
|
||||
void sub_08080964(u16 time, u32 magnitude)
|
||||
|
||||
{
|
||||
gRoomControls.screenShakeTime = time;
|
||||
gRoomControls.screenShakeMagnitude = magnitude & 7;
|
||||
return;
|
||||
}
|
||||
|
||||
void sub_08080974(u32 arg0, u32 arg1) {
|
||||
u32 var0, var1;
|
||||
RoomControls* roomControls = &gRoomControls;
|
||||
|
||||
var0 = roomControls->roomOriginX;
|
||||
if (arg0 <= var0 + 120) {
|
||||
roomControls->roomScrollX = var0;
|
||||
} else {
|
||||
var0 += roomControls->width;
|
||||
var1 = var0 - 120;
|
||||
if (arg0 < var1) {
|
||||
var1 = arg0;
|
||||
}
|
||||
roomControls->roomScrollX = var1 - 120;
|
||||
}
|
||||
|
||||
var0 = roomControls->roomOriginY;
|
||||
if (arg1 <= var0 + 80) {
|
||||
roomControls->roomScrollY = var0;
|
||||
} else {
|
||||
var0 += roomControls->height;
|
||||
var1 = var0 - 80;
|
||||
if (arg1 < var1) {
|
||||
var1 = arg1;
|
||||
}
|
||||
roomControls->roomScrollY = var1 - 80;
|
||||
}
|
||||
|
||||
sub_080809D4();
|
||||
gUnk_02000070 = 1;
|
||||
}
|
||||
|
||||
void sub_080809D4(void) {
|
||||
register Entity* target asm("r4");
|
||||
int x, y;
|
||||
int var1, var0;
|
||||
RoomControls* roomControls = &gRoomControls;
|
||||
roomControls->unk6 &= 0xFB;
|
||||
|
||||
target = roomControls->cameraTarget;
|
||||
x = target->x.HALF.HI;
|
||||
var0 = roomControls->roomOriginX;
|
||||
if (x <= var0 + 120) {
|
||||
roomControls->roomScrollX = var0;
|
||||
} else {
|
||||
var0 += roomControls->width;
|
||||
var1 = var0 - 120;
|
||||
if (x < var1) {
|
||||
var1 = (u16)target->x.HALF.HI;
|
||||
}
|
||||
roomControls->roomScrollX = var1 - 120;
|
||||
}
|
||||
|
||||
target = roomControls->cameraTarget;
|
||||
y = target->y.HALF.HI;
|
||||
var0 = roomControls->roomOriginY;
|
||||
if (y <= var0 + 80) {
|
||||
roomControls->roomScrollY = var0;
|
||||
} else {
|
||||
var0 += roomControls->height;
|
||||
var1 = var0 - 80;
|
||||
if (y < var1) {
|
||||
var1 = (u16)target->y.HALF.HI;
|
||||
}
|
||||
roomControls->roomScrollY = var1 - 80;
|
||||
}
|
||||
|
||||
sub_08080BC4();
|
||||
gUnk_02000070 = 1;
|
||||
}
|
||||
|
||||
@@ -316,8 +316,8 @@ void sub_08031E48(Entity* this, Entity* child) {
|
||||
child->field_0x6c.HALF.LO = this->field_0x6c.HALF.LO;
|
||||
child->field_0x70.HALF.LO = this->field_0x70.HALF.LO;
|
||||
child->field_0x70.HALF.HI = this->field_0x70.HALF.HI;
|
||||
child->filler4[0] = this->filler4[0];
|
||||
child->filler4[1] = this->filler4[1];
|
||||
child->field_0x6e.HALF.LO = this->field_0x6e.HALF.LO;
|
||||
child->field_0x6e.HALF.HI = this->field_0x6e.HALF.HI;
|
||||
child->field_0x7c.WORD = (s32)this;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,6 @@ void sub_08023330(Entity* this) {
|
||||
}
|
||||
}
|
||||
|
||||
extern u32 GetTileTypeByEntity(Entity*);
|
||||
void sub_08023A68(Entity*);
|
||||
void sub_08023AB0(Entity*);
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ extern const s8 gUnk_080CA5D4[];
|
||||
void sub_080205F8(Entity*);
|
||||
void sub_08020604(Entity*);
|
||||
|
||||
extern u32 sub_0800442E(Entity*);
|
||||
extern u32 sub_08049F1C(Entity*, Entity*, u32);
|
||||
extern void sub_0804AA1C(Entity*);
|
||||
|
||||
|
||||
+2
-2
@@ -72,7 +72,7 @@ void sub_08033650(Entity* this) {
|
||||
}
|
||||
|
||||
void sub_08033658(Entity* this) {
|
||||
sub_0806F4E8();
|
||||
sub_0806F4E8(this);
|
||||
}
|
||||
|
||||
void sub_08033660(Entity* this) {
|
||||
@@ -146,4 +146,4 @@ void sub_08033744(Entity* this) {
|
||||
}
|
||||
}
|
||||
this->direction = temp;
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+442
@@ -0,0 +1,442 @@
|
||||
#include "global.h"
|
||||
#include "entity.h"
|
||||
#include "flags.h"
|
||||
#include "functions.h"
|
||||
#include "player.h"
|
||||
|
||||
static void sub_08081150(Entity*);
|
||||
static u8 sub_0808147C(u32);
|
||||
static void sub_080814A4(Entity*);
|
||||
static u32 sub_080814C0(Entity*);
|
||||
static void sub_08081500(Entity*);
|
||||
static void sub_0808153C(Entity*);
|
||||
static void sub_08081598(Entity*);
|
||||
static void sub_080813BC(Entity*);
|
||||
static void sub_080810FC(Entity*);
|
||||
static bool32 CheckShouldPlayItemGetCutscene(Entity*);
|
||||
|
||||
extern u32 sub_080002D0(Entity*);
|
||||
extern u32 sub_080177A0(Entity*, Entity*);
|
||||
extern void GiveItem(u32, u32);
|
||||
extern u32 sub_0805E40C(Entity*);
|
||||
|
||||
extern void (*const gUnk_0811E7D4[])(Entity*);
|
||||
extern void (*const gUnk_0811E7E8[])(Entity*);
|
||||
extern void (*const gUnk_0811E814[])(Entity*);
|
||||
extern void (*const gUnk_0811E840[])(Entity*);
|
||||
extern BoundingBox gUnk_080FD1A8;
|
||||
|
||||
typedef struct {
|
||||
u8 unk0[3];
|
||||
u8 unk3;
|
||||
u8 unk4[4];
|
||||
} Unk_080FD5B4;
|
||||
|
||||
extern const Unk_080FD5B4 gUnk_080FD5B4[];
|
||||
|
||||
typedef struct {
|
||||
u8 unk0[2];
|
||||
u16 sfx;
|
||||
u8 unk4;
|
||||
u8 unk5[3];
|
||||
} Unk_0811E84C;
|
||||
|
||||
extern const Unk_0811E84C gUnk_0811E84C[];
|
||||
|
||||
void ItemOnGround(Entity* this) {
|
||||
if (this->bitfield & 0x80) {
|
||||
switch (this->bitfield & 0x7F) {
|
||||
case 20:
|
||||
this->action = 3;
|
||||
this->flags &= 0x7F;
|
||||
this->spriteSettings.b.draw = 1;
|
||||
this->field_0x3c |= 0x10;
|
||||
this->attachedEntity = this->field_0x4c;
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 30:
|
||||
sub_08081598(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sub_0806F520(this)) {
|
||||
sub_080813BC(this);
|
||||
} else {
|
||||
gUnk_0811E7D4[this->action](this);
|
||||
}
|
||||
|
||||
if (this->entityType.form == 0x5C) {
|
||||
gRoomVars.field_0x4++;
|
||||
}
|
||||
|
||||
sub_08080CB4(this);
|
||||
}
|
||||
|
||||
void sub_08080F20(Entity* this) {
|
||||
if (this->field_0x86 && CheckFlags(this->field_0x86)) {
|
||||
DeleteThisEntity();
|
||||
}
|
||||
|
||||
if (this->entityType.form != 0x60) {
|
||||
this->spriteSettings.b.draw = 1;
|
||||
this->spritePriority.b1 = 3;
|
||||
this->spriteSettings.b.shadow = 0;
|
||||
this->damageType = 7;
|
||||
this->field_0x3c = 0x47;
|
||||
this->field_0x40 = 0x44;
|
||||
this->currentHealth = 0xFF;
|
||||
this->boundingBox = &gUnk_080FD1A8;
|
||||
switch (this->entityType.form - 0x3F) {
|
||||
case 0:
|
||||
case 21:
|
||||
case 22:
|
||||
case 23:
|
||||
case 24:
|
||||
case 25:
|
||||
case 29:
|
||||
case 30:
|
||||
case 31:
|
||||
case 32:
|
||||
this->flags2 = 0x17;
|
||||
break;
|
||||
default:
|
||||
this->flags2 = 0x11;
|
||||
break;
|
||||
}
|
||||
|
||||
this->field_0x68.HALF.HI = this->actionDelay;
|
||||
this->field_0x6a.HALF.LO = 0;
|
||||
this->field_0x6c.HWORD = 0;
|
||||
this->field_0x68.HALF.LO = 0;
|
||||
this->actionDelay = 0;
|
||||
sub_0805E3A0(this, 3);
|
||||
this->field_0x1c = sub_0808147C(this->entityType.form);
|
||||
gUnk_0811E7E8[this->field_0x68.HALF.HI](this);
|
||||
} else {
|
||||
Entity* entity = CreateObject(0x40, 0x60, 0);
|
||||
if (entity) {
|
||||
entity->actionDelay = 0;
|
||||
if (this->actionDelay == 1) {
|
||||
entity->entityType.parameter = 2;
|
||||
}
|
||||
|
||||
CopyPosition(this, entity);
|
||||
DeleteThisEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_080810A8(Entity* this) {
|
||||
this->action = 1;
|
||||
sub_080814A4(this);
|
||||
if (this->direction & 0x80) {
|
||||
this->direction &= 0x1F;
|
||||
if (this->nonPlanarMovement == 0) {
|
||||
this->nonPlanarMovement = 0x100;
|
||||
}
|
||||
} else {
|
||||
this->direction |= 0xFF;
|
||||
}
|
||||
|
||||
if (this->field_0x20 == 0) {
|
||||
this->field_0x20 = 0x1E000;
|
||||
}
|
||||
|
||||
if (this->collisionLayer == 2) {
|
||||
sub_08016A30(this);
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_080810FC(Entity* this) {
|
||||
if (this->entityType.form != 0x5F) {
|
||||
sub_08081598(this);
|
||||
} else {
|
||||
this->action = 2;
|
||||
this->previousActionFlag = 0;
|
||||
this->flags |= 0x80;
|
||||
this->flags2 = 0x11;
|
||||
CopyPosition(&gPlayerEntity, this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08081134(Entity* this) {
|
||||
sub_080814A4(this);
|
||||
this->field_0x6c.HWORD += 80;
|
||||
sub_08081150(this);
|
||||
}
|
||||
|
||||
static void sub_08081150(Entity* this) {
|
||||
this->action = 2;
|
||||
this->flags |= 0x80;
|
||||
this->height.HALF.HI = -0x80;
|
||||
this->spriteOrientation.flipY = 1;
|
||||
this->spriteRendering.b3 = 1;
|
||||
PlaySFX(0x12D);
|
||||
}
|
||||
|
||||
static void sub_08081188(Entity* this) {
|
||||
this->action = 2;
|
||||
this->flags |= 0x80;
|
||||
if (this->collisionLayer == 2) {
|
||||
sub_08016A30(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_080811AC(Entity* this) {
|
||||
this->action = 2;
|
||||
this->spriteSettings.b.draw = 0;
|
||||
this->field_0x6e.HWORD = GetTileTypeByEntity(this);
|
||||
}
|
||||
|
||||
void sub_080811C8(Entity* this) {
|
||||
this->action = 2;
|
||||
this->spriteSettings.b.draw = 0;
|
||||
}
|
||||
|
||||
void sub_080811D8(Entity* this) {
|
||||
sub_08081188(this);
|
||||
PlaySFX(0x215);
|
||||
}
|
||||
|
||||
void sub_080811EC(Entity* this) {
|
||||
if (this->field_0x68.HALF.HI != 6) {
|
||||
sub_080AEFE0(this);
|
||||
} else {
|
||||
sub_0806F69C(this);
|
||||
}
|
||||
|
||||
sub_08003FC4(this, 0x2800);
|
||||
if (this->field_0x20 <= 0) {
|
||||
this->action = 2;
|
||||
this->flags |= 0x80;
|
||||
sub_080814A4(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0808122C(Entity* this) {
|
||||
gUnk_0811E814[this->field_0x68.HALF.HI](this);
|
||||
}
|
||||
|
||||
void sub_08081248(Entity* this) {
|
||||
sub_08081500(this);
|
||||
if (sub_080814C0(this)) {
|
||||
sub_08081404(this, 0);
|
||||
} else {
|
||||
sub_0800442E(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0808126C(Entity* this) {
|
||||
UpdateAnimationSingleFrame(this);
|
||||
sub_0808153C(this);
|
||||
}
|
||||
|
||||
void sub_0808127C(Entity* this) {
|
||||
if (sub_080814C0(this)) {
|
||||
sub_08081404(this, 0);
|
||||
} else {
|
||||
sub_0808153C(this);
|
||||
}
|
||||
}
|
||||
|
||||
void nullsub_113(Entity* this) {
|
||||
}
|
||||
|
||||
void sub_080812A0(Entity* this) {
|
||||
sub_08081500(this);
|
||||
}
|
||||
|
||||
void sub_080812A8(Entity* this) {
|
||||
if (sub_080002D0(this) != 0xF && this->field_0x6e.HWORD != GetTileTypeByEntity(this)) {
|
||||
this->direction = 0;
|
||||
this->nonPlanarMovement = 0;
|
||||
this->spriteSettings.b.draw = 1;
|
||||
this->field_0x68.HALF.HI = 0;
|
||||
sub_080810A8(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_080812E8(Entity* this) {
|
||||
PlayerState* playerState = &gPlayerState;
|
||||
if ((playerState->swimState & 0x80) &&
|
||||
!(playerState->flags.all & 0x80) &&
|
||||
sub_080177A0(this, &gPlayerEntity)) {
|
||||
sub_080810FC(this);
|
||||
}
|
||||
}
|
||||
|
||||
void nullsub_510(Entity* this) {
|
||||
}
|
||||
|
||||
void sub_08081328(Entity* this) {
|
||||
Entity* other = this->attachedEntity;
|
||||
if (!(other->entityType.type == 8 && other->entityType.subtype == 3)) {
|
||||
sub_08081404(this, 0);
|
||||
} else {
|
||||
CopyPosition(other, this);
|
||||
this->height.HALF.HI--;
|
||||
other = &gPlayerEntity;
|
||||
if (sub_080177A0(this, other)) {
|
||||
sub_080810FC(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0808136C(Entity* this) {
|
||||
if (--this->actionDelay) {
|
||||
Entity* other = this->attachedEntity;
|
||||
this->x.WORD = other->x.WORD;
|
||||
this->y.WORD = other->y.WORD;
|
||||
this->spriteOrientation.flipY = other->spriteOrientation.flipY;
|
||||
this->spriteRendering.b3 = other->spriteRendering.b3;
|
||||
sub_08003FC4(this, 0x2800);
|
||||
} else {
|
||||
sub_08081404(this, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_080813BC(Entity* this) {
|
||||
gUnk_0811E840[this->previousActionFlag](this);
|
||||
}
|
||||
|
||||
void sub_080813D4(Entity* this) {
|
||||
this->previousActionFlag = 1;
|
||||
this->field_0x1d = 1;
|
||||
this->spriteSettings.b.draw = 1;
|
||||
}
|
||||
|
||||
void sub_080813E8(Entity* this) {
|
||||
sub_0806F4E8(this);
|
||||
}
|
||||
|
||||
void sub_080813F0(Entity* this) {
|
||||
if (sub_0806F3E4(this)) {
|
||||
sub_080810FC(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08081404(Entity* this, u32 arg1) {
|
||||
if (arg1 && this->field_0x86) {
|
||||
SetFlag(this->field_0x86);
|
||||
}
|
||||
|
||||
DeleteThisEntity();
|
||||
}
|
||||
|
||||
bool32 sub_08081420(Entity* this) {
|
||||
if (CheckShouldPlayItemGetCutscene(this)) {
|
||||
sub_0805E3A0(this, 6);
|
||||
CreateItemEntity(this->entityType.form, this->entityType.parameter, 0);
|
||||
return TRUE;
|
||||
} else {
|
||||
GiveItem(this->entityType.form, this->entityType.parameter);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static bool32 CheckShouldPlayItemGetCutscene(Entity* this) {
|
||||
bool32 result = FALSE;
|
||||
if ((gUnk_080FD5B4[this->entityType.form].unk0[3] & 0x2) || !GetInventoryValue(this->entityType.form)) {
|
||||
result = TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static u8 sub_0808147C(u32 arg0) {
|
||||
const Unk_0811E84C* var0 = &gUnk_0811E84C[arg0];
|
||||
return var0->unk4;
|
||||
}
|
||||
|
||||
void sub_0808148C(u32 arg0) {
|
||||
const Unk_0811E84C* var0 = &gUnk_0811E84C[arg0];
|
||||
if (var0->sfx) {
|
||||
PlaySFX(var0->sfx);
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_080814A4(Entity* this) {
|
||||
if (this->field_0x68.HALF.HI == 10) {
|
||||
this->field_0x6c.HWORD = 120;
|
||||
} else {
|
||||
this->field_0x6c.HWORD = 600;
|
||||
}
|
||||
}
|
||||
|
||||
static u32 sub_080814C0(Entity* this) {
|
||||
if (!sub_0805E40C(this)) {
|
||||
if (--this->field_0x6c.HWORD == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (this->field_0x6c.HWORD < 90) {
|
||||
this->spriteSettings.b.draw ^= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void sub_08081500(Entity* this) {
|
||||
if (this->field_0x68.HALF.LO == 0) {
|
||||
u32 var0 = sub_080044EC(this, 0x2800);
|
||||
if (var0 == 0) {
|
||||
this->field_0x68.HALF.LO = 1;
|
||||
} else {
|
||||
if (var0 == 1) {
|
||||
sub_0808148C(this->entityType.form);
|
||||
UpdateSpriteForCollisionLayer(this);
|
||||
}
|
||||
|
||||
sub_080AEFE0(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_0808153C(Entity* this) {
|
||||
if (this->field_0x68.HALF.LO > 1)
|
||||
return;
|
||||
|
||||
if (this->field_0x68.HALF.LO == 0) {
|
||||
if (!sub_08003FC4(this, 0x1000) && !sub_0800442E(this)) {
|
||||
this->field_0x68.HALF.LO = 1;
|
||||
this->field_0x20 = 0x1E000;
|
||||
sub_0808148C(this->entityType.form);
|
||||
UpdateSpriteForCollisionLayer(this);
|
||||
}
|
||||
} else {
|
||||
if (!sub_08003FC4(this, 0x2800)) {
|
||||
this->field_0x68.HALF.LO = 2;
|
||||
sub_0808148C(this->entityType.form);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_08081598(Entity* this) {
|
||||
if (this->currentHealth == 0) {
|
||||
sub_08081404(this, 1);
|
||||
}
|
||||
|
||||
this->flags &= 0x7F;
|
||||
this->action = 4;
|
||||
this->actionDelay = 14;
|
||||
this->field_0x20 = 0x20000;
|
||||
this->spriteSettings.b.draw = 1;
|
||||
this->spritePriority.b1 = 2;
|
||||
this->spritePriority.b0 = 3;
|
||||
this->attachedEntity = &gPlayerEntity;
|
||||
CopyPosition(this->attachedEntity, this);
|
||||
this->height.HALF.HI -= 4;
|
||||
if (this->entityType.form != 0x5F && sub_08081420(this)) {
|
||||
sub_08081404(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,9 @@ extern BoundingBox gUnk_080FD340; // TODO: should be const
|
||||
|
||||
extern u32 sub_08016A30(Entity*);
|
||||
extern u32 sub_080001DA(u32, u32);
|
||||
extern u32 GetTileTypeByEntity(Entity*);
|
||||
extern void sub_08078930(Entity*);
|
||||
extern u32 sub_080002B8(Entity*);
|
||||
extern void sub_08016A6C(Entity*);
|
||||
extern u32 sub_0800442E(Entity*);
|
||||
|
||||
void Pot(Entity* this) {
|
||||
gUnk_0811F090[this->action](this);
|
||||
|
||||
Reference in New Issue
Block a user