mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 19:54:21 +01:00
Fix TextPrinterDrawDownArrow fakematch
This commit is contained in:
parent
a1244aa5dd
commit
3617a064d2
80
gflib/text.c
80
gflib/text.c
@ -178,7 +178,7 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, voi
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
gTempTextPrinter.subUnion.fields[i] = 0;
|
||||
gTempTextPrinter.subStructFields[i] = 0;
|
||||
}
|
||||
|
||||
gTempTextPrinter.printerTemplate = *printerTemplate;
|
||||
@ -187,7 +187,7 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, voi
|
||||
gTempTextPrinter.japanese = 0;
|
||||
|
||||
GenerateFontHalfRowLookupTable(printerTemplate->fgColor, printerTemplate->bgColor, printerTemplate->shadowColor);
|
||||
if (speed != TEXT_SPEED_FF && speed != 0x0)
|
||||
if (speed != TEXT_SPEED_FF && speed != 0)
|
||||
{
|
||||
--gTempTextPrinter.textSpeed;
|
||||
gTextPrinters[printerTemplate->windowId] = gTempTextPrinter;
|
||||
@ -1297,11 +1297,11 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width)
|
||||
|
||||
u16 Font0Func(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||
{
|
||||
textPrinter->subUnion.sub.glyphId = 0;
|
||||
subStruct->glyphId = 0;
|
||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||
}
|
||||
return RenderText(textPrinter);
|
||||
@ -1309,11 +1309,11 @@ u16 Font0Func(struct TextPrinter *textPrinter)
|
||||
|
||||
u16 Font1Func(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||
{
|
||||
textPrinter->subUnion.sub.glyphId = 1;
|
||||
subStruct->glyphId = 1;
|
||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||
}
|
||||
return RenderText(textPrinter);
|
||||
@ -1321,11 +1321,11 @@ u16 Font1Func(struct TextPrinter *textPrinter)
|
||||
|
||||
u16 Font2Func(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||
{
|
||||
textPrinter->subUnion.sub.glyphId = 2;
|
||||
subStruct->glyphId = 2;
|
||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||
}
|
||||
return RenderText(textPrinter);
|
||||
@ -1333,11 +1333,11 @@ u16 Font2Func(struct TextPrinter *textPrinter)
|
||||
|
||||
u16 Font3Func(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||
{
|
||||
textPrinter->subUnion.sub.glyphId = 3;
|
||||
subStruct->glyphId = 3;
|
||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||
}
|
||||
return RenderText(textPrinter);
|
||||
@ -1345,11 +1345,11 @@ u16 Font3Func(struct TextPrinter *textPrinter)
|
||||
|
||||
u16 Font4Func(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||
{
|
||||
textPrinter->subUnion.sub.glyphId = 4;
|
||||
subStruct->glyphId = 4;
|
||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||
}
|
||||
return RenderText(textPrinter);
|
||||
@ -1357,11 +1357,11 @@ u16 Font4Func(struct TextPrinter *textPrinter)
|
||||
|
||||
u16 Font5Func(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||
{
|
||||
textPrinter->subUnion.sub.glyphId = 5;
|
||||
subStruct->glyphId = 5;
|
||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||
}
|
||||
return RenderText(textPrinter);
|
||||
@ -1369,11 +1369,11 @@ u16 Font5Func(struct TextPrinter *textPrinter)
|
||||
|
||||
u16 Font7Func(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||
{
|
||||
textPrinter->subUnion.sub.glyphId = 7;
|
||||
subStruct->glyphId = 7;
|
||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||
}
|
||||
return RenderText(textPrinter);
|
||||
@ -1381,11 +1381,11 @@ u16 Font7Func(struct TextPrinter *textPrinter)
|
||||
|
||||
u16 Font8Func(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||
{
|
||||
textPrinter->subUnion.sub.glyphId = 8;
|
||||
subStruct->glyphId = 8;
|
||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||
}
|
||||
return RenderText(textPrinter);
|
||||
@ -1393,10 +1393,12 @@ u16 Font8Func(struct TextPrinter *textPrinter)
|
||||
|
||||
void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (gTextFlags.autoScroll == 1)
|
||||
{
|
||||
subStruct->autoScrollDelay = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
subStruct->downArrowYPosIdx = 0;
|
||||
@ -1406,14 +1408,14 @@ void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter)
|
||||
|
||||
void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
const u8 *arrowTiles;
|
||||
|
||||
if (gTextFlags.autoScroll == 0)
|
||||
{
|
||||
if (subStruct->downArrowDelay != 0)
|
||||
{
|
||||
subStruct->downArrowDelay = ((*(u32*)&textPrinter->subUnion.sub) << 19 >> 27) - 1; // convoluted way of getting downArrowDelay, necessary to match
|
||||
subStruct->downArrowDelay--;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1422,16 +1424,16 @@ void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter)
|
||||
textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor,
|
||||
textPrinter->printerTemplate.currentX,
|
||||
textPrinter->printerTemplate.currentY,
|
||||
0x8,
|
||||
0x10);
|
||||
8,
|
||||
16);
|
||||
|
||||
switch (gTextFlags.useAlternateDownArrow)
|
||||
{
|
||||
case 0:
|
||||
case FALSE:
|
||||
default:
|
||||
arrowTiles = gDownArrowTiles;
|
||||
break;
|
||||
case 1:
|
||||
case TRUE:
|
||||
arrowTiles = gDarkDownArrowTiles;
|
||||
break;
|
||||
}
|
||||
@ -1440,17 +1442,17 @@ void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter)
|
||||
textPrinter->printerTemplate.windowId,
|
||||
arrowTiles,
|
||||
0,
|
||||
gDownArrowYCoords[*(u32*)subStruct << 17 >> 30], // subStruct->downArrowYPosIdx but again, stupidly retrieved
|
||||
0x8,
|
||||
0x10,
|
||||
gDownArrowYCoords[subStruct->downArrowYPosIdx],
|
||||
8,
|
||||
16,
|
||||
textPrinter->printerTemplate.currentX,
|
||||
textPrinter->printerTemplate.currentY,
|
||||
0x8,
|
||||
0x10);
|
||||
CopyWindowToVram(textPrinter->printerTemplate.windowId, 0x2);
|
||||
8,
|
||||
16);
|
||||
CopyWindowToVram(textPrinter->printerTemplate.windowId, 2);
|
||||
|
||||
subStruct->downArrowDelay = 0x8;
|
||||
subStruct->downArrowYPosIdx = (*(u32*)subStruct << 17 >> 30) + 1;
|
||||
subStruct->downArrowDelay = 8;
|
||||
subStruct->downArrowYPosIdx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1462,14 +1464,14 @@ void TextPrinterClearDownArrow(struct TextPrinter *textPrinter)
|
||||
textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor,
|
||||
textPrinter->printerTemplate.currentX,
|
||||
textPrinter->printerTemplate.currentY,
|
||||
0x8,
|
||||
0x10);
|
||||
CopyWindowToVram(textPrinter->printerTemplate.windowId, 0x2);
|
||||
8,
|
||||
16);
|
||||
CopyWindowToVram(textPrinter->printerTemplate.windowId, 2);
|
||||
}
|
||||
|
||||
bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
|
||||
if (subStruct->autoScrollDelay == 49)
|
||||
{
|
||||
@ -1477,7 +1479,7 @@ bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter)
|
||||
}
|
||||
else
|
||||
{
|
||||
++subStruct->autoScrollDelay;
|
||||
subStruct->autoScrollDelay++;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -1563,7 +1565,7 @@ void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *c
|
||||
|
||||
u16 RenderText(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||
u16 currChar;
|
||||
s32 width;
|
||||
s32 widthHelper;
|
||||
|
10
gflib/text.h
10
gflib/text.h
@ -200,15 +200,7 @@ struct TextPrinter
|
||||
|
||||
void (*callback)(struct TextPrinterTemplate *, u16); // 0x10
|
||||
|
||||
union
|
||||
#if !MODERN
|
||||
__attribute__((packed))
|
||||
#endif
|
||||
{
|
||||
struct TextPrinterSubStruct sub;
|
||||
u8 fields[7];
|
||||
} subUnion;
|
||||
|
||||
u8 subStructFields[7]; // always cast to struct TextPrinterSubStruct... so why bother
|
||||
u8 active;
|
||||
u8 state; // 0x1C
|
||||
u8 textSpeed;
|
||||
|
Loading…
Reference in New Issue
Block a user