Skip to content

Commit

Permalink
fix: actually load hd debug font (#27)
Browse files Browse the repository at this point in the history
* fix: actually load hd debug font

* toggle debug text correctly

---------

Co-authored-by: briaguya <briaguya>
  • Loading branch information
briaguya-ai authored Apr 7, 2023
1 parent 06ac6dc commit d6d1c0b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions soh/src/code/gfxprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ u8 sGfxPrintFontData[(16 * 256) / 2] = {

// Can be used to set GFXP_FLAG_ENLARGE by default
static u8 sDefaultSpecialFlags;
static const char rGfxPrintFontData[] = "__OTR__textures/font/sGfxPrintFontData";
static const char rGfxPrintFontData[] = "__OTR__hd/textures/font/sGfxPrintFontData";

void GfxPrint_Setup(GfxPrint* this) {
s32 width = 16;
Expand All @@ -142,8 +142,8 @@ void GfxPrint_Setup(GfxPrint* this) {
G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2);
gDPSetCombineMode(this->dList++, G_CC_DECALRGBA, G_CC_DECALRGBA);

bool hasHDTexture = ResourceMgr_FileExists(rGfxPrintFontData);
if (!hasHDTexture) {
bool useHdTexture = ResourceMgr_FileExists(rGfxPrintFontData) && CVarGetInteger("gHdAssets", 0);
if (!useHdTexture) {
gDPLoadTextureBlock_4b(this->dList++, sGfxPrintFontData, G_IM_FMT_CI, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
} else {
Expand All @@ -154,7 +154,7 @@ void GfxPrint_Setup(GfxPrint* this) {
gDPLoadTLUT(this->dList++, 64, 256, sGfxPrintFontTLUT);

for (i = 1; i < 4; i++) {
if (hasHDTexture) {
if (useHdTexture) {
gDPSetTile(this->dList++, G_IM_FMT_RGBA, G_IM_SIZ_4b, 1, 0, i * 2, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
} else {
Expand Down Expand Up @@ -204,7 +204,7 @@ void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y) {
void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) {
u32 tile = (c & 0xFF) * 2;
u8 offset = ((c * 2) & 0x7) / 2;
u8 hasHDTexture = ResourceMgr_FileExists(rGfxPrintFontData);
u8 useHDTexture = ResourceMgr_FileExists(rGfxPrintFontData) && CVarGetInteger("gHdAssets", 0);

if (this->flags & GFXP_FLAG_UPDATE) {
this->flags &= ~GFXP_FLAG_UPDATE;
Expand Down Expand Up @@ -242,8 +242,8 @@ void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) {
gSPTextureRectangle(this->dList++, (this->posX) << 1, (this->posY) << 1, (this->posX + 32) << 1,
(this->posY + 32) << 1, tile, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1 << 9, 1 << 9);
} else {
gSPTextureRectangle(this->dList++, this->posX, this->posY, this->posX + 32, this->posY + 32, hasHDTexture ? 0 : tile,
(hasHDTexture ? ((128 * 4) * offset) : 0) + (u16)((c & 4) * 64), (u16)(c >> 3) * 256, 1 << 10, 1 << 10);
gSPTextureRectangle(this->dList++, this->posX, this->posY, this->posX + 32, this->posY + 32, useHDTexture ? 0 : tile,
(useHDTexture ? ((128 * 4) * offset) : 0) + (u16)((c & 4) * 64), (u16)(c >> 3) * 256, 1 << 10, 1 << 10);
}

this->posX += CVarGetInteger("gGfxPrintCharSpacing", 32);
Expand Down

0 comments on commit d6d1c0b

Please sign in to comment.