From 20efe6984eb9ff9ac11dbb1c5d519c5134e7af60 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 17 Dec 2016 13:43:44 +0100 Subject: Rename `charset` and use macro for build language --- src/text.c | 52 +++++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index fb7c085a2..2fa573051 100644 --- a/src/text.c +++ b/src/text.c @@ -6,12 +6,6 @@ #include "palette.h" #include "sound.h" -enum -{ - CHARSET_JAPANESE = 1, - CHARSET_LATIN -}; - enum { WIN_STATE_END, @@ -361,7 +355,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 *); @@ -1947,7 +1941,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 +2039,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 +2049,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 +2285,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 +2590,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 +2621,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) { @@ -3137,7 +3131,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)); @@ -3341,9 +3335,9 @@ static u8 GetGlyphWidth(struct Window *win, u32 glyph) u8 width = 8; #if REVISION >= 1 - if (win->charset != CHARSET_JAPANESE) + if (win->language != LANGUAGE_JAPANESE) #else - if (win->charset == CHARSET_LATIN) + if (win->language == LANGUAGE_ENGLISH) #endif { width = win->spacing; @@ -3539,7 +3533,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 +3546,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 +3574,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 +3590,7 @@ u8 GetStringWidth(struct Window *win, const u8 *s) } win->spacing = savedSpacing; - win->charset = savedCharset; + win->language = savedCharset; win->fontNum = savedFontNum; return width; @@ -3659,7 +3653,7 @@ u8 GetStringWidthGivenWindowConfig(struct WindowConfig *winConfig, const u8 *s) void ConvertInternationalString(u8 *s, u8 language) { - if (language == CHARSET_JAPANESE) + if (language == LANGUAGE_JAPANESE) { u8 i; @@ -4253,7 +4247,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; -- cgit v1.2.3 From 97aecd23b88060691bbfb7fcb36b7c3c88c254d2 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Thu, 29 Dec 2016 13:48:52 -0800 Subject: more bugfix ifdefs --- src/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index 2fa573051..265ef5493 100644 --- a/src/text.c +++ b/src/text.c @@ -3334,7 +3334,7 @@ static u8 GetGlyphWidth(struct Window *win, u32 glyph) { u8 width = 8; -#if REVISION >= 1 +#ifdef BUGFIX_GLYPHWIDTH if (win->language != LANGUAGE_JAPANESE) #else if (win->language == LANGUAGE_ENGLISH) -- cgit v1.2.3 From e1120f3a62097abb80bfa2f910d98ef53f1e5671 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 2 Jan 2017 01:26:00 -0800 Subject: gBattleTypeFlags --- src/text.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index 265ef5493..2a2d2c0d3 100644 --- a/src/text.c +++ b/src/text.c @@ -178,7 +178,7 @@ EWRAM_DATA u8 gStringVar2[0x100] = {0}; EWRAM_DATA u8 gStringVar3[0x100] = {0}; EWRAM_DATA u8 gStringVar4[0x100] = {0}; -extern u16 gUnknown_020239F8; +extern u16 gBattleTypeFlags; extern u8 gUnknown_0203869A; extern u8 gTileBuffer[]; @@ -2911,7 +2911,7 @@ static bool8 PlayerCanInterruptWait(struct Window *win) retVal = TRUE; break; case 1: - retVal &= ~(gUnknown_020239F8 >> 1); + retVal &= ~(gBattleTypeFlags >> 1); break; } -- cgit v1.2.3 From 1ae67805bcf7ba402ce2a73b2fbf04b26ded377b Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 2 Jan 2017 03:01:17 -0800 Subject: battle type constants --- src/text.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index 2a2d2c0d3..fb6118b65 100644 --- a/src/text.c +++ b/src/text.c @@ -5,6 +5,7 @@ #include "songs.h" #include "palette.h" #include "sound.h" +#include "battle.h" enum { @@ -2911,7 +2912,7 @@ static bool8 PlayerCanInterruptWait(struct Window *win) retVal = TRUE; break; case 1: - retVal &= ~(gBattleTypeFlags >> 1); + retVal = (gBattleTypeFlags & BATTLE_TYPE_LINK) ? FALSE : TRUE; break; } -- cgit v1.2.3 From 10aea2512150731570c997ad11b4c3144f51ef8b Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 2 Jan 2017 03:24:03 -0800 Subject: gUnknown_0203869A -> gIsLinkContest --- src/text.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index fb6118b65..a3e07594e 100644 --- a/src/text.c +++ b/src/text.c @@ -180,7 +180,7 @@ EWRAM_DATA u8 gStringVar3[0x100] = {0}; EWRAM_DATA u8 gStringVar4[0x100] = {0}; extern u16 gBattleTypeFlags; -extern u8 gUnknown_0203869A; +extern u8 gIsLinkContest; extern u8 gTileBuffer[]; vu16 *const gBGControlRegs[] = @@ -2908,7 +2908,7 @@ static bool8 PlayerCanInterruptWait(struct Window *win) break; case 3: retVal = FALSE; - if (!gUnknown_0203869A) + if (!gIsLinkContest) retVal = TRUE; break; case 1: -- cgit v1.2.3 From 371fc31138678ca4a5aa27449b931c70332e3dfa Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 2 Jan 2017 03:25:55 -0800 Subject: simplify conditional --- src/text.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index a3e07594e..6089fdba8 100644 --- a/src/text.c +++ b/src/text.c @@ -2907,9 +2907,7 @@ static bool8 PlayerCanInterruptWait(struct Window *win) retVal = FALSE; break; case 3: - retVal = FALSE; - if (!gIsLinkContest) - retVal = TRUE; + retVal = gIsLinkContest ? FALSE : TRUE; break; case 1: retVal = (gBattleTypeFlags & BATTLE_TYPE_LINK) ? FALSE : TRUE; -- cgit v1.2.3 From c9722602cb47eb5b6ecbccddf13df5f286a8ef7b Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 17 Jan 2017 14:13:04 +0100 Subject: Sort includes --- src/text.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index 6089fdba8..44ce6655f 100644 --- a/src/text.c +++ b/src/text.c @@ -1,11 +1,11 @@ #include "global.h" #include "text.h" +#include "battle.h" #include "main.h" -#include "string_util.h" -#include "songs.h" #include "palette.h" +#include "songs.h" #include "sound.h" -#include "battle.h" +#include "string_util.h" enum { -- cgit v1.2.3 From c8542506580c0fa247bbb44c169a2cb1244577e4 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 23 Jan 2017 16:34:20 -0800 Subject: preproc incbins --- src/text.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index 44ce6655f..cc3dab547 100644 --- a/src/text.c +++ b/src/text.c @@ -211,20 +211,22 @@ const u16 gUnknown_081E29D8[] = { 0x100, 0x200, 0x400, 0x800 }; const u16 gUnknown_081E29E0[] = { 0x100, 0x200, 0x400, 0x800 }; const u16 gUnknown_081E29E8[] = { 1, 2, 4, 8 }; -#include "fonts/font0_lat_glyphs.h" -#include "fonts/font1_lat_glyphs.h" -#include "fonts/font0_jpn_glyphs.h" -#include "fonts/font1_jpn_glyphs.h" -#include "fonts/braille_glyphs.h" -#include "fonts/down_arrow_tiles.h" +static const u8 sFont0LatinGlyphs[] = INCBIN_U8("graphics/fonts/font0_lat.1bpp"); +static const u8 sFont1LatinGlyphs[] = INCBIN_U8("graphics/fonts/font1_lat.1bpp"); +static const u8 sFont0JapaneseGlyphs[] = INCBIN_U8("graphics/fonts/font0_jpn.1bpp"); +static const u8 sFont1JapaneseGlyphs[] = INCBIN_U8("graphics/fonts/font1_jpn.1bpp"); +static const u8 sBrailleGlyphs[] = INCBIN_U8("graphics/fonts/font6_braille.1bpp"); +static const u32 sDownArrowTiles[] = INCBIN_U32("graphics/fonts/down_arrow.4bpp"); + #include "fonts/type1_map.h" #include "fonts/type3_map.h" #include "fonts/font1_widths.h" #include "fonts/font4_widths.h" #include "fonts/font0_widths.h" #include "fonts/font3_widths.h" -#include "fonts/unknown_palette_81E6692.h" -#include "fonts/default_palette.h" + +const u16 gUnknownPalette_81E6692[] = INCBIN_U16("graphics/fonts/unknown_81E6692.gbapal"); +const u16 gFontDefaultPalette[] = INCBIN_U16("graphics/fonts/default.gbapal"); const u8 sBlankTile[8] = { 0, 0, 0, 0, 0, 0, 0, 0, }; -- cgit v1.2.3 From 084dc5134cedbb7e1b2ae280ecbcb3884993a7be Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Fri, 5 May 2017 16:46:59 -0700 Subject: some German differences --- src/text.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index cc3dab547..05f327adf 100644 --- a/src/text.c +++ b/src/text.c @@ -2474,12 +2474,18 @@ static u8 UpdateWindowText(struct Window *win) return 0; } +#if defined(ENGLISH) +#define SUB_800374C_LINE_LENGTH 26 +#elif defined(GERMAN) +#define SUB_800374C_LINE_LENGTH 27 +#endif + u8 sub_800374C(struct Window *win) { u8 retVal; sWaitType = 1; - sLineLength = 26; + sLineLength = SUB_800374C_LINE_LENGTH; retVal = UpdateWindowText(win); sLineLength = 26; sWaitType = 0; -- cgit v1.2.3 From e75c3262f37483d3503126bebf8bf8b7b662d345 Mon Sep 17 00:00:00 2001 From: Cameron Hall Date: Mon, 8 May 2017 18:52:58 -0500 Subject: Decompile battle interface (#281) * start decompiling * more decompilation * sub_8044804 refuses to match. moving on... * decompile sub_80451A0 * more decompilation * finish decompiling * clean up a bit * remove trailing whitespace and change tabs to spaces --- src/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index 05f327adf..7be72833a 100644 --- a/src/text.c +++ b/src/text.c @@ -2338,7 +2338,7 @@ u8 sub_8003490(struct Window *win, u8 c, u16 tileDataStartOffset, u8 left, u8 to return retVal; } -void sub_80034D4(u8 *tileData, u8 *text) +void sub_80034D4(u8 *tileData, const u8 *text) { sub_8004E3C((struct WindowConfig *)&gWindowConfig_81E6C74, tileData, text); } -- cgit v1.2.3 From 010eb456d63b0d644285f263f310d73bfb9646b2 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 20 May 2017 17:49:54 +0200 Subject: Decrease indentation level of switches --- src/text.c | 78 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index 7be72833a..02cafea48 100644 --- a/src/text.c +++ b/src/text.c @@ -1755,21 +1755,21 @@ u16 InitWindowTileData(struct Window *win, u16 startOffset) case 1: switch (win->config->fontNum) { - case 0: - case 3: - retVal = LoadFixedWidthFont(win, startOffset); - break; - case 1: - case 2: - retVal = LoadFixedWidthFont_Font1Latin(win, startOffset); - break; - case 4: - case 5: - retVal = LoadFixedWidthFont_Font4Latin(win, startOffset); - break; - case 6: - retVal = LoadFixedWidthFont_Braille(win, startOffset); - break; + case 0: + case 3: + retVal = LoadFixedWidthFont(win, startOffset); + break; + case 1: + case 2: + retVal = LoadFixedWidthFont_Font1Latin(win, startOffset); + break; + case 4: + case 5: + retVal = LoadFixedWidthFont_Font4Latin(win, startOffset); + break; + case 6: + retVal = LoadFixedWidthFont_Braille(win, startOffset); + break; } break; } @@ -1888,30 +1888,30 @@ static void MultistepLoadFont_LoadGlyph(struct Window *win, u16 startOffset, u8 switch (win->config->fontNum) { - case 0: - case 3: - buffer = win->tileData + 32 * startOffset + 64 * glyph; - LoadFixedWidthGlyph(win, glyph, buffer); - break; - case 1: - case 2: - buffer = win->tileData + 32 * (glyph + startOffset); - ApplyColors_UnshadowedFont( - &sFont1LatinGlyphs[8 * glyph], - (u32 *)buffer, - win->foregroundColor, - win->backgroundColor); - break; - case 4: - case 5: - buffer = win->tileData + 32 * (glyph + startOffset); - ApplyColors_ShadowedFont( - &gFont4LatinGlyphs[8 * glyph], - buffer, - win->foregroundColor, - win->shadowColor, - win->backgroundColor); - break; + case 0: + case 3: + buffer = win->tileData + 32 * startOffset + 64 * glyph; + LoadFixedWidthGlyph(win, glyph, buffer); + break; + case 1: + case 2: + buffer = win->tileData + 32 * (glyph + startOffset); + ApplyColors_UnshadowedFont( + &sFont1LatinGlyphs[8 * glyph], + (u32 *)buffer, + win->foregroundColor, + win->backgroundColor); + break; + case 4: + case 5: + buffer = win->tileData + 32 * (glyph + startOffset); + ApplyColors_ShadowedFont( + &gFont4LatinGlyphs[8 * glyph], + buffer, + win->foregroundColor, + win->shadowColor, + win->backgroundColor); + break; } } -- cgit v1.2.3 From c14b7b8d913e2917cdb5234680162a70965f41d0 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 21 Jun 2017 15:20:30 +0200 Subject: Move text data --- src/text.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index 02cafea48..b27084b86 100644 --- a/src/text.c +++ b/src/text.c @@ -218,12 +218,14 @@ static const u8 sFont1JapaneseGlyphs[] = INCBIN_U8("graphics/fonts/font1_jpn.1bp static const u8 sBrailleGlyphs[] = INCBIN_U8("graphics/fonts/font6_braille.1bpp"); static const u32 sDownArrowTiles[] = INCBIN_U32("graphics/fonts/down_arrow.4bpp"); -#include "fonts/type1_map.h" -#include "fonts/type3_map.h" -#include "fonts/font1_widths.h" -#include "fonts/font4_widths.h" -#include "fonts/font0_widths.h" -#include "fonts/font3_widths.h" +// clang-format off +#include "data/text/type1_map.h" +#include "data/text/type3_map.h" +#include "data/text/font1_widths.h" +#include "data/text/font4_widths.h" +#include "data/text/font0_widths.h" +#include "data/text/font3_widths.h" +// clang-format on const u16 gUnknownPalette_81E6692[] = INCBIN_U16("graphics/fonts/unknown_81E6692.gbapal"); const u16 gFontDefaultPalette[] = INCBIN_U16("graphics/fonts/default.gbapal"); -- cgit v1.2.3