mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Get RenderText a bit closer (thanks Egg)
This commit is contained in:
parent
7941558b80
commit
a75c476d57
113
src/text.c
113
src/text.c
@ -2054,20 +2054,16 @@ void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *c
|
||||
#ifdef NONMATCHING
|
||||
u16 RenderText(struct TextPrinter *textPrinter)
|
||||
{
|
||||
struct TextPrinterSubStruct* r4 = &textPrinter->sub_union.sub;
|
||||
int temp;
|
||||
int r4two;
|
||||
int jpnvar;
|
||||
u8* tempTwo;
|
||||
u16 songId;
|
||||
int dummy;
|
||||
u8 dummyTwo;
|
||||
struct TextPrinterSubStruct *r4 = &textPrinter->sub_union.sub;
|
||||
u16 currChar;
|
||||
s32 width;
|
||||
|
||||
switch (textPrinter->state) // _080057C4
|
||||
{
|
||||
case 0: // _080057F0
|
||||
if ((gMain.heldKeys & (A_BUTTON | B_BUTTON)) && r4->font_type_upper)
|
||||
textPrinter->delayCounter = 0;
|
||||
|
||||
if (textPrinter->delayCounter && textPrinter->text_speed) //_0800580A
|
||||
{
|
||||
textPrinter->delayCounter--;
|
||||
@ -2078,15 +2074,16 @@ u16 RenderText(struct TextPrinter *textPrinter)
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
else // _0800584C
|
||||
{
|
||||
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED) && gTextFlags.flag_2)
|
||||
textPrinter->delayCounter = 3;
|
||||
else
|
||||
textPrinter->delayCounter = textPrinter->text_speed;
|
||||
temp = *textPrinter->subPrinter.current_text_offset;
|
||||
|
||||
currChar = *textPrinter->subPrinter.current_text_offset;
|
||||
textPrinter->subPrinter.current_text_offset++;
|
||||
switch (temp) //_0800588A
|
||||
|
||||
switch (currChar) //_0800588A
|
||||
{
|
||||
case 0xF8+6: //_080058B8
|
||||
textPrinter->subPrinter.currentX = textPrinter->subPrinter.x;
|
||||
@ -2096,11 +2093,10 @@ u16 RenderText(struct TextPrinter *textPrinter)
|
||||
textPrinter->subPrinter.current_text_offset++;
|
||||
return 2;
|
||||
case 0xF8+4: //_080058E0
|
||||
temp = *textPrinter->subPrinter.current_text_offset;
|
||||
currChar = *textPrinter->subPrinter.current_text_offset;
|
||||
textPrinter->subPrinter.current_text_offset++;
|
||||
switch (temp) // _080058F0
|
||||
switch (currChar) // _080058F0
|
||||
{
|
||||
|
||||
case 1: // _08005960
|
||||
textPrinter->subPrinter.fontColor_h = *textPrinter->subPrinter.current_text_offset;
|
||||
textPrinter->subPrinter.current_text_offset++;
|
||||
@ -2148,18 +2144,18 @@ u16 RenderText(struct TextPrinter *textPrinter)
|
||||
textPrinter->state = 5;
|
||||
return 3;
|
||||
case 11: // _08005A5C
|
||||
songId = *textPrinter->subPrinter.current_text_offset;
|
||||
currChar = *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++;
|
||||
PlayBGM(songId);
|
||||
PlayBGM(currChar);
|
||||
return 2;
|
||||
case 16: // _08005A76
|
||||
songId = *textPrinter->subPrinter.current_text_offset;
|
||||
currChar = *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++;
|
||||
PlaySE(songId);
|
||||
PlaySE(currChar);
|
||||
return 2;
|
||||
case 13: // _08005A90
|
||||
textPrinter->subPrinter.currentX = textPrinter->subPrinter.x + *textPrinter->subPrinter.current_text_offset;
|
||||
@ -2181,12 +2177,12 @@ u16 RenderText(struct TextPrinter *textPrinter)
|
||||
m4aMPlayContinue(&gMPlayInfo_BGM);
|
||||
return 2;
|
||||
case 17: // _08005AD8
|
||||
temp = *textPrinter->subPrinter.current_text_offset;
|
||||
width = *textPrinter->subPrinter.current_text_offset;
|
||||
textPrinter->subPrinter.current_text_offset++;
|
||||
if (temp > 0)
|
||||
if (width > 0)
|
||||
{
|
||||
ClearTextSpan(textPrinter, temp);
|
||||
textPrinter->subPrinter.currentX += temp;
|
||||
ClearTextSpan(textPrinter, width);
|
||||
textPrinter->subPrinter.currentX += width;
|
||||
return 0;
|
||||
}
|
||||
return 2;
|
||||
@ -2195,16 +2191,18 @@ u16 RenderText(struct TextPrinter *textPrinter)
|
||||
textPrinter->subPrinter.current_text_offset++;
|
||||
return 2;
|
||||
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);
|
||||
textPrinter->subPrinter.currentX += r4two;
|
||||
s32 widthHelper = *textPrinter->subPrinter.current_text_offset;
|
||||
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 2;
|
||||
case 20: // _08005B26
|
||||
textPrinter->minLetterSpacing = *textPrinter->subPrinter.current_text_offset++;
|
||||
@ -2216,13 +2214,12 @@ u16 RenderText(struct TextPrinter *textPrinter)
|
||||
textPrinter->japanese = 0;
|
||||
return 2;
|
||||
case 12: // _08005B5A
|
||||
dummyTwo = *textPrinter->subPrinter.current_text_offset;
|
||||
dummy = 0x100;
|
||||
temp = dummy | dummyTwo;
|
||||
currChar = *textPrinter->subPrinter.current_text_offset | 0x100;
|
||||
textPrinter->subPrinter.current_text_offset++;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xF8+3: // _08005B48
|
||||
textPrinter->state = 2;
|
||||
TextPrinterInitDownArrowCounters(textPrinter);
|
||||
@ -2232,59 +2229,53 @@ u16 RenderText(struct TextPrinter *textPrinter)
|
||||
TextPrinterInitDownArrowCounters(textPrinter);
|
||||
return 3;
|
||||
case 0xF8+1: // _08005B5A
|
||||
dummyTwo = *textPrinter->subPrinter.current_text_offset;
|
||||
dummy = 0x100;
|
||||
temp = dummy | dummyTwo;
|
||||
currChar = *textPrinter->subPrinter.current_text_offset | 0x100;
|
||||
textPrinter->subPrinter.current_text_offset++;
|
||||
break;
|
||||
case 0xF8+0: // _08005B6C
|
||||
temp = *textPrinter->subPrinter.current_text_offset;
|
||||
currChar = *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;
|
||||
return 0;
|
||||
case 0xF8+7: // _08005D6C
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
switch (r4->font_type) // _08005B90
|
||||
{
|
||||
case 0: // _08005BCC
|
||||
jpnvar = textPrinter->japanese;
|
||||
DecompressGlyphFont0(temp, jpnvar);
|
||||
DecompressGlyphFont0(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case 1: // _08005BDA
|
||||
jpnvar = textPrinter->japanese;
|
||||
DecompressGlyphFont1(temp, jpnvar);
|
||||
DecompressGlyphFont1(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5: // _08005BE8
|
||||
jpnvar = textPrinter->japanese;
|
||||
DecompressGlyphFont2(temp, jpnvar);
|
||||
DecompressGlyphFont2(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case 7: // _08005BF6
|
||||
jpnvar = textPrinter->japanese;
|
||||
DecompressGlyphFont7(temp, jpnvar);
|
||||
DecompressGlyphFont7(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case 8: // _08005C04
|
||||
jpnvar = textPrinter->japanese;
|
||||
DecompressGlyphFont8(temp, jpnvar);
|
||||
DecompressGlyphFont8(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case 6: // _08005C10
|
||||
break;
|
||||
}
|
||||
|
||||
CopyGlyphToWindow(textPrinter); // _08005C10
|
||||
|
||||
if (textPrinter->minLetterSpacing)
|
||||
{
|
||||
textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80];
|
||||
r4two = textPrinter->minLetterSpacing - gUnknown_03002F90[0x80];
|
||||
if (r4two > 0)
|
||||
width = textPrinter->minLetterSpacing - gUnknown_03002F90[0x80];
|
||||
if (width > 0)
|
||||
{
|
||||
ClearTextSpan(textPrinter, r4two);
|
||||
textPrinter->subPrinter.currentX += r4two;
|
||||
ClearTextSpan(textPrinter, width);
|
||||
textPrinter->subPrinter.currentX += width;
|
||||
}
|
||||
}
|
||||
else // _08005C48
|
||||
@ -2294,6 +2285,7 @@ u16 RenderText(struct TextPrinter *textPrinter)
|
||||
else
|
||||
textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80];
|
||||
}
|
||||
|
||||
return 0;
|
||||
case 1: // _08005C78
|
||||
if (TextPrinterWait(textPrinter))
|
||||
@ -2321,21 +2313,23 @@ u16 RenderText(struct TextPrinter *textPrinter)
|
||||
if (textPrinter->scrollDistance)
|
||||
{
|
||||
int scrollSpeed = sub_8197964();
|
||||
int r4two = gWindowVerticalScrollSpeeds[scrollSpeed];
|
||||
if (textPrinter->scrollDistance < r4two)
|
||||
int speed = gWindowVerticalScrollSpeeds[scrollSpeed];
|
||||
if (textPrinter->scrollDistance < speed)
|
||||
{
|
||||
ScrollWindow(textPrinter->subPrinter.windowId, 0, textPrinter->scrollDistance, textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor);
|
||||
textPrinter->scrollDistance = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ScrollWindow(textPrinter->subPrinter.windowId, 0, (int)r4two, textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor);
|
||||
textPrinter->scrollDistance -= r4two;
|
||||
ScrollWindow(textPrinter->subPrinter.windowId, 0, speed, textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor);
|
||||
textPrinter->scrollDistance -= speed;
|
||||
}
|
||||
CopyWindowToVram(textPrinter->subPrinter.windowId, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
textPrinter->state = 0;
|
||||
}
|
||||
return 3;
|
||||
case 5: // _08005D48
|
||||
if (!IsSEPlaying())
|
||||
@ -2348,6 +2342,7 @@ u16 RenderText(struct TextPrinter *textPrinter)
|
||||
textPrinter->state = 0;
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user