1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-14 21:40:03 +00:00

[ntsc-1.2] Partially match gfxprint.c (#2101)

* [ntsc-1.2] Partially match gfxprint.c

* yeet bss

* fix

* review
This commit is contained in:
Dragorn421 2024-09-04 19:22:59 +02:00 committed by GitHub
parent c6d7cc7697
commit fab309ae08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 5 deletions

View file

@ -34,7 +34,9 @@ typedef struct GfxPrint {
#define GFXP_FLAG_RAINBOW (1 << 1)
#define GFXP_FLAG_SHADOW (1 << 2)
#define GFXP_FLAG_UPDATE (1 << 3)
#if PLATFORM_GC
#define GFXP_FLAG_ENLARGE (1 << 6)
#endif
#define GFXP_FLAG_OPEN (1 << 7)
#endif

View file

@ -126,8 +126,10 @@ u8 sGfxPrintFontData[(16 * 256) / 2] = {
0x1B, 0xAA, 0x40, 0x21, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#if PLATFORM_GC
// Can be used to set GFXP_FLAG_ENLARGE by default
static u8 sDefaultSpecialFlags;
#endif
void GfxPrint_Setup(GfxPrint* this) {
s32 width = 16;
@ -210,6 +212,10 @@ void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) {
if (this->flags & GFXP_FLAG_SHADOW) {
gDPSetColor(this->dList++, G_SETPRIMCOLOR, 0);
#if PLATFORM_N64
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);
#else
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,
@ -218,10 +224,15 @@ void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) {
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);
}
#endif
gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba);
}
#if PLATFORM_N64
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);
#else
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);
@ -229,26 +240,32 @@ void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) {
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);
}
#endif
this->posX += GFX_CHAR_X_SPACING << 2;
}
void GfxPrint_PrintChar(GfxPrint* this, u8 c) {
#if PLATFORM_N64
#define CHAR_PARAM c
#else
#define CHAR_PARAM charParam
u8 charParam = c;
#endif
if (c == ' ') {
this->posX += GFX_CHAR_X_SPACING << 2;
} else if (c > ' ' && c < 0x7F) {
GfxPrint_PrintCharImpl(this, charParam);
GfxPrint_PrintCharImpl(this, c);
} else if (c >= 0xA0 && c < 0xE0) {
if (this->flags & GFXP_FLAG_HIRAGANA) {
if (c < 0xC0) {
charParam = c - 0x20;
CHAR_PARAM = c - 0x20;
} else {
charParam = c + 0x20;
CHAR_PARAM = c + 0x20;
}
}
GfxPrint_PrintCharImpl(this, charParam);
GfxPrint_PrintCharImpl(this, CHAR_PARAM);
} else {
switch (c) {
case '\0':
@ -325,11 +342,13 @@ void GfxPrint_Init(GfxPrint* this) {
this->flags |= GFXP_FLAG_SHADOW;
this->flags |= GFXP_FLAG_UPDATE;
#if PLATFORM_GC
if (sDefaultSpecialFlags & GFXP_FLAG_ENLARGE) {
this->flags |= GFXP_FLAG_ENLARGE;
} else {
this->flags &= ~GFXP_FLAG_ENLARGE;
}
#endif
}
void GfxPrint_Destroy(GfxPrint* this) {
@ -341,7 +360,9 @@ void GfxPrint_Open(GfxPrint* this, Gfx* dList) {
this->dList = dList;
GfxPrint_Setup(this);
} else {
PRINTF("gfxprint_open:2重オープンです\n");
#if PLATFORM_N64 || OOT_DEBUG
osSyncPrintf("gfxprint_open:2重オープンです\n");
#endif
}
}
@ -349,7 +370,9 @@ Gfx* GfxPrint_Close(GfxPrint* this) {
Gfx* ret;
this->flags &= ~GFXP_FLAG_OPEN;
#if PLATFORM_GC
gDPPipeSync(this->dList++);
#endif
ret = this->dList;
this->dList = NULL;