mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-12 10:54:44 +00:00
Improve gfxprint documentation and strings (#1028)
* Improve gfxprint documentation and strings * Add GFXP_UNUSED_CHAR and rename bss variable
This commit is contained in:
parent
1fa6e3874b
commit
54d77c71f1
9 changed files with 508 additions and 387 deletions
|
@ -1,9 +1,5 @@
|
|||
#include "global.h"
|
||||
|
||||
// .bss
|
||||
u8 D_801755F0;
|
||||
|
||||
// .data
|
||||
u16 sGfxPrintFontTLUT[64] = {
|
||||
0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000,
|
||||
0xFFFF, 0x0000, 0xFFFF, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0x0000, 0x0000,
|
||||
|
@ -12,12 +8,12 @@ u16 sGfxPrintFontTLUT[64] = {
|
|||
0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
|
||||
};
|
||||
|
||||
u16 sGfxPrintUnkTLUT[16] = {
|
||||
u16 sGfxPrintRainbowTLUT[16] = {
|
||||
0xF801, 0xFBC1, 0xFFC1, 0x07C1, 0x0421, 0x003F, 0x803F, 0xF83F,
|
||||
0xF801, 0xFBC1, 0xFFC1, 0x07C1, 0x0421, 0x003F, 0x803F, 0xF83F,
|
||||
};
|
||||
|
||||
u8 sGfxPrintUnkData[8] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 };
|
||||
u8 sGfxPrintRainbowData[8] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 };
|
||||
|
||||
u8 sGfxPrintFontData[(16 * 256) / 2] = {
|
||||
0x00, 0xDF, 0xFD, 0x00, 0x0A, 0xEE, 0xFF, 0xA0, 0x0D, 0xF2, 0x2D, 0xD0, 0x06, 0x61, 0x1D, 0xC0, 0x01, 0x12, 0x2D,
|
||||
|
@ -130,38 +126,41 @@ u8 sGfxPrintFontData[(16 * 256) / 2] = {
|
|||
0x1B, 0xAA, 0x40, 0x21, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
void GfxPrint_InitDlist(GfxPrint* this) {
|
||||
// Can be used to set GFXP_FLAG_ENLARGE by default
|
||||
static u8 sDefaultSpecialFlags;
|
||||
|
||||
void GfxPrint_Setup(GfxPrint* this) {
|
||||
s32 width = 16;
|
||||
s32 height = 256;
|
||||
s32 i;
|
||||
|
||||
gDPPipeSync(this->dlist++);
|
||||
gDPSetOtherMode(this->dlist++,
|
||||
gDPPipeSync(this->dList++);
|
||||
gDPSetOtherMode(this->dList++,
|
||||
G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_IA16 | G_TL_TILE |
|
||||
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
|
||||
G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2);
|
||||
gDPSetCombineMode(this->dlist++, G_CC_DECALRGBA, G_CC_DECALRGBA);
|
||||
gDPLoadTextureBlock_4b(this->dlist++, sGfxPrintFontData, G_IM_FMT_CI, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP,
|
||||
gDPSetCombineMode(this->dList++, G_CC_DECALRGBA, G_CC_DECALRGBA);
|
||||
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);
|
||||
gDPLoadTLUT(this->dlist++, 64, 256, sGfxPrintFontTLUT);
|
||||
gDPLoadTLUT(this->dList++, 64, 256, sGfxPrintFontTLUT);
|
||||
|
||||
for (i = 1; i < 4; i++) {
|
||||
gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2, i, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK,
|
||||
gDPSetTile(this->dList++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2, i, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK,
|
||||
G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
|
||||
gDPSetTileSize(this->dlist++, i * 2, 0, 0, 60, 1020);
|
||||
gDPSetTileSize(this->dList++, i * 2, 0, 0, 60, 1020);
|
||||
}
|
||||
|
||||
gDPSetColor(this->dlist++, G_SETPRIMCOLOR, this->color.rgba);
|
||||
gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba);
|
||||
|
||||
gDPLoadMultiTile_4b(this->dlist++, sGfxPrintUnkData, 0, 1, G_IM_FMT_CI, 2, 8, 0, 0, 1, 7, 4,
|
||||
gDPLoadMultiTile_4b(this->dList++, sGfxPrintRainbowData, 0, 1, G_IM_FMT_CI, 2, 8, 0, 0, 1, 7, 4,
|
||||
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 1, 3, G_TX_NOLOD, G_TX_NOLOD);
|
||||
|
||||
gDPLoadTLUT(this->dlist++, 16, 320, sGfxPrintUnkTLUT);
|
||||
gDPLoadTLUT(this->dList++, 16, 320, sGfxPrintRainbowTLUT);
|
||||
|
||||
for (i = 1; i < 4; i++) {
|
||||
gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2 + 1, 4, G_TX_NOMIRROR | G_TX_WRAP, 3,
|
||||
gDPSetTile(this->dList++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2 + 1, 4, G_TX_NOMIRROR | G_TX_WRAP, 3,
|
||||
G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 1, G_TX_NOLOD);
|
||||
gDPSetTileSize(this->dlist++, i * 2 + 1, 0, 0, 4, 28);
|
||||
gDPSetTileSize(this->dList++, i * 2 + 1, 0, 0, 4, 28);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,64 +169,64 @@ void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a) {
|
|||
this->color.g = g;
|
||||
this->color.b = b;
|
||||
this->color.a = a;
|
||||
gDPPipeSync(this->dlist++);
|
||||
gDPSetColor(this->dlist++, G_SETPRIMCOLOR, this->color.rgba);
|
||||
gDPPipeSync(this->dList++);
|
||||
gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba);
|
||||
}
|
||||
|
||||
void GfxPrint_SetPosPx(GfxPrint* this, s32 x, s32 y) {
|
||||
this->posX = this->baseX + (x << 2);
|
||||
this->posY = this->baseY + (y << 2);
|
||||
this->posX = this->baseX + (x * 4);
|
||||
this->posY = this->baseY + (y * 4);
|
||||
}
|
||||
|
||||
void GfxPrint_SetPos(GfxPrint* this, s32 x, s32 y) {
|
||||
GfxPrint_SetPosPx(this, x << 3, y << 3);
|
||||
GfxPrint_SetPosPx(this, x * 8, y * 8);
|
||||
}
|
||||
|
||||
void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y) {
|
||||
this->baseX = x << 2;
|
||||
this->baseY = y << 2;
|
||||
this->baseX = x * 4;
|
||||
this->baseY = y * 4;
|
||||
}
|
||||
|
||||
void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) {
|
||||
u32 tile = (c & 0xFF) * 2;
|
||||
|
||||
if (this->flag & GFXPRINT_UPDATE_MODE) {
|
||||
this->flag &= ~GFXPRINT_UPDATE_MODE;
|
||||
if (this->flags & GFXP_FLAG_UPDATE) {
|
||||
this->flags &= ~GFXP_FLAG_UPDATE;
|
||||
|
||||
gDPPipeSync(this->dlist++);
|
||||
if (this->flag & GFXPRINT_USE_RGBA16) {
|
||||
gDPSetTextureLUT(this->dlist++, G_TT_RGBA16);
|
||||
gDPSetCycleType(this->dlist++, G_CYC_2CYCLE);
|
||||
gDPSetRenderMode(this->dlist++, G_RM_OPA_CI, G_RM_XLU_SURF2);
|
||||
gDPSetCombineMode(this->dlist++, G_CC_INTERFERENCE, G_CC_PASS2);
|
||||
gDPPipeSync(this->dList++);
|
||||
if (this->flags & GFXP_FLAG_RAINBOW) {
|
||||
gDPSetTextureLUT(this->dList++, G_TT_RGBA16);
|
||||
gDPSetCycleType(this->dList++, G_CYC_2CYCLE);
|
||||
gDPSetRenderMode(this->dList++, G_RM_OPA_CI, G_RM_XLU_SURF2);
|
||||
gDPSetCombineMode(this->dList++, G_CC_INTERFERENCE, G_CC_PASS2);
|
||||
} else {
|
||||
gDPSetTextureLUT(this->dlist++, G_TT_IA16);
|
||||
gDPSetCycleType(this->dlist++, G_CYC_1CYCLE);
|
||||
gDPSetRenderMode(this->dlist++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
|
||||
gDPSetCombineMode(this->dlist++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM);
|
||||
gDPSetTextureLUT(this->dList++, G_TT_IA16);
|
||||
gDPSetCycleType(this->dList++, G_CYC_1CYCLE);
|
||||
gDPSetRenderMode(this->dList++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
|
||||
gDPSetCombineMode(this->dList++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM);
|
||||
}
|
||||
}
|
||||
|
||||
if (this->flag & GFXPRINT_FLAG4) {
|
||||
gDPSetColor(this->dlist++, G_SETPRIMCOLOR, 0);
|
||||
if (this->flags & GFXP_FLAG_SHADOW) {
|
||||
gDPSetColor(this->dList++, G_SETPRIMCOLOR, 0);
|
||||
|
||||
if (this->flag & GFXPRINT_FLAG64) {
|
||||
gSPTextureRectangle(this->dlist++, (this->posX + 4) << 1, (this->posY + 4) << 1, (this->posX + 4 + 32) << 1,
|
||||
if (this->flags & GFXP_FLAG_ENLARGE) {
|
||||
gSPTextureRectangle(this->dList++, (this->posX + 4) << 1, (this->posY + 4) << 1, (this->posX + 4 + 32) << 1,
|
||||
(this->posY + 4 + 32) << 1, tile, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1 << 9,
|
||||
1 << 9);
|
||||
} else {
|
||||
gSPTextureRectangle(this->dlist++, this->posX + 4, this->posY + 4, this->posX + 4 + 32, this->posY + 4 + 32,
|
||||
gSPTextureRectangle(this->dList++, this->posX + 4, this->posY + 4, this->posX + 4 + 32, this->posY + 4 + 32,
|
||||
tile, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1 << 10, 1 << 10);
|
||||
}
|
||||
|
||||
gDPSetColor(this->dlist++, G_SETPRIMCOLOR, this->color.rgba);
|
||||
gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba);
|
||||
}
|
||||
|
||||
if (this->flag & GFXPRINT_FLAG64) {
|
||||
gSPTextureRectangle(this->dlist++, (this->posX) << 1, (this->posY) << 1, (this->posX + 32) << 1,
|
||||
if (this->flags & GFXP_FLAG_ENLARGE) {
|
||||
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, tile,
|
||||
gSPTextureRectangle(this->dList++, this->posX, this->posY, this->posX + 32, this->posY + 32, tile,
|
||||
(u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1 << 10, 1 << 10);
|
||||
}
|
||||
|
||||
|
@ -238,11 +237,11 @@ void GfxPrint_PrintChar(GfxPrint* this, u8 c) {
|
|||
u8 charParam = c;
|
||||
|
||||
if (c == ' ') {
|
||||
this->posX += 0x20;
|
||||
} else if (c > 0x20 && c < 0x7F) {
|
||||
this->posX += 32;
|
||||
} else if (c > ' ' && c < 0x7F) {
|
||||
GfxPrint_PrintCharImpl(this, charParam);
|
||||
} else if (c >= 0xA0 && c < 0xE0) {
|
||||
if (this->flag & GFXPRINT_FLAG1) {
|
||||
if (this->flags & GFXP_FLAG_HIRAGANA) {
|
||||
if (c < 0xC0) {
|
||||
charParam = c - 0x20;
|
||||
} else {
|
||||
|
@ -252,91 +251,94 @@ void GfxPrint_PrintChar(GfxPrint* this, u8 c) {
|
|||
GfxPrint_PrintCharImpl(this, charParam);
|
||||
} else {
|
||||
switch (c) {
|
||||
case 0:
|
||||
case '\0':
|
||||
break;
|
||||
case '\n':
|
||||
this->posY += 0x20;
|
||||
this->posY += 32;
|
||||
case '\r':
|
||||
this->posX = this->baseX;
|
||||
break;
|
||||
case '\t':
|
||||
do {
|
||||
GfxPrint_PrintCharImpl(this, 0x20);
|
||||
GfxPrint_PrintCharImpl(this, ' ');
|
||||
} while ((this->posX - this->baseX) % 256);
|
||||
break;
|
||||
case 0x8D:
|
||||
this->flag |= GFXPRINT_FLAG1;
|
||||
case GFXP_HIRAGANA_CHAR:
|
||||
this->flags |= GFXP_FLAG_HIRAGANA;
|
||||
break;
|
||||
case 0x8C:
|
||||
this->flag &= ~GFXPRINT_FLAG1;
|
||||
case GFXP_KATAKANA_CHAR:
|
||||
this->flags &= ~GFXP_FLAG_HIRAGANA;
|
||||
break;
|
||||
case 0x8B:
|
||||
this->flag |= GFXPRINT_USE_RGBA16;
|
||||
this->flag |= GFXPRINT_UPDATE_MODE;
|
||||
case GFXP_RAINBOW_ON_CHAR:
|
||||
this->flags |= GFXP_FLAG_RAINBOW;
|
||||
this->flags |= GFXP_FLAG_UPDATE;
|
||||
break;
|
||||
case 0x8A:
|
||||
this->flag &= ~GFXPRINT_USE_RGBA16;
|
||||
this->flag |= GFXPRINT_UPDATE_MODE;
|
||||
case GFXP_RAINBOW_OFF_CHAR:
|
||||
this->flags &= ~GFXP_FLAG_RAINBOW;
|
||||
this->flags |= GFXP_FLAG_UPDATE;
|
||||
break;
|
||||
case 0x8E:
|
||||
case GFXP_UNUSED_CHAR:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GfxPrint_PrintStringWithSize(GfxPrint* this, const void* buffer, size_t charSize, size_t charCount) {
|
||||
void GfxPrint_PrintStringWithSize(GfxPrint* this, const void* buffer, u32 charSize, u32 charCount) {
|
||||
const char* str = (const char*)buffer;
|
||||
size_t count = charSize * charCount;
|
||||
u32 count = charSize * charCount;
|
||||
|
||||
while (count) {
|
||||
GfxPrint_PrintChar(this, *str++);
|
||||
while (count != 0) {
|
||||
GfxPrint_PrintChar(this, *(str++));
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
void GfxPrint_PrintString(GfxPrint* this, const char* str) {
|
||||
while (*str) {
|
||||
while (*str != '\0') {
|
||||
GfxPrint_PrintChar(this, *(str++));
|
||||
}
|
||||
}
|
||||
|
||||
GfxPrint* GfxPrint_Callback(GfxPrint* this, const char* str, size_t size) {
|
||||
void* GfxPrint_Callback(void* arg, const char* str, u32 size) {
|
||||
GfxPrint* this = arg;
|
||||
|
||||
GfxPrint_PrintStringWithSize(this, str, sizeof(char), size);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
void GfxPrint_Init(GfxPrint* this) {
|
||||
this->flag &= ~GFXPRINT_OPEN;
|
||||
this->flags &= ~GFXP_FLAG_OPEN;
|
||||
|
||||
this->callback = &GfxPrint_Callback;
|
||||
this->dlist = NULL;
|
||||
this->callback = GfxPrint_Callback;
|
||||
this->dList = NULL;
|
||||
this->posX = 0;
|
||||
this->posY = 0;
|
||||
this->baseX = 0;
|
||||
this->baseY = 0;
|
||||
this->color.rgba = 0;
|
||||
|
||||
this->flag &= ~GFXPRINT_FLAG1;
|
||||
this->flag &= ~GFXPRINT_USE_RGBA16;
|
||||
this->flag |= GFXPRINT_FLAG4;
|
||||
this->flag |= GFXPRINT_UPDATE_MODE;
|
||||
this->flags &= ~GFXP_FLAG_HIRAGANA;
|
||||
this->flags &= ~GFXP_FLAG_RAINBOW;
|
||||
this->flags |= GFXP_FLAG_SHADOW;
|
||||
this->flags |= GFXP_FLAG_UPDATE;
|
||||
|
||||
if ((D_801755F0 & GFXPRINT_FLAG64)) {
|
||||
this->flag |= GFXPRINT_FLAG64; //? dsdx/dtdy
|
||||
if (sDefaultSpecialFlags & GFXP_FLAG_ENLARGE) {
|
||||
this->flags |= GFXP_FLAG_ENLARGE;
|
||||
} else {
|
||||
this->flag &= ~GFXPRINT_FLAG64;
|
||||
this->flags &= ~GFXP_FLAG_ENLARGE;
|
||||
}
|
||||
}
|
||||
|
||||
void GfxPrint_Destroy(GfxPrint* this) {
|
||||
}
|
||||
|
||||
void GfxPrint_Open(GfxPrint* this, Gfx* dlist) {
|
||||
if (!(this->flag & GFXPRINT_OPEN)) {
|
||||
this->flag |= GFXPRINT_OPEN;
|
||||
this->dlist = dlist;
|
||||
GfxPrint_InitDlist(this);
|
||||
void GfxPrint_Open(GfxPrint* this, Gfx* dList) {
|
||||
if (!(this->flags & GFXP_FLAG_OPEN)) {
|
||||
this->flags |= GFXP_FLAG_OPEN;
|
||||
this->dList = dList;
|
||||
GfxPrint_Setup(this);
|
||||
} else {
|
||||
osSyncPrintf("gfxprint_open:2重オープンです\n");
|
||||
}
|
||||
|
@ -345,15 +347,16 @@ void GfxPrint_Open(GfxPrint* this, Gfx* dlist) {
|
|||
Gfx* GfxPrint_Close(GfxPrint* this) {
|
||||
Gfx* ret;
|
||||
|
||||
this->flag &= ~GFXPRINT_OPEN;
|
||||
gDPPipeSync(this->dlist++);
|
||||
ret = this->dlist;
|
||||
this->dlist = NULL;
|
||||
this->flags &= ~GFXP_FLAG_OPEN;
|
||||
gDPPipeSync(this->dList++);
|
||||
ret = this->dList;
|
||||
this->dList = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
s32 GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args) {
|
||||
return PrintUtils_VPrintf((PrintCallback*)&this->callback, fmt, args);
|
||||
return PrintUtils_VPrintf(&this->callback, fmt, args);
|
||||
}
|
||||
|
||||
s32 GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue