Get RenderText a bit closer (thanks Egg)

This commit is contained in:
Diegoisawesome 2018-01-30 13:13:07 -06:00
parent 7941558b80
commit a75c476d57

View File

@ -2054,20 +2054,16 @@ void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *c
#ifdef NONMATCHING #ifdef NONMATCHING
u16 RenderText(struct TextPrinter *textPrinter) u16 RenderText(struct TextPrinter *textPrinter)
{ {
struct TextPrinterSubStruct* r4 = &textPrinter->sub_union.sub; struct TextPrinterSubStruct *r4 = &textPrinter->sub_union.sub;
int temp; u16 currChar;
int r4two; s32 width;
int jpnvar;
u8* tempTwo;
u16 songId;
int dummy;
u8 dummyTwo;
switch (textPrinter->state) // _080057C4 switch (textPrinter->state) // _080057C4
{ {
case 0: // _080057F0 case 0: // _080057F0
if ((gMain.heldKeys & (A_BUTTON | B_BUTTON)) && r4->font_type_upper) if ((gMain.heldKeys & (A_BUTTON | B_BUTTON)) && r4->font_type_upper)
textPrinter->delayCounter = 0; textPrinter->delayCounter = 0;
if (textPrinter->delayCounter && textPrinter->text_speed) //_0800580A if (textPrinter->delayCounter && textPrinter->text_speed) //_0800580A
{ {
textPrinter->delayCounter--; textPrinter->delayCounter--;
@ -2078,15 +2074,16 @@ u16 RenderText(struct TextPrinter *textPrinter)
} }
return 3; return 3;
} }
else // _0800584C
{
if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED) && gTextFlags.flag_2) if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED) && gTextFlags.flag_2)
textPrinter->delayCounter = 3; textPrinter->delayCounter = 3;
else else
textPrinter->delayCounter = textPrinter->text_speed; textPrinter->delayCounter = textPrinter->text_speed;
temp = *textPrinter->subPrinter.current_text_offset;
currChar = *textPrinter->subPrinter.current_text_offset;
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
switch (temp) //_0800588A
switch (currChar) //_0800588A
{ {
case 0xF8+6: //_080058B8 case 0xF8+6: //_080058B8
textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; textPrinter->subPrinter.currentX = textPrinter->subPrinter.x;
@ -2096,11 +2093,10 @@ u16 RenderText(struct TextPrinter *textPrinter)
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
return 2; return 2;
case 0xF8+4: //_080058E0 case 0xF8+4: //_080058E0
temp = *textPrinter->subPrinter.current_text_offset; currChar = *textPrinter->subPrinter.current_text_offset;
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
switch (temp) // _080058F0 switch (currChar) // _080058F0
{ {
case 1: // _08005960 case 1: // _08005960
textPrinter->subPrinter.fontColor_h = *textPrinter->subPrinter.current_text_offset; textPrinter->subPrinter.fontColor_h = *textPrinter->subPrinter.current_text_offset;
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
@ -2148,18 +2144,18 @@ u16 RenderText(struct TextPrinter *textPrinter)
textPrinter->state = 5; textPrinter->state = 5;
return 3; return 3;
case 11: // _08005A5C case 11: // _08005A5C
songId = *textPrinter->subPrinter.current_text_offset; currChar = *textPrinter->subPrinter.current_text_offset;
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
songId |= *textPrinter->subPrinter.current_text_offset << 8; currChar |= *textPrinter->subPrinter.current_text_offset << 8;
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
PlayBGM(songId); PlayBGM(currChar);
return 2; return 2;
case 16: // _08005A76 case 16: // _08005A76
songId = *textPrinter->subPrinter.current_text_offset; currChar = *textPrinter->subPrinter.current_text_offset;
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
songId |= (*textPrinter->subPrinter.current_text_offset << 8); currChar |= (*textPrinter->subPrinter.current_text_offset << 8);
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
PlaySE(songId); PlaySE(currChar);
return 2; return 2;
case 13: // _08005A90 case 13: // _08005A90
textPrinter->subPrinter.currentX = textPrinter->subPrinter.x + *textPrinter->subPrinter.current_text_offset; textPrinter->subPrinter.currentX = textPrinter->subPrinter.x + *textPrinter->subPrinter.current_text_offset;
@ -2181,12 +2177,12 @@ u16 RenderText(struct TextPrinter *textPrinter)
m4aMPlayContinue(&gMPlayInfo_BGM); m4aMPlayContinue(&gMPlayInfo_BGM);
return 2; return 2;
case 17: // _08005AD8 case 17: // _08005AD8
temp = *textPrinter->subPrinter.current_text_offset; width = *textPrinter->subPrinter.current_text_offset;
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
if (temp > 0) if (width > 0)
{ {
ClearTextSpan(textPrinter, temp); ClearTextSpan(textPrinter, width);
textPrinter->subPrinter.currentX += temp; textPrinter->subPrinter.currentX += width;
return 0; return 0;
} }
return 2; return 2;
@ -2195,16 +2191,18 @@ u16 RenderText(struct TextPrinter *textPrinter)
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
return 2; return 2;
case 19: // _08005B02 case 19: // _08005B02
temp = *textPrinter->subPrinter.current_text_offset;
temp += textPrinter->subPrinter.x;
textPrinter->subPrinter.current_text_offset++;
r4two = temp - textPrinter->subPrinter.currentX;
if (temp - textPrinter->subPrinter.currentX > 0)
{ {
ClearTextSpan(textPrinter, r4two); s32 widthHelper = *textPrinter->subPrinter.current_text_offset;
textPrinter->subPrinter.currentX += r4two; widthHelper += textPrinter->subPrinter.x;
textPrinter->subPrinter.current_text_offset++;
width = widthHelper - textPrinter->subPrinter.currentX;
if (width > 0)
{
ClearTextSpan(textPrinter, width);
textPrinter->subPrinter.currentX += width;
return 0; return 0;
} }
}
return 2; return 2;
case 20: // _08005B26 case 20: // _08005B26
textPrinter->minLetterSpacing = *textPrinter->subPrinter.current_text_offset++; textPrinter->minLetterSpacing = *textPrinter->subPrinter.current_text_offset++;
@ -2216,13 +2214,12 @@ u16 RenderText(struct TextPrinter *textPrinter)
textPrinter->japanese = 0; textPrinter->japanese = 0;
return 2; return 2;
case 12: // _08005B5A case 12: // _08005B5A
dummyTwo = *textPrinter->subPrinter.current_text_offset; currChar = *textPrinter->subPrinter.current_text_offset | 0x100;
dummy = 0x100;
temp = dummy | dummyTwo;
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
break; break;
} }
break; break;
case 0xF8+3: // _08005B48 case 0xF8+3: // _08005B48
textPrinter->state = 2; textPrinter->state = 2;
TextPrinterInitDownArrowCounters(textPrinter); TextPrinterInitDownArrowCounters(textPrinter);
@ -2232,59 +2229,53 @@ u16 RenderText(struct TextPrinter *textPrinter)
TextPrinterInitDownArrowCounters(textPrinter); TextPrinterInitDownArrowCounters(textPrinter);
return 3; return 3;
case 0xF8+1: // _08005B5A case 0xF8+1: // _08005B5A
dummyTwo = *textPrinter->subPrinter.current_text_offset; currChar = *textPrinter->subPrinter.current_text_offset | 0x100;
dummy = 0x100;
temp = dummy | dummyTwo;
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
break; break;
case 0xF8+0: // _08005B6C case 0xF8+0: // _08005B6C
temp = *textPrinter->subPrinter.current_text_offset; currChar = *textPrinter->subPrinter.current_text_offset;
textPrinter->subPrinter.current_text_offset++; textPrinter->subPrinter.current_text_offset++;
gUnknown_03002F90[0x80] = DrawKeypadIcon(textPrinter->subPrinter.windowId, temp, textPrinter->subPrinter.currentX, textPrinter->subPrinter.currentY); gUnknown_03002F90[0x80] = DrawKeypadIcon(textPrinter->subPrinter.windowId, currChar, textPrinter->subPrinter.currentX, textPrinter->subPrinter.currentY);
textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80] + textPrinter->subPrinter.letterSpacing; textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80] + textPrinter->subPrinter.letterSpacing;
return 0; return 0;
case 0xF8+7: // _08005D6C case 0xF8+7: // _08005D6C
return 1; return 1;
} }
}
switch (r4->font_type) // _08005B90 switch (r4->font_type) // _08005B90
{ {
case 0: // _08005BCC case 0: // _08005BCC
jpnvar = textPrinter->japanese; DecompressGlyphFont0(currChar, textPrinter->japanese);
DecompressGlyphFont0(temp, jpnvar);
break; break;
case 1: // _08005BDA case 1: // _08005BDA
jpnvar = textPrinter->japanese; DecompressGlyphFont1(currChar, textPrinter->japanese);
DecompressGlyphFont1(temp, jpnvar);
break; break;
case 2: case 2:
case 3: case 3:
case 4: case 4:
case 5: // _08005BE8 case 5: // _08005BE8
jpnvar = textPrinter->japanese; DecompressGlyphFont2(currChar, textPrinter->japanese);
DecompressGlyphFont2(temp, jpnvar);
break; break;
case 7: // _08005BF6 case 7: // _08005BF6
jpnvar = textPrinter->japanese; DecompressGlyphFont7(currChar, textPrinter->japanese);
DecompressGlyphFont7(temp, jpnvar);
break; break;
case 8: // _08005C04 case 8: // _08005C04
jpnvar = textPrinter->japanese; DecompressGlyphFont8(currChar, textPrinter->japanese);
DecompressGlyphFont8(temp, jpnvar);
break; break;
case 6: // _08005C10 case 6: // _08005C10
break; break;
} }
CopyGlyphToWindow(textPrinter); // _08005C10 CopyGlyphToWindow(textPrinter); // _08005C10
if (textPrinter->minLetterSpacing) if (textPrinter->minLetterSpacing)
{ {
textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80]; textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80];
r4two = textPrinter->minLetterSpacing - gUnknown_03002F90[0x80]; width = textPrinter->minLetterSpacing - gUnknown_03002F90[0x80];
if (r4two > 0) if (width > 0)
{ {
ClearTextSpan(textPrinter, r4two); ClearTextSpan(textPrinter, width);
textPrinter->subPrinter.currentX += r4two; textPrinter->subPrinter.currentX += width;
} }
} }
else // _08005C48 else // _08005C48
@ -2294,6 +2285,7 @@ u16 RenderText(struct TextPrinter *textPrinter)
else else
textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80]; textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80];
} }
return 0; return 0;
case 1: // _08005C78 case 1: // _08005C78
if (TextPrinterWait(textPrinter)) if (TextPrinterWait(textPrinter))
@ -2321,21 +2313,23 @@ u16 RenderText(struct TextPrinter *textPrinter)
if (textPrinter->scrollDistance) if (textPrinter->scrollDistance)
{ {
int scrollSpeed = sub_8197964(); int scrollSpeed = sub_8197964();
int r4two = gWindowVerticalScrollSpeeds[scrollSpeed]; int speed = gWindowVerticalScrollSpeeds[scrollSpeed];
if (textPrinter->scrollDistance < r4two) if (textPrinter->scrollDistance < speed)
{ {
ScrollWindow(textPrinter->subPrinter.windowId, 0, textPrinter->scrollDistance, textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor); ScrollWindow(textPrinter->subPrinter.windowId, 0, textPrinter->scrollDistance, textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor);
textPrinter->scrollDistance = 0; textPrinter->scrollDistance = 0;
} }
else else
{ {
ScrollWindow(textPrinter->subPrinter.windowId, 0, (int)r4two, textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor); ScrollWindow(textPrinter->subPrinter.windowId, 0, speed, textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor);
textPrinter->scrollDistance -= r4two; textPrinter->scrollDistance -= speed;
} }
CopyWindowToVram(textPrinter->subPrinter.windowId, 2); CopyWindowToVram(textPrinter->subPrinter.windowId, 2);
} }
else else
{
textPrinter->state = 0; textPrinter->state = 0;
}
return 3; return 3;
case 5: // _08005D48 case 5: // _08005D48
if (!IsSEPlaying()) if (!IsSEPlaying())
@ -2348,6 +2342,7 @@ u16 RenderText(struct TextPrinter *textPrinter)
textPrinter->state = 0; textPrinter->state = 0;
return 3; return 3;
} }
return 1; return 1;
} }
#else #else