diff options
| author | notyourav <65437533+notyourav@users.noreply.github.com> | 2022-03-11 09:48:29 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-11 09:48:29 -0800 |
| commit | 5ebbffc50d7679b33074f474d3f49a43aafd57f2 (patch) | |
| tree | 91372f86e40bb929c677e18b586b6985081a0b5e /src/object | |
| parent | db306db638dbef985462a5535a14dda64661515f (diff) | |
| parent | c09f143423955fdca6db1b6bb588c4a11d1d4b67 (diff) | |
Merge pull request #439 from octorock/objects
Diffstat (limited to 'src/object')
| -rw-r--r-- | src/object/chestSpawner.c | 2 | ||||
| -rw-r--r-- | src/object/jailBars.c | 12 | ||||
| -rw-r--r-- | src/object/object11.c | 142 | ||||
| -rw-r--r-- | src/object/object12.c | 98 | ||||
| -rw-r--r-- | src/object/object1E.c | 109 | ||||
| -rw-r--r-- | src/object/object20.c | 91 | ||||
| -rw-r--r-- | src/object/object21.c | 153 | ||||
| -rw-r--r-- | src/object/object30.c | 114 | ||||
| -rw-r--r-- | src/object/object3A.c | 164 | ||||
| -rw-r--r-- | src/object/object3D.c | 117 | ||||
| -rw-r--r-- | src/object/object42.c | 82 | ||||
| -rw-r--r-- | src/object/object4B.c | 118 | ||||
| -rw-r--r-- | src/object/object5B.c | 86 | ||||
| -rw-r--r-- | src/object/object64.c | 120 | ||||
| -rw-r--r-- | src/object/object70.c | 77 | ||||
| -rw-r--r-- | src/object/object74.c | 116 | ||||
| -rw-r--r-- | src/object/objectB.c | 172 | ||||
| -rw-r--r-- | src/object/objectB3.c | 106 | ||||
| -rw-r--r-- | src/object/objectBD.c | 112 | ||||
| -rw-r--r-- | src/object/objectD.c | 70 | ||||
| -rw-r--r-- | src/object/objectE.c | 26 | ||||
| -rw-r--r-- | src/object/paper.c | 78 | ||||
| -rw-r--r-- | src/object/pushableGrave.c | 2 | ||||
| -rw-r--r-- | src/object/stoneTablet.c | 15 |
24 files changed, 2164 insertions, 18 deletions
diff --git a/src/object/chestSpawner.c b/src/object/chestSpawner.c index 20016663..a7890edb 100644 --- a/src/object/chestSpawner.c +++ b/src/object/chestSpawner.c @@ -310,7 +310,7 @@ void sub_080842D8(ChestSpawnerEntity* this) { if ((super->y.HALF.HI & 8) != 0) { index += 2; } - sub_0801AF18((u8*)gUnk_0811F898[index], COORD_TO_TILE(super), super->collisionLayer); + SetMultipleTiles((u16*)gUnk_0811F898[index], COORD_TO_TILE(super), super->collisionLayer); } const Hitbox gUnk_0811F8A8 = { 0, -3, { 0, 0, 0, 0 }, 6, 6 }; diff --git a/src/object/jailBars.c b/src/object/jailBars.c index 7a36f0e2..9983eb1c 100644 --- a/src/object/jailBars.c +++ b/src/object/jailBars.c @@ -8,8 +8,8 @@ extern void sub_080A0960(Entity*, u32); extern void (*const gUnk_08124950[])(Entity*); -extern u8 gUnk_08124960; -extern u8 gUnk_0812497A; +extern u16 gUnk_08124960[]; +extern u16 gUnk_0812497A[]; void JailBars(Entity* this) { gUnk_08124950[this->action](this); @@ -49,11 +49,11 @@ void nullsub_127(Entity* this) { } void sub_080A0960(Entity* this, u32 arg1) { - u8* puVar1; + u16* puVar1; - puVar1 = &gUnk_08124960; + puVar1 = gUnk_08124960; if (arg1 == 1) { - puVar1 = &gUnk_0812497A; + puVar1 = gUnk_0812497A; } - sub_0801AF18(puVar1, COORD_TO_TILE(this), 1); + SetMultipleTiles(puVar1, COORD_TO_TILE(this), 1); } diff --git a/src/object/object11.c b/src/object/object11.c new file mode 100644 index 00000000..ed7de0ed --- /dev/null +++ b/src/object/object11.c @@ -0,0 +1,142 @@ +/** + * @file object11.c + * @ingroup Objects + * + * @brief Object11 object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" +#include "hitbox.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[8]; + /*0x70*/ u16 unk_70; + /*0x72*/ u8 unk_72; +} Object11Entity; + +typedef struct { + u8 unk_0; + u8 unk_1; + u8 unk_2; +} struct_08120588; + +void Object11_Init(Object11Entity*); +void Object11_Action1(Object11Entity*); +void Object11_Action2(Object11Entity*); +void Object11_Action2SubAction0(Object11Entity*); +void Object11_Action2SubAction1(Object11Entity*); +void Object11_Action2SubAction2(Object11Entity*); +void Object11_Action2SubAction3(Object11Entity*); +void Object11_Action2SubAction4(Object11Entity*); +void Object11_Action2SubAction5(Object11Entity*); + +void Object11(Object11Entity* this) { + static void (*const Object11_Actions[])(Object11Entity*) = { + Object11_Init, + Object11_Action1, + Object11_Action2, + }; + if (!EntityIsDeleted(super)) { + Object11_Actions[super->action](this); + } +} + +extern const Hitbox gUnk_081205B4; +void Object11_Init(Object11Entity* this) { + static const struct_08120588 gUnk_08120588[] = { + { 0, 32, 1 }, { 0, 64, 2 }, { 0, 32, 2 }, { 13, 1, 0 }, { 22, 1, 0 }, + }; + if (super->type == 3) { + Object11_Action2SubAction5(this); + } + sub_08004168(super); + if (super->type == 4) { + Object11_Action2SubAction5(this); + } + super->action = 2; + super->flags |= ENT_COLLIDE; + super->spriteRendering.b3 = 2; + super->field_0x1d = gUnk_08120588[super->type].unk_1; + super->field_0x1c = gUnk_08120588[super->type].unk_2; + super->speed = 0x80; + super->collisionLayer = gPlayerEntity.collisionLayer; + super->health = 1; + super->field_0x3c = 7; + super->hitType = 0x6e; + super->flags2 = 4; + super->hitbox = (Hitbox*)&gUnk_081205B4; + this->unk_72 = 0; + this->unk_70 = GetTileIndex(COORD_TO_TILE(super), super->collisionLayer); + SetTile(0x4022, COORD_TO_TILE(super), super->collisionLayer); + InitializeAnimation(super, gUnk_08120588[super->type].unk_0); +} + +void Object11_Action1(Object11Entity* this) { + if (((gPlayerState.field_0x1c & 0xf) != 1) || ((super->bitfield & 0x7f) != 0x13)) { + sub_0807BA8C(COORD_TO_TILE(super), super->collisionLayer); + DeleteThisEntity(); + } +} + +void Object11_Action2(Object11Entity* this) { + static void (*const Object11_Action2SubActions[])(Object11Entity*) = { + Object11_Action2SubAction0, Object11_Action2SubAction1, Object11_Action2SubAction2, + Object11_Action2SubAction3, Object11_Action2SubAction4, Object11_Action2SubAction5, + }; + Object11_Action2SubActions[super->subAction](this); +} + +const Hitbox gUnk_081205B4 = { 0, 0, { 6, 3, 3, 6 }, 6, 6 }; + +void Object11_Action2SubAction0(Object11Entity* this) { + super->subAction = 1; + Object11_Action2SubAction1(this); +} + +void Object11_Action2SubAction1(Object11Entity* this) { + Object11_Action1(this); + sub_0806F4E8(super); + if ((super->field_0x1d != 0) && (--super->field_0x1d == 0)) { + super->subAction = 2; + } +} + +void Object11_Action2SubAction2(Object11Entity* this) { + if (this->unk_72 == 0) { + this->unk_72 = 1; + super->spriteOffsetX = 0; + sub_0807B9B8(this->unk_70, COORD_TO_TILE(super), super->collisionLayer); + } + if (((gPlayerState.field_0x1c & 0xf) != 1) || ((super->bitfield & 0x7f) != 0x13)) { + Object11_Action2SubAction5(this); + } + if (sub_0806F3E4(super) && ((super->field_0x1c & 0xf) == 1)) { + DeleteThisEntity(); + } +} + +void Object11_Action2SubAction3(Object11Entity* this) { +} + +void Object11_Action2SubAction4(Object11Entity* this) { +} + +void Object11_Action2SubAction5(Object11Entity* this) { + switch (super->type2) { + case 0xff: + break; + case 0xf: + CreateFx(super, super->actionDelay, 0x80); + break; + case 0: + break; + default: + CreateObjectWithParent(super, super->type2, super->actionDelay, 0); + break; + } + DeleteThisEntity(); +} diff --git a/src/object/object12.c b/src/object/object12.c new file mode 100644 index 00000000..bc5aa3d6 --- /dev/null +++ b/src/object/object12.c @@ -0,0 +1,98 @@ +/** + * @file object12.c + * @ingroup Objects + * + * @brief Object12 object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" +#include "screen.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[30]; + /*0x86*/ u16 unk_86; +} Object12Entity; + +void Object12_Init(Object12Entity*); +void Object12_Action1(Object12Entity*); +void Object12_Action2(Object12Entity*); +void Object12_Action3(Object12Entity*); +void Object12_Action4(Object12Entity*); +void sub_080850FC(Object12Entity*); + +void Object12(Object12Entity* this) { + static void (*const Object12_Actions[])(Object12Entity*) = { + Object12_Init, Object12_Action1, Object12_Action2, Object12_Action3, Object12_Action4, + }; + Object12_Actions[super->action](this); +} + +void Object12_Init(Object12Entity* this) { + if (super->type == 0) { + if (CheckFlags(this->unk_86)) { + DeleteThisEntity(); + } + super->action = 1; + super->spritePriority.b0 = 7; + sub_080850FC(this); + } else { + super->action = 2; + super->actionDelay = 0xf0; + super->speed = 0x80; + super->direction = 0x18; + } + super->frameIndex = 0; +} + +void Object12_Action1(Object12Entity* this) { +} + +NONMATCH("asm/non_matching/object12/Object12_Action2.inc", void Object12_Action2(Object12Entity* this)) { + u32 tmp; + if (--super->actionDelay == 0) { + super->action = 3; + super->actionDelay = 0x1e; + super->spriteOffsetY = 4; + gScreen.lcd.displayControl |= 0x2000; + gScreen.controls.windowInsideControl = 0x1f; + gScreen.controls.windowOutsideControl = 0xf; + tmp = super->x.HALF.HI - gRoomControls.scroll_x; + gScreen.controls.window0HorizontalDimensions = (((tmp - 0x18) & 0xff) << 8) | ((tmp + 0x18) & 0xff); + tmp = super->y.HALF.HI - gRoomControls.scroll_y; + gScreen.controls.window0VerticalDimensions = (((tmp - 0x18) & 0xff) << 8) | ((tmp + 0x18) & 0xff); + } +} +END_NONMATCH + +void Object12_Action3(Object12Entity* this) { + if (--super->actionDelay == 0) { + super->action = 4; + super->actionDelay = 0x60; + } +} + +void Object12_Action4(Object12Entity* this) { + LinearMoveUpdate(super); + if (--super->actionDelay == 0) { + gScreen.lcd.displayControl &= 0xdfff; + DeleteEntity(super); + } +} + +void sub_080850FC(Object12Entity* this) { + u32 position = COORD_TO_TILE(super); + u32 layer = super->collisionLayer; + SetTile(0x403d, position - 0x41, layer); + SetTile(0x403d, position - 0x40, layer); + SetTile(0x403d, position - 0x3f, layer); + SetTile(0x403d, position - 1, layer); + SetTile(0x403d, position, layer); + SetTile(0x403d, position + 1, layer); + SetTile(0x403d, position + 0x3f, layer); + SetTile(0x403d, position + 0x40, layer); + SetTile(0x403d, position + 0x41, layer); +} diff --git a/src/object/object1E.c b/src/object/object1E.c new file mode 100644 index 00000000..48991a92 --- /dev/null +++ b/src/object/object1E.c @@ -0,0 +1,109 @@ +/** + * @file object1E.c + * @ingroup Objects + * + * @brief Object1E object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" +#include "area.h" + +void sub_08087528(Entity*); +void sub_080875F4(Entity*); +void sub_08087640(Entity*); + +void Object1E(Entity* this) { + static void (*const gUnk_081208B8[])(Entity*) = { + sub_08087528, + sub_080875F4, + }; + if (!EntityIsDeleted(this)) { + gUnk_081208B8[this->action](this); + } +} + +NONMATCH("asm/non_matching/object1E/sub_08087528.inc", void sub_08087528(Entity* this)) { + u32 palette; + + this->action = 1; + this->animationState = gPlayerEntity.animationState >> 1; + this->spriteRendering.b3 = 2; + this->spritePriority.b0 = 3; + this->spriteOrientation.flipY--; + if (this->type2 != 0) { + this->palette.b.b0 = 1; + if (this->animationState == 1) { + this->spriteSettings.flipX = 1; + } + sub_08087640(this); + } else { + if (gArea.locationIndex == 0x10) { + palette = 0x16a; + } else { + palette = 4; + } + ChangeObjPalette(this, palette); + switch (this->animationState) { + case 1: + this->spriteSettings.flipX = 1; + if (this->type == 0x40) { + this->y.HALF.HI += 4; + } + break; + case 3: + if (this->type == 0x40) { + this->y.HALF.HI += 4; + } + break; + default: + if (this->type == 0x40) { + this->spriteSettings.flipX = 1; + } + break; + } + } + SetDefaultPriority(this, 3); + InitializeAnimation(this, this->type2 * 4 + this->animationState); +} +END_NONMATCH + +void sub_080875F4(Entity* this) { + GetNextFrame(this); + if ((this->frame & 0x80) != 0) { + DeleteThisEntity(); + } + if (this->type2 != 0) { + this->spritePriority.b0 = gPlayerEntity.spritePriority.b0 + 1 - this->frame; + } +} + +void sub_08087640(Entity* this) { + static const s8 gUnk_081208C0[] = { 0, -12, 16, 0, 0, 15, -16, 0 }; + s32 oldX; + s32 oldY; + u32 tmp; + const s8* ptr; + + oldX = this->x.HALF.HI; + oldY = this->y.HALF.HI; + ptr = &gUnk_081208C0[this->animationState * 2]; + this->x.HALF.HI += ptr[0]; + this->y.HALF.HI += ptr[1]; + if (gRoomControls.area == 3 && gRoomControls.room == 4) { +#ifdef EU + tmp = 0x18; + } else { + tmp = 0x17; +#else + tmp = 0x17; + } else { + tmp = 0x16; +#endif + } + CreateRandomItemDrop(this, tmp); + this->x.HALF.HI = oldX; + this->y.HALF.HI = oldY; +} diff --git a/src/object/object20.c b/src/object/object20.c new file mode 100644 index 00000000..1cfb4c2c --- /dev/null +++ b/src/object/object20.c @@ -0,0 +1,91 @@ +/** + * @file object20.c + * @ingroup Objects + * + * @brief Object20 object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +void sub_08087824(Entity*); +void sub_08087888(Entity*); +void sub_080878CC(Entity*); + +void (*const gUnk_08120A28[])(Entity*) = { + sub_08087824, + sub_08087888, +}; +const Hitbox3D gUnk_08120A30 = { 0, 0, { 0, 0, 0, 0 }, 6, 6, 10, { 0, 0, 0 } }; +const Hitbox3D gUnk_08120A3C = { 0, 0, { 0, 0, 0, 0 }, 12, 12, 16, { 0, 0, 0 } }; +const Hitbox3D gUnk_08120A48 = { 0, 0, { 0, 0, 0, 0 }, 16, 16, 20, { 0, 0, 0 } }; +const Hitbox3D* const gUnk_08120A54[] = { &gUnk_08120A30, &gUnk_08120A30, &gUnk_08120A48, &gUnk_08120A3C, + &gUnk_08120A3C }; + +void Object20(Entity* this) { + gUnk_08120A28[this->action](this); +} + +void sub_08087824(Entity* this) { + if (this->collisionLayer == 0) { + ResolveCollisionLayer(this); + } + this->action = 1; + this->flags |= 0x80; + this->field_0x3c = 0x13; + this->health = 0xff; + this->hitType = 0xa9; + this->hurtType = 0x16; + this->hitbox = (Hitbox*)gUnk_08120A54[0]; + this->flags2 = 0x8b; + sub_080878CC(this); + InitializeAnimation(this, 1); + sub_0801766C(this); + EnqueueSFX(SFX_ITEM_BOMB_EXPLODE); +} + +void sub_08087888(Entity* this) { + GetNextFrame(this); + if ((this->frame & 0x80) != 0) { + DeleteThisEntity(); + } else { + if (this->frame < 5) { + this->hitbox = (Hitbox*)gUnk_08120A54[this->frame]; + } else { + this->flags &= 0x7f; + } + } +} + +NONMATCH("asm/non_matching/object20/sub_080878CC.inc", void sub_080878CC(Entity* this)) { + s32 x; + s32 y; + s32 itX; + s32 itY; + u32 layer; + u32 tileType; + u32 pos; + + x = this->x.HALF.HI; + y = this->y.HALF.HI; + layer = this->collisionLayer; + for (itX = -0x10; itX < 0x11; itX += 0x10) { + for (itY = -0x10; itY < 0x11; itY += 0x10) { + pos = TILE((u32)x + itX, (u32)y + itY); + if (sub_080B1AE0(pos, layer) == 0x2e) { + tileType = GetTileType(pos, layer); + if (tileType == 0x368 || tileType == 0x367 + /*(tileType < 0x369) && (0x366 < tileType)*/) { + sub_08008796(this, 3, x + itX, y + itY); + } else { + SetTile(0x4022, pos, layer); + } + } else { + sub_08008796(this, 3, x + itX, y + itY); + } + } + } +} +END_NONMATCH diff --git a/src/object/object21.c b/src/object/object21.c new file mode 100644 index 00000000..6641b14c --- /dev/null +++ b/src/object/object21.c @@ -0,0 +1,153 @@ +/** + * @file object21.c + * @ingroup Objects + * + * @brief Object21 object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[0x18]; + /*0x80*/ u32 unk_80; + /*0x84*/ u32 unk_84; +} Object21Entity; + +void sub_08087A10(Object21Entity*); +void sub_08087AFC(Object21Entity*); +void sub_08087B58(Object21Entity*); +void sub_08087B88(Object21Entity*); +void sub_08087B9C(Object21Entity*); +void sub_08087B9C(Object21Entity*); + +void Object21(Object21Entity* this) { + static void (*const gUnk_08120A68[])(Object21Entity*) = { + sub_08087A10, + sub_08087AFC, + NULL, + sub_08087B58, + }; + gUnk_08120A68[super->action](this); + GetNextFrame(super); + if (super->actionDelay != 0) { + super->actionDelay--; + } else { + if (super->animIndex == 0xa) { + InitializeAnimation(super, 0xd); + } else if ((super->frame & 0x80) != 0) { + DeleteThisEntity(); + } + } + if (super->speed != 0) { + LinearMoveUpdate(super); + if (super->speed > 0x10) { + super->speed -= 0x10; + } else { + super->speed = 0; + } + } +} + +extern const Hitbox gUnk_08120A8C; + +void sub_08087A10(Object21Entity* this) { + static const u8 gUnk_08120A78[] = { + 3, + 63, + }; + static const u8 gUnk_08120A7A[] = { + 15, 24, 30, 35, 0, 0, + }; + u32 rand; + u32 tmp; + super->action = 1; + if (super->type2 != 0) { + ChangeObjPalette(super, 3); + } + if (super->type > 2) { + ChangeObjPalette(super, gUnk_08120A78[super->type - 3]); + } + switch (super->type) { + case 4: + super->collisionLayer = 2; + UpdateSpriteForCollisionLayer(super); + case 0: + case 3: + super->flags |= ENT_COLLIDE; + super->health = 1; + super->field_0x3c = 7; + super->hitType = 0xaa; + super->flags2 = 0x0e; + super->hitbox = (Hitbox*)&gUnk_08120A8C; + super->field_0x1c = 0; + case 2: + rand = Random(); + super->actionDelay = gUnk_08120A7A[rand & 3]; + tmp = (rand >> 8) & 3; + if ((rand & 0x10) != 0) { + tmp = -tmp; + } + super->x.HALF.HI += tmp; + super->y.HALF.HI += tmp; + super->collisionLayer = gPlayerEntity.collisionLayer; + InitializeAnimation(super, 10); + return; + case 1: + break; + } + InitializeAnimation(super, 0x10); +} + +void sub_08087AFC(Object21Entity* this) { + Object21Entity* entity; + if ((super->bitfield & 0x80) == 0) { + return; + } + switch (super->bitfield & 0x7f) { + case 0x16: + super->direction = GetFacingDirection(super->field_0x4c, super); + super->speed = 0x100; + break; + case 0x13: + super->action = 3; + super->subAction = 0; + break; + case 0x1b: + case 0x1c: + entity = (Object21Entity*)super->field_0x4c; + super->direction = CalculateDirectionTo(entity->unk_84, entity->unk_80, super->x.WORD, super->y.WORD); + super->speed = 0x100; + break; + } +} + +void sub_08087B58(Object21Entity* this) { + static void (*const gUnk_08120A80[])(Object21Entity*) = { + sub_08087B88, + sub_08087B9C, + sub_08087B9C, + }; + if ((super->bitfield & 0x80) != 0) { + gUnk_08120A80[super->subAction](this); + } else { + super->action = 1; + } +} + +const Hitbox gUnk_08120A8C = { 0, 0, { 6, 3, 3, 6 }, 3, 3 }; + +void sub_08087B88(Object21Entity* this) { + super->knockbackSpeed = 0x100; + super->subAction = 1; + super->field_0x1d = 1; +} + +void sub_08087B9C(Object21Entity* this) { + if (sub_0806F3E4(super)) { + DeleteThisEntity(); + } +} diff --git a/src/object/object30.c b/src/object/object30.c new file mode 100644 index 00000000..dca304b4 --- /dev/null +++ b/src/object/object30.c @@ -0,0 +1,114 @@ +/** + * @file object30.c + * @ingroup Objects + * + * @brief Object30 object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" +#include "item.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u16 unk_68; + /*0x6a*/ u16 unk_6a; + /*0x6c*/ u16* unk_6c; + /*0x70*/ u32 unk_70; +} Object30Entity; + +extern u32 sub_0806F798(Entity*); +extern const Hitbox gUnk_08121C58; + +void Object30_Init(Object30Entity*); +void Object30_Action1(Object30Entity*); +void Object30_Action2(Object30Entity*); +void sub_0808A968(Object30Entity*); + +void Object30(Object30Entity* this) { + static void (*const Object30_Actions[])(Object30Entity*) = { + Object30_Init, + Object30_Action1, + Object30_Action2, + }; + Object30_Actions[super->action](this); + sub_08080CB4(super); +} + +void Object30_Init(Object30Entity* this) { + LayerStruct* data; + const u16* ptr; + switch (super->type) { + case 0: + data = GetLayerByIndex(super->collisionLayer); + ptr = &data->mapData[sub_0806F798(super)]; + this->unk_6c = (u16*)ptr; + this->unk_68 = ptr[0]; + super->action = 1; + break; + case 1: + sub_0808A968(this); + break; + case 2: + case 3: + sub_0808A968(this); + Object30_Action2(this); + break; + } +} + +void Object30_Action1(Object30Entity* this) { + if (this->unk_68 != this->unk_6c[0]) { + sub_0808A968(this); + } +} + +void Object30_Action2(Object30Entity* this) { + static const u8 gUnk_08121194[] = { + 249, 248, 247, 246, 245, 246, 247, 248, + }; + u8 tmp; + switch (super->type) { + case 0: + if (this->unk_70 != 0) { + if (super->zVelocity < 0) { + if (super->z.HALF.HI > -8) { + this->unk_70 = 0; + } else { + if (super->zVelocity < -0x4000) { + this->unk_70 = -0x400; + } else { + this->unk_70 = 0x400; + } + } + } + GravityUpdate(super, this->unk_70); + return; + } + // fallthrough + case 1: + tmp = gUnk_08121194[(super->field_0xf++ >> 3) & 7]; + super->z.HALF.HI = tmp << 0x18 >> 0x18; + if (!IsCollidingPlayer(super)) { + return; + } + break; + } + CreateItemEntity(ITEM_KINSTONE, (u32)super->type2, 0); + DeleteThisEntity(); +} + +void sub_0808A968(Object30Entity* this) { + super->action = 2; + super->actionDelay = 0x1e; + super->spriteSettings.draw = 1; + super->zVelocity = 0x28000; + super->spritePriority.b1 = 3; + super->spriteSettings.shadow = 0; + super->field_0x3c |= 0x10; + super->hitbox = (Hitbox*)&gUnk_08121C58; + SetDefaultPriority(super, 2); + this->unk_70 = 0x2800; +} diff --git a/src/object/object3A.c b/src/object/object3A.c new file mode 100644 index 00000000..568712f6 --- /dev/null +++ b/src/object/object3A.c @@ -0,0 +1,164 @@ +/** + * @file object3A.c + * @ingroup Objects + * + * @brief Object3A object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" +#include "screen.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u16 unk_68; + /*0x6a*/ u16 unk_6a; + /*0x6c*/ u8 unk_6c[0x15]; + /*0x81*/ u8 unk_81; + /*0x82*/ s8 unk_82; + /*0x83*/ u8 unk_83; + /*0x84*/ u8 unk_84; + /*0x85*/ s8 unk_85; + /*0x86*/ s16 unk_86; +} Object3AEntity; + +typedef struct { + u16 unk_0; + u16 unk_1; + u16 unk_2; + s16 unk_3; + u16 unk_4; + u16 unk_5; + s16 unk_6; + u16 unk_7; + u16 unk_8; + u16 unk_9; +} struct_081215E8; + +extern void sub_0801E49C(u32, u32, u32, u32); +extern bool32 gUnk_02036BB8; + +void sub_0808C6D4(Object3AEntity*); +void sub_0808C74C(Object3AEntity*); +void sub_0808C858(Object3AEntity*); +void sub_0808C8B8(Object3AEntity*); +void sub_0808C840(Object3AEntity*); + +const struct_081215E8 gUnk_081215E8[] = { + { 5, 4, 280, -6, 0, 0, -8, 0, 31, 63 }, + { 6, 2, 0, 4, 0, 0, 8, 0, 63, 31 }, + { 7, 4, 0, 4, 0, 0, -6, 0, 63, 31 }, + { 6, 2, 0, 16, 0, 0, 16, 0, 63, 31 }, +}; + +void Object3A(Object3AEntity* this) { + static void (*const gUnk_08121638[])(Object3AEntity*) = { + sub_0808C6D4, + sub_0808C74C, + }; + static void (*const gUnk_08121640[])(Object3AEntity*) = { + sub_0808C858, + sub_0808C8B8, + }; + + if (super->type == 0) { + gUnk_08121638[super->action](this); + } else { + gUnk_08121640[super->action](this); + } +} + +void sub_0808C6D4(Object3AEntity* this) { + Object3AEntity* obj; + const struct_081215E8* ptr = &gUnk_081215E8[super->type2]; + this->unk_86 = ptr->unk_2; + this->unk_85 = ptr->unk_3; + this->unk_84 = ptr->unk_4; + this->unk_83 = ptr->unk_5; + this->unk_82 = ptr->unk_6; + this->unk_81 = ptr->unk_7; + sub_0801E1B8((gScreen.controls.windowInsideControl & 0xff00) | ptr->unk_8, ptr->unk_9); + super->action = 1; + sub_0808C74C(this); + obj = (Object3AEntity*)CreateObject(OBJECT_3A, 1, ptr->unk_0); + if (obj != NULL) { + obj->unk_6a = ptr->unk_1; + } +} + +void sub_0808C74C(Object3AEntity* this) { + if (super->parent != NULL) { + super->x.HALF.HI = super->parent->x.HALF.HI - gRoomControls.scroll_x; + super->y.HALF.HI = super->parent->y.HALF.HI - gRoomControls.scroll_y; + } else { + super->x.HALF.HI = 0x78; + super->y.HALF.HI = 0x50; + } + if (this->unk_86 < 0) { + sub_0801E49C(super->x.HALF.HI, super->y.HALF.HI, 0, 0); + gUnk_02036BB8 = TRUE; + sub_0808C840(this); + } + if (this->unk_86 > 500) { + sub_0801E49C(super->x.HALF.HI, super->y.HALF.HI, 500, 0); + gUnk_02036BB8 = 1; + sub_0808C840(this); + } + this->unk_86 += this->unk_85; + this->unk_85 += this->unk_84; + if (this->unk_85 > 0x10) { + this->unk_85 = 0x10; + } + if (this->unk_85 < -0x10) { + this->unk_85 = 0xf0; + } + this->unk_83 += this->unk_82; + this->unk_82 += this->unk_81; + if (this->unk_82 > 0x10) { + this->unk_82 = 0x10; + } + if (this->unk_82 < -0x10) { + this->unk_82 = -0x10; + } + sub_0801E49C(super->x.HALF.HI, super->y.HALF.HI, this->unk_86, this->unk_83); +} + +void sub_0808C840(Object3AEntity* this) { + gScreen.controls.layerFXControl = 0; + sub_0801E104(); + DeleteThisEntity(); +} + +void sub_0808C858(Object3AEntity* this) { + if ((super->type2 & 2) != 0) { + gScreen.controls.layerFXControl = 0x3fbf; + } else { + gScreen.controls.layerFXControl = 0x3fff; + } + if ((super->type2 & 1) != 0) { + gScreen.controls.layerBrightness = 0; + } else { + gScreen.controls.layerBrightness = 0x10; + } + super->action = 1; + this->unk_68 = 0x100; +} + +void sub_0808C8B8(Object3AEntity* this) { + s32 tmp = this->unk_68 -= this->unk_6a; + if (tmp * 0x10000 < 0) { + this->unk_68 = 0; + } + if ((super->type2 & 1) != 0) { + gScreen.controls.layerBrightness = 0x10 - ((s16)this->unk_68 >> 4); + } else { + gScreen.controls.layerBrightness = (s16)this->unk_68 >> 4; + } + if ((s16)this->unk_68 == 0) { + DeleteThisEntity(); + } +} + +const u16 gUnk_08121648[] = { 264, 252, 256, 256, 248, 260, 240, 264, 248, 260, 256, 256, 264, 252, 272, 248 }; diff --git a/src/object/object3D.c b/src/object/object3D.c new file mode 100644 index 00000000..0416ac2c --- /dev/null +++ b/src/object/object3D.c @@ -0,0 +1,117 @@ +/** + * @file object3D.c + * @ingroup Objects + * + * @brief Object3D object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" +#include "area.h" +#include "screen.h" +#include "main.h" +#include "structures.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u16 unk_68; +} Object3DEntity; + +void Object3D_Init(Object3DEntity*); +void Object3D_Action1(Object3DEntity*); +void Object3D_Action2(Object3DEntity*); +void sub_0808D030(void); + +void Object3D(Object3DEntity* this) { + static void (*const Object3D_Actions[])(Object3DEntity*) = { + Object3D_Init, + Object3D_Action1, + Object3D_Action2, + }; + Object3D_Actions[super->action](this); +} + +void Object3D_Init(Object3DEntity* this) { + super->action = 1; + super->x.HALF.HI = gArea.curPortalX - gRoomControls.scroll_x; + super->y.HALF.HI = gArea.curPortalY - gRoomControls.scroll_y; + this->unk_68 = 0x80; + super->updatePriority = 6; + sub_0801E1B8(0x1f17, 0); + sub_0801E1EC(super->x.HALF.HI, super->y.HALF.HI, this->unk_68); +} + +void Object3D_Action1(Object3DEntity* this) { +#ifdef EU + static const u16 gUnk_081216C8[] = { 206, 19, 333, 208, 16, 333, 207, 1, 333, 0 }; +#else + static const u16 gUnk_081216C8[] = { 206, 19, 334, 208, 16, 334, 207, 1, 334, 0 }; +#endif + const u16* ptr; + this->unk_68 -= 2; + if (this->unk_68 >= 0x15) { + sub_0801E1EC(super->x.HALF.HI, super->y.HALF.HI, this->unk_68); + } else { + gScreen.controls.windowOutsideControl = 0x10; + sub_0808D030(); + ResetPaletteTable(0); + ResetPalettes(); + gGFXSlots.unk0 = 1; + ptr = &gUnk_081216C8[super->type * 3]; + LoadFixedGFX(super, ptr[0]); + LoadObjPalette(super, ptr[1]); + super->spriteIndex = ptr[2]; + if (super->type == 2) { + super->frameIndex = 2; + } + super->action = 2; + super->spriteSettings.draw = 2; + super->spriteOrientation.flipY = 0; + super->spriteRendering.b3 = 0; + super->spritePriority.b0 = 0; + super->actionDelay = 0x1e; + super->field_0xf = 0xff; + super->spriteRendering.b0 = 3; + sub_0805EC9C(super, 0x100, 0x100, 0); + gArea.field_0x10 = 1; + SetFade(5, 8); + } +} + +void sub_0808D030(void) { + struct OamData* ptr; + s32 index; + + ptr = gOAMControls.oam; + index = 0x80; + MemClear(&gOAMControls, 0xb74); + while (index != 0) { + // TODO split up into bitfield writes? + *(u16*)ptr = 0x2a0; + ptr++; + index--; + } + gOAMControls.field_0x0 = 1; +} + +void Object3D_Action2(Object3DEntity* this) { + u32 tmp = super->actionDelay--; + if (tmp != 0) { + if (this->unk_68 != 0) { + this->unk_68 -= 2; + } else { + this->unk_68 = 0; + } + sub_0801E1EC(super->x.HALF.HI, super->y.HALF.HI, this->unk_68); + if (0x80 < super->field_0xf) { + super->field_0xf -= 8; + } + sub_0805EC9C(super, super->field_0xf, super->field_0xf, 0); + } else { + gArea.filler3[0]++; + gArea.field_0x10 = 0; + DeleteThisEntity(); + } +} diff --git a/src/object/object42.c b/src/object/object42.c new file mode 100644 index 00000000..28a5df5c --- /dev/null +++ b/src/object/object42.c @@ -0,0 +1,82 @@ +/** + * @file object42.c + * @ingroup Objects + * + * @brief Object42 object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[4]; + /*0x6c*/ u16 unk_6c; +} Object42Entity; + +void sub_0808DDB4(Object42Entity*); +void sub_0808DDE0(Object42Entity*); +void sub_0808DDE8(Object42Entity*); + +void Object42(Object42Entity* this) { + static void (*const gUnk_081217A8[])(Object42Entity*) = { + sub_0808DDB4, + sub_0808DDE0, + }; + static void (*const gUnk_081217B0[])(Object42Entity*) = { + sub_0808DDB4, + sub_0808DDE8, + }; + if (super->type != 0) { + gUnk_081217B0[super->action](this); + } else { + gUnk_081217A8[super->action](this); + } +} + +void sub_0808DDB4(Object42Entity* this) { + super->action = 1; + if (super->type != 0) { + super->actionDelay = 0x78; + this->unk_6c = 0xf0; + InitializeAnimation(super, 0); + sub_0808DDE8(this); + } +} + +void sub_0808DDE0(Object42Entity* this) { + DeleteThisEntity(); +} + +void sub_0808DDE8(Object42Entity* this) { + static const s8 gUnk_081217B8[] = { 0, -6, 0, 6 }; + Entity* player; + this->unk_6c--; + if (sub_0807953C()) { + super->field_0xf++; + } + if (((0x1e < super->field_0xf) || ((gPlayerState.flags & 0x1810) != 0)) || (this->unk_6c == 0)) { + gPlayerState.flags &= 0xfffffbff; + DeleteThisEntity(); + } + player = &gPlayerEntity; + super->x.HALF.HI = (s8)gUnk_081217B8[gPlayerEntity.animationState >> 1] + player->x.HALF.HI; + super->y.HALF.HI = gPlayerEntity.y.HALF.HI + -6; + super->z = gPlayerEntity.z; + super->collisionLayer = gPlayerEntity.collisionLayer; + super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; + super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; + if ((gPlayerState.flags & 0x400) != 0) { + GetNextFrame(super); + } else { + DeleteThisEntity(); + } + if (gPlayerEntity.animationState >> 1 == 2) { + sub_0806FEBC(&gPlayerEntity, 3, super); + super->y.HALF.HI -= 5; + } else { + sub_0806FEBC(&gPlayerEntity, 0, super); + } +} diff --git a/src/object/object4B.c b/src/object/object4B.c new file mode 100644 index 00000000..7e76e856 --- /dev/null +++ b/src/object/object4B.c @@ -0,0 +1,118 @@ +/** + * @file object4B.c + * @ingroup Objects + * + * @brief Object4B object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" +#include "menu.h" + +typedef struct { + /*0x00*/ Entity base; +} Object4BEntity; + +void Object4B_Init(Object4BEntity*); +void Object4B_Action1(Object4BEntity*); +void Object4B_Action2(Object4BEntity*); +void Object4B_Action3(Object4BEntity*); +void Object4B_Action4(Object4BEntity*); +void Object4B_Action5(Object4BEntity*); +void Object4B_Action6(Object4BEntity*); +void Object4B_Action7(Object4BEntity*); + +void Object4B(Object4BEntity* this) { + static void (*const Object4B_Actions[])(Object4BEntity*) = { + Object4B_Init, Object4B_Action1, Object4B_Action2, Object4B_Action3, + Object4B_Action4, Object4B_Action5, Object4B_Action6, Object4B_Action7, + }; + Object4B_Actions[super->action](this); +} + +void Object4B_Init(Object4BEntity* this) { + super->action = 1; + super->actionDelay = 0x3c; + InitializeAnimation(super, 0); +} + +void Object4B_Action1(Object4BEntity* this) { + if (--super->actionDelay == 0) { + super->actionDelay = 0x78; + super->action++; + super->spriteSettings.draw = 1; + } +} + +void Object4B_Action2(Object4BEntity* this) { + GetNextFrame(super); + if ((super->frame & 0x80) != 0) { + super->action++; + super->spritePriority.b1 = 3; + InitializeAnimation(super, 2); + } +} + +void Object4B_Action3(Object4BEntity* this) { + GetNextFrame(super); + if (--super->actionDelay == 0) { + super->action++; + super->direction = 0; + super->speed = 0x100; + super->zVelocity = 0x20000; + super->spriteOrientation.flipY = 0; + super->actionDelay = 0; + InitializeAnimation(super, 3); + SoundReq(SFX_12B); + } +} + +void Object4B_Action4(Object4BEntity* this) { + if ((super->frame & 0x10) != 0) { + LinearMoveUpdate(super); + if (GravityUpdate(super, 0x2000) == 0) { + GetNextFrame(super); + } + } else { + GetNextFrame(super); + } + if ((super->y.HALF.HI - gRoomControls.origin_y) < 0x231) { + super->y.HALF.HI = gRoomControls.origin_y + 0x230; + if ((super->frame & 0x80) != 0) { + super->action++; + super->actionDelay = 0x78; + InitializeAnimation(super, 2); + } + } else if ((super->frame & 0x80) != 0) { + super->zVelocity = 0x20000; + InitializeAnimation(super, 3); + SoundReq(SFX_12B); + } +} + +void Object4B_Action5(Object4BEntity* this) { + GetNextFrame(super); + if (--super->actionDelay == 0) { + super->action++; + InitializeAnimation(super, 5); + } +} + +void Object4B_Action6(Object4BEntity* this) { + GetNextFrame(super); + if ((super->frame & 0x80) != 0) { + super->action++; + super->actionDelay = 0x3c; + InitializeAnimation(super, 1); + } +} + +void Object4B_Action7(Object4BEntity* this) { + GetNextFrame(super); + if (--super->actionDelay == 0) { + gMenu.overlayType++; + DeleteThisEntity(); + } +} diff --git a/src/object/object5B.c b/src/object/object5B.c new file mode 100644 index 00000000..01c324d7 --- /dev/null +++ b/src/object/object5B.c @@ -0,0 +1,86 @@ +/** + * @file object5B.c + * @ingroup Objects + * + * @brief Object5B object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[0x1a]; + /*0x82*/ u16 unk_82; + /*0x84*/ ScriptExecutionContext* unk_84; +} Object5BEntity; + +void sub_080928C8(Object5BEntity*); +void nullsub_119(Object5BEntity*); +void sub_08092930(Object5BEntity*); +void sub_08092940(Object5BEntity*); +void sub_08092958(Object5BEntity*, ScriptExecutionContext*); + +void Object5B(Object5BEntity* this) { + static void (*const gUnk_08122794[])(Object5BEntity*) = { + sub_080928C8, + nullsub_119, + }; + static void (*const gUnk_0812279C[])(Object5BEntity*) = { + sub_08092930, + sub_08092940, + }; + if ((super->flags & 2) != 0) { + gUnk_0812279C[super->action](this); + } else { + gUnk_08122794[super->action](this); + } +} + +void sub_080928C8(Object5BEntity* this) { + super->action = 1; + super->spriteSettings.draw = 1; + super->frameIndex = super->type; + super->spriteRendering.b3 = 3; + super->spritePriority.b0 = 6; + super->spriteOrientation.flipY = 2; + switch (super->type) { + case 2: + CreateObjectWithParent(super, OBJECT_5B, 4, 0); + break; + case 4: + super->spritePriority.b0 = 7; + break; + } +} + +void nullsub_119(Object5BEntity* this) { +} + +void sub_08092930(Object5BEntity* this) { + sub_080928C8(this); + this->unk_82 = 0; +} + +void sub_08092940(Object5BEntity* this) { + ExecuteScript(super, this->unk_84); + sub_08092958(this, this->unk_84); +} + +void sub_08092958(Object5BEntity* this, ScriptExecutionContext* context) { + u32 tmp; + while (context->postScriptActions != 0) { + tmp = (~context->postScriptActions + 1) & context->postScriptActions; + context->postScriptActions = context->postScriptActions ^ tmp; + switch (tmp) { + case 1: + super->frameIndex = 0; + break; + case 2: + super->frameIndex = context->intVariable; + break; + } + } +} diff --git a/src/object/object64.c b/src/object/object64.c new file mode 100644 index 00000000..a536c556 --- /dev/null +++ b/src/object/object64.c @@ -0,0 +1,120 @@ +/** + * @file object64.c + * @ingroup Objects + * + * @brief Object64 object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +typedef struct { + /*0x00*/ Entity base; +} Object64Entity; + +void sub_08093E3C(Object64Entity*); +void sub_08093EAC(Object64Entity*); +void sub_08093ED0(Object64Entity*); +void sub_08093EF0(Object64Entity*); + +typedef struct { + u16 unk_0; + u8 unk_2; + u8 unk_3; +} struct_08122950; + +const struct_08122950 gUnk_08122950[] = { + { 244, 31, 0 }, + { 0, 31, 0 }, + { 0, 31, 0 }, +}; + +void Object64(Object64Entity* this) { + static void (*const gUnk_0812295C[])(Object64Entity*) = { + sub_08093E3C, + sub_08093EAC, + }; + gUnk_0812295C[super->action](this); +} + +void sub_08093E3C(Object64Entity* this) { + const u16* ptr; + super->action = 1; + super->flags &= 0x7f; + super->spriteSettings.draw = 1; + if (super->collisionLayer == 0) { + ResolveCollisionLayer(super); + } + InitializeAnimation(super, super->type); + ptr = &gUnk_08122950[super->type].unk_0; + if ((ptr[0] != 0) && ((super->type2 & 0x40) == 0)) { + EnqueueSFX(ptr[0]); + } + if ((super->type2 & 0x20) != 0) { + super->spriteRendering.b3 = 1; + } +} + +void sub_08093EAC(Object64Entity* this) { + static void (*const gUnk_08122964[])(Object64Entity*) = { + sub_08093ED0, + sub_08093EF0, + }; + gUnk_08122964[gUnk_08122950[super->type].unk_2 >> 4](this); +} + +void sub_08093ED0(Object64Entity* this) { + GetNextFrame(super); + if ((super->frame & 0x80) != 0) { + DeleteEntity(super); + } +} + +void sub_08093EF0(Object64Entity* this) { + Entity* object; + switch (super->type) { + case 0: + if (super->subAction != 0) { + return; + } + GetNextFrame(super); + if ((super->frame & 0x80) == 0) { + return; + } + object = CreateObject(OBJECT_64, 1, 0); + if (object != NULL) { + object->parent = super->parent; + CopyPosition(super, object); + } + DeleteThisEntity(); + break; + case 1: + GetNextFrame(super); + if ((super->frame & 1) != 0) { + super->frame = 0; + object = CreateObject(OBJECT_64, 2, 0); + if (object != NULL) { + object->parent = super->parent; + CopyPosition(super, object); + } + } + if ((super->frame & 0x80) == 0) { + return; + } + if (super->parent == &gPlayerEntity) { + SoundReq(SFX_PLY_VO6); + sub_08079D84(); + } + DeleteThisEntity(); + break; + case 2: + GetNextFrame(super); + if ((super->frame & 0x80) == 0) { + return; + } + DeleteThisEntity(); + break; + } +} diff --git a/src/object/object70.c b/src/object/object70.c new file mode 100644 index 00000000..fa0a4bb4 --- /dev/null +++ b/src/object/object70.c @@ -0,0 +1,77 @@ +/** + * @file object70.c + * @ingroup Objects + * + * @brief Object70 object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +void Object70_Init(Entity*); +void Object70_Action1(Entity*); + +void Object70(Entity* this) { + static void (*const Object70_Actions[])(Entity*) = { + Object70_Init, + Object70_Action1, + }; + Object70_Actions[this->action](this); +} + +void Object70_Init(Entity* this) { + this->action = 1; + this->spriteSettings.draw = 1; + this->frameIndex = this->type + 0xb; + if (this->type != 0) { + sub_08004168(this); + gPlayerEntity.spriteOrientation.flipY = 3; + if ((gPlayerEntity.spritePriority.b0) != 7) { + this->spritePriority.b0 = gPlayerEntity.spritePriority.b0 + 1; + } else { + this->spritePriority.b0 = 7; + } + } +} + +void Object70_Action1(Entity* this) { + u8 bVar1; + + if (this->type == 0) { + if (gPlayerEntity.z.WORD == 0) { + if ((((gPlayerState.dash_state & 0x40) == 0) && (gPlayerState.floor_type == 0x11)) && + ((gPlayerEntity.action == 1 || ((gPlayerEntity.action == 0x18 || (gPlayerEntity.action == 4)))))) { + goto _080974FA; + } else { + if (gPlayerEntity.z.WORD == 0) { + CreateFx(&gPlayerEntity, FX_GREEN_SPLASH, 0); + } + } + } + gPlayerEntity.spriteOrientation.flipY = 2; + DeleteThisEntity(); + _080974FA: + this->x = gPlayerEntity.x; + this->y = gPlayerEntity.y; + if (gPlayerState.jump_status == 0) { + gPlayerEntity.spriteOrientation.flipY = 3; + if (gPlayerEntity.spritePriority.b0 != 7) { + this->spritePriority.b0 = gPlayerEntity.spritePriority.b0 + 1; + } else { + this->spritePriority.b0 = 7; + } + } + + } else { + if (gPlayerEntity.action != 0x1e) { + if (this->collisionLayer == 1) { + gPlayerEntity.spriteOrientation.flipY = 2; + } else { + gPlayerEntity.spriteOrientation.flipY = 1; + } + DeleteThisEntity(); + } + } +} diff --git a/src/object/object74.c b/src/object/object74.c new file mode 100644 index 00000000..e3c4111c --- /dev/null +++ b/src/object/object74.c @@ -0,0 +1,116 @@ +/** + * @file object74.c + * @ingroup Objects + * + * @brief Object74 object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" +#include "screen.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[0x1e]; + /*0x86*/ u16 unk_86; +} Object74Entity; + +void sub_08097B84(Object74Entity*); +void sub_08097BDC(Object74Entity*); +void sub_08097C18(Object74Entity*); +void sub_08097C20(Object74Entity*); +void sub_08097C1C(Object74Entity*); +void sub_08097CFC(Object74Entity*); +bool32 sub_08097CB0(Object74Entity*); +void sub_08097CB4(Object74Entity*); + +const Hitbox gUnk_08123328 = { 0, 0, { 4, 0, 0, 4 }, 18, 18 }; + +void Object74(Object74Entity* this) { + static void (*const gUnk_08123330[])(Object74Entity*) = { + sub_08097B84, sub_08097BDC, sub_08097C18, sub_08097C20, sub_08097C1C, + }; + gUnk_08123330[super->action](this); +} + +void sub_08097B84(Object74Entity* this) { + super->action = 1; + super->spritePriority.b0 = 7; + super->hitbox = (Hitbox*)&gUnk_08123328; + if ((this->unk_86 == 0xffff) || (CheckFlags(this->unk_86))) { + super->spriteSettings.draw = 1; + super->action = 4; + sub_08097CFC(this); + } else { + sub_0805BC4C(); + } +} + +void sub_08097BDC(Object74Entity* this) { + if (CheckFlags(this->unk_86)) { + SetPlayerControl(CONTROL_1); + gUnk_02034490.unk0 = 1; + RequestPriorityDuration(super, 0x1e); + if (sub_08097CB0(this) == FALSE) { + sub_08097CB4(this); + } + } +} + +void sub_08097C18(Object74Entity* this) { +} + +void sub_08097C1C(Object74Entity* this) { +} + +void sub_08097C20(Object74Entity* this) { + u32 tmp; + SetPriorityTimer(0x1e); + sub_0800445C(super); + CreateMagicSparkles(super->x.HALF.HI, super->y.HALF.HI, super->collisionLayer); + if (--super->actionDelay == 0) { + super->actionDelay = 8; + tmp = ++super->field_0xf; + gScreen.controls.alphaBlend = (((0x10 - tmp) * 0x100)) | tmp; + if (gScreen.controls.alphaBlend == 0x10) { + SetPlayerControl(CONTROL_ENABLED); + gUnk_02034490.unk0 = 0; + gScreen.controls.layerFXControl = 0; + sub_08097CFC(this); + super->action = 4; + super->spriteRendering.alphaBlend = 0; + SoundReq(SFX_SECRET); + SetGlobalFlag(TINY_ENTRANCE); + } + } +} + +bool32 sub_08097CB0(Object74Entity* this) { + return FALSE; +} + +void sub_08097CB4(Object74Entity* this) { + super->action = 3; + super->spriteSettings.draw = 1; + super->spriteRendering.alphaBlend = 1; + super->actionDelay = 0x1e; + super->field_0xf = 0; + gScreen.controls.layerFXControl = 0xf40; + gScreen.controls.alphaBlend = 0x1000; + SoundReq(SFX_14A); +} + +void sub_08097CFC(Object74Entity* this) { + static const u16 gUnk_08123344[] = { 16448, 65471, 16449, 65472, 16450, 65473, 16451, 65535, 16452, 0, + 16453, 1, 16454, 63, 16455, 64, 16456, 65, 65535 }; + static const u16 gUnk_0812336A[] = { + 16449, 65471, 16449, 65472, 16452, 65535, 16452, 0, 16455, 63, 16455, 64, 65535 + }; + if ((super->x.HALF.HI & 0xf) == 0) { + SetMultipleTiles((u16*)gUnk_0812336A, COORD_TO_TILE(super), super->collisionLayer); + } else { + SetMultipleTiles((u16*)gUnk_08123344, COORD_TO_TILE(super), super->collisionLayer); + } +} diff --git a/src/object/objectB.c b/src/object/objectB.c new file mode 100644 index 00000000..f0cfc4e5 --- /dev/null +++ b/src/object/objectB.c @@ -0,0 +1,172 @@ +/** + * @file objectB.c + * @ingroup Objects + * + * @brief ObjectB object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" +#include "itemMetaData.h" +#include "message.h" +#include "save.h" +#include "game.h" +#include "item.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u16 unk_68; +} ObjectBEntity; + +typedef struct { + u8 unk_0[6]; + u16 unk_6; +} struct_080FD964; +extern const struct_080FD964 gUnk_080FD964[]; +extern const u16 gUnk_080FD5B4[]; + +void ObjectB_Init(ObjectBEntity*); +void ObjectB_Action1(ObjectBEntity*); +void ObjectB_Action2(ObjectBEntity*); +void ObjectB_Action3(ObjectBEntity*); + +void ObjectB(ObjectBEntity* this) { + static void (*const ObjectB_Actions[])(ObjectBEntity*) = { ObjectB_Init, ObjectB_Action1, ObjectB_Action2, + ObjectB_Action3 }; + u32 tmp; + ObjectB_Actions[super->action](this); + tmp = (super->parent->frame >> 6); + super->spriteSettings.draw = tmp & 1; + sub_08080CB4(super); + super->spritePriority.b1 = 0; + super->spriteOrientation.flipY = 1; + super->spriteRendering.b3 = 0; +} + +void ObjectB_Init(ObjectBEntity* this) { + SetDefaultPriority(super, 6); + super->action = 1; +} + +void ObjectB_Action1(ObjectBEntity* this) { + u32 tmp; + const ItemMetaData* ptr; + + if ((super->parent)->frame != 0x41) { + return; + } + super->action = 2; + switch (super->actionDelay) { + case 0: + case 1: + this->unk_68 = GiveItem(super->type, super->type2); + switch (super->type) { + case 0x40: + case 0x41: + case 0x42: + case 0x43: + break; + default: + SoundReq(SFX_109); + break; + } + break; + case 2: + GiveItem(super->type, super->type2); + this->unk_68 = gUnk_080FD964[super->type].unk_6; + SoundReq(SFX_109); + break; + case 5: + tmp = GetInventoryValue((u32)super->type); + ptr = &gItemMetaData[super->type]; + if (tmp == 0) { + this->unk_68 = *(u16*)&ptr->unk4; + } else { + this->unk_68 = *(u16*)&ptr->unk6; + } + return; + case 3: + case 4: + default: + return; + } +} + +void ObjectB_Action2(ObjectBEntity* this) { + u32 messageIndex; + if ((super->parent)->frame == 0x42) { + super->action = 3; + switch (super->actionDelay) { + case 1: + case 3: + case 4: + default: + break; + case 0: + case 2: + case 5: + messageIndex = this->unk_68; + if (messageIndex != 0) { + switch (super->type) { + case 0x63: + messageIndex += gSave.stats.heartPieces; + break; + case 0x3f: + if (super->type2 > 1) { + if (messageIndex == 0x577) { + messageIndex--; + } else { + messageIndex++; + } + } + break; + } + MessageFromTarget(messageIndex); + gMessage.field_0x10 = super->type2; + } + } + } +} + +void ObjectB_Action3(ObjectBEntity* this) { + u32 tmp; + if ((super->parent)->action == 8) { + return; + } + switch (super->actionDelay) { + case 0: + case 1: + case 2: + if (super->type != 0x62) { + if (super->type != 0x63) { + break; + } + ModHealth(0xa0); + gSave.stats.heartPieces++; + if (gSave.stats.heartPieces < 4) { + break; + } + gSave.stats.heartPieces = 0; + } + gSave.stats.maxHealth += 8; + if (gSave.stats.maxHealth > 0xa0) { + gSave.stats.maxHealth = 0xa0; + } + ModHealth(0xa0); + break; + case 3: + tmp = GetBottleContaining(super->type); + if (tmp != 0) { + gSave.stats.itemButtons[tmp + 1] = 0x20; + } else { + SetInventoryValue(super->type, ITEM_GREEN_SWORD); + } + break; + case 4: + case 5: + break; + } + DeleteThisEntity(); +} diff --git a/src/object/objectB3.c b/src/object/objectB3.c new file mode 100644 index 00000000..770d4e27 --- /dev/null +++ b/src/object/objectB3.c @@ -0,0 +1,106 @@ +/** + * @file objectB3.c + * @ingroup Objects + * + * @brief ObjectB3 object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" +#include "kinstone.h" + +void sub_080A0ADC(Entity*); +void sub_080A0AF0(Entity*); +void sub_080A0AC4(Entity*); +void sub_080A0AD0(Entity*); +void sub_080A0B4C(Entity*); +void sub_080A0B60(Entity*); +void sub_080A0B80(Entity*); + +void ObjectB3(Entity* this) { + static void (*const gUnk_08124A10[])(Entity*) = { + sub_080A0ADC, + sub_080A0AF0, + }; + static void (*const gUnk_08124A18[])(Entity*) = { + sub_080A0AC4, + sub_080A0AD0, + }; + static void (*const gUnk_08124A20[])(Entity*) = { + sub_080A0B4C, + sub_080A0B60, + sub_080A0B80, + }; + void (*const* ptr)(Entity*); + + switch (this->type) { + case 0: + if ((this->flags & 2) != 0) { + ptr = gUnk_08124A10; + } else { + ptr = gUnk_08124A18; + } + break; + case 1: + ptr = gUnk_08124A20; + break; + } + ptr[this->action](this); + if (this->action == 0) { + this->action = 1; + this->spriteRendering.b3 = 1; + this->spritePriority.b0 = 0; + this->spriteOrientation.flipY = 1; + ChangeObjPalette(this, gUnk_080C9CBC[gFuseInfo._3].unk0); + } + GetNextFrame(this); +} + +void sub_080A0AC4(Entity* this) { + InitializeAnimation(this, this->type); +} + +void sub_080A0AD0(Entity* this) { + GravityUpdate(this, 0x80); +} + +void sub_080A0ADC(Entity* this) { + sub_0807DD64(this); + ExecuteScriptForEntity(this, NULL); +} + +void sub_080A0AF0(Entity* this) { + ExecuteScriptForEntity(this, NULL); + GetNextFrame(this); + if (this->animIndex == 5) { + if ((this->frame & 0x80) != 0) { + DeleteThisEntity(); + } + } + GravityUpdate(this, 0x80); +} + +void sub_080A0B28(Entity* this, ScriptExecutionContext* context) { + sub_0807DEDC(this, context, this->x.HALF.HI, this->y.HALF.HI); + this->y.HALF.HI -= 0xb0; + this->spriteSettings.draw = 0; +} + +void sub_080A0B4C(Entity* this) { + this->x.HALF.HI = 0x78; + this->y.HALF.HI = 0x50; + InitializeAnimation(this, 0); +} + +void sub_080A0B60(Entity* this) { + if ((this->frame & 0x40) != 0) { + this->action = 2; + SoundReq(SFX_136); + } +} + +void sub_080A0B80(Entity* this) { + this->y.WORD -= 0x28000; +} diff --git a/src/object/objectBD.c b/src/object/objectBD.c new file mode 100644 index 00000000..6e12c57c --- /dev/null +++ b/src/object/objectBD.c @@ -0,0 +1,112 @@ +/** + * @file objectBD.c + * @ingroup Objects + * + * @brief ObjectBD object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +void sub_080A2274(Entity*); +void sub_080A22B0(Entity*); +void sub_080A22C4(Entity*); +void sub_080A2340(Entity*); + +typedef struct { + u16 unk_0; + u16 unk_2; + u16 unk_4; + u8 unk_6; + u8 pad; +} struct_08125014; + +const struct_08125014 gUnk_08125014[] = { + { 120, 48, 16, 4, 0 }, { 136, 81, 22, 3, 0 }, { 190, 20, 25, 2, 0 }, { 192, 81, 26, 2, 0 }, { 32, 104, 27, 3, 0 }, +}; + +void ObjectBD(Entity* this) { + static void (*const gUnk_0812503C[])(Entity*) = { + sub_080A2274, sub_080A22B0, sub_080A22B0, sub_080A22B0, sub_080A22C4, + }; + gUnk_0812503C[this->type](this); +} + +void sub_080A2274(Entity* this) { + u32 addr; + u32 type; + + if (this->action == 0) { + sub_080A2340(this); + CreateObject(OBJECT_BD, 1, 0); + addr = 0x02000000; // TODO write to 0x2000007 + if (*(u8*)(addr + 7) == 1) { + type = 2; + } else { + type = 3; + } + CreateObject(OBJECT_BD, type, 0); + CreateObject(OBJECT_BD, 4, 0); + } +} + +void sub_080A22B0(Entity* this) { + if (this->action == 0) { + sub_080A2340(this); + } +} + +NONMATCH("asm/non_matching/objectBD/sub_080A22C4.inc", void sub_080A22C4(Entity* this)) { + u8 bVar1; + u8 uVar2; + s16 sVar3; + u32 uVar4; + u32 tmp1, tmp2, tmp3, tmp4; + + switch (this->action) { + case 0: + sub_080A2340(this); + this->actionDelay = 8; + this->field_0xf = 0; + this->subAction = this->frameIndex; + this->speed = (Random() & 3) * 0x10 + 0x1e; + break; + case 1: + if (--this->speed != 0) { + return; + } + this->speed = (Random() & 7) * 0x10 + 0x1e; + this->action = 2; + break; + default: + if (--this->actionDelay != 0) { + return; + } + this->actionDelay = 8; + this->field_0xf = tmp2 = (this->field_0xf + 1) & 3; + tmp3 = this->subAction; + tmp1 = tmp3 + tmp2; + this->frameIndex = tmp1; + if (tmp3 * 0x1000000 != tmp1 * 0x1000000) { + return; + } + this->action = 1; + break; + } +} +END_NONMATCH + +void sub_080A2340(Entity* this) { + const struct_08125014* ptr; + ptr = &gUnk_08125014[this->type]; + this->x.HALF.HI = ptr->unk_0; + this->y.HALF.HI = ptr->unk_2; + this->frameIndex = ptr->unk_4; + this->spritePriority.b0 = ptr->unk_6; + this->spriteRendering.b3 = 1; + this->spriteOrientation.flipY = 1; + this->spriteSettings.draw = 2; + this->action = 1; +} diff --git a/src/object/objectD.c b/src/object/objectD.c new file mode 100644 index 00000000..89b72fa2 --- /dev/null +++ b/src/object/objectD.c @@ -0,0 +1,70 @@ +/** + * @file objectD.c + * @ingroup Objects + * + * @brief ObjectD object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" +#include "hitbox.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[0x1e]; + /*0x86*/ u16 unk_86; +} ObjectDEntity; + +void sub_0808434C(ObjectDEntity*); +void sub_080843F8(ObjectDEntity*); +void sub_08084428(ObjectDEntity*); + +void (*const gUnk_0811F908[])(ObjectDEntity*) = { + sub_0808434C, + sub_080843F8, + sub_08084428, + (void (*)(ObjectDEntity*))GetNextFrame, +}; + +void ObjectD(ObjectDEntity* this) { + gUnk_0811F908[super->action](this); +} + +void sub_0808434C(ObjectDEntity* this) { + super->action = 1; + super->flags |= 0x80; + super->spriteSettings.draw = 1; + super->field_0x3c = 7; + super->hitType = 1; + super->hurtType = 0x47; + super->flags2 = 2; + super->hitbox = (Hitbox*)&gHitbox_4; + SetTile(0x4050, COORD_TO_TILE(super), super->collisionLayer); + if (super->type == 1 || CheckFlags(this->unk_86)) { + super->action = 3; + SetFlag(this->unk_86); + InitializeAnimation(super, 1); + } else { + InitializeAnimation(super, super->type); + } +} + +void sub_080843F8(ObjectDEntity* this) { + if (super->bitfield == 0x9c) { + super->action = 2; + super->flags &= 0x7f; + CreateFx(super, FX_ICE, 0); + EnqueueSFX(SFX_10D); + } +} + +void sub_08084428(ObjectDEntity* this) { + GetNextFrame(super); + if ((super->frame & 1) != 0) { + super->action = 3; + SetFlag(this->unk_86); + EnqueueSFX(SFX_BUTTON_PRESS); + } +} diff --git a/src/object/objectE.c b/src/object/objectE.c new file mode 100644 index 00000000..e7cee6bc --- /dev/null +++ b/src/object/objectE.c @@ -0,0 +1,26 @@ +/** + * @file objectE.c + * @ingroup Objects + * + * @brief ObjectE object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +void ObjectE(Entity* this) { + if (this->action == 0) { + this->action = 1; + this->actionDelay = 0x14; + sub_08004168(this); + } else { + if (this->actionDelay-- == 0) { + sub_0807B7D8(0x35, COORD_TO_TILE(this), this->collisionLayer); + CreateFx(this, FX_FALL_DOWN, 0x40); + SoundReq(SFX_126); + DeleteThisEntity(); + } + } +} diff --git a/src/object/paper.c b/src/object/paper.c new file mode 100644 index 00000000..bd81e2b9 --- /dev/null +++ b/src/object/paper.c @@ -0,0 +1,78 @@ +/** + * @file paper.c + * @ingroup Objects + * + * @brief Paper object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +void Paper_Init(Entity*); +void Paper_Action1(Entity*); +void Paper_Type0(Entity*); +void Paper_Type1(Entity*); +void Paper_Type2(Entity*); + +void Paper(Entity* this) { + static void (*const Paper_Actions[])(Entity*) = { + Paper_Init, + Paper_Action1, + }; + Paper_Actions[this->action](this); +} + +void Paper_Init(Entity* this) { + static void (*const Paper_Types[])(Entity*) = { + Paper_Type0, + Paper_Type1, + Paper_Type2, + }; + Paper_Types[this->type](this); +} + +void Paper_Type0(Entity* this) { + this->action = 1; + this->spriteRendering.b3 = 1; + this->z.HALF.HI -= 8; + if (this->type2 != 1) { + if (this->type2 != 2) { + return; + } + this->spriteSettings.draw = 0; + } + SetTile(0x4051, COORD_TO_TILE(this), 1); +} + +void Paper_Type1(Entity* this) { + this->action = 1; + this->frameIndex = this->type2; + switch (this->type2) { + case 0: + this->spriteOffsetY = 2; + break; + case 2: + this->spriteOffsetY = -2; + break; + } +} + +void Paper_Type2(Entity* this) { + this->action = 1; + this->y.HALF.HI++; + this->spriteOffsetY = -1; + SetTile(0x4051, COORD_TO_TILE(this) - 1, 1); + SetTile(0x4051, COORD_TO_TILE(this), 1); +} + +void Paper_Action1(Entity* this) { + if (this->type == 0) { + if ((gPlayerEntity.y.HALF.HI < this->y.HALF.HI) || (gPlayerEntity.y.HALF.HI) > this->y.HALF.HI + 0x18) { + this->spriteRendering.b3 = 1; + } else { + this->spriteRendering.b3 = 2; + } + } +} diff --git a/src/object/pushableGrave.c b/src/object/pushableGrave.c index 989f817e..a3421aa2 100644 --- a/src/object/pushableGrave.c +++ b/src/object/pushableGrave.c @@ -78,7 +78,7 @@ void PushableGrave_Init(PushableGraveEntity* this) { super->hitbox = (Hitbox*)&gUnk_080FD570; SetTile(tileIndex, tilePosition, super->collisionLayer); if (super->type2 == 2) { - sub_0801AF18((u8*)gUnk_081232C0, tilePosition, super->collisionLayer); + SetMultipleTiles((u16*)gUnk_081232C0, tilePosition, super->collisionLayer); } } } diff --git a/src/object/stoneTablet.c b/src/object/stoneTablet.c index 9216e9b8..ce0df01e 100644 --- a/src/object/stoneTablet.c +++ b/src/object/stoneTablet.c @@ -15,22 +15,17 @@ void StoneTablet(Entity* this) { } void sub_080979CC(Entity* this) { - static const u8 gUnk_081232EC[] = { - 0x22, 0x40, 0xFE, 0xFF, 0x22, 0x40, 0xFF, 0xFF, 0x22, 0x40, 0x0, 0x0, 0x22, 0x40, 0x1, 0x0, 0xFF, 0xFF, - }; - - static const u8 gUnk_081232FE[] = { - 0x65, 0x40, 0xBF, 0xFF, 0x22, 0x40, 0xC0, 0xFF, 0x66, 0x40, 0xC1, 0xFF, 0x29, - 0x40, 0xFF, 0xFF, 0x26, 0x40, 0x0, 0x0, 0x2A, 0x40, 0x1, 0x0, 0xFF, 0xFF, - }; + static const u16 gUnk_081232EC[] = { 0x4022, 0xfffe, 0x4022, 0xffff, 0x4022, 0x0, 0x4022, 0x1, 0xffff }; + static const u16 gUnk_081232FE[] = { 0x4065, 0xffbf, 0x4022, 0xffc0, 0x4066, 0xffc1, 0x4029, + 0xffff, 0x4026, 0x0, 0x402a, 0x1, 0xffff }; this->action = 1; this->spriteSettings.draw = 1; if (this->type == 3) { this->frameIndex = 0; - sub_0801AF18(gUnk_081232FE, COORD_TO_TILE(this), this->collisionLayer); + SetMultipleTiles((u16*)gUnk_081232FE, COORD_TO_TILE(this), this->collisionLayer); } else { this->frameIndex = this->type; - sub_0801AF18(gUnk_081232EC, COORD_TO_TILE(this), this->collisionLayer); + SetMultipleTiles((u16*)gUnk_081232EC, COORD_TO_TILE(this), this->collisionLayer); } } |
