Merge branch 'main' into android-building

This commit is contained in:
CraftyBoss
2026-04-14 02:48:24 -07:00
21 changed files with 465 additions and 53 deletions
@@ -5,6 +5,17 @@
#include <cstring>
#include "dusk/endian.h"
#if TARGET_PC
struct FontDrawContext {
bool isTextureLoaded = false;
};
#define FONT_DRAW_CTX , FontDrawContext* context
#define FONT_DRAW_CTX_ARG , context
#else
#define FONT_DRAW_CTX
#define FONT_DRAW_CTX_ARG
#endif
/**
* @ingroup jsystem-jutility
*
@@ -84,7 +95,12 @@ public:
/* 0x0C */ virtual void setGX() = 0;
/* 0x10 */ virtual void setGX(JUtility::TColor col1, JUtility::TColor col2) { setGX(); }
/* 0x14 */ virtual f32 drawChar_scale(f32 a1, f32 a2, f32 a3, f32 a4, int a5, bool a6) = 0;
/* 0x14 */ virtual f32 drawChar_scale(f32 a1, f32 a2, f32 a3, f32 a4, int a5, bool a6 FONT_DRAW_CTX) = 0;
#if TARGET_PC
f32 drawChar_scale(f32 a1, f32 a2, f32 a3, f32 a4, int a5, bool a6) {
return drawChar_scale(a1, a2, a3, a4, a5, a6, nullptr);
}
#endif
/* 0x18 */ virtual int getLeading() const = 0;
/* 0x1C */ virtual s32 getAscent() const = 0;
/* 0x20 */ virtual s32 getDescent() const = 0;
@@ -97,6 +113,11 @@ public:
/* 0x3C */ virtual ResFONT* getResFont() const = 0;
/* 0x40 */ virtual bool isLeadByte(int a1) const = 0;
#if TARGET_PC
virtual void pushDrawState() = 0;
virtual void popDrawState() = 0;
#endif
static bool isLeadByte_1Byte(int b) {
return false;
}
@@ -18,10 +18,6 @@ struct BlockHeader {
BE(u32) size;
};
#if TARGET_PC
struct GlyphTextures;
#endif
/**
* @ingroup jsystem-jutility
*
@@ -31,7 +27,7 @@ public:
virtual ~JUTResFont();
virtual void setGX();
virtual void setGX(JUtility::TColor, JUtility::TColor);
virtual f32 drawChar_scale(f32, f32, f32, f32, int, bool);
virtual f32 drawChar_scale(f32, f32, f32, f32, int, bool FONT_DRAW_CTX);
virtual int getLeading() const;
virtual s32 getAscent() const;
virtual s32 getDescent() const;
@@ -43,7 +39,7 @@ public:
virtual int getFontType() const;
virtual ResFONT* getResFont() const;
virtual bool isLeadByte(int) const;
virtual void loadImage(int, GXTexMapID);
virtual void loadImage(int, GXTexMapID FONT_DRAW_CTX);
virtual void setBlock();
JUTResFont(ResFONT const*, JKRHeap*);
@@ -53,10 +49,15 @@ public:
bool initiate(ResFONT const*, JKRHeap*);
bool protected_initiate(ResFONT const*, JKRHeap*);
void countBlock();
void loadFont(int, GXTexMapID, JUTFont::TWidth*);
void loadFont(int, GXTexMapID, JUTFont::TWidth* FONT_DRAW_CTX);
int getFontCode(int) const;
int convertSjis(int, BE(u16)*) const;
#if TARGET_PC
void pushDrawState() override;
void popDrawState() override;
#endif
inline void delete_and_initialize() {
deleteMemBlocks_ResFont();
initialize_state();
@@ -86,6 +87,16 @@ public:
/* 0x66 */ u16 field_0x66;
/* 0x68 */ u16 mMaxCode;
/* 0x6C */ const IsLeadByte_func* mIsLeadByte;
#if TARGET_PC
// Dusk change: we use a single large texture for all characters.
// This enables better draw call merging, ideally enabling entire blocks of
// text to be one draw call.
TGXTexObj mJoinedTextureObject;
u16 mJoinedTextureHeight;
void initJoinedTexture();
#endif
};
extern u8 const JUTResFONT_Ascfont_fix12[];