diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index bdfc3e1e6..a5e52f04e 100644 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -1180,7 +1180,7 @@ sub_81965D8: @ 81965D8 negs r0, r0 ands r0, r1 strb r0, [r2] - bl GetPlayerTextSpeed + bl GetPlayerTextSpeedDelay adds r1, r0, 0 lsls r1, 24 lsrs r1, 24 diff --git a/asm/contest.s b/asm/contest.s index b984a98b6..35dbaf385 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -6485,7 +6485,7 @@ _080DEC80: b _080DEC9C .pool _080DEC94: - bl GetPlayerTextSpeed + bl GetPlayerTextSpeedDelay lsls r0, 24 lsrs r1, r0, 24 _080DEC9C: diff --git a/asm/party_menu.s b/asm/party_menu.s index 8ee815968..cb5b1c712 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -6178,7 +6178,7 @@ sub_81B3300: @ 81B3300 movs r1, 0x1 orrs r0, r1 strb r0, [r2] - bl GetPlayerTextSpeed + bl GetPlayerTextSpeedDelay adds r3, r0, 0 lsls r3, 24 lsrs r3, 24 diff --git a/asm/pokenav.s b/asm/pokenav.s index 732f0ef2e..6fedbbd58 100644 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -10440,7 +10440,7 @@ sub_81CC158: @ 81CC158 adds r1, 0xF bl sub_81CAF78 adds r5, r0, 0 - bl GetPlayerTextSpeed + bl GetPlayerTextSpeedDelay lsls r0, 24 lsrs r0, 24 ldrb r2, [r4, 0x14] @@ -22957,7 +22957,7 @@ sub_81D2BF4: @ 81D2BF4 movs r1, 0x1 orrs r0, r1 strb r0, [r2] - bl GetPlayerTextSpeed + bl GetPlayerTextSpeedDelay adds r3, r0, 0 lsls r3, 24 lsrs r3, 24 diff --git a/asm/post_battle_event_funcs.s b/asm/post_battle_event_funcs.s deleted file mode 100644 index c6d4fd88f..000000000 --- a/asm/post_battle_event_funcs.s +++ /dev/null @@ -1,165 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start GameClear -GameClear: @ 8137734 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x1C - bl HealPlayerParty - ldr r4, =0x00000864 - adds r0, r4, 0 - bl FlagGet - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x1 - bne _08137760 - ldr r0, =gHasHallOfFameRecords - strb r1, [r0] - b _0813776C - .pool -_08137760: - ldr r1, =gHasHallOfFameRecords - movs r0, 0 - strb r0, [r1] - adds r0, r4, 0 - bl FlagSet -_0813776C: - movs r0, 0x1 - bl GetGameStat - cmp r0, 0 - bne _0813778E - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldrh r1, [r2, 0xE] - lsls r1, 16 - ldrb r0, [r2, 0x10] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x11] - orrs r1, r0 - movs r0, 0x1 - bl SetGameStat -_0813778E: - bl sub_8076D48 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r0, [r0, 0x8] - cmp r0, 0 - bne _081377AC - movs r0, 0x1 - bl sub_8084F6C - b _081377B2 - .pool -_081377AC: - movs r0, 0x2 - bl sub_8084F6C -_081377B2: - movs r7, 0 - movs r6, 0 - add r0, sp, 0x18 - mov r8, r0 - mov r5, sp -_081377BC: - movs r0, 0x64 - adds r1, r6, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r4, r1, r0 - movs r0, 0 - strb r6, [r5] - strb r0, [r5, 0x1] - adds r0, r4, 0 - movs r1, 0x5 - bl GetMonData - cmp r0, 0 - beq _0813780A - adds r0, r4, 0 - movs r1, 0x6 - bl GetMonData - cmp r0, 0 - bne _0813780A - adds r0, r4, 0 - movs r1, 0x43 - bl GetMonData - cmp r0, 0 - bne _0813780A - movs r0, 0x1 - mov r1, r8 - strb r0, [r1] - adds r0, r4, 0 - movs r1, 0x43 - add r2, sp, 0x18 - bl SetMonData - adds r0, r4, 0 - bl GetRibbonCount - strb r0, [r5, 0x1] - movs r7, 0x1 -_0813780A: - adds r5, 0x4 - adds r6, 0x1 - cmp r6, 0x5 - ble _081377BC - cmp r7, 0x1 - bne _0813785A - movs r0, 0x2A - bl IncrementGameStat - ldr r0, =0x0000089b - bl FlagSet - mov r3, sp - add r2, sp, 0x4 - movs r6, 0x4 -_08137828: - ldrb r1, [r3, 0x1] - ldrb r0, [r2, 0x1] - cmp r0, r1 - bls _08137838 - ldr r1, [sp] - ldr r0, [r2] - str r0, [sp] - str r1, [r2] -_08137838: - adds r2, 0x4 - subs r6, 0x1 - cmp r6, 0 - bge _08137828 - mov r0, sp - ldrb r0, [r0, 0x1] - cmp r0, 0x4 - bls _0813785A - mov r0, sp - ldrb r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0x43 - bl sub_80EE4DC -_0813785A: - ldr r0, =CB2_DoHallOfFameScreen - bl SetMainCallback2 - movs r0, 0 - add sp, 0x1C - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end GameClear - - thumb_func_start sp0C8_whiteout_maybe -sp0C8_whiteout_maybe: @ 813787C - push {lr} - ldr r0, =CB2_WhiteOut - bl SetMainCallback2 - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sp0C8_whiteout_maybe diff --git a/common_syms/text.txt b/common_syms/text.txt index b34571495..4406c8bf9 100644 --- a/common_syms/text.txt +++ b/common_syms/text.txt @@ -1,8 +1,4 @@ gFonts gUnknown_03002F84 gUnknown_03002F90 -gUnknown_03002FB0 -gUnknown_03002FD0 -gUnknown_03002FF0 -gGlyphDimensions gTextFlags diff --git a/include/load_save.h b/include/load_save.h index 5fb5f6c42..b8b27ade5 100644 --- a/include/load_save.h +++ b/include/load_save.h @@ -17,7 +17,7 @@ void SetSaveBlocksPointers(u16 offset); void MoveSaveBlocks_ResetHeap(void); u32 GetSecretBase2Field_9(void); void ClearSecretBase2Field_9(void); -void sub_8076D48(void); +void SetSecretBase2Field_9(void); void sub_8076D5C(void); void sav2_gender2_inplace_and_xFE(void); void SavePlayerParty(void); diff --git a/include/menu.h b/include/menu.h index 175eabc07..842f33c0b 100644 --- a/include/menu.h +++ b/include/menu.h @@ -26,15 +26,15 @@ u16 RunTextPrintersAndIsPrinter0Active(void); void sub_81973A4(void); void NewMenuHelpers_DrawDialogueFrame(u8, u8); void sub_819746C(u8 windowId, bool8 copyToVram); -u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 fgColor, u8 bgColor, u8 shadowColor); +u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16), u8 fgColor, u8 bgColor, u8 shadowColor); void PrintPlayerNameOnWindow(u8, const u8*, u16, u16); void DisplayItemMessageOnField(u8 taskId, const u8 *src, TaskFunc callback); void sub_8197434(u8 windowId, bool8 copyToVram); void SetStandardWindowBorderStyle(u8 a0, u8 a1); void sub_8197930(void); -u8 GetPlayerTextSpeed(void); +u8 GetPlayerTextSpeedDelay(void); void sub_81978B0(u16 arg0); -void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextSubPrinter *, u16)); +void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextPrinterTemplate *, u16)); void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 speed, const u8 *str); void sub_8198070(u8 windowId, bool8 copyToVram); void SetWindowTemplateFields(struct WindowTemplate* template, u8 priority, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 palNum, u16 baseBlock); @@ -82,7 +82,7 @@ void sub_819A344(u8 a0, u8 *dest, u8 color); void RemoveMapNamePopUpWindow(void); u8 GetMapNamePopUpWindowId(void); u8 AddMapNamePopUpWindow(void); -void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 letterSpacing, u8 lineSpacing); +void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16), u8 letterSpacing, u8 lineSpacing); void sub_8199C30(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette); void sub_8199D3C(void *ptr, int delta, int width, int height, bool32 is8BPP); void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyToVram); diff --git a/include/script_pokemon_util_80F87D8.h b/include/script_pokemon_util_80F87D8.h index 68aec7eb6..7c2a1ff66 100644 --- a/include/script_pokemon_util_80F87D8.h +++ b/include/script_pokemon_util_80F87D8.h @@ -4,5 +4,6 @@ u16 sub_80F903C(void); void ReducePlayerPartyToThree(void); +void HealPlayerParty(void); #endif // GUARD_SCRIPT_POKEMON_UTIL_80F87D8_H diff --git a/include/text.h b/include/text.h index f677f2ced..4946f1c5f 100644 --- a/include/text.h +++ b/include/text.h @@ -114,7 +114,7 @@ enum { FONTATTR_MAX_LETTER_HEIGHT, FONTATTR_LETTER_SPACING, FONTATTR_LINE_SPACING, - FONTATTR_COLOR_LOWNIBBLE, // dunno what this is yet + FONTATTR_UNKNOWN, // dunno what this is yet FONTATTR_COLOR_FOREGROUND, FONTATTR_COLOR_BACKGROUND, FONTATTR_COLOR_SHADOW @@ -122,23 +122,18 @@ enum { struct TextPrinterSubStruct { - u8 font_type:4; // 0x14 - u8 font_type_upper:1; - u8 font_type_5:3; - u8 field_1:5; - u8 field_1_upmid:2; - u8 field_1_top:1; - u8 frames_visible_counter; - u8 field_3; - u8 field_4; // 0x18 - u8 field_5; - u8 field_6; - u8 active; + u8 glyphId:4; // 0x14 + bool8 hasPrintBeenSpedUp:1; + u8 unk:3; + u8 downArrowDelay:5; + u8 downArrowYPosIdx:2; + bool8 hasGlyphIdBeenSet:1; + u8 autoScrollDelay; }; -struct TextSubPrinter // TODO: Better name +struct TextPrinterTemplate { - const u8* current_text_offset; + const u8* currentChar; u8 windowId; u8 fontId; u8 x; @@ -147,7 +142,7 @@ struct TextSubPrinter // TODO: Better name u8 currentY; u8 letterSpacing; u8 lineSpacing; - u8 fontColor_l:4; // 0xC + u8 unk:4; // 0xC u8 fgColor:4; u8 bgColor:4; u8 shadowColor:4; @@ -155,18 +150,18 @@ struct TextSubPrinter // TODO: Better name struct TextPrinter { - struct TextSubPrinter subPrinter; + struct TextPrinterTemplate printerTemplate; - void (*callback)(struct TextSubPrinter *, u16); // 0x10 + void (*callback)(struct TextPrinterTemplate *, u16); // 0x10 - union { + union __attribute__((packed)) { struct TextPrinterSubStruct sub; + u8 fields[7]; + } subUnion; - u8 sub_fields[8]; - } sub_union; - + u8 active; u8 state; // 0x1C - u8 text_speed; + u8 textSpeed; u8 delayCounter; u8 scrollDistance; u8 minLetterSpacing; // 0x20 @@ -180,7 +175,7 @@ struct FontInfo u8 maxLetterHeight; u8 letterSpacing; u8 lineSpacing; - u8 fontColor_l:4; + u8 unk:4; u8 fgColor:4; u8 bgColor:4; u8 shadowColor:4; @@ -190,24 +185,34 @@ extern const struct FontInfo *gFonts; struct GlyphWidthFunc { - u32 font_id; + u32 fontId; u32 (*func)(u16 glyphId, bool32 isJapanese); }; struct KeypadIcon { - u16 tile_offset; + u16 tileOffset; u8 width; u8 height; }; typedef struct { - u8 flag_0:1; - u8 flag_1:1; - u8 flag_2:1; - u8 flag_3:1; + bool8 canABSpeedUpPrint:1; + bool8 useAlternateDownArrow:1; + bool8 autoScroll:1; + bool8 forceMidTextSpeed:1; } TextFlags; +struct Struct_03002F90 +{ + u8 unk0[0x20]; + u8 unk20[0x20]; + u8 unk40[0x20]; + u8 unk60[0x20]; + u8 unk80; + u8 unk81; +}; + extern TextFlags gTextFlags; extern u8 gStringVar1[]; @@ -215,17 +220,13 @@ extern u8 gStringVar2[]; extern u8 gStringVar3[]; extern u8 gStringVar4[]; -u8 gUnknown_03002F84; -u8 gUnknown_03002F90[0x20]; -u8 gUnknown_03002FB0[0x20]; -u8 gUnknown_03002FD0[0x20]; -u8 gUnknown_03002FF0[0x20]; -u8 gGlyphDimensions[0x2]; +extern u8 gUnknown_03002F84; +extern struct Struct_03002F90 gUnknown_03002F90; void SetFontsPointer(const struct FontInfo *fonts); void DeactivateAllTextPrinters(void); -u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextSubPrinter *, u16)); -bool16 AddTextPrinter(struct TextSubPrinter *textSubPrinter, u8 speed, void (*callback)(struct TextSubPrinter *, u16)); +u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)); +bool16 AddTextPrinter(struct TextPrinterTemplate *template, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)); void RunTextPrinters(void); bool16 IsTextPrinterActive(u8 id); u32 RenderFont(struct TextPrinter *textPrinter); diff --git a/ld_script.txt b/ld_script.txt index 911cfaa89..ae0e53e04 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -196,7 +196,7 @@ SECTIONS { src/rom6.o(.text); src/pokeblock.o(.text); src/fldeff_flash.o(.text); - asm/post_battle_event_funcs.o(.text); + src/post_battle_event_funcs.o(.text); src/time_events.o(.text); src/birch_pc.o(.text); src/hof_pc.o(.text); diff --git a/src/battle_dome.c b/src/battle_dome.c index d5489f529..b39162dda 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -4720,7 +4720,7 @@ static u8 sub_819221C(u8 taskId) static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) { - struct TextSubPrinter textPrinter; + struct TextPrinterTemplate textPrinter; s32 i, j, k; s32 trainerId = 0; u8 nature = 0; @@ -4792,7 +4792,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) textPrinter.currentY = textPrinter.y; textPrinter.letterSpacing = 2; textPrinter.lineSpacing = 0; - textPrinter.fontColor_l = 0; + textPrinter.unk = 0; textPrinter.fgColor = 14; textPrinter.bgColor = 0; textPrinter.shadowColor = 13; @@ -4826,7 +4826,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) } textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, gStringVar1, 0xD0, textPrinter.letterSpacing); - textPrinter.current_text_offset = gStringVar1; + textPrinter.currentChar = gStringVar1; textPrinter.windowId = windowId; PutWindowTilemap(windowId); CopyWindowToVram(windowId, 3); @@ -4837,11 +4837,11 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) { textPrinter.currentY = gUnknown_0860D346[i]; if (trainerId == TRAINER_PLAYER) - textPrinter.current_text_offset = gSpeciesNames[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]]; + textPrinter.currentChar = gSpeciesNames[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]]; else if (trainerId == TRAINER_FRONTIER_BRAIN) - textPrinter.current_text_offset = gSpeciesNames[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]]; + textPrinter.currentChar = gSpeciesNames[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]]; else - textPrinter.current_text_offset = gSpeciesNames[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].species]; + textPrinter.currentChar = gSpeciesNames[gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].species]; textPrinter.windowId = 1 + i + windowId; if (i == 1) @@ -4857,9 +4857,9 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) PutWindowTilemap(windowId + 4); CopyWindowToVram(windowId + 4, 3); if (trainerId == TRAINER_FRONTIER_BRAIN) - textPrinter.current_text_offset = gBattleDomePotentialPointers[16]; + textPrinter.currentChar = gBattleDomePotentialPointers[16]; else - textPrinter.current_text_offset = gBattleDomePotentialPointers[trainerTournamentId]; + textPrinter.currentChar = gBattleDomePotentialPointers[trainerTournamentId]; textPrinter.fontId = 1; textPrinter.windowId = windowId + 4; @@ -4901,7 +4901,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) break; } - textPrinter.current_text_offset = gBattleDomeOpponentStylePointers[i]; + textPrinter.currentChar = gBattleDomeOpponentStylePointers[i]; textPrinter.y = 20; textPrinter.currentY = 20; AddTextPrinter(&textPrinter, 0, NULL); @@ -5073,7 +5073,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) else i = 42; - textPrinter.current_text_offset = gBattleDomeOpponentStatsPointers[i]; + textPrinter.currentChar = gBattleDomeOpponentStatsPointers[i]; textPrinter.y = 36; textPrinter.currentY = 36; AddTextPrinter(&textPrinter, 0, NULL); @@ -5144,7 +5144,7 @@ static s32 sub_8192F08(u8 arg0, u8 *arg1) static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) { - struct TextSubPrinter textPrinter; + struct TextPrinterTemplate textPrinter; s32 tournamentIds[2]; s32 trainerIds[2]; bool32 lost[2]; @@ -5292,12 +5292,12 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) textPrinter.currentY = textPrinter.y; textPrinter.letterSpacing = 0; textPrinter.lineSpacing = 0; - textPrinter.fontColor_l = 0; + textPrinter.unk = 0; textPrinter.fgColor = 14; textPrinter.bgColor = 0; textPrinter.shadowColor = 13; StringExpandPlaceholders(gStringVar4, gBattleDomeWinStringsPointers[winStringId]); - textPrinter.current_text_offset = gStringVar4; + textPrinter.currentChar = gStringVar4; textPrinter.windowId = windowId + 8; textPrinter.fontId = 1; PutWindowTilemap(windowId + 8); @@ -5316,9 +5316,9 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) textPrinter.fontId = 2; textPrinter.letterSpacing = 2; - textPrinter.current_text_offset = gStringVar1; + textPrinter.currentChar = gStringVar1; textPrinter.windowId = windowId + 6; - textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.current_text_offset, 0x40, textPrinter.letterSpacing); + textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.currentChar, 0x40, textPrinter.letterSpacing); textPrinter.currentY = textPrinter.y = 2; PutWindowTilemap(windowId + 6); CopyWindowToVram(windowId + 6, 3); @@ -5332,9 +5332,9 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) else CopyDomeTrainerName(gStringVar1, trainerIds[1]); - textPrinter.current_text_offset = gStringVar1; + textPrinter.currentChar = gStringVar1; textPrinter.windowId = windowId + 7; - textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.current_text_offset, 0x40, textPrinter.letterSpacing); + textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.currentChar, 0x40, textPrinter.letterSpacing); textPrinter.currentY = textPrinter.y = 2; PutWindowTilemap(windowId + 7); CopyWindowToVram(windowId + 7, 3); @@ -5342,9 +5342,9 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) // Print match number. textPrinter.letterSpacing = 0; - textPrinter.current_text_offset = gBattleDomeMatchNumberPointers[matchNo]; + textPrinter.currentChar = gBattleDomeMatchNumberPointers[matchNo]; textPrinter.windowId = windowId + 5; - textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.current_text_offset, 0xA0, textPrinter.letterSpacing); + textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.currentChar, 0xA0, textPrinter.letterSpacing); textPrinter.currentY = textPrinter.y = 2; PutWindowTilemap(windowId + 5); CopyWindowToVram(windowId + 5, 3); @@ -5663,7 +5663,7 @@ static u16 GetWinningMove(s32 winnerTournamentId, s32 loserTournamentId, u8 roun static void sub_8194220(u8 taskId) { s32 i; - struct TextSubPrinter textPrinter; + struct TextPrinterTemplate textPrinter; s32 r10 = gTasks[taskId].data[1]; s32 r4 = gTasks[taskId].data[2]; @@ -5740,15 +5740,15 @@ static void sub_8194220(u8 taskId) break; case 4: textPrinter.fontId = 2; - textPrinter.current_text_offset = gText_BattleTourney; + textPrinter.currentChar = gText_BattleTourney; textPrinter.windowId = 2; textPrinter.x = 0; textPrinter.y = 0; textPrinter.letterSpacing = 2; textPrinter.lineSpacing = 0; - textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.current_text_offset, 0x70, textPrinter.letterSpacing); + textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.currentChar, 0x70, textPrinter.letterSpacing); textPrinter.currentY = 1; - textPrinter.fontColor_l = 0; + textPrinter.unk = 0; textPrinter.fgColor = 14; textPrinter.bgColor = 0; textPrinter.shadowColor = 13; @@ -5831,7 +5831,7 @@ static void sub_8194220(u8 taskId) textPrinter.currentX = GetStringWidthDifference(textPrinter.fontId, gDisplayedStringBattle, 0x3D, textPrinter.letterSpacing); else textPrinter.currentX = 3; - textPrinter.current_text_offset = gDisplayedStringBattle; + textPrinter.currentChar = gDisplayedStringBattle; textPrinter.windowId = gUnknown_0860D3F1[i][0]; textPrinter.currentY = gUnknown_0860D3F1[i][1]; AddTextPrinter(&textPrinter, 0, NULL); @@ -5899,7 +5899,7 @@ static void sub_81948EC(u8 tournamentId, u8 arg1) static void sub_8194950(u8 taskId) { s32 i; - struct TextSubPrinter textPrinter; + struct TextPrinterTemplate textPrinter; switch (gTasks[taskId].data[0]) { @@ -5917,7 +5917,7 @@ static void sub_8194950(u8 taskId) textPrinter.y = 0; textPrinter.letterSpacing = 2; textPrinter.lineSpacing = 0; - textPrinter.fontColor_l = 0; + textPrinter.unk = 0; textPrinter.fgColor = 11; textPrinter.bgColor = 0; textPrinter.shadowColor = 13; @@ -5932,7 +5932,7 @@ static void sub_8194950(u8 taskId) else textPrinter.currentX = 3; - textPrinter.current_text_offset = gDisplayedStringBattle; + textPrinter.currentChar = gDisplayedStringBattle; textPrinter.windowId = gUnknown_0860D3F1[i][0]; textPrinter.currentY = gUnknown_0860D3F1[i][1]; AddTextPrinter(&textPrinter, 0, NULL); diff --git a/src/battle_message.c b/src/battle_message.c index 837f3e6d3..44ea5d7d7 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -2938,7 +2938,7 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId) { const struct BattleWindowText *textInfo = sBattleTextOnWindowsInfo[gBattleScripting.windowsType]; bool32 copyToVram; - struct TextSubPrinter textSubPrinter; + struct TextPrinterTemplate printerTemplate; u8 speed; if (windowId & 0x80) @@ -2952,36 +2952,36 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId) copyToVram = TRUE; } - textSubPrinter.current_text_offset = text; - textSubPrinter.windowId = windowId; - textSubPrinter.fontId = textInfo[windowId].fontId; - textSubPrinter.x = textInfo[windowId].x; - textSubPrinter.y = textInfo[windowId].y; - textSubPrinter.currentX = textSubPrinter.x; - textSubPrinter.currentY = textSubPrinter.y; - textSubPrinter.letterSpacing = textInfo[windowId].letterSpacing; - textSubPrinter.lineSpacing = textInfo[windowId].lineSpacing; - textSubPrinter.fontColor_l = 0; - textSubPrinter.fgColor = textInfo[windowId].fgColor; - textSubPrinter.bgColor = textInfo[windowId].bgColor; - textSubPrinter.shadowColor = textInfo[windowId].shadowColor; + printerTemplate.currentChar = text; + printerTemplate.windowId = windowId; + printerTemplate.fontId = textInfo[windowId].fontId; + printerTemplate.x = textInfo[windowId].x; + printerTemplate.y = textInfo[windowId].y; + printerTemplate.currentX = printerTemplate.x; + printerTemplate.currentY = printerTemplate.y; + printerTemplate.letterSpacing = textInfo[windowId].letterSpacing; + printerTemplate.lineSpacing = textInfo[windowId].lineSpacing; + printerTemplate.unk = 0; + printerTemplate.fgColor = textInfo[windowId].fgColor; + printerTemplate.bgColor = textInfo[windowId].bgColor; + printerTemplate.shadowColor = textInfo[windowId].shadowColor; - if (textSubPrinter.x == 0xFF) + if (printerTemplate.x == 0xFF) { u32 width = sub_80397C4(gBattleScripting.windowsType, windowId); - s32 alignX = GetStringCenterAlignXOffsetWithLetterSpacing(textSubPrinter.fontId, textSubPrinter.current_text_offset, width, textSubPrinter.letterSpacing); - textSubPrinter.x = textSubPrinter.currentX = alignX; + s32 alignX = GetStringCenterAlignXOffsetWithLetterSpacing(printerTemplate.fontId, printerTemplate.currentChar, width, printerTemplate.letterSpacing); + printerTemplate.x = printerTemplate.currentX = alignX; } if (windowId == 0x16) - gTextFlags.flag_1 = 0; + gTextFlags.useAlternateDownArrow = 0; else - gTextFlags.flag_1 = 1; + gTextFlags.useAlternateDownArrow = 1; if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED)) - gTextFlags.flag_2 = 1; + gTextFlags.autoScroll = 1; else - gTextFlags.flag_2 = 0; + gTextFlags.autoScroll = 0; if (windowId == 0 || windowId == 0x16) { @@ -2990,17 +2990,17 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId) else if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) speed = sRecordedBattleTextSpeeds[GetTextSpeedInRecordedBattle()]; else - speed = GetPlayerTextSpeed(); + speed = GetPlayerTextSpeedDelay(); - gTextFlags.flag_0 = 1; + gTextFlags.canABSpeedUpPrint = 1; } else { speed = textInfo[windowId].speed; - gTextFlags.flag_0 = 0; + gTextFlags.canABSpeedUpPrint = 0; } - AddTextPrinter(&textSubPrinter, speed, NULL); + AddTextPrinter(&printerTemplate, speed, NULL); if (copyToVram) { diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index fce8c9e2a..98b7639bb 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -1457,7 +1457,7 @@ static void sub_81C6DAC(u8 taskId, const struct YesNoFuncTable *yesNoTable) void DisplayItemMessageInBattlePyramid(u8 taskId, const u8 *str, void (*callback)(u8 taskId)) { FillWindowPixelBuffer(2, 0x11); - DisplayMessageAndContinueTask(taskId, 2, 0xA, 0xD, 1, GetPlayerTextSpeed(), str, callback); + DisplayMessageAndContinueTask(taskId, 2, 0xA, 0xD, 1, GetPlayerTextSpeedDelay(), str, callback); schedule_bg_copy_tilemap_to_vram(1); } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 87783a6de..b652049c4 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6380,7 +6380,7 @@ static void PutLevelAndGenderOnLvlUpBox(void) { u16 monLevel; u8 monGender; - struct TextSubPrinter subPrinter; + struct TextPrinterTemplate printerTemplate; u8 *txtPtr; u32 var; @@ -6388,21 +6388,21 @@ static void PutLevelAndGenderOnLvlUpBox(void) monGender = GetMonGender(&gPlayerParty[gBattleStruct->expGetterMonId]); GetMonNickname(&gPlayerParty[gBattleStruct->expGetterMonId], gStringVar4); - subPrinter.current_text_offset = gStringVar4; - subPrinter.windowId = 14; - subPrinter.fontId = 0; - subPrinter.x = 32; - subPrinter.y = 0; - subPrinter.currentX = 32; - subPrinter.currentY = 0; - subPrinter.letterSpacing = 0; - subPrinter.lineSpacing = 0; - subPrinter.fontColor_l = TEXT_COLOR_TRANSPARENT; - subPrinter.fgColor = TEXT_COLOR_WHITE; - subPrinter.bgColor = TEXT_COLOR_TRANSPARENT; - subPrinter.shadowColor = TEXT_COLOR_DARK_GREY; + printerTemplate.currentChar = gStringVar4; + printerTemplate.windowId = 14; + printerTemplate.fontId = 0; + printerTemplate.x = 32; + printerTemplate.y = 0; + printerTemplate.currentX = 32; + printerTemplate.currentY = 0; + printerTemplate.letterSpacing = 0; + printerTemplate.lineSpacing = 0; + printerTemplate.unk = 0; + printerTemplate.fgColor = TEXT_COLOR_WHITE; + printerTemplate.bgColor = TEXT_COLOR_TRANSPARENT; + printerTemplate.shadowColor = TEXT_COLOR_DARK_GREY; - AddTextPrinter(&subPrinter, 0xFF, NULL); + AddTextPrinter(&printerTemplate, 0xFF, NULL); txtPtr = gStringVar4; gStringVar4[0] = CHAR_SPECIAL_F9; @@ -6432,9 +6432,9 @@ static void PutLevelAndGenderOnLvlUpBox(void) *(txtPtr++) = EOS; } - subPrinter.y = 10; - subPrinter.currentY = 10; - AddTextPrinter(&subPrinter, 0xFF, NULL); + printerTemplate.y = 10; + printerTemplate.currentY = 10; + AddTextPrinter(&printerTemplate, 0xFF, NULL); CopyWindowToVram(14, 2); } diff --git a/src/berry_blender.c b/src/berry_blender.c index 643bd2e30..f4ea78521 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -1031,7 +1031,7 @@ static void sub_807FAC8(void) sBerryBlenderData->mainState++; break; case 4: - if (Blender_PrintText(&sBerryBlenderData->textState, sText_BerryBlenderStart, GetPlayerTextSpeed())) + if (Blender_PrintText(&sBerryBlenderData->textState, sText_BerryBlenderStart, GetPlayerTextSpeedDelay())) sBerryBlenderData->mainState++; break; case 5: @@ -2490,7 +2490,7 @@ static void CB2_HandleBlenderEndGame(void) } break; case 7: - if (Blender_PrintText(&sBerryBlenderData->textState, sText_WouldLikeToBlendAnotherBerry, GetPlayerTextSpeed())) + if (Blender_PrintText(&sBerryBlenderData->textState, sText_WouldLikeToBlendAnotherBerry, GetPlayerTextSpeedDelay())) sBerryBlenderData->gameEndState++; break; case 9: @@ -2572,7 +2572,7 @@ static void CB2_HandleBlenderEndGame(void) sBerryBlenderData->gameEndState++; break; case 13: - if (Blender_PrintText(&sBerryBlenderData->textState, sText_CommunicationStandby, GetPlayerTextSpeed())) + if (Blender_PrintText(&sBerryBlenderData->textState, sText_CommunicationStandby, GetPlayerTextSpeedDelay())) { SetMainCallback2(CB2_HandlePlayerLinkPlayAgainChoice); sBerryBlenderData->gameEndState = 0; @@ -2680,7 +2680,7 @@ static void CB2_HandlePlayerLinkPlayAgainChoice(void) StringAppend(gStringVar4, sText_HasNoBerriesToPut); break; case 3: - if (Blender_PrintText(&sBerryBlenderData->textState, gStringVar4, GetPlayerTextSpeed())) + if (Blender_PrintText(&sBerryBlenderData->textState, gStringVar4, GetPlayerTextSpeedDelay())) { sBerryBlenderData->framesToWait = 0; sBerryBlenderData->gameEndState++; @@ -2787,7 +2787,7 @@ static void CB2_HandlePlayerPlayAgainChoice(void) StringCopy(gStringVar4, sText_RunOutOfBerriesForBlending); break; case 3: - if (Blender_PrintText(&sBerryBlenderData->textState, gStringVar4, GetPlayerTextSpeed())) + if (Blender_PrintText(&sBerryBlenderData->textState, gStringVar4, GetPlayerTextSpeedDelay())) sBerryBlenderData->gameEndState = 9; break; case 9: @@ -3363,7 +3363,7 @@ static bool8 Blender_PrintBlendingResults(void) sBerryBlenderData->mainState++; break; case 6: - if (Blender_PrintText(&sBerryBlenderData->textState, sBerryBlenderData->stringVar, GetPlayerTextSpeed())) + if (Blender_PrintText(&sBerryBlenderData->textState, sBerryBlenderData->stringVar, GetPlayerTextSpeedDelay())) { TryUpdateBerryBlenderRecord(); return TRUE; diff --git a/src/contest.c b/src/contest.c index 473f77f9c..20e5619f0 100644 --- a/src/contest.c +++ b/src/contest.c @@ -316,11 +316,11 @@ void sub_80D77E4(void) DeactivateAllTextPrinters(); if (gIsLinkContest & 1) { - gTextFlags.flag_0 = FALSE; + gTextFlags.canABSpeedUpPrint = FALSE; } else { - gTextFlags.flag_0 = TRUE; + gTextFlags.canABSpeedUpPrint = TRUE; } } diff --git a/src/daycare.c b/src/daycare.c index db46b3a4f..2356b36f5 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -1206,17 +1206,17 @@ static void GetDaycareLevelMenuLevelText(struct DayCare *daycare, u8 *dest) static void DaycareAddTextPrinter(u8 windowId, const u8 *text, u32 x, u32 y) { - struct TextSubPrinter printer; + struct TextPrinterTemplate printer; - printer.current_text_offset = text; + printer.currentChar = text; printer.windowId = windowId; printer.fontId = 1; printer.x = x; printer.y = y; printer.currentX = x; printer.currentY = y; - printer.fontColor_l = 0; - gTextFlags.flag_1 = 0; + printer.unk = 0; + gTextFlags.useAlternateDownArrow = 0; printer.letterSpacing = 0; printer.lineSpacing = 1; printer.fgColor = 2; diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 067e103c2..87866df5c 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -531,7 +531,7 @@ void TradeEvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, u8 preEvoSpri gBattle_BG3_X = 256; gBattle_BG3_Y = 0; - gTextFlags.flag_1 = 1; + gTextFlags.useAlternateDownArrow = 1; SetVBlankCallback(VBlankCB_TradeEvolutionScene); SetMainCallback2(CB2_TradeEvolutionSceneUpdate); @@ -1135,7 +1135,7 @@ static void Task_TradeEvolutionScene(u8 taskID) DestroyTask(taskID); Free(sEvoStructPtr); sEvoStructPtr = NULL; - gTextFlags.flag_1 = 0; + gTextFlags.useAlternateDownArrow = 0; SetMainCallback2(gCB2_AfterEvolution); } break; diff --git a/src/field_message_box.c b/src/field_message_box.c index f45b6607d..46da9e9e5 100755 --- a/src/field_message_box.c +++ b/src/field_message_box.c @@ -16,10 +16,10 @@ void textbox_auto_and_task_add(void); void sub_8098128(void) { gUnknown_020375BC = 0; - gTextFlags.flag_0 = 0; - gTextFlags.flag_1 = 0; - gTextFlags.flag_2 = 0; - gTextFlags.flag_3 = 0; + gTextFlags.canABSpeedUpPrint = 0; + gTextFlags.useAlternateDownArrow = 0; + gTextFlags.autoScroll = 0; + gTextFlags.forceMidTextSpeed = 0; } void sub_8098154(u8 taskId) diff --git a/src/item_menu.c b/src/item_menu.c index 124fbccd2..0c3e26354 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1031,7 +1031,7 @@ void DisplayItemMessage(u8 taskId, u8 fontId, const u8 *str, void ( *callback)(u data[10] = AddItemMessageWindow(4); FillWindowPixelBuffer(data[10], 17); - DisplayMessageAndContinueTask(taskId, data[10], 10, 13, fontId, GetPlayerTextSpeed(), str, callback); + DisplayMessageAndContinueTask(taskId, data[10], 10, 13, fontId, GetPlayerTextSpeedDelay(), str, callback); schedule_bg_copy_tilemap_to_vram(1); } diff --git a/src/load_save.c b/src/load_save.c index 005af7c42..45b4d200b 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -144,7 +144,7 @@ void ClearSecretBase2Field_9(void) gSaveBlock2Ptr->specialSaveWarp &= ~1; } -void sub_8076D48(void) +void SetSecretBase2Field_9(void) { gSaveBlock2Ptr->specialSaveWarp |= 1; } diff --git a/src/main_menu.c b/src/main_menu.c index 8539ab027..224958bd9 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -74,7 +74,7 @@ static void NewGameBirchSpeech_ShowDialogueWindow(u8, u8); static void NewGameBirchSpeech_ClearWindow(u8); static void Task_NewGameBirchSpeech_ThisIsAPokemon(u8); static void Task_NewGameBirchSpeech_MainSpeech(u8); -static void NewGameBirchSpeech_ShowPokeBallPrinterCallback(struct TextSubPrinter *printer, u16 a); +static void NewGameBirchSpeech_ShowPokeBallPrinterCallback(struct TextPrinterTemplate *printer, u16 a); static void Task_NewGameBirchSpeech_AndYouAre(u8); static void Task_NewGameBirchSpeechSub_WaitForLotad(u8); static void Task_NewGameBirchSpeech_StartBirchLotadPlatformFade(u8); @@ -2126,9 +2126,9 @@ static void NewGameBirchSpeech_ClearWindow(u8 windowId) CopyWindowToVram(windowId, 2); } -static void NewGameBirchSpeech_ShowPokeBallPrinterCallback(struct TextSubPrinter *printer, u16 a) +static void NewGameBirchSpeech_ShowPokeBallPrinterCallback(struct TextPrinterTemplate *printer, u16 a) { - if (*(printer->current_text_offset - 2) == 8 && gUnknown_02022D04 == 0) + if (*(printer->currentChar - 2) == 8 && gUnknown_02022D04 == 0) { gUnknown_02022D04 = 1; CreateTask(Task_NewGameBirchSpeechSub_InitPokeBall, 0); diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 3d3408bbb..cc4228949 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -430,7 +430,7 @@ static void sub_81206F0(void) gUnknown_03002F84 = FALSE; } -static void BardSong_TextSubPrinter(struct TextSubPrinter * printer, u16 a1) +static void BardSong_TextSubPrinter(struct TextPrinterTemplate * printer, u16 a1) { gUnknown_03002F84 = TRUE; } diff --git a/src/menu.c b/src/menu.c index e5dce2ee0..6687ff2a2 100644 --- a/src/menu.c +++ b/src/menu.c @@ -163,11 +163,11 @@ u16 RunTextPrintersAndIsPrinter0Active(void) return IsTextPrinterActive(0); } -u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 fgColor, u8 bgColor, u8 shadowColor) +u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16), u8 fgColor, u8 bgColor, u8 shadowColor) { - struct TextSubPrinter printer; + struct TextPrinterTemplate printer; - printer.current_text_offset = str; + printer.currentChar = str; printer.windowId = windowId; printer.fontId = fontId; printer.x = 0; @@ -176,31 +176,31 @@ u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed printer.currentY = 1; printer.letterSpacing = 0; printer.lineSpacing = 0; - printer.fontColor_l = 0; + printer.unk = 0; printer.fgColor = fgColor; printer.bgColor = bgColor; printer.shadowColor = shadowColor; - gTextFlags.flag_1 = 0; + gTextFlags.useAlternateDownArrow = 0; return AddTextPrinter(&printer, speed, callback); } void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress) { - void (*callback)(struct TextSubPrinter *, u16) = NULL; - gTextFlags.flag_0 = allowSkippingDelayWithButtonPress; - AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeed(), callback, 2, 1, 3); + void (*callback)(struct TextPrinterTemplate *, u16) = NULL; + gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress; + AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), callback, 2, 1, 3); } void AddTextPrinterForMessage_2(bool8 allowSkippingDelayWithButtonPress) { - gTextFlags.flag_0 = allowSkippingDelayWithButtonPress; - AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeed(), NULL, 2, 1, 3); + gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress; + AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), NULL, 2, 1, 3); } void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonPress, u8 speed) { - gTextFlags.flag_0 = allowSkippingDelayWithButtonPress; + gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress; AddTextPrinterParameterized2(0, 1, gStringVar4, speed, NULL, 2, 1, 3); } @@ -454,7 +454,7 @@ u16 sub_81978D0(u8 colorNum) void DisplayItemMessageOnField(u8 taskId, const u8 *string, TaskFunc callback) { sub_81973A4(); - DisplayMessageAndContinueTask(taskId, 0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM, 1, GetPlayerTextSpeed(), string, callback); + DisplayMessageAndContinueTask(taskId, 0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM, 1, GetPlayerTextSpeedDelay(), string, callback); CopyWindowToVram(0, 3); } @@ -468,19 +468,19 @@ void sub_8197948(u8 initialCursorPos) CreateYesNoMenu(&gUnknown_0860F0A8, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, initialCursorPos); } -u32 sub_8197964(void) +u32 GetPlayerTextSpeed(void) { - if (gTextFlags.flag_3) - return 1; + if (gTextFlags.forceMidTextSpeed) + return OPTIONS_TEXT_SPEED_MID; return gSaveBlock2Ptr->optionsTextSpeed; } -u8 GetPlayerTextSpeed(void) +u8 GetPlayerTextSpeedDelay(void) { u32 speed; - if (gSaveBlock2Ptr->optionsTextSpeed > 2) - gSaveBlock2Ptr->optionsTextSpeed = 1; - speed = sub_8197964(); + if (gSaveBlock2Ptr->optionsTextSpeed > OPTIONS_TEXT_SPEED_FAST) + gSaveBlock2Ptr->optionsTextSpeed = OPTIONS_TEXT_SPEED_MID; + speed = GetPlayerTextSpeed(); return gUnknown_0860F094[speed]; } @@ -536,10 +536,10 @@ void RemoveMapNamePopUpWindow(void) } } -void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextSubPrinter *, u16)) +void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextPrinterTemplate *, u16)) { - gTextFlags.flag_0 = a1; - AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeed(), callback, 2, 1, 3); + gTextFlags.canABSpeedUpPrint = a1; + AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), callback, 2, 1, 3); } void sub_8197AE8(bool8 copyToVram) @@ -1116,14 +1116,14 @@ void sub_8198854(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const stru void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8) { u8 i; - struct TextSubPrinter printer; + struct TextPrinterTemplate printer; printer.windowId = windowId; printer.fontId = fontId; printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); - printer.fontColor_l = GetFontAttribute(fontId, FONTATTR_COLOR_LOWNIBBLE); + printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN); printer.letterSpacing = letterSpacing; printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); printer.x = left; @@ -1131,7 +1131,7 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l for (i = 0; i < itemCount; i++) { - printer.current_text_offset = strs[a8[i]].text; + printer.currentChar = strs[a8[i]].text; printer.y = (lineHeight * i) + top; printer.currentY = printer.y; AddTextPrinter(&printer, 0xFF, NULL); @@ -1172,12 +1172,12 @@ u16 sub_8198AA4(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) { - struct TextSubPrinter printer; + struct TextPrinterTemplate printer; gUnknown_0203CD9F = AddWindow(window); SetWindowBorderStyle(gUnknown_0203CD9F, TRUE, baseTileNum, paletteNum); - printer.current_text_offset = gText_YesNo; + printer.currentChar = gText_YesNo; printer.windowId = gUnknown_0203CD9F; printer.fontId = fontId; printer.x = GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH) + left; @@ -1187,7 +1187,7 @@ void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); - printer.fontColor_l = GetFontAttribute(fontId, FONTATTR_COLOR_LOWNIBBLE); + printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN); printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING); printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); @@ -1238,22 +1238,22 @@ void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u { u8 i; u8 j; - struct TextSubPrinter printer; + struct TextPrinterTemplate printer; printer.windowId = windowId; printer.fontId = fontId; - printer.fgColor = GetFontAttribute(fontId, 5); - printer.bgColor = GetFontAttribute(fontId, 6); - printer.shadowColor = GetFontAttribute(fontId, 7); - printer.fontColor_l = GetFontAttribute(fontId, 4); - printer.letterSpacing = GetFontAttribute(fontId, 2); - printer.lineSpacing = GetFontAttribute(fontId, 3); + printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); + printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); + printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); + printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN); + printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING); + printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); for (i = 0; i < itemCount2; i++) { for (j = 0; j < itemCount; j++) { - printer.current_text_offset = strs[a8[(itemCount * i) + j]].text; + printer.currentChar = strs[a8[(itemCount * i) + j]].text; printer.x = (a4 * j) + left; printer.y = (GetFontAttribute(fontId, 1) * i) + top; printer.currentX = printer.x; @@ -1611,14 +1611,14 @@ void PrintMenuTable(u8 windowId, u8 itemCount, const struct MenuAction *strs) void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const u8 *a8) { u8 i; - struct TextSubPrinter printer; + struct TextPrinterTemplate printer; printer.windowId = windowId; printer.fontId = 1; - printer.fgColor = GetFontAttribute(1, 5); - printer.bgColor = GetFontAttribute(1, 6); - printer.shadowColor = GetFontAttribute(1, 7); - printer.fontColor_l = GetFontAttribute(1, 4); + printer.fgColor = GetFontAttribute(1, FONTATTR_COLOR_FOREGROUND); + printer.bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); + printer.shadowColor = GetFontAttribute(1, FONTATTR_COLOR_SHADOW); + printer.unk = GetFontAttribute(1, FONTATTR_UNKNOWN); printer.letterSpacing = 0; printer.lineSpacing = 0; printer.x = 8; @@ -1626,7 +1626,7 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const for (i = 0; i < itemCount; i++) { - printer.current_text_offset = strs[a8[i]].text; + printer.currentChar = strs[a8[i]].text; printer.y = (i * 16) + 1; printer.currentY = (i * 16) + 1; AddTextPrinter(&printer, 0xFF, NULL); @@ -1637,22 +1637,22 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) { - struct TextSubPrinter printer; + struct TextPrinterTemplate printer; gUnknown_0203CD9F = AddWindow(window); SetWindowBorderStyle(gUnknown_0203CD9F, TRUE, baseTileNum, paletteNum); - printer.current_text_offset = gText_YesNo; + printer.currentChar = gText_YesNo; printer.windowId = gUnknown_0203CD9F; printer.fontId = 1; printer.x = 8; printer.y = 1; printer.currentX = printer.x; printer.currentY = printer.y; - printer.fgColor = GetFontAttribute(1, 5); - printer.bgColor = GetFontAttribute(1, 6); - printer.shadowColor = GetFontAttribute(1, 7); - printer.fontColor_l = GetFontAttribute(1, 4); + printer.fgColor = GetFontAttribute(1, FONTATTR_COLOR_FOREGROUND); + printer.bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); + printer.shadowColor = GetFontAttribute(1, FONTATTR_COLOR_SHADOW); + printer.unk = GetFontAttribute(1, FONTATTR_UNKNOWN); printer.letterSpacing = 0; printer.lineSpacing = 0; @@ -1678,14 +1678,14 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M { u8 i; u8 j; - struct TextSubPrinter printer; + struct TextPrinterTemplate printer; printer.windowId = windowId; printer.fontId = 1; - printer.fgColor = GetFontAttribute(1, 5); - printer.bgColor = GetFontAttribute(1, 6); - printer.shadowColor = GetFontAttribute(1, 7); - printer.fontColor_l = GetFontAttribute(1, 4); + printer.fgColor = GetFontAttribute(1, FONTATTR_COLOR_FOREGROUND); + printer.bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); + printer.shadowColor = GetFontAttribute(1, FONTATTR_COLOR_SHADOW); + printer.unk = GetFontAttribute(1, FONTATTR_UNKNOWN); printer.letterSpacing = 0; printer.lineSpacing = 0; @@ -1693,7 +1693,7 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M { for (j = 0; j < itemCount; j++) { - printer.current_text_offset = strs[a8[(itemCount * i) + j]].text; + printer.currentChar = strs[a8[(itemCount * i) + j]].text; printer.x = (a4 * j) + 8; printer.y = (16 * i) + 1; printer.currentX = printer.x; @@ -1941,9 +1941,9 @@ void sub_8199DF0(u32 bg, u8 a1, int a2, int a3) void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 speed, const u8 *str) { - struct TextSubPrinter printer; + struct TextPrinterTemplate printer; - printer.current_text_offset = str; + printer.currentChar = str; printer.windowId = windowId; printer.fontId = fontId; printer.x = left; @@ -1952,7 +1952,7 @@ void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const printer.currentY = printer.y; printer.letterSpacing = GetFontAttribute(fontId, 2); printer.lineSpacing = GetFontAttribute(fontId, 3); - printer.fontColor_l = 0; + printer.unk = 0; printer.fgColor = color[1]; printer.bgColor = color[0]; printer.shadowColor = color[2]; @@ -1962,9 +1962,9 @@ void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineSpacing, const u8 *color, s8 speed, const u8 *str) { - struct TextSubPrinter printer; + struct TextPrinterTemplate printer; - printer.current_text_offset = str; + printer.currentChar = str; printer.windowId = windowId; printer.fontId = fontId; printer.x = left; @@ -1973,7 +1973,7 @@ void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 left, u8 top, u8 le printer.currentY = printer.y; printer.letterSpacing = letterSpacing; printer.lineSpacing = lineSpacing; - printer.fontColor_l = 0; + printer.unk = 0; printer.fgColor = color[1]; printer.bgColor = color[0]; printer.shadowColor = color[2]; @@ -1981,11 +1981,11 @@ void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 left, u8 top, u8 le AddTextPrinter(&printer, speed, NULL); } -void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 letterSpacing, u8 lineSpacing) +void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16), u8 letterSpacing, u8 lineSpacing) { - struct TextSubPrinter printer; + struct TextPrinterTemplate printer; - printer.current_text_offset = str; + printer.currentChar = str; printer.windowId = windowId; printer.fontId = fontId; printer.x = left; @@ -1994,7 +1994,7 @@ void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left printer.currentY = top; printer.letterSpacing = letterSpacing; printer.lineSpacing = lineSpacing; - printer.fontColor_l = 0; + printer.unk = 0; printer.fgColor = GetFontAttribute(fontId, 5); printer.bgColor = GetFontAttribute(fontId, 6); diff --git a/src/menu_helpers.c b/src/menu_helpers.c index 5070ef312..8bd53ab85 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -134,7 +134,7 @@ void DisplayMessageAndContinueTask(u8 taskId, u8 windowId, u16 arg2, u8 arg3, u8 if (string != gStringVar4) StringExpandPlaceholders(gStringVar4, string); - gTextFlags.flag_0 = 1; + gTextFlags.canABSpeedUpPrint = 1; AddTextPrinterParameterized2(windowId, fontId, gStringVar4, textSpeed, NULL, 2, 1, 3); gUnknown_0300117C = taskFunc; gTasks[taskId].func = Task_ContinueTaskAfterMessagePrints; diff --git a/src/naming_screen.c b/src/naming_screen.c index a67516602..9902df04c 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -558,8 +558,8 @@ static void DisplaySentToPCMessage(void) StringExpandPlaceholders(gStringVar4, gUnknown_0858BDB8[stringToDisplay]); NewMenuHelpers_DrawDialogueFrame(0, 0); - gTextFlags.flag_0 = TRUE; - AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeed(), 0, 2, 1, 3); + gTextFlags.canABSpeedUpPrint = TRUE; + AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), 0, 2, 1, 3); CopyWindowToVram(0, 3); } diff --git a/src/pokeblock.c b/src/pokeblock.c index 1382ff6a7..1ca89d5de 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -1179,7 +1179,7 @@ static void PokeblockAction_Toss(u8 taskId) sub_8198070(data[1], FALSE); StringCopy(gStringVar1, gPokeblockNames[gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId].color]); StringExpandPlaceholders(gStringVar4, gText_ThrowAwayVar1); - DisplayMessageAndContinueTask(taskId, 10, 10, 13, 1, GetPlayerTextSpeed(), gStringVar4, CreateTossPokeblockYesNoMenu); + DisplayMessageAndContinueTask(taskId, 10, 10, 13, 1, GetPlayerTextSpeedDelay(), gStringVar4, CreateTossPokeblockYesNoMenu); } static void CreateTossPokeblockYesNoMenu(u8 taskId) @@ -1190,7 +1190,7 @@ static void CreateTossPokeblockYesNoMenu(u8 taskId) static void TossPokeblockChoice_Yes(u8 taskId) { StringExpandPlaceholders(gStringVar4, gText_Var1ThrownAway); - DisplayMessageAndContinueTask(taskId, 10, 10, 13, 1, GetPlayerTextSpeed(), gStringVar4, HandleErasePokeblock); + DisplayMessageAndContinueTask(taskId, 10, 10, 13, 1, GetPlayerTextSpeedDelay(), gStringVar4, HandleErasePokeblock); } static void HandleErasePokeblock(u8 taskId) diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index d8dd12e13..6978f0715 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -785,8 +785,8 @@ static void Task_HandleMonAtePokeblock(u8 taskId) else StringExpandPlaceholders(gStringVar4, gText_Var1DisdainfullyAteVar2); - gTextFlags.flag_0 = 1; - AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeed(), NULL, 2, 1, 3); + gTextFlags.canABSpeedUpPrint = 1; + AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), NULL, 2, 1, 3); gTasks[taskId].func = Task_WaitForAtePokeblockText; } diff --git a/src/post_battle_event_funcs.c b/src/post_battle_event_funcs.c new file mode 100644 index 000000000..f15396102 --- /dev/null +++ b/src/post_battle_event_funcs.c @@ -0,0 +1,94 @@ +#include "global.h" +#include "main.h" +#include "credits.h" +#include "event_data.h" +#include "hall_of_fame.h" +#include "load_save.h" +#include "overworld.h" +#include "script_pokemon_util_80F87D8.h" +#include "tv.h" +#include "constants/heal_locations.h" +#include "constants/flags.h" + +int GameClear(void) +{ + int i; + bool32 ribbonGet; + struct RibbonCounter { + u8 partyIndex; + u8 count; + } ribbonCounts[6]; + s8 val; + + HealPlayerParty(); + + if (FlagGet(FLAG_SYS_GAME_CLEAR) == TRUE) + { + gHasHallOfFameRecords = TRUE; + } + else + { + gHasHallOfFameRecords = FALSE; + FlagSet(FLAG_SYS_GAME_CLEAR); + } + + if (GetGameStat(GAME_STAT_FIRST_HOF_PLAY_TIME) == 0) + SetGameStat(GAME_STAT_FIRST_HOF_PLAY_TIME, (gSaveBlock2Ptr->playTimeHours << 16) | (gSaveBlock2Ptr->playTimeMinutes << 8) | gSaveBlock2Ptr->playTimeSeconds); + + SetSecretBase2Field_9(); + + if (gSaveBlock2Ptr->playerGender == MALE) + sub_8084F6C(HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F); + else + sub_8084F6C(HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F); + + ribbonGet = FALSE; + + for (i = 0; i < 6; i++) + { + struct Pokemon *mon = &gPlayerParty[i]; + + ribbonCounts[i].partyIndex = i; + ribbonCounts[i].count = 0; + + if (GetMonData(mon, MON_DATA_SANITY_BIT2) + && !GetMonData(mon, MON_DATA_SANITY_BIT3) + && !GetMonData(mon, MON_DATA_CHAMPION_RIBBON)) + { + u8 val[1] = {TRUE}; + SetMonData(mon, MON_DATA_CHAMPION_RIBBON, val); + ribbonCounts[i].count = GetRibbonCount(mon); + ribbonGet = TRUE; + } + } + + if (ribbonGet == TRUE) + { + IncrementGameStat(GAME_STAT_RECEIVED_RIBBONS); + FlagSet(FLAG_SYS_RIBBON_GET); + + for (i = 1; i < 6; i++) + { + if (ribbonCounts[i].count > ribbonCounts[0].count) + { + struct RibbonCounter prevBest = ribbonCounts[0]; + ribbonCounts[0] = ribbonCounts[i]; + ribbonCounts[i] = prevBest; + } + } + + if (ribbonCounts[0].count > 4) + { + sub_80EE4DC(&gPlayerParty[ribbonCounts[0].partyIndex], MON_DATA_CHAMPION_RIBBON); + } + } + + SetMainCallback2(CB2_DoHallOfFameScreen); + return 0; +} + +bool8 sp0C8_whiteout_maybe(void) +{ + SetMainCallback2(CB2_WhiteOut); + return FALSE; +} diff --git a/src/scrcmd.c b/src/scrcmd.c index 5a5867a96..127a5ecaa 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1295,8 +1295,8 @@ bool8 ScrCmd_messageautoscroll(struct ScriptContext *ctx) if (msg == NULL) msg = (const u8 *)ctx->data[0]; - gTextFlags.flag_2 = TRUE; - gTextFlags.flag_3 = TRUE; + gTextFlags.autoScroll = TRUE; + gTextFlags.forceMidTextSpeed = TRUE; ShowFieldAutoScrollMessage(msg); return FALSE; } diff --git a/src/shop.c b/src/shop.c index 35f52c8f9..e9c26cdf3 100755 --- a/src/shop.c +++ b/src/shop.c @@ -694,7 +694,7 @@ static void BuyMenuPrint(u8 windowId, const u8 *text, u8 x, u8 y, s8 speed, u8 c static void BuyMenuDisplayMessage(u8 taskId, const u8 *text, TaskFunc callback) { - DisplayMessageAndContinueTask(taskId, 5, 10, 14, 1, GetPlayerTextSpeed(), text, callback); + DisplayMessageAndContinueTask(taskId, 5, 10, 14, 1, GetPlayerTextSpeedDelay(), text, callback); schedule_bg_copy_tilemap_to_vram(0); } diff --git a/src/text.c b/src/text.c index 84964ffbf..b134bcacd 100644 --- a/src/text.c +++ b/src/text.c @@ -14,7 +14,7 @@ extern u8 GetKeypadIconWidth(u8 keypadIconId); extern u16 Font6Func(struct TextPrinter *textPrinter); extern u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese); -extern int sub_8197964(); +extern int GetPlayerTextSpeed(); EWRAM_DATA struct TextPrinter gTempTextPrinter = {0}; EWRAM_DATA struct TextPrinter gTextPrinters[NUM_TEXT_PRINTERS] = {0}; @@ -26,11 +26,7 @@ static u16 gLastTextShadowColor; const struct FontInfo *gFonts; u8 gUnknown_03002F84; -u8 gUnknown_03002F90[0x20]; -u8 gUnknown_03002FB0[0x20]; -u8 gUnknown_03002FD0[0x20]; -u8 gUnknown_03002FF0[0x20]; -u8 gGlyphDimensions[0x2]; +struct Struct_03002F90 gUnknown_03002F90; TextFlags gTextFlags; const u8 gFontHalfRowOffsets[] = { @@ -141,62 +137,63 @@ void DeactivateAllTextPrinters(void) { int printer; for (printer = 0; printer < NUM_TEXT_PRINTERS; ++printer) - gTextPrinters[printer].sub_union.sub.active = 0; + gTextPrinters[printer].active = 0; } -u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextSubPrinter *, u16)) +u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)) { - struct TextSubPrinter subPrinter; + struct TextPrinterTemplate printerTemplate; - subPrinter.current_text_offset = str; - subPrinter.windowId = windowId; - subPrinter.fontId = fontId; - subPrinter.x = x; - subPrinter.y = y; - subPrinter.currentX = x; - subPrinter.currentY = y; - subPrinter.letterSpacing = gFonts[fontId].letterSpacing; - subPrinter.lineSpacing = gFonts[fontId].lineSpacing; - subPrinter.fontColor_l = gFonts[fontId].fontColor_l; - subPrinter.fgColor = gFonts[fontId].fgColor; - subPrinter.bgColor = gFonts[fontId].bgColor; - subPrinter.shadowColor = gFonts[fontId].shadowColor; - return AddTextPrinter(&subPrinter, speed, callback); + printerTemplate.currentChar = str; + printerTemplate.windowId = windowId; + printerTemplate.fontId = fontId; + printerTemplate.x = x; + printerTemplate.y = y; + printerTemplate.currentX = x; + printerTemplate.currentY = y; + printerTemplate.letterSpacing = gFonts[fontId].letterSpacing; + printerTemplate.lineSpacing = gFonts[fontId].lineSpacing; + printerTemplate.unk = gFonts[fontId].unk; + printerTemplate.fgColor = gFonts[fontId].fgColor; + printerTemplate.bgColor = gFonts[fontId].bgColor; + printerTemplate.shadowColor = gFonts[fontId].shadowColor; + return AddTextPrinter(&printerTemplate, speed, callback); } -bool16 AddTextPrinter(struct TextSubPrinter *textSubPrinter, u8 speed, void (*callback)(struct TextSubPrinter *, u16)) +bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)) { int i; u16 j; + u8 *ptr; if (!gFonts) return FALSE; - gTempTextPrinter.sub_union.sub.active = 1; + gTempTextPrinter.active = 1; gTempTextPrinter.state = 0; - gTempTextPrinter.text_speed = speed; + gTempTextPrinter.textSpeed = speed; gTempTextPrinter.delayCounter = 0; gTempTextPrinter.scrollDistance = 0; - for (i = 0; i < 7; ++i) + for (i = 0; i < 7; i++) { - gTempTextPrinter.sub_union.sub_fields[i] = 0; + gTempTextPrinter.subUnion.fields[i] = 0; } - gTempTextPrinter.subPrinter = *textSubPrinter; + gTempTextPrinter.printerTemplate = *printerTemplate; gTempTextPrinter.callback = callback; gTempTextPrinter.minLetterSpacing = 0; gTempTextPrinter.japanese = 0; - GenerateFontHalfRowLookupTable(textSubPrinter->fgColor, textSubPrinter->bgColor, textSubPrinter->shadowColor); + GenerateFontHalfRowLookupTable(printerTemplate->fgColor, printerTemplate->bgColor, printerTemplate->shadowColor); if (speed != TEXT_SPEED_FF && speed != 0x0) { - --gTempTextPrinter.text_speed; - gTextPrinters[textSubPrinter->windowId] = gTempTextPrinter; + --gTempTextPrinter.textSpeed; + gTextPrinters[printerTemplate->windowId] = gTempTextPrinter; } else { - gTempTextPrinter.text_speed = 0; + gTempTextPrinter.textSpeed = 0; for (j = 0; j < 0x400; ++j) { if ((u32)RenderFont(&gTempTextPrinter) == 1) @@ -204,8 +201,8 @@ bool16 AddTextPrinter(struct TextSubPrinter *textSubPrinter, u8 speed, void (*ca } if (speed != TEXT_SPEED_FF) - CopyWindowToVram(gTempTextPrinter.subPrinter.windowId, 2); - gTextPrinters[textSubPrinter->windowId].sub_union.sub.active = 0; + CopyWindowToVram(gTempTextPrinter.printerTemplate.windowId, 2); + gTextPrinters[printerTemplate->windowId].active = 0; } gUnknown_03002F84 = 0; return TRUE; @@ -220,18 +217,18 @@ void RunTextPrinters(void) { for (i = 0; i < 0x20; ++i) { - if (gTextPrinters[i].sub_union.sub.active != 0) + if (gTextPrinters[i].active != 0) { temp = RenderFont(&gTextPrinters[i]); switch (temp) { case 0: - CopyWindowToVram(gTextPrinters[i].subPrinter.windowId, 2); + CopyWindowToVram(gTextPrinters[i].printerTemplate.windowId, 2); case 3: if (gTextPrinters[i].callback != 0) - gTextPrinters[i].callback(&gTextPrinters[i].subPrinter, temp); + gTextPrinters[i].callback(&gTextPrinters[i].printerTemplate, temp); break; case 1: - gTextPrinters[i].sub_union.sub.active = 0; + gTextPrinters[i].active = 0; break; } } @@ -241,7 +238,7 @@ void RunTextPrinters(void) bool16 IsTextPrinterActive(u8 id) { - return gTextPrinters[id].sub_union.sub.active; + return gTextPrinters[id].active; } u32 RenderFont(struct TextPrinter *textPrinter) @@ -249,7 +246,7 @@ u32 RenderFont(struct TextPrinter *textPrinter) u32 ret; while (TRUE) { - ret = gFonts[textPrinter->subPrinter.fontId].fontFunction(textPrinter); + ret = gFonts[textPrinter->printerTemplate.fontId].fontFunction(textPrinter); if (ret != 2) return ret; } @@ -1247,7 +1244,7 @@ _08004F06:\n\ bcc _08004EA8\n\ _08004F0E:\n\ ldr r1, [sp, #0x88]\n\ - ldr r3, =gUnknown_03002FD0\n\ + ldr r3, =gUnknown_03002F90 + 0x40\n\ str r3, [sp, #0x20]\n\ ldr r0, [sp, #0x74]\n\ mov r8, r0\n\ @@ -1392,7 +1389,7 @@ _08005014:\n\ bcc _08004FBA\n\ _0800501C:\n\ mov r1, r8\n\ - ldr r3, =gUnknown_03002FB0\n\ + ldr r3, =gUnknown_03002F90 + 0x20\n\ str r3, [sp, #0x38]\n\ ldr r0, [sp, #0x84]\n\ ldr r2, [sp, #0x7C]\n\ @@ -1537,7 +1534,7 @@ _08005124:\n\ bcc _080050CA\n\ _0800512C:\n\ mov r1, r8\n\ - ldr r3, =gUnknown_03002FB0\n\ + ldr r3, =gUnknown_03002F90 + 0x20\n\ str r3, [sp, #0x50]\n\ ldr r0, [sp, #0x84]\n\ ldr r2, [sp, #0x7C]\n\ @@ -1606,7 +1603,7 @@ _080051A4:\n\ bcc _08005146\n\ _080051AC:\n\ ldr r1, [sp, #0x88]\n\ - ldr r3, =gUnknown_03002FD0\n\ + ldr r3, =gUnknown_03002F90 + 0x40\n\ str r3, [sp, #0x5C]\n\ ldr r0, [sp, #0x84]\n\ mov r8, r0\n\ @@ -1675,7 +1672,7 @@ _08005222:\n\ _0800522A:\n\ ldr r4, [sp, #0x84]\n\ ldr r1, [sp, #0x88]\n\ - ldr r3, =gUnknown_03002FF0\n\ + ldr r3, =gUnknown_03002F90 + 0x60\n\ str r3, [sp, #0x68]\n\ ldr r0, [sp, #0x7C]\n\ add r0, r4\n\ @@ -1757,23 +1754,23 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width) { struct Window *window; struct Bitmap pixels_data; - u8* gUnk; + struct Struct_03002F90 *gUnk; u8* glyphHeight; if (gLastTextBgColor != 0) { - window = &gWindows[textPrinter->subPrinter.windowId]; + window = &gWindows[textPrinter->printerTemplate.windowId]; pixels_data.pixels = window->tileData; pixels_data.width = window->window.width << 3; pixels_data.height = window->window.height << 3; - gUnk = gUnknown_03002F90; - glyphHeight = &gUnk[0x81]; + gUnk = &gUnknown_03002F90; + glyphHeight = &gUnk->unk81; FillBitmapRect4Bit( &pixels_data, - textPrinter->subPrinter.currentX, - textPrinter->subPrinter.currentY, + textPrinter->printerTemplate.currentX, + textPrinter->printerTemplate.currentY, width, *glyphHeight, gLastTextBgColor); @@ -1782,135 +1779,135 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width) u16 Font0Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 0; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 0; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font1Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 1; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 1; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font2Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 2; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 2; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font3Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 3; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 3; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font4Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 4; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 4; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font5Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 5; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 5; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font7Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 7; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 7; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font8Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 8; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 8; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (gTextFlags.flag_2 == 1) - subStruct->frames_visible_counter = 0; + if (gTextFlags.autoScroll == 1) + subStruct->autoScrollDelay = 0; else { - subStruct->field_1_upmid = 0; - subStruct->field_1 = 0; + subStruct->downArrowYPosIdx = 0; + subStruct->downArrowDelay = 0; } } void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; const u8 *arrowTiles; - if (gTextFlags.flag_2 == 0) + if (gTextFlags.autoScroll == 0) { - if (subStruct->field_1 != 0) + if (subStruct->downArrowDelay != 0) { - subStruct->field_1 = ((*(u32*)&textPrinter->sub_union.sub) << 19 >> 27) - 1; // convoluted way of getting field_1, necessary to match + subStruct->downArrowDelay = ((*(u32*)&textPrinter->subUnion.sub) << 19 >> 27) - 1; // convoluted way of getting downArrowDelay, necessary to match } else { FillWindowPixelRect( - textPrinter->subPrinter.windowId, - textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor, - textPrinter->subPrinter.currentX, - textPrinter->subPrinter.currentY, + textPrinter->printerTemplate.windowId, + textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor, + textPrinter->printerTemplate.currentX, + textPrinter->printerTemplate.currentY, 0x8, 0x10); - switch (gTextFlags.flag_1) + switch (gTextFlags.useAlternateDownArrow) { case 0: default: @@ -1922,20 +1919,20 @@ void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter) } BlitBitmapRectToWindow( - textPrinter->subPrinter.windowId, + textPrinter->printerTemplate.windowId, arrowTiles, 0, - gDownArrowYCoords[*(u32*)subStruct << 17 >> 30], // subStruct->field_1_upmid but again, stupidly retrieved + gDownArrowYCoords[*(u32*)subStruct << 17 >> 30], // subStruct->downArrowYPosIdx but again, stupidly retrieved 0x8, 0x10, - textPrinter->subPrinter.currentX, - textPrinter->subPrinter.currentY, + textPrinter->printerTemplate.currentX, + textPrinter->printerTemplate.currentY, 0x8, 0x10); - CopyWindowToVram(textPrinter->subPrinter.windowId, 0x2); + CopyWindowToVram(textPrinter->printerTemplate.windowId, 0x2); - subStruct->field_1 = 0x8; - subStruct->field_1_upmid = (*(u32*)subStruct << 17 >> 30) + 1; + subStruct->downArrowDelay = 0x8; + subStruct->downArrowYPosIdx = (*(u32*)subStruct << 17 >> 30) + 1; } } } @@ -1943,26 +1940,26 @@ void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter) void TextPrinterClearDownArrow(struct TextPrinter *textPrinter) { FillWindowPixelRect( - textPrinter->subPrinter.windowId, - textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor, - textPrinter->subPrinter.currentX, - textPrinter->subPrinter.currentY, + textPrinter->printerTemplate.windowId, + textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor, + textPrinter->printerTemplate.currentX, + textPrinter->printerTemplate.currentY, 0x8, 0x10); - CopyWindowToVram(textPrinter->subPrinter.windowId, 0x2); + CopyWindowToVram(textPrinter->printerTemplate.windowId, 0x2); } bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->frames_visible_counter == 49) + if (subStruct->autoScrollDelay == 49) { return TRUE; } else { - ++subStruct->frames_visible_counter; + ++subStruct->autoScrollDelay; return FALSE; } } @@ -1970,7 +1967,7 @@ bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter) bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter) { bool8 result = FALSE; - if (gTextFlags.flag_2 != 0) + if (gTextFlags.autoScroll != 0) { result = TextPrinterWaitAutoMode(textPrinter); } @@ -1989,7 +1986,7 @@ bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter) bool16 TextPrinterWait(struct TextPrinter *textPrinter) { bool16 result = FALSE; - if (gTextFlags.flag_2 != 0) + if (gTextFlags.autoScroll != 0) { result = TextPrinterWaitAutoMode(textPrinter); } @@ -2017,7 +2014,7 @@ void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *c FillWindowPixelRect(windowId, (bgColor << 4) | bgColor, x, y, 0x8, 0x10); if (drawArrow == 0) { - switch (gTextFlags.flag_1) + switch (gTextFlags.useAlternateDownArrow) { case 0: default: @@ -2045,290 +2042,289 @@ 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; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; u16 currChar; s32 width; + s32 widthHelper; - switch (textPrinter->state) // _080057C4 + switch (textPrinter->state) { - case 0: // _080057F0 - if ((gMain.heldKeys & (A_BUTTON | B_BUTTON)) && r4->font_type_upper) + case 0: + if ((gMain.heldKeys & (A_BUTTON | B_BUTTON)) && subStruct->hasPrintBeenSpedUp) textPrinter->delayCounter = 0; - if (textPrinter->delayCounter && textPrinter->text_speed) //_0800580A + if (textPrinter->delayCounter && textPrinter->textSpeed) { textPrinter->delayCounter--; - if (gTextFlags.flag_0 && (gMain.newKeys & (A_BUTTON | B_BUTTON))) + if (gTextFlags.canABSpeedUpPrint && (gMain.newKeys & (A_BUTTON | B_BUTTON))) { - r4->font_type_upper = 1; + subStruct->hasPrintBeenSpedUp = TRUE; textPrinter->delayCounter = 0; } return 3; } - if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED) && gTextFlags.flag_2) + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED) && gTextFlags.autoScroll) textPrinter->delayCounter = 3; else - textPrinter->delayCounter = textPrinter->text_speed; + textPrinter->delayCounter = textPrinter->textSpeed; - currChar = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; + currChar = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; - switch (currChar) //_0800588A + switch (currChar) { - case 0xF8+6: //_080058B8 - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; - textPrinter->subPrinter.currentY += (gFonts[textPrinter->subPrinter.fontId].maxLetterHeight + textPrinter->subPrinter.lineSpacing); + case CHAR_NEWLINE: + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentY += (gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing); return 2; - case 0xF8+5: //_080058DC - textPrinter->subPrinter.current_text_offset++; + case PLACEHOLDER_BEGIN: + textPrinter->printerTemplate.currentChar++; return 2; - case 0xF8+4: //_080058E0 - currChar = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - switch (currChar) // _080058F0 + case EXT_CTRL_CODE_BEGIN: + currChar = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + switch (currChar) { - case 1: // _08005960 - textPrinter->subPrinter.fontColor_h = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + case 1: + textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; - case 2: // _08005982 - textPrinter->subPrinter.bgColor = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + case 2: + textPrinter->printerTemplate.bgColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; - case 3: // _080059A6 - textPrinter->subPrinter.shadowColor = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + case 3: + textPrinter->printerTemplate.shadowColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; - case 4: // _080059C0 - textPrinter->subPrinter.fontColor_h = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - textPrinter->subPrinter.bgColor = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - textPrinter->subPrinter.shadowColor = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + case 4: + textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + textPrinter->printerTemplate.bgColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + textPrinter->printerTemplate.shadowColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; - case 5: // _08005A0E - textPrinter->subPrinter.current_text_offset++; + case 5: + textPrinter->printerTemplate.currentChar++; return 2; - case 6: //_08005A12 - r4->font_type = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; + case 6: + subStruct->glyphId = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; return 2; - case 7: // _08005A0A + case 7: return 2; - case 8: // _08005A2A - textPrinter->delayCounter = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; + case 8: + textPrinter->delayCounter = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; textPrinter->state = 6; return 2; - case 9: // _08005A3A + case 9: textPrinter->state = 1; - if (gTextFlags.flag_2) - r4->frames_visible_counter = 0; + if (gTextFlags.autoScroll) + subStruct->autoScrollDelay = 0; return 3; - case 10: // _08005A58 + case 10: textPrinter->state = 5; return 3; - case 11: // _08005A5C - currChar = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - currChar |= *textPrinter->subPrinter.current_text_offset << 8; - textPrinter->subPrinter.current_text_offset++; + case 11: + currChar = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + currChar |= *textPrinter->printerTemplate.currentChar << 8; + textPrinter->printerTemplate.currentChar++; PlayBGM(currChar); return 2; - case 16: // _08005A76 - currChar = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - currChar |= (*textPrinter->subPrinter.current_text_offset << 8); - textPrinter->subPrinter.current_text_offset++; + case 12: + currChar = *textPrinter->printerTemplate.currentChar | 0x100; + textPrinter->printerTemplate.currentChar++; + break; + case 16: + currChar = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + currChar |= (*textPrinter->printerTemplate.currentChar << 8); + textPrinter->printerTemplate.currentChar++; PlaySE(currChar); return 2; - case 13: // _08005A90 - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x + *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; + case 13: + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x + *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; return 2; - case 14: // _08005A98 - textPrinter->subPrinter.currentY = textPrinter->subPrinter.y + *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; + case 14: + textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y + *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; return 2; - case 15: // _08005AA4 - FillWindowPixelBuffer(textPrinter->subPrinter.windowId, textPrinter->subPrinter.bgColor | textPrinter->subPrinter.bgColor << 4); - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; - textPrinter->subPrinter.currentY = textPrinter->subPrinter.y; + case 15: + FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, textPrinter->printerTemplate.bgColor | textPrinter->printerTemplate.bgColor << 4); + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y; return 2; - case 23: // _08005ABE + case 23: m4aMPlayStop(&gMPlayInfo_BGM); return 2; - case 24: // _08005ACC + case 24: m4aMPlayContinue(&gMPlayInfo_BGM); return 2; - case 17: // _08005AD8 - width = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; + case 17: + width = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; if (width > 0) { ClearTextSpan(textPrinter, width); - textPrinter->subPrinter.currentX += width; + textPrinter->printerTemplate.currentX += width; return 0; } return 2; - case 18: // _08005AF2 - textPrinter->subPrinter.currentX = *textPrinter->subPrinter.current_text_offset + textPrinter->subPrinter.x; - textPrinter->subPrinter.current_text_offset++; + case 18: + textPrinter->printerTemplate.currentX = *textPrinter->printerTemplate.currentChar + textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentChar++; return 2; - case 19: // _08005B02 + case 19: { - s32 widthHelper = *textPrinter->subPrinter.current_text_offset; - widthHelper += textPrinter->subPrinter.x; - textPrinter->subPrinter.current_text_offset++; - width = widthHelper - textPrinter->subPrinter.currentX; + widthHelper = *textPrinter->printerTemplate.currentChar; + widthHelper += textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentChar++; + width = widthHelper - textPrinter->printerTemplate.currentX; if (width > 0) { ClearTextSpan(textPrinter, width); - textPrinter->subPrinter.currentX += width; + textPrinter->printerTemplate.currentX += width; return 0; } } return 2; - case 20: // _08005B26 - textPrinter->minLetterSpacing = *textPrinter->subPrinter.current_text_offset++; + case 20: + textPrinter->minLetterSpacing = *textPrinter->printerTemplate.currentChar++; return 2; - case 21: // _08005B36 + case 21: textPrinter->japanese = 1; return 2; - case 22: // _08005B3E + case 22: textPrinter->japanese = 0; return 2; - case 12: // _08005B5A - currChar = *textPrinter->subPrinter.current_text_offset | 0x100; - textPrinter->subPrinter.current_text_offset++; - break; } break; - - case 0xF8+3: // _08005B48 + case CHAR_PROMPT_CLEAR: textPrinter->state = 2; TextPrinterInitDownArrowCounters(textPrinter); return 3; - case 0xF8+2: // _08005B4C + case CHAR_PROMPT_SCROLL: textPrinter->state = 3; TextPrinterInitDownArrowCounters(textPrinter); return 3; - case 0xF8+1: // _08005B5A - currChar = *textPrinter->subPrinter.current_text_offset | 0x100; - textPrinter->subPrinter.current_text_offset++; + case CHAR_SPECIAL_F9: + currChar = *textPrinter->printerTemplate.currentChar | 0x100; + textPrinter->printerTemplate.currentChar++; break; - case 0xF8+0: // _08005B6C - currChar = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - gUnknown_03002F90[0x80] = DrawKeypadIcon(textPrinter->subPrinter.windowId, currChar, textPrinter->subPrinter.currentX, textPrinter->subPrinter.currentY); - textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80] + textPrinter->subPrinter.letterSpacing; + case CHAR_SPECIAL_F8: + currChar = *textPrinter->printerTemplate.currentChar++; + gUnknown_03002F90.unk80 = DrawKeypadIcon(textPrinter->printerTemplate.windowId, currChar, textPrinter->printerTemplate.currentX, textPrinter->printerTemplate.currentY); + textPrinter->printerTemplate.currentX += gUnknown_03002F90.unk80 + textPrinter->printerTemplate.letterSpacing; return 0; - case 0xF8+7: // _08005D6C + case EOS: return 1; } - switch (r4->font_type) // _08005B90 + switch (subStruct->glyphId) { - case 0: // _08005BCC + case 0: DecompressGlyphFont0(currChar, textPrinter->japanese); break; - case 1: // _08005BDA + case 1: DecompressGlyphFont1(currChar, textPrinter->japanese); break; case 2: case 3: case 4: - case 5: // _08005BE8 + case 5: DecompressGlyphFont2(currChar, textPrinter->japanese); break; - case 7: // _08005BF6 + case 7: DecompressGlyphFont7(currChar, textPrinter->japanese); break; - case 8: // _08005C04 + case 8: DecompressGlyphFont8(currChar, textPrinter->japanese); break; - case 6: // _08005C10 + case 6: break; } - CopyGlyphToWindow(textPrinter); // _08005C10 + CopyGlyphToWindow(textPrinter); if (textPrinter->minLetterSpacing) { - textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80]; - width = textPrinter->minLetterSpacing - gUnknown_03002F90[0x80]; + textPrinter->printerTemplate.currentX += gUnknown_03002F90.unk80; + width = textPrinter->minLetterSpacing - gUnknown_03002F90.unk80; if (width > 0) { ClearTextSpan(textPrinter, width); - textPrinter->subPrinter.currentX += width; + textPrinter->printerTemplate.currentX += width; } } - else // _08005C48 + else { if (textPrinter->japanese) - textPrinter->subPrinter.currentX += (gUnknown_03002F90[0x80] + textPrinter->subPrinter.letterSpacing); + textPrinter->printerTemplate.currentX += (gUnknown_03002F90.unk80 + textPrinter->printerTemplate.letterSpacing); else - textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80]; + textPrinter->printerTemplate.currentX += gUnknown_03002F90.unk80; } return 0; - case 1: // _08005C78 + case 1: if (TextPrinterWait(textPrinter)) textPrinter->state = 0; return 3; - case 2: // _08005C8C + case 2: if (TextPrinterWaitWithDownArrow(textPrinter)) { - FillWindowPixelBuffer(textPrinter->subPrinter.windowId, (textPrinter->subPrinter.bgColor << 4) | textPrinter->subPrinter.bgColor); - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; - textPrinter->subPrinter.currentY = textPrinter->subPrinter.y; + FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, (textPrinter->printerTemplate.bgColor << 4) | textPrinter->printerTemplate.bgColor); + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y; textPrinter->state = 0; } return 3; - case 3: // _08005CB8 + case 3: if (TextPrinterWaitWithDownArrow(textPrinter)) { TextPrinterClearDownArrow(textPrinter); - textPrinter->scrollDistance = gFonts[textPrinter->subPrinter.fontId].maxLetterHeight + textPrinter->subPrinter.lineSpacing; - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; + textPrinter->scrollDistance = gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing; + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; textPrinter->state = 4; } return 3; - case 4: // _08005CF0 + case 4: if (textPrinter->scrollDistance) { - int scrollSpeed = sub_8197964(); + int scrollSpeed = GetPlayerTextSpeed(); int speed = gWindowVerticalScrollSpeeds[scrollSpeed]; if (textPrinter->scrollDistance < speed) { - ScrollWindow(textPrinter->subPrinter.windowId, 0, textPrinter->scrollDistance, textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor); + ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor); textPrinter->scrollDistance = 0; } else { - ScrollWindow(textPrinter->subPrinter.windowId, 0, speed, textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor); + ScrollWindow(textPrinter->printerTemplate.windowId, 0, speed, textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor); textPrinter->scrollDistance -= speed; } - CopyWindowToVram(textPrinter->subPrinter.windowId, 2); + CopyWindowToVram(textPrinter->printerTemplate.windowId, 2); } else { textPrinter->state = 0; } return 3; - case 5: // _08005D48 + case 5: if (!IsSEPlaying()) textPrinter->state = 0; return 3; - case 6: // _08005D5A + case 6: if (textPrinter->delayCounter != 0) textPrinter->delayCounter--; else @@ -2338,734 +2334,6 @@ u16 RenderText(struct TextPrinter *textPrinter) return 1; } -#else -NAKED -u16 RenderText(struct TextPrinter *textPrinter) -{ - asm("push {r4-r6,lr}\n\ - add r6, r0, #0\n\ - add r4, r6, #0\n\ - add r4, #0x14\n\ - ldrb r0, [r6, #0x1C]\n\ - cmp r0, #0x6\n\ - bls _080057C4\n\ - b _08005D6C\n\ -_080057C4:\n\ - lsl r0, #2\n\ - ldr r1, =_080057D4\n\ - add r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ -_080057D4:\n\ - .4byte _080057F0\n\ - .4byte _08005C78\n\ - .4byte _08005C8C\n\ - .4byte _08005CB8\n\ - .4byte _08005CF0\n\ - .4byte _08005D48\n\ - .4byte _08005D5A\n\ -_080057F0:\n\ - ldr r2, =gMain\n\ - ldrh r1, [r2, #0x2C]\n\ - mov r0, #0x3\n\ - and r0, r1\n\ - cmp r0, #0\n\ - beq _0800580A\n\ - ldrb r1, [r4]\n\ - mov r0, #0x10\n\ - and r0, r1\n\ - cmp r0, #0\n\ - beq _0800580A\n\ - mov r0, #0\n\ - strb r0, [r6, #0x1E]\n\ -_0800580A:\n\ - ldrb r1, [r6, #0x1E]\n\ - cmp r1, #0\n\ - beq _0800584C\n\ - ldrb r0, [r6, #0x1D]\n\ - cmp r0, #0\n\ - beq _0800584C\n\ - sub r0, r1, #0x1\n\ - strb r0, [r6, #0x1E]\n\ - ldr r0, =gTextFlags\n\ - ldrb r1, [r0]\n\ - mov r0, #0x1\n\ - and r0, r1\n\ - cmp r0, #0\n\ - bne _08005828\n\ - b _08005B56\n\ -_08005828:\n\ - ldrh r1, [r2, #0x2E]\n\ - mov r0, #0x3\n\ - and r0, r1\n\ - cmp r0, #0\n\ - bne _08005834\n\ - b _08005B56\n\ -_08005834:\n\ - ldrb r0, [r4]\n\ - mov r1, #0x10\n\ - orr r0, r1\n\ - strb r0, [r4]\n\ - mov r0, #0\n\ - strb r0, [r6, #0x1E]\n\ - b _08005B56\n\ - .pool\n\ -_0800584C:\n\ - ldr r0, =gBattleTypeFlags\n\ - ldr r0, [r0]\n\ - mov r1, #0x80\n\ - lsl r1, #17\n\ - and r0, r1\n\ - cmp r0, #0\n\ - bne _08005874\n\ - ldr r0, =gTextFlags\n\ - ldrb r1, [r0]\n\ - mov r0, #0x4\n\ - and r0, r1\n\ - cmp r0, #0\n\ - beq _08005874\n\ - mov r0, #0x3\n\ - b _08005876\n\ - .pool\n\ -_08005874:\n\ - ldrb r0, [r6, #0x1D]\n\ -_08005876:\n\ - strb r0, [r6, #0x1E]\n\ - ldr r0, [r6]\n\ - ldrb r3, [r0]\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - add r0, r3, #0\n\ - sub r0, #0xF8\n\ - cmp r0, #0x7\n\ - bls _0800588A\n\ - b _08005B90\n\ -_0800588A:\n\ - lsl r0, #2\n\ - ldr r1, =_08005898\n\ - add r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ -_08005898:\n\ - .4byte _08005B6C\n\ - .4byte _08005B5A\n\ - .4byte _08005B4C\n\ - .4byte _08005B48\n\ - .4byte _080058E0\n\ - .4byte _080058DC\n\ - .4byte _080058B8\n\ - .4byte _08005D6C\n\ -_080058B8:\n\ - ldrb r0, [r6, #0x6]\n\ - strb r0, [r6, #0x8]\n\ - ldrb r1, [r6, #0x5]\n\ - ldr r0, =gFonts\n\ - ldr r2, [r0]\n\ - lsl r0, r1, #1\n\ - add r0, r1\n\ - lsl r0, #2\n\ - add r0, r2\n\ - ldrb r1, [r6, #0xB]\n\ - ldrb r0, [r0, #0x5]\n\ - add r1, r0\n\ - ldrb r0, [r6, #0x9]\n\ - add r0, r1\n\ - b _08005ABA\n\ - .pool\n\ -_080058DC:\n\ - ldr r0, [r6]\n\ - b _08005B30\n\ -_080058E0:\n\ - ldr r0, [r6]\n\ - ldrb r3, [r0]\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - sub r0, r3, #0x1\n\ - cmp r0, #0x17\n\ - bls _080058F0\n\ - b _08005B90\n\ -_080058F0:\n\ - lsl r0, #2\n\ - ldr r1, =_08005900\n\ - add r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ -_08005900:\n\ - .4byte _08005960 @0\n\ - .4byte _08005982 @1\n\ - .4byte _080059A6 @2\n\ - .4byte _080059C0 @3\n\ - .4byte _08005A0E @4\n\ - .4byte _08005A12 @5\n\ - .4byte _08005A0A @6\n\ - .4byte _08005A2A @7\n\ - .4byte _08005A3A @8\n\ - .4byte _08005A58 @9\n\ - .4byte _08005A5C @10\n\ - .4byte _08005B5A @11\n\ - .4byte _08005A90 @12\n\ - .4byte _08005A98 @13\n\ - .4byte _08005AA4 @14\n\ - .4byte _08005A76 @15\n\ - .4byte _08005AD8 @16\n\ - .4byte _08005AF2 @17\n\ - .4byte _08005B02 @18\n\ - .4byte _08005B26 @19\n\ - .4byte _08005B36 @20\n\ - .4byte _08005B3E @21\n\ - .4byte _08005ABE @22\n\ - .4byte _08005ACC @23\n\ -_08005960:\n\ - ldr r2, [r6]\n\ - ldrb r1, [r2]\n\ - lsl r1, #4\n\ - ldrb r3, [r6, #0xC]\n\ - mov r0, #0xF\n\ - and r0, r3\n\ - orr r0, r1\n\ - strb r0, [r6, #0xC]\n\ - add r2, #0x1\n\ - str r2, [r6]\n\ - lsl r0, #24\n\ - lsr r0, #28\n\ - ldrb r2, [r6, #0xD]\n\ - lsl r1, r2, #28\n\ - lsr r1, #28\n\ - lsr r2, #4\n\ - b _08005A06\n\ -_08005982:\n\ - ldr r1, [r6]\n\ - ldrb r2, [r1]\n\ - mov r0, #0xF\n\ - and r0, r2\n\ - ldrb r3, [r6, #0xD]\n\ - mov r2, #0x10\n\ - neg r2, r2\n\ - and r2, r3\n\ - orr r2, r0\n\ - strb r2, [r6, #0xD]\n\ - add r1, #0x1\n\ - str r1, [r6]\n\ - ldrb r0, [r6, #0xC]\n\ - lsr r0, #4\n\ - lsl r1, r2, #28\n\ - lsr r1, #28\n\ - lsr r2, #4\n\ - b _08005A06\n\ -_080059A6:\n\ - ldr r1, [r6]\n\ - ldrb r0, [r1]\n\ - lsl r0, #4\n\ - ldrb r3, [r6, #0xD]\n\ - mov r2, #0xF\n\ - and r2, r3\n\ - orr r2, r0\n\ - strb r2, [r6, #0xD]\n\ - add r1, #0x1\n\ - str r1, [r6]\n\ - ldrb r0, [r6, #0xC]\n\ - lsr r0, #4\n\ - b _080059FE\n\ -_080059C0:\n\ - ldr r3, [r6]\n\ - ldrb r1, [r3]\n\ - lsl r1, #4\n\ - ldrb r4, [r6, #0xC]\n\ - mov r2, #0xF\n\ - add r0, r2, #0\n\ - and r0, r4\n\ - orr r0, r1\n\ - strb r0, [r6, #0xC]\n\ - add r5, r3, #0x1\n\ - str r5, [r6]\n\ - ldrb r3, [r3, #0x1]\n\ - add r1, r2, #0\n\ - and r1, r3\n\ - ldrb r4, [r6, #0xD]\n\ - mov r3, #0x10\n\ - neg r3, r3\n\ - and r3, r4\n\ - orr r3, r1\n\ - strb r3, [r6, #0xD]\n\ - add r4, r5, #0x1\n\ - str r4, [r6]\n\ - ldrb r1, [r5, #0x1]\n\ - lsl r1, #4\n\ - and r2, r3\n\ - orr r2, r1\n\ - strb r2, [r6, #0xD]\n\ - add r4, #0x1\n\ - str r4, [r6]\n\ - lsl r0, #24\n\ - lsr r0, #28\n\ -_080059FE:\n\ - lsl r1, r2, #28\n\ - lsr r1, #28\n\ - lsl r2, #24\n\ - lsr r2, #28\n\ -_08005A06:\n\ - bl GenerateFontHalfRowLookupTable\n\ -_08005A0A:\n\ - mov r0, #0x2\n\ - b _08005D6E\n\ -_08005A0E:\n\ - ldr r0, [r6]\n\ - b _08005B30\n\ -_08005A12:\n\ - ldr r0, [r6]\n\ - ldrb r0, [r0]\n\ - mov r1, #0xF\n\ - and r1, r0\n\ - ldrb r2, [r4]\n\ - mov r0, #0x10\n\ - neg r0, r0\n\ - and r0, r2\n\ - orr r0, r1\n\ - strb r0, [r4]\n\ - ldr r0, [r6]\n\ - b _08005B30\n\ -_08005A2A:\n\ - ldr r0, [r6]\n\ - ldrb r1, [r0]\n\ - strb r1, [r6, #0x1E]\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - mov r0, #0x6\n\ - strb r0, [r6, #0x1C]\n\ - b _08005A0A\n\ -_08005A3A:\n\ - mov r0, #0x1\n\ - strb r0, [r6, #0x1C]\n\ - ldr r0, =gTextFlags\n\ - ldrb r1, [r0]\n\ - mov r0, #0x4\n\ - and r0, r1\n\ - cmp r0, #0\n\ - bne _08005A4C\n\ - b _08005B56\n\ -_08005A4C:\n\ - mov r0, #0\n\ - strb r0, [r4, #0x2]\n\ - b _08005B56\n\ - .pool\n\ -_08005A58:\n\ - mov r0, #0x5\n\ - b _08005D56\n\ -_08005A5C:\n\ - ldr r0, [r6]\n\ - ldrb r3, [r0]\n\ - add r1, r0, #0x1\n\ - str r1, [r6]\n\ - ldrb r0, [r0, #0x1]\n\ - lsl r0, #8\n\ - orr r3, r0\n\ - add r1, #0x1\n\ - str r1, [r6]\n\ - add r0, r3, #0\n\ - bl PlayBGM\n\ - b _08005A0A\n\ -_08005A76:\n\ - ldr r0, [r6]\n\ - ldrb r3, [r0]\n\ - add r1, r0, #0x1\n\ - str r1, [r6]\n\ - ldrb r0, [r0, #0x1]\n\ - lsl r0, #8\n\ - orr r3, r0\n\ - add r1, #0x1\n\ - str r1, [r6]\n\ - add r0, r3, #0\n\ - bl PlaySE\n\ - b _08005A0A\n\ -_08005A90:\n\ - ldr r1, [r6]\n\ - ldrb r0, [r1]\n\ - ldrb r3, [r6, #0x6]\n\ - b _08005AF8\n\ -_08005A98:\n\ - ldr r1, [r6]\n\ - ldrb r0, [r1]\n\ - ldrb r2, [r6, #0x7]\n\ - add r0, r2\n\ - strb r0, [r6, #0x9]\n\ - b _08005AFC\n\ -_08005AA4:\n\ - ldrb r0, [r6, #0x4]\n\ - ldrb r2, [r6, #0xD]\n\ - lsl r2, #28\n\ - lsr r1, r2, #4\n\ - orr r1, r2\n\ - lsr r1, #24\n\ - bl FillWindowPixelBuffer\n\ - ldrb r0, [r6, #0x6]\n\ - strb r0, [r6, #0x8]\n\ - ldrb r0, [r6, #0x7]\n\ -_08005ABA:\n\ - strb r0, [r6, #0x9]\n\ - b _08005A0A\n\ -_08005ABE:\n\ - ldr r0, =gMPlayInfo_BGM\n\ - bl m4aMPlayStop\n\ - b _08005A0A\n\ - .pool\n\ -_08005ACC:\n\ - ldr r0, =gMPlayInfo_BGM\n\ - bl m4aMPlayContinue\n\ - b _08005A0A\n\ - .pool\n\ -_08005AD8:\n\ - ldr r0, [r6]\n\ - ldrb r4, [r0]\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - cmp r4, #0\n\ - ble _08005A0A\n\ - add r0, r6, #0\n\ - add r1, r4, #0\n\ - bl ClearTextSpan\n\ - ldrb r0, [r6, #0x8]\n\ - add r0, r4\n\ - b _08005C6E\n\ -_08005AF2:\n\ - ldr r1, [r6]\n\ - ldrb r0, [r6, #0x6]\n\ - ldrb r3, [r1]\n\ -_08005AF8:\n\ - add r0, r3\n\ - strb r0, [r6, #0x8]\n\ -_08005AFC:\n\ - add r1, #0x1\n\ - str r1, [r6]\n\ - b _08005A0A\n\ -_08005B02:\n\ - ldr r0, [r6]\n\ - ldrb r2, [r0]\n\ - ldrb r1, [r6, #0x6]\n\ - add r2, r1\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - ldrb r0, [r6, #0x8]\n\ - sub r4, r2, r0\n\ - cmp r4, #0\n\ - bgt _08005B18\n\ - b _08005A0A\n\ -_08005B18:\n\ - add r0, r6, #0\n\ - add r1, r4, #0\n\ - bl ClearTextSpan\n\ - ldrb r0, [r6, #0x8]\n\ - add r0, r4\n\ - b _08005C6E\n\ -_08005B26:\n\ - ldr r0, [r6]\n\ - ldrb r2, [r0]\n\ - add r1, r6, #0\n\ - add r1, #0x20\n\ - strb r2, [r1]\n\ -_08005B30:\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - b _08005A0A\n\ -_08005B36:\n\ - add r1, r6, #0\n\ - add r1, #0x21\n\ - mov r0, #0x1\n\ - b _08005B44\n\ -_08005B3E:\n\ - add r1, r6, #0\n\ - add r1, #0x21\n\ - mov r0, #0\n\ -_08005B44:\n\ - strb r0, [r1]\n\ - b _08005A0A\n\ -_08005B48:\n\ - mov r0, #0x2\n\ - b _08005B4E\n\ -_08005B4C:\n\ - mov r0, #0x3\n\ -_08005B4E:\n\ - strb r0, [r6, #0x1C]\n\ - add r0, r6, #0\n\ - bl TextPrinterInitDownArrowCounters\n\ -_08005B56:\n\ - mov r0, #0x3\n\ - b _08005D6E\n\ -_08005B5A:\n\ - ldr r0, [r6]\n\ - ldrb r3, [r0]\n\ - mov r2, #0x80\n\ - lsl r2, #1\n\ - add r1, r2, #0\n\ - orr r3, r1\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - b _08005B90\n\ -_08005B6C:\n\ - ldr r0, [r6]\n\ - ldrb r3, [r0]\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - ldrb r0, [r6, #0x4]\n\ - add r1, r3, #0\n\ - ldrb r2, [r6, #0x8]\n\ - ldrb r3, [r6, #0x9]\n\ - bl DrawKeypadIcon\n\ - ldr r1, =gUnknown_03002F90\n\ - add r1, #0x80\n\ - strb r0, [r1]\n\ - ldrb r3, [r6, #0xA]\n\ - add r0, r3\n\ - b _08005C6A\n\ - .pool\n\ -_08005B90:\n\ - ldr r0, [r4]\n\ - lsl r0, #28\n\ - lsr r0, #28\n\ - cmp r0, #0x8\n\ - bhi _08005C10\n\ - lsl r0, #2\n\ - ldr r1, =_08005BA8\n\ - add r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ -_08005BA8:\n\ - .4byte _08005BCC\n\ - .4byte _08005BDA\n\ - .4byte _08005BE8\n\ - .4byte _08005BE8\n\ - .4byte _08005BE8\n\ - .4byte _08005BE8\n\ - .4byte _08005C10\n\ - .4byte _08005BF6\n\ - .4byte _08005C04\n\ -_08005BCC:\n\ - add r0, r6, #0\n\ - add r0, #0x21\n\ - ldrb r1, [r0]\n\ - add r0, r3, #0\n\ - bl DecompressGlyphFont0\n\ - b _08005C10\n\ -_08005BDA:\n\ - add r0, r6, #0\n\ - add r0, #0x21\n\ - ldrb r1, [r0]\n\ - add r0, r3, #0\n\ - bl DecompressGlyphFont1\n\ - b _08005C10\n\ -_08005BE8:\n\ - add r0, r6, #0\n\ - add r0, #0x21\n\ - ldrb r1, [r0]\n\ - add r0, r3, #0\n\ - bl DecompressGlyphFont2\n\ - b _08005C10\n\ -_08005BF6:\n\ - add r0, r6, #0\n\ - add r0, #0x21\n\ - ldrb r1, [r0]\n\ - add r0, r3, #0\n\ - bl DecompressGlyphFont7\n\ - b _08005C10\n\ -_08005C04:\n\ - add r0, r6, #0\n\ - add r0, #0x21\n\ - ldrb r1, [r0]\n\ - add r0, r3, #0\n\ - bl DecompressGlyphFont8\n\ -_08005C10:\n\ - add r0, r6, #0\n\ - bl CopyGlyphToWindow\n\ - add r2, r6, #0\n\ - add r2, #0x20\n\ - ldrb r0, [r2]\n\ - cmp r0, #0\n\ - beq _08005C48\n\ - ldr r1, =gUnknown_03002F90\n\ - add r1, #0x80\n\ - ldrb r0, [r1]\n\ - ldrb r3, [r6, #0x8]\n\ - add r0, r3\n\ - strb r0, [r6, #0x8]\n\ - ldrb r2, [r2]\n\ - ldrb r0, [r1]\n\ - sub r4, r2, r0\n\ - cmp r4, #0\n\ - ble _08005C70\n\ - add r0, r6, #0\n\ - add r1, r4, #0\n\ - bl ClearTextSpan\n\ - ldrb r0, [r6, #0x8]\n\ - add r0, r4\n\ - b _08005C6E\n\ - .pool\n\ -_08005C48:\n\ - add r0, r6, #0\n\ - add r0, #0x21\n\ - ldrb r0, [r0]\n\ - cmp r0, #0\n\ - beq _08005C64\n\ - ldr r0, =gUnknown_03002F90\n\ - add r0, #0x80\n\ - ldrb r1, [r6, #0xA]\n\ - ldrb r0, [r0]\n\ - add r1, r0\n\ - ldrb r0, [r6, #0x8]\n\ - b _08005C6C\n\ - .pool\n\ -_08005C64:\n\ - ldr r0, =gUnknown_03002F90\n\ - add r0, #0x80\n\ - ldrb r0, [r0]\n\ -_08005C6A:\n\ - ldrb r1, [r6, #0x8]\n\ -_08005C6C:\n\ - add r0, r1\n\ -_08005C6E:\n\ - strb r0, [r6, #0x8]\n\ -_08005C70:\n\ - mov r0, #0\n\ - b _08005D6E\n\ - .pool\n\ -_08005C78:\n\ - add r0, r6, #0\n\ - bl TextPrinterWait\n\ - lsl r0, #16\n\ - cmp r0, #0\n\ - bne _08005C86\n\ - b _08005B56\n\ -_08005C86:\n\ - mov r0, #0\n\ - strb r0, [r6, #0x1C]\n\ - b _08005B56\n\ -_08005C8C:\n\ - add r0, r6, #0\n\ - bl TextPrinterWaitWithDownArrow\n\ - lsl r0, #16\n\ - cmp r0, #0\n\ - bne _08005C9A\n\ - b _08005B56\n\ -_08005C9A:\n\ - ldrb r0, [r6, #0x4]\n\ - ldrb r2, [r6, #0xD]\n\ - lsl r2, #28\n\ - lsr r1, r2, #4\n\ - orr r1, r2\n\ - lsr r1, #24\n\ - bl FillWindowPixelBuffer\n\ - ldrb r0, [r6, #0x6]\n\ - mov r1, #0\n\ - strb r0, [r6, #0x8]\n\ - ldrb r0, [r6, #0x7]\n\ - strb r0, [r6, #0x9]\n\ - strb r1, [r6, #0x1C]\n\ - b _08005B56\n\ -_08005CB8:\n\ - add r0, r6, #0\n\ - bl TextPrinterWaitWithDownArrow\n\ - lsl r0, #16\n\ - cmp r0, #0\n\ - bne _08005CC6\n\ - b _08005B56\n\ -_08005CC6:\n\ - add r0, r6, #0\n\ - bl TextPrinterClearDownArrow\n\ - ldrb r1, [r6, #0x5]\n\ - ldr r0, =gFonts\n\ - ldr r2, [r0]\n\ - lsl r0, r1, #1\n\ - add r0, r1\n\ - lsl r0, #2\n\ - add r0, r2\n\ - ldrb r1, [r6, #0xB]\n\ - ldrb r0, [r0, #0x5]\n\ - add r1, r0\n\ - strb r1, [r6, #0x1F]\n\ - ldrb r0, [r6, #0x6]\n\ - strb r0, [r6, #0x8]\n\ - mov r0, #0x4\n\ - strb r0, [r6, #0x1C]\n\ - b _08005B56\n\ - .pool\n\ -_08005CF0:\n\ - ldrb r0, [r6, #0x1F]\n\ - cmp r0, #0\n\ - beq _08005D44\n\ - bl sub_8197964\n\ - ldr r1, =gWindowVerticalScrollSpeeds\n\ - add r0, r1\n\ - ldrb r4, [r0]\n\ - ldrb r2, [r6, #0x1F]\n\ - cmp r2, r4\n\ - bge _08005D20\n\ - ldrb r0, [r6, #0x4]\n\ - ldrb r1, [r6, #0xD]\n\ - lsl r1, #28\n\ - lsr r3, r1, #4\n\ - orr r3, r1\n\ - lsr r3, #24\n\ - mov r1, #0\n\ - bl ScrollWindow\n\ - mov r0, #0\n\ - b _08005D38\n\ - .pool\n\ -_08005D20:\n\ - ldrb r0, [r6, #0x4]\n\ - ldrb r1, [r6, #0xD]\n\ - lsl r1, #28\n\ - lsr r3, r1, #4\n\ - orr r3, r1\n\ - lsr r3, #24\n\ - mov r1, #0\n\ - add r2, r4, #0\n\ - bl ScrollWindow\n\ - ldrb r0, [r6, #0x1F]\n\ - sub r0, r4\n\ -_08005D38:\n\ - strb r0, [r6, #0x1F]\n\ - ldrb r0, [r6, #0x4]\n\ - mov r1, #0x2\n\ - bl CopyWindowToVram\n\ - b _08005B56\n\ -_08005D44:\n\ - strb r0, [r6, #0x1C]\n\ - b _08005B56\n\ -_08005D48:\n\ - bl IsSEPlaying\n\ - lsl r0, #24\n\ - lsr r0, #24\n\ - cmp r0, #0\n\ - beq _08005D56\n\ - b _08005B56\n\ -_08005D56:\n\ - strb r0, [r6, #0x1C]\n\ - b _08005B56\n\ -_08005D5A:\n\ - ldrb r0, [r6, #0x1E]\n\ - add r1, r0, #0\n\ - cmp r1, #0\n\ - beq _08005D68\n\ - sub r0, #0x1\n\ - strb r0, [r6, #0x1E]\n\ - b _08005B56\n\ -_08005D68:\n\ - strb r1, [r6, #0x1C]\n\ - b _08005B56\n\ -_08005D6C:\n\ - mov r0, #0x1\n\ -_08005D6E:\n\ - pop {r4-r6}\n\ - pop {r1}\n\ - bx r1\n"); -} -#endif u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) { @@ -3093,59 +2361,59 @@ u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) temp = strLocal[strPos++]; switch (temp) { - case CHAR_NEWLINE: - case EOS: - lineWidths[line] = width; - width = 0; - line++; - break; - case EXT_CTRL_CODE_BEGIN: - temp2 = strLocal[strPos++]; - switch (temp2) - { - case 0x4: - ++strPos; - case 0xB: - case 0x10: - ++strPos; - case 0x1: - case 0x2: - case 0x3: - case 0x5: - case 0x6: - case 0x8: - case 0xC: - case 0xD: - case 0xE: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - ++strPos; - break; - case 0x7: - case 0x9: - case 0xA: - case 0xF: - case 0x15: - case 0x16: - default: - break; - } - break; - case CHAR_SPECIAL_F7: - case PLACEHOLDER_BEGIN: + case CHAR_NEWLINE: + case EOS: + lineWidths[line] = width; + width = 0; + line++; + break; + case EXT_CTRL_CODE_BEGIN: + temp2 = strLocal[strPos++]; + switch (temp2) + { + case 0x4: + ++strPos; + case 0xB: + case 0x10: + ++strPos; + case 0x1: + case 0x2: + case 0x3: + case 0x5: + case 0x6: + case 0x8: + case 0xC: + case 0xD: + case 0xE: + case 0x11: + case 0x12: + case 0x13: + case 0x14: ++strPos; break; - case CHAR_PROMPT_SCROLL: - case CHAR_PROMPT_CLEAR: - break; - case CHAR_SPECIAL_F8: - case CHAR_SPECIAL_F9: - ++strPos; + case 0x7: + case 0x9: + case 0xA: + case 0xF: + case 0x15: + case 0x16: default: - ++width; break; + } + break; + case CHAR_SPECIAL_F7: + case PLACEHOLDER_BEGIN: + ++strPos; + break; + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: + break; + case CHAR_SPECIAL_F8: + case CHAR_SPECIAL_F9: + ++strPos; + default: + ++width; + break; } } while (temp != EOS); @@ -3164,7 +2432,7 @@ u32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32) for (i = 0; i < 9; ++i) { - if (glyphId == gGlyphWidthFuncs[i].font_id) + if (glyphId == gGlyphWidthFuncs[i].fontId) return gGlyphWidthFuncs[i].func; } @@ -3203,107 +2471,32 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) { switch (*str) { - case CHAR_NEWLINE: - if (lineWidth > width) - width = lineWidth; - lineWidth = 0; - break; - case PLACEHOLDER_BEGIN: - switch (*++str) - { - case 0x2: - bufferPointer = gStringVar1; - break; - case 0x3: - bufferPointer = gStringVar2; - break; - case 0x4: - bufferPointer = gStringVar3; - break; - default: - return 0; - } - case CHAR_SPECIAL_F7: - if (bufferPointer == NULL) - bufferPointer = DynamicPlaceholderTextUtil_GetPlaceholderPtr(*++str); - while (*bufferPointer != EOS) - { - glyphWidth = func(*bufferPointer++, isJapanese); - if (minGlyphWidth > 0) - { - if (glyphWidth < minGlyphWidth) - glyphWidth = minGlyphWidth; - lineWidth += glyphWidth; - } - else - { - lineWidth += glyphWidth; - if (isJapanese && str[1] != EOS) - lineWidth += localLetterSpacing; - } - } - bufferPointer = 0; - break; - case EXT_CTRL_CODE_BEGIN: - switch (*++str) - { - case 0x4: - ++str; - case 0xB: - case 0x10: - ++str; - case 0x1: - case 0x2: - case 0x3: - case 0x5: - case 0x8: - case 0xC: - case 0xD: - case 0xE: - ++str; - break; - case 0x6: - func = GetFontWidthFunc(*++str); - if (func == NULL) - return 0; - if (letterSpacing == -1) - localLetterSpacing = GetFontAttribute(*str, FONTATTR_LETTER_SPACING); - break; - case 0x11: - glyphWidth = *++str; - lineWidth += glyphWidth; - break; - case 0x12: - lineWidth = *++str; - break; - case 0x13: - if (*++str > lineWidth) - lineWidth = *str; - break; - case 0x14: - minGlyphWidth = *++str; - break; - case 0x15: - isJapanese = 1; - break; - case 0x16: - isJapanese = 0; - break; - case 0x7: - case 0x9: - case 0xA: - case 0xF: - default: - break; - } - break; - case CHAR_SPECIAL_F8: - case CHAR_SPECIAL_F9: - if (*str == CHAR_SPECIAL_F9) - glyphWidth = func(*++str | 0x100, isJapanese); - else - glyphWidth = GetKeypadIconWidth(*++str); - + case CHAR_NEWLINE: + if (lineWidth > width) + width = lineWidth; + lineWidth = 0; + break; + case PLACEHOLDER_BEGIN: + switch (*++str) + { + case 0x2: + bufferPointer = gStringVar1; + break; + case 0x3: + bufferPointer = gStringVar2; + break; + case 0x4: + bufferPointer = gStringVar3; + break; + default: + return 0; + } + case CHAR_SPECIAL_F7: + if (bufferPointer == NULL) + bufferPointer = DynamicPlaceholderTextUtil_GetPlaceholderPtr(*++str); + while (*bufferPointer != EOS) + { + glyphWidth = func(*bufferPointer++, isJapanese); if (minGlyphWidth > 0) { if (glyphWidth < minGlyphWidth) @@ -3316,25 +2509,100 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) if (isJapanese && str[1] != EOS) lineWidth += localLetterSpacing; } + } + bufferPointer = 0; + break; + case EXT_CTRL_CODE_BEGIN: + switch (*++str) + { + case 0x4: + ++str; + case 0xB: + case 0x10: + ++str; + case 0x1: + case 0x2: + case 0x3: + case 0x5: + case 0x8: + case 0xC: + case 0xD: + case 0xE: + ++str; break; - case CHAR_PROMPT_SCROLL: - case CHAR_PROMPT_CLEAR: + case 0x6: + func = GetFontWidthFunc(*++str); + if (func == NULL) + return 0; + if (letterSpacing == -1) + localLetterSpacing = GetFontAttribute(*str, FONTATTR_LETTER_SPACING); break; + case 0x11: + glyphWidth = *++str; + lineWidth += glyphWidth; + break; + case 0x12: + lineWidth = *++str; + break; + case 0x13: + if (*++str > lineWidth) + lineWidth = *str; + break; + case 0x14: + minGlyphWidth = *++str; + break; + case 0x15: + isJapanese = 1; + break; + case 0x16: + isJapanese = 0; + break; + case 0x7: + case 0x9: + case 0xA: + case 0xF: default: - glyphWidth = func(*str, isJapanese); - if (minGlyphWidth > 0) - { - if (glyphWidth < minGlyphWidth) - glyphWidth = minGlyphWidth; - lineWidth += glyphWidth; - } - else - { - lineWidth += glyphWidth; - if (isJapanese && str[1] != EOS) - lineWidth += localLetterSpacing; - } break; + } + break; + case CHAR_SPECIAL_F8: + case CHAR_SPECIAL_F9: + if (*str == CHAR_SPECIAL_F9) + glyphWidth = func(*++str | 0x100, isJapanese); + else + glyphWidth = GetKeypadIconWidth(*++str); + + if (minGlyphWidth > 0) + { + if (glyphWidth < minGlyphWidth) + glyphWidth = minGlyphWidth; + lineWidth += glyphWidth; + } + else + { + lineWidth += glyphWidth; + if (isJapanese && str[1] != EOS) + lineWidth += localLetterSpacing; + } + break; + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: + break; + default: + glyphWidth = func(*str, isJapanese); + if (minGlyphWidth > 0) + { + if (glyphWidth < minGlyphWidth) + glyphWidth = minGlyphWidth; + lineWidth += glyphWidth; + } + else + { + lineWidth += glyphWidth; + if (isJapanese && str[1] != EOS) + lineWidth += localLetterSpacing; + } + break; } ++str; } @@ -3370,82 +2638,81 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) temp = strLocal[strPos++]; switch (temp) { - case EXT_CTRL_CODE_BEGIN: - temp2 = strLocal[strPos++]; - switch (temp2) - { - case 0x4: - fgColor = strLocal[strPos++]; - bgColor = strLocal[strPos++]; - shadowColor = strLocal[strPos++]; - GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); - continue; - case 0x1: - fgColor = strLocal[strPos++]; - GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); - continue; - case 0x2: - bgColor = strLocal[strPos++]; - GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); - continue; - case 0x3: - shadowColor = strLocal[strPos++]; - GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); - continue; - case 0x6: - fontId = strLocal[strPos++]; - break; - case 0xB: - case 0x10: - ++strPos; - case 0x5: - case 0x8: - case 0xC: - case 0xD: - case 0xE: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - ++strPos; - break; - case 0x7: - case 0x9: - case 0xA: - case 0xF: - case 0x15: - case 0x16: - default: - continue; - } + case EXT_CTRL_CODE_BEGIN: + temp2 = strLocal[strPos++]; + switch (temp2) + { + case 0x4: + fgColor = strLocal[strPos++]; + bgColor = strLocal[strPos++]; + shadowColor = strLocal[strPos++]; + GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); + continue; + case 0x1: + fgColor = strLocal[strPos++]; + GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); + continue; + case 0x2: + bgColor = strLocal[strPos++]; + GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); + continue; + case 0x3: + shadowColor = strLocal[strPos++]; + GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); + continue; + case 0x6: + fontId = strLocal[strPos++]; break; - case CHAR_SPECIAL_F7: - case CHAR_SPECIAL_F8: - case CHAR_SPECIAL_F9: - case PLACEHOLDER_BEGIN: + case 0xB: + case 0x10: + ++strPos; + case 0x5: + case 0x8: + case 0xC: + case 0xD: + case 0xE: + case 0x11: + case 0x12: + case 0x13: + case 0x14: ++strPos; break; - case CHAR_PROMPT_SCROLL: - case CHAR_PROMPT_CLEAR: - case CHAR_NEWLINE: - case EOS: - break; + case 0x7: + case 0x9: + case 0xA: + case 0xF: + case 0x15: + case 0x16: default: - switch (fontId) - { - case 9: - DecompressGlyphFont9(temp); - break; - case 1: - default: - DecompressGlyphFont1(temp, 1); - break; - } - - CpuCopy32(gUnknown_03002F90, pixels, 0x20); - CpuCopy32(gUnknown_03002F90 + 0x40, pixels + 0x20, 0x20); - pixels += 0x40; + continue; + } + break; + case CHAR_SPECIAL_F7: + case CHAR_SPECIAL_F8: + case CHAR_SPECIAL_F9: + case PLACEHOLDER_BEGIN: + ++strPos; + break; + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: + case CHAR_NEWLINE: + case EOS: + break; + default: + switch (fontId) + { + case 9: + DecompressGlyphFont9(temp); break; + case 1: + default: + DecompressGlyphFont1(temp, 1); + break; + } + CpuCopy32(gUnknown_03002F90.unk0, pixels, 0x20); + CpuCopy32(gUnknown_03002F90.unk40, pixels + 0x20, 0x20); + pixels += 0x40; + break; } } while (temp != EOS); @@ -3458,7 +2725,7 @@ u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y) { BlitBitmapRectToWindow( windowId, - gKeypadIconTiles + (gKeypadIcons[keypadIconId].tile_offset * 0x20), + gKeypadIconTiles + (gKeypadIcons[keypadIconId].tileOffset * 0x20), 0, 0, 0x80, @@ -3472,7 +2739,7 @@ u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y) u8 GetKeypadIconTileOffset(u8 keypadIconId) { - return gKeypadIcons[keypadIconId].tile_offset; + return gKeypadIcons[keypadIconId].tileOffset; } u8 GetKeypadIconWidth(u8 keypadIconId) @@ -3507,8 +2774,8 @@ u8 GetFontAttribute(u8 fontId, u8 attributeId) case FONTATTR_LINE_SPACING: result = gFontInfos[fontId].lineSpacing; break; - case FONTATTR_COLOR_LOWNIBBLE: - result = gFontInfos[fontId].fontColor_l; + case FONTATTR_UNKNOWN: + result = gFontInfos[fontId].unk; break; case FONTATTR_COLOR_FOREGROUND: result = gFontInfos[fontId].fgColor; @@ -3535,30 +2802,30 @@ void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese) if (isJapanese == 1) { glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); // gUnknown_03002FD0 - gUnknown_03002F90[0x80] = 8; // gGlyphWidth - gUnknown_03002F90[0x81] = 12; // gGlyphHeight + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); // gUnknown_03002F90 + 0x40 + gUnknown_03002F90.unk80 = 8; // gGlyphWidth + gUnknown_03002F90.unk81 = 12; // gGlyphHeight } else { glyphs = gFont0LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90[0x80] = gFont0LatinGlyphWidths[glyphId]; + gUnknown_03002F90.unk80 = gFont0LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90[0x80] <= 8) + if (gUnknown_03002F90.unk80 <= 8) { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); } else { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90 + 0x60)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90.unk60)); } - gUnknown_03002F90[0x81] = 13; + gUnknown_03002F90.unk81 = 13; } } @@ -3578,30 +2845,30 @@ void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese) { int eff; glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); // gUnknown_03002FD0 - gUnknown_03002F90[0x80] = 8; // gGlyphWidth - gUnknown_03002F90[0x81] = 15; // gGlyphHeight + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); // gUnknown_03002F90 + 0x40 + gUnknown_03002F90.unk80 = 8; // gGlyphWidth + gUnknown_03002F90.unk81 = 15; // gGlyphHeight } else { glyphs = gFont7LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90[0x80] = gFont7LatinGlyphWidths[glyphId]; + gUnknown_03002F90.unk80 = gFont7LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90[0x80] <= 8) + if (gUnknown_03002F90.unk80 <= 8) { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); } else { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90 + 0x60)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90.unk60)); } - gUnknown_03002F90[0x81] = 15; + gUnknown_03002F90.unk81 = 15; } } @@ -3620,30 +2887,30 @@ void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese) if (isJapanese == TRUE) { glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); // gUnknown_03002FD0 - gUnknown_03002F90[0x80] = 8; // gGlyphWidth - gUnknown_03002F90[0x81] = 12; // gGlyphHeight + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); // gUnknown_03002F90 + 0x40 + gUnknown_03002F90.unk80 = 8; // gGlyphWidth + gUnknown_03002F90.unk81 = 12; // gGlyphHeight } else { glyphs = gFont8LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90[0x80] = gFont8LatinGlyphWidths[glyphId]; + gUnknown_03002F90.unk80 = gFont8LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90[0x80] <= 8) + if (gUnknown_03002F90.unk80 <= 8) { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); } else { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90 + 0x60)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90.unk60)); } - gUnknown_03002F90[0x81] = 12; + gUnknown_03002F90.unk81 = 12; } } @@ -3662,32 +2929,32 @@ void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese) if (isJapanese == TRUE) { glyphs = gFont2JapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7)); - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); // gUnknown_03002FD0 - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); // gUnknown_03002FB0 - DecompressGlyphTile(glyphs + 0x88, (u16 *)(gUnknown_03002F90 + 0x60)); // gUnknown_03002FF0 - gUnknown_03002F90[0x80] = gFont2JapaneseGlyphWidths[glyphId]; // gGlyphWidth - gUnknown_03002F90[0x81] = 14; // gGlyphHeight + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); // gUnknown_03002F90 + 0x40 + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); // gUnknown_03002F90 + 0x20 + DecompressGlyphTile(glyphs + 0x88, (u16 *)(gUnknown_03002F90.unk60)); // gUnknown_03002F90 + 0x60 + gUnknown_03002F90.unk80 = gFont2JapaneseGlyphWidths[glyphId]; // gGlyphWidth + gUnknown_03002F90.unk81 = 14; // gGlyphHeight } else { glyphs = gFont2LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90[0x80] = gFont2LatinGlyphWidths[glyphId]; + gUnknown_03002F90.unk80 = gFont2LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90[0x80] <= 8) + if (gUnknown_03002F90.unk80 <= 8) { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); } else { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90 + 0x60)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90.unk60)); } - gUnknown_03002F90[0x81] = 14; + gUnknown_03002F90.unk81 = 14; } } @@ -3707,30 +2974,30 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese) { int eff; glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); // gUnknown_03002FD0 - gUnknown_03002F90[0x80] = 8; // gGlyphWidth - gUnknown_03002F90[0x81] = 15; // gGlyphHeight + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); // gUnknown_03002F90 + 0x40 + gUnknown_03002F90.unk80 = 8; // gGlyphWidth + gUnknown_03002F90.unk81 = 15; // gGlyphHeight } else { glyphs = gFont1LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90[0x80] = gFont1LatinGlyphWidths[glyphId]; + gUnknown_03002F90.unk80 = gFont1LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90[0x80] <= 8) + if (gUnknown_03002F90.unk80 <= 8) { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); } else { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90 + 0x60)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90.unk60)); } - gUnknown_03002F90[0x81] = 15; + gUnknown_03002F90.unk81 = 15; } } @@ -3747,8 +3014,8 @@ void DecompressGlyphFont9(u16 glyphId) const u16* glyphs; glyphs = gFont9JapaneseGlyphs + (0x100 * (glyphId >> 4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); - gUnknown_03002F90[0x80] = 8; - gUnknown_03002F90[0x81] = 12; + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); + gUnknown_03002F90.unk80 = 8; + gUnknown_03002F90.unk81 = 12; } diff --git a/src/unk_text_util_2.c b/src/unk_text_util_2.c index 4821ed776..bbc256915 100644 --- a/src/unk_text_util_2.c +++ b/src/unk_text_util_2.c @@ -15,86 +15,86 @@ u16 Font6Func(struct TextPrinter *textPrinter) u16 char_; struct TextPrinterSubStruct *sub; - sub = &textPrinter->sub_union.sub; + sub = &textPrinter->subUnion.sub; switch (textPrinter->state) { case 0: - if (gMain.heldKeys & (A_BUTTON | B_BUTTON) && sub->font_type_upper) + if (gMain.heldKeys & (A_BUTTON | B_BUTTON) && sub->hasPrintBeenSpedUp) { textPrinter->delayCounter = 0; } - if (textPrinter->delayCounter && textPrinter->text_speed) + if (textPrinter->delayCounter && textPrinter->textSpeed) { textPrinter->delayCounter --; - if (gTextFlags.flag_0 && gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (gTextFlags.canABSpeedUpPrint && gMain.newKeys & (A_BUTTON | B_BUTTON)) { - sub->font_type_upper = TRUE; + sub->hasPrintBeenSpedUp = TRUE; textPrinter->delayCounter = 0; } return 3; } - if (gTextFlags.flag_2) + if (gTextFlags.autoScroll) { textPrinter->delayCounter = 3; } else { - textPrinter->delayCounter = textPrinter->text_speed; + textPrinter->delayCounter = textPrinter->textSpeed; } - char_ = *textPrinter->subPrinter.current_text_offset ++; + char_ = *textPrinter->printerTemplate.currentChar++; switch (char_) { case EOS: return 1; case CHAR_NEWLINE: - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; - textPrinter->subPrinter.currentY += gFonts[textPrinter->subPrinter.fontId].maxLetterHeight + textPrinter->subPrinter.lineSpacing; + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentY += gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing; return 2; case PLACEHOLDER_BEGIN: - textPrinter->subPrinter.current_text_offset ++; + textPrinter->printerTemplate.currentChar++; return 2; case EXT_CTRL_CODE_BEGIN: - char_ = *textPrinter->subPrinter.current_text_offset ++; + char_ = *textPrinter->printerTemplate.currentChar++; switch (char_) { case 1: - textPrinter->subPrinter.fgColor = *textPrinter->subPrinter.current_text_offset ++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fgColor, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; case 2: - textPrinter->subPrinter.bgColor = *textPrinter->subPrinter.current_text_offset ++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fgColor, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + textPrinter->printerTemplate.bgColor = *textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; case 3: - textPrinter->subPrinter.shadowColor = *textPrinter->subPrinter.current_text_offset ++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fgColor, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + textPrinter->printerTemplate.shadowColor = *textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; case 4: - textPrinter->subPrinter.fgColor = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.bgColor = *++ textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.shadowColor = *++ textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset ++; + textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.bgColor = *++textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.shadowColor = *++textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fgColor, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; case 5: - textPrinter->subPrinter.current_text_offset ++; + textPrinter->printerTemplate.currentChar++; return 2; case 6: - sub->font_type = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset ++; + sub->glyphId = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; return 2; case 7: return 2; case 8: - textPrinter->delayCounter = *textPrinter->subPrinter.current_text_offset ++; + textPrinter->delayCounter = *textPrinter->printerTemplate.currentChar++; textPrinter->state = 6; return 2; case 9: textPrinter->state = 1; - if (gTextFlags.flag_2) + if (gTextFlags.autoScroll) { - sub->frames_visible_counter = 0; + sub->autoScrollDelay = 0; } return 3; case 10: @@ -102,19 +102,19 @@ u16 Font6Func(struct TextPrinter *textPrinter) return 3; case 11: case 16: - textPrinter->subPrinter.current_text_offset += 2; + textPrinter->printerTemplate.currentChar += 2; return 2; case 12: - char_ = *++textPrinter->subPrinter.current_text_offset; + char_ = *++textPrinter->printerTemplate.currentChar; break; case 13: - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x + *textPrinter->subPrinter.current_text_offset ++; + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x + *textPrinter->printerTemplate.currentChar++; return 2; case 14: - textPrinter->subPrinter.currentY = textPrinter->subPrinter.y + *textPrinter->subPrinter.current_text_offset ++; + textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y + *textPrinter->printerTemplate.currentChar++; return 2; case 15: - FillWindowPixelBuffer(textPrinter->subPrinter.windowId, textPrinter->subPrinter.bgColor | (textPrinter->subPrinter.bgColor << 4)); + FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, textPrinter->printerTemplate.bgColor | (textPrinter->printerTemplate.bgColor << 4)); return 2; } break; @@ -127,15 +127,15 @@ u16 Font6Func(struct TextPrinter *textPrinter) TextPrinterInitDownArrowCounters(textPrinter); return 3; case 0xF9: - char_ = *textPrinter->subPrinter.current_text_offset ++ | 0x100; + char_ = *textPrinter->printerTemplate.currentChar++| 0x100; break; case 0xF8: - textPrinter->subPrinter.current_text_offset ++; + textPrinter->printerTemplate.currentChar++; return 0; } DecompressGlyphFont6(char_); CopyGlyphToWindow(textPrinter); - textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80] + textPrinter->subPrinter.letterSpacing; + textPrinter->printerTemplate.currentX += gUnknown_03002F90.unk80 + textPrinter->printerTemplate.letterSpacing; return 0; case 1: if (TextPrinterWait(textPrinter)) @@ -146,9 +146,9 @@ u16 Font6Func(struct TextPrinter *textPrinter) case 2: if (TextPrinterWaitWithDownArrow(textPrinter)) { - FillWindowPixelBuffer(textPrinter->subPrinter.windowId, textPrinter->subPrinter.bgColor | (textPrinter->subPrinter.bgColor << 4)); - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; - textPrinter->subPrinter.currentY = textPrinter->subPrinter.y; + FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, textPrinter->printerTemplate.bgColor | (textPrinter->printerTemplate.bgColor << 4)); + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y; textPrinter->state = 0; } return 3; @@ -156,8 +156,8 @@ u16 Font6Func(struct TextPrinter *textPrinter) if (TextPrinterWaitWithDownArrow(textPrinter)) { TextPrinterClearDownArrow(textPrinter); - textPrinter->scrollDistance = gFonts[textPrinter->subPrinter.fontId].maxLetterHeight + textPrinter->subPrinter.lineSpacing; - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; + textPrinter->scrollDistance = gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing; + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; textPrinter->state = 4; } return 3; @@ -166,15 +166,15 @@ u16 Font6Func(struct TextPrinter *textPrinter) { if (textPrinter->scrollDistance < sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed]) { - ScrollWindow(textPrinter->subPrinter.windowId, 0, textPrinter->scrollDistance, textPrinter->subPrinter.bgColor | (textPrinter->subPrinter.bgColor << 4)); + ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, textPrinter->printerTemplate.bgColor | (textPrinter->printerTemplate.bgColor << 4)); textPrinter->scrollDistance = 0; } else { - ScrollWindow(textPrinter->subPrinter.windowId, 0, sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed], textPrinter->subPrinter.bgColor | (textPrinter->subPrinter.bgColor << 4)); + ScrollWindow(textPrinter->printerTemplate.windowId, 0, sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed], textPrinter->printerTemplate.bgColor | (textPrinter->printerTemplate.bgColor << 4)); textPrinter->scrollDistance -= sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed]; } - CopyWindowToVram(textPrinter->subPrinter.windowId, 2); + CopyWindowToVram(textPrinter->printerTemplate.windowId, 2); } else { @@ -206,12 +206,12 @@ static void DecompressGlyphFont6(u16 glyph) const u16 *glyphs; glyphs = sFont6BrailleGlyphs + 0x100 * (glyph / 8) + 0x10 * (glyph % 8); - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); - DecompressGlyphTile(glyphs + 0x88, (u16 *)(gUnknown_03002F90 + 0x60)); - gUnknown_03002F90[0x80] = 0x10; - gUnknown_03002F90[0x81] = 0x10; + 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; } u8 GetGlyphWidthFont6(void)