diff options
| author | theo3 <arisstephenson2@gmail.com> | 2022-01-22 11:27:56 -0800 |
|---|---|---|
| committer | theo3 <arisstephenson2@gmail.com> | 2022-01-22 11:32:56 -0800 |
| commit | 737302d9d1808e5a1def42725e27cef99d0196b2 (patch) | |
| tree | b9aa9840d57e5d3bd889e29a86163d3387b5aec5 /src | |
| parent | 93e745e9638bb4f48e27908eebe2bb4eb349812e (diff) | |
pressure plate ok
Diffstat (limited to 'src')
| -rw-r--r-- | src/collision.c | 6 | ||||
| -rw-r--r-- | src/enemy/gleerok.c | 2 | ||||
| -rw-r--r-- | src/object/bird.c | 2 | ||||
| -rw-r--r-- | src/object/book.c | 2 | ||||
| -rw-r--r-- | src/object/button.c | 4 | ||||
| -rw-r--r-- | src/object/heartContainer.c | 2 | ||||
| -rw-r--r-- | src/object/itemOnGround.c | 8 | ||||
| -rw-r--r-- | src/object/pressurePlate.c | 185 | ||||
| -rw-r--r-- | src/player.c | 1 | ||||
| -rw-r--r-- | src/projectile/cannonballProjectile.c | 4 | ||||
| -rw-r--r-- | src/projectile/dekuSeedProjectile.c | 4 | ||||
| -rw-r--r-- | src/sound.c | 8 |
12 files changed, 206 insertions, 22 deletions
diff --git a/src/collision.c b/src/collision.c index 91471613..b312d6ea 100644 --- a/src/collision.c +++ b/src/collision.c @@ -177,7 +177,7 @@ NONMATCH("asm/non_matching/arm_proxy/sub_08017744.inc", void sub_08017744(Entity } END_NONMATCH -bool32 sub_080177A0(Entity* this, Entity* that) { +bool32 IsColliding(Entity* this, Entity* that) { u32 this_d; u32 depth; @@ -206,9 +206,9 @@ bool32 sub_080177A0(Entity* this, Entity* that) { return FALSE; } -bool32 sub_08017850(Entity* this) { +bool32 IsCollidingPlayer(Entity* this) { if (sub_08079F8C()) - return sub_080177A0(this, &gPlayerEntity); + return IsColliding(this, &gPlayerEntity); return FALSE; } diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c index 8066e3fc..cfad4857 100644 --- a/src/enemy/gleerok.c +++ b/src/enemy/gleerok.c @@ -605,7 +605,7 @@ NONMATCH("asm/non_matching/gleerok/sub_0802D86C.inc", void sub_0802D86C(GleerokE super->parent->subAction = 4; super->parent->type2 = 0; ((GleerokEntity*)super->parent)->unk_7b = 0; - SoundReq(SFX_10C); + SoundReq(SFX_BUTTON_PRESS); } } else { if (super->actionDelay != this->unk_84->filler[1]) { diff --git a/src/object/bird.c b/src/object/bird.c index efd3ce74..cafe1262 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -116,7 +116,7 @@ void sub_0809D10C(Entity* this) { void sub_0809D130(Entity* this) { if ((gPlayerState.flags & PL_MINISH) != 0) { sub_0800445C(this); - } else if (sub_08017850(this) != 0) { + } else if (IsCollidingPlayer(this) != 0) { CreateItemEntity(0x17, 0, 0); gSave.windcrests |= 0x10000000; DeleteThisEntity(); diff --git a/src/object/book.c b/src/object/book.c index 811ca4ae..790c5839 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -141,7 +141,7 @@ void sub_0809B56C(Entity* this) { void sub_0809B5B4(Entity* this) { if (gPlayerState.flags & PL_MINISH) { sub_0800445C(this); - } else if (sub_08017850(this)) { + } else if (IsCollidingPlayer(this)) { CreateItemEntity(this->type + 0x39, 0, 0); DeleteThisEntity(); } diff --git a/src/object/button.c b/src/object/button.c index cb7a58c7..316f7608 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -90,7 +90,7 @@ void sub_08081C30(Entity* this) { this->action = 2; ClearFlag(this->field_0x86.HWORD); SetTileType(0x77, this->field_0x74.HWORD, this->collisionLayer); - SoundReq(SFX_10C); + SoundReq(SFX_BUTTON_PRESS); } } @@ -251,7 +251,7 @@ u32 sub_08081F7C(Entity* this, u32 r7) { SetFlag(this->field_0x86.HWORD); SetTileType(r7, this->field_0x74.HWORD, this->collisionLayer); sub_08081F24(this); - SoundReq(SFX_10C); + SoundReq(SFX_BUTTON_PRESS); if (this->field_0x70.HALF_U.LO != 0xFFFF) SetTile(this->field_0x70.HALF_U.LO, this->field_0x74.HWORD, this->collisionLayer); return 0; diff --git a/src/object/heartContainer.c b/src/object/heartContainer.c index 9e8346b3..a81709c4 100644 --- a/src/object/heartContainer.c +++ b/src/object/heartContainer.c @@ -59,7 +59,7 @@ static void sub_0808E714(Entity* this) { static void sub_0808E764(Entity* this) { sub_08080CB4(this); - if (!(gPlayerState.flags & PL_MINISH) && sub_08017850(this)) { + if (!(gPlayerState.flags & PL_MINISH) && IsCollidingPlayer(this)) { SetFlag(this->cutsceneBeh.HWORD); CreateItemEntity(0x62, 0, 0); DeleteThisEntity(); diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index 910764a2..ec9b2bef 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -18,7 +18,7 @@ void sub_080813BC(Entity*); void sub_080810FC(Entity*); bool32 CheckShouldPlayItemGetCutscene(Entity*); -extern u32 sub_080177A0(Entity*, Entity*); +extern u32 IsColliding(Entity*, Entity*); extern void GiveItem(u32, u32); extern void (*const gUnk_0811E7D4[])(Entity*); @@ -269,10 +269,10 @@ void sub_080812A8(Entity* this) { void sub_080812E8(Entity* this) { PlayerState* playerState = &gPlayerState; #ifdef EU - if ((playerState->swim_state & 0x80) && sub_080177A0(this, &gPlayerEntity)) { + if ((playerState->swim_state & 0x80) && IsColliding(this, &gPlayerEntity)) { #else if ((playerState->swim_state & 0x80) && (playerState->flags & PL_MINISH) == 0 && - sub_080177A0(this, &gPlayerEntity)) { + IsColliding(this, &gPlayerEntity)) { #endif sub_080810FC(this); } @@ -289,7 +289,7 @@ void sub_08081328(Entity* this) { CopyPosition(other, this); this->z.HALF.HI--; other = &gPlayerEntity; - if (sub_080177A0(this, other)) { + if (IsColliding(this, other)) { sub_080810FC(this); } } diff --git a/src/object/pressurePlate.c b/src/object/pressurePlate.c new file mode 100644 index 00000000..891616ca --- /dev/null +++ b/src/object/pressurePlate.c @@ -0,0 +1,185 @@ +#define NENT_DEPRECATED +#include "object.h" +#include "functions.h" + +u32 IsColliding(Entity*, Entity*); + +typedef struct { + Entity base; + /*0x68*/ union SplitHWord field_0x68; + /*0x6a*/ union SplitHWord field_0x6a; + /*0x6c*/ union SplitHWord field_0x6c; + /*0x6e*/ union SplitHWord field_0x6e; + /*0x70*/ u16 canToggle; + /*0x72*/ u8 dir; + /*0x73*/ u8 filler73[0x86 - 0x73]; + /*0x86*/ u16 flag; +} PressurePlateEntity; + +typedef void(PressurePlateAction)(PressurePlateEntity*); + +PressurePlateAction sub_08088840; +PressurePlateAction sub_0808886C; +PressurePlateAction sub_080888F4; + +extern Hitbox gUnk_080FD1D4; + +static u32 sub_08088938(PressurePlateEntity*); +static u32 get_standing_count(PressurePlateEntity*); + +static const u8 sSpriteOffsets[]; + +void PressurePlate(PressurePlateEntity* this) { + static PressurePlateAction* const sActions[] = { + sub_08088840, + sub_0808886C, + sub_080888F4, + }; + + if (super->field_0xf) { + if (--super->field_0xf == 0) { + this->dir = super->animationState; + InitializeAnimation(super, super->animationState); + } + } + + sActions[super->action](this); +} + +void sub_08088840(PressurePlateEntity* this) { + super->action = 1; + super->spriteSettings.draw = 1; + super->spritePriority.b0 = 7; + super->hitbox = &gUnk_080FD1D4; + this->dir = super->animationState; +} + +void sub_0808886C(PressurePlateEntity* this) { + u8 weight; + + weight = sub_08088938(this) + get_standing_count(this); + if (super->type + 2 <= weight) { + super->action = 2; + super->field_0xf = 0; + super->animationState = 4; + super->z.HALF.HI = 0; + InitializeAnimation(super, 4); + SetFlag(this->flag); + EnqueueSFX(SFX_PRESSURE_PLATE); + } else { + if (weight > super->animationState) { + if (super->type + 1 == weight) { + super->field_0xf = 4; + InitializeAnimation(super, weight + 1); + } else { + InitializeAnimation(super, weight); + } + EnqueueSFX(SFX_BUTTON_PRESS); + } else if (weight < super->animationState) { + InitializeAnimation(super, weight); + } + super->animationState = weight; + } +} + +void sub_080888F4(PressurePlateEntity* this) { + u8 weight; + + if (this->canToggle) { + weight = sub_08088938(this) + get_standing_count(this); + if (super->type + 2 > weight) { + super->action = 1; + super->animationState = weight; + ClearFlag(this->flag); + InitializeAnimation(super, weight); + } + } +} + +static u32 NONMATCH("asm/non_matching/pressurePlate/sub_08088938.inc", sub_08088938(PressurePlateEntity* this)) { + u16 x, y; + s32 num; + u8* tmp; + u32 i; + + num = 0; + x = super->x.HALF.HI - 8; + y = super->y.HALF.HI - 8; + + tmp = &this->dir; + for (i = 0; i < 8; ++i) { + Entity* e = gRoomVars.field_0x8c[8 + i]; + if (e != NULL) { + if ((u16)(e->x.HALF.HI - x) < 0x11 && ((u16)(e->y.HALF_U.HI - y) < 0x11)) { + e->spriteOffsetY = sSpriteOffsets[*tmp]; + num++; + } + } + } + return num; +} +END_NONMATCH + +static u32 get_standing_count(PressurePlateEntity* this) { + u32 num; + + num = 0; + if (IsCollidingPlayer(super) != 0) { + gPlayerEntity.spriteOffsetY = sSpriteOffsets[this->dir]; + num = 1; + } + if ((gPlayerState.flags & PL_CLONING) != 0) { + if (IsColliding(super, gPlayerClones[0]) != 0) { + gPlayerClones[0]->spriteOffsetY = sSpriteOffsets[this->dir]; + num++; + } + if (IsColliding(super, gPlayerClones[1]) != 0) { + gPlayerClones[1]->spriteOffsetY = sSpriteOffsets[this->dir]; + num++; + } + if (IsColliding(super, gPlayerClones[2]) != 0) { + gPlayerClones[2]->spriteOffsetY = sSpriteOffsets[this->dir]; + num++; + } + } + return num; +} + +static const u8 sSpriteOffsets[] = { + -4, -3, -2, -1, 0, +}; + +static const Frame gSpriteAnimations_PressurePlate_0 = { + .index = 0, + .duration = 0xFF, + .frameSettings = { .b = { .endOfAnimation = 1 } }, +}; + +static const Frame gSpriteAnimations_PressurePlate_1 = { + .index = 1, + .duration = 0xFF, + .frameSettings = { .b = { .endOfAnimation = 1 } }, +}; + +static const Frame gSpriteAnimations_PressurePlate_2 = { + .index = 2, + .duration = 0xFF, + .frameSettings = { .b = { .endOfAnimation = 1 } }, +}; + +static const Frame gSpriteAnimations_PressurePlate_3 = { + .index = 3, + .duration = 0xFF, + .frameSettings = { .b = { .endOfAnimation = 1 } }, +}; + +static const Frame gSpriteAnimations_PressurePlate_4 = { + .index = 4, + .duration = 0xFF, + .frameSettings = { .b = { .endOfAnimation = 1 } }, +}; + +const Frame* const gSpriteAnimations_PressurePlate[] = { + &gSpriteAnimations_PressurePlate_0, &gSpriteAnimations_PressurePlate_1, &gSpriteAnimations_PressurePlate_2, + &gSpriteAnimations_PressurePlate_3, &gSpriteAnimations_PressurePlate_4, +}; diff --git a/src/player.c b/src/player.c index 4c1d2d43..09e83b77 100644 --- a/src/player.c +++ b/src/player.c @@ -321,7 +321,6 @@ extern u8 gUnk_080082DC[]; extern u16 script_BedInLinksRoom; extern u16 script_BedAtSimons; -extern Entity* gPlayerClones[]; extern ScriptExecutionContext gPlayerScriptExecutionContext; NONMATCH("asm/non_matching/playerItemPacciCane/CheckPlayerInactive.inc", u32 CheckPlayerInactive(void)) { diff --git a/src/projectile/cannonballProjectile.c b/src/projectile/cannonballProjectile.c index 449240e1..5e07dfc4 100644 --- a/src/projectile/cannonballProjectile.c +++ b/src/projectile/cannonballProjectile.c @@ -5,7 +5,7 @@ extern void CreateItemOnGround(Entity*); extern s32 sub_080AF090(Entity*); extern void sub_080043A8(Entity*); extern void CreateChestSpawner(Entity*); -extern u32 sub_080177A0(Entity*, Entity*); +extern u32 IsColliding(Entity*, Entity*); extern void (*const CannonballProjectile_Functions[])(Entity*); extern void (*const CannonballProjectile_Actions[])(Entity*); @@ -79,7 +79,7 @@ bool32 sub_080AB634(Entity* this) { Entity** entities = ((Entity**)&this->parent->zVelocity); u32 i; for (i = 0; i <= 3; ++i) { - if (entities[i] != NULL && (sub_080177A0(this, entities[i]) != 0)) { + if (entities[i] != NULL && (IsColliding(this, entities[i]) != 0)) { if (entities[i]->action < 3) { entities[i]->action = 3; entities[i]->actionDelay = 0x1e; diff --git a/src/projectile/dekuSeedProjectile.c b/src/projectile/dekuSeedProjectile.c index d84d0409..3afad118 100644 --- a/src/projectile/dekuSeedProjectile.c +++ b/src/projectile/dekuSeedProjectile.c @@ -5,7 +5,7 @@ extern s32 sub_080AF090(Entity*); extern s32 IsProjectileOffScreen(Entity*); extern void sub_08016AD2(Entity*); -extern u32 sub_080177A0(Entity*, Entity*); +extern u32 IsColliding(Entity*, Entity*); extern void (*const DekuSeedProjectile_Functions[])(Entity*); extern void (*const DekuSeedProjectile_Actions[])(Entity*); @@ -70,7 +70,7 @@ void DekuSeedProjectile_Action1(Entity* this) { } if (this->field_0xf != 0) { parent = this->parent; - if ((parent->next != NULL) && (sub_080177A0(this, parent) != 0)) { + if ((parent->next != NULL) && (IsColliding(this, parent) != 0)) { this->iframes = 0x10; this->knockbackDirection = -this->direction; this->bitfield = 0x80; diff --git a/src/sound.c b/src/sound.c index 342ae9c6..b0bb5901 100644 --- a/src/sound.c +++ b/src/sound.c @@ -462,7 +462,7 @@ extern const SongHeader sfx108; extern const SongHeader sfx109; extern const SongHeader sfx10A; extern const SongHeader sfx10B; -extern const SongHeader sfx10C; +extern const SongHeader sfxButtonPress; extern const SongHeader sfx10D; extern const SongHeader sfx10E; extern const SongHeader sfx10F; @@ -557,7 +557,7 @@ extern const SongHeader sfx167; extern const SongHeader sfx168; extern const SongHeader sfx169; extern const SongHeader sfx16A; -extern const SongHeader sfx16B; +extern const SongHeader sfxPressurePlate; extern const SongHeader sfx16C; extern const SongHeader sfx16D; extern const SongHeader sfx16E; @@ -1094,7 +1094,7 @@ const Song gSongTable[] = { [SFX_109] = { &sfx109, MUSIC_PLAYER_1E, MUSIC_PLAYER_1E }, [SFX_10A] = { &sfx10A, MUSIC_PLAYER_08, MUSIC_PLAYER_08 }, [SFX_10B] = { &sfx10B, MUSIC_PLAYER_07, MUSIC_PLAYER_07 }, - [SFX_10C] = { &sfx10C, MUSIC_PLAYER_06, MUSIC_PLAYER_06 }, + [SFX_BUTTON_PRESS] = { &sfxButtonPress, MUSIC_PLAYER_06, MUSIC_PLAYER_06 }, [SFX_10D] = { &sfx10D, MUSIC_PLAYER_05, MUSIC_PLAYER_05 }, [SFX_10E] = { &sfx10E, MUSIC_PLAYER_04, MUSIC_PLAYER_04 }, [SFX_10F] = { &sfx10F, MUSIC_PLAYER_03, MUSIC_PLAYER_03 }, @@ -1189,7 +1189,7 @@ const Song gSongTable[] = { [SFX_168] = { &sfx168, MUSIC_PLAYER_16, MUSIC_PLAYER_16 }, [SFX_169] = { &sfx169, MUSIC_PLAYER_15, MUSIC_PLAYER_15 }, [SFX_16A] = { &sfx16A, MUSIC_PLAYER_14, MUSIC_PLAYER_14 }, - [SFX_16B] = { &sfx16B, MUSIC_PLAYER_13, MUSIC_PLAYER_13 }, + [SFX_PRESSURE_PLATE] = { &sfxPressurePlate, MUSIC_PLAYER_13, MUSIC_PLAYER_13 }, [SFX_16C] = { &sfx16C, MUSIC_PLAYER_03, MUSIC_PLAYER_03 }, [SFX_16D] = { &sfx16D, MUSIC_PLAYER_12, MUSIC_PLAYER_12 }, [SFX_16E] = { &sfx16E, MUSIC_PLAYER_11, MUSIC_PLAYER_11 }, |
