From 3ffc197173a819fd3b5686de2774710be8331cbe Mon Sep 17 00:00:00 2001 From: krystalgamer Date: Sun, 22 Sep 2024 18:50:12 +0200 Subject: [PATCH] Pal_Init --- pal.cpp | 34 +++++++++++++++++++++++++++++++--- ps2funcs.cpp | 3 ++- ps2funcs.h | 1 + 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/pal.cpp b/pal.cpp index 49d1e00..30dfc23 100644 --- a/pal.cpp +++ b/pal.cpp @@ -1,9 +1,13 @@ #include "pal.h" #include "ps2funcs.h" +#include "pack.h" +#include "mem.h" #include "validate.h" -const i32 PAL_ARRAY_SIZE = 259; +EXPORT i32 gPalRelated; + +const i32 PAL_ARRAY_SIZE = 260; EXPORT tag_S_Pal gPalArrayData[PAL_ARRAY_SIZE]; EXPORT tag_S_Pal* gPalArray = &gPalArrayData[0]; @@ -75,10 +79,34 @@ void Pal_FindPaletteEntry(u32) printf("Pal_FindPaletteEntry(u32)"); } -// @SMALLTODO +// @Ok +// @Matching void Pal_Init(void) { - printf("Pal_Init(void)"); + pPaletteList = 0; + gPalArray = &gPalArrayData[0]; + + for (i32 i = 0; i < PAL_ARRAY_SIZE - 1; i++) + { + gPalArrayData[i].pNext = &gPalArrayData[i+1]; + } + gPalArrayData[PAL_ARRAY_SIZE-1].pNext = 0; + + Mem_Delete(Pack_Pack(-1, 256, 12, &Pal16X, &Pal16Y, 16, 0, 0)); + Mem_Delete(Pack_Pack(-1, 256, 68, &gClutRelated, &gPalRelated, 16, 0, 0)); + + + for (i32 k = 0; k < MAXFREE16SLOTS; k++) + { + Free16Slots[k] = 1; + } + + Free256Slots[0] = 0; + for (i32 m = 1; m < MAXFREE256SLOTS; m++) + { + Free256Slots[m] = 1; + } + } // @SMALLTODO diff --git a/ps2funcs.cpp b/ps2funcs.cpp index c9aad35..0166cb7 100644 --- a/ps2funcs.cpp +++ b/ps2funcs.cpp @@ -10,6 +10,8 @@ #include +i32 gClutRelated; + i32 DoVblankProcessing = 1; i32 gPortRelatedOne; i32 gSomeSize = 0x6E0000; @@ -568,7 +570,6 @@ int ratan2(int x, int y) } -static int gClutRelated; // @NotOk // Globals diff --git a/ps2funcs.h b/ps2funcs.h index 0bfff79..0da48fc 100644 --- a/ps2funcs.h +++ b/ps2funcs.h @@ -6,6 +6,7 @@ #include "export.h" #include "quat.h" +EXPORT extern i32 gClutRelated; EXPORT extern i32 gPortRelatedOne; EXPORT extern i32 gSomeSize; EXPORT extern i32 DoVblankProcessing;