Use new entity structs in a few more files

This commit is contained in:
octorock 2023-12-30 18:42:30 +01:00
parent 3b87c04162
commit 5676cb7890
12 changed files with 93 additions and 76 deletions

View File

@ -0,0 +1,13 @@
#ifndef HOUSESIGN_H
#define HOUSESIGN_H
#include "entity.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ s16 unk_80;
/*0x82*/ s16 unk_82;
} HouseSignEntity;
#endif // HOUSESIGN_H

View File

@ -0,0 +1,13 @@
#ifndef ITEMFORSALE_H
#define ITEMFORSALE_H
#include "object.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[0x18];
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
} ItemForSaleEntity;
#endif // ITEMFORSALE_H

View File

@ -1,7 +1,7 @@
#define ENT_DEPRECATED
#include "entity.h" #include "entity.h"
#include "functions.h" #include "functions.h"
#include "item.h" #include "item.h"
#include "new_player.h"
#include "playeritem.h" #include "playeritem.h"
void (*const ItemGustJar_StateFunctions[])(ItemBehavior* this, u32); void (*const ItemGustJar_StateFunctions[])(ItemBehavior* this, u32);
@ -20,7 +20,7 @@ void sub_08076DF4(ItemBehavior* this, u32 index) {
this->priority |= 0x80; this->priority |= 0x80;
this->priority++; this->priority++;
gPlayerState.gustJarSpeed = 1; gPlayerState.gustJarSpeed = 1;
*(u32*)&gPlayerEntity.field_0x74 = 0; gNewPlayerEntity.unk_74 = NULL;
gPlayerState.field_0x1c = 1; gPlayerState.field_0x1c = 1;
sub_08077BB8(this); sub_08077BB8(this);
} else { } else {
@ -87,7 +87,7 @@ void sub_08076EC8(ItemBehavior* this, u32 index) {
void sub_08076F64(ItemBehavior* this, u32 index) { void sub_08076F64(ItemBehavior* this, u32 index) {
Entity* item; Entity* item;
Entity* player; PlayerEntity* player;
switch (gPlayerState.field_0x1c & 0xf) { switch (gPlayerState.field_0x1c & 0xf) {
case 5: case 5:
if (this->playerFrame & 0x80) { if (this->playerFrame & 0x80) {
@ -95,15 +95,15 @@ void sub_08076F64(ItemBehavior* this, u32 index) {
this->subtimer = 0; this->subtimer = 0;
this->timer = 0; this->timer = 0;
gPlayerState.gustJarSpeed = 1; gPlayerState.gustJarSpeed = 1;
player = &gPlayerEntity; player = &gNewPlayerEntity;
*(u32*)&player->field_0x74 = 0; player->unk_74 = NULL;
gPlayerState.field_0x1c = 1; gPlayerState.field_0x1c = 1;
gPlayerState.field_0xa &= ~(8 >> index); gPlayerState.field_0xa &= ~(8 >> index);
this->stateID = 2; this->stateID = 2;
SetItemAnim(this, ANIM_GUSTJAR_SUCK); SetItemAnim(this, ANIM_GUSTJAR_SUCK);
item = CreatePlayerItem(PLAYER_ITEM_GUST, 0, 0, 0); item = CreatePlayerItem(PLAYER_ITEM_GUST, 0, 0, 0);
if (item) { if (item) {
item->parent = player; item->parent = &player->base;
} }
return; return;
} else { } else {
@ -137,7 +137,7 @@ void sub_08076F64(ItemBehavior* this, u32 index) {
UpdateItemAnim(this); UpdateItemAnim(this);
if (this->playerFrame & 1) { if (this->playerFrame & 1) {
gPlayerState.field_0x1c = 5; gPlayerState.field_0x1c = 5;
gPlayerEntity.field_0x70.WORD = 0; gNewPlayerEntity.unk_70 = NULL;
if (gPlayerState.gustJarSpeed) { if (gPlayerState.gustJarSpeed) {
CreatePlayerItem(PLAYER_ITEM_GUST_BIG, 0, 0, 0); CreatePlayerItem(PLAYER_ITEM_GUST_BIG, 0, 0, 0);
} }
@ -169,7 +169,7 @@ void sub_08076F64(ItemBehavior* this, u32 index) {
break; break;
} }
gPlayerState.field_0x1c = 0; gPlayerState.field_0x1c = 0;
gPlayerEntity.field_0x70.WORD = 0; gNewPlayerEntity.unk_70 = NULL;
DeleteItemBehavior(this, index); DeleteItemBehavior(this, index);
} }

View File

@ -1,9 +1,9 @@
#define ENT_DEPRECATED
#include "item.h"
#include "functions.h" #include "functions.h"
#include "sound.h"
#include "object.h"
#include "game.h" #include "game.h"
#include "item.h"
#include "new_player.h"
#include "object.h"
#include "sound.h"
extern s8 gUnk_08126EEC[]; extern s8 gUnk_08126EEC[];
extern Entity* CreatePlayerItemForItemIfNotExists(ItemBehavior*); extern Entity* CreatePlayerItemForItemIfNotExists(ItemBehavior*);
@ -98,7 +98,7 @@ void sub_08075B54(ItemBehavior* this, u32 index) {
gPlayerEntity.collisionLayer, 0x40) != 0)) { gPlayerEntity.collisionLayer, 0x40) != 0)) {
this->animPriority = 0xf; this->animPriority = 0xf;
this->stateID++; this->stateID++;
gPlayerEntity.field_0x7a.HWORD = 2; gNewPlayerEntity.unk_7a = 2;
object = CreateObjectWithParent(&gPlayerEntity, LAMP_PARTICLE, 1, 0); object = CreateObjectWithParent(&gPlayerEntity, LAMP_PARTICLE, 1, 0);
if (object != NULL) { if (object != NULL) {
object->spriteVramOffset = gPlayerEntity.spriteVramOffset; object->spriteVramOffset = gPlayerEntity.spriteVramOffset;
@ -129,6 +129,6 @@ void sub_08075C9C(ItemBehavior* this, u32 index) {
gPlayerState.field_0xa = (~(8 >> index)) & gPlayerState.field_0xa; gPlayerState.field_0xa = (~(8 >> index)) & gPlayerState.field_0xa;
gPlayerState.keepFacing = (~(8 >> index)) & gPlayerState.keepFacing; gPlayerState.keepFacing = (~(8 >> index)) & gPlayerState.keepFacing;
} else { } else {
gPlayerEntity.field_0x7a.HWORD++; gNewPlayerEntity.unk_7a++;
} }
} }

View File

@ -1,6 +1,6 @@
#define ENT_DEPRECATED
#include "functions.h" #include "functions.h"
#include "item.h" #include "item.h"
#include "new_player.h"
#include "sound.h" #include "sound.h"
extern void ResetPlayerVelocity(void); extern void ResetPlayerVelocity(void);
@ -14,7 +14,7 @@ void ItemOcarina(ItemBehavior* this, u32 index) {
OcarinaUpdate, OcarinaUpdate,
}; };
gOcarinaStates[this->stateID](this, index); gOcarinaStates[this->stateID](this, index);
gPlayerEntity.field_0x7a.HWORD++; gNewPlayerEntity.unk_7a++;
} }
void OcarinaUse(ItemBehavior* this, u32 index) { void OcarinaUse(ItemBehavior* this, u32 index) {
@ -25,7 +25,7 @@ void OcarinaUse(ItemBehavior* this, u32 index) {
gPlayerEntity.animationState = 0x04; gPlayerEntity.animationState = 0x04;
gPlayerEntity.spriteSettings.flipX = 0; gPlayerEntity.spriteSettings.flipX = 0;
gPlayerEntity.flags &= ~ENT_COLLIDE; gPlayerEntity.flags &= ~ENT_COLLIDE;
gPlayerEntity.field_0x7a.HWORD = 2; gNewPlayerEntity.unk_7a = 2;
gPlayerState.flags |= PL_USE_OCARINA; gPlayerState.flags |= PL_USE_OCARINA;
gPlayerState.field_0x27[0] = -1; gPlayerState.field_0x27[0] = -1;
gPauseMenuOptions.disabled = 1; gPauseMenuOptions.disabled = 1;

View File

@ -1,7 +1,7 @@
#define ENT_DEPRECATED
#include "item.h"
#include "sound.h"
#include "functions.h" #include "functions.h"
#include "item.h"
#include "new_player.h"
#include "sound.h"
void sub_08076758(ItemBehavior*, u32); void sub_08076758(ItemBehavior*, u32);
extern void sub_08077F84(void); extern void sub_08077F84(void);
@ -67,18 +67,18 @@ void sub_08076758(ItemBehavior* this, u32 index) {
if (this->stateID < 2) { if (this->stateID < 2) {
if ((gPlayerEntity.zVelocity <= 0) && ((gPlayerState.jump_status & 0x10) == 0)) { if ((gPlayerEntity.zVelocity <= 0) && ((gPlayerState.jump_status & 0x10) == 0)) {
this->stateID = 2; this->stateID = 2;
gPlayerEntity.field_0x7a.HWORD = 2; gNewPlayerEntity.unk_7a = 2;
gPlayerEntity.zVelocity = Q_16_16(2.0); gPlayerEntity.zVelocity = Q_16_16(2.0);
gPlayerState.jump_status |= 0x10; gPlayerState.jump_status |= 0x10;
gPlayerState.animation = ANIM_ROCS_CAPE; gPlayerState.animation = ANIM_ROCS_CAPE;
SoundReq(SFX_172); SoundReq(SFX_172);
} }
} else { } else {
gPlayerEntity.field_0x7a.HWORD++; gNewPlayerEntity.unk_7a++;
} }
} else { } else {
if (this->stateID > 1) { if (this->stateID > 1) {
gPlayerEntity.field_0x7a.HWORD++; gNewPlayerEntity.unk_7a++;
gPlayerState.jump_status &= 0xef; gPlayerState.jump_status &= 0xef;
} }
} }

View File

@ -1,6 +1,6 @@
#define ENT_DEPRECATED
#include "functions.h" #include "functions.h"
#include "item.h" #include "item.h"
#include "new_player.h"
#include "playeritem.h" #include "playeritem.h"
#include "sound.h" #include "sound.h"
@ -39,8 +39,8 @@ void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) {
gPlayerState.framestate = 4; gPlayerState.framestate = 4;
this->stateID = 2; this->stateID = 2;
this->animPriority = 0xf; this->animPriority = 0xf;
if ((gPlayerEntity.field_0x78.HALF.HI & 0x80)) { if ((gNewPlayerEntity.unk_79 & 0x80)) {
gPlayerEntity.field_0x78.HALF.HI = 0; gNewPlayerEntity.unk_79 = 0;
COLLISION_ON(&gPlayerEntity); COLLISION_ON(&gPlayerEntity);
gPlayerState.heldObject = 4; gPlayerState.heldObject = 4;
gPlayerState.keepFacing = ~(8 >> param_3) & gPlayerState.keepFacing; gPlayerState.keepFacing = ~(8 >> param_3) & gPlayerState.keepFacing;
@ -56,11 +56,11 @@ void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) {
if (param_2 == NULL) { if (param_2 == NULL) {
PlayerCancelHoldItem(this, param_3); PlayerCancelHoldItem(this, param_3);
} else { } else {
Entity* playerEnt = &gPlayerEntity; PlayerEntity* playerEnt = &gNewPlayerEntity;
*(Entity**)&playerEnt->field_0x74 = param_2; playerEnt->unk_74 = param_2;
playerEnt->subtimer = 0; playerEnt->base.subtimer = 0;
param_2->child = this->field_0x18; param_2->child = this->field_0x18;
param_2->carryFlags = playerEnt->carryFlags; param_2->carryFlags = playerEnt->base.carryFlags;
param_2->parent = (Entity*)this; param_2->parent = (Entity*)this;
this->field_0x18 = param_2; this->field_0x18 = param_2;
param_2->type2 = this->field_0x2[1]; param_2->type2 = this->field_0x2[1];

View File

@ -6,10 +6,11 @@
* *
* If you leave the room without picking the item up and enter again, the item falls from the sky again. * If you leave the room without picking the item up and enter again, the item falls from the sky again.
*/ */
#define ENT_DEPRECATED
#include "manager/fallingItemManager.h" #include "manager/fallingItemManager.h"
#include "flags.h" #include "flags.h"
#include "object.h" #include "object.h"
#include "object/itemOnGround.h"
#include "room.h" #include "room.h"
void FallingItemManager_Init(FallingItemManager*); void FallingItemManager_Init(FallingItemManager*);
@ -33,13 +34,13 @@ void FallingItemManager_Init(FallingItemManager* this) {
void FallingItemManager_Action1(FallingItemManager* this) { void FallingItemManager_Action1(FallingItemManager* this) {
if (CheckFlags(this->field_0x3e)) { if (CheckFlags(this->field_0x3e)) {
Entity* object = CreateObject(GROUND_ITEM, super->type, super->type2); ItemOnGroundEntity* object = (ItemOnGroundEntity*)CreateObject(GROUND_ITEM, super->type, super->type2);
if (object != NULL) { if (object != NULL) {
object->timer = this->field_0x35; object->base.timer = this->field_0x35;
object->collisionLayer = this->field_0x36; object->base.collisionLayer = this->field_0x36;
object->x.HALF.HI = this->field_0x38 + gRoomControls.origin_x; object->base.x.HALF.HI = this->field_0x38 + gRoomControls.origin_x;
object->y.HALF.HI = this->field_0x3a + gRoomControls.origin_y; object->base.y.HALF.HI = this->field_0x3a + gRoomControls.origin_y;
object->field_0x86.HWORD = this->field_0x3c; object->unk_86 = this->field_0x3c;
} }
DeleteThisEntity(); DeleteThisEntity();
} }

View File

@ -4,12 +4,13 @@
* *
* @brief Spawns the shop items for the kinstones for the goron merchant. * @brief Spawns the shop items for the kinstones for the goron merchant.
*/ */
#define ENT_DEPRECATED
#include "manager/goronMerchantShopManager.h" #include "manager/goronMerchantShopManager.h"
#include "asm.h" #include "asm.h"
#include "flags.h" #include "flags.h"
#include "object.h"
#include "item.h" #include "item.h"
#include "object.h"
#include "object/itemForSale.h"
typedef struct { typedef struct {
u16 minType; u16 minType;
@ -60,17 +61,17 @@ void GoronMerchantShopManager_Main(GoronMerchantShopManager* this) {
count = 0; count = 0;
for (count = 0; count < 3;) { for (count = 0; count < 3;) {
if (CheckGlobalFlag(GORON_KAKERA_L + count) == 0) { if (CheckGlobalFlag(GORON_KAKERA_L + count) == 0) {
Entity* object = ItemForSaleEntity* object = (ItemForSaleEntity*)CreateObject(
CreateObject(SHOP_ITEM, ITEM_KINSTONE, ((s32)Random() % spawnData->numTypes) + spawnData->minType); SHOP_ITEM, ITEM_KINSTONE, ((s32)Random() % spawnData->numTypes) + spawnData->minType);
if (object != NULL) { if (object != NULL) {
object->timer = 1; object->base.timer = 1;
object->subtimer = count; object->base.subtimer = count;
object->x.HALF.HI = spawnData->x + gRoomControls.origin_x; object->base.x.HALF.HI = spawnData->x + gRoomControls.origin_x;
object->y.HALF.HI = spawnData->y + gRoomControls.origin_y; object->base.y.HALF.HI = spawnData->y + gRoomControls.origin_y;
object->field_0x80.HWORD = spawnData->x; object->unk_80 = spawnData->x;
object->field_0x82.HWORD = spawnData->y; object->unk_82 = spawnData->y;
object->collisionLayer = 1; object->base.collisionLayer = 1;
object->parent = (Entity*)this; object->base.parent = (Entity*)this;
this->itemActive[count] = 1; this->itemActive[count] = 1;
} }
} }

View File

@ -7,12 +7,13 @@
* Spawns HOUSE_SIGN objects that check this and unsets the value in the bitfield. * Spawns HOUSE_SIGN objects that check this and unsets the value in the bitfield.
* Creates the signs on the houses in hyrule town. * Creates the signs on the houses in hyrule town.
*/ */
#define ENT_DEPRECATED
#include "manager/houseSignManager.h" #include "manager/houseSignManager.h"
#include "area.h" #include "area.h"
#include "object.h"
#include "room.h"
#include "asm.h" #include "asm.h"
#include "object.h"
#include "object/houseSign.h"
#include "room.h"
typedef struct { typedef struct {
u16 x; u16 x;
@ -57,15 +58,15 @@ void HouseSignManager_Main(HouseSignManager* this) {
u32 bitfieldFlag = 1 << type2; u32 bitfieldFlag = 1 << type2;
if ((((this->bitfield & bitfieldFlag) == 0) && if ((((this->bitfield & bitfieldFlag) == 0) &&
(CheckRectOnScreen(spawnData->x, spawnData->y, 0x10, 0x10) != 0))) { (CheckRectOnScreen(spawnData->x, spawnData->y, 0x10, 0x10) != 0))) {
Entity* object = CreateObject(HOUSE_SIGN, spawnData->type, type2); HouseSignEntity* object = (HouseSignEntity*)CreateObject(HOUSE_SIGN, spawnData->type, type2);
if (object != NULL) { if (object != NULL) {
object->frameIndex = spawnData->frameIndex; object->base.frameIndex = spawnData->frameIndex;
object->x.HALF.HI = gRoomControls.origin_x + spawnData->x; object->base.x.HALF.HI = gRoomControls.origin_x + spawnData->x;
object->y.HALF.HI = gRoomControls.origin_y + spawnData->y; object->base.y.HALF.HI = gRoomControls.origin_y + spawnData->y;
object->parent = (Entity*)this; object->base.parent = (Entity*)this;
object->field_0x80.HWORD = spawnData->x; object->unk_80 = spawnData->x;
object->field_0x82.HWORD = spawnData->y; object->unk_82 = spawnData->y;
object->collisionLayer = spawnData->collisionLayer; object->base.collisionLayer = spawnData->collisionLayer;
this->bitfield |= bitfieldFlag; this->bitfield |= bitfieldFlag;
} }
} }

View File

@ -4,15 +4,9 @@
* *
* @brief HouseSign object * @brief HouseSign object
*/ */
#include "asm.h" #include "object/houseSign.h"
#include "entity.h"
typedef struct { #include "asm.h"
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ s16 unk_80;
/*0x82*/ s16 unk_82;
} HouseSignEntity;
/* /*
This object is created by HouseSignManager. This object is created by HouseSignManager.

View File

@ -4,19 +4,13 @@
* *
* @brief Item for Sale object * @brief Item for Sale object
*/ */
#include "object/itemForSale.h"
#include "functions.h" #include "functions.h"
#include "hitbox.h" #include "hitbox.h"
#include "kinstone.h" #include "kinstone.h"
#include "message.h" #include "message.h"
#include "new_player.h" #include "new_player.h"
#include "object.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[0x18];
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
} ItemForSaleEntity;
typedef struct { typedef struct {
u8 before[0x20]; u8 before[0x20];