diff options
| author | Behemoth <Luisscheurenbrand@gmail.com> | 2020-09-20 18:50:37 +0200 |
|---|---|---|
| committer | Behemoth <Luisscheurenbrand@gmail.com> | 2020-09-20 18:50:37 +0200 |
| commit | e6e690107c9cea4b96be3bf518706d25de5c30a8 (patch) | |
| tree | c26d497d8920c2a316b38e367caea9ccc10f5acd /src/enemy/sensorBladeTrap.c | |
| parent | 0703d4ad8bf6f630998b5370a6c18399c7ad09fd (diff) | |
decompile Sensor BladeTrap
Diffstat (limited to 'src/enemy/sensorBladeTrap.c')
| -rw-r--r-- | src/enemy/sensorBladeTrap.c | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/src/enemy/sensorBladeTrap.c b/src/enemy/sensorBladeTrap.c new file mode 100644 index 00000000..a0a049c0 --- /dev/null +++ b/src/enemy/sensorBladeTrap.c @@ -0,0 +1,120 @@ +#include "enemy.h" +#include "functions.h" + +extern u32 sub_0804A024(Entity*, u32, u32); +extern bool32 sub_080AE4CC(Entity*, u32, u32, u32); +extern bool32 sub_080AF038(Entity*); + +extern Entity gUnk_02027EB4; +extern Entity gUnk_0200D654; + +void sub_0802BB10(Entity*); +bool32 sub_0802BB2C(Entity*, u32); + +extern void (*const gUnk_080CD3C4[])(Entity*); +extern const u16 gUnk_080CD3D4[]; +extern const s8 gUnk_080CD3DC[]; + +void SensorBladeTrap(Entity* this) { + gUnk_080CD3C4[this->action](this); +} + +void sub_0802B9EC(Entity* this) { + this->action = 1; + this->field_0x78.HWORD = gUnk_080CD3D4[this->entityType.form]; + this->field_0x7c.HALF.LO = this->cutsceneBeh.HWORD; + this->field_0x7c.HALF.HI = this->field_0x86.HWORD; +} + +void sub_0802BA18(Entity* this) { + u32 direction = sub_0804A024(this, 1, 0xe); + if (direction == 0xff) + return; + + if (sub_0802BB2C(this, direction)) + return; + + this->action = 2; + this->nonPlanarMovement = this->field_0x78.HWORD; + this->direction = direction; + + switch (direction >> 3) { + case 0: + this->field_0x7a.HWORD = this->y.HALF.HI - this->field_0x7c.HALF.HI; + break; + case 1: + this->field_0x7a.HWORD = this->x.HALF.HI + this->field_0x7c.HALF.LO; + break; + case 2: + this->field_0x7a.HWORD = this->y.HALF.HI + this->field_0x7c.HALF.HI; + break; + case 3: + this->field_0x7a.HWORD = this->x.HALF.HI - this->field_0x7c.HALF.LO; + break; + } +} + +void sub_0802BA8C(Entity* this) { + if (!sub_080AF038(this)) { + sub_0802BB10(this); + } else { + switch (this->direction >> 3) { + case 0: + if (this->field_0x7a.HWORD >= this->y.HALF.HI) + sub_0802BB10(this); + break; + case 1: + if (this->field_0x7a.HWORD <= this->x.HALF.HI) + sub_0802BB10(this); + break; + case 2: + if (this->field_0x7a.HWORD <= this->y.HALF.HI) + sub_0802BB10(this); + break; + case 3: + if (this->field_0x7a.HWORD >= this->x.HALF.HI) + sub_0802BB10(this); + break; + } + } +} + +void sub_0802BAFC(Entity* this) { + if (!sub_080AF038(this)) { + this->action = 1; + } +} + +void sub_0802BB10(Entity* this) { + this->action = 3; + this->nonPlanarMovement = 0xc0; + this->direction = this->direction ^ 0x10; + EnqueueSFX(0x74); +} + +bool32 sub_0802BB2C(Entity* this, u32 param_2) { + Entity* ent = this->collisionLayer == 2 ? &gUnk_0200D654 : &gUnk_02027EB4; + const s8* ptr = &gUnk_080CD3DC[param_2 >> 2]; + return sub_080AE4CC(ent, this->x.HALF.HI + ptr[0], this->y.HALF.HI + ptr[1], 0); +} + +// clang-format off +void (*const gUnk_080CD3C4[])(Entity*) = { + sub_0802B9EC, + sub_0802BA18, + sub_0802BA8C, + sub_0802BAFC, +}; + +const u16 gUnk_080CD3D4[] = { + 0x100, 0x180, + 0x200, 0x280, +}; + +const s8 gUnk_080CD3DC[] = { + 0, -12, + 12, 0, + 0, 12, + -12, 0, +}; +// clang-format on |
