From 9488eb01e74dfc80cea6c4ead8fa6b11ec0fee42 Mon Sep 17 00:00:00 2001 From: gamezter Date: Wed, 12 Feb 2025 11:15:37 -0500 Subject: [PATCH] Decompile `lib` dhuron functions (#2203) `func_us_801CC6B0`: PSX: https://decomp.me/scratch/XJVWJ PSP: https://decomp.me/scratch/BKgXI `func_us_801CC7BC`: PSX: https://decomp.me/scratch/cSNo7 PSP: https://decomp.me/scratch/lsF0V `func_us_801CC984`: PSX: https://decomp.me/scratch/HtaiR PSP: https://decomp.me/scratch/NXku6 `func_us_801CC984` uses `ext.dhuron.unk88` as an s16 and `ext.dhuron.unk89` as a u8 . I reused the same extension struct for simplicity but maybe this is a union or a completely separate extension struct. --- include/entity.h | 7 +- src/dra/692E8.c | 2 +- src/dra/75F54.c | 2 +- src/dra/7879C.c | 8 +- src/dra/7E4BC.c | 6 +- src/dra/843B0.c | 2 +- src/dra/8D3E8.c | 2 +- src/dra_psp/58E60.c | 2 +- src/ric/1AC60.c | 2 +- src/ric/211D0.c | 2 +- src/ric/24788.c | 2 +- src/ric/2A060.c | 22 +-- src/ric/2C4C4.c | 10 +- src/servant/tt_003/demon.c | 2 +- src/st/chi/en_salem_witch.c | 2 +- src/st/e_explosion_puff_opaque.h | 2 +- src/st/e_merman2.h | 4 +- src/st/lib/e_dhuron.c | 281 ++++++++++++++++++++++++++++- src/st/lib/lib.h | 3 +- src/st/lib/unk_3C57C.c | 2 +- src/st/no1/e_mouse.c | 2 +- src/st/no1/e_wall_chicken_secret.c | 4 +- src/st/no1/e_wereskeleton.c | 2 +- src/st/no1/unk_35E20.c | 2 +- src/st/no1/unk_381E8.c | 4 +- src/st/no1/unk_3D8AC.c | 4 +- src/st/no1/unk_3FA34.c | 2 +- src/st/np3/48238.c | 2 +- src/st/np3/gaibon.c | 6 +- src/st/nz0/311C0.c | 2 +- src/st/nz0/e_subweapon_container.c | 2 +- src/st/nz0/gaibon.c | 6 +- src/st/sel/3410C.c | 6 +- src/st/sel/3585C.c | 2 +- src/st/st0/2DAC8.c | 4 +- src/st/st0/3AB08.c | 2 +- src/weapon/w_029.c | 4 +- 37 files changed, 348 insertions(+), 73 deletions(-) diff --git a/include/entity.h b/include/entity.h index 53564ca6cd..ecfb7db951 100644 --- a/include/entity.h +++ b/include/entity.h @@ -2804,11 +2804,10 @@ typedef struct { } ET_LibraryShadow; typedef struct { - /* 0x7C */ s32 : 32; - /* 0x80 */ s16 : 16; - /* 0x82 */ s16 : 16; + /* 0x7C */ struct Primitive* unk7C; + /* 0x80 */ struct Primitive* unk80; /* 0x84 */ s16 unk84; - /* 0x86 */ s16 : 16; + /* 0x86 */ s16 unk86; /* 0x88 */ u8 unk88; /* 0x89 */ u8 unk89; /* 0x8A */ s16 : 16; diff --git a/src/dra/692E8.c b/src/dra/692E8.c index 9d2dbf4acc..12f2acabb4 100644 --- a/src/dra/692E8.c +++ b/src/dra/692E8.c @@ -217,7 +217,7 @@ void func_80109594() { DestroyEntity(e); e->animSet = ANIMSET_DRA(1); e->unk5A = i + 1; - e->palette = 0x8100; + e->palette = PAL_OVL(0x100); e->flags = FLAG_UNK_20000 | FLAG_POS_CAMERA_LOCKED; } diff --git a/src/dra/75F54.c b/src/dra/75F54.c index ddf7f445b6..37ac8d3196 100644 --- a/src/dra/75F54.c +++ b/src/dra/75F54.c @@ -262,7 +262,7 @@ bool BatFormFinished(void) { SetPlayerStep(Player_UnmorphBat); SetPlayerAnim(0xCA); D_800AFDA4[1] = 6; - g_Entities->palette = 0x810D; + g_Entities->palette = PAL_OVL(0x10D); g_Player.unk66 = 0; g_Player.unk68 = 0; CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(44, 0x21), 0); diff --git a/src/dra/7879C.c b/src/dra/7879C.c index 2f79a55af8..57141f1274 100644 --- a/src/dra/7879C.c +++ b/src/dra/7879C.c @@ -1528,7 +1528,7 @@ void func_8011B5A4(Entity* self) { self->anim = D_800AD57C; self->zPriority = PLAYER.zPriority + 2; self->flags = FLAG_POS_CAMERA_LOCKED | FLAG_UNK_100000 | FLAG_UNK_10000; - self->palette = 0x8195; + self->palette = PAL_OVL(0x195); paramsHi = self->params >> 8; paramsLo = self->params & 0xFF; self->drawMode = DRAW_TPAGE; @@ -1660,12 +1660,12 @@ void EntityUnkId24(Entity* self) { self->posX.i.hi -= 32 - (rand() & 63); self->posY.i.hi -= 48 - (rand() & 63); self->drawMode = DRAW_TPAGE; - self->palette = 0x8195; + self->palette = PAL_OVL(0x195); } else { self->posY.i.hi -= 12 - rand() % 24; self->drawFlags = FLAG_DRAW_ROTY | FLAG_DRAW_ROTX; self->rotX = self->rotY = 0x80; - self->palette = 0x8170; + self->palette = PAL_OVL(0x170); } self->step++; return; @@ -2691,7 +2691,7 @@ void EntityWingSmashTrail(Entity* entity) { entity->drawMode = DRAW_TPAGE2 | DRAW_TPAGE; entity->rotZ = PLAYER.rotZ; entity->facingLeft = PLAYER.facingLeft; - entity->palette = 0x8102; + entity->palette = PAL_OVL(0x102); entity->rotX = entity->rotY = 0x100; entity->step++; return; diff --git a/src/dra/7E4BC.c b/src/dra/7E4BC.c index ae95cd269c..9fd7425de0 100644 --- a/src/dra/7E4BC.c +++ b/src/dra/7E4BC.c @@ -526,7 +526,7 @@ void func_8011EDA8(Entity* self) { } else { self->animSet = ANIMSET_DRA(5); self->anim = D_800AD57C; - self->palette = 0x8170; + self->palette = PAL_OVL(0x170); } } self->flags = FLAG_UNK_20000 | FLAG_UNK_100000 | FLAG_POS_CAMERA_LOCKED; @@ -585,7 +585,7 @@ void func_8011F074(Entity* entity) { entity->unk5A = 0x79; entity->animSet = ANIMSET_DRA(14); entity->zPriority = PLAYER.zPriority + 2; - entity->palette = 0x819F; + entity->palette = PAL_OVL(0x19F); if (D_8013808C & 1) { entity->drawMode = DRAW_UNK_40 | DRAW_TPAGE2 | DRAW_TPAGE; @@ -2380,7 +2380,7 @@ void func_80123F78(Entity* entity) { entity->unk5A = 0xD; entity->drawFlags = PLAYER.drawFlags; entity->drawMode = DRAW_TPAGE2 | DRAW_TPAGE; - entity->palette = 0x815F; + entity->palette = PAL_OVL(0x15F); entity->zPriority = PLAYER.zPriority - 2; entity->facingLeft = PLAYER.facingLeft; diff --git a/src/dra/843B0.c b/src/dra/843B0.c index 34b422c57b..0377a23f34 100644 --- a/src/dra/843B0.c +++ b/src/dra/843B0.c @@ -242,7 +242,7 @@ void EntityPlayerSleepZ(Entity* self) { self->velocityY = FIX(-0.375); SetSpeedX(FIX(0.25)); self->unk5A = 0x50; - self->palette = 0x819F; + self->palette = PAL_OVL(0x19F); self->anim = D_800AE294; self->posY.i.hi -= 16; diff --git a/src/dra/8D3E8.c b/src/dra/8D3E8.c index 8ac7d0df8f..8f23dc1ccd 100644 --- a/src/dra/8D3E8.c +++ b/src/dra/8D3E8.c @@ -1272,7 +1272,7 @@ void func_8012F894(Entity* self) { f178_finish = false; if (abs(PLAYER.velocityX) > FIX(3)) { f178_finish = true; - self->palette = PLAYER.palette = 0x810D; + self->palette = PLAYER.palette = PAL_OVL(0x10D); } prim = &g_PrimBuf[self->primIndex]; func_8012F178(prim, f178_count, f178_finish); diff --git a/src/dra_psp/58E60.c b/src/dra_psp/58E60.c index 5701decae3..88d5c7823c 100644 --- a/src/dra_psp/58E60.c +++ b/src/dra_psp/58E60.c @@ -18,7 +18,7 @@ void EntityPlayerSleepZ(Entity* self) { self->velocityY = FIX(-0.375); SetSpeedX(FIX(0.25)); self->unk5A = 0x50; - self->palette = 0x819F; + self->palette = PAL_OVL(0x19F); self->anim = D_800AE294; self->posY.i.hi -= 16; diff --git a/src/ric/1AC60.c b/src/ric/1AC60.c index eeebc770a4..d73b6788ac 100644 --- a/src/ric/1AC60.c +++ b/src/ric/1AC60.c @@ -149,7 +149,7 @@ void RicInit(s16 initParam) { DestroyEntity(e); e->animSet = ANIMSET_OVL(0x10); e->unk5A = i + 1; - e->palette = 0x8120; + e->palette = PAL_OVL(0x120); e->flags = FLAG_UNK_20000 | FLAG_POS_CAMERA_LOCKED; } primIndex = g_api.AllocPrimitives(PRIM_TILE, 6); diff --git a/src/ric/211D0.c b/src/ric/211D0.c index 385b5b963e..056a31edfb 100644 --- a/src/ric/211D0.c +++ b/src/ric/211D0.c @@ -1364,7 +1364,7 @@ void RicEntityHitByDark(Entity* entity) { entity->unk5A = 0x79; entity->animSet = ANIMSET_DRA(14); entity->zPriority = PLAYER.zPriority + 2; - entity->palette = 0x819F; + entity->palette = PAL_OVL(0x19F); if (D_80174FFC & 1) { entity->drawMode = DRAW_UNK_40 | DRAW_TPAGE2 | DRAW_TPAGE; diff --git a/src/ric/24788.c b/src/ric/24788.c index d1c592bccc..281475d9f1 100644 --- a/src/ric/24788.c +++ b/src/ric/24788.c @@ -735,7 +735,7 @@ void func_80161C2C(Entity* self) { } else { self->animSet = ANIMSET_DRA(5); self->anim = anim_smoke_puff; - self->palette = 0x8170; + self->palette = PAL_OVL(0x170); } } self->flags = FLAG_UNK_20000 | FLAG_UNK_100000 | FLAG_POS_CAMERA_LOCKED; diff --git a/src/ric/2A060.c b/src/ric/2A060.c index 04539d83f9..8b44c0671e 100644 --- a/src/ric/2A060.c +++ b/src/ric/2A060.c @@ -329,7 +329,7 @@ void RicEntityWhip(Entity* self) { self->step = 1; self->velocityX = 0; self->velocityY = 0; - self->palette = 0x8148; + self->palette = PAL_OVL(0x148); if (!PLAYER.facingLeft) { self->ext.whip.unk88 = playerUnk46; } else { @@ -419,9 +419,9 @@ void RicEntityWhip(Entity* self) { } switch (self->step) { case 0: - self->animSet = -0x7FEE; + self->animSet = ANIMSET_OVL(18); self->animCurFrame = 0x1E; - self->palette = 0x8138; + self->palette = PAL_OVL(0x138); self->unk5A = 0x46; if (lowerParams < 8) { self->hitboxWidth = 3; @@ -555,12 +555,12 @@ void RicEntityWhip(Entity* self) { if (PLAYER.animFrameIdx == 6) { if ((PLAYER.animFrameDuration >= 0xF) || (PLAYER.animFrameDuration == 0)) { - self->palette = 0x8138; + self->palette = PAL_OVL(0x138); } else if ((PLAYER.animFrameDuration == 11 || PLAYER.animFrameDuration == 12) || (PLAYER.animFrameDuration == 13 || PLAYER.animFrameDuration == 14)) { - self->palette = 0x813C; + self->palette = PAL_OVL(0x13C); } else { // animFrameDuration can be -1 apparently. // todo this should read the previous element out of bounds? @@ -613,15 +613,15 @@ void RicEntityWhip(Entity* self) { } // This very well might be a switch if (PLAYER.animFrameDuration > 14) { - self->palette = 0x8138; + self->palette = PAL_OVL(0x138); } else if (PLAYER.animFrameDuration == 0) { - self->palette = 0x8138; + self->palette = PAL_OVL(0x138); } else if (PLAYER.animFrameDuration == 11 || PLAYER.animFrameDuration == 12) { - self->palette = 0x813C; + self->palette = PAL_OVL(0x13C); } else if (PLAYER.animFrameDuration == 13 || PLAYER.animFrameDuration == 14) { - self->palette = 0x813C; + self->palette = PAL_OVL(0x13C); } else { // animFrameDuration can be -1 apparently. // todo this should read the previous element out of bounds? @@ -733,7 +733,7 @@ void RicEntityWhip(Entity* self) { self->drawMode = DRAW_TPAGE2 | DRAW_TPAGE; self->drawFlags |= DRAW_HIDE; } - self->palette = 0x8160; + self->palette = PAL_OVL(0x160); } } @@ -761,7 +761,7 @@ void RicEntityArmBrandishWhip(Entity* entity) { FLAG_KEEP_ALIVE_OFFCAMERA | FLAG_UNK_10000; entity->animSet = ANIMSET_OVL(18); entity->unk5A = 0x46; - entity->palette = 0x8120; + entity->palette = PAL_OVL(0x120); entity->zPriority = PLAYER.zPriority + 2; } diff --git a/src/ric/2C4C4.c b/src/ric/2C4C4.c index 2ba58637a2..a99b131158 100644 --- a/src/ric/2C4C4.c +++ b/src/ric/2C4C4.c @@ -24,7 +24,7 @@ void RicEntitySubwpnHolyWater(Entity* self) { self->animCurFrame = 0x23; self->zPriority = PLAYER.zPriority + 2; self->unk5A = 0x46; - self->palette = 0x812F; + self->palette = PAL_OVL(0x12F); self->posX.i.hi = self->posX.i.hi; self->posY.i.hi = self->posY.i.hi - 0x10; self->ext.holywater.angle = (rand() & 0x7F) + 0xDC0; @@ -649,9 +649,9 @@ void RicEntitySubwpnCross(Entity* self) { } // Applies a flickering effect if (!((g_GameTimer >> 1) & 1)) { - self->palette = 0x81B1; + self->palette = PAL_OVL(0x1B1); } else { - self->palette = 0x81B0; + self->palette = PAL_OVL(0x1B0); } temp_a0 = self->ext.crossBoomerang.unk84; // This indexes into the unk84 array. @@ -721,7 +721,7 @@ void RicEntitySubwpnCrossTrail(Entity* self) { self->animSet = ANIMSET_OVL(17); self->animCurFrame = D_80155E68[self->params]; self->unk5A = 0x66; - self->palette = 0x81B0; + self->palette = PAL_OVL(0x1B0); self->drawMode = DRAW_TPAGE; self->facingLeft = PLAYER.facingLeft; self->zPriority = PLAYER.zPriority; @@ -2339,7 +2339,7 @@ void RicEntityVibhutiCrashCloud(Entity* entity) { RicSetSubweaponParams(entity); entity->unk5A = 0x79; entity->animSet = ANIMSET_DRA(14); - entity->palette = 0x819E; + entity->palette = PAL_OVL(0x19E); entity->anim = D_80155EA8; entity->drawMode = DRAW_TPAGE2 | DRAW_TPAGE; entity->drawFlags = FLAG_DRAW_UNK8; diff --git a/src/servant/tt_003/demon.c b/src/servant/tt_003/demon.c index 831880a3db..59f0f3da4e 100644 --- a/src/servant/tt_003/demon.c +++ b/src/servant/tt_003/demon.c @@ -1506,7 +1506,7 @@ void func_us_801765A0(Entity* self) { } self->flags = FLAG_POS_CAMERA_LOCKED | FLAG_KEEP_ALIVE_OFFCAMERA; - self->palette = 0x8143; + self->palette = PAL_OVL(0x143); self->drawMode = DRAW_TPAGE2 | DRAW_TPAGE; self->animSet = 0xE; self->unk5A = 0x79; diff --git a/src/st/chi/en_salem_witch.c b/src/st/chi/en_salem_witch.c index 83971fead2..fb09efbbc6 100644 --- a/src/st/chi/en_salem_witch.c +++ b/src/st/chi/en_salem_witch.c @@ -867,7 +867,7 @@ void EntitySalemWitchTriboltLaunch(Entity* self) { return; case SPAWN_PROJECTILES: - self->animSet = -0x7FFA; + self->animSet = ANIMSET_OVL(6); self->unk5A = 0x4B; self->rotY = BurstStartRotation; self->rotX = BurstStartRotation; diff --git a/src/st/e_explosion_puff_opaque.h b/src/st/e_explosion_puff_opaque.h index 3fc5f87ed4..5b2b00e3fc 100644 --- a/src/st/e_explosion_puff_opaque.h +++ b/src/st/e_explosion_puff_opaque.h @@ -50,7 +50,7 @@ void EntityExplosionPuffOpaque(Entity* self) { } if (self->params & 0xF0) { - self->palette = 0x819F; + self->palette = PAL_OVL(0x19F); self->drawMode = DRAW_TPAGE; self->facingLeft = 1; } diff --git a/src/st/e_merman2.h b/src/st/e_merman2.h index 60d079e856..9b66fadd29 100644 --- a/src/st/e_merman2.h +++ b/src/st/e_merman2.h @@ -1371,10 +1371,10 @@ void EntityHighWaterSplash(Entity* self) { InitializeEntity(g_EInitParticle); self->animSet = ANIMSET_DRA(2); self->velocityY = FIX(-5); - self->palette = 0x8162; + self->palette = PAL_OVL(0x162); self->drawMode = DRAW_TPAGE; self->drawFlags |= FLAG_DRAW_ROTY | FLAG_DRAW_ROTX; - self->palette = 0x8018; + self->palette = PAL_OVL(0x18); self->drawMode = DRAW_TPAGE2 | DRAW_TPAGE; self->drawFlags |= FLAG_DRAW_UNK8; self->unk6C = 0xA0; diff --git a/src/st/lib/e_dhuron.c b/src/st/lib/e_dhuron.c index 6464005489..37222c7480 100644 --- a/src/st/lib/e_dhuron.c +++ b/src/st/lib/e_dhuron.c @@ -1,7 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later #include "lib.h" +typedef struct { + s32 velocityX; + s32 velocityY; + s16 rotZ; + s16 unkA; +} dhuronUnkStruct; + +extern u16 g_EInitInteractable[]; extern u16 D_us_8018089C[]; +extern u16 D_us_801808A8[]; +extern u16 D_us_801808B4[]; + extern s16 D_us_80182954[]; extern s16 D_us_80182964[]; extern u8 D_us_8018296C[]; @@ -12,6 +23,10 @@ extern u8 D_us_801829D4[]; extern u8 D_us_801829F0[]; extern s8 D_us_801829FC[][4]; extern u8 D_us_80182A14[]; +extern s8 D_us_80182A30[][4]; +extern u8 D_us_80182A48[]; +extern dhuronUnkStruct D_us_80182A64[]; +extern u8 D_us_80182ACC[]; // Dhuron void func_us_801CC054(Entity* self) { @@ -202,9 +217,269 @@ void func_us_801CC054(Entity* self) { } // Dhuron death parts -INCLUDE_ASM("st/lib/nonmatchings/e_dhuron", func_us_801CC6B0); +void func_us_801CC6B0(Entity* self) { + s8* hitboxPtr; + Entity* tempEntity; + s32 tempVar; + + switch (self->step) { + case 0: + InitializeEntity(D_us_801808A8); + break; + + case 1: + tempEntity = self - 1; + self->facingLeft = tempEntity->facingLeft; + self->posX.i.hi = tempEntity->posX.i.hi; + self->posY.i.hi = tempEntity->posY.i.hi; + hitboxPtr = D_us_80182A30[0]; + tempVar = D_us_80182A48[tempEntity->animCurFrame]; + hitboxPtr += tempVar * 4; + self->hitboxOffX = *hitboxPtr++; + self->hitboxOffY = *hitboxPtr++; + self->hitboxWidth = *hitboxPtr++; + self->hitboxHeight = *hitboxPtr++; + if (self->ext.dhuron.unk89) { + self->attackElement |= ELEMENT_THUNDER; + self->attackElement &= ~ELEMENT_CUT; + self->attack *= 2; + self->ext.dhuron.unk89 = 0; + } + if (tempEntity->entityId != E_ID_33) { + DestroyEntity(self); + } + break; + } +} // Dhuron death -INCLUDE_ASM("st/lib/nonmatchings/e_dhuron", func_us_801CC7BC); +void func_us_801CC7BC(Entity* self) { + Collider collider; + dhuronUnkStruct* ptr; + s32 posX, posY; -INCLUDE_ASM("st/lib/nonmatchings/e_dhuron", func_us_801CC984); + switch (self->step) { + case 0: + InitializeEntity(D_us_801808B4); + self->drawFlags = FLAG_DRAW_ROTZ; + self->animCurFrame = self->params + 0x1B; + self->zPriority += self->params; + ptr = &D_us_80182A64[self->params]; + if (self->facingLeft) { + self->velocityX = ptr->velocityX; + } else { + self->velocityX = -ptr->velocityX; + } + self->velocityY = ptr->velocityY; + self->ext.dhuron.unk84 = ptr->unkA; + break; + + case 1: + MoveEntity(); + self->velocityY += FIX(2.5 / 16); + ptr = &D_us_80182A64[self->params]; + self->rotZ += ptr->rotZ; + if (!--self->ext.dhuron.unk84) { + self->drawFlags = FLAG_DRAW_DEFAULT; + self->step = 0; + self->entityId = E_EXPLOSION; + self->pfnUpdate = EntityExplosion; + self->params = 0; + PlaySfxPositional(SFX_SMALL_FLAME_IGNITE); + } + if (self->params == 6) { + posX = self->posX.i.hi; + posY = self->posY.i.hi + 4; + g_api.CheckCollision(posX, posY, &collider, 0); + if (collider.effects != EFFECT_NONE) { + PlaySfxPositional(SFX_SKULL_KNOCK_A); + self->posY.i.hi += collider.unk18; + self->velocityY = -self->velocityY; + self->velocityY -= self->velocityY / 4; + } + } + break; + } +} + +void func_us_801CC984(Entity* self) { + Primitive* prim; + Primitive* prim2; + s32 i; + u8 condition; + s16 angle, angle2; + Entity* tempEntity; + s32 primIndex; + s32 multiplier; + s16 temp; + s32 posX, posY; + + switch (self->step) { + case 0: + self->posY.i.hi = 0; + InitializeEntity(g_EInitInteractable); + primIndex = g_api.AllocPrimitives(PRIM_GT4, 0x28); + if (primIndex == -1) { + DestroyEntity(self); + return; + } + self->flags |= FLAG_HAS_PRIMS; + self->primIndex = primIndex; + prim = &g_PrimBuf[primIndex]; + self->ext.dhuron.unk7C = prim; + self->ext.dhuron.unk80 = prim; + i = 0; + while (prim != NULL) { + prim->tpage = 0x1A; + prim->clut = 0x194; + prim->u0 = prim->u1 = (i * 0x10) + 0x90; + prim->u2 = prim->u3 = prim->u0 + 0x10; + prim->v0 = prim->v2 = 0xD0; + prim->v1 = prim->v3 = 0xC0; + prim->r0 = prim->g0 = prim->b0 = 0x50; + LOW(prim->r1) = LOW(prim->r0); + LOW(prim->r2) = LOW(prim->r0); + LOW(prim->r3) = LOW(prim->r0); + prim->priority = self->zPriority - 1; + prim->drawMode = DRAW_HIDE; + prim = prim->next; + i++; + if (i > 5) { + i = 0; + } + } + prim = self->ext.dhuron.unk7C; + prim->x0 = self->posX.i.hi; + prim->y0 = self->posY.i.hi; + prim->x1 = prim->x0; + prim->y1 = prim->y1 - 0x10; + prim->x2 = self->posX.i.hi; + prim->y2 = self->posY.i.hi; + prim->x3 = prim->x2; + prim->y3 = prim->y2 - 0x10; + self->ext.dhuron.unk80 = prim; + self->ext.dhuron.unk84 = 0xC00; + LOH(self->ext.dhuron.unk88) = 0; + break; + + case 1: + prim = self->ext.dhuron.unk80; + angle2 = self->ext.dhuron.unk84; + tempEntity = self->ext.dhuron.unk9C; + posX = tempEntity->posX.i.hi; + if (tempEntity->facingLeft) { + posX -= 7; + } else { + posX += 7; + } + posY = tempEntity->posY.i.hi - 0x30; + posX -= prim->x2; + posY -= prim->y2; + if (abs(posX) < 8 && abs(posY) < 8) { + self->step = 2; + return; + } + if (abs(posX) < 0x40 && abs(posY) < 0x40) { + condition = true; + } else { + condition = false; + } + if (!LOH(self->ext.dhuron.unk88)) { + LOH(self->ext.dhuron.unk88) = 4; + if (condition) { + LOH(self->ext.dhuron.unk88) = 2; + } + temp = ratan2(-posY, posX); + angle = temp - angle2; + if (angle > 0x800) { + angle = 0x1000 - angle; + } + if (angle < -0x800) { + angle = angle + 0x1000; + } + if (!condition) { + angle /= 4; + } else { + angle /= 2; + } + self->ext.dhuron.unk86 = angle; + } + angle2 += self->ext.dhuron.unk86; + if (!condition) { + angle2 += 0x180 - ((Random() & 3) << 8); + } + angle2 &= 0xFFF; + prim2 = prim->next; + if (prim2 == NULL) { + self->step = 2; + return; + } + LOW(prim2->x0) = LOW(prim->x2); + LOW(prim2->x1) = LOW(prim->x3); + self->ext.dhuron.unk84 = angle2; + self->ext.dhuron.unk80 = prim2; + posX = (rcos(angle2) * 0xC) >> 0xC; + posY = -((rsin(angle2) * 0xC) >> 0xC); + prim2->x2 = prim2->x0 + posX; + prim2->y2 = prim2->y0 + posY; + angle = angle2 - 0x400; + multiplier = 0x10; + posX = (rcos(angle) * multiplier) >> 0xC; + posY = -((rsin(angle) * multiplier) >> 0xC); + prim2->x3 = prim2->x2 + posX; + prim2->y3 = prim2->y2 + posY; + prim2->drawMode = + DRAW_TPAGE2 | DRAW_TPAGE | DRAW_COLORS | DRAW_UNK02 | DRAW_TRANSP; + LOH(self->ext.dhuron.unk88)--; + break; + + case 2: + prim = self->ext.dhuron.unk7C; + while (prim != NULL) { + prim->drawMode = DRAW_HIDE; + prim = prim->next; + } + tempEntity = self->ext.dhuron.unk9C; + tempEntity->ext.dhuron.unk89 = 1; + posY = tempEntity->posY.i.hi; + posX = tempEntity->posX.i.hi; + self->posY.i.hi = posY + 0x18; + self->posX.i.hi = posX; + self->drawFlags = FLAG_DRAW_UNK8 | FLAG_DRAW_ROTY; + self->rotY = 0x180; + self->unk6C = 0x80; + self->drawMode = DRAW_UNK_40 | DRAW_TPAGE2 | DRAW_TPAGE; + self->palette = PAL_OVL(0x15B); + self->unk5A = 0x4E; + self->animSet = ANIMSET_OVL(4); + self->animCurFrame = 0; + self->animFrameIdx = 0; + self->animFrameDuration = 0; + self->step = 3; + break; + + case 3: + if (!AnimateEntity(D_us_80182ACC, self)) { + self->step = 4; + } + break; + + case 4: + self->posY.val -= FIX(0.25); + self->unk6C -= 8; + if (!self->unk6C) { + DestroyEntity(self); + } + break; + } + + tempEntity = self->ext.dhuron.unk9C; +#ifdef VERSION_PSP + if (tempEntity != NULL && tempEntity->entityId != E_ID_33) { +#else + if (tempEntity->entityId != E_ID_33) { +#endif + DestroyEntity(self); + return; + } +} diff --git a/src/st/lib/lib.h b/src/st/lib/lib.h index cc64bb3f47..a8220a64f5 100644 --- a/src/st/lib/lib.h +++ b/src/st/lib/lib.h @@ -40,7 +40,8 @@ typedef enum EntityIDs { /* 0x2E */ E_ID_2E, /* 0x2F */ E_ID_2F, /* 0x31 */ E_ID_31 = 0x31, - /* 0x34 */ E_ID_34 = 0x34, + /* 0x33 */ E_ID_33 = 0x33, + /* 0x34 */ E_ID_34, /* 0x35 */ E_ID_35, /* 0x36 */ E_ID_36, /* 0x3A */ E_THORNWEED = 0x3A, diff --git a/src/st/lib/unk_3C57C.c b/src/st/lib/unk_3C57C.c index 5de48ea507..181300c72a 100644 --- a/src/st/lib/unk_3C57C.c +++ b/src/st/lib/unk_3C57C.c @@ -493,7 +493,7 @@ void func_us_801BDAE4(Entity* self) { break; case 15: - self->palette = 0x8160; + self->palette = PAL_OVL(0x160); if (g_Timer % 7 == 0) { tempEntity = AllocEntity(&g_Entities[224], &g_Entities[256]); if (tempEntity != NULL) { diff --git a/src/st/no1/e_mouse.c b/src/st/no1/e_mouse.c index e4a2040e33..ae2aaafe31 100644 --- a/src/st/no1/e_mouse.c +++ b/src/st/no1/e_mouse.c @@ -18,7 +18,7 @@ void EntityMouse(Entity* self) { switch (self->step) { case 0: InitializeEntity(g_EInitCommon); - self->animSet = 0x8001; + self->animSet = ANIMSET_OVL(1); self->zPriority = PLAYER.zPriority - 0x10; self->facingLeft = true; self->animFrameIdx = 0; diff --git a/src/st/no1/e_wall_chicken_secret.c b/src/st/no1/e_wall_chicken_secret.c index a0a19182db..f92a628307 100644 --- a/src/st/no1/e_wall_chicken_secret.c +++ b/src/st/no1/e_wall_chicken_secret.c @@ -202,7 +202,7 @@ void func_us_801BEE00(Entity* self) { InitializeEntity(g_EInitParticle); self->animSet = 8; self->animCurFrame = 1; - self->palette = 0x8004; + self->palette = PAL_OVL(4); break; case 1: @@ -275,7 +275,7 @@ void func_us_801BF074(Entity* self) { InitializeEntity(g_EInitParticle); self->animSet = 8; self->animCurFrame = 1; - self->palette = 0x8004; + self->palette = PAL_OVL(4); break; case 1: diff --git a/src/st/no1/e_wereskeleton.c b/src/st/no1/e_wereskeleton.c index fa53ff9853..830adeeafe 100644 --- a/src/st/no1/e_wereskeleton.c +++ b/src/st/no1/e_wereskeleton.c @@ -213,7 +213,7 @@ void EntityWereskeleton(Entity* self) { tempEntity = AllocEntity(&g_Entities[224], &g_Entities[256]); if (tempEntity != NULL) { MakeEntityFromId(E_WERESKELETON, self, tempEntity); - tempEntity->palette = 0x8160; + tempEntity->palette = PAL_OVL(0x160); tempEntity->hitboxState = 0; tempEntity->facingLeft = self->facingLeft; tempEntity->flags = FLAG_DESTROY_IF_OUT_OF_CAMERA | diff --git a/src/st/no1/unk_35E20.c b/src/st/no1/unk_35E20.c index 2efbdba7bb..87a9f57fe6 100644 --- a/src/st/no1/unk_35E20.c +++ b/src/st/no1/unk_35E20.c @@ -129,7 +129,7 @@ void func_us_801B6198(Entity* self) { case 0: if (self->params & 0x100) { InitializeEntity(g_EInitInteractable); - self->animSet = 0x8018; + self->animSet = ANIMSET_OVL(24); self->unk5A = 0x5B; self->palette = 0x22D; self->animCurFrame = 0x15; diff --git a/src/st/no1/unk_381E8.c b/src/st/no1/unk_381E8.c index 2f2c2386da..96aae891a2 100644 --- a/src/st/no1/unk_381E8.c +++ b/src/st/no1/unk_381E8.c @@ -111,7 +111,7 @@ void func_us_801B84E4(Entity* self) { self->ext.et_801B84E4.unk7E = self->ext.et_801B84E4.unk7C + 0x20; self->velocityX = FIX(-1.375); self->posY.i.hi -= 0x16; - self->animSet = 0x8001; + self->animSet = ANIMSET_OVL(1); self->zPriority = PLAYER.zPriority; self->animFrameDuration = self->animFrameIdx = 0; self->anim = D_us_80181044; @@ -637,7 +637,7 @@ void func_us_801B9BE4(Entity* self) { (self + 1)->posY.i.hi += 0x10; self->step = 3; } else { - self->palette = 0x8041; + self->palette = PAL_OVL(0x41); self->hitboxState = 3; self->hitboxWidth = 6; self->hitboxHeight = 0x12; diff --git a/src/st/no1/unk_3D8AC.c b/src/st/no1/unk_3D8AC.c index 971fb065e1..8ae25b5479 100644 --- a/src/st/no1/unk_3D8AC.c +++ b/src/st/no1/unk_3D8AC.c @@ -127,7 +127,7 @@ void func_us_801BDA0C(Entity* self) { self->ext.et_801BDA0C.unk80 = 0; break; case 1: - self->palette = 0x804F; + self->palette = PAL_OVL(0x4F); if (self->ext.et_801BDA0C.unk84) { self->step++; } @@ -157,7 +157,7 @@ void func_us_801BDA0C(Entity* self) { self->palette++; if (self->palette > 0x8058) { g_api.PlaySfx(SFX_ELECTRICITY); - self->palette = 0x804F; + self->palette = PAL_OVL(0x4F); self->step++; if (self->params == 5) { (self + 1)->ext.et_801BDA0C.unk84 = 1; diff --git a/src/st/no1/unk_3FA34.c b/src/st/no1/unk_3FA34.c index 8bb68160a7..7fd1089fa3 100644 --- a/src/st/no1/unk_3FA34.c +++ b/src/st/no1/unk_3FA34.c @@ -268,7 +268,7 @@ void func_us_801C01F0(Entity* self) { InitializeEntity(g_EInitParticle); self->animSet = 8; self->animCurFrame = 0; - self->palette = 0x8004; + self->palette = PAL_OVL(4); break; case 1: diff --git a/src/st/np3/48238.c b/src/st/np3/48238.c index 8d9de550d1..50fdbfa6ad 100644 --- a/src/st/np3/48238.c +++ b/src/st/np3/48238.c @@ -435,7 +435,7 @@ void func_801C8F54(Entity* self) { void EntityMermanExplosion(Entity* self) { if (self->step == 0) { InitializeEntity(g_EInitParticle); - self->palette = 0x82BB; + self->palette = PAL_OVL(0x2BB); self->animSet = ANIMSET_DRA(2); self->animCurFrame = D_80182454[self->params]; self->velocityY = D_80182440[self->params]; diff --git a/src/st/np3/gaibon.c b/src/st/np3/gaibon.c index 5620eebc2d..7808442cef 100644 --- a/src/st/np3/gaibon.c +++ b/src/st/np3/gaibon.c @@ -721,7 +721,7 @@ void EntitySmallGaibonProjectile(Entity* self) { self->rotX = 0xC0; self->velocityX = (rcos(self->rotZ) * 0x28000) >> 0xC; self->velocityY = (rsin(self->rotZ) * 0x28000) >> 0xC; - self->palette = 0x81B6; + self->palette = PAL_OVL(0x1B6); self->rotZ -= 0x400; case 1: @@ -751,7 +751,7 @@ void EntityLargeGaibonProjectile(Entity* self) { self->drawFlags = FLAG_DRAW_ROTZ; self->velocityX = (rcos(self->rotZ) * 0x38000) >> 0xC; self->velocityY = (rsin(self->rotZ) * 0x38000) >> 0xC; - self->palette = 0x81B6; + self->palette = PAL_OVL(0x1B6); self->rotZ -= 0x400; } else { self->animSet = ANIMSET_DRA(14); @@ -759,7 +759,7 @@ void EntityLargeGaibonProjectile(Entity* self) { self->drawFlags = FLAG_DRAW_ROTX | FLAG_DRAW_ROTZ | FLAG_DRAW_UNK8; self->rotX = 0x100; self->unk6C = 0x80; - self->palette = 0x81F3; + self->palette = PAL_OVL(0x1F3); self->drawMode = DRAW_TPAGE2 | DRAW_TPAGE; self->step = 2; self->hitboxState = 0; diff --git a/src/st/nz0/311C0.c b/src/st/nz0/311C0.c index 0a58c2a54e..39c96acf90 100644 --- a/src/st/nz0/311C0.c +++ b/src/st/nz0/311C0.c @@ -716,7 +716,7 @@ void EntityCannonShot(Entity* self) { InitializeEntity(g_EInitInteractable); self->animSet = ANIMSET_DRA(2); self->animCurFrame = 1; - self->palette = 0x81AF; + self->palette = PAL_OVL(0x1AF); self->zPriority = 0x6F; self->velocityX = FIX(-8); diff --git a/src/st/nz0/e_subweapon_container.c b/src/st/nz0/e_subweapon_container.c index 79f3a15565..1df1e4b045 100644 --- a/src/st/nz0/e_subweapon_container.c +++ b/src/st/nz0/e_subweapon_container.c @@ -210,7 +210,7 @@ void func_801C7654(Entity* entity) { case 0: InitializeEntity(g_EInitParticle); entity->animSet = ANIMSET_DRA(2); - entity->palette = 0x816D; + entity->palette = PAL_OVL(0x16D); entity->drawMode = DRAW_UNK_40 | DRAW_TPAGE2 | DRAW_TPAGE; entity->velocityX = rcos(entity->rotZ) * 0x10; entity->velocityY = rsin(entity->rotZ) * 0x10; diff --git a/src/st/nz0/gaibon.c b/src/st/nz0/gaibon.c index 25836aa4b4..886ad0eee0 100644 --- a/src/st/nz0/gaibon.c +++ b/src/st/nz0/gaibon.c @@ -618,7 +618,7 @@ void EntitySmallGaibonProjectile(Entity* self) { self->rotX = 0xC0; self->velocityX = (rcos(self->rotZ) * 0x28000) >> 0xC; self->velocityY = (rsin(self->rotZ) * 0x28000) >> 0xC; - self->palette = 0x81B6; + self->palette = PAL_OVL(0x1B6); self->rotZ -= 0x400; case 1: @@ -649,7 +649,7 @@ void EntityLargeGaibonProjectile(Entity* self) { self->drawFlags = FLAG_DRAW_ROTZ; self->velocityX = (rcos(self->rotZ) * 0x38000) >> 0xC; self->velocityY = (rsin(self->rotZ) * 0x38000) >> 0xC; - self->palette = 0x81B6; + self->palette = PAL_OVL(0x1B6); self->rotZ -= 0x400; } else { self->animSet = ANIMSET_DRA(14); @@ -657,7 +657,7 @@ void EntityLargeGaibonProjectile(Entity* self) { self->drawFlags = FLAG_DRAW_ROTX | FLAG_DRAW_ROTZ | FLAG_DRAW_UNK8; self->rotX = 0x100; self->unk6C = 0x80; - self->palette = 0x81F3; + self->palette = PAL_OVL(0x1F3); self->drawMode = DRAW_TPAGE2 | DRAW_TPAGE; self->step = 2; self->hitboxState = 0; diff --git a/src/st/sel/3410C.c b/src/st/sel/3410C.c index a359112f93..63c2959c73 100644 --- a/src/st/sel/3410C.c +++ b/src/st/sel/3410C.c @@ -521,7 +521,7 @@ void func_801B5350(void) { self->posY.i.hi = 159; self->zPriority = 0xC0; self->unk5A = 0; - self->palette = 0x8100; + self->palette = PAL_OVL(0x100); self->step = 1; break; @@ -557,7 +557,7 @@ void func_801B54C8(void) { self->ext.unkSelEnts.unk80.val = FIX(120); self->posY.i.hi = 158; self->zPriority = 0xC0; - self->palette = 0x8210; + self->palette = PAL_OVL(0x210); self->step = 1; } } @@ -572,7 +572,7 @@ void func_801B5548(void) { self->ext.unkSelEnts.unk80.val = FIX(120); self->posY.i.hi = 158; self->zPriority = 0xC0; - self->palette = 0x8210; + self->palette = PAL_OVL(0x210); self->facingLeft = 0; self->step = 1; } diff --git a/src/st/sel/3585C.c b/src/st/sel/3585C.c index fd487429c3..00a6b62310 100644 --- a/src/st/sel/3585C.c +++ b/src/st/sel/3585C.c @@ -17,7 +17,7 @@ void func_801B585C(u16 arg0) { self->animCurFrame = 0; self->unk5A = 0; self->ext.unkSelEnts.unk80.val = 0; - self->palette = 0x8100; + self->palette = PAL_OVL(0x100); self->step++; break; diff --git a/src/st/st0/2DAC8.c b/src/st/st0/2DAC8.c index bfb4bb896a..cee91fa536 100644 --- a/src/st/st0/2DAC8.c +++ b/src/st/st0/2DAC8.c @@ -601,7 +601,7 @@ void EntityDraculaFinalForm(Entity* self) { if (--self->ext.dracFinalForm.timer == 0) { self->animCurFrame = 0x5A; self->unk5A = 0x5E; - self->palette = 0x815F; + self->palette = PAL_OVL(0x15F); self->drawMode = DRAW_TPAGE2 | DRAW_TPAGE; self->drawFlags = FLAG_DRAW_UNK8 | FLAG_DRAW_ROTY | FLAG_DRAW_ROTX; @@ -625,7 +625,7 @@ void EntityDraculaFinalForm(Entity* self) { if (D_801C2578 == 0) { self->animCurFrame = 1; self->unk5A = 0x50; - self->palette = 0x815F; + self->palette = PAL_OVL(0x15F); self->drawFlags = FLAG_DRAW_UNK8; self->unk6C = 0; self->drawMode = DRAW_TPAGE2 | DRAW_TPAGE; diff --git a/src/st/st0/3AB08.c b/src/st/st0/3AB08.c index adc8a9e0d8..4aa82b9041 100644 --- a/src/st/st0/3AB08.c +++ b/src/st/st0/3AB08.c @@ -713,7 +713,7 @@ void EntityCutscenePhotographFire(Entity* entity) { InitializeEntity(g_EInit3DObject); entity->animSet = ANIMSET_OVL(7); entity->unk5A = 0x57; - entity->palette = 0x8285; + entity->palette = PAL_OVL(0x285); entity->drawFlags = FLAG_DRAW_UNK8; entity->unk6C = 0x40; entity->flags &= ~FLAG_POS_CAMERA_LOCKED; diff --git a/src/weapon/w_029.c b/src/weapon/w_029.c index a98e7da45c..d435fd0a97 100644 --- a/src/weapon/w_029.c +++ b/src/weapon/w_029.c @@ -221,13 +221,13 @@ static void EntityWeaponShieldSpell(Entity* self) { } SetSpriteBank1(g_Animset); if (g_HandId != 0) { - self->animSet = -0x7FEE; + self->animSet = ANIMSET_OVL(18); self->ext.weapon.childPalette = 0x128; self->unk5A = 0x66; self->ext.shield.unk7C = 0; self->ext.shield.unk7D = 0x80; } else { - self->animSet = -0x7FF0; + self->animSet = ANIMSET_OVL(16); self->ext.weapon.childPalette = 0x110; self->unk5A = 0x64; self->ext.shield.unk7C = 0x80;