Use more PlayerFlags constants

This commit is contained in:
Catobat 2023-04-30 18:49:08 +02:00
parent 06c0f111e7
commit b4995417d3
8 changed files with 33 additions and 32 deletions

View File

@ -204,7 +204,7 @@ u32 UpdatePlayerCollision(void) {
ptr1 = &gUnk_080B4490[index * 2]; ptr1 = &gUnk_080B4490[index * 2];
if (sub_080B1B44(COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr1[0], -ptr1[1]), gPlayerEntity.collisionLayer) == if (sub_080B1B44(COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr1[0], -ptr1[1]), gPlayerEntity.collisionLayer) ==
0xff) { 0xff) {
if ((((gPlayerState.flags & 0x10002) != 0) || ((gPlayerState.sword_state & 0x10) != 0)) || if ((((gPlayerState.flags & (PL_FLAGS10000 | PL_FLAGS2)) != 0) || ((gPlayerState.sword_state & 0x10) != 0)) ||
((sub_080806BC(gPlayerEntity.x.HALF.HI - gRoomControls.origin_x, ((sub_080806BC(gPlayerEntity.x.HALF.HI - gRoomControls.origin_x,
gPlayerEntity.y.HALF.HI - gRoomControls.origin_y, index, 5) == 0 && gPlayerEntity.y.HALF.HI - gRoomControls.origin_y, index, 5) == 0 &&
(((gPlayerState.heldObject != 0 || ((gPlayerState.field_0x1c & 0xf) != 0)) || (((gPlayerState.heldObject != 0 || ((gPlayerState.field_0x1c & 0xf) != 0)) ||
@ -234,19 +234,19 @@ u32 UpdatePlayerCollision(void) {
return 0; return 0;
} }
layer->mapData[position] = 0x4001 + (gPlayerEntity.animationState >> 1); layer->mapData[position] = 0x4001 + (gPlayerEntity.animationState >> 1);
if ((gPlayerState.flags & 0x80) != 0) { if ((gPlayerState.flags & PL_MINISH) != 0) {
gPlayerState.pushedObject = 0xc0; gPlayerState.pushedObject = 0xc0;
} else { } else {
gPlayerState.pushedObject = 0xa0; gPlayerState.pushedObject = 0xa0;
} }
gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= 1; gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
return 1; return 1;
case 0x28: case 0x28:
if ((gPlayerState.flags & 0x80) != 0) { if ((gPlayerState.flags & PL_MINISH) != 0) {
return 0; return 0;
} }
gPlayerEntity.action = gPlayerEntity.action; gPlayerEntity.action = gPlayerEntity.action;
@ -286,7 +286,7 @@ u32 UpdatePlayerCollision(void) {
layer->mapData[position] = 0x401c + (gPlayerEntity.animationState >> 1); layer->mapData[position] = 0x401c + (gPlayerEntity.animationState >> 1);
gPlayerState.pushedObject = 0xa0; gPlayerState.pushedObject = 0xa0;
gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= 1; gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
@ -304,7 +304,7 @@ u32 UpdatePlayerCollision(void) {
case 0x3a: case 0x3a:
case 0x5b: case 0x5b:
case 0x4051: case 0x4051:
if ((gPlayerState.flags & 0x80) != 0) { if ((gPlayerState.flags & PL_MINISH) != 0) {
return 0; return 0;
} }
if (gPlayerEntity.animationState != 0) { if (gPlayerEntity.animationState != 0) {
@ -321,7 +321,7 @@ u32 UpdatePlayerCollision(void) {
if ((animationState1 & 0xff) != 0) { if ((animationState1 & 0xff) != 0) {
return 0; return 0;
} }
if ((gPlayerState.flags & 0x4080) != 0) { if ((gPlayerState.flags & (PL_DRUGGED | PL_MINISH)) != 0) {
return 0; return 0;
} }
gUnk_0200AF00.rActionInteractTile = R_ACTION_OPEN; gUnk_0200AF00.rActionInteractTile = R_ACTION_OPEN;
@ -344,7 +344,7 @@ u32 UpdatePlayerCollision(void) {
return 2; return 2;
case 0x3d: case 0x3d:
case 0x4040 ... 0x4048: case 0x4040 ... 0x4048:
if ((gPlayerState.flags & 0x4000) != 0) { if ((gPlayerState.flags & PL_DRUGGED) != 0) {
return 0; return 0;
} }
if (sub_08079778() == 0) { if (sub_08079778() == 0) {
@ -365,7 +365,7 @@ u32 UpdatePlayerCollision(void) {
return 0; return 0;
} }
gPlayerState.jump_status = 0x81; gPlayerState.jump_status = 0x81;
gPlayerState.flags |= 0x20; gPlayerState.flags |= PL_USE_PORTAL;
gPlayerState.queued_action = PLAYER_USEPORTAL; gPlayerState.queued_action = PLAYER_USEPORTAL;
gPlayerEntity.zVelocity = 0x20000; gPlayerEntity.zVelocity = 0x20000;
COLLISION_OFF(&gPlayerEntity); COLLISION_OFF(&gPlayerEntity);
@ -381,7 +381,7 @@ u32 UpdatePlayerCollision(void) {
} }
gPlayerState.pushedObject = 0xa0; gPlayerState.pushedObject = 0xa0;
gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= 1; gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
@ -393,7 +393,7 @@ u32 UpdatePlayerCollision(void) {
layer->mapData[position] = 0x405b + (gPlayerEntity.animationState >> 1); layer->mapData[position] = 0x405b + (gPlayerEntity.animationState >> 1);
gPlayerState.pushedObject = 0x98; gPlayerState.pushedObject = 0x98;
gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= 1; gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
@ -405,7 +405,7 @@ u32 UpdatePlayerCollision(void) {
layer->mapData[position] = 0x4037 + (gPlayerEntity.animationState >> 1); layer->mapData[position] = 0x4037 + (gPlayerEntity.animationState >> 1);
gPlayerState.pushedObject = 0xa0; gPlayerState.pushedObject = 0xa0;
gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= 1; gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
@ -423,7 +423,7 @@ u32 UpdatePlayerCollision(void) {
layer->mapData[position] = 0x403f; layer->mapData[position] = 0x403f;
gPlayerState.pushedObject = 0x82; gPlayerState.pushedObject = 0x82;
gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= 1; gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
@ -464,7 +464,7 @@ u32 UpdatePlayerCollision(void) {
pushedBlock->collisionLayer = gPlayerEntity.collisionLayer; pushedBlock->collisionLayer = gPlayerEntity.collisionLayer;
gPlayerState.pushedObject = 0xa0; gPlayerState.pushedObject = 0xa0;
gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= 1; gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = pushedBlock->direction; gPlayerEntity.direction = pushedBlock->direction;
@ -472,13 +472,13 @@ u32 UpdatePlayerCollision(void) {
case 0x402b ... 0x402d: case 0x402b ... 0x402d:
if (sub_0801A370(layer, position) != 0) { if (sub_0801A370(layer, position) != 0) {
layer->mapData[position] = 0x4030 + ((gPlayerEntity.animationState & 4) >> 2); layer->mapData[position] = 0x4030 + ((gPlayerEntity.animationState & 4) >> 2);
if ((gPlayerState.flags & 0x80) != 0) { if ((gPlayerState.flags & PL_MINISH) != 0) {
gPlayerState.pushedObject = 0xa0; gPlayerState.pushedObject = 0xa0;
} else { } else {
gPlayerState.pushedObject = 0x90; gPlayerState.pushedObject = 0x90;
} }
gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= 1; gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
@ -491,13 +491,13 @@ u32 UpdatePlayerCollision(void) {
return 0; return 0;
} }
layer->mapData[position] = 0x404b + (gPlayerEntity.animationState >> 1); layer->mapData[position] = 0x404b + (gPlayerEntity.animationState >> 1);
if ((gPlayerState.flags & 0x80) != 0) { if ((gPlayerState.flags & PL_MINISH) != 0) {
gPlayerState.pushedObject = 0xc0; gPlayerState.pushedObject = 0xc0;
} else { } else {
gPlayerState.pushedObject = 0xa0; gPlayerState.pushedObject = 0xa0;
} }
gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= 1; gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
@ -563,7 +563,7 @@ u32 UpdatePlayerCollision(void) {
SetTile(0x4074, position, gPlayerEntity.collisionLayer); SetTile(0x4074, position, gPlayerEntity.collisionLayer);
gPlayerState.pushedObject = 0xa0; gPlayerState.pushedObject = 0xa0;
gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= 1; gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
@ -831,7 +831,7 @@ bool32 sub_0801AA58(Entity* this, u32 param_2, u32 param_3) {
object->collisionLayer = this->collisionLayer; object->collisionLayer = this->collisionLayer;
gPlayerState.pushedObject = 0xa0; gPlayerState.pushedObject = 0xa0;
gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= 1; gPlayerState.flags |= PL_BUSY;
this->x.HALF.LO = 0; this->x.HALF.LO = 0;
this->y.HALF.LO = 0; this->y.HALF.LO = 0;
this->direction = param_3; this->direction = param_3;

View File

@ -43,7 +43,7 @@ Entity* sub_08049E4C(void) {
} }
Entity* sub_08049E80(void) { Entity* sub_08049E80(void) {
if ((gPlayerState.field_0x3c != 0) || !(gPlayerState.flags & 0x80)) { if ((gPlayerState.field_0x3c != 0) || !(gPlayerState.flags & PL_MINISH)) {
return NULL; return NULL;
} }
gUnk_020000B0 = &gPlayerEntity; gUnk_020000B0 = &gPlayerEntity;
@ -51,7 +51,8 @@ Entity* sub_08049E80(void) {
} }
Entity* sub_08049EB0(void) { Entity* sub_08049EB0(void) {
if ((gPlayerState.field_0x3c == 0) && !(gPlayerState.flags & 0x80190)) { if ((gPlayerState.field_0x3c == 0) && !(gPlayerState.flags &
(PL_MOLDWORM_CAPTURED | PL_DISABLE_ITEMS | PL_MINISH | PL_CAPTURED))) {
gUnk_020000B0 = &gPlayerEntity; gUnk_020000B0 = &gPlayerEntity;
return &gPlayerEntity; return &gPlayerEntity;
} }

View File

@ -422,7 +422,7 @@ bool32 sub_0803086C(ArmosEntity* this) {
FORCE_REGISTER(u32 r2, r2); FORCE_REGISTER(u32 r2, r2);
if (this->unk_7c != NULL) { if (this->unk_7c != NULL) {
if ((gPlayerState.flags & 0x80) != 0) { if ((gPlayerState.flags & PL_MINISH) != 0) {
centerX = super->x.HALF_U.HI - gRoomControls.origin_x; centerX = super->x.HALF_U.HI - gRoomControls.origin_x;
centerY = super->y.HALF_U.HI - gRoomControls.origin_y; centerY = super->y.HALF_U.HI - gRoomControls.origin_y;
// TODO for some reason the 0x3f of COORD_TO_TILE(super) needs to be forced to r2 here. // TODO for some reason the 0x3f of COORD_TO_TILE(super) needs to be forced to r2 here.

View File

@ -127,7 +127,7 @@ void sub_080754B8(ItemBehavior* this, u32 index) {
} }
if ((this->playerFrame & 0x80) != 0) { if ((this->playerFrame & 0x80) != 0) {
if (((gPlayerState.flags & 0x80) != 0) || ((gPlayerState.skills & SKILL_SPIN_ATTACK) == 0)) { if (((gPlayerState.flags & PL_MINISH) != 0) || ((gPlayerState.skills & SKILL_SPIN_ATTACK) == 0)) {
sub_080759B8(this, index); sub_080759B8(this, index);
} else { } else {
sub_08075580(this, index); sub_08075580(this, index);

View File

@ -117,7 +117,7 @@ void sub_080855E8(LilypadLargeEntity* this) {
super->flags |= 0x20; super->flags |= 0x20;
if (sub_0806FC80(super, &gPlayerEntity, 0x18) != 0) { if (sub_0806FC80(super, &gPlayerEntity, 0x18) != 0) {
gPlayerState.flags |= 2; gPlayerState.flags |= PL_FLAGS2;
if (gPlayerEntity.z.WORD == 0) { if (gPlayerEntity.z.WORD == 0) {
if (gPlayerState.swim_state != 0) { if (gPlayerState.swim_state != 0) {
gPlayerEntity.collisionFlags &= 0xfb; gPlayerEntity.collisionFlags &= 0xfb;
@ -258,7 +258,7 @@ void sub_080855E8(LilypadLargeEntity* this) {
this->unk_85 = 0; this->unk_85 = 0;
} }
if ((gPlayerState.flags & 2) != 0) { if ((gPlayerState.flags & PL_FLAGS2) != 0) {
sub_08085F1C(this); sub_08085F1C(this);
} }

View File

@ -132,7 +132,7 @@ void PushableStatue_SubAction0(PushableStatueEntity* this) {
if (sub_080896B0()) { if (sub_080896B0()) {
gPlayerState.queued_action = PLAYER_PULL; gPlayerState.queued_action = PLAYER_PULL;
gPlayerState.field_0x38 = 0x20; gPlayerState.field_0x38 = 0x20;
gPlayerState.flags |= 1; gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0;
super->direction = (gPlayerEntity.animationState ^ 4) << 2; super->direction = (gPlayerEntity.animationState ^ 4) << 2;

View File

@ -182,7 +182,7 @@ void sub_080A76CC(PlayerItemSwordEntity* this) {
} }
} else { } else {
if ((gPlayerState.flags & 0x8000000) != 0) { if ((gPlayerState.flags & PL_SWORD_THRUST) != 0) {
if (this->unk_68 == 6) { if (this->unk_68 == 6) {
super->hurtType = 0xc; super->hurtType = 0xc;
} else { } else {

View File

@ -1526,10 +1526,10 @@ void sub_08078FB0(Entity* this) {
gPlayerState.field_0x35 = 0xff; gPlayerState.field_0x35 = 0xff;
} }
sub_08079064(this); sub_08079064(this);
if ((gPlayerState.flags & 8) != 0) { if ((gPlayerState.flags & PL_NO_CAP) != 0) {
animIndex = 0x58; animIndex = 0x58;
} else { } else {
if ((gPlayerState.flags & 0x80) != 0) { if ((gPlayerState.flags & PL_MINISH) != 0) {
animIndex = 0x18; animIndex = 0x18;
} else { } else {
if (gPlayerState.animation >> 8 == 7) { if (gPlayerState.animation >> 8 == 7) {
@ -1722,8 +1722,8 @@ void RespawnPlayer(void) {
player->zVelocity = 0; player->zVelocity = 0;
player->knockbackDuration = 0; player->knockbackDuration = 0;
ResetPlayerPosition(); ResetPlayerPosition();
if ((gPlayerState.flags & 0x20000) == 0) { if ((gPlayerState.flags & PL_GYORG_FIGHT) == 0) {
if ((gPlayerState.flags & 0x10000) != 0) { if ((gPlayerState.flags & PL_FLAGS10000) != 0) {
player->x.HALF.HI = gPlayerState.lilypad->x.HALF.HI; player->x.HALF.HI = gPlayerState.lilypad->x.HALF.HI;
player->y.HALF.HI = gPlayerState.lilypad->y.HALF.HI; player->y.HALF.HI = gPlayerState.lilypad->y.HALF.HI;
} else { } else {