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 0a6687f
Show file tree
Hide file tree
Showing 34 changed files with 145 additions and 128 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
4 changes: 2 additions & 2 deletions src/enemy/enemy64.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ void Enemy64_Action3(Enemy64Entity* this) {

void Enemy64_Action3_SubAction0(Enemy64Entity* this) {
u32 tmp = CalcOffsetAngle(gRoomControls.origin_x + 0xa8 - super->x.HALF.HI,
gRoomControls.origin_y + 0x80 - super->y.HALF.HI);
gRoomControls.origin_y + 0x80 - super->y.HALF.HI);
if (tmp != super->direction) {
if (((tmp - super->direction) & 0x80) != 0) {
super->direction--;
Expand Down Expand Up @@ -491,7 +491,7 @@ void sub_080499F0(Enemy64Entity* this) {
if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24) &&
((this->unk_7c & 2) == 0)) {
tmp = CalcOffsetAngle((s32)gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
(s32)gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
(s32)gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
gPlayerEntity.base.x.WORD = super->x.WORD + gSineTable[tmp] * 0x2400;
gPlayerEntity.base.y.WORD = super->y.WORD + gSineTable[tmp + 0x40] * -0x2400;
}
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
4 changes: 2 additions & 2 deletions src/enemy/gyorgMale.c
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ void sub_08047EA4(GyorgMaleEntity* this, u32 unk1) {
if (this->unk_7c & 1) {
tmp2 = sub_08047F68(this) << 8;
dir = CalcOffsetAngle(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
tmp = dir - (tmp / 256);
tmp &= 0xFF;
gPlayerEntity.base.x.WORD += (gSineTable[tmp] - gSineTable[dir]) * tmp2;
Expand Down Expand Up @@ -1150,7 +1150,7 @@ void sub_08048004(GyorgMaleEntity* this) {
if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24)) {
if (!(this->unk_7c & 2)) {
u32 tmp = CalcOffsetAngle(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
gPlayerEntity.base.x.WORD = super->x.WORD + (gSineTable[tmp] * 9216);
gPlayerEntity.base.y.WORD = super->y.WORD - (gSineTable[tmp + 0x40] * 9216);
}
Expand Down
8 changes: 4 additions & 4 deletions src/enemy/octorokBoss.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ void OctorokBoss_Hit_SubAction1(OctorokBossEntity* this) {
this->heap->field_0x2 = 1;
#if defined(JP) || defined(DEMO_JP) || defined(EU)
super->direction = ((s32)CalcOffsetAngle((((gRoomControls.origin_x + 0x108) << 0x10) - super->x.WORD),
(((gRoomControls.origin_y + 0x88) << 0x10) - super->y.WORD))) >>
(((gRoomControls.origin_y + 0x88) << 0x10) - super->y.WORD))) >>
3;
#else
super->direction = ((s32)CalcOffsetAngle(gRoomControls.origin_x + 0x108 - super->x.HALF.HI,
gRoomControls.origin_y + 0x88 - super->y.HALF.HI)) >>
gRoomControls.origin_y + 0x88 - super->y.HALF.HI)) >>
3;
#endif
super->speed = 0x100;
Expand Down Expand Up @@ -913,7 +913,7 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) {
this->timer = 2;
this->heap->targetAngle =
CalcOffsetAngle((gRoomControls.origin_x + 0x108) * 0x10000 - super->x.WORD,
(gRoomControls.origin_y + 0x88) * 0x10000 - super->y.WORD);
(gRoomControls.origin_y + 0x88) * 0x10000 - super->y.WORD);
this->heap->targetAngle = (u8) - (this->heap->targetAngle + 0x80);
SoundReq(SFX_ED);
}
Expand Down Expand Up @@ -1179,7 +1179,7 @@ void sub_08036AF0(OctorokBossEntity* this, s32 radius, s32 angleSpeed) {
} else {
heap->tailObjects[index - 1]->angle.HALF.HI =
CalcOffsetAngle(heap->tailObjects[index - 1]->base.x.WORD - heap->tailObjects[index]->base.x.WORD,
heap->tailObjects[index - 1]->base.y.WORD - heap->tailObjects[index]->base.y.WORD);
heap->tailObjects[index - 1]->base.y.WORD - heap->tailObjects[index]->base.y.WORD);
tmp = FixedMul(gSineTable[heap->tailObjects[index - 1]->angle.HALF.HI], radius << 4);
tmp = FixedDiv(tmp, 0x100);
heap->tailObjects[index - 1]->base.x.WORD = heap->tailObjects[index]->base.x.WORD + ((s32)tmp << 8);
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
5 changes: 3 additions & 2 deletions src/object/evilSpirit.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ void EvilSpirit_Action1(EvilSpiritEntity* this) {
CalcOffsetAngle(super->parent->x.WORD - super->x.WORD, super->parent->y.WORD - super->y.WORD) ^ 0x80;
} else {
super->speed = 0x600;
dir = CalcOffsetAngle(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) ^
0x80;
dir =
CalcOffsetAngle(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) ^
0x80;
if (dir != super->direction) {
if ((u8)(dir - super->direction) > 0x80) {
super->direction += 3;
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();
}
}
Loading

0 comments on commit 0a6687f

Please sign in to comment.