SFontEntry

This commit is contained in:
krystalgamer 2024-09-12 19:08:45 +02:00
parent 7908cca1d5
commit 6d41279394
7 changed files with 100 additions and 12 deletions

View File

@ -4,6 +4,7 @@
#include "mem.h"
#include "ps2pad.h"
#include "utils.h"
#include "PCTex.h"
#include <cstring>
@ -15,8 +16,49 @@ Font::Font(void)
}
// @SMALLTODO
Font::Font(u8*, char*)
Font::Font(
u8* a2,
char* a3)
{
strcpy(this->field_38, a3);
this->field_8 = 3;
this->field_10 = 3;
this->field_4 = 0;
this->mRed = 128;
this->mGreen = 128;
this->mBlue = 128;
this->field_C = 2;
this->field_20 = 0;
this->field_21 = 1;
this->field_24 = 1;
this->field_28 = 1;
this->field_2C = 255;
this->field_30 = 0;
this->field_34 = 3800;
this->field_54 = 0;
this->field_4C = *reinterpret_cast<i32*>(a2);
this->SetCharMap(0);
this->field_48 = static_cast<SFontEntry*>(
DCMem_New(sizeof(SFontEntry) * (this->field_4C + 1), 0, 1, 0, 1));
i32 v26 = gClutRelatedOne;
i32 v6 = gClutRelatedTwo + GetFree16Slot();
u16* Clut = PCTex_CreateClut(16);
for (i32 i = 0; i < 16; i++)
{
u16* pColor = reinterpret_cast<u16*>(a2);
u16 color = pColor[8 * this->field_4C + 2 + i];
Clut[i] = color;
gSlicedImageRelated[i] = color;
}
_LoadImage();
this->field_50 = GetClut(v26, v6);
}
// @Ok
@ -61,7 +103,7 @@ int __inline Font::GetCharMap(void)
// @Ok
void __inline Font::SetCharMap(int a2)
INLINE void Font::SetCharMap(int a2)
{
this->field_58 = a2;
for (int i = 0; i < 256; i++)
@ -462,11 +504,7 @@ INLINE void Font::unload(void)
for (i32 i = 0; i < this->field_4C + 1; i++)
{
Font *ouch = reinterpret_cast<Font*>(this->field_48[2*i]);
// @FIXME this should be fixed to the correct type, it just works
// because it's invoking a virtual destructor
if (ouch)
delete ouch;
delete this->field_48[i].pImage;
}
Mem_Delete(reinterpret_cast<void*>(this->field_48));
@ -510,3 +548,14 @@ void validate_Font(void)
VALIDATE(Font, field_160, 0x160);
}
void validate_SFontEntry(void)
{
VALIDATE_SIZE(SFontEntry, 0x8);
VALIDATE(SFontEntry, pImage, 0x0);
VALIDATE(SFontEntry, field_4, 0x4);
VALIDATE(SFontEntry, field_5, 0x5);
VALIDATE(SFontEntry, field_6, 0x6);
VALIDATE(SFontEntry, field_7, 0x7);
}

View File

@ -5,12 +5,23 @@
#include "main.h"
#include "export.h"
#include "Image.h"
struct SFontEntry
{
SlicedImage2* pImage;
u8 field_4;
u8 field_5;
u8 field_6;
u8 field_7;
};
class Font : public CClass
{
public:
EXPORT Font(void);
EXPORT Font(u8*, char*);
EXPORT ~Font(void);
EXPORT int GetCharMap(void);
@ -44,7 +55,8 @@ class Font : public CClass
char field_38[16];
i32** field_48;
SFontEntry* field_48;
i32 field_4C;
i32 field_50;
i32 field_54;
@ -74,4 +86,6 @@ class FontManager
void validate_Font(void);
void validate_SFontEntry(void);
#endif

View File

@ -6,8 +6,7 @@
#include "mem.h"
// @FIXME
EXPORT u16 gSlicedImageRelated[1];
u16 gSlicedImageRelated[16];
// @Ok
Image::~Image(void)

View File

@ -50,6 +50,8 @@ EXPORT i32 GetBMPBitDepth(char *);
EXPORT void Load4BitBMP_2(char *,char **,i32 *,i32 *,u16 *);
EXPORT i32 LoadNBitBMP_(char *,char **,i32 *,i32 *,u16 *,i32 *);
EXPORT extern u16 gSlicedImageRelated[16];
void validate_Image(void);
void validate_SlicedImage2(void);
#endif

View File

@ -387,6 +387,7 @@ i32 validate(void)
validate_DXVideoModeContext();
validate_DxZBufferContext();
validate_DXPOLY();
validate_SFontEntry();
puts("[*] Validation done!");

View File

@ -5,6 +5,9 @@
#include "ob.h"
#include "m3dcolij.h"
i32 gClutRelatedOne;
i32 gClutRelatedTwo;
EXPORT i16 gRotMatrix[3][3];
EXPORT int vertexRegister[4];
@ -558,11 +561,18 @@ static int gClutRelated;
// @NotOk
// Globals
int GetClut(int, int a2)
u16 GetClut(int, int a2)
{
return a2 - gClutRelated;
}
// @SMALLTODO
i32 GetFree16Slot(void)
{
printf("i32 GetFree16Slot(void)");
return 0x12092024;
}
// @BIGTODO
void M3dAsm_LineColijPreprocessItems(CItem*, i32, SLineInfo*, u16)
{}

View File

@ -6,6 +6,9 @@
#include "export.h"
#include "quat.h"
EXPORT extern i32 gClutRelatedOne;
EXPORT extern i32 gClutRelatedTwo;
EXPORT extern u8 gPrintStubbed;
EXPORT extern u8 gClearImagePrint;
@ -91,7 +94,8 @@ EXPORT MATRIX* M3dMaths_RotMatrixYXZ(SVECTOR *a1, MATRIX *a2);
EXPORT int ratan2(int, int);
EXPORT int GetClut(int, int);
EXPORT u16 GetClut(i32, i32);
EXPORT i32 GetFree16Slot(void);
EXPORT void M3dAsm_LineColijPreprocessItems(CItem*, i32, SLineInfo*, u16);
@ -118,4 +122,13 @@ INLINE static void ClearImage(void)
}
}
// @Ok
INLINE static void _LoadImage(void)
{
if (!gPrintStubbed)
{
stubbed_printf("stubbed out: LoadImage");
}
}
#endif