summaryrefslogtreecommitdiff
path: root/src/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/text.c')
-rw-r--r--src/text.c76
1 files changed, 34 insertions, 42 deletions
diff --git a/src/text.c b/src/text.c
index 885fb7547..6089fdba8 100644
--- a/src/text.c
+++ b/src/text.c
@@ -5,12 +5,7 @@
#include "songs.h"
#include "palette.h"
#include "sound.h"
-
-enum
-{
- CHARSET_JAPANESE = 1,
- CHARSET_LATIN
-};
+#include "battle.h"
enum
{
@@ -184,8 +179,8 @@ EWRAM_DATA u8 gStringVar2[0x100] = {0};
EWRAM_DATA u8 gStringVar3[0x100] = {0};
EWRAM_DATA u8 gStringVar4[0x100] = {0};
-extern u16 gUnknown_020239F8;
-extern u8 gUnknown_0203869A;
+extern u16 gBattleTypeFlags;
+extern u8 gIsLinkContest;
extern u8 gTileBuffer[];
vu16 *const gBGControlRegs[] =
@@ -361,7 +356,7 @@ static const WriteGlyphTilemapFunc sWriteGlyphTilemapFuncs[] =
WriteGlyphTilemap_Font6,
};
-static const struct Window sDefaultWindow = { .charset = CHARSET_LATIN };
+static const struct Window sDefaultWindow = { .language = GAME_LANGUAGE };
typedef u8 (*ExtCtrlCodeFunc)(struct Window *);
@@ -770,7 +765,7 @@ const struct WindowConfig gWindowConfig_81E6DA8 =
(u16 *)BG_SCREEN_ADDR(11), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6DC4 =
+const struct WindowConfig WindowConfig_TrainerCard_Back_Values =
{
0, // BG number
2, // BG character base block
@@ -791,7 +786,7 @@ const struct WindowConfig gWindowConfig_81E6DC4 =
(u16 *)BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6DE0 =
+const struct WindowConfig WindowConfig_TrainerCard_Back_Labels =
{
0, // BG number
2, // BG character base block
@@ -1918,14 +1913,14 @@ static void MultistepLoadFont_LoadGlyph(struct Window *win, u16 startOffset, u8
}
}
-static void EmptyFunc(void)
+void EmptyFunc(void)
{
}
-void InitWindowFromConfig(struct Window *win, struct WindowConfig *winConfig)
+void InitWindowFromConfig(struct Window *win, const struct WindowConfig *winConfig)
{
*win = sDefaultWindow;
- win->config = winConfig;
+ win->config = (struct WindowConfig *)winConfig;
win->textMode = winConfig->textMode;
win->spacing = winConfig->spacing;
win->fontNum = winConfig->fontNum;
@@ -1947,7 +1942,7 @@ void InitWindow(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8
struct WindowConfig *winConfig = win->config;
win->textMode = winConfig->textMode;
win->fontNum = winConfig->fontNum;
- win->charset = CHARSET_LATIN;
+ win->language = GAME_LANGUAGE;
win->paletteNum = winConfig->paletteNum;
win->win_field_B = 0;
win->win_field_C = 0;
@@ -2045,7 +2040,7 @@ u8 sub_8002F44(struct Window *win)
static u8 sub_8002FA0(struct Window *win, const u8 *text)
{
u8 retVal;
- u8 savedCharset = win->charset;
+ u8 savedLanguage = win->language;
const u8 *savedText = win->text;
u16 savedTextIndex = win->textIndex;
win->text = text;
@@ -2055,7 +2050,7 @@ static u8 sub_8002FA0(struct Window *win, const u8 *text)
win->text = savedText;
win->textIndex = savedTextIndex;
win->state = WIN_STATE_NORMAL;
- win->charset = savedCharset;
+ win->language = savedLanguage;
return retVal;
}
@@ -2291,13 +2286,13 @@ static u8 ExtCtrlCode_Spacing(struct Window *win)
static u8 ExtCtrlCode_Japanese(struct Window *win)
{
- win->charset = CHARSET_JAPANESE;
+ win->language = LANGUAGE_JAPANESE;
return 2;
}
static u8 ExtCtrlCode_Latin(struct Window *win)
{
- win->charset = CHARSET_LATIN;
+ win->language = GAME_LANGUAGE;
return 2;
}
@@ -2596,7 +2591,7 @@ static void LoadFixedWidthGlyph(struct Window *win, u32 glyph, u8 *dest)
u8 *upperTile;
u8 *lowerTile;
- GetGlyphTilePointers(win->fontNum, win->charset, glyph, &upperTile, &lowerTile);
+ GetGlyphTilePointers(win->fontNum, win->language, glyph, &upperTile, &lowerTile);
switch (win->fontNum)
{
@@ -2627,17 +2622,17 @@ static void WriteGlyphTilemap(struct Window *win, u16 upperTileNum, u16 lowerTil
}
}
-static void GetGlyphTilePointers(u8 fontNum, u8 charset, u16 glyph, u8 **upperTilePtr, u8 **lowerTilePtr)
+static void GetGlyphTilePointers(u8 fontNum, u8 language, u16 glyph, u8 **upperTilePtr, u8 **lowerTilePtr)
{
u16 index;
const struct Font *font;
- if (charset == CHARSET_JAPANESE)
- charset = 0;
+ if (language == LANGUAGE_JAPANESE)
+ language = 0;
else
- charset = 7;
+ language = 7;
- font = &sFonts[charset + fontNum];
+ font = &sFonts[language + fontNum];
switch (font->type)
{
@@ -2912,12 +2907,10 @@ static bool8 PlayerCanInterruptWait(struct Window *win)
retVal = FALSE;
break;
case 3:
- retVal = FALSE;
- if (!gUnknown_0203869A)
- retVal = TRUE;
+ retVal = gIsLinkContest ? FALSE : TRUE;
break;
case 1:
- retVal &= ~(gUnknown_020239F8 >> 1);
+ retVal = (gBattleTypeFlags & BATTLE_TYPE_LINK) ? FALSE : TRUE;
break;
}
@@ -3137,7 +3130,7 @@ static void DrawDownArrow(struct Window *win)
{
u8 *upperTile;
u8 *lowerTile;
- GetGlyphTilePointers(win->fontNum, win->charset, 0, &upperTile, &lowerTile);
+ GetGlyphTilePointers(win->fontNum, win->language, 0, &upperTile, &lowerTile);
glyphTileInfo.width = 8 - glyphTileInfo.startPixel;
glyphTileInfo.src = upperTile;
glyphTileInfo.dest = (u32 *)(win->tileData + 32 * GetCursorTileNum(win, 1, 0));
@@ -3340,10 +3333,10 @@ static u8 GetGlyphWidth(struct Window *win, u32 glyph)
{
u8 width = 8;
-#if REVISION >= 1
- if (win->charset != CHARSET_JAPANESE)
+#ifdef BUGFIX_GLYPHWIDTH
+ if (win->language != LANGUAGE_JAPANESE)
#else
- if (win->charset == CHARSET_LATIN)
+ if (win->language == LANGUAGE_ENGLISH)
#endif
{
width = win->spacing;
@@ -3539,7 +3532,7 @@ u8 GetStringWidth(struct Window *win, const u8 *s)
{
u8 width = 0;
u8 savedFontNum = win->fontNum;
- u8 savedCharset = win->charset;
+ u8 savedCharset = win->language;
u8 savedSpacing = win->spacing;
s32 i = 0;
@@ -3552,9 +3545,9 @@ u8 GetStringWidth(struct Window *win, const u8 *s)
{
u8 temp;
i++;
- temp = win->charset;
+ temp = win->language;
width += GetStringWidth(win, GetExpandedPlaceholder(s[i]));
- win->charset = temp;
+ win->language = temp;
i++;
break;
}
@@ -3580,10 +3573,10 @@ u8 GetStringWidth(struct Window *win, const u8 *s)
win->spacing = s[i + 1];
break;
case 0x15:
- win->charset = 1;
+ win->language = LANGUAGE_JAPANESE;
break;
case 0x16:
- win->charset = 2;
+ win->language = GAME_LANGUAGE;
break;
}
@@ -3596,7 +3589,7 @@ u8 GetStringWidth(struct Window *win, const u8 *s)
}
win->spacing = savedSpacing;
- win->charset = savedCharset;
+ win->language = savedCharset;
win->fontNum = savedFontNum;
return width;
@@ -3659,10 +3652,9 @@ u8 GetStringWidthGivenWindowConfig(struct WindowConfig *winConfig, const u8 *s)
void ConvertInternationalString(u8 *s, u8 language)
{
- if (language == CHARSET_JAPANESE)
+ if (language == LANGUAGE_JAPANESE)
{
u8 i;
- u8 length;
StripExtCtrlCodes(s);
i = StringLength(s);
@@ -4254,7 +4246,7 @@ static s32 DrawGlyphTiles(struct Window *win, u32 glyph, u32 glyphWidth)
u8 *lowerTile;
s32 retVal = 0;
- GetGlyphTilePointers(win->fontNum, win->charset, glyph, &upperTile, &lowerTile);
+ GetGlyphTilePointers(win->fontNum, win->language, glyph, &upperTile, &lowerTile);
glyphTileInfo.textMode = win->textMode;
glyphTileInfo.startPixel = (win->left + win->cursorX) & 7;
glyphTileInfo.width = glyphWidth;