mirror of
https://github.com/pret/pokeplatinum.git
synced 2026-03-21 17:55:13 -05:00
SPLManager tex/pal loading functions
This commit is contained in:
parent
a2bb6b05b1
commit
effeafc69c
|
|
@ -6,7 +6,7 @@
|
|||
struct SPLParticle;
|
||||
struct SPLEmitter;
|
||||
|
||||
typedef struct {
|
||||
typedef struct SPLBehavior {
|
||||
void (*apply)(const void *, struct SPLParticle *, VecFx32 *, struct SPLEmitter *);
|
||||
const void *object;
|
||||
} SPLBehavior;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ typedef struct SPLManager {
|
|||
typedef void(* EmitterCallback)(SPLEmitter *);
|
||||
typedef void(* EmitterCallbackEx)(SPLEmitter *, void *);
|
||||
|
||||
typedef u32(* SPLTexVRAMAllocFunc)(u32 size, BOOL is4x4comp);
|
||||
typedef u32(* SPLPalVRAMAllocFunc)(u32 size, BOOL is4pal);
|
||||
|
||||
SPLManager *SPLManager_New(SPLAllocFunc alloc, u16 maxEmitters, u16 maxParticles, u16 fixPolyID, u16 minPolyID, u16 maxPolyID);
|
||||
void SPL_0209C400(SPLManager * param0);
|
||||
|
|
@ -54,10 +56,10 @@ SPLEmitter *SPL_CreateWithInitializeEx(SPLManager *mgr, int resNo, VecFx32 *pos,
|
|||
void SPL_0209C5E0(SPLManager * param0, const MtxFx43 * param1);
|
||||
SPLEmitter * SPL_0209C56C(SPLManager * param0, int param1, const VecFx32 * param2);
|
||||
void SPL_0209C6A8(SPLManager * param0);
|
||||
BOOL SPL_0209C7E0(SPLManager * param0);
|
||||
BOOL SPL_0209C7F4(SPLManager * param0);
|
||||
BOOL SPL_0209C808(SPLManager * param0, u32 (* param1)(u32, BOOL));
|
||||
BOOL SPL_0209C8BC(SPLManager * param0, u32 (* param1)(u32, BOOL));
|
||||
void SPL_0209C988(SPLManager * param0, const void * param1);
|
||||
BOOL SPLManager_UploadPalettes(SPLManager * param0);
|
||||
BOOL SPLManager_UploadTextures(SPLManager * param0);
|
||||
BOOL SPLManager_UploadPalettesEx(SPLManager * param0, u32 (* param1)(u32, BOOL));
|
||||
BOOL SPLManager_UploadTexturesEx(SPLManager * param0, u32 (* param1)(u32, BOOL));
|
||||
void SPLManager_LoadResource(SPLManager * param0, const void * param1);
|
||||
|
||||
#endif // SPL_MANAGER_H
|
||||
|
|
|
|||
|
|
@ -5,35 +5,40 @@
|
|||
|
||||
|
||||
typedef union SPLTextureParam {
|
||||
u32 val1;
|
||||
u32 all;
|
||||
struct {
|
||||
u32 val2_00_0 : 4;
|
||||
u32 format : 4; // Maps to GXTexFmt
|
||||
u32 s : 4;
|
||||
u32 t : 4;
|
||||
u32 val2_01_4 : 2;
|
||||
u32 val2_01_6 : 2;
|
||||
u32 val2_02_0 : 1;
|
||||
u32 val2_02_1 : 1;
|
||||
u32 val2_02_2 : 8;
|
||||
u32 sharedTexID : 8;
|
||||
u32 val2_03_2 : 6;
|
||||
};
|
||||
} SPLTextureParam;
|
||||
|
||||
typedef struct SPLTextureResource {
|
||||
u32 unk_00;
|
||||
u32 id;
|
||||
SPLTextureParam param;
|
||||
u32 unk_08;
|
||||
u32 unk_0C;
|
||||
u32 unk_10;
|
||||
u32 textureSize; // size of the texture data
|
||||
u32 paletteOffset; // offset to the palette data from the start of the header
|
||||
u32 paletteSize; // size of the palette data
|
||||
u32 unk_14;
|
||||
u32 unk_18;
|
||||
u32 resourceSize; // size of the texture data
|
||||
u32 resourceSize; // total size of the resource (header + data)
|
||||
} SPLTextureResource;
|
||||
|
||||
static inline const void *SPLTextureResource_GetTexData(const SPLTextureResource *resource)
|
||||
{
|
||||
return (const void *)(resource + 1);
|
||||
}
|
||||
|
||||
typedef struct SPLTexture {
|
||||
const void * resource;
|
||||
u32 unk_04;
|
||||
u32 unk_08;
|
||||
const void *resource;
|
||||
u32 texAddr; // VRAM address of the texture
|
||||
u32 palAddr; // VRAM address of the palette
|
||||
SPLTextureParam param;
|
||||
u16 width;
|
||||
u16 height;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ SPLManager *SPLManager_New(SPLAllocFunc alloc, u16 maxEmitters, u16 maxParticles
|
|||
return mgr;
|
||||
}
|
||||
|
||||
void SPL_0209C988(SPLManager *mgr, const void *data)
|
||||
void SPLManager_LoadResource(SPLManager *mgr, const void *data)
|
||||
{
|
||||
// Required to match
|
||||
int i, offset;
|
||||
|
|
@ -206,24 +206,22 @@ void SPL_0209C988(SPLManager *mgr, const void *data)
|
|||
}
|
||||
}
|
||||
|
||||
BOOL SPL_0209C8BC(SPLManager *mgr, u32 (*func)(u32, BOOL))
|
||||
BOOL SPLManager_UploadTexturesEx(SPLManager *mgr, SPLTexVRAMAllocFunc vramAlloc)
|
||||
{
|
||||
int i;
|
||||
u32 addr;
|
||||
|
||||
GX_BeginLoadTex();
|
||||
|
||||
for (i = 0; i < mgr->texCount; i++) {
|
||||
for (int i = 0; i < mgr->texCount; i++) {
|
||||
SPLTexture *textures = mgr->textures;
|
||||
SPLTexture *tex = &textures[i];
|
||||
SPLTextureResource *hdr = (SPLTextureResource *)tex->resource;
|
||||
SPLTextureResource *texRes = (SPLTextureResource *)tex->resource;
|
||||
|
||||
if (hdr->param.val2_02_1) {
|
||||
tex->unk_04 = textures[hdr->param.val2_02_2].unk_04;
|
||||
if (texRes->param.val2_02_1) {
|
||||
tex->texAddr = textures[texRes->param.sharedTexID].texAddr;
|
||||
} else {
|
||||
addr = func(hdr->unk_08, hdr->param.val2_00_0 == 5);
|
||||
GX_LoadTex(((SPLTextureResource *)tex->resource) + 1, addr, hdr->unk_08);
|
||||
tex->unk_04 = addr;
|
||||
u32 addr = vramAlloc(texRes->textureSize, texRes->param.format == GX_TEXFMT_COMP4x4);
|
||||
const void *data = SPLTextureResource_GetTexData((SPLTextureResource *)tex->resource);
|
||||
GX_LoadTex(data, addr, texRes->textureSize);
|
||||
tex->texAddr = addr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -231,40 +229,40 @@ BOOL SPL_0209C8BC(SPLManager *mgr, u32 (*func)(u32, BOOL))
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL SPL_0209C808(SPLManager *mgr, u32 (*func)(u32, BOOL))
|
||||
BOOL SPLManager_UploadPalettesEx(SPLManager *mgr, SPLPalVRAMAllocFunc vramAlloc)
|
||||
{
|
||||
// Required to match
|
||||
s32 i;
|
||||
SPLTexture *tex;
|
||||
SPLTextureResource *hdr;
|
||||
u32 ofs;
|
||||
SPLTextureResource *texRes;
|
||||
|
||||
GX_BeginLoadTexPltt();
|
||||
|
||||
for (i = 0; i < mgr->texCount; i++) {
|
||||
ofs = 0;
|
||||
u32 addr = 0;
|
||||
tex = &mgr->textures[i];
|
||||
hdr = (SPLTextureResource *)tex->resource;
|
||||
texRes = (SPLTextureResource *)tex->resource;
|
||||
|
||||
if (hdr->unk_10 != 0) {
|
||||
ofs = func(hdr->unk_10, hdr->param.val2_00_0 == 2);
|
||||
GX_LoadTexPltt((u8 *)tex->resource + hdr->unk_0C, ofs, hdr->unk_10);
|
||||
if (texRes->paletteSize != 0) {
|
||||
addr = vramAlloc(texRes->paletteSize, texRes->param.format == GX_TEXFMT_PLTT4);
|
||||
GX_LoadTexPltt((u8 *)tex->resource + texRes->paletteOffset, addr, texRes->paletteSize);
|
||||
}
|
||||
|
||||
tex->unk_08 = ofs;
|
||||
tex->palAddr = addr;
|
||||
}
|
||||
|
||||
GX_EndLoadTexPltt();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int SPL_0209C7F4(SPLManager *mgr)
|
||||
BOOL SPLManager_UploadTextures(SPLManager *mgr)
|
||||
{
|
||||
return SPL_0209C8BC(mgr, SPLUtil_AllocTextureVRAM);
|
||||
return SPLManager_UploadTexturesEx(mgr, SPLUtil_AllocTextureVRAM);
|
||||
}
|
||||
|
||||
int SPL_0209C7E0(SPLManager *mgr)
|
||||
BOOL SPLManager_UploadPalettes(SPLManager *mgr)
|
||||
{
|
||||
return SPL_0209C808(mgr, SPLUtil_AllocPaletteVRAM);
|
||||
return SPLManager_UploadPalettesEx(mgr, SPLUtil_AllocPaletteVRAM);
|
||||
}
|
||||
|
||||
void SPL_0209C6A8(SPLManager *mgr)
|
||||
|
|
|
|||
|
|
@ -37,16 +37,16 @@ static void sub_0209DC68(SPLTexture *tex)
|
|||
SPLTextureParam param = tex->param;
|
||||
|
||||
G3_TexImageParam(
|
||||
param.val2_00_0,
|
||||
param.format,
|
||||
GX_TEXGEN_TEXCOORD,
|
||||
param.s,
|
||||
param.t,
|
||||
param.val2_01_4,
|
||||
param.val2_01_6,
|
||||
param.val2_02_0,
|
||||
tex->unk_04);
|
||||
tex->texAddr);
|
||||
|
||||
G3_TexPlttBase(tex->unk_08, param.val2_00_0);
|
||||
G3_TexPlttBase(tex->palAddr, param.format);
|
||||
G3_MtxMode(GX_MTXMODE_TEXTURE);
|
||||
G3_Identity();
|
||||
G3_Scale(tex->width * FX32_ONE, tex->height * FX32_ONE, 0);
|
||||
|
|
|
|||
|
|
@ -431,18 +431,18 @@ void sub_020144CC(UnkStruct_02014014 *param0, void *param1, int param2, int para
|
|||
|
||||
static void sub_02014560(UnkStruct_02014014 *param0)
|
||||
{
|
||||
SPL_0209C988(param0->unk_00, param0->unk_04);
|
||||
SPLManager_LoadResource(param0->unk_00, param0->unk_04);
|
||||
|
||||
Unk_021BF610 = param0;
|
||||
if (param0->unk_18 == NULL) {
|
||||
(void)SPL_0209C7F4(param0->unk_00);
|
||||
(void)SPLManager_UploadTextures(param0->unk_00);
|
||||
} else {
|
||||
SPL_0209C8BC(param0->unk_00, param0->unk_18);
|
||||
SPLManager_UploadTexturesEx(param0->unk_00, param0->unk_18);
|
||||
}
|
||||
if (param0->unk_1C == NULL) {
|
||||
(void)SPL_0209C7E0(param0->unk_00);
|
||||
(void)SPLManager_UploadPalettes(param0->unk_00);
|
||||
} else {
|
||||
SPL_0209C808(param0->unk_00, param0->unk_1C);
|
||||
SPLManager_UploadPalettesEx(param0->unk_00, param0->unk_1C);
|
||||
}
|
||||
Unk_021BF610 = NULL;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user