PCTex_CreateClut

This commit is contained in:
krystalgamer 2024-08-20 15:32:35 +01:00
parent ae534ddcae
commit aa1ebd746e
2 changed files with 43 additions and 10 deletions

View File

@ -100,10 +100,36 @@ i32 PCTex_CountActiveTextures(void)
return count;
}
// @SMALLTODO
void PCTex_CreateClut(i32)
// @Ok
// @Matching
u16* PCTex_CreateClut(i32 colorCount)
{
printf("PCTex_CreateClut(i32)");
ClutPC* clut = static_cast<ClutPC*>(malloc(sizeof(ClutPC)));
print_if_false(colorCount == 16 || colorCount == 256, "Weird color count in CreateClut: %i", colorCount);
if (!clut)
{
error("Out of memory allocating ClutPC!");
return 0;
}
clut->mRefs = 0;
clut->mColorCount = colorCount;
clut->mClut = static_cast<u16*>(malloc(2 * colorCount));
if (!clut->mClut)
{
error("Out of memory allocating ClutPC colors!");
free(clut);
return 0;
}
clut->mNext = gClutPcRelated;
gClutPcRelated = clut;
gClutCount++;
return clut->mClut;
}
// @MEDIUMTODO
@ -200,10 +226,11 @@ IDirectDrawSurface7* PCTex_GetDirect3DTexture(i32 index)
return gGlobalTextures[index].mD3DTex;
}
// @SMALLTODO
void PCTex_GetInvTextureSize(i32,float *,float *)
// @Ok
void PCTex_GetInvTextureSize(i32 index, float* pF1 ,float * pF2)
{
printf("PCTex_GetInvTextureSize(i32,float *,float *)");
*pF1 = gGlobalTextures[index].field_C;
*pF2 = gGlobalTextures[index].field_10;
}
// @Ok
@ -507,6 +534,10 @@ void validate_SPCTexture(void)
VALIDATE(SPCTexture, wScale, 0x4);
VALIDATE(SPCTexture, hScale, 0x8);
VALIDATE(SPCTexture, field_C, 0xC);
VALIDATE(SPCTexture, field_10, 0x10);
VALIDATE(SPCTexture, mTexture, 0x14);
VALIDATE(SPCTexture, mAlpha, 0x18);
VALIDATE(SPCTexture, mD3DTex, 0x1C);
@ -535,5 +566,6 @@ void validate_ClutPC(void)
VALIDATE(ClutPC, mNext, 0x0);
VALIDATE(ClutPC, mRefs, 0x4);
VALIDATE(ClutPC, mColorCount, 0x6);
VALIDATE(ClutPC, mClut, 0x8);
}

View File

@ -15,8 +15,7 @@ struct ClutPC
{
ClutPC* mNext;
i16 mRefs;
u8 padAfter6[2];
i16 mColorCount;
u16* mClut;
};
@ -38,7 +37,9 @@ struct SPCTexture
u16 mSizeTwo;
float wScale;
float hScale;
u8 padAfter8[0x14-0x8-4];
float field_C;
float field_10;
Bitmap256* mTexture;
i32 mAlpha;
@ -66,7 +67,7 @@ EXPORT void ConvertPSXPaletteToPC(u16 const *,u16 *,u32,u32);
EXPORT void PCTEX_Init(void);
EXPORT void* PCTex_BufferPVR(const char *,char *);
EXPORT i32 PCTex_CountActiveTextures(void);
EXPORT void PCTex_CreateClut(i32);
EXPORT u16* PCTex_CreateClut(i32);
EXPORT void PCTex_CreateTexture16(i32,i32,void const *,u16 const *,char const *,i32,i32,u32);
EXPORT void PCTex_CreateTexture256(i32,i32,void const *,u16 const *,u32,char const *,i32,i32);
EXPORT i32 PCTex_CreateTexturePVR(i32,i32,u32,void *,u32,const char *,u32);