Skip to content

Commit

Permalink
gustjar player fields
Browse files Browse the repository at this point in the history
  • Loading branch information
hytopoulos committed Jan 1, 2024
1 parent 5324928 commit e8f53b0
Show file tree
Hide file tree
Showing 29 changed files with 133 additions and 117 deletions.
2 changes: 1 addition & 1 deletion asm/src/player.s
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ _080085E6:
ldr r3, _080088A8 @ =gPlayerState
ldrb r2, [r3, #0x1c]
orrs r2, r2
bne _0800861A // field_0x1c != 0
bne _0800861A // gustJarState != 0
ldrb r2, [r3, #5]
orrs r2, r2
bne _0800861A // heldObject != 0
Expand Down
26 changes: 22 additions & 4 deletions include/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ typedef struct {
/*0x6d*/ u8 unk_6d;
/*0x6e*/ u8 unk_6e;
/*0x6f*/ u8 unk_6f;
/*0x70*/ Entity* unk_70;
/*0x74*/ Entity* unk_74;
/*0x70*/ Entity* pulledJarEntity;
/*0x74*/ Entity* carriedEntity;
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u16 unk_7a;
Expand Down Expand Up @@ -298,6 +298,24 @@ typedef enum {
SWORD_MOVE_LOW_BEAM,
} SwordMove;

typedef enum {
PL_JAR_NONE = 0x0,
PL_JAR_SUCK = 0x1,
PL_JAR_2 = 0x2,
PL_JAR_3 = 0x3,
PL_JAR_BLAST_INIT = 0x4,
PL_JAR_BLAST_UPDATE = 0x5,
PL_JAR_BLAST_DONE = 0x6,
PL_JAR_ENT_ATTACHED = 0x7,
} GustJarState;

typedef enum {
JAR_CHARGE_NONE = 0,
JAR_CHARGE_SMALL = 1,
JAR_CHARGE_MID = 2,
JAR_CHARGE_BIG = 3,
} GustJarCharge;

typedef enum {
ANIM_DEFAULT = 0x100,
ANIM_WALK = 0x104,
Expand Down Expand Up @@ -492,8 +510,8 @@ typedef struct {
/*0x18*/ u16 startPosY;
/*0x1a*/ u8 mobility;
/*0x1b*/ u8 sword_state;
/*0x1c*/ u8 field_0x1c;
/*0x1d*/ u8 gustJarSpeed;
/*0x1c*/ u8 gustJarState;
/*0x1d*/ u8 gustJarCharge;
/*0x1e*/ u8 dash_state;
/*0x1f*/ u8 field_0x1f[2];
/*0x21*/ u8 bow_state;
Expand Down
2 changes: 1 addition & 1 deletion src/beanstalkSubtask.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ u32 UpdatePlayerCollision(void) {
((gPlayerState.sword_state & 0x10) != 0)) ||
((sub_080806BC(gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x,
gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y, index, 5) == 0 &&
(((gPlayerState.heldObject != 0 || ((gPlayerState.field_0x1c & 0xf) != 0)) ||
(((gPlayerState.heldObject != 0 || ((gPlayerState.gustJarState & 0xf) != 0)) ||
(sub_0807BD14(&gPlayerEntity.base, index) == 0)))))) {
return 3;
}
Expand Down
2 changes: 1 addition & 1 deletion src/collision.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ CollisionResult sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSetting
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;
tgt->gustJarTolerance = tgt->gustJarTolerance - gPlayerState.gustJarCharge;
if ((s8)tgt->gustJarTolerance <= 0) {
tgt->gustJarTolerance = 0;
tgt->subAction = 2;
Expand Down
4 changes: 2 additions & 2 deletions src/enemy/bombPeahat.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ void sub_0802A8F4(BombPeahatEntity* this) {
}

void sub_0802A8FC(BombPeahatEntity* this) {
if ((gPlayerState.field_0x1c & 0xf) == 0) {
super->health = gPlayerState.field_0x1c & 0xf;
if ((gPlayerState.gustJarState & 0xf) == 0) {
super->health = gPlayerState.gustJarState & 0xf;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/enemy/dust.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void sub_08044550(DustEntity* this) {
u8 uVar1;
const s8* ptr;

if ((gPlayerState.field_0x1c & 0xf) == 1) {
if ((gPlayerState.gustJarState & 0xf) == 1) {
if (super->speed < 0x100) {
super->speed += 0x10;
}
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/flyingPot.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void FlyingPot_SubAction2(FlyingPotEntity* this) {
}

void FlyingPot_SubAction3(FlyingPotEntity* this) {
if (!(gPlayerState.field_0x1c & 0xF)) {
if (!(gPlayerState.gustJarState & 0xF)) {
sub_08037408(this);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/flyingSkull.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void sub_08039CE0(FlyingSkullEntity* this) {
}

void sub_08039D4C(FlyingSkullEntity* this) {
if ((gPlayerState.field_0x1c & 0xf) == 0) {
if ((gPlayerState.gustJarState & 0xf) == 0) {
sub_0803A0E0(this);
}
}
Expand Down
60 changes: 30 additions & 30 deletions src/item/itemGustJar.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ void sub_08076DF4(ItemBehavior* this, u32 index) {
this->playerAnimationState = gPlayerEntity.base.animationState;
this->priority |= 0x80;
this->priority++;
gPlayerState.gustJarSpeed = 1;
gPlayerEntity.unk_74 = NULL;
gPlayerState.field_0x1c = 1;
gPlayerState.gustJarCharge = JAR_CHARGE_SMALL;
gPlayerEntity.carriedEntity = NULL;
gPlayerState.gustJarState = PL_JAR_SUCK;
sub_08077BB8(this);
} else {
DeleteItemBehavior(this, index);
Expand All @@ -30,7 +30,7 @@ void sub_08076DF4(ItemBehavior* this, u32 index) {
void sub_08076E60(ItemBehavior* this, u32 index) {
Entity* playerItem;

if ((gPlayerState.field_0x1c & 0xf) == 0) {
if ((gPlayerState.gustJarState & 0xf) == 0) {
DeleteItemBehavior(this, index);
}
if ((this->playerFrame & 0x80) != 0) {
Expand All @@ -47,19 +47,19 @@ void sub_08076E60(ItemBehavior* this, u32 index) {
}

void sub_08076EC8(ItemBehavior* this, u32 index) {
if ((gPlayerState.field_0x1c & 0xf) == 0) {
if ((gPlayerState.gustJarState & 0xf) == PL_JAR_NONE) {
DeleteItemBehavior(this, index);
return;
}

if (IsItemActive(this)) {
u32 animIndex;
if (this->timer > 0xef) {
gPlayerState.gustJarSpeed = 3;
gPlayerState.gustJarCharge = JAR_CHARGE_BIG;
} else if (++this->timer > 0x77) {
gPlayerState.gustJarSpeed = 2;
gPlayerState.gustJarCharge = JAR_CHARGE_MID;
} else {
gPlayerState.gustJarSpeed = 1;
gPlayerState.gustJarCharge = JAR_CHARGE_SMALL;
}

if (gPlayerEntity.base.subAction == 0x1b) {
Expand Down Expand Up @@ -87,16 +87,16 @@ void sub_08076EC8(ItemBehavior* this, u32 index) {
void sub_08076F64(ItemBehavior* this, u32 index) {
Entity* item;
PlayerEntity* player;
switch (gPlayerState.field_0x1c & 0xf) {
case 5:
switch (gPlayerState.gustJarState & 0xf) {
case PL_JAR_BLAST_UPDATE:
if (this->playerFrame & 0x80) {
if (this->subtimer) {
this->subtimer = 0;
this->timer = 0;
gPlayerState.gustJarSpeed = 1;
gPlayerState.gustJarCharge = JAR_CHARGE_SMALL;
player = &gPlayerEntity;
player->unk_74 = NULL;
gPlayerState.field_0x1c = 1;
player->carriedEntity = NULL;
gPlayerState.gustJarState = PL_JAR_SUCK;
gPlayerState.field_0xa &= ~(8 >> index);
this->stateID = 2;
SetItemAnim(this, ANIM_GUSTJAR_SUCK);
Expand All @@ -106,7 +106,7 @@ void sub_08076F64(ItemBehavior* this, u32 index) {
}
return;
} else {
gPlayerState.field_0x1c = 6;
gPlayerState.gustJarState = PL_JAR_BLAST_DONE;
SetItemAnim(this, ANIM_GUSTJAR_END);
return;
}
Expand All @@ -126,18 +126,18 @@ void sub_08076F64(ItemBehavior* this, u32 index) {
return;
}
return;
case 3:
gPlayerState.field_0x1c = 4;
case 4:
case PL_JAR_3:
gPlayerState.gustJarState = PL_JAR_BLAST_INIT;
case PL_JAR_BLAST_INIT:
if (IsItemActive(this)) {
this->subtimer = 1;
}

UpdateItemAnim(this);
if (this->playerFrame & 1) {
gPlayerState.field_0x1c = 5;
gPlayerEntity.unk_70 = NULL;
if (gPlayerState.gustJarSpeed) {
gPlayerState.gustJarState = PL_JAR_BLAST_UPDATE;
gPlayerEntity.pulledJarEntity = NULL;
if (gPlayerState.gustJarCharge) {
CreatePlayerItem(PLAYER_ITEM_GUST_BIG, 0, 0, 0);
}
}
Expand All @@ -149,27 +149,27 @@ void sub_08076F64(ItemBehavior* this, u32 index) {
gPlayerEntity.base.speed = 0x80;
UpdatePlayerMovement();
return;
case 6:
case PL_JAR_BLAST_DONE:
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) == 0)
return;
break;
case 7:
case PL_JAR_ENT_ATTACHED:
SetItemAnim(this, ANIM_GUSTJAR_BLOW);
gPlayerState.field_0x1c = 3;
gPlayerState.gustJarSpeed = 0;
gPlayerState.gustJarState = PL_JAR_3;
gPlayerState.gustJarCharge = JAR_CHARGE_NONE;
return;
case 1:
case 2:
case PL_JAR_SUCK:
case PL_JAR_2:
default:
gPlayerState.field_0x1c = 3;
gPlayerState.gustJarState = PL_JAR_3;
SetItemAnim(this, ANIM_GUSTJAR_BLOW);
return;
case 0:
case PL_JAR_NONE:
break;
}
gPlayerState.field_0x1c = 0;
gPlayerEntity.unk_70 = NULL;
gPlayerState.gustJarState = PL_JAR_NONE;
gPlayerEntity.pulledJarEntity = NULL;
DeleteItemBehavior(this, index);
}

Expand Down
2 changes: 1 addition & 1 deletion src/item/itemPegasusBoots.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void sub_080768F8(ItemBehavior* this, u32 index) {
u32 bVar1;
u32 bVar2;

bVar1 = gPlayerState.field_0x1c | gPlayerState.attack_status | gPlayerState.heldObject | gPlayerState.jump_status;
bVar1 = gPlayerState.gustJarState | gPlayerState.attack_status | gPlayerState.heldObject | gPlayerState.jump_status;
bVar2 = (gPlayerState.flags & PL_IN_MINECART);
bVar1 |= bVar2;
if (bVar1 == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/item/itemRocsCape.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void ItemRocsCape(ItemBehavior* this, u32 index) {
}
} else {
if (((u8)(gPlayerState.sword_state | gPlayerState.field_0xa | gPlayerState.attack_status |
gPlayerState.heldObject | gPlayerState.field_0x1c | gPlayerState.moleMittsState) == 0) &&
gPlayerState.heldObject | gPlayerState.gustJarState | gPlayerState.moleMittsState) == 0) &&
((((gPlayerState.floor_type != SURFACE_DOOR && gPlayerState.floor_type != SURFACE_DOOR_13 &&
gPlayerState.floor_type != SURFACE_PIT) ||
(gPlayerEntity.base.z.WORD != 0)) ||
Expand Down
2 changes: 1 addition & 1 deletion src/item/itemTryPickupObject.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) {
PlayerCancelHoldItem(this, param_3);
} else {
PlayerEntity* playerEnt = &gPlayerEntity;
playerEnt->unk_74 = param_2;
playerEnt->carriedEntity = param_2;
playerEnt->base.subtimer = 0;
param_2->child = this->field_0x18;
param_2->carryFlags = playerEnt->base.carryFlags;
Expand Down
4 changes: 2 additions & 2 deletions src/object/bush.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void Bush_Init(BushEntity* this) {
}

void Bush_Action1(BushEntity* this) {
if (((gPlayerState.field_0x1c & 0xf) != 1) || ((super->contactFlags & 0x7f) != 0x13)) {
if (((gPlayerState.gustJarState & 0xf) != 1) || ((super->contactFlags & 0x7f) != 0x13)) {
RestorePrevTileEntity(COORD_TO_TILE(super), super->collisionLayer);
DeleteThisEntity();
}
Expand Down Expand Up @@ -108,7 +108,7 @@ void Bush_Action2SubAction2(BushEntity* this) {
super->spriteOffsetX = 0;
sub_0807B9B8(this->unk_70, COORD_TO_TILE(super), super->collisionLayer);
}
if (((gPlayerState.field_0x1c & 0xf) != 1) || ((super->contactFlags & 0x7f) != 0x13)) {
if (((gPlayerState.gustJarState & 0xf) != 1) || ((super->contactFlags & 0x7f) != 0x13)) {
Bush_Action2SubAction5(this);
}
if (sub_0806F3E4(super) && ((super->gustJarFlags & 0xf) == 1)) {
Expand Down
2 changes: 1 addition & 1 deletion src/object/chuchuBossStartParticle.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void ChuchuBossStartParticle_Type9(ChuchuBossStartParticleEntity* this) {
DeleteThisEntity();
}

if (gPlayerState.field_0x1c != 1) {
if (gPlayerState.gustJarState != 1) {
DeleteThisEntity();
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/object/gustJarParticle.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void GustJarParticle_Action1(Entity* this) {

if (sub_0806F3E4(this)) {
DeleteThisEntity();
} else if ((gPlayerState.field_0x1c & 0xf) != 1) {
} else if ((gPlayerState.gustJarState & 0xf) != 1) {
DeleteThisEntity();
}
}
6 changes: 3 additions & 3 deletions src/object/itemForSale.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void ItemForSale_Action1(ItemForSaleEntity* this) {
PausePlayer();
ResetActiveItems();
gPlayerState.heldObject = 4;
gPlayerEntity.unk_74 = super;
gPlayerEntity.carriedEntity = super;
gUnk_0200AF00.rActionPlayerState = R_ACTION_DROP;
MessageClose();
}
Expand All @@ -104,7 +104,7 @@ void ItemForSale_Action2(ItemForSaleEntity* this) {

gUnk_0200AF00.rActionPlayerState = R_ACTION_DROP;
super->spriteSettings.draw = gPlayerEntity.base.spriteSettings.draw;
if ((gPlayerState.heldObject == 0) || (super != gPlayerEntity.unk_74)) {
if ((gPlayerState.heldObject == 0) || (super != gPlayerEntity.carriedEntity)) {
sub_080819B4(this);
} else {
ptr = sub_080784E4();
Expand All @@ -129,7 +129,7 @@ void sub_080819B4(ItemForSaleEntity* this) {
DeleteThisEntity();
}
gPlayerState.heldObject = 0;
gPlayerEntity.unk_74 = 0;
gPlayerEntity.carriedEntity = 0;
ptr = &gUnk_0200AF00;
gRoomVars.shopItemType = 0;
ptr->rActionInteractObject = R_ACTION_NONE;
Expand Down
6 changes: 3 additions & 3 deletions src/object/lilypadLarge.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ void LilypadLarge_Action1(LilypadLargeEntity* this) {
this->unk_70 = 0;
this->unk_6c = 0;
}
if (gPlayerState.field_0x1c == 3) {
tmp = gUnk_08120620[gPlayerState.gustJarSpeed - 1];
if (gPlayerState.gustJarState == PL_JAR_3) {
tmp = gUnk_08120620[gPlayerState.gustJarCharge - 1];
switch (gPlayerEntity.base.animationState & 6) {
case 4:
this->unk_70 -= tmp;
Expand Down Expand Up @@ -154,7 +154,7 @@ void LilypadLarge_Action1(LilypadLargeEntity* this) {
uVar4 = gPlayerEntity.base.y.HALF.HI + gUnk_08126EE4[gPlayerEntity.base.animationState | 1];
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, sVar10, uVar4);

switch (gPlayerState.gustJarSpeed) {
switch (gPlayerState.gustJarCharge) {
case 3:
tmp = 0x400;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/object/minecart.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void Minecart_Action1(MinecartEntity* this) {
SoundReq(SFX_13B);
} else {
if (sub_0800445C(super) != 0) {
if (!((gPlayerState.flags & (PL_MINISH | PL_ROLLING)) || gPlayerState.field_0x1c ||
if (!((gPlayerState.flags & (PL_MINISH | PL_ROLLING)) || gPlayerState.gustJarState ||
gPlayerState.heldObject || gPlayerState.jump_status)) {
super->timer++;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/object/objectA8.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ void ObjectA8_Action2Subaction0(ObjectA8Entity* this) {
}

void ObjectA8_Action2Subaction1(ObjectA8Entity* this) {
if ((gPlayerState.field_0x1c & 0xf) != 1 || (super->contactFlags & 0x7f) != 0x13) {
if ((gPlayerState.gustJarState & 0xf) != 1 || (super->contactFlags & 0x7f) != 0x13) {
super->action = 3;
} else {
sub_0806F4E8(super);
}
}

void ObjectA8_Action2Subaction2(ObjectA8Entity* this) {
if ((gPlayerState.field_0x1c & 0xf) != 1 || (super->contactFlags & 0x7f) != 0x13) {
if ((gPlayerState.gustJarState & 0xf) != 1 || (super->contactFlags & 0x7f) != 0x13) {
super->action = 3;
} else {
if (sub_0806F3E4(super)) {
Expand Down
Loading

0 comments on commit e8f53b0

Please sign in to comment.