Spool_FindTextureEntry

This commit is contained in:
krystalgamer 2024-07-18 19:48:01 +02:00
parent e522cc26ad
commit 7efdb4f03e
4 changed files with 51 additions and 16 deletions

View File

@ -49,8 +49,15 @@ void validate_SAnimFrame(void)
void validate_Texture(void)
{
VALIDATE_SIZE(Texture, 0x24);
VALIDATE(Texture, field_0, 0x0);
VALIDATE(Texture, field_1, 0x1);
VALIDATE(Texture, field_4, 0x4);
VALIDATE(Texture, field_9, 0x9);
VALIDATE(Texture, Checksum, 0x14);
VALIDATE(Texture, pNext, 0x20);
}

View File

@ -4,10 +4,14 @@
#include "utils.h"
const int MAXPSX = 40;
SPSXRegion PSXRegion[MAXPSX];
EXPORT SPSXRegion PSXRegion[MAXPSX];
EXPORT Texture* TextureChecksumHashTable[512];
int lowGraphics;
int CurrentSuit;
EXPORT i32 lowGraphics;
EXPORT i32 CurrentSuit;
EXPORT u8 gGiveDefaultTexture;
EXPORT i32** gUnknownRelatedToFind;
#if _WIN32
static const char SuitNames[5][32];
@ -73,12 +77,6 @@ unsigned int *Spool_SkipPackets(unsigned int *a1)
return i + 1;
}
// @MEDIUMTODO
Texture* Spool_FindTextureEntry(unsigned int)
{
return (Texture*)0x03062024;
}
// @BIGTODO
void ClearRegion(int, int)
{
@ -137,6 +135,31 @@ void Spool_ClearAllPSXs(void)
Spool_RemoveUnusedTextures();
}
// @NotOk
// understand the unknown variable
Texture *Spool_FindTextureEntry(u32 checksum)
{
Texture *pSearch;
for (pSearch = TextureChecksumHashTable[checksum & 511];
pSearch;
pSearch = pSearch->pNext)
{
if (pSearch->Checksum == checksum)
break;
}
if (!pSearch)
{
if (!gGiveDefaultTexture)
{
print_if_false(0, "Can't find texture from checksum %ld", checksum);
return reinterpret_cast<Texture*>(gUnknownRelatedToFind[1]);
}
}
return pSearch;
}
void validate_SPSXRegion(void)
{
VALIDATE_SIZE(SPSXRegion, 0x44);

View File

@ -71,12 +71,12 @@ struct SPSXRegion {
EXPORT int Spool_FindRegion(const char *);
EXPORT unsigned int Spool_GetModel(unsigned int, int);
EXPORT unsigned int *Spool_SkipPackets(unsigned int *);
EXPORT Texture* Spool_FindTextureEntry(unsigned int);
EXPORT void Spool_ClearAllPSXs(void);
EXPORT void ClearRegion(int, int);
EXPORT void Spool_RemoveUnusedTextures(void);
EXPORT void Spool_ClearPSX(const char*);
EXPORT CItem* Spool_FindEnviroItem(u32);
EXPORT Texture* Spool_FindTextureEntry(u32);
void validate_SPSXRegion(void);

View File

@ -6,14 +6,19 @@
// @TODO go to types.h
struct Texture
{
unsigned char field_0;
unsigned char field_1;
unsigned char padAfter1[0x4-0x1-1];
u8 field_0;
u8 field_1;
u8 padAfter1[0x4-0x1-1];
int field_4;
unsigned char padAfter4[0x9-0x4-4];
i32 field_4;
u8 padAfter4[0x9-0x4-4];
unsigned char field_9;
u8 field_9;
u8 padAfter9[0x14-0x9-1];
u32 Checksum;
u8 padAfter14[0x20-0x14-4];
Texture *pNext;
};
#endif