diff options
| author | notyourav <65437533+notyourav@users.noreply.github.com> | 2022-06-08 15:02:43 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-08 15:02:43 -0700 |
| commit | 06d6f7aaa4502698ddef83821c258f835ea41fbd (patch) | |
| tree | b79ba550d13cab7b057f0638f8ae6a97ba939d6d /src | |
| parent | e94528d9bf0d6bc3c4488d66b512c6c96964e89f (diff) | |
| parent | 5dd8bb6078105d1508094fdac705492ab7198f5a (diff) | |
Merge pull request #518 from hatal175/sub_0801A8D0
Diffstat (limited to 'src')
| -rw-r--r-- | src/beanstalkSubtask.c | 88 | ||||
| -rw-r--r-- | src/color.c | 37 | ||||
| -rw-r--r-- | src/common.c | 26 | ||||
| -rw-r--r-- | src/enemy/armos.c | 40 | ||||
| -rw-r--r-- | src/enemy/darkNut.c | 12 | ||||
| -rw-r--r-- | src/game.c | 1 | ||||
| -rw-r--r-- | src/item/itemBomb.c | 57 | ||||
| -rw-r--r-- | src/item/itemPacciCane.c | 3 | ||||
| -rw-r--r-- | src/item/itemPegasusBoots.c | 3 | ||||
| -rw-r--r-- | src/item/itemSword.c | 4 | ||||
| -rw-r--r-- | src/manager/delayedEntityLoadManager.c | 27 | ||||
| -rw-r--r-- | src/manager/lightRayManager.c | 21 | ||||
| -rw-r--r-- | src/object/object12.c | 16 | ||||
| -rw-r--r-- | src/object/object1E.c | 9 | ||||
| -rw-r--r-- | src/player.c | 3 | ||||
| -rw-r--r-- | src/playerUtils.c | 15 | ||||
| -rw-r--r-- | src/projectile/gyorgTail.c | 166 |
17 files changed, 396 insertions, 132 deletions
diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c index 334a4811..b4992d01 100644 --- a/src/beanstalkSubtask.c +++ b/src/beanstalkSubtask.c @@ -280,36 +280,36 @@ bool32 sub_0801A4F8(void) { ASM_FUNC("asm/non_matching/beanstalkSubtask/sub_0801A570.inc", void sub_0801A570()) -NONMATCH("asm/non_matching/beanstalkSubtask/sub_0801A8D0.inc", u32 sub_0801A8D0(Entity* this, u32 param_2)) { +u32 sub_0801A8D0(Entity* this, u32 param_2) { u16* mapData; u32 tile; u32 position; - if (this != NULL) { - mapData = GetLayerByIndex(this->collisionLayer)->mapData; - if (param_2 == 0) { - position = COORD_TO_TILE_OFFSET(this, 0, 8); - tile = mapData[position]; - if (tile == 0x4055) { - return position - 1; - } - if (tile == 0x4056) { - return position; - } - } else { - position = COORD_TO_TILE_OFFSET(this, 8, 0); - tile = mapData[position]; - if (tile == 0x4057) { - return position - 0x40; - } - if (tile == 0x4058) { - return position; - } + if (this == NULL) + return 0xffff; + + mapData = GetLayerByIndex(this->collisionLayer)->mapData; + if (param_2 == 0) { + position = COORD_TO_TILE_OFFSET(this, 0, 8); + tile = mapData[position]; + if (tile == 0x4055) { + return position - 1; + } + if (tile == 0x4056) { + return position; + } + } else { + position = COORD_TO_TILE_OFFSET(this, 8, 0); + tile = mapData[position]; + if (tile == 0x4057) { + return position - 0x40; + } + if (tile == 0x4058) { + return position; } } return 0xffff; } -END_NONMATCH bool32 sub_0801A980(void) { u16 tileType; @@ -323,46 +323,42 @@ bool32 sub_0801A980(void) { return FALSE; } -NONMATCH("asm/non_matching/beanstalkSubtask/sub_0801A9F0.inc", - bool32 sub_0801A9F0(u32 param_1, u32 param_2, u32 param_3)) { - +bool32 sub_0801A9F0(u32 param_1, u32 param_2, u32 param_3) { + bool32 cond = FALSE; switch (param_2) { + case 0x360: + cond = TRUE; + break; case 0x361: if (param_1 == 0) { - goto result; - } else { - return FALSE; + cond = TRUE; + } + break; + case 0x364: + if (param_1 == 8) { + cond = TRUE; } break; case 0x362: if (param_1 == 0x10) { - goto result; - } else { - return FALSE; + cond = TRUE; } break; case 0x363: if (param_1 == 0x18) { - goto result; - } else { - return FALSE; + cond = TRUE; } break; - case 0x364: - if (param_1 == 8) { - goto result; - } else { - return FALSE; - } - break; - case 0x360: - result: - return sub_0801AA58(&gPlayerEntity, param_3, param_1); default: - return FALSE; + break; } + + if (cond) { + return sub_0801AA58(&gPlayerEntity, param_3, param_1); + } + + return FALSE; } -END_NONMATCH bool32 sub_0801AA58(Entity* this, u32 param_2, u32 param_3) { LayerStruct* layer; diff --git a/src/color.c b/src/color.c index 3211e948..20c2d321 100644 --- a/src/color.c +++ b/src/color.c @@ -289,4 +289,39 @@ u32 sub_0801D458(u32 a1) { return 0; } -ASM_FUNC("asm/non_matching/color/sub_0801D48C.inc", void sub_0801D48C(u32 a1, u32 a2)); +void sub_0801D48C(u32 a1, u32 a2) { + Palette* pPVar1; + Palette* pPVar2; + s32 iVar2; + u16* iVar3; + u16* iVar4; + Palette* pPVar5; + u32 tmp; + u16* ptr; + Palette* ptr2; + + pPVar2 = gPaletteList; + pPVar1 = pPVar2 + a1; + iVar2 = (*(u8*)pPVar1) >> 4; + if (--iVar2 != -1) { + ptr = gPaletteBuffer; + iVar4 = ptr + 0x100 + a2 * 0x10; + pPVar5 = gPaletteList + a2; + iVar3 = ptr + 0x100 + a1 * 0x10; + do { + *pPVar5 = *pPVar1; + pPVar1->_0_0 = 0; + pPVar1->_0_4 = 0; + pPVar1->_1 = 0; + pPVar1->_2 = 0; + MemCopy(iVar3, iVar4, 0x20); + iVar3 += 0x10; + pPVar1++; + iVar4 += 0x10; + iVar2--; + pPVar5++; + } while (iVar2 != -1); + } + + gUsedPalettes |= 0xffff0000; +} diff --git a/src/common.c b/src/common.c index ee50370b..89220604 100644 --- a/src/common.c +++ b/src/common.c @@ -310,7 +310,31 @@ void sub_0801D898(void* dest, void* src, u32 word, u32 size) { ASM_FUNC("asm/non_matching/common/zMalloc.inc", void* zMalloc(u32 size)); -ASM_FUNC("asm/non_matching/common/zFree.inc", void zFree(void* ptr)); +void zFree(void* ptr) { + u32 uVar1; + u32 i; + u16* puVar3; + s32 uVar5; + u16* ptr2; + + uVar1 = (int)ptr - (int)gzHeap; + if (uVar1 < 0x1000) { + puVar3 = (u16*)gzHeap; + uVar5 = *puVar3++; + + for (i = 0; i < uVar5; puVar3 += 2, i++) { + if (*puVar3 == uVar1) { + ptr2 = &((u16*)(gzHeap - 2))[uVar5 * 2]; + *puVar3 = *ptr2; + *ptr2++ = 0; + *(puVar3 + 1) = *ptr2; + *ptr2 = 0; + *(u16*)(gzHeap) = uVar5 - 1; + break; + } + } + } +} void zMallocInit(void) { MemClear(gzHeap, sizeof(gzHeap)); diff --git a/src/enemy/armos.c b/src/enemy/armos.c index b6e262cc..076c278d 100644 --- a/src/enemy/armos.c +++ b/src/enemy/armos.c @@ -12,6 +12,7 @@ #include "hitbox.h" #include "common.h" #include "flags.h" +#include "collision.h" typedef struct { /*0x00*/ Entity base; @@ -27,8 +28,8 @@ typedef struct { } ArmosEntity; extern Entity* gUnk_020000B0; -extern Entity gUnk_02027EB4; -extern Entity gUnk_0200D654; +extern u8 gUnk_02027EB4[]; +extern u8 gUnk_0200D654[]; extern void (*const gUnk_080CE124[])(ArmosEntity*); extern void (*const gUnk_080CE13C[])(ArmosEntity*); @@ -361,7 +362,40 @@ bool32 sub_08030650(ArmosEntity* this) { return FALSE; } -ASM_FUNC("asm/non_matching/armos/sub_080306C4.inc", void sub_080306C4(ArmosEntity* this)) +void sub_080306C4(ArmosEntity* this) { + u32 uVar3; + u32 var; + u32 tmp; + + if (sub_08049FDC(super, 1) && this->unk_7a != 0) { + + super->timer = 0x18; + uVar3 = sub_0800132C(super, gUnk_020000B0); + if (uVar3 != 0xff) { + var = 0; + if ((((Random() & 7) != 0) || (super->animationState == 0xff)) && ((this->unk_82 & 3) != 3)) { + super->direction = (uVar3 + 4) & 0x18; + var = 1; + } + if (!var) { + super->direction = (4 + uVar3 + ((Random() & 2) - 1) * 8) & 0x18; + } + if (IsTileCollision(super->collisionLayer == 2 ? gUnk_0200D654 : gUnk_02027EB4, + super->x.HALF.HI + gUnk_080CE164[super->direction >> 2], + super->y.HALF.HI + gUnk_080CE164[(super->direction >> 2) + 1], 0)) { + super->direction = ((u8)(((uVar3 & 4) ^ 4) << 1)) | (uVar3 & 0x10); + var = 0; + } + sub_080307D4(this); + tmp = this->unk_82 << 1 | var; + this->unk_82 = tmp; + } + } else { + super->action = 4; + super->timer = 0x78; + super->speed = 0xa0; + } +} void sub_080307D4(ArmosEntity* this) { u8 tmp = super->direction >> 3; diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c index 4f948162..ae29107c 100644 --- a/src/enemy/darkNut.c +++ b/src/enemy/darkNut.c @@ -392,7 +392,17 @@ void sub_0802124C(Entity* this) { } } -ASM_FUNC("asm/non_matching/darkNut/sub_08021274.inc", u32 sub_08021274(u32 a, u32 b)) +u32 sub_08021274(u32 animationState, u32 dir) { + if (((dir & 7) - 3 < 3) && (((dir & 0x18) >> 3 == animationState || (((dir + 8) & 0x18) >> 3 == animationState)))) { + return 0xff; + } + + dir = DirectionToAnimationState(DirectionRoundUp(dir)); + if (animationState == dir) { + return 0xff; + } + return dir; +} void sub_080212B0(Entity* this) { u8 tmp; @@ -175,7 +175,6 @@ typedef struct { } CutsceneData; static const CutsceneData sCutsceneData[]; -extern u8 gUnk_0200AF13; extern u8 gUnk_0200AF14; extern u8 gUnk_080FE1C6[]; extern void (*const gUnk_080FE2AC[])(void); diff --git a/src/item/itemBomb.c b/src/item/itemBomb.c index fb7ba4fc..ce290853 100644 --- a/src/item/itemBomb.c +++ b/src/item/itemBomb.c @@ -36,7 +36,7 @@ void sub_08075FF8(ItemBehavior* this, u32 idx) { } maxBombs = this->behaviorID == 7 ? 3 : 1; if (maxBombs > bombCount) { - entity = CreatePlayerItemWithParent(this, 2); + entity = CreatePlayerItemWithParent(this, PLAYER_ITEM_BOMB); if (entity != NULL) { pos = &gUnk_0811BDAC[gPlayerEntity.animationState & 6]; PositionRelative(&gPlayerEntity, entity, Q_16_16(pos[0]), Q_16_16(pos[1])); @@ -48,4 +48,57 @@ void sub_08075FF8(ItemBehavior* this, u32 idx) { DeletePlayerItem(this, idx); } -ASM_FUNC("asm/non_matching/itemBomb/sub_08076088.inc", void sub_08076088(ItemBehavior* this, void* arg1)) +void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) { + if (param_2 != NULL) { + if ((param_2->carryFlags & 1) != 0) { + return; + } + param_2->action = 2; + param_2->subAction = param_2->carryFlags & 1; + } + + this->field_0x18 = param_2; + if ((gPlayerState.flags & PL_NO_CAP)) { + sub_08077DF4(this, 0x928); + } else { + sub_08077DF4(this, 0x338); + } + gPlayerState.heldObject = 3; + gPlayerState.framestate = 4; + this->stateID = 2; + this->field_0xf = 0xf; + if ((gPlayerEntity.field_0x78.HALF.HI & 0x80)) { + gPlayerEntity.field_0x78.HALF.HI = 0; + COLLISION_ON(&gPlayerEntity); + gPlayerState.heldObject = 4; + gPlayerState.keepFacing = ~(8 >> param_3) & gPlayerState.keepFacing; + gPlayerState.field_0xa = ~(8 >> param_3) & gPlayerState.field_0xa; + this->stateID = 3; + this->field_0xf = 0; + } else { + gPlayerState.field_0xa |= (8 >> param_3); + gPlayerState.keepFacing |= (8 >> param_3); + } + + param_2 = CreatePlayerItemWithParent(this, PLAYER_ITEM_13); + if (param_2 == NULL) { + PlayerCancelHoldItem(this, param_3); + } else { + Entity* playerEnt = &gPlayerEntity; + *(Entity**)&playerEnt->field_0x74 = param_2; + playerEnt->subtimer = 0; + param_2->child = this->field_0x18; + param_2->carryFlags = playerEnt->carryFlags; + param_2->parent = (Entity*)this; + this->field_0x18 = param_2; + param_2->type2 = this->field_0x2[1]; + param_2->timer = this->field_0x5[2]; + param_2->subtimer = this->field_0x5[3]; + if ((this->field_0x18->carryFlags & 0xf0) == 0x10) { + this->field_0x5[2] = 8; + } else { + this->field_0x5[2] = 0; + } + SoundReq(SFX_PLY_LIFT); + } +} diff --git a/src/item/itemPacciCane.c b/src/item/itemPacciCane.c index a09a7640..01615582 100644 --- a/src/item/itemPacciCane.c +++ b/src/item/itemPacciCane.c @@ -2,6 +2,7 @@ #include "entity.h" #include "item.h" #include "functions.h" +#include "playeritem.h" void sub_08076C98(ItemBehavior*, u32); void sub_08076CBC(ItemBehavior*, u32); @@ -26,7 +27,7 @@ void sub_08076CBC(ItemBehavior* beh, u32 idx) { DeletePlayerItem(beh, idx); } else { if ((beh->field_0x5[9] & 0x40) != 0) { - CreatePlayerItemWithParent(beh, 0x12); + CreatePlayerItemWithParent(beh, PLAYER_ITEM_12); } UpdateItemAnim(beh); } diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index 28479b75..eb2696c6 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -5,6 +5,7 @@ #include "effects.h" #include "game.h" #include "save.h" +#include "playeritem.h" void sub_08076964(ItemBehavior*, u32); void sub_080768F8(ItemBehavior*, u32); @@ -105,7 +106,7 @@ void sub_08076964(ItemBehavior* this, u32 idx) { (gPlayerState.skills & SKILL_DASH_ATTACK) != 0) { gPlayerState.field_0xab = 3; sub_08077DF4(this, 0x298); - bombEntity = CreatePlayerItemWithParent(this, 0xc); + bombEntity = CreatePlayerItemWithParent(this, PLAYER_ITEM_C); if (bombEntity != NULL) { if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != 0) { uVar3 = gSave.stats.itemButtons[SLOT_A]; diff --git a/src/item/itemSword.c b/src/item/itemSword.c index e6171072..6e5b0d6f 100644 --- a/src/item/itemSword.c +++ b/src/item/itemSword.c @@ -114,7 +114,7 @@ void sub_080754B8(ItemBehavior* this, u32 idx) { if (gPlayerEntity.frameSpriteSettings & 1) { iVar1 = sub_0807B014(); if (iVar1 && FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_SWORD_BEAM1, 2) == 0) { - CreatePlayerItemWithParent(this, 0xf); + CreatePlayerItemWithParent(this, PLAYER_ITEM_SWORD_BEAM1); if (iVar1 == 0xf) { gPlayerState.field_0xab = 5; } else { @@ -235,7 +235,7 @@ void sub_08075738(ItemBehavior* this, u32 idx) { } else { if (((((gPlayerEntity.frameSpriteSettings & 1) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) && ((gPlayerState.skills & SKILL_FOURSWORD) != 0))) { - Entity* bombEnt = CreatePlayerItemWithParent(this, 0x14); + Entity* bombEnt = CreatePlayerItemWithParent(this, PLAYER_ITEM_14); if (bombEnt) { bombEnt->animationState = (gPlayerEntity.animationState & 6) | 0x80; } diff --git a/src/manager/delayedEntityLoadManager.c b/src/manager/delayedEntityLoadManager.c index 00a0bbde..a878d70e 100644 --- a/src/manager/delayedEntityLoadManager.c +++ b/src/manager/delayedEntityLoadManager.c @@ -5,8 +5,33 @@ * @brief Delayed entity loader. */ #include "manager/delayedEntityLoadManager.h" +#include "room.h" ASM_FUNC("asm/non_matching/delayedEntityLoadManager/DelayedEntityLoadManager_Main.inc", void DelayedEntityLoadManager_Main()) -ASM_FUNC("asm/non_matching/delayedEntityLoadManager/sub_0805ACC0.inc", u32 sub_0805ACC0(Entity* ent)) +u32 sub_0805ACC0(Entity* param_1) { + u16* ptr; + Entity* entity; + Entity* list; + s32 tmp; + + if (param_1->health == 0) { + return 0; + } + tmp = (param_1->health & 0x7f) - 1; + list = (Entity*)(gEntityLists + 6); + + for (entity = gEntityLists[6].first; entity != list; entity = entity->next) { + if ((entity->kind == 9 && entity->id == 0x16) && entity->type2 <= tmp && + (entity->type2 + *(u8*)((u32)&entity->zVelocity + 1)) > tmp) { + + ptr = (u16*)GetCurrentRoomProperty(entity->type); + if (ptr != NULL) { + ptr += (tmp - entity->type2) * 8; + return (((ptr[2] + gRoomControls.origin_x) * 0x10000) | ptr[3]) + gRoomControls.origin_y; + } + } + } + return 0; +} diff --git a/src/manager/lightRayManager.c b/src/manager/lightRayManager.c index a738f620..fb704702 100644 --- a/src/manager/lightRayManager.c +++ b/src/manager/lightRayManager.c @@ -79,8 +79,7 @@ void sub_08057118(LightRayManager* this) { RegisterTransitionManager(this, sub_080570B8, sub_080570F8); } -// regalloc -NONMATCH("asm/non_matching/lightRayManager/sub_08057174.inc", void sub_08057174(LightRayManager* this)) { +void sub_08057174(LightRayManager* this) { LightRayManagerProp* prop = GetCurrentRoomProperty(super->type); s32 temp; s32 x; @@ -88,23 +87,14 @@ NONMATCH("asm/non_matching/lightRayManager/sub_08057174.inc", void sub_08057174( if (prop->unk0 == 0xff) return; - temp = gPlayerEntity.x.HALF.HI; - if (temp < 0) { - temp += 0xf; - } - - x = temp >> 4; - temp = gPlayerEntity.y.HALF.HI; - if (temp < 0) { - temp += 0xf; - } - y = temp >> 4; + x = gPlayerEntity.x.HALF.HI / 16; + y = gPlayerEntity.y.HALF.HI / 16; for (; prop->unk0 != 0xff; prop++) { if (prop->unk0 != this->unk_21) { - u32 x2 = (gRoomControls.origin_x >> 4) + prop->unk1; - u32 y2 = (gRoomControls.origin_y >> 4) + prop->unk2; + u32 x2 = (gRoomControls.origin_x / 16) + prop->unk1; + u32 y2 = (gRoomControls.origin_y / 16) + prop->unk2; if (y - y2 < prop->unk4 && x - x2 < prop->unk3) { switch (prop->unk0) { @@ -158,7 +148,6 @@ NONMATCH("asm/non_matching/lightRayManager/sub_08057174.inc", void sub_08057174( } } } -END_NONMATCH void sub_0805728C(LightRayManager* this) { if (--super->subtimer == 0) { diff --git a/src/object/object12.c b/src/object/object12.c index 2b1ce0c5..d99bc2ad 100644 --- a/src/object/object12.c +++ b/src/object/object12.c @@ -51,8 +51,9 @@ void Object12_Init(Object12Entity* this) { void Object12_Action1(Object12Entity* this) { } -NONMATCH("asm/non_matching/object12/Object12_Action2.inc", void Object12_Action2(Object12Entity* this)) { +void Object12_Action2(Object12Entity* this) { u32 tmp; + u32 tmp2; if (--super->timer == 0) { super->action = 3; super->timer = 0x1e; @@ -60,13 +61,16 @@ NONMATCH("asm/non_matching/object12/Object12_Action2.inc", void Object12_Action2 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); + tmp2 = super->x.HALF.HI; + tmp = gRoomControls.scroll_x; + tmp2 = tmp2 - tmp; + gScreen.controls.window0HorizontalDimensions = (((tmp2 - 0x18) & 0xff) << 8) | ((tmp2 + 0x18) & 0xff); + tmp2 = super->y.HALF.HI; + tmp = gRoomControls.scroll_y; + tmp2 = tmp2 - tmp; + gScreen.controls.window0VerticalDimensions = (((tmp2 - 0x18) & 0xff) << 8) | ((tmp2 + 0x18) & 0xff); } } -END_NONMATCH void Object12_Action3(Object12Entity* this) { if (--super->timer == 0) { diff --git a/src/object/object1E.c b/src/object/object1E.c index 1356bdd0..05d7b271 100644 --- a/src/object/object1E.c +++ b/src/object/object1E.c @@ -25,7 +25,7 @@ void Object1E(Entity* this) { } } -NONMATCH("asm/non_matching/object1E/sub_08087528.inc", void sub_08087528(Entity* this)) { +void sub_08087528(Entity* this) { u32 palette; this->action = 1; @@ -47,13 +47,13 @@ NONMATCH("asm/non_matching/object1E/sub_08087528.inc", void sub_08087528(Entity* } ChangeObjPalette(this, palette); switch (this->animationState) { - case 1: - this->spriteSettings.flipX = 1; + case 3: if (this->type == 0x40) { this->y.HALF.HI += 4; } break; - case 3: + case 1: + this->spriteSettings.flipX = 1; if (this->type == 0x40) { this->y.HALF.HI += 4; } @@ -68,7 +68,6 @@ NONMATCH("asm/non_matching/object1E/sub_08087528.inc", void sub_08087528(Entity* SetDefaultPriority(this, 3); InitializeAnimation(this, this->type2 * 4 + this->animationState); } -END_NONMATCH void sub_080875F4(Entity* this) { GetNextFrame(this); diff --git a/src/player.c b/src/player.c index 86af3340..99ab57f3 100644 --- a/src/player.c +++ b/src/player.c @@ -22,6 +22,7 @@ #include "game.h" #include "screen.h" #include "main.h" +#include "playeritem.h" #define GRAVITY_RATE Q_8_8(32) #define SLOPE_SPEED_MODIFIER 0x50 @@ -1657,7 +1658,7 @@ static void PlayerEmptyBottleInit(Entity* this) { Entity* ent; ResetPlayerItem(); - ent = CreatePlayerItemWithParent((ItemBehavior*)this, 0xe); + ent = CreatePlayerItemWithParent((ItemBehavior*)this, PLAYER_ITEM_BOTTLE); if (ent != NULL) { ent->field_0x68.HALF.LO = gPlayerState.field_0x38; this->subAction++; diff --git a/src/playerUtils.c b/src/playerUtils.c index 59575041..f262b98b 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -1812,20 +1812,20 @@ u32 sub_0807A894(Entity* this) { void nullsub_505(void) { } -NONMATCH("asm/non_matching/playerUtils/sub_0807A8D8.inc", void sub_0807A8D8(Entity* this)) { +void sub_0807A8D8(Entity* this) { u32 tmp; if ((gPlayerState.flags & PL_MINISH) == 0) { - tmp = sub_080B1B84(COORD_TO_TILE_OFFSET(this, 0, 1), gPlayerEntity.collisionLayer) & 0x20; - if (tmp != 0) { + tmp = sub_080B1B84(COORD_TO_TILE_OFFSET(this, 0, 1), gPlayerEntity.collisionLayer); + if ((tmp & 0x20) != 0) { sub_0807AAF8(this, COORD_TO_TILE_OFFSET(this, 0, 1)); } - tmp = sub_080B1B84(COORD_TO_TILE_OFFSET(this, -2, 0), gPlayerEntity.collisionLayer) & 0x20; - if (tmp != 0) { + tmp = sub_080B1B84(COORD_TO_TILE_OFFSET(this, -2, 0), gPlayerEntity.collisionLayer); + if ((tmp & 0x20) != 0) { sub_0807AAF8(this, COORD_TO_TILE_OFFSET(this, -2, 0)); } - tmp = sub_080B1B84(COORD_TO_TILE_OFFSET(this, 2, 0), gPlayerEntity.collisionLayer) & 0x20; - if (tmp != 0) { + tmp = sub_080B1B84(COORD_TO_TILE_OFFSET(this, 2, 0), gPlayerEntity.collisionLayer); + if ((tmp & 0x20) != 0) { sub_0807AAF8(this, COORD_TO_TILE_OFFSET(this, 2, 0)); } } @@ -1841,7 +1841,6 @@ NONMATCH("asm/non_matching/playerUtils/sub_0807A8D8.inc", void sub_0807A8D8(Enti } } } -END_NONMATCH void sub_0807AA80(Entity* this) { if (((gPlayerState.flags & PL_HIDDEN) == 0) && (this->collisionLayer = 2, this->z.HALF.HI == 0)) { diff --git a/src/projectile/gyorgTail.c b/src/projectile/gyorgTail.c index ddd0fcb9..586c90bd 100644 --- a/src/projectile/gyorgTail.c +++ b/src/projectile/gyorgTail.c @@ -6,22 +6,22 @@ #include "projectile.h" #include "hitbox.h" -extern u8 gEntCount; - -extern void (*const gUnk_0812A994[])(Entity*); -extern void (*const GyorgTail_Actions[])(Entity*); -extern const s16 gUnk_0812A9B4[]; -extern const u8 gUnk_0812A9B8[]; -extern const u8 gUnk_0812A9BA[]; -extern const u8 gUnk_0812A9C0[]; - bool32 sub_080AC5E4(Entity*); void sub_080AC388(Entity*); void sub_080AC6F0(Entity*); void sub_080AC760(Entity*); void sub_080AC7C4(Entity*); +void sub_080AC328(Entity*); +void sub_080AC510(Entity*); +void sub_080AC560(Entity*); +void sub_080AC884(Entity*); +void sub_080AC480(Entity*); +void GyorgTail_Init(Entity*); void GyorgTail(Entity* this) { + static void (*const gUnk_0812A994[])(Entity*) = { + sub_080AC328, sub_080AC510, sub_080AC510, sub_080AC510, sub_080AC560, + }; Entity* parent; if (this->parent->next == NULL) { @@ -47,10 +47,16 @@ void GyorgTail(Entity* this) { } void sub_080AC328(Entity* this) { + static void (*const GyorgTail_Actions[])(Entity*) = { + GyorgTail_Init, + sub_080AC388, + sub_080AC480, + }; GyorgTail_Actions[this->action](this); } void GyorgTail_Init(Entity* this) { + static const s16 gUnk_0812A9B4[] = { -64, 64 }; if (sub_080AC5E4(this) != 0) { this->action = 1; this->frameIndex = 0xc; @@ -61,7 +67,46 @@ void GyorgTail_Init(Entity* this) { } } -ASM_FUNC("asm/non_matching/gyorgTail/sub_080AC388.inc", void sub_080AC388(Entity* this)) +void sub_080AC388(Entity* this) { + static const u8 gUnk_0812A9B8[] = { 24, 20 }; + Entity* pEVar2; + int iVar3; + u32 uVar5; + + uVar5 = gUnk_0812A9B8[this->type]; + pEVar2 = this->parent; + iVar3 = (pEVar2->animationState ^ 0x80) - (this->field_0x7c.HALF_U.LO >> 8); + if ((short)this->field_0x7a.HWORD < 0) { + if (((iVar3 - uVar5) & 0xff) <= 0x7f) { + s32 tmp = -(short)this->field_0x7a.HWORD; + this->field_0x7a.HWORD = tmp; + this->field_0x7c.HALF_U.LO = (short)((((pEVar2->animationState ^ 0x80) - uVar5) & 0xff) << 8); + sub_080AC884(this); + } else { + this->field_0x7c.HALF_U.LO = this->field_0x7c.HALF_U.LO + this->field_0x7a.HWORD; + if (((iVar3 + uVar5) & 0xff) >= 0x81) { + this->field_0x7c.HALF_U.LO = ((((pEVar2->animationState ^ 0x80) + uVar5) & 0xff) << 8) | 0x80; + } + } + } else { + if (((iVar3 + uVar5) & 0xff) >= 0x81) { + s32 tmp = -(short)this->field_0x7a.HWORD; + this->field_0x7a.HWORD = tmp; + this->field_0x7c.HALF_U.LO = (short)((((pEVar2->animationState ^ 0x80) + uVar5) & 0xff) << 8); + sub_080AC884(this); + } else { + this->field_0x7c.HALF_U.LO = this->field_0x7c.HALF_U.LO + this->field_0x7a.HWORD; + if (0x7e >= ((iVar3 - uVar5) & 0xff) - 1) { + this->field_0x7c.HALF_U.LO = ((((pEVar2->animationState ^ 0x80) - uVar5) & 0xff) << 8) | 0x80; + } + } + } + + this->direction = this->field_0x7c.HALF_U.LO >> 8; + sub_080AC6F0(this); + sub_080AC760(this); + sub_080AC7C4(this); +} void sub_080AC480(Entity* this) { if (this->timer != 0) { @@ -88,6 +133,7 @@ void sub_080AC480(Entity* this) { } void sub_080AC510(Entity* this) { + static const u8 gUnk_0812A9BA[] = { 24, 25, 25, 24, 24, 24 }; if (this->action == 0) { this->action = 1; this->frameIndex = gUnk_0812A9BA[this->type * 3 + this->type2 - 1]; @@ -186,7 +232,57 @@ NONMATCH("asm/non_matching/gyorgTail/sub_080AC5E4.inc", bool32 sub_080AC5E4(Enti } END_NONMATCH -ASM_FUNC("asm/non_matching/gyorgTail/sub_080AC6F0.inc", void sub_080AC6F0(Entity* this)) +void sub_080AC6F0(Entity* this) { + static const u8 gUnk_0812A9C0[] = { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + + u32 uVar1; + s32 iVar2; + s32 iVar3; + u32 uVar4; + u32 tmp; + + uVar4 = this->direction & 0x1f; + uVar1 = this->direction >> 5; + iVar3 = uVar1 * 3; + tmp = gUnk_0812A9C0[this->animationState] - uVar1 * 3; + if (tmp <= 3) { + switch (tmp) { + default: + if (uVar4 > 0x19) { + return; + } + break; + case 0: + if (uVar4 < 7) { + return; + } + break; + case 1: + if (uVar4 - 5 < 0xd) { + return; + } + break; + case 2: + if (uVar4 - 0xf < 0xd) { + return; + } + break; + } + } + iVar2 = iVar3 + 3; + if (uVar4 < 0x1b) { + iVar2 = iVar3 + 2; + if (uVar4 < 0x11) { + iVar2 = iVar3; + if (5 < uVar4) { + iVar2 = iVar3 + 1; + } + } + } + this->animationState = iVar2 % 0x18; + this->frameIndex = gUnk_0812A9C0[iVar2 % 0x18]; +} void sub_080AC760(Entity* param_1) { s32 tmp; @@ -218,14 +314,17 @@ void sub_080AC760(Entity* param_1) { } } -NONMATCH("asm/non_matching/gyorgTail/sub_080AC7C4.inc", void sub_080AC7C4(Entity* this)) { - // TODO regalloc +void sub_080AC7C4(Entity* this) { Entity* entity1; Entity* entity2; Entity* entity3; - s32 iVar1; - s32 iVar2; - s32 iVar3; + s32 tmp; + s32 tmp2; + s32 tmp3; + s32 tmp4; + s32 tmp5; + s32 tmp6; + s32 r6; entity1 = this->child; entity2 = entity1->child; @@ -235,14 +334,22 @@ NONMATCH("asm/non_matching/gyorgTail/sub_080AC7C4.inc", void sub_080AC7C4(Entity } else { entity3 = this->parent; } - PositionRelative(entity3, entity2, (entity2->field_0x78.HALF.HI << 8) * gSineTable[entity2->direction], - -((entity2->field_0x78.HALF.HI << 8) * gSineTable[entity2->direction + 0x40])); - PositionRelative(entity2, entity1, (entity1->field_0x78.HALF.HI << 8) * gSineTable[entity1->direction], - -((entity1->field_0x78.HALF.HI << 8) * gSineTable[entity1->direction + 0x40])); - PositionRelative(entity1, this, (this->field_0x78.HALF.HI << 8) * gSineTable[this->direction], - -((this->field_0x78.HALF.HI << 8) * gSineTable[this->direction + 0x40])); + tmp = entity2->field_0x78.HALF.HI << 8; + tmp2 = gSineTable[entity2->direction]; + r6 = tmp2 * tmp; + tmp2 = gSineTable[entity2->direction + 0x40] * tmp; + PositionRelative(entity3, entity2, r6, -tmp2); + tmp3 = entity1->field_0x78.HALF.HI << 8; + tmp4 = gSineTable[entity1->direction]; + r6 = tmp4 * tmp3; + tmp4 = gSineTable[entity1->direction + 0x40] * tmp3; + PositionRelative(entity2, entity1, r6, -tmp4); + tmp5 = this->field_0x78.HALF.HI << 8; + tmp6 = gSineTable[this->direction]; + r6 = tmp6 * tmp5; + tmp6 = gSineTable[this->direction + 0x40] * tmp5; + PositionRelative(entity1, this, r6, -tmp6); } -END_NONMATCH void sub_080AC884(Entity* this) { if (this->parent->field_0x70.HALF_U.HI != 0) { @@ -252,16 +359,3 @@ void sub_080AC884(Entity* this) { this->subtimer = 0x56; } } - -void (*const gUnk_0812A994[])(Entity*) = { - sub_080AC328, sub_080AC510, sub_080AC510, sub_080AC510, sub_080AC560, -}; -void (*const GyorgTail_Actions[])(Entity*) = { - GyorgTail_Init, - sub_080AC388, - sub_080AC480, -}; -const s16 gUnk_0812A9B4[] = { -64, 64 }; -const u8 gUnk_0812A9B8[] = { 24, 20 }; -const u8 gUnk_0812A9BA[] = { 24, 25, 25, 24, 24, 24 }; -const u8 gUnk_0812A9C0[] = { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; |
