Merge pull request #310 from notyourav/pressurePlate

pressure plate ok
This commit is contained in:
notyourav 2022-01-22 11:35:36 -08:00 committed by GitHub
commit 85aaada18f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 285 additions and 390 deletions

View File

@ -0,0 +1,59 @@
.syntax unified
push {r4, r5, r6, r7, lr}
mov r7, r8
push {r7}
movs r5, #0
ldrh r1, [r0, #0x2e]
subs r1, #8
lsls r1, r1, #0x10
lsrs r1, r1, #0x10
mov ip, r1
ldrh r1, [r0, #0x32]
subs r1, #8
lsls r1, r1, #0x10
lsrs r7, r1, #0x10
movs r4, #0
ldr r1, _080889A0 @ =gRoomVars
ldr r2, _080889A4 @ =sSpriteOffsets
mov r8, r2
adds r3, r1, #0
adds r3, #0xac
adds r6, r0, #0
adds r6, #0x72
_08088962:
ldr r2, [r3]
cmp r2, #0
beq _08088990
ldrh r0, [r2, #0x2e]
mov r1, ip
subs r0, r0, r1
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r0, #0x10
bhi _08088990
ldrh r0, [r2, #0x32]
subs r0, r0, r7
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r0, #0x10
bhi _08088990
ldrb r0, [r6]
add r0, r8
ldrb r1, [r0]
adds r0, r2, #0
adds r0, #0x63
strb r1, [r0]
adds r5, #1
_08088990:
adds r3, #4
adds r4, #1
cmp r4, #7
bls _08088962
adds r0, r5, #0
pop {r3}
mov r8, r3
pop {r4, r5, r6, r7, pc}
.align 2, 0
_080889A0: .4byte gRoomVars
_080889A4: .4byte sSpriteOffsets
.syntax divided

View File

@ -392,7 +392,7 @@ _0808D972:
strh r0, [r4, #0x36]
ldr r1, _0808D994 @ =gPlayerEntity
adds r0, r4, #0
bl sub_080177A0
bl IsColliding
cmp r0, #0
beq _0808D992
adds r0, r4, #0

View File

@ -151,7 +151,7 @@ sub_080A02CC: @ 0x080A02CC
adds r0, r4, #0
bl sub_080A0444
adds r0, r4, #0
bl sub_08017850
bl IsCollidingPlayer
cmp r0, #0
beq _080A0342
ldr r0, [r4, #0x54]

View File

@ -144,7 +144,7 @@ _0808A930:
asrs r0, r0, #0x18
strh r0, [r4, #0x36]
adds r0, r4, #0
bl sub_08017850
bl IsCollidingPlayer
cmp r0, #0
beq _0808A962
_0808A954:

View File

@ -189,7 +189,7 @@ sub_0809D8C8: @ 0x0809D8C8
_0809D8E4: .4byte gPlayerState
_0809D8E8:
adds r0, r5, #0
bl sub_08017850
bl IsCollidingPlayer
cmp r0, #0
beq _0809D90A
ldrb r0, [r6, #0xd]

View File

@ -340,7 +340,7 @@ _0809FD1C:
strh r0, [r4, #0x36]
ldr r1, _0809FD48 @ =gPlayerEntity
adds r0, r4, #0
bl sub_080177A0
bl IsColliding
cmp r0, #0
beq _0809FD44
adds r0, r4, #0

View File

@ -1,308 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start PressurePlate
PressurePlate: @ 0x08088804
push {r4, lr}
adds r4, r0, #0
ldrb r0, [r4, #0xf]
cmp r0, #0
beq _08088828
subs r0, #1
strb r0, [r4, #0xf]
lsls r0, r0, #0x18
cmp r0, #0
bne _08088828
ldrb r0, [r4, #0x14]
adds r1, r4, #0
adds r1, #0x72
strb r0, [r1]
ldrb r1, [r4, #0x14]
adds r0, r4, #0
bl InitializeAnimation
_08088828:
ldr r0, _0808883C @ =gUnk_08120BE0
ldrb r1, [r4, #0xc]
lsls r1, r1, #2
adds r1, r1, r0
ldr r1, [r1]
adds r0, r4, #0
bl _call_via_r1
pop {r4, pc}
.align 2, 0
_0808883C: .4byte gUnk_08120BE0
thumb_func_start sub_08088840
sub_08088840: @ 0x08088840
movs r3, #1
movs r1, #1
strb r1, [r0, #0xc]
ldrb r2, [r0, #0x18]
subs r1, #5
ands r1, r2
orrs r1, r3
strb r1, [r0, #0x18]
adds r3, r0, #0
adds r3, #0x29
ldrb r1, [r3]
movs r2, #7
orrs r1, r2
strb r1, [r3]
ldr r1, _08088868 @ =gUnk_080FD1D4
str r1, [r0, #0x48]
ldrb r1, [r0, #0x14]
adds r0, #0x72
strb r1, [r0]
bx lr
.align 2, 0
_08088868: .4byte gUnk_080FD1D4
thumb_func_start sub_0808886C
sub_0808886C: @ 0x0808886C
push {r4, r5, lr}
adds r5, r0, #0
bl sub_08088938
adds r4, r0, #0
adds r0, r5, #0
bl sub_080889A8
adds r4, r4, r0
lsls r4, r4, #0x18
lsrs r4, r4, #0x18
ldrb r1, [r5, #0xa]
adds r0, r1, #2
cmp r0, r4
bgt _080888B8
movs r1, #0
movs r0, #2
strb r0, [r5, #0xc]
strb r1, [r5, #0xf]
movs r0, #4
strb r0, [r5, #0x14]
strh r1, [r5, #0x36]
adds r0, r5, #0
movs r1, #4
bl InitializeAnimation
adds r0, r5, #0
adds r0, #0x86
ldrh r0, [r0]
bl SetFlag
ldr r0, _080888B4 @ =0x0000016B
bl EnqueueSFX
b _080888F2
.align 2, 0
_080888B4: .4byte 0x0000016B
_080888B8:
ldrb r0, [r5, #0x14]
cmp r4, r0
bls _080888E4
adds r0, r1, #1
cmp r0, r4
bne _080888D2
movs r0, #4
strb r0, [r5, #0xf]
adds r1, r4, #1
adds r0, r5, #0
bl InitializeAnimation
b _080888DA
_080888D2:
adds r0, r5, #0
adds r1, r4, #0
bl InitializeAnimation
_080888DA:
movs r0, #0x86
lsls r0, r0, #1
bl EnqueueSFX
b _080888F0
_080888E4:
cmp r4, r0
bhs _080888F0
adds r0, r5, #0
adds r1, r4, #0
bl InitializeAnimation
_080888F0:
strb r4, [r5, #0x14]
_080888F2:
pop {r4, r5, pc}
thumb_func_start sub_080888F4
sub_080888F4: @ 0x080888F4
push {r4, r5, lr}
adds r5, r0, #0
adds r0, #0x70
ldrh r0, [r0]
cmp r0, #0
beq _08088934
adds r0, r5, #0
bl sub_08088938
adds r4, r0, #0
adds r0, r5, #0
bl sub_080889A8
adds r4, r4, r0
lsls r4, r4, #0x18
lsrs r4, r4, #0x18
ldrb r0, [r5, #0xa]
adds r0, #2
cmp r0, r4
ble _08088934
movs r0, #1
strb r0, [r5, #0xc]
strb r4, [r5, #0x14]
adds r0, r5, #0
adds r0, #0x86
ldrh r0, [r0]
bl ClearFlag
adds r0, r5, #0
adds r1, r4, #0
bl InitializeAnimation
_08088934:
pop {r4, r5, pc}
.align 2, 0
thumb_func_start sub_08088938
sub_08088938: @ 0x08088938
push {r4, r5, r6, r7, lr}
mov r7, r8
push {r7}
movs r5, #0
ldrh r1, [r0, #0x2e]
subs r1, #8
lsls r1, r1, #0x10
lsrs r1, r1, #0x10
mov ip, r1
ldrh r1, [r0, #0x32]
subs r1, #8
lsls r1, r1, #0x10
lsrs r7, r1, #0x10
movs r4, #0
ldr r1, _080889A0 @ =gRoomVars
ldr r2, _080889A4 @ =gUnk_08120BEC
mov r8, r2
adds r3, r1, #0
adds r3, #0xac
adds r6, r0, #0
adds r6, #0x72
_08088962:
ldr r2, [r3]
cmp r2, #0
beq _08088990
ldrh r0, [r2, #0x2e]
mov r1, ip
subs r0, r0, r1
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r0, #0x10
bhi _08088990
ldrh r0, [r2, #0x32]
subs r0, r0, r7
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r0, #0x10
bhi _08088990
ldrb r0, [r6]
add r0, r8
ldrb r1, [r0]
adds r0, r2, #0
adds r0, #0x63
strb r1, [r0]
adds r5, #1
_08088990:
adds r3, #4
adds r4, #1
cmp r4, #7
bls _08088962
adds r0, r5, #0
pop {r3}
mov r8, r3
pop {r4, r5, r6, r7, pc}
.align 2, 0
_080889A0: .4byte gRoomVars
_080889A4: .4byte gUnk_08120BEC
thumb_func_start sub_080889A8
sub_080889A8: @ 0x080889A8
push {r4, r5, r6, lr}
adds r4, r0, #0
movs r5, #0
bl sub_08017850
cmp r0, #0
beq _080889CA
ldr r1, _08088A40 @ =gPlayerEntity
ldr r2, _08088A44 @ =gUnk_08120BEC
adds r0, r4, #0
adds r0, #0x72
ldrb r0, [r0]
adds r0, r0, r2
ldrb r0, [r0]
adds r1, #0x63
strb r0, [r1]
movs r5, #1
_080889CA:
ldr r0, _08088A48 @ =gPlayerState
ldr r0, [r0, #0x30]
movs r1, #0x80
lsls r1, r1, #0xf
ands r0, r1
cmp r0, #0
beq _08088A3A
ldr r6, _08088A4C @ =gPlayerClones
ldr r1, [r6]
adds r0, r4, #0
bl sub_080177A0
cmp r0, #0
beq _080889FA
ldr r1, [r6]
ldr r2, _08088A44 @ =gUnk_08120BEC
adds r0, r4, #0
adds r0, #0x72
ldrb r0, [r0]
adds r0, r0, r2
ldrb r0, [r0]
adds r1, #0x63
strb r0, [r1]
adds r5, #1
_080889FA:
ldr r1, [r6, #4]
adds r0, r4, #0
bl sub_080177A0
cmp r0, #0
beq _08088A1A
ldr r1, [r6, #4]
ldr r2, _08088A44 @ =gUnk_08120BEC
adds r0, r4, #0
adds r0, #0x72
ldrb r0, [r0]
adds r0, r0, r2
ldrb r0, [r0]
adds r1, #0x63
strb r0, [r1]
adds r5, #1
_08088A1A:
ldr r1, [r6, #8]
adds r0, r4, #0
bl sub_080177A0
cmp r0, #0
beq _08088A3A
ldr r1, [r6, #8]
ldr r2, _08088A44 @ =gUnk_08120BEC
adds r0, r4, #0
adds r0, #0x72
ldrb r0, [r0]
adds r0, r0, r2
ldrb r0, [r0]
adds r1, #0x63
strb r0, [r1]
adds r5, #1
_08088A3A:
adds r0, r5, #0
pop {r4, r5, r6, pc}
.align 2, 0
_08088A40: .4byte gPlayerEntity
_08088A44: .4byte gUnk_08120BEC
_08088A48: .4byte gPlayerState
_08088A4C: .4byte gPlayerClones

View File

@ -709,7 +709,7 @@ sub_080A11C0: @ 0x080A11C0
cmp r0, #0
bne _080A11DC
adds r0, r1, #0
bl sub_08017850
bl IsCollidingPlayer
b _080A11DE
.align 2, 0
_080A11D8: .4byte gPlayerEntity

View File

@ -2861,7 +2861,7 @@
"size": 52
},
{
"path": "sounds/sfx10C.bin",
"path": "sounds/sfxButtonPress.bin",
"start": 14557448,
"type": "midi",
"options": {
@ -3906,7 +3906,7 @@
"size": 60
},
{
"path": "sounds/sfx16B.bin",
"path": "sounds/sfxPressurePlate.bin",
"start": 14565100,
"type": "midi",
"options": {

View File

@ -266,7 +266,7 @@
.equiv SFX_109, 0x109
.equiv SFX_10A, 0x10a
.equiv SFX_10B, 0x10b
.equiv SFX_10C, 0x10c
.equiv SFX_BUTTON_PRESS, 0x10c
.equiv SFX_10D, 0x10d
.equiv SFX_10E, 0x10e
.equiv SFX_10F, 0x10f

View File

@ -1,27 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
@ .align 2
gSpriteAnimations_PressurePlate_0:: @ 08120BF1
.include "animations/gSpriteAnimations_PressurePlate_0.s"
gSpriteAnimations_PressurePlate_1:: @ 08120BF5
.include "animations/gSpriteAnimations_PressurePlate_1.s"
gSpriteAnimations_PressurePlate_2:: @ 08120BF9
.include "animations/gSpriteAnimations_PressurePlate_2.s"
gSpriteAnimations_PressurePlate_3:: @ 08120BFD
.include "animations/gSpriteAnimations_PressurePlate_3.s"
gSpriteAnimations_PressurePlate_4:: @ 08120C01
.include "animations/gSpriteAnimations_PressurePlate_4.s"
gSpriteAnimations_PressurePlate:: @ 08120C08
.4byte gSpriteAnimations_PressurePlate_0
.4byte gSpriteAnimations_PressurePlate_1
.4byte gSpriteAnimations_PressurePlate_2
.4byte gSpriteAnimations_PressurePlate_3
.4byte gSpriteAnimations_PressurePlate_4

View File

@ -1,13 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnk_08120BE0:: @ 08120BE0
.4byte sub_08088840
.4byte sub_0808886C
.4byte sub_080888F4
gUnk_08120BEC:: @ 08120BEC
.incbin "PressurePlate/gUnk_08120BEC.bin"

View File

@ -46,7 +46,7 @@ script_080144C0:
script_080144C8:
ModRupees 0xfff6
MessageFromTarget 0x420c
PlaySound SFX_10C
PlaySound SFX_BUTTON_PRESS
Wait 0x0018
SetRoomFlag 0x0000
SetLocalFlag 0x0092

View File

@ -232,7 +232,7 @@
.include "sounds/sfx109.s"
.include "sounds/sfx10A.s"
.include "sounds/sfx10B.s"
.include "sounds/sfx10C.s"
.include "sounds/sfxButtonPress.s"
.include "sounds/sfx10D.s"
.include "sounds/sfx10E.s"
.include "sounds/sfx10F.s"
@ -327,7 +327,7 @@
.include "sounds/sfx168.s"
.include "sounds/sfx169.s"
.include "sounds/sfx16A.s"
.include "sounds/sfx16B.s"
.include "sounds/sfxPressurePlate.s"
.include "sounds/sfx16C.s"
.include "sounds/sfx16D.s"
.include "sounds/sfx16E.s"

View File

@ -86,7 +86,7 @@ extern u32 sub_080002B8(Entity*);
extern u32 sub_08049F84(Entity*, u32);
extern u32 sub_0800419C(Entity*, Entity*, u32, u32);
extern void sub_08004542(Entity*);
extern u32 sub_08017850(Entity*);
extern u32 IsCollidingPlayer(Entity*);
extern void sub_080809D4(void);
extern void sub_08080CB4(Entity*);
extern void sub_0807B7D8(u32, u32, u32);

View File

@ -262,7 +262,7 @@ void Object20(Entity*);
void Object21(Entity*);
void FigurineDevice(Entity*);
void EyeSwitch(Entity*);
void PressurePlate(Entity*);
void PressurePlate();
void BigBarrel(Entity*);
void BarrelInside(Entity*);
void PushableStatue(Entity*);

View File

@ -278,6 +278,7 @@ extern void (*const gPlayerItemFunctions[])(Entity*);
extern u8 gBombBagSizes[];
extern u8 gQuiverSizes[];
extern u16 gWalletSizes[];
extern Entity* gPlayerClones[];
extern PlayerState gPlayerState;
extern Entity gPlayerEntity;

View File

@ -299,7 +299,7 @@ typedef enum {
SFX_109,
SFX_10A,
SFX_10B,
SFX_10C,
SFX_BUTTON_PRESS,
SFX_10D,
SFX_10E,
SFX_10F,
@ -394,7 +394,7 @@ typedef enum {
SFX_168,
SFX_169,
SFX_16A,
SFX_16B,
SFX_PRESSURE_PLATE,
SFX_16C,
SFX_16D,
SFX_16E,

View File

@ -22,7 +22,7 @@ typedef struct {
u8 endOfAnimation : 1;
} PACKED b;
} PACKED frameSettings;
} Frame;
} PACKED Frame;
typedef struct {
u8 numGfxTiles;

View File

@ -680,7 +680,7 @@ SECTIONS {
asm/object/object21.o(.text);
asm/object/figurineDevice.o(.text);
asm/object/eyeSwitch.o(.text);
asm/object/pressurePlate.o(.text);
src/object/pressurePlate.o(.text);
asm/object/bigBarrel.o(.text);
src/object/barrelInside.o(.text);
asm/object/pushableStatue.o(.text);
@ -1400,8 +1400,7 @@ SECTIONS {
data/animations/object/figurineDevice.o(.rodata);
data/const/object/eyeSwitch.o(.rodata);
data/animations/object/eyeSwitch.o(.rodata);
data/const/object/pressurePlate.o(.rodata);
data/animations/object/pressurePlate.o(.rodata);
src/object/pressurePlate.o(.rodata);
data/const/object/bigBarrel.o(.rodata);
data/animations/object/bigBarrel.o(.rodata);
src/object/barrelInside.o(.rodata);

View File

@ -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;
}

View File

@ -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]) {

View File

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

View File

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

View File

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

View File

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

View File

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

185
src/object/pressurePlate.c Normal file
View File

@ -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,
};

View File

@ -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)) {

View File

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

View File

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

View File

@ -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 },