Merge pull request #1053 from Sierraffinity/text-drawdownarrow-fix
Fix TextPrinterDrawDownArrow fakematch
This commit is contained in:
+43
-41
@@ -178,7 +178,7 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, voi
|
|||||||
|
|
||||||
for (i = 0; i < 7; i++)
|
for (i = 0; i < 7; i++)
|
||||||
{
|
{
|
||||||
gTempTextPrinter.subUnion.fields[i] = 0;
|
gTempTextPrinter.subStructFields[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gTempTextPrinter.printerTemplate = *printerTemplate;
|
gTempTextPrinter.printerTemplate = *printerTemplate;
|
||||||
@@ -187,7 +187,7 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, voi
|
|||||||
gTempTextPrinter.japanese = 0;
|
gTempTextPrinter.japanese = 0;
|
||||||
|
|
||||||
GenerateFontHalfRowLookupTable(printerTemplate->fgColor, printerTemplate->bgColor, printerTemplate->shadowColor);
|
GenerateFontHalfRowLookupTable(printerTemplate->fgColor, printerTemplate->bgColor, printerTemplate->shadowColor);
|
||||||
if (speed != TEXT_SPEED_FF && speed != 0x0)
|
if (speed != TEXT_SPEED_FF && speed != 0)
|
||||||
{
|
{
|
||||||
--gTempTextPrinter.textSpeed;
|
--gTempTextPrinter.textSpeed;
|
||||||
gTextPrinters[printerTemplate->windowId] = gTempTextPrinter;
|
gTextPrinters[printerTemplate->windowId] = gTempTextPrinter;
|
||||||
@@ -202,7 +202,7 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, voi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (speed != TEXT_SPEED_FF)
|
if (speed != TEXT_SPEED_FF)
|
||||||
CopyWindowToVram(gTempTextPrinter.printerTemplate.windowId, 2);
|
CopyWindowToVram(gTempTextPrinter.printerTemplate.windowId, 2);
|
||||||
gTextPrinters[printerTemplate->windowId].active = 0;
|
gTextPrinters[printerTemplate->windowId].active = 0;
|
||||||
}
|
}
|
||||||
gUnknown_03002F84 = 0;
|
gUnknown_03002F84 = 0;
|
||||||
@@ -215,7 +215,7 @@ void RunTextPrinters(void)
|
|||||||
|
|
||||||
if (gUnknown_03002F84 == 0)
|
if (gUnknown_03002F84 == 0)
|
||||||
{
|
{
|
||||||
for (i = 0; i < 0x20; ++i)
|
for (i = 0; i < NUM_TEXT_PRINTERS; ++i)
|
||||||
{
|
{
|
||||||
if (gTextPrinters[i].active)
|
if (gTextPrinters[i].active)
|
||||||
{
|
{
|
||||||
@@ -1297,11 +1297,11 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width)
|
|||||||
|
|
||||||
u16 Font0Func(struct TextPrinter *textPrinter)
|
u16 Font0Func(struct TextPrinter *textPrinter)
|
||||||
{
|
{
|
||||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||||
|
|
||||||
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||||
{
|
{
|
||||||
textPrinter->subUnion.sub.glyphId = 0;
|
subStruct->glyphId = 0;
|
||||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||||
}
|
}
|
||||||
return RenderText(textPrinter);
|
return RenderText(textPrinter);
|
||||||
@@ -1309,11 +1309,11 @@ u16 Font0Func(struct TextPrinter *textPrinter)
|
|||||||
|
|
||||||
u16 Font1Func(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)
|
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||||
{
|
{
|
||||||
textPrinter->subUnion.sub.glyphId = 1;
|
subStruct->glyphId = 1;
|
||||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||||
}
|
}
|
||||||
return RenderText(textPrinter);
|
return RenderText(textPrinter);
|
||||||
@@ -1321,11 +1321,11 @@ u16 Font1Func(struct TextPrinter *textPrinter)
|
|||||||
|
|
||||||
u16 Font2Func(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)
|
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||||
{
|
{
|
||||||
textPrinter->subUnion.sub.glyphId = 2;
|
subStruct->glyphId = 2;
|
||||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||||
}
|
}
|
||||||
return RenderText(textPrinter);
|
return RenderText(textPrinter);
|
||||||
@@ -1333,11 +1333,11 @@ u16 Font2Func(struct TextPrinter *textPrinter)
|
|||||||
|
|
||||||
u16 Font3Func(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)
|
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||||
{
|
{
|
||||||
textPrinter->subUnion.sub.glyphId = 3;
|
subStruct->glyphId = 3;
|
||||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||||
}
|
}
|
||||||
return RenderText(textPrinter);
|
return RenderText(textPrinter);
|
||||||
@@ -1345,11 +1345,11 @@ u16 Font3Func(struct TextPrinter *textPrinter)
|
|||||||
|
|
||||||
u16 Font4Func(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)
|
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||||
{
|
{
|
||||||
textPrinter->subUnion.sub.glyphId = 4;
|
subStruct->glyphId = 4;
|
||||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||||
}
|
}
|
||||||
return RenderText(textPrinter);
|
return RenderText(textPrinter);
|
||||||
@@ -1357,11 +1357,11 @@ u16 Font4Func(struct TextPrinter *textPrinter)
|
|||||||
|
|
||||||
u16 Font5Func(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)
|
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||||
{
|
{
|
||||||
textPrinter->subUnion.sub.glyphId = 5;
|
subStruct->glyphId = 5;
|
||||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||||
}
|
}
|
||||||
return RenderText(textPrinter);
|
return RenderText(textPrinter);
|
||||||
@@ -1369,11 +1369,11 @@ u16 Font5Func(struct TextPrinter *textPrinter)
|
|||||||
|
|
||||||
u16 Font7Func(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)
|
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||||
{
|
{
|
||||||
textPrinter->subUnion.sub.glyphId = 7;
|
subStruct->glyphId = 7;
|
||||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||||
}
|
}
|
||||||
return RenderText(textPrinter);
|
return RenderText(textPrinter);
|
||||||
@@ -1381,11 +1381,11 @@ u16 Font7Func(struct TextPrinter *textPrinter)
|
|||||||
|
|
||||||
u16 Font8Func(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)
|
if (subStruct->hasGlyphIdBeenSet == FALSE)
|
||||||
{
|
{
|
||||||
textPrinter->subUnion.sub.glyphId = 8;
|
subStruct->glyphId = 8;
|
||||||
subStruct->hasGlyphIdBeenSet = TRUE;
|
subStruct->hasGlyphIdBeenSet = TRUE;
|
||||||
}
|
}
|
||||||
return RenderText(textPrinter);
|
return RenderText(textPrinter);
|
||||||
@@ -1393,10 +1393,12 @@ u16 Font8Func(struct TextPrinter *textPrinter)
|
|||||||
|
|
||||||
void TextPrinterInitDownArrowCounters(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)
|
if (gTextFlags.autoScroll == 1)
|
||||||
|
{
|
||||||
subStruct->autoScrollDelay = 0;
|
subStruct->autoScrollDelay = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
subStruct->downArrowYPosIdx = 0;
|
subStruct->downArrowYPosIdx = 0;
|
||||||
@@ -1406,14 +1408,14 @@ void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter)
|
|||||||
|
|
||||||
void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter)
|
void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter)
|
||||||
{
|
{
|
||||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||||
const u8 *arrowTiles;
|
const u8 *arrowTiles;
|
||||||
|
|
||||||
if (gTextFlags.autoScroll == 0)
|
if (gTextFlags.autoScroll == 0)
|
||||||
{
|
{
|
||||||
if (subStruct->downArrowDelay != 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
|
else
|
||||||
{
|
{
|
||||||
@@ -1422,16 +1424,16 @@ void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter)
|
|||||||
textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor,
|
textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor,
|
||||||
textPrinter->printerTemplate.currentX,
|
textPrinter->printerTemplate.currentX,
|
||||||
textPrinter->printerTemplate.currentY,
|
textPrinter->printerTemplate.currentY,
|
||||||
0x8,
|
8,
|
||||||
0x10);
|
16);
|
||||||
|
|
||||||
switch (gTextFlags.useAlternateDownArrow)
|
switch (gTextFlags.useAlternateDownArrow)
|
||||||
{
|
{
|
||||||
case 0:
|
case FALSE:
|
||||||
default:
|
default:
|
||||||
arrowTiles = gDownArrowTiles;
|
arrowTiles = gDownArrowTiles;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case TRUE:
|
||||||
arrowTiles = gDarkDownArrowTiles;
|
arrowTiles = gDarkDownArrowTiles;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1440,17 +1442,17 @@ void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter)
|
|||||||
textPrinter->printerTemplate.windowId,
|
textPrinter->printerTemplate.windowId,
|
||||||
arrowTiles,
|
arrowTiles,
|
||||||
0,
|
0,
|
||||||
gDownArrowYCoords[*(u32*)subStruct << 17 >> 30], // subStruct->downArrowYPosIdx but again, stupidly retrieved
|
gDownArrowYCoords[subStruct->downArrowYPosIdx],
|
||||||
0x8,
|
8,
|
||||||
0x10,
|
16,
|
||||||
textPrinter->printerTemplate.currentX,
|
textPrinter->printerTemplate.currentX,
|
||||||
textPrinter->printerTemplate.currentY,
|
textPrinter->printerTemplate.currentY,
|
||||||
0x8,
|
8,
|
||||||
0x10);
|
16);
|
||||||
CopyWindowToVram(textPrinter->printerTemplate.windowId, 0x2);
|
CopyWindowToVram(textPrinter->printerTemplate.windowId, 2);
|
||||||
|
|
||||||
subStruct->downArrowDelay = 0x8;
|
subStruct->downArrowDelay = 8;
|
||||||
subStruct->downArrowYPosIdx = (*(u32*)subStruct << 17 >> 30) + 1;
|
subStruct->downArrowYPosIdx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1462,14 +1464,14 @@ void TextPrinterClearDownArrow(struct TextPrinter *textPrinter)
|
|||||||
textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor,
|
textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor,
|
||||||
textPrinter->printerTemplate.currentX,
|
textPrinter->printerTemplate.currentX,
|
||||||
textPrinter->printerTemplate.currentY,
|
textPrinter->printerTemplate.currentY,
|
||||||
0x8,
|
8,
|
||||||
0x10);
|
16);
|
||||||
CopyWindowToVram(textPrinter->printerTemplate.windowId, 0x2);
|
CopyWindowToVram(textPrinter->printerTemplate.windowId, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter)
|
bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter)
|
||||||
{
|
{
|
||||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||||
|
|
||||||
if (subStruct->autoScrollDelay == 49)
|
if (subStruct->autoScrollDelay == 49)
|
||||||
{
|
{
|
||||||
@@ -1477,7 +1479,7 @@ bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
++subStruct->autoScrollDelay;
|
subStruct->autoScrollDelay++;
|
||||||
return FALSE;
|
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)
|
u16 RenderText(struct TextPrinter *textPrinter)
|
||||||
{
|
{
|
||||||
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
|
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||||
u16 currChar;
|
u16 currChar;
|
||||||
s32 width;
|
s32 width;
|
||||||
s32 widthHelper;
|
s32 widthHelper;
|
||||||
|
|||||||
+1
-9
@@ -200,15 +200,7 @@ struct TextPrinter
|
|||||||
|
|
||||||
void (*callback)(struct TextPrinterTemplate *, u16); // 0x10
|
void (*callback)(struct TextPrinterTemplate *, u16); // 0x10
|
||||||
|
|
||||||
union
|
u8 subStructFields[7]; // always cast to struct TextPrinterSubStruct... so why bother
|
||||||
#if !MODERN
|
|
||||||
__attribute__((packed))
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
struct TextPrinterSubStruct sub;
|
|
||||||
u8 fields[7];
|
|
||||||
} subUnion;
|
|
||||||
|
|
||||||
u8 active;
|
u8 active;
|
||||||
u8 state; // 0x1C
|
u8 state; // 0x1C
|
||||||
u8 textSpeed;
|
u8 textSpeed;
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ static void DecompressGlyphFont6(u16);
|
|||||||
u16 Font6Func(struct TextPrinter *textPrinter)
|
u16 Font6Func(struct TextPrinter *textPrinter)
|
||||||
{
|
{
|
||||||
u16 char_;
|
u16 char_;
|
||||||
struct TextPrinterSubStruct *sub;
|
struct TextPrinterSubStruct *subStruct;
|
||||||
|
subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
|
||||||
|
|
||||||
sub = &textPrinter->subUnion.sub;
|
|
||||||
switch (textPrinter->state)
|
switch (textPrinter->state)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (gMain.heldKeys & (A_BUTTON | B_BUTTON) && sub->hasPrintBeenSpedUp)
|
if (gMain.heldKeys & (A_BUTTON | B_BUTTON) && subStruct->hasPrintBeenSpedUp)
|
||||||
{
|
{
|
||||||
textPrinter->delayCounter = 0;
|
textPrinter->delayCounter = 0;
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ u16 Font6Func(struct TextPrinter *textPrinter)
|
|||||||
textPrinter->delayCounter --;
|
textPrinter->delayCounter --;
|
||||||
if (gTextFlags.canABSpeedUpPrint && gMain.newKeys & (A_BUTTON | B_BUTTON))
|
if (gTextFlags.canABSpeedUpPrint && gMain.newKeys & (A_BUTTON | B_BUTTON))
|
||||||
{
|
{
|
||||||
sub->hasPrintBeenSpedUp = TRUE;
|
subStruct->hasPrintBeenSpedUp = TRUE;
|
||||||
textPrinter->delayCounter = 0;
|
textPrinter->delayCounter = 0;
|
||||||
}
|
}
|
||||||
return 3;
|
return 3;
|
||||||
@@ -81,7 +81,7 @@ u16 Font6Func(struct TextPrinter *textPrinter)
|
|||||||
textPrinter->printerTemplate.currentChar++;
|
textPrinter->printerTemplate.currentChar++;
|
||||||
return 2;
|
return 2;
|
||||||
case 6:
|
case 6:
|
||||||
sub->glyphId = *textPrinter->printerTemplate.currentChar;
|
subStruct->glyphId = *textPrinter->printerTemplate.currentChar;
|
||||||
textPrinter->printerTemplate.currentChar++;
|
textPrinter->printerTemplate.currentChar++;
|
||||||
return 2;
|
return 2;
|
||||||
case 7:
|
case 7:
|
||||||
@@ -94,7 +94,7 @@ u16 Font6Func(struct TextPrinter *textPrinter)
|
|||||||
textPrinter->state = 1;
|
textPrinter->state = 1;
|
||||||
if (gTextFlags.autoScroll)
|
if (gTextFlags.autoScroll)
|
||||||
{
|
{
|
||||||
sub->autoScrollDelay = 0;
|
subStruct->autoScrollDelay = 0;
|
||||||
}
|
}
|
||||||
return 3;
|
return 3;
|
||||||
case 10:
|
case 10:
|
||||||
|
|||||||
Reference in New Issue
Block a user