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

View File

@ -78,7 +78,7 @@ SoftReset: @ 0x080B1504
ldr r3, _080B1518 @ =0x04000208
movs r2, #0
strb r2, [r3]
ldr r3, _080B151C @ =gUnk_03007FFA
ldr r3, _080B151C @ =soft_reset_flag
movs r2, #0
strb r2, [r3]
subs r3, #0xfa
@ -87,4 +87,4 @@ SoftReset: @ 0x080B1504
svc #0
.align 2, 0
_080B1518: .4byte 0x04000208
_080B151C: .4byte gUnk_03007FFA
_080B151C: .4byte soft_reset_flag

View File

@ -122,7 +122,7 @@ _080763C8:
cmp r1, r0
beq _080763D4
adds r0, r5, #0
bl sub_08077DF4
bl SetItemAnim
_080763D4:
ldrb r0, [r4, #5]
movs r1, #0x10
@ -208,7 +208,7 @@ _08076472:
lsls r1, r1, #4
_08076476:
adds r0, r5, #0
bl sub_08077DF4
bl SetItemAnim
b _08076486
_0807647E:
adds r0, r5, #0

View File

@ -109,7 +109,7 @@ _08079374:
ldrb r0, [r4, #2]
cmp r0, #0
bne _080793CA
bl ResetPlayerItem
bl ResetActiveItems
ldr r0, [r4, #0x30]
movs r1, #8
ands r0, r1

View File

@ -127,7 +127,7 @@ _080798CE:
bl sub_080793E4
cmp r0, #0
beq _0807991E
bl sub_0807A500
bl GetPlayerTilePos
ldr r1, _080798F8 @ =gPlayerEntity
adds r1, #0x38
ldrb r1, [r1]

View File

@ -537,7 +537,7 @@ sub_080042D0: @ 0x080042D0
ldrb r3, [r0, r3]
movs r4, #0xc
muls r3, r4, r3
ldr r4, _080043A4 @ =gUnk_02024494
ldr r4, _080043A4 @ =gGFXSlots+4
adds r4, r4, r3
ldrb r3, [r4]
movs r5, #0xf
@ -619,7 +619,7 @@ _08004394: .4byte gUnk_08000228
_08004398: .4byte 0x00004000
_0800439C: .4byte gSpritePtrs
_080043A0: .4byte gSpritePtrs
_080043A4: .4byte gUnk_02024494
_080043A4: .4byte gGFXSlots+4
thumb_func_start sub_080043A8
sub_080043A8: @ 0x080043A8

View File

@ -437,7 +437,7 @@ _080B1E74:
ldrb r0, [r3]
cmp r0, #0xff
ldrheq r1, [r3, #2]
ldr r0, _080B2018 @ =gUnk_080B3744
ldr r0, _080B2018 @ =gCollisionHandlers
ldr r7, [r0, r1, lsl #2]
mov r0, r4
mov r1, r5
@ -548,7 +548,7 @@ _080B2008: .4byte ram_sub_080B1FE4
_080B200C: .4byte gCollidableList
_080B2010: .4byte gCollidableCount
_080B2014: .4byte gCollisionMtx
_080B2018: .4byte gUnk_080B3744
_080B2018: .4byte gCollisionHandlers
arm_func_start IntrMain
IntrMain:

View File

@ -40117,7 +40117,7 @@
"size": 8
},
{
"path": "data_0811BE38/gUnk_0811BE48_EU.bin",
"path": "data_0811BE38/gItemDefinitions_EU.bin",
"variants": [
"EU"
],
@ -40127,7 +40127,7 @@
"size": 384
},
{
"path": "data_0811BE38/gUnk_0811BE48_1_USA-JP-DEMO_USA-DEMO_JP.bin",
"path": "data_0811BE38/gItemDefinitions_1_USA-JP-DEMO_USA-DEMO_JP.bin",
"variants": [
"USA",
"JP",

View File

@ -3818,7 +3818,7 @@
"size": 36
},
{
"path": "sounds/sfx163.bin",
"path": "sounds/sfxToggleDiving.bin",
"start": 14564384,
"type": "midi",
"options": {

View File

@ -4,27 +4,13 @@
.section .rodata
.align 2
gUnk_0811BE38:: @ 0811BE38
.incbin "data_0811BE38/gUnk_0811BE38.bin"
gUnk_0811BE40:: @ 0811BE40
.incbin "data_0811BE38/gUnk_0811BE40.bin"
gUnk_0811BE48:: @ 0811BE48
.ifdef EU
@ TODO only small differences
.incbin "data_0811BE38/gUnk_0811BE48_EU.bin"
.else
.incbin "data_0811BE38/gUnk_0811BE48_1_USA-JP-DEMO_USA-DEMO_JP.bin"
.endif
gUnk_0811BFC8:: @ 0811BFC8
.4byte sub_080779E8
.4byte sub_080779EC
.4byte sub_08077A18
.4byte sub_08077A48
.4byte sub_08077A98
.4byte sub_08077AC8
gCreateItemsFuncs:: @ 0811BFC8
.4byte CreateItemNone
.4byte CreateItem1
.4byte CreateItem2
.4byte CreateItem3
.4byte CreateItem4
.4byte CreateItem5
gUnk_0811BFE0:: @ 0811BFE0
.incbin "data_0811BE38/gUnk_0811BFE0.bin"

11
data/item.s Normal file
View File

@ -0,0 +1,11 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnk_0811BE38:: @ 0811BE38
.incbin "data_0811BE38/gUnk_0811BE38.bin"
gUnk_0811BE40:: @ 0811BE40
.incbin "data_0811BE38/gUnk_0811BE40.bin"

View File

@ -12,7 +12,8 @@ script_08011A7C:
SetPlayerIdle
FacePlayer
CallWithArg sub_0807F3D8, 0x00000000
CallWithArg sub_080644B4, 0x00000006
@ Check if player has performed great spin.
CallWithArg CheckLastSwordMove, 0x00000006
JumpIf script_08011AFA
MessageFromTarget TEXT_VAATI, 0x20
WaitUntilTextboxCloses

View File

@ -4,7 +4,7 @@ SCRIPT_START script_GuardWest
SetAnimationState 0x0002
_0807E9D4
CallWithArg sub_0807F3D8, 0x00000008
Call sub_080644A4
Call GuardWithSpear_ResetLastSwordMove
.ifndef EU
ClearLocalFlag MACHI_02_HEISHI_TALK
.endif
@ -19,10 +19,10 @@ script_0800FF92:
Call sub_08064198
CheckLocalFlag MACHI_02_HEISHI_TALK
JumpIfNot script_0800FFCC
Call sub_08064488
Call GuardWithSpear_ResetLastSwordMoveIfNotInSwordState
CheckPlayerInRegion2 0x4040
JumpIfNot script_0800FFCC
Call sub_08064470
Call GuardWithSpear_CheckSwordMoveSpin
JumpIf script_08010014
script_0800FFCC:
CheckEntityInteractType
@ -65,7 +65,7 @@ script_08010014:
CallWithArg sub_0807F3D8, 0x00000008
SetLocalFlag MACHI_02_HEISHI
script_08010060:
Call sub_080644A4
Call GuardWithSpear_ResetLastSwordMove
CallWithArg sub_0807F5B0, 0x0000000a
EnablePlayerControl
Jump script_0800FF92

View File

@ -37,7 +37,7 @@ script_08016262:
WaitUntilTextboxCloses
DoPostScriptAction 0x0001
Call WaitForAnimDone
Call sub_08068E90
Call BladeBrothers_LearnSkill
Call sub_08068C8C
JumpIf script_0801631C
Call sub_08068F00
@ -50,13 +50,13 @@ script_08016262:
Wait 0x001e
Call sub_08068E18
WaitUntilTextboxCloses
Call sub_08068EB4
Call BladeBrothers_ResetLastSwordMove
Call EnablePauseMenu
EnablePlayerControl
script_080162CC:
EndBlock
BeginBlock
Call sub_08068EC4
Call BladeBrothers_CheckLastSwordMove
JumpIf script_080162F6
CheckEntityInteractType
JumpIf script_080162E4

View File

@ -319,7 +319,7 @@
.include "sounds/sfx160.s"
.include "sounds/sfx161.s"
.include "sounds/sfx162.s"
.include "sounds/sfx163.s"
.include "sounds/sfxToggleDiving.s"
.include "sounds/sfx164.s"
.include "sounds/sfx165.s"
.include "sounds/sfx166.s"

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*);

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

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);

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.

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

View File

@ -227,7 +227,7 @@ typedef enum {
PINWHEEL,
OBJECT_BF,
ENEMY_ITEM,
OBJECT_C1,
LINK_ANIMATION,
} Object;
void ItemOnGround();

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();

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;

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;

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

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,

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

View File

@ -75,7 +75,6 @@ SECTIONS {
. = 0x00024050; gRoomMemory = .;
. = 0x00024090; gUnk_02024090 = .;
. = 0x00024490; gGFXSlots = .;
. = 0x00024494; gUnk_02024494 = .;
. = 0x000246B0; gUnk_020246B0 = .;
. = 0x00025EB0; gMapBottom = .;
. = 0x00031EC0; gNPCData = .;
@ -131,7 +130,7 @@ SECTIONS {
iwram (NOLOAD) : ALIGN(4) {
. = 0x00000000; gOAMControls = .;
. = 0x00000420; gUnk_03000420 = .;
. = 0x00000B80; gUnk_03000B80 = .;
. = 0x00000B80; gActiveItems = .;
. = 0x00000BF0; gRoomControls = .;
. = 0x00000C24; gUnk_03000C24 = .;
. = 0x00000C30; gUnk_03000C30 = .;
@ -236,7 +235,7 @@ SECTIONS {
#endif
. = 0x00007F00; usr_stack_begin = .;
. = 0x00007FA0; irq_stack_begin = .;
. = 0x00007FFA; gUnk_03007FFA = .;
. = 0x00007FFA; soft_reset_flag = .;
. = 0x00008000;
} >iwram
@ -1290,6 +1289,8 @@ SECTIONS {
src/item/itemGustJar.o(.rodata);
src/item/itemMoleMitts.o(.rodata);
src/item/itemJarEmpty.o(.rodata);
data/item.o(.rodata);
src/itemDefinitions.o(.rodata);
data/data_0811BE38.o(.rodata);
data/map/room_headers.o(.rodata);
src/flags.o(.rodata);

View File

@ -39,7 +39,16 @@ extern const u16* gUnk_080B4550[];
extern const u16 gUnk_080B77C0[];
extern BgAnimationFrame* gUnk_080B7278[];
void sub_0801AD6C(u16*, u32);
typedef struct {
u16 tileType;
u16 kind;
u16 id;
u16 type;
u16 type2;
u16 unk_a;
} Data;
void sub_0801AD6C(const Data*, u32);
bool32 sub_0801A4F8(void);
bool32 sub_0801AA58(Entity*, u32, u32);
void sub_0801AB08(u16*, LayerStruct*);
@ -146,7 +155,7 @@ NONMATCH("asm/non_matching/beanstalkSubtask/sub_0801A2B0.inc",
u32 temp5;
uVar1 = gUnk_080B4488[gPlayerEntity.animationState >> 1];
if ((((gPlayerState.field_0x35 | gPlayerState.field_0xd) & 0x80) == 0) && ((gPlayerEntity.frame & 1) != 0)) {
if ((((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) == 0) && ((gPlayerEntity.frame & 1) != 0)) {
position = (u16)(position + uVar1);
temp4 = sub_080B1B54(GetTileType(position, gPlayerEntity.collisionLayer));
switch (temp4) {
@ -264,10 +273,10 @@ bool32 sub_0801A4F8(void) {
if (GetInventoryValue(ITEM_POWER_BRACELETS) != 1) {
return FALSE;
}
if ((gPlayerState.field_0xd & 0x80) != 0) {
if ((gPlayerState.direction & 0x80) != 0) {
return FALSE;
}
if (gPlayerState.field_0xd != gPlayerEntity.direction) {
if (gPlayerState.direction != gPlayerEntity.direction) {
return FALSE;
}
tmp = (((gPlayerEntity.direction + 4) & 0x18) >> 3);
@ -275,7 +284,7 @@ bool32 sub_0801A4F8(void) {
return FALSE;
}
} else {
if (((gPlayerState.field_0x35 | gPlayerState.field_0xd) & 0x80) != 0) {
if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) {
return FALSE;
}
if ((gPlayerEntity.frame & 1) == 0) {
@ -411,19 +420,18 @@ u32 sub_0801AC68(u32 position, u32 data) {
return data << 2;
}
extern const u16 gUnk_080B44C0[];
extern const u16 gUnk_080B44C2[];
extern const Data gUnk_080B44C0[];
extern const Data gUnk_080B44C2[];
extern const u32 gUnk_080B44B8[];
NONMATCH("asm/non_matching/beanstalkSubtask/sub_0801AC98.inc", void sub_0801AC98()) {
u32 width;
u32 height;
u32 indexX;
u32 width;
u32 indexY;
const u16* puVar7;
const Data* ptr1;
const Data* ptr2;
u32 position;
const u32* ptr;
u32 tmp;
width = gRoomControls.width >> 4;
height = gRoomControls.height >> 4;
@ -431,32 +439,30 @@ NONMATCH("asm/non_matching/beanstalkSubtask/sub_0801AC98.inc", void sub_0801AC98
for (indexY = 0; indexY < height; indexY++) {
for (indexX = 0; indexX < width; indexX++, position++) {
for (puVar7 = gUnk_080B44C0; puVar7[0] != 0xffff; puVar7 += 6) {
if (puVar7[0] == GetTileType(position, 1)) {
ptr = gUnk_080B44B8 + puVar7[5];
if (ptr[0] != 0) {
sub_0801AD6C((u16*)puVar7, position);
for (ptr1 = gUnk_080B44C0; ptr1->tileType != 0xffff; ptr1++) {
if (ptr1->tileType == GetTileType(position, 1)) {
if (gUnk_080B44B8[ptr1->unk_a] != 0) {
sub_0801AD6C(ptr1, position);
break;
}
}
}
for (puVar7 = gUnk_080B44C2; puVar7[0] != 0xffff; puVar7 += 6) {
if (puVar7[0] == GetTileType(position, 2)) {
ptr = gUnk_080B44B8 + puVar7[5];
if (ptr[0] != 0) {
sub_0801AD6C((u16*)puVar7, position);
for (ptr2 = gUnk_080B44C2; ptr2->tileType != 0xffff; ptr2++) {
if (ptr2->tileType == GetTileType(position, 2)) {
if (gUnk_080B44B8[ptr2->unk_a] != 0) {
sub_0801AD6C(ptr2, position);
break;
}
}
}
}
tmp = (position + 0x40);
position = tmp - width;
position = position + (0x40 - width);
}
}
END_NONMATCH
void sub_0801AD6C(u16* param_1, u32 param_2) {
void sub_0801AD6C(const Data* param_1, u32 tilePosition) {
Entity* entity;
Manager* manager;
s32 tmpX1;
@ -464,16 +470,16 @@ void sub_0801AD6C(u16* param_1, u32 param_2) {
s32 tmpX2;
s32 tmpY2;
if (param_1[1] != MANAGER) {
if (param_1->kind != MANAGER) {
entity = GetEmptyEntity();
if (entity != NULL) {
entity->kind = (u8)param_1[1];
entity->id = (u8)param_1[2];
entity->type = (u8)param_1[3];
entity->type2 = (u8)param_1[4];
tmpX1 = ((u16)param_2 & 0x3f) * 0x10 + 8;
entity->kind = (u8)param_1->kind;
entity->id = (u8)param_1->id;
entity->type = (u8)param_1->type;
entity->type2 = (u8)param_1->type2;
tmpX1 = ((u16)tilePosition & 0x3f) * 0x10 + 8;
entity->x.HALF.HI = tmpX1 + gRoomControls.origin_x;
tmpY1 = (s16)((param_2 & 0xfc0) >> 2) + 8;
tmpY1 = (s16)((tilePosition & 0xfc0) >> 2) + 8;
entity->y.HALF.HI = tmpY1 + gRoomControls.origin_y;
entity->collisionLayer = 0;
ResolveCollisionLayer(entity);
@ -482,14 +488,14 @@ void sub_0801AD6C(u16* param_1, u32 param_2) {
} else {
manager = GetEmptyManager();
if (manager != NULL) {
manager->kind = (u8)param_1[1];
manager->id = (u8)param_1[2];
manager->type = (u8)param_1[3];
manager->type2 = (u8)param_1[4];
manager->kind = (u8)param_1->kind;
manager->id = (u8)param_1->id;
manager->type = (u8)param_1->type;
manager->type2 = (u8)param_1->type2;
// TODO are these fields common for all managers or does this usually create managers of certain types?
tmpX2 = ((u16)param_2 & 0x3f) * 0x10 + 8;
tmpX2 = ((u16)tilePosition & 0x3f) * 0x10 + 8;
*(u16*)(&manager[1].timer + 10) = tmpX2 + gRoomControls.origin_x;
tmpY2 = (s16)((param_2 & 0xfc0) >> 2) + 8;
tmpY2 = (s16)((tilePosition & 0xfc0) >> 2) + 8;
*(u16*)(&manager[1].timer + 12) = tmpY2 + gRoomControls.origin_y;
AppendEntityToList((Entity*)manager, gUnk_081091E4[manager->kind]);
}

View File

@ -1,17 +1,26 @@
#include "global.h"
#include "asm.h"
#include "collision.h"
#include "common.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
#include "game.h"
#include "global.h"
#include "item.h"
#include "object.h"
#include "player.h"
#include "save.h"
#include "common.h"
#include "functions.h"
#include "enemy.h"
#include "object.h"
#include "game.h"
extern u8 gCollidableCount;
extern u8 gUnk_080B3740[];
typedef enum {
COL_FLAG_1 = 1,
COL_FLAG_2 = 2,
COL_FLAG_4 = 4,
COL_FLAG_8 = 8,
} ColSettingsFlags;
typedef struct {
/*0x00*/ u8 orgKnockbackSpeed;
/*0x01*/ u8 orgIframes;
@ -23,8 +32,8 @@ typedef struct {
/*0x07*/ u8 tgtKnockbackDuration;
/*0x08*/ u8 orgDamage;
/*0x09*/ u8 tgtConfusedTime;
/*0x0a*/ u8 _a;
/*0x0b*/ u8 _b;
/*0x0a*/ u8 flags; /**< @see ColSettingsFlags */
/*0x0b*/ u8 pad;
} ColSettings;
extern ColSettings gCollisionMtx[173 * 34];
@ -32,10 +41,8 @@ extern ColSettings gCollisionMtx[173 * 34];
extern void ram_CollideAll(void);
u32 sub_08081420(Entity*);
extern void SoundReqClipped(Entity*, u32);
s32 sub_08018308(Entity*, Entity*, u32, ColSettings*);
void sub_08079D84(void);
void sub_080180BC(Entity*, Entity*);
void sub_0807AFE8(void);
typedef struct {
void* last;
@ -208,51 +215,49 @@ bool32 IsCollidingPlayer(Entity* this) {
return FALSE;
}
s32 sub_08017874(Entity* a, Entity* b) {
s32 newDmg;
s32 v5;
s32 v6;
s32 CalculateDamage(Entity* org, Entity* tgt) {
s32 damage;
s32 health;
asm("" ::: "r1");
if (a->kind == PLAYER) {
newDmg = b->damage;
if (org->kind == PLAYER) {
damage = tgt->damage;
switch (gSave.stats.charm) {
case 47:
newDmg /= 4;
case BOTTLE_CHARM_NAYRU:
damage /= 4;
break;
case 48:
newDmg /= 2;
case BOTTLE_CHARM_FARORE:
damage /= 2;
break;
}
if (newDmg <= 0)
newDmg = 1;
v5 = ModHealth(-newDmg);
SoundReqClipped(a, SFX_PLY_VO6);
if (damage <= 0)
damage = 1;
health = ModHealth(-damage);
SoundReqClipped(org, SFX_PLY_VO6);
} else {
v6 = b->damage;
if (b->kind == PLAYER_ITEM) {
damage = tgt->damage;
if (tgt->kind == PLAYER_ITEM) {
switch (gSave.stats.charm) {
case 48:
v6 = 3 * v6 / 2;
case BOTTLE_CHARM_FARORE:
damage = 3 * damage / 2;
break;
case 49:
v6 *= 2;
case BOTTLE_CHARM_DIN:
damage *= 2;
break;
}
}
v5 = a->health - v6;
if (a->kind == ENEMY) {
if ((a->field_0x6c.HALF.HI & 1) != 0)
SoundReqClipped(a, SFX_BOSS_HIT);
health = org->health - damage;
if (org->kind == ENEMY) {
if ((org->field_0x6c.HALF.HI & 1) != 0)
SoundReqClipped(org, SFX_BOSS_HIT);
else
SoundReqClipped(a, SFX_HIT);
SoundReqClipped(org, SFX_HIT);
}
}
if (v5 <= 0) {
COLLISION_OFF(a);
if (health <= 0) {
COLLISION_OFF(org);
return 0;
}
return v5;
return health;
}
void sub_08017940(Entity* org, Entity* tgt) {
@ -308,51 +313,71 @@ Entity* sub_08017A90(Entity* a1, Entity* parent) {
return NULL;
}
typedef s32 (*CollisionHandler)(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017F3C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_0801802C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08018228(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08018288(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017E88(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
typedef CollisionResult (*CollisionHandler)(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult CollisionDefault(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08017F3C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_0801802C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08018228(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult CollisionMazaalShrinkRay(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
CollisionResult sub_08017E88(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
const CollisionHandler gUnk_080B3744[] = {
sub_08018308, CollisionNoOp, CollisionNoOp, CollisionGroundItem, sub_08017B58, sub_08017EB0,
sub_08017F3C, sub_08017F40, sub_0801802C, sub_08017DD4, sub_080180E8, sub_08017BBC,
sub_08017C40, sub_08017D6C, sub_08017D28, sub_08018168, sub_08018228, sub_08018250,
sub_08018288, sub_080182A8, sub_08017B1C, sub_08017CBC, sub_08017E88,
const CollisionHandler gCollisionHandlers[] = {
CollisionDefault,
CollisionNoOp,
CollisionNoOp,
CollisionGroundItem,
sub_08017B58,
sub_08017EB0,
sub_08017F3C,
sub_08017F40,
sub_0801802C,
sub_08017DD4,
sub_080180E8,
sub_08017BBC,
sub_08017C40,
sub_08017D6C,
sub_08017D28,
sub_08018168,
sub_08018228,
sub_08018250,
CollisionMazaalShrinkRay,
sub_080182A8,
sub_08017B1C,
sub_08017CBC,
sub_08017E88,
};
s32 CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
return 0;
CollisionResult CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
return RESULT_NO_COLLISION;
}
// origin: player or sword
// target: item
s32 CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
COLLISION_OFF(tgt);
tgt->contactFlags = org->hurtType | 0x80;
if ((tgt->type == 0x5F || tgt->type == 0x60) && sub_08081420(tgt))
tgt->health = 0;
return 2;
return RESULT_COLLISION_WITHOUT_SET;
}
s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((gPlayerState.dash_state & 0x60) != 0) {
COLLISION_OFF(tgt);
} else {
@ -360,10 +385,10 @@ s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
org->iframes = -20;
org->knockbackSpeed = 640;
}
return 1;
return RESULT_COLLISION;
}
s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((tgt->gustJarState & 4) != 0) {
if (tgt->gustJarTolerance) {
tgt->gustJarTolerance = tgt->gustJarTolerance - gPlayerState.gustJarSpeed;
@ -379,10 +404,10 @@ s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
}
if (tgt->iframes == 0)
tgt->iframes = -1;
return 1;
return RESULT_COLLISION;
}
s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((gPlayerState.flags & (PL_BUSY | PL_MINISH | PL_BURNING | PL_IN_MINECART)) == 0) {
Entity* e = CreateObject(LINK_FIRE, 1, 0);
if (e != NULL) {
@ -392,21 +417,21 @@ s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
}
}
tgt->damage = 4;
org->health = sub_08017874(org, tgt);
org->health = CalculateDamage(org, tgt);
org->knockbackDuration = 12;
org->iframes = 30;
org->knockbackSpeed = 384;
if (tgt->iframes == 0)
tgt->iframes = -1;
return 1;
return RESULT_COLLISION;
}
s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((gPlayerState.flags & (PL_BUSY | PL_MINISH | PL_FROZEN | PL_IN_MINECART)) == 0 &&
gPlayerState.queued_action == PLAYER_INIT) {
if (org->action == 1 || org->action == 24) {
tgt->damage = 4;
org->health = sub_08017874(org, tgt);
org->health = CalculateDamage(org, tgt);
gPlayerState.flags = PL_FROZEN;
gPlayerState.queued_action = PLAYER_FROZEN;
}
@ -416,10 +441,10 @@ s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
org->knockbackSpeed = 640;
if (tgt->iframes == 0)
tgt->iframes = -1;
return 1;
return RESULT_COLLISION;
}
s32 sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
direction = DirectionNormalize(DirectionTurnAround(direction) - 0xc);
if (DirectionNormalize(-direction + tgt->direction) < 0x19) {
org->iframes = -12;
@ -433,10 +458,10 @@ s32 sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
if (org->iframes == 0)
org->iframes = -1;
}
return 1;
return RESULT_COLLISION;
}
s32 sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
gPlayerState.mobility = 1;
org->field_0x7a.HWORD = 600;
org->knockbackDuration = 12;
@ -444,10 +469,10 @@ s32 sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
org->knockbackSpeed = 640;
if (tgt->iframes == 0)
tgt->iframes = -1;
return 1;
return RESULT_COLLISION;
}
s32 sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
u32 x;
u32 y;
ColSettings* p;
@ -463,16 +488,16 @@ s32 sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
y = 0xae4;
}
p = &gCollisionMtx[x + y];
return sub_08018308(org, tgt, direction, p);
return CollisionDefault(org, tgt, direction, p);
}
int sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
org->contactFlags = 0;
if (tgt->damage & 0x80)
tgt->damage &= ~0x80;
else
tgt->damage = 4;
gPlayerEntity.health = sub_08017874(&gPlayerEntity, tgt);
gPlayerEntity.health = CalculateDamage(&gPlayerEntity, tgt);
tgt->iframes = -12;
if ((gPlayerState.flags & PL_MINISH) == 0) {
sub_08079D84();
@ -486,25 +511,25 @@ int sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
}
if (tgt->iframes == 0)
tgt->iframes = -1;
return 1;
return RESULT_COLLISION;
}
s32 sub_08017E88(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08017E88(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
org->knockbackDuration = 2;
org->knockbackSpeed = 640;
if (tgt->iframes == 0)
tgt->iframes = -1;
return 1;
return RESULT_COLLISION;
}
s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->damage == 0)
return 0;
return RESULT_NO_COLLISION;
if (org == &gPlayerEntity) {
u32 temp = tgt->damage;
u32 prevDamage = tgt->damage;
tgt->damage = 8;
gPlayerEntity.health = sub_08017874(&gPlayerEntity, tgt);
tgt->damage = temp;
gPlayerEntity.health = CalculateDamage(&gPlayerEntity, tgt);
tgt->damage = prevDamage;
gPlayerEntity.knockbackDuration = 12;
gPlayerEntity.iframes = 16;
gPlayerEntity.knockbackSpeed = 384;
@ -516,14 +541,14 @@ s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
}
if (tgt->iframes == 0)
tgt->iframes = -1;
return 1;
return RESULT_COLLISION;
}
s32 sub_08017F3C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
return 1;
CollisionResult sub_08017F3C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
return RESULT_COLLISION;
}
s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->confusedTime == 0) {
if (org == &gPlayerEntity) {
if (PlayerCanBeMoved() &&
@ -548,8 +573,8 @@ s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
org->spriteOrientation.flipY = tgt->spriteOrientation.flipY;
org->iframes = -1;
tgt->iframes = -8;
ResetPlayerItem();
return 1;
ResetActiveItems();
return RESULT_COLLISION;
}
} else {
org->health = 0;
@ -557,39 +582,39 @@ s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
} else if (tgt->kind == ENEMY && org == &gPlayerEntity) {
sub_08004484(tgt, org);
}
return 0;
return RESULT_NO_COLLISION;
}
s32 sub_0801802C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_0801802C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
int kind;
u32 x;
kind = org->kind;
if (kind == 1) {
if (kind == PLAYER) {
if (PlayerCanBeMoved()) {
if (((DirectionNormalize(DirectionTurnAround(direction) -
Direction8FromAnimationState(tgt->animationState) + 5))) > 0xA) {
x = 0x11aa;
return sub_08018308(org, tgt, direction, &gCollisionMtx[x + org->hurtType]);
return CollisionDefault(org, tgt, direction, &gCollisionMtx[x + org->hurtType]);
} else {
sub_080180BC(org, tgt);
return 1;
return RESULT_COLLISION;
}
}
} else if (kind == 8) {
} else if (kind == PLAYER_ITEM) {
if (DirectionNormalize(
(DirectionTurnAround(org->direction) - Direction8FromAnimationState(tgt->animationState) + 5)) <= 0xA) {
org->health = 0;
sub_080180BC(org, tgt);
return 1;
return RESULT_COLLISION;
}
} else {
org->health = 0;
return 0;
return RESULT_NO_COLLISION;
}
x = 0x11aa;
return sub_08018308(org, tgt, direction, &gCollisionMtx[x + org->hurtType]);
return CollisionDefault(org, tgt, direction, &gCollisionMtx[x + org->hurtType]);
}
void sub_080180BC(Entity* org, Entity* tgt) {
@ -600,7 +625,7 @@ void sub_080180BC(Entity* org, Entity* tgt) {
tgt->subAction = -1;
}
s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
u32 v3;
u32 x;
@ -613,13 +638,13 @@ s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
tgt->iframes = -16;
tgt->knockbackSpeed = 768;
sub_08017940(org, tgt);
return 1;
return RESULT_COLLISION;
}
x = 0x352;
return sub_08018308(org, tgt, v3, &gCollisionMtx[org->hurtType + x]);
return CollisionDefault(org, tgt, v3, &gCollisionMtx[org->hurtType + x]);
}
s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->confusedTime == 0) {
if (org == &gPlayerEntity) {
if (PlayerCanBeMoved() &&
@ -639,7 +664,7 @@ s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
gPlayerEntity.iframes = 0xff;
tgt->iframes = -8;
PutAwayItems();
return 1;
return RESULT_COLLISION;
}
} else {
org->health = 0;
@ -647,16 +672,16 @@ s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
} else if ((tgt->kind == ENEMY) && (org == &gPlayerEntity)) {
sub_08004484(tgt, &gPlayerEntity);
}
return 0;
return RESULT_NO_COLLISION;
}
s32 sub_08018228(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08018228(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (org == &gPlayerEntity && PlayerCanBeMoved())
sub_08004484(tgt, org);
return 0;
return RESULT_NO_COLLISION;
}
s32 sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
org->iframes = -1;
if (org->direction == 0) {
tgt->iframes = 16;
@ -664,18 +689,18 @@ s32 sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
} else {
tgt->iframes = -1;
}
return 1;
return RESULT_COLLISION;
}
s32 sub_08018288(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult CollisionMazaalShrinkRay(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (org == &gPlayerEntity)
sub_0807AFE8();
PlayerShrinkByRay();
else
org->health = 0;
return 1;
return RESULT_COLLISION;
}
s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->confusedTime == 0) {
if (org->iframes == 0)
org->iframes = -1;
@ -683,12 +708,12 @@ s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
tgt->iframes = -1;
} else {
u32 x = 0x92a;
return sub_08018308(org, tgt, direction, &gCollisionMtx[org->hurtType + x]);
return CollisionDefault(org, tgt, direction, &gCollisionMtx[org->hurtType + x]);
}
return 1;
return RESULT_COLLISION;
}
s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
CollisionResult CollisionDefault(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
u32 confused = 0;
if (tgt->confusedTime && tgt->kind == ENEMY && org == &gPlayerEntity) {
sub_08004484(tgt, org);
@ -697,7 +722,7 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
if ((org->kind == PLAYER_ITEM && org->id == PL_ITEM_SHIELD) &&
gPlayerEntity.animationState ==
AnimationStateFlip180(Direction8ToAnimationState(DirectionRoundUp(direction)))) {
return 0;
return RESULT_NO_COLLISION;
}
if (!confused) {
u32 tmp2;
@ -709,7 +734,7 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
tgt->damage = settings->tgtDamage;
tmp2 = 0xFF;
if (settings->tgtDamage != 0)
org->health = sub_08017874(org, tgt);
org->health = CalculateDamage(org, tgt);
if (settings->orgConfusedTime > org->confusedTime)
org->confusedTime = settings->orgConfusedTime;
tgt->knockbackSpeed = 16 * settings->tgtKnockbackSpeed;
@ -719,15 +744,15 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
tgt->knockbackDuration = settings->tgtKnockbackDuration;
tmp2 &= (org->damage = settings->orgDamage);
if (tmp2 != 0)
tgt->health = sub_08017874(tgt, org);
tgt->health = CalculateDamage(tgt, org);
if (settings->tgtConfusedTime > tgt->confusedTime)
tgt->confusedTime = settings->tgtConfusedTime;
}
if (settings->_a & 1)
if (settings->flags & COL_FLAG_1)
sub_08017940(org, tgt);
if (settings->_a & 2)
if (settings->flags & COL_FLAG_2)
org->contactFlags = 0xca;
if (settings->_a & 4) {
if (settings->flags & COL_FLAG_4) {
Entity* parent = tgt->parent;
if (parent != NULL) {
parent->contactFlags = 0xcc;
@ -746,7 +771,7 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
sub_080179EC(org, tgt);
}
} else if (org->id == PL_ITEM_BOW) {
if (org->damage || (settings->_a & 8)) {
if (org->damage || (settings->flags & COL_FLAG_8)) {
sub_08017A90(org, tgt);
}
} else if (org->id == PL_ITEM_BOOMERANG) {
@ -760,5 +785,5 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
if (tgt->kind == PLAYER_ITEM && org->id == PL_ITEM_SHIELD) {
gPlayerEntity.iframes = 0x80;
}
return 1;
return RESULT_COLLISION;
}

View File

@ -30,8 +30,8 @@ void ResetPaletteTable(u32 a1) {
sub_0801D000(a1);
}
void sub_0801CFD0(u32 a1) {
Palette* p = &gPaletteList[a1];
void sub_0801CFD0(u32 index) {
Palette* p = &gPaletteList[index];
p->_0_0 = 4;
p->_0_4 = 1;
p->_1 = 0x80;

View File

@ -69,11 +69,11 @@ void sub_080300E8(void) {
}
}
void sub_08030118(u32 param_1) {
if (((s32)(u32)gRoomTransition.armos_data.field_0xac >> (param_1)&1) != 0) {
SetLocalFlagByBank(FLAG_BANK_3, param_1 + 0x67);
void sub_08030118(u32 armosId) {
if (((gRoomTransition.armos_data.field_0xac >> armosId) & 1) != 0) {
SetLocalFlagByBank(FLAG_BANK_3, armosId + 0x67);
} else {
ClearLocalFlagByBank(FLAG_BANK_3, param_1 + 0x67);
ClearLocalFlagByBank(FLAG_BANK_3, armosId + 0x67);
}
}

View File

@ -252,7 +252,7 @@ void sub_08021B64(Entity* this) {
} else {
gPlayerState.mobility |= 0x80;
gPlayerState.speed_modifier -= 0x50;
gPlayerState.field_0xaa++;
gPlayerState.attachedBeetleCount++;
CopyPositionAndSpriteOffset(&gPlayerEntity, this);
this->x.HALF.HI += gUnk_080CB5E4[(this->subtimer++ & 0xe) >> 1];
this->z.HALF.HI--;

View File

@ -1830,7 +1830,7 @@ Entity* sub_08027D20(ChuchuBossEntity* this) {
r4->spriteVramOffset = super->spriteVramOffset;
r4->palette.b.b0 = super->palette.b.b0;
#endif
r4->y.HALF.HI += 1;
r4->y.HALF.HI++;
r4->spriteOffsetY = 8;
#ifndef EU
LoadFixedGFX(r4, 0x3e);

View File

@ -277,7 +277,7 @@ void sub_08044498(DustEntity* this) {
u32 xdiff, ydiff;
uVar4 = COORD_TO_TILE(&gPlayerEntity);
tmp = (gPlayerState.playerInput.field_0x92 & 0xf00);
tmp = (gPlayerState.playerInput.newInput & 0xf00);
if (tmp != this->unk_75 || uVar4 != this->unk_76) {
this->unk_75 = tmp;
this->unk_76 = uVar4;

View File

@ -411,13 +411,13 @@ void Enemy64_Action4_SubAction5(Enemy64Entity* this) {
super->subAction = 6;
super->spriteSettings.draw = 0;
entity = super->child;
entity->flags &= 0x7f;
entity->flags &= ~0x80;
entity->spriteSettings.draw = 0;
entity = entity->child;
entity->flags &= 0x7f;
entity->flags &= ~0x80;
entity->spriteSettings.draw = 0;
entity = entity->child;
entity->flags &= 0x7f;
entity->flags &= ~0x80;
entity->spriteSettings.draw = 0;
entity = &gPlayerEntity;
entity->x.HALF.HI = gRoomControls.origin_x + 0xa8;

View File

@ -384,7 +384,7 @@ void sub_0803F6EC(GhiniEntity* this) {
}
void sub_0803F738(GhiniEntity* this) {
ResetPlayerItem();
ResetActiveItems();
gPlayerState.mobility |= 0x80;
gPlayerState.field_0xa |= 0x80;
sub_0806FA90(&gPlayerEntity, super, 0, 1);

View File

@ -166,7 +166,7 @@ void sub_08037690(GibdoEntity* this) {
void sub_080376D0(GibdoEntity* this) {
if (!sub_080379EC(this)) {
ResetPlayerItem();
ResetActiveItems();
gPlayerState.mobility |= 0x80;
gPlayerState.field_0xa |= 0x80;
CopyPositionAndSpriteOffset(&gPlayerEntity, super);

View File

@ -1076,7 +1076,7 @@ void sub_0802E300(GleerokEntity* this) {
}
}
this->unk_79 &= 0x7f;
this->unk_79 &= ~0x80;
heap = this->unk_84;
dir = sub_0806F5A4(GetFacingDirection(super, &gPlayerEntity)) << 3;
index = 0;

View File

@ -90,7 +90,7 @@ void GyorgMaleEye_Action2(GyorgMaleEyeEntity* this) {
sub_08048F50(this);
if (--super->timer == 0) {
super->action = 3;
super->flags &= 0x7f;
super->flags &= ~0x80;
InitializeAnimation(super, super->animIndex + 4);
}
}

View File

@ -198,7 +198,7 @@ void sub_0802805C(LikeLikeEntity* this) {
if (super->subtimer >= 0x19 || gSave.stats.health == 0) {
LikeLike_ReleasePlayer(this);
} else {
ResetPlayerItem();
ResetActiveItems();
gPlayerState.mobility |= 0x80;
PositionRelative(super, &gPlayerEntity, 0, Q_16_16(1.0));

View File

@ -557,7 +557,7 @@ void sub_0803A978(Entity* this) {
this->action = 0x12;
this->timer = 3;
COLLISION_OFF(this);
*(u8*)(*(int*)&this->field_0x74 + 0x10) &= 0x7f;
*(u8*)(*(int*)&this->field_0x74 + 0x10) &= ~0x80;
InitializeAnimation(this, 8);
InitAnimationForceUpdate(this->child, 3);
}
@ -1244,7 +1244,7 @@ void sub_0803B804(Entity* this) {
}
void sub_0803B824(Entity* this) {
ResetPlayerItem();
ResetActiveItems();
gPlayerState.mobility |= 0x80;
sub_0806FA90(this, &gPlayerEntity, gUnk_080CFD1D[this->type], 1);
gPlayerEntity.spriteOffsetY = -6;

View File

@ -39,7 +39,7 @@ void MiniFireballGuy_OnCollision(Entity* this) {
void MiniFireballGuy_OnDeath(Entity* this) {
if ((this != this->parent) && (this->parent != NULL)) {
this->field_0x6c.HALF.LO &= 0x7f;
this->field_0x6c.HALF.LO &= ~0x80;
this->parent->child = this->child;
this->child->parent = this->parent;
}

View File

@ -50,7 +50,7 @@ void MiniSlime_OnCollision(Entity* this) {
void MiniSlime_OnDeath(Entity* this) {
Entity* parent = this->parent;
if ((this != parent) && (parent != NULL)) {
this->field_0x6c.HALF.LO &= 0x7f;
this->field_0x6c.HALF.LO &= ~0x80;
this->parent->child = this->child;
this->child->parent = this->parent;
if (this->field_0x6c.HALF.HI & 0x40)

View File

@ -237,7 +237,7 @@ void sub_08033000(MulldozerEntity* this) {
super->subtimer = 16;
if ((this->unk_82 & 0x80) != 0) {
super->direction = (super->direction + 0x18) & 0x1c;
this->unk_82 &= 0x7f;
this->unk_82 &= ~0x80;
} else {
super->direction = (super->direction + 8) & 0x1c;
this->unk_82 |= 0x80;

View File

@ -1226,7 +1226,7 @@ void sub_08036F60(OctorokBossEntity* this) {
void OctorokBoss_StepSound(OctorokBossEntity* this, u32 frameMask) {
if ((gRoomTransition.frameCount & frameMask) == 0) {
if (IS_FROZEN(this) == FALSE) {
SoundReq(SFX_163);
SoundReq(SFX_TOGGLE_DIVING);
} else {
SoundReq(SFX_ICE_BLOCK_SLIDE);
}

View File

@ -828,7 +828,7 @@ void sub_08024E4C(Entity* this) {
sub_08024A14(this, 0, 8);
} else {
Entity* player = &gPlayerEntity;
ResetPlayerItem();
ResetActiveItems();
gPlayerState.flags |= PL_DISABLE_ITEMS;
gPlayerState.field_0xa |= 0x80;
gPlayerState.queued_action = PLAYER_0807204C;

View File

@ -167,7 +167,7 @@ void sub_0802953C(Entity* this) {
if (((this->subtimer > 0x2d) || (gSave.stats.rupees == 0)) && (this->timer == 0)) {
sub_080296D8(this);
} else {
ResetPlayerItem();
ResetActiveItems();
gPlayerState.mobility |= 0x80;
PositionRelative(this, &gPlayerEntity, 0, Q_16_16(1.0));
pbVar3 = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex);

View File

@ -226,7 +226,7 @@ void VaatiProjectileFunction0Action9(Entity* this) {
}
void sub_0803E444(Entity* this) {
ResetPlayerItem();
ResetActiveItems();
gPlayerState.mobility |= 0x80;
gPlayerState.field_0xa |= 0x80;
sub_0806FA90(this, this->contactedEntity, 0, -2);

View File

@ -113,7 +113,7 @@ void WizzrobeFire_Action2(WizzrobeEntity* this) {
this->timer1 = 0x28;
super->timer = 40;
super->subtimer = 0;
super->flags &= 0x7f;
super->flags &= ~0x80;
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
EnqueueSFX(SFX_156);
InitializeAnimation(super, super->direction >> 3);

View File

@ -120,7 +120,7 @@ void WizzrobeIce_Action2(WizzrobeEntity* this) {
this->timer1 = 0x28;
super->timer = 40;
super->subtimer = 0;
super->flags &= 0x7f;
super->flags &= ~0x80;
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
EnqueueSFX(SFX_156);
InitializeAnimation(super, super->direction >> 3);

View File

@ -136,7 +136,7 @@ void WizzrobeWind_Action2(WizzrobeEntity* this) {
this->timer1 = 0x28;
super->timer = 40;
super->subtimer = 0;
super->flags &= 0x7f;
super->flags &= ~0x80;
EnqueueSFX(SFX_156);
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
InitializeAnimation(super, super->direction >> 3);
@ -264,7 +264,7 @@ void sub_0802F9C8(WizzrobeEntity* this) {
if (super->type2 != 0) {
ProcessMovement0(super);
if (super->collisions != COL_NONE) {
super->flags &= 0x7f;
super->flags &= ~0x80;
this->timer1 = 0x28;
}
}

View File

@ -972,10 +972,10 @@ static void InitializePlayer(void) {
Entity* pl;
sub_080784C8();
MemClear(&gUnk_03000B80, sizeof gUnk_03000B80);
MemClear(&gPlayerState, sizeof gPlayerState);
MemFill32(0xffffffff, &gPlayerState.path_memory, sizeof gPlayerState.path_memory);
MemClear(&gPlayerEntity, sizeof gPlayerEntity);
MemClear(&gActiveItems, sizeof(gActiveItems));
MemClear(&gPlayerState, sizeof(gPlayerState));
MemFill32(0xffffffff, &gPlayerState.path_memory, sizeof(gPlayerState.path_memory));
MemClear(&gPlayerEntity, sizeof(gPlayerEntity));
pl = &gPlayerEntity;
@ -2463,68 +2463,69 @@ void ModArrows(s32 arrows) {
* 1: B
* 2: Not equipped
*/
u32 IsItemEquipped(u32 itemID) {
u32 itemSlot;
EquipSlot IsItemEquipped(u32 itemId) {
EquipSlot equipSlot;
if (itemID == gSave.stats.itemButtons[SLOT_A])
itemSlot = 0;
else if (itemID == gSave.stats.itemButtons[SLOT_B])
itemSlot = 1;
else
itemSlot = 2;
return itemSlot;
if (itemId == gSave.stats.itemButtons[SLOT_A]) {
equipSlot = EQUIP_SLOT_A;
} else if (itemId == gSave.stats.itemButtons[SLOT_B]) {
equipSlot = EQUIP_SLOT_B;
} else {
equipSlot = EQUIP_SLOT_NONE;
}
return equipSlot;
}
void PutItemOnSlot(u32 itemID) {
u32 itemSlot;
u32 itemID2 = itemID;
if (itemID2 < 0x47) {
void PutItemOnSlot(u32 itemId) {
EquipSlot equipSlot;
u32 itemId2 = itemId;
if (itemId2 < 0x47) {
SetInventoryValue(0, 1);
}
if (itemID2 - 1 < 0x1f) {
itemSlot = 2;
if (itemId2 - 1 < 0x1f) {
equipSlot = EQUIP_SLOT_NONE;
if (gSave.stats.itemButtons[SLOT_A] == ITEM_NONE) {
itemSlot = 0;
equipSlot = EQUIP_SLOT_A;
} else if (gSave.stats.itemButtons[SLOT_B] == ITEM_NONE) {
itemSlot = 1;
equipSlot = EQUIP_SLOT_B;
}
if (itemSlot == 2) {
u32 temp = gItemMetaData[itemID2].menuSlot;
if (equipSlot == EQUIP_SLOT_NONE) {
u32 temp = gItemMetaData[itemId2].menuSlot;
if (temp == gItemMetaData[gSave.stats.itemButtons[SLOT_A]].menuSlot) {
itemSlot = 0;
equipSlot = EQUIP_SLOT_A;
} else {
if (temp == gItemMetaData[gSave.stats.itemButtons[SLOT_B]].menuSlot) {
itemSlot = 1;
equipSlot = EQUIP_SLOT_B;
}
}
if (itemSlot == 2) {
if (equipSlot == EQUIP_SLOT_NONE) {
return;
}
}
ForceEquipItem(itemID2, itemSlot);
ForceEquipItem(itemId2, equipSlot);
}
}
void ForceEquipItem(u32 itemID, u32 itemSlot) {
void ForceEquipItem(u32 itemId, u32 equipSlot) {
u32 otherItem;
u32 otherItemIndex;
u32 otherItemSlot;
u32 replacedItem;
if ((itemID - 1 < 0x1f) && (itemSlot < 2)) {
otherItemIndex = itemSlot == 0;
replacedItem = gSave.stats.itemButtons[itemSlot];
otherItem = gSave.stats.itemButtons[otherItemIndex];
if (gItemMetaData[otherItem].menuSlot == gItemMetaData[itemID].menuSlot) {
if ((itemId - 1 < 0x1f) && (equipSlot < EQUIP_SLOT_NONE)) {
otherItemSlot = equipSlot == EQUIP_SLOT_A;
replacedItem = gSave.stats.itemButtons[equipSlot];
otherItem = gSave.stats.itemButtons[otherItemSlot];
if (gItemMetaData[otherItem].menuSlot == gItemMetaData[itemId].menuSlot) {
otherItem = replacedItem;
}
gSave.stats.itemButtons[itemSlot] = itemID;
gSave.stats.itemButtons[otherItemIndex] = otherItem;
gSave.stats.itemButtons[equipSlot] = itemId;
gSave.stats.itemButtons[otherItemSlot] = otherItem;
gUnk_0200AF00.unk_13 = 0x7f;
gUnk_0200AF00.unk_14 = 0x7f;
}
}
u32 SetBottleContents(u32 itemID, u32 bottleIndex) {
u32 SetBottleContents(u32 itemId, u32 bottleIndex) {
if (bottleIndex > 3) {
bottleIndex = 0;
for (bottleIndex = 0; gSave.stats.bottles[bottleIndex] != ITEM_BOTTLE_EMPTY;) {
@ -2536,7 +2537,7 @@ u32 SetBottleContents(u32 itemID, u32 bottleIndex) {
return bottleIndex;
}
}
gSave.stats.bottles[bottleIndex] = itemID;
gSave.stats.bottles[bottleIndex] = itemId;
return bottleIndex;
}
@ -2614,7 +2615,7 @@ void EnableRandomDrops(void) {
extern void sub_08000F14(s16*, const s16*, const s16*, const s16*);
extern u32 sub_08000F2C(s16*, const s16*, const s16*, const s16*);
u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter);
u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter);
u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
extern const u8 gUnk_080FE1B4[] /* = {
ITEM_NONE, ITEM_RUPEE1, ITEM_RUPEE5, ITEM_RUPEE20, ITEM_HEART, ITEM_FAIRY,
@ -2717,11 +2718,11 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
return ITEM_NONE;
}
u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter) {
u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter) {
u32 adjustedParam = itemParameter;
Entity* itemEntity;
switch (itemID) {
switch (itemId) {
case ITEM_ENEMY_BEETLE:
if (!GetInventoryValue(ITEM_SMITH_SWORD)) {
return ITEM_NONE;
@ -2757,22 +2758,22 @@ u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter) {
return ITEM_NONE;
}
if (itemID != ITEM_KINSTONE) {
adjustedParam = itemID - ITEM_KINSTONE_GREEN;
if (itemId != ITEM_KINSTONE) {
adjustedParam = itemId - ITEM_KINSTONE_GREEN;
rand = (Random() & 0x3f);
adjustedParam = gUnk_080FE1DD[(rand + adjustedParam * 0x40)];
if (adjustedParam == 0) {
itemID = ITEM_NONE;
itemId = ITEM_NONE;
} else {
itemID = ITEM_KINSTONE;
itemId = ITEM_KINSTONE;
}
}
break;
}
}
if (itemID != ITEM_NONE) {
if (itemID != ITEM_ENEMY_BEETLE) {
itemEntity = CreateObject(GROUND_ITEM, itemID, adjustedParam);
if (itemId != ITEM_NONE) {
if (itemId != ITEM_ENEMY_BEETLE) {
itemEntity = CreateObject(GROUND_ITEM, itemId, adjustedParam);
if (itemEntity != NULL) {
if (arg0 == &gPlayerEntity) {
itemEntity->timer = 1;
@ -2800,7 +2801,7 @@ u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter) {
}
}
}
return itemID;
return itemId;
}
void Subtask_WorldEvent(void) {

View File

@ -1313,7 +1313,7 @@ void CgbSound(void) {
if (channels->n4 & 0x80) {
*nrx0ptr = 0x80;
*nrx4ptr = channels->n4;
channels->n4 &= 0x7f;
channels->n4 &= ~0x80;
}
} else {
envelopeStepTimeAndDir &= 0xf;

View File

@ -1,14 +1,14 @@
#include "global.h"
#include "sound.h"
#include "main.h"
#include "player.h"
#include "structures.h"
#include "save.h"
#include "message.h"
#include "functions.h"
#include "screen.h"
#include "gba/m4a.h"
#include "global.h"
#include "main.h"
#include "message.h"
#include "object.h"
#include "player.h"
#include "save.h"
#include "screen.h"
#include "sound.h"
#include "structures.h"
#include "ui.h"
extern u8 gUnk_03003DE0;
@ -197,7 +197,7 @@ void PlayerUpdate(Entity* this) {
else
gPlayerState.flags &= ~PL_DRUGGED;
if (EntityIsDeleted(this) == 0) {
if (!EntityIsDeleted(this)) {
if (gPlayerState.flags & PL_MOLDWORM_CAPTURED) {
PutAwayItems();
if (gPlayerState.flags & PL_MOLDWORM_RELEASED) {
@ -218,7 +218,7 @@ void PlayerUpdate(Entity* this) {
}
sub_08078FB0(this);
DrawEntity(this);
sub_0807A050();
UpdatePlayerPalette();
}
// Responsible for some life things like low health beep and initiating the death sequence
@ -234,7 +234,7 @@ static void HandlePlayerLife(Entity* this) {
gPlayerState.flags &= ~(PL_FALLING | PL_CONVEYOR_PUSHED);
if (gPlayerState.flags & PL_BURNING)
ResetPlayerItem();
ResetActiveItems();
if ((gPlayerState.flags & PL_CLONING) && gPlayerState.chargeState.action == 0)
DeleteClones();
if (sub_08079B24() == 0)
@ -309,7 +309,7 @@ static void HandlePlayerLife(Entity* this) {
static void sub_080171F0(void) {
if (gPlayerState.mobility != 0)
ResetPlayerItem();
ResetActiveItems();
if (gPlayerState.field_0x14 != 0)
gPlayerState.field_0x14--;
if (gPlayerEntity.field_0x7a.HWORD != 0)
@ -331,7 +331,7 @@ static void sub_080171F0(void) {
gPlayerState.keepFacing &= ~0x80;
gPlayerState.mobility = 0;
gPlayerState.speed_modifier = 0;
gPlayerState.field_0xaa = 0;
gPlayerState.attachedBeetleCount = 0;
MemClear(&gCarriedEntity, sizeof(gCarriedEntity));
gPlayerEntity.spriteOffsetY = gPlayerState.spriteOffsetY;
gPlayerState.spriteOffsetY = 0;

View File

@ -3,14 +3,40 @@
// TODO - How does this relate to PlayerItemFunctions? Is this just a lookup table?
void (*const gItemFunctions[])(ItemBehavior*, u32) = {
ItemDebug, ItemSword, ItemSword, ItemSword, ItemSword, ItemSword, ItemSword,
ItemBomb, ItemBomb, ItemBow, ItemBow, ItemBoomerang, ItemBoomerang, ItemShield,
ItemShield, ItemLantern, ItemLantern, ItemGustJar, ItemPacciCane, ItemMoleMitts, ItemRocsCape,
ItemPegasusBoots, ItemDebug, ItemOcarina, ItemDebug, ItemDebug, ItemDebug, ItemTryPickupObject,
ItemJarEmpty, ItemJarEmpty, ItemJarEmpty, ItemJarEmpty,
[ITEM_NONE] = ItemDebug,
[ITEM_SMITH_SWORD] = ItemSword,
[ITEM_GREEN_SWORD] = ItemSword,
[ITEM_RED_SWORD] = ItemSword,
[ITEM_BLUE_SWORD] = ItemSword,
[ITEM_UNUSED_SWORD] = ItemSword,
[ITEM_FOURSWORD] = ItemSword,
[ITEM_BOMBS] = ItemBomb,
[ITEM_REMOTE_BOMBS] = ItemBomb,
[ITEM_BOW] = ItemBow,
[ITEM_LIGHT_ARROW] = ItemBow,
[ITEM_BOOMERANG] = ItemBoomerang,
[ITEM_MAGIC_BOOMERANG] = ItemBoomerang,
[ITEM_SHIELD] = ItemShield,
[ITEM_MIRROR_SHIELD] = ItemShield,
[ITEM_LANTERN_OFF] = ItemLantern,
[ITEM_LANTERN_ON] = ItemLantern,
[ITEM_GUST_JAR] = ItemGustJar,
[ITEM_PACCI_CANE] = ItemPacciCane,
[ITEM_MOLE_MITTS] = ItemMoleMitts,
[ITEM_ROCS_CAPE] = ItemRocsCape,
[ITEM_PEGASUS_BOOTS] = ItemPegasusBoots,
[ITEM_FIRE_ROD] = ItemDebug,
[ITEM_OCARINA] = ItemOcarina,
[ITEM_ORB_GREEN] = ItemDebug,
[ITEM_ORB_BLUE] = ItemDebug,
[ITEM_ORB_RED] = ItemDebug,
[ITEM_TRY_PICKUP_OBJECT] = ItemTryPickupObject,
[ITEM_BOTTLE1] = ItemJarEmpty,
[ITEM_BOTTLE2] = ItemJarEmpty,
[ITEM_BOTTLE3] = ItemJarEmpty,
[ITEM_BOTTLE4] = ItemJarEmpty,
};
void sub_080752E8(ItemBehavior* behavior, u32 idx) {
gItemFunctions[behavior->behaviorID](behavior, idx);
void ExecuteItemFunction(ItemBehavior* behavior, u32 index) {
gItemFunctions[behavior->behaviorId](behavior, index);
}

View File

@ -10,14 +10,14 @@ void sub_08076488(ItemBehavior*, u32);
void sub_08076518(ItemBehavior*, u32);
void sub_080765E0(ItemBehavior*, u32);
void ItemBomb(ItemBehavior* this, u32 idx) {
void ItemBomb(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08075FF8, NULL, sub_08076488, sub_08076518, sub_080765E0,
};
stateFuncs[this->stateID](this, idx);
stateFuncs[this->stateID](this, index);
}
void sub_08075FF8(ItemBehavior* this, u32 idx) {
void sub_08075FF8(ItemBehavior* this, u32 index) {
static const s8 gUnk_0811BDAC[] = {
0, -8, 4, -1, 0, 2, -4, -1,
};
@ -28,13 +28,13 @@ void sub_08075FF8(ItemBehavior* this, u32 idx) {
s32 x;
s32 y;
if ((gPlayerState.jump_status | gPlayerState.field_0x3[1]) == 0) {
if ((gPlayerState.jump_status | gPlayerState.attack_status) == 0) {
bombCount = 0;
for (entity = FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_BOMB, 2); entity != NULL;
entity = FindNextDuplicateID(entity, 2)) {
bombCount++;
}
maxBombs = this->behaviorID == 7 ? 3 : 1;
maxBombs = this->behaviorId == 7 ? 3 : 1;
if (maxBombs > bombCount) {
entity = CreatePlayerItemWithParent(this, PLAYER_ITEM_BOMB);
if (entity != NULL) {
@ -45,60 +45,5 @@ void sub_08075FF8(ItemBehavior* this, u32 idx) {
}
}
}
DeletePlayerItem(this, idx);
}
void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) {
if (param_2 != NULL) {
if ((param_2->carryFlags & 1) != 0) {
return;
}
param_2->action = 2;
param_2->subAction = param_2->carryFlags & 1;
}
this->field_0x18 = param_2;
if ((gPlayerState.flags & PL_NO_CAP)) {
sub_08077DF4(this, 0x928);
} else {
sub_08077DF4(this, 0x338);
}
gPlayerState.heldObject = 3;
gPlayerState.framestate = PL_STATE_HOLD;
this->stateID = 2;
this->field_0xf = 0xf;
if ((gPlayerEntity.field_0x78.HALF.HI & 0x80)) {
gPlayerEntity.field_0x78.HALF.HI = 0;
COLLISION_ON(&gPlayerEntity);
gPlayerState.heldObject = 4;
gPlayerState.keepFacing = ~(8 >> param_3) & gPlayerState.keepFacing;
gPlayerState.field_0xa = ~(8 >> param_3) & gPlayerState.field_0xa;
this->stateID = 3;
this->field_0xf = 0;
} else {
gPlayerState.field_0xa |= (8 >> param_3);
gPlayerState.keepFacing |= (8 >> param_3);
}
param_2 = CreatePlayerItemWithParent(this, PLAYER_ITEM_13);
if (param_2 == NULL) {
PlayerCancelHoldItem(this, param_3);
} else {
Entity* playerEnt = &gPlayerEntity;
*(Entity**)&playerEnt->field_0x74 = param_2;
playerEnt->subtimer = 0;
param_2->child = this->field_0x18;
param_2->carryFlags = playerEnt->carryFlags;
param_2->parent = (Entity*)this;
this->field_0x18 = param_2;
param_2->type2 = this->field_0x2[1];
param_2->timer = this->timer;
param_2->subtimer = this->subtimer;
if ((this->field_0x18->carryFlags & 0xf0) == 0x10) {
this->timer = 8;
} else {
this->timer = 0;
}
SoundReq(SFX_PLY_LIFT);
}
DeleteItemBehavior(this, index);
}

View File

@ -4,29 +4,29 @@
void sub_08075D2C(ItemBehavior*, u32);
void sub_08075D88(ItemBehavior*, u32);
void ItemBoomerang(ItemBehavior* this, u32 idx) {
void ItemBoomerang(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08075D2C,
sub_08075D88,
};
stateFuncs[this->stateID](this, idx);
stateFuncs[this->stateID](this, index);
}
void sub_08075D2C(ItemBehavior* this, u32 idx) {
if (((gPlayerState.field_0x3[1] & 8) == 0) && (sub_08077C94(this, this->behaviorID) == NULL)) {
this->field_0x9 |= 0xf;
void sub_08075D2C(ItemBehavior* this, u32 index) {
if (((gPlayerState.attack_status & 8) == 0) && (FindPlayerItemForItem(this, this->behaviorId) == NULL)) {
this->priority |= 0xf;
sub_0806F948(&gPlayerEntity);
sub_08077C0C(this, 0xb);
sub_08077D38(this, idx);
gPlayerState.field_0x3[1] |= 8;
CreatePlayerItemIfNotExists(this, ITEM_BOOMERANG);
sub_08077D38(this, index);
gPlayerState.attack_status |= 8;
} else {
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
}
void sub_08075D88(ItemBehavior* this, u32 idx) {
if ((gPlayerState.field_0x3[1] & 0x80) == 0) {
if (((this->behaviorID == 0xc) && ((gPlayerState.field_0xa & 0x80) != 0)) && ((this->playerFrame & 2) != 0)) {
void sub_08075D88(ItemBehavior* this, u32 index) {
if ((gPlayerState.attack_status & 0x80) == 0) {
if (((this->behaviorId == 0xc) && ((gPlayerState.field_0xa & 0x80) != 0)) && ((this->playerFrame & 2) != 0)) {
ResetPlayerVelocity();
return;
}
@ -35,5 +35,5 @@ void sub_08075D88(ItemBehavior* this, u32 idx) {
return;
}
}
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}

View File

@ -9,81 +9,78 @@ void sub_08075F38(ItemBehavior*, u32);
void sub_08075F84(ItemBehavior*, u32);
void sub_08075D88(ItemBehavior*, u32);
void ItemBow(ItemBehavior* this, u32 idx) {
void ItemBow(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08075DF4, sub_08075E40, sub_08075EC0, sub_08075F38, sub_08075F84, sub_08075D88,
};
stateFuncs[this->stateID](this, idx);
stateFuncs[this->stateID](this, index);
}
void sub_08075DF4(ItemBehavior* this, u32 idx) {
if ((gPlayerState.field_0x3[1] & 8) == 0) {
this->field_0x9 |= 0x80;
void sub_08075DF4(ItemBehavior* this, u32 index) {
if ((gPlayerState.attack_status & 8) == 0) {
this->priority |= 0x80;
sub_0806F948(&gPlayerEntity);
sub_08077BB8(this);
sub_08077D38(this, idx);
sub_08077D38(this, index);
gPlayerState.field_0x1f[2] = 1;
} else {
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
}
void sub_08075E40(ItemBehavior* this, u32 idx) {
u8 bVar1;
void sub_08075E40(ItemBehavior* this, u32 index) {
if (gPlayerState.field_0x1f[2] != 0) {
bVar1 = gPlayerState.field_0x3[1] & 0x80;
if (bVar1 == 0) {
if ((gPlayerState.attack_status & 0x80) == 0) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
this->stateID = 2;
this->field_0x9 &= ~0x80;
this->priority &= ~0x80;
if (gSave.stats.arrowCount != 0) {
this->field_0xf = bVar1;
gPlayerState.field_0xa &= ~(8 >> idx);
this->animPriority = 0;
gPlayerState.field_0xa &= ~(8 >> index);
}
}
return;
}
}
gPlayerState.field_0x1f[2] = 0;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
void sub_08075EC0(ItemBehavior* this, u32 idx) {
void sub_08075EC0(ItemBehavior* this, u32 index) {
u8 arrowCount;
s32 iVar2;
arrowCount = gSave.stats.arrowCount;
iVar2 = sub_08077EFC(this);
iVar2 = IsItemActive(this);
if (iVar2 != 0 && arrowCount != 0) {
if (((gPlayerState.field_0x3[1] & 0x80) != 0) || (gPlayerState.field_0x1f[2] == 0)) {
if (((gPlayerState.attack_status & 0x80) != 0) || (gPlayerState.field_0x1f[2] == 0)) {
gPlayerState.field_0x1f[2] = 0;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
} else {
gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa;
sub_08077DF4(this, 0x27c);
this->field_0xf = 0xf;
this->field_0x9 |= 0xf;
gPlayerState.field_0xa = (8 >> index) | gPlayerState.field_0xa;
SetItemAnim(this, 0x27c);
this->animPriority = 0xf;
this->priority |= 0xf;
this->stateID = 3;
}
}
void sub_08075F38(ItemBehavior* this, u32 idx) {
if (((gPlayerState.field_0x3[1] & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) {
void sub_08075F38(ItemBehavior* this, u32 index) {
if (((gPlayerState.attack_status & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) {
UpdateItemAnim(this);
if ((this->playerFrame & 1) != 0) {
this->stateID = 4;
}
} else {
gPlayerState.field_0x1f[2] = 0;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
}
void sub_08075F84(ItemBehavior* this, u32 idx) {
if (((gPlayerState.field_0x3[1] & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) {
void sub_08075F84(ItemBehavior* this, u32 index) {
if (((gPlayerState.attack_status & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) {
if (GetInventoryValue(ITEM_ARROW_BUTTERFLY) == 1) {
sub_08077E3C(this, 5);
} else {
@ -94,5 +91,5 @@ void sub_08075F84(ItemBehavior* this, u32 idx) {
}
}
gPlayerState.field_0x1f[2] = 0;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}

View File

@ -1,9 +1,9 @@
#include "item.h"
extern Entity* sub_08077BD4(ItemBehavior*);
extern void DeletePlayerItem(ItemBehavior*, u32);
extern Entity* CreatePlayerItemForItemIfNotExists(ItemBehavior*);
extern void DeleteItemBehavior(ItemBehavior*, u32);
void ItemDebug(ItemBehavior* beh, u32 idx) {
sub_08077BD4(beh);
DeletePlayerItem(beh, idx);
void ItemDebug(ItemBehavior* this, u32 index) {
CreatePlayerItemForItemIfNotExists(this);
DeleteItemBehavior(this, index);
}

View File

@ -4,41 +4,41 @@
#include "functions.h"
#include "playeritem.h"
void (*const ItemGustJar_StateFunctions[])(ItemBehavior* beh, u32);
void (*const ItemGustJar_StateFunctions[])(ItemBehavior* this, u32);
void ItemGustJar(ItemBehavior* this, u32 idx) {
void ItemGustJar(ItemBehavior* this, u32 index) {
gPlayerState.framestate = PL_STATE_GUSTJAR;
ItemGustJar_StateFunctions[this->stateID](this, idx);
ItemGustJar_StateFunctions[this->stateID](this, index);
}
void sub_08076DF4(ItemBehavior* this, u32 idx) {
if (sub_0807A894(&gPlayerEntity) != 0x29 && gPlayerState.floor_type != SURFACE_DOOR &&
void sub_08076DF4(ItemBehavior* this, u32 index) {
if (GetCollisionTileInFront(&gPlayerEntity) != 0x29 && gPlayerState.floor_type != SURFACE_DOOR &&
gPlayerState.floor_type != SURFACE_DOOR_13 && gPlayerState.jump_status == 0) {
sub_08077D38(this, idx);
sub_08077D38(this, index);
this->timer = 0;
this->playerAnimationState = gPlayerEntity.animationState;
this->field_0x9 |= 0x80;
this->field_0x9++;
this->priority |= 0x80;
this->priority++;
gPlayerState.gustJarSpeed = 1;
*(u32*)&gPlayerEntity.field_0x74 = 0;
gPlayerState.field_0x1c = 1;
sub_08077BB8(this);
} else {
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
}
void sub_08076E60(ItemBehavior* this, u32 idx) {
void sub_08076E60(ItemBehavior* this, u32 index) {
Entity* playerItem;
if ((gPlayerState.field_0x1c & 0xf) == 0) {
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
if ((this->playerFrame & 0x80) != 0) {
this->stateID = 2;
sub_08077DF4(this, 0x504);
gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> idx);
playerItem = CreatePlayerItem(PLAYER_ITEM_10, 0, 0, 0);
SetItemAnim(this, 0x504);
gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> index);
playerItem = CreatePlayerItem(PLAYER_ITEM_GUST, 0, 0, 0);
if (playerItem != NULL) {
playerItem->parent = &gPlayerEntity;
}
@ -47,14 +47,14 @@ void sub_08076E60(ItemBehavior* this, u32 idx) {
}
}
void sub_08076EC8(ItemBehavior* this, u32 idx) {
void sub_08076EC8(ItemBehavior* this, u32 index) {
if ((gPlayerState.field_0x1c & 0xf) == 0) {
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
return;
}
if (sub_08077EFC(this)) {
u32 val;
if (IsItemActive(this)) {
u32 animIndex;
if (this->timer > 0xef) {
gPlayerState.gustJarSpeed = 3;
} else if (++this->timer > 0x77) {
@ -64,17 +64,17 @@ void sub_08076EC8(ItemBehavior* this, u32 idx) {
}
if (gPlayerEntity.subAction == 0x1b) {
val = 0x524;
animIndex = 0x524;
} else {
if (gPlayerState.field_0xd & 0x80) {
val = 0x504;
if (gPlayerState.direction & 0x80) {
animIndex = 0x504;
} else {
val = 0x518;
animIndex = 0x518;
}
}
if (val != *(u16*)&this->field_0x10) {
sub_08077DF4(this, val);
if (animIndex != this->animIndex) {
SetItemAnim(this, animIndex);
} else {
UpdateItemAnim(this);
}
@ -82,10 +82,10 @@ void sub_08076EC8(ItemBehavior* this, u32 idx) {
}
this->stateID++;
gPlayerState.field_0xa |= 8 >> idx;
gPlayerState.field_0xa |= 8 >> index;
}
void sub_08076F64(ItemBehavior* this, u32 idx) {
void sub_08076F64(ItemBehavior* this, u32 index) {
Entity* item;
Entity* player;
switch (gPlayerState.field_0x1c & 0xf) {
@ -98,21 +98,21 @@ void sub_08076F64(ItemBehavior* this, u32 idx) {
player = &gPlayerEntity;
*(u32*)&player->field_0x74 = 0;
gPlayerState.field_0x1c = 1;
gPlayerState.field_0xa &= ~(8 >> idx);
gPlayerState.field_0xa &= ~(8 >> index);
this->stateID = 2;
sub_08077DF4(this, 0x504);
item = CreatePlayerItem(PLAYER_ITEM_10, 0, 0, 0);
SetItemAnim(this, 0x504);
item = CreatePlayerItem(PLAYER_ITEM_GUST, 0, 0, 0);
if (item) {
item->parent = player;
}
return;
} else {
gPlayerState.field_0x1c = 6;
sub_08077DF4(this, 0x510);
SetItemAnim(this, 0x510);
return;
}
} else {
if (sub_08077EFC(this)) {
if (IsItemActive(this)) {
this->subtimer = 1;
}
@ -130,7 +130,7 @@ void sub_08076F64(ItemBehavior* this, u32 idx) {
case 3:
gPlayerState.field_0x1c = 4;
case 4:
if (sub_08077EFC(this)) {
if (IsItemActive(this)) {
this->subtimer = 1;
}
@ -139,7 +139,7 @@ void sub_08076F64(ItemBehavior* this, u32 idx) {
gPlayerState.field_0x1c = 5;
gPlayerEntity.field_0x70.WORD = 0;
if (gPlayerState.gustJarSpeed) {
CreatePlayerItem(PLAYER_ITEM_11, 0, 0, 0);
CreatePlayerItem(PLAYER_ITEM_GUST_BIG, 0, 0, 0);
}
}
@ -155,7 +155,7 @@ void sub_08076F64(ItemBehavior* this, u32 idx) {
return;
break;
case 7:
sub_08077DF4(this, 0x514);
SetItemAnim(this, 0x514);
gPlayerState.field_0x1c = 3;
gPlayerState.gustJarSpeed = 0;
return;
@ -163,17 +163,17 @@ void sub_08076F64(ItemBehavior* this, u32 idx) {
case 2:
default:
gPlayerState.field_0x1c = 3;
sub_08077DF4(this, 0x514);
SetItemAnim(this, 0x514);
return;
case 0:
break;
}
gPlayerState.field_0x1c = 0;
gPlayerEntity.field_0x70.WORD = 0;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
void (*const ItemGustJar_StateFunctions[])(ItemBehavior* beh, u32) = {
void (*const ItemGustJar_StateFunctions[])(ItemBehavior*, u32) = {
sub_08076DF4,
sub_08076E60,
sub_08076EC8,

View File

@ -7,27 +7,27 @@ void sub_08077618(ItemBehavior*, u32);
void sub_08077640(ItemBehavior*, u32);
void sub_0807766C(ItemBehavior*, u32);
void ItemJarEmpty(ItemBehavior* this, u32 idx) {
void ItemJarEmpty(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08077534,
sub_08077618,
sub_08077640,
sub_0807766C,
};
stateFuncs[this->stateID](this, idx);
stateFuncs[this->stateID](this, index);
}
void sub_08077534(ItemBehavior* this, u32 idx) {
void sub_08077534(ItemBehavior* this, u32 index) {
u32 tmp;
sub_08077D38(this, idx);
sub_08077D38(this, index);
sub_0806F948(&gPlayerEntity);
sub_08077BB8(this);
this->field_0x9 |= 0xf;
tmp = this->behaviorID;
this->priority |= 0xf;
tmp = this->behaviorId;
this->timer = gSave.filler86[tmp + 0x14];
switch (this->timer) {
case 0x20:
sub_08077DF4(this, 0x614);
SetItemAnim(this, 0x614);
return;
case 0x21:
case 0x22:
@ -43,40 +43,40 @@ void sub_08077534(ItemBehavior* this, u32 idx) {
this->stateID = 3;
gPlayerEntity.animationState = 4;
gPlayerEntity.spriteSettings.flipX = 0;
sub_08077DF4(this, 0x2df);
SetItemAnim(this, 0x2df);
break;
case 0x2f:
case 0x30:
case 0x31:
default:
this->stateID = 3;
sub_08077DF4(this, 0x610);
SetItemAnim(this, 0x610);
break;
}
gPlayerEntity.flags &= ~ENT_COLLIDE;
}
void sub_08077618(ItemBehavior* this, u32 idx) {
void sub_08077618(ItemBehavior* this, u32 index) {
if ((this->playerFrame & 0x80) != 0) {
sub_08077DF4(this, 0x618);
this->stateID += 1;
SetItemAnim(this, 0x618);
this->stateID++;
} else {
UpdateItemAnim(this);
}
}
void sub_08077640(ItemBehavior* this, u32 idx) {
void sub_08077640(ItemBehavior* this, u32 index) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
gPlayerEntity.flags |= ENT_COLLIDE;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
}
void sub_0807766C(ItemBehavior* this, u32 idx) {
void sub_0807766C(ItemBehavior* this, u32 index) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
gPlayerEntity.flags |= ENT_COLLIDE;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
}

View File

@ -5,41 +5,41 @@
#include "game.h"
extern s8 gUnk_08126EEC[];
extern Entity* sub_08077BD4(ItemBehavior*);
extern Entity* CreatePlayerItemForItemIfNotExists(ItemBehavior*);
extern void sub_0807AB44(Entity*, s32, s32);
void sub_08075A0C(ItemBehavior*, u32);
void sub_08075ADC(ItemBehavior*, u32);
void sub_08075B54(ItemBehavior*, u32);
void sub_08075C9C(ItemBehavior*, u32);
void ItemLantern(ItemBehavior* this, u32 idx) {
void ItemLantern(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08075A0C,
sub_08075ADC,
sub_08075B54,
sub_08075C9C,
};
stateFuncs[this->stateID](this, idx);
stateFuncs[this->stateID](this, index);
}
void sub_08075A0C(ItemBehavior* this, u32 idx) {
void sub_08075A0C(ItemBehavior* this, u32 index) {
Entity* object;
u32 itemSlot;
EquipSlot equipSlot;
s8* tmp;
itemSlot = IsItemEquipped(this->behaviorID);
equipSlot = IsItemEquipped(this->behaviorId);
if (gPlayerState.heldObject != 0 || gPlayerState.queued_action == PLAYER_ROLL || gPlayerState.jump_status != 0 ||
gPlayerState.item != NULL || (gPlayerState.flags & PL_MINISH) != 0) {
ForceEquipItem(ITEM_LANTERN_OFF, itemSlot);
ForceEquipItem(ITEM_LANTERN_OFF, equipSlot);
gPlayerState.flags &= ~PL_USE_LANTERN;
ForceEquipItem(ITEM_LANTERN_OFF, itemSlot);
DeletePlayerItem(this, idx);
ForceEquipItem(ITEM_LANTERN_OFF, equipSlot);
DeleteItemBehavior(this, index);
} else {
this->field_0x9 |= 0x80;
sub_08077D38(this, idx);
sub_08077BD4(this);
this->priority |= 0x80;
sub_08077D38(this, index);
CreatePlayerItemForItemIfNotExists(this);
sub_0806F948(&gPlayerEntity);
this->behaviorID = 0x10;
ForceEquipItem(ITEM_LANTERN_ON, itemSlot);
this->behaviorId = 0x10;
ForceEquipItem(ITEM_LANTERN_ON, equipSlot);
tmp = &gUnk_08126EEC[gPlayerEntity.animationState & 6];
object = CreateObjectWithParent(&gPlayerEntity, LAMP_PARTICLE, 1, 0);
if (object != NULL) {
@ -50,7 +50,7 @@ void sub_08075A0C(ItemBehavior* this, u32 idx) {
}
}
void sub_08075ADC(ItemBehavior* this, u32 idx) {
void sub_08075ADC(ItemBehavior* this, u32 index) {
u32 bVar1;
if (
@ -59,11 +59,11 @@ void sub_08075ADC(ItemBehavior* this, u32 idx) {
#endif
(this->playerFrame & 1) == 0 || (gPlayerState.flags & (PL_DISABLE_ITEMS | PL_CAPTURED)) != 0 ||
sub_08079D48() == 0) {
this->field_0xf = 0;
this->animPriority = 0;
this->stateID++;
gPlayerState.flags |= PL_USE_LANTERN;
bVar1 = 8 >> idx;
gPlayerState.field_0x3[1] = gPlayerState.field_0x3[1] & ~((bVar1 << 4) | bVar1);
bVar1 = 8 >> index;
gPlayerState.attack_status &= ~((bVar1 << 4) | bVar1);
bVar1 = ~bVar1;
gPlayerState.field_0xa = bVar1 & gPlayerState.field_0xa;
gPlayerState.keepFacing = bVar1 & gPlayerState.keepFacing;
@ -73,18 +73,19 @@ void sub_08075ADC(ItemBehavior* this, u32 idx) {
}
}
void sub_08075B54(ItemBehavior* this, u32 idx) {
void sub_08075B54(ItemBehavior* this, u32 index) {
u32 bVar1;
u32 itemSlot;
EquipSlot equipSlot;
Entity* object;
s8* tmp;
if ((gPlayerState.flags & (PL_CAPTURED | PL_DISABLE_ITEMS)) == 0) {
itemSlot = IsItemEquipped(this->behaviorID);
if (!(((sub_08077F10(this) == 0) && (itemSlot < 2)) || (gPlayerState.jump_status != 0))) {
ForceEquipItem(ITEM_LANTERN_OFF, itemSlot);
equipSlot = IsItemEquipped(this->behaviorId);
if (!(((IsItemActivatedThisFrame(this) == 0) && (equipSlot < EQUIP_SLOT_NONE)) ||
(gPlayerState.jump_status != 0))) {
ForceEquipItem(ITEM_LANTERN_OFF, equipSlot);
gPlayerState.flags &= ~PL_USE_LANTERN;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
SoundReq(SFX_ITEM_LANTERN_OFF);
} else {
if (((gPlayerState.queued_action != PLAYER_ROLL) && (gPlayerEntity.frameIndex < 0x37)) &&
@ -94,7 +95,7 @@ void sub_08075B54(ItemBehavior* this, u32 idx) {
if ((gPlayerState.jump_status == 0) &&
(sub_080B1BA4(TILE(gPlayerEntity.x.HALF.HI + tmp[0], gPlayerEntity.y.HALF.HI + tmp[1]),
gPlayerEntity.collisionLayer, 0x40) != 0)) {
this->field_0xf = 0xf;
this->animPriority = 0xf;
this->stateID++;
gPlayerEntity.field_0x7a.HWORD = 2;
object = CreateObjectWithParent(&gPlayerEntity, LAMP_PARTICLE, 1, 0);
@ -103,8 +104,8 @@ void sub_08075B54(ItemBehavior* this, u32 idx) {
object->x.HALF.HI = tmp[0] + object->x.HALF.HI;
object->y.HALF.HI = tmp[1] + object->y.HALF.HI;
}
sub_08077DF4(this, 0x60c);
bVar1 = (8 >> (idx));
SetItemAnim(this, 0x60c);
bVar1 = (8 >> (index));
gPlayerState.field_0xa |= bVar1;
gPlayerState.keepFacing |= bVar1;
}
@ -113,7 +114,7 @@ void sub_08075B54(ItemBehavior* this, u32 idx) {
}
}
void sub_08075C9C(ItemBehavior* this, u32 idx) {
void sub_08075C9C(ItemBehavior* this, u32 index) {
s8* tmp;
UpdateItemAnim(this);
@ -122,10 +123,10 @@ void sub_08075C9C(ItemBehavior* this, u32 idx) {
sub_0807AB44(&gPlayerEntity, tmp[0], tmp[1]);
}
if ((this->playerFrame & 0x80) != 0) {
this->field_0xf = 0;
this->animPriority = 0;
this->stateID--;
gPlayerState.field_0xa = (~(8 >> idx)) & gPlayerState.field_0xa;
gPlayerState.keepFacing = (~(8 >> idx)) & gPlayerState.keepFacing;
gPlayerState.field_0xa = (~(8 >> index)) & gPlayerState.field_0xa;
gPlayerState.keepFacing = (~(8 >> index)) & gPlayerState.keepFacing;
} else {
gPlayerEntity.field_0x7a.HWORD++;
}

View File

@ -14,27 +14,27 @@ void sub_080771C8(ItemBehavior*, u32);
void sub_080772A8(ItemBehavior*, u32);
void sub_08077448(ItemBehavior*, u32);
void ItemMoleMitts(ItemBehavior* this, u32 idx) {
void ItemMoleMitts(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08077130,
sub_080771C8,
sub_080772A8,
sub_08077448,
};
stateFuncs[this->stateID](this, idx);
stateFuncs[this->stateID](this, index);
}
void sub_08077130(ItemBehavior* this, u32 idx) {
void sub_08077130(ItemBehavior* this, u32 index) {
s32 iVar1;
if (gPlayerState.jump_status == 0) {
sub_08077D38(this, idx);
sub_08077D38(this, index);
gPlayerState.moleMittsState = 1;
this->field_0x9 |= 0x80;
this->priority |= 0x80;
iVar1 = sub_080774A0();
if (iVar1 != 0) {
if (this->timer == 0) {
sub_08077DF4(this, 0x50c);
SetItemAnim(this, 0x50c);
this->stateID = 2;
if (iVar1 == 0x56) {
if ((gPlayerEntity.animationState & 2) != 0) {
@ -45,16 +45,16 @@ void sub_08077130(ItemBehavior* this, u32 idx) {
}
}
} else {
sub_08077DF4(this, 0x508);
SetItemAnim(this, 0x508);
this->stateID = 1;
}
} else {
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
gPlayerState.moleMittsState = 0;
}
}
void sub_080771C8(ItemBehavior* this, u32 idx) {
void sub_080771C8(ItemBehavior* this, u32 index) {
static const u8 gUnk_0811BE14[] = {
0x1,
0x12,
@ -63,7 +63,7 @@ void sub_080771C8(ItemBehavior* this, u32 idx) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
gPlayerState.moleMittsState = 0;
} else {
if (((this->playerFrame & 0x20) != 0) && (this->subtimer == 0xff)) {
@ -71,7 +71,7 @@ void sub_080771C8(ItemBehavior* this, u32 idx) {
}
if ((this->playerFrame & 0x10) != 0) {
if (sub_0800875A(&gPlayerEntity, 0xd, this) == 0) {
sub_08077DF4(this, 0x520);
SetItemAnim(this, 0x520);
this->stateID = 3;
SoundReq(SFX_107);
} else {
@ -95,7 +95,7 @@ void sub_080771C8(ItemBehavior* this, u32 idx) {
}
}
void sub_080772A8(ItemBehavior* this, u32 idx) {
void sub_080772A8(ItemBehavior* this, u32 index) {
static const s16 gUnk_0811BE16[] = {
0,
0xc0,
@ -104,7 +104,7 @@ void sub_080772A8(ItemBehavior* this, u32 idx) {
};
Entity* effect;
if (((this->playerFrame & 8) != 0) && sub_08077F10(this)) {
if (((this->playerFrame & 8) != 0) && IsItemActivatedThisFrame(this)) {
this->timer = 1;
}
if (GetInventoryValue(ITEM_DIG_BUTTERFLY) == 1) {
@ -131,7 +131,7 @@ void sub_080772A8(ItemBehavior* this, u32 idx) {
return;
}
}
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
gPlayerState.moleMittsState = 0;
} else {
if ((this->playerFrame & 0x60) != 0) {
@ -140,7 +140,7 @@ void sub_080772A8(ItemBehavior* this, u32 idx) {
SoundReq(SFX_108);
CreateObjectWithParent(&gPlayerEntity, MOLE_MITTS_PARTICLE, this->playerFrame, 0);
} else {
sub_08077DF4(this, 0x51c);
SetItemAnim(this, 0x51c);
effect = CreateFx(&gPlayerEntity, FX_STARS_STRIKE, 0);
if (effect != NULL) {
effect->animationState = this->playerAnimationState;
@ -160,7 +160,7 @@ void sub_080772A8(ItemBehavior* this, u32 idx) {
}
}
void sub_08077448(ItemBehavior* this, u32 idx) {
void sub_08077448(ItemBehavior* this, u32 index) {
gPlayerEntity.direction = gPlayerEntity.animationState << 2 ^ 0x10;
gPlayerEntity.speed = 0x100;
if (((this->playerFrame & 1) != 0) && (this->field_0x5 != 0)) {
@ -169,7 +169,7 @@ void sub_08077448(ItemBehavior* this, u32 idx) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
gPlayerState.moleMittsState = 0;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
}

View File

@ -7,20 +7,20 @@ extern void CreateBird(Entity*);
void OcarinaUse(ItemBehavior*, u32);
void OcarinaUpdate(ItemBehavior*, u32);
void ItemOcarina(ItemBehavior* this, u32 idx) {
void ItemOcarina(ItemBehavior* this, u32 index) {
static void (*const gOcarinaStates[])(ItemBehavior*, u32) = {
OcarinaUse,
OcarinaUpdate,
};
gOcarinaStates[this->stateID](this, idx);
gPlayerEntity.field_0x7a.HWORD += 1;
gOcarinaStates[this->stateID](this, index);
gPlayerEntity.field_0x7a.HWORD++;
}
void OcarinaUse(ItemBehavior* this, u32 idx) {
void OcarinaUse(ItemBehavior* this, u32 index) {
if (gPlayerState.queued_action == PLAYER_ROLL) {
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
} else {
this->field_0x9 |= 0xf;
this->priority |= 0xf;
gPlayerEntity.animationState = 0x04;
gPlayerEntity.spriteSettings.flipX = 0;
gPlayerEntity.flags &= ~ENT_COLLIDE;
@ -28,17 +28,16 @@ void OcarinaUse(ItemBehavior* this, u32 idx) {
gPlayerState.flags |= PL_USE_OCARINA;
gPlayerState.field_0x27[0] = -1;
gPauseMenuOptions.disabled = 1;
gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa;
gPlayerState.keepFacing = (8 >> idx) | gPlayerState.keepFacing;
gPlayerState.field_0xa = (8 >> index) | gPlayerState.field_0xa;
gPlayerState.keepFacing = (8 >> index) | gPlayerState.keepFacing;
ResetPlayerVelocity();
sub_08077D38(this, idx);
sub_08077D38(this, index);
SoundReq(SFX_216);
SetPlayerEventPriority();
}
}
void OcarinaUpdate(ItemBehavior* this, u32 idx) {
// TODO regalloc
void OcarinaUpdate(ItemBehavior* this, u32 index) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
gPlayerEntity.flags |= ENT_COLLIDE;
@ -47,6 +46,6 @@ void OcarinaUpdate(ItemBehavior* this, u32 idx) {
gPauseMenuOptions.disabled = 0;
CreateBird(&gPlayerEntity);
ResetPlayerEventPriority();
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
}

View File

@ -7,28 +7,28 @@
void sub_08076C98(ItemBehavior*, u32);
void sub_08076CBC(ItemBehavior*, u32);
void ItemPacciCane(ItemBehavior* beh, u32 idx) {
static void (*const stateFuncs[])(ItemBehavior * beh, u32) = {
void ItemPacciCane(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08076C98,
sub_08076CBC,
};
stateFuncs[beh->stateID](beh, idx);
stateFuncs[this->stateID](this, index);
}
void sub_08076C98(ItemBehavior* beh, u32 idx) {
beh->field_0x9 |= 0xf;
sub_08077D38(beh, idx);
void sub_08076C98(ItemBehavior* this, u32 index) {
this->priority |= 0xf;
sub_08077D38(this, index);
sub_0806F948(&gPlayerEntity);
sub_08077BB8(beh);
sub_08077BB8(this);
}
void sub_08076CBC(ItemBehavior* beh, u32 idx) {
if ((beh->playerFrame & 0x80) != 0) {
DeletePlayerItem(beh, idx);
void sub_08076CBC(ItemBehavior* this, u32 index) {
if ((this->playerFrame & 0x80) != 0) {
DeleteItemBehavior(this, index);
} else {
if ((beh->playerFrame & 0x40) != 0) {
CreatePlayerItemWithParent(beh, PLAYER_ITEM_12);
if ((this->playerFrame & 0x40) != 0) {
CreatePlayerItemWithParent(this, PLAYER_ITEM_PACCI_CANE_PROJECTILE);
}
UpdateItemAnim(beh);
UpdateItemAnim(this);
}
}

View File

@ -14,7 +14,7 @@ void sub_08076A88(ItemBehavior*, u32);
extern u16 gUnk_0800275C[];
extern u8 gUnk_0811BE38[];
void ItemPegasusBoots(ItemBehavior* this, u32 idx) {
void ItemPegasusBoots(ItemBehavior* this, u32 index) {
static void (*const ItemPegasusBoots_StateFunctions[])(ItemBehavior * beh, u32) = {
sub_080768F8,
sub_08076964,
@ -26,8 +26,8 @@ void ItemPegasusBoots(ItemBehavior* this, u32 idx) {
if (gPlayerEntity.field_0x7a.HWORD != 0) {
gPlayerState.dash_state = 0;
gPlayerState.field_0xe = 0;
DeletePlayerItem(this, idx);
gPlayerState.itemAnimPriority = 0;
DeleteItemBehavior(this, index);
} else {
--this->timer;
if ((this->timer & 7) == 0) {
@ -54,15 +54,15 @@ void ItemPegasusBoots(ItemBehavior* this, u32 idx) {
}
}
}
ItemPegasusBoots_StateFunctions[this->stateID](this, idx);
ItemPegasusBoots_StateFunctions[this->stateID](this, index);
}
}
void sub_080768F8(ItemBehavior* this, u32 idx) {
void sub_080768F8(ItemBehavior* this, u32 index) {
u32 bVar1;
u32 bVar2;
bVar1 = gPlayerState.field_0x1c | gPlayerState.field_0x3[1] | gPlayerState.heldObject | gPlayerState.jump_status;
bVar1 = gPlayerState.field_0x1c | gPlayerState.attack_status | gPlayerState.heldObject | gPlayerState.jump_status;
bVar2 = (gPlayerState.flags & PL_IN_MINECART);
bVar1 |= bVar2;
if (bVar1 == 0) {
@ -73,19 +73,19 @@ void sub_080768F8(ItemBehavior* this, u32 idx) {
} else {
gPlayerState.animation = 0xc14;
}
sub_08077D38(this, idx);
sub_08076964(this, idx);
sub_08077D38(this, index);
sub_08076964(this, index);
} else {
gPlayerState.dash_state = 0;
gPlayerState.field_0xe = 0;
DeletePlayerItem(this, idx);
gPlayerState.itemAnimPriority = 0;
DeleteItemBehavior(this, index);
}
}
void sub_08076964(ItemBehavior* this, u32 idx) {
Entity* bombEntity;
void sub_08076964(ItemBehavior* this, u32 index) {
Entity* entity;
u32 uVar3;
if (sub_08077EFC(this) && gPlayerEntity.z.WORD == 0 && gPlayerState.dash_state) {
if (IsItemActive(this) && gPlayerEntity.z.WORD == 0 && gPlayerState.dash_state) {
UpdateItemAnim(this);
if ((gPlayerState.flags & PL_MINISH) == 0) {
@ -95,28 +95,28 @@ void sub_08076964(ItemBehavior* this, u32 idx) {
if ((++gPlayerState.dash_state) == 0x1e) {
if ((gPlayerState.flags & PL_FLAGS2) != 0) {
gPlayerState.dash_state = 0;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
return;
}
gPlayerState.dash_state = 0x40;
gPlayerState.field_0xa &= ~(8 >> idx);
gPlayerState.field_0xa &= ~(8 >> index);
this->stateID++;
if (HasSwordEquipped() && (gPlayerState.flags & PL_MINISH) == 0 &&
(gPlayerState.skills & SKILL_DASH_ATTACK) != 0) {
gPlayerState.field_0xab = 3;
sub_08077DF4(this, 0x298);
bombEntity = CreatePlayerItemWithParent(this, PLAYER_ITEM_C);
if (bombEntity != NULL) {
gPlayerState.lastSwordMove = SWORD_MOVE_DASH;
SetItemAnim(this, 0x298);
entity = CreatePlayerItemWithParent(this, PLAYER_ITEM_DASH_SWORD);
if (entity != NULL) {
if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != 0) {
uVar3 = gSave.stats.itemButtons[SLOT_A];
} else {
uVar3 = gSave.stats.itemButtons[SLOT_B];
}
bombEntity->field_0x68.HALF.LO = uVar3;
entity->field_0x68.HALF.LO = uVar3;
return;
}
} else if ((gPlayerState.flags & PL_MINISH) == 0) {
sub_08077DF4(this, 0x104);
SetItemAnim(this, 0x104);
return;
} else {
gPlayerState.animation = 0xc10;
@ -127,15 +127,15 @@ void sub_08076964(ItemBehavior* this, u32 idx) {
}
}
gPlayerState.dash_state = 0;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}
void sub_08076A88(ItemBehavior* this, u32 idx) {
void sub_08076A88(ItemBehavior* this, u32 index) {
u32 uVar1;
u32 uVar2;
u8* ptr;
if ((sub_08077EFC(this) != 0) && (gPlayerState.dash_state != 0)) {
if ((IsItemActive(this) != 0) && (gPlayerState.dash_state != 0)) {
if ((gPlayerState.flags & PL_MINISH) == 0) {
gPlayerEntity.speed = 0x300;
} else {
@ -148,27 +148,27 @@ void sub_08076A88(ItemBehavior* this, u32 idx) {
gPlayerEntity.subAction = 0;
COLLISION_OFF(&gPlayerEntity);
gPlayerState.field_0x38 = 0;
gPlayerState.field_0xd = 0xff;
gPlayerState.direction = 0xff;
return;
}
this->subtimer = 1;
return;
}
ptr = gUnk_0811BE38;
if ((*(u16*)&ptr[(gPlayerEntity.animationState & 0xfe)] & gPlayerState.playerInput.field_0x90) == 0) {
if ((*(u16*)&ptr[(gPlayerEntity.animationState & 0xfe)] & gPlayerState.playerInput.heldInput) == 0) {
this->direction = (this->playerAnimationState & 0xe) * 4;
if ((gPlayerState.field_0xd != 0xff) && (gPlayerState.field_0xd != this->direction)) {
if (((gPlayerState.field_0xd - this->direction) & 0x1f) < 0x10) {
if ((gPlayerState.direction != 0xff) && (gPlayerState.direction != this->direction)) {
if (((gPlayerState.direction - this->direction) & 0x1f) < 0x10) {
this->direction = this->direction + 2;
}
this->direction--;
this->direction &= 0x1f;
}
gPlayerState.field_0xd = this->direction;
gPlayerState.direction = this->direction;
UpdateItemAnim(this);
return;
}
}
gPlayerState.dash_state = 0;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}

View File

@ -5,23 +5,23 @@
void sub_08076758(ItemBehavior*, u32);
extern void sub_08077F84(void);
void ItemRocsCape(ItemBehavior* this, u32 arg1) {
void ItemRocsCape(ItemBehavior* this, u32 index) {
if (this->stateID != 0) {
sub_08076758(this, arg1);
sub_08076758(this, index);
return;
}
if (gPlayerState.item == NULL) {
if (gPlayerState.field_0x0[1]) {
if (((gPlayerState.field_0x3[1] | gPlayerState.heldObject) == 0) &&
if (gPlayerState.grab_status) {
if (((gPlayerState.attack_status | gPlayerState.heldObject) == 0) &&
(((gPlayerState.floor_type != SURFACE_DOOR && (gPlayerState.floor_type != SURFACE_PIT)) ||
((gPlayerEntity.z.WORD != 0 || (gPlayerState.field_0x14 != 0)))))) {
if ((gPlayerState.jump_status == 0) || ((gPlayerState.jump_status & 7) == 3)) {
if (-1 < gPlayerEntity.z.WORD) {
gPlayerState.field_0x0[1] = 0;
this->stateID += 1;
gPlayerState.grab_status = 0;
this->stateID++;
gPlayerState.keepFacing = 0;
gPlayerState.jump_status = 1;
gPlayerState.field_0xe = -1;
gPlayerState.itemAnimPriority = -1;
gPlayerState.item = NULL;
gPlayerEntity.zVelocity = Q_16_16(2.0);
sub_08077F84();
@ -29,25 +29,25 @@ void ItemRocsCape(ItemBehavior* this, u32 arg1) {
return;
}
} else {
sub_08076758(this, arg1);
sub_08076758(this, index);
return;
}
}
} else {
if (((u8)(gPlayerState.sword_state | gPlayerState.field_0xa | gPlayerState.field_0x3[1] |
if (((u8)(gPlayerState.sword_state | gPlayerState.field_0xa | gPlayerState.attack_status |
gPlayerState.heldObject | gPlayerState.field_0x1c | gPlayerState.moleMittsState) == 0) &&
((((gPlayerState.floor_type != SURFACE_DOOR && gPlayerState.floor_type != SURFACE_DOOR_13 &&
gPlayerState.floor_type != SURFACE_PIT) ||
(gPlayerEntity.z.WORD != 0)) ||
(gPlayerState.field_0x14 != 0)))) {
if ((gPlayerState.jump_status != 0) && ((gPlayerState.jump_status & 7) != 3)) {
sub_08076758(this, arg1);
sub_08076758(this, index);
return;
} else if (gPlayerEntity.z.WORD >= 0) {
gPlayerEntity.zVelocity = Q_16_16(2.0);
gPlayerState.jump_status = 1;
gPlayerState.item = NULL;
this->stateID += 1;
this->stateID++;
sub_08077F84();
SoundReq(SFX_PLY_VO4);
return;
@ -55,16 +55,14 @@ void ItemRocsCape(ItemBehavior* this, u32 arg1) {
}
}
}
DeletePlayerItem(this, arg1);
DeleteItemBehavior(this, index);
}
void sub_08076758(ItemBehavior* this, u32 arg1) {
s32 iVar1;
gPlayerState.field_0xe = 0;
void sub_08076758(ItemBehavior* this, u32 index) {
gPlayerState.itemAnimPriority = 0;
if ((((gPlayerState.jump_status & 0x28) == 0) && (gPlayerState.jump_status != 0)) &&
((gPlayerState.jump_status & 7) != 3)) {
if (sub_08077EFC(this)) {
if (IsItemActive(this)) {
if (this->stateID < 2) {
if ((gPlayerEntity.zVelocity <= 0) && ((gPlayerState.jump_status & 0x10) == 0)) {
this->stateID = 2;
@ -75,15 +73,15 @@ void sub_08076758(ItemBehavior* this, u32 arg1) {
SoundReq(SFX_172);
}
} else {
gPlayerEntity.field_0x7a.HWORD += 1;
gPlayerEntity.field_0x7a.HWORD++;
}
} else {
if (this->stateID > 1) {
gPlayerEntity.field_0x7a.HWORD += 1;
gPlayerEntity.field_0x7a.HWORD++;
gPlayerState.jump_status &= 0xef;
}
}
} else {
DeletePlayerItem(this, arg1);
DeleteItemBehavior(this, index);
}
}

View File

@ -8,45 +8,45 @@ void sub_08076D04(ItemBehavior*, u32);
void sub_08076D34(ItemBehavior*, u32);
void sub_08076D94(ItemBehavior*, u32);
void ItemShield(ItemBehavior* beh, u32 idx) {
void ItemShield(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08076D04,
sub_08076D34,
sub_08076D94,
};
stateFuncs[beh->stateID](beh, idx);
stateFuncs[this->stateID](this, index);
}
void sub_08076D04(ItemBehavior* beh, u32 idx) {
gPlayerState.field_0x3[0] = 0x81;
beh->field_0x9 = 2;
void sub_08076D04(ItemBehavior* this, u32 index) {
gPlayerState.shield_status = 0x81;
this->priority = 2;
sub_0806F948(&gPlayerEntity);
sub_08077D38(beh, idx);
sub_08077BB8(beh);
sub_08077D38(this, index);
sub_08077BB8(this);
}
void sub_08076D34(ItemBehavior* beh, u32 idx) {
if (sub_08077EFC(beh) != 0) {
gPlayerState.field_0x3[0] |= 1;
UpdateItemAnim(beh);
if (beh->playerFrame != 0) {
beh->stateID++;
beh->field_0xf = 0;
gPlayerState.field_0xa &= ~(u8)(8 >> idx);
void sub_08076D34(ItemBehavior* this, u32 index) {
if (IsItemActive(this) != 0) {
gPlayerState.shield_status |= 1;
UpdateItemAnim(this);
if (this->playerFrame != 0) {
this->stateID++;
this->animPriority = 0;
gPlayerState.field_0xa &= ~(u8)(8 >> index);
SoundReq(SFX_15D);
}
} else {
gPlayerState.field_0x3[0] = 0;
DeletePlayerItem(beh, idx);
gPlayerState.shield_status = 0;
DeleteItemBehavior(this, index);
}
}
void sub_08076D94(ItemBehavior* beh, u32 idx) {
if (sub_08077EFC(beh)) {
gPlayerState.field_0x3[0] |= 1;
UpdateItemAnim(beh);
void sub_08076D94(ItemBehavior* this, u32 index) {
if (IsItemActive(this)) {
gPlayerState.shield_status |= 1;
UpdateItemAnim(this);
} else {
gPlayerState.field_0x3[0] = 0;
DeletePlayerItem(beh, idx);
gPlayerState.shield_status = 0;
DeleteItemBehavior(this, index);
}
}

View File

@ -1,8 +1,9 @@
#include "item.h"
#include "functions.h"
#include "sound.h"
#include "item.h"
#include "object.h"
#include "player.h"
#include "playeritem.h"
#include "sound.h"
void sub_080759B8(ItemBehavior*, u32);
void sub_080754B8(ItemBehavior*, u32);
@ -16,20 +17,20 @@ void sub_080758B0(ItemBehavior*, u32);
void sub_08075900(ItemBehavior*, u32);
void sub_08075694(ItemBehavior*, u32);
void ItemSword(ItemBehavior* this, u32 idx) {
void ItemSword(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08075338, sub_080754B8, sub_080755F0, sub_0807564C, sub_08075738,
sub_08075580, sub_08075898, sub_080758B0, sub_08075900,
};
gPlayerState.framestate = PL_STATE_SWORD;
stateFuncs[this->stateID](this, idx);
stateFuncs[this->stateID](this, index);
}
void sub_08075338(ItemBehavior* this, u32 idx) {
void sub_08075338(ItemBehavior* this, u32 index) {
u32 temp, temp2;
if (gPlayerState.flags & PL_MINISH) {
this->field_0x9 |= 0x80;
sub_08077D38(this, idx);
this->priority |= 0x80;
sub_08077D38(this, index);
gPlayerState.animation = 0xc00;
SoundReq(SFX_PLY_VO1);
return;
@ -40,20 +41,20 @@ void sub_08075338(ItemBehavior* this, u32 idx) {
if ((gPlayerState.jump_status & 0x78) == 0 && (u32)gPlayerEntity.zVelocity < Q_16_16(1.5) &&
(gPlayerState.skills & SKILL_DOWN_THRUST) && gPlayerEntity.z.WORD != 0) {
gPlayerState.jump_status |= 0x20;
gPlayerState.field_0xab = 7;
gPlayerState.field_0x3[1] |= (8 >> idx) | ((8 >> idx) << 4);
gPlayerState.lastSwordMove = SWORD_MOVE_DOWN_THRUST;
gPlayerState.attack_status |= (8 >> index) | ((8 >> index) << 4);
sub_08077B98(this);
this->stateID = 6;
sub_08075898(this, idx);
sub_08075898(this, index);
return;
}
}
#ifndef EU
sub_080759B8(this, idx);
sub_080759B8(this, index);
return;
} else if (gPlayerEntity.z.WORD) {
#endif
sub_080759B8(this, idx);
sub_080759B8(this, index);
return;
}
@ -67,19 +68,19 @@ void sub_08075338(ItemBehavior* this, u32 idx) {
}
// Do the roll attack.
sub_08077D38(this, idx);
sub_08077D38(this, index);
sub_08077B98(this);
temp = (8 >> idx);
gPlayerState.field_0x3[1] |= temp | (temp << 4);
temp = (8 >> index);
gPlayerState.attack_status |= temp | (temp << 4);
gPlayerState.field_0xa |= temp;
gPlayerState.keepFacing |= temp;
this->stateID = 8;
this->timer = 0x14;
this->field_0xf = 6;
this->field_0x9 |= 0x80;
gPlayerState.field_0xab = 2;
this->animPriority = 6;
this->priority |= 0x80;
gPlayerState.lastSwordMove = SWORD_MOVE_ROLL;
gPlayerState.flags |= PL_SWORD_THRUST;
sub_08077DF4(this, 0x130);
SetItemAnim(this, 0x130);
SoundReq(SFX_PLY_VO3);
return;
}
@ -96,105 +97,107 @@ void sub_08075338(ItemBehavior* this, u32 idx) {
}
}
sub_08077D38(this, idx);
sub_08077D38(this, index);
sub_08077B98(this);
}
void sub_080754B8(ItemBehavior* this, u32 idx) {
u32 iVar1;
void sub_080754B8(ItemBehavior* this, u32 index) {
u32 swordBeam;
if ((gPlayerState.sword_state & 0x80) != 0) {
sub_08075694(this, idx);
} else if (gPlayerState.field_0x3[1] != 0) {
sub_08075694(this, index);
} else if (gPlayerState.attack_status != 0) {
UpdateItemAnim(this);
if (this->playerFrame != 0) {
this->field_0x9 &= ~0x80;
this->priority &= ~0x80;
}
if (gPlayerEntity.frameSpriteSettings & 1) {
iVar1 = sub_0807B014();
if (iVar1 && FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_SWORD_BEAM1, 2) == 0) {
swordBeam = GetSwordBeam();
if (swordBeam && FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_SWORD_BEAM1, 2) == 0) {
CreatePlayerItemWithParent(this, PLAYER_ITEM_SWORD_BEAM1);
if (iVar1 == 0xf) {
gPlayerState.field_0xab = 5;
if (swordBeam == 0xf) {
// SKILL_SWORD_BEAM (full health)
gPlayerState.lastSwordMove = SWORD_MOVE_FULL_BEAM;
} else {
gPlayerState.field_0xab = 8;
// SKILL_PERIL_BEAM (low health)
gPlayerState.lastSwordMove = SWORD_MOVE_LOW_BEAM;
}
}
}
if ((this->playerFrame & 0x80) != 0) {
if (((gPlayerState.flags & 0x80) != 0) || ((gPlayerState.skills & SKILL_SPIN_ATTACK) == 0)) {
sub_080759B8(this, idx);
sub_080759B8(this, index);
} else {
sub_08075580(this, idx);
sub_08075580(this, index);
}
}
} else {
sub_080759B8(this, idx);
sub_080759B8(this, index);
}
}
void sub_08075580(ItemBehavior* this, u32 idx) {
if ((sub_08077EFC(this) != 0) && (gPlayerState.jump_status == 0)) {
gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> idx);
void sub_08075580(ItemBehavior* this, u32 index) {
if ((IsItemActive(this) != 0) && (gPlayerState.jump_status == 0)) {
gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> index);
gPlayerState.sword_state = 1;
gPlayerState.item->hurtType = 0xd;
this->field_0xf = 0;
this->animPriority = 0;
this->stateID = 2;
if ((gPlayerState.skills & SKILL_FAST_SPIN) != 0) {
this->timer = 0x28; // TODO spin speed?
} else {
this->timer = 0x50;
}
sub_08077DF4(this, 0x168);
SetItemAnim(this, 0x168);
CreateObject(SWORD_PARTICLE, 0, 0);
return;
}
sub_080759B8(this, idx);
sub_080759B8(this, index);
}
void sub_080755F0(ItemBehavior* this, u32 idx) {
if (sub_08077EFC(this) != 0) {
void sub_080755F0(ItemBehavior* this, u32 index) {
if (IsItemActive(this) != 0) {
if (sub_08077EC8(this) == 0) {
if ((gPlayerState.sword_state | gPlayerState.field_0x3[1]) != 0) {
if ((gPlayerState.sword_state | gPlayerState.attack_status) != 0) {
if (--this->timer == 0) {
this->stateID = 3;
this->field_0x9 |= 0x80;
this->priority |= 0x80;
gPlayerState.sword_state = gPlayerState.sword_state | 0x20;
}
} else {
sub_080759B8(this, idx);
sub_080759B8(this, index);
}
}
} else {
sub_080759B8(this, idx);
sub_080759B8(this, index);
}
}
void sub_0807564C(ItemBehavior* this, u32 idx) {
if ((gPlayerState.sword_state | gPlayerState.field_0x3[1]) == 0) {
sub_080759B8(this, idx);
void sub_0807564C(ItemBehavior* this, u32 index) {
if ((gPlayerState.sword_state | gPlayerState.attack_status) == 0) {
sub_080759B8(this, index);
} else {
if ((sub_08077EC8(this) == 0) && ((sub_08077EFC(this) == 0 || ((gPlayerState.sword_state & 0x80) != 0)))) {
sub_08075694(this, idx);
if ((sub_08077EC8(this) == 0) && ((IsItemActive(this) == 0 || ((gPlayerState.sword_state & 0x80) != 0)))) {
sub_08075694(this, index);
}
}
}
void sub_08075694(ItemBehavior* this, u32 idx) {
void sub_08075694(ItemBehavior* this, u32 index) {
this->timer = 1;
if (gPlayerState.flags & PL_SWORD_THRUST) {
gPlayerState.flags &= ~PL_SWORD_THRUST;
gPlayerState.flags &= ~PL_ROLLING;
sub_08077DF4(this, 300);
SetItemAnim(this, 300);
} else {
gPlayerState.field_0xab = 1;
sub_08077DF4(this, 0x124);
gPlayerState.lastSwordMove = SWORD_MOVE_SPIN;
SetItemAnim(this, 0x124);
}
gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa;
gPlayerState.field_0xa = (8 >> index) | gPlayerState.field_0xa;
this->stateID = 4;
this->field_0xf = 6;
this->animPriority = 6;
gPlayerEntity.hurtType = 0x1e;
gPlayerState.sword_state |= 0x40;
gPlayerState.sword_state &= 0xdf;
@ -205,20 +208,20 @@ void sub_08075694(ItemBehavior* this, u32 idx) {
SoundReq(SFX_PLY_VO2);
}
void sub_08075738(ItemBehavior* this, u32 idx) {
void sub_08075738(ItemBehavior* this, u32 index) {
u32 bVar6;
if (gPlayerState.field_0x3[1] == 0) {
sub_080759B8(this, idx);
if (gPlayerState.attack_status == 0) {
sub_080759B8(this, index);
} else {
UpdateItemAnim(this);
if (sub_08077F10(this)) {
if (IsItemActivatedThisFrame(this)) {
this->timer = 2;
}
if ((gPlayerState.sword_state & 0x10) != 0) {
if ((gPlayerState.field_0xd & 0x80) == 0) {
this->direction = gPlayerState.field_0xd;
if ((gPlayerState.direction & 0x80) == 0) {
this->direction = gPlayerState.direction;
}
gPlayerEntity.direction = this->direction;
gPlayerEntity.speed = 0x180;
@ -229,13 +232,13 @@ void sub_08075738(ItemBehavior* this, u32 idx) {
}
if ((bVar6 <= ++this->subtimer) || (--this->timer == 0)) {
sub_080759B8(this, idx);
sub_080759B8(this, index);
}
}
} else {
if (((((gPlayerEntity.frameSpriteSettings & 1) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) &&
((gPlayerState.skills & SKILL_FOURSWORD) != 0))) {
Entity* bombEnt = CreatePlayerItemWithParent(this, PLAYER_ITEM_14);
Entity* bombEnt = CreatePlayerItemWithParent(this, PLAYER_ITEM_SPIRAL_BEAM);
if (bombEnt) {
bombEnt->animationState = (gPlayerEntity.animationState & 6) | 0x80;
}
@ -244,34 +247,34 @@ void sub_08075738(ItemBehavior* this, u32 idx) {
if ((((gPlayerEntity.frameSpriteSettings & 2) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) &&
(((gPlayerState.skills & SKILL_GREAT_SPIN) != 0 && (--this->timer != 0)))) {
gPlayerState.sword_state |= 0x10;
gPlayerState.field_0xab = 6;
gPlayerState.lastSwordMove = SWORD_MOVE_GREAT_SPIN;
this->direction = gPlayerEntity.animationState << 2;
this->timer = 1;
this->subtimer = 1;
gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> idx);
sub_08077DF4(this, 0x128);
gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> index);
SetItemAnim(this, 0x128);
}
if ((this->playerFrame & 0x80) != 0) {
sub_080759B8(this, idx);
sub_080759B8(this, index);
}
}
}
}
void sub_08075898(ItemBehavior* this, u32 idx) {
if (gPlayerState.field_0x3[1] == 0) {
sub_080759B8(this, idx);
void sub_08075898(ItemBehavior* this, u32 index) {
if (gPlayerState.attack_status == 0) {
sub_080759B8(this, index);
}
}
void sub_080758B0(ItemBehavior* this, u32 idx) {
if (gPlayerState.field_0x3[1] == 0) {
sub_080759B8(this, idx);
void sub_080758B0(ItemBehavior* this, u32 index) {
if (gPlayerState.attack_status == 0) {
sub_080759B8(this, index);
} else {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
this->field_0xf = 0;
this->animPriority = 0;
if ((gPlayerState.sword_state & 0x20) != 0) {
this->stateID = 3;
} else {
@ -282,20 +285,20 @@ void sub_080758B0(ItemBehavior* this, u32 idx) {
}
}
void sub_08075900(ItemBehavior* this, u32 idx) {
void sub_08075900(ItemBehavior* this, u32 index) {
if (gPlayerState.floor_type == SURFACE_SWAMP) {
gPlayerState.flags &= ~PL_ROLLING;
sub_080759B8(this, idx);
sub_080759B8(this, index);
} else {
UpdateItemAnim(this);
if ((gPlayerState.sword_state & 0x80) != 0) {
gPlayerState.sword_state = 0xa0;
sub_0807564C(this, idx);
sub_0807564C(this, index);
} else {
if (this->timer != 0) {
if (--this->timer == 0) {
sub_08077DF4(this, 0x134);
SetItemAnim(this, 0x134);
}
gPlayerEntity.direction = (gPlayerEntity.animationState >> 1) << 3;
gPlayerEntity.speed = 0x300;
@ -306,19 +309,19 @@ void sub_08075900(ItemBehavior* this, u32 idx) {
} else {
if ((this->playerFrame & 0x80) != 0) {
gPlayerState.flags &= ~PL_ROLLING;
sub_080759B8(this, idx);
sub_080759B8(this, index);
}
}
}
}
}
void sub_080759B8(ItemBehavior* this, u32 idx) {
void sub_080759B8(ItemBehavior* this, u32 index) {
if ((gPlayerState.flags & PL_MINISH) == 0) {
gPlayerEntity.hurtType = 0;
}
gPlayerState.flags &= ~PL_SWORD_THRUST;
gPlayerState.sword_state = 0;
gPlayerState.item = NULL;
DeletePlayerItem(this, idx);
DeleteItemBehavior(this, index);
}

View File

@ -1,11 +1,12 @@
#include "item.h"
#include "functions.h"
#include "sound.h"
#include "playeritem.h"
u32 sub_08077F64(ItemBehavior* arg0, u32 idx);
u32 sub_08077F64(ItemBehavior* arg0, u32 index);
u32 sub_080789A8(void);
void sub_080762C4(ItemBehavior*, Entity*, u8, u32);
void sub_08076088(ItemBehavior*, void*, u32);
void sub_08076088(ItemBehavior*, Entity*, u32);
void ItemPickupCheck(ItemBehavior*, u32);
void sub_080762D8(ItemBehavior*, u32);
void sub_08076488(ItemBehavior*, u32);
@ -13,24 +14,79 @@ void sub_08076518(ItemBehavior*, u32);
void sub_080765E0(ItemBehavior*, u32);
void sub_0807660C(ItemBehavior*, u32);
void ItemTryPickupObject(ItemBehavior* this, u32 idx) {
void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) {
if (param_2 != NULL) {
if ((param_2->carryFlags & 1) != 0) {
return;
}
param_2->action = 2;
param_2->subAction = param_2->carryFlags & 1;
}
this->field_0x18 = param_2;
if ((gPlayerState.flags & PL_NO_CAP)) {
SetItemAnim(this, 0x928);
} else {
SetItemAnim(this, 0x338);
}
gPlayerState.heldObject = 3;
gPlayerState.framestate = 4;
this->stateID = 2;
this->animPriority = 0xf;
if ((gPlayerEntity.field_0x78.HALF.HI & 0x80)) {
gPlayerEntity.field_0x78.HALF.HI = 0;
COLLISION_ON(&gPlayerEntity);
gPlayerState.heldObject = 4;
gPlayerState.keepFacing = ~(8 >> param_3) & gPlayerState.keepFacing;
gPlayerState.field_0xa = ~(8 >> param_3) & gPlayerState.field_0xa;
this->stateID = 3;
this->animPriority = 0;
} else {
gPlayerState.field_0xa |= (8 >> param_3);
gPlayerState.keepFacing |= (8 >> param_3);
}
param_2 = CreatePlayerItemWithParent(this, PLAYER_ITEM_HELD_OBJECT);
if (param_2 == NULL) {
PlayerCancelHoldItem(this, param_3);
} else {
Entity* playerEnt = &gPlayerEntity;
*(Entity**)&playerEnt->field_0x74 = param_2;
playerEnt->subtimer = 0;
param_2->child = this->field_0x18;
param_2->carryFlags = playerEnt->carryFlags;
param_2->parent = (Entity*)this;
this->field_0x18 = param_2;
param_2->type2 = this->field_0x2[1];
param_2->timer = this->timer;
param_2->subtimer = this->subtimer;
if ((this->field_0x18->carryFlags & 0xf0) == 0x10) {
this->timer = 8;
} else {
this->timer = 0;
}
SoundReq(SFX_PLY_LIFT);
}
}
void ItemTryPickupObject(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
ItemPickupCheck, sub_080762D8, sub_08076488, sub_08076518, sub_080765E0, sub_0807660C,
};
stateFuncs[this->stateID](this, idx);
stateFuncs[this->stateID](this, index);
}
void ItemPickupCheck(ItemBehavior* this, u32 idx) {
void ItemPickupCheck(ItemBehavior* this, u32 index) {
Entity* carried;
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)))))) {
if (gPlayerState.attack_status == 0 &&
(gPlayerState.jump_status == 0 || (gPlayerState.flags & (PL_BUSY | PL_FALLING | PL_IN_MINECART)) != 0) &&
(gPlayerState.grab_status = gPlayerEntity.animationState | 0x80, gPlayerEntity.iframes <= 8)) {
switch (sub_080789A8()) {
case 2:
if (((gCarriedEntity.unk_8)->carryFlags & 0xf) == 0) {
sub_08076088(this, gCarriedEntity.unk_8, idx);
sub_08076088(this, gCarriedEntity.unk_8, index);
return;
}
carried = gCarriedEntity.unk_8;
@ -38,24 +94,24 @@ void ItemPickupCheck(ItemBehavior* this, u32 idx) {
carried->action = 2;
carried->subAction = 5;
gPlayerState.framestate = PL_STATE_THROW;
sub_080762C4(this, carried, 2, idx);
sub_080762C4(this, carried, 2, index);
gUnk_0200AF00.unk_2e = 8;
SoundReq(SFX_102);
break;
case 1:
sub_080762C4(this, 0, 1, idx);
sub_080762C4(this, 0, 1, index);
SoundReq(SFX_102);
break;
case 0:
this->stateID = 5;
this->timer = 0x0f;
this->field_0xf = 6;
gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa;
gPlayerState.keepFacing = (8 >> idx) | gPlayerState.keepFacing;
this->animPriority = 6;
gPlayerState.field_0xa = (8 >> index) | gPlayerState.field_0xa;
gPlayerState.keepFacing = (8 >> index) | gPlayerState.keepFacing;
if ((gPlayerState.flags & PL_NO_CAP) == 0) {
sub_08077DF4(this, 0x378);
SetItemAnim(this, 0x378);
} else {
sub_08077DF4(this, 0x948);
SetItemAnim(this, 0x948);
}
SoundReq(SFX_88);
break;
@ -63,7 +119,7 @@ void ItemPickupCheck(ItemBehavior* this, u32 idx) {
break;
}
} else {
PlayerCancelHoldItem(this, idx);
PlayerCancelHoldItem(this, index);
}
}
@ -73,14 +129,14 @@ void sub_080762C4(ItemBehavior* this, Entity* arg1, u8 arg2, u32 arg3) {
sub_08077D38(this, arg3);
}
ASM_FUNC("asm/non_matching/itemTryPickupObject/sub_080762D8.inc", void sub_080762D8(ItemBehavior* this, u32 idx))
ASM_FUNC("asm/non_matching/itemTryPickupObject/sub_080762D8.inc", void sub_080762D8(ItemBehavior* this, u32 index))
void sub_08076488(ItemBehavior* this, u32 idx) {
void sub_08076488(ItemBehavior* this, u32 index) {
u32 bVar1;
s32 iVar2;
if (this->timer == 0) {
if (PlayerTryDropObject(this, idx) != 0) {
if (PlayerTryDropObject(this, index) != 0) {
if ((((this->field_0x18->carryFlags) & 0xf0) == 0x10) && ((gRoomTransition.frameCount & 1U) != 0)) {
return;
}
@ -88,11 +144,11 @@ void sub_08076488(ItemBehavior* this, u32 idx) {
if ((this->playerFrame & 0x80) != 0) {
gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerState.heldObject = 4;
bVar1 = ~(8 >> idx);
bVar1 = ~(8 >> index);
gPlayerState.keepFacing = bVar1 & gPlayerState.keepFacing;
gPlayerState.field_0xa = bVar1 & gPlayerState.field_0xa;
this->stateID++;
this->field_0xf = 0;
this->animPriority = 0;
}
}
} else {
@ -108,19 +164,18 @@ void sub_08076518(ItemBehavior* this, u32 index) {
if (gPlayerEntity.knockbackDuration != 0) {
PlayerCancelHoldItem(this, index);
} else {
if ((gPlayerState.playerInput.field_0x92 & (PLAYER_INPUT_8000 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) !=
0) {
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_8000 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0) {
sub_0806F948(&gPlayerEntity);
gPlayerState.heldObject = 5;
this->field_0x18->subAction = 2;
this->field_0x18->direction = (gPlayerEntity.animationState & 0xe) << 2;
this->field_0x18 = NULL;
this->stateID++;
this->field_0xf = 0x0f;
this->animPriority = 0x0f;
if ((gPlayerState.flags & PL_NO_CAP) != 0) {
sub_08077DF4(this, 0x930);
SetItemAnim(this, 0x930);
} else {
sub_08077DF4(this, 0x344);
SetItemAnim(this, 0x344);
}
gPlayerState.field_0xa |= 8 >> index;
gPlayerState.keepFacing |= 8 >> index;
@ -130,20 +185,20 @@ void sub_08076518(ItemBehavior* this, u32 index) {
}
}
void sub_080765E0(ItemBehavior* this, u32 idx) {
if (PlayerTryDropObject(this, idx) != 0) {
void sub_080765E0(ItemBehavior* this, u32 index) {
if (PlayerTryDropObject(this, index) != 0) {
if ((this->playerFrame & 0x80) != 0) {
PlayerCancelHoldItem(this, idx);
PlayerCancelHoldItem(this, index);
} else {
UpdateItemAnim(this);
}
}
}
void sub_0807660C(ItemBehavior* this, u32 idx) {
void sub_0807660C(ItemBehavior* this, u32 index) {
UpdateItemAnim(this);
if ((this->timer-- == 0) || (gPlayerState.field_0x0[1] == 0)) {
gPlayerState.field_0x0[1] = 0;
DeletePlayerItem(this, idx);
if ((this->timer-- == 0) || (gPlayerState.grab_status == 0)) {
gPlayerState.grab_status = 0;
DeleteItemBehavior(this, index);
}
}

43
src/itemDefinitions.c Normal file
View File

@ -0,0 +1,43 @@
#include "item.h"
#include "playeritem.h"
#include "structures.h"
const ItemDefinition gItemDefinitions[] = {
[ITEM_NONE] = { TRUE, 1, CREATE_ITEM_0, PLAYER_ITEM_NONE, 0, 0, FALSE, FALSE },
[ITEM_SMITH_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
[ITEM_GREEN_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
[ITEM_RED_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
[ITEM_BLUE_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
[ITEM_UNUSED_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
[ITEM_FOURSWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
[ITEM_BOMBS] = { TRUE, 3, CREATE_ITEM_4, PLAYER_ITEM_BOMB, 0, 3, FALSE, FALSE },
[ITEM_REMOTE_BOMBS] = { TRUE, 3, CREATE_ITEM_4, PLAYER_ITEM_BOMB, 0, 3, FALSE, FALSE },
[ITEM_BOW] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOW, 540, 3, FALSE, FALSE },
[ITEM_LIGHT_ARROW] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOW, 540, 3, FALSE, FALSE },
[ITEM_BOOMERANG] = { TRUE, 5, CREATE_ITEM_3, PLAYER_ITEM_BOOMERANG, 2072, 3, FALSE, FALSE },
[ITEM_MAGIC_BOOMERANG] = { TRUE, 5, CREATE_ITEM_3, PLAYER_ITEM_BOOMERANG, 1796, 3, FALSE, FALSE },
[ITEM_SHIELD] = { FALSE, 1, CREATE_ITEM_3, PLAYER_ITEM_SHIELD, 344, 2, FALSE, FALSE },
[ITEM_MIRROR_SHIELD] = { TRUE, 1, CREATE_ITEM_3, PLAYER_ITEM_SHIELD, 344, 2, FALSE, FALSE },
#ifdef EU
[ITEM_LANTERN_OFF] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, 1536, 6, FALSE, FALSE },
[ITEM_LANTERN_ON] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, 1536, 6, FALSE, FALSE },
#else
[ITEM_LANTERN_OFF] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, 1536, 2, FALSE, FALSE },
[ITEM_LANTERN_ON] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, 1536, 2, FALSE, FALSE },
#endif
[ITEM_GUST_JAR] = { TRUE, 6, CREATE_ITEM_3, PLAYER_ITEM_GUST_JAR, 1280, 2, FALSE, FALSE },
[ITEM_PACCI_CANE] = { TRUE, 4, CREATE_ITEM_3, PLAYER_ITEM_PACCI_CANE, 1576, 6, TRUE, FALSE },
[ITEM_MOLE_MITTS] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_NONE2, 0, 2, TRUE, FALSE },
[ITEM_ROCS_CAPE] = { TRUE, 1, CREATE_ITEM_1, PLAYER_ITEM_NONE3, 2060, 0, FALSE, FALSE },
[ITEM_PEGASUS_BOOTS] = { TRUE, CREATE_ITEM_1, PLAYER_ITEM_SWORD, 12, 260, 6, FALSE, FALSE },
[ITEM_FIRE_ROD] = { TRUE, 4, CREATE_ITEM_3, PLAYER_ITEM_CELL_OVERWRITE_SET, 260, 6, FALSE, FALSE },
[ITEM_OCARINA] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_NONE, 2273, 6, FALSE, FALSE },
[ITEM_ORB_GREEN] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_NULLED2, 0, 1, TRUE, TRUE },
[ITEM_ORB_BLUE] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_NULLED, 0, 1, TRUE, TRUE },
[ITEM_ORB_RED] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_CELL_OVERWRITE_SET2, 0, 1, TRUE, TRUE },
[ITEM_TRY_PICKUP_OBJECT] = { TRUE, 2, CREATE_ITEM_3, PLAYER_ITEM_HELD_OBJECT, 832, 4, FALSE, TRUE },
[ITEM_BOTTLE1] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOTTLE, 0, 6, TRUE, FALSE },
[ITEM_BOTTLE2] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOTTLE, 0, 6, TRUE, FALSE },
[ITEM_BOTTLE3] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOTTLE, 0, 6, TRUE, FALSE },
[ITEM_BOTTLE4] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOTTLE, 0, 6, TRUE, FALSE },
};

View File

@ -31,7 +31,7 @@ const ItemMetaData gItemMetaData[] = {
[ITEM_ORB_GREEN] = { 0x63u, 0u, 0u, 0u, 0u, 0u, 0u, 0u },
[ITEM_ORB_BLUE] = { 0x63u, 0u, 0u, 0u, 0u, 0u, 0u, 0u },
[ITEM_ORB_RED] = { 0x63u, 0u, 0u, 0u, 0u, 0u, 0u, 0u },
[ITEM_TRAP] = { 0x63u, 0u, 0u, 0u, 0u, 0u, 0u, 0u },
[ITEM_TRY_PICKUP_OBJECT] = { 0x63u, 0u, 0u, 0u, 0u, 0u, 0u, 0u },
[ITEM_BOTTLE1] = { MENU_SLOT_BOTTLE0, 0x3u, 0u, 0x1u, 0x20u, TEXT_ITEM_GET, 0x20u, 0x5u },
[ITEM_BOTTLE2] = { MENU_SLOT_BOTTLE1, 0x3u, 0u, 0x1u, 0x20u, TEXT_ITEM_GET, 0x20u, 0x5u },
[ITEM_BOTTLE3] = { MENU_SLOT_BOTTLE2, 0x3u, 0u, 0x1u, 0x20u, TEXT_ITEM_GET, 0x20u, 0x5u },

View File

@ -83,7 +83,7 @@ void CreateMagicSparkles(u32 baseX, u32 baseY, u32 layer) {
}
bool32 PortalReadyForMinish(void) {
if ((gPlayerState.flags & PL_MINISH) && !gPlayerState.field_0xaa && (gArea.portal_type != 0x6) &&
if ((gPlayerState.flags & PL_MINISH) && gPlayerState.attachedBeetleCount == 0 && (gArea.portal_type != 0x6) &&
(gPlayerState.heldObject == 0)) {
switch (gPlayerState.framestate) {
case PL_STATE_IDLE:

View File

@ -365,7 +365,7 @@ void MiscManager_TypeB(MiscManager* this) {
bool32 sub_080593CC(MiscManager* this) {
if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.swim_state != 0 && gPlayerEntity.animationState == 0 &&
(gPlayerState.playerInput.field_0x90 & PLAYER_INPUT_ANY_DIRECTION) == PLAYER_INPUT_UP) {
(gPlayerState.playerInput.heldInput & PLAYER_INPUT_ANY_DIRECTION) == PLAYER_INPUT_UP) {
return EntityWithinDistance(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6);
}
return FALSE;

View File

@ -75,7 +75,7 @@ void PauseMenu_Variant0(void) {
(u16)gRoomTransition.player_status.overworld_map_y);
gPauseMenuOptions.unk2[4] = ptr->_4;
gPauseMenuOptions.unk2[5] = sub_0801DB94();
if (IsItemEquipped(ITEM_LANTERN_ON) != 2) {
if (IsItemEquipped(ITEM_LANTERN_ON) != EQUIP_SLOT_NONE) {
r1 = 0x10;
} else {
r1 = 0xf;
@ -399,8 +399,8 @@ void PauseMenu_ItemMenu_Update(void) {
}
case B_BUTTON:
if (gPauseMenu.items[menuSlot] != 0) {
u32 t = !!(gInput.newKeys ^ 1);
ForceEquipItem(gPauseMenu.items[menuSlot], t);
u32 slot = !!(gInput.newKeys ^ 1);
ForceEquipItem(gPauseMenu.items[menuSlot], slot);
SoundReq(SFX_TEXTBOX_SELECT);
}
break;

View File

@ -20,7 +20,8 @@ void NPCUpdate(Entity* this) {
if (gNPCFunctions[this->id][1] != NULL)
gNPCFunctions[this->id][1](this);
if (this->health % 0x80) {
if (this->health % 0x80) { // If this NPC was created by DelayedEntityLoadManager_Main, we need to update the
// location in gNPCData.
NPCStruct* npc = gNPCData;
npc += (this->health - 1);
npc->x = this->x.HALF.HI - gRoomControls.origin_x;

View File

@ -418,12 +418,12 @@ void sub_0806D520(Entity* this, u32 param_2) {
}
void sub_0806D5D4(void) {
u32 itemSlot;
EquipSlot equipSlot;
InitBiggoronTimer();
itemSlot = IsItemEquipped(ITEM_SHIELD);
if (itemSlot != 2) {
gSave.stats.itemButtons[itemSlot] = ITEM_NONE;
equipSlot = IsItemEquipped(ITEM_SHIELD);
if (equipSlot != EQUIP_SLOT_NONE) {
gSave.stats.itemButtons[equipSlot] = ITEM_NONE;
}
SetInventoryValue(ITEM_SHIELD, 0);
}

View File

@ -144,7 +144,7 @@ void BladeBrothers_StartPlayerDemonstration(Entity* this, ScriptExecutionContext
if (BladeBrothers_EquippedItem) {}
if (p = this->timer, BladeBrothers_EquippedItem[p]) {
ForceEquipItem(BladeBrothers_EquippedItem[this->timer], 0);
ForceEquipItem(BladeBrothers_EquippedItem[this->timer], EQUIP_SLOT_A);
}
InitPlayerMacro(BladeBrothers_PlayerMacros[this->timer]);
}
@ -157,9 +157,10 @@ void sub_08068BB4(Entity* this) {
*(&this->field_0x68.HALF.HI + 1) = item;
}
// Restore previous equipped items.
void sub_08068BD0(Entity* this) {
ForceEquipItem(this->field_0x68.HALF.HI, 0);
ForceEquipItem(*(u8*)(&this->field_0x68.HALF.HI + 1), 1);
ForceEquipItem(this->field_0x68.HALF.HI, EQUIP_SLOT_A);
ForceEquipItem(*(u8*)(&this->field_0x68.HALF.HI + 1), EQUIP_SLOT_B);
}
static void sub_08068BEC(Entity* this, u32 unused) {
@ -337,18 +338,18 @@ void sub_08068E78(Entity* this) {
MessageNoOverlap(gUnk_08111714[this->timer], this);
}
void sub_08068E90(Entity* this) {
void BladeBrothers_LearnSkill(Entity* this) {
// Learn a skill.
PlayerState* s = &gPlayerState;
*(u16*)&s->skills = (1 << (gUnk_08111740[this->timer] - 1)) | *(u16*)&s->skills;
}
void sub_08068EB4(void) {
gPlayerState.field_0xab = 0;
void BladeBrothers_ResetLastSwordMove(void) {
gPlayerState.lastSwordMove = SWORD_MOVE_NONE;
}
void sub_08068EC4(Entity* this, ScriptExecutionContext* context) {
if (gUnk_08111740[this->timer] == gPlayerState.field_0xab) {
void BladeBrothers_CheckLastSwordMove(Entity* this, ScriptExecutionContext* context) {
if (gUnk_08111740[this->timer] == gPlayerState.lastSwordMove) {
context->wait = gUnk_0811172A[this->timer];
context->condition = 1;
} else {

View File

@ -69,7 +69,7 @@ void sub_08064570(CastleMaidEntity* this) {
if (LoadExtraSpriteData(super, data) == 0) {
return;
}
super->action += 1;
super->action++;
super->timer = 0;
tmp2 = sub_0805ACC0(super);
if (tmp2 == 0) {
@ -84,7 +84,7 @@ void sub_08064570(CastleMaidEntity* this) {
case 1:
sub_0807DD94(super, NULL);
if (super->interactType != 0) {
super->action += 1;
super->action++;
super->interactType = 0;
InitializeAnimation(super, sub_0806F5A4(GetFacingDirection(super, &gPlayerEntity)));
if (this->dialogFunc != NULL) {

View File

@ -7,7 +7,7 @@ void sub_0806BFD8(Entity* this);
void DrLeft(Entity* this) {
if (this->type == 0) {
if (this->action == 0) {
this->action += 1;
this->action++;
SetDefaultPriority(this, PRIO_MESSAGE);
sub_0807DD50(this);
}
@ -17,7 +17,7 @@ void DrLeft(Entity* this) {
sub_0806BFD8(this);
} else {
if (this->action == 0) {
this->action += 1;
this->action++;
this->frameIndex = 0;
SortEntityBelow(this, this);
}

View File

@ -104,7 +104,7 @@ void sub_08065AA4(Entity* this) {
void Epona_Fusion(Entity* this) {
if (this->action == 0) {
this->action += 1;
this->action++;
this->spriteSettings.draw = 1;
InitAnimationForceUpdate(this, 7);
} else {

View File

@ -121,7 +121,7 @@ void sub_08060158(Entity* this) {
if (tmp2 & 0x80) {
this->animationState = sub_0806F5B0(index);
}
tmp2 &= 0x7f;
tmp2 &= ~0x80;
this->frame = tmp1;
this->frameIndex = tmp2;
this->frameSpriteSettings = 1;

View File

@ -253,25 +253,25 @@ void sub_08064428(GuardWithSpearEntity* this) {
ShowNPCDialogue(super, pDialog);
}
void sub_08064470(Entity* this, ScriptExecutionContext* context) {
if (gPlayerState.field_0xab == 1) {
void GuardWithSpear_CheckSwordMoveSpin(Entity* this, ScriptExecutionContext* context) {
if (gPlayerState.lastSwordMove == SWORD_MOVE_SPIN) {
context->condition = 1;
} else {
context->condition = 0;
}
}
void sub_08064488(void) {
void GuardWithSpear_ResetLastSwordMoveIfNotInSwordState(void) {
if (gPlayerState.framestate != PL_STATE_SWORD) {
gPlayerState.field_0xab = 0;
gPlayerState.lastSwordMove = SWORD_MOVE_NONE;
}
}
void sub_080644A4(void) {
gPlayerState.field_0xab = 0;
void GuardWithSpear_ResetLastSwordMove(void) {
gPlayerState.lastSwordMove = SWORD_MOVE_NONE;
}
void sub_080644B4(Entity* this, ScriptExecutionContext* context) {
void CheckLastSwordMove(Entity* this, ScriptExecutionContext* context) {
context->condition = this->animationState == context->intVariable;
}

View File

@ -100,7 +100,7 @@ void sub_0806C4F8(Entity* this) {
void Mama_Fusion(Entity* this) {
if (this->action == 0) {
if (sub_0806C454(this) != 0) {
this->action += 1;
this->action++;
this->spriteSettings.draw = 1;
this->y.HALF.HI -= 4;
InitializeAnimation(this, 2);

View File

@ -180,8 +180,8 @@ void NPC4E_SaveEquippedItems(Entity* this) {
}
void NPC4E_RestoreEquippedItems(Entity* this) {
ForceEquipItem(sub_0806DBF4(this->field_0x68.HALF.LO), 0);
ForceEquipItem(sub_0806DBF4(this->field_0x68.HALF.HI), 1);
ForceEquipItem(sub_0806DBF4(this->field_0x68.HALF.LO), EQUIP_SLOT_A);
ForceEquipItem(sub_0806DBF4(this->field_0x68.HALF.HI), EQUIP_SLOT_B);
}
void sub_0806DC7C(void) {

View File

@ -17,7 +17,7 @@ void NPC58(Entity* this) {
if (LoadExtraSpriteData(this, gUnk_081146D0) == 0) {
return;
}
this->action += 1;
this->action++;
this->spriteSettings.draw = 2;
this->spriteRendering.b3 = 0;
this->spritePriority.b0 = 0;

View File

@ -29,7 +29,7 @@ void sub_08063A80(Entity* this) {
}
void sub_08063A98(Entity* this) {
this->action += 1;
this->action++;
this->spriteSettings.draw = 1;
InitAnimationForceUpdate(this, 4);
sub_08078778(this);
@ -157,7 +157,7 @@ void sub_08063CAC(Entity* this) {
void Pina_Fusion(Entity* this) {
if (this->action == 0) {
this->action += 1;
this->action++;
this->spriteSettings.draw = 1;
this->y.HALF.HI -= 4;
InitAnimationForceUpdate(this, 2);

View File

@ -320,7 +320,7 @@ void sub_0806AEE4(Entity* this) {
if (tmp2 & 0x80) {
this->animationState = sub_0806F5B0(index);
}
tmp2 &= 0x7f;
tmp2 &= ~0x80;
this->frame = tmp1;
this->frameIndex = tmp2;
this->frameSpriteSettings = 1;

View File

@ -195,7 +195,7 @@ void (*const gObjectFunctions[])(Entity*) = {
[PINWHEEL] = Pinwheel,
[OBJECT_BF] = ObjectBF,
[ENEMY_ITEM] = EnemyItem,
[OBJECT_C1] = LinkAnimation,
[LINK_ANIMATION] = LinkAnimation,
};
void ObjectInit(Entity*);

View File

@ -71,7 +71,7 @@ void sub_0808BBE0(BarrelSpiderwebEntity* this) {
ptr = &gUnk_0812144C[diff * 2];
SetAffineInfo(super, ptr[0], ptr[1], 0);
} else {
super->contactFlags &= 0x7f;
super->contactFlags &= ~0x80;
}
}

View File

@ -97,7 +97,7 @@ void BigIceBlock_Action2(BigIceBlockEntity* this) {
}
super->action = 3;
super->timer = 60;
super->flags &= 0x7f;
super->flags &= ~0x80;
}
void sub_08099880(BigIceBlockEntity* this) {

View File

@ -238,7 +238,7 @@ void Bird_Type8(Entity* this) {
PutAwayItems();
gPlayerState.swim_state = 0;
gPlayerState.jump_status = 0;
gPlayerEntity.flags &= 0x7f;
gPlayerEntity.flags &= ~0x80;
gPlayerEntity.spriteSettings.draw = 0;
gPriorityHandler.sys_priority = 6;
gPauseMenuOptions.disabled = 1;

View File

@ -213,7 +213,7 @@ void Book_Action5(Entity* this) {
u32 sub_0809B688(Entity* this) {
u32 ret = EntityInRectRadius(this, &gPlayerEntity, 6, 12);
if (ret == 1 && gPlayerState.field_0xd != 16) {
if (ret == 1 && gPlayerState.direction != 16) {
ret = 0;
}

View File

@ -140,7 +140,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
if (super->parent->action == 2) {
switch (super->parent->subAction) {
case 1:
if ((gPlayerState.field_0xd & 0x80) != 0) {
if ((gPlayerState.direction & 0x80) != 0) {
InitializeAnimation(super, 4);
} else {
GetNextFrame(super);
@ -163,7 +163,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
} else {
gPlayerState.mobility |= 0x80;
gPlayerState.heldObject = 5;
if ((gPlayerState.field_0xd & 0x80) != 0) {
if ((gPlayerState.direction & 0x80) != 0) {
InitializeAnimation(super, (super->type >> 1) + 3);
} else {
GetNextFrame(super);
@ -181,7 +181,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
RestorePrevTileEntity(0xdc, super->collisionLayer);
sub_08096A78(this);
}
if ((gPlayerState.playerInput.field_0x92 & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) {
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) {
return;
}
if (gUnk_0200AF00.unk_2f != 3) {
@ -297,7 +297,7 @@ void CrenelBeanSprout_Action6SubAction1(CrenelBeanSproutEntity* this) {
sub_0807B7D8(gUnk_081231AE[super->type2], COORD_TO_TILE(super), super->collisionLayer);
super->type2++;
if (super->type2 == super->subtimer) {
gPlayerState.keepFacing &= 0x7f;
gPlayerState.keepFacing &= ~0x80;
super->subAction++;
super->timer = 60;
} else {

View File

@ -9,8 +9,8 @@
#include "main.h"
#include "menu.h"
#include "object.h"
#include "player.h"
extern int sub_0807A094(int);
extern u32 sub_080041EC(int, int);
static bool32 sub_0808E950(void);
@ -104,7 +104,7 @@ void sub_0808E818(Entity* this) {
this->field_0x68.HWORD = CheckGlobalFlag(EZERO_1ST) == 0 ? 0x400 : 0x100;
this->field_0x70.BYTES.byte0 = 4;
this->animationState = 2;
var1 = gUnk_08133368[sub_0807A094(1) - 22] & 0xFFFFFF;
var1 = gUnk_08133368[GetPlayerPalette(TRUE) - 22] & 0xFFFFFF;
LoadPalettes(&gGlobalGfxAndPalettes[var1], 31, 1);
}

View File

@ -319,7 +319,7 @@ void FrozenOctorok_Action1SubAction6(FrozenOctorokEntity* this) {
super->subAction = 7;
}
if ((gRoomTransition.frameCount & 0xf) == 0) {
SoundReq(SFX_163);
SoundReq(SFX_TOGGLE_DIVING);
}
}

View File

@ -179,7 +179,7 @@ void sub_0808692C(Entity* this) {
static u8 sub_08086954(Entity* this) {
if (sub_0800445C(this)) {
if (GetAnimationStateInRectRadius(this, 6, 20) >= 0 && gPlayerEntity.animationState == 0 &&
(u16)gPlayerState.playerInput.field_0x90 == PLAYER_INPUT_UP && gPlayerState.jump_status == 0) {
(u16)gPlayerState.playerInput.heldInput == PLAYER_INPUT_UP && gPlayerState.jump_status == 0) {
this->timer--;
}
} else {

View File

@ -92,7 +92,7 @@ void HouseDoorInterior_Action1(HouseDoorInteriorEntity* this) {
if (sub_0800445C(super) && this->unk7d == 0) {
ptr = gUnk_081227CC + super->type2;
if (GetAnimationStateInRectRadius(super, ptr->x, ptr->y) >= 0 &&
ptr->animationState == gPlayerEntity.animationState && gPlayerState.playerInput.field_0x90 & ptr->unk2) {
ptr->animationState == gPlayerEntity.animationState && gPlayerState.playerInput.heldInput & ptr->unk2) {
--super->timer;
}
} else {

View File

@ -99,7 +99,7 @@ void ItemForSale_Action1(ItemForSaleEntity* this) {
super->interactType = 0;
super->subAction = 1;
sub_08078B48();
ResetPlayerItem();
ResetActiveItems();
gPlayerState.heldObject = 4;
gNewPlayerEntity.unk_74 = super;
gUnk_0200AF00.unk_2f = 2;
@ -119,9 +119,9 @@ void ItemForSale_Action2(ItemForSaleEntity* this) {
} else {
ptr = sub_080784E4();
if (((*(int*)(ptr + 8) == 0) ||
((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.unk_2f = 7, (gPlayerState.playerInput.field_0x92 &
((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.unk_2f = 7, (gPlayerState.playerInput.newInput &
(PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0)))) &&
((gPlayerState.playerInput.field_0x92 & (PLAYER_INPUT_80 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0)) {
((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0)) {
sub_080819B4(this);
}
}

View File

@ -28,7 +28,7 @@ void LampParticle_Init(Entity* this) {
}
void LampParticle_Action1(Entity* this) {
if (1 < IsItemEquipped(ITEM_LANTERN_ON)) {
if (IsItemEquipped(ITEM_LANTERN_ON) >= EQUIP_SLOT_NONE) {
DeleteThisEntity();
}
GetNextFrame(this);

Some files were not shown because too many files have changed in this diff Show More