From 88024b24ff0548e121db34a52e640e6bd2bc0d9d Mon Sep 17 00:00:00 2001 From: sozud <122322823+sozud@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:02:21 -0700 Subject: [PATCH] More dedupes (#1555) --- config/symbols.us.stcen.txt | 1 + config/symbols.us.stdre.txt | 1 + config/symbols.us.stno3.txt | 1 + config/symbols.us.stnp3.txt | 1 + config/symbols.us.stnz0.txt | 1 + config/symbols.us.stst0.txt | 1 + src/st/cen/18084.c | 262 +------------------------------- src/st/dre/1E1C8.c | 264 +-------------------------------- src/st/e_misc.h | 263 +------------------------------- src/st/initialize_unk_entity.h | 25 ++++ src/st/mad/15520.c | 40 +---- src/st/make_entity_from_id.h | 20 +++ src/st/make_explosions.h | 19 +++ src/st/no3/48A84.c | 257 +------------------------------- src/st/no3/53F38.c | 2 +- src/st/np3/48238.c | 2 +- src/st/np3/e_misc.c | 261 +------------------------------- src/st/nz0/4070C.c | 261 +------------------------------- src/st/nz0/e_spittle_bone.c | 6 +- src/st/st0/37308.c | 260 +------------------------------- src/st/unk_collision_func4.h | 171 +++++++++++++++++++++ src/st/unk_collision_func5.h | 23 +++ 22 files changed, 307 insertions(+), 1835 deletions(-) create mode 100644 src/st/initialize_unk_entity.h create mode 100644 src/st/make_entity_from_id.h create mode 100644 src/st/make_explosions.h create mode 100644 src/st/unk_collision_func4.h create mode 100644 src/st/unk_collision_func5.h diff --git a/config/symbols.us.stcen.txt b/config/symbols.us.stcen.txt index aa6bc4fd5..89833953a 100644 --- a/config/symbols.us.stcen.txt +++ b/config/symbols.us.stcen.txt @@ -5,6 +5,7 @@ unk14_yVel = 0x80181148; unk14_startFrame = 0x80181160; unk14_lifetime = 0x80181164; g_olroxDroolCollOffsets = 0x8018116C; +g_UnkEntityAnimData = 0x80181174; g_UnkRecursPrimVecOrder = 0x80181184; g_UnkRecursPrim2Inds = 0x801811A4; g_ESoulStealOrbAngles = 0x801811C8; diff --git a/config/symbols.us.stdre.txt b/config/symbols.us.stdre.txt index a1fa7cb27..820dd747d 100644 --- a/config/symbols.us.stdre.txt +++ b/config/symbols.us.stdre.txt @@ -23,6 +23,7 @@ unk14_yVel = 0x8018130C; unk14_startFrame = 0x80181324; unk14_lifetime = 0x80181328; g_olroxDroolCollOffsets = 0x80181330; +g_UnkEntityAnimData = 0x80181338; g_UnkRecursPrimVecOrder = 0x80181348; g_UnkRecursPrim2Inds = 0x80181368; g_ESoulStealOrbAngles = 0x8018138C; diff --git a/config/symbols.us.stno3.txt b/config/symbols.us.stno3.txt index 6e01540df..abdf5f1e7 100644 --- a/config/symbols.us.stno3.txt +++ b/config/symbols.us.stno3.txt @@ -23,6 +23,7 @@ unk14_yVel = 0x80182650; unk14_startFrame = 0x80182668; unk14_lifetime = 0x8018266C; g_olroxDroolCollOffsets = 0x80182674; +g_UnkEntityAnimData = 0x8018267C; g_UnkRecursPrimVecOrder = 0x8018268C; g_UnkRecursPrim2Inds = 0x801826AC; g_ESoulStealOrbAngles = 0x801826D0; diff --git a/config/symbols.us.stnp3.txt b/config/symbols.us.stnp3.txt index afb8dfecf..d0b7baff2 100644 --- a/config/symbols.us.stnp3.txt +++ b/config/symbols.us.stnp3.txt @@ -8,6 +8,7 @@ unk14_yVel = 0x80181FDC; unk14_startFrame = 0x80181FF4; unk14_lifetime = 0x80181FF8; g_olroxDroolCollOffsets = 0x80182000; +g_UnkEntityAnimData = 0x80182008; g_UnkRecursPrimVecOrder = 0x80182018; g_UnkRecursPrim2Inds = 0x80182038; g_ESoulStealOrbAngles = 0x8018205C; diff --git a/config/symbols.us.stnz0.txt b/config/symbols.us.stnz0.txt index e8eb2199f..00642d208 100644 --- a/config/symbols.us.stnz0.txt +++ b/config/symbols.us.stnz0.txt @@ -10,6 +10,7 @@ unk14_yVel = 0x80181F04; unk14_startFrame = 0x80181F1C; unk14_lifetime = 0x80181F20; g_olroxDroolCollOffsets = 0x80181F28; +g_UnkEntityAnimData = 0x80181F30; g_UnkRecursPrimVecOrder = 0x80181F40; g_UnkRecursPrim2Inds = 0x80181F60; g_eBlueDoorUV = 0x801826B8; diff --git a/config/symbols.us.stst0.txt b/config/symbols.us.stst0.txt index 61ea58107..44bb360de 100644 --- a/config/symbols.us.stst0.txt +++ b/config/symbols.us.stst0.txt @@ -20,6 +20,7 @@ unk14_yVel = 0x80181ED8; unk14_startFrame = 0x80181EF0; unk14_lifetime = 0x80181EF4; g_olroxDroolCollOffsets = 0x80181EFC; +g_UnkEntityAnimData = 0x80181F04; g_UnkRecursPrimVecOrder = 0x80181F14; g_UnkRecursPrim2Inds = 0x80181F34; g_ESoulStealOrbAngles = 0x80181F54; diff --git a/src/st/cen/18084.c b/src/st/cen/18084.c index 84efe6538..1cc476212 100644 --- a/src/st/cen/18084.c +++ b/src/st/cen/18084.c @@ -14,270 +14,18 @@ #include "../entity_olrox_drool.h" -bool func_801988B0(Point16* unk) { - Collider collider; +#include "../unk_collision_func5.h" - FallEntity(); - g_CurrentEntity->posX.val += g_CurrentEntity->velocityX; - g_CurrentEntity->posY.val += g_CurrentEntity->velocityY; - - if (g_CurrentEntity->velocityY >= 0) { - s16 posX = g_CurrentEntity->posX.i.hi; - s16 posY = g_CurrentEntity->posY.i.hi; - posX += unk->x; - posY += unk->y; - g_api.CheckCollision(posX, posY, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - g_CurrentEntity->posY.i.hi += collider.unk18; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY / 2; - if (g_CurrentEntity->velocityY > FIX(-1.0)) { - return true; - } - } - } - return false; -} - -u8 func_801989AC(s32 arg0) { - Collider collider; - u32 bits_67; - u32 bits_45; - u32 bits_23; - u8 bits_01; - u16 collEff; - - MoveEntity(); - bits_67 = 0; - bits_23 = 0; - bits_45 = 0; - bits_01 = arg0 & 3; - collEff = 0; - switch (bits_01) { - case 0: - g_CurrentEntity->posY.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk18; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi - 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 1: - g_CurrentEntity->posY.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk20; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi + 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 2: - g_CurrentEntity->posX.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk14; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi - 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - break; - - case 3: - g_CurrentEntity->posX.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk1C; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi + 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } - - if (collEff & EFFECT_UNK_8000) { - bits_23 = 4; - } - if (collEff & EFFECT_UNK_1000) { - bits_23 = 8; - } - if (collEff & EFFECT_UNK_2000) { - bits_23 = 0xC; - } - if (collEff & EFFECT_UNK_0800) { - bits_45 = 0x20; - } - if (collEff & EFFECT_UNK_4000) { - bits_45 = 0x10; - } - bits_01 = (bits_45 + (bits_23 + (bits_67 + bits_01))); - return bits_01; -} +#include "../unk_collision_func4.h" // ID 06 #include "../entity_intense_explosion.h" -extern u8 D_80181174[]; +#include "../initialize_unk_entity.h" -void func_8019902C(Entity* entity) { - if (!entity->step) { - InitializeEntity(g_InitializeEntityData0); - entity->unk6C = 0xF0; - entity->rotX = 0x1A0; - entity->rotY = 0x1A0; - entity->animSet = ANIMSET_DRA(8); - entity->animCurFrame = 1; - entity->zPriority += 0x10; +#include "../make_entity_from_id.h" - if (entity->params != 0) { - entity->palette = entity->params; - } else { - entity->palette = 0x8160; - } - - entity->step++; - return; - } - - MoveEntity(); - - if (!AnimateEntity(D_80181174, entity)) { - DestroyEntity(entity); - } -} - -void func_801990F8(u16 entityId, Entity* src, Entity* dst) { - DestroyEntity(dst); - dst->entityId = entityId; - dst->pfnUpdate = PfnEntityUpdates[entityId - 1]; - dst->posX.i.hi = src->posX.i.hi; - dst->posY.i.hi = src->posY.i.hi; - dst->unk5A = src->unk5A; - dst->zPriority = src->zPriority; - dst->animSet = src->animSet; - dst->flags = FLAG_UNK_2000 | FLAG_UNK_01000000 | FLAG_UNK_04000000 | - FLAG_UNK_08000000 | FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA | - FLAG_DESTROY_IF_OUT_OF_CAMERA; - - if (src->palette & 0x8000) { - dst->palette = src->hitEffect; - } else { - dst->palette = src->palette; - } -} - -void func_801991C0(void) { - Entity* entity; - s8 temp_s4 = Random() & 3; - s16 temp_s3 = ((Random() & 0xF) << 8) - 0x800; - s32 i; - - for (i = 0; i < 6; i++) { - entity = AllocEntity(&g_Entities[224], &g_Entities[256]); - if (entity != NULL) { - CreateEntityFromEntity(2, g_CurrentEntity, entity); - entity->ext.generic.unk84.U8.unk1 = 6 - i; - entity->ext.generic.unk80.modeS16.unk0 = temp_s3; - entity->ext.generic.unk84.U8.unk0 = temp_s4; - } - } -} +#include "../make_explosions.h" #include "../entity_big_red_fireball.h" diff --git a/src/st/dre/1E1C8.c b/src/st/dre/1E1C8.c index 31bcdc3da..3dc84ab97 100644 --- a/src/st/dre/1E1C8.c +++ b/src/st/dre/1E1C8.c @@ -14,271 +14,17 @@ #include "../entity_olrox_drool.h" -bool func_8019E9F4(Point16* arg0) { - Collider collider; +#include "../unk_collision_func5.h" - FallEntity(); - g_CurrentEntity->posX.val += g_CurrentEntity->velocityX; - g_CurrentEntity->posY.val += g_CurrentEntity->velocityY; - - if (g_CurrentEntity->velocityY >= 0) { - s16 posX = g_CurrentEntity->posX.i.hi; - s16 posY = g_CurrentEntity->posY.i.hi; - posX += arg0->x; - posY += arg0->y; - - g_api.CheckCollision(posX, posY, &collider, 0); - - if (collider.effects & EFFECT_SOLID) { - g_CurrentEntity->posY.i.hi += collider.unk18; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY / 2; - - if (g_CurrentEntity->velocityY > FIX(-1.0)) { - return true; - } - } - } - - return false; -} - -u8 func_8019EAF0(s32 arg0) { - Collider collider; - u32 bits_67; - u32 bits_45; - u32 bits_23; - u8 bits_01; - u16 collEff; - - MoveEntity(); - bits_67 = 0; - bits_23 = 0; - bits_45 = 0; - bits_01 = arg0 & 3; - collEff = 0; - switch (bits_01) { - case 0: - g_CurrentEntity->posY.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk18; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi - 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 1: - g_CurrentEntity->posY.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk20; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi + 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 2: - g_CurrentEntity->posX.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk14; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi - 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - break; - - case 3: - g_CurrentEntity->posX.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk1C; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi + 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } - - if (collEff & EFFECT_UNK_8000) { - bits_23 = 4; - } - if (collEff & EFFECT_UNK_1000) { - bits_23 = 8; - } - if (collEff & EFFECT_UNK_2000) { - bits_23 = 0xC; - } - if (collEff & EFFECT_UNK_0800) { - bits_45 = 0x20; - } - if (collEff & EFFECT_UNK_4000) { - bits_45 = 0x10; - } - bits_01 = (bits_45 + (bits_23 + (bits_67 + bits_01))); - return bits_01; -} +#include "../unk_collision_func4.h" #include "../entity_intense_explosion.h" -void func_8019F170(Entity* entity) { - if (!entity->step) { - InitializeEntity(g_InitializeEntityData0); - entity->unk6C = 0xF0; - entity->rotX = 0x1A0; - entity->rotY = 0x1A0; - entity->animSet = ANIMSET_DRA(8); - entity->animCurFrame = 1; - entity->zPriority += 0x10; +#include "../initialize_unk_entity.h" - if (entity->params != 0) { - entity->palette = entity->params; - } else { - entity->palette = 0x8160; - } +#include "../make_entity_from_id.h" - entity->step++; - return; - } - - MoveEntity(); - - if (!AnimateEntity(D_80181338, entity)) { - DestroyEntity(entity); - } -} - -void func_8019F23C(u16 entityId, Entity* src, Entity* dst) { - DestroyEntity(dst); - dst->entityId = entityId; - dst->pfnUpdate = PfnEntityUpdates[entityId - 1]; - dst->posX.i.hi = src->posX.i.hi; - dst->posY.i.hi = src->posY.i.hi; - dst->unk5A = src->unk5A; - dst->zPriority = src->zPriority; - dst->animSet = src->animSet; - dst->flags = FLAG_UNK_2000 | FLAG_UNK_01000000 | FLAG_UNK_04000000 | - FLAG_UNK_08000000 | FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA | - FLAG_DESTROY_IF_OUT_OF_CAMERA; - - if (src->palette & 0x8000) { - dst->palette = src->hitEffect; - } else { - dst->palette = src->palette; - } -} - -void func_8019F304(void) { - Entity* entity; - s8 temp_s4 = Random() & 3; - s16 temp_s3 = ((Random() & 0xF) << 8) - 0x800; - s32 i; - - for (i = 0; i < 6; i++) { - entity = AllocEntity(&g_Entities[224], &g_Entities[256]); - if (entity != NULL) { - CreateEntityFromEntity(2, g_CurrentEntity, entity); - entity->ext.generic.unk84.U8.unk1 = 6 - i; - entity->ext.generic.unk80.modeS16.unk0 = temp_s3; - entity->ext.generic.unk84.U8.unk0 = temp_s4; - } - } -} +#include "../make_explosions.h" #include "../entity_big_red_fireball.h" diff --git a/src/st/e_misc.h b/src/st/e_misc.h index 279d88748..b03025c4b 100644 --- a/src/st/e_misc.h +++ b/src/st/e_misc.h @@ -117,272 +117,21 @@ u32 g_olroxDroolCollOffsets[] = { }; #include "entity_olrox_drool.h" -bool func_8018FC4C(Point16* unk) { - Collider collider; +#include "unk_collision_func5.h" - FallEntity(); - g_CurrentEntity->posX.val += g_CurrentEntity->velocityX; - g_CurrentEntity->posY.val += g_CurrentEntity->velocityY; - - if (g_CurrentEntity->velocityY >= 0) { - s16 posX = g_CurrentEntity->posX.i.hi; - s16 posY = g_CurrentEntity->posY.i.hi; - posX += unk->x; - posY += unk->y; - g_api.CheckCollision(posX, posY, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - g_CurrentEntity->posY.i.hi += collider.unk18; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY / 2; - if (g_CurrentEntity->velocityY > FIX(-1.0)) { - return true; - } - } - } - return false; -} - -u8 func_8018FD48(s32 arg0) { - Collider collider; - u32 bits_67; - u32 bits_45; - u32 bits_23; - u8 bits_01; - u16 collEff; - - MoveEntity(); - bits_67 = 0; - bits_23 = 0; - bits_45 = 0; - bits_01 = arg0 & 3; - collEff = 0; - switch (bits_01) { - case 0: - g_CurrentEntity->posY.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk18; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi - 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 1: - g_CurrentEntity->posY.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk20; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi + 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 2: - g_CurrentEntity->posX.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk14; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi - 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - break; - - case 3: - g_CurrentEntity->posX.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk1C; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi + 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } - - if (collEff & EFFECT_UNK_8000) { - bits_23 = 4; - } - if (collEff & EFFECT_UNK_1000) { - bits_23 = 8; - } - if (collEff & EFFECT_UNK_2000) { - bits_23 = 0xC; - } - if (collEff & EFFECT_UNK_0800) { - bits_45 = 0x20; - } - if (collEff & EFFECT_UNK_4000) { - bits_45 = 0x10; - } - bits_01 = (bits_45 + (bits_23 + (bits_67 + bits_01))); - return bits_01; -} +#include "unk_collision_func4.h" #include "entity_intense_explosion.h" -u8 D_8018104C[] = { +u8 g_UnkEntityAnimData[] = { 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 4, 6, -1, }; -void func_801903C8(Entity* self) { - if (!self->step) { - InitializeEntity(g_InitializeEntityData0); - self->unk6C = 0xF0; - self->rotX = 0x01A0; - self->rotY = 0x01A0; - self->animSet = ANIMSET_DRA(8); - self->animCurFrame = 1; - self->zPriority += 16; - if (self->params) { - self->palette = self->params; - } else { - self->palette = PAL_OVL(0x160); - } +#include "initialize_unk_entity.h" - self->step++; - } else { - MoveEntity(); - if (!AnimateEntity(D_8018104C, self)) { - DestroyEntity(self); - } - } -} +#include "make_entity_from_id.h" -extern PfnEntityUpdate PfnEntityUpdates[]; -void func_80190494(u16 entityId, Entity* src, Entity* dst) { - DestroyEntity(dst); - dst->entityId = entityId; - dst->pfnUpdate = PfnEntityUpdates[entityId - 1]; - dst->posX.i.hi = src->posX.i.hi; - dst->posY.i.hi = src->posY.i.hi; - dst->unk5A = src->unk5A; - dst->zPriority = src->zPriority; - dst->animSet = src->animSet; - dst->flags = FLAG_UNK_2000 | FLAG_UNK_01000000 | FLAG_UNK_04000000 | - FLAG_UNK_08000000 | FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA | - FLAG_DESTROY_IF_OUT_OF_CAMERA; - - if (src->palette & PAL_OVL_FLAG) { - dst->palette = src->hitEffect; - } else { - dst->palette = src->palette; - } -} - -void func_8019055C(void) { - s32 temp_s3; - s8 temp_s4; - Entity* entity; - s32 i; - - temp_s4 = Random() & 3; - temp_s3 = ((Random() & 0xF) << 8) - 0x800; - - for (i = 0; i < 6; i++) { - entity = AllocEntity(&g_Entities[224], &g_Entities[256]); - if (entity != NULL) { - CreateEntityFromEntity(E_EXPLOSION, g_CurrentEntity, entity); - entity->ext.generic.unk84.U8.unk1 = 6 - i; - entity->ext.generic.unk80.modeS16.unk0 = temp_s3; - entity->ext.generic.unk84.U8.unk0 = temp_s4; - } - } -} +#include "make_explosions.h" extern u8 g_bigRedFireballAnim[]; u16 g_UnkRecursPrimVecOrder[] = { diff --git a/src/st/initialize_unk_entity.h b/src/st/initialize_unk_entity.h new file mode 100644 index 000000000..8f6a368f3 --- /dev/null +++ b/src/st/initialize_unk_entity.h @@ -0,0 +1,25 @@ +extern u8 g_UnkEntityAnimData[]; +void InitializeUnkEntity(Entity* self) { + if (!self->step) { + InitializeEntity(g_InitializeEntityData0); + self->unk6C = 0xF0; + self->rotX = 0x01A0; + self->rotY = 0x01A0; + self->animSet = ANIMSET_DRA(8); + self->animCurFrame = 1; + self->zPriority += 16; + + if (self->params) { + self->palette = self->params; + } else { + self->palette = PAL_OVL(0x160); + } + + self->step++; + } else { + MoveEntity(); + if (!AnimateEntity(g_UnkEntityAnimData, self)) { + DestroyEntity(self); + } + } +} diff --git a/src/st/mad/15520.c b/src/st/mad/15520.c index 070a88092..b090bb5fe 100644 --- a/src/st/mad/15520.c +++ b/src/st/mad/15520.c @@ -312,45 +312,9 @@ void func_801966B0(u16* sensors) { } } -void func_8019686C(u16 entityId, Entity* src, Entity* dst) { - DestroyEntity(dst); - dst->entityId = entityId; - dst->pfnUpdate = PfnEntityUpdates[entityId - 1]; - dst->posX.i.hi = src->posX.i.hi; - dst->posY.i.hi = src->posY.i.hi; - dst->unk5A = src->unk5A; - dst->zPriority = src->zPriority; - dst->animSet = src->animSet; - dst->flags = FLAG_UNK_2000 | FLAG_UNK_01000000 | FLAG_UNK_04000000 | - FLAG_UNK_08000000 | FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA | - FLAG_DESTROY_IF_OUT_OF_CAMERA; +#include "../make_entity_from_id.h" - if (src->palette & 0x8000) { - dst->palette = src->hitEffect; - } else { - dst->palette = src->palette; - } -} - -void func_80196934(void) { - Entity* entity; - s16 temp_s3; - s32 i; - u8 temp_s4; - - temp_s4 = Random() & 3; - temp_s3 = ((Random() & 0xF) << 8) - 0x800; - - for (i = 0; i < 6; i++) { - entity = AllocEntity(&g_Entities[224], &g_Entities[256]); - if (entity != NULL) { - CreateEntityFromEntity(2, g_CurrentEntity, entity); - entity->ext.generic.unk84.U8.unk1 = 6 - i; - entity->ext.generic.unk80.modeS16.unk0 = temp_s3; - entity->ext.generic.unk84.U8.unk0 = temp_s4; - } - } -} +#include "../make_explosions.h" #include "../entity_big_red_fireball.h" diff --git a/src/st/make_entity_from_id.h b/src/st/make_entity_from_id.h new file mode 100644 index 000000000..d2688fd32 --- /dev/null +++ b/src/st/make_entity_from_id.h @@ -0,0 +1,20 @@ +extern PfnEntityUpdate PfnEntityUpdates[]; +void MakeEntityFromId(u16 entityId, Entity* src, Entity* dst) { + DestroyEntity(dst); + dst->entityId = entityId; + dst->pfnUpdate = PfnEntityUpdates[entityId - 1]; + dst->posX.i.hi = src->posX.i.hi; + dst->posY.i.hi = src->posY.i.hi; + dst->unk5A = src->unk5A; + dst->zPriority = src->zPriority; + dst->animSet = src->animSet; + dst->flags = FLAG_UNK_2000 | FLAG_UNK_01000000 | FLAG_UNK_04000000 | + FLAG_UNK_08000000 | FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA | + FLAG_DESTROY_IF_OUT_OF_CAMERA; + + if (src->palette & PAL_OVL_FLAG) { + dst->palette = src->hitEffect; + } else { + dst->palette = src->palette; + } +} diff --git a/src/st/make_explosions.h b/src/st/make_explosions.h new file mode 100644 index 000000000..22f958904 --- /dev/null +++ b/src/st/make_explosions.h @@ -0,0 +1,19 @@ +void MakeExplosions(void) { + s32 temp_s3; + s8 temp_s4; + Entity* entity; + s32 i; + + temp_s4 = Random() & 3; + temp_s3 = ((Random() & 0xF) << 8) - 0x800; + + for (i = 0; i < 6; i++) { + entity = AllocEntity(&g_Entities[224], &g_Entities[256]); + if (entity != NULL) { + CreateEntityFromEntity(E_EXPLOSION, g_CurrentEntity, entity); + entity->ext.generic.unk84.U8.unk1 = 6 - i; + entity->ext.generic.unk80.modeS16.unk0 = temp_s3; + entity->ext.generic.unk84.U8.unk0 = temp_s4; + } + } +} diff --git a/src/st/no3/48A84.c b/src/st/no3/48A84.c index d7bb4c412..36bbe51c3 100644 --- a/src/st/no3/48A84.c +++ b/src/st/no3/48A84.c @@ -14,264 +14,17 @@ #include "../entity_olrox_drool.h" -bool func_801C92B0(Point16* unk) { - Collider collider; +#include "../unk_collision_func5.h" - FallEntity(); - g_CurrentEntity->posX.val += g_CurrentEntity->velocityX; - g_CurrentEntity->posY.val += g_CurrentEntity->velocityY; - - if (g_CurrentEntity->velocityY >= 0) { - s16 posX = g_CurrentEntity->posX.i.hi; - s16 posY = g_CurrentEntity->posY.i.hi; - posX += unk->x; - posY += unk->y; - g_api.CheckCollision(posX, posY, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - g_CurrentEntity->posY.i.hi += collider.unk18; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY / 2; - if (g_CurrentEntity->velocityY > FIX(-1.0)) { - return true; - } - } - } - return false; -} - -u8 func_801C93AC(s32 arg0) { - Collider collider; - u32 bits_67; - u32 bits_45; - u32 bits_23; - u8 bits_01; - u16 collEff; - - MoveEntity(); - bits_67 = 0; - bits_23 = 0; - bits_45 = 0; - bits_01 = arg0 & 3; - collEff = 0; - switch (bits_01) { - case 0: - g_CurrentEntity->posY.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk18; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi - 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 1: - g_CurrentEntity->posY.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk20; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi + 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 2: - g_CurrentEntity->posX.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk14; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi - 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - break; - - case 3: - g_CurrentEntity->posX.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk1C; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi + 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } - - if (collEff & EFFECT_UNK_8000) { - bits_23 = 4; - } - if (collEff & EFFECT_UNK_1000) { - bits_23 = 8; - } - if (collEff & EFFECT_UNK_2000) { - bits_23 = 0xC; - } - if (collEff & EFFECT_UNK_0800) { - bits_45 = 0x20; - } - if (collEff & EFFECT_UNK_4000) { - bits_45 = 0x10; - } - bits_01 = (bits_45 + (bits_23 + (bits_67 + bits_01))); - return bits_01; -} +#include "../unk_collision_func4.h" #include "../entity_intense_explosion.h" -void func_801903C8(Entity* entity) { - if (entity->step == 0) { - InitializeEntity(g_InitializeEntityData0); - entity->unk6C = 0xF0; - entity->rotX = 0x01A0; - entity->rotY = 0x01A0; - entity->animSet = ANIMSET_DRA(8); - entity->animCurFrame = 1; - entity->zPriority += 16; - if (entity->params) { - entity->palette = entity->params; - } else { - entity->palette = 0x8160; - } +#include "../initialize_unk_entity.h" - entity->step++; - } else { - MoveEntity(); - if (!AnimateEntity(D_8018267C, entity)) { - DestroyEntity(entity); - } - } -} +#include "../make_entity_from_id.h" -void func_801C9AF8(u16 entityId, Entity* src, Entity* dst) { - DestroyEntity(dst); - dst->entityId = entityId; - dst->pfnUpdate = PfnEntityUpdates[entityId - 1]; - dst->posX.i.hi = src->posX.i.hi; - dst->posY.i.hi = src->posY.i.hi; - dst->unk5A = src->unk5A; - dst->zPriority = src->zPriority; - dst->animSet = src->animSet; - dst->flags = FLAG_UNK_2000 | FLAG_UNK_01000000 | FLAG_UNK_04000000 | - FLAG_UNK_08000000 | FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA | - FLAG_DESTROY_IF_OUT_OF_CAMERA; - - if (src->palette & 0x8000) { - dst->palette = src->hitEffect; - } else { - dst->palette = src->palette; - } -} - -void func_801C9BC0(void) { - Entity* entity; - s8 temp_s4 = Random() & 3; - s16 temp_s3 = ((Random() & 0xF) << 8) - 0x800; - s32 i; - - for (i = 0; i < 6; i++) { - entity = AllocEntity(&g_Entities[224], &g_Entities[256]); - if (entity != NULL) { - CreateEntityFromEntity(2, g_CurrentEntity, entity); - entity->ext.generic.unk84.U8.unk1 = 6 - i; - entity->ext.generic.unk80.modeS16.unk0 = temp_s3; - entity->ext.generic.unk84.U8.unk0 = temp_s4; - } - } -} +#include "../make_explosions.h" #include "../entity_big_red_fireball.h" diff --git a/src/st/no3/53F38.c b/src/st/no3/53F38.c index c7bd0fa55..d1880eb6a 100644 --- a/src/st/no3/53F38.c +++ b/src/st/no3/53F38.c @@ -289,7 +289,7 @@ void EntityMerman(Entity* self) { if (collider.effects & EFFECT_SOLID) { self->velocityX = 0; } - func_801C92B0(&D_80183A5C); + UnkCollisionFunc5(&D_80183A5C); if (self->facingLeft != 0) { self->velocityX -= FIX(0.03125); } else { diff --git a/src/st/np3/48238.c b/src/st/np3/48238.c index d38e16373..ddb8b17dc 100644 --- a/src/st/np3/48238.c +++ b/src/st/np3/48238.c @@ -280,7 +280,7 @@ void EntityMerman(Entity* self) { if (collider.effects & EFFECT_SOLID) { self->velocityX = 0; } - func_8018FC4C(&D_8018236C); + UnkCollisionFunc5(&D_8018236C); if (self->facingLeft != 0) { self->velocityX -= FIX(0.03125); } else { diff --git a/src/st/np3/e_misc.c b/src/st/np3/e_misc.c index 5d1c84163..f76f360d7 100644 --- a/src/st/np3/e_misc.c +++ b/src/st/np3/e_misc.c @@ -53,268 +53,17 @@ void EntityHeartDrop(Entity* self) { #include "../entity_olrox_drool.h" -bool func_8018FC4C(Point16* unk) { - Collider collider; +#include "../unk_collision_func5.h" - FallEntity(); - g_CurrentEntity->posX.val += g_CurrentEntity->velocityX; - g_CurrentEntity->posY.val += g_CurrentEntity->velocityY; - - if (g_CurrentEntity->velocityY >= 0) { - s16 posX = g_CurrentEntity->posX.i.hi; - s16 posY = g_CurrentEntity->posY.i.hi; - posX += unk->x; - posY += unk->y; - g_api.CheckCollision(posX, posY, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - g_CurrentEntity->posY.i.hi += collider.unk18; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY / 2; - if (g_CurrentEntity->velocityY > FIX(-1.0)) { - return true; - } - } - } - return false; -} - -u8 func_8018FD48(s32 arg0) { - Collider collider; - u32 bits_67; - u32 bits_45; - u32 bits_23; - u8 bits_01; - u16 collEff; - - MoveEntity(); - bits_67 = 0; - bits_23 = 0; - bits_45 = 0; - bits_01 = arg0 & 3; - collEff = 0; - switch (bits_01) { - case 0: - g_CurrentEntity->posY.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk18; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi - 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 1: - g_CurrentEntity->posY.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk20; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi + 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 2: - g_CurrentEntity->posX.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk14; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi - 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - break; - - case 3: - g_CurrentEntity->posX.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk1C; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi + 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } - - if (collEff & EFFECT_UNK_8000) { - bits_23 = 4; - } - if (collEff & EFFECT_UNK_1000) { - bits_23 = 8; - } - if (collEff & EFFECT_UNK_2000) { - bits_23 = 0xC; - } - if (collEff & EFFECT_UNK_0800) { - bits_45 = 0x20; - } - if (collEff & EFFECT_UNK_4000) { - bits_45 = 0x10; - } - bits_01 = (bits_45 + (bits_23 + (bits_67 + bits_01))); - return bits_01; -} +#include "../unk_collision_func4.h" #include "../entity_intense_explosion.h" -void func_801903C8(Entity* entity) { - if (entity->step == 0) { - InitializeEntity(g_InitializeEntityData0); - entity->unk6C = 0xF0; - entity->rotX = 0x1A0; - entity->rotY = 0x1A0; - entity->animSet = ANIMSET_DRA(8); - entity->animCurFrame = 1; - entity->zPriority += 0x10; +#include "../initialize_unk_entity.h" - if (entity->params != 0) { - entity->palette = entity->params; - } else { - entity->palette = 0x8160; - } +#include "../make_entity_from_id.h" - entity->step++; - } else { - MoveEntity(); - if (!AnimateEntity(D_80182008, entity)) { - DestroyEntity(entity); - } - } -} - -void func_80190494(u16 entityId, Entity* src, Entity* dst) { - DestroyEntity(dst); - dst->entityId = entityId; - dst->pfnUpdate = PfnEntityUpdates[entityId - 1]; - dst->posX.i.hi = src->posX.i.hi; - dst->posY.i.hi = src->posY.i.hi; - dst->unk5A = src->unk5A; - dst->zPriority = src->zPriority; - dst->animSet = src->animSet; - dst->flags = FLAG_UNK_2000 | FLAG_UNK_01000000 | FLAG_UNK_04000000 | - FLAG_UNK_08000000 | FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA | - FLAG_DESTROY_IF_OUT_OF_CAMERA; - - if (src->palette & 0x8000) { - dst->palette = src->hitEffect; - } else { - dst->palette = src->palette; - } -} - -void func_8019055C(void) { - s32 temp_s3; - s8 temp_s4; - Entity* entity; - s32 i; - - temp_s4 = Random() & 3; - temp_s3 = ((Random() & 0xF) << 8) - 0x800; - - for (i = 0; i < 6; i++) { - entity = AllocEntity(&g_Entities[224], &g_Entities[256]); - if (entity != NULL) { - CreateEntityFromEntity(E_EXPLOSION, g_CurrentEntity, entity); - entity->ext.generic.unk84.U8.unk1 = 6 - i; - entity->ext.generic.unk80.modeS16.unk0 = temp_s3; - entity->ext.generic.unk84.U8.unk0 = temp_s4; - } - } -} +#include "../make_explosions.h" #include "../entity_big_red_fireball.h" diff --git a/src/st/nz0/4070C.c b/src/st/nz0/4070C.c index 08c65dbe5..16ef70822 100644 --- a/src/st/nz0/4070C.c +++ b/src/st/nz0/4070C.c @@ -14,268 +14,17 @@ #include "../entity_olrox_drool.h" -bool func_801C0F38(Point16* unk) { - Collider collider; +#include "../unk_collision_func5.h" - FallEntity(); - g_CurrentEntity->posX.val += g_CurrentEntity->velocityX; - g_CurrentEntity->posY.val += g_CurrentEntity->velocityY; - - if (g_CurrentEntity->velocityY >= 0) { - s16 posX = g_CurrentEntity->posX.i.hi; - s16 posY = g_CurrentEntity->posY.i.hi; - posX += unk->x; - posY += unk->y; - g_api.CheckCollision(posX, posY, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - g_CurrentEntity->posY.i.hi += collider.unk18; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY / 2; - if (g_CurrentEntity->velocityY > FIX(-1.0)) { - return true; - } - } - } - return false; -} - -u8 func_801C1034(s32 arg0) { - Collider collider; - u32 bits_67; - u32 bits_45; - u32 bits_23; - u8 bits_01; - u16 collEff; - - MoveEntity(); - bits_67 = 0; - bits_23 = 0; - bits_45 = 0; - bits_01 = arg0 & 3; - collEff = 0; - switch (bits_01) { - case 0: - g_CurrentEntity->posY.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk18; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi - 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 1: - g_CurrentEntity->posY.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk20; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi + 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 2: - g_CurrentEntity->posX.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk14; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi - 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - break; - - case 3: - g_CurrentEntity->posX.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk1C; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi + 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } - - if (collEff & EFFECT_UNK_8000) { - bits_23 = 4; - } - if (collEff & EFFECT_UNK_1000) { - bits_23 = 8; - } - if (collEff & EFFECT_UNK_2000) { - bits_23 = 0xC; - } - if (collEff & EFFECT_UNK_0800) { - bits_45 = 0x20; - } - if (collEff & EFFECT_UNK_4000) { - bits_45 = 0x10; - } - bits_01 = (bits_45 + (bits_23 + (bits_67 + bits_01))); - return bits_01; -} +#include "../unk_collision_func4.h" #include "../entity_intense_explosion.h" -void func_801C16B4(Entity* entity) { - if (entity->step == 0) { - InitializeEntity(g_InitializeEntityData0); - entity->unk6C = 0xF0; - entity->rotX = 0x1A0; - entity->rotY = 0x1A0; - entity->animSet = ANIMSET_DRA(8); - entity->animCurFrame = 1; - entity->zPriority += 0x10; +#include "../initialize_unk_entity.h" - if (entity->params != 0) { - entity->palette = entity->params; - } else { - entity->palette = 0x8160; - } +#include "../make_entity_from_id.h" - entity->step++; - } else { - MoveEntity(); - if (!AnimateEntity(D_80181F30, entity)) { - DestroyEntity(entity); - } - } -} - -void func_801C1780(u16 entityId, Entity* src, Entity* dst) { - DestroyEntity(dst); - dst->entityId = entityId; - dst->pfnUpdate = PfnEntityUpdates[entityId - 1]; - dst->posX.i.hi = src->posX.i.hi; - dst->posY.i.hi = src->posY.i.hi; - dst->unk5A = src->unk5A; - dst->zPriority = src->zPriority; - dst->animSet = src->animSet; - dst->flags = FLAG_UNK_2000 | FLAG_UNK_01000000 | FLAG_UNK_04000000 | - FLAG_UNK_08000000 | FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA | - FLAG_DESTROY_IF_OUT_OF_CAMERA; - - if (src->palette & 0x8000) { - dst->palette = src->hitEffect; - } else { - dst->palette = src->palette; - } -} - -void func_8019055C(void) { - s32 temp_s3; - s8 temp_s4; - Entity* entity; - s32 i; - - temp_s4 = Random() & 3; - temp_s3 = ((Random() & 0xF) << 8) - 0x800; - - for (i = 0; i < 6; i++) { - entity = AllocEntity(&g_Entities[224], &g_Entities[256]); - if (entity != NULL) { - CreateEntityFromEntity(E_EXPLOSION, g_CurrentEntity, entity); - entity->ext.generic.unk84.U8.unk1 = 6 - i; - entity->ext.generic.unk80.modeS16.unk0 = temp_s3; - entity->ext.generic.unk84.U8.unk0 = temp_s4; - } - } -} +#include "../make_explosions.h" #include "../entity_big_red_fireball.h" diff --git a/src/st/nz0/e_spittle_bone.c b/src/st/nz0/e_spittle_bone.c index 2e9128e85..70f2f572f 100644 --- a/src/st/nz0/e_spittle_bone.c +++ b/src/st/nz0/e_spittle_bone.c @@ -46,7 +46,7 @@ void EntitySpittleBone(Entity* self) { case 2: AnimateEntity(D_80182524, self); self->ext.spittleBone.unk7C = - func_801C1034(self->ext.spittleBone.unk7C); + UnkCollisionFunc4(self->ext.spittleBone.unk7C); if (self->ext.spittleBone.unk82 != 0) { self->rotZ += self->ext.spittleBone.unk80; self->ext.spittleBone.unk82--; @@ -71,7 +71,7 @@ void EntitySpittleBone(Entity* self) { for (i = 0; i < 6; i++) { newEntity = AllocEntity(&g_Entities[224], &g_Entities[256]); if (newEntity != NULL) { - func_801C1780(E_SPITTLEBONE, self, newEntity); + MakeEntityFromId(E_SPITTLEBONE, self, newEntity); newEntity->facingLeft = self->facingLeft; newEntity->flags = FLAG_UNK_2000 | FLAG_UNK_08000000 | FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA | @@ -131,7 +131,7 @@ void EntityRotateSpittlebone(Entity* self) { case 1: temp1 = self->ext.spittleBone.unk7C & 0x3F; prevEntity = &self[-1]; - temp4 = func_801C1034(self->ext.spittleBone.unk7C); + temp4 = UnkCollisionFunc4(self->ext.spittleBone.unk7C); self->ext.spittleBone.unk7C = temp4; if ((temp4 & 0x3F) != temp1) { temp2 = temp4 & 0x3C; diff --git a/src/st/st0/37308.c b/src/st/st0/37308.c index e52c0b8b0..db30e3a83 100644 --- a/src/st/st0/37308.c +++ b/src/st/st0/37308.c @@ -18,267 +18,17 @@ INCLUDE_ASM("st/st0/nonmatchings/37308", func_801B7308); #include "../entity_olrox_drool.h" -bool func_801B8338(Point16* unk) { - Collider collider; +#include "../unk_collision_func5.h" - FallEntity(); - g_CurrentEntity->posX.val += g_CurrentEntity->velocityX; - g_CurrentEntity->posY.val += g_CurrentEntity->velocityY; - - if (g_CurrentEntity->velocityY >= 0) { - s16 posX = g_CurrentEntity->posX.i.hi; - s16 posY = g_CurrentEntity->posY.i.hi; - posX += unk->x; - posY += unk->y; - g_api.CheckCollision(posX, posY, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - g_CurrentEntity->posY.i.hi += collider.unk18; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY / 2; - if (g_CurrentEntity->velocityY > FIX(-1.0)) { - return true; - } - } - } - return false; -} - -u8 func_801B8434(s32 arg0) { - Collider collider; - u32 bits_67; - u32 bits_45; - u32 bits_23; - u8 bits_01; - u16 collEff; - - MoveEntity(); - bits_67 = 0; - bits_23 = 0; - bits_45 = 0; - bits_01 = arg0 & 3; - collEff = 0; - switch (bits_01) { - case 0: - g_CurrentEntity->posY.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk18; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi - 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 1: - g_CurrentEntity->posY.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posY.i.hi += collider.unk20; - g_api.CheckCollision( - g_CurrentEntity->posX.i.hi, - (s16)(g_CurrentEntity->posY.i.hi + 4), &collider, 0); - if (collider.effects & EFFECT_UNK_0002) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 2; - } else { - bits_01 = 3; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; - if (g_CurrentEntity->velocityX > 0) { - bits_01 = 3; - } else { - bits_01 = 2; - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; - } - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; - g_CurrentEntity->velocityX = 0; - } - break; - - case 2: - g_CurrentEntity->posX.i.hi += 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk14; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi - 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - break; - - case 3: - g_CurrentEntity->posX.i.hi -= 3; - g_api.CheckCollision(g_CurrentEntity->posX.i.hi, - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects != 0) { - collEff = collider.effects; - g_CurrentEntity->posX.i.hi += collider.unk1C; - g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi + 4), - g_CurrentEntity->posY.i.hi, &collider, 0); - if (collider.effects & EFFECT_SOLID) { - bits_67 = 0x40; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 0; - } else { - bits_01 = 1; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } else { - bits_67 = 0x80; - g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; - if (g_CurrentEntity->velocityY > 0) { - bits_01 = 1; - } else { - bits_01 = 0; - g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; - } - g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; - g_CurrentEntity->velocityY = 0; - } - } - - if (collEff & EFFECT_UNK_8000) { - bits_23 = 4; - } - if (collEff & EFFECT_UNK_1000) { - bits_23 = 8; - } - if (collEff & EFFECT_UNK_2000) { - bits_23 = 0xC; - } - if (collEff & EFFECT_UNK_0800) { - bits_45 = 0x20; - } - if (collEff & EFFECT_UNK_4000) { - bits_45 = 0x10; - } - bits_01 = (bits_45 + (bits_23 + (bits_67 + bits_01))); - return bits_01; -} +#include "../unk_collision_func4.h" #include "../entity_intense_explosion.h" -void func_801B8AB4(Entity* entity) { - if (entity->step == 0) { - InitializeEntity(g_InitializeEntityData0); - entity->unk6C = 0xF0; - entity->rotX = 0x01A0; - entity->rotY = 0x01A0; - entity->animSet = ANIMSET_DRA(8); - entity->animCurFrame = 1; - entity->zPriority += 16; - if (entity->params) { - entity->palette = entity->params; - } else { - entity->palette = 0x8160; - } +#include "../initialize_unk_entity.h" - entity->step++; - } else { - MoveEntity(); - if (!AnimateEntity(D_80181F04, entity)) { - DestroyEntity(entity); - } - } -} +#include "../make_entity_from_id.h" -void func_801B8B80(u16 entityId, Entity* src, Entity* dst) { - DestroyEntity(dst); - dst->entityId = entityId; - dst->pfnUpdate = PfnEntityUpdates[entityId - 1]; - dst->posX.i.hi = src->posX.i.hi; - dst->posY.i.hi = src->posY.i.hi; - dst->unk5A = src->unk5A; - dst->zPriority = src->zPriority; - dst->animSet = src->animSet; - dst->flags = FLAG_UNK_2000 | FLAG_UNK_01000000 | FLAG_UNK_04000000 | - FLAG_UNK_08000000 | FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA | - FLAG_DESTROY_IF_OUT_OF_CAMERA; - - if (src->palette & 0x8000) { - dst->palette = src->hitEffect; - } else { - dst->palette = src->palette; - } -} - -void func_801B8C48(void) { - s32 temp_s3; - s8 temp_s4; - Entity* entity; - s32 i; - - temp_s4 = Random() & 3; - temp_s3 = ((Random() & 0xF) << 8) - 0x800; - - for (i = 0; i < 6; i++) { - entity = AllocEntity(&g_Entities[224], &g_Entities[256]); - if (entity != NULL) { - CreateEntityFromEntity(E_EXPLOSION, g_CurrentEntity, entity); - entity->ext.generic.unk84.U8.unk1 = 6 - i; - entity->ext.generic.unk80.modeS16.unk0 = temp_s3; - entity->ext.generic.unk84.U8.unk0 = temp_s4; - } - } -} +#include "../make_explosions.h" #include "../entity_big_red_fireball.h" diff --git a/src/st/unk_collision_func4.h b/src/st/unk_collision_func4.h new file mode 100644 index 000000000..268124a4b --- /dev/null +++ b/src/st/unk_collision_func4.h @@ -0,0 +1,171 @@ +u8 UnkCollisionFunc4(s32 arg0) { + Collider collider; + u32 bits_67; + u32 bits_45; + u32 bits_23; + u8 bits_01; + u16 collEff; + + MoveEntity(); + bits_67 = 0; + bits_23 = 0; + bits_45 = 0; + bits_01 = arg0 & 3; + collEff = 0; + switch (bits_01) { + case 0: + g_CurrentEntity->posY.i.hi += 3; + g_api.CheckCollision(g_CurrentEntity->posX.i.hi, + g_CurrentEntity->posY.i.hi, &collider, 0); + if (collider.effects != 0) { + collEff = collider.effects; + g_CurrentEntity->posY.i.hi += collider.unk18; + g_api.CheckCollision( + g_CurrentEntity->posX.i.hi, + (s16)(g_CurrentEntity->posY.i.hi - 4), &collider, 0); + if (collider.effects & EFFECT_UNK_0002) { + bits_67 = 0x40; + if (g_CurrentEntity->velocityX > 0) { + bits_01 = 2; + } else { + bits_01 = 3; + g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; + } + g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; + g_CurrentEntity->velocityX = 0; + } + } else { + bits_67 = 0x80; + g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; + if (g_CurrentEntity->velocityX > 0) { + bits_01 = 3; + } else { + bits_01 = 2; + g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; + } + g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; + g_CurrentEntity->velocityX = 0; + } + break; + + case 1: + g_CurrentEntity->posY.i.hi -= 3; + g_api.CheckCollision(g_CurrentEntity->posX.i.hi, + g_CurrentEntity->posY.i.hi, &collider, 0); + if (collider.effects != 0) { + collEff = collider.effects; + g_CurrentEntity->posY.i.hi += collider.unk20; + g_api.CheckCollision( + g_CurrentEntity->posX.i.hi, + (s16)(g_CurrentEntity->posY.i.hi + 4), &collider, 0); + if (collider.effects & EFFECT_UNK_0002) { + bits_67 = 0x40; + if (g_CurrentEntity->velocityX > 0) { + bits_01 = 2; + } else { + bits_01 = 3; + g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; + } + g_CurrentEntity->velocityY = g_CurrentEntity->velocityX; + g_CurrentEntity->velocityX = 0; + } + } else { + bits_67 = 0x80; + g_CurrentEntity->posX.val -= g_CurrentEntity->velocityX; + if (g_CurrentEntity->velocityX > 0) { + bits_01 = 3; + } else { + bits_01 = 2; + g_CurrentEntity->velocityX = -g_CurrentEntity->velocityX; + } + g_CurrentEntity->velocityY = -g_CurrentEntity->velocityX; + g_CurrentEntity->velocityX = 0; + } + break; + + case 2: + g_CurrentEntity->posX.i.hi += 3; + g_api.CheckCollision(g_CurrentEntity->posX.i.hi, + g_CurrentEntity->posY.i.hi, &collider, 0); + if (collider.effects != 0) { + collEff = collider.effects; + g_CurrentEntity->posX.i.hi += collider.unk14; + g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi - 4), + g_CurrentEntity->posY.i.hi, &collider, 0); + if (collider.effects & EFFECT_SOLID) { + bits_67 = 0x40; + if (g_CurrentEntity->velocityY > 0) { + bits_01 = 0; + } else { + bits_01 = 1; + g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; + } + g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; + g_CurrentEntity->velocityY = 0; + } + } else { + bits_67 = 0x80; + g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; + if (g_CurrentEntity->velocityY > 0) { + bits_01 = 1; + } else { + bits_01 = 0; + g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; + } + g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; + g_CurrentEntity->velocityY = 0; + } + break; + + case 3: + g_CurrentEntity->posX.i.hi -= 3; + g_api.CheckCollision(g_CurrentEntity->posX.i.hi, + g_CurrentEntity->posY.i.hi, &collider, 0); + if (collider.effects != 0) { + collEff = collider.effects; + g_CurrentEntity->posX.i.hi += collider.unk1C; + g_api.CheckCollision((s16)(g_CurrentEntity->posX.i.hi + 4), + g_CurrentEntity->posY.i.hi, &collider, 0); + if (collider.effects & EFFECT_SOLID) { + bits_67 = 0x40; + if (g_CurrentEntity->velocityY > 0) { + bits_01 = 0; + } else { + bits_01 = 1; + g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; + } + g_CurrentEntity->velocityX = g_CurrentEntity->velocityY; + g_CurrentEntity->velocityY = 0; + } + } else { + bits_67 = 0x80; + g_CurrentEntity->posY.val -= g_CurrentEntity->velocityY; + if (g_CurrentEntity->velocityY > 0) { + bits_01 = 1; + } else { + bits_01 = 0; + g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY; + } + g_CurrentEntity->velocityX = -g_CurrentEntity->velocityY; + g_CurrentEntity->velocityY = 0; + } + } + + if (collEff & EFFECT_UNK_8000) { + bits_23 = 4; + } + if (collEff & EFFECT_UNK_1000) { + bits_23 = 8; + } + if (collEff & EFFECT_UNK_2000) { + bits_23 = 0xC; + } + if (collEff & EFFECT_UNK_0800) { + bits_45 = 0x20; + } + if (collEff & EFFECT_UNK_4000) { + bits_45 = 0x10; + } + bits_01 = (bits_45 + (bits_23 + (bits_67 + bits_01))); + return bits_01; +} diff --git a/src/st/unk_collision_func5.h b/src/st/unk_collision_func5.h new file mode 100644 index 000000000..40accc7d9 --- /dev/null +++ b/src/st/unk_collision_func5.h @@ -0,0 +1,23 @@ +bool UnkCollisionFunc5(Point16* unk) { + Collider collider; + + FallEntity(); + g_CurrentEntity->posX.val += g_CurrentEntity->velocityX; + g_CurrentEntity->posY.val += g_CurrentEntity->velocityY; + + if (g_CurrentEntity->velocityY >= 0) { + s16 posX = g_CurrentEntity->posX.i.hi; + s16 posY = g_CurrentEntity->posY.i.hi; + posX += unk->x; + posY += unk->y; + g_api.CheckCollision(posX, posY, &collider, 0); + if (collider.effects & EFFECT_SOLID) { + g_CurrentEntity->posY.i.hi += collider.unk18; + g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY / 2; + if (g_CurrentEntity->velocityY > FIX(-1.0)) { + return true; + } + } + } + return false; +}