Document some player item stuff

This commit is contained in:
octorock
2022-08-09 18:48:05 +02:00
parent dd59d70447
commit ad44d63b73
134 changed files with 1616 additions and 1484 deletions
+7
View File
@@ -5,6 +5,7 @@
#include "entity.h"
/** Collisions. */
typedef enum {
COL_NONE = 0x0,
COL_NORTH_WEST = 0x2,
@@ -25,6 +26,12 @@ typedef enum {
COL_EAST_ANY = 0xe000,
} Collisions;
typedef enum {
RESULT_NO_COLLISION = 0,
RESULT_COLLISION = 1,
RESULT_COLLISION_WITHOUT_SET = 2,
} CollisionResult;
bool32 IsTileCollision(const u8*, s32, s32, u32);
bool32 IsColliding(Entity*, Entity*);
bool32 IsCollidingPlayer(Entity*);
+3 -3
View File
@@ -1,5 +1,5 @@
#ifndef ENEMY_OCTOROK_BOSS_H
#define ENEMY_OCTOROK_BOSS_H
#ifndef OCTOROKBOSS_H
#define OCTOROKBOSS_H
#include "enemy.h"
@@ -74,4 +74,4 @@ enum OctorokBossAction1SubAction {
ACTION1_ATTACK, // Attack
};
#endif
#endif // OCTOROKBOSS_H
+6 -6
View File
@@ -249,12 +249,12 @@ typedef void (*const* EntityActionArray)(Entity*);
*/
void DrawEntity(Entity* entity);
void InitializeAnimation(Entity*, u32);
void InitAnimationForceUpdate(Entity*, u32);
void UpdateAnimationSingleFrame(Entity*);
void UpdateSpriteForCollisionLayer(Entity*);
void GetNextFrame(Entity*);
u32 LoadExtraSpriteData(Entity*, const SpriteLoadData*);
void InitializeAnimation(Entity* entity, u32 animIndex);
void InitAnimationForceUpdate(Entity* entity, u32 animIndex);
void UpdateAnimationSingleFrame(Entity* entity);
void UpdateSpriteForCollisionLayer(Entity* entity);
void GetNextFrame(Entity* entity);
u32 LoadExtraSpriteData(Entity* entity, const SpriteLoadData* spriteData);
void SetExtraSpriteFrame(Entity*, u32, u32);
void SetSpriteSubEntryOffsetData1(Entity*, u32, u32);
void SetSpriteSubEntryOffsetData2(Entity*, u32, u32);
+1 -1
View File
@@ -149,7 +149,7 @@ void PutItemOnSlot(u32 item);
* @param item The item to equip.
* @param slot The slot to equip the item in.
*/
void ForceEquipItem(u32 item, u32 slot);
void ForceEquipItem(u32 item, /*EquipSlot*/ u32 slot);
/**
* Get item price.
+16 -1
View File
@@ -7,6 +7,7 @@
void CreateItemEntity(u32, u32, u32);
void sub_08081404(Entity*, u32);
extern void ExecuteItemFunction(ItemBehavior* this, u32 index);
extern void ItemDebug(ItemBehavior*, u32);
extern void ItemSword(ItemBehavior*, u32);
@@ -52,11 +53,12 @@ typedef enum {
ITEM_ORB_GREEN,
ITEM_ORB_BLUE,
ITEM_ORB_RED,
ITEM_TRAP,
ITEM_TRY_PICKUP_OBJECT,
ITEM_BOTTLE1,
ITEM_BOTTLE2,
ITEM_BOTTLE3,
ITEM_BOTTLE4,
// End of activatable items.
ITEM_BOTTLE_EMPTY,
ITEM_BOTTLE_BUTTER,
ITEM_BOTTLE_MILK,
@@ -151,4 +153,17 @@ typedef enum {
ITEM_ENEMY_BEETLE
} Item;
/** Slot that the item is equipped in. */
typedef enum { EQUIP_SLOT_A, EQUIP_SLOT_B, EQUIP_SLOT_NONE } EquipSlot;
/** Function used to create the item. */
typedef enum {
CREATE_ITEM_0,
CREATE_ITEM_1,
CREATE_ITEM_2,
CREATE_ITEM_3,
CREATE_ITEM_4,
CREATE_ITEM_5,
} CreateItemFunc;
#endif // ITEM_H
+1 -1
View File
@@ -227,7 +227,7 @@ typedef enum {
PINWHEEL,
OBJECT_BF,
ENEMY_ITEM,
OBJECT_C1,
LINK_ANIMATION,
} Object;
void ItemOnGround();
+61 -42
View File
@@ -12,7 +12,7 @@ enum PlayerActions {
PLAYER_JUMP,
PLAYER_PUSH,
PLAYER_BOUNCE,
PLAYER_08070E9C,
PLAYER_08070E9C, // sub_080782C0, only when PLAYER_INPUT_1000 is newInput
PLAYER_ITEMGET,
PLAYER_MINISH,
PLAYER_MINISHDIE,
@@ -236,35 +236,50 @@ typedef struct {
typedef enum {
PLAYER_INPUT_1 = 0x1, // A
PLAYER_INPUT_2 = 0x2, // B
PLAYER_INPUT_8 = 0x8, // A sub_080782C0, sub_0807953C, sub_0807AE20, sub_08076518. ItemForSale_Action2
PLAYER_INPUT_10 = 0x10, // B sub_0807953C, sub_0807ADB8, sub_08076518, ItemForSale_Action2
PLAYER_INPUT_8 = 0x8, // A sub_080782C0, sub_0807953C, PlayerUpdateSwimming, sub_08076518. ItemForSale_Action2
PLAYER_INPUT_10 = 0x10, // B sub_0807953C, ToggleDiving, sub_08076518, ItemForSale_Action2
PLAYER_INPUT_20 = 0x20, // R sub_0807953C
PLAYER_INPUT_40 = 0x40, // A CrenelBeanSprout_Action1
PLAYER_INPUT_80 = 0x80, // R sub_08073584, sub_080777A0, sub_080782C0, CrenelBeanSprout_Action1, ItemForSale_Action2
PLAYER_INPUT_80 =
0x80, // R sub_08073584, IsPreventedFromUsingItem, sub_080782C0, CrenelBeanSprout_Action1, ItemForSale_Action2
PLAYER_INPUT_RIGHT = 0x100,
PLAYER_INPUT_LEFT = 0x200,
PLAYER_INPUT_UP = 0x400,
PLAYER_INPUT_DOWN = 0x800,
PLAYER_INPUT_ANY_DIRECTION = 0xf00,
PLAYER_INPUT_1000 = 0x1000, // where is it set? sub_080782C0
PLAYER_INPUT_8000 = 0x8000, // R, sub_080778CC, sub_08076518
PLAYER_INPUT_1000 = 0x1000, // L, where is it set? sub_080782C0
PLAYER_INPUT_8000 = 0x8000, // R, IsTryingToPickupObject, sub_08076518
// TODO What is the result of u32 result = (s32) - (keys & 0x200) >> 0x1f & 0x1000;?
} PlayerInputState;
typedef struct {
/*0x90*/ u16 field_0x90;
/*0x92*/ u16 field_0x92;
/*0x90*/ u16 heldInput; /**< Input currently held @see PlayerInputState */
/*0x92*/ u16 newInput; /**< New input this frame @see PlayerInputState */
/*0x94*/ u32 field_0x94;
/*0x98*/ u16 playerMacroWaiting;
/*0x9a*/ u16 playerMacroHeldKeys;
/*0x9c*/ PlayerMacroEntry* playerMacro;
} PlayerInput;
typedef enum {
SWORD_MOVE_NONE,
SWORD_MOVE_SPIN,
SWORD_MOVE_ROLL,
SWORD_MOVE_DASH,
SWORD_MOVE_BREAK_POT,
SWORD_MOVE_FULL_BEAM,
SWORD_MOVE_GREAT_SPIN,
SWORD_MOVE_DOWN_THRUST,
SWORD_MOVE_LOW_BEAM,
} SwordMove;
typedef struct {
/*0x00*/ u8 field_0x0[2];
/*0x00*/ u8 prevAnim;
/*0x00*/ u8 grab_status;
/*0x02*/ u8 jump_status;
/*0x03*/ u8 field_0x3[2];
/*0x03*/ u8 shield_status;
/*0x04*/ u8 attack_status;
/*0x05*/ u8 heldObject;
/*0x06*/ u8 pushedObject; // hi bit is special, rest is used as a timer
/*0x07*/ u8 field_0x7;
@@ -272,8 +287,8 @@ typedef struct {
/*0x0a*/ u8 field_0xa;
/*0x0b*/ u8 keepFacing;
/*0x0c*/ u8 queued_action;
/*0x0d*/ u8 field_0xd;
/*0x0e*/ u8 field_0xe;
/*0x0d*/ u8 direction;
/*0x0e*/ u8 itemAnimPriority;
/*0x0f*/ u8 hurtBlinkSpeed;
/*0x10*/ u8 field_0x10;
/*0x11*/ u8 surfacePositionSameTimer;
@@ -291,7 +306,7 @@ typedef struct {
/*0x1f*/ u8 field_0x1f[3];
/*0x22*/ u16 tilePosition;
/*0x24*/ u16 tileType;
/*0x26*/ u8 swim_state;
/*0x26*/ u8 swim_state; /**< Is the player swimming? 0x80 for diving */
/*0x27*/ u8 field_0x27[5];
/*0x2c*/ Entity* item;
/*0x30*/ u32 flags;
@@ -323,10 +338,10 @@ typedef struct {
/*0xa0*/ ChargeState chargeState;
/*0xa8*/ u8 framestate;
/*0xa9*/ u8 framestate_last;
/*0xaa*/ u8 field_0xaa;
/*0xab*/ u8 field_0xab;
/*0xac*/ u16 skills; /**< Bitfield of skills @see PlayerSkill */
/*0xae*/ u16 field_0xae;
/*0xaa*/ u8 attachedBeetleCount; /**< Count of the Beetles attached to the player. */
/*0xab*/ u8 lastSwordMove; /**< The last move that has been performed with the sword. @see SwordMove */
/*0xac*/ u16 skills; /**< Bitfield of skills @see PlayerSkill */
/*0xae*/ u8 pad[2];
} PlayerState;
typedef struct {
@@ -359,23 +374,25 @@ typedef struct {
typedef struct {
/*0x0*/ u8 field_0x0;
/*0x1*/ u8 behaviorID;
/*0x1*/ u8 behaviorId;
/*0x2*/ u8 field_0x2[2];
/*0x4*/ u8 stateID;
/*0x5*/ u8 field_0x5;
/*0x6*/ u8 field_0x6;
/*0x7*/ u8 timer;
/*0x8*/ u8 subtimer;
/*0x9*/ u8 field_0x9;
/*0x9*/ u8 priority;
/*0xa*/ u8 playerAnimationState;
/*0xb*/ u8 direction;
/*0xc*/ u8 playerAnimIndex;
/*0xd*/ u8 playerFrameDuration;
/*0xe*/ u8 playerFrame;
/*0xf*/ u8 field_0xf;
/*0x10*/ u16 field_0x10;
/*0xf*/ u8 playerFrameIndex;
/*0x12*/ u8 field_0x12[5];
/*0xc*/ u8 playerAnimIndex; /**< Stored animIndex of the player entity. */
/*0xd*/ u8 playerFrameDuration; /**< Stored frameDuration of the player entity. */
/*0xe*/ u8
playerFrame; /**< Stored frame of the player entity. But also used for general purpose in item behaviours? */
/*0xf*/ u8
animPriority; /**< In sub_08079064 the animIndex of the ItemBehavior with the max animPriority is selected. */
/*0x10*/ u16 animIndex;
/*0x12*/ u8 playerFrameIndex; /**< Stored frameIndex of the player entity. */
/*0x13*/ u8 field_0x13[5];
/*0x18*/ Entity* field_0x18;
} ItemBehavior;
@@ -392,7 +409,7 @@ extern Entity gPlayerEntity;
void DoPlayerAction(Entity*);
bool32 CheckInitPauseMenu(void);
void SetPlayerControl(PlayerControlMode mode);
void ResetPlayerItem(void);
void ResetActiveItems(void);
void ResetPlayerVelocity(void);
void ResetPlayerAnimationAndAction(void);
void SetPlayerActionNormal(void);
@@ -407,7 +424,7 @@ void CreateEzloHint(u32, u32);
// game.c
/** @see Item */
u32 IsItemEquipped(u32);
/*EquipSlot*/ u32 IsItemEquipped(u32 itemId);
/** @see Item */
u32 GetInventoryValue(u32);
/** @see Item */
@@ -418,7 +435,7 @@ void ModBombs(s32 delta);
// playerUtils.c
void DeleteClones(void);
void sub_08077728(u32);
void CreateItemEquippedAtSlot(/*EquipSlot*/ u32 equipSlot);
void PutAwayItems(void);
void sub_08079E58(s32 speed, u32 direction);
void RespawnPlayer(void);
@@ -430,13 +447,13 @@ void PlayerMinishSetNormalAndCollide(void);
u32 sub_08079B24(void);
void sub_08079708(Entity*);
void sub_08079744(Entity*);
void sub_0807AE20(Entity*);
u32 sub_0807A894(Entity*);
void PlayerUpdateSwimming(Entity*);
u32 GetCollisionTileInFront(Entity*);
u32 sub_080797C4(void);
void CheckPlayerVelocity(void);
void sub_0807B068(Entity*);
u32 sub_0807A2F8(u32);
void sub_08077698(/* PlayerEntity* */);
void UpdateActiveItems(/* PlayerEntity* */);
bool32 sub_0807A2B8(void);
u32 sub_08079550(void);
u32 sub_080782C0(void);
@@ -467,20 +484,20 @@ void RegisterCarryEntity(Entity*);
void FreeCarryEntity(Entity*);
void PlayerDropHeldObject();
void PlayerResetStateFromFusion();
void DeletePlayerItem(ItemBehavior*, u32);
void DeleteItemBehavior(ItemBehavior*, u32);
void sub_08077D38(ItemBehavior*, u32);
void sub_08077DF4(ItemBehavior*, u32);
void SetItemAnim(ItemBehavior* this, u32 animIndex);
void sub_08077E3C(ItemBehavior*, u32);
void sub_080751E8(u32, u32, void*);
void sub_08077B98(ItemBehavior*);
void sub_08077BB8(ItemBehavior*);
Entity* sub_08077C0C(ItemBehavior*, u32);
Entity* sub_08077C94(ItemBehavior*, u32);
Entity* CreatePlayerItemIfNotExists(ItemBehavior*, u32);
Entity* FindPlayerItemForItem(ItemBehavior*, u32);
bool32 PlayerCanBeMoved(void);
bool32 sub_08077EC8(ItemBehavior*);
bool32 sub_08077EFC(ItemBehavior*);
bool32 sub_08077F10(ItemBehavior*);
bool32 sub_08077F24(ItemBehavior*, u32);
bool32 IsItemActive(ItemBehavior*);
bool32 IsItemActivatedThisFrame(ItemBehavior*);
bool32 IsItemActiveByInput(ItemBehavior*, PlayerInputState);
bool32 sub_08077FEC(u32);
void sub_08078180(void);
void sub_080784C8();
@@ -500,17 +517,19 @@ void sub_08079BD8(Entity*);
u32 sub_08079D48();
void sub_08079D84(void);
u32 sub_08079FC4(u32);
void sub_0807A050(void);
void UpdatePlayerPalette(void);
void sub_0807A5B8(u32);
void sub_0807A8D8(Entity*);
void sub_0807AA80(Entity*);
void sub_0807AABC(Entity*);
void sub_0807ACCC(Entity*);
u32 sub_0807B014();
void PlayerSwimming(Entity*);
u32 GetSwordBeam();
void sub_0807B0C8(void);
bool32 sub_0807BD14(Entity*, u32);
Entity* CreatePlayerItemWithParent(ItemBehavior*, u32);
bool32 HasSwordEquipped();
u32 GetPlayerPalette(bool32 use);
void PlayerShrinkByRay(void);
// player.s
extern u32 PlayerCheckNEastTile();
+12 -12
View File
@@ -5,27 +5,27 @@ typedef enum {
PLAYER_ITEM_NONE,
PLAYER_ITEM_SWORD,
PLAYER_ITEM_BOMB,
PLAYER_ITEM_3,
PLAYER_ITEM_BOOMERANG,
PLAYER_ITEM_BOW,
PLAYER_ITEM_SHIELD,
PLAYER_ITEM_LANTERN,
PLAYER_ITEM_7,
PLAYER_ITEM_NULLED,
PLAYER_ITEM_GUST_JAR,
PLAYER_ITEM_PACCI_CANE,
PLAYER_ITEM_A,
PLAYER_ITEM_B,
PLAYER_ITEM_C,
PLAYER_ITEM_NONE2, // Mole Mitts
PLAYER_ITEM_NONE3, // Rocs Cape
PLAYER_ITEM_DASH_SWORD,
PLAYER_ITEM_CELL_OVERWRITE_SET,
PLAYER_ITEM_BOTTLE,
PLAYER_ITEM_SWORD_BEAM1,
PLAYER_ITEM_10,
PLAYER_ITEM_11,
PLAYER_ITEM_12,
PLAYER_ITEM_13,
PLAYER_ITEM_14,
PLAYER_ITEM_15,
PLAYER_ITEM_GUST,
PLAYER_ITEM_GUST_BIG,
PLAYER_ITEM_PACCI_CANE_PROJECTILE,
PLAYER_ITEM_HELD_OBJECT,
PLAYER_ITEM_SPIRAL_BEAM,
PLAYER_ITEM_FIRE_ROD_PROJECTILE,
PLAYER_ITEM_SWORD_BEAM2,
PLAYER_ITEM_17,
PLAYER_ITEM_NULLED2,
PLAYER_ITEM_CELL_OVERWRITE_SET2,
} PlayerItem;
+4 -4
View File
@@ -113,13 +113,13 @@ typedef struct {
u8 animationState;
u8 field_0x6;
u8 field_0x7;
} struct_030010EC;
} MinecartData;
typedef struct {
u16 data[32];
u16 field_0xac;
u16 field_0xae;
} struct_0300110C;
} ArmosData;
// Status of the player's positioning within the scene.
typedef struct {
@@ -168,8 +168,8 @@ typedef struct {
/* 0x46 */ u16 field_0x46;
/* 0x48 */ u16 field_0x48;
/* 0x4a */ u16 field_0x4a;
/* 0x4c */ struct_030010EC minecart_data[4];
/* 0x6c */ struct_0300110C armos_data;
/* 0x4c */ MinecartData minecart_data[4];
/* 0x6c */ ArmosData armos_data;
} RoomTransition;
static_assert(sizeof(RoomTransition) == 0xB0);
extern RoomTransition gRoomTransition;
+2 -1
View File
@@ -59,5 +59,6 @@ void ExecuteScriptForEntity(Entity* entity, void (*postScriptCallback)(Entity*,
void HandlePostScriptActions(Entity* entity, ScriptExecutionContext* context);
void HandleEntity0x82Actions(Entity* entity);
void sub_0807DD94(Entity*, void (*function)(Entity*, ScriptExecutionContext*));
ScriptExecutionContext* CreateScriptExecutionContext(void);
void InitScriptForEntity(Entity* entity, ScriptExecutionContext* context, u16* script);
#endif // SCRIPT_H
+1 -1
View File
@@ -387,7 +387,7 @@ typedef enum {
SFX_160,
SFX_161,
SFX_162,
SFX_163,
SFX_TOGGLE_DIVING,
SFX_164,
SFX_165,
SFX_166,
+37 -15
View File
@@ -148,21 +148,21 @@ typedef enum {
} GfxSlotVramStatus;
typedef struct {
u8 status : 4;
u8 vramStatus : 4; // Whether the gfx was uploaded to the vram?
u8 slotCount;
u8 referenceCount; /**< How many entities use this gfx slot */
u8 unk_3;
u16 gfxIndex;
u16 paletteIndex;
const void* palettePointer;
/*0x00*/ u8 status : 4;
/*0x00*/ u8 vramStatus : 4; // Whether the gfx was uploaded to the vram?
/*0x01*/ u8 slotCount;
/*0x02*/ u8 referenceCount; /**< How many entities use this gfx slot */
/*0x03*/ u8 unk_3;
/*0x04*/ u16 gfxIndex;
/*0x06*/ u16 paletteIndex;
/*0x08*/ const void* palettePointer;
} GfxSlot;
typedef struct {
u8 unk0;
u8 unk_1;
u8 unk_2;
u8 unk_3;
GfxSlot slots[MAX_GFX_SLOTS];
/*0x00*/ u8 unk0;
/*0x01*/ u8 unk_1;
/*0x02*/ u8 unk_2;
/*0x03*/ u8 unk_3;
/*0x04*/ GfxSlot slots[MAX_GFX_SLOTS];
} GfxSlotList;
extern GfxSlotList gGFXSlots;
@@ -179,8 +179,16 @@ extern u16 gBG1Buffer[0x400];
extern u16 gBG2Buffer[0x400];
extern u16 gBG3Buffer[0x800];
extern ItemBehavior gUnk_03000B80[4];
static_assert(sizeof(gUnk_03000B80) == 0x70);
typedef enum { ACTIVE_ITEM_0, ACTIVE_ITEM_1, ACTIVE_ITEM_2, ACTIVE_ITEM_LANTERN, MAX_ACTIVE_ITEMS } ActiveItemIndex;
/**
* Currently active items.
* 0: Active items?
* 1: Boots, Cape
* 2: would be used by CreateItem1 if gActiveItems[1] was already filled
* 3: Lamp
*/
extern ItemBehavior gActiveItems[MAX_ACTIVE_ITEMS];
static_assert(sizeof(gActiveItems) == 0x70);
typedef struct {
u8 sys_priority; // system requested priority
@@ -323,4 +331,18 @@ typedef struct {
s16 position;
} TileData;
typedef struct {
/*0x00*/ bool8 isOnlyActiveFirstFrame; /**< Is the behavior for this item only created on the first frame */
/*0x01*/ u8 priority;
/*0x02*/ u8 createFunc;
/*0x03*/ u8 playerItemId; /**< Id for the corresponsing PlayerItem. */
/*0x04*/ u16 frameIndex;
/*0x06*/ u8 animPriority;
/*0x07*/ bool8 isChangingAttackStatus;
/*0x08*/ bool8 isUseableAsMinish;
/*0x09*/ u8 pad[3];
} ItemDefinition;
static_assert(sizeof(ItemDefinition) == 0xc);
#endif // STRUCTURES_H