Decompile some functions

This commit is contained in:
octorock
2022-03-28 17:30:56 +02:00
parent c86ada3e3d
commit eb1158855b
38 changed files with 935 additions and 2299 deletions
+1 -2
View File
@@ -231,7 +231,6 @@ void EraseAllEntities(void) {
}
extern Entity gUnk_030015A0[0x48];
extern Entity gCarriedEntity;
NONMATCH("asm/non_matching/GetEmptyEntity.inc", Entity* GetEmptyEntity()) {
u8 flags_ip;
@@ -262,7 +261,7 @@ NONMATCH("asm/non_matching/GetEmptyEntity.inc", Entity* GetEmptyEntity()) {
ClearDeletedEntity(ptr);
return ptr;
}
} while (++ptr < &gCarriedEntity);
} while (++ptr < (Entity*)&gCarriedEntity);
flags_ip = 0;
rv = NULL;
+28 -1
View File
@@ -246,6 +246,8 @@ extern void (*const gUnk_080FD138[])(void);
extern const u16 gUnk_080FD964[];
extern void sub_0801B170(void);
void GameTask(void) {
static GameState* const sStates[] = {
GameTask_Transition,
@@ -1865,7 +1867,32 @@ void sub_0805373C(void) {
gUnk_080FCD40[gMenu.overlayType]();
}
ASM_FUNC("asm/non_matching/game/sub_08053758.inc", void sub_08053758())
void sub_08053758(void) {
gMenu.overlayType = 1;
gMenu.transitionTimer = 0x78;
gMenu.field_0xa = 0x1e;
*((u8*)&gMenu + 0x10) = 0; // TODO
gUI.field_0x6 = 1;
gMapBottom.bgControlPtr = NULL;
gMapTop.bgControlPtr = NULL;
gRoomControls.camera_target = NULL;
gRoomControls.scroll_y = 0;
gRoomControls.scroll_x = 0;
sub_0801B170();
DispReset(0);
gScreen.lcd.displayControl = 0x2640;
gScreen.controls.layerFXControl = 0x2244;
gScreen.controls.alphaBlend = 0x1000;
gScreen.controls.windowInsideControl = 0x1f;
gScreen.controls.windowOutsideControl = 0x3f;
gScreen.controls.window0HorizontalDimensions = 0xf0;
gScreen.controls.window0VerticalDimensions = 0x60;
gScreen.bg1.control = 0x1c4e;
gScreen.bg2.control = 0x1dc1;
SoundReq(BGM_STORY);
ResetSystemPriority();
SetFade(5, 0x100);
}
ASM_FUNC("asm/non_matching/game/sub_08053800.inc", void sub_08053800())
-1
View File
@@ -14,7 +14,6 @@ extern u8 gUnk_03003DE0;
extern u8 gUnk_03000C30;
extern u8 gUpdateVisibleTiles;
extern Entity gCarriedEntity;
extern Entity* gPlayerClones[3];
extern u16 gUnk_080B2CD8[];
+64 -1
View File
@@ -2,6 +2,8 @@
#include "item.h"
#include "functions.h"
#include "sound.h"
#include "effects.h"
#include "object.h"
extern void (*const gUnk_0811BE04[])(ItemBehavior*, u32);
@@ -12,6 +14,10 @@ extern s32 sub_0800875A(Entity*, u32, ItemBehavior*);
extern void UpdatePlayerMovement(void);
extern bool32 sub_0807B5B0(Entity*);
extern const s16 gUnk_0811BE16[];
void ItemMoleMitts(ItemBehavior* this, u32 arg1) {
gUnk_0811BE04[this->stateID](this, arg1);
}
@@ -83,7 +89,64 @@ void sub_080771C8(ItemBehavior* this, u32 arg1) {
}
}
ASM_FUNC("asm/non_matching/itemMoleMitts/sub_080772A8.inc", void sub_080772A8(ItemBehavior* this, u32 arg1))
void sub_080772A8(ItemBehavior* this, u32 param_2) {
Entity* effect;
if (((this->field_0x5[9] & 8) != 0) && sub_08077F10(this)) {
this->field_0x5[2] = 1;
}
if (GetInventoryValue(ITEM_DIG_BUTTERFLY) == 1) {
if ((this->field_0x5[9] & 7) != 3) {
sub_08077E3C(this, 2);
gPlayerEntity.speed = gUnk_0811BE16[this->field_0x5[9] & 7] << 1;
} else {
UpdateItemAnim(this);
gPlayerEntity.speed = gUnk_0811BE16[this->field_0x5[9] & 7];
}
} else {
UpdateItemAnim(this);
gPlayerEntity.speed = gUnk_0811BE16[this->field_0x5[9] & 7];
}
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
if (gPlayerEntity.speed != 0) {
UpdatePlayerMovement();
}
if ((this->field_0x5[9] & 0x10) != 0) {
if (this->field_0x5[2] != 0) {
gPlayerEntity.frameDuration = 1;
if (sub_080774A0()) {
this->field_0x5[2] = 0;
return;
}
}
DeletePlayerItem(this, param_2);
gPlayerState.field_0x3c[1] = 0;
} else {
if ((this->field_0x5[9] & 0x60) != 0) {
gPlayerEntity.frameDuration = 1;
if (sub_0807B5B0(&gPlayerEntity)) {
SoundReq(SFX_108);
CreateObjectWithParent(&gPlayerEntity, OBJECT_1E, this->field_0x5[9], 0);
} else {
sub_08077DF4(this, 0x51c);
effect = CreateFx(&gPlayerEntity, FX_STARS_STRIKE, 0);
if (effect != NULL) {
effect->animationState = this->field_0x5[5];
effect->spritePriority.b0 = gPlayerEntity.spritePriority.b0 - 1;
}
effect = CreateFx(&gPlayerEntity, FX_STARS_STRIKE, 0);
if (effect != NULL) {
effect->animationState = this->field_0x5[5];
effect->spritePriority.b0 = gPlayerEntity.spritePriority.b0 - 1;
effect->field_0xf = 1;
}
this->stateID = 3;
this->field_0x5[0] = 1;
SoundReq(SFX_ITEM_GLOVES_KNOCKBACK);
}
}
}
}
void sub_08077448(ItemBehavior* this, u32 arg1) {
gPlayerEntity.direction = gPlayerEntity.animationState << 2 ^ 0x10;
+54 -3
View File
@@ -1,17 +1,68 @@
#include "item.h"
#include "functions.h"
#include "sound.h"
extern void (*const gUnk_0811BDB4[])(ItemBehavior*, u32);
u32 sub_08077F64(ItemBehavior* arg0, u32 unk);
u32 sub_080789A8(void);
void sub_080762C4(ItemBehavior*, void*, u8, u32);
void sub_08076088(ItemBehavior*, void*, u32);
void ItemTryPickupObject(ItemBehavior* this, u32 arg1) {
gUnk_0811BDB4[this->stateID](this, arg1);
}
ASM_FUNC("asm/non_matching/itemTryPickupObject/ItemPickupCheck.inc", void ItemPickupCheck(ItemBehavior* this, u32 arg1))
void ItemPickupCheck(ItemBehavior* this, u32 param_2) {
Entity* entity;
void sub_080762C4(ItemBehavior* this, u32 arg1, u8 arg2, u32 arg3) {
if (!(((gPlayerState.field_0x3[1] != 0) ||
(((gPlayerState.jump_status != 0 && ((gPlayerState.flags & (PL_BUSY | PL_FALLING | PL_IN_MINECART)) == 0)) ||
(gPlayerState.field_0x0[1] = gPlayerEntity.animationState | 0x80, 8 < gPlayerEntity.iframes)))))) {
switch (sub_080789A8()) {
case 2:
if (((gCarriedEntity.unk_8)->field_0x16 & 0xf) == 0) {
sub_08076088(this, gCarriedEntity.unk_8, param_2);
return;
}
entity = gCarriedEntity.unk_8;
this->field_0x18 = entity;
entity->action = 2;
entity->subAction = 5;
gPlayerState.framestate = 5;
sub_080762C4(this, entity, 2, param_2);
gUnk_0200AF00.unk_2e = 8;
SoundReq(SFX_102);
break;
case 1:
sub_080762C4(this, 0, 1, param_2);
SoundReq(SFX_102);
break;
case 0:
this->stateID = 5;
this->field_0x5[2] = 0x0f;
this->field_0xf = 6;
gPlayerState.field_0xa = (8 >> param_2) | gPlayerState.field_0xa;
gPlayerState.keepFacing = (8 >> param_2) | gPlayerState.keepFacing;
if ((gPlayerState.flags & PL_NO_CAP) == 0) {
sub_08077DF4(this, 0x378);
} else {
sub_08077DF4(this, 0x948);
}
SoundReq(SFX_88);
break;
default:
break;
}
} else {
sub_08077F50(this, param_2);
}
}
void sub_080762C4(ItemBehavior* this, void* arg1, u8 arg2, u32 arg3) {
this->field_0x18 = arg1;
gPlayerState.heldObject = arg2;
sub_08077D38(this, arg3);
@@ -25,7 +76,7 @@ void sub_08076488(ItemBehavior* this, u32 arg1) {
if (this->field_0x5[2] == 0) {
if (sub_08077F64(this, arg1) != 0) {
if (((*(u8*)((this->field_0x18) + 0x16) & 0xf0) == 0x10) && ((gRoomTransition.frameCount & 1U) != 0)) {
if ((((this->field_0x18->field_0x16) & 0xf0) == 0x10) && ((gRoomTransition.frameCount & 1U) != 0)) {
return;
}
UpdateItemAnim(this);
+78 -3
View File
@@ -34,6 +34,17 @@ Entity* sub_0806D00C(Entity* this);
void sub_0806D4C0(Entity*, u32);
extern const u8 gUnk_08114100[];
typedef struct {
s8 type;
s8 x;
s8 y;
u8 direction;
} struct_08114104;
extern const struct_08114104 gUnk_08114104[];
void BigGoron(Entity* this) {
gUnk_081140D4[this->type](this);
}
@@ -85,7 +96,27 @@ Entity* sub_0806D00C(Entity* this) {
return entity;
}
ASM_FUNC("asm/non_matching/bigGoron/sub_0806D02C.inc", void sub_0806D02C(Entity* this))
void sub_0806D02C(Entity* this) {
s32 tmp1;
s32 tmp2;
sub_0806D164(this);
gScreen.lcd.displayControl |= 0x4000;
gScreen.controls.windowInsideControl = 0x3f3f;
gScreen.controls.windowOutsideControl = 0x3d;
tmp1 = -(s16)gScreen.bg1.xOffset;
tmp2 = tmp1 + 0x100;
tmp1 = min(max(0, tmp1), 0xf0);
tmp2 = min(max(0, tmp2), 0xf0);
gScreen.controls.window1HorizontalDimensions = (tmp1 << 8) | tmp2;
tmp1 = -(s16)gScreen.bg1.yOffset;
tmp2 = tmp1 + 0x100;
tmp1 = min(max(0, tmp1), 0xa0);
tmp2 = min(max(0, tmp2), 0xa0);
gScreen.controls.window1VerticalDimensions = (tmp1 << 8) | tmp2;
}
void sub_0806D0B0(Entity* this) {
gMapTop.bgControlPtr = 0;
@@ -310,7 +341,39 @@ void sub_0806D514(Entity* this) {
sub_0806D520(this, 3);
}
ASM_FUNC("asm/non_matching/bigGoron/sub_0806D520.inc", void sub_0806D520(Entity* this, u32 param))
void sub_0806D520(Entity* this, u32 param_2) {
if (this->action == 0) {
this->action = 1;
this->field_0xf = gUnk_08114100[param_2] + 6;
this->frameIndex = this->field_0xf;
this->actionDelay = 8;
}
this->x.HALF.HI = this->parent->x.HALF.HI;
this->y.HALF.HI = this->parent->y.HALF.HI;
this->spriteOffsetX = this->parent->spriteOffsetX;
this->spriteOffsetY = this->parent->spriteOffsetY;
this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY;
if (this->subAction != 0 ||
CheckPlayerProximity(this->x.HALF.HI + param_2 * -0x10 + 0xc, this->y.HALF.HI, 0x18, 0x40)) {
if (this->frameIndex >= this->field_0xf + 2) {
return;
}
if (--this->actionDelay != 0) {
return;
}
this->actionDelay = 8;
this->frameIndex++;
} else {
if (this->frameIndex <= this->field_0xf) {
return;
}
if (--this->actionDelay != 0) {
return;
}
this->actionDelay = 8;
this->frameIndex--;
}
}
void sub_0806D5D4(void) {
u32 itemSlot;
@@ -357,7 +420,19 @@ void sub_0806D66C(Entity* this) {
this->spriteOrientation.flipY = 2;
}
ASM_FUNC("asm/non_matching/bigGoron/sub_0806D67C.inc", void sub_0806D67C(Entity* this))
void sub_0806D67C(Entity* this) {
const struct_08114104* ptr = gUnk_08114104;
while (ptr->type != -1) {
Entity* effect = CreateFx(this, ptr->type, 0x40);
if (effect != NULL) {
effect->x.HALF.HI = ptr->x + effect->x.HALF.HI;
effect->y.HALF.HI = ptr->y + effect->y.HALF.HI;
effect->direction = ptr->direction;
effect->speed = 0x100;
}
ptr++;
}
}
void sub_0806D6D0(void) {
Entity* entity = FindEntity(NPC, BIG_GORON, 7, 2, 0);
+61 -3
View File
@@ -10,10 +10,68 @@ extern u16 gUnk_08113078[];
extern void sub_08095BE0(Entity*, u32);
ASM_FUNC("asm/non_matching/librarians/Librarians.inc", void Librarians(Entity* this))
extern const u8 gUnk_08114F30[];
ASM_FUNC("asm/non_matching/librarians/sub_0806BA34.inc",
void sub_0806BA34(Entity* this, ScriptExecutionContext* context))
void Librarians(Entity* this) {
if (this->action == 0) {
this->action = 1;
sub_0807DD50(this);
this->spriteRendering.b3 = gUnk_08114F30[this->spriteRendering.b3];
}
ExecuteScriptForEntity(this, NULL);
HandleEntity0x82Actions(this);
GetNextFrame(this);
}
void sub_0806BA34(Entity* this, ScriptExecutionContext* context) {
u32 gotBook1;
u32 gotBook2;
u32 gotBook3;
u32 message = 0x4912;
context->condition = 0;
if (CheckLocalFlag(0x73)) {
message = 0x4913;
} else {
gotBook1 = GetInventoryValue(ITEM_QST_BOOK1);
gotBook2 = GetInventoryValue(ITEM_QST_BOOK2);
gotBook3 = GetInventoryValue(ITEM_QST_BOOK3);
if (gotBook1 == 1) {
message = 0x4906;
context->condition = 1;
SetLocalFlag(0x6b);
SetLocalFlag(0x6a);
} else if (gotBook2 == 1) {
message = 0x4907;
context->condition = 1;
SetLocalFlag(0x6b);
SetLocalFlag(0x6a);
} else if (gotBook3 == 1) {
message = 0x4908;
context->condition = 1;
SetLocalFlag(0x6b);
SetLocalFlag(0x6a);
} else {
if (CheckLocalFlag(0x6a)) {
if (!CheckLocalFlag(0x6b)) {
message = 0x4901;
SetLocalFlag(0x6b);
} else {
if (gotBook1 == 0) {
message = 0x4902;
SetLocalFlag(0x6b);
} else if (gotBook2 == 0) {
message = 0x4903;
SetLocalFlag(0x6d);
} else if (gotBook3 == 0) {
message = 0x4904;
SetLocalFlag(0x70);
}
}
}
}
}
MessageNoOverlap(message, this);
}
void sub_0806BB1C(Entity* this, ScriptExecutionContext* context) {
s32 item = 0xffffffff;
+65 -1
View File
@@ -14,6 +14,11 @@ extern Hitbox gUnk_080B3E18;
extern u8 gUnk_080B3DE0[];
extern Hitbox* gUnk_080B3DE8[];
extern u32 sub_08007DD6(u32, const u16*);
extern const u16 gUnk_080B3DF4[];
extern const u8 gUnk_08003E44[];
void PlayerItem11(Entity* this) {
if (this->health) {
this->iframes = 0;
@@ -93,7 +98,66 @@ void sub_08018DE8(Entity* this) {
sub_08078CD0(&gPlayerEntity);
}
ASM_FUNC("asm/non_matching/playerItem11/sub_08018E68.inc", void sub_08018E68(Entity* this))
void sub_08018E68(Entity* this) {
s32 y;
s32 x;
if (this->child == NULL) {
GetNextFrame(this);
sub_08008790(this, 5);
} else {
if ((this->child->field_0x3a & 4) == 0) {
DeleteThisEntity();
}
if ((this->bitfield & 0x80) != 0) {
sub_08018F6C(this);
return;
}
}
if (this->actionDelay-- != 0) {
LinearMoveUpdate(this);
switch (this->direction) {
case DirectionNorth:
x = 0;
y = -4;
break;
case DirectionSouth:
x = 0;
y = 4;
break;
case DirectionWest:
x = -4;
y = 0;
break;
case DirectionEast:
x = 4;
y = 0;
break;
}
if (this->child != NULL) {
this->child->direction = this->direction;
CopyPosition(this, this->child);
}
if (this->type2 == 0) {
sub_0800451C(this);
}
if (sub_08007DD6(sub_080B1A0C(this, x, y), gUnk_080B3DF4) != 0) {
return;
}
if (GetRelativeCollisionTile(this, x, y) == 0x74) {
return;
}
if (sub_080040D8(this, (u8*)gUnk_08003E44, this->x.HALF.HI + x, this->y.HALF.HI + y) == 0) {
return;
}
}
if (this->child == NULL) {
InitializeAnimation(this, this->type + 0xd);
}
this->action++;
sub_08018F6C(this);
}
void sub_08018F6C(Entity* this) {
if (this->child != NULL) {
+197 -5
View File
@@ -1,26 +1,218 @@
#define NENT_DEPRECATED
#include "entity.h"
#include "functions.h"
#include "player.h"
#include "new_player.h"
#include "asm.h"
#include "effects.h"
#include "functions.h"
#include "player.h"
#include "new_player.h"
#include "sound.h"
#include "functions.h"
#include "new_player.h"
#include "player.h"
extern void (*const gUnk_081320A8[])(Entity*);
typedef struct {
Entity base;
u8 unk_68[4];
u16 unk_6c;
u16 unk_6e;
} PlayerItem13Entity;
extern bool32 ProcessMovement10(Entity*);
extern const s8 gUnk_081320C4[];
bool32 sub_080AD32C(PlayerItem13Entity*);
void sub_080AD27C(PlayerItem13Entity*);
u32 sub_0806F8DC(Entity*);
extern const u16 gUnk_081320CC[];
extern const u32 gUnk_081320D4[];
void PlayerItem13(Entity* this) {
gUnk_081320A8[this->subAction](this);
}
ASM_FUNC("asm/non_matching/playerItem13/sub_080ACF2C.inc", void sub_080ACF2C(Entity* this))
ASM_FUNC("asm/non_matching/playerItem13/sub_080ACFCC.inc", void sub_080ACFCC(Entity* this))
void sub_080ACFCC(PlayerItem13Entity* this) {
Entity* child = super->child;
if ((this->unk_6c == child->kind) || (this->unk_6e == child->id)) {
if (child->action != 2) {
sub_08079184();
DeleteThisEntity();
} else {
if ((gPlayerState.heldObject == 0) || ((gNewPlayerEntity.unk_79 & 0x7f) != 0)) {
sub_080AD27C(this);
super->subAction++;
super->flags &= 0x7f;
super->direction = 0xff;
super->zVelocity = 0;
}
}
} else {
sub_08079184();
DeleteThisEntity();
}
}
ASM_FUNC("asm/non_matching/playerItem13/sub_080AD040.inc", void sub_080AD040(Entity* this))
void sub_080AD040(PlayerItem13Entity* this) {
PlayerItem13Entity* child;
u32 tile;
u32 tmp;
child = (PlayerItem13Entity*)super->child;
if ((child->base).action != 2) {
DeleteThisEntity();
}
if ((super->bitfield & 0x80) != 0) {
super->z.WORD = 0;
}
if (super->speed != 0) {
if ((super->knockbackDuration & 0x80) != 0) {
super->direction = super->knockbackDirection;
super->knockbackDuration = 0;
}
if (GetRelativeCollisionTile(super, gUnk_081320C4[super->direction >> 2],
gUnk_081320C4[(super->direction >> 2) + 1]) == 0x74) {
LinearMoveUpdate(super);
} else {
tile = sub_080B1B0C(super);
if ((tile != 0x24) && (tile != 0x26)) {
ProcessMovement10(super);
}
}
if (GravityUpdate(super, 0x2000) == 0) {
(child->base).zVelocity = super->zVelocity;
(child->base).x = super->x;
(child->base).y = super->y;
(child->base).z = super->z;
tile = GetTileUnderEntity(super);
switch (tile) {
case 0xd:
case 0x10:
case 0x11:
case 0x13:
case 0x5a:
if (child == this) {
switch (tile) {
case 0xd:
CreateFx(super, FX_FALL_DOWN, 0);
break;
case 0x5a:
CreateFx(super, FX_LAVA_SPLASH, 0);
break;
case 0x10:
case 0x11:
CreateFx(super, FX_WATER_SPLASH, 0);
break;
case 0x13:
CreateFx(super, FX_GREEN_SPLASH, 0);
break;
}
(child->base).subAction = 4;
} else {
(child->base).subAction = 3;
}
DeleteThisEntity();
break;
}
if (super->child == super) {
if (super->type2 != 0xff) {
if (super->type2 == 0x0f) {
CreateFx(super, super->actionDelay, 0x80);
} else {
CreateObjectWithParent(super, super->type2, super->actionDelay, 0);
}
}
DeleteThisEntity();
} else {
if (super->actionDelay != 0 || sub_080AD32C(child)) {
if (super->actionDelay == 1) {
SoundReq(SFX_104);
}
UpdateSpriteForCollisionLayer(super);
child->base.subAction = 3;
child->base.spriteRendering.b3 = super->spriteRendering.b3;
child->base.spriteOrientation.flipY = super->spriteOrientation.flipY;
child->base.spritePriority.b0 = super->spritePriority.b0;
DeleteThisEntity();
} else {
SoundReq(SFX_104);
super->actionDelay++;
super->zVelocity = 0x10000;
super->speed /= 2;
return;
}
}
} else {
sub_0800451C(super);
sub_0806F8DC(super);
CopyPosition(super, (Entity*)child);
(child->base).zVelocity = super->zVelocity;
(child->base).direction = super->direction;
return;
}
} else {
tmp = gPlayerEntity.frame & 1;
if (tmp != 0) {
SoundReq(SFX_PLY_VO5);
sub_080AD27C(this);
return;
}
if ((gPlayerState.heldObject != 0) && ((gNewPlayerEntity.unk_79 & 0x80) == 0)) {
return;
}
sub_080AD27C(this);
super->flags &= 0x7f;
super->direction = 0xff;
super->zVelocity = tmp & 1;
return;
}
}
void sub_080AD274(Entity* this) {
DeleteThisEntity();
}
ASM_FUNC("asm/non_matching/playerItem13/sub_080AD27C.inc", void sub_080AD27C(Entity* this))
void sub_080AD27C(PlayerItem13Entity* this) {
u32 tmp;
PlayerItem13Entity* child = (PlayerItem13Entity*)super->child;
gNewPlayerEntity.unk_74 = NULL;
if ((this->unk_6c == (u16)(child->base).kind) && (this->unk_6e == (u16)(child->base).id)) {
if (child != this) {
(child->base).subAction = 2;
} else {
super->spritePriority.b1 = 3;
}
super->hitbox = (child->base).hitbox;
tmp = super->field_0x16 >> 4;
super->speed = gUnk_081320CC[tmp];
super->zVelocity = gUnk_081320D4[tmp];
(child->base).z.HALF.HI += 8;
super->z.HALF.HI = (child->base).z.HALF.HI;
super->collisionLayer = (child->base).collisionLayer;
super->y.HALF.HI = gPlayerEntity.y.HALF.HI;
super->x.HALF.HI = gPlayerEntity.x.HALF.HI;
super->field_0x3c = gPlayerEntity.field_0x3c;
super->flags |= 0x80;
sub_0801766C(super);
} else {
sub_08079184();
DeleteThisEntity();
}
}
bool32 sub_080AD32C(Entity* this) {
bool32 sub_080AD32C(PlayerItem13Entity* this) {
bool32 result = FALSE;
if (((this->field_0x16 & 0xf0) == 0x10) || ((this->kind == OBJECT && ((this->id == 5 || (this->id == 0x7d)))))) {
if (((super->field_0x16 & 0xf0) == 0x10) ||
((super->kind == OBJECT && ((super->id == 5 || (super->id == 0x7d)))))) {
result = TRUE;
}
return result;
+99 -28
View File
@@ -1,45 +1,54 @@
#define NENT_DEPRECATED
#include "entity.h"
#include "player.h"
#include "functions.h"
#include "asm.h"
#include "item.h"
typedef struct {
Entity base;
u32 unk_68;
} PlayerItemBombEntity;
extern void (*const gUnk_080B77C8[])(Entity*);
void sub_0801B418(Entity*);
void sub_0801B3A4(Entity*);
void sub_0801B3A4(PlayerItemBombEntity*);
extern void (*const gUnk_080B77D8[])(Entity*);
void PlayerItemBomb(Entity* this) {
extern const Hitbox gUnk_080B77F4;
void PlayerItemBomb(PlayerItemBombEntity* this) {
u8 uVar1, uVar2;
gUnk_080B77C8[this->action](this);
GetNextFrame(this);
// TODO regalloc
uVar2 = uVar1 = this->action;
gUnk_080B77C8[super->action](super);
GetNextFrame(super);
uVar2 = uVar1 = super->action;
if (uVar1 != 0x03) {
if (this->actionDelay != 0) {
if (this->field_0x68.HALF.LO == 7) {
this->actionDelay -= 1;
if (super->actionDelay != 0) {
if (*(u8*)&this->unk_68 == 7) {
super->actionDelay -= 1;
}
if (this->actionDelay == 0) {
this->field_0xf = 0x50;
*(u32*)&this->field_0x68 = 0;
this->spriteRendering.b0 = 3;
SetAffineInfo(this, 0x100, 0x100, 0);
if (super->actionDelay == 0) {
super->field_0xf = 0x50;
this->unk_68 = 0;
super->spriteRendering.b0 = 3;
SetAffineInfo(super, 0x100, 0x100, 0);
}
} else {
if (this->field_0xf != 0) {
if (this->field_0xf-- == 0x01) {
if ((uVar1 == 0x02) && (this->subAction == 1)) {
if (super->field_0xf != 0) {
if (super->field_0xf-- == 0x01) {
if ((uVar1 == 0x02) && (super->subAction == 1)) {
gPlayerState.heldObject = 0;
}
this->action = 0x03;
this->spritePriority.b1 = 2;
this->actionDelay = 0x0f;
this->spriteSettings.draw = 0;
sub_0805EC60(this);
FreeCarryEntity(this);
CreateObjectWithParent(this, 0x20, 0, 0);
sub_0801B418(this);
super->action = 0x03;
super->spritePriority.b1 = 2;
super->actionDelay = 0x0f;
super->spriteSettings.draw = 0;
sub_0805EC60(super);
FreeCarryEntity(super);
CreateObjectWithParent(super, 0x20, 0, 0);
sub_0801B418(super);
} else {
sub_0801B3A4(this);
}
@@ -48,9 +57,50 @@ void PlayerItemBomb(Entity* this) {
}
}
ASM_FUNC("asm/non_matching/playerItemBomb/sub_0801B250.inc", void sub_0801B250(Entity* this))
void sub_0801B250(PlayerItemBombEntity* this) {
super->spriteSettings.draw = 1;
super->action = 1;
super->spritePriority.b1 = 3;
super->flags &= 0x7f;
if (super->type == 0xff) {
super->actionDelay = 0x3c;
} else if (super->type == 0xfe) {
super->actionDelay = 0x0f;
super->type = 0xff;
} else {
super->actionDelay = 0x96;
}
super->hitbox = (Hitbox*)&gUnk_080B77F4;
super->field_0x16 = 0;
if (*(u8*)&this->unk_68 == 7) {
InitializeAnimation(super, 5);
} else {
InitializeAnimation(super, 0x15);
}
}
ASM_FUNC("asm/non_matching/playerItemBomb/sub_0801B2CC.inc", void sub_0801B2CC(Entity* this))
void sub_0801B2CC(PlayerItemBombEntity* this) {
u16 unaff_r5;
if (!sub_0800442E(super)) {
RegisterCarryEntity(super);
}
switch (IsItemEquipped(ITEM_REMOTE_BOMBS)) {
case 0:
unaff_r5 = 1;
break;
case 1:
unaff_r5 = 2;
break;
case 2:
unaff_r5 = 0;
break;
}
if ((unaff_r5 & gPlayerState.field_0x92) != 0) {
super->actionDelay = 0;
super->field_0xf = 1;
}
}
void sub_0801B318(Entity* this) {
gUnk_080B77D8[this->subAction](this);
@@ -87,7 +137,28 @@ void sub_0801B38C(Entity* this) {
}
}
ASM_FUNC("asm/non_matching/playerItemBomb/sub_0801B3A4.inc", void sub_0801B3A4(Entity* this))
void sub_0801B3A4(PlayerItemBombEntity* this) {
u32 tmp;
if (super->field_0xf >= 0x29) {
tmp = 8;
} else {
tmp = 4;
if ((this->unk_68 & 0x8000) != 0) {
this->unk_68 -= 0x10;
} else {
this->unk_68 += 0x10;
}
if (0x7f < (this->unk_68 & 0xf0) - 1) {
this->unk_68 ^= 0x8000;
}
SetAffineInfo(super, 0x130 - (this->unk_68 & 0xf0), 0x130 - (this->unk_68 & 0xf0), 0);
}
if ((super->field_0xf & tmp) == 0) {
super->palette.b.b0 = 0;
} else {
super->palette.b.b0 = super->palette.b.b4;
}
}
void sub_0801B418(Entity* this) {
s32 x;
+88 -2
View File
@@ -1,18 +1,104 @@
#define NENT_DEPRECATED
#include "global.h"
#include "asm.h"
#include "entity.h"
#include "functions.h"
#include "effects.h"
#include "object.h"
extern void (*const gUnk_080B3E30[])(Entity*);
typedef struct {
Entity base;
u8 unk_68;
u8 unk_69[3];
u32 unk_6c;
u32 unk_70;
u32 unk_74;
u32 unk_78;
} PlayerItemBowEntity;
typedef struct {
s8 x;
s8 y;
u8 spriteSettings;
u8 unk_3;
s8 unk_4;
s8 unk_5;
u8 animIndex;
u8 unk_7;
Hitbox* hitbox;
} struct_080B3E40;
extern const struct_080B3E40 gUnk_080B3E40[];
void sub_0801917C(PlayerItemBowEntity*);
void PlayerItemBow(Entity* this) {
gUnk_080B3E30[(this->action)](this);
}
ASM_FUNC("asm/non_matching/playerItemBow/sub_08018FE4.inc", void sub_08018FE4(Entity* this))
void sub_08018FE4(PlayerItemBowEntity* this) {
Entity* object;
const struct_080B3E40* ptr;
super->action = 1;
if (super->type != 0) {
super->spriteSettings.draw = 1;
super->flags |= 0x80;
this->unk_74 = 0x6a;
super->hurtType = super->type2;
super->spriteIndex = 0xa6;
if (super->hurtType == 0x0e) {
super->speed = 0x400;
} else {
super->speed = 0x300;
}
super->direction = super->animationState << 2;
super->field_0x3c = gPlayerEntity.field_0x3c + 1;
super->flags2 = gPlayerEntity.flags2;
if (super->collisionLayer == 2) {
super->type2 = 1;
} else {
super->type2 = 0;
}
super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY;
ptr = &gUnk_080B3E40[super->animationState >> 1];
super->x.HALF.HI = gPlayerEntity.x.HALF.HI + ptr->x;
super->y.HALF.HI = gPlayerEntity.y.HALF.HI + ptr->y;
super->spriteSettings.flipX = ptr->spriteSettings;
super->spriteSettings.flipY = ptr->unk_3;
super->animIndex = ptr->animIndex;
this->unk_6c = ptr->unk_4;
this->unk_70 = ptr->unk_5;
super->hitbox = ptr->hitbox;
sub_0801766C(super);
if (super->hurtType == 0x0e) {
super->animIndex += 6;
super->spriteVramOffset = 0;
}
InitializeAnimation(super, super->animIndex);
SoundReq(SFX_FC);
} else {
super->updatePriority = 6;
super->frameIndex = 0xff;
super->spriteSettings.flipX = gUnk_080B3E40[super->animationState >> 1].spriteSettings;
gPlayerState.item = super;
LoadSwapGFX(super, 1, 3);
sub_08079BD8(super);
if (this->unk_68 == 0xa) {
this->unk_78 = 0x3c;
object = CreateObject(OBJECT_43, super->type, 1);
if (object != NULL) {
CopyPosition(super, object);
}
} else {
this->unk_78 = 0;
}
sub_0801917C(this);
}
}
ASM_FUNC("asm/non_matching/playerItemBow/sub_0801917C.inc", void sub_0801917C(Entity* this))
ASM_FUNC("asm/non_matching/playerItemBow/sub_0801917C.inc", void sub_0801917C(PlayerItemBowEntity* this))
void sub_08019410(Entity* this) {
if (this->actionDelay < 0xf) {
+41 -1
View File
@@ -1,11 +1,15 @@
#include "entity.h"
#include "player.h"
#include "functions.h"
#include "item.h"
#include "object.h"
extern void (*const gUnk_080FEEA8[])(Entity*);
void sub_08054AC8(Entity*);
extern const s8 gUnk_080FEEB0[];
void PlayerItemLantern(Entity* this) {
gUnk_080FEEA8[this->action](this);
this->bitfield = 0;
@@ -29,4 +33,40 @@ void sub_08054A60(Entity* this) {
sub_08054AC8(this);
}
ASM_FUNC("asm/non_matching/playerItemLantern/sub_08054AC8.inc", void sub_08054AC8(Entity* this))
void sub_08054AC8(Entity* this) {
Entity* object;
this->animationState = gPlayerEntity.animationState & 0xe;
this->hitbox->offset_x = gUnk_080FEEB0[this->animationState];
this->hitbox->offset_y = gUnk_080FEEB0[this->animationState + 1];
this->hitbox->width = 4;
this->hitbox->height = 4;
if (!((gPlayerEntity.frameIndex < 0x37) && ((u32)gPlayerEntity.spriteIndex == 6))) {
this->frameIndex = 0xff;
this->flags &= ~ENT_COLLIDE;
} else {
this->flags |= ENT_COLLIDE;
this->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX;
this->spriteSettings.flipY = gPlayerEntity.spriteSettings.flipY;
if (gPlayerEntity.frameIndex != this->frameIndex) {
this->frameIndex = gPlayerEntity.frameIndex;
sub_080042D0(this, this->frameIndex, this->spriteIndex);
}
this->frame = gPlayerEntity.frame;
this->frameSpriteSettings = gPlayerEntity.frameSpriteSettings;
}
if (IsItemEquipped(ITEM_LANTERN_ON) < 2) {
if (((this->frameIndex != 0xff) && (gPlayerEntity.spriteSettings.draw != 0)) && (this->actionDelay-- == 0)) {
this->actionDelay = 4;
object = CreateObject(OBJECT_45, 0, 0x10);
if (object != NULL) {
PositionRelative(this, object, 0, 0x20000);
object->spritePriority.b0 = this->spritePriority.b0;
object->spriteOffsetX = gUnk_080FEEB0[this->animationState];
object->spriteOffsetY = gUnk_080FEEB0[this->animationState + 1];
}
}
sub_08078E84(this, &gPlayerEntity);
} else {
DeleteThisEntity();
}
}
+122 -8
View File
@@ -1,10 +1,22 @@
#define NENT_DEPRECATED
#include "entity.h"
#include "functions.h"
#include "sound.h"
extern void (*const gUnk_0812905C[])(Entity*);
extern u8 gUnk_08129096[];
typedef struct {
Entity base;
u8 unk_68;
} PlayerItemSwordEntity;
void sub_080A78B8(PlayerItemSwordEntity*, Entity*);
void sub_080A7B98(PlayerItemSwordEntity*);
void sub_080A7A54(PlayerItemSwordEntity*);
void PlayerItemSword(Entity* this) {
gUnk_0812905C[this->action](this);
if (this->type == 0) {
@@ -18,20 +30,122 @@ ASM_FUNC("asm/non_matching/playerItemSword/sub_080A758C.inc", void sub_080A758C(
ASM_FUNC("asm/non_matching/playerItemSword/sub_080A76CC.inc", void sub_080A76CC(Entity* this))
ASM_FUNC("asm/non_matching/playerItemSword/sub_080A7824.inc", void sub_080A7824(Entity* this))
void sub_080A7824(PlayerItemSwordEntity* this) {
if (gPlayerState.item != super) {
DeleteThisEntity();
}
if (gPlayerState.field_0x3[1] != 0) {
if (gPlayerState.jump_status == 0) {
gPlayerState.item = NULL;
DeleteThisEntity();
}
if ((gPlayerEntity.frame & 0x80) != 0) {
gPlayerState.item = NULL;
DeleteThisEntity();
} else {
sub_080A78B8(this, &gPlayerEntity);
if ((gPlayerEntity.frame & 0x20) != 0) {
SoundReq(SFX_PLY_VO3);
}
if (super->frameIndex > 0x8a) {
super->frameIndex = 0xff;
}
if ((gPlayerEntity.frame & 8) != 0) {
super->flags |= ENT_COLLIDE;
sub_080A7B98(this);
} else {
super->flags &= ~ENT_COLLIDE;
}
}
} else {
gPlayerState.item = NULL;
DeleteThisEntity();
}
}
ASM_FUNC("asm/non_matching/playerItemSword/sub_080A78B8.inc", void sub_080A78B8(Entity* this))
void sub_080A78B8(PlayerItemSwordEntity* this, Entity* param_2) {
u32 flipX;
void sub_080A7A54(Entity* this) {
if ((gPlayerState.sword_state & 0x20) != 0) {
super->frameIndex = param_2->frameIndex - 0x6a;
if ((gRoomTransition.frameCount & 4) != 0) {
sub_080042D0(super, (super->animationState >> 1) + 0xb1, super->spriteIndex);
} else {
sub_080042D0(super, super->frameIndex, super->spriteIndex);
}
} else {
if (param_2->frameIndex - 0x6a != super->frameIndex) {
super->frameIndex = param_2->frameIndex - 0x6a;
sub_080042D0(super, (u32)super->frameIndex, super->spriteIndex);
}
}
if ((gPlayerState.sword_state & 0x40) != 0) {
super->spriteSettings.flipX = 0;
} else {
if ((param_2->animationState & 2) != 0) {
flipX = param_2->spriteSettings.flipX ^ 1;
} else {
flipX = param_2->spriteSettings.flipX;
}
super->spriteSettings.flipX = flipX;
}
if ((super->bitfield & 0x80) != 0) {
if ((param_2->iframes == 0) || ((u8)param_2->iframes == 0x81)) {
param_2->iframes = super->iframes;
param_2->knockbackDirection = super->knockbackDirection;
param_2->knockbackDuration = super->knockbackDuration;
super->knockbackDuration = 0;
super->knockbackDirection = 0;
super->iframes = 0;
}
if ((gPlayerState.flags & 0x8000000) != 0) {
gPlayerState.sword_state |= 0x80;
} else if (gPlayerState.sword_state != 0) {
switch (super->bitfield & 0x7f) {
case 0x44:
break;
case 0x43:
case 0xd:
gPlayerState.sword_state |= 8;
param_2->knockbackDuration = 2;
if ((gPlayerState.sword_state & 0x20) == 0) {
gPlayerState.sword_state &= 0xfe;
}
break;
default:
if ((gPlayerState.sword_state & 0xc0) == 0) {
gPlayerState.sword_state = 0;
gPlayerState.field_0x3[1] = 0;
gPlayerState.item = NULL;
DeleteThisEntity();
}
break;
}
}
}
if (super->iframes != 0) {
if (super->iframes >= 1) {
super->iframes--;
} else {
super->iframes++;
}
}
sub_080A7A54(this);
if ((*(u8*)&super->spriteSettings * 0x2000000) < 0) { // TODO
super->hitbox->offset_x = -super->hitbox->offset_x;
}
}
void sub_080A7A54(PlayerItemSwordEntity* this) {
u8* tmp;
tmp = &gUnk_08129096[(gPlayerEntity.frameIndex - 0x6a) * 4];
this->hitbox->offset_x = tmp[0];
this->hitbox->offset_y = tmp[1];
this->hitbox->width = tmp[2];
this->hitbox->height = tmp[3];
super->hitbox->offset_x = tmp[0];
super->hitbox->offset_y = tmp[1];
super->hitbox->width = tmp[2];
super->hitbox->height = tmp[3];
}
ASM_FUNC("asm/non_matching/playerItemSword/sub_080A7A84.inc", void sub_080A7A84(Entity* this))
ASM_FUNC("asm/non_matching/playerItemSword/sub_080A7B98.inc", void sub_080A7B98(Entity* this))
ASM_FUNC("asm/non_matching/playerItemSword/sub_080A7B98.inc", void sub_080A7B98(PlayerItemSwordEntity* this))
+18 -2
View File
@@ -819,9 +819,25 @@ s32 sub_08078904(Entity* entity) {
return -1;
}
ASM_FUNC("asm/non_matching/playerUtils/RegisterCarryEntity.inc", void RegisterCarryEntity(Entity* a))
void RegisterCarryEntity(Entity* this) {
if (gCarriedEntity.count < 0x20) {
gCarriedEntity.unk_c[gCarriedEntity.count] = this;
gCarriedEntity.count++;
}
}
ASM_FUNC("asm/non_matching/playerUtils/FreeCarryEntity.inc", void FreeCarryEntity(Entity* a))
void FreeCarryEntity(Entity* this) {
u32 index;
for (index = 0; index < gCarriedEntity.count; index++) {
if (gCarriedEntity.unk_c[index] == this) {
gCarriedEntity.count--;
break;
}
}
for (; index < gCarriedEntity.count; index++) {
gCarriedEntity.unk_c[index] = gCarriedEntity.unk_c[index + 1];
}
}
ASM_FUNC("asm/non_matching/playerUtils/sub_080789A8.inc", u32 sub_080789A8())