2017-09-22 05:43:13 +02:00
|
|
|
#include "global.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "sound.h"
|
|
|
|
|
2018-08-26 15:27:06 +02:00
|
|
|
ALIGNED(4)
|
2017-12-17 23:45:27 +01:00
|
|
|
static const u8 sUnknown_08616124[] = {1, 2, 4};
|
|
|
|
static const u16 sFont6BrailleGlyphs[] = INCBIN_U16("data/graphics/fonts/font6.fwjpnfont");
|
2017-09-22 05:43:13 +02:00
|
|
|
|
2017-09-22 06:01:07 +02:00
|
|
|
static void DecompressGlyphFont6(u16);
|
2017-09-22 05:43:13 +02:00
|
|
|
|
|
|
|
u16 Font6Func(struct TextPrinter *textPrinter)
|
|
|
|
{
|
|
|
|
u16 char_;
|
|
|
|
struct TextPrinterSubStruct *sub;
|
2017-12-17 23:45:27 +01:00
|
|
|
|
2018-11-06 18:30:21 +01:00
|
|
|
sub = &textPrinter->subUnion.sub;
|
2017-09-22 05:43:13 +02:00
|
|
|
switch (textPrinter->state)
|
|
|
|
{
|
|
|
|
case 0:
|
2018-11-06 17:44:48 +01:00
|
|
|
if (gMain.heldKeys & (A_BUTTON | B_BUTTON) && sub->hasPrintBeenSpedUp)
|
2017-09-22 05:43:13 +02:00
|
|
|
{
|
|
|
|
textPrinter->delayCounter = 0;
|
|
|
|
}
|
2018-11-05 21:42:12 +01:00
|
|
|
if (textPrinter->delayCounter && textPrinter->textSpeed)
|
2017-09-22 05:43:13 +02:00
|
|
|
{
|
|
|
|
textPrinter->delayCounter --;
|
2018-11-06 17:44:48 +01:00
|
|
|
if (gTextFlags.canABSpeedUpPrint && gMain.newKeys & (A_BUTTON | B_BUTTON))
|
2017-09-22 05:43:13 +02:00
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
sub->hasPrintBeenSpedUp = TRUE;
|
2017-09-22 05:43:13 +02:00
|
|
|
textPrinter->delayCounter = 0;
|
|
|
|
}
|
|
|
|
return 3;
|
|
|
|
}
|
2018-11-06 18:30:21 +01:00
|
|
|
if (gTextFlags.autoScroll)
|
2017-09-22 05:43:13 +02:00
|
|
|
{
|
|
|
|
textPrinter->delayCounter = 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-05 21:42:12 +01:00
|
|
|
textPrinter->delayCounter = textPrinter->textSpeed;
|
2017-09-22 05:43:13 +02:00
|
|
|
}
|
2018-11-06 17:44:48 +01:00
|
|
|
char_ = *textPrinter->printerTemplate.currentChar++;
|
2017-09-22 05:43:13 +02:00
|
|
|
switch (char_)
|
|
|
|
{
|
|
|
|
case EOS:
|
|
|
|
return 1;
|
|
|
|
case CHAR_NEWLINE:
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x;
|
|
|
|
textPrinter->printerTemplate.currentY += gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing;
|
2017-09-22 05:43:13 +02:00
|
|
|
return 2;
|
|
|
|
case PLACEHOLDER_BEGIN:
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.currentChar++;
|
2017-09-22 05:43:13 +02:00
|
|
|
return 2;
|
|
|
|
case EXT_CTRL_CODE_BEGIN:
|
2018-11-06 17:44:48 +01:00
|
|
|
char_ = *textPrinter->printerTemplate.currentChar++;
|
2017-09-22 05:43:13 +02:00
|
|
|
switch (char_)
|
|
|
|
{
|
|
|
|
case 1:
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar++;
|
|
|
|
GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor);
|
2017-09-22 05:43:13 +02:00
|
|
|
return 2;
|
|
|
|
case 2:
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.bgColor = *textPrinter->printerTemplate.currentChar++;
|
|
|
|
GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor);
|
2017-09-22 05:43:13 +02:00
|
|
|
return 2;
|
|
|
|
case 3:
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.shadowColor = *textPrinter->printerTemplate.currentChar++;
|
|
|
|
GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor);
|
2017-09-22 05:43:13 +02:00
|
|
|
return 2;
|
|
|
|
case 4:
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar;
|
|
|
|
textPrinter->printerTemplate.bgColor = *++textPrinter->printerTemplate.currentChar;
|
|
|
|
textPrinter->printerTemplate.shadowColor = *++textPrinter->printerTemplate.currentChar;
|
|
|
|
textPrinter->printerTemplate.currentChar++;
|
2017-09-22 05:43:13 +02:00
|
|
|
|
2018-11-06 17:44:48 +01:00
|
|
|
GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor);
|
2017-09-22 05:43:13 +02:00
|
|
|
return 2;
|
|
|
|
case 5:
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.currentChar++;
|
2017-09-22 05:43:13 +02:00
|
|
|
return 2;
|
|
|
|
case 6:
|
2018-11-06 17:44:48 +01:00
|
|
|
sub->glyphId = *textPrinter->printerTemplate.currentChar;
|
|
|
|
textPrinter->printerTemplate.currentChar++;
|
2017-09-22 05:43:13 +02:00
|
|
|
return 2;
|
|
|
|
case 7:
|
|
|
|
return 2;
|
|
|
|
case 8:
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->delayCounter = *textPrinter->printerTemplate.currentChar++;
|
2017-09-22 05:43:13 +02:00
|
|
|
textPrinter->state = 6;
|
|
|
|
return 2;
|
|
|
|
case 9:
|
|
|
|
textPrinter->state = 1;
|
2018-11-06 18:30:21 +01:00
|
|
|
if (gTextFlags.autoScroll)
|
2017-09-22 05:43:13 +02:00
|
|
|
{
|
2018-11-06 18:30:21 +01:00
|
|
|
sub->autoScrollDelay = 0;
|
2017-09-22 05:43:13 +02:00
|
|
|
}
|
|
|
|
return 3;
|
|
|
|
case 10:
|
|
|
|
textPrinter->state = 5;
|
|
|
|
return 3;
|
|
|
|
case 11:
|
|
|
|
case 16:
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.currentChar += 2;
|
2017-09-22 05:43:13 +02:00
|
|
|
return 2;
|
|
|
|
case 12:
|
2018-11-06 17:44:48 +01:00
|
|
|
char_ = *++textPrinter->printerTemplate.currentChar;
|
2017-09-22 05:43:13 +02:00
|
|
|
break;
|
|
|
|
case 13:
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x + *textPrinter->printerTemplate.currentChar++;
|
2017-09-22 05:43:13 +02:00
|
|
|
return 2;
|
|
|
|
case 14:
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y + *textPrinter->printerTemplate.currentChar++;
|
2017-09-22 05:43:13 +02:00
|
|
|
return 2;
|
|
|
|
case 15:
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
|
2017-09-22 05:43:13 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CHAR_PROMPT_CLEAR:
|
|
|
|
textPrinter->state = 2;
|
|
|
|
TextPrinterInitDownArrowCounters(textPrinter);
|
|
|
|
return 3;
|
|
|
|
case CHAR_PROMPT_SCROLL:
|
|
|
|
textPrinter->state = 3;
|
|
|
|
TextPrinterInitDownArrowCounters(textPrinter);
|
|
|
|
return 3;
|
|
|
|
case 0xF9:
|
2018-11-06 17:44:48 +01:00
|
|
|
char_ = *textPrinter->printerTemplate.currentChar++| 0x100;
|
2017-09-22 05:43:13 +02:00
|
|
|
break;
|
|
|
|
case 0xF8:
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.currentChar++;
|
2017-09-22 05:43:13 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
DecompressGlyphFont6(char_);
|
|
|
|
CopyGlyphToWindow(textPrinter);
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.currentX += gUnknown_03002F90.unk80 + textPrinter->printerTemplate.letterSpacing;
|
2017-09-22 05:43:13 +02:00
|
|
|
return 0;
|
|
|
|
case 1:
|
|
|
|
if (TextPrinterWait(textPrinter))
|
|
|
|
{
|
|
|
|
textPrinter->state = 0;
|
|
|
|
}
|
|
|
|
return 3;
|
|
|
|
case 2:
|
|
|
|
if (TextPrinterWaitWithDownArrow(textPrinter))
|
|
|
|
{
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x;
|
|
|
|
textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y;
|
2017-09-22 05:43:13 +02:00
|
|
|
textPrinter->state = 0;
|
|
|
|
}
|
|
|
|
return 3;
|
|
|
|
case 3:
|
|
|
|
if (TextPrinterWaitWithDownArrow(textPrinter))
|
|
|
|
{
|
|
|
|
TextPrinterClearDownArrow(textPrinter);
|
2018-11-06 17:44:48 +01:00
|
|
|
textPrinter->scrollDistance = gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing;
|
|
|
|
textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x;
|
2017-09-22 05:43:13 +02:00
|
|
|
textPrinter->state = 4;
|
|
|
|
}
|
|
|
|
return 3;
|
|
|
|
case 4:
|
|
|
|
if (textPrinter->scrollDistance)
|
|
|
|
{
|
2017-12-17 23:45:27 +01:00
|
|
|
if (textPrinter->scrollDistance < sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed])
|
2017-09-22 05:43:13 +02:00
|
|
|
{
|
2019-03-02 23:25:39 +01:00
|
|
|
ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
|
2017-09-22 05:43:13 +02:00
|
|
|
textPrinter->scrollDistance = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-02 23:25:39 +01:00
|
|
|
ScrollWindow(textPrinter->printerTemplate.windowId, 0, sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed], PIXEL_FILL(textPrinter->printerTemplate.bgColor));
|
2017-12-17 23:45:27 +01:00
|
|
|
textPrinter->scrollDistance -= sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed];
|
2017-09-22 05:43:13 +02:00
|
|
|
}
|
2018-11-06 17:44:48 +01:00
|
|
|
CopyWindowToVram(textPrinter->printerTemplate.windowId, 2);
|
2017-09-22 05:43:13 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
textPrinter->state = 0;
|
|
|
|
}
|
|
|
|
return 3;
|
|
|
|
case 5:
|
|
|
|
if (!IsSEPlaying())
|
|
|
|
{
|
|
|
|
textPrinter->state = 0;
|
|
|
|
}
|
|
|
|
return 3;
|
|
|
|
case 6:
|
|
|
|
if (textPrinter->delayCounter)
|
|
|
|
{
|
|
|
|
textPrinter->delayCounter --;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
textPrinter->state = 0;
|
|
|
|
}
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2017-09-22 06:01:07 +02:00
|
|
|
|
|
|
|
static void DecompressGlyphFont6(u16 glyph)
|
|
|
|
{
|
|
|
|
const u16 *glyphs;
|
|
|
|
|
2017-12-17 23:45:27 +01:00
|
|
|
glyphs = sFont6BrailleGlyphs + 0x100 * (glyph / 8) + 0x10 * (glyph % 8);
|
2018-11-05 21:42:12 +01:00
|
|
|
DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0);
|
|
|
|
DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20));
|
|
|
|
DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40));
|
|
|
|
DecompressGlyphTile(glyphs + 0x88, (u16 *)(gUnknown_03002F90.unk60));
|
|
|
|
gUnknown_03002F90.unk80 = 0x10;
|
|
|
|
gUnknown_03002F90.unk81 = 0x10;
|
2017-09-22 06:01:07 +02:00
|
|
|
}
|
|
|
|
|
2019-03-02 09:18:08 +01:00
|
|
|
u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese)
|
2017-09-22 06:01:07 +02:00
|
|
|
{
|
|
|
|
return 0x10;
|
|
|
|
}
|