Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions include/game/shared/stage/water_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/game/shared/stage/stage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/game/shared/stage/water_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading