summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorengineer124 <engineer124engineer124@gmail.com>2022-01-04 19:21:01 +1100
committerengineer124 <engineer124engineer124@gmail.com>2022-01-04 19:21:01 +1100
commit6ae618545f83f5522ec4847bfccab18458bf6f8a (patch)
tree5407af415616a76c9e5b3ea71a2fe688b7a76040 /src/code
parent542bbfdeea2b4647ad82ad5b9b2c733a4be29b46 (diff)
parentb74bec0e1d9d6f46f7e218eb14e274fd05dc43cb (diff)
Merge branch 'master' into parameter
Diffstat (limited to 'src/code')
-rw-r--r--src/code/graph.c26
-rw-r--r--src/code/z_effect_soft_sprite.c107
-rw-r--r--src/code/z_effect_soft_sprite_dlftbls.c56
-rw-r--r--src/code/z_effect_soft_sprite_old_init.c118
-rw-r--r--src/code/z_en_hy.c2
-rw-r--r--src/code/z_en_item00.c192
-rw-r--r--src/code/z_sub_s.c110
7 files changed, 359 insertions, 252 deletions
diff --git a/src/code/graph.c b/src/code/graph.c
index 7ef1715fd..b874fef51 100644
--- a/src/code/graph.c
+++ b/src/code/graph.c
@@ -88,33 +88,27 @@ GameStateOverlay* Graph_GetNextGameState(GameState* gameState) {
return NULL;
}
-#ifdef NON_MATCHING
-// Regalloc differences
void* Graph_FaultAddrConvFunc(void* address, void* param) {
- u32 addr = address;
- GameStateOverlay* gamestateOvl;
- u32 ramConv;
- u32 ramStart;
- u32 diff;
+ uintptr_t addr = address;
+ GameStateOverlay* gamestateOvl = &gGameStateOverlayTable[0];
+ uintptr_t ramConv;
+ void* ramStart;
+ uintptr_t diff;
s32 i;
- for (i = 0; i < graphNumGameStates; i++) {
- gamestateOvl = &gGameStateOverlayTable[i];
+ for (i = 0; i < graphNumGameStates; i++, gamestateOvl++) {
+ diff = (uintptr_t)gamestateOvl->vramEnd - (uintptr_t)gamestateOvl->vramStart;
ramStart = gamestateOvl->loadedRamAddr;
- diff = (u32)gamestateOvl->vramEnd - (u32)gamestateOvl->vramStart;
- ramConv = (u32)gamestateOvl->vramStart - ramStart;
+ ramConv = (uintptr_t)gamestateOvl->vramStart - (uintptr_t)ramStart;
- if (gamestateOvl->loadedRamAddr != NULL) {
- if (addr >= ramStart && addr < ramStart + diff) {
+ if (ramStart != NULL) {
+ if (addr >= (uintptr_t)ramStart && addr < (uintptr_t)ramStart + diff) {
return addr + ramConv;
}
}
}
return NULL;
}
-#else
-#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_FaultAddrConvFunc.s")
-#endif
void Graph_Init(GraphicsContext* gfxCtx) {
bzero(gfxCtx, sizeof(GraphicsContext));
diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c
index 47c2202f1..424166f89 100644
--- a/src/code/z_effect_soft_sprite.c
+++ b/src/code/z_effect_soft_sprite.c
@@ -1,20 +1,22 @@
#include "global.h"
+EffectSsInfo sEffectSsInfo = { NULL, 0, 0 };
+
void EffectSS_Init(GlobalContext* globalCtx, s32 numEntries) {
u32 i;
EffectSs* effectsSs;
EffectSsOverlay* overlay;
- EffectSS2Info.data_table = (EffectSs*)THA_AllocEndAlign16(&globalCtx->state.heap, numEntries * sizeof(EffectSs));
- EffectSS2Info.searchIndex = 0;
- EffectSS2Info.size = numEntries;
+ sEffectSsInfo.data_table = (EffectSs*)THA_AllocEndAlign16(&globalCtx->state.heap, numEntries * sizeof(EffectSs));
+ sEffectSsInfo.searchIndex = 0;
+ sEffectSsInfo.size = numEntries;
- for (effectsSs = &EffectSS2Info.data_table[0]; effectsSs < &EffectSS2Info.data_table[EffectSS2Info.size];
+ for (effectsSs = &sEffectSsInfo.data_table[0]; effectsSs < &sEffectSsInfo.data_table[sEffectSsInfo.size];
effectsSs++) {
EffectSS_ResetEntry(effectsSs);
}
- overlay = &particleOverlayTable[0];
+ overlay = &gParticleOverlayTable[0];
for (i = 0; i < EFFECT_SS_MAX; i++) {
overlay->loadedRamAddr = NULL;
overlay++;
@@ -27,30 +29,31 @@ void EffectSS_Clear(GlobalContext* globalCtx) {
EffectSsOverlay* overlay;
void* addr;
- EffectSS2Info.data_table = NULL;
- EffectSS2Info.searchIndex = 0;
- EffectSS2Info.size = 0;
+ sEffectSsInfo.data_table = NULL;
+ sEffectSsInfo.searchIndex = 0;
+ sEffectSsInfo.size = 0;
- // This code is completely useless, as data_table was just set to NULL and size to 0
- for (effectsSs = EffectSS2Info.data_table; effectsSs < EffectSS2Info.data_table + EffectSS2Info.size; effectsSs++) {
+ //! @bug: Effects left in the table are not properly deleted, as data_table was just set to NULL and size to 0
+ for (effectsSs = &sEffectSsInfo.data_table[0]; effectsSs < &sEffectSsInfo.data_table[sEffectSsInfo.size];
+ effectsSs++) {
EffectSS_Delete(effectsSs);
}
// Free memory from loaded particle overlays
- overlay = &particleOverlayTable[0];
+ overlay = &gParticleOverlayTable[0];
for (i = 0; i < EFFECT_SS_MAX; i++) {
addr = overlay->loadedRamAddr;
if (addr != NULL) {
ZeldaArena_Free(addr);
}
- overlay->loadedRamAddr = 0;
+ overlay->loadedRamAddr = NULL;
overlay++;
}
}
EffectSs* EffectSS_GetTable() {
- return EffectSS2Info.data_table;
+ return sEffectSsInfo.data_table;
}
void EffectSS_Delete(EffectSs* effectSs) {
@@ -90,27 +93,27 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) {
s32 foundFree;
s32 i;
- if (EffectSS2Info.searchIndex >= EffectSS2Info.size) {
- EffectSS2Info.searchIndex = 0;
+ if (sEffectSsInfo.searchIndex >= sEffectSsInfo.size) {
+ sEffectSsInfo.searchIndex = 0;
}
// Search for a unused entry
- i = EffectSS2Info.searchIndex;
+ i = sEffectSsInfo.searchIndex;
foundFree = false;
while (true) {
- if (EffectSS2Info.data_table[i].life == -1) {
+ if (sEffectSsInfo.data_table[i].life == -1) {
foundFree = true;
break;
}
i++;
- if (i >= EffectSS2Info.size) {
+ if (i >= sEffectSsInfo.size) {
i = 0; // Loop around the whole table
}
// After a full loop, break out
- if (i == EffectSS2Info.searchIndex) {
+ if (i == sEffectSsInfo.searchIndex) {
break;
}
}
@@ -122,22 +125,22 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) {
// If all slots are in use, search for a slot with a lower priority
// Note that a lower priority is representend by a higher value
- i = EffectSS2Info.searchIndex;
+ i = sEffectSsInfo.searchIndex;
while (true) {
// Equal priority should only be considered "lower" if flag 0 is set
- if ((priority <= EffectSS2Info.data_table[i].priority) &&
- !((priority == EffectSS2Info.data_table[i].priority) && (EffectSS2Info.data_table[i].flags & 1))) {
+ if ((priority <= sEffectSsInfo.data_table[i].priority) &&
+ !((priority == sEffectSsInfo.data_table[i].priority) && (sEffectSsInfo.data_table[i].flags & 1))) {
break;
}
i++;
- if (i >= EffectSS2Info.size) {
+ if (i >= sEffectSsInfo.size) {
i = 0; // Loop around the whole table
}
// After a full loop, return 1 to indicate that we failed to find a suitable slot
- if (i == EffectSS2Info.searchIndex) {
+ if (i == sEffectSsInfo.searchIndex) {
return true;
}
}
@@ -151,8 +154,8 @@ void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) {
if (FrameAdvance_IsEnabled(globalCtx) != true) {
if (EffectSS_FindFreeSpace(effectsSs->priority, &index) == 0) {
- EffectSS2Info.searchIndex = index + 1;
- EffectSS2Info.data_table[index] = *effectsSs;
+ sEffectSsInfo.searchIndex = index + 1;
+ sEffectSsInfo.data_table[index] = *effectsSs;
}
}
}
@@ -160,7 +163,7 @@ void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) {
void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* initData) {
s32 index;
u32 overlaySize;
- EffectSsOverlay* entry = &particleOverlayTable[type];
+ EffectSsOverlay* entry = &gParticleOverlayTable[type];
EffectSsInit* initInfo;
if (EffectSS_FindFreeSpace(priority, &index) != 0) {
@@ -168,8 +171,8 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init
return;
}
- EffectSS2Info.searchIndex = index + 1;
- overlaySize = (u32)entry->vramEnd - (u32)entry->vramStart;
+ sEffectSsInfo.searchIndex = index + 1;
+ overlaySize = (uintptr_t)entry->vramEnd - (uintptr_t)entry->vramStart;
if (entry->vramStart == NULL) {
initInfo = entry->initInfo;
@@ -184,27 +187,27 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init
Load2_LoadOverlay(entry->vromStart, entry->vromEnd, entry->vramStart, entry->vramEnd, entry->loadedRamAddr);
}
- initInfo = (void*)(u32)(
- entry->initInfo != NULL
- ? (EffectSsInit*)(-((u32)entry->vramStart - (u32)entry->loadedRamAddr) + (u32)entry->initInfo)
- : NULL);
+ initInfo = (u32)((entry->initInfo != NULL)
+ ? (EffectSsInit*)(-((uintptr_t)entry->vramStart - (uintptr_t)entry->loadedRamAddr) +
+ (uintptr_t)entry->initInfo)
+ : NULL);
}
if (initInfo->init != NULL) {
// Delete the previous effect in the slot, in case the slot wasn't free
- EffectSS_Delete(&EffectSS2Info.data_table[index]);
+ EffectSS_Delete(&sEffectSsInfo.data_table[index]);
- EffectSS2Info.data_table[index].type = type;
- EffectSS2Info.data_table[index].priority = priority;
+ sEffectSsInfo.data_table[index].type = type;
+ sEffectSsInfo.data_table[index].priority = priority;
- if (initInfo->init(globalCtx, index, &EffectSS2Info.data_table[index], initData) == 0) {
- EffectSS_ResetEntry(&EffectSS2Info.data_table[index]);
+ if (initInfo->init(globalCtx, index, &sEffectSsInfo.data_table[index], initData) == 0) {
+ EffectSS_ResetEntry(&sEffectSsInfo.data_table[index]);
}
}
}
void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index) {
- EffectSs* particle = &EffectSS2Info.data_table[index];
+ EffectSs* particle = &sEffectSsInfo.data_table[index];
if (particle->update != NULL) {
particle->velocity.x += particle->accel.x;
@@ -222,23 +225,23 @@ void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index) {
void EffectSS_UpdateAllParticles(GlobalContext* globalCtx) {
s32 i;
- for (i = 0; i < EffectSS2Info.size; i++) {
- if (EffectSS2Info.data_table[i].life > -1) {
- EffectSS2Info.data_table[i].life--;
+ for (i = 0; i < sEffectSsInfo.size; i++) {
+ if (sEffectSsInfo.data_table[i].life > -1) {
+ sEffectSsInfo.data_table[i].life--;
- if (EffectSS2Info.data_table[i].life < 0) {
- EffectSS_Delete(&EffectSS2Info.data_table[i]);
+ if (sEffectSsInfo.data_table[i].life < 0) {
+ EffectSS_Delete(&sEffectSsInfo.data_table[i]);
}
}
- if (EffectSS2Info.data_table[i].life > -1) {
+ if (sEffectSsInfo.data_table[i].life > -1) {
EffectSS_UpdateParticle(globalCtx, i);
}
}
}
void EffectSS_DrawParticle(GlobalContext* globalCtx, s32 index) {
- EffectSs* entry = &EffectSS2Info.data_table[index];
+ EffectSs* entry = &sEffectSsInfo.data_table[index];
if (entry->draw != NULL) {
entry->draw(globalCtx, index, entry);
@@ -252,12 +255,12 @@ void EffectSS_DrawAllParticles(GlobalContext* globalCtx) {
Lights_BindAll(lights, globalCtx->lightCtx.listHead, NULL, globalCtx);
Lights_Draw(lights, globalCtx->state.gfxCtx);
- for (i = 0; i < EffectSS2Info.size; i++) {
- if (EffectSS2Info.data_table[i].life > -1) {
- if ((EffectSS2Info.data_table[i].pos.x > 32000.0f) || (EffectSS2Info.data_table[i].pos.x < -32000.0f) ||
- (EffectSS2Info.data_table[i].pos.y > 32000.0f) || (EffectSS2Info.data_table[i].pos.y < -32000.0f) ||
- (EffectSS2Info.data_table[i].pos.z > 32000.0f) || (EffectSS2Info.data_table[i].pos.z < -32000.0f)) {
- EffectSS_Delete(&EffectSS2Info.data_table[i]);
+ for (i = 0; i < sEffectSsInfo.size; i++) {
+ if (sEffectSsInfo.data_table[i].life > -1) {
+ if ((sEffectSsInfo.data_table[i].pos.x > 32000.0f) || (sEffectSsInfo.data_table[i].pos.x < -32000.0f) ||
+ (sEffectSsInfo.data_table[i].pos.y > 32000.0f) || (sEffectSsInfo.data_table[i].pos.y < -32000.0f) ||
+ (sEffectSsInfo.data_table[i].pos.z > 32000.0f) || (sEffectSsInfo.data_table[i].pos.z < -32000.0f)) {
+ EffectSS_Delete(&sEffectSsInfo.data_table[i]);
} else {
EffectSS_DrawParticle(globalCtx, i);
}
diff --git a/src/code/z_effect_soft_sprite_dlftbls.c b/src/code/z_effect_soft_sprite_dlftbls.c
new file mode 100644
index 000000000..e215cdee9
--- /dev/null
+++ b/src/code/z_effect_soft_sprite_dlftbls.c
@@ -0,0 +1,56 @@
+#include "global.h"
+#include "initvars.h"
+
+#define EFFECT_SS_OVERLAY(name) \
+ { \
+ SEGMENT_ROM_START(ovl_##name), SEGMENT_ROM_END(ovl_##name), SEGMENT_START(ovl_##name), \
+ SEGMENT_END(ovl_##name), NULL, &name##_InitVars, 1, \
+ }
+
+#define EFFECT_SS_OVERLAY_INTERNAL(name) \
+ { 0, 0, NULL, NULL, NULL, &name##_InitVars, 1 }
+
+#define EFFECT_SS_OVERLAY_UNSET \
+ { 0 }
+
+EffectSsOverlay gParticleOverlayTable[] = {
+ EFFECT_SS_OVERLAY(Effect_Ss_Dust),
+ EFFECT_SS_OVERLAY(Effect_Ss_Kirakira),
+ EFFECT_SS_OVERLAY_UNSET,
+ EFFECT_SS_OVERLAY(Effect_Ss_Bomb2),
+ EFFECT_SS_OVERLAY(Effect_Ss_Blast),
+ EFFECT_SS_OVERLAY(Effect_Ss_G_Spk),
+ EFFECT_SS_OVERLAY(Effect_Ss_D_Fire),
+ EFFECT_SS_OVERLAY(Effect_Ss_Bubble),
+ EFFECT_SS_OVERLAY_UNSET,
+ EFFECT_SS_OVERLAY(Effect_Ss_G_Ripple),
+ EFFECT_SS_OVERLAY(Effect_Ss_G_Splash),
+ EFFECT_SS_OVERLAY_UNSET,
+ EFFECT_SS_OVERLAY(Effect_Ss_G_Fire),
+ EFFECT_SS_OVERLAY(Effect_Ss_Lightning),
+ EFFECT_SS_OVERLAY(Effect_Ss_Dt_Bubble),
+ EFFECT_SS_OVERLAY(Effect_Ss_Hahen),
+ EFFECT_SS_OVERLAY(Effect_Ss_Stick),
+ EFFECT_SS_OVERLAY(Effect_Ss_Sibuki),
+ EFFECT_SS_OVERLAY_UNSET,
+ EFFECT_SS_OVERLAY_UNSET,
+ EFFECT_SS_OVERLAY(Effect_Ss_Stone1),
+ EFFECT_SS_OVERLAY(Effect_Ss_Hitmark),
+ EFFECT_SS_OVERLAY(Effect_Ss_Fhg_Flash),
+ EFFECT_SS_OVERLAY(Effect_Ss_K_Fire),
+ EFFECT_SS_OVERLAY(Effect_Ss_Solder_Srch_Ball),
+ EFFECT_SS_OVERLAY(Effect_Ss_Kakera),
+ EFFECT_SS_OVERLAY(Effect_Ss_Ice_Piece),
+ EFFECT_SS_OVERLAY(Effect_Ss_En_Ice),
+ EFFECT_SS_OVERLAY(Effect_Ss_Fire_Tail),
+ EFFECT_SS_OVERLAY(Effect_Ss_En_Fire),
+ EFFECT_SS_OVERLAY(Effect_Ss_Extra),
+ EFFECT_SS_OVERLAY_UNSET,
+ EFFECT_SS_OVERLAY(Effect_Ss_Dead_Db),
+ EFFECT_SS_OVERLAY(Effect_Ss_Dead_Dd),
+ EFFECT_SS_OVERLAY(Effect_Ss_Dead_Ds),
+ EFFECT_SS_OVERLAY_UNSET,
+ EFFECT_SS_OVERLAY(Effect_Ss_Ice_Smoke),
+ EFFECT_SS_OVERLAY(Effect_En_Ice_Block),
+ EFFECT_SS_OVERLAY(Effect_Ss_Sbn),
+};
diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c
index 4303d3db2..1c69f57f3 100644
--- a/src/code/z_effect_soft_sprite_old_init.c
+++ b/src/code/z_effect_soft_sprite_old_init.c
@@ -124,32 +124,32 @@ void func_800B1054(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f*
EffectSsDust_Spawn(globalCtx, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1);
}
-extern Color_RGBA8 D_801AE3B0;
-extern Color_RGBA8 D_801AE3B4;
+static Color_RGBA8 sDustBrownPrim = { 170, 130, 90, 255 };
+static Color_RGBA8 sDustBrownEnv = { 100, 60, 20, 255 };
void func_800B10C0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
- EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, 100, 5, 10, 0);
+ EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0);
}
void func_800B1130(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
- EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, 100, 5, 10, 0);
+ EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0);
}
void func_800B11A0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) {
- EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, scale, scaleStep, 10, 0);
+ EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0);
}
void func_800B1210(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) {
- EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, scale, scaleStep, 10, 0);
+ EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0);
}
void func_800B1280(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
s16 life) {
- EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, scale, scaleStep, life, 0);
+ EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0);
}
void func_800B12F0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
s16 life) {
- EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, scale, scaleStep, life, 0);
+ EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0);
}
void func_800B1360(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
@@ -206,12 +206,9 @@ void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) {
}
}
-extern Color_RGBA8 D_801AE3B8;
-extern Color_RGBA8 D_801AE3BC;
-
void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
- Color_RGBA8 primColor = D_801AE3B8;
- Color_RGBA8 envColor = D_801AE3BC;
+ Color_RGBA8 primColor = { 255, 255, 200, 255 };
+ Color_RGBA8 envColor = { 255, 200, 0, 0 };
EffectSsKiraKira_SpawnDispersed(globalCtx, pos, velocity, accel, &primColor, &envColor, 1000, 16);
}
@@ -307,12 +304,12 @@ void EffectSsBlast_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
EffectSs_Spawn(globalCtx, EFFECT_SS_BLAST, 128, &initParams);
}
-extern Color_RGBA8 D_801AE3C0;
-extern Color_RGBA8 D_801AE3C4;
-
void EffectSsBlast_SpawnWhiteCustomScale(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale,
s16 scaleStep, s16 life) {
- EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, &D_801AE3C0, &D_801AE3C4, scale, scaleStep, 35, life);
+ static Color_RGBA8 primColor = { 255, 255, 255, 255 };
+ static Color_RGBA8 envColor = { 200, 200, 200, 0 };
+
+ EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, &primColor, &envColor, scale, scaleStep, 35, life);
}
void EffectSsBlast_SpawnShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
@@ -320,11 +317,11 @@ void EffectSsBlast_SpawnShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* v
EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, primColor, envColor, 100, 375, 35, life);
}
-extern Color_RGBA8 D_801AE3C8;
-extern Color_RGBA8 D_801AE3CC;
-
void EffectSsBlast_SpawnWhiteShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
- EffectSsBlast_SpawnShockwave(globalCtx, pos, velocity, accel, &D_801AE3C8, &D_801AE3CC, 10);
+ static Color_RGBA8 primColor = { 255, 255, 255, 255 };
+ static Color_RGBA8 envColor = { 200, 200, 200, 0 };
+
+ EffectSsBlast_SpawnShockwave(globalCtx, pos, velocity, accel, &primColor, &envColor, 10);
}
// EffectSsGSpk Spawn Functions
@@ -364,24 +361,18 @@ void EffectSsGSpk_SpawnNoAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* po
EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPK, 128, &initParams);
}
-extern Color_RGBA8 D_801AE3D0;
-extern Color_RGBA8 D_801AE3D4;
-
void EffectSsGSpk_SpawnFuse(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
- Color_RGBA8 primColor = D_801AE3D0;
- Color_RGBA8 envColor = D_801AE3D4;
+ Color_RGBA8 primColor = { 255, 255, 150, 255 };
+ Color_RGBA8 envColor = { 255, 0, 0, 0 };
EffectSsGSpk_SpawnSmall(globalCtx, actor, pos, velocity, accel, &primColor, &envColor);
}
-extern Color_RGBA8 D_801AE3D8;
-extern Color_RGBA8 D_801AE3DC;
-
// unused
void EffectSsGSpk_SpawnRandColor(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
s16 scale, s16 scaleStep) {
- Color_RGBA8 primColor = D_801AE3D8;
- Color_RGBA8 envColor = D_801AE3DC;
+ Color_RGBA8 primColor = { 255, 255, 150, 255 };
+ Color_RGBA8 envColor = { 255, 0, 0, 0 };
s32 randOffset = (Rand_ZeroOne() * 20.0f) - 10.0f;
primColor.r += randOffset;
@@ -585,12 +576,10 @@ void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstSca
}
}
-extern Vec3f D_801AE3E0;
-
void func_800B2364(GlobalContext* globalCtx, Vec3f* pos, Gfx* dList) {
- Vec3f posVec = D_801AE3E0;
+ Vec3f accel = { 0.0f, -2.0f, 0.0f };
- EffectSsHahen_Spawn(globalCtx, pos, &gZeroVec3f, &posVec, 1, 5, 1, 10, dList);
+ EffectSsHahen_Spawn(globalCtx, pos, &gZeroVec3f, &accel, 1, 5, 1, 10, dList);
}
// EffectSsStick Spawn Functions
@@ -624,12 +613,9 @@ void EffectSsSibuki_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
EffectSs_Spawn(globalCtx, EFFECT_SS_SIBUKI, 128, &initParams);
}
-extern Vec3f D_801AE3EC;
-extern Vec3f D_801AE3F8;
-
void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos) {
s16 i;
- Vec3f zeroVec = D_801AE3EC;
+ Vec3f zeroVec = { 0.0f, 0.0f, 0.0f };
s16 randDirection = Rand_ZeroOne() * 1.99f;
for (i = 0; i < KREG(19) + 30; i++) {
@@ -759,11 +745,6 @@ void EffectSsIcePiece_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec
EffectSs_Spawn(globalCtx, EFFECT_SS_ICE_PIECE, 128, &initParams);
}
-extern Vec3f D_801AE3F8;
-extern Vec3f D_801AE404[10];
-
-#ifdef NON_MATCHING
-/* needs data migration to match */
void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 scale) {
static Vec3f accel = { 0.0f, 0.0f, 0.0f };
static Vec3f vecScales[] = {
@@ -799,15 +780,11 @@ void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 sc
&accel, 25);
}
}
-#else
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsIcePiece_SpawnBurst.s")
-#endif
// EffectSsEnIce Spawn Functions
void EffectSsEnIce_SpawnFlyingVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Color_RGBA8* prim,
Color_RGBA8* env, f32 scale) {
-
EffectSsEnIceInitParams initParams;
initParams.actor = actor;
@@ -824,11 +801,11 @@ void EffectSsEnIce_SpawnFlyingVec3f(GlobalContext* globalCtx, Actor* actor, Vec3
EffectSs_Spawn(globalCtx, EFFECT_SS_EN_ICE, 80, &initParams);
}
-extern Color_RGBA8 D_801AE47C;
-extern Color_RGBA8 D_801AE480;
-
void func_800B2B44(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 scale) {
- EffectSsEnIce_SpawnFlyingVec3f(globalCtx, actor, pos, &D_801AE47C, &D_801AE480, scale);
+ static Color_RGBA8 primColor = { 150, 150, 150, 250 };
+ static Color_RGBA8 envColor = { 235, 245, 255, 255 };
+
+ EffectSsEnIce_SpawnFlyingVec3f(globalCtx, actor, pos, &primColor, &envColor, scale);
}
void func_800B2B7C(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, f32 scale) {
@@ -874,29 +851,21 @@ void EffectSsFireTail_Spawn(GlobalContext* globalCtx, Actor* actor, Vec3f* pos,
EffectSs_Spawn(globalCtx, EFFECT_SS_FIRE_TAIL, 128, &initParams);
}
-extern Color_RGBA8 D_801AE484;
-extern Color_RGBA8 D_801AE488;
-
-#ifdef NON_MATCHING
-// needs data migration to match
void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 arg3, s16 bodyPart,
f32 colorIntensity) {
+ static Color_RGBA8 primColor = { 255, 255, 0, 255 };
+ static Color_RGBA8 envColor = { 255, 0, 0, 255 };
- D_801AE484.g = (s32)(255.0f * colorIntensity);
- D_801AE484.b = 0;
+ primColor.g = (s32)(255.0f * colorIntensity);
+ primColor.b = 0;
- D_801AE488.g = 0;
- D_801AE488.b = 0;
- D_801AE484.r = D_801AE488.r = (s32)(255.0f * colorIntensity);
+ envColor.g = 0;
+ envColor.b = 0;
+ primColor.r = envColor.r = (s32)(255.0f * colorIntensity);
- EffectSsFireTail_Spawn(globalCtx, actor, pos, arg3, &actor->velocity, 15, &D_801AE484, &D_801AE488,
+ EffectSsFireTail_Spawn(globalCtx, actor, pos, arg3, &actor->velocity, 15, &primColor, &envColor,
(colorIntensity == 1.0f) ? 0 : 1, bodyPart, 1);
}
-#else
-void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 arg3, s16 bodyPart,
- f32 colorIntensity);
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsFireTail_SpawnFlame.s")
-#endif
void EffectSsFireTail_SpawnFlameOnPlayer(GlobalContext* globalCtx, f32 scale, s16 bodyPart, f32 colorIntensity) {
Player* player = GET_PLAYER(globalCtx);
@@ -982,12 +951,17 @@ void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DB, 120, &initParams);
}
-extern Color_RGBA8 D_801AE48C;
-extern Color_RGBA8 D_801AE490[4];
-
void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
s32 colorIndex) {
- EffectSsDeadDb_Spawn(globalCtx, pos, velocity, accel, &D_801AE48C, &D_801AE490[colorIndex], scale, scaleStep, 9);
+ static Color_RGBA8 primColor = { 255, 255, 255, 255 };
+ static Color_RGBA8 envColors[] = {
+ { 255, 0, 0, 255 },
+ { 0, 255, 0, 255 },
+ { 0, 0, 255, 255 },
+ { 150, 150, 150, 255 },
+ };
+
+ EffectSsDeadDb_Spawn(globalCtx, pos, velocity, accel, &primColor, &envColors[colorIndex], scale, scaleStep, 9);
}
// EffectSsDeadDd Spawn Functions
diff --git a/src/code/z_en_hy.c b/src/code/z_en_hy.c
index 73adc5fa5..323dc14f8 100644
--- a/src/code/z_en_hy.c
+++ b/src/code/z_en_hy.c
@@ -66,7 +66,7 @@ Actor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) {
f32 minDist = 0.0f;
do {
- doorIter = func_ActorCategoryIterateById(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR);
+ doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR);
door = doorIter;
dist = Actor_DistanceBetweenActors(actor, door);
if (!isSetup || (dist < minDist)) {
diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c
index 595ffba90..ff564b7c0 100644
--- a/src/code/z_en_item00.c
+++ b/src/code/z_en_item00.c
@@ -829,29 +829,22 @@ s16 func_800A7650(s16 dropId) {
return dropId;
}
-#ifdef NON_MATCHING
-// Reordering issues
-EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params) {
+Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params) {
s32 pad;
- EnItem00* spawnedActor = NULL;
- s32 pad2;
- s32 param10000;
- s16 param8000;
- s16 param7F00;
- s32 param20000;
- s32 paramFF;
+ Actor* spawnedActor = NULL;
+ s32 newParamFF;
+ s32 param10000 = params & 0x10000;
+ s16 param8000 = params & 0x8000;
+ s16 param7F00 = params & 0x7F00;
+ s32 param20000 = params & 0x20000;
+ s32 paramFF = params & 0xFF;
s32 i;
- param10000 = params & 0x10000;
- param8000 = params & 0x8000;
- param7F00 = params & 0x7F00;
- param20000 = params & 0x20000;
- paramFF = params & 0xFF;
-
params &= 0x7FFF;
+ newParamFF = params & 0xFF;
if (paramFF == ITEM00_3_HEARTS) {
- for (i = 0; i != 3; i++) {
+ for (i = 0; i < 3; i++) {
spawnedActor = Item_DropCollectible(globalCtx, spawnPos, param7F00 | ITEM00_HEART | param8000);
}
} else if (paramFF == ITEM00_MUSHROOM_CLOUD) {
@@ -860,20 +853,18 @@ EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 pa
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_KINOKO, spawnPos->x, spawnPos->y, spawnPos->z, 0, 0,
0, param7F00);
}
- } else if (((paramFF == ITEM00_FLEXIBLE) || ((params & 0xFF) == ITEM00_BIG_FAIRY)) && (param10000 == 0)) {
- if ((params & 0xFF) == ITEM00_FLEXIBLE) {
- // TODO: fix cast, this actor is not an EnItem00
- spawnedActor =
- (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
+ } else if (((paramFF == ITEM00_FLEXIBLE) || (newParamFF == ITEM00_BIG_FAIRY)) && (param10000 == 0)) {
+ newParamFF = params & 0xFF;
+ if (newParamFF == ITEM00_FLEXIBLE) {
+ spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) << 9) & 0xFE00) | 0x102);
if (!Actor_GetCollectibleFlag(globalCtx, (param7F00 >> 8) & 0x7F)) {
Audio_PlaySoundAtPosition(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
}
} else {
- // TODO: fix cast, this actor is not an EnItem00
- spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x,
- spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0,
- ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7);
+ spawnedActor =
+ Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f,
+ spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7);
if (param20000 == 0) {
if (!Actor_GetCollectibleFlag(globalCtx, (param7F00 >> 8) & 0x7F)) {
Audio_PlaySoundAtPosition(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
@@ -882,59 +873,50 @@ EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 pa
}
} else {
if (param8000 == 0) {
- params = func_800A7650(params & 0xFF);
+ params = func_800A7650(newParamFF);
}
- if (params != (u32)ITEM00_NO_DROP) {
- spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x,
- spawnPos->y, spawnPos->z, 0, 0, 0, params | param8000 | param7F00);
+ if ((s32)params != ITEM00_NO_DROP) {
+ spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y,
+ spawnPos->z, 0, 0, 0, (s32)params | param8000 | param7F00);
if ((spawnedActor != NULL) && (param8000 == 0)) {
if (param10000 == 0) {
- spawnedActor->actor.velocity.y = 8.0f;
+ spawnedActor->velocity.y = 8.0f;
} else {
- spawnedActor->actor.velocity.y = -2.0f;
+ spawnedActor->velocity.y = -2.0f;
}
- spawnedActor->actor.speedXZ = 2.0f;
- spawnedActor->actor.gravity = -0.9f;
- spawnedActor->actor.world.rot.y = randPlusMinusPoint5Scaled(65536.0f);
- Actor_SetScale(&spawnedActor->actor, 0.0f);
- spawnedActor->actionFunc = func_800A6780;
- spawnedActor->unk152 = 0xDC;
- if ((spawnedActor->actor.params != ITEM00_SMALL_KEY) &&
- (spawnedActor->actor.params != ITEM00_HEART_PIECE) &&
- (spawnedActor->actor.params != ITEM00_HEART_CONTAINER)) {
- spawnedActor->actor.room = -1;
+ spawnedActor->speedXZ = 2.0f;
+ spawnedActor->gravity = -0.9f;
+ spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(65536.0f);
+ Actor_SetScale(spawnedActor, 0.0f);
+ ((EnItem00*)spawnedActor)->actionFunc = func_800A6780;
+ ((EnItem00*)spawnedActor)->unk152 = 0xDC;
+ if ((spawnedActor->params != ITEM00_SMALL_KEY) && (spawnedActor->params != ITEM00_HEART_PIECE) &&
+ (spawnedActor->params != ITEM00_HEART_CONTAINER)) {
+ spawnedActor->room = -1;
}
- spawnedActor->actor.flags |= 0x0010;
+ spawnedActor->flags |= 0x0010;
}
}
}
return spawnedActor;
}
-#else
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_en_item00/Item_DropCollectible.s")
-#endif
-#ifdef NON_MATCHING
-// Regalloc, minor reordering
-Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params) {
+Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 params) {
Actor* spawnedActor = NULL;
- u32 pad;
- u32 param10000;
- s16 param8000;
- s16 param7F00;
+ s32 pad;
+ s32 param10000 = params & 0x10000;
+ s16 param8000 = params & 0x8000;
+ s16 param7F00 = params & 0x7F00;
- param10000 = params & 0x10000;
- param8000 = params & 0x8000;
- param7F00 = params & 0x7F00;
params &= 0xFF;
- if (params == ITEM00_3_HEARTS) {
+ if ((params & 0xFF) == ITEM00_3_HEARTS) {
return NULL;
}
- if (((params == ITEM00_FLEXIBLE) || (params == ITEM00_BIG_FAIRY)) && (param10000 == 0)) {
- if (params == ITEM00_FLEXIBLE) {
+ if ((((params & 0xFF) == ITEM00_FLEXIBLE) || ((params & 0xFF) == ITEM00_BIG_FAIRY)) && (param10000 == 0)) {
+ if ((params & 0xFF) == ITEM00_FLEXIBLE) {
spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) << 9) & 0xFE00) | 0x102);
} else {
@@ -946,10 +928,10 @@ Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, u32 para
Audio_PlaySoundAtPosition(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
}
} else {
- params = func_800A7650(params);
- if (params != (u32)ITEM00_NO_DROP) {
+ params = func_800A7650(params & 0xFF);
+ if (params != ITEM00_NO_DROP) {
spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y,
- spawnPos->z, 0, 0, 0, params | param8000 | param7F00);
+ spawnPos->z, 0, 0, 0, (s32)params | param8000 | param7F00);
if (spawnedActor != NULL) {
if (param8000 == 0) {
spawnedActor->velocity.y = 0.0f;
@@ -968,9 +950,6 @@ Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, u32 para
return spawnedActor;
}
-#else
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_en_item00/Item_DropCollectible2.s")
-#endif
u8 sDropTable[DROP_TABLE_SIZE * DROP_TABLE_NUMBER] = {
ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, ITEM00_NO_DROP,
@@ -1048,17 +1027,14 @@ u8 sDropTableAmounts[DROP_TABLE_SIZE * DROP_TABLE_NUMBER] = {
0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
};
-#ifdef NON_MATCHING
-// Many regalloc and reordering issues
void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params) {
EnItem00* spawnedActor;
u8 dropId;
s32 dropQuantity;
- s16 dropTableIndex;
- s16 param8000;
+ s16 dropTableIndex = Rand_ZeroOne() * 16.0f;
+ s16 param8000 = params & 0x8000;
+ u8 dropFlag;
- dropTableIndex = Rand_ZeroOne() * 16.0f;
- param8000 = params & 0x8000;
params &= 0x1F0;
if (params < 0x101) {
@@ -1066,50 +1042,54 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3
dropQuantity = sDropTableAmounts[params + dropTableIndex];
if (dropId == ITEM00_MASK) {
- dropQuantity = 1;
- if (gSaveContext.save.playerForm != PLAYER_FORM_GORON) {
- if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) {
- if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) {
- dropId = ITEM00_RUPEE_GREEN;
- } else {
- dropId = ITEM00_ARROWS_10;
- }
- } else {
+ switch (gSaveContext.save.playerForm) {
+ case PLAYER_FORM_HUMAN:
+ dropId = ITEM00_ARROWS_10;
+ break;
+ case PLAYER_FORM_ZORA:
dropId = ITEM00_HEART;
- }
- } else {
- dropId = ITEM00_MAGIC_SMALL;
+ break;
+ case PLAYER_FORM_GORON:
+ dropId = ITEM00_MAGIC_SMALL;
+ break;
+ default:
+ dropId = ITEM00_RUPEE_GREEN;
+ break;
}
+ dropQuantity = 1;
}
if (fromActor != NULL) {
- if (fromActor->dropFlag != 0) {
- if ((fromActor->dropFlag & 1) != 0) {
+ dropFlag = fromActor->dropFlag;
+ if (dropFlag != 0) {
+ if (fromActor->dropFlag & 1) {
+ params = 0x10;
dropId = ITEM00_ARROWS_30;
+ dropQuantity = 1;
+ } else if (fromActor->dropFlag & 2) {
params = 0x10;
- } else if ((fromActor->dropFlag & 2) != 0) {
dropId = ITEM00_HEART;
- params = 0x10;
- } else if ((fromActor->dropFlag & 0x20) != 0) {
+ dropQuantity = 1;
+ } else if (fromActor->dropFlag & 0x20) {
dropId = ITEM00_RUPEE_PURPLE;
+ dropQuantity = 1;
}
- dropQuantity = 1;
}
}
if (dropId == ITEM00_FLEXIBLE) {
- if (gSaveContext.save.playerData.health < 0x11) {
+ if (gSaveContext.save.playerData.health <= 0x10) {
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
spawnPos->z, 0, 0, 0, 2);
Audio_PlaySoundAtPosition(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
return;
}
- if (gSaveContext.save.playerData.health < 0x31) {
+ if (gSaveContext.save.playerData.health <= 0x30) {
params = 0x10;
dropId = ITEM00_HEART;
dropQuantity = 3;
- } else if (gSaveContext.save.playerData.health < 0x51) {
+ } else if (gSaveContext.save.playerData.health <= 0x50) {
params = 0x10;
dropId = ITEM00_HEART;
dropQuantity = 1;
@@ -1134,6 +1114,8 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3
params = 0xA0;
dropId = ITEM00_RUPEE_RED;
dropQuantity = 1;
+ } else {
+ return;
}
}
@@ -1169,18 +1151,16 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3
}
}
}
-#else
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_en_item00/Item_DropCollectibleRandom.s")
-#endif
-
-s32 D_801AE194[32] = { ITEM00_NO_DROP, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP,
- ITEM00_RUPEE_RED, ITEM00_RUPEE_PURPLE, ITEM00_NO_DROP, ITEM00_RUPEE_HUGE,
- ITEM00_COMPASS, ITEM00_MUSHROOM_CLOUD, ITEM00_HEART, ITEM00_3_HEARTS,
- ITEM00_HEART_PIECE, ITEM00_HEART_CONTAINER, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE,
- ITEM00_FLEXIBLE, ITEM00_BIG_FAIRY, ITEM00_NO_DROP, ITEM00_NUTS_10,
- ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_NO_DROP, ITEM00_NO_DROP,
- ITEM00_NO_DROP, ITEM00_STICK, ITEM00_NO_DROP, ITEM00_NO_DROP,
- ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_ARROWS_10, ITEM00_ARROWS_30 };
+
+s32 D_801AE194[32] = {
+ ITEM00_NO_DROP, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, ITEM00_RUPEE_RED,
+ ITEM00_RUPEE_PURPLE, ITEM00_NO_DROP, ITEM00_RUPEE_HUGE, ITEM00_COMPASS, ITEM00_MUSHROOM_CLOUD,
+ ITEM00_HEART, ITEM00_3_HEARTS, ITEM00_HEART_PIECE, ITEM00_HEART_CONTAINER, ITEM00_MAGIC_SMALL,
+ ITEM00_MAGIC_LARGE, ITEM00_FLEXIBLE, ITEM00_BIG_FAIRY, ITEM00_NO_DROP, ITEM00_NUTS_10,
+ ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP,
+ ITEM00_STICK, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP,
+ ITEM00_ARROWS_10, ITEM00_ARROWS_30,
+};
s32 func_800A8150(s32 index) {
if ((index < 0) || (index >= ARRAY_COUNT(D_801AE194))) {
@@ -1190,9 +1170,7 @@ s32 func_800A8150(s32 index) {
return D_801AE194[index];
}
-u8 D_801AE214[32] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
+u8 D_801AE214[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
s32 func_800A817C(s32 index) {
if ((index < 0) || (index >= ARRAY_COUNT(D_801AE214))) {
diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c
index 1ab44acc1..3255b86d8 100644
--- a/src/code/z_sub_s.c
+++ b/src/code/z_sub_s.c
@@ -1,6 +1,40 @@
+/*
+ * File: z_sub_s.c
+ * Description: Various miscellaneous helpers
+ */
+
#include "global.h"
+#include "overlays/actors/ovl_En_Door/z_en_door.h"
+
+/**
+ * Finds the first EnDoor instance with unk_1A4 == 5 and the specified unk_1A5.
+ */
+EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) {
+ Actor* actor = NULL;
+ EnDoor* door;
+
+ while (true) {
+ actor = SubS_FindActor(globalCtx, actor, ACTORCAT_DOOR, ACTOR_EN_DOOR);
+ door = (EnDoor*)actor;
+
+ if (actor == NULL) {
+ break;
+ }
+
+ if ((door->unk_1A4 == 5) && (door->unk_1A5 == (u8)unk_1A5)) {
+ break;
+ }
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013A7C0.s")
+ if (actor->next == NULL) {
+ door = NULL;
+ break;
+ }
+
+ actor = actor->next;
+ }
+
+ return door;
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013A860.s")
@@ -26,7 +60,40 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BB34.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BB7C.s")
+/**
+ * Finds the nearest actor instance of a specified Id and category to an actor.
+ */
+Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId) {
+ Actor* actorIter = NULL;
+ Actor* actorTmp;
+ f32 dist;
+ Actor* closestActor = NULL;
+ f32 minDist = 99999.0f;
+ s32 isSetup = false;
+
+ do {
+ actorIter = SubS_FindActor(globalCtx, actorIter, actorCategory, actorId);
+
+ actorTmp = actorIter;
+ if (actorTmp == NULL) {
+ break;
+ }
+ actorIter = actorTmp;
+
+ if (actorIter != actor) {
+ dist = Actor_DistanceBetweenActors(actor, actorIter);
+ if (!isSetup || dist < minDist) {
+ closestActor = actorIter;
+ minDist = dist;
+ isSetup = true;
+ }
+ }
+
+ actorIter = actorIter->next;
+ } while (actorIter != NULL);
+
+ return closestActor;
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BC6C.s")
@@ -68,7 +135,22 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D924.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_ActorCategoryIterateById.s")
+/**
+ * Finds the first actor instance of a specified Id and category.
+ */
+Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId) {
+ Actor* actor = actorListStart;
+
+ if (actor == NULL) {
+ actor = globalCtx->actorCtx.actorList[actorCategory].first;
+ }
+
+ while (actor != NULL && actorId != actor->id) {
+ actor = actor->next;
+ }
+
+ return actor;
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D9C8.s")
@@ -100,7 +182,27 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E5CC.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E640.s")
+/**
+ * Finds the first actor instance of a specified Id and category verified with a custom callback.
+ * The callback should return `true` when the actor is succesfully verified.
+ */
+Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory,
+ s16 actorId, void* verifyData, VerifyActor verifyActor) {
+ Actor* actorIter = actorListStart;
+
+ if (actorListStart == NULL) {
+ actorIter = globalCtx->actorCtx.actorList[actorCategory].first;
+ }
+
+ while (actorIter != NULL && (actorId != actorIter->id ||
+ (actorId == actorIter->id &&
+ (verifyActor == NULL ||
+ (verifyActor != NULL && !verifyActor(globalCtx, actor, actorIter, verifyData)))))) {
+ actorIter = actorIter->next;
+ }
+
+ return actorIter;
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E748.s")