PCTex_BufferPVR

This commit is contained in:
krystalgamer 2024-08-19 11:37:19 +01:00
parent c6ee9ea52e
commit fcf1320108
4 changed files with 40 additions and 6 deletions

View File

@ -1,5 +1,9 @@
#include "PCTex.h"
#include "validate.h"
#include "mem.h"
#include "dcfileio.h"
#include <cstring>
EXPORT WeirdTextureHolder gGlobalTextures[2];
@ -21,10 +25,39 @@ void PCTEX_Init(void)
printf("PCTEX_Init(void)");
}
// @SMALLTODO
void PCTex_BufferPVR(char const *,char *)
// @Ok
// @Matching
void* PCTex_BufferPVR(const char * a1, char * a2)
{
printf("PCTex_BufferPVR(char const *,char *)");
char nameBuf[128];
const char* fileName = a1;
if (!strchr(a1, '.'))
{
strcpy(nameBuf, a1);
strcat(nameBuf, ".pvr");
fileName = nameBuf;
}
i32* buf = reinterpret_cast<i32*>(a2);
if (!buf)
{
i32 size = FileIO_Open(fileName);
if (size <= 0)
{
print_if_false(0, "Can't find texture file!");
return 0;
}
buf = static_cast<i32*>(DCMem_New(size, 0, 1, 0, 1));
print_if_false(buf != 0, "out of memory");
FileIO_Load(buf);
FileIO_Sync();
}
print_if_false(buf[4] == 0x54525650, "corrupted PVR file");
return buf;
}
// @SMALLTODO

View File

@ -36,7 +36,7 @@ EXPORT int PCTex_GetTextureSplitID(int, int);
EXPORT void CheckValidTexture(i32);
EXPORT void ConvertPSXPaletteToPC(u16 const *,u16 *,u32,u32);
EXPORT void PCTEX_Init(void);
EXPORT void PCTex_BufferPVR(char const *,char *);
EXPORT void* PCTex_BufferPVR(const char *,char *);
EXPORT void PCTex_CountActiveTextures(void);
EXPORT void PCTex_CreateClut(i32);
EXPORT void PCTex_CreateTexture16(i32,i32,void const *,u16 const *,char const *,i32,i32,u32);

View File

@ -27,9 +27,10 @@ void FileIO_Load(void *)
}
// @SMALLTODO
void FileIO_Open(char const *)
i32 FileIO_Open(const char*)
{
printf("FileIO_Open(char const *)");
return 0x19082024;
}
// @NotOk

View File

@ -10,6 +10,6 @@ EXPORT void DebugPrintfX(char *,...);
EXPORT void FileIO_FileExists(char const *);
EXPORT void FileIO_Init(void);
EXPORT void FileIO_Load(void *);
EXPORT void FileIO_Open(char const *);
EXPORT i32 FileIO_Open(const char *);
#endif