Skip to content

Commit

Permalink
Merge pull request #1599 from paulsapps/master
Browse files Browse the repository at this point in the history
Hack pal allocs to never fail on recording/playbacks
  • Loading branch information
Paul authored Mar 17, 2023
2 parents 7f96dd2 + bcf93fa commit 1c6fc25
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Source/AliveLibAE/VRam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ static bool Pal_Allocate_Helper(s32& i, s32& palX_idx, s32 maskValue, s32 numBit
return false;
}

EXPORT s16 CC Pal_Allocate_483110(PSX_RECT* pRect, u32 paletteColorCount)
static s16 Pal_Allocate_Impl(PSX_RECT* pRect, u32 paletteColorCount)
{
if (!pal_free_count_5C915E)
{
Expand Down Expand Up @@ -345,6 +345,22 @@ EXPORT s16 CC Pal_Allocate_483110(PSX_RECT* pRect, u32 paletteColorCount)
return 1;
}

EXPORT s16 CC Pal_Allocate_483110(PSX_RECT* pRect, u32 paletteColorCount)
{
const s16 ret = Pal_Allocate_Impl(pRect, paletteColorCount);
if (ret == 0 && (GetGameAutoPlayer().IsRecording() || GetGameAutoPlayer().IsPlaying()))
{
// pal alloc failure (panto voices: oh no he didn't!)
LOG_WARNING("Fat pal alloc hax");
pRect->w = static_cast<s16>(paletteColorCount);
pRect->h = 1;
pRect->x = 0;
pRect->y = 0;
return 1;
}
return ret;
}

EXPORT void CC Pal_free_483390(PSX_Point xy, s16 palDepth)
{
const s32 palIdx = xy.field_2_y - pal_ypos_5C9160;
Expand Down

0 comments on commit 1c6fc25

Please sign in to comment.