From 1034843e5bf5b51fb5293aa41733bbbc3b0a1c0e Mon Sep 17 00:00:00 2001 From: JaceCear <11230293+JaceCear@users.noreply.github.com> Date: Tue, 5 May 2026 18:15:33 +0200 Subject: [PATCH 1/2] Align water_effects.h with SA3 --- include/game/shared/stage/water_effects.h | 30 ++++++++++++----------- src/game/shared/stage/stage.c | 3 ++- src/game/shared/stage/water_effects.c | 10 ++++---- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/include/game/shared/stage/water_effects.h b/include/game/shared/stage/water_effects.h index 7cead89b15..3332320e24 100644 --- a/include/game/shared/stage/water_effects.h +++ b/include/game/shared/stage/water_effects.h @@ -12,9 +12,10 @@ #ifdef M2C // M2C: Empty structs are not supported. #else -typedef struct { -#if (GAME == GAME_SA2) - u16 pal[32][16]; +// Additional "palette memory". Statically alloced in SA1! +typedef struct WaterData { +#if (GAME >= GAME_SA2) + ColorRaw pal[32][16]; #endif } WaterData; #endif @@ -24,22 +25,23 @@ typedef struct { #ifdef BUG_FIX /* 0x00 */ bool8 isActive; #endif - /* 0x00 */ u8 SA2_LABEL(unk1); - /* 0x01 */ u8 SA2_LABEL(unk2); -#elif (GAME == GAME_SA2) + /* 0x00 */ int_vcount SA2_LABEL(unk1); + /* 0x01 */ int_vcount SA2_LABEL(unk2); +#elif (GAME >= GAME_SA2) /* 0x00 */ bool8 isActive; - /* 0x01 */ u8 unk1; - /* 0x02 */ u8 unk2; - /* 0x03 */ u8 unk3; + /* 0x00 */ int_vcount SA2_LABEL(unk1); + /* 0x01 */ int_vcount SA2_LABEL(unk2); + /* 0x03 */ int_vcount SA2_LABEL(unk3); #endif /* 0x02|0x04 */ s16 currentWaterLevel; /* 0x04|0x06 */ s16 targetWaterLevel; - /* 0x08|0x08 */ u32 unk8; - /* 0x0C|0x0C */ u32 mask; - - // Additional "palette memory", statically alloced in SA1! - /* 0x10 */ struct Task *t; /* size: SA1: 0x00, SA2: 0x400 */ + /* 0x08|0x08 */ u32 flags; + /* 0x0C|0x0C */ u32 blendColors; + /* 0x10 */ struct Task *t; /* -> WaterData | size: SA1: 0x00, SA2: 0x400, SA3: *unused* */ /* 0x14 */ Sprite s; +#if (GAME == GAME_SA3) + /* 0x3C */ WaterData wd; +#endif } Water; extern Water gWater; diff --git a/src/game/shared/stage/stage.c b/src/game/shared/stage/stage.c index f2d4ea738e..1282deddb9 100644 --- a/src/game/shared/stage/stage.c +++ b/src/game/shared/stage/stage.c @@ -493,14 +493,15 @@ void Task_GameStage(void) #ifndef COLLECT_RINGS_ROM if (IS_SINGLE_PLAYER) { #if DEBUG -#include "game/sa2/ui/character_select.h" if (gInput & SELECT_BUTTON) { const u32 initialCharacter = CHARACTER_TAILS; const bool32 allUnlocked = TRUE; TasksDestroyAll(); #if (GAME == GAME_SA1) +#include "game/sa1/ui/character_select.h" CreateCharacterSelectionScreen(initialCharacter); #elif (GAME == GAME_SA2) +#include "game/sa2/ui/character_select.h" CreateCharacterSelectionScreen(initialCharacter, allUnlocked); #endif return; diff --git a/src/game/shared/stage/water_effects.c b/src/game/shared/stage/water_effects.c index 3815857bae..1461df8d61 100644 --- a/src/game/shared/stage/water_effects.c +++ b/src/game/shared/stage/water_effects.c @@ -75,7 +75,7 @@ static const u16 gUnknown_080D550C[NUM_CHARACTERS] = { SA2_ANIM_UNDERWATER_1UP_KNUCKLES, SA2_ANIM_UNDERWATER_1UP_AMY, }; -static void inline CopyPalette(u32 *dst, u32 *src, s32 length) +static inline void CopyPalette(u32 *dst, u32 *src, s32 length) { u32 r2 = length >> 4; @@ -161,7 +161,7 @@ void InitWaterPalettes(void) pal = (animation[0]->pal.palId + 4); CopyPalette((u32 *)wd->pal[4], (u32 *)gSpritePalettes[pal], 12 * PALETTE_LEN_4BPP); - MaskPaletteWithUnderwaterColor_inline((u32 *)wd->pal[16], (u32 *)gBgPalette, water->mask, 16 * 16); + MaskPaletteWithUnderwaterColor_inline((u32 *)wd->pal[16], (u32 *)gBgPalette, water->blendColors, 16 * 16); #endif } @@ -190,8 +190,8 @@ void CreateStageWaterTask(s32 waterLevel, u32 p1, u32 mask) gWater.targetWaterLevel = waterLevel; gWater.SA2_LABEL(unk2) = 0xFF; gWater.SA2_LABEL(unk1) = -1; - gWater.unk8 = mask & 0x100; - gWater.mask = p1; + gWater.flags = mask & 0x100; + gWater.blendColors = p1; if (waterLevel >= 0) { Sprite *s = &gWater.s; @@ -425,7 +425,7 @@ static void SA2_LABEL(sub_8011A4C)(void) WaterData *wd = TASK_DATA(water->t); u32 unk2 = water->SA2_LABEL(unk2); water->SA2_LABEL(unk1) = unk2; - water->unk8 &= ~0x1; + water->flags &= ~0x1; // TODO: This surely can be matched differently! unk2 <<= 24; From eab87d869b557c8cf436b2fd8341e146e04efa98 Mon Sep 17 00:00:00 2001 From: JaceCear <11230293+JaceCear@users.noreply.github.com> Date: Wed, 6 May 2026 00:37:24 +0200 Subject: [PATCH 2/2] Fix SA1 build --- src/game/shared/stage/water_effects.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/shared/stage/water_effects.c b/src/game/shared/stage/water_effects.c index 1461df8d61..a1682bd5e7 100644 --- a/src/game/shared/stage/water_effects.c +++ b/src/game/shared/stage/water_effects.c @@ -116,8 +116,8 @@ void InitWaterPalettes(void) Water *water = &gWater; WaterData *wd = TASK_DATA(water->t); #if (GAME == GAME_SA1) - MaskPaletteWithUnderwaterColor_inline((u32 *)&sPaletteBuffer[0], (u32 *)&gObjPalette[0], water->mask, 16 * 16); - MaskPaletteWithUnderwaterColor_inline((u32 *)&sPaletteBuffer[16 * 16], (u32 *)&gBgPalette[0], water->mask, 16 * 16); + MaskPaletteWithUnderwaterColor_inline((u32 *)&sPaletteBuffer[0], (u32 *)&gObjPalette[0], water->blendColors, 16 * 16); + MaskPaletteWithUnderwaterColor_inline((u32 *)&sPaletteBuffer[16 * 16], (u32 *)&gBgPalette[0], water->blendColors, 16 * 16); #elif (GAME == GAME_SA2) if (IS_MULTI_PLAYER) { u8 i = 0, j = 0;