From 489f94a7b3717981d3d386e0150ff4097362c5d2 Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Wed, 19 Mar 2025 04:26:12 -0400 Subject: [PATCH 1/5] Verify input.c file boundary is correct --- src/input.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/input.c b/src/input.c index e2026d801..fcd037b06 100644 --- a/src/input.c +++ b/src/input.c @@ -2,14 +2,18 @@ #include "code_800C9CC.h" #include "input.h" -EWRAM_DATA Inputs gRealInputs = {0}; // GBA=20255F0 | NDS=20F5CC0 -static EWRAM_DATA UnusedInputStruct sUnusedInputsRelated = {0}; // 2025600 -static EWRAM_DATA u32 sUnusedScrambledInputJunk[3] = {0}; // 202562C -static EWRAM_DATA Inputs sBufferedInputs = {0}; // 2025638 -static EWRAM_DATA Inputs sCurrentInputs = {0}; // 2025648 -static EWRAM_DATA Inputs sPrevInputs = {0}; // 2025658 -static EWRAM_DATA InputTimers sInputTimers = {0}; // 2025668 +#define JUNK_INIT 0x4A14C1 +#define JUNK_UPDATE 0x54A1C41 +EWRAM_DATA Inputs gRealInputs = {0}; // GBA=20255F0 | NDS=20F5CC0 +static EWRAM_DATA UnusedInputStruct sUnusedInputsRelated = {0}; // GBA=2025600 | NDS=020F5CD0 +static EWRAM_DATA u32 sUnusedScrambledInputJunk[3] = {0}; // GBA=202562C | NDS=020F5C88 +static EWRAM_DATA Inputs sBufferedInputs = {0}; // GBA=2025638 | NDS=020F5C90 +static EWRAM_DATA Inputs sCurrentInputs = {0}; // GBA=2025648 | NDS=020F5CB0 +static EWRAM_DATA Inputs sPrevInputs = {0}; // GBA=2025658 | NDS=020F5CA0 +static EWRAM_DATA InputTimers sInputTimers = {0}; // GBA=2025668 | NDS=020F5C8C + +// arm9.bin::0200754C void InitInput(void) { gRealInputs.held = 0; @@ -22,7 +26,7 @@ void InitInput(void) sBufferedInputs.repeated = 0; sBufferedInputs.shortPress = 0; - sUnusedScrambledInputJunk[0] = 0x4A14C1; // seems like random keyboard mashing (see UpdateInput) + sUnusedScrambledInputJunk[0] = JUNK_INIT; sUnusedInputsRelated.unk20 = 0; sUnusedInputsRelated.unk0 = 0xFFFF; // probably a mask @@ -46,6 +50,7 @@ void InitInput(void) sInputTimers.holdTimerR = 0; } +// arm9.bin::02007200 void LoadBufferedInputs(void) { gRealInputs = sBufferedInputs; @@ -70,8 +75,14 @@ void LoadBufferedInputs(void) sUnusedInputsRelated.unk28 = 0; sUnusedInputsRelated.unk29 = 0; + + // This is way different in blue } +// TODO: 2 funcs in blue. Not sure which they are in red, if they exist +// arm9.bin::020071CC +// arm9.bin::02007198 + UNUSED static bool8 sub_80048B8(void) { return FALSE; @@ -102,6 +113,7 @@ UNUSED static bool8 sub_80048CC(void) return FALSE; } +// arm9.bin::0200715C void ResetRepeatTimers(void) { gRealInputs.repeated = 0; @@ -111,6 +123,7 @@ void ResetRepeatTimers(void) sInputTimers.holdTimerR = 999; } +// arm9.bin::02007130 void UnpressButtons(void) { gRealInputs.pressed = 0; @@ -118,6 +131,7 @@ void UnpressButtons(void) sCurrentInputs.pressed = 0; } +// arm9.bin::020070D4 void ResetUnusedInputStruct(void) { sUnusedInputsRelated.unk20 = 5; @@ -139,6 +153,7 @@ void ResetUnusedInputStruct(void) sUnusedInputsRelated.unk29 = 0; } +// arm9.bin::02006EC0 void UpdateInput(void) { sPrevInputs = sCurrentInputs; @@ -162,9 +177,8 @@ void UpdateInput(void) sCurrentInputs.heldDpad = 0; } - if (sCurrentInputs.repeatTimerDpad == 1) { + if (sCurrentInputs.repeatTimerDpad == 1) sCurrentInputs.repeated = (sCurrentInputs.heldDpad & DPAD_ANY) | sCurrentInputs.pressed; - } else if (sCurrentInputs.repeatTimerDpad == 48) { sCurrentInputs.repeatTimerDpad = 43; sCurrentInputs.repeated = (sCurrentInputs.heldDpad & DPAD_ANY) | sCurrentInputs.pressed; @@ -201,5 +215,5 @@ void UpdateInput(void) sBufferedInputs.repeated |= sCurrentInputs.repeated; sBufferedInputs.shortPress |= sCurrentInputs.shortPress; - sUnusedScrambledInputJunk[0] *= sCurrentInputs.held | 0x54A1C41; // very similar to odd constant in InitInput - probably keymashing -} \ No newline at end of file + sUnusedScrambledInputJunk[0] *= sCurrentInputs.held | JUNK_UPDATE; +} From 10cbb42719a953c8782da9a5c18c71398475b8e6 Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Fri, 21 Mar 2025 23:48:05 -0400 Subject: [PATCH 2/5] Split text.c and decompress.c --- asm/code_8023868.s | 2 +- asm/code_803B050.s | 2 +- data/data.s | 2 +- include/code_8002774.h | 7 +- include/code_800558C.h | 31 - include/code_8009804.h | 6 +- include/code_800E9A8.h | 2 +- include/code_802DB28.h | 5 +- include/debug.h | 24 +- include/decompress.h | 26 - include/decompress_3.h | 11 + include/decompress_at.h | 10 + include/decompress_sir.h | 16 + include/event_flag.h | 2 +- include/felicity_bank.h | 7 +- include/gba/defines.h | 3 +- include/gba/types.h | 2 +- include/gulpin_shop.h | 9 +- include/gulpin_shop_801FB50.h | 6 +- include/input.h | 46 +- include/kangaskhan_storage1.h | 6 +- include/kecleon_bros1.h | 6 +- include/makuhita_dojo1.h | 6 +- include/post_office_guide1.h | 4 +- include/rescue_password_menu.h | 1 - include/save_write.h | 12 - include/sprite.h | 29 +- include/string_format.h | 35 +- include/structs/axdata.h | 37 +- include/structs/dungeon_entity.h | 3 +- include/structs/str_3001B64.h | 6 +- include/structs/str_dungeon.h | 1 - include/structs/str_mon_portrait.h | 33 + include/structs/str_text.h | 34 +- include/structs/struct_sub80095e4.h | 4 +- include/text.h | 104 - include/text_1.h | 65 + include/text_2.h | 24 + include/text_3.h | 41 + include/text_4.h | 9 + include/thank_you_wonder_mail.h | 4 +- include/wigglytuff_shop3.h | 6 +- include/wonder_mail.h | 4 +- ld_script.txt | 14 +- src/adventure_log.c | 14 +- src/adventure_log_menu.c | 4 +- src/code_8002774.c | 124 +- src/code_8004AA0.c | 3 +- src/code_800558C.c | 195 +- src/code_8009804.c | 7 +- src/code_800C9CC.c | 2 + src/code_800D090.c | 1 + src/code_800DAC0.c | 5 +- src/code_800ED38.c | 6 +- src/code_800F958.c | 7 +- src/code_80118A4.c | 12 +- src/code_8012A18.c | 2 +- src/code_8012A18_1.c | 8 +- src/code_8015080.c | 15 +- src/code_801602C.c | 6 +- src/code_801B3C0.c | 9 +- src/code_801B60C.c | 14 +- src/code_801C8C4.c | 13 +- src/code_801D014.c | 6 +- src/code_801D9E4.c | 15 +- src/code_801EE10.c | 13 +- src/code_801F428.c | 10 +- src/code_801F808.c | 9 +- src/code_80227B8.c | 12 +- src/code_8023144.c | 15 +- src/code_8024458.c | 6 +- src/code_802DB28.c | 10 +- src/code_802DE84.c | 4 +- src/code_8031D70.c | 14 +- src/code_803D110.c | 3 +- src/code_803E46C.c | 10 +- src/code_803E724.c | 54 +- src/code_8040094.c | 4 +- src/code_8040094_1.c | 8 +- src/code_8041AD0.c | 18 +- src/code_804267C.c | 10 +- src/code_8042B34.c | 94 +- src/code_8066D04.c | 3 +- src/code_8069E0C.c | 48 +- src/code_806CD90.c | 53 +- src/code_8072F3C.c | 8 +- src/code_807E5AC.c | 1 + src/code_808333C.c | 1 + src/code_80861A8.c | 4 +- src/code_809447C.c | 7 +- src/code_80972F4.c | 1 + src/code_8097DD0.c | 2 +- src/code_8099360.c | 11 +- src/code_809A560.c | 50 +- src/code_809D148.c | 5 +- src/code_80A7714.c | 6 +- src/cpu.c | 3 + src/credits1.c | 5 +- src/data/decompress.h | 1 - src/data/decompress_at.h | 1 + src/data/text.h | 76 + src/debug.c | 133 +- src/debug_menu1.c | 4 +- src/debug_menu2.c | 7 +- src/debug_menu3.c | 6 +- src/debug_menu4.c | 10 +- src/decompress_3.c | 34 + src/{decompress.c => decompress_at.c} | 106 +- src/decompress_sir.c | 47 + src/ds_menus.c | 2 +- src/dungeon_items.c | 1 + src/dungeon_main.c | 99 +- src/dungeon_map.c | 36 +- src/dungeon_map_access.c | 4 +- src/dungeon_menu_items.c | 2 +- src/dungeon_menu_moves.c | 52 +- src/dungeon_menu_others.c | 32 +- src/dungeon_menu_recruitment.c | 16 +- src/dungeon_menu_stairs.c | 23 +- src/dungeon_menu_team.c | 78 +- src/dungeon_menu_tile.c | 25 +- src/dungeon_message.c | 61 +- src/dungeon_misc.c | 2 - src/dungeon_move.c | 70 +- src/dungeon_submenu.c | 5 +- src/event_flag.c | 55 +- src/felicity_bank.c | 10 +- src/file_system.c | 2 +- src/friend_area_action_menu.c | 11 +- src/friend_areas_map.c | 5 +- src/friend_areas_map_util.c | 6 +- src/friend_list_menu.c | 13 +- src/friend_rescue.c | 56 +- src/ground_main.c | 1 + src/ground_script.c | 23 +- src/ground_sprite.c | 2 +- src/gulpin_shop.c | 10 +- src/gulpin_shop_801FB50.c | 10 +- src/hints_menu1.c | 7 +- src/hints_menu2.c | 6 +- src/iq_skill_info_menu.c | 8 +- src/iq_skill_list_menu.c | 9 +- src/iq_skill_menu.c | 8 +- src/items.c | 8 +- src/kangaskhan_storage1.c | 9 +- src/kangaskhan_storage2.c | 7 +- src/kecleon_bros1.c | 8 +- src/kecleon_bros2.c | 9 +- src/kecleon_bros3.c | 9 +- src/kecleon_bros4.c | 9 +- src/load_screen.c | 18 +- src/luminous_cave.c | 12 +- src/mailbox.c | 18 +- src/main.c | 2 +- src/main_loops.c | 22 +- src/main_menu1.c | 8 +- src/main_menu2.c | 4 +- src/makuhita_dojo1.c | 10 +- src/makuhita_dojo2.c | 9 +- src/memory.c | 148 +- src/menu_input.c | 16 +- src/mission_reward.c | 16 +- src/moves.c | 3 +- src/options_menu1.c | 6 +- src/options_menu2.c | 8 +- src/other_menus1.c | 11 +- src/other_random.c | 5 +- src/party_list_menu.c | 11 +- src/pelipper_board.c | 27 +- src/personality_test1.c | 14 +- src/personality_test2.c | 9 +- src/pokemon.c | 6 +- src/pokemon_3.c | 18 +- src/pokemon_mail.c | 6 +- src/pokemon_news1.c | 11 +- src/pokemon_news2.c | 11 +- src/pokemon_news3.c | 14 +- src/post_office_guide1.c | 10 +- src/post_office_guide2.c | 9 +- src/reg_control.c | 2 +- src/rescue_password_menu.c | 11 +- src/save_menu.c | 5 +- src/save_write.c | 18 +- src/sprite.c | 283 +- src/string_format.c | 38 +- src/text.c | 3520 ------------------------- src/text_1.c | 1429 ++++++++++ src/text_2.c | 1291 +++++++++ src/text_3.c | 546 ++++ src/text_4.c | 263 ++ src/thank_you_wonder_mail.c | 24 +- src/trade_items_menu.c | 15 +- src/unk_menu_203B360.c | 7 +- src/wigglytuff_shop1.c | 7 +- src/wigglytuff_shop2.c | 6 +- src/wigglytuff_shop3.c | 8 +- src/wonder_mail.c | 28 +- src/wonder_mail_2.c | 12 +- src/wonder_mail_3_mid.c | 18 +- src/wonder_mail_4.c | 13 +- src/wonder_mail_5.c | 11 +- src/wonder_mail_6.c | 12 +- src/wonder_mail_802C10C.c | 8 +- src/wonder_mail_802C4C8.c | 11 +- src/wonder_mail_802C860.c | 6 +- src/wonder_mail_802CDD4.c | 13 +- src/wonder_mail_802D098.c | 10 +- src/wonder_mail_main_menu.c | 22 +- src/world_map.c | 7 +- sym_ewram.txt | 4 +- sym_ewram_init.txt | 2 +- sym_iwram.txt | 2 +- sym_iwram_init.txt | 2 +- 213 files changed, 5700 insertions(+), 5327 deletions(-) delete mode 100644 include/decompress.h create mode 100644 include/decompress_3.h create mode 100644 include/decompress_at.h create mode 100644 include/decompress_sir.h create mode 100644 include/structs/str_mon_portrait.h delete mode 100644 include/text.h create mode 100644 include/text_1.h create mode 100644 include/text_2.h create mode 100644 include/text_3.h create mode 100644 include/text_4.h delete mode 100644 src/data/decompress.h create mode 100644 src/data/decompress_at.h create mode 100644 src/data/text.h create mode 100644 src/decompress_3.c rename src/{decompress.c => decompress_at.c} (86%) create mode 100644 src/decompress_sir.c delete mode 100644 src/text.c create mode 100644 src/text_1.c create mode 100644 src/text_2.c create mode 100644 src/text_3.c create mode 100644 src/text_4.c diff --git a/asm/code_8023868.s b/asm/code_8023868.s index 3f2e8d83d..b88ed6dba 100644 --- a/asm/code_8023868.s +++ b/asm/code_8023868.s @@ -170,7 +170,7 @@ _0802398E: adds r1, r0, r1 str r1, [r2] adds r0, r6 - bl RestoreUnkTextStruct_8006518 + bl RestoreSavedWindows ldr r1, [r5] adds r4, r1, r4 ldr r2, [r4] diff --git a/asm/code_803B050.s b/asm/code_803B050.s index 47d122d7c..da56cba09 100644 --- a/asm/code_803B050.s +++ b/asm/code_803B050.s @@ -20,7 +20,7 @@ sub_803B050: adds r1, 0x84 str r1, [r0, 0x38] adds r0, 0x3C - bl RestoreUnkTextStruct_8006518 + bl RestoreSavedWindows ldr r1, [r4] ldr r2, [r1, 0x34] lsls r0, r2, 1 diff --git a/data/data.s b/data/data.s index 527bfa2e1..39482338e 100644 --- a/data/data.s +++ b/data/data.s @@ -1011,7 +1011,7 @@ gUnknown_80B7DF8: .fill 8, 1, 0 .global gVectorDirections -gVectorDirections: @ 80B7E3C +gVectorDirections: @ GBA=080B7E3C | NDS=0208772C .4byte 0, 1 @N .4byte 1, 1 @NE .4byte 1, 0 @E diff --git a/include/code_8002774.h b/include/code_8002774.h index 5cd4d592b..985bb3a56 100644 --- a/include/code_8002774.h +++ b/include/code_8002774.h @@ -3,13 +3,12 @@ #include "structs/str_position.h" +void sub_800290C(PixelPos *param_1, s32 param_2); +void sub_8002934(PixelPos *param_1, PixelPos *param_2, PixelPos *param_3, s32 param_4, s32 param_5); s32 sub_8002A70(s32 a0, s32 a1, s32 a2); s32 sub_8002B04(s32, s32); -s32 VecDirection8Sign(PixelPos *param_1); -s32 VecDirection4SignYX(PixelPos *param_1); s8 VecDirection8Radial(PixelPos *param_1); -s8 VecDirection4Radial(PixelPos *param_1); s8 SizedDeltaDirection4(const PixelPos *r0, const PixelPos *r1, const PixelPos *r2, const PixelPos *r3); s8 SizedDeltaDirection8(const PixelPos *r0, const PixelPos *r1, const PixelPos *r2, const PixelPos *r3); -#endif +#endif // GUARD_CODE_8002774_H diff --git a/include/code_800558C.h b/include/code_800558C.h index fbf51943e..807ea2d80 100644 --- a/include/code_800558C.h +++ b/include/code_800558C.h @@ -1,43 +1,12 @@ #ifndef GUARD_CODE_800558C_H #define GUARD_CODE_800558C_H -#include "structs/axdata.h" -#include "structs/rgb.h" - -typedef struct Palette256 -{ - RGB pal[256]; -} Palette256; - -// size: 0x20 -struct EfoFileData -{ - /* 0x0 */ ax_pose **poses; // TODO: Verify if these fields' names are actually valid - /* 0x4 */ ax_anim ***animations; - /* 0x8 */ s32 animCount; - /* 0xC */ void *spriteData; // ? - /* 0x10 */ Palette256 *unk10; // ? - /* 0x14 */ const u32 *tiles; - /* 0x18 */ const RGB *pal; - /* 0x1C */ s32 tileCount; -}; - extern bool8 gUnknown_2026E38; extern u32 *gUnknown_2026E3C; extern s16 gUnknown_2026E4E; extern s16 *gUnknown_203B078; -void nullsub_7(s16 *); -void nullsub_8(u32); -void nullsub_9(void); -void nullsub_10(bool8); -void nullsub_12(void); -void nullsub_13(void); -void nullsub_14(void); -void sub_8005610(OpenedFile *, s32, s32, const RGB *); -const RGB *sub_8005674(const struct EfoFileData *a0, s32 vramIdx); -void sub_8005770(s32, const RGB *color, s32, const RGB *ramp); void sub_80057E8(void); void sub_8005838(s32 *, u8 kind); void sub_80060EC(void); diff --git a/include/code_8009804.h b/include/code_8009804.h index 7f868fd5f..62c759ec1 100644 --- a/include/code_8009804.h +++ b/include/code_8009804.h @@ -1,7 +1,7 @@ #ifndef GUARD_CODE_8009804_H #define GUARD_CODE_8009804_H -#include "structs/rgb.h" +#include "structs/axdata.h" extern RGB gFontPalette[128]; @@ -16,11 +16,11 @@ struct unkStruct_202D240 struct unkStruct_8009A1C_ptr { u8 fill0; - struct EfoFileData *ptr; + EfoFileData *ptr; }; void vram_related_8009804(void); -void sub_8009A1C(const struct EfoFileData *r0, u32 palId, u32 vramDstOffset, u32 r3); +void sub_8009A1C(const EfoFileData *r0, u32 palId, u32 vramDstOffset, u32 r3); void InitFontPalette(void); void sub_80098A0(void); void sub_80098BC(u32 *, const u32 *, u32); diff --git a/include/code_800E9A8.h b/include/code_800E9A8.h index 395a7c4b2..de569a2d1 100644 --- a/include/code_800E9A8.h +++ b/include/code_800E9A8.h @@ -27,7 +27,7 @@ struct unkStruct_203B0CC_sub s32 unk50; u8 unk54; u8 fill55[0x58 - 0x55]; - struct axObject unk58; + axObject unk58; u8 fillA4[0xB8 - 0xA4]; u32 unkB8; u8 fillBC[0xCC - 0xBC]; diff --git a/include/code_802DB28.h b/include/code_802DB28.h index ca94c97a7..a44853f9a 100644 --- a/include/code_802DB28.h +++ b/include/code_802DB28.h @@ -1,10 +1,9 @@ #ifndef GUARD_CODE_802DB28_H #define GUARD_CODE_802DB28_H -#include "file_system.h" +#include "structs/str_mon_portrait.h" #include "structs/str_text.h" #include "structs/str_wonder_mail.h" -#include "string_format.h" // size: 0xA8 struct unkStruct_203B2FC @@ -14,7 +13,7 @@ struct unkStruct_203B2FC unkStruct_802F204 unk8; /* 0x30 */ u8 jobSlotIndex; /* 0x34 */ WonderMail *jobInfo; - /* 0x38 */ struct MonPortraitMsg monPortrait; + /* 0x38 */ MonPortraitMsg monPortrait; WindowTemplates unk48; }; diff --git a/include/debug.h b/include/debug.h index 34329236b..f7a825c97 100644 --- a/include/debug.h +++ b/include/debug.h @@ -9,30 +9,10 @@ typedef struct DebugLocation /* 0x8 */ const u8 *func; } DebugLocation; +void FatalError(const DebugLocation *debug, const char *text, ...) NORETURN; void Log(u8 num, const u8 *text, ...); void NDS_DebugInit(void); void nullsub_25(void); -void nullsub_26(void); -void nullsub_27(void); -void nullsub_28(void); -void nullsub_29(void); -void nullsub_30(void); -void nullsub_31(void); -void nullsub_32(void); -void nullsub_137(void); -void nullsub_199(void); -void PrintFuncFileLine(u8 *buf, const DebugLocation *loc, const u8 *prefix); -void PrintMessageWithFuncFileLine(u8 *buffer, const DebugLocation *debug, const u8 *text, ...); -void sub_8011B08(void); -void sub_8011B88(const u8 *text, ...); -s8 ScriptLoggingEnabled(bool8); -u32 sub_8011BA8(void); -const u8 *sub_8011BAC(void); -void sub_8011B14(void); -u8 sub_8011B20(void); -u8 sub_8011B3C(void); -void sub_8011BC8(u32, u32, u32, ...); -void UnusedHang(void); -void FatalError(const DebugLocation *debug, const char *text, ...) __attribute__((noreturn)); +bool8 ScriptLoggingEnabled(bool8); #endif // GUARD_DEBUG_H diff --git a/include/decompress.h b/include/decompress.h deleted file mode 100644 index 05f3aef98..000000000 --- a/include/decompress.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef GUARD_DECOMPRESS_H -#define GUARD_DECOMPRESS_H - -#include "file_system.h" - -// size: 0x8 -typedef struct SiroArchive -{ - /* 0x0 */ u32 magic; - /* 0x4 */ const void *data; -} SiroArchive; - -u32 DecompressAT(u8 *dst, s32 dstLen, const u8 *src); -u32 DecompressATFile(void *dst, s32 dstLen, OpenedFile *file); -u32 DecompressATGlobalFile(u32 *result, s32 resultLength, OpenedFile *file); -const void *GetSiroPtr(OpenedFile *openedFile); -void nullsub_16(void); - -// Returns FALSE if the ascii chars in both strings match, ignoring uppercase/lowercase differences. -// "YeS\0" and "yEs\0" => FALSE -// "Yes\0" and "Tes\0" => TRUE -// "Yes\0" and "y\0" => TRUE -// "T\0" and "Tes\0" => TRUE -bool8 StrsDifferent_IgnoreCase(const char *strA, const char *strB, s32 maxLen); - -#endif // GUARD_DECOMPRESS_H diff --git a/include/decompress_3.h b/include/decompress_3.h new file mode 100644 index 000000000..a12394366 --- /dev/null +++ b/include/decompress_3.h @@ -0,0 +1,11 @@ +#ifndef GUARD_DECOMPRESS_3_H +#define GUARD_DECOMPRESS_3_H + +// Returns FALSE if the ascii chars in both strings match, ignoring uppercase/lowercase differences. +// "YeS\0" and "yEs\0" => FALSE +// "Yes\0" and "Tes\0" => TRUE +// "Yes\0" and "y\0" => TRUE +// "T\0" and "Tes\0" => TRUE +bool8 StrsDifferent_IgnoreCase(const char *strA, const char *strB, s32 maxLen); + +#endif // GUARD_DECOMPRESS_3_H diff --git a/include/decompress_at.h b/include/decompress_at.h new file mode 100644 index 000000000..c0f8b087d --- /dev/null +++ b/include/decompress_at.h @@ -0,0 +1,10 @@ +#ifndef GUARD_DECOMPRESS_AT_H +#define GUARD_DECOMPRESS_AT_H + +#include "file_system.h" + +u32 DecompressAT(u8 *dst, s32 dstLen, const u8 *src); +u32 DecompressATFile(void *dst, s32 dstLen, OpenedFile *file); +u32 DecompressATGlobalFile(u32 *result, s32 resultLength, OpenedFile *file); + +#endif // GUARD_DECOMPRESS_AT_H diff --git a/include/decompress_sir.h b/include/decompress_sir.h new file mode 100644 index 000000000..7835d31af --- /dev/null +++ b/include/decompress_sir.h @@ -0,0 +1,16 @@ +#ifndef GUARD_DECOMPRESS_SIR_H +#define GUARD_DECOMPRESS_SIR_H + +#include "file_system.h" + +// size: 0x8 +typedef struct SiroArchive +{ + /* 0x0 */ u32 magic; + /* 0x4 */ const void *data; +} SiroArchive; + +const void *GetSiroPtr(OpenedFile *openedFile); +void nullsub_16(void); + +#endif // GUARD_DECOMPRESS_SIR_H diff --git a/include/event_flag.h b/include/event_flag.h index 1c4d0c98c..b68a3c828 100644 --- a/include/event_flag.h +++ b/include/event_flag.h @@ -171,7 +171,7 @@ bool8 SaveGlobalScriptVars(void *r0); bool8 RestoreGlobalScriptVars(u8 *r0); // .rodata -extern struct ScriptVarInfo gScriptVarInfo[]; +extern struct ScriptVarInfo gScriptVarInfo[]; // NDS=0210FAC4 // EWRAM extern u8 gScriptVarBuffer[0x400]; diff --git a/include/felicity_bank.h b/include/felicity_bank.h index 7bf8b85b9..a676364b4 100644 --- a/include/felicity_bank.h +++ b/include/felicity_bank.h @@ -1,10 +1,9 @@ #ifndef GUARD_FELICITY_BANK_H #define GUARD_FELICITY_BANK_H -#include "file_system.h" #include "structs/menu.h" +#include "structs/str_mon_portrait.h" #include "structs/str_text.h" -#include "string_format.h" #define FELICITY_BANK_ACTION_WITHDRAW 0 #define FELICITY_BANK_ACTION_DEPOSIT 1 @@ -20,8 +19,8 @@ typedef struct FelicityBankWork MenuItem unk14[8]; u16 unk54[8]; unkStructFor8013AA0 unk64; - /* 0x94 */ struct MonPortraitMsg monPortrait; - struct MonPortraitMsg *monPortraitPtr; + /* 0x94 */ MonPortraitMsg monPortrait; + MonPortraitMsg *monPortraitPtr; WindowTemplates unkA8; } FelicityBankWork; diff --git a/include/gba/defines.h b/include/gba/defines.h index e00d5c0ee..5e1560240 100644 --- a/include/gba/defines.h +++ b/include/gba/defines.h @@ -13,7 +13,8 @@ #define IWRAM_INIT __attribute__((section("iwram_init"))) #define UNUSED __attribute__((unused)) #define NAKED __attribute__((naked)) - +#define NORETURN __attribute__((noreturn)) +#define PACKED __attribute__((packed)) #define ALIGNED(n) __attribute__((aligned(n))) #define SOUND_INFO_PTR (*(struct SoundInfo **)0x3007FF0) diff --git a/include/gba/types.h b/include/gba/types.h index 480619d21..25bd24550 100644 --- a/include/gba/types.h +++ b/include/gba/types.h @@ -34,7 +34,7 @@ struct PlttData u16 g:5; // green u16 b:5; // blue u16 unused_15:1; -} /*__attribute__((packed))*/; +} /*PACKED*/; struct OamData { diff --git a/include/gulpin_shop.h b/include/gulpin_shop.h index fb798ae74..a4829efa3 100644 --- a/include/gulpin_shop.h +++ b/include/gulpin_shop.h @@ -1,11 +1,10 @@ #ifndef GUARD_GULPIN_SHOP_H #define GUARD_GULPIN_SHOP_H -#include "file_system.h" #include "structs/menu.h" -#include "structs/str_text.h" +#include "structs/str_mon_portrait.h" #include "structs/str_moves.h" -#include "string_format.h" +#include "structs/str_text.h" // size: 0x18C typedef struct GulpinShopWork @@ -25,8 +24,8 @@ typedef struct GulpinShopWork u16 unk68[8]; MenuStruct unk78; u8 fillC8[0x118 - 0xC8]; - /* 0x118 */ struct MonPortraitMsg monPortrait; - struct MonPortraitMsg *monPortraitPtr; + /* 0x118 */ MonPortraitMsg monPortrait; + MonPortraitMsg *monPortraitPtr; WindowTemplates unk12C; } GulpinShopWork; diff --git a/include/gulpin_shop_801FB50.h b/include/gulpin_shop_801FB50.h index a141f018d..f087c3ac8 100644 --- a/include/gulpin_shop_801FB50.h +++ b/include/gulpin_shop_801FB50.h @@ -2,9 +2,9 @@ #define GUARD_GULPIN_SHOP_801FB50_H #include "constants/move.h" -#include "file_system.h" #include "structs/menu.h" #include "pokemon.h" +#include "structs/str_mon_portrait.h" #include "structs/str_text.h" // size: 0x1E0 @@ -33,8 +33,8 @@ typedef struct unkStruct_203B27C u16 unkBC[8]; MenuStruct unkCC; u8 fill11C[0x16C - 0x11C]; - /* 0x16C */ struct MonPortraitMsg monPortrait; - struct MonPortraitMsg *monPortraitPtr; + /* 0x16C */ MonPortraitMsg monPortrait; + MonPortraitMsg *monPortraitPtr; WindowTemplates unk180; } unkStruct_203B27C; diff --git a/include/input.h b/include/input.h index 2029913a8..f6295a3dc 100644 --- a/include/input.h +++ b/include/input.h @@ -17,34 +17,34 @@ typedef struct InputTimers { /* 0x0 */ s16 holdTimerB; /* 0x2 */ s16 holdTimerR; - u16 unk4; - u16 unk6; + /* 0x4 */ u16 unk4; + /* 0x6 */ u16 unk6; } InputTimers; // size: 0x2C typedef struct UnusedInputStruct { - u16 unk0; - u16 unk2; - u16 unk4; - u16 unk6; - u16 unk8; - u16 unkA; - u16 unkC; - u16 unkE; - u16 unk10; - u16 unk12; - u16 unk14; - u16 unk16; - u16 unk18; - u16 unk1A; - u16 unk1C; - u16 unk1E; - u32 unk20; - u16 unk24; - u16 unk26; - u8 unk28; - u8 unk29; + /* 0x0 */ u16 unk0; + /* 0x2 */ u16 unk2; + /* 0x4 */ u16 unk4; + /* 0x6 */ u16 unk6; + /* 0x8 */ u16 unk8; + /* 0xA */ u16 unkA; + /* 0xC */ u16 unkC; + /* 0xE */ u16 unkE; + /* 0x10 */ u16 unk10; + /* 0x12 */ u16 unk12; + /* 0x14 */ u16 unk14; + /* 0x16 */ u16 unk16; + /* 0x18 */ u16 unk18; + /* 0x1A */ u16 unk1A; + /* 0x1C */ u16 unk1C; + /* 0x1E */ u16 unk1E; + /* 0x20 */ u32 unk20; + /* 0x24 */ u16 unk24; + /* 0x26 */ u16 unk26; + /* 0x28 */ u8 unk28; + /* 0x29 */ u8 unk29; } UnusedInputStruct; extern Inputs gRealInputs; diff --git a/include/kangaskhan_storage1.h b/include/kangaskhan_storage1.h index dbaf17aee..67bdca81a 100644 --- a/include/kangaskhan_storage1.h +++ b/include/kangaskhan_storage1.h @@ -1,9 +1,9 @@ #ifndef GUARD_KANGASKHAN_STORAGE1_H #define GUARD_KANGASKHAN_STORAGE1_H -#include "file_system.h" #include "structs/menu.h" #include "structs/str_items.h" +#include "structs/str_mon_portrait.h" #include "structs/str_text.h" enum KangaskhanStorageStates @@ -45,8 +45,8 @@ struct KangaskhanStorageWork u16 unk4C[5]; MenuStruct unk58; unkStructFor8013AA0 unkA8; - /* 0xD8 */ struct MonPortraitMsg monPortrait; - struct MonPortraitMsg *monPortraitPtr; + /* 0xD8 */ MonPortraitMsg monPortrait; + MonPortraitMsg *monPortraitPtr; WindowTemplates unkEC; }; diff --git a/include/kecleon_bros1.h b/include/kecleon_bros1.h index 5219dcebb..688143194 100644 --- a/include/kecleon_bros1.h +++ b/include/kecleon_bros1.h @@ -1,9 +1,9 @@ #ifndef GUARD_KECLEON_BROS1_H #define GUARD_KECLEON_BROS1_H -#include "file_system.h" #include "items.h" #include "structs/menu.h" +#include "structs/str_mon_portrait.h" #include "structs/str_text.h" enum KecleonStoreStates @@ -63,8 +63,8 @@ typedef struct KecleonBrosWork1 /* 0x34 */ MenuItem menuItems[8]; u16 unk74[8]; /* 0x84 */ MenuStruct menu; - /* 0xD4 */ struct MonPortraitMsg monPortrait; - struct MonPortraitMsg *monPortraitPtr; + /* 0xD4 */ MonPortraitMsg monPortrait; + MonPortraitMsg *monPortraitPtr; WindowTemplates unkE8; } KecleonBrosWork1; diff --git a/include/makuhita_dojo1.h b/include/makuhita_dojo1.h index 3fc978859..56fe2932d 100644 --- a/include/makuhita_dojo1.h +++ b/include/makuhita_dojo1.h @@ -1,8 +1,8 @@ #ifndef GUARD_MAKUHITA_DOJO1_H #define GUARD_MAKUHITA_DOJO1_H -#include "file_system.h" #include "structs/menu.h" +#include "structs/str_mon_portrait.h" #include "structs/str_text.h" enum MakuhitaDojoInitMode @@ -28,8 +28,8 @@ typedef struct MakuhitaDojoWork1 /* 0x14 */ s32 menuAction; MenuItem unk18[4]; u8 fill38[0x58 - 0x38]; - /* 0x58 */ struct MonPortraitMsg monPortrait; - struct MonPortraitMsg *monPortraitPtr; + /* 0x58 */ MonPortraitMsg monPortrait; + MonPortraitMsg *monPortraitPtr; WindowTemplates unk6C; } MakuhitaDojoWork1; diff --git a/include/post_office_guide1.h b/include/post_office_guide1.h index 87be1ab38..59c9ac92f 100644 --- a/include/post_office_guide1.h +++ b/include/post_office_guide1.h @@ -1,14 +1,14 @@ #ifndef GUARD_POST_OFFICE_GUIDE1_H #define GUARD_POST_OFFICE_GUIDE1_H -#include "file_system.h" +#include "structs/str_mon_portrait.h" // size: 0x18 typedef struct PostOfficeWork { /* 0x0 */ u8 state; /* 0x4 */ s32 currMenuChoice; - /* 0x8 */ struct MonPortraitMsg monPortrait; + /* 0x8 */ MonPortraitMsg monPortrait; } PostOfficeWork; void CleanHelperPelipper(void); diff --git a/include/rescue_password_menu.h b/include/rescue_password_menu.h index e7c58b5cc..0a56dd0a9 100644 --- a/include/rescue_password_menu.h +++ b/include/rescue_password_menu.h @@ -2,7 +2,6 @@ #define GUARD_RESCUE_PASSWORD_MENU_H #include "structs/menu.h" -#include "sprite.h" #include "structs/str_text.h" // Similar to unkStruct_203B360 diff --git a/include/save_write.h b/include/save_write.h index 80d0e76c1..87aaf8b6e 100644 --- a/include/save_write.h +++ b/include/save_write.h @@ -1,18 +1,6 @@ #ifndef GUARD_SAVE_WRITE_H #define GUARD_SAVE_WRITE_H -#include "file_system.h" - -// size: 0x20 -typedef struct SavePakWrite -{ - /* 0x0 */ u32 state; - s32 unk4; - /* 0x8 */ u32 saveStatus; - /* 0xC */ struct MonPortraitMsg monPortrait; - /* 0x1C */ u16 pokeID; -} SavePakWrite; - void FinishWriteSavePak(void); u32 GetSavePakStatus(void); void PrepareSavePakWrite(s16 pokemonID); diff --git a/include/sprite.h b/include/sprite.h index 674802db1..ca132e295 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -28,20 +28,33 @@ typedef struct unkStruct_20266B0 /* 0x8 */ void *dest; } unkStruct_20266B0; -void AddSprite(SpriteOAM *, s32, UnkSpriteMem *, unkStruct_2039DB0 *); +void AddAxSprite(ax_pose *, axdata1 *, UnkSpriteMem *, unkStruct_2039DB0 *spriteMasks); +void AddSprite(SpriteOAM *, s32, UnkSpriteMem *, unkStruct_2039DB0 *spriteMasks); +void AxResInit(axdata *, axmain *, u32, u32 direction, u32, u32 spriteAnimIndex, bool8); +void AxResInitFile(axdata *, OpenedFile *, u32, u32, u32, u32 spriteAnimIndex, bool8); +void AxResInitUnorientedFile(axdata *, OpenedFile *, u32, u32, u32 spriteAnimIndex, bool8); void BlinkSavingIcon(void); void CopySpritesToOam(void); +void DoAxFrame_800558C(axdata *, s32 spriteX, s32 spriteY, u32, u32 paletteNum, unkStruct_2039DB0 *spriteMasks); void InitSprites(void); +void nullsub_7(s16 *); +void nullsub_8(u32); +void nullsub_9(void); +void nullsub_10(bool8); +void nullsub_11(SpriteOAM *, s32, UnkSpriteMem *, unkStruct_2039DB0 *); +void nullsub_12(void); +void nullsub_13(void); +void nullsub_14(void); void ResetSprites(bool8); -void SetSavingIconCoords(DungeonPos *); +void RunAxAnimationFrame(axdata *); +void SetSavingIconCoords(DungeonPos *pos); void sub_8004E8C(unkStruct_2039DB0 *); void sub_8005180(void); void sub_8005304(void); -void sub_800533C(ax_pose **, UnkSpriteMem **, axdata1 *, unkStruct_2039DB0 *, bool8); -void AxResInitFile(axdata *, OpenedFile *, u32, u32, u32, u32, bool8); -void AxResInit(axdata *, axmain *, u32, u32, u32, u32, bool8); -void AxResInitUnorientedFile(axdata *, OpenedFile *, u32, u32, u32, bool8); -void RunAxAnimationFrame(struct axdata *); -void DoAxFrame_800558C(struct axdata *a0, s32 spriteX, s32 spriteY, u32 a3, u32 paletteNum, unkStruct_2039DB0 *spriteMasks); +void sub_8005610(OpenedFile *, s32 vramIdx, s32 brightness, const RGB *ramp); +const RGB *sub_8005674(const EfoFileData *, s32 vramIdx); +void sub_800569C(DungeonPos *, axObject *, u8); +void sub_8005700(DungeonPos *, axObject *); +void sub_8005770(s32, const RGB *color, s32 brightness, const RGB *ramp); #endif // GUARD_SPRITE_H diff --git a/include/string_format.h b/include/string_format.h index ed2fe640c..1e4b97720 100644 --- a/include/string_format.h +++ b/include/string_format.h @@ -1,10 +1,11 @@ #ifndef GUARD_STRING_FORMAT_H #define GUARD_STRING_FORMAT_H -#include "file_system.h" #include "structs/menu.h" -#include "structs/str_text.h" #include "structs/rgb.h" +#include "structs/str_file_system.h" +#include "structs/str_mon_portrait.h" +#include "structs/str_text.h" // TODO: once the files close to string_format.c are decompiled, check if these should be included here. Most likely, they should be declared elsewhere. // code_80130A8.s @@ -15,28 +16,6 @@ u32 sub_80151C0(u32, u8 *); u32 sub_80154F0(void); void sub_80155F0(void); -struct PortraitGfxSub -{ - const RGB *pal; - const u8 *gfx; -}; - -struct PortraitGfx -{ - // NOTE: The actual number of sprites is different depending on pokemon. For example, starters have 12 sprites, while most legendaries only 1. [0] means that any number of sprites is valid. - struct PortraitGfxSub sprites[0]; -}; - -struct MonPortraitMsg -{ - OpenedFile *faceFile; - struct PortraitGfx *faceData; - DungeonPos pos; - u8 spriteId; // Which mon's sprite to use. For example Kecleon has multiple sprites depending on whether it's green or purple. - bool8 flip; // Whether the mon's sprite is flipped. - u8 unkE; -}; - #define FORMAT_BUFFER_LEN 80 #define FRIEND_AREA_BUFFER_LEN 184 @@ -49,10 +28,10 @@ extern u8 gFormatBuffer_FriendArea[FRIEND_AREA_BUFFER_LEN]; void sub_8014144(void); void sub_801416C(s32 param_1,s32 param_2); -void CreateDialogueBoxAndPortrait(const u8 *text, void *param_2, struct MonPortraitMsg *monPortraitPtr, u16 flags); -void CreateYesNoDialogueBoxAndPortrait_DefaultYes(const u8 *text, struct MonPortraitMsg *monPortraitPtr, u16 flags); -void CreateYesNoDialogueBoxAndPortrait_DefaultNo(const u8 *text, struct MonPortraitMsg *monPortraitPtr, u16 flags); -void CreateMenuDialogueBoxAndPortrait(const u8 *text, void *a1, u32 r9, const MenuItem *menuItems, void *arg_0, u32 a5, u32 unknownUnused, struct MonPortraitMsg *monPortraitPtr, u16 flags); +void CreateDialogueBoxAndPortrait(const u8 *text, void *param_2, MonPortraitMsg *monPortraitPtr, u16 flags); +void CreateYesNoDialogueBoxAndPortrait_DefaultYes(const u8 *text, MonPortraitMsg *monPortraitPtr, u16 flags); +void CreateYesNoDialogueBoxAndPortrait_DefaultNo(const u8 *text, MonPortraitMsg *monPortraitPtr, u16 flags); +void CreateMenuDialogueBoxAndPortrait(const u8 *text, void *a1, u32 r9, const MenuItem *menuItems, void *arg_0, u32 a5, u32 unknownUnused, MonPortraitMsg *monPortraitPtr, u16 flags); void sub_8014490(void); s32 sub_80144A4(s32 *a0); void DrawDialogueBoxString(void); diff --git a/include/structs/axdata.h b/include/structs/axdata.h index 02e771233..757dae955 100644 --- a/include/structs/axdata.h +++ b/include/structs/axdata.h @@ -1,6 +1,7 @@ #ifndef GUARD_AXDATA_H #define GUARD_AXDATA_H +#include "structs/rgb.h" #include "structs/str_file_system.h" #include "structs/str_position.h" @@ -28,21 +29,21 @@ typedef struct axdata1 } axdata1; // Size: 0x2 -typedef struct __attribute__((packed, aligned(2))) ax_pose_unk2 +typedef struct ax_pose_unk2 { u8 unk0; s8 unk1; -} ax_pose_unk2; +} ax_pose_unk2 __attribute__((packed, aligned(2))); // size: 0xA -typedef struct __attribute__((packed, aligned(2))) ax_pose +typedef struct ax_pose { /* 0x0 */ s16 sprite; /* 0x2 */ ax_pose_unk2 unk2; // Always {0, 0} in red (except for end markers which are {0xFF, 0xFF}) /* 0x4 */ u16 flags1; /* 0x6 */ u16 flags2; /* 0x8 */ u16 flags3; -} ax_pose; +} ax_pose __attribute__((packed, aligned(2))); // size: 0xC typedef struct ax_anim @@ -80,7 +81,7 @@ typedef struct axmain } axmain; // size: 0x4C -struct axObject +typedef struct axObject { /* 0x0 */ axdata axdata; /* 0x3C */ OpenedFile *spriteFile; // This might be a unkStruct_202EE8C instead and unkStruct_202EE8C.unk0 might be a OpenedFile* etc. See friend_areas_map_util.AnimateSprites() @@ -97,12 +98,12 @@ struct axObject struct EntityInfo* monster; struct Trap* trap; } info; -}; +} axObject; // size: 0x80? (assuming it's the last sub-struct of GroundLives) -struct axPokemon +typedef struct axPokemon { - struct axObject obj; + axObject obj; /* 0x4C */ axmain *axmain; u16 flags_0x50; s16 unk52; @@ -123,6 +124,24 @@ struct axPokemon s32 unk74; s32 unk78; s32 unk7C; -}; +} axPokemon; + +typedef struct Palette256 +{ + RGB pal[256]; +} Palette256; + +// size: 0x20 +typedef struct EfoFileData +{ + /* 0x0 */ ax_pose **poses; // TODO: Verify if these fields' names are actually valid + /* 0x4 */ ax_anim ***animations; + /* 0x8 */ s32 animCount; + /* 0xC */ void *spriteData; // ? + /* 0x10 */ Palette256 *unk10; // ? + /* 0x14 */ const u32 *tiles; + /* 0x18 */ const RGB *pal; + /* 0x1C */ s32 tileCount; +} EfoFileData; #endif // GUARD_AXDATA_H diff --git a/include/structs/dungeon_entity.h b/include/structs/dungeon_entity.h index 2bd92ba32..6ad7f56e4 100644 --- a/include/structs/dungeon_entity.h +++ b/include/structs/dungeon_entity.h @@ -12,7 +12,6 @@ #include "structs/str_iq_skill_flags.h" #include "math.h" #include "number_util.h" -#include "sprite.h" #define MAX_STAT_STAGE 20 #define STAT_MULTIPLIER_THRESHOLD 0.249 // one tick less than 0.25 @@ -361,7 +360,7 @@ typedef struct Entity // The global spawn index counter starts at 10. Each Pokémon that spawns increments the counter and // gets assigned the current counter value as its spawn index. /* 0x26 */ u16 spawnGenID; - /* 0x28 */ struct axObject axObj; + /* 0x28 */ axObject axObj; } Entity; enum EntityType diff --git a/include/structs/str_3001B64.h b/include/structs/str_3001B64.h index 3b66da5bb..62de2c874 100644 --- a/include/structs/str_3001B64.h +++ b/include/structs/str_3001B64.h @@ -1,9 +1,9 @@ #ifndef GUARD_STR_3001B64_H #define GUARD_STR_3001B64_H -#include "file_system.h" #include "structs/menu.h" -#include "string_format.h" +#include "structs/str_file_system.h" +#include "structs/str_mon_portrait.h" // Maybe Position32? struct unkStruct_3001B64_sub_sub @@ -22,7 +22,7 @@ struct unkStruct_3001B64_sub s8 unk6; u8 unk7; struct unkStruct_3001B64_sub_sub unk8; - struct MonPortraitMsg monPortrait; + MonPortraitMsg monPortrait; /* 0x20 */ OpenedFile *faceFile; }; diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index cd9f5cc32..426e03d83 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -9,7 +9,6 @@ #include "structs/str_position.h" #include "structs/str_traps.h" #include "structs/str_dungeon_location.h" -#include "sprite.h" #define DUNGEON_MAX_SIZE_X 56 #define DUNGEON_MAX_SIZE_Y 32 diff --git a/include/structs/str_mon_portrait.h b/include/structs/str_mon_portrait.h new file mode 100644 index 000000000..c292b7ecd --- /dev/null +++ b/include/structs/str_mon_portrait.h @@ -0,0 +1,33 @@ +#ifndef GUARD_STR_MON_PORTRAIT_H +#define GUARD_STR_MON_PORTRAIT_H + +#include "structs/rgb.h" +#include "structs/str_file_system.h" +#include "structs/str_position.h" + +// size: 0x8 +typedef struct PortraitGfxSub +{ + const RGB *pal; + const u8 *gfx; +} PortraitGfxSub; + +// size: variable +typedef struct PortraitGfx +{ + // NOTE: The actual number of sprites is different depending on pokemon. For example, starters have 12 sprites, while most legendaries only 1. [0] means that any number of sprites is valid. + PortraitGfxSub sprites[0]; +} PortraitGfx; + +// size: 0xC +typedef struct MonPortraitMsg +{ + OpenedFile *faceFile; + PortraitGfx *faceData; + DungeonPos pos; + u8 spriteId; // Which mon's sprite to use. For example Kecleon has multiple sprites depending on whether it's green or purple. + bool8 flip; // Whether the mon's sprite is flipped. + u8 unkE; +} MonPortraitMsg; + +#endif // GUARD_STR_MON_PORTRAIT_H diff --git a/include/structs/str_text.h b/include/structs/str_text.h index ddf0ce496..3f22ef2ba 100644 --- a/include/structs/str_text.h +++ b/include/structs/str_text.h @@ -1,6 +1,20 @@ #ifndef GUARD_STR_TEXT_H #define GUARD_STR_TEXT_H +#include "structs/str_position.h" + +// size: 0xC +typedef struct unkChar +{ + const u16 *unk0; + u16 unk4; + s16 unk6; + u8 unk8; + u8 fill9; + u8 unkA; + u8 fillB; +} unkChar; + // size: 0x48 typedef struct Window { @@ -37,8 +51,6 @@ typedef struct WindowHeader /* 0x3 */ u8 f3; } WindowHeader; -#include "structs/str_position.h" - // size: 0x18 typedef struct WindowTemplate { @@ -52,14 +64,14 @@ typedef struct WindowTemplate const WindowHeader *header; } WindowTemplate; -#define WINDOW_TYPE_0 0 -#define WINDOW_TYPE_WITHOUT_BORDER 1 -#define WINDOW_TYPE_2 2 -#define WINDOW_TYPE_NORMAL 3 -#define WINDOW_TYPE_4 4 -#define WINDOW_TYPE_FILL_TRANSPARENT 5 -#define WINDOW_TYPE_WITH_HEADER 6 -#define WINDOW_TYPE_7 7 +#define WINDOW_TYPE_0 0 +#define WINDOW_TYPE_WITHOUT_BORDER 1 +#define WINDOW_TYPE_2 2 +#define WINDOW_TYPE_NORMAL 3 +#define WINDOW_TYPE_4 4 +#define WINDOW_TYPE_FILL_TRANSPARENT 5 +#define WINDOW_TYPE_WITH_HEADER 6 +#define WINDOW_TYPE_7 7 #define MAX_WINDOWS 4 @@ -72,4 +84,4 @@ typedef struct WindowTemplates /* 0x0 */ WindowTemplate id[MAX_WINDOWS]; } WindowTemplates; -#endif // GUARD_STR_TEXT_H \ No newline at end of file +#endif // GUARD_STR_TEXT_H diff --git a/include/structs/struct_sub80095e4.h b/include/structs/struct_sub80095e4.h index 64c730531..94da41810 100644 --- a/include/structs/struct_sub80095e4.h +++ b/include/structs/struct_sub80095e4.h @@ -4,8 +4,8 @@ #include "structs/menu.h" #include "structs/str_text.h" -s32 sub_80095E4(s32 a0, s32 a1); -s32 sub_8009614(s32 a0, s32 a1); +#include "text_1.h" +#include "text_3.h" // Struct related with sub_80095E4 typedef struct struct_Sub80095E4 diff --git a/include/text.h b/include/text.h deleted file mode 100644 index 2f981e8b0..000000000 --- a/include/text.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef GUARD_TEXT_H -#define GUARD_TEXT_H - -#include "structs/str_text.h" - -// size: 0x10 -struct unkShiftData -{ - u32 bytesA; - u32 bytesB; - u32 shift_left; - u32 shift_right; -}; - -// size: 0xC -struct unkChar -{ - const u16 *unk0; - u16 unk4; - s16 unk6; - u8 unk8; - u8 fill9; - u8 unkA; - u8 fillB; -}; - -struct UnkDrawStringStruct; - -struct UnkDrawStringStruct -{ - s16 unk0; - s16 unk2; - s16 unk4; - s16 unk6; - s16 unk8; - s16 unkA; - s32 unkC; - u32 unk10; - u32 unk14; - u32 unk18; - u32 unk1C; - u8 unk20; - u8 unk21; - u8 fill22; - u8 fill23; - const u8* (*unk24)(const u8 *, const u8 *, struct UnkDrawStringStruct*); - s32 unk28; - s32 unk2C; - s32 unk30; -}; - -extern Window gWindows[MAX_WINDOWS]; -extern u8 gUnknown_202749A[11]; -extern bool8 gUnknown_20274A5; - -// These should probably go to code_8009804.h -#define TILEMAP_TILE_NUM(num)(num & 0x3FF) // bits 0-9 -#define TILEMAP_FLIP_HORIZONTAL(f)((f & 1) << 10) // bit 10 -#define TILEMAP_FLIP_VERTICAL(f)((f & 1) << 11) // bit 11 -#define TILEMAP_PAL(pal)((pal & 0xF) << 12) // bits 12-15 -extern u16 gBgTilemaps[4][32][32]; // 4 bgs, 32x32 tiles, y dimension goes before x [bgId][y][x] - -extern void (*ScrollDownWindowFunc)(s32 windowId); -extern void (*ScrollUpWindowFunc)(s32 windowId); -extern void (*gIwramTextFunc3)(s32 a0); -extern void (*gIwramTextFunc4)(s32 a0); - -void LoadCharmaps(void); -u32 UpdateFadeInTile(u32 a0); -u32 sub_80063B0(void); -void SelectCharmap(u32 a0); -void SetCharacterMask(int a0); -void ShowWindows(const WindowTemplates *windows, bool8 a1, bool8 a2); -void RestoreUnkTextStruct_8006518(WindowTemplates *unkData); -u32 sub_8006544(u32 index); -void sub_8007334(s32 windowId); -void sub_80073B8(s32 a0); -void sub_80073E0(s32 a0); -u32 xxx_call_draw_char(s32 x, s32 y, u32 a2, u32 color, u32 a4); -void AddDoubleUnderScoreHighlight(u32 windowId, s32 x, s32 y, s32 width, u32 color); -void AddUnderScoreHighlight(u32 windowId, s32 x, s32 y, s32 width, u32 color); -void sub_8007A78(u32 a0, s32 x, s32 y, s32 a3, u32 color); -void sub_8007B7C(u32 a0, s32 x, s32 y, s32 a3, u32 color); -void sub_8007E20(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 *a5, u32 a6); -void DisplayMonPortraitSprite(s32 a0, const u8 *compressedData, s32 a2); -void DisplayMonPortraitSpriteFlipped(s32 a0, const u8 *compressedData, s32 a1); -const struct unkChar *GetCharacter(s32 chr); -const u8 *xxx_get_next_char_from_string(const u8 *a1, u32 *a0); -void sub_80087EC(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); -bool8 xxx_call_update_bg_vram(void); -void CallPrepareTextbox_8008C54(u32 strId); -bool8 sub_8008D8C(u32 strId); -void sub_8008DC8(s32 a0, s32 a1, u16 a2, s32 a3); -s32 sub_8008ED0(const u8 *str); -void PrintStringOnWindow2(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 lineSpacing); -void PrintStringOnWindow(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr); -const u8 *xxx_handle_format_global(const u8 *str, struct UnkDrawStringStruct *unkStrPtr); -void sub_8009408(s32 from, s32 to); -void sub_8009524(s32 strArrId); -void sub_80095CC(s32 a0, s32 a1); -s32 sub_80095E4(s32 a0, s32 a1); -s32 sub_8009614(s32 a0, s32 a1); - -#endif // GUARD_TEXT_H diff --git a/include/text_1.h b/include/text_1.h new file mode 100644 index 000000000..1ce9901e2 --- /dev/null +++ b/include/text_1.h @@ -0,0 +1,65 @@ +#ifndef GUARD_TEXT_1_H +#define GUARD_TEXT_1_H + +#include "structs/str_text.h" + +// These should probably go to code_8009804.h +#define TILEMAP_TILE_NUM(num)(num & 0x3FF) // bits 0-9 +#define TILEMAP_FLIP_HORIZONTAL(f)((f & 1) << 10) // bit 10 +#define TILEMAP_FLIP_VERTICAL(f)((f & 1) << 11) // bit 11 +#define TILEMAP_PAL(pal)((pal & 0xF) << 12) // bits 12-15 + +// size: 0x10 +typedef struct unkShiftData +{ + u32 bytesA; + u32 bytesB; + u32 shift_left; + u32 shift_right; +} unkShiftData; + +typedef struct CharMapStruct +{ + s32 unk0; + unkChar *unk4; +} CharMapStruct; + +extern Window gWindows[MAX_WINDOWS]; +extern CharMapStruct *gCharmaps[2]; +extern s16 gCharacterSpacing; +extern u8 gUnknown_202749A[11]; +extern bool8 gUnknown_20274A5; +extern u8 gUnknown_20274A6[6]; +extern s32 gCurrentCharmap; +extern s32 gUnknown_202B020; +extern s32 gUnknown_202B024; +extern s32 gCharHeight[2]; +extern u32 gTextShadowMask; +extern u8 gDrawTextShadow; +extern u16 gBgTilemaps[4][32][32]; + +extern void (*ScrollDownWindowFunc)(s32 windowId); +extern void (*ScrollUpWindowFunc)(s32 windowId); +extern void (*gIwramTextFunc3)(s32 a0); +extern void (*gIwramTextFunc4)(s32 a0); + +extern s16 gUnknown_3000E94[161]; + +extern const u32 gUnknown_80B853C[16]; +extern const unkShiftData gCharMasksOffsets[8]; +extern const unkChar gUnknown_80B86A4; +extern const u32 gUnknown_80B86B4[][32]; + +void LoadCharmaps(void); +void RestoreSavedWindows(WindowTemplates *dst); +void SelectCharmap(u32); +void SetCharacterMask(s32); +void ShowWindows(const WindowTemplates *winTemplates, bool8, bool8); +u32 sub_80063B0(void); +u32 sub_8006544(u32 index); +void sub_8007334(s32 windowId); +void sub_80073B8(s32 windowId); +void sub_80073E0(s32 windowId); +u32 UpdateFadeInTile(u32); + +#endif // GUARD_TEXT_1_H diff --git a/include/text_2.h b/include/text_2.h new file mode 100644 index 000000000..54a65a6c7 --- /dev/null +++ b/include/text_2.h @@ -0,0 +1,24 @@ +#ifndef GUARD_TEXT_2_H +#define GUARD_TEXT_2_H + +#include "structs/str_text.h" + +void AddDoubleUnderScoreHighlight(u32 windowId, s32 x, s32 y, s32 width, u32 color); +void AddUnderScoreHighlight(u32 windowId, s32 x, s32 y, s32 width, u32 color); +void CallPrepareTextbox_8008C54(u32 strId); +void DisplayMonPortraitSprite(s32 a0, const u8 *compressedData, s32 a2); +void DisplayMonPortraitSpriteFlipped(s32 a0, const u8 *compressedData, s32 a1); +const unkChar *GetCharacter(s32 chr); +void PrepareTextbox_8008C6C(Window *windows, u32 windowId); +void ResetWindowBgData(void); +void sub_8007A78(u32 a0, s32 x, s32 y, s32 a3, u32 color); +void sub_8007B7C(u32 a0, s32 x, s32 y, s32 a3, u32 color); +void sub_8007E20(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 *a5, u32 a6); +void sub_80087EC(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +void sub_80089AC(const WindowTemplate *r4, DungeonPos *r5_Str); +u32 xxx_call_draw_char(s32 x, s32 y, u32 a2, u32 color, u32 a4); +bool8 xxx_call_update_bg_vram(void); +u32 xxx_draw_char(Window *windows, s32 x, s32 y, u32 a3, u32 color, u32 windowId); +const u8 *xxx_get_next_char_from_string(const u8 *a1, u32 *a0); + +#endif // GUARD_TEXT_2_H diff --git a/include/text_3.h b/include/text_3.h new file mode 100644 index 000000000..205d33c12 --- /dev/null +++ b/include/text_3.h @@ -0,0 +1,41 @@ +#ifndef GUARD_TEXT_3_H +#define GUARD_TEXT_3_H + +// size: 0x34 +typedef struct UnkDrawStringStruct +{ + s16 unk0; + s16 unk2; + s16 unk4; + s16 unk6; + s16 unk8; + s16 unkA; + s32 unkC; + u32 unk10; + u32 unk14; + u32 unk18; + u32 unk1C; + u8 unk20; + u8 unk21; + u8 fill22; + u8 fill23; + const u8 * (*unk24)(const u8 *, const u8 *, struct UnkDrawStringStruct *); + s32 unk28; + s32 unk2C; + s32 unk30; +} UnkDrawStringStruct; + +void PrintStringOnWindow(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr); +void PrintStringOnWindow2(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 lineSpacing); +bool8 sub_8008D8C(s32 windowId); +void sub_8008DC8(s32 x, s32 y, u16 bg0Val, u16 bg1Val); +s32 sub_8008ED0(const u8 *str); +void sub_8009388(void); +void sub_8009408(s32 from, s32 to); +void sub_8009524(s32 windowId); +void sub_80095CC(s32 a0, s32 a1); +s32 sub_80095E4(s32 a0, s32 a1); +s32 sub_8009614(s32 a0, s32 a1); +const u8 *xxx_handle_format_global(const u8 *str, UnkDrawStringStruct *unkStrPtr); + +#endif // GUARD_TEXT_3_H diff --git a/include/text_4.h b/include/text_4.h new file mode 100644 index 000000000..dd500dbb5 --- /dev/null +++ b/include/text_4.h @@ -0,0 +1,9 @@ +#ifndef GUARD_TEXT_4_H +#define GUARD_TEXT_4_H + +void ScrollDownWindow(s32 windowId); +void ScrollUpWindow(s32 windowId); +void sub_82729A4(s32 id); +void sub_8272A78(s32 id); + +#endif // GUARD_TEXT_4_H diff --git a/include/thank_you_wonder_mail.h b/include/thank_you_wonder_mail.h index f418f6bc0..5898cccad 100644 --- a/include/thank_you_wonder_mail.h +++ b/include/thank_you_wonder_mail.h @@ -2,9 +2,9 @@ #define GUARD_THANK_YOU_WONDER_MAIL_H #include "constants/wonder_mail.h" -#include "file_system.h" #include "structs/menu.h" #include "structs/str_items.h" +#include "structs/str_mon_portrait.h" #include "structs/str_text.h" #include "structs/str_wonder_mail.h" @@ -25,7 +25,7 @@ typedef struct WonderMailStruct_203B2C4 WindowTemplates unk35C; WindowTemplates unk3BC; Item unk41C; - /* 0x420 */ struct MonPortraitMsg monPortrait; + /* 0x420 */ MonPortraitMsg monPortrait; u32 unk430; /* 0x434 */ u8 formattedString[0x100]; /* 0x534 */ s32 wonderMailMethod; diff --git a/include/wigglytuff_shop3.h b/include/wigglytuff_shop3.h index 0466a1b27..050180d83 100644 --- a/include/wigglytuff_shop3.h +++ b/include/wigglytuff_shop3.h @@ -1,8 +1,8 @@ #ifndef GUARD_WIGGLYTUFF_SHOP3_H #define GUARD_WIGGLYTUFF_SHOP3_H -#include "file_system.h" #include "structs/menu.h" +#include "structs/str_mon_portrait.h" #include "structs/str_text.h" enum WigglytuffStates @@ -52,8 +52,8 @@ typedef struct WigglytuffShop3Work MenuItem unk1C[8]; u16 unk5C[8]; MenuStruct unk6C; - /* 0xBC */ struct MonPortraitMsg monPortrait; - struct MonPortraitMsg *monPortraitPtr; + /* 0xBC */ MonPortraitMsg monPortrait; + MonPortraitMsg *monPortraitPtr; WindowTemplates unkD0; u32 unk130; u32 unk134; diff --git a/include/wonder_mail.h b/include/wonder_mail.h index 40db9e853..7342e7b9b 100644 --- a/include/wonder_mail.h +++ b/include/wonder_mail.h @@ -2,8 +2,8 @@ #define GUARD_WONDER_MAIL_H #include "constants/wonder_mail.h" -#include "file_system.h" #include "structs/menu.h" +#include "structs/str_mon_portrait.h" #include "structs/str_wonder_mail.h" // size: 0x548 @@ -25,7 +25,7 @@ typedef struct WonderMailStruct_203B2C0 WindowTemplates unk35C; WindowTemplates unk3BC; /* 0x41C */ u32 unkfill; // ItemSlot? - /* 0x420 */ struct MonPortraitMsg monPortrait; + /* 0x420 */ MonPortraitMsg monPortrait; /* 0x430 */ u8 padding3[0x534 - 0x430]; u32 unk534; s32 unk538; // A7 << 3 diff --git a/ld_script.txt b/ld_script.txt index 84fa9304f..dd34b55c8 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -62,12 +62,17 @@ SECTIONS { src/sprite.o(.text); src/code_800558C.o(.text); src/random.o(.text); - src/text.o(.text); + src/text_1.o(.text); + src/text_2.o(.text); + src/text_3.o(.text); + src/text_4.o(.text); src/code_8009804.o(.text); asm/code_8009804.o(.text); src/math.o(.text); src/file_system.o(.text); - src/decompress.o(.text); + src/decompress_sir.o(.text); + src/decompress_at.o(.text); + src/decompress_3.o(.text); src/main.o(.text); src/reg_control.o(.text); src/music.o(.text); @@ -402,12 +407,13 @@ SECTIONS { src/memory.o(.rodata); data/data1.o(.rodata); src/random.o(.rodata); - src/text.o(.rodata); + src/text_1.o(.rodata); + src/text_2.o(.rodata); src/code_8009804.o(.rodata); data/data2.o(.rodata); src/math.o(.rodata); src/file_system.o(.rodata); - src/decompress.o(.rodata); + src/decompress_at.o(.rodata); data/data_80B9BB8.o(.rodata); src/main.o(.rodata); src/reg_control.o(.rodata); diff --git a/src/adventure_log.c b/src/adventure_log.c index 396ffe2b4..bd164e671 100644 --- a/src/adventure_log.c +++ b/src/adventure_log.c @@ -1,22 +1,22 @@ #include "global.h" #include "globaldata.h" +#include "constants/input.h" +#include "structs/struct_sub80095e4.h" #include "adventure_log.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_8097670.h" -#include "constants/input.h" #include "input.h" #include "memory.h" #include "menu_input.h" -#include "text.h" -#include "structs/struct_sub80095e4.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" -static EWRAM_INIT struct_Sub80095E4_2 *sAdventureLog = {NULL}; +static EWRAM_INIT struct_Sub80095E4_2 *sAdventureLog = { NULL }; #include "data/adventure_log.h" static void DisplayAdventureLog(); - static void sub_8032084(); bool8 CreateAdventureLogScreen(u32 kind) @@ -24,7 +24,7 @@ bool8 CreateAdventureLogScreen(u32 kind) sAdventureLog = MemoryAlloc(sizeof(*sAdventureLog), 8); sAdventureLog->s0.unk34 = kind; sAdventureLog->s0.unk38 = &sAdventureLog->s0.windows.id[kind]; - RestoreUnkTextStruct_8006518(&sAdventureLog->s0.windows); + RestoreSavedWindows(&sAdventureLog->s0.windows); sAdventureLog->s0.windows.id[sAdventureLog->s0.unk34] = sUnknown_80E2008; sAdventureLog->s0.unk38->header = &sAdventureLog->unk9C; diff --git a/src/adventure_log_menu.c b/src/adventure_log_menu.c index e45c0595b..1f8cb761e 100644 --- a/src/adventure_log_menu.c +++ b/src/adventure_log_menu.c @@ -1,9 +1,9 @@ #include "global.h" +#include "constants/main_menu.h" #include "adventure_log.h" #include "adventure_log_menu.h" -#include "constants/main_menu.h" #include "input.h" -#include "text.h" +#include "text_1.h" void CreateAdventureLogMenu(void) { diff --git a/src/code_8002774.c b/src/code_8002774.c index 55d4b69c8..6a47f936b 100644 --- a/src/code_8002774.c +++ b/src/code_8002774.c @@ -11,6 +11,10 @@ struct S u8 x0[UNK_STRUCT_ARR_COUNT]; }; +extern const PixelPos gVectorDirections[8]; + +static s8 VecDirection4Radial(PixelPos *pixelPos); + u16 sub_8002774(struct S s) { return ((s.x0[2] & 0xF8) << 7) | ((s.x0[1] & 0xF8) << 2) | ((s.x0[0] & 0xF8) >> 3); @@ -63,22 +67,28 @@ UNUSED static void sub_800282C(struct S *dst, s32 a1, struct S *a2, struct S *a3 *dst = *a3; } -// File split here? -extern PixelPos gVectorDirections[8]; +// TODO: File split here + + + + +// arm9.bin::02010314 void sub_800290C(PixelPos *param_1, s32 param_2) { if (param_1->x > param_2) param_1->x = param_2; else if (param_1->x < -param_2) param_1->x = -param_2; + if (param_1->y > param_2) param_1->y = param_2; else if(param_1->y < -param_2) param_1->y = -param_2; } +// arm9.bin::020102B8 void sub_8002934(PixelPos *param_1, PixelPos *param_2, PixelPos *param_3, s32 param_4, s32 param_5) { s32 r9 = (param_4 + param_5); @@ -86,11 +96,22 @@ void sub_8002934(PixelPos *param_1, PixelPos *param_2, PixelPos *param_3, s32 pa param_1->y = (param_4 * param_2->y + param_5 * param_3->y) / r9; } + + + +// TODO: File split here + + + + + + static inline s8 sub_8002984_sub(s32 direction1, s32 rand, s32 add, s32 multi) { return (s8)(((direction1 + add) + OtherRandInt(rand) * multi) % NUM_DIRECTIONS); } +// arm9.bin::020109F4 s32 sub_8002984(s32 _direction1, u32 caseID) { s32 direction1; @@ -151,7 +172,7 @@ s32 sub_8002984(s32 _direction1, u32 caseID) return direction1; } - +// arm9.bin::020108EC s32 sub_8002A70(s32 _direction1, s32 _direction2, s32 _caseId) { s32 direction1 = (s8)(_direction1); @@ -196,6 +217,7 @@ s32 sub_8002A70(s32 _direction1, s32 _direction2, s32 _caseId) return direction1; } +// arm9.bin::02010824 s32 sub_8002B04(s32 _direction1, s32 _direction2) { s32 direction1 = (s8)(_direction1); @@ -217,11 +239,12 @@ s32 sub_8002B04(s32 _direction1, s32 _direction2) return direction1; } -UNUSED s32 sub_8002B5C(s32 _direction1, s32 _direction2) +#if (GAME_VERSION == VERSION_RED) +UNUSED static s32 sub_8002B5C(s32 _direction1, s32 _direction2) { - int newDirection; - int direction1; - int direction2; + s32 newDirection; + s32 direction1; + s32 direction2; direction1 = (s8)_direction1; direction2 = (s8)_direction2; @@ -241,50 +264,43 @@ UNUSED s32 sub_8002B5C(s32 _direction1, s32 _direction2) } return direction1 & DIRECTION_MASK_CARDINAL; } +#endif +// arm9.bin::02010790 PixelPos SetVecFromDirectionSpeed(s8 r1, u32 r2) { - PixelPos *vec = &gVectorDirections[r1]; + const PixelPos *vec = &gVectorDirections[r1]; return (PixelPos){ .x = vec->x * r2, .y = vec->y * r2 }; } -s32 VecDirection8Sign(PixelPos *param_1) +UNUSED static s32 VecDirection8Sign(PixelPos *param_1) { if (param_1->x < 0) { - if (param_1->y < 0) { + if (param_1->y < 0) return DIRECTION_NORTHWEST; - } - else if (param_1->y > 0) { + else if (param_1->y > 0) return DIRECTION_SOUTHWEST; - } - else { + else return DIRECTION_WEST; - } } else if (param_1->x > 0) { - if (param_1->y < 0) { + if (param_1->y < 0) return DIRECTION_NORTHEAST; - } - else if (param_1->y > 0) { + else if (param_1->y > 0) return DIRECTION_SOUTHEAST; - } - else { + else return DIRECTION_EAST; - } } - else if (param_1->y < 0) { + else if (param_1->y < 0) return DIRECTION_NORTH; - } - else if (param_1->y > 0) { + else if (param_1->y > 0) return DIRECTION_SOUTH; - } - else { + else return -1; - } } -s32 VecDirection4SignYX(PixelPos *param_1) +UNUSED static s32 VecDirection4SignYX(PixelPos *param_1) { if (param_1->y < 0) { return DIRECTION_NORTH; @@ -303,6 +319,7 @@ s32 VecDirection4SignYX(PixelPos *param_1) } } +// arm9.bin::02010680 s8 VecDirection8Radial(PixelPos *pixelPos) { PixelPos absPos = {abs(pixelPos->x), abs(pixelPos->y)}; @@ -355,7 +372,8 @@ s8 VecDirection8Radial(PixelPos *pixelPos) return DIRECTION_SOUTH; } -s8 VecDirection4Radial(PixelPos *pixelPos) +// arm9.bin::020105A0 +static s8 VecDirection4Radial(PixelPos *pixelPos) { PixelPos absPos = {abs(pixelPos->x), abs(pixelPos->y)}; @@ -395,6 +413,7 @@ s8 VecDirection4Radial(PixelPos *pixelPos) return DIRECTION_SOUTH; } +// arm9.bin::02010478 s8 SizedDeltaDirection4(const PixelPos *r0, const PixelPos *r1, const PixelPos *r2, const PixelPos *r3) { PixelPos stack; @@ -435,10 +454,10 @@ s8 SizedDeltaDirection4(const PixelPos *r0, const PixelPos *r1, const PixelPos * if(stack.y > 0) stack.y = 0; } - return VecDirection4Radial(&stack); } +// arm9.bin::02010350 s8 SizedDeltaDirection8(const PixelPos *r0, const PixelPos *r1, const PixelPos *r2, const PixelPos *r3) { PixelPos stack; @@ -446,39 +465,38 @@ s8 SizedDeltaDirection8(const PixelPos *r0, const PixelPos *r1, const PixelPos * s32 iVar2; s32 iVar3; - stack.x = r2->x - r0->x; - stack.y = r2->y - r0->y; + stack.x = r2->x - r0->x; + stack.y = r2->y - r0->y; - if(stack.x >= 0) - { - iVar3 = (stack.x + 1); - iVar3 -= ((r1->x + r3->x) / 2); + if (stack.x >= 0) { + iVar3 = stack.x + 1; + iVar3 -= (r1->x + r3->x) / 2; stack.x = iVar3; - if(stack.x < 0) stack.x = 0; + if (stack.x < 0) + stack.x = 0; } - else - { - iVar1 = (stack.x - 1); - iVar1 += ((r1->x + r3->x) / 2); + else { + iVar1 = stack.x - 1; + iVar1 += (r1->x + r3->x) / 2; stack.x = iVar1; - if(stack.x > 0) stack.x = 0; + if (stack.x > 0) + stack.x = 0; } - if(stack.y >= 0) - { - iVar2 = (stack.y + 1); - iVar2 -= ((r1->y + r3->y) / 2); + if (stack.y >= 0) { + iVar2 = stack.y + 1; + iVar2 -= (r1->y + r3->y) / 2; stack.y = iVar2; - if(stack.y < 0) stack.y = 0; + if (stack.y < 0) + stack.y = 0; } - else - { - iVar1 = (stack.y - 1); - iVar1 += ((r1->y + r3->y) / 2); + else { + iVar1 = stack.y - 1; + iVar1 += (r1->y + r3->y) / 2; stack.y = iVar1; - if(stack.y > 0) stack.y = 0; + if (stack.y > 0) + stack.y = 0; } - return VecDirection8Radial(&stack); } diff --git a/src/code_8004AA0.c b/src/code_8004AA0.c index cac7766cd..da878e05b 100644 --- a/src/code_8004AA0.c +++ b/src/code_8004AA0.c @@ -3,7 +3,8 @@ #include "code_8004AA0.h" void nullsub_6(void) -{} +{ +} void sub_8004AA4(unkStruct_202EE8C *a0, OpenedFile *a1, s32 a2) { diff --git a/src/code_800558C.c b/src/code_800558C.c index 6442c8a7d..d58db47e0 100644 --- a/src/code_800558C.c +++ b/src/code_800558C.c @@ -1,24 +1,21 @@ #include "global.h" #include "bg_control.h" -#include "bg_palette_buffer.h" #include "code_800558C.h" -#include "cpu.h" #include "math.h" -#include "sprite.h" EWRAM_DATA bool8 gUnknown_2026E38 = FALSE; EWRAM_DATA u32 *gUnknown_2026E3C = NULL; -static EWRAM_DATA s32 sUnknown_2026E40 = 0; // Read from but never written to -static EWRAM_DATA s32 sUnknown_2026E44 = 0; // Read from but never written to -static EWRAM_DATA s32 sUnknown_2026E48 = 0; // Read from but never written to -static EWRAM_DATA bool8 sUnknown_2026E4C = FALSE; +EWRAM_DATA static s32 sUnknown_2026E40 = 0; // Read from but never written to +EWRAM_DATA static s32 sUnknown_2026E44 = 0; // Read from but never written to +EWRAM_DATA static s32 sUnknown_2026E48 = 0; // Read from but never written to +EWRAM_DATA static bool8 sUnknown_2026E4C = FALSE; EWRAM_DATA s16 gUnknown_2026E4E = 0; -static EWRAM_DATA bool32 sUnknown_2026E50 = FALSE; -static EWRAM_DATA bool32 sUnknown_2026E54 = FALSE; -static EWRAM_DATA u32 *sUnknown_2026E58 = NULL; -UNUSED static EWRAM_DATA u32 sUnused0 = 0; -static EWRAM_DATA s16 sUnknown_2026E60[324] = {0}; // These might be [2][162] -static EWRAM_DATA s16 sUnknown_20270E8[324] = {0}; +EWRAM_DATA static bool32 sUnknown_2026E50 = FALSE; +EWRAM_DATA static bool32 sUnknown_2026E54 = FALSE; +EWRAM_DATA static u32 *sUnknown_2026E58 = NULL; +UNUSED EWRAM_DATA static u32 sUnused0 = 0; +EWRAM_DATA static s16 sUnknown_2026E60[324] = {0}; // These might be [2][162] +EWRAM_DATA static s16 sUnknown_20270E8[324] = {0}; EWRAM_INIT s16 *gUnknown_203B078 = NULL; @@ -29,173 +26,7 @@ extern const s16 gUnknown_80B816A[16 * 10]; extern const s16 gUnknown_80B82AA[16 * 10]; extern const s16 gUnknown_80B83EA[16 * 10]; -static void sub_800561C(struct EfoFileData *, s32, s32, const RGB *); - -void sub_8005610(OpenedFile *a0, s32 vramIdx, s32 brightness, const RGB *ramp) -{ - sub_800561C((struct EfoFileData *)a0->data, vramIdx, brightness, ramp); -} - -static void sub_800561C(struct EfoFileData *a0, s32 vramIdx, s32 brightness, const RGB *ramp) -{ - s32 i; - - if (a0->tiles != NULL) - CpuCopy(OBJ_VRAM0 + vramIdx * 0x20, a0->tiles, a0->tileCount * 0x20); - - if (a0->pal != NULL) { - for (i = 0; i < 16; i++) - SetBGPaletteBufferColorRGB(i + 480, &a0->pal[i], brightness, ramp); - } -} - -UNUSED static const RGB *sub_8005668(OpenedFile *a0, s32 vramIdx) -{ - return sub_8005674((struct EfoFileData *)a0->data, vramIdx); -} - -const RGB *sub_8005674(const struct EfoFileData *a0, s32 vramIdx) -{ - if (a0->tiles != NULL) - CpuCopy(OBJ_VRAM0 + vramIdx * 0x20, a0->tiles, a0->tileCount * 0x20); - - return a0->pal; -} - -void sub_800569C(DungeonPos *a0, struct axObject *a1, u8 a2) -{ - DungeonPos *ptr; - DungeonPos *ptr2; - DungeonPos *ptr3; - - a0->x = 0; - a0->y = 0; - - if (!(a1->axdata.flags >> 15) || a2 >= 4) - return; - - if (a1->axdata.paletteData != NULL) { - ptr = &((DungeonPos*)a1->axdata.paletteData)[a1->axdata.sub1.poseId * 4]; - ptr2 = &ptr[a2]; - if (*&ptr2->x == 99 && *&ptr2->y == 99) { - a0->x = 99; - a0->y = 99; - } - else { - ptr3 = &ptr[a2]; - a0->x = a1->axdata.sub1.offset.x + ptr3->x; - a0->y = a1->axdata.sub1.offset.y + ptr3->y; - } - } - else { - a0->x = 99; - a0->y = 99; - } -} - -void sub_8005700(DungeonPos *a0, struct axObject *a1) -{ - s32 i; - DungeonPos *ptr; - - if (!(a1->axdata.flags >> 15)) - return; - - if (a1->axdata.paletteData != NULL) { - ptr = &((DungeonPos*)a1->axdata.paletteData)[a1->axdata.sub1.poseId * 4]; - for (i = 0; i < 4; i++) { - if (*&ptr[i].x == 99 && *&ptr[i].y == 99) { - a0->x = 99; - a0->y = 99; - } - else { - a0->x = a1->axdata.sub1.offset.x + ptr[i].x; - a0->y = a1->axdata.sub1.offset.y + ptr[i].y; - } - a0++; - } - } - else { - for (i = 0; i < 4; i++) { - a0->x = 99; - a0->y = 99; - a0++; - } - } -} - -UNUSED static void sub_8005764(s32 a0, OpenedFile *file, s32 a2, const RGB *a3) -{ - sub_8005770(a0, (const RGB*)file->data, a2, a3); -} - -void sub_8005770(s32 param_1, const RGB *color, s32 brightness, const RGB *ramp) -{ - s32 i; - - for (i = 0; i < 16; i++) - SetBGPaletteBufferColorRGB((param_1 + 0x10) * 0x10 + i, &color[i], brightness, ramp); -} - -// Maybe DungeonPos -void nullsub_7(s16 *a0) -{} - -void nullsub_8(u32 a0) -{} - -void nullsub_9(void) -{} - -void nullsub_10(bool8 a0) -{} - -UNUSED static void nullsub_144(void) -{} - -void nullsub_11(void) -{} - -void nullsub_12(void) -{} - -void nullsub_13(void) -{} - -UNUSED static void nullsub_145(void) -{} - -void nullsub_14(void) -{} - -UNUSED static void nullsub_146(void) -{} - -UNUSED static void nullsub_147(void) -{} - -UNUSED static void nullsub_148(void) -{} - -UNUSED static void nullsub_149(void) -{} - -UNUSED static bool8 sub_80057D8(void) -{ - return FALSE; -} - -UNUSED static bool8 sub_80057DC(void) -{ - return FALSE; -} - -UNUSED static void nullsub_150(void) -{} - -UNUSED static void nullsub_151(void) -{} - +// arm9.bin::02006154 void sub_80057E8(void) { sUnknown_2026E4C = TRUE; @@ -208,6 +39,7 @@ void sub_80057E8(void) gUnknown_203B078 = NULL; } +// arm9.bin::02005758 void sub_8005838(s32 *a0, u8 kind) { const s16 *r1, *r2; @@ -569,6 +401,7 @@ void sub_8005838(s32 *a0, u8 kind) } } +#if (GAME_VERSION == VERSION_RED) UNUSED static void sub_80060A8(void) { gUnknown_2026E3C = sUnknown_2026E58; @@ -576,7 +409,9 @@ UNUSED static void sub_80060A8(void) sUnknown_2026E50 = !sUnknown_2026E50; gUnknown_2026E38 = FALSE; } +#endif +// arm9.bin::020056C0 void sub_80060EC(void) { gUnknown_2026E3C = sUnknown_2026E58; diff --git a/src/code_8009804.c b/src/code_8009804.c index 3315e577f..7701d407a 100644 --- a/src/code_8009804.c +++ b/src/code_8009804.c @@ -1,12 +1,12 @@ #include "global.h" #include "globaldata.h" #include "bg_palette_buffer.h" -#include "code_800558C.h" +#include "structs/axdata.h" #include "code_8009804.h" #include "cpu.h" #include "def_filearchives.h" #include "file_system.h" -#include "text.h" +#include "text_1.h" struct FontData { @@ -168,6 +168,7 @@ void sub_80098F8(u32 r0) sUnknown_202D238[r0] = 1; } +// arm9.bin::02009BE0 void sub_8009908(void) { s32 i; @@ -213,7 +214,7 @@ UNUSED static void sub_8009A10(struct unkStruct_8009A1C_ptr *a0, u32 palId, u32 sub_8009A1C(a0->ptr, palId, vramDstOffset, r3); } -void sub_8009A1C(const struct EfoFileData *r0, u32 palId, u32 vramDstOffset, u32 r3) +void sub_8009A1C(const EfoFileData *r0, u32 palId, u32 vramDstOffset, u32 r3) { s32 i; u32 *dst, *src; diff --git a/src/code_800C9CC.c b/src/code_800C9CC.c index c460c1cec..01335d668 100644 --- a/src/code_800C9CC.c +++ b/src/code_800C9CC.c @@ -7,6 +7,7 @@ // Todo: Figure out if this file could be merged with bg_control and cpu? EWRAM_INIT u32 gUnknown_203B0B8 = {0}; +// Should be arm9.bin02008A00, but it's way different void WaitForNextFrameAndAdvanceRNG(void) { sub_800BA5C(); @@ -27,6 +28,7 @@ UNUSED static void nullsub_180(void) { } +// Should be arm9.bin::020084D4, but it's way different void xxx_call_update_bg_sound_input(void) { xxx_update_bg_sound_input(); diff --git a/src/code_800D090.c b/src/code_800D090.c index 28550b514..b81f9c73e 100644 --- a/src/code_800D090.c +++ b/src/code_800D090.c @@ -63,6 +63,7 @@ void sub_800D098(void) while(REG_KEYINPUT != KEYS_MASK){} // All buttons } +// arm9.bin::02007FF8 void sprintfStatic(char *buffer, const char *text, ...) { va_list vArgv; diff --git a/src/code_800DAC0.c b/src/code_800DAC0.c index b1d1406f9..71dce6f05 100644 --- a/src/code_800DAC0.c +++ b/src/code_800DAC0.c @@ -1,15 +1,16 @@ #include "global.h" +#include "structs/axdata.h" #include "bg_control.h" -#include "code_800558C.h" #include "code_800DAC0.h" #include "code_800E9A8.h" #include "code_80118A4.h" #include "code_803E724.h" #include "def_filearchives.h" +#include "dungeon_map.h" #include "file_system.h" #include "main_loops.h" #include "memory.h" -#include "dungeon_map.h" +#include "sprite.h" EWRAM_INIT struct unkStruct_203B0CC *gUnknown_203B0CC = NULL; diff --git a/src/code_800ED38.c b/src/code_800ED38.c index 6bd3b4b74..df41f0c17 100644 --- a/src/code_800ED38.c +++ b/src/code_800ED38.c @@ -1,6 +1,6 @@ #include "global.h" #include "bg_control.h" -#include "code_800558C.h" +#include "structs/axdata.h" #include "code_8009804.h" #include "code_800C9CC.h" #include "code_800E9E4.h" @@ -12,14 +12,14 @@ #include "main_loops.h" #include "memory.h" #include "sprite.h" -#include "text.h" +#include "text_2.h" struct unkStruct_203B0D0_sub { // size: 0x24 u32 unk0; OpenedFile *file; - const struct EfoFileData *fileData; + const EfoFileData *fileData; u32 unkC; s32 unk10; s32 unk14; diff --git a/src/code_800F958.c b/src/code_800F958.c index dd092183b..4ad90a0e1 100644 --- a/src/code_800F958.c +++ b/src/code_800F958.c @@ -1,13 +1,12 @@ #include "global.h" #include "globaldata.h" +#include "structs/sprite_oam.h" #include "code_800F958.h" #include "code_8009804.h" #include "cpu.h" #include "dungeon_pokemon_sprites.h" #include "memory.h" #include "sprite.h" -#include "structs/sprite_oam.h" -#include struct StatusGraphicsInfo { @@ -75,7 +74,7 @@ extern SpriteOAM gUnknown_203B0DC; extern DungeonPos gUnknown_80D3564; -void DrawStatusSprite(s16 param_1,s32 status,DungeonPos *pos,DungeonPos *posOffset, +static void DrawStatusSprite(s16 param_1,s32 status,DungeonPos *pos,DungeonPos *posOffset, DungeonPos *posScreen,u32 priority, u32 unused); DungeonPokemonSprite *GetDungeonPokemonSprite(s32 id) @@ -200,7 +199,7 @@ void sub_800F2EC(DungeonPokemonSprite *sprite, s32 index, DungeonPos *screenPos) } } -void DrawStatusSprite(s16 param_1, s32 status, DungeonPos *pos, DungeonPos *posOffset, +static void DrawStatusSprite(s16 param_1, s32 status, DungeonPos *pos, DungeonPos *posOffset, DungeonPos *posScreen, u32 priority, u32 unused) { struct StatusSprite sprite; diff --git a/src/code_80118A4.c b/src/code_80118A4.c index 7ada63dd5..c3ea2761e 100644 --- a/src/code_80118A4.c +++ b/src/code_80118A4.c @@ -1,20 +1,19 @@ #include "global.h" -#include "code_800558C.h" +#include "structs/axdata.h" #include "code_8009804.h" #include "code_80118A4.h" #include "music.h" #include "constants/bg_music.h" #include "config.h" -#include "sprite.h" #include "event_flag.h" #include "file_system.h" extern const u16 gUnknown_80D4144[8]; -EWRAM_DATA u32 gUnknown_202DE1C = {0}; -EWRAM_DATA s16 gUnknown_202DE20 = {0}; -EWRAM_DATA s16 gUnknown_202DE22 = {0}; -EWRAM_DATA s16 gUnknown_202DE24 = {0}; +EWRAM_DATA u32 gUnknown_202DE1C = {0}; // GBA=202DE1C | NDS=02134218 +EWRAM_DATA s16 gUnknown_202DE20 = {0}; // GBA=202DE20 | NDS=0213420C +EWRAM_DATA s16 gUnknown_202DE22 = {0}; // GBA=202DE22 | NDS=02134210 +EWRAM_DATA s16 gUnknown_202DE24 = {0}; // GBA=202DE24 | NDS=02134214 void sub_8011760(void) { @@ -82,6 +81,7 @@ void xxx_call_start_bg_music(void) StartBGMusicVSync(); } +// arm9.bin::020187C0 void sub_8011860(void) { if (gUnknown_202DE20 > 0) diff --git a/src/code_8012A18.c b/src/code_8012A18.c index cacdb37d9..1ce0cd45c 100644 --- a/src/code_8012A18.c +++ b/src/code_8012A18.c @@ -7,7 +7,7 @@ #include "string_format.h" #include "game_options.h" #include "sprite.h" -#include "text.h" +#include "text_2.h" void sub_8012A18() { diff --git a/src/code_8012A18_1.c b/src/code_8012A18_1.c index f22d32e7b..7c8cfca35 100644 --- a/src/code_8012A18_1.c +++ b/src/code_8012A18_1.c @@ -1,8 +1,8 @@ #include "global.h" -#include "code_8012A18_1.h" #include "structs/sprite_oam.h" +#include "code_8012A18_1.h" +#include "text_2.h" #include "text_util.h" -#include "text.h" struct unkStruct_203B1FC { @@ -50,7 +50,7 @@ s32 sub_8015F44(void) void sub_8015F84(void) { u32 uVar2; - const struct unkChar *puVar3; + const unkChar *puVar3; s32 index; s32 total; @@ -73,7 +73,7 @@ void sub_8015F84(void) s32 sub_8015FEC(u8 *buffer, s32 size) { - const struct unkChar *iVar2; + const unkChar *iVar2; s32 currLength; s32 length; u8 *bufferPtr; diff --git a/src/code_8015080.c b/src/code_8015080.c index ba719a8f7..5be6ad797 100644 --- a/src/code_8015080.c +++ b/src/code_8015080.c @@ -1,15 +1,16 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" -#include "input.h" -#include "memory.h" -#include "menu_input.h" -#include "text.h" -#include "sprite.h" #include "code_800D090.h" #include "code_80118A4.h" #include "code_803D0D8.h" -#include "text.h" +#include "input.h" +#include "memory.h" +#include "menu_input.h" +#include "sprite.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" struct unkStruct_203B1F8 { diff --git a/src/code_801602C.c b/src/code_801602C.c index c3320e8b1..fe42be4b4 100644 --- a/src/code_801602C.c +++ b/src/code_801602C.c @@ -1,15 +1,15 @@ #include "global.h" #include "globaldata.h" #include "code_8012A18_1.h" -#include "string_format.h" #include "code_801602C.h" #include "common_strings.h" #include "input.h" #include "memory.h" +#include "string_format.h" #include "text_util.h" -#include "text.h" +#include "text_1.h" -static EWRAM_INIT struct unkStruct_203B200 *sUnknown_203B200 = {NULL}; +EWRAM_INIT static struct unkStruct_203B200 *sUnknown_203B200 = {NULL}; #include "data/code_801602C.h" diff --git a/src/code_801B3C0.c b/src/code_801B3C0.c index c7079216d..0bc81bdac 100644 --- a/src/code_801B3C0.c +++ b/src/code_801B3C0.c @@ -1,18 +1,19 @@ #include "global.h" #include "globaldata.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_801B3C0.h" #include "input.h" #include "items.h" #include "memory.h" #include "menu_input.h" #include "sprite.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" -static EWRAM_INIT unkStruct_203B230 *sUnknown_203B230 = {NULL}; +static EWRAM_INIT unkStruct_203B230 *sUnknown_203B230 = { NULL }; -#include "data/code_801B3C0.h" // 80DBA4C +#include "data/code_801B3C0.h" static void sub_801B46C(u32); static void sub_801B480(void); diff --git a/src/code_801B60C.c b/src/code_801B60C.c index ae88c5fd0..d42ba3f1c 100644 --- a/src/code_801B60C.c +++ b/src/code_801B60C.c @@ -1,12 +1,11 @@ #include "global.h" #include "globaldata.h" +#include "constants/colors.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_801B3C0.h" #include "code_801B60C.h" #include "code_8099360.h" #include "common_strings.h" -#include "constants/colors.h" #include "event_flag.h" #include "input.h" #include "items.h" @@ -14,9 +13,10 @@ #include "memory.h" #include "menu_input.h" #include "pokemon.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" -static EWRAM_INIT unkStruct_203B234 *sUnknown_203B234 = {NULL}; +static EWRAM_INIT unkStruct_203B234 *sUnknown_203B234 = { NULL }; #include "data/code_801B60C.h" // 80DBA58 @@ -124,7 +124,7 @@ static void sub_801B760(void) case 13: case 14: case 15: - RestoreUnkTextStruct_8006518(&sUnknown_203B234->windows); + RestoreSavedWindows(&sUnknown_203B234->windows); for (i = 0; i < 4; i++) sUnknown_203B234->windows.id[i] = sUnknown_80DBA58; @@ -132,7 +132,7 @@ static void sub_801B760(void) ShowWindows(&sUnknown_203B234->windows, TRUE, TRUE); break; case 10: - RestoreUnkTextStruct_8006518(&sUnknown_203B234->windows); + RestoreSavedWindows(&sUnknown_203B234->windows); sub_801BB5C(); sUnknown_203B234->windows.id[2] = sUnknown_80DBA70; sub_8012CAC(&sUnknown_203B234->windows.id[2], sUnknown_203B234->unkCC); @@ -140,7 +140,7 @@ static void sub_801B760(void) ShowWindows(&sUnknown_203B234->windows, TRUE, TRUE); break; case 12: - RestoreUnkTextStruct_8006518(&sUnknown_203B234->windows); + RestoreSavedWindows(&sUnknown_203B234->windows); sUnknown_203B234->windows.id[1] = sUnknown_80DBA88; ResetUnusedInputStruct(); ShowWindows(&sUnknown_203B234->windows, TRUE, TRUE); diff --git a/src/code_801C8C4.c b/src/code_801C8C4.c index 76a38db8c..223bc4110 100644 --- a/src/code_801C8C4.c +++ b/src/code_801C8C4.c @@ -6,12 +6,13 @@ #include "items.h" #include "memory.h" #include "menu_input.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" -static EWRAM_INIT struct unkStruct_203B244 *sUnknown_203B244 = {NULL}; -static EWRAM_INIT u32 sUnknown_203B248 = {0}; -static EWRAM_INIT u16 sUnknown_203B24C = {0}; -static EWRAM_INIT u16 sUnknown_203B24E = {0}; +EWRAM_INIT static struct unkStruct_203B244 *sUnknown_203B244 = { NULL }; +EWRAM_INIT static u32 sUnknown_203B248 = {0}; +EWRAM_INIT static u16 sUnknown_203B24C = {0}; +EWRAM_INIT static u16 sUnknown_203B24E = {0}; #include "data/code_801C8C4.h" @@ -30,7 +31,7 @@ bool8 sub_801C8C4(s32 a0, s32 a1, DungeonPos *a2, u32 a3) sub_801CF94(); sUnknown_203B244->unk4B4.s0.unk34 = a1; sUnknown_203B244->unk4B4.s0.unk38 = &sUnknown_203B244->unk4B4.s0.windows.id[a1]; - RestoreUnkTextStruct_8006518(&sUnknown_203B244->unk4B4.s0.windows); + RestoreSavedWindows(&sUnknown_203B244->unk4B4.s0.windows); sUnknown_203B244->unk4B4.s0.windows.id[sUnknown_203B244->unk4B4.s0.unk34] = sUnknown_80DBE54; sUnknown_203B244->unk4B4.s0.unk38->header = &sUnknown_203B244->unk4B4.unk9C; diff --git a/src/code_801D014.c b/src/code_801D014.c index 69a1cea41..de746eabe 100644 --- a/src/code_801D014.c +++ b/src/code_801D014.c @@ -25,7 +25,9 @@ #include "party_list_menu.h" #include "rescue_team_info.h" #include "string_format.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" #include "wigglytuff_shop2.h" #include "wonder_mail_802C4C8.h" #include "wonder_mail_802C860.h" @@ -187,7 +189,7 @@ static void sub_801D220(void) { s32 i; - RestoreUnkTextStruct_8006518(&sUnknown_203B250->windows); + RestoreSavedWindows(&sUnknown_203B250->windows); switch (sUnknown_203B250->state) { case 0: diff --git a/src/code_801D9E4.c b/src/code_801D9E4.c index d3264dbf2..1d5ef6a9c 100644 --- a/src/code_801D9E4.c +++ b/src/code_801D9E4.c @@ -1,18 +1,19 @@ #include "global.h" #include "globaldata.h" +#include "constants/input.h" +#include "structs/struct_sub80095e4.h" #include "code_80118A4.h" #include "code_801D9E4.h" -#include "constants/input.h" #include "ground_main.h" #include "input.h" #include "memory.h" #include "menu_input.h" -#include "text.h" -#include "structs/struct_sub80095e4.h" +#include "text_1.h" +#include "text_2.h" -static EWRAM_INIT struct struct_Sub80095E4_2 *sUnknown_203B258 = {NULL}; +EWRAM_INIT static struct struct_Sub80095E4_2 *sUnknown_203B258 = {NULL}; -extern struct unkStruct_81188F0 gUnknown_81188F0[10]; +extern const struct unkStruct_81188F0 gUnknown_81188F0[10]; #include "data/code_801D9E4.h" @@ -24,7 +25,7 @@ bool8 sub_801D9E4(void) sUnknown_203B258 = MemoryAlloc(sizeof(*sUnknown_203B258), 8); sUnknown_203B258->s0.unk34 = 3; sUnknown_203B258->s0.unk38 = &sUnknown_203B258->s0.windows.id[3]; - RestoreUnkTextStruct_8006518(&sUnknown_203B258->s0.windows); + RestoreSavedWindows(&sUnknown_203B258->s0.windows); sUnknown_203B258->s0.windows.id[sUnknown_203B258->s0.unk34] = sUnknown_80DBF88; sUnknown_203B258->s0.unk38->header = &sUnknown_203B258->unk9C; ResetUnusedInputStruct(); @@ -104,7 +105,7 @@ static void sub_801DB54(void) static void sub_801DBD4(void) { GroundConversionStruct *temp; - struct unkStruct_81188F0 *temp2; + const struct unkStruct_81188F0 *temp2; s32 x, y, n; s16 index; int counter; diff --git a/src/code_801EE10.c b/src/code_801EE10.c index ce71e75c9..67b5a636a 100644 --- a/src/code_801EE10.c +++ b/src/code_801EE10.c @@ -1,17 +1,18 @@ #include "global.h" #include "globaldata.h" #include "constants/input.h" +#include "code_80118A4.h" +#include "code_801EE10.h" #include "input.h" #include "items.h" -#include "text.h" #include "memory.h" -#include "moves.h" -#include "code_801EE10.h" -#include "code_80118A4.h" #include "menu_input.h" +#include "moves.h" #include "string_format.h" +#include "text_1.h" +#include "text_2.h" -EWRAM_INIT unkStruct_203B270 *gUnknown_203B270 = {NULL}; +EWRAM_INIT unkStruct_203B270 *gUnknown_203B270 = { NULL }; const WindowTemplate gUnknown_80DC240 = { 0x00, @@ -84,7 +85,7 @@ u8 sub_801EE10(u32 param_1, s16 species, Move *moves, u32 param_4, const u8 *tex if (iVar8 < four) { iVar8 = 4; } - RestoreUnkTextStruct_8006518(&gUnknown_203B270->windows); + RestoreSavedWindows(&gUnknown_203B270->windows); gUnknown_203B270->unk50 = param_6; gUnknown_203B270->windows.id[param_6] = gUnknown_80DC25C; if (gUnknown_203B270->text != NULL) { diff --git a/src/code_801F428.c b/src/code_801F428.c index 8cef24760..125edddad 100644 --- a/src/code_801F428.c +++ b/src/code_801F428.c @@ -1,14 +1,15 @@ #include "global.h" #include "globaldata.h" -#include "code_80118A4.h" +#include "structs/struct_sub80095e4.h" #include "code_800D090.h" +#include "code_80118A4.h" #include "input.h" #include "memory.h" #include "menu_input.h" #include "moves.h" #include "pokemon.h" -#include "text.h" -#include "structs/struct_sub80095e4.h" +#include "text_1.h" +#include "text_2.h" struct unkStruct_203B274 { @@ -18,6 +19,7 @@ struct unkStruct_203B274 unkStruct_808E218_arg unk8; struct_Sub80095E4_2 s348; }; + EWRAM_INIT struct unkStruct_203B274 *gUnknown_203B274 = {NULL}; static const WindowTemplate sUnknown_80DC2AC = { @@ -53,7 +55,7 @@ bool8 sub_801F428(s16 index, s32 param_2) gUnknown_203B274->unk4 = &gUnknown_203B274->unk8; gUnknown_203B274->s348.s0.unk34 = param_2; gUnknown_203B274->s348.s0.unk38 = &gUnknown_203B274->s348.s0.windows.id[gUnknown_203B274->s348.s0.unk34]; - RestoreUnkTextStruct_8006518(&gUnknown_203B274->s348.s0.windows); + RestoreSavedWindows(&gUnknown_203B274->s348.s0.windows); gUnknown_203B274->s348.s0.windows.id[gUnknown_203B274->s348.s0.unk34] = sUnknown_80DC2C4; gUnknown_203B274->s348.s0.unk38->header = &gUnknown_203B274->s348.unk9C; gUnknown_203B274->s348.unk9C.count = 1; diff --git a/src/code_801F808.c b/src/code_801F808.c index dd8428b0c..7682e2653 100644 --- a/src/code_801F808.c +++ b/src/code_801F808.c @@ -1,15 +1,16 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" +#include "structs/menu.h" +#include "structs/str_text.h" #include "code_80118A4.h" #include "input.h" #include "memory.h" #include "menu_input.h" #include "moves.h" #include "sprite.h" -#include "structs/menu.h" -#include "structs/str_text.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" // TODO: UNIFY WITH struct_Sub80095E4 struct unkStruct_203B278 diff --git a/src/code_80227B8.c b/src/code_80227B8.c index 6f584aeb3..d7a4bf8a4 100644 --- a/src/code_80227B8.c +++ b/src/code_80227B8.c @@ -1,22 +1,22 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" +#include "constants/colors.h" +#include "code_80118A4.h" #include "code_801AFA4.h" #include "code_801B3C0.h" #include "code_80227B8.h" #include "code_8098BDC.h" #include "code_8099360.h" -#include "code_80118A4.h" #include "common_strings.h" -#include "constants/colors.h" #include "input.h" #include "kecleon_bros4.h" #include "memory.h" #include "menu_input.h" #include "pokemon_3.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" -static EWRAM_INIT unkStruct_203B294 *sUnknown_203B294 = {NULL}; +EWRAM_INIT static unkStruct_203B294 *sUnknown_203B294 = {NULL}; #include "data/code_80227B8.h" @@ -109,7 +109,7 @@ static void sub_802293C(void) { s32 i; - RestoreUnkTextStruct_8006518(&sUnknown_203B294->windows); + RestoreSavedWindows(&sUnknown_203B294->windows); switch (sUnknown_203B294->state) { case 2: diff --git a/src/code_8023144.c b/src/code_8023144.c index b48f81678..c925778c1 100644 --- a/src/code_8023144.c +++ b/src/code_8023144.c @@ -1,21 +1,22 @@ #include "global.h" #include "globaldata.h" +#include "constants/colors.h" +#include "constants/input.h" #include "code_800D090.h" #include "code_80118A4.h" #include "code_8023144.h" -#include "constants/colors.h" -#include "constants/input.h" #include "exclusive_pokemon.h" #include "friend_area.h" #include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon_3.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" -static EWRAM_INIT u32 gUnknown_203B298 = {1}; -static EWRAM_INIT u16 gUnknown_203B29C = {0}; -static EWRAM_INIT u16 gUnknown_203B29E = {0}; +EWRAM_INIT static u32 gUnknown_203B298 = {1}; +EWRAM_INIT static u16 gUnknown_203B29C = {0}; +EWRAM_INIT static u16 gUnknown_203B29E = {0}; EWRAM_INIT s32 gUnknown_203B2A0 = 2; EWRAM_INIT s32 gUnknown_203B2A4 = 1; EWRAM_INIT u16 gUnknown_203B2A8 = 0; @@ -48,7 +49,7 @@ bool8 sub_8023144(s32 a0, s32 index, DungeonPos *sub, u32 a3) gUnknown_3001B5C->s35C.s0.unk34 = index; gUnknown_3001B5C->s35C.s0.unk38 = &gUnknown_3001B5C->s35C.s0.windows.id[index]; - RestoreUnkTextStruct_8006518(&gUnknown_3001B5C->s35C.s0.windows); + RestoreSavedWindows(&gUnknown_3001B5C->s35C.s0.windows); gUnknown_3001B5C->s35C.s0.windows.id[gUnknown_3001B5C->s35C.s0.unk34] = sUnknown_80DC91C; gUnknown_3001B5C->s35C.s0.unk38->header = &gUnknown_3001B5C->s35C.unk9C; diff --git a/src/code_8024458.c b/src/code_8024458.c index 3b59376a8..2ecc7f8aa 100644 --- a/src/code_8024458.c +++ b/src/code_8024458.c @@ -1,15 +1,15 @@ #include "global.h" #include "globaldata.h" +#include "constants/input.h" #include "code_80118A4.h" #include "code_8024458.h" -#include "constants/input.h" #include "event_flag.h" #include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon.h" #include "pokemon_3.h" -#include "text.h" +#include "text_1.h" static EWRAM_INIT struct unkStruct_203B2AC *sUnknown_203B2AC = {NULL}; @@ -27,7 +27,7 @@ bool8 sub_8024458(s16 speciesNum, s32 a1) sUnknown_203B2AC->speciesNum = speciesNum_s32; sUnknown_203B2AC->unkE0 = a1; sUnknown_203B2AC->unkE4 = &sUnknown_203B2AC->unkE8.id[a1]; - RestoreUnkTextStruct_8006518(&sUnknown_203B2AC->unkE8); + RestoreSavedWindows(&sUnknown_203B2AC->unkE8); sUnknown_203B2AC->unkE8.id[sUnknown_203B2AC->unkE0] = sUnknown_80DC9C8; sUnknown_203B2AC->unkE4->header = &sUnknown_203B2AC->unk148; sUnknown_203B2AC->unk148.width = 10; diff --git a/src/code_802DB28.c b/src/code_802DB28.c index e47fe5a5c..2c9d80c0d 100644 --- a/src/code_802DB28.c +++ b/src/code_802DB28.c @@ -1,6 +1,5 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" #include "code_802DB28.h" #include "code_802F204.h" #include "code_803C1D0.h" @@ -10,9 +9,10 @@ #include "items.h" #include "memory.h" #include "pokemon.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" -static EWRAM_INIT struct unkStruct_203B2FC *sUnknown_203B2FC = {NULL}; +EWRAM_INIT static struct unkStruct_203B2FC *sUnknown_203B2FC = {NULL}; #include "data/code_802DB28.h" @@ -49,7 +49,7 @@ bool8 sub_802DB28(u8 jobSlotIndex, u8 dungeon) sUnknown_203B2FC->monPortrait.pos.y = 8; if (sUnknown_203B2FC->monPortrait.faceFile != NULL) - sUnknown_203B2FC->monPortrait.faceData = (struct PortraitGfx *) sUnknown_203B2FC->monPortrait.faceFile->data; + sUnknown_203B2FC->monPortrait.faceData = (PortraitGfx *) sUnknown_203B2FC->monPortrait.faceFile->data; sub_802DC28(0); return TRUE; @@ -92,7 +92,7 @@ static void sub_802DC40(void) { s32 i; - RestoreUnkTextStruct_8006518(&sUnknown_203B2FC->unk48); + RestoreSavedWindows(&sUnknown_203B2FC->unk48); switch (sUnknown_203B2FC->state) { case 0: diff --git a/src/code_802DE84.c b/src/code_802DE84.c index 71b567161..5dbceb436 100644 --- a/src/code_802DE84.c +++ b/src/code_802DE84.c @@ -6,7 +6,7 @@ #include "memory.h" #include "menu_input.h" #include "pokemon_mail.h" -#include "text.h" +#include "text_1.h" static EWRAM_INIT struct unkStruct_203B300 *sUnknown_203B300 = {NULL}; @@ -23,7 +23,7 @@ bool8 sub_802DE84(unkStruct_802C39C *mail) sub_801317C(&sUnknown_203B300->unk0); sUnknown_203B300->unk10 = sUnknown_203B300->mail->unk0[0]; sUnknown_203B300->unk14 = &sUnknown_203B300->unk18.id[sUnknown_203B300->unk10]; - RestoreUnkTextStruct_8006518(&sUnknown_203B300->unk18); + RestoreSavedWindows(&sUnknown_203B300->unk18); sUnknown_203B300->unk18.id[sUnknown_203B300->unk10] = sUnknown_80E0264; sub_802DF14(); return TRUE; diff --git a/src/code_8031D70.c b/src/code_8031D70.c index 987c8e593..7a13380c4 100644 --- a/src/code_8031D70.c +++ b/src/code_8031D70.c @@ -2,15 +2,17 @@ #include "globaldata.h" #include "constants/wonder_mail.h" #include "constants/colors.h" +#include "structs/str_dungeon.h" +#include "code_80118A4.h" #include "code_803D0D8.h" +#include "code_8094F88.h" #include "input.h" #include "memory.h" -#include "text.h" -#include "structs/str_dungeon.h" -#include "pokemon.h" -#include "code_8094F88.h" #include "menu_input.h" -#include "code_80118A4.h" +#include "pokemon.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" struct unkStruct_203B334 { @@ -59,7 +61,7 @@ bool8 sub_8031D70(u32 mailIndex, s32 param_2) sub_801317C(&gUnknown_203B334->unk4); gUnknown_203B334->unk10 = param_2; gUnknown_203B334->unk14 = &gUnknown_203B334->unk18.id[param_2]; - RestoreUnkTextStruct_8006518(&gUnknown_203B334->unk18); + RestoreSavedWindows(&gUnknown_203B334->unk18); gUnknown_203B334->unk18.id[gUnknown_203B334->unk10] = gUnknown_80E1FC4; sub_8031E00(); return TRUE; diff --git a/src/code_803D110.c b/src/code_803D110.c index b67ab5c7a..294c6d256 100644 --- a/src/code_803D110.c +++ b/src/code_803D110.c @@ -15,7 +15,8 @@ #include "game_options.h" #include "pokemon.h" #include "pokemon_3.h" -#include "text.h" +#include "text_1.h" +#include "text_3.h" extern s32 sub_80902C8(u8 dungeon); extern void sub_808E9C4(UnkDungeonGlobal_unk1CD98 *r0, s16 r1); diff --git a/src/code_803E46C.c b/src/code_803E46C.c index b46c936f0..3de72890d 100644 --- a/src/code_803E46C.c +++ b/src/code_803E46C.c @@ -1,5 +1,7 @@ #include "global.h" #include "structs/str_dungeon.h" +#include "bg_control.h" +#include "bg_palette_buffer.h" #include "code_8004AA0.h" #include "code_800558C.h" #include "code_8009804.h" @@ -9,14 +11,12 @@ #include "code_803E668.h" #include "code_803E724.h" #include "dungeon_map.h" -#include "bg_palette_buffer.h" -#include "bg_control.h" #include "dungeon_music.h" #include "game_options.h" #include "input.h" #include "play_time.h" #include "sprite.h" -#include "text.h" +#include "text_2.h" EWRAM_INIT u8 gUnknown_203B40C = 0; EWRAM_INIT u8 gUnknown_203B40D = 0; @@ -26,7 +26,7 @@ extern s32 gDungeonFramesCounter; extern u32 gUnknown_202EDD0; extern s32 gUnknown_202EDD4; -extern void sub_803E490(u32); +static void sub_803E490(u32); void xxx_draw_string_80524F0(void); void sub_8085F78(void); void sub_803F580(s32); @@ -48,7 +48,7 @@ void DungeonRunFrameActions(u32 a0) sub_803E668(a0); } -void sub_803E490(u32 unused) +static void sub_803E490(u32 unused) { gUnknown_202EDD4++; xxx_draw_string_80524F0(); diff --git a/src/code_803E724.c b/src/code_803E724.c index ee4bbcbad..fa8883ac3 100644 --- a/src/code_803E724.c +++ b/src/code_803E724.c @@ -1,31 +1,31 @@ #include "global.h" -#include "dungeon.h" -#include "bg_palette_buffer.h" -#include "code_8004AA0.h" -#include "input.h" -#include "text.h" -#include "code_801602C.h" -#include "menu_input.h" -#include "code_8009804.h" -#include "code_803E46C.h" -#include "dungeon_util.h" -#include "code_800E9E4.h" -#include "dungeon_pokemon_attributes.h" -#include "dungeon_map_access.h" -#include "sprite.h" -#include "bg_control.h" -#include "dungeon_map.h" -#include "game_options.h" -#include "code_800558C.h" -#include "dungeon_range.h" -#include "dungeon_message.h" -#include "code_806CD90.h" -#include "dungeon_items.h" #include "constants/item.h" #include "constants/status.h" -#include "code_803E724.h" #include "structs/str_202EDE8.h" +#include "bg_control.h" +#include "bg_palette_buffer.h" +#include "code_8004AA0.h" +#include "code_800558C.h" +#include "code_8009804.h" +#include "code_800E9E4.h" +#include "code_801602C.h" +#include "code_803E46C.h" +#include "code_803E724.h" +#include "code_806CD90.h" +#include "dungeon.h" +#include "dungeon_items.h" +#include "dungeon_map.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" #include "dungeon_music.h" +#include "dungeon_pokemon_attributes.h" +#include "dungeon_range.h" +#include "dungeon_util.h" +#include "game_options.h" +#include "input.h" +#include "menu_input.h" +#include "sprite.h" +#include "text_1.h" extern s32 gDungeonBrightness; extern u32 gUnknown_202EDD0; @@ -170,7 +170,7 @@ void sub_803EA10(void) SetBGPaletteBufferColorRGB(248, &gFontPalette[8], gDungeonBrightness, NULL); } -static const struct WindowTemplates gUnknown_80F62B0 = +static const WindowTemplates gUnknown_80F62B0 = { .id = { [0] = { @@ -188,7 +188,7 @@ static const struct WindowTemplates gUnknown_80F62B0 = } }; -static const struct WindowTemplates gUnknown_80F6310 = +static const WindowTemplates gUnknown_80F6310 = { .id = { [0] = { @@ -206,7 +206,7 @@ static const struct WindowTemplates gUnknown_80F6310 = } }; -static const struct WindowTemplates gUnknown_80F6370 = +static const WindowTemplates gUnknown_80F6370 = { .id = { [0] = { @@ -240,7 +240,7 @@ static const struct WindowTemplates gUnknown_80F6370 = } }; -static const struct WindowTemplates gUnknown_80F63D0 = +static const WindowTemplates gUnknown_80F63D0 = { .id = { [0] = { diff --git a/src/code_8040094.c b/src/code_8040094.c index 554ce0f0c..d4712b484 100644 --- a/src/code_8040094.c +++ b/src/code_8040094.c @@ -1,11 +1,11 @@ #include "global.h" +#include "structs/dungeon_entity.h" +#include "structs/str_dungeon.h" #include "code_800558C.h" #include "code_800C9CC.h" #include "code_80118A4.h" #include "def_filearchives.h" #include "dungeon_message.h" -#include "structs/dungeon_entity.h" -#include "structs/str_dungeon.h" #include "dungeon_map_access.h" #include "dungeon_music.h" #include "file_system.h" diff --git a/src/code_8040094_1.c b/src/code_8040094_1.c index 25e02a212..0b5f33dc7 100644 --- a/src/code_8040094_1.c +++ b/src/code_8040094_1.c @@ -17,6 +17,7 @@ #include "dungeon_music.h" #include "dungeon_random.h" #include "dungeon_util.h" +#include "sprite.h" #include "tile_types.h" #include "weather.h" @@ -32,7 +33,6 @@ struct UnkStruct_8040094 extern u8 sub_800EC94(s32 param_1); extern s32 sub_800E710(s32 a0, u16 a1); -extern void sub_800569C(DungeonPos *, axdata *, u8); extern void sub_800EEC8(u16 r0); extern void sub_8042DD4(s32 a0, Entity *a1, s32 a2); extern u8 sub_800EA44(s32 species, u16 a2); @@ -100,7 +100,7 @@ static void sub_8040C4C(Entity *entity, Move *move, bool32 a2) s32 r2 = sub_800E710(apparentId, sub_80412E0(move->id, GetApparentWeather(entity), TRUE)); if (r2 != -1) { - sub_800569C(&sp.unk8, &entity->axObj.axdata, r2); + sub_800569C(&sp.unk8, &entity->axObj, r2); } else { sp.unk8 = (DungeonPos) {0}; @@ -252,7 +252,7 @@ static void sub_8041038(struct UnkStruct_8040094 *a0, Entity *entity, Move *move s32 r2 = sub_800E710(entInfo->apparentID, sub_80412E0(move->id, GetApparentWeather(entity), a2)); if (r2 != -1) { - sub_800569C(&a0->unk8, &entity->axObj.axdata, r2); + sub_800569C(&a0->unk8, &entity->axObj, r2); } else { a0->unk8 = (DungeonPos) {0}; @@ -312,7 +312,7 @@ void sub_8041168(Entity *entity, Entity *entity2, Move *move, DungeonPos *pos) var2 = sub_800ECA4(var)->unk1c; if (var2 != -1) { if (EntityIsValid(entity2)) { - sub_800569C(&sp.unk8, &entity2->axObj.axdata, var2); + sub_800569C(&sp.unk8, &entity2->axObj, var2); } else { sp.unk8 = (DungeonPos) {0}; diff --git a/src/code_8041AD0.c b/src/code_8041AD0.c index 5f6d9ad44..d6e398968 100644 --- a/src/code_8041AD0.c +++ b/src/code_8041AD0.c @@ -1,5 +1,10 @@ #include "global.h" -#include "math.h" +#include "constants/direction.h" +#include "constants/status.h" +#include "constants/type.h" +#include "structs/dungeon_entity.h" +#include "structs/sprite_oam.h" +#include "structs/str_dungeon.h" #include "code_800558C.h" #include "code_800DAC0.h" #include "code_800E9A8.h" @@ -10,15 +15,11 @@ #include "code_804267C.h" #include "code_806CD90.h" #include "dungeon_config.h" -#include "constants/direction.h" -#include "constants/status.h" -#include "constants/type.h" #include "dungeon_pokemon_attributes.h" #include "dungeon_util.h" #include "items.h" -#include "structs/dungeon_entity.h" -#include "structs/sprite_oam.h" -#include "structs/str_dungeon.h" +#include "math.h" +#include "sprite.h" extern u32 gStatusSpriteMasks_SleepClassStatus[]; extern u32 gStatusSpriteMasks_BurnClassStatus[]; @@ -37,7 +38,6 @@ extern u32 gStatusSpriteMasks_MuzzledStatus[]; extern void sub_803ED30(u8, Entity *pokemon, u8, u8); extern u32 sub_806F62C(u32); extern u32 sub_800DC9C(s32 a0); -extern void sub_800569C(DungeonPos *, axdata *, u8); extern void PlaySoundEffect(u32); void EntityUpdateStatusSprites(Entity *entity); @@ -82,7 +82,7 @@ s32 sub_8041550(Entity *entity, s32 a1, u8 a2, u8 a3, s32 a4, u8 a5) sub_804178C(a4 == 2); } - sub_800569C(&pos, &entity->axObj.axdata, a3); + sub_800569C(&pos, &entity->axObj, a3); if (pos.x != 99 && pos.y != 99) { pixelPos.x = entity->pixelPos.x + (pos.x << 8); pixelPos.y = (entity->pixelPos.y + (pos.y << 8)) - entInfo->unk174.raw; diff --git a/src/code_804267C.c b/src/code_804267C.c index 698c8c56a..d32435619 100644 --- a/src/code_804267C.c +++ b/src/code_804267C.c @@ -1,21 +1,22 @@ #include "global.h" +#include "structs/str_dungeon.h" #include "code_800DAC0.h" #include "code_800ED38.h" -#include "code_8041AD0.h" -#include "code_804267C.h" #include "code_803E46C.h" #include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" #include "code_8045A00.h" #include "code_806CD90.h" #include "dungeon.h" #include "dungeon_engine.h" -#include "dungeon_map.h" #include "dungeon_leader.h" +#include "dungeon_map.h" #include "dungeon_message.h" #include "dungeon_music.h" #include "dungeon_util.h" #include "items.h" -#include "structs/str_dungeon.h" +#include "sprite.h" extern const u16 gUnknown_80F67DC[4]; extern const u16 gUnknown_80F67E4[4]; @@ -35,7 +36,6 @@ extern u8 GetFloorType(void); extern bool8 sub_8045888(Entity *); extern s32 sub_80416E0(PixelPos*, u32, bool8); extern u32 sub_8041764(unkStruct_80416E0 *, bool8); -extern void sub_8005700(DungeonPos *a0, struct axObject *a1); extern u32 sub_800E49C(); extern void sub_800EF40(u8 r0, u8 r1); diff --git a/src/code_8042B34.c b/src/code_8042B34.c index d00038383..561a67977 100644 --- a/src/code_8042B34.c +++ b/src/code_8042B34.c @@ -1,53 +1,54 @@ #include "global.h" -#include "dungeon_util_1.h" -#include "memory.h" -#include "structs/rgb.h" -#include "structs/sprite_oam.h" -#include "structs/str_dungeon_8042F6C.h" -#include "code_800558C.h" -#include "code_803D110.h" -#include "code_803E46C.h" -#include "code_803E724.h" -#include "code_800E9E4.h" -#include "code_800DAC0.h" -#include "code_800E9A8.h" -#include "dungeon_util.h" -#include "dungeon_message.h" -#include "dungeon_generation.h" -#include "bg_control.h" -#include "random.h" -#include "file_system.h" -#include "dungeon_leader.h" -#include "dungeon.h" -#include "dungeon_ai.h" -#include "pokemon.h" -#include "cpu.h" -#include "dungeon_music.h" -#include "dungeon_random.h" -#include "code_8009804.h" -#include "tile_types.h" -#include "text.h" -#include "code_805D8C8.h" -#include "code_803E668.h" -#include "dungeon_engine.h" -#include "dungeon_map_access.h" -#include "pokemon.h" -#include "weather.h" -#include "moves.h" -#include "code_8094F88.h" -#include "code_8099360.h" -#include "bg_palette_buffer.h" -#include "exclusive_pokemon.h" #include "constants/dungeon.h" #include "constants/monster.h" #include "constants/trap.h" -#include "dungeon_serializer.h" -#include "dungeon_config.h" -#include "dungeon_map.h" -#include "dungeon_items.h" -#include "dungeon_misc.h" -#include "code_8042B34.h" +#include "structs/rgb.h" +#include "structs/sprite_oam.h" +#include "structs/str_dungeon_8042F6C.h" +#include "bg_control.h" +#include "bg_palette_buffer.h" +#include "code_800558C.h" +#include "code_8009804.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "code_800E9E4.h" #include "code_800ED38.h" +#include "code_803D110.h" +#include "code_803E46C.h" +#include "code_803E668.h" +#include "code_803E724.h" +#include "code_8042B34.h" +#include "code_805D8C8.h" +#include "code_8094F88.h" +#include "code_8099360.h" +#include "cpu.h" +#include "dungeon.h" +#include "dungeon_ai.h" +#include "dungeon_config.h" +#include "dungeon_engine.h" +#include "dungeon_generation.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_misc.h" +#include "dungeon_music.h" +#include "dungeon_random.h" +#include "dungeon_serializer.h" +#include "dungeon_util.h" +#include "dungeon_util_1.h" +#include "exclusive_pokemon.h" +#include "file_system.h" +#include "memory.h" +#include "moves.h" +#include "pokemon.h" +#include "random.h" +#include "sprite.h" +#include "text_1.h" +#include "text_3.h" +#include "tile_types.h" +#include "weather.h" extern void sub_800F15C(s32); @@ -226,7 +227,6 @@ void sub_8042E98(void) } } -extern void sub_800569C(DungeonPos *, axdata *, u8); extern void sub_800EB24(s32 param_1, DungeonPos *param_2, DungeonPos *param_3, s32 param_4, s32 param_5); @@ -243,7 +243,7 @@ void sub_8042EC8(Entity *a0, s32 a1) if (strPtr->unk8 != -1) { sub_800569C(&sp4, - &a0->axObj.axdata, + &a0->axObj, strPtr->unk8); } diff --git a/src/code_8066D04.c b/src/code_8066D04.c index 7dad6e2df..7a6a0b22b 100644 --- a/src/code_8066D04.c +++ b/src/code_8066D04.c @@ -34,9 +34,10 @@ #include "pokemon.h" #include "pokemon_3.h" #include "position_util.h" +#include "sprite.h" #include "status_checks_1.h" #include "string_format.h" -#include "text.h" +#include "text_1.h" #include "trap.h" extern u8 *gUnknown_80F8BE0[]; diff --git a/src/code_8069E0C.c b/src/code_8069E0C.c index e00ca610b..41866d6d0 100644 --- a/src/code_8069E0C.c +++ b/src/code_8069E0C.c @@ -1,45 +1,46 @@ #include "global.h" -#include "code_800F958.h" -#include "code_803E46C.h" -#include "code_803E668.h" -#include "code_8041AD0.h" -#include "code_8045A00.h" -#include "code_805D8C8.h" -#include "code_804267C.h" -#include "random.h" #include "constants/ability.h" +#include "constants/iq_skill.h" #include "constants/move_id.h" #include "constants/status.h" #include "constants/type.h" #include "constants/weather.h" +#include "structs/dungeon_entity.h" +#include "structs/str_202ED28.h" +#include "structs/str_806B7F8.h" +#include "structs/str_dungeon.h" +#include "code_800F958.h" +#include "code_803E46C.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_8045A00.h" +#include "code_805D8C8.h" +#include "code_806CD90.h" +#include "code_8077274_1.h" +#include "dungeon_config.h" #include "dungeon_engine.h" #include "dungeon_leader.h" #include "dungeon_map_access.h" +#include "dungeon_misc.h" #include "dungeon_movement.h" #include "dungeon_pokemon_attributes.h" #include "dungeon_random.h" #include "dungeon_message.h" #include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "file_system.h" #include "move_effects_target.h" #include "moves.h" -#include "pokemon.h" -#include "structs/dungeon_entity.h" -#include "structs/str_dungeon.h" -#include "weather.h" -#include "file_system.h" -#include "tile_types.h" -#include "position_util.h" -#include "exclusive_pokemon.h" #include "number_util.h" +#include "pokemon.h" #include "pokemon_3.h" -#include "code_8077274_1.h" -#include "code_806CD90.h" +#include "position_util.h" +#include "random.h" +#include "sprite.h" #include "status_checks_1.h" -#include "constants/iq_skill.h" -#include "structs/str_806B7F8.h" -#include "structs/str_202ED28.h" -#include "dungeon_config.h" -#include "dungeon_misc.h" +#include "tile_types.h" +#include "weather.h" extern void sub_8042900(Entity *r0); extern void sub_8042968(Entity *r0); @@ -66,7 +67,6 @@ extern void sub_80429E8(Entity *r0); extern s32 sub_803DA20(s32 param_1); extern s32 gDungeonFramesCounter; extern void sub_800F958(s32 dungeonSpriteID, DungeonPos *pos, DungeonPos *statusOffsets, u32 a3); -extern void sub_8005700(DungeonPos *a0, struct axObject *a1); extern void sub_8042EC8(Entity *a0, s32 a1); extern Entity *sub_804550C(s16 a); extern Entity *sub_80453AC(s16 id); diff --git a/src/code_806CD90.c b/src/code_806CD90.c index 41748231f..4a47fb793 100644 --- a/src/code_806CD90.c +++ b/src/code_806CD90.c @@ -1,40 +1,39 @@ #include "global.h" -#include "code_806CD90.h" -#include "code_803E46C.h" -#include "code_805D8C8.h" #include "constants/direction.h" #include "constants/status.h" #include "constants/ability.h" #include "constants/type.h" #include "constants/dungeon.h" #include "constants/iq_skill.h" -#include "dungeon_util.h" -#include "code_803E668.h" -#include "exclusive_pokemon.h" -#include "code_8077274_1.h" -#include "dungeon_misc.h" -#include "code_8045A00.h" -#include "position_util.h" -#include "game_options.h" -#include "dungeon_items.h" -#include "status.h" -#include "pokemon.h" -#include "random.h" -#include "dungeon_misc.h" -#include "sprite.h" #include "structs/str_dungeon.h" -#include "tile_types.h" -#include "dungeon_capabilities.h" -#include "dungeon_random.h" -#include "text_util.h" -#include "dungeon_visibility.h" -#include "code_804267C.h" -#include "move_effects_target.h" -#include "dungeon_pokemon_attributes.h" +#include "code_803E46C.h" +#include "code_803E668.h" #include "code_8041AD0.h" -#include "dungeon_message.h" -#include "dungeon_map_access.h" +#include "code_804267C.h" +#include "code_8045A00.h" +#include "code_805D8C8.h" +#include "code_806CD90.h" +#include "code_8077274_1.h" +#include "dungeon_capabilities.h" #include "dungeon_config.h" +#include "dungeon_items.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_pokemon_attributes.h" +#include "dungeon_random.h" +#include "dungeon_misc.h" +#include "dungeon_util.h" +#include "dungeon_visibility.h" +#include "exclusive_pokemon.h" +#include "game_options.h" +#include "move_effects_target.h" +#include "pokemon.h" +#include "position_util.h" +#include "random.h" +#include "sprite.h" +#include "status.h" +#include "text_util.h" +#include "tile_types.h" extern u8 gUnknown_202F221; diff --git a/src/code_8072F3C.c b/src/code_8072F3C.c index 17ff7d44d..d3745ce03 100644 --- a/src/code_8072F3C.c +++ b/src/code_8072F3C.c @@ -1,15 +1,15 @@ #include "global.h" #include "globaldata.h" #include "constants/input.h" +#include "structs/struct_sub80095e4.h" #include "code_80118A4.h" #include "code_80958E8.h" #include "code_80A26CC.h" #include "input.h" #include "memory.h" #include "menu_input.h" -#include "text.h" -#include "structs/struct_sub80095e4.h" - +#include "text_1.h" +#include "text_2.h" struct unkStruct_203B314 { @@ -77,7 +77,7 @@ u32 sub_802F73C(u32 r0, DungeonPos *r1, u32 r2, u8 r3) gUnknown_203B314->unkB8 = r3; gUnknown_203B314->sBC.s0.unk34 = r0; gUnknown_203B314->sBC.s0.unk38 = &gUnknown_203B314->sBC.s0.windows.id[gUnknown_203B314->sBC.s0.unk34]; - RestoreUnkTextStruct_8006518(&gUnknown_203B314->sBC.s0.windows); + RestoreSavedWindows(&gUnknown_203B314->sBC.s0.windows); if (r3 != 0) gUnknown_203B314->sBC.s0.windows.id[gUnknown_203B314->sBC.s0.unk34] = gUnknown_80E072C; diff --git a/src/code_807E5AC.c b/src/code_807E5AC.c index 8567c4638..eec543689 100644 --- a/src/code_807E5AC.c +++ b/src/code_807E5AC.c @@ -36,6 +36,7 @@ #include "constants/type.h" #include "dungeon_misc.h" #include "code_807E5AC.h" +#include "sprite.h" extern OpenedFile *gUnknown_202ECA0; extern SpriteOAM gUnknown_202EDC0; diff --git a/src/code_808333C.c b/src/code_808333C.c index 5a6a97171..c1978c7f7 100644 --- a/src/code_808333C.c +++ b/src/code_808333C.c @@ -1,6 +1,7 @@ #include "global.h" #include "structs/str_dungeon.h" #include "structs/str_202ED28.h" +#include "sprite.h" bool8 sub_8083568(s32 inX, s32 inY, u8 index) { diff --git a/src/code_80861A8.c b/src/code_80861A8.c index b25216b8a..631569927 100644 --- a/src/code_80861A8.c +++ b/src/code_80861A8.c @@ -9,6 +9,7 @@ #include "code_80861A8.h" #include "dungeon_music.h" #include "dungeon_util.h" +#include "sprite.h" extern const unkStruct_2039DB0 gUnknown_8107380; @@ -21,7 +22,6 @@ extern const u8 *gUnknown_810671C[]; static void sub_80861EC(Entity *); s32 sub_800E700(s32); -void sub_800569C(DungeonPos *, axdata *, u8); void sub_8085F44(s32); void sub_8052FB8(const u8 *); @@ -95,7 +95,7 @@ s32 sub_80861F8(s32 param_1,Entity *param_2,bool32 param_3) pos.y = 0; uStack_38 = sub_800E700(param_1Copy); if (uStack_38 != -1) { - sub_800569C(&pos,¶m_2->axObj.axdata,uStack_38); + sub_800569C(&pos, ¶m_2->axObj, uStack_38); } stack.unk0 = param_1Copy; stack.unk4 = 0; diff --git a/src/code_809447C.c b/src/code_809447C.c index 3c62dcdfa..7f30365cb 100644 --- a/src/code_809447C.c +++ b/src/code_809447C.c @@ -1,13 +1,14 @@ #include "global.h" -#include "string_format.h" +#include "structs/str_dungeon.h" #include "code_8092334.h" #include "code_809447C.h" #include "dungeon.h" -#include "structs/str_dungeon.h" #include "items.h" #include "moves.h" +#include "string_format.h" +#include "text_1.h" +#include "text_3.h" #include "text_util.h" -#include "text.h" struct unkStruct_8113080 { diff --git a/src/code_80972F4.c b/src/code_80972F4.c index 11702506b..ff51aa34a 100644 --- a/src/code_80972F4.c +++ b/src/code_80972F4.c @@ -12,6 +12,7 @@ ALIGNED(4) const u8 gDummyScenarioText[] = _("{COLOR YELLOW_C}Scenario try dummy{RESET}"); ALIGNED(4) const u8 gBlankMission[] = _("{COLOR RED_W}???{RESET}"); +// arm9.bin::020688A8 void sub_80972F4(void) { ClearScriptVarArray(NULL, RESCUE_SCENARIO_ORDER_LIST); diff --git a/src/code_8097DD0.c b/src/code_8097DD0.c index b0ddac682..acd506508 100644 --- a/src/code_8097DD0.c +++ b/src/code_8097DD0.c @@ -1,6 +1,6 @@ #include "global.h" #include "structs/str_status_text.h" -#include "decompress.h" +#include "decompress_3.h" static bool8 AreStatusesTheSame(const StatusText *status1, const StatusText *status2) { diff --git a/src/code_8099360.c b/src/code_8099360.c index 617bd7409..022804d9b 100644 --- a/src/code_8099360.c +++ b/src/code_8099360.c @@ -4,20 +4,19 @@ #include "def_filearchives.h" #include "event_flag.h" #include "file_system.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" -extern const u8 gUnknown_811601C[]; extern u8 gUnknown_20398B8; +extern const u8 gUnknown_811601C[]; + extern void sub_8003600(void); - extern s32 sub_800388C(u16, const u8 *, u8); - +extern void sub_8099690(u32); extern void sub_80A4B38(void); extern void sub_80A4B54(void); -extern void sub_8099690(u32); - bool8 sub_8099360(u8 *dungeonId) { s16 script_disc; DungeonInfo* dungeonInfo; diff --git a/src/code_809A560.c b/src/code_809A560.c index 6b0ca4df7..9d57f7f31 100644 --- a/src/code_809A560.c +++ b/src/code_809A560.c @@ -1,37 +1,37 @@ #include "global.h" #include "globaldata.h" -#include "text.h" -#include "memory.h" -#include "pokemon.h" -#include "ground_script.h" -#include "code_8099360.h" -#include "code_800D090.h" -#include "code_800558C.h" -#include "pokemon_mid.h" -#include "string_format.h" -#include "structs/str_3001B64.h" #include "constants/dungeon.h" -#include "wigglytuff_shop1.h" -#include "event_flag.h" -#include "input.h" -#include "ground_main.h" +#include "structs/str_3001B64.h" +#include "code_800558C.h" +#include "code_800D090.h" +#include "code_80118A4.h" #include "code_801D014.h" +#include "code_8099360.h" +#include "credits2.h" +#include "event_flag.h" +#include "felicity_bank.h" +#include "flash.h" +#include "friend_list_menu.h" +#include "ground_main.h" +#include "ground_script.h" +#include "gulpin_shop_801FB50.h" +#include "input.h" #include "kangaskhan_storage1.h" #include "kangaskhan_storage2.h" -#include "felicity_bank.h" #include "kecleon_bros1.h" -#include "gulpin_shop_801FB50.h" +#include "main_loops.h" +#include "memory.h" +#include "personality_test1.h" +#include "pokemon.h" +#include "pokemon_mid.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" +#include "wigglytuff_shop1.h" #include "wigglytuff_shop3.h" #include "wonder_mail.h" -#include "flash.h" -#include "code_80118A4.h" -#include "friend_list_menu.h" -#include "personality_test1.h" -#include "credits2.h" -#include "main_loops.h" -#include "string_format.h" -IWRAM_INIT struct unkStruct_3001B64 *gUnknown_3001B64 = {NULL}; +IWRAM_INIT struct unkStruct_3001B64 *gUnknown_3001B64 = { NULL }; extern u16 gUnknown_20399DC; extern u16 gUnknown_20399DE; @@ -606,7 +606,7 @@ bool8 sub_809ADD8(s32 a0_, struct unkStruct_3001B64_sub_sub *a1) return TRUE; } -struct MonPortraitMsg *sub_809AE3C(s32 a0_) +MonPortraitMsg *sub_809AE3C(s32 a0_) { s32 a0 = (s16) a0_; diff --git a/src/code_809D148.c b/src/code_809D148.c index 07294bebc..4c5a06c4d 100644 --- a/src/code_809D148.c +++ b/src/code_809D148.c @@ -1,8 +1,9 @@ #include "global.h" #include "structs/str_position.h" -#include "other_random.h" +#include "code_8002774.h" #include "math.h" #include "memory.h" +#include "other_random.h" struct unkStruct_20399E8 { @@ -255,8 +256,6 @@ u8 sub_809D248(PixelPos *r0) extern s32 sub_80A8FD8(s16 a0, PixelPos *a1); extern s32 sub_80AC448(s16 a0, PixelPos *a1); extern s32 sub_80AD360(s16 a0, PixelPos *a1); -extern void sub_800290C(PixelPos *a0, s32 a1); -extern void sub_8002934(PixelPos *a0, PixelPos *a1, PixelPos *a2, u32 a3, u32 a4); extern bool8 sub_80A579C(PixelPos *a0, PixelPos *a1); void sub_809D25C(void) diff --git a/src/code_80A7714.c b/src/code_80A7714.c index db09f68c6..355aa6195 100644 --- a/src/code_80A7714.c +++ b/src/code_80A7714.c @@ -2,8 +2,8 @@ #include "structs/axdata.h" extern void sub_80A68A0(u32); -extern void sub_80A7094(struct axPokemon *, u32, u32, u32); -extern void sub_80A7310(struct axPokemon *, u32, u32, u32); +extern void sub_80A7094(axPokemon *, u32, u32, u32); +extern void sub_80A7310(axPokemon *, u32, u32, u32); extern void ResetCurrentScriptFile(); static EWRAM_DATA s16 sUnknown_2039DE0 = {0}; @@ -16,7 +16,7 @@ void sub_80A7714(u32 a0) sub_80A68A0(a0); } -void sub_80A7720(struct axPokemon *a0, u32 a1, u32 a2) +void sub_80A7720(axPokemon *a0, u32 a1, u32 a2) { sub_80A7094(a0, 0, a1, a2); sub_80A7310(a0, a1, 0, a2); diff --git a/src/cpu.c b/src/cpu.c index 815c4ec15..e6d7cc6d5 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -28,6 +28,7 @@ u32 sub_800CDC8(void) return gUnknown_202D800; } +// arm9.bin::02007FF4 void SetWindowTitle(const u8 *title) { } @@ -45,11 +46,13 @@ UNUSED static bool8 sub_800CDE0(void) return TRUE; } +// In NDS, this func is copied to 01FF9FC4 void CpuCopy(void *dest, const void *src, s32 size) { CpuCopy32(src, dest, size); } +// In NDS, this func is copied to 01FF9FB0 void CpuClear(void *dest, s32 size) { CpuFill32(NULL, dest, size); diff --git a/src/credits1.c b/src/credits1.c index 1d66e0026..6e8fd2aae 100644 --- a/src/credits1.c +++ b/src/credits1.c @@ -4,9 +4,10 @@ #include "event_flag.h" #include "input.h" #include "memory.h" -#include "text.h" +#include "text_1.h" +#include "text_3.h" -static EWRAM_INIT Credits1Work *sCredits1Work = {NULL}; +EWRAM_INIT static Credits1Work *sCredits1Work = {NULL}; extern const WindowTemplate gUnknown_80E4A10; extern const WindowTemplate gUnknown_80E4A28; diff --git a/src/data/decompress.h b/src/data/decompress.h deleted file mode 100644 index 30dadcf53..000000000 --- a/src/data/decompress.h +++ /dev/null @@ -1 +0,0 @@ -static const u32 gByteShiftLookup[4] = {0, 8, 16, 24}; \ No newline at end of file diff --git a/src/data/decompress_at.h b/src/data/decompress_at.h new file mode 100644 index 000000000..9bf9d1259 --- /dev/null +++ b/src/data/decompress_at.h @@ -0,0 +1 @@ +static const u32 gByteShiftLookup[4] = {0, 8, 16, 24}; // NDS=020831CC \ No newline at end of file diff --git a/src/data/text.h b/src/data/text.h new file mode 100644 index 000000000..d6f2b6dbb --- /dev/null +++ b/src/data/text.h @@ -0,0 +1,76 @@ +const u32 gUnknown_80B853C[16] = +{ + 0x66666666, + 0x00000000, + 0x11111111, + 0x22222222, + 0x33333333, + 0x44444444, + 0x55555555, + 0x66666666, + 0x77777777, + 0x88888888, + 0x99999999, + 0xAAAAAAAA, + 0xBBBBBBBB, + 0xCCCCCCCC, + 0xDDDDDDDD, + 0xEEEEEEEE, +}; + +static const WindowTemplates sDummyWindows = +{ + .id = { + [0] = WIN_TEMPLATE_DUMMY, + [1] = WIN_TEMPLATE_DUMMY, + [2] = WIN_TEMPLATE_DUMMY, + [3] = WIN_TEMPLATE_DUMMY, + } +}; + +const unkShiftData gCharMasksOffsets[8] = +{ + [0] = {.bytesA = 0xFFFFFFFF, .bytesB = 0x00000000, .shift_left = 0x00, .shift_right = 0x20}, + [1] = {.bytesA = 0x0FFFFFFF, .bytesB = 0xF0000000, .shift_left = 0x04, .shift_right = 0x1C}, + [2] = {.bytesA = 0x00FFFFFF, .bytesB = 0xFF000000, .shift_left = 0x08, .shift_right = 0x18}, + [3] = {.bytesA = 0x000FFFFF, .bytesB = 0xFFF00000, .shift_left = 0x0C, .shift_right = 0x14}, + [4] = {.bytesA = 0x0000FFFF, .bytesB = 0xFFFF0000, .shift_left = 0x10, .shift_right = 0x10}, + [5] = {.bytesA = 0x00000FFF, .bytesB = 0xFFFFF000, .shift_left = 0x14, .shift_right = 0x0C}, + [6] = {.bytesA = 0x000000FF, .bytesB = 0xFFFFFF00, .shift_left = 0x18, .shift_right = 0x08}, + [7] = {.bytesA = 0x0000000F, .bytesB = 0xFFFFFFF0, .shift_left = 0x1C, .shift_right = 0x04}, +}; + +static const u16 sUnknown_80B865C[] = +{ + 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, + 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, + 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, + 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, + 0xFF, 0, 0, 0, 0, 0, 0 +}; + +// Fallback character with bitmap? +const unkChar gUnknown_80B86A4 = +{ + .unk0 = sUnknown_80B865C, + .unk4 = 0x81A1, + .unk6 = 7, + .unk8 = 10, + .fill9 = 0, + .unkA = 0, + .fillB = 0, +}; + +// Very weird... +UNUSED static const u8 sByte8 = 8; + +const u32 gUnknown_80B86B4[][32] = INCBIN_U32("graphics/warning.4bpp"); + +static const u8 sKanjiA_file_string[] = "kanji_a"; +static const u8 sKanjiB_file_string[] = "kanji_b"; + +static const u32 sFadeInNone[8] = {0}; +static const u32 sFadeInDungeon[8] = {0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888}; + +static const u32 sUnknown_80B8804[4] = {0, 1, 2, 3}; +static const u32 sUnknown_80B8814[4] = {1, 2, 3, 0}; \ No newline at end of file diff --git a/src/debug.c b/src/debug.c index 805565f8d..3f1b75d13 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1,24 +1,10 @@ #include "global.h" #include "debug.h" -extern void Hang(); -static void FatalErrorHang(void) __attribute__((noreturn)); +static EWRAM_INIT bool32 gNDS_DebugEnabled = {0}; // NDS=020EACE4 +static EWRAM_INIT u8 gUnknown_203B150 = {0}; -EWRAM_INIT bool32 gNDS_DebugEnabled = {0}; -EWRAM_INIT u8 gUnknown_203B150 = {0}; - -ALIGNED(4) const char gFuncFileLineString[] = "func = '%s'\nfile = '%s' line = %5d"; - -ALIGNED(4) const char gNotEntryText[] = "--- not entry ---"; -ALIGNED(4) const char gFuncFileLineStringWPrefix[] = "%sfunc = '%s'\nfile = '%s' line = %5d\n"; - -ALIGNED(4) const char gFuncFileLineString2[] = "func = '%s'\nfile = '%s' line = %5d\n"; - -ALIGNED(4) const char debug_fill14[] = "pksdir0"; -ALIGNED(4) const char gDebugPrintPrefix[] = " Print "; -ALIGNED(4) static const char debug_fill13[] = "pksdir0"; - -static UNUSED EWRAM_INIT const char *sUnusedEwramDebugStrings[] = +UNUSED static EWRAM_INIT const char *sUnusedEwramDebugStrings[] = { "Ground", "GroundScript", @@ -32,14 +18,25 @@ static UNUSED EWRAM_INIT const char *sUnusedEwramDebugStrings[] = "Performance", }; -ALIGNED(4) const char gNotMountText[] = "not mount log system"; +ALIGNED(4) static const char gFuncFileLineString[] = "func = '%s'\nfile = '%s' line = %5d"; + +ALIGNED(4) static const char gNotEntryText[] = "--- not entry ---"; +ALIGNED(4) static const char gFuncFileLineStringWPrefix[] = "%sfunc = '%s'\nfile = '%s' line = %5d\n"; + +ALIGNED(4) static const char gFuncFileLineString2[] = "func = '%s'\nfile = '%s' line = %5d\n"; + +ALIGNED(4) static const char debug_fill14[] = "pksdir0"; +ALIGNED(4) static const char gDebugPrintPrefix[] = " Print "; +ALIGNED(4) static const char debug_fill13[] = "pksdir0"; + +ALIGNED(4) static const char gNotMountText[] = "not mount log system"; ALIGNED(4) static const char debug_fill9[] = "pksdir0"; ALIGNED(4) static const char debug_fill10[] = "pksdir0"; ALIGNED(4) static const char debug_fill11[] = "pksdir0"; ALIGNED(4) static const char debug_fill12[] = "pksdir0"; -ALIGNED(4) const char gFatalText[] = "!!!!! Fatal !!!!!\n"; -ALIGNED(4) const char gFatalErrorBufferPlaceholder[] = "%s\n"; +ALIGNED(4) static const char gFatalText[] = "!!!!! Fatal !!!!!\n"; +ALIGNED(4) static const char gFatalErrorBufferPlaceholder[] = "%s\n"; ALIGNED(4) static const char debug_fill0[] = "pksdir0"; ALIGNED(4) static const char debug_fill1[] = "pksdir0"; @@ -50,6 +47,21 @@ ALIGNED(4) static const char debug_fill5[] = "pksdir0"; ALIGNED(4) static const char debug_fill6[] = "pksdir0"; ALIGNED(4) static const char debug_fill7[] = "pksdir0"; +extern void Hang(); + +static void FatalErrorFormatMessage(const u8 *text, ...); +static void FatalErrorHang(void) NORETURN; +static void FatalErrorPrintFuncFileLine(const u8 *prefix, const DebugLocation *debug); +static void nullsub_26(void); +static void nullsub_27(void); +static void nullsub_28(void); +static void nullsub_29(void); +static void nullsub_30(void); +static void nullsub_31(void); +static void nullsub_32(void); +static void PrintFuncFileLine(u8 *buf, const DebugLocation *loc, const u8 *prefix); + +// arm9.bin::0201888C void NDS_DebugInit(void) { nullsub_26(); @@ -66,7 +78,7 @@ void nullsub_25(void) { } -void nullsub_26(void) +static void nullsub_26(void) { } @@ -78,12 +90,12 @@ UNUSED static void PrintFuncFileLineOrNotEntry(u8 *buf, DebugLocation *debug) sprintf(buf, gNotEntryText); } -void PrintFuncFileLine(u8 *buf, const DebugLocation *loc, const u8* prefix) +static void PrintFuncFileLine(u8 *buf, const DebugLocation *loc, const u8* prefix) { sprintf(buf, gFuncFileLineStringWPrefix, prefix, loc->func, loc->file, loc->line); } -void PrintMessageWithFuncFileLine(u8 *buffer, const DebugLocation *debug, const u8 *text, ...) +UNUSED static void PrintMessageWithFuncFileLine(u8 *buffer, const DebugLocation *debug, const u8 *text, ...) { va_list vArgv; u32 length; @@ -95,103 +107,99 @@ void PrintMessageWithFuncFileLine(u8 *buffer, const DebugLocation *debug, const va_end(vArgv); } -void nullsub_199(void) +UNUSED static void nullsub_199(void) { } -void nullsub_27(void) +static void nullsub_27(void) { } -// Unused -void sub_8011B08(void) +UNUSED static void sub_8011B08(void) { gUnknown_203B150 = 1; } -// Unused -void sub_8011B14(void) +UNUSED static void sub_8011B14(void) { gUnknown_203B150 = 0; } -// Unused -u8 sub_8011B20(void) +UNUSED static u8 sub_8011B20(void) { gUnknown_203B150 = !gUnknown_203B150; return gUnknown_203B150; } -// unused -u8 sub_8011B3C(void) +UNUSED static u8 sub_8011B3C(void) { return gUnknown_203B150; } -// unused -void nullsub_137(void) +UNUSED static void nullsub_137(void) { } -static void FatalErrorPrintFuncFileLine(const char *prefix, const DebugLocation *debug) +static void FatalErrorPrintFuncFileLine(const u8 *prefix, const DebugLocation *debug) { char buf[0x100]; - if(prefix != NULL){ + + if (prefix != NULL) PrintFuncFileLine(buf, debug, prefix); - } else - { PrintFuncFileLine(buf, debug, gDebugPrintPrefix); - } } -static void FatalErrorFormatMessage(const char *text, ...) +static void FatalErrorFormatMessage(const u8 *text, ...) { char bufPrint[0x100]; + va_list vArgv; va_start(vArgv, text); vsprintf(bufPrint, text, vArgv); va_end(vArgv); } - -void sub_8011B88(const u8 *text, ...) +UNUSED static void sub_8011B88(const u8 *text, ...) { char bufPrint[0x100]; + va_list vArgv; va_start(vArgv, text); vsprintf(bufPrint, text, vArgv); va_end(vArgv); } -void nullsub_28(void) +// arm9.bin::02018978 +static void nullsub_28(void) { } -s8 ScriptLoggingEnabled(bool8 unused) +// arm9.bin::02018970 +bool8 ScriptLoggingEnabled(bool8 unused) +{ + return FALSE; +} + +#if (GAME_VERSION == VERSION_RED) +UNUSED static u32 sub_8011BA8(void) { return 0; } -// Unused -u32 sub_8011BA8(void) -{ - return 0; -} - -// Unused -const char *GetNotMountText(void) +UNUSED static const u8 *GetNotMountText(void) { return gNotMountText; } -// Unused -void UnusedHang(void) +UNUSED static void UnusedHang(void) { Hang(); } +#endif +// arm9.bin::02018964 void Log(u8 num, const u8 *text, ...) { va_list vArgv; @@ -199,27 +207,29 @@ void Log(u8 num, const u8 *text, ...) va_end(vArgv); } -// Unused -void sub_8011BC8(u32 r0, u32 r1, u32 r2, ...) +#if (GAME_VERSION == VERSION_RED) +UNUSED static void sub_8011BC8(u32 r0, u32 r1, u32 r2, ...) { va_list vArgv; va_start(vArgv, r2); va_end(vArgv); } +#endif -void nullsub_29() +// arm9.bin::02018960 +static void nullsub_29() { } -void nullsub_30() +static void nullsub_30() { } -void nullsub_31() +static void nullsub_31() { } -void nullsub_32() +static void nullsub_32() { } @@ -228,6 +238,7 @@ static void FatalErrorHang() Hang(); } +// arm9.bin::020189C0 void FatalError(const DebugLocation *debug, const char *text, ...) { char buf[0x100]; diff --git a/src/debug_menu1.c b/src/debug_menu1.c index 1d4079344..43d618f9d 100644 --- a/src/debug_menu1.c +++ b/src/debug_menu1.c @@ -1,9 +1,9 @@ #include "global.h" #include "globaldata.h" -#include "code_8097670.h" #include "constants/friend_area.h" #include "constants/main_menu.h" #include "constants/move_id.h" +#include "code_8097670.h" #include "debug_menu1.h" #include "friend_area.h" #include "input.h" @@ -12,8 +12,8 @@ #include "menu_input.h" #include "pokemon.h" #include "save.h" +#include "text_1.h" #include "text_util.h" -#include "text.h" enum DebugMenuOptions { diff --git a/src/debug_menu2.c b/src/debug_menu2.c index 3a2fe7eff..2e7c27ac0 100644 --- a/src/debug_menu2.c +++ b/src/debug_menu2.c @@ -1,6 +1,5 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" #include "code_801B3C0.h" #include "code_801C8C4.h" #include "common_strings.h" @@ -8,7 +7,9 @@ #include "input.h" #include "memory.h" #include "menu_input.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT unkStruct_203B3F0 *sUnknown_203B3F0 = {NULL}; @@ -80,7 +81,7 @@ static void sub_803A51C(void) { s32 i; - RestoreUnkTextStruct_8006518(&sUnknown_203B3F0->unkD8); + RestoreSavedWindows(&sUnknown_203B3F0->unkD8); switch (sUnknown_203B3F0->state) { case 3: diff --git a/src/debug_menu3.c b/src/debug_menu3.c index ab1f7156f..7c1fb14c5 100644 --- a/src/debug_menu3.c +++ b/src/debug_menu3.c @@ -8,11 +8,11 @@ #include "memory.h" #include "menu_input.h" #include "pokemon.h" -#include "text.h" +#include "text_1.h" #include "wigglytuff_shop1.h" #include "wigglytuff_shop2.h" -static EWRAM_INIT unkStruct_203B3F4 *sUnknown_203B3F4 = {NULL}; +EWRAM_INIT static unkStruct_203B3F4 *sUnknown_203B3F4 = {NULL}; #include "data/debug_menu3.h" @@ -79,7 +79,7 @@ static void sub_803A93C(void) { s32 i; - RestoreUnkTextStruct_8006518(&sUnknown_203B3F4->unk9C); + RestoreSavedWindows(&sUnknown_203B3F4->unk9C); if (sUnknown_203B3F4->state == 2) sUnknown_203B3F4->unk9C.id[2] = sUnknown_80E7EA4; diff --git a/src/debug_menu4.c b/src/debug_menu4.c index 482c695fc..ec236869f 100644 --- a/src/debug_menu4.c +++ b/src/debug_menu4.c @@ -1,15 +1,17 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" #include "code_801602C.h" #include "code_8023868.h" #include "debug_menu4.h" #include "input.h" #include "memory.h" #include "menu_input.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" -static EWRAM_INIT unkStruct_203B3F8 *sUnknown_203B3F8 = {NULL}; +EWRAM_INIT static unkStruct_203B3F8 *sUnknown_203B3F8 = {NULL}; #include "data/debug_menu4.h" @@ -82,7 +84,7 @@ static void sub_803ACE8(void) { s32 i; - RestoreUnkTextStruct_8006518(&sUnknown_203B3F8->unkE0); + RestoreSavedWindows(&sUnknown_203B3F8->unkE0); switch (sUnknown_203B3F8->state) { case 3: diff --git a/src/decompress_3.c b/src/decompress_3.c new file mode 100644 index 000000000..b5e0dab4c --- /dev/null +++ b/src/decompress_3.c @@ -0,0 +1,34 @@ +#include "global.h" +#include "decompress_3.h" + +// TODO: Find these 2 funcs in blue. + +UNUSED static bool32 IsATxPCompressed_unused(char *data) +{ + if ((data[0] == 'A' && data[1] == 'T' && data[2] == '4' && data[3] == 'P')) return TRUE; + if ((data[0] == 'A' && data[1] == 'T' && data[2] == '3' && data[3] == 'P')) return TRUE; + return FALSE; +} + +bool8 StrsDifferent_IgnoreCase(const char *strA, const char *strB, s32 maxLen) +{ + s32 i; + + for (i = 0; i < maxLen; i++) { + char a = strA[i]; + char b = strB[i]; + + // Uppercase -> lowercase + if ('A' <= a && a <= 'Z') + a += 0x20; + if ('A' <= b && b <= 'Z') + b += 0x20; + + if (a != b) + return TRUE; + // `a` and `b` are equal here, but we check them for null terminators since `maxLen` is just a suggestion + if (a == '\0' /*&& b == '\0'*/) + break; + } + return FALSE; +} diff --git a/src/decompress.c b/src/decompress_at.c similarity index 86% rename from src/decompress.c rename to src/decompress_at.c index 7a8aaa8a4..172c45fee 100644 --- a/src/decompress.c +++ b/src/decompress_at.c @@ -1,67 +1,27 @@ #include "global.h" #include "globaldata.h" -#include "decompress.h" +#include "decompress_at.h" -#define MAGIC_SIR0 0x30524953 -#define MAGIC_SIRO 0x4F524953 +EWRAM_DATA u32 *gDecompressBufferPtr = {0}; // NDS=020EDCC8 +EWRAM_DATA u32 *gDecompressBufferStart = {0}; // NDS=02EDCD4 +EWRAM_DATA u32 gDecompressBufferCurrent = {0}; // NDS=020EDCCC +EWRAM_DATA u32 gDecompressBufferByteInInt = {0}; // NDS=020EDCD0 -EWRAM_DATA u32 *gDecompressBufferPtr = {0}; -EWRAM_DATA u32 *gDecompressBufferStart = {0}; -EWRAM_DATA u32 gDecompressBufferCurrent = {0}; -EWRAM_DATA u32 gDecompressBufferByteInInt = {0}; +#include "data/decompress_at.h" -#include "data/decompress.h" - -static void DecompressAT_AppendByte(char); +static void DecompressAT_AppendByte(u8); static void DecompressAT_Finish(void); -static char DecompressAT_GetByte(s32); +static u8 DecompressAT_GetByte(s32); static void DecompressAT_Init(u32 *); -static u32 DecompressATGlobal(u32 *, s32, const char *); -static void NDS_DecompressRLE(const SiroArchive *); - -// arm9.bin::020093F4 -const void *GetSiroPtr(OpenedFile *openedFile) -{ - const SiroArchive *siro = (const SiroArchive *)openedFile->data; - - if (siro->magic == MAGIC_SIR0) - NDS_DecompressRLE(openedFile->data); - else if (siro->magic != MAGIC_SIRO) - return openedFile->data; - - openedFile->data = siro->data; - - return openedFile->data; -} - -// arm9.bin::020093A0 -UNUSED static const void *UnusedGetSir0Ptr(const SiroArchive *siro) -{ - if (siro->magic != MAGIC_SIR0) - return siro; - - NDS_DecompressRLE(siro); - return siro->data; -} - -// arm9.bin::02009324 -static void NDS_DecompressRLE(const SiroArchive *siro) -{ -} - -void nullsub_16(void) -{ -} - -UNUSED static void nullsub_175(void) -{ -} +static u32 DecompressATGlobal(u32 *, s32, const u8 *); +// arm9.bin::02003148 u32 DecompressATFile(void *dst, s32 dstLen, OpenedFile *file) { return DecompressAT(dst, dstLen, file->data); } +// arm9.bin::02002CE4 u32 DecompressAT(u8 *dst, s32 dstLen, const u8 *src) { s32 compressedLength = src[5] + (src[6] << 8); @@ -219,12 +179,14 @@ u32 DecompressAT(u8 *dst, s32 dstLen, const u8 *src) return bytesWritten; } +// arm9.bin::02002CD4 u32 DecompressATGlobalFile(u32 *result, s32 resultLength, OpenedFile *file) { return DecompressATGlobal(result, resultLength, file->data); } -static u32 DecompressATGlobal(u32 *result, s32 resultLength, const char *compressedData) +// arm9.bin::02002804 +static u32 DecompressATGlobal(u32 *result, s32 resultLength, const u8 *compressedData) { s32 flags[9]; s32 curIndex; @@ -384,6 +346,7 @@ static u32 DecompressATGlobal(u32 *result, s32 resultLength, const char *compres return bytesWritten; } +// arm9.bin::020027C0 static void DecompressAT_Init(u32 *buffer) { gDecompressBufferPtr = buffer; @@ -392,7 +355,8 @@ static void DecompressAT_Init(u32 *buffer) gDecompressBufferByteInInt = 0; } -static char DecompressAT_GetByte(s32 index) +// arm9.bin::02002754 +static u8 DecompressAT_GetByte(s32 index) { u32 data; s32 offset; @@ -410,7 +374,8 @@ static char DecompressAT_GetByte(s32 index) return data; } -static void DecompressAT_AppendByte(char value) +// arm9.bin::020026DC +static void DecompressAT_AppendByte(u8 value) { gDecompressBufferCurrent |= value << gByteShiftLookup[gDecompressBufferByteInInt]; *gDecompressBufferPtr = gDecompressBufferCurrent; @@ -423,40 +388,9 @@ static void DecompressAT_AppendByte(char value) } } +// arm9.bin::020026AC static void DecompressAT_Finish(void) { if (gDecompressBufferByteInInt) *gDecompressBufferPtr = gDecompressBufferCurrent; } - -UNUSED static bool32 IsATxPCompressed_unused(char *data) -{ - if ((data[0] == 'A' && data[1] == 'T' && data[2] == '4' && data[3] == 'P')) return TRUE; - if ((data[0] == 'A' && data[1] == 'T' && data[2] == '3' && data[3] == 'P')) return TRUE; - return FALSE; -} - -// Is this for sure part of this file? - -bool8 StrsDifferent_IgnoreCase(const char *strA, const char *strB, s32 maxLen) -{ - s32 i; - - for (i = 0; i < maxLen; i++) { - char a = strA[i]; - char b = strB[i]; - - // Uppercase -> lowercase - if ('A' <= a && a <= 'Z') - a += 0x20; - if ('A' <= b && b <= 'Z') - b += 0x20; - - if (a != b) - return TRUE; - // `a` and `b` are equal here, but we check them for null terminators since `maxLen` is just a suggestion - if (a == '\0' /*&& b == '\0'*/) - break; - } - return FALSE; -} diff --git a/src/decompress_sir.c b/src/decompress_sir.c new file mode 100644 index 000000000..f0ac4ef33 --- /dev/null +++ b/src/decompress_sir.c @@ -0,0 +1,47 @@ +#include "global.h" +#include "decompress_sir.h" + +#define MAGIC_SIR0 0x30524953 +#define MAGIC_SIRO 0x4F524953 + +static void NDS_DecompressRLE(const SiroArchive *); + +// arm9.bin::020093F4 +const void *GetSiroPtr(OpenedFile *openedFile) +{ + const SiroArchive *siro = (const SiroArchive *)openedFile->data; + + if (siro->magic == MAGIC_SIR0) + NDS_DecompressRLE(openedFile->data); + else if (siro->magic != MAGIC_SIRO) + return openedFile->data; + + openedFile->data = siro->data; + + return openedFile->data; +} + +// arm9.bin::020093A0 +UNUSED static const void *UnusedGetSir0Ptr(const SiroArchive *siro) +{ + if (siro->magic != MAGIC_SIR0) + return siro; + + NDS_DecompressRLE(siro); + return siro->data; +} + +// arm9.bin::02009324 +static void NDS_DecompressRLE(const SiroArchive *siro) +{ +} + +// TODO: IDK if these two funcs are in blue. Figure it out + +void nullsub_16(void) +{ +} + +UNUSED static void nullsub_175(void) +{ +} diff --git a/src/ds_menus.c b/src/ds_menus.c index 1db68d8c8..b694953b7 100644 --- a/src/ds_menus.c +++ b/src/ds_menus.c @@ -1,6 +1,6 @@ #include "global.h" #include "input.h" -#include "text.h" +#include "text_1.h" u32 CreateDualSlotMenu(void) { diff --git a/src/dungeon_items.c b/src/dungeon_items.c index 9e5752a9c..478a21066 100644 --- a/src/dungeon_items.c +++ b/src/dungeon_items.c @@ -27,6 +27,7 @@ #include "code_80450F8.h" #include "structs/str_item_text.h" #include "code_803E46C.h" +#include "sprite.h" extern SpriteOAM gUnknown_202EDC0; diff --git a/src/dungeon_main.c b/src/dungeon_main.c index a6d676507..ee40d17df 100644 --- a/src/dungeon_main.c +++ b/src/dungeon_main.c @@ -1,65 +1,64 @@ #include "global.h" #include "globaldata.h" -#include "dungeon_main.h" -#include "structs/str_dungeon.h" -#include "number_util.h" -#include "input.h" +#include "constants/dungeon.h" +#include "constants/dungeon_action.h" +#include "constants/iq_skill.h" +#include "constants/status.h" +#include "constants/tactic.h" #include "structs/map.h" -#include "dungeon_message.h" +#include "structs/str_dungeon.h" +#include "structs/str_text.h" +#include "structs/struct_sub80095e4.h" +#include "bg_control.h" +#include "charge_move.h" +#include "code_800D090.h" +#include "code_801602C.h" +#include "code_801B3C0.h" +#include "code_803E46C.h" +#include "code_803E724.h" +#include "code_8044CC8.h" +#include "code_8045A00.h" +#include "code_8066D04.h" +#include "code_806CD90.h" #include "dungeon_action.h" +#include "dungeon_ai_movement.h" #include "dungeon_ai_targeting.h" +#include "dungeon_capabilities.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_main.h" +#include "dungeon_map.h" +#include "dungeon_map_access.h" +#include "dungeon_menu_items.h" +#include "dungeon_menu_moves.h" +#include "dungeon_menu_others.h" +#include "dungeon_menu_stairs.h" +#include "dungeon_menu_team.h" +#include "dungeon_menu_tile.h" +#include "dungeon_message.h" +#include "dungeon_misc.h" +#include "dungeon_movement.h" +#include "dungeon_music.h" #include "dungeon_pokemon_attributes.h" #include "dungeon_random.h" #include "dungeon_util.h" -#include "dungeon_map.h" -#include "pokemon.h" -#include "moves.h" -#include "items.h" -#include "dungeon_music.h" -#include "dungeon_ai_movement.h" -#include "code_8045A00.h" -#include "string_format.h" -#include "code_803E46C.h" -#include "code_803E724.h" -#include "code_801602C.h" -#include "code_800D090.h" -#include "trap.h" -#include "charge_move.h" -#include "dungeon_map_access.h" -#include "dungeon_misc.h" -#include "status_checks_1.h" -#include "game_options.h" -#include "weather.h" -#include "dungeon_items.h" -#include "dungeon_leader.h" -#include "tile_types.h" #include "dungeon_visibility.h" -#include "dungeon_movement.h" -#include "bg_control.h" -#include "menu_input.h" -#include "music.h" +#include "game_options.h" +#include "input.h" #include "items.h" +#include "menu_input.h" +#include "moves.h" +#include "music.h" +#include "number_util.h" #include "play_time.h" +#include "pokemon.h" #include "pokemon_3.h" -#include "text.h" -#include "code_806CD90.h" -#include "code_8066D04.h" -#include "code_8044CC8.h" -#include "code_801B3C0.h" -#include "dungeon_capabilities.h" -#include "dungeon_menu_items.h" -#include "dungeon_menu_team.h" -#include "dungeon_menu_moves.h" -#include "dungeon_menu_tile.h" -#include "dungeon_menu_stairs.h" -#include "dungeon_menu_others.h" -#include "constants/dungeon.h" -#include "constants/status.h" -#include "constants/tactic.h" -#include "constants/iq_skill.h" -#include "constants/dungeon_action.h" -#include "structs/struct_sub80095e4.h" -#include "structs/str_text.h" +#include "sprite.h" +#include "status_checks_1.h" +#include "string_format.h" +#include "tile_types.h" +#include "trap.h" +#include "weather.h" extern void HandleUnsetItemAction(Entity *,bool8); extern bool8 sub_8048A68(Entity *param_1,Item *item); diff --git a/src/dungeon_map.c b/src/dungeon_map.c index 1465ecbac..f0db4757a 100644 --- a/src/dungeon_map.c +++ b/src/dungeon_map.c @@ -1,29 +1,29 @@ #include "global.h" #include "globaldata.h" -#include "def_filearchives.h" -#include "dungeon_map.h" -#include "structs/dungeon_entity.h" -#include "structs/str_dungeon.h" -#include "dungeon_map_access.h" -#include "dungeon_music.h" -#include "file_system.h" -#include "cpu.h" -#include "dungeon.h" -#include "game_options.h" -#include "bg_palette_buffer.h" -#include "code_8009804.h" -#include "code_800E9E4.h" -#include "dungeon_generation.h" -#include "dungeon_util.h" -#include "trap.h" -#include "text.h" #include "constants/dungeon.h" #include "constants/trap.h" +#include "structs/dungeon_entity.h" +#include "structs/str_dungeon.h" +#include "bg_palette_buffer.h" +#include "cpu.h" +#include "code_8009804.h" +#include "code_800E9E4.h" +#include "def_filearchives.h" +#include "dungeon.h" +#include "dungeon_generation.h" +#include "dungeon_map.h" +#include "dungeon_map_access.h" +#include "dungeon_music.h" +#include "dungeon_util.h" +#include "file_system.h" +#include "game_options.h" +#include "sprite.h" +#include "text_1.h" +#include "trap.h" extern DungeonPos gPlayerDotMapPosition; extern s32 gUnknown_202EDD0; -extern void nullsub_11(SpriteOAM *, s32, UnkSpriteMem *, unkStruct_2039DB0 *); extern u8 GetFloorType(void); extern bool8 sub_8094C48(void); extern bool8 sub_8045804(Entity *ent); diff --git a/src/dungeon_map_access.c b/src/dungeon_map_access.c index 0ec4b24dd..ad16366b5 100644 --- a/src/dungeon_map_access.c +++ b/src/dungeon_map_access.c @@ -4,7 +4,7 @@ #include "code_8042B34.h" #include "code_8004AA0.h" #include "code_8009804.h" -#include "decompress.h" +#include "decompress_at.h" #include "def_filearchives.h" #include "dungeon_engine.h" #include "dungeon_leader.h" @@ -15,7 +15,7 @@ #include "dungeon_visibility.h" #include "game_options.h" #include "random.h" -#include "text.h" +#include "text_1.h" #include "tile_types.h" extern const Tile gOtherOobTile; diff --git a/src/dungeon_menu_items.c b/src/dungeon_menu_items.c index 405ebe5da..24dcc021b 100644 --- a/src/dungeon_menu_items.c +++ b/src/dungeon_menu_items.c @@ -26,7 +26,7 @@ #include "dungeon_leader.h" #include "tile_types.h" #include "menu_input.h" -#include "text.h" +#include "text_1.h" #include "code_8044CC8.h" #include "code_801B3C0.h" #include "dungeon_capabilities.h" diff --git a/src/dungeon_menu_moves.c b/src/dungeon_menu_moves.c index 20faefb39..1124678d1 100644 --- a/src/dungeon_menu_moves.c +++ b/src/dungeon_menu_moves.c @@ -1,33 +1,35 @@ #include "global.h" #include "globaldata.h" -#include "dungeon_menu_moves.h" -#include "dungeon_menu_team.h" -#include "dungeon_submenu.h" -#include "structs/str_dungeon.h" -#include "input.h" #include "structs/map.h" -#include "dungeon_main.h" -#include "dungeon_message.h" -#include "dungeon_action.h" -#include "dungeon_random.h" -#include "dungeon_util.h" -#include "pokemon.h" -#include "moves.h" -#include "dungeon_music.h" -#include "code_8045A00.h" -#include "string_format.h" +#include "structs/str_dungeon.h" #include "code_803E46C.h" #include "code_803E724.h" -#include "status_checks_1.h" -#include "dungeon_leader.h" -#include "tile_types.h" -#include "dungeon_visibility.h" -#include "dungeon_movement.h" -#include "menu_input.h" -#include "music.h" -#include "text.h" #include "code_8044CC8.h" +#include "code_8045A00.h" +#include "dungeon_action.h" +#include "dungeon_leader.h" +#include "dungeon_main.h" +#include "dungeon_menu_moves.h" +#include "dungeon_menu_team.h" +#include "dungeon_message.h" +#include "dungeon_movement.h" +#include "dungeon_music.h" +#include "dungeon_random.h" +#include "dungeon_submenu.h" +#include "dungeon_util.h" +#include "dungeon_visibility.h" +#include "input.h" +#include "moves.h" +#include "menu_input.h" #include "move_util.h" +#include "music.h" +#include "pokemon.h" +#include "status_checks_1.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" +#include "tile_types.h" extern void PlayDungeonCancelSE(void); extern void PlayDungeonConfirmationSE(void); @@ -224,12 +226,12 @@ bool8 ShowDungeonMovesMenu(Entity * entity, bool8 addLinkOptions, bool8 addUseMo } } - while (1) { + while (TRUE) { r5 = 0; ret = FALSE; r10 = FALSE; ShowMovesMenuWindows(entity, entInfo, addLinkOptions, &windows, &header, unk, a3, a4); - while (1) { + while (TRUE) { AddMenuCursorSprite_(&gDungeonMenu, unk); DungeonRunFrameActions(0x1E); if (gRealInputs.repeated & DPAD_DOWN) { diff --git a/src/dungeon_menu_others.c b/src/dungeon_menu_others.c index 9bbc7d63d..01495c30a 100644 --- a/src/dungeon_menu_others.c +++ b/src/dungeon_menu_others.c @@ -1,28 +1,30 @@ #include "global.h" #include "globaldata.h" -#include "dungeon_menu_others.h" -#include "dungeon_menu_recruitment.h" -#include "dungeon_submenu.h" -#include "dungeon.h" -#include "text.h" -#include "menu_input.h" -#include "input.h" #include "code_803D110.h" +#include "code_803E46C.h" #include "code_803E724.h" #include "code_8044CC8.h" -#include "dungeon_action.h" -#include "dungeon_util.h" -#include "dungeon_map_access.h" -#include "dungeon_leader.h" #include "code_8045A00.h" #include "code_8097DD0.h" -#include "dungeon_message.h" -#include "game_options.h" -#include "post_office_guide2.h" +#include "dungeon.h" +#include "dungeon_action.h" +#include "dungeon_leader.h" #include "dungeon_main.h" #include "dungeon_map.h" +#include "dungeon_map_access.h" +#include "dungeon_menu_others.h" +#include "dungeon_menu_recruitment.h" +#include "dungeon_message.h" #include "dungeon_music.h" -#include "code_803E46C.h" +#include "dungeon_submenu.h" +#include "dungeon_util.h" +#include "game_options.h" +#include "input.h" +#include "menu_input.h" +#include "post_office_guide2.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" extern void PlayDungeonCancelSE(void); extern void PlayDungeonConfirmationSE(void); diff --git a/src/dungeon_menu_recruitment.c b/src/dungeon_menu_recruitment.c index 1893604d0..7710672d9 100644 --- a/src/dungeon_menu_recruitment.c +++ b/src/dungeon_menu_recruitment.c @@ -3,17 +3,19 @@ #include "code_800D090.h" #include "code_803E46C.h" #include "code_803E724.h" -#include "dungeon_menu_recruitment.h" #include "dungeon.h" -#include "text.h" -#include "menu_input.h" -#include "input.h" +#include "dungeon_menu_recruitment.h" #include "dungeon_message.h" +#include "dungeon_music.h" +#include "exclusive_pokemon.h" +#include "input.h" +#include "menu_input.h" #include "pokemon.h" #include "pokemon_3.h" #include "sprite.h" -#include "exclusive_pokemon.h" -#include "dungeon_music.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" extern void PlayDungeonCancelSE(void); extern void PlayDungeonConfirmationSE(void); @@ -262,7 +264,7 @@ static bool8 TryScrollDown(struct MonRecruitList *tabData, s32 a1) // Almost identical to CreateMessageLogArrow static void CreateScrollingArrow(bool8 upArrow, s32 y) { - struct Window *window = &gWindows[0]; + Window *window = &gWindows[0]; if (!(gDungeonFramesCounter & 8)) { SpriteSetAffine1(&sScrollingArrowOAM, 0); SpriteSetAffine2(&sScrollingArrowOAM, 0); diff --git a/src/dungeon_menu_stairs.c b/src/dungeon_menu_stairs.c index 57d88d8fb..27727ea56 100644 --- a/src/dungeon_menu_stairs.c +++ b/src/dungeon_menu_stairs.c @@ -3,21 +3,22 @@ #include "code_803E46C.h" #include "code_803E724.h" #include "code_8044CC8.h" -#include "dungeon_menu_stairs.h" -#include "dungeon_menu_team.h" -#include "dungeon_menu_moves.h" -#include "dungeon_submenu.h" -#include "dungeon.h" -#include "text.h" -#include "menu_input.h" -#include "input.h" -#include "dungeon_action.h" -#include "dungeon_util.h" -#include "dungeon_map_access.h" #include "code_8045A00.h" #include "code_8097DD0.h" +#include "dungeon.h" +#include "dungeon_action.h" #include "dungeon_generation.h" +#include "dungeon_map_access.h" +#include "dungeon_menu_moves.h" +#include "dungeon_menu_stairs.h" +#include "dungeon_menu_team.h" #include "dungeon_music.h" +#include "dungeon_submenu.h" +#include "dungeon_util.h" +#include "input.h" +#include "menu_input.h" +#include "text_1.h" +#include "text_3.h" extern void PlayDungeonCancelSE(void); extern void PlayDungeonConfirmationSE(void); diff --git a/src/dungeon_menu_team.c b/src/dungeon_menu_team.c index 7f4714f45..a0edd4650 100644 --- a/src/dungeon_menu_team.c +++ b/src/dungeon_menu_team.c @@ -1,52 +1,52 @@ #include "global.h" #include "globaldata.h" -#include "dungeon_menu_team.h" -#include "dungeon_menu_moves.h" -#include "dungeon_submenu.h" -#include "structs/str_dungeon.h" -#include "number_util.h" -#include "input.h" +#include "constants/tactic.h" #include "structs/map.h" -#include "dungeon_main.h" -#include "dungeon_message.h" -#include "dungeon_action.h" -#include "dungeon_pokemon_attributes.h" -#include "dungeon_random.h" -#include "dungeon_util.h" -#include "pokemon.h" -#include "moves.h" -#include "items.h" -#include "dungeon_music.h" -#include "dungeon_misc.h" -#include "dungeon_ai_movement.h" -#include "code_8045A00.h" -#include "string_format.h" +#include "structs/str_dungeon.h" +#include "structs/str_text.h" +#include "structs/struct_sub80095e4.h" +#include "code_800D090.h" +#include "code_801602C.h" +#include "code_801B3C0.h" #include "code_803E46C.h" #include "code_803E724.h" -#include "code_801602C.h" -#include "code_800D090.h" -#include "dungeon_map_access.h" -#include "status_checks_1.h" -#include "weather.h" +#include "code_8044CC8.h" +#include "code_8045A00.h" +#include "code_806CD90.h" +#include "code_8097DD0.h" +#include "dungeon_action.h" +#include "dungeon_ai_movement.h" +#include "dungeon_capabilities.h" #include "dungeon_items.h" #include "dungeon_leader.h" -#include "tile_types.h" -#include "dungeon_visibility.h" +#include "dungeon_main.h" +#include "dungeon_map_access.h" +#include "dungeon_menu_moves.h" +#include "dungeon_menu_team.h" +#include "dungeon_message.h" +#include "dungeon_misc.h" #include "dungeon_movement.h" -#include "menu_input.h" -#include "music.h" +#include "dungeon_music.h" +#include "dungeon_pokemon_attributes.h" +#include "dungeon_random.h" +#include "dungeon_submenu.h" +#include "dungeon_util.h" +#include "dungeon_visibility.h" +#include "input.h" #include "items.h" -#include "pokemon_3.h" -#include "text.h" -#include "code_806CD90.h" -#include "code_8044CC8.h" -#include "code_801B3C0.h" -#include "dungeon_capabilities.h" -#include "constants/tactic.h" -#include "structs/struct_sub80095e4.h" -#include "structs/str_text.h" -#include "code_8097DD0.h" +#include "menu_input.h" #include "move_util.h" +#include "moves.h" +#include "music.h" +#include "number_util.h" +#include "pokemon.h" +#include "pokemon_3.h" +#include "sprite.h" +#include "status_checks_1.h" +#include "string_format.h" +#include "text_2.h" +#include "tile_types.h" +#include "weather.h" extern bool8 sub_8048A68(Entity *param_1,Item *item); extern bool8 sub_8048950(Entity *param_1,Item *item); diff --git a/src/dungeon_menu_tile.c b/src/dungeon_menu_tile.c index 923a50ad5..6d9004712 100644 --- a/src/dungeon_menu_tile.c +++ b/src/dungeon_menu_tile.c @@ -2,22 +2,23 @@ #include "globaldata.h" #include "code_803E46C.h" #include "code_803E724.h" -#include "dungeon_menu_tile.h" -#include "dungeon_menu_team.h" -#include "dungeon_menu_moves.h" -#include "dungeon_submenu.h" -#include "dungeon.h" -#include "text.h" -#include "menu_input.h" -#include "input.h" #include "code_8044CC8.h" -#include "dungeon_action.h" -#include "dungeon_util.h" -#include "dungeon_map_access.h" #include "code_8045A00.h" -#include "trap.h" #include "code_8097DD0.h" +#include "dungeon.h" +#include "dungeon_action.h" +#include "dungeon_map_access.h" +#include "dungeon_menu_moves.h" +#include "dungeon_menu_team.h" +#include "dungeon_menu_tile.h" #include "dungeon_music.h" +#include "dungeon_submenu.h" +#include "dungeon_util.h" +#include "input.h" +#include "menu_input.h" +#include "text_1.h" +#include "text_3.h" +#include "trap.h" extern void PlayDungeonCancelSE(void); extern void PlayDungeonConfirmationSE(void); diff --git a/src/dungeon_message.c b/src/dungeon_message.c index 041c5ba04..dc904cd8b 100644 --- a/src/dungeon_message.c +++ b/src/dungeon_message.c @@ -1,27 +1,30 @@ #include "global.h" -#include "dungeon_message.h" -#include "dungeon_map.h" -#include "dungeon.h" #include "structs/dungeon_entity.h" -#include "code_803E46C.h" -#include "code_803E724.h" -#include "code_8009804.h" -#include "string_format.h" -#include "code_800E9E4.h" -#include "menu_input.h" -#include "code_803E668.h" #include "bg_palette_buffer.h" -#include "input.h" -#include "pokemon.h" -#include "file_system.h" -#include "dungeon_util_1.h" +#include "code_8009804.h" #include "code_800D090.h" -#include "dungeon_util.h" +#include "code_800E9E4.h" +#include "code_803E46C.h" +#include "code_803E668.h" +#include "code_803E724.h" #include "code_8045A00.h" -#include "exclusive_pokemon.h" +#include "dungeon.h" #include "dungeon_leader.h" -#include "text.h" +#include "dungeon_map.h" +#include "dungeon_message.h" #include "dungeon_music.h" +#include "dungeon_util.h" +#include "dungeon_util_1.h" +#include "exclusive_pokemon.h" +#include "file_system.h" +#include "input.h" +#include "menu_input.h" +#include "pokemon.h" +#include "sprite.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" void sub_80526D0(s32 r0); static void PutStringsOnMessageLog(void); @@ -38,8 +41,6 @@ extern void sub_8083E28(void); extern u32 sub_8014140(s32 a0, const void *a1); extern void PlayDungeonCancelSE(void); extern void PlayDungeonConfirmationSE(void); -extern void sub_8007334(s32 a0); -extern void sub_80087EC(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); extern u32 gUnknown_202EDD0; extern u8 gUnknown_203B40C; @@ -235,7 +236,7 @@ void xxx_draw_string_80524F0(void) sub_803EAF0(3, NULL); // fall through case 2: { - struct UnkDrawStringStruct sp; + UnkDrawStringStruct sp; u32 currChr; s32 id = strPtr->unk1C062; @@ -335,7 +336,7 @@ void sub_8052740(s32 a0) void DisplayDungeonMessage(struct MonDialogueSpriteInfo *monSpriteInfo, const u8 *str, bool8 a2) { - struct MonPortraitMsg monPortrait, *monPortraitPtr; + MonPortraitMsg monPortrait, *monPortraitPtr; s32 chosenMenuIndex; if (gUnknown_203B40C) { @@ -354,7 +355,7 @@ void DisplayDungeonMessage(struct MonDialogueSpriteInfo *monSpriteInfo, const u8 && IsPokemonDialogueSpriteAvail(monSpriteInfo->species, monSpriteInfo->spriteId)) { monPortrait.faceFile = GetDialogueSpriteDataPtr(monSpriteInfo->species); - monPortrait.faceData = (struct PortraitGfx *) monPortrait.faceFile->data; + monPortrait.faceData = (PortraitGfx *) monPortrait.faceFile->data; monPortrait.pos.x = 2; monPortrait.pos.y = 9; monPortrait.spriteId = monSpriteInfo->spriteId; @@ -402,12 +403,12 @@ extern const struct Struct_sub_808CDB0 *sub_808CDB0(s32 a0); void DisplayDungeonDialogue(const struct DungeonDialogueStruct *dialogueInfo) { - struct MonPortraitMsg monPortrait; + MonPortraitMsg monPortrait; s32 leaderId, partnerId, dialogueMonId; s32 chosenMenuIndex; Entity *leader = xxx_call_GetLeader(); Entity *partner = GetPartnerEntity(); - struct MonPortraitMsg *monPortraitPtr = NULL; + MonPortraitMsg *monPortraitPtr = NULL; if (leader != NULL) { EntityInfo *leaderInfo = GetEntInfo(leader); @@ -479,7 +480,7 @@ void DisplayDungeonDialogue(const struct DungeonDialogueStruct *dialogueInfo) monPortraitPtr = &monPortrait; monPortraitPtr->faceFile = GetDialogueSpriteDataPtr(dialogueMonId); if (monPortraitPtr->faceFile != NULL) { - monPortraitPtr->faceData = (struct PortraitGfx *) monPortraitPtr->faceFile->data; + monPortraitPtr->faceData = (PortraitGfx *) monPortraitPtr->faceFile->data; monPortraitPtr->unkE = 0; monPortraitPtr->spriteId = dialogueInfo->unk2; monPortraitPtr->flip = strPtr->flip; @@ -513,7 +514,7 @@ void DisplayDungeonDialogue(const struct DungeonDialogueStruct *dialogueInfo) bool32 DisplayDungeonYesNoMessage(struct MonDialogueSpriteInfo *monSpriteInfo, const u8 *str, bool32 defaultYes) { - struct MonPortraitMsg monPortrait, *monPortraitPtr; + MonPortraitMsg monPortrait, *monPortraitPtr; s32 chosenMenuIndex; sub_8052740(10); @@ -529,7 +530,7 @@ bool32 DisplayDungeonYesNoMessage(struct MonDialogueSpriteInfo *monSpriteInfo, c && IsPokemonDialogueSpriteAvail(monSpriteInfo->species, monSpriteInfo->spriteId)) { monPortrait.faceFile = GetDialogueSpriteDataPtr(monSpriteInfo->species); - monPortrait.faceData = (struct PortraitGfx *) monPortrait.faceFile->data; + monPortrait.faceData = (PortraitGfx *) monPortrait.faceFile->data; monPortrait.pos.x = 2; monPortrait.pos.y = 9; monPortrait.spriteId = monSpriteInfo->spriteId; @@ -562,7 +563,7 @@ bool32 DisplayDungeonYesNoMessage(struct MonDialogueSpriteInfo *monSpriteInfo, c s32 DisplayDungeonMenuMessage(struct MonDialogueSpriteInfo *monSpriteInfo, const u8 *str, const MenuItem *menuItems, u16 unkArg) { - struct MonPortraitMsg monPortrait, *monPortraitPtr; + MonPortraitMsg monPortrait, *monPortraitPtr; s32 chosenMenuIndex; sub_8052740(10); @@ -578,7 +579,7 @@ s32 DisplayDungeonMenuMessage(struct MonDialogueSpriteInfo *monSpriteInfo, const && IsPokemonDialogueSpriteAvail(monSpriteInfo->species, monSpriteInfo->spriteId)) { monPortrait.faceFile = GetDialogueSpriteDataPtr(monSpriteInfo->species); - monPortrait.faceData = (struct PortraitGfx *) monPortrait.faceFile->data; + monPortrait.faceData = (PortraitGfx *) monPortrait.faceFile->data; monPortrait.pos.x = 2; monPortrait.pos.y = 9; monPortrait.spriteId = monSpriteInfo->spriteId; @@ -1041,7 +1042,7 @@ static bool8 TryScrollLogDown(s32 a0) static void CreateMessageLogArrow(bool8 upArrow, s32 y) { - struct Window *window = &gWindows[0]; + Window *window = &gWindows[0]; if (!(gDungeonFramesCounter & 8)) { SpriteSetAffine1(&sMessageLogArrowSpriteOAM, 0); SpriteSetAffine2(&sMessageLogArrowSpriteOAM, 0); diff --git a/src/dungeon_misc.c b/src/dungeon_misc.c index 311b556a9..29bfba921 100644 --- a/src/dungeon_misc.c +++ b/src/dungeon_misc.c @@ -8,7 +8,6 @@ #include "file_system.h" #include "pokemon.h" #include "pokemon_3.h" -#include "text.h" #include "moves.h" #include "string_format.h" #include "friend_area.h" @@ -87,7 +86,6 @@ extern void sub_80429E8(Entity *r0); extern s32 sub_803DA20(s32 param_1); extern s32 gDungeonFramesCounter; extern void sub_800F958(s32 dungeonSpriteID, DungeonPos *pos, DungeonPos *statusOffsets, u32 a3); -extern void sub_8005700(DungeonPos *a0, struct axObject *a1); extern void sub_8042EC8(Entity *a0, s32 a1); extern Entity *sub_804550C(s16 a); extern Entity *sub_80453AC(s16 id); diff --git a/src/dungeon_move.c b/src/dungeon_move.c index 978263f47..7fa4c9d1f 100644 --- a/src/dungeon_move.c +++ b/src/dungeon_move.c @@ -1,46 +1,47 @@ #include "global.h" -#include "dungeon_move.h" -#include "dungeon_pokemon_attributes.h" -#include "dungeon_util.h" -#include "dungeon_message.h" -#include "moves.h" -#include "status_checks_1.h" -#include "dungeon_ai_targeting.h" -#include "structs/str_damage.h" #include "constants/ability.h" +#include "constants/iq_skill.h" #include "constants/status.h" #include "constants/weather.h" -#include "constants/iq_skill.h" -#include "position_util.h" -#include "dungeon_items.h" -#include "code_806CD90.h" -#include "move_util.h" -#include "code_808417C.h" -#include "dungeon_capabilities.h" -#include "move_effects_target.h" -#include "status.h" -#include "weather.h" -#include "code_8077274_1.h" +#include "structs/str_damage.h" #include "charge_move.h" -#include "dungeon_random.h" -#include "targeting_flags.h" -#include "dungeon_misc.h" -#include "dungeon_map_access.h" -#include "math.h" #include "code_800DAC0.h" -#include "text_util.h" -#include "dungeon_visibility.h" -#include "code_807CD9C.h" -#include "dungeon_engine.h" -#include "status_actions.h" -#include "code_8045A00.h" +#include "code_800E9E4.h" +#include "code_800ED38.h" +#include "code_803E46C.h" #include "code_803E668.h" #include "code_803E724.h" -#include "code_803E46C.h" #include "code_8041AD0.h" -#include "code_800E9E4.h" +#include "code_8045A00.h" +#include "code_806CD90.h" +#include "code_8077274_1.h" +#include "code_807CD9C.h" +#include "code_808417C.h" +#include "dungeon_ai_targeting.h" +#include "dungeon_capabilities.h" #include "dungeon_config.h" -#include "code_800ED38.h" +#include "dungeon_engine.h" +#include "dungeon_items.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_misc.h" +#include "dungeon_move.h" +#include "dungeon_pokemon_attributes.h" +#include "dungeon_random.h" +#include "dungeon_util.h" +#include "dungeon_visibility.h" +#include "math.h" +#include "move_effects_target.h" +#include "move_util.h" +#include "moves.h" +#include "position_util.h" +#include "sprite.h" +#include "status.h" +#include "status_actions.h" +#include "status_checks_1.h" +#include "weather.h" +#include "targeting_flags.h" +#include "text_util.h" extern void sub_80429C8(Entity *r0); extern bool8 sub_8045888(Entity *r0); @@ -57,7 +58,6 @@ extern void sub_80428A0(Entity *r0); extern bool8 sub_8040BB0(Entity *entity, Move *move, bool8); extern void sub_8040DA0(Entity *entity, Move *move); extern u16 sub_80412E0(u16 moveId, u8 weather, u8 a2); -extern void sub_800569C(DungeonPos *, axdata *, u8); extern void sub_800EF10(u16 r0); extern s32 sub_800E710(s16 a0, u16 a1); extern void sub_800E3AC(s32 a0, DungeonPos *pos, s32 a2); @@ -2288,7 +2288,7 @@ s32 sub_8056564(Entity *entity, DungeonPos *pos, Move *move, s32 r4) DungeonRunFrameActions(0x5E); someRetVal = sub_800E710(entInfo->apparentID, sub_80412E0(move->id, GetApparentWeather(entity), 1)); if (someRetVal != -1) { - sub_800569C(&unkSp1.unk8, &entity->axObj.axdata, someRetVal); + sub_800569C(&unkSp1.unk8, &entity->axObj, someRetVal); } else { unkSp1.unk8 = (DungeonPos) {0}; diff --git a/src/dungeon_submenu.c b/src/dungeon_submenu.c index c5db577b7..e652ea576 100644 --- a/src/dungeon_submenu.c +++ b/src/dungeon_submenu.c @@ -1,9 +1,10 @@ #include "global.h" #include "globaldata.h" +#include "code_800D090.h" #include "dungeon_submenu.h" #include "menu_input.h" -#include "text.h" -#include "code_800D090.h" +#include "text_1.h" +#include "text_3.h" // The reason this short file(just 1 function) exists is because of the pksdir string which usually signifies the file's beginning. diff --git a/src/event_flag.c b/src/event_flag.c index 0ae78d5b6..7b9e324c1 100644 --- a/src/event_flag.c +++ b/src/event_flag.c @@ -14,7 +14,7 @@ #include "pokemon.h" #include "pokemon_3.h" -EWRAM_DATA u8 gScriptVarBuffer[0x400] = {0}; +EWRAM_DATA u8 gScriptVarBuffer[0x400] = {0}; // NDS=020876DC struct GroundEventTableEntry { @@ -54,6 +54,7 @@ extern void nullsub_128(void); // A fakematch? Debugging leftover? A bug? No clue. #define GET_PTR_x400VAR(varId)(((void*) (&gScriptVarInfo[varId - 0x466])) - 4) +// arm9.bin::0200FF68 void ThoroughlyResetScriptVars(void) { s32 iVar1; @@ -121,12 +122,14 @@ void ThoroughlyResetScriptVars(void) sub_80972F4(); } +#if (GAME_VERSION == VERSION_RED) void sub_8001564(void) { nullsub_128(); } +#endif - +// arm9.bin::0200FEB4 void ResetScriptVarArray(u8 *localVarBuf, s16 varId_) { struct ScriptVarInfo *infoPtr; @@ -145,6 +148,7 @@ void ResetScriptVarArray(u8 *localVarBuf, s16 varId_) } } +// arm9.bin::0200FE04 void ClearScriptVarArray(u8 *localVarBuf, s16 varId_) { struct ScriptVarInfo *infoPtr; @@ -163,6 +167,7 @@ void ClearScriptVarArray(u8 *localVarBuf, s16 varId_) } } +// arm9.bin::0200FD60 void GetScriptVarRef(struct ScriptVarPtr *out, u8 *localVarBuf, s32 varId_) { struct ScriptVarInfo *infoPtr; @@ -180,6 +185,7 @@ void GetScriptVarRef(struct ScriptVarPtr *out, u8 *localVarBuf, s32 varId_) } } +// arm9.bin::0200FC00 s32 GetScriptVarValue(u8 *localVarBuf, s32 varId_) { struct ScriptVarPtr sp; @@ -222,6 +228,7 @@ s32 GetScriptVarValue(u8 *localVarBuf, s32 varId_) } } +// arm9.bin::0200FA50 s32 GetScriptVarArrayValue(u8 *localVarBuf, s32 varId_, s32 idx_) { struct ScriptVarPtr sp; @@ -267,6 +274,7 @@ s32 GetScriptVarArrayValue(u8 *localVarBuf, s32 varId_, s32 idx_) } } +// arm9.bin::0200F808 void SetScriptVarValue(u8 *localVarBuf, s32 varId_, s32 val) { s32 varID; @@ -324,6 +332,7 @@ void SetScriptVarValue(u8 *localVarBuf, s32 varId_, s32 val) } } +// arm9.bin::0200F5A8 void SetScriptVarArrayValue(u8 *localVarBuf, s32 varId_, s32 idx_, s32 val) { s32 varID; @@ -385,6 +394,7 @@ void SetScriptVarArrayValue(u8 *localVarBuf, s32 varId_, s32 idx_, s32 val) } } +#if (GAME_VERSION == VERSION_RED) UNUSED u8 *GetScriptVarPointer(s16 varId) { struct ScriptVarPtr local_1c; @@ -400,7 +410,9 @@ UNUSED s16 GetScriptVarArrayLength(s16 varId) GetScriptVarRef(&local_1c,0,varId); return local_1c.info->arrayLen; } +#endif +// arm9.bin::0200F544 s32 GetScriptVarArraySum(u8 *localVarBuf, s16 varId) { s32 counter; @@ -419,6 +431,7 @@ s32 GetScriptVarArraySum(u8 *localVarBuf, s16 varId) return total; } +#if (GAME_VERSION == VERSION_RED) UNUSED void GetScriptVarString(s16 varId, u8 *buf, s32 maxLen) { u8 *r1; @@ -456,13 +469,16 @@ UNUSED void ScriptVarStringPopFirstChar(s16 varId,u32 param_2,s32 maxLen) } } } +#endif +// arm9.bin::0200F508 void GetScriptVarScenario(s32 param_1,u32 *param_2,u32 *param_3) { *param_2 = GetScriptVarArrayValue(NULL, (s16)param_1, 0); *param_3 = GetScriptVarArrayValue(NULL, (s16)param_1, 1); } +// arm9.bin::0200F36C void ScenarioCalc(s16 param_1,s32 param_2,s32 param_3) { s32 param_1_s32; @@ -509,6 +525,7 @@ void ScenarioCalc(s16 param_1,s32 param_2,s32 param_3) } } +// arm9.bin::0200F2D4 bool8 ScriptVarScenarioBefore(s16 varId,u32 pMain,s32 pSub) { s32 sMain; @@ -528,6 +545,7 @@ bool8 ScriptVarScenarioBefore(s16 varId,u32 pMain,s32 pSub) } } +// arm9.bin::0200F270 bool8 ScriptVarScenarioEqual(s16 varId,u32 pMain,s32 pSub) { s32 sMain; @@ -542,6 +560,7 @@ bool8 ScriptVarScenarioEqual(s16 varId,u32 pMain,s32 pSub) return FALSE; } +// arm9.bin::0200F1d8 bool8 ScriptVarScenarioAfter(s16 varId,u32 pMain,s32 pSub) { s32 sMain; @@ -561,6 +580,7 @@ bool8 ScriptVarScenarioAfter(s16 varId,u32 pMain,s32 pSub) } } +// arm9.bin::0200ECE0 void sub_8001D88(void) { u32 local_c; @@ -654,6 +674,7 @@ void sub_8001D88(void) } } +// arm9.bin::0200EC08 s32 _FlagCalc(s32 param_1, s32 param_2, enum FlagCalcOperation operation) { switch(operation) { @@ -686,6 +707,7 @@ s32 _FlagCalc(s32 param_1, s32 param_2, enum FlagCalcOperation operation) } } +// arm9.bin::0200EAE4 bool8 _FlagJudge(s32 param_1, s32 param_2, enum FlagJudgeOperation operation) { switch(operation) { @@ -716,11 +738,13 @@ bool8 _FlagJudge(s32 param_1, s32 param_2, enum FlagJudgeOperation operation) } } +// arm9.bin::0200EAD8 s32 FlagCalc(s32 r0, s32 r1, enum FlagCalcOperation operation) { return _FlagCalc(r0, r1, operation); } +// arm9.bin::0200EA98 void UpdateScriptVarWithImmediate(u8 *param_1, s16 param_2, s32 param_3, enum FlagCalcOperation operation) { u32 uVar1; @@ -731,6 +755,7 @@ void UpdateScriptVarWithImmediate(u8 *param_1, s16 param_2, s32 param_3, enum Fl SetScriptVarValue(param_1,param_2,uVar3); } +// arm9.bin::0200EA4C void UpdateScriptVarWithVar(u8 *param_1, s16 param_2, s16 param_3, enum FlagCalcOperation operation) { s32 uVar1; @@ -747,11 +772,13 @@ void UpdateScriptVarWithVar(u8 *param_1, s16 param_2, s16 param_3, enum FlagCalc SetScriptVarValue(param_1,param_2_s32,uVar3); } +// arm9.bin::0200EA40 bool8 FlagJudge(s32 r0, s32 r1, enum FlagJudgeOperation operation) { return _FlagJudge(r0, r1, operation); } +// arm9.bin::0200EA18 bool8 JudgeVarWithImmediate(u8 *param_1, s16 param_2, s32 param_3, enum FlagJudgeOperation operation) { s32 uVar1; @@ -760,6 +787,7 @@ bool8 JudgeVarWithImmediate(u8 *param_1, s16 param_2, s32 param_3, enum FlagJudg return _FlagJudge(uVar1,param_3,operation); } +// arm9.bin::0200E9D8 bool8 JudgeVarWithVar(u8 *param_1, s16 param_2, s16 param_3, enum FlagJudgeOperation operation) { s32 uVar1; @@ -773,6 +801,7 @@ bool8 JudgeVarWithVar(u8 *param_1, s16 param_2, s16 param_3, enum FlagJudgeOpera return _FlagJudge(uVar1,uVar2,operation); } +#if (GAME_VERSION == VERSION_RED) UNUSED s32 sub_8002354(u32 param_1) { if (param_1 < 0x3b) { @@ -815,7 +844,9 @@ UNUSED u8 *sub_80023C4(u32 param_1) return gUnknown_80B7144; // NONE } } +#endif +// arm9.bin::0200E654 // 6 checks for post game being reached bool8 sub_80023E4(u32 param_1) { @@ -885,8 +916,8 @@ bool8 sub_80023E4(u32 param_1) } } +// arm9.bin::0200E620 u8 sub_8002658(s16 param_1) - { short sVar1; s32 param_1_s32; @@ -908,9 +939,9 @@ u8 sub_8002658(s16 param_1) return 0; } +// arm9.bin::0200E5E8 s16 sub_8002694(u8 param_1) { - struct GroundEventTableEntry *puVar2 = gGroundEnterLookupTable; while (puVar2->groundEnterId != -1) { @@ -923,32 +954,37 @@ s16 sub_8002694(u8 param_1) return -1; } +// arm9.bin::0200E5A8 bool8 sub_80026CC(s16 r0) { return GetFriendAreaStatus(sub_8002658(r0)); } +// arm9.bin::0200E568 void sub_80026E8(s16 r0, bool8 r1) { UnlockFriendArea(sub_8002658(r0)); } +// arm9.bin::0200E544 bool8 SaveGlobalScriptVars(void *r0) { MemoryCopy8(r0, gScriptVarBuffer, 0x400); - return 1; + return TRUE; } +// arm9.bin::0200E4DC bool8 RestoreGlobalScriptVars(u8 *r0) { struct ScriptVarPtr temp; GetScriptVarRef(&temp, NULL, VERSION); MemoryCopy8(gScriptVarBuffer, r0, 0x400); if (temp.info->defaultValue != *(u32 *)temp.ptr) - return 0; - return 1; + return FALSE; + return TRUE; } +#if (GAME_VERSION == VERSION_RED) UNUSED void SetConditionBit(s32 r0) { UpdateScriptVarWithImmediate(NULL, CONDITION, r0, CALC_SETBIT); @@ -963,3 +999,8 @@ UNUSED void nullsub_140(void) { } +#endif + + + +// TODO: Merge with main_loops.c (below) and code_8002774.c (above) diff --git a/src/felicity_bank.c b/src/felicity_bank.c index daf809066..1724fb33d 100644 --- a/src/felicity_bank.c +++ b/src/felicity_bank.c @@ -1,14 +1,16 @@ #include "global.h" #include "globaldata.h" #include "code_80118A4.h" -#include "string_format.h" #include "common_strings.h" #include "felicity_bank.h" #include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" static EWRAM_INIT FelicityBankWork *sFelicityBankWork = {NULL}; @@ -68,7 +70,7 @@ bool8 CreateFelicityBank(s32 mode) faceFile = GetDialogueSpriteDataPtr(MONSTER_PERSIAN); sFelicityBankWork->monPortrait.faceFile = faceFile; - sFelicityBankWork->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; + sFelicityBankWork->monPortrait.faceData = (PortraitGfx *) faceFile->data; sFelicityBankWork->monPortrait.spriteId = 0; sFelicityBankWork->monPortrait.flip = FALSE; sFelicityBankWork->monPortrait.unkE = 0; @@ -130,7 +132,7 @@ static void sub_801645C(void) { s32 i; - RestoreUnkTextStruct_8006518(&sFelicityBankWork->unkA8); + RestoreSavedWindows(&sFelicityBankWork->unkA8); switch (sFelicityBankWork->currState) { case 2: diff --git a/src/file_system.c b/src/file_system.c index 32ede7242..84b533a01 100644 --- a/src/file_system.c +++ b/src/file_system.c @@ -1,5 +1,5 @@ #include "global.h" -#include "decompress.h" +#include "decompress_sir.h" #include "file_system.h" // size: 0x8 diff --git a/src/friend_area_action_menu.c b/src/friend_area_action_menu.c index 6d5ff8b7a..996ff97f8 100644 --- a/src/friend_area_action_menu.c +++ b/src/friend_area_action_menu.c @@ -1,8 +1,7 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" +#include "constants/dungeon.h" #include "code_801B3C0.h" -#include "iq_skill_menu.h" #include "code_801EE10.h" #include "code_801EE10_mid.h" #include "code_8023868.h" @@ -10,10 +9,10 @@ #include "code_8098BDC.h" #include "code_8099360.h" #include "common_strings.h" -#include "constants/dungeon.h" #include "event_flag.h" #include "friend_area_action_menu.h" #include "input.h" +#include "iq_skill_menu.h" #include "items.h" #include "kecleon_bros4.h" #include "memory.h" @@ -22,7 +21,9 @@ #include "pokemon.h" #include "pokemon_3.h" #include "sprite.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT struct unkStruct_203B2BC *sUnknown_203B2BC = {NULL}; @@ -140,7 +141,7 @@ void sub_802719C(void) { s32 index; - RestoreUnkTextStruct_8006518(&sUnknown_203B2BC->unk180); + RestoreSavedWindows(&sUnknown_203B2BC->unk180); switch(sUnknown_203B2BC->state) { case 3: diff --git a/src/friend_areas_map.c b/src/friend_areas_map.c index e35bea7e5..e77d4eecb 100644 --- a/src/friend_areas_map.c +++ b/src/friend_areas_map.c @@ -9,7 +9,7 @@ #include "code_800C9CC.h" #include "code_800D090.h" #include "code_80118A4.h" -#include "decompress.h" +#include "decompress_sir.h" #include "friend_area.h" #include "friend_areas_map.h" #include "friend_areas_map_util.h" @@ -19,7 +19,8 @@ #include "pokemon.h" #include "sprite.h" #include "string_format.h" -#include "text.h" +#include "text_1.h" +#include "text_3.h" EWRAM_INIT struct FriendAreasMap *gFriendAreasMapPtr = NULL; EWRAM_DATA static u8 sCurrDirection = 0; diff --git a/src/friend_areas_map_util.c b/src/friend_areas_map_util.c index 64d76f578..e1407b11e 100644 --- a/src/friend_areas_map_util.c +++ b/src/friend_areas_map_util.c @@ -9,7 +9,7 @@ #include "code_800C9CC.h" #include "code_800D090.h" #include "code_80118A4.h" -#include "decompress.h" +#include "decompress_at.h" #include "def_filearchives.h" #include "friend_area.h" #include "friend_areas_map.h" @@ -21,7 +21,9 @@ #include "pokemon.h" #include "sprite.h" #include "string_format.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" static inline bool8 CheckAxFlag8000(axdata *ptr) { diff --git a/src/friend_list_menu.c b/src/friend_list_menu.c index aad9ac460..9afb0977e 100644 --- a/src/friend_list_menu.c +++ b/src/friend_list_menu.c @@ -1,11 +1,9 @@ #include "global.h" #include "globaldata.h" +#include "constants/dungeon.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_801602C.h" #include "code_801B3C0.h" -#include "friend_list_menu.h" -#include "iq_skill_menu.h" #include "code_801EE10.h" #include "code_801EE10_mid.h" #include "code_8023868.h" @@ -13,10 +11,11 @@ #include "code_8098BDC.h" #include "code_8099360.h" #include "common_strings.h" -#include "constants/dungeon.h" #include "event_flag.h" +#include "friend_list_menu.h" #include "ground_map_1.h" #include "input.h" +#include "iq_skill_menu.h" #include "items.h" #include "kecleon_bros4.h" #include "memory.h" @@ -24,7 +23,9 @@ #include "moves.h" #include "pokemon.h" #include "pokemon_3.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" EWRAM_INIT unkStruct_203B2B4 *gUnknown_203B2B4 = {NULL}; @@ -144,7 +145,7 @@ void sub_802544C(void) { s32 i; - RestoreUnkTextStruct_8006518(&gUnknown_203B2B4->unk118); + RestoreSavedWindows(&gUnknown_203B2B4->unk118); switch (gUnknown_203B2B4->state) { case 3: diff --git a/src/friend_rescue.c b/src/friend_rescue.c index d345b6178..5346f9835 100644 --- a/src/friend_rescue.c +++ b/src/friend_rescue.c @@ -1,17 +1,16 @@ #include "global.h" #include "globaldata.h" +#include "constants/communication_error_codes.h" +#include "constants/monster.h" +#include "constants/wonder_mail.h" #include "code_800D090.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_801B3C0.h" #include "code_801C8C4.h" #include "code_8023868.h" #include "code_8024458.h" #include "code_802F204.h" #include "code_8094F88.h" -#include "constants/communication_error_codes.h" -#include "constants/monster.h" -#include "constants/wonder_mail.h" #include "cpu.h" #include "friend_rescue.h" #include "input.h" @@ -21,10 +20,11 @@ #include "menu_input.h" #include "other_menus2.h" #include "pokemon.h" -#include "save_write.h" #include "rescue_password_menu.h" +#include "save_write.h" +#include "string_format.h" +#include "text_1.h" #include "text_util.h" -#include "text.h" #include "wonder_mail_4.h" #include "wonder_mail_5.h" @@ -821,7 +821,7 @@ void sub_8032828(void) } break; case 0x33: - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk35C); + RestoreSavedWindows(&gUnknown_203B33C->unk35C); SetMenuItems(gUnknown_203B33C->unk21C, &gUnknown_203B33C->unk35C, 3, &gUnknown_80E231C, gUnknown_80E234C, TRUE, 0, FALSE); sub_803092C(); sub_8035CF4(gUnknown_203B33C->unk21C, 3, 1); @@ -844,7 +844,7 @@ void sub_8032828(void) CreateDialogueBoxAndPortrait(&gUnknown_80E2A0C[0], 0, 0, 0x101); break; case 0x3A: - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8031D70(gUnknown_203B33C->unk218, 0); @@ -859,7 +859,7 @@ void sub_8032828(void) CreateDialogueBoxAndPortrait(&gUnknown_80E2A80[0], 0, 0, 0x101); break; case 0x2E: - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8031D70(gUnknown_203B33C->unk218, 0); @@ -901,7 +901,7 @@ void sub_8032828(void) sub_8023868(3, 0, 0, 9); break; case 0x27: - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk35C); + RestoreSavedWindows(&gUnknown_203B33C->unk35C); SetMenuItems(gUnknown_203B33C->unk21C, &gUnknown_203B33C->unk35C, 3, &gUnknown_80E2334, gUnknown_80E234C, TRUE, 0, FALSE); sub_8023DA4(); sub_8035CF4(gUnknown_203B33C->unk21C, 3, 1); @@ -923,7 +923,7 @@ void sub_8032828(void) } break; case 0x1E: - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk35C); + RestoreSavedWindows(&gUnknown_203B33C->unk35C); SetMenuItems(gUnknown_203B33C->unk21C, &gUnknown_203B33C->unk35C, 3, &gUnknown_80E231C, gUnknown_80E234C, TRUE, 0, FALSE); sub_803092C(); sub_8035CF4(gUnknown_203B33C->unk21C, 3, 1); @@ -1025,7 +1025,7 @@ void sub_8032828(void) sub_80306A8(WONDER_MAIL_TYPE_SOS, 0, NULL, 6); break; case 0x13: - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk35C); + RestoreSavedWindows(&gUnknown_203B33C->unk35C); SetMenuItems(gUnknown_203B33C->unk21C, &gUnknown_203B33C->unk35C, 3, &gUnknown_80E231C, gUnknown_80E234C, TRUE, 0, FALSE); sub_803092C(); sub_8035CF4(gUnknown_203B33C->unk21C, 3, 1); @@ -1054,7 +1054,7 @@ void sub_8032828(void) CreateDialogueBoxAndPortrait(&gUnknown_80E3078[0], 0, 0, 0x101); break; case 0x1A: - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_80151C0(4, gUnknown_203B33C->passwordBuffer); @@ -1073,7 +1073,7 @@ void sub_8032828(void) } break; case 0x5D: - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk35C); + RestoreSavedWindows(&gUnknown_203B33C->unk35C); SetMenuItems(gUnknown_203B33C->unk21C, &gUnknown_203B33C->unk35C, 3, &gUnknown_80E231C, gUnknown_80E2408, TRUE, 0, FALSE); sub_803092C(); sub_8035CF4(gUnknown_203B33C->unk21C, 3, 1); @@ -1089,7 +1089,7 @@ void sub_8032828(void) } break; case 0x60: - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk35C); + RestoreSavedWindows(&gUnknown_203B33C->unk35C); SetMenuItems(gUnknown_203B33C->unk21C, &gUnknown_203B33C->unk35C, 3, &gUnknown_80E23F0, gUnknown_80E2408, TRUE, 0, FALSE); sub_801CCD8(); sub_8035CF4(gUnknown_203B33C->unk21C, 3, 1); @@ -1130,7 +1130,7 @@ void sub_8032828(void) CreateDialogueBoxAndPortrait(gUnknown_80E311C, 0, 0, 0x101); break; case 0x73: - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_80151C0(4, gUnknown_203B33C->passwordBuffer); @@ -1139,7 +1139,7 @@ void sub_8032828(void) CreateDialogueBoxAndPortrait(gUnknown_80E314C, 0, 0, 0x101); break; case 0x67: - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8031D70(gUnknown_203B33C->unk218, 0); @@ -1250,7 +1250,7 @@ void sub_8032828(void) } break; case 0x48: - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk35C); + RestoreSavedWindows(&gUnknown_203B33C->unk35C); SetMenuItems(gUnknown_203B33C->unk21C, &gUnknown_203B33C->unk35C, 3, &gUnknown_80E231C, gUnknown_80E234C, TRUE, 0, FALSE); sub_803092C(); sub_8035CF4(gUnknown_203B33C->unk21C, 3, 1); @@ -1792,7 +1792,7 @@ void sub_8033FE4(void) case 4: gUnknown_203B33C->fallbackState = 0x1D; gUnknown_203B33C->unk218 = sub_80307EC(); - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8030D40(gUnknown_203B33C->unk218, 0); @@ -1817,7 +1817,7 @@ void sub_8034074(void) break; case 10: gUnknown_203B33C->fallbackState = FRIEND_RESCUE_MENU_DEFAULT_FALLBACK; - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8030D40(gUnknown_203B33C->unk218, 0); @@ -1875,7 +1875,7 @@ void sub_803418C(void) case 4: gUnknown_203B33C->fallbackState = 0x26; gUnknown_203B33C->speciesNum = sub_8023B44(); - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8024458(gUnknown_203B33C->speciesNum, 0); @@ -1900,7 +1900,7 @@ void sub_8034254(void) break; case 10: gUnknown_203B33C->fallbackState = FRIEND_RESCUE_MENU_DEFAULT_FALLBACK; - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8024458(gUnknown_203B33C->speciesNum, 0); @@ -2070,7 +2070,7 @@ void sub_8034500(void) case 4: gUnknown_203B33C->fallbackState = 0x32; gUnknown_203B33C->unk218 = sub_80307EC(); - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8030D40(gUnknown_203B33C->unk218, 0); @@ -2095,7 +2095,7 @@ void sub_8034590(void) break; case 10: gUnknown_203B33C->fallbackState = FRIEND_RESCUE_MENU_DEFAULT_FALLBACK; - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8030D40(gUnknown_203B33C->unk218, 0); @@ -2394,7 +2394,7 @@ void sub_80349E0(void) case 4: gUnknown_203B33C->fallbackState = 0x5C; gUnknown_203B33C->unk218 = sub_80307EC(); - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8030D40(gUnknown_203B33C->unk218, 0); @@ -2419,7 +2419,7 @@ void sub_8034A70(void) break; case 10: gUnknown_203B33C->fallbackState = FRIEND_RESCUE_MENU_DEFAULT_FALLBACK; - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8030D40(gUnknown_203B33C->unk218, 0); @@ -2475,7 +2475,7 @@ void sub_8034B88(void) case 4: gUnknown_203B33C->fallbackState = 0x5F; gUnknown_203B33C->item.id = sub_801CB24(); - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); InitItemDescriptionWindow(&gUnknown_203B33C->item); @@ -2524,7 +2524,7 @@ void sub_8034C98(void) break; case 10: gUnknown_203B33C->fallbackState = FRIEND_RESCUE_MENU_DEFAULT_FALLBACK; - RestoreUnkTextStruct_8006518(&gUnknown_203B33C->unk3BC); + RestoreSavedWindows(&gUnknown_203B33C->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); InitItemDescriptionWindow(&gUnknown_203B33C->item); diff --git a/src/ground_main.c b/src/ground_main.c index 23d499271..d0412a992 100644 --- a/src/ground_main.c +++ b/src/ground_main.c @@ -144,6 +144,7 @@ void sub_8098CC8(void) ClearAllItems_8091FB4(); } +// arm9.bin::0206C1A4 bool8 GroundMainGroundRequest(s32 r0, s32 r1, s32 r2) { s32 temp = (s16) r0; // force a asr shift diff --git a/src/ground_script.c b/src/ground_script.c index bc0729a7b..61dca0cd5 100644 --- a/src/ground_script.c +++ b/src/ground_script.c @@ -1,24 +1,23 @@ #include "global.h" #include "code_8002774.h" +#include "code_80118A4.h" +#include "code_8097670.h" +#include "code_80A26CC.h" #include "debug.h" +#include "dungeon.h" #include "event_flag.h" +#include "exclusive_pokemon.h" #include "ground_link.h" #include "ground_script.h" #include "ground_sprite.h" +#include "ground_main.h" #include "ground_map.h" -#include "dungeon.h" -#include "string_format.h" -#include "other_random.h" -#include "rescue_team_info.h" -#include "code_80118A4.h" -#include "code_8097670.h" -#include "exclusive_pokemon.h" #include "items.h" #include "math.h" -#include "ground_main.h" -#include "code_80A26CC.h" +#include "other_random.h" +#include "rescue_team_info.h" +#include "string_format.h" #include "wigglytuff_shop1.h" -#include "code_8002774.h" #include "wonder_mail.h" void GroundMap_Select(s16); @@ -120,12 +119,9 @@ s32 ExecuteScriptCommand(Action *action); bool8 IsFanfareSEPlaying_1(u16 songIndex); bool8 sub_8099B94(void); bool8 IsEqualtoBGTrack(u16 songIndex); -void sub_800290C(PixelPos *a0, s32 a1); s32 ExecuteScriptCommand(Action *action); void InitScriptData(ScriptData *); bool8 sub_8099B94(void); -void sub_800290C(PixelPos*, s32); -void sub_8002934(PixelPos*, PixelPos*, PixelPos*, s32, s32); s8 VecDirection8Radial(PixelPos*); PixelPos SetVecFromDirectionSpeed(s8, s32); void CopyStringtoBuffer(u8 *buffer, u8 *string); @@ -1345,6 +1341,7 @@ s16 HandleAction(Action *action, DebugLocation *debug) } } +// overlay_0000.bin::021497FC // Return values: // This function returns what's likely an enum, which controls the state of the script engine state machine, and possibly provides information to code calling the engine. // The enum is shared at least with HandleAction. diff --git a/src/ground_sprite.c b/src/ground_sprite.c index 19887845b..2f20c34e7 100644 --- a/src/ground_sprite.c +++ b/src/ground_sprite.c @@ -1,6 +1,6 @@ #include "gba/defines.h" #include "global.h" -#include "code_800558C.h" +#include "structs/axdata.h" #include "code_800DAC0.h" #include "debug.h" #include "def_filearchives.h" diff --git a/src/gulpin_shop.c b/src/gulpin_shop.c index f52a89cb8..be915522a 100644 --- a/src/gulpin_shop.c +++ b/src/gulpin_shop.c @@ -3,15 +3,15 @@ #include "code_80118A4.h" #include "code_801EE10.h" #include "code_801EE10_mid.h" -#include "string_format.h" #include "common_strings.h" #include "gulpin_shop.h" #include "input.h" -#include "pokemon.h" #include "memory.h" #include "menu_input.h" #include "moves.h" -#include "text.h" +#include "pokemon.h" +#include "string_format.h" +#include "text_1.h" static EWRAM_INIT GulpinShopWork *sGulpinShopWork = {NULL}; @@ -48,7 +48,7 @@ bool8 CreateGulpinShop(u32 mode, s16 pokeSpecies, Move *moves) faceFile = GetDialogueSpriteDataPtr(MONSTER_GULPIN); sGulpinShopWork->monPortrait.faceFile = faceFile; - sGulpinShopWork->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; + sGulpinShopWork->monPortrait.faceData = (PortraitGfx *) faceFile->data; sGulpinShopWork->monPortrait.spriteId = 0; sGulpinShopWork->monPortrait.flip = FALSE; @@ -111,7 +111,7 @@ static void sub_801E980(void) { s32 index; - RestoreUnkTextStruct_8006518(&sGulpinShopWork->unk12C); + RestoreSavedWindows(&sGulpinShopWork->unk12C); switch (sGulpinShopWork->state) { case 2: diff --git a/src/gulpin_shop_801FB50.c b/src/gulpin_shop_801FB50.c index b48c58a05..3a049c240 100644 --- a/src/gulpin_shop_801FB50.c +++ b/src/gulpin_shop_801FB50.c @@ -1,8 +1,6 @@ #include "global.h" #include "globaldata.h" #include "code_80118A4.h" -#include "string_format.h" -#include "iq_skill_menu.h" #include "code_801EE10.h" #include "code_801EE10_mid.h" #include "code_8023868.h" @@ -12,12 +10,14 @@ #include "gulpin_shop.h" #include "gulpin_shop_801FB50.h" #include "input.h" +#include "iq_skill_menu.h" #include "memory.h" #include "menu_input.h" #include "moves.h" #include "pokemon_3.h" #include "pokemon.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" EWRAM_INIT unkStruct_203B27C *gUnknown_203B27C = {NULL}; @@ -98,7 +98,7 @@ bool8 sub_801FB50(u32 mode) faceFile = GetDialogueSpriteDataPtr(MONSTER_GULPIN); gUnknown_203B27C->monPortrait.faceFile = faceFile; - gUnknown_203B27C->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; + gUnknown_203B27C->monPortrait.faceData = (PortraitGfx *) faceFile->data; gUnknown_203B27C->monPortrait.spriteId = 0; gUnknown_203B27C->monPortrait.flip = FALSE; gUnknown_203B27C->monPortrait.unkE = 0; @@ -194,7 +194,7 @@ static void sub_801FDC0(void) { s32 index; - RestoreUnkTextStruct_8006518(&gUnknown_203B27C->unk180); + RestoreSavedWindows(&gUnknown_203B27C->unk180); switch (gUnknown_203B27C->state) { case 0x2: diff --git a/src/hints_menu1.c b/src/hints_menu1.c index 790f6214f..fde57b5ed 100644 --- a/src/hints_menu1.c +++ b/src/hints_menu1.c @@ -1,13 +1,14 @@ #include "global.h" #include "globaldata.h" +#include "structs/struct_sub80095e4.h" #include "code_80118A4.h" #include "common_strings.h" #include "hints_menu1.h" #include "input.h" #include "memory.h" #include "menu_input.h" -#include "text.h" -#include "structs/struct_sub80095e4.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT struct_Sub80095E4 *sUnknown_203B264 = {NULL}; @@ -24,7 +25,7 @@ bool8 sub_801E3F0(u32 a0) sUnknown_203B264->unk34 = a0; sUnknown_203B264->unk38 = &sUnknown_203B264->windows.id[a0]; - RestoreUnkTextStruct_8006518(&sUnknown_203B264->windows); + RestoreSavedWindows(&sUnknown_203B264->windows); sUnknown_203B264->windows.id[sUnknown_203B264->unk34] = sUnknown_80DC0BC; sub_8012D08(sUnknown_203B264->unk38, 10); ResetUnusedInputStruct(); diff --git a/src/hints_menu2.c b/src/hints_menu2.c index 52b2496d7..a52d7a6b2 100644 --- a/src/hints_menu2.c +++ b/src/hints_menu2.c @@ -1,13 +1,13 @@ #include "global.h" #include "globaldata.h" +#include "structs/struct_sub80095e4.h" #include "code_80118A4.h" #include "common_strings.h" #include "hints_menu2.h" #include "input.h" #include "memory.h" #include "menu_input.h" -#include "text.h" -#include "structs/struct_sub80095e4.h" +#include "text_1.h" static EWRAM_INIT struct_Sub80095E4_2 *sUnknown_203B268 = {NULL}; @@ -23,7 +23,7 @@ bool8 CreateHintDisplayScreen(u32 index) sUnknown_203B268 = MemoryAlloc(sizeof(struct_Sub80095E4_2), 8); sUnknown_203B268->s0.unk34 = 0; sUnknown_203B268->s0.unk38 = &sUnknown_203B268->s0.windows.id[0]; - RestoreUnkTextStruct_8006518(&sUnknown_203B268->s0.windows); + RestoreSavedWindows(&sUnknown_203B268->s0.windows); sUnknown_203B268->s0.windows.id[sUnknown_203B268->s0.unk34] = sUnknown_80DC0FC; sUnknown_203B268->s0.unk38->header = &sUnknown_203B268->unk9C; ResetUnusedInputStruct(); diff --git a/src/iq_skill_info_menu.c b/src/iq_skill_info_menu.c index 2aafedbb3..66ba3160f 100644 --- a/src/iq_skill_info_menu.c +++ b/src/iq_skill_info_menu.c @@ -1,15 +1,17 @@ #include "global.h" #include "globaldata.h" #include "code_80118A4.h" -#include "string_format.h" -#include "iq_skill_info_menu.h" #include "code_8097DD0.h" #include "input.h" +#include "iq_skill_info_menu.h" #include "memory.h" #include "menu_input.h" #include "pokemon_3.h" #include "sprite.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" static EWRAM_INIT struct IQSkillInfoMenu *sIQSkillInfoMenu = {NULL}; diff --git a/src/iq_skill_list_menu.c b/src/iq_skill_list_menu.c index 9b74c99f2..30ee64976 100644 --- a/src/iq_skill_list_menu.c +++ b/src/iq_skill_list_menu.c @@ -2,13 +2,14 @@ #include "globaldata.h" #include "constants/input.h" #include "code_80118A4.h" -#include "string_format.h" -#include "iq_skill_list_menu.h" #include "input.h" +#include "iq_skill_list_menu.h" #include "memory.h" #include "menu_input.h" #include "pokemon_3.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT struct IQSkillListMenu *sIQSkillListMenu = {NULL}; @@ -31,7 +32,7 @@ bool8 CreateIQSkillListMenu(s16 species, u32 index, u32 a2) sIQSkillListMenu->numIQSkills = GetNumAvailableIQSkills(sIQSkillListMenu->iqSkills, sIQSkillListMenu->pokeStruct->IQ); sIQSkillListMenu->s24.s0.unk34 = index; sIQSkillListMenu->s24.s0.unk38 = &sIQSkillListMenu->s24.s0.windows.id[index]; - RestoreUnkTextStruct_8006518(&sIQSkillListMenu->s24.s0.windows); + RestoreSavedWindows(&sIQSkillListMenu->s24.s0.windows); sIQSkillListMenu->s24.s0.windows.id[sIQSkillListMenu->s24.s0.unk34] = sUnknown_80DBDF0; sIQSkillListMenu->s24.s0.unk38->header = &sIQSkillListMenu->s24.unk9C; sub_8012D08(sIQSkillListMenu->s24.s0.unk38, a2); diff --git a/src/iq_skill_menu.c b/src/iq_skill_menu.c index dfd55c353..4e6cc7783 100644 --- a/src/iq_skill_menu.c +++ b/src/iq_skill_menu.c @@ -1,15 +1,15 @@ #include "global.h" #include "globaldata.h" #include "code_80118A4.h" +#include "common_strings.h" +#include "input.h" #include "iq_skill_menu.h" #include "iq_skill_list_menu.h" #include "iq_skill_info_menu.h" -#include "common_strings.h" -#include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon_3.h" -#include "text.h" +#include "text_1.h" static EWRAM_INIT struct IQSkillMenu *sIQSkillMenu = {NULL}; @@ -77,7 +77,7 @@ static void sub_801BFCC(void) { s32 i; - RestoreUnkTextStruct_8006518(&sIQSkillMenu->unkC4); + RestoreSavedWindows(&sIQSkillMenu->unkC4); if (sIQSkillMenu->state == 2) sIQSkillMenu->unkC4.id[2] = sUnknown_80DBDB0; diff --git a/src/items.c b/src/items.c index dfdd5dc1a..2e18199a1 100644 --- a/src/items.c +++ b/src/items.c @@ -2,16 +2,16 @@ #include "code_8097DD0.h" #include "constants/colors.h" #include "constants/type.h" +#include "code_800D090.h" #include "def_filearchives.h" #include "items.h" #include "moves.h" -#include "random.h" #include "pokemon.h" #include "random.h" -#include "code_800D090.h" -#include "text_util.h" -#include "text.h" #include "string_format.h" +#include "text_1.h" +#include "text_2.h" +#include "text_util.h" extern const char gItemParaFileName[]; extern const char gUnknown_8109794[]; diff --git a/src/kangaskhan_storage1.c b/src/kangaskhan_storage1.c index 76b2e6515..4baf0d997 100644 --- a/src/kangaskhan_storage1.c +++ b/src/kangaskhan_storage1.c @@ -1,6 +1,5 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" #include "code_801B3C0.h" #include "code_801C8C4.h" #include "code_8099360.h" @@ -11,7 +10,9 @@ #include "memory.h" #include "menu_input.h" #include "pokemon.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" EWRAM_INIT struct KangaskhanStorageWork *gKangaskhanStorageWork = {NULL}; @@ -64,7 +65,7 @@ bool8 CreateKangaskhanStorage(u32 mode) faceFile = GetDialogueSpriteDataPtr(MONSTER_KANGASKHAN); gKangaskhanStorageWork->monPortrait.faceFile = faceFile; - gKangaskhanStorageWork->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; + gKangaskhanStorageWork->monPortrait.faceData = (PortraitGfx *) faceFile->data; gKangaskhanStorageWork->monPortrait.spriteId = FALSE; gKangaskhanStorageWork->monPortrait.flip = FALSE; gKangaskhanStorageWork->monPortrait.unkE = 0; @@ -145,7 +146,7 @@ static void sub_8016E80(void) { s32 index; - RestoreUnkTextStruct_8006518(&gKangaskhanStorageWork->unkEC); + RestoreSavedWindows(&gKangaskhanStorageWork->unkEC); switch (gKangaskhanStorageWork->currState) { case 13: diff --git a/src/kangaskhan_storage2.c b/src/kangaskhan_storage2.c index ca026110f..db7abb9d2 100644 --- a/src/kangaskhan_storage2.c +++ b/src/kangaskhan_storage2.c @@ -1,6 +1,5 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" #include "code_801B3C0.h" #include "code_801C8C4.h" #include "code_8099360.h" @@ -10,7 +9,9 @@ #include "kecleon_bros4.h" #include "memory.h" #include "menu_input.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT unkStruct_203B20C *sUnknown_203B20C = {NULL}; @@ -108,7 +109,7 @@ static void sub_8017F28(void) { s32 index; - RestoreUnkTextStruct_8006518(&sUnknown_203B20C->unkF0); + RestoreSavedWindows(&sUnknown_203B20C->unkF0); switch (sUnknown_203B20C->state) { case KANGASKHAN_STORAGE_2_MAIN: diff --git a/src/kecleon_bros1.c b/src/kecleon_bros1.c index 2d6f440f6..1c9f8da32 100644 --- a/src/kecleon_bros1.c +++ b/src/kecleon_bros1.c @@ -1,7 +1,6 @@ #include "global.h" #include "globaldata.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_801B3C0.h" #include "code_8099360.h" #include "common_strings.h" @@ -15,7 +14,8 @@ #include "memory.h" #include "menu_input.h" #include "pokemon.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" static EWRAM_INIT KecleonBrosWork1 *sKecleonBrosWork1 = {NULL}; @@ -104,7 +104,7 @@ bool8 CreateKecleonBros(u32 mode) faceFile = GetDialogueSpriteDataPtr(MONSTER_KECLEON); sKecleonBrosWork1->monPortrait.faceFile = faceFile; - sKecleonBrosWork1->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; + sKecleonBrosWork1->monPortrait.faceData = (PortraitGfx *) faceFile->data; sKecleonBrosWork1->monPortrait.spriteId = 0; sKecleonBrosWork1->monPortrait.flip = FALSE; sKecleonBrosWork1->monPortrait.unkE = 0; @@ -179,7 +179,7 @@ static void sub_8018D30(void) { s32 i; - RestoreUnkTextStruct_8006518(&sKecleonBrosWork1->unkE8); + RestoreSavedWindows(&sKecleonBrosWork1->unkE8); switch (sKecleonBrosWork1->currState) { case 18: diff --git a/src/kecleon_bros2.c b/src/kecleon_bros2.c index eef49dd1a..221c25649 100644 --- a/src/kecleon_bros2.c +++ b/src/kecleon_bros2.c @@ -1,15 +1,16 @@ #include "global.h" #include "globaldata.h" +#include "constants/input.h" +#include "structs/struct_sub80095e4.h" #include "code_800D090.h" #include "code_80118A4.h" -#include "constants/input.h" #include "input.h" #include "items.h" #include "kecleon_bros2.h" #include "memory.h" #include "menu_input.h" -#include "text.h" -#include "structs/struct_sub80095e4.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT struct_Sub80095E4_2 *gUnknown_203B214 = {NULL}; static EWRAM_INIT u16 gUnknown_203B218 = {0}; @@ -26,7 +27,7 @@ bool8 sub_8019E40(u32 r0) gUnknown_203B214 = MemoryAlloc(sizeof(*gUnknown_203B214), 8); gUnknown_203B214->s0.unk34 = r0; gUnknown_203B214->s0.unk38 = &gUnknown_203B214->s0.windows.id[gUnknown_203B214->s0.unk34]; - RestoreUnkTextStruct_8006518(&gUnknown_203B214->s0.windows); + RestoreSavedWindows(&gUnknown_203B214->s0.windows); gUnknown_203B214->s0.windows.id[gUnknown_203B214->s0.unk34] = sUnknown_80DB8CC; gUnknown_203B214->s0.unk38->header = &gUnknown_203B214->unk9C; ResetUnusedInputStruct(); diff --git a/src/kecleon_bros3.c b/src/kecleon_bros3.c index 78fb7a7d9..f71eee4c4 100644 --- a/src/kecleon_bros3.c +++ b/src/kecleon_bros3.c @@ -1,15 +1,16 @@ #include "global.h" #include "globaldata.h" +#include "constants/input.h" +#include "structs/struct_sub80095e4.h" #include "code_800D090.h" #include "code_80118A4.h" -#include "constants/input.h" #include "input.h" #include "items.h" #include "kecleon_bros3.h" #include "memory.h" #include "menu_input.h" -#include "text.h" -#include "structs/struct_sub80095e4.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT struct_Sub80095E4_2 *gUnknown_203B21C = {NULL}; static EWRAM_INIT u16 gUnknown_203B220 = {0}; @@ -26,7 +27,7 @@ u8 sub_801A20C(u32 r0) gUnknown_203B21C = MemoryAlloc(sizeof(*gUnknown_203B21C), 8); gUnknown_203B21C->s0.unk34 = r0; gUnknown_203B21C->s0.unk38 = &gUnknown_203B21C->s0.windows.id[gUnknown_203B21C->s0.unk34]; - RestoreUnkTextStruct_8006518(&gUnknown_203B21C->s0.windows); + RestoreSavedWindows(&gUnknown_203B21C->s0.windows); gUnknown_203B21C->s0.windows.id[gUnknown_203B21C->s0.unk34] = sUnknown_80DB914; gUnknown_203B21C->s0.unk38->header = &gUnknown_203B21C->unk9C; ResetUnusedInputStruct(); diff --git a/src/kecleon_bros4.c b/src/kecleon_bros4.c index 6a50ff9a5..9dfd45c8a 100644 --- a/src/kecleon_bros4.c +++ b/src/kecleon_bros4.c @@ -1,16 +1,17 @@ #include "global.h" #include "globaldata.h" +#include "constants/input.h" #include "code_800D090.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_8099360.h" -#include "constants/input.h" #include "input.h" #include "items.h" #include "kecleon_bros4.h" #include "memory.h" #include "menu_input.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT unkStruct_203B224 *gUnknown_203B224 = {NULL}; static EWRAM_INIT u16 gUnknown_203B228 = {0}; @@ -36,7 +37,7 @@ bool8 sub_801A5D8(u32 param_1, s32 param_2, DungeonPos *param_3, u32 param_4) sub_801AE84(); gUnknown_203B224->unk54.s0.unk34 = param_2; gUnknown_203B224->unk54.s0.unk38 = &gUnknown_203B224->unk54.s0.windows.id[param_2]; - RestoreUnkTextStruct_8006518(&gUnknown_203B224->unk54.s0.windows); + RestoreSavedWindows(&gUnknown_203B224->unk54.s0.windows); gUnknown_203B224->unk54.s0.windows.id[gUnknown_203B224->unk54.s0.unk34] = sUnknown_80DB95C; gUnknown_203B224->unk54.s0.unk38->header = &gUnknown_203B224->unk54.unk9C; diff --git a/src/load_screen.c b/src/load_screen.c index cc25b37e2..0874b0425 100644 --- a/src/load_screen.c +++ b/src/load_screen.c @@ -1,12 +1,13 @@ #include "global.h" #include "globaldata.h" -#include "bg_palette_buffer.h" -#include "code_800D090.h" -#include "string_format.h" -#include "code_8094F88.h" -#include "code_8097670.h" #include "constants/main_menu.h" #include "constants/wonder_mail.h" +#include "structs/menu.h" +#include "bg_palette_buffer.h" +#include "code_800D090.h" +#include "code_8094F88.h" +#include "code_8097670.h" +#include "def_filearchives.h" #include "dungeon.h" #include "event_flag.h" #include "file_system.h" @@ -14,14 +15,15 @@ #include "input.h" #include "main_menu1.h" #include "memory.h" -#include "structs/menu.h" #include "menu_input.h" #include "play_time.h" #include "pokemon.h" #include "save.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" #include "text_util.h" -#include "text.h" -#include "def_filearchives.h" struct LoadScreen { diff --git a/src/luminous_cave.c b/src/luminous_cave.c index ba628e768..71347a7c2 100644 --- a/src/luminous_cave.c +++ b/src/luminous_cave.c @@ -1,16 +1,15 @@ #include "global.h" #include "globaldata.h" +#include "constants/bg_music.h" +#include "constants/colors.h" +#include "constants/evolution_status.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_801602C.h" #include "code_801B3C0.h" #include "code_8097670.h" #include "code_8098BDC.h" #include "code_8099360.h" #include "common_strings.h" -#include "constants/bg_music.h" -#include "constants/colors.h" -#include "constants/evolution_status.h" #include "input.h" #include "kecleon_bros4.h" #include "luminous_cave.h" @@ -18,8 +17,9 @@ #include "menu_input.h" #include "pokemon.h" #include "random.h" +#include "string_format.h" +#include "text_1.h" #include "text_util.h" -#include "text.h" enum { @@ -180,7 +180,7 @@ static void sub_8024804(void) { s32 i; - RestoreUnkTextStruct_8006518(&sLuminousCaveWork->unk114); + RestoreSavedWindows(&sLuminousCaveWork->unk114); switch (sLuminousCaveWork->state) { case 8: diff --git a/src/mailbox.c b/src/mailbox.c index b9126a1e0..3ff554fb2 100644 --- a/src/mailbox.c +++ b/src/mailbox.c @@ -1,20 +1,20 @@ #include "global.h" #include "globaldata.h" -#include "code_802DE84.h" -#include "common_strings.h" -#include "memory.h" -#include "text.h" #include "structs/menu.h" +#include "code_80118A4.h" +#include "code_802DE84.h" +#include "code_803B050.h" +#include "code_80958E8.h" +#include "common_strings.h" #include "input.h" #include "mailbox.h" +#include "memory.h" #include "menu_input.h" -#include "code_80118A4.h" #include "pokemon_news1.h" #include "pokemon_news2.h" #include "pokemon_news3.h" -#include "code_80958E8.h" -#include "code_803B050.h" -#include "code_80958E8.h" +#include "text_1.h" +#include "text_2.h" #include "wonder_mail_802C4C8.h" #include "wonder_mail_802C860.h" @@ -150,7 +150,7 @@ void SetMailboxState(u32 newState) void sub_802E0A0(void) { s32 index; - RestoreUnkTextStruct_8006518(&gUnknown_203B304->unk10C); + RestoreSavedWindows(&gUnknown_203B304->unk10C); switch(gUnknown_203B304->state) { case MAIN_MAILBOX_MENU: diff --git a/src/main.c b/src/main.c index 837f72fd6..4840d8357 100644 --- a/src/main.c +++ b/src/main.c @@ -16,7 +16,7 @@ #include "random.h" #include "reg_control.h" #include "sprite.h" -#include "text.h" +#include "text_1.h" extern u8 ewram_start[]; extern u8 ewram_end[]; // Force a second storage in the asm diff --git a/src/main_loops.c b/src/main_loops.c index 66e14a2bf..62c13479b 100644 --- a/src/main_loops.c +++ b/src/main_loops.c @@ -39,8 +39,11 @@ #include "rescue_team_info.h" #include "save.h" #include "save_read.h" +#include "sprite.h" #include "string_format.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" #include "text_util.h" typedef struct unkTalkTable @@ -238,18 +241,26 @@ static void MainLoops_RunFrameActions(u32 unused) DrawDialogueBoxString(); sub_8005838(NULL, 0); nullsub_8(gGameOptionsRef->unkA); + sub_8005180(); + // Extra call here in blue. Seems to be for 2nd screen sprites + sub_80060EC(); sub_8011860(); WaitForNextFrameAndAdvanceRNG(); LoadBufferedInputs(); + CopySpritesToOam(); sub_8005304(); + // 2 extra calls here in blue. They seem to be copies of the 2 above funcs, but for 2nd screen sprites + TransferBGPaletteBuffer(); xxx_call_update_bg_vram(); sub_8009908(); xxx_call_update_bg_sound_input(); + ResetSprites(FALSE); + // Extra call here in blue. Seems to be for 2nd screen sprites } // https://decomp.me/scratch/w6tN1 (82.93%) @@ -1204,6 +1215,7 @@ static u32 sub_80009D0(u32 param_1) // This func is probably used for running the dungeon in general (and updating RNG mechanics), not just quicksave. // More documentation needed to be sure // It'd also be cool to see what happens if a quicksave load fails and the dungeon is skipped entirely +// arm9.bin::0200D01C /* static */ // TODO: Uncomment void LoadAndRunQuickSaveDungeon_Async(UnkStruct_RunDungeon *param_1) { @@ -1288,16 +1300,19 @@ void LoadAndRunQuickSaveDungeon_Async(UnkStruct_RunDungeon *param_1) } } +// arm9.bin::0200CFF4 void sub_8001024(PersonalityRelated *dst) { *dst = sPersonalityRelated_203B040; } +// arm9.bin::0200CFA4 void sub_8001044(PersonalityRelated *src) { sPersonalityRelated_203B040 = *src; } +// arm9.bin::0200CE48 void sub_8001064(void) { const unkTalkTable *psVar2; @@ -1341,6 +1356,7 @@ void sub_8001064(void) } } +// arm9.bin::0200CDD4 /* static */ // TODO: Uncomment u8 sub_8001170(void) { @@ -1357,6 +1373,7 @@ u8 sub_8001170(void) return dungeonID; } +// arm9.bin::0200CDA4 /* static */ // TODO: Uncomment void sub_80011CC(u8 *param_1, u8 param_2) { @@ -1373,6 +1390,7 @@ void sub_80011CC(u8 *param_1, u8 param_2) param_1[13] = 0; } +// arm9.bin::0200CD1C /* static */ // TODO: Uncomment void sub_80011E8(u8 *param_1) { @@ -1388,6 +1406,7 @@ void sub_80011E8(u8 *param_1) param_1[7] = 0; } +// arm9.bin::0200CC4C /* static */ // TODO: Uncomment void sub_8001248(void) { @@ -1409,6 +1428,7 @@ void sub_8001248(void) gTeamInventoryRef->teamMoney = 0; } +// arm9.bin::0200CB88 /* static */ // TODO: Uncomment void sub_80012C0(void) { diff --git a/src/main_menu1.c b/src/main_menu1.c index b1627fbb9..bad2e2e5d 100644 --- a/src/main_menu1.c +++ b/src/main_menu1.c @@ -1,9 +1,9 @@ #include "global.h" #include "globaldata.h" -#include "adventure_log_menu.h" -#include "code_8099360.h" #include "constants/item.h" #include "constants/main_menu.h" +#include "adventure_log_menu.h" +#include "code_8099360.h" #include "debug_menu1.h" #include "ds_menus.h" #include "friend_rescue.h" @@ -17,7 +17,7 @@ #include "other_menus1.h" #include "rescue_password_menu.h" #include "save_menu.h" -#include "text.h" +#include "text_1.h" #include "trade_items_menu.h" #include "unk_menu_203B360.h" #include "wonder_mail_main_menu.h" @@ -310,7 +310,7 @@ void sub_8035CC0(WindowTemplates *dataArray, u32 index) { WindowTemplate *winPtrs; - RestoreUnkTextStruct_8006518(dataArray); + RestoreSavedWindows(dataArray); winPtrs = dataArray->id; winPtrs[index] = sUnknown_80E59A8; ResetUnusedInputStruct(); diff --git a/src/main_menu2.c b/src/main_menu2.c index 26837cfe3..310f50662 100644 --- a/src/main_menu2.c +++ b/src/main_menu2.c @@ -1,15 +1,15 @@ #include "global.h" #include "globaldata.h" -#include "code_803D0D8.h" #include "constants/main_menu.h" #include "constants/wonder_mail.h" +#include "code_803D0D8.h" #include "input.h" #include "main_menu1.h" #include "main_menu2.h" #include "memory.h" #include "menu_input.h" #include "save.h" -#include "text.h" +#include "text_1.h" static EWRAM_INIT MainMenu2Work *sUnknown_203B34C = {NULL}; static EWRAM_INIT u32 sUnknown_203B350 = {MENU_DEBUG}; diff --git a/src/makuhita_dojo1.c b/src/makuhita_dojo1.c index a4d430b09..d400915cf 100644 --- a/src/makuhita_dojo1.c +++ b/src/makuhita_dojo1.c @@ -1,18 +1,18 @@ #include "global.h" #include "globaldata.h" +#include "constants/colors.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_801B60C.h" #include "code_80A26CC.h" #include "common_strings.h" -#include "constants/colors.h" #include "dungeon.h" #include "input.h" #include "makuhita_dojo1.h" #include "makuhita_dojo2.h" #include "memory.h" #include "pokemon.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" static EWRAM_INIT MakuhitaDojoWork1 *sMakuhitaDojoWork1 = {NULL}; @@ -95,7 +95,7 @@ bool8 MakuhitaDojo_New(u32 mode) faceFile = GetDialogueSpriteDataPtr(MONSTER_MAKUHITA); sMakuhitaDojoWork1->monPortrait.faceFile = faceFile; - sMakuhitaDojoWork1->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; + sMakuhitaDojoWork1->monPortrait.faceData = (PortraitGfx *) faceFile->data; sMakuhitaDojoWork1->monPortrait.spriteId = 0; sMakuhitaDojoWork1->monPortrait.flip = FALSE; sMakuhitaDojoWork1->monPortrait.unkE = 0; @@ -152,7 +152,7 @@ static void sub_802FF1C(void) { s32 index; - RestoreUnkTextStruct_8006518(&sMakuhitaDojoWork1->unk6C); + RestoreSavedWindows(&sMakuhitaDojoWork1->unk6C); switch (sMakuhitaDojoWork1->state) { case 0: diff --git a/src/makuhita_dojo2.c b/src/makuhita_dojo2.c index 09ccdb020..e5e2d545c 100644 --- a/src/makuhita_dojo2.c +++ b/src/makuhita_dojo2.c @@ -1,17 +1,18 @@ #include "global.h" #include "globaldata.h" +#include "constants/colors.h" +#include "constants/input.h" #include "code_800D090.h" #include "code_80118A4.h" #include "code_80972F4.h" #include "code_80A26CC.h" -#include "constants/colors.h" -#include "constants/input.h" #include "dungeon.h" #include "input.h" #include "makuhita_dojo2.h" #include "memory.h" #include "menu_input.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT MakuhitaDojoWork2 *sMakuhitaDojoWork2 = {NULL}; @@ -32,7 +33,7 @@ bool8 sub_80302E8(s32 param_1, DungeonPos *param_2, u32 param_3) sMakuhitaDojoWork2->s30.s0.unk34 = param_1; sMakuhitaDojoWork2->s30.s0.unk38 = &sMakuhitaDojoWork2->s30.s0.windows.id[param_1]; - RestoreUnkTextStruct_8006518(&sMakuhitaDojoWork2->s30.s0.windows); + RestoreSavedWindows(&sMakuhitaDojoWork2->s30.s0.windows); sMakuhitaDojoWork2->s30.s0.windows.id[sMakuhitaDojoWork2->s30.s0.unk34] = sUnknown_80E0804; sMakuhitaDojoWork2->s30.s0.unk38->header = &sMakuhitaDojoWork2->s30.unk9C; diff --git a/src/memory.c b/src/memory.c index 243743876..56f94f0dc 100644 --- a/src/memory.c +++ b/src/memory.c @@ -38,7 +38,7 @@ struct HeapFreeListElement }; // size: 0x1C -struct HeapDescriptor +typedef struct HeapDescriptor { u32 unk0; /* 0x4 */ struct HeapDescriptor *parentHeap; @@ -47,28 +47,28 @@ struct HeapDescriptor /* 0x10 */ s32 freeListLength; /* 0x14 */ u8 *start; /* 0x18 */ u32 size; -}; +} HeapDescriptor; // size: 0x8 struct unkMemoryStruct { - struct HeapDescriptor *unk0; + HeapDescriptor *unk0; u32 end; }; -static EWRAM_DATA struct HeapDescriptor *sHeapDescriptorList[8] = {0}; +static EWRAM_DATA HeapDescriptor *sHeapDescriptorList[8] = {0}; static EWRAM_DATA s32 sHeapCount = {0}; UNUSED static EWRAM_DATA u32 sUnused1 = 0; -static EWRAM_DATA struct HeapDescriptor sMainHeapDescriptor = {0}; +static EWRAM_DATA HeapDescriptor sMainHeapDescriptor = {0}; UNUSED static EWRAM_DATA u32 sUnused2 = 0; static EWRAM_DATA struct HeapFreeListElement sMainHeapFreeList[32] = {0}; static EWRAM_DATA u8 sMainHeap[HEAP_SIZE] = {0}; -static void DoFree(struct HeapDescriptor *, void *); -static void DoInitHeap(struct HeapDescriptor *, struct HeapSettings *, struct HeapFreeListElement *, u32); -static void InitSubHeap(struct HeapDescriptor *, struct HeapMemoryBlock2 *, u32); -static struct HeapDescriptor *DoCreateSubHeap(struct unkMemoryStruct *a, u32 b); -static void *DoAlloc(struct HeapDescriptor *heap, s32 size, u32 a2); +static void DoFree(HeapDescriptor *, void *); +static void DoInitHeap(HeapDescriptor *, struct HeapSettings *, struct HeapFreeListElement *, u32); +static void InitSubHeap(HeapDescriptor *, struct HeapMemoryBlock2 *, u32); +static HeapDescriptor *DoCreateSubHeap(struct unkMemoryStruct *a, u32 b); +static void *DoAlloc(HeapDescriptor *heap, s32 size, u32 a2); static void InitHeapInternal(void); ALIGNED(4) static const char sFileNameText[] = "../system/memory_locate.c"; @@ -127,6 +127,7 @@ UNUSED static void MemoryFill32(u32 *dest, u32 value, s32 size) } } +// arm9.bin::02010BB4 void MemoryCopy8(void *dest, void *src, s32 size) { u8 *dCur = dest; @@ -154,6 +155,7 @@ void MemoryCopy32(u32 *dest, u32 *src, s32 size) } } +// arm9.bin::02011320 static void InitHeapInternal(void) { struct HeapSettings settings; @@ -164,7 +166,8 @@ static void InitHeapInternal(void) DoInitHeap(&sMainHeapDescriptor, &settings, sMainHeapFreeList, sizeof(sMainHeapFreeList) / sizeof(struct HeapFreeListElement)); } -static void DoInitHeap(struct HeapDescriptor *descriptor, struct HeapSettings *settings, struct HeapFreeListElement *freeList, u32 freeListLength) +// arm9.bin::020112A4 +static void DoInitHeap(HeapDescriptor *descriptor, struct HeapSettings *settings, struct HeapFreeListElement *freeList, u32 freeListLength) { u32 aligned_size; @@ -188,7 +191,7 @@ static void DoInitHeap(struct HeapDescriptor *descriptor, struct HeapSettings *s freeList->grp = 0; } -static void InitSubHeap(struct HeapDescriptor *parentHeap, struct HeapMemoryBlock2 *block, u32 freeListMax) +static void InitSubHeap(HeapDescriptor *parentHeap, struct HeapMemoryBlock2 *block, u32 freeListMax) { u32 freeListSize; u32 aligned_size; @@ -230,7 +233,7 @@ static u32 xxx_memory_attr_related(u32 r0) return return_var; } -static s32 MemorySearchFromFront(struct HeapDescriptor *heap, s32 atb, s32 size) +static s32 MemorySearchFromFront(HeapDescriptor *heap, s32 atb, s32 size) { s32 i; struct HeapFreeListElement *curr; @@ -274,7 +277,7 @@ static s32 MemorySearchFromFront(struct HeapDescriptor *heap, s32 atb, s32 size) return -1; } -static s32 MemorySearchFromBack(struct HeapDescriptor *heap, s32 atb, s32 size) +static s32 MemorySearchFromBack(HeapDescriptor *heap, s32 atb, s32 size) { s32 i; struct HeapFreeListElement *curr; @@ -326,7 +329,7 @@ static const DebugLocation sLocateSetFrontDebugLocation = .func = sText_LocateSetFront }; -static struct HeapFreeListElement * _LocateSetFront(struct HeapDescriptor *heap, s32 index, s32 atb, s32 size, s32 group) +static struct HeapFreeListElement * _LocateSetFront(HeapDescriptor *heap, s32 index, s32 atb, s32 size, s32 group) { s32 i; struct HeapFreeListElement *curr; @@ -370,7 +373,7 @@ static const DebugLocation sLocateSetBackDebugLocation = .func = sText_LocateSetBack }; -static struct HeapFreeListElement * _LocateSetBack(struct HeapDescriptor *heap, s32 index, s32 atb, s32 size, s32 group) +static struct HeapFreeListElement * _LocateSetBack(HeapDescriptor *heap, s32 index, s32 atb, s32 size, s32 group) { s32 i; struct HeapFreeListElement *curr; @@ -416,39 +419,40 @@ static const DebugLocation sLocateSetDebugLocation = .func = sText_LocateSet }; -static void * _LocateSet(struct HeapDescriptor *heap, s32 size, s32 group) +static void * _LocateSet(HeapDescriptor *heap, s32 size, s32 group) { - s32 index; - struct HeapFreeListElement * foundSet; - s32 atb; + s32 index; + struct HeapFreeListElement * foundSet; + s32 atb; - if (heap == NULL) { - heap = &sMainHeapDescriptor; - } + if (heap == NULL) + heap = &sMainHeapDescriptor; - // Set some sort flag/attr? - atb = group >> 8 | 1; + // Set some sort flag/attr? + atb = group >> 8 | 1; - // Reset it? - group = group & 0xff; + // Reset it? + group = group & 0xff; - if ((atb & 2) != 0) { - index = MemorySearchFromFront(heap,atb,size); - if (index < 0) goto error; - foundSet = _LocateSetFront(heap,index,atb,size,group); - return foundSet->block.start; - } - else { - index = MemorySearchFromBack(heap,atb,size); - if (index < 0) goto error; - foundSet = _LocateSetBack(heap,index,atb,size,group); - return foundSet->block.start; - } + if ((atb & 2) != 0) { + index = MemorySearchFromFront(heap, atb, size); + if (index < 0) + goto error; + foundSet = _LocateSetFront(heap, index, atb, size, group); + return foundSet->block.start; + } + else { + index = MemorySearchFromBack(heap, atb, size); + if (index < 0) + goto error; + foundSet = _LocateSetBack(heap, index, atb, size, group); + return foundSet->block.start; + } error: - FatalError(&sLocateSetDebugLocation, - "Memroy LocateSet [%p] buffer %8x size can't locate\n atb %02x grp %3d ", // Spelling error is intentional - heap,size,atb,group); + FatalError(&sLocateSetDebugLocation, + "Memroy LocateSet [%p] buffer %8x size can't locate\n atb %02x grp %3d ", + heap, size, atb, group); } void *MemoryAlloc(s32 size, s32 group) @@ -463,49 +467,49 @@ void MemoryFree(void *a) ALIGNED(4) static const char sText_MemoryLocate_LocalCreate[] = "MemoryLocate_LocalCreate"; -UNUSED static struct HeapDescriptor *MemoryLocate_LocalCreate(struct HeapDescriptor *parentHeap,u32 size,u32 param_3,u32 group) +UNUSED static HeapDescriptor *MemoryLocate_LocalCreate(HeapDescriptor *parentHeap, u32 size, u32 param_3, u32 group) { - int index; - struct HeapFreeListElement *foundSet; - struct HeapDescriptor *iVar3; - struct unkMemoryStruct local_1c; + s32 index; + struct HeapFreeListElement *foundSet; + HeapDescriptor *iVar3; + struct unkMemoryStruct local_1c; - if (parentHeap == NULL) { - parentHeap = &sMainHeapDescriptor; - } + if (parentHeap == NULL) + parentHeap = &sMainHeapDescriptor; - index = MemorySearchFromBack(parentHeap,9,size); - if (index < 0) { - static const DebugLocation debugInfo = { - .file = sFileNameText, - .line = 1109, - .func = sText_MemoryLocate_LocalCreate - }; - FatalError(&debugInfo,"Memroy LocalCreate buffer %08x size can't locate",size); // Spelling error is intentional - } + index = MemorySearchFromBack(parentHeap, 9, size); - foundSet = _LocateSetBack(parentHeap,index,9,size,group); - local_1c.unk0 = (void *) foundSet->block.start; - local_1c.end = foundSet->block.size; + if (index < 0) { + static const DebugLocation debugInfo = { + .file = sFileNameText, + .line = 1109, + .func = sText_MemoryLocate_LocalCreate + }; + FatalError(&debugInfo, "Memroy LocalCreate buffer %08x size can't locate", size); + } - iVar3 = DoCreateSubHeap(&local_1c,param_3); - iVar3->parentHeap = parentHeap; - return iVar3; + foundSet = _LocateSetBack(parentHeap, index, 9, size, group); + local_1c.unk0 = (void *)foundSet->block.start; + local_1c.end = foundSet->block.size; + + iVar3 = DoCreateSubHeap(&local_1c, param_3); + iVar3->parentHeap = parentHeap; + return iVar3; } -static struct HeapDescriptor *DoCreateSubHeap(struct unkMemoryStruct *a, u32 b) +static HeapDescriptor *DoCreateSubHeap(struct unkMemoryStruct *a, u32 b) { struct HeapMemoryBlock2 s2; - struct HeapDescriptor *a1; + HeapDescriptor *a1; a1 = a->unk0; - s2.start = (struct HeapFreeListElement *)((u8*)a1 + sizeof(struct HeapDescriptor)); - s2.size = a->end - sizeof(struct HeapDescriptor); + s2.start = (struct HeapFreeListElement *)((u8*)a1 + sizeof(HeapDescriptor)); + s2.size = a->end - sizeof(HeapDescriptor); InitSubHeap(a1, &s2, b); return a1; } -UNUSED static void xxx_unused_memory_free(struct HeapDescriptor *a1) +UNUSED static void xxx_unused_memory_free(HeapDescriptor *a1) { bool8 b; s32 i; @@ -536,12 +540,12 @@ UNUSED static void xxx_unused_memory_free(struct HeapDescriptor *a1) } } -static void *DoAlloc(struct HeapDescriptor *heap, s32 size, u32 a2) +static void *DoAlloc(HeapDescriptor *heap, s32 size, u32 a2) { return _LocateSet(heap, size, a2 | 0x100); } -static void DoFree(struct HeapDescriptor *heapDescriptior, void *ptrToFree) +static void DoFree(HeapDescriptor *heapDescriptior, void *ptrToFree) { struct HeapFreeListElement *curr; struct HeapFreeListElement *next; diff --git a/src/menu_input.c b/src/menu_input.c index a973b4795..2ca0ab553 100644 --- a/src/menu_input.c +++ b/src/menu_input.c @@ -1,18 +1,18 @@ #include "global.h" #include "globaldata.h" -#include "code_800558C.h" +#include "structs/axdata.h" +#include "structs/struct_sub80095e4.h" #include "code_800D090.h" #include "code_80118A4.h" -#include "string_format.h" #include "constants/colors.h" #include "constants/input.h" #include "input.h" #include "menu_input.h" #include "sprite.h" +#include "string_format.h" +#include "text_2.h" #include "text_util.h" -#include "text.h" #include "util.h" -#include "structs/struct_sub80095e4.h" const u32 gDefaultMenuTextColors[3] = { COLOR_WHITE_2, COLOR_RED, COLOR_RED }; @@ -164,7 +164,7 @@ void sub_8012BC4(u32 x, u32 y, s32 n, s32 len, u32 color, u32 a5) { s32 iVar1; u32 uVar2; - const struct unkChar *iVar3; + const unkChar *iVar3; s32 counter; s32 *piVar3; s32 *piVar4; @@ -209,7 +209,7 @@ void sub_8012BC4(u32 x, u32 y, s32 n, s32 len, u32 color, u32 a5) void sub_8012C60(u32 x, u32 y, u32 a2, u32 color, u32 a4) { u32 add_x; - const struct unkChar *iVar3; + const unkChar *iVar3; u32 uVar2; uVar2 = ReturnIntFromChar2(a2); @@ -258,7 +258,7 @@ void sub_8012D08(WindowTemplate *param_1, s32 param_2) param_1->unk10 = sVar3; } -void sub_8012D34(struct WindowTemplate *param_1, s32 param_2) +void sub_8012D34(WindowTemplate *param_1, s32 param_2) { s32 sVar2; s16 sVar3; @@ -397,7 +397,7 @@ void sub_8012EBC(MenuStruct *param_1) if (window->type == WINDOW_TYPE_WITH_HEADER) { WindowTemplate *windowTemplate = &winTemplates.id[index]; - RestoreUnkTextStruct_8006518(&winTemplates); + RestoreSavedWindows(&winTemplates); x = sub_8008ED0(param_1->unk0); PrintFormattedStringOnWindow(((windowTemplate->header->width * 8 - x) / 2) + 8, 0, param_1->unk0, param_1->index, 0); } diff --git a/src/mission_reward.c b/src/mission_reward.c index 5973a4e68..6feede231 100644 --- a/src/mission_reward.c +++ b/src/mission_reward.c @@ -1,16 +1,16 @@ #include "global.h" #include "globaldata.h" +#include "code_80118A4.h" +#include "code_801B60C.h" #include "code_802F204.h" -#include "pokemon.h" -#include "rescue_team_info.h" #include "friend_area.h" #include "input.h" #include "items.h" #include "memory.h" +#include "pokemon.h" +#include "rescue_team_info.h" #include "string_format.h" -#include "code_80118A4.h" -#include "code_801B60C.h" -#include "text.h" +#include "text_1.h" struct unkStruct_203B310 { @@ -21,7 +21,7 @@ struct unkStruct_203B310 /* 0x9 */ u8 currTeamRank; // team rank /* 0xC */ s32 itemRewardIndex; unkStruct_802F204 *unk10; - /* 0x14 */ struct MonPortraitMsg monPortrait; + /* 0x14 */ MonPortraitMsg monPortrait; WindowTemplates unk24; }; @@ -134,7 +134,7 @@ u32 sub_802F204(unkStruct_802F204 *r0, bool8 displayClientSprite) if(gUnknown_203B310->monPortrait.faceFile != NULL) { - gUnknown_203B310->monPortrait.faceData = (struct PortraitGfx *) gUnknown_203B310->monPortrait.faceFile->data; + gUnknown_203B310->monPortrait.faceData = (PortraitGfx *) gUnknown_203B310->monPortrait.faceFile->data; } SetRewardSceneState(PREP_MONEY_REWARD); @@ -180,7 +180,7 @@ void sub_802F300(void) switch(gUnknown_203B310->state) { case PREP_MONEY_REWARD: - RestoreUnkTextStruct_8006518(&gUnknown_203B310->unk24); + RestoreSavedWindows(&gUnknown_203B310->unk24); for(index = 0; index < 4; index++) { gUnknown_203B310->unk24.id[index] = gUnknown_80E041C; diff --git a/src/moves.c b/src/moves.c index 26ffa0f9d..e8079db16 100644 --- a/src/moves.c +++ b/src/moves.c @@ -8,8 +8,9 @@ #include "memory.h" #include "moves.h" #include "string_format.h" +#include "text_1.h" +#include "text_2.h" #include "text_util.h" -#include "text.h" static EWRAM_DATA OpenedFile *sWazaParametersFile = { NULL }; // NDS=213C188 static EWRAM_DATA MoveDataEntry *sMovesData = { NULL }; // NDS=213C18C diff --git a/src/options_menu1.c b/src/options_menu1.c index 16be3d3b9..0c14b2993 100644 --- a/src/options_menu1.c +++ b/src/options_menu1.c @@ -1,6 +1,5 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" #include "code_8099360.h" #include "common_strings.h" #include "hints_menu1.h" @@ -10,7 +9,8 @@ #include "menu_input.h" #include "options_menu1.h" #include "options_menu2.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" enum { @@ -104,7 +104,7 @@ static void sub_801DD84(void) { s32 i; - RestoreUnkTextStruct_8006518(&sUnknown_203B25C->unkBC); + RestoreSavedWindows(&sUnknown_203B25C->unkBC); switch (sUnknown_203B25C->state) { case OPTIONS_MENU_INIT: diff --git a/src/options_menu2.c b/src/options_menu2.c index cb0a936b2..7f7d87294 100644 --- a/src/options_menu2.c +++ b/src/options_menu2.c @@ -1,13 +1,15 @@ #include "global.h" #include "globaldata.h" -#include "code_80118A4.h" #include "constants/colors.h" #include "constants/input.h" +#include "code_80118A4.h" #include "input.h" #include "memory.h" #include "menu_input.h" #include "options_menu2.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" static EWRAM_INIT struct unkStruct_203B260 *sUnknown_203B260 = {NULL}; @@ -23,7 +25,7 @@ bool8 sub_801E198(GameOptions *optionsMenu) sub_801317C(&sUnknown_203B260->unk4); sUnknown_203B260->unk44 = 0; sUnknown_203B260->unk48 = &sUnknown_203B260->unk4C.id[0]; - RestoreUnkTextStruct_8006518(&sUnknown_203B260->unk4C); + RestoreSavedWindows(&sUnknown_203B260->unk4C); sUnknown_203B260->unk4C.id[sUnknown_203B260->unk44] = sUnknown_80DC03C; sub_8012D08(sUnknown_203B260->unk48, 1); ResetUnusedInputStruct(); diff --git a/src/other_menus1.c b/src/other_menus1.c index 5abc97426..ce1f2a085 100644 --- a/src/other_menus1.c +++ b/src/other_menus1.c @@ -1,14 +1,13 @@ #include "global.h" #include "globaldata.h" +#include "constants/communication_error_codes.h" +#include "constants/main_menu.h" +#include "structs/str_dungeon.h" #include "bg_palette_buffer.h" #include "code_800558C.h" #include "code_8009804.h" #include "code_800C9CC.h" #include "code_80118A4.h" -#include "string_format.h" -#include "constants/communication_error_codes.h" -#include "constants/main_menu.h" -#include "structs/str_dungeon.h" #include "input.h" #include "items.h" #include "memory.h" @@ -16,7 +15,9 @@ #include "other_menus1.h" #include "other_menus2.h" #include "sprite.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT unkStruct_203B35C *sUnknown_203B35C = {NULL}; diff --git a/src/other_random.c b/src/other_random.c index 1b5e2bc57..5699c87e9 100644 --- a/src/other_random.c +++ b/src/other_random.c @@ -1,19 +1,22 @@ #include "global.h" #include "other_random.h" -EWRAM_INIT u16 gOtherRngState = {0x348C}; +EWRAM_INIT u16 gOtherRngState = {0x348C}; // NDS=020EAC58 +// arm9.bin::020127F4 static s32 OtherRandom16(void) { gOtherRngState = 109 * gOtherRngState + 1021; return gOtherRngState; } +// arm9.bin::020127DC s32 OtherRandInt(s32 cap) { return (OtherRandom16() * cap) >> 16; } +// arm9.bin::020127C4 s32 OtherRandRange(s32 a, s32 b) { return OtherRandInt(b - a) + a; diff --git a/src/party_list_menu.c b/src/party_list_menu.c index 9b85d90d2..7a62196a1 100644 --- a/src/party_list_menu.c +++ b/src/party_list_menu.c @@ -1,10 +1,9 @@ #include "global.h" #include "globaldata.h" +#include "constants/dungeon.h" #include "code_800D090.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_801B3C0.h" -#include "iq_skill_menu.h" #include "code_801EE10.h" #include "code_801EE10_mid.h" #include "code_80227B8.h" @@ -12,9 +11,9 @@ #include "code_8098BDC.h" #include "code_8099360.h" #include "common_strings.h" -#include "constants/dungeon.h" #include "event_flag.h" #include "input.h" +#include "iq_skill_menu.h" #include "items.h" #include "kecleon_bros4.h" #include "memory.h" @@ -23,8 +22,10 @@ #include "party_list_menu.h" #include "pokemon.h" #include "pokemon_3.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" #include "text_util.h" -#include "text.h" static EWRAM_INIT unkStruct_203B2B8 *sUnknown_203B2B8 = {NULL}; @@ -157,7 +158,7 @@ static void SetPartyListMenuState(s32 newState) static void sub_802608C(void) { s32 index; - RestoreUnkTextStruct_8006518(&sUnknown_203B2B8->unk220); + RestoreSavedWindows(&sUnknown_203B2B8->unk220); switch(sUnknown_203B2B8->state) { case PARTY_LIST_STATE_MAIN_MENU: diff --git a/src/pelipper_board.c b/src/pelipper_board.c index 13a521c0b..b6725d973 100644 --- a/src/pelipper_board.c +++ b/src/pelipper_board.c @@ -1,20 +1,21 @@ #include "global.h" #include "globaldata.h" -#include "code_802DE84.h" -#include "mailbox.h" -#include "pokemon.h" -#include "items.h" -#include "memory.h" -#include "text.h" #include "structs/menu.h" -#include "input.h" -#include "menu_input.h" -#include "common_strings.h" -#include "pelipper_board.h" #include "code_80118A4.h" -#include "wonder_mail_802C10C.h" -#include "code_80958E8.h" +#include "code_802DE84.h" #include "code_803B050.h" +#include "code_80958E8.h" +#include "common_strings.h" +#include "items.h" +#include "input.h" +#include "mailbox.h" +#include "memory.h" +#include "menu_input.h" +#include "pelipper_board.h" +#include "pokemon.h" +#include "text_1.h" +#include "text_2.h" +#include "wonder_mail_802C10C.h" #include "wonder_mail_802C4C8.h" #include "wonder_mail_802C860.h" @@ -145,7 +146,7 @@ void SetPelipperBoardState(u32 newState) void sub_802E94C(void) { s32 index; - RestoreUnkTextStruct_8006518(&gPelipperBoard->unk10C); + RestoreSavedWindows(&gPelipperBoard->unk10C); switch(gPelipperBoard->state) { case MAIN_PELIPPER_BOARD_MENU: diff --git a/src/personality_test1.c b/src/personality_test1.c index c53b502a1..38430e3db 100644 --- a/src/personality_test1.c +++ b/src/personality_test1.c @@ -1,11 +1,10 @@ #include "global.h" #include "globaldata.h" +#include "constants/emotions.h" #include "bg_palette_buffer.h" -#include "string_format.h" #include "code_801602C.h" #include "code_8094D28.h" #include "code_8099360.h" -#include "constants/emotions.h" #include "game_options.h" #include "input.h" #include "main_loops.h" @@ -15,9 +14,10 @@ #include "personality_test2.h" #include "random.h" #include "save.h" -#include "text_util.h" -#include "text.h" #include "string_format.h" +#include "text_1.h" +#include "text_2.h" +#include "text_util.h" enum { @@ -389,7 +389,7 @@ static void PersonalityTest_DisplayStarterSprite(void) WindowTemplates stackArray; starterID = sPersonalityTestTracker->unk4.StarterID; - RestoreUnkTextStruct_8006518(&stackArray); + RestoreSavedWindows(&stackArray); stackArray.id[1] = sUnknown_80F4244; ResetUnusedInputStruct(); ShowWindows(&stackArray, TRUE, FALSE); @@ -397,10 +397,10 @@ static void PersonalityTest_DisplayStarterSprite(void) sub_80073B8(1); faceFile = GetDialogueSpriteDataPtr(starterID); - gfx = ((struct PortraitGfx *)(faceFile->data))->sprites[EMOTION_HAPPY].gfx; + gfx = ((PortraitGfx *)(faceFile->data))->sprites[EMOTION_HAPPY].gfx; emotionId = EMOTION_HAPPY; for (paletteIndex = 0; paletteIndex < 0x10; paletteIndex++) { - SetBGPaletteBufferColorArray(paletteIndex + 0xE0, &((struct PortraitGfx *)(faceFile->data))->sprites[emotionId].pal[paletteIndex]); + SetBGPaletteBufferColorArray(paletteIndex + 0xE0, &((PortraitGfx *)(faceFile->data))->sprites[emotionId].pal[paletteIndex]); } DisplayMonPortraitSpriteFlipped(1, gfx, 14); diff --git a/src/personality_test2.c b/src/personality_test2.c index c82d295fe..eaac3c4a3 100644 --- a/src/personality_test2.c +++ b/src/personality_test2.c @@ -1,17 +1,18 @@ #include "global.h" #include "globaldata.h" #include "bg_palette_buffer.h" -#include "code_80118A4.h" #include "constants/emotions.h" #include "constants/input.h" #include "constants/type.h" +#include "code_80118A4.h" #include "input.h" #include "memory.h" #include "menu_input.h" #include "personality_test2.h" #include "pokemon.h" -#include "text.h" #include "string_format.h" +#include "text_1.h" +#include "text_2.h" EWRAM_INIT struct PersonalityStruct_203B404 *gUnknown_203B404 = {NULL}; @@ -150,10 +151,10 @@ static void PersonalityTest_DisplayPartnerSprite(void) CallPrepareTextbox_8008C54(1); sub_80073B8(1); faceFile = GetDialogueSpriteDataPtr(partnerID); - gfx = ((struct PortraitGfx *)(faceFile->data))->sprites[EMOTION_NORMAL].gfx; + gfx = ((PortraitGfx *)(faceFile->data))->sprites[EMOTION_NORMAL].gfx; emotionId = EMOTION_NORMAL; for (paletteIndex = 0; paletteIndex < 0x10; paletteIndex++) { - SetBGPaletteBufferColorArray(paletteIndex + 0xE0, &((struct PortraitGfx *)(faceFile->data))->sprites[emotionId].pal[paletteIndex]); + SetBGPaletteBufferColorArray(paletteIndex + 0xE0, &((PortraitGfx *)(faceFile->data))->sprites[emotionId].pal[paletteIndex]); } DisplayMonPortraitSpriteFlipped(1, gfx, 14); diff --git a/src/pokemon.c b/src/pokemon.c index 0c2690687..02bb9a3b4 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -6,7 +6,7 @@ #include "code_800D090.h" #include "code_8097DD0.h" #include "cpu.h" -#include "decompress.h" +#include "decompress_at.h" #include "def_filearchives.h" #include "exclusive_pokemon.h" #include "file_system.h" @@ -14,6 +14,7 @@ #include "moves.h" #include "pokemon.h" #include "pokemon_3.h" +#include "sprite.h" #include "text_util.h" static EWRAM_DATA MonsterDataEntry *gMonsterParameters = {0}; @@ -26,7 +27,8 @@ static EWRAM_DATA LevelData gLevelCurrentData[0x64] = {0}; EWRAM_INIT unkStruct_203B45C *gRecruitedPokemonRef = {NULL}; -struct unkStruct_8107654 { +struct unkStruct_8107654 +{ s16 species; s32 unk4; }; diff --git a/src/pokemon_3.c b/src/pokemon_3.c index e1a11de13..f19ccae3e 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -1,7 +1,5 @@ #include "global.h" -#include "pokemon.h" -#include "pokemon_3.h" -#include "random.h" +#include "constants/ability.h" #include "constants/colors.h" #include "constants/dungeon.h" #include "constants/evolve_type.h" @@ -9,17 +7,19 @@ #include "constants/iq_skill.h" #include "constants/tactic.h" #include "constants/type.h" -#include "constants/ability.h" +#include "structs/sprite_oam.h" #include "structs/str_pokemon.h" -#include "sprite.h" -#include "text_util.h" +#include "code_8097670.h" +#include "dungeon.h" #include "friend_area.h" #include "luminous_cave.h" -#include "code_8097670.h" #include "moves.h" +#include "pokemon.h" +#include "pokemon_3.h" +#include "random.h" #include "string_format.h" -#include "dungeon.h" -#include "text.h" +#include "text_1.h" +#include "text_util.h" extern u8 *gIQSkillNames[]; extern u8 *gIQSkillDescriptions[]; diff --git a/src/pokemon_mail.c b/src/pokemon_mail.c index eb8c6e449..aa124c544 100644 --- a/src/pokemon_mail.c +++ b/src/pokemon_mail.c @@ -1,9 +1,9 @@ #include "global.h" #include "globaldata.h" +#include "constants/colors.h" #include "code_800D090.h" #include "code_8012A18_1.h" #include "code_803C1D0.h" -#include "constants/colors.h" #include "code_803D0D8.h" #include "dungeon.h" #include "event_flag.h" @@ -14,9 +14,9 @@ #include "pokemon_3.h" #include "pokemon_mail.h" #include "pokemon_mail_pre.h" -#include "text_util.h" -#include "text.h" #include "string_format.h" +#include "text_3.h" +#include "text_util.h" #include "data/pokemon_mail.h" diff --git a/src/pokemon_news1.c b/src/pokemon_news1.c index 037a09d9f..3d738cf8f 100644 --- a/src/pokemon_news1.c +++ b/src/pokemon_news1.c @@ -1,16 +1,17 @@ #include "global.h" #include "globaldata.h" -#include "code_80118A4.h" -#include "string_format.h" -#include "code_80958E8.h" #include "constants/input.h" +#include "code_80118A4.h" +#include "code_80958E8.h" #include "input.h" #include "pokemon_mail.h" #include "pokemon_news1.h" #include "pokemon_news2.h" #include "memory.h" #include "menu_input.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT struct unkStruct_203B2CC *sUnknown_203B2CC = {NULL}; static EWRAM_INIT u16 sUnknown_203B2D0 = {0}; @@ -34,7 +35,7 @@ bool8 sub_802B640(u32 a0, DungeonPos *a1, u32 a2) sUnknown_203B2CC->s38.unk34 = a0; sUnknown_203B2CC->s38.unk38 = &sUnknown_203B2CC->s38.windows.id[a0]; - RestoreUnkTextStruct_8006518(&sUnknown_203B2CC->s38.windows); + RestoreSavedWindows(&sUnknown_203B2CC->s38.windows); sUnknown_203B2CC->s38.windows.id[sUnknown_203B2CC->s38.unk34] = sUnknown_80DFBEC; diff --git a/src/pokemon_news2.c b/src/pokemon_news2.c index c7c1db65a..af472f38a 100644 --- a/src/pokemon_news2.c +++ b/src/pokemon_news2.c @@ -1,15 +1,16 @@ #include "global.h" #include "globaldata.h" #include "code_80118A4.h" -#include "string_format.h" #include "game_options.h" #include "input.h" -#include "pokemon_mail.h" -#include "pokemon.h" -#include "pokemon_news2.h" #include "memory.h" #include "menu_input.h" -#include "text.h" +#include "pokemon.h" +#include "pokemon_mail.h" +#include "pokemon_news2.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT struct unkStruct_203B2D4 *sUnknown_203B2D4 = {NULL}; diff --git a/src/pokemon_news3.c b/src/pokemon_news3.c index 655690036..70d5d28ba 100644 --- a/src/pokemon_news3.c +++ b/src/pokemon_news3.c @@ -1,21 +1,21 @@ #include "global.h" #include "globaldata.h" +#include "constants/input.h" +#include "constants/mailbox.h" +#include "structs/str_802C39C.h" #include "code_800D090.h" #include "code_80118A4.h" #include "code_803B050.h" #include "code_80958E8.h" -#include "constants/input.h" -#include "constants/mailbox.h" #include "input.h" -#include "code_80958E8.h" #include "memory.h" #include "menu_input.h" -#include "pokemon_mail.h" #include "pokemon.h" +#include "pokemon_mail.h" #include "pokemon_news3.h" -#include "structs/str_802C39C.h" -#include "text.h" #include "string_format.h" +#include "text_1.h" +#include "text_2.h" static EWRAM_INIT struct unkStruct_203B2D8 *sUnknown_203B2D8 = {NULL}; static EWRAM_INIT u16 sUnknown_203B2DC = {0}; @@ -36,7 +36,7 @@ bool8 sub_802BD14(s32 a0, DungeonPos *a1, u32 a2) sUnknown_203B2D8->unk4.s0.unk34 = a0; sUnknown_203B2D8->unk4.s0.unk38 = &sUnknown_203B2D8->unk4.s0.windows.id[a0]; - RestoreUnkTextStruct_8006518(&sUnknown_203B2D8->unk4.s0.windows); + RestoreSavedWindows(&sUnknown_203B2D8->unk4.s0.windows); sUnknown_203B2D8->unk4.s0.windows.id[sUnknown_203B2D8->unk4.s0.unk34] = sUnknown_80DFC74; sUnknown_203B2D8->unk4.s0.unk38->header = &sUnknown_203B2D8->unk4.unk9C; diff --git a/src/post_office_guide1.c b/src/post_office_guide1.c index d86dcbc8d..327b37e45 100644 --- a/src/post_office_guide1.c +++ b/src/post_office_guide1.c @@ -1,12 +1,12 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" +#include "structs/menu.h" #include "input.h" #include "memory.h" -#include "structs/menu.h" #include "pokemon.h" #include "post_office_guide1.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" enum PostOfficeStates { @@ -65,7 +65,7 @@ bool8 CreateHelperPelipperMenu(s16 speciesID) sPostOfficeHelper->monPortrait.pos.y = 8; if (sPostOfficeHelper->monPortrait.faceFile != NULL) - sPostOfficeHelper->monPortrait.faceData = (struct PortraitGfx *) sPostOfficeHelper->monPortrait.faceFile->data; + sPostOfficeHelper->monPortrait.faceData = (PortraitGfx *) sPostOfficeHelper->monPortrait.faceFile->data; } sPostOfficeHelper->currMenuChoice = 0; @@ -123,7 +123,7 @@ static void nullsub_39(void) static void UpdateHelperPelipperText(void) { - struct MonPortraitMsg *monPortraitPtr; + MonPortraitMsg *monPortraitPtr; monPortraitPtr = NULL; if (sPostOfficeHelper->monPortrait.faceFile != NULL) diff --git a/src/post_office_guide2.c b/src/post_office_guide2.c index 7c09ff679..0e8c3e8f2 100644 --- a/src/post_office_guide2.c +++ b/src/post_office_guide2.c @@ -1,5 +1,7 @@ #include "global.h" #include "globaldata.h" +#include "constants/mailbox.h" +#include "constants/wonder_mail.h" #include "code_800D090.h" #include "code_80118A4.h" #include "code_8094F88.h" @@ -8,16 +10,15 @@ #include "code_8099328.h" #include "code_8099360.h" #include "code_80A26CC.h" -#include "constants/mailbox.h" -#include "constants/wonder_mail.h" #include "input.h" #include "items.h" #include "memory.h" #include "menu_input.h" #include "pokemon_mail.h" #include "post_office_guide2.h" -#include "text.h" #include "string_format.h" +#include "text_1.h" +#include "text_3.h" static EWRAM_INIT unkStruct_203B330 *sUnknown_203B330 = {NULL}; @@ -75,7 +76,7 @@ static void sub_8031A84(void) { s32 jobs; - RestoreUnkTextStruct_8006518(&sUnknown_203B330->unk18); + RestoreSavedWindows(&sUnknown_203B330->unk18); sUnknown_203B330->unk18.id[sUnknown_203B330->unk10] = sUnknown_80E1F18; if (sUnknown_203B330->unkC == 2) { diff --git a/src/reg_control.c b/src/reg_control.c index 92dc4ea9b..17fdb8f17 100644 --- a/src/reg_control.c +++ b/src/reg_control.c @@ -1,12 +1,12 @@ #include "global.h" #include "globaldata.h" #include "bg_control.h" +#include "crt0.h" #include "debug.h" #include "input.h" #include "music.h" #include "reg_control.h" #include "sprite.h" -#include "crt0.h" extern void (gUnknown_202DBB8)(void); diff --git a/src/rescue_password_menu.c b/src/rescue_password_menu.c index 7c38bfb8a..ec4d40188 100644 --- a/src/rescue_password_menu.c +++ b/src/rescue_password_menu.c @@ -1,9 +1,8 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" +#include "constants/main_menu.h" #include "code_803D0D8.h" #include "code_8094F88.h" -#include "constants/main_menu.h" #include "dungeon.h" #include "input.h" #include "items.h" @@ -13,7 +12,9 @@ #include "pokemon.h" #include "rescue_password_menu.h" #include "save.h" -#include "text.h" +#include "sprite.h" +#include "string_format.h" +#include "text_1.h" #define RESCUE_PASSWORD_SIZE 0x36 @@ -543,7 +544,7 @@ s32 UpdateRescuePasswordMenu(void) void DisplayRescuePasswordError(u32 passwordError) { - RestoreUnkTextStruct_8006518(&gRescuePasswordMenu->unk1A8); + RestoreSavedWindows(&gRescuePasswordMenu->unk1A8); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_80155F0(); @@ -583,7 +584,7 @@ void DisplayRescuePasswordError(u32 passwordError) void DisplayPasswordAcceptScreen(void) { - RestoreUnkTextStruct_8006518(&gRescuePasswordMenu->unk1A8); + RestoreSavedWindows(&gRescuePasswordMenu->unk1A8); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_80155F0(); diff --git a/src/save_menu.c b/src/save_menu.c index f48d370e0..9b7831922 100644 --- a/src/save_menu.c +++ b/src/save_menu.c @@ -1,5 +1,4 @@ #include "global.h" -#include "string_format.h" #include "constants/main_menu.h" #include "input.h" #include "main_menu1.h" @@ -8,7 +7,8 @@ #include "save.h" #include "save_menu.h" #include "sprite.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" static EWRAM_INIT SaveMenuWork *sSaveMenuWork = {NULL}; @@ -118,7 +118,6 @@ static void sub_8038830(void); static void sub_80388C4(void); extern void sub_8038440(void); -extern void sub_80384D0(void); extern void sub_80140F8(void); void CreateSaveMenu(s32 currMenu) diff --git a/src/save_write.c b/src/save_write.c index 6cbfaeaa4..5e7bc37d7 100644 --- a/src/save_write.c +++ b/src/save_write.c @@ -1,10 +1,20 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" #include "code_8099360.h" #include "memory.h" #include "save.h" #include "save_write.h" +#include "string_format.h" + +// size: 0x20 +typedef struct SavePakWrite +{ + /* 0x0 */ u32 state; + s32 unk4; + /* 0x8 */ u32 saveStatus; + /* 0xC */ MonPortraitMsg monPortrait; + /* 0x1C */ u16 pokeID; +} SavePakWrite; static EWRAM_INIT SavePakWrite *sSavePakWrite = {NULL}; @@ -26,7 +36,7 @@ void PrepareSavePakWrite(s16 pokemonID) if (pokemonID != MONSTER_NONE) { file = GetDialogueSpriteDataPtr(pokemonID); sSavePakWrite->monPortrait.faceFile = file; - sSavePakWrite->monPortrait.faceData = (struct PortraitGfx *) file->data; + sSavePakWrite->monPortrait.faceData = (PortraitGfx *) file->data; sSavePakWrite->monPortrait.spriteId = 0; sSavePakWrite->monPortrait.flip = FALSE; sSavePakWrite->monPortrait.unkE = 0; @@ -35,7 +45,7 @@ void PrepareSavePakWrite(s16 pokemonID) } if (sSavePakWrite->monPortrait.faceFile != 0) { - struct MonPortraitMsg *monPortraitPtr = &sSavePakWrite->monPortrait; + MonPortraitMsg *monPortraitPtr = &sSavePakWrite->monPortrait; CreateDialogueBoxAndPortrait(sSavingAdventure, 0, monPortraitPtr, 0x20); } else @@ -46,7 +56,7 @@ void PrepareSavePakWrite(s16 pokemonID) bool8 WriteSavePak(void) { - struct MonPortraitMsg *monPortraitPtr; + MonPortraitMsg *monPortraitPtr; u32 local_14; u32 other_stack; diff --git a/src/sprite.c b/src/sprite.c index c71476106..492a89bef 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -1,37 +1,42 @@ #include "global.h" +#include "bg_palette_buffer.h" #include "cpu.h" #include "main_loops.h" #include "random.h" #include "sprite.h" -static EWRAM_DATA u16 sOAMSpriteCount = {0}; // GBA=2025670 | NDS=20EC504 | Written to but never read -static EWRAM_DATA s16 sUnknown_2025672[8] = {0}; -static EWRAM_DATA s16 sUnknown_2025682[9] = {0}; -static EWRAM_DATA DungeonPos sUnknown_2025694 = {0}; -static EWRAM_DATA u32 sUnknown_2025698 = {0}; -UNUSED static EWRAM_DATA u32 sUnused1 = {0}; // GBA=202569C -static EWRAM_DATA SpriteList sSpriteList = {0}; // NDS=20ED4C0 -static EWRAM_DATA UnkSpriteLink sUnknown_2025EA8[128] = {0}; -static EWRAM_DATA SpriteOAM sUnknown_20262A8[128] = {0}; -static EWRAM_DATA s32 sSpriteCount = {0}; // GBA=20266A8 -UNUSED static EWRAM_DATA u32 sUnused2 = {0}; // GBA=20266AC +EWRAM_DATA static u16 sOAMSpriteCount = {0}; // GBA=2025670 | NDS=20EC504 | Written to but never read +EWRAM_DATA static s16 sUnknown_2025672[8] = {0}; +EWRAM_DATA static s16 sUnknown_2025682[9] = {0}; +EWRAM_DATA static DungeonPos sUnknown_2025694 = {0}; +EWRAM_DATA static u32 sUnknown_2025698 = {0}; +UNUSED EWRAM_DATA static u32 sUnused1 = {0}; // GBA=202569C +EWRAM_DATA static SpriteList sSpriteList = {0}; // NDS=20ED4C0 +EWRAM_DATA static UnkSpriteLink sUnknown_2025EA8[128] = {0}; +EWRAM_DATA static SpriteOAM sUnknown_20262A8[128] = {0}; +EWRAM_DATA static s32 sSpriteCount = {0}; // GBA=20266A8 +UNUSED EWRAM_DATA static u32 sUnused2 = {0}; // GBA=20266AC #define UNK_20266B0_ARR_COUNT 160 -static EWRAM_DATA unkStruct_20266B0 sUnknown_20266B0[UNK_20266B0_ARR_COUNT] = {0}; +EWRAM_DATA static unkStruct_20266B0 sUnknown_20266B0[UNK_20266B0_ARR_COUNT] = {0}; -static EWRAM_DATA void *sCharMemCursor = {0}; // GBA=2026E30 -UNUSED static EWRAM_DATA u32 sUnused3 = {0}; // GBA=2026E34 +EWRAM_DATA static void *sCharMemCursor = {0}; // GBA=2026E30 +UNUSED EWRAM_DATA static u32 sUnused3 = {0}; // GBA=2026E34 -static EWRAM_INIT unkStruct_20266B0 *sUnknown_203B074 = {0}; +EWRAM_INIT static unkStruct_20266B0 *sUnknown_203B074 = {0}; -static void RegisterSpriteParts_80052BC(UnkSpriteMem *); static void AxResInitUnoriented(axdata *, axmain *, u32, u32, u32, bool8); +static void RegisterSpriteParts_80052BC(UnkSpriteMem *); +static void sub_800533C(ax_pose **, UnkSpriteMem **, axdata1 *, unkStruct_2039DB0 *spriteMasks, bool8); +static void sub_800561C(const EfoFileData *, s32 vramIdx, s32 brightness, const RGB *ramp); // arm9.bin::0200265C void InitSprites(void) { ResetSprites(TRUE); SetSavingIconCoords(NULL); + + // NDS version has more here } // arm9.bin::020024f4 @@ -147,22 +152,22 @@ void sub_8004E8C(unkStruct_2039DB0 *a0) a0->unkA = 0; } -// Needed to match AddAxSprite and AddAxSprite. These macros assume SpriteOAM struct has size of 8 -#define SpriteCopy(_dst, _src) \ -{ \ - u16 *_dstVar = (void *) _dst; \ - u16 *_srcVar = (void *) _src; \ - \ - *(_dstVar++) = *(_srcVar++); \ - *(_dstVar++) = *(_srcVar++); \ - *(_dstVar++) = *(_srcVar++); \ - *(_dstVar++) = *(_srcVar++); \ +// Needed to match AddAxSprite and AddSprite. These macros assume SpriteOAM struct has size of 8 +#define SpriteCopy(_dst, _src) \ +{ \ + u16 *_dstVar = (void *)_dst; \ + u16 *_srcVar = (void *)_src; \ + \ + *(_dstVar++) = *(_srcVar++); \ + *(_dstVar++) = *(_srcVar++); \ + *(_dstVar++) = *(_srcVar++); \ + *(_dstVar++) = *(_srcVar++); \ } #define SpriteCopyWithMasks(_dst, _src, _spriteMasks) \ { \ - u16 *_dstVar = (void *) _dst; \ - u16 *_srcVar = (void *) _src; \ + u16 *_dstVar = (void *)_dst; \ + u16 *_srcVar = (void *)_src; \ \ *(_dstVar++) = (*(_srcVar++) & _spriteMasks->unk0) | _spriteMasks->unk6; \ *(_dstVar++) = (*(_srcVar++) & _spriteMasks->unk2) | _spriteMasks->unk8; \ @@ -258,10 +263,10 @@ void AddAxSprite(ax_pose *a0, axdata1 *a1, UnkSpriteMem *a2, unkStruct_2039DB0 * // a2 and spriteMasks are always called with NULL lol // arm9.bin::02002088 -void AddSprite(struct SpriteOAM *a0, s32 a1, struct UnkSpriteMem *a2, struct unkStruct_2039DB0 *spriteMasks) +void AddSprite(SpriteOAM *a0, s32 a1, UnkSpriteMem *a2, unkStruct_2039DB0 *spriteMasks) { s32 yPos; - struct SpriteOAM *spr; + SpriteOAM *spr; if (sSpriteCount >= 128) return; @@ -369,6 +374,7 @@ void CopySpritesToOam(void) sOAMSpriteCount = count; } +// arm9.bin::02001F64 void SetSavingIconCoords(DungeonPos *pos) { if (pos == NULL) { @@ -382,6 +388,7 @@ void SetSavingIconCoords(DungeonPos *pos) } } +// arm9.bin::02001EE8 void BlinkSavingIcon(void) { vu16 *oam; @@ -421,7 +428,8 @@ void BlinkSavingIcon(void) } } -void RegisterSpriteParts_80052BC(struct UnkSpriteMem *a0) +// arm9.bin::02001E70 +static void RegisterSpriteParts_80052BC(UnkSpriteMem *a0) { while (a0->byteCount != 0) { if ((uintptr_t)sUnknown_203B074 >= (uintptr_t)&sUnknown_20266B0[UNK_20266B0_ARR_COUNT]) @@ -435,6 +443,7 @@ void RegisterSpriteParts_80052BC(struct UnkSpriteMem *a0) } } +// arm9.bin::02001E14 void sub_8005304(void) { unkStruct_20266B0 *s; @@ -447,7 +456,8 @@ void sub_8005304(void) } } -void sub_800533C(ax_pose **a0, UnkSpriteMem **a1, axdata1 *a2, unkStruct_2039DB0 *spriteMasks, bool8 a4) +// arm9.bin::02001D88 +static void sub_800533C(ax_pose **a0, UnkSpriteMem **a1, axdata1 *a2, unkStruct_2039DB0 *spriteMasks, bool8 a4) { UnkSpriteMem *mem; ax_pose *r4; @@ -462,11 +472,13 @@ void sub_800533C(ax_pose **a0, UnkSpriteMem **a1, axdata1 *a2, unkStruct_2039DB0 } } +// arm9.bin::02001D58 void AxResInitFile(axdata *a0, OpenedFile *a1, u32 a2, u32 a3, u32 a4, u32 spriteAnimIndex, bool8 a6) { AxResInit(a0, (axmain *)a1->data, a2, a3, a4, spriteAnimIndex, a6); } +// arm9.bin::02001CC4 void AxResInit(axdata *a0, axmain *a1, u32 a2, u32 direction, u32 a4, u32 spriteAnimIndex, bool8 a6) { a0->flags = 0x8000; @@ -490,11 +502,13 @@ void AxResInit(axdata *a0, axmain *a1, u32 a2, u32 direction, u32 a4, u32 sprite a0->paletteData = a1->palettes; } +// arm9.bin::02001C9C void AxResInitUnorientedFile(axdata *a0, OpenedFile *a1, u32 a2, u32 a3, u32 spriteAnimIndex, bool8 a5) { AxResInitUnoriented(a0, (axmain *)a1->data, a2, a3, spriteAnimIndex, a5); } +// arm9.bin::02001C18 static void AxResInitUnoriented(axdata *a0, axmain *a1, u32 a2, u32 a3, u32 spriteAnimIndex, bool8 a5) { a0->flags = 0x8000; @@ -517,14 +531,16 @@ static void AxResInitUnoriented(axdata *a0, axmain *a1, u32 a2, u32 a3, u32 spri a0->paletteData = 0; } -static inline s16 check_flag_for_80054BC(u16 flags) { +static inline s16 check_flag_for_80054BC(u16 flags) +{ if (flags & 0x2000) return 0; else return flags >> 15; } -void RunAxAnimationFrame(struct axdata *a0) +// arm9.bin::02001AC4 +void RunAxAnimationFrame(axdata *a0) { ax_anim *aData; @@ -571,7 +587,8 @@ void RunAxAnimationFrame(struct axdata *a0) a0->activeAnimData = aData + 1; } -void DoAxFrame_800558C(struct axdata *a0, s32 spriteX, s32 spriteY, u32 a3, u32 paletteNum, unkStruct_2039DB0 *spriteMasks) +// arm9.bin::020019F4 +void DoAxFrame_800558C(axdata *a0, s32 spriteX, s32 spriteY, u32 a3, u32 paletteNum, unkStruct_2039DB0 *spriteMasks) { if (!(a0->flags >> 15)) return; @@ -592,3 +609,199 @@ void DoAxFrame_800558C(struct axdata *a0, s32 spriteX, s32 spriteY, u32 a3, u32 if (a0->flags & 0x800) a0->flags &= 0xF7FF; } + +// arm9.bin::020019E4 +void sub_8005610(OpenedFile *a0, s32 vramIdx, s32 brightness, const RGB *ramp) +{ + sub_800561C((const EfoFileData *)a0->data, vramIdx, brightness, ramp); +} + +// arm9.bin::02001970 +static void sub_800561C(const EfoFileData *a0, s32 vramIdx, s32 brightness, const RGB *ramp) +{ + s32 i; + + if (a0->tiles != NULL) + CpuCopy(OBJ_VRAM0 + vramIdx * 0x20, a0->tiles, a0->tileCount * 0x20); + + if (a0->pal != NULL) { + for (i = 0; i < 16; i++) + SetBGPaletteBufferColorRGB(i + 480, &a0->pal[i], brightness, ramp); + } +} + +#if (GAME_VERSION == VERSION_RED) +UNUSED static const RGB *sub_8005668(OpenedFile *a0, s32 vramIdx) +{ + return sub_8005674((const EfoFileData *)a0->data, vramIdx); +} +#endif + +// arm9.bin::0200193C +const RGB *sub_8005674(const EfoFileData *a0, s32 vramIdx) +{ + if (a0->tiles != NULL) + CpuCopy(OBJ_VRAM0 + vramIdx * 0x20, a0->tiles, a0->tileCount * 0x20); + + return a0->pal; +} + +// arm9.bin::02001894 +void sub_800569C(DungeonPos *a0, axObject *a1, u8 a2) +{ + DungeonPos *ptr; + DungeonPos *ptr2; + DungeonPos *ptr3; + + a0->x = 0; + a0->y = 0; + + if (!(a1->axdata.flags >> 15) || a2 >= 4) + return; + + if (a1->axdata.paletteData != NULL) { + ptr = &((DungeonPos*)a1->axdata.paletteData)[a1->axdata.sub1.poseId * 4]; + ptr2 = &ptr[a2]; + if (*&ptr2->x == 99 && *&ptr2->y == 99) { + a0->x = 99; + a0->y = 99; + } + else { + ptr3 = &ptr[a2]; + a0->x = a1->axdata.sub1.offset.x + ptr3->x; + a0->y = a1->axdata.sub1.offset.y + ptr3->y; + } + } + else { + a0->x = 99; + a0->y = 99; + } +} + +// arm9.bin::020017D4 +void sub_8005700(DungeonPos *a0, axObject *a1) +{ + s32 i; + DungeonPos *ptr; + + if (!(a1->axdata.flags >> 15)) + return; + + if (a1->axdata.paletteData != NULL) { + ptr = &((DungeonPos*)a1->axdata.paletteData)[a1->axdata.sub1.poseId * 4]; + for (i = 0; i < 4; i++) { + if (*&ptr[i].x == 99 && *&ptr[i].y == 99) { + a0->x = 99; + a0->y = 99; + } + else { + a0->x = a1->axdata.sub1.offset.x + ptr[i].x; + a0->y = a1->axdata.sub1.offset.y + ptr[i].y; + } + a0++; + } + } + else { + for (i = 0; i < 4; i++) { + a0->x = 99; + a0->y = 99; + a0++; + } + } +} + +#if (GAME_VERSION == VERSION_RED) +UNUSED static void sub_8005764(s32 a0, OpenedFile *file, s32 a2, const RGB *a3) +{ + sub_8005770(a0, (const RGB*)file->data, a2, a3); +} +#endif + +// arm9.bin::02001794 +void sub_8005770(s32 param_1, const RGB *color, s32 brightness, const RGB *ramp) +{ + s32 i; + + for (i = 0; i < 16; i++) + SetBGPaletteBufferColorRGB((param_1 + 0x10) * 0x10 + i, &color[i], brightness, ramp); +} + +// Maybe DungeonPos +// arm9.bin::02001790 +void nullsub_7(s16 *a0) +{ +} + +// arm9.bin::0200178C +void nullsub_8(u32 a0) +{ +} + +// Should be arm9.bin::02001788 +void nullsub_9(void) +{ +} + +// TODO: Find these in blue if they exist + +void nullsub_10(bool8 a0) +{ +} + +UNUSED static void nullsub_144(void) +{ +} + +void nullsub_11(SpriteOAM *a0, s32 a1, UnkSpriteMem *a2, unkStruct_2039DB0 *a3) +{ +} + +void nullsub_12(void) +{ +} + +void nullsub_13(void) +{ +} + +UNUSED static void nullsub_145(void) +{ +} + +void nullsub_14(void) +{ +} + +UNUSED static void nullsub_146(void) +{ +} + +UNUSED static void nullsub_147(void) +{ +} + +UNUSED static void nullsub_148(void) +{ +} + +UNUSED static void nullsub_149(void) +{ +} + +UNUSED static bool8 sub_80057D8(void) +{ + return FALSE; +} + +UNUSED static bool8 sub_80057DC(void) +{ + return FALSE; +} + +UNUSED static void nullsub_150(void) +{ +} + +UNUSED static void nullsub_151(void) +{ +} diff --git a/src/string_format.c b/src/string_format.c index 9449d9fd8..75d035a32 100644 --- a/src/string_format.c +++ b/src/string_format.c @@ -1,18 +1,20 @@ -#include "constants/input.h" #include "global.h" #include "globaldata.h" -#include "menu_input.h" -#include "sprite.h" -#include "code_80118A4.h" -#include "string_format.h" +#include "constants/input.h" #include "bg_palette_buffer.h" -#include "input.h" -#include "text.h" -#include "game_options.h" -#include "pokemon.h" #include "code_800D090.h" -#include "rescue_team_info.h" +#include "code_80118A4.h" #include "event_flag.h" +#include "game_options.h" +#include "input.h" +#include "menu_input.h" +#include "pokemon.h" +#include "rescue_team_info.h" +#include "sprite.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" #include "data/code_80140DC.h" @@ -60,7 +62,7 @@ u32 sub_8014140(void) // This kinda looks like the 'true' beginning of the file static const u32 gUnknown_80D48A0[] = {0x7, 0x2, 0x2}; -static const struct WindowTemplate gUnknown_80D48AC = { +static const WindowTemplate gUnknown_80D48AC = { 0x00, 0x03, 0x00, 0x00, @@ -94,7 +96,6 @@ ALIGNED(4) static const u8 gUnknown_80D4904[] = "%*d" ; extern const u8 gUnknown_80D4908[]; extern const u8 gUnknown_80D4910[]; -extern void SetCharacterMask(int a0); extern void DisplayMonPortraitSprite(s32 a0, const u8 *compressedData, s32 a2); extern void sub_80073E0(s32 a0); extern void sub_8011A04(void); @@ -126,7 +127,7 @@ static EWRAM_DATA s32 gUnknown_202E738 = 0; static EWRAM_DATA s32 gUnknown_202E73C = 0; static EWRAM_DATA s32 gUnknown_202E740 = 0; static EWRAM_DATA s32 gUnknown_202E744 = 0; -static EWRAM_DATA struct UnkDrawStringStruct gUnknown_202E748 = {0}; +static EWRAM_DATA UnkDrawStringStruct gUnknown_202E748 = {0}; static EWRAM_DATA u16 sUnknownTextFlags = 0; static EWRAM_DATA s32 gUnknown_202E780 = 0; static EWRAM_DATA s32 gUnknown_202E784 = 0; @@ -148,7 +149,7 @@ static EWRAM_DATA s32 gUnknown_202EC1C = 0; // Only read, but never written to. Possibly used in Blue? struct NeverWrittenToStruct202EC20 { - struct WindowTemplate unk0; + WindowTemplate unk0; const u8 *unk18; }; static EWRAM_DATA struct NeverWrittenToStruct202EC20 *sNeverWrittenToUnknownStructPtr = NULL; @@ -204,22 +205,22 @@ void sub_801416C(s32 param_1,s32 param_2) gUnknown_202E73C = (param_2 < 0 ) ? 0 : param_2; } -void CreateDialogueBoxAndPortrait(const u8 *text, void *param_2, struct MonPortraitMsg *monPortraitPtr, u16 flags) +void CreateDialogueBoxAndPortrait(const u8 *text, void *param_2, MonPortraitMsg *monPortraitPtr, u16 flags) { CreateMenuDialogueBoxAndPortrait(text, param_2, -1, NULL, NULL, 3, 0, monPortraitPtr, flags); } -void CreateYesNoDialogueBoxAndPortrait_DefaultYes(const u8 *text, struct MonPortraitMsg *monPortraitPtr, u16 flags) +void CreateYesNoDialogueBoxAndPortrait_DefaultYes(const u8 *text, MonPortraitMsg *monPortraitPtr, u16 flags) { CreateMenuDialogueBoxAndPortrait(text, NULL, -1, gUnknown_80D485C, NULL, 3, 0, monPortraitPtr, flags | 0x300); } -void CreateYesNoDialogueBoxAndPortrait_DefaultNo(const u8 *text, struct MonPortraitMsg *monPortraitPtr, u16 flags) +void CreateYesNoDialogueBoxAndPortrait_DefaultNo(const u8 *text, MonPortraitMsg *monPortraitPtr, u16 flags) { CreateMenuDialogueBoxAndPortrait(text, NULL, -1, gUnknown_80D4880, NULL, 3, 0, monPortraitPtr, flags | 0x300); } -void CreateMenuDialogueBoxAndPortrait(const u8 *text, void *a1, u32 r9, const MenuItem *menuItems, void *arg_0, u32 a5, u32 unknownUnused, struct MonPortraitMsg *monPortraitPtr, u16 flags) +void CreateMenuDialogueBoxAndPortrait(const u8 *text, void *a1, u32 r9, const MenuItem *menuItems, void *arg_0, u32 a5, u32 unknownUnused, MonPortraitMsg *monPortraitPtr, u16 flags) { bool8 portraitOn = FALSE; @@ -320,6 +321,7 @@ s32 sub_80144A4(s32 *a0) return gUnknown_202E744; } +// arm9.bin::0201CEB0 void DrawDialogueBoxString(void) { bool8 keepLooping = TRUE; diff --git a/src/text.c b/src/text.c deleted file mode 100644 index 4224739bb..000000000 --- a/src/text.c +++ /dev/null @@ -1,3520 +0,0 @@ -#include "global.h" -#include "globaldata.h" -#include "structs/str_text.h" -#include "bg_palette_buffer.h" -#include "code_8009804.h" -#include "code_800558C.h" -#include "cpu.h" -#include "decompress.h" -#include "def_filearchives.h" -#include "file_system.h" -#include "text.h" - -struct CharMapStruct -{ - s32 unk0; - struct unkChar *unk4; -}; - -EWRAM_DATA Window gWindows[MAX_WINDOWS] = {0}; -EWRAM_DATA static struct CharMapStruct *sCharmaps[2] = {NULL}; -EWRAM_DATA static s16 sCharacterSpacing = 0; -EWRAM_DATA u8 gUnknown_202749A[11] = {0}; -EWRAM_DATA bool8 gUnknown_20274A5 = FALSE; -EWRAM_DATA static u8 sUnknown_20274A6[6] = {0}; -EWRAM_DATA static s32 sCurrentCharmap = 0; -EWRAM_DATA static vu32 sUnknown_20274B0 = 0; -EWRAM_DATA static u32 sUnknown_20274B4[0xEC0] = {0}; -EWRAM_DATA static OpenedFile *sCharmapFiles[3] = {NULL}; -EWRAM_DATA static WindowTemplates sSavedWindows = {0}; -EWRAM_DATA static s32 sUnknown_202B020 = 0; -EWRAM_DATA static s32 sUnknown_202B024 = 0; -EWRAM_DATA static s32 sCharHeight[2] = {0}; -EWRAM_DATA static u32 sTextShadowMask = 0; // Some text color info is stored; retrieve via "& 0xF" -EWRAM_DATA static u8 sDrawTextShadow = 0; -EWRAM_DATA ALIGNED(4) u16 gBgTilemaps[4][32][32] = {0}; - -IWRAM_DATA ALIGNED(4) static s16 gUnknown_3000E94[161] = {0}; - -// These text-related functions were deemed important as they're copied and run from IWRAM for improved performance. -static void ScrollDownWindowInternal(Window *txtStructs, s32 id); -static void ScrollUpWindowInternal(Window *txtStructs, s32 id); -static void sub_82729B8(Window *txtStructs, s32 id); -static void sub_8272A8C(Window *txtStructs, s32 id); -void ScrollDownWindow(s32 windowId); -void ScrollUpWindow(s32 windowId); -void sub_82729A4(s32 id); -void sub_8272A78(s32 id); - -EWRAM_INIT void (*ScrollDownWindowFunc)(s32 windowId) = ScrollDownWindow; -EWRAM_INIT void (*ScrollUpWindowFunc)(s32 windowId) = ScrollUpWindow; -EWRAM_INIT void (*gIwramTextFunc3)(s32 a0) = sub_82729A4; -EWRAM_INIT void (*gIwramTextFunc4)(s32 a0) = sub_8272A78; - -static void ShowWindowsInternal(const WindowTemplates *a0, bool8 a1, bool8 a2, DungeonPos *a3); -static void AddWindow(Window *windows, u32 *vram, u32 *a2, u16 *a3, u32 windowId, const WindowTemplate *winTemplate, bool8 a6, s32 firstBlockId, DungeonPos *positionModifier, u8 a9); -static void sub_800677C(Window *a0, s32 a1, u16 *a2, u8 a3); -static void sub_80069CC(Window *a0, s32 a1, s32 a2, s32 a3, u16 *a4); -static void sub_8006AC4(Window *a0, s32 a1, s32 a2, s32 a3, u16 *a4); -static void sub_8006B70(Window *a0, s32 a1, s32 a2, s32 a3, u16 *a4); -static void sub_8006C44(Window *a0, s32 a1, u16 *a2, u8 a3); -static void sub_8006E94(Window *a0, s32 a1, u32 a2, const WindowHeader *a3, u16 *a4); -static u32 xxx_draw_char(struct Window *a0, s32 x, s32 y, u32 a3, u32 color, u32 a5); -static void nullsub_129(u32 a0, s32 x, s32 y, s32 a3, u32 color); -static void AddUnderScoreHighlightInternal(Window *windows, u32 windowId, s32 x, s32 y, s32 width, u32 color); -static void sub_8007AA4(struct Window *a0, u32 a1, s32 x, s32 y, s32 a4, u32 color); -static void sub_8007BA8(Window *a0, u32 a1, s32 x, s32 y, s32 a4, s32 color); -static void sub_8007D00(Window *a0, u32 a1, s32 x, s32 y, s32 a4, s32 color); -static void sub_8007E64(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 *a7, u32 a8); -static void sub_8008030(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 *a7, u32 a8); -static void DisplayMonPortrait(Window *a0, u16 a1[32][32], s32 a2, const u8 *compressedData, u32 a4); -static void DisplayMonPortraitFlipped(Window *a0, s32 a1, const u8 *compressedData, s32 a3); -static void sub_80084A4(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 a8); -static void sub_8008818(Window *a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); -static bool8 xxx_update_bg_vram(Window *a0); -static void ResetWindowBgData(void); -static void sub_80089AC(const WindowTemplate *r4, DungeonPos *r5_Str); -static void PrepareTextbox_8008C6C(Window *strArr, u32 strId); -static void xxx_draw_string(Window *strArr, s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 characterSpacing, s32 lineSpacing); -static const u8 *HandleTextFormat(Window *strArr, const u8 *str, struct UnkDrawStringStruct *sp); -static void sub_8009388(void); -static s32 InterpretColorChar(u8 a0); - -static const u32 gUnknown_80B853C[16] = -{ - 0x66666666, - 0x00000000, - 0x11111111, - 0x22222222, - 0x33333333, - 0x44444444, - 0x55555555, - 0x66666666, - 0x77777777, - 0x88888888, - 0x99999999, - 0xAAAAAAAA, - 0xBBBBBBBB, - 0xCCCCCCCC, - 0xDDDDDDDD, - 0xEEEEEEEE, -}; - -static const WindowTemplates sDummyWindows = -{ - .id = { - [0] = WIN_TEMPLATE_DUMMY, - [1] = WIN_TEMPLATE_DUMMY, - [2] = WIN_TEMPLATE_DUMMY, - [3] = WIN_TEMPLATE_DUMMY, - } -}; - -static const struct unkShiftData gCharMasksOffsets[8] = -{ - [0] = {.bytesA = 0xFFFFFFFF, .bytesB = 0x00000000, .shift_left = 0x00, .shift_right = 0x20}, - [1] = {.bytesA = 0x0FFFFFFF, .bytesB = 0xF0000000, .shift_left = 0x04, .shift_right = 0x1C}, - [2] = {.bytesA = 0x00FFFFFF, .bytesB = 0xFF000000, .shift_left = 0x08, .shift_right = 0x18}, - [3] = {.bytesA = 0x000FFFFF, .bytesB = 0xFFF00000, .shift_left = 0x0C, .shift_right = 0x14}, - [4] = {.bytesA = 0x0000FFFF, .bytesB = 0xFFFF0000, .shift_left = 0x10, .shift_right = 0x10}, - [5] = {.bytesA = 0x00000FFF, .bytesB = 0xFFFFF000, .shift_left = 0x14, .shift_right = 0x0C}, - [6] = {.bytesA = 0x000000FF, .bytesB = 0xFFFFFF00, .shift_left = 0x18, .shift_right = 0x08}, - [7] = {.bytesA = 0x0000000F, .bytesB = 0xFFFFFFF0, .shift_left = 0x1C, .shift_right = 0x04}, -}; - -static const u16 gUnknown_80B865C[] = -{ - 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, - 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, - 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, - 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, - 0xFF, 0, 0, 0, 0, 0, 0 -}; - -// Fallback character with bitmap? -static const struct unkChar gUnknown_80B86A4 = -{ - .unk0 = gUnknown_80B865C, - .unk4 = 0x81A1, - .unk6 = 7, - .unk8 = 10, - .fill9 = 0, - .unkA = 0, - .fillB = 0, -}; - -// Very weird... -UNUSED static const u8 sByte8 = 8; - -static const u32 gUnknown_80B86B4[][32] = INCBIN_U32("graphics/warning.4bpp"); - -static const u8 gKanjiA_file_string[] = "kanji_a"; -static const u8 gKanjiB_file_string[] = "kanji_b"; - -static const u32 gFadeInNone[8] = {0}; -static const u32 gFadeInDungeon[8] = {0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888}; - -static const u32 gUnknown_80B8804[4] = {0, 1, 2, 3}; -static const u32 gUnknown_80B8814[4] = {1, 2, 3, 0}; - -void LoadCharmaps(void) -{ - int i; - int j; - int k; - - sCurrentCharmap = 0; - sCharmapFiles[0] = OpenFileAndGetFileDataPtr(gKanjiA_file_string, &gSystemFileArchive); - sCharmapFiles[1] = OpenFileAndGetFileDataPtr(gKanjiB_file_string, &gSystemFileArchive); - sCharmaps[0] = (void *) sCharmapFiles[0]->data; - sCharmaps[1] = (void *) sCharmapFiles[1]->data; - sCharHeight[0] = 11; - sCharHeight[1] = 12; - - for (k = 0; k < 4; k++) { - gWindows[k].width = 0; - gWindows[k].unk8 = 0; - gWindows[k].unk46 = 0; - } - - sCharacterSpacing = 0; - - for (i = 0; i < 20; i++) { - gBgTilemaps[0][i][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x279); - gBgTilemaps[1][i][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); - - for (j = 1; j < 32; j++) { - gBgTilemaps[0][i][j] = 0; - gBgTilemaps[1][i][j] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); - } - } - - sDrawTextShadow = 1; - sTextShadowMask = 0x88888888; - gUnknown_203B078 = NULL; - gUnknown_20274A5 = FALSE; - sUnknown_202B020 = 1; - sUnknown_202B024 = 20; - UpdateFadeInTile(0); -} - -u32 UpdateFadeInTile(u32 a0) -{ - u32 r5 = sUnknown_20274B0; - u32 *r4 = (u32 *)(VRAM + 0x4F40); - const u32 *r2; - sUnknown_20274B0 = a0; - - if (a0 == 0 || a0 == 2) { - sub_800CDA8(2); - r2 = gFadeInNone; - } - else { - sub_800CDA8(1); - r2 = gFadeInDungeon; - } - - sTextShadowMask = 0x88888888; - *r4++ = *r2++; - *r4++ = *r2++; - *r4++ = *r2++; - *r4++ = *r2++; - *r4++ = *r2++; - *r4++ = *r2++; - *r4++ = *r2++; - *r4++ = *r2++; - return r5; -} - -u32 sub_80063B0(void) -{ - return sUnknown_20274B0; -} - -UNUSED static u8 UnusedSetTextShadow(u8 a0) -{ - u8 retval = sDrawTextShadow; - sDrawTextShadow = a0; - return retval; -} - -void SelectCharmap(u32 a0) -{ - sCurrentCharmap = a0; -} - -void SetCharacterMask(int a0) -{ - u32 retval; - if (a0 == 0) { - UNUSED u32 unusedVal = sUnknown_20274B0; - retval = 0x88888888; - } - else { - retval = (a0 & 0xF) | ((a0 & 0xF) << 4); // Must be one line for matching - retval |= ((a0 & 0xF) << 8); - retval |= ((a0 & 0xF) << 12); - retval |= ((a0 & 0xF) << 16); - retval |= ((a0 & 0xF) << 20); - retval |= ((a0 & 0xF) << 24); - retval |= ((a0 & 0xF) << 28); - } - sTextShadowMask = retval; -} - -// arm9.bin::020052E4 -void ShowWindows(const WindowTemplates *winTemplates, bool8 a1, bool8 a2) -{ - DungeonPos positionModifier = {0, 0}; - ShowWindowsInternal(winTemplates, a1, a2, &positionModifier); -} - -// red https://decomp.me/scratch/EN6n0 (includes removed code from pmd-blue) -// blue https://decomp.me/scratch/1y9BG -// arm9.bin::020051B0 -static void ShowWindowsInternal(const WindowTemplates *winTemplates, bool8 a1, bool8 a2, DungeonPos *positionModifier) -{ - s32 i; - s32 area = 2; - - if (winTemplates == NULL) - winTemplates = &sDummyWindows; - if (a2) - sub_8009388(); - - ResetWindowBgData(); - - for (i = 0; i < MAX_WINDOWS; i++) { - sSavedWindows.id[i] = winTemplates->id[i]; - - if (winTemplates->id[i].width != 0) { - AddWindow(gWindows, (u32 *)VRAM, sUnknown_20274B4, &gBgTilemaps[0][0][0], gUnknown_80B8804[i], &winTemplates->id[i], a1, area, positionModifier, 0); - sub_80089AC(&winTemplates->id[i], positionModifier); - area += winTemplates->id[i].width * winTemplates->id[i].unk10; - } - } - - // Needed to account for weird compiler LDRs - ASM_MATCH_TRICK(gUnknown_203B078); - ASM_MATCH_TRICK(gUnknown_3000E94[0]); - ASM_MATCH_TRICK(gUnknown_20274A5); - - gUnknown_203B078 = gUnknown_3000E94; - gUnknown_20274A5 = TRUE; -} - -UNUSED static void nullsub_152(void) -{ -} - -void RestoreUnkTextStruct_8006518(WindowTemplates *unkData) -{ - s32 i; - for (i = 0; i < MAX_WINDOWS; i++) - unkData->id[i] = sSavedWindows.id[i]; -} - -UNUSED static void nullsub_153(void) -{ -} - -u32 sub_8006544(u32 index) -{ - return gUnknown_80B8814[index]; -} - -static void AddWindow(Window *windows, u32 *vram, u32 *a2, u16 *a3, u32 windowId, const WindowTemplate *winTemplate, bool8 a6, s32 firstBlockId, DungeonPos *positionModifier, u8 a9) -{ - Window *newWindow; - s32 x, y; - s32 numI; - u32 uVar1; - - newWindow = &windows[windowId]; - x = winTemplate->pos.x + positionModifier->x; - y = winTemplate->pos.y + positionModifier->y; - newWindow->x = x; - newWindow->y = y; - newWindow->width = winTemplate->width; - newWindow->unk8 = winTemplate->unk10; - newWindow->height = winTemplate->height; - newWindow->type = winTemplate->type; - newWindow->unk10 = firstBlockId; - - if (newWindow->type == WINDOW_TYPE_WITH_HEADER) - newWindow->unk14 = firstBlockId; - else - newWindow->unk14 = firstBlockId + winTemplate->unk12 * newWindow->width; - - newWindow->unk18 = &a2[newWindow->unk10 * 8]; - newWindow->unk1C = &a2[newWindow->unk14 * 8]; - newWindow->unk24 = winTemplate->unk12; - newWindow->unk28 = &vram[newWindow->unk14 * 8]; - - if (newWindow->type == WINDOW_TYPE_WITH_HEADER) - newWindow->unk2C = newWindow->width * (newWindow->height + winTemplate->unk12) * 32; - else - newWindow->unk2C = newWindow->width * newWindow->height * 32; - - newWindow->unk30 = 0; - newWindow->unk34 = 0; - newWindow->unk38 = 0; - newWindow->unk20 = (newWindow->width * 8) - 8; - newWindow->unk45 = newWindow->type == WINDOW_TYPE_0; - - if (newWindow->unk8 == 0) - return; - - if ((winTemplate->unk0 & 0xA0) != 0x80) { - s32 newY = y - 1; - s32 i, j; - - if (newWindow->type == WINDOW_TYPE_WITH_HEADER) { - uVar1 = a6 ? newWindow->unk14 : 0; - - sub_8006E94(newWindow, newY, uVar1, winTemplate->header, a3); - - newY = y + 2; - uVar1 = a6 ? newWindow->unk14 + newWindow->width * (winTemplate->unk12 + 2) : 0; - numI = newWindow->height - 2; - } - else { - sub_800677C(newWindow, newY, a3, a9); - - newY = y; - uVar1 = a6 ? newWindow->unk14 : 0; - numI = newWindow->height; - } - - for (i = 0; i < numI; i++) { - s32 newX = x - 1; - sub_80069CC(newWindow, newX, newY, i, a3); - newX = x; - - for (j = 0; j < newWindow->width; j++) { - sub_8006AC4(newWindow, newX, newY, uVar1, a3); - - newX++; - if (a6) - uVar1++; - } - - sub_8006B70(newWindow, newX, newY, i, a3); - newY++; - } - sub_8006C44(newWindow, newY, a3, a9); - } - - if ((winTemplate->unk0 & 0x80) == 0) - PrepareTextbox_8008C6C(windows, windowId); - - newWindow->unk46 = 0; -} - -static void sub_800677C(Window *window, s32 a1, u16 *a2, u8 a3) -{ - s32 iVar5; - s32 i; - - iVar5 = window->x - 1; - - if (a1 > 28) - return; - if (a1 < 0) - return; - - switch (window->type) { - case WINDOW_TYPE_0: - case WINDOW_TYPE_WITHOUT_BORDER: - case WINDOW_TYPE_2: - case WINDOW_TYPE_WITH_HEADER: - break; - case WINDOW_TYPE_NORMAL: - (a2 + a1 * 0x20)[iVar5] = 0xF2D8; - if (a3 != 0) - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF293; - else - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; - iVar5++; - for (i = 0; i < window->width; i++) { - (a2 + a1 * 0x20)[iVar5] = 0xF2D9; - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; - iVar5++; - } - - (a2 + a1 * 0x20)[iVar5] = 0xF6D8; - if (a3 != 0) - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF693; - else - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; - break; - case WINDOW_TYPE_4: - (a2 + a1 * 0x20)[iVar5] = 0xF2E8; - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; - iVar5++; - for (i = 0; i < window->width; i++) { - (a2 + a1 * 0x20)[iVar5] = 0xF2E9; - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; - iVar5++; - } - - (a2 + a1 * 0x20)[iVar5] = 0xF6E8; - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; - break; - case WINDOW_TYPE_FILL_TRANSPARENT: - (a2 + a1 * 0x20)[iVar5] = 0xF2DC; - iVar5++; - for (i = 0; i < window->width; i++) { - (a2 + a1 * 0x20)[iVar5] = 0xF2DD; - iVar5++; - } - - (a2 + a1 * 0x20)[iVar5] = 0xF6DC; - break; - case WINDOW_TYPE_7: - (a2 + a1 * 0x20)[iVar5] = 0xF293; - iVar5++; - for (i = 0; i < window->width; i++) { - (a2 + a1 * 0x20)[iVar5] = 0xF297; - iVar5++; - } - - (a2 + a1 * 0x20)[iVar5] = 0xF693; - break; - } -} - -static void sub_80069CC(Window *window, s32 a1, s32 a2, s32 a3, u16 *a4) -{ - if (a2 > 28) - return; - if (a2 < 0) - return; - - switch (window->type) { - case WINDOW_TYPE_WITHOUT_BORDER: - case WINDOW_TYPE_2: - break; - case WINDOW_TYPE_0: - if (a3 == 0) { - (a4 + a2 * 0x20)[a1] = 0xF297; - (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; - break; - } - if (a3 == window->height - 1) { - (a4 + a2 * 0x20)[a1] = 0xFA97; - (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; - break; - } - // Fallthrough - case WINDOW_TYPE_NORMAL: - case WINDOW_TYPE_WITH_HEADER: - (a4 + a2 * 0x20)[a1] = 0xF2DA; - (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; - break; - case WINDOW_TYPE_4: - (a4 + a2 * 0x20)[a1] = 0xF2EA; - (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; - break; - case WINDOW_TYPE_FILL_TRANSPARENT: - (a4 + a2 * 0x20)[a1] = 0xF2DE; - break; - case WINDOW_TYPE_7: - (a4 + a2 * 0x20)[a1] = 0xF2B6; - break; - } -} - -static void sub_8006AC4(Window *window, s32 a1, s32 a2, s32 a3, u16 *a4) -{ - if (a2 > 28) - return; - if (a2 < 0) - return; - - switch (window->type) { - case WINDOW_TYPE_2: - (a4 + a2 * 0x20)[a1] = a3 | 0xF000; - (a4 + a2 * 0x20)[a1 + 0x400] = 0xF278; - break; - case WINDOW_TYPE_0: - case WINDOW_TYPE_WITHOUT_BORDER: - case WINDOW_TYPE_NORMAL: - case WINDOW_TYPE_4: - case WINDOW_TYPE_WITH_HEADER: - (a4 + a2 * 0x20)[a1] = a3 | 0xF000; - (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; - break; - case WINDOW_TYPE_FILL_TRANSPARENT: - case WINDOW_TYPE_7: - (a4 + a2 * 0x20)[a1] = a3 | 0xF000; - break; - } -} - -static void sub_8006B70(Window *window, s32 a1, s32 a2, s32 a3, u16 *a4) -{ - if (a2 > 28) - return; - if (a2 < 0) - return; - - switch (window->type) { - case WINDOW_TYPE_WITHOUT_BORDER: - case WINDOW_TYPE_2: - break; - case WINDOW_TYPE_0: - if (a3 == 0) { - (a4 + a2 * 0x20)[a1] = 0xF697; - (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; - break; - } - if (a3 == window->height - 1) { - (a4 + a2 * 0x20)[a1] = 0xFE97; - (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; - break; - } - // Fallthrough - case WINDOW_TYPE_NORMAL: - case WINDOW_TYPE_WITH_HEADER: - (a4 + a2 * 0x20)[a1] = 0xF6DA; - (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; - break; - case WINDOW_TYPE_4: - (a4 + a2 * 0x20)[a1] = 0xF6EA; - (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; - break; - case WINDOW_TYPE_FILL_TRANSPARENT: - (a4 + a2 * 0x20)[a1] = 0xF6DE; - break; - case WINDOW_TYPE_7: - (a4 + a2 * 0x20)[a1] = 0xF6B6; - break; - } -} - -static void sub_8006C44(Window *window, s32 a1, u16 *a2, u8 a3) -{ - s32 iVar5; - s32 i; - - iVar5 = window->x - 1; - - if (a1 > 28) - return; - if (a1 < 0) - return; - - switch (window->type) { - case WINDOW_TYPE_0: - case WINDOW_TYPE_WITHOUT_BORDER: - case WINDOW_TYPE_2: - break; - case WINDOW_TYPE_NORMAL: - case WINDOW_TYPE_WITH_HEADER: - (a2 + a1 * 0x20)[iVar5] = 0xFAD8; - if (a3 != 0) - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xFA93; - else - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; - iVar5++; - for (i = 0; i < window->width; i++) { - (a2 + a1 * 0x20)[iVar5] = 0xFAD9; - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; - iVar5++; - } - - (a2 + a1 * 0x20)[iVar5] = 0xFED8; - if (a3 != 0) - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xFE93; - else - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; - break; - case WINDOW_TYPE_4: - (a2 + a1 * 0x20)[iVar5] = 0xFAE8; - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; - iVar5++; - for (i = 0; i < window->width; i++) { - (a2 + a1 * 0x20)[iVar5] = 0xFAE9; - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; - iVar5++; - } - - (a2 + a1 * 0x20)[iVar5] = 0xFEE8; - (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; - break; - case WINDOW_TYPE_FILL_TRANSPARENT: - (a2 + a1 * 0x20)[iVar5] = 0xFADC; - iVar5++; - for (i = 0; i < window->width; i++) { - (a2 + a1 * 0x20)[iVar5] = 0xFADD; - iVar5++; - } - - (a2 + a1 * 0x20)[iVar5] = 0xFEDC; - break; - case WINDOW_TYPE_7: - (a2 + a1 * 0x20)[iVar5] = 0xFA93; - iVar5++; - for (i = 0; i < window->width; i++) { - (a2 + a1 * 0x20)[iVar5] = 0xFA97; - iVar5++; - } - - (a2 + a1 * 0x20)[iVar5] = 0xFE93; - break; - } -} - -// Not even close but I don't feel like continuing atm https://decomp.me/scratch/F58jg -/* -void sub_8006E94(Window *a0, s32 a1, u32 a2, const WindowHeader *a3, u16 *a4) -{ - s32 bVar1; - s32 iVar2; - s32 iVar3; - s32 sVar4; - u16 *puVar5; - u16 *puVar6; - u16 *puVar7; - s32 iVar8; - u16 *puVar9; - u16 *puVar10; - u16 *puVar11; - s32 local_44; - u32 local_3c; - u16 *local_30; - s32 local_2c; - u16 *local_24; - - iVar2 = a0->unk0; - bVar1 = -1; - - if (a1 > 28) - return; - if (a1 < 0) - return; - - (a4 + a1 * 0x20)[iVar2 - 1] = 0xF278; - (a4 + a1 * 0x20)[iVar2 - 1 + 0x400] = 0xF27A; - (a4 + a1 * 0x20)[iVar2 - 1 + 0x20] = 0xF278; - (a4 + a1 * 0x20)[iVar2 - 1 + 0x420] = 0xF27A; - (a4 + a1 * 0x20)[iVar2 - 1 + 0x40] = 0xF2D8; - (a4 + a1 * 0x20)[iVar2 - 1 + 0x440] = 0xF2DB; - - local_2c = iVar2 * 2; - puVar5 = a4 + a1 * 0x20 + iVar2 + 0x40; - puVar7 = a4 + a1 * 0x20 + iVar2 + 0x20; - local_30 = a4 + a1 * 0x20 + iVar2 + 0x400; - puVar11 = a4 + a1 * 0x20 + iVar2 + 0x420; - puVar9 = a4 + a1 * 0x20 + iVar2; - iVar8 = a1 * 0x40; - - for (local_3c = 0; local_3c < a3[0]; local_3c++) { - if (local_3c == a3[1]) { - bVar1 = TRUE; - *puVar9 = 0xF2E0; - *local_30 = 0xF2E2; - *puVar7 = 0xF2DA; - *puVar11 = 0xF2DB; - *puVar5 = 0xF6E7; - puVar9[0x440] = 0xF2DB; - puVar5++; - puVar7++; - local_30++; - puVar11++; - puVar9++; - local_2c += 2; - iVar2++; - - if (a2 == 0 || ++a2 == 0) - iVar3 = 0; - else - iVar3 = a2 + a0->unk4; - - local_24 = a4 + local_2c + iVar8 + 0x80; - puVar10 = a4 + local_2c + iVar8 + 0x40; - puVar6 = a4 + local_2c + iVar8; - - for (local_44 = 0; local_44 < a3[2]; local_44++) { - *puVar6 = 0xF2E1; - puVar6[0x400] = 0xF2E2; - *puVar10 = a2 | 0xF000; - puVar6[0x420] = 0xF2DB; - *local_24 = iVar3 | 0xF000; - puVar6[0x440] = 0xF2DB; - local_24++; - puVar10++; - puVar6++; - puVar5++; - puVar7++; - local_30++; - puVar11++; - puVar9++; - local_2c += 2; - iVar2++; - if (a2 != 0) - a2++; - - if (iVar3 != 0) - iVar3++; - } - - *puVar9 = 0xF6E0; - *local_30 = 0xF2E2; - *puVar7 = 0xF6DA; - *puVar11 = 0xF2DB; - *puVar5 = 0xF2E7; - puVar9[0x440] = 0xF2DB; - } - else { - if (bVar1) { - if ((a3[3] >> (local_3c & 0xFF) & 1) == 0) { - sVar4 = 107; - if (local_3c == a3[0] - 1) - sVar4 = 103; - - *puVar9 = (sVar4 + 0x278) | 0xF000; - *puVar7 = 0xF6EF; - *puVar5 = 0xF2D9; - } - else { - sVar4 = 31; - if (local_3c == a3[0] - 1) - sVar4 = 27; - - *puVar9 = (sVar4 + 0x278) | 0xF000; - *puVar7 = 0xF6B6; - *puVar5 = 0xF2D9; - } - *local_30 = 0xF27A; - *puVar11 = 0xF6DB; - } - else { - if ((a3[3] >> (local_3c & 0xFF) & 1) == 0) { - sVar4 = 107; - if (local_3c == 0) - sVar4 = 103; - - *puVar9 = (sVar4 + 0x278) | 0xF400; - *puVar7 = 0xF2EF; - *puVar5 = 0xF2D9; - } - else { - sVar4 = 31; - if (local_3c == 0) - sVar4 = 27; - - *puVar9 = (sVar4 + 0x278) | 0xF400; - *puVar7 = 0xF2B6; - *puVar5 = 0xF2D9; - } - *local_30 = 0xF27A; - *puVar11 = 0xF2DB; - } - puVar9[0x440] = 0xF2DB; - } - - local_2c += 2; - local_30++; - iVar2++; - puVar11++; - puVar5++; - puVar7++; - puVar9++; - if (a2 != 0) - a2++; - } - - iVar8 = a0->unk0 + a0->unk4; - if (iVar2 < iVar8) { - for (iVar3 = iVar8 - iVar2; iVar3 != 0; iVar3--) { - (a4 + a1 * 0x20)[iVar2 + iVar3] = 0xF278; - (a4 + a1 * 0x20)[iVar2 + 0x400 + iVar3] = 0xF27A; - (a4 + a1 * 0x20)[iVar2 + 0x20 + iVar3] = 0xF278; - (a4 + a1 * 0x20)[iVar2 + 0x420 + iVar3] = 0xF27A; - (a4 + a1 * 0x20)[iVar2 + 0x40 + iVar3] = 0xF2D9; - (a4 + a1 * 0x20)[iVar2 + 0x440 + iVar3] = 0xF2DB; - - if (a2 != 0) - a2++; - - iVar2 = iVar8; - } - } - - (a4 + a1 * 0x20)[iVar2] = 0xF278; - (a4 + a1 * 0x20)[iVar2 + 0x400] = 0xF27A; - (a4 + a1 * 0x20)[iVar2 + 0x20] = 0xF278; - (a4 + a1 * 0x20)[iVar2 + 0x420] = 0xF27A; - (a4 + a1 * 0x20)[iVar2 + 0x40] = 0xF6D8; - (a4 + a1 * 0x20)[iVar2 + 0x440] = 0xF2DB; -} -*/ -NAKED -static void sub_8006E94(Window *a0, s32 a1, u32 a2, const WindowHeader *a3, u16 *a4) -{ - asm_unified( - "\tpush {r4-r7,lr}\n" - "\tmov r7, r10\n" - "\tmov r6, r9\n" - "\tmov r5, r8\n" - "\tpush {r5-r7}\n" - "\tsub sp, 0x30\n" - "\tstr r0, [sp]\n" - "\tadds r4, r1, 0\n" - "\tadds r7, r2, 0\n" - "\tstr r3, [sp, 0x4]\n" - "\tmovs r1, 0\n" - "\tldrsh r0, [r0, r1]\n" - "\tmov r10, r0\n" - "\tmovs r2, 0x1\n" - "\tnegs r2, r2\n" - "\tadd r2, r10\n" - "\tmovs r3, 0\n" - "\tstr r3, [sp, 0x8]\n" - "\tcmp r4, 0x1C\n" - "\tble _08006EBE\n" - "\tb _080072FE\n" -"_08006EBE:\n" - "\tcmp r4, 0\n" - "\tbge _08006EC4\n" - "\tb _080072FE\n" -"_08006EC4:\n" - "\tlsls r1, r2, 1\n" - "\tlsls r4, 6\n" - "\tldr r6, [sp, 0x50]\n" - "\tadds r5, r4, r6\n" - "\tadds r1, r5\n" - "\tldr r0, _08006F9C\n" - "\tadds r3, r0, 0\n" - "\tstrh r3, [r1]\n" - "\tmovs r2, 0x80\n" - "\tlsls r2, 4\n" - "\tadds r0, r1, r2\n" - "\tldr r6, _08006FA0\n" - "\tadds r2, r6, 0\n" - "\tstrh r2, [r0]\n" - "\tadds r0, r1, 0\n" - "\tadds r0, 0x40\n" - "\tstrh r3, [r0]\n" - "\tmovs r0, 0x84\n" - "\tlsls r0, 4\n" - "\tadds r0, r1, r0\n" - "\tstrh r2, [r0]\n" - "\tadds r2, r1, 0\n" - "\tadds r2, 0x80\n" - "\tldr r3, _08006FA4\n" - "\tadds r0, r3, 0\n" - "\tstrh r0, [r2]\n" - "\tmovs r6, 0x88\n" - "\tlsls r6, 4\n" - "\tadds r1, r6\n" - "\tldr r2, _08006FA8\n" - "\tadds r0, r2, 0\n" - "\tstrh r0, [r1]\n" - "\tmov r12, r10\n" - "\tmovs r3, 0\n" - "\tstr r4, [sp, 0x18]\n" - "\tldr r4, [sp, 0x4]\n" - "\tldrb r4, [r4]\n" - "\tcmp r3, r4\n" - "\tblt _08006F14\n" - "\tb _08007238\n" -"_08006F14:\n" - "\tadds r2, r5, 0\n" - "\tmov r5, r12\n" - "\tlsls r1, r5, 1\n" - "\tldr r0, [sp, 0x50]\n" - "\tadds r0, 0x80\n" - "\tldr r6, [sp, 0x18]\n" - "\tadds r0, r6, r0\n" - "\tadds r0, r1\n" - "\tmov r9, r0\n" - "\tldr r0, [sp, 0x50]\n" - "\tadds r0, 0x40\n" - "\tadds r0, r6, r0\n" - "\tadds r0, r1\n" - "\tmov r8, r0\n" - "\tldr r4, [sp, 0x50]\n" - "\tmovs r5, 0x80\n" - "\tlsls r5, 4\n" - "\tadds r0, r4, r5\n" - "\tadds r0, r6, r0\n" - "\tadds r0, r1, r0\n" - "\tstr r0, [sp, 0x20]\n" - "\tmovs r6, 0x84\n" - "\tlsls r6, 4\n" - "\tadds r0, r4, r6\n" - "\tldr r4, [sp, 0x18]\n" - "\tadds r0, r4, r0\n" - "\tadds r0, r1\n" - "\tmov r10, r0\n" - "\tadds r4, r1, r2\n" - "\tldr r5, [sp, 0x18]\n" - "\tstr r5, [sp, 0x10]\n" - "\tstr r2, [sp, 0x1C]\n" - "\tstr r1, [sp, 0x24]\n" -"_08006F56:\n" - "\tldr r6, [sp, 0x4]\n" - "\tldrb r6, [r6, 0x1]\n" - "\tcmp r3, r6\n" - "\tbne _08006F60\n" - "\tb _080070C8\n" -"_08006F60:\n" - "\tldr r0, [sp, 0x8]\n" - "\tcmp r0, 0\n" - "\tbne _08007008\n" - "\tldr r1, [sp, 0x4]\n" - "\tldrb r0, [r1, 0x3]\n" - "\tasrs r0, r3\n" - "\tmovs r1, 0x1\n" - "\tands r0, r1\n" - "\tcmp r0, 0\n" - "\tbeq _08006FB8\n" - "\tmovs r1, 0x1F\n" - "\tcmp r3, 0\n" - "\tbne _08006F7C\n" - "\tmovs r1, 0x1B\n" -"_08006F7C:\n" - "\tmovs r2, 0x9E\n" - "\tlsls r2, 2\n" - "\tadds r0, r1, r2\n" - "\tldr r5, _08006FAC\n" - "\tadds r1, r5, 0\n" - "\torrs r0, r1\n" - "\tstrh r0, [r4]\n" - "\tldr r6, _08006FB0\n" - "\tadds r0, r6, 0\n" - "\tmov r1, r8\n" - "\tstrh r0, [r1]\n" - "\tldr r5, _08006FB4\n" - "\tmov r2, r9\n" - "\tstrh r5, [r2]\n" - "\tb _08006FDC\n" - "\t.align 2, 0\n" -"_08006F9C: .4byte 0x0000f278\n" -"_08006FA0: .4byte 0x0000f27a\n" -"_08006FA4: .4byte 0x0000f2d8\n" -"_08006FA8: .4byte 0x0000f2db\n" -"_08006FAC: .4byte 0xfffff400\n" -"_08006FB0: .4byte 0x0000f2b6\n" -"_08006FB4: .4byte 0x0000f2d9\n" -"_08006FB8:\n" - "\tmovs r1, 0x6B\n" - "\tcmp r3, 0\n" - "\tbne _08006FC0\n" - "\tmovs r1, 0x67\n" -"_08006FC0:\n" - "\tmovs r6, 0x9E\n" - "\tlsls r6, 2\n" - "\tadds r0, r1, r6\n" - "\tldr r2, _08006FF4\n" - "\tadds r1, r2, 0\n" - "\torrs r0, r1\n" - "\tstrh r0, [r4]\n" - "\tldr r5, _08006FF8\n" - "\tadds r0, r5, 0\n" - "\tmov r6, r8\n" - "\tstrh r0, [r6]\n" - "\tldr r1, _08006FFC\n" - "\tmov r0, r9\n" - "\tstrh r1, [r0]\n" -"_08006FDC:\n" - "\tldr r2, _08007000\n" - "\tadds r0, r2, 0\n" - "\tldr r5, [sp, 0x20]\n" - "\tstrh r0, [r5]\n" - "\tldr r0, _08007004\n" - "\tmov r6, r10\n" - "\tstrh r0, [r6]\n" - "\tmovs r1, 0x88\n" - "\tlsls r1, 4\n" - "\tadds r0, r4, r1\n" - "\tadds r2, 0x61\n" - "\tb _0800708E\n" - "\t.align 2, 0\n" -"_08006FF4: .4byte 0xfffff400\n" -"_08006FF8: .4byte 0x0000f2ef\n" -"_08006FFC: .4byte 0x0000f2d9\n" -"_08007000: .4byte 0x0000f27a\n" -"_08007004: .4byte 0x0000f2db\n" -"_08007008:\n" - "\tldr r5, [sp, 0x4]\n" - "\tldrb r0, [r5, 0x3]\n" - "\tasrs r0, r3\n" - "\tmovs r1, 0x1\n" - "\tands r0, r1\n" - "\tcmp r0, 0\n" - "\tbeq _0800704C\n" - "\tldrb r0, [r5]\n" - "\tsubs r0, 0x1\n" - "\tmovs r1, 0x1F\n" - "\tcmp r3, r0\n" - "\tbne _08007022\n" - "\tmovs r1, 0x1B\n" -"_08007022:\n" - "\tmovs r6, 0x9E\n" - "\tlsls r6, 2\n" - "\tadds r0, r1, r6\n" - "\tldr r2, _08007040\n" - "\tadds r1, r2, 0\n" - "\torrs r0, r1\n" - "\tstrh r0, [r4]\n" - "\tldr r5, _08007044\n" - "\tadds r0, r5, 0\n" - "\tmov r6, r8\n" - "\tstrh r0, [r6]\n" - "\tldr r1, _08007048\n" - "\tmov r0, r9\n" - "\tstrh r1, [r0]\n" - "\tb _08007076\n" - "\t.align 2, 0\n" -"_08007040: .4byte 0xfffff000\n" -"_08007044: .4byte 0x0000f6b6\n" -"_08007048: .4byte 0x0000f2d9\n" -"_0800704C:\n" - "\tldr r2, [sp, 0x4]\n" - "\tldrb r0, [r2]\n" - "\tsubs r0, 0x1\n" - "\tmovs r1, 0x6B\n" - "\tcmp r3, r0\n" - "\tbne _0800705A\n" - "\tmovs r1, 0x67\n" -"_0800705A:\n" - "\tmovs r5, 0x9E\n" - "\tlsls r5, 2\n" - "\tadds r0, r1, r5\n" - "\tldr r6, _080070B0\n" - "\tadds r1, r6, 0\n" - "\torrs r0, r1\n" - "\tstrh r0, [r4]\n" - "\tldr r1, _080070B4\n" - "\tadds r0, r1, 0\n" - "\tmov r2, r8\n" - "\tstrh r0, [r2]\n" - "\tldr r6, _080070B8\n" - "\tmov r5, r9\n" - "\tstrh r6, [r5]\n" -"_08007076:\n" - "\tldr r1, _080070BC\n" - "\tadds r0, r1, 0\n" - "\tldr r2, [sp, 0x20]\n" - "\tstrh r0, [r2]\n" - "\tldr r5, _080070C0\n" - "\tadds r0, r5, 0\n" - "\tmov r6, r10\n" - "\tstrh r0, [r6]\n" - "\tmovs r1, 0x88\n" - "\tlsls r1, 4\n" - "\tadds r0, r4, r1\n" - "\tldr r2, _080070C4\n" -"_0800708E:\n" - "\tstrh r2, [r0]\n" - "\tmovs r5, 0x2\n" - "\tadd r9, r5\n" - "\tadd r8, r5\n" - "\tldr r6, [sp, 0x20]\n" - "\tadds r6, 0x2\n" - "\tstr r6, [sp, 0x20]\n" - "\tadd r10, r5\n" - "\tadds r4, 0x2\n" - "\tldr r0, [sp, 0x24]\n" - "\tadds r0, 0x2\n" - "\tstr r0, [sp, 0x24]\n" - "\tmovs r1, 0x1\n" - "\tadd r12, r1\n" - "\tadds r3, 0x1\n" - "\tstr r3, [sp, 0x14]\n" - "\tb _08007226\n" - "\t.align 2, 0\n" -"_080070B0: .4byte 0xfffff000\n" -"_080070B4: .4byte 0x0000f6ef\n" -"_080070B8: .4byte 0x0000f2d9\n" -"_080070BC: .4byte 0x0000f27a\n" -"_080070C0: .4byte 0x0000f6db\n" -"_080070C4: .4byte 0x0000f2db\n" -"_080070C8:\n" - "\tmovs r2, 0x1\n" - "\tstr r2, [sp, 0x8]\n" - "\tldr r5, _08007128\n" - "\tadds r0, r5, 0\n" - "\tstrh r0, [r4]\n" - "\tldr r6, _0800712C\n" - "\tadds r0, r6, 0\n" - "\tldr r1, [sp, 0x20]\n" - "\tstrh r0, [r1]\n" - "\tldr r2, _08007130\n" - "\tadds r0, r2, 0\n" - "\tmov r5, r8\n" - "\tstrh r0, [r5]\n" - "\tldr r0, _08007134\n" - "\tmov r6, r10\n" - "\tstrh r0, [r6]\n" - "\tldr r1, _08007138\n" - "\tadds r0, r1, 0\n" - "\tmov r2, r9\n" - "\tstrh r0, [r2]\n" - "\tmovs r5, 0x88\n" - "\tlsls r5, 4\n" - "\tadds r0, r4, r5\n" - "\tldr r6, _08007134\n" - "\tstrh r6, [r0]\n" - "\tmovs r0, 0x2\n" - "\tadd r9, r0\n" - "\tadd r8, r0\n" - "\tldr r1, [sp, 0x20]\n" - "\tadds r1, 0x2\n" - "\tstr r1, [sp, 0x20]\n" - "\tadd r10, r0\n" - "\tadds r4, 0x2\n" - "\tldr r2, [sp, 0x24]\n" - "\tadds r2, 0x2\n" - "\tstr r2, [sp, 0x24]\n" - "\tmovs r5, 0x1\n" - "\tadd r12, r5\n" - "\tcmp r7, 0\n" - "\tbeq _0800713C\n" - "\tadds r7, 0x1\n" - "\tcmp r7, 0\n" - "\tbeq _0800713C\n" - "\tldr r6, [sp]\n" - "\tmovs r1, 0x4\n" - "\tldrsh r0, [r6, r1]\n" - "\tadds r2, r7, r0\n" - "\tb _0800713E\n" - "\t.align 2, 0\n" -"_08007128: .4byte 0x0000f2e0\n" -"_0800712C: .4byte 0x0000f2e2\n" -"_08007130: .4byte 0x0000f2da\n" -"_08007134: .4byte 0x0000f2db\n" -"_08007138: .4byte 0x0000f6e7\n" -"_0800713C:\n" - "\tmovs r2, 0\n" -"_0800713E:\n" - "\tmovs r5, 0\n" - "\tstr r5, [sp, 0xC]\n" - "\tadds r3, 0x1\n" - "\tstr r3, [sp, 0x14]\n" - "\tldr r6, [sp, 0x4]\n" - "\tldrb r6, [r6, 0x2]\n" - "\tcmp r5, r6\n" - "\tbge _080071E0\n" - "\tldr r0, [sp, 0x50]\n" - "\tadds r0, 0x80\n" - "\tldr r1, [sp, 0x10]\n" - "\tadds r0, r1, r0\n" - "\tldr r3, [sp, 0x24]\n" - "\tadds r0, r3, r0\n" - "\tstr r0, [sp, 0x2C]\n" - "\tldr r0, [sp, 0x50]\n" - "\tadds r0, 0x40\n" - "\tadds r0, r1, r0\n" - "\tadds r5, r3, r0\n" - "\tldr r6, [sp, 0x1C]\n" - "\tadds r3, r6\n" -"_08007168:\n" - "\tldr r1, _08007310\n" - "\tadds r0, r1, 0\n" - "\tstrh r0, [r3]\n" - "\tmovs r6, 0x80\n" - "\tlsls r6, 4\n" - "\tadds r6, r3, r6\n" - "\tstr r6, [sp, 0x28]\n" - "\tadds r1, 0x1\n" - "\tadds r0, r1, 0\n" - "\tstrh r0, [r6]\n" - "\tadds r0, r7, 0\n" - "\tldr r6, _08007314\n" - "\torrs r0, r6\n" - "\tstrh r0, [r5]\n" - "\tmovs r1, 0x84\n" - "\tlsls r1, 4\n" - "\tadds r0, r3, r1\n" - "\tldr r6, _08007318\n" - "\tstrh r6, [r0]\n" - "\tadds r0, r2, 0\n" - "\tldr r1, _08007314\n" - "\torrs r0, r1\n" - "\tldr r6, [sp, 0x2C]\n" - "\tstrh r0, [r6]\n" - "\tmovs r1, 0x88\n" - "\tlsls r1, 4\n" - "\tadds r0, r3, r1\n" - "\tldr r6, _08007318\n" - "\tstrh r6, [r0]\n" - "\tldr r0, [sp, 0x2C]\n" - "\tadds r0, 0x2\n" - "\tstr r0, [sp, 0x2C]\n" - "\tadds r5, 0x2\n" - "\tadds r3, 0x2\n" - "\tmovs r1, 0x2\n" - "\tadd r9, r1\n" - "\tadd r8, r1\n" - "\tldr r6, [sp, 0x20]\n" - "\tadds r6, 0x2\n" - "\tstr r6, [sp, 0x20]\n" - "\tadd r10, r1\n" - "\tadds r4, 0x2\n" - "\tldr r0, [sp, 0x24]\n" - "\tadds r0, 0x2\n" - "\tstr r0, [sp, 0x24]\n" - "\tmovs r1, 0x1\n" - "\tadd r12, r1\n" - "\tcmp r7, 0\n" - "\tbeq _080071CC\n" - "\tadds r7, 0x1\n" -"_080071CC:\n" - "\tcmp r2, 0\n" - "\tbeq _080071D2\n" - "\tadds r2, 0x1\n" -"_080071D2:\n" - "\tldr r6, [sp, 0xC]\n" - "\tadds r6, 0x1\n" - "\tstr r6, [sp, 0xC]\n" - "\tldr r0, [sp, 0x4]\n" - "\tldrb r0, [r0, 0x2]\n" - "\tcmp r6, r0\n" - "\tblt _08007168\n" -"_080071E0:\n" - "\tldr r1, _0800731C\n" - "\tadds r0, r1, 0\n" - "\tstrh r0, [r4]\n" - "\tldr r2, _08007320\n" - "\tadds r0, r2, 0\n" - "\tldr r3, [sp, 0x20]\n" - "\tstrh r0, [r3]\n" - "\tldr r5, _08007324\n" - "\tadds r0, r5, 0\n" - "\tmov r6, r8\n" - "\tstrh r0, [r6]\n" - "\tldr r1, _08007318\n" - "\tmov r0, r10\n" - "\tstrh r1, [r0]\n" - "\tadds r2, 0x5\n" - "\tadds r0, r2, 0\n" - "\tmov r3, r9\n" - "\tstrh r0, [r3]\n" - "\tmovs r5, 0x88\n" - "\tlsls r5, 4\n" - "\tadds r0, r4, r5\n" - "\tstrh r1, [r0]\n" - "\tmovs r6, 0x2\n" - "\tadd r9, r6\n" - "\tadd r8, r6\n" - "\tldr r0, [sp, 0x20]\n" - "\tadds r0, 0x2\n" - "\tstr r0, [sp, 0x20]\n" - "\tadd r10, r6\n" - "\tadds r4, 0x2\n" - "\tldr r1, [sp, 0x24]\n" - "\tadds r1, 0x2\n" - "\tstr r1, [sp, 0x24]\n" - "\tmovs r2, 0x1\n" - "\tadd r12, r2\n" -"_08007226:\n" - "\tcmp r7, 0\n" - "\tbeq _0800722C\n" - "\tadds r7, 0x1\n" -"_0800722C:\n" - "\tldr r3, [sp, 0x14]\n" - "\tldr r5, [sp, 0x4]\n" - "\tldrb r5, [r5]\n" - "\tcmp r3, r5\n" - "\tbge _08007238\n" - "\tb _08006F56\n" -"_08007238:\n" - "\tldr r6, [sp]\n" - "\tmovs r0, 0\n" - "\tldrsh r1, [r6, r0]\n" - "\tmovs r2, 0x4\n" - "\tldrsh r0, [r6, r2]\n" - "\tadds r0, r1, r0\n" - "\tcmp r12, r0\n" - "\tbge _080072BC\n" - "\tldr r3, _08007328\n" - "\tadds r4, r3, 0\n" - "\tmov r8, r0\n" - "\tmov r5, r12\n" - "\tlsls r1, r5, 1\n" - "\tldr r0, [sp, 0x50]\n" - "\tadds r0, 0x80\n" - "\tldr r6, [sp, 0x18]\n" - "\tadds r0, r6, r0\n" - "\tadds r5, r1, r0\n" - "\tldr r0, [sp, 0x50]\n" - "\tadds r0, 0x40\n" - "\tadds r0, r6, r0\n" - "\tadds r3, r1, r0\n" - "\tldr r0, [sp, 0x50]\n" - "\tadds r6, r0\n" - "\tadds r2, r1, r6\n" - "\tmovs r1, 0x80\n" - "\tlsls r1, 4\n" - "\tmov r10, r1\n" - "\tmovs r6, 0x84\n" - "\tlsls r6, 4\n" - "\tmov r9, r6\n" - "\tmov r0, r8\n" - "\tmov r1, r12\n" - "\tsubs r0, r1\n" - "\tmov r12, r0\n" -"_0800727E:\n" - "\tstrh r4, [r2]\n" - "\tmov r6, r10\n" - "\tadds r0, r2, r6\n" - "\tldr r1, _0800732C\n" - "\tstrh r1, [r0]\n" - "\tstrh r4, [r3]\n" - "\tmov r6, r9\n" - "\tadds r0, r2, r6\n" - "\tstrh r1, [r0]\n" - "\tadds r1, 0x5F\n" - "\tadds r0, r1, 0\n" - "\tstrh r0, [r5]\n" - "\tmovs r6, 0x88\n" - "\tlsls r6, 4\n" - "\tadds r1, r2, r6\n" - "\tldr r6, _08007318\n" - "\tadds r0, r6, 0\n" - "\tstrh r0, [r1]\n" - "\tadds r5, 0x2\n" - "\tadds r3, 0x2\n" - "\tadds r2, 0x2\n" - "\tmovs r0, 0x1\n" - "\tnegs r0, r0\n" - "\tadd r12, r0\n" - "\tcmp r7, 0\n" - "\tbeq _080072B4\n" - "\tadds r7, 0x1\n" -"_080072B4:\n" - "\tmov r1, r12\n" - "\tcmp r1, 0\n" - "\tbne _0800727E\n" - "\tmov r12, r8\n" -"_080072BC:\n" - "\tmov r2, r12\n" - "\tlsls r1, r2, 1\n" - "\tldr r3, [sp, 0x18]\n" - "\tldr r4, [sp, 0x50]\n" - "\tadds r0, r3, r4\n" - "\tadds r1, r0\n" - "\tldr r5, _08007328\n" - "\tadds r3, r5, 0\n" - "\tstrh r3, [r1]\n" - "\tmovs r6, 0x80\n" - "\tlsls r6, 4\n" - "\tadds r0, r1, r6\n" - "\tldr r4, _0800732C\n" - "\tadds r2, r4, 0\n" - "\tstrh r2, [r0]\n" - "\tadds r0, r1, 0\n" - "\tadds r0, 0x40\n" - "\tstrh r3, [r0]\n" - "\tmovs r5, 0x84\n" - "\tlsls r5, 4\n" - "\tadds r0, r1, r5\n" - "\tstrh r2, [r0]\n" - "\tadds r2, r1, 0\n" - "\tadds r2, 0x80\n" - "\tldr r6, _08007330\n" - "\tadds r0, r6, 0\n" - "\tstrh r0, [r2]\n" - "\tmovs r0, 0x88\n" - "\tlsls r0, 4\n" - "\tadds r1, r0\n" - "\tldr r2, _08007318\n" - "\tadds r0, r2, 0\n" - "\tstrh r0, [r1]\n" -"_080072FE:\n" - "\tadd sp, 0x30\n" - "\tpop {r3-r5}\n" - "\tmov r8, r3\n" - "\tmov r9, r4\n" - "\tmov r10, r5\n" - "\tpop {r4-r7}\n" - "\tpop {r0}\n" - "\tbx r0\n" - "\t.align 2, 0\n" -"_08007310: .4byte 0x0000f2e1\n" -"_08007314: .4byte 0xfffff000\n" -"_08007318: .4byte 0x0000f2db\n" -"_0800731C: .4byte 0x0000f6e0\n" -"_08007320: .4byte 0x0000f2e2\n" -"_08007324: .4byte 0x0000f6da\n" -"_08007328: .4byte 0x0000f278\n" -"_0800732C: .4byte 0x0000f27a\n" -"_08007330: .4byte 0x0000f6d8"); -} - -void sub_8007334(s32 windowId) -{ - s32 i, j; - struct Window *window = &gWindows[windowId]; - s32 r5 = window->unk14; - s32 r6 = window->y; - for (i = 0; i < window->height; i++) { - s32 id = window->x; - for (j = 0; j < window->width; j++) { - gBgTilemaps[0][r6][id] &= ~(TILEMAP_TILE_NUM(0x3FF)); - gBgTilemaps[0][r6][id] |= r5; - id++; - r5++; - } - r6++; - } -} - -UNUSED static void nullsub_154(void) -{ -} - -void sub_80073B8(s32 windowId) -{ - Window *window = &gWindows[windowId]; - - window->unk3C = &window->unk1C[(u32)window->unk2C >> 2]; - window->unk40 = window->unk1C; - window->unk46 = 1; -} - -UNUSED static void nullsub_155(void) -{ -} - -void sub_80073E0(s32 windowId) -{ - Window *window = &gWindows[windowId]; - - if (window->unk44 == 0) { - window->unk30 = &window->unk28[window->unk3C - window->unk1C]; - window->unk34 = window->unk3C; - window->unk38 = (window->unk40 - window->unk3C + 1) * 4; - - if (window->unk38 >= window->unk2C) - window->unk38 = window->unk2C; - - if (window->unk38 < 0) - window->unk38 = 0; - } - - window->unk46 = 0; -} - -UNUSED static void nullsub_156(void) -{ -} - -u32 xxx_call_draw_char(s32 x, s32 y, u32 a2, u32 color, u32 a4) -{ - return xxx_draw_char(gWindows, x, y, a2, color, a4); -} - -UNUSED static bool8 sub_8007464(void) -{ - return FALSE; -} - -static u32 xxx_draw_char(struct Window *windows, s32 x, s32 y, u32 a3, u32 color, u32 windowId) -{ - u32 *r3; - const struct unkShiftData *shiftData; - const struct unkChar *sp0; - const u16 *local_44; - const u16 *sp8; - const u16 *local_3c; - s32 i; - s32 xDiv8, yDiv8; - struct Window *window = &windows[windowId]; - s32 sp18 = gUnknown_80B853C[color & 0xF]; - u8 var_2C; - u32 r4; - u32 r2; - - if (sCurrentCharmap == 1) { - if (a3 == 0x70 || a3 == 0x6A || a3 == 0x71 || a3 == 0x79 || a3 == 0x67) - y += 2; - else if (a3 == 0x8199) - y -= 2; - } - - sp0 = GetCharacter(a3); - local_44 = sp0->unk0; - ASM_MATCH_TRICK(local_3c); // stack doesn't match without it - local_3c = sp0->unk0; - sp8 = sp0->unk0 - 3; - - if (sDrawTextShadow != 0) { - var_2C = (sp0->unkA >> 1) & 1; - } - else { - var_2C = 0; - } - - if (sp0->unkA & 1) { - r3 = window->unk18 + ((((y / 8) * window->width) + (x / 8)) * 8); - r3 += y - (y / 8 * 8); - shiftData = &gCharMasksOffsets[x - ((x / 8) * 8)]; - xDiv8 = x / 8; - yDiv8 = y / 8; - - if (yDiv8 < window->unk8) { - for (i = 0; i < sCharHeight[sCurrentCharmap]; i++) { - r2 = (local_44[1] << 0x10) | (local_44[0]); - if (r2 != 0) { - if (xDiv8 < window->width) { - *r3 |= (shiftData->bytesA & r2) << shiftData->shift_left; - if (window->unk3C > r3) - window->unk3C = r3; - if (window->unk40 < r3) - window->unk40 = r3; - } - if (xDiv8 < window->width - 1) { - r3 += 8; - r2 &= shiftData->bytesB; - *r3 |= (r2) >> shiftData->shift_right; - if (window->unk40 < r3) - window->unk40 = r3; - r3 -= 8; - } - } - - r2 = local_44[2]; - if (r2 != 0) { - if (xDiv8 < window->width - 1) { - r3 += 8; - *r3 |= (r2 & shiftData->bytesA) << shiftData->shift_left; - if (window->unk40 < r3) - window->unk40 = r3; - r3 -= 8; - } - if (xDiv8 < window->width - 2) { - r3 += 16; - *r3 |= (r2 & shiftData->bytesB) >> shiftData->shift_right; - if (window->unk40 < r3) - window->unk40 = r3; - r3 -= 16; - } - } - - local_44 += 3; - r3++; - y++; - if (y % 8 == 0) { - r3 += window->unk20; - yDiv8++; - if (yDiv8 >= window->unk8) - break; - } - } - } - } - else { - bool8 notFirstIteration = FALSE; - u32 r1; - - r3 = window->unk18 + ((((y / 8) * window->width) + (x / 8)) * 8); - r3 += y - (y / 8 * 8); - shiftData = &gCharMasksOffsets[x - ((x / 8) * 8)]; - xDiv8 = x / 8; - yDiv8 = y / 8; - - if (yDiv8 < window->unk8) { - for (i = 0; i < sCharHeight[sCurrentCharmap]; i++) { - r4 = (local_44[1] << 0x10) | (local_44[0]); - r2 = (0x11111111 & r4) + (sp18 & r4); - - if (var_2C != 0) { - r1 = ((local_3c[1] << 0x10) | local_3c[0]) << 4; - r1 |= r4; // This doesn't really do anything since r4 bits are cleared, but it's needed to match. - r1 &= ~(r4); - r1 &= sTextShadowMask; - r2 |= (r1); - if (notFirstIteration) { - r1 = (((sp8[1] << 0x10) | sp8[0]) << 4) ^ r4; - r1 &= ~(r4); - r2 |= (r1 & sTextShadowMask); - } - } - - if (r2 != 0) { - if (xDiv8 < window->width) { - *r3 |= (r2 & shiftData->bytesA) << shiftData->shift_left; - if (window->unk3C > r3) - window->unk3C = r3; - if (window->unk40 < r3) - window->unk40 = r3; - } - if (xDiv8 < window->width - 1) { - r3 += 8; - *r3 |= (r2 & shiftData->bytesB) >> shiftData->shift_right; - if (window->unk40 < r3) - window->unk40 = r3; - r3 -= 8; - } - } - - r4 = local_44[2]; - r2 = (0x11111111 & r4) + (sp18 & r4); - if (var_2C != 0) { - r1 = (local_3c[2] << 4) | ((local_3c[1] >> 0xC) & 0xF); - r1 |= r4; // This doesn't really do anything since r4 bits are cleared, but it's needed to match. - r1 &= ~(r4); - r1 &= sTextShadowMask; - r2 |= r1; - if (notFirstIteration) { - r1 = ((sp8[2] << 4) | ((sp8[1] >> 0xC) & 0xF)) ^ r4; - r1 &= ~(r4); - r1 &= sTextShadowMask; - r2 |= (r1); - } - } - - if (r2 != 0) { - if (xDiv8 < window->width - 1) { - r3 += 8; - *r3 |= (r2 & shiftData->bytesA) << shiftData->shift_left; - if (window->unk40 < r3) - window->unk40 = r3; - r3 -= 8; - } - if (xDiv8 < window->width - 2) { - r3 += 16; - *r3 |= (r2 & shiftData->bytesB) >> shiftData->shift_right; - if (window->unk40 < r3) - window->unk40 = r3; - r3 -= 16; - } - } - - notFirstIteration = TRUE; - local_44 += 3; - sp8 += 3; - local_3c += 3; - r3++; - y++; - if (y % 8 == 0) { - r3 += window->unk20; - yDiv8++; - if (yDiv8 >= window->unk8) - break; - } - } - } - } - - return sp0->unk6 + sCharacterSpacing; -} - -void AddDoubleUnderScoreHighlight(u32 windowId, s32 x, s32 y, s32 width, u32 color) -{ - AddUnderScoreHighlight(windowId, x, y, width, color); - AddUnderScoreHighlight(windowId, x, y + 1, width, sTextShadowMask & 0xF); -} - -UNUSED static void sub_80078E8(u32 a0, s32 x, s32 y, s32 a3, u32 color) -{ - nullsub_129(a0, x, y, a3, color); - nullsub_129(a0, x, y + 1, a3, sTextShadowMask & 0xF); -} - -void AddUnderScoreHighlight(u32 windowId, s32 x, s32 y, s32 width, u32 color) -{ - AddUnderScoreHighlightInternal(gWindows, windowId, x, y, width, color); -} - -static void nullsub_129(u32 windowId, s32 x, s32 y, s32 width, u32 color) -{ -} - -static void AddUnderScoreHighlightInternal(Window *windows, u32 windowId, s32 x, s32 y, s32 width, u32 color) -{ - u32 uVar4; - u32 *dest; - s32 r4; - const struct unkShiftData *shiftData; - Window *window; - s32 r6; - u32 r9; - - window = &windows[windowId]; - r9 = gUnknown_80B853C[color & 0xF]; - - r4 = y / 8; - - dest = window->unk18 + (((window->width * r4) + (x / 8)) * 8); - dest += (r4 * -8) + y; - r6 = x / 8; - - if (y / 8 >= window->unk8) { - return; - } - else { - const u32 unkBits[] = {0, 0xF, 0xFF, 0xFFF, 0xFFFF, 0xFFFFF, 0xFFFFFF, 0xFFFFFFF, 0xFFFFFFFF}; - - for (; width > 0; width -= 8) { - s32 currWidth = width; - if (currWidth > 7) - currWidth = 8; - - shiftData = &gCharMasksOffsets[x + (x / 8 * -8)]; - - uVar4 = unkBits[currWidth]; - uVar4 = (uVar4 & 0x11111111) + (uVar4 & r9); - - if (uVar4 != 0) { - if (r6 < window->width) { - dest[0] |= (shiftData->bytesA & uVar4) << shiftData->shift_left; - - if (window->unk3C > dest) - window->unk3C = dest; - if (window->unk40 < dest) - window->unk40 = dest; - } - - if (r6 < window->width - 1) { - dest += 8; - dest[0] |= (uVar4 & shiftData->bytesB) >> shiftData->shift_right; - - if (window->unk40 < dest) - window->unk40 = dest; - dest -= 8; - } - } - - r6++; - dest += 8; - } - } -} - -void sub_8007A78(u32 a0, s32 x, s32 y, s32 a3, u32 color) -{ - sub_8007AA4(gWindows, a0, x, y, a3, color); -} - -UNUSED static void nullsub_157(void) -{ -} - -static void sub_8007AA4(struct Window *windows, u32 windowId, s32 x, s32 y, s32 a4, u32 color) -{ - struct Window *window = &windows[windowId]; - u32 ip = gUnknown_80B853C[color & 0xF] + 0x11111111; - const u32 unkBits[] = {0xF, 0xF0, 0xF00, 0xF000, 0xF0000, 0xF00000, 0xF000000, 0xF0000000}; - s32 r3 = y / 8; - u32 *dest = window->unk18 + ((window->width * r3 + x / 8) * 8); - s32 r2 = x / 8; - - dest += r3 * -8 + y; - ip &= unkBits[x & 7]; - - if (r2 < window->width) { - // This goto looks like a fakematch, but I couldn't get it to work otherwise. - goto LOOP_MIDDLE; - while (1) { - y++; - dest++; - if ((y % 8) == 0) - dest += window->unk20; - a4--; - - LOOP_MIDDLE: - if (a4 <= 0) - return; - if (r3 >= window->unk8) - return; - - dest[0] |= ip; - - if (window->unk3C > dest) - window->unk3C = dest; - if (window->unk40 < dest) - window->unk40 = dest; - } - } -} - -void sub_8007B7C(u32 a0, s32 x, s32 y, s32 a3, u32 color) -{ - sub_8007BA8(gWindows, a0, x, y, a3, color); -} - -UNUSED static void nullsub_158(void) -{ -} - -void sub_8007BA8(struct Window *windows, u32 windowId, s32 x, s32 y, s32 a4, s32 color) -{ - u32 *dst; - s32 i; - s32 xDiv8, yDiv8; - s32 j, k; - - struct Window *window = &windows[windowId]; - yDiv8 = y / 8; - if (yDiv8 >= window->unk8) - return; - - dst = window->unk18 + (((yDiv8 * window->width) + x / 8) * 8); - dst += y - (yDiv8 * 8); - - for (i = 0; i < color; i++) { - u32 *loopDst = dst; - xDiv8 = x / 8; - - for (j = 0; j < a4; j += 8) { - if (xDiv8 < window->width) { - u32 andBits = 0xF0000000; - u32 orBits = 0xE0000000; - u32 bits = 0; - u32 var = *loopDst; - - for (k = 0; k < 8; k++) { - if (!(var & andBits)) - bits |= orBits; - - andBits >>= 4; - orBits >>= 4; - } - - *loopDst |= bits; - if (window->unk3C > loopDst) - window->unk3C = loopDst; - if (window->unk40 < loopDst) - window->unk40 = loopDst; - - xDiv8++; - loopDst += 8; - } - else { - break; - } - } - - y++; - dst++; - if ((y % 8) == 0) { - dst += window->unk20; - yDiv8++; - if (yDiv8 >= window->unk8) - return; - } - } -} - -UNUSED static void sub_8007CD4(u32 a0, s32 a1, s32 a2, s32 a3, s32 a4) -{ - sub_8007D00(gWindows, a0, a1, a2, a3, a4); -} - -UNUSED static void nullsub_159(void) -{ -} - -// Very similar to sub_8007BA8. It clears bits instead of setting them. -void sub_8007D00(struct Window *windows, u32 windowId, s32 x, s32 y, s32 a4, s32 color) -{ - u32 *dst; - s32 i; - s32 xDiv8, yDiv8; - s32 j, k; - - struct Window *window = &windows[windowId]; - yDiv8 = y / 8; - if (yDiv8 >= window->unk8) - return; - - dst = window->unk18 + (((yDiv8 * window->width) + x / 8) * 8); - dst += y - (yDiv8 * 8); - - for (i = 0; i < color; i++) { - u32 *loopDst = dst; - xDiv8 = x / 8; - - for (j = 0; j < a4; j += 8) { - if (xDiv8 < window->width) { - u32 andBits = 0xF0000000; - u32 equalBits = 0xE0000000; - u32 bits = 0; - u32 var = *loopDst; - - for (k = 0; k < 8; k++) { - if ((var & andBits) == equalBits) - bits |= andBits; - - andBits >>= 4; - equalBits >>= 4; - } - - *loopDst &= ~(bits); - if (window->unk3C > loopDst) - window->unk3C = loopDst; - if (window->unk40 < loopDst) - window->unk40 = loopDst; - - xDiv8++; - loopDst += 8; - } - else { - break; - } - } - - y++; - dst++; - if ((y % 8) == 0) { - dst += window->unk20; - yDiv8++; - if (yDiv8 >= window->unk8) - return; - } - } -} - -void sub_8007E20(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 *a5, u32 a6) -{ - sub_8007E64(gWindows, gBgTilemaps[0], a0, a1, a2, a3, a4, a5, a6); -} - -UNUSED static void nullsub_160(void) -{ -} - -static void sub_8007E64(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 *a7, u32 a8) -{ - s32 i, j; - Window *window = &a0[a2]; - - a3 /= 8; - a4 /= 8; - a5 /= 8; - a6 /= 8; - a8 *= 4096; - if (a4 < window->unk8) { - s32 id = (window->width * a4) + a3; - u32 *unk18Ptr = &window->unk18[id * 8]; - - for (i = 0; i < a6; i++) { - s32 xMaybe = a3; - u32 *loopUnk18Ptr = unk18Ptr; - for (j = 0; j < a5; j++) { - if (xMaybe < window->width) { - if (window->unk3C > loopUnk18Ptr) { - window->unk3C = loopUnk18Ptr; - } - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *a7; - if (window->unk40 < loopUnk18Ptr) { - window->unk40 = loopUnk18Ptr; - } - a7++; - a1[window->y + a4][window->x + xMaybe] &= 0xFFF; - a1[window->y + a4][window->x + xMaybe] |= a8; - } - else { - loopUnk18Ptr += 8; - a7 += 8; - } - xMaybe++; - } - a4++; - unk18Ptr += window->unk20; - unk18Ptr += 8; - if (a4 >= window->unk8) - break; - } - } -} - -static u32 FlipPixelsHorizontally(u32 a0) -{ - u32 r0; - - r0 = (a0 >> 28) & 0xF; - r0 |= (a0 >> 20) & 0xF0; - r0 |= (a0 >> 12) & 0xF00; - r0 |= (a0 >> 4) & 0xF000; - r0 |= (a0 << 4) & 0xF0000; - r0 |= (a0 << 12) & 0xF00000; - r0 |= (a0 << 20) & 0xF000000; - r0 |= (a0 << 28) & 0xF0000000; - - return r0; -} - -UNUSED static void sub_8007FEC(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 *a5, u32 a6) -{ - sub_8008030(gWindows, gBgTilemaps[0], a0, a1, a2, a3, a4, a5, a6); -} - -UNUSED static void nullsub_161(void) -{ -} - -// Similar to sub_8007E64 -static void sub_8008030(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 *a7, u32 a8) -{ - s32 i, j; - Window *window = &a0[a2]; - - a3 /= 8; - a4 /= 8; - a5 /= 8; - a6 /= 8; - a8 *= 4096; - if (a4 < window->unk8) { - u32 *unk18Ptr = &window->unk18[((window->width * a4) + (a3 + a5)) * 8]; - for (i = 0; i < a6; i++) { - s32 xMaybe = a3 + a5; - u32 *loopUnk18Ptr = unk18Ptr; - for (j = 0; j < a5; j++) { - xMaybe--; - loopUnk18Ptr -= 8; - if (xMaybe < window->width) { - if (window->unk3C > loopUnk18Ptr) { - window->unk3C = loopUnk18Ptr; - } - loopUnk18Ptr[0] = FlipPixelsHorizontally(*(a7++)); - loopUnk18Ptr[1] = FlipPixelsHorizontally(*(a7++)); - loopUnk18Ptr[2] = FlipPixelsHorizontally(*(a7++)); - loopUnk18Ptr[3] = FlipPixelsHorizontally(*(a7++)); - loopUnk18Ptr[4] = FlipPixelsHorizontally(*(a7++)); - loopUnk18Ptr[5] = FlipPixelsHorizontally(*(a7++)); - loopUnk18Ptr[6] = FlipPixelsHorizontally(*(a7++)); - loopUnk18Ptr[7] = FlipPixelsHorizontally(*(a7++)); - if (window->unk40 < loopUnk18Ptr + 8) { - window->unk40 = loopUnk18Ptr + 8; - } - a1[window->y + a4][window->x + xMaybe] &= 0xFFF; - a1[window->y + a4][window->x + xMaybe] |= a8; - } - else { - a7 += 8; - } - } - a4++; - unk18Ptr += window->unk20; - unk18Ptr += 8; - if (a4 >= window->unk8) - break; - } - } -} - -// Similar to sub_8007E64 -UNUSED static void sub_80081A4(s32 a0, s32 a3, s32 a4, s32 a7Id) -{ - s32 i, j, a5, a6; - Window *window = &gWindows[a0]; - const u32 *a7 = gUnknown_80B86B4[a7Id]; - - a3 /= 8; - a4 /= 8; - a5 = 2; - a6 = 2; - if (a4 < window->unk8) { - s32 id = (window->width * a4) + a3; - u32 *unk18Ptr = &window->unk28[id * 8]; - - for (i = 0; i < a6; i++) { - s32 xMaybe = a3; - u32 *loopUnk18Ptr = unk18Ptr; - for (j = 0; j < a5; j++) { - if (xMaybe < window->width) { - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *(a7++); - *(loopUnk18Ptr++) = *a7; - a7++; - } - else { - loopUnk18Ptr += 8; - a7 += 8; - } - xMaybe++; - } - a4++; - unk18Ptr += window->unk20; - unk18Ptr += 8; - if (a4 >= window->unk8) - break; - } - } -} - -void DisplayMonPortraitSprite(s32 a0, const u8 *compressedData, s32 a2) -{ - DisplayMonPortrait(gWindows, gBgTilemaps[0], a0, compressedData, a2); -} - -UNUSED static void nullsub_162(void) -{ -} - -static void DisplayMonPortrait(Window *a0, u16 a1[32][32], s32 a2, const u8 *compressedData, u32 a4) -{ - s32 i, j; - Window *window = &a0[a2]; - - a4 *= 4096; - DecompressAT((u8 *)window->unk18, (window->width * 32) * window->unk8, compressedData); - for (i = 0; i < window->unk8; i++) { - for (j = 0; j < window->width; j++) { - a1[window->y + i][window->x + j] &= 0xFFF; - a1[window->y + i][window->x + j] |= a4; - } - } - window->unk30 = window->unk28; - window->unk34 = window->unk1C; - window->unk38 = window->unk2C; - window->unk44 = 1; -} - -static void sub_8008334(u32 *r7, u32 *r12) -{ - s32 i; - u32 r2, r3; - u32 r4, r1; - - r4 = *r7; - r1 = *r12; - - r3 = 0; - r2 = 0; - - for (i = 0; i < 32; i += 4) { - r2 <<= 4; - r3 <<= 4; - r2 |= r4 & 0xF; - r3 |= r1 & 0xF; - r4 >>= 4; - r1 >>= 4; - } - *r7 = r3; - *r12 = r2; -} - -void DisplayMonPortraitSpriteFlipped(s32 a0, const u8 *compressedData, s32 a1) -{ - DisplayMonPortraitFlipped(gWindows, a0, compressedData, a1); -} - -UNUSED static void nullsub_163(void) -{ -} - -static void DisplayMonPortraitFlipped(Window *windows, s32 windowId, const u8 *compressedData, s32 a3) -{ - s32 i, j; - Window *window = &windows[windowId]; - - DisplayMonPortraitSprite(windowId, compressedData, a3); - for (i = 0; i < window->unk8; i++) { - s32 r8 = window->width / 2; - if (window->width & 1) - r8++; - for (j = 0; j < r8; j++) { - u32 *r4, *r5; - s32 unk4Mul = window->width * i; - - r4 = &window->unk18[(unk4Mul + j) * 8]; - unk4Mul--; - r5 = &window->unk18[(unk4Mul + (window->width - j)) * 8]; - - sub_8008334(r4++, r5++); - sub_8008334(r4++, r5++); - sub_8008334(r4++, r5++); - sub_8008334(r4++, r5++); - sub_8008334(r4++, r5++); - sub_8008334(r4++, r5++); - sub_8008334(r4++, r5++); - sub_8008334(r4++, r5++); - } - } -} - -UNUSED static void sub_8008468(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 a6) -{ - sub_80084A4(gWindows, gBgTilemaps[0], a0, a1, a2, a3, a4, a6); -} - -UNUSED static void nullsub_164(void) -{ -} - -// Effectively unused -static void sub_80084A4(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 a8) -{ - s32 i, j; - Window *window = &a0[a2]; - - a3 /= 8; - a4 /= 8; - a5 /= 8; - a6 /= 8; - a8 *= 4096; - if (a4 < window->unk8) { - for (i = 0; i < a6; i++) { - s32 xMaybe = a3; - for (j = 0; j < a5; j++) { - if (xMaybe < window->width) { - a1[window->y + a4][window->x + xMaybe] &= 0xFFF; - a1[window->y + a4][window->x + xMaybe] |= a8; - } - xMaybe++; - } - a4++; - if (a4 >= window->unk8) - break; - } - } -} - -// Oddly similar to sub_803DEC8 -const struct unkChar *GetCharacter(s32 chr) -{ - s32 r2, r4; - const struct unkChar *ret; - const struct unkChar *strPtr = sCharmaps[sCurrentCharmap]->unk4; - // TODO: create labels for these - if (chr > 63487 && chr < 65535) - { - s32 r2 = chr & 0xFF; - s32 r1 = (chr & 0xFF00) >> 8; - r2 -= 32; - r1 -= 248; - ret = &strPtr[r1 * 224 + r2]; - } - else - { - r4 = 0; - r2 = sCharmaps[sCurrentCharmap]->unk0 - 1; - while (r4 < r2) { - s32 r1 = (r4 + r2) / 2; - if (strPtr[r1].unk4 == chr) { - r4 = r1; - break; - } - else if (strPtr[r1].unk4 < chr) { - r4 = r1 + 1; - } - else { - r2 = r1; - } - } - - ret = &strPtr[r4]; - if (ret->unk4 != chr) - ret = &gUnknown_80B86A4; - - } - return ret; -} - -static s32 HexDigitValue(u8 chr) -{ - if (chr >= '0' && chr <= '9') - return chr - '0'; - else if (chr >= 'a' && chr <= 'f') - return (chr - 'a') + 10; - else - return 1; -} - -const u8 *xxx_get_next_char_from_string(const u8 *a1, u32 *a0) -{ - s32 currChr = *a1; - if (currChr == 0x7E) { - s32 hexDigit; - - a1++; - hexDigit = (HexDigitValue(a1[0]) << 4) + HexDigitValue(a1[1]); - if (*a1 != '\0') { - a1++; - if (*a1 != '\0') { - a1++; - } - } - *a0 = hexDigit; - return a1; - } - else if ((currChr >= 0x81 && currChr <= 0x84) || currChr == 0x87) { - *a0 = a1[1] | (a1[0] << 8); - return a1 + 2; - } - else { - *a0 = currChr; - return a1 + 1; - } -} - -UNUSED static void nullsub_165(void) -{ -} - -UNUSED static void nullsub_166(void) -{ -} - -UNUSED static void nullsub_167(void) -{ -} - -UNUSED static void nullsub_168(void) -{ -} - -static const u32 gUnknown_80B8868[] = -{ - 0, 0xF, 0xFF, 0xFFF, 0xFFFF, 0xFFFFF, 0xFFFFFF, 0xFFFFFFF, - 0xFFFFFFFF, 0xFFFFFFF0, 0xFFFFFF00, 0xFFFFF000, 0xFFFF0000, - 0xFFF00000, 0xFF000000, 0xF0000000 -}; - -UNUSED static void sub_80086C8(Window *windows, s32 windowId, s32 a2, s32 a3, s32 a4, s32 a5) -{ - u32 *r5; - s32 r2, r0, r1; - Window *window = &windows[windowId]; - - if (a2 < 0) { - a4 += a2; - a2 = 0; - } - if (a3 < 0) { - a5 += a3; - a3 = 0; - } - - if (a4 + a2 > window->width * 8) { - a4 = (window->width * 8) - a2; - } - if (a3 + a5 > window->unk8 * 8) { - a5 = (window->unk8 * 8) - a3; - } - - r2 = window->width * (a3 / 8); - r0 = 8 * (r2 + (a2 / 8)); - r1 = a3 - ((a3 / 8) * 8); - r5 = &window->unk18[r0 + r1]; - while (a5 > 0) { - u32 *loopPtr; - s32 r4, r6; - - loopPtr = r5; - r4 = a4; - r6 = a2; - if (window->unk3C > r5) { - window->unk3C = r5; - } - - while (r4 > 0) { - s32 r3; - if (r4 < 8) { - r3 = r4; - *loopPtr &= gUnknown_80B8868[(r4 & 7) + 8]; - } - else if ((r6 & 7) != 0) { - r3 = 8 - (r6 & 7); - *loopPtr &= gUnknown_80B8868[r6 & 7]; - } - else { - r3 = 8; - *loopPtr = r6 & 7; - } - - loopPtr += 8; - r4 -= r3; - r6 += r3; - } - a5--; - a3++; - if (window->unk40 < r5) { - window->unk40 = r5; - } - r5++; - if (!(a3 & 7)) { - r5 = &r5[window->unk20]; - } - } -} - -void sub_80087EC(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4) -{ - sub_8008818(gWindows, a0, a1, a2, a3, a4); -} - -UNUSED static void nullsub_176(void) -{ -} - -static void sub_8008818(Window *windows, s32 windowId, s32 a2, s32 a3, s32 a4, s32 a5) -{ - s32 i, j; - Window *window = &windows[windowId]; - s32 a2Div = a2 / 8; - s32 a3Div = a3 / 8; - - for (i = 0; i < a5; i += 8) { - u32 *ptr = &window->unk18[((window->width * a3Div) + a2Div) * 8]; - for (j = 0; j < a4; j += 8) { - if (window->unk3C > ptr) { - window->unk3C = ptr; - } - *(ptr++) = 0; - *(ptr++) = 0; - *(ptr++) = 0; - *(ptr++) = 0; - *(ptr++) = 0; - *(ptr++) = 0; - *(ptr++) = 0; - *ptr = 0; - if (window->unk40 < ptr) { - window->unk40 = ptr; - } - ptr++; - } - a3Div++; - } -} - -bool8 xxx_call_update_bg_vram(void) -{ - bool8 ret = FALSE; - if (gUnknown_20274A5 != 0) { - gUnknown_20274A5 = FALSE; - sub_80099C0(); - } - ret = xxx_update_bg_vram(gWindows); - return ret; -} - -static bool8 xxx_update_bg_vram(Window *windows) -{ - s32 i, j; - u32 r5; - bool8 ret = FALSE; - - for (i = 0; i < MAX_WINDOWS; i++) { - Window *window = &windows[i]; - if (window->width == 0) - continue; - r5 = window->unk38; - if (r5 == 0) - continue; - - if (window->unk45) { - u32 *r2, *r1; - - CpuCopy(window->unk28, window->unk18, 0xD00); - // The reason for void casts is because we want to add 0xD00/r5 directly to pointers. Because pointers are u32, without the casts, it would multiply the value by 4. - r2 = (void *)(window->unk18) + 0xD00; - r1 = (void *)(window->unk28) + 0xD00; - for (j = 0; j < window->width; j++) { - *(r1++) = *(r2++); - *(r1++) = *(r2++); - *(r1++) = *(r2++); - *(r1++) = *(r2++); - *(r1++) = *(r2++); - *(r1++) = 0xDDDDDDDD; - *(r1++) = 0xEEEEEEEE; - *(r1++) = 0xFFFFFFFF; - r2 += 3; - } - window->unk38 = 0; - } - else { - CpuCopy(window->unk30, window->unk34, r5); - window->unk34 += (r5 / 4); - window->unk30 = (void *)(window->unk30) + r5; - window->unk38 -= r5; - } - - if (window->unk38 == 0) { - window->unk44 = 0; - } - ret = TRUE; - } - - return ret; -} - -static void ResetWindowBgData(void) -{ - s32 i; - - for (i = 0; i < ARRAY_COUNT_INT(gUnknown_3000E94); i++) { - gUnknown_3000E94[i] = 0xF0F0; - } -} - -static void sub_80089AC(const WindowTemplate *r4, DungeonPos *r5_Str) -{ - u8 *r6; - - if (r4->unk0 & 0x40) - return; - - r6 = (u8*) gUnknown_3000E94; - if (r4->type == WINDOW_TYPE_WITHOUT_BORDER) { - s32 r12 = (r4->pos.x + r5_Str->x) * 8; - s32 r5 = (r4->pos.y + r5_Str->y) * 8; - s32 r7 = (r4->pos.x + r5_Str->x + r4->width) * 8; - s32 r2 = (r4->pos.y + r5_Str->y + r4->height) * 8; - if (r4->height != 0) { - if (r5 < 0) - r5 = 0; - if (r2 < 0) - r2 = 0; - if (r5 > 160) - r5 = 160; - if (r2 > 160) - r2 = 160; - while (r5 < r2) { - s32 id = r5 * 2; - if (r6[id] == 240 && r6[id + 1] == 240) { - r6[id++] = r7; - r6[id] = r12; - } - else { - if (r6[id] < r7) { - r6[id] = r7; - } - id++; - if (r6[id] > r12) { - r6[id] = r12; - } - } - r5++; - } - } - } - else if (r4->type == WINDOW_TYPE_WITH_HEADER) { - s32 i; - s32 r9 = ((r4->pos.x + r5_Str->x) * 8) - 5; - s32 r5 = ((r4->pos.y + r5_Str->y) * 8) - 4; - s32 var_24 = ((r4->pos.x + r5_Str->x + r4->width) * 8) + 5; - s32 r8 = ((r4->pos.y + r5_Str->y + r4->height) * 8) + 5; - s32 r12 = ((r4->pos.x + r5_Str->x) * 8) + 3; - const WindowHeader *r2 = r4->header; - s32 tmp = r2->width - 1; - s32 r10 = (((tmp + r2->count + 2) * 8) + r12) - 4; - s32 r4 = r9 + ((r2->currId + 1) * 8); - s32 r7 = (r4 + ((r2->width + 2) * 8)) - 4; - - if (r5 < 0) - r5 = 0; - if (r8 < 0) - r8 = 0; - if (r5 > 160) - r5 = 160; - if (r8 > 160) - r8 = 160; - - for (i = 0; i < 4; i++) { - s32 id = r5 * 2; - if (r6[id] == 240 && r6[id + 1] == 240) { - r6[id++] = r7; - r6[id] = r4; - } - else { - if (r6[id] < r7) { - r6[id] = r7; - } - id++; - if (r6[id] > r4) { - r6[id] = r4; - } - } - r5++; - } - for (i = 0; i < 8; i++) { - s32 id = r5 * 2; - if (r6[id] == 240 && r6[id + 1] == 240) { - r6[id++] = r10; - r6[id] = r12; - } - else { - if (r6[id] < r10) { - r6[id] = r10; - } - id++; - if (r6[id] > r12) { - r6[id] = r12; - } - } - r5++; - } - - while (r5 < r8) { - s32 id = r5 * 2; - if (r6[id] == 240 && r6[id + 1] == 240) { - r6[id++] = var_24; - r6[id] = r9; - } - else { - if (r6[id] < var_24) { - r6[id] = var_24; - } - id++; - if (r6[id] > r9) { - r6[id] = r9; - } - } - r5++; - } - } - else { - s32 r8 = ((r4->pos.x + r5_Str->x) * 8) - 5; - s32 r3 = ((r4->pos.y + r5_Str->y) * 8) - 5; - s32 r12 = ((r4->pos.x + r5_Str->x + r4->width) * 8) + 5; - s32 r5 = ((r4->pos.y + r5_Str->y + r4->height) * 8) + 5; - if (r4->height != 0) { - if (r4->type == 0) { - r3 += 8; - r5 = ((r4->pos.y + r5_Str->y + r4->height) * 8) - 3; - } - if (r3 < 0) - r3 = 0; - if (r5 < 0) - r5 = 0; - if (r3 > 160) - r3 = 160; - if (r5 > 160) - r5 = 160; - while (r3 < r5) { - s32 id = r3 * 2; - if (r6[id] == 240 && r6[id + 1] == 240) { - r6[id++] = r12; - r6[id] = r8; - } - else { - if (r6[id] < r12) { - r6[id] = r12; - } - id++; - if (r6[id] > r8) { - r6[id] = r8; - } - } - r3++; - } - } - } -} - -void CallPrepareTextbox_8008C54(u32 strId) -{ - PrepareTextbox_8008C6C(gWindows, strId); -} - -UNUSED static void nullsub_169(void) -{ -} - -static void PrepareTextbox_8008C6C(Window *windows, u32 windowId) -{ - s32 i; - Window *window = &windows[windowId]; - - if (!window->unk45) { - s32 count = (window->width * window->unk8) * 32; - for (i = 0; i < count; i += 32) { - CpuClear(&window->unk18[i / 4u], 32); - } - } - else { - s32 count = (window->width * (window->unk8 - 1)) * 32; - u32 *ptr = window->unk18; - for (i = 0; i < window->width; i++) { - *(ptr++) = 0xFFFFFFFF; - *(ptr++) = 0xEEEEEEEE; - *(ptr++) = 0xDDDDDDDD; - *(ptr++) = 0; - *(ptr++) = 0; - *(ptr++) = 0; - *(ptr++) = 0; - *(ptr++) = 0; - } - for (i = 0; i < count; i += 32) { - CpuClear(ptr, 32); - ptr += 8; - } - } - - if (window->type == WINDOW_TYPE_WITH_HEADER) { - window->unk46 = 1; - AddUnderScoreHighlightInternal(windows, windowId, 0, 10, window->width * 8, 0xE); - AddUnderScoreHighlightInternal(windows, windowId, 0, 11, window->width * 8, 0xD); - window->unk46 = 0; - } - - window->unk30 = window->unk28; - window->unk34 = window->unk1C; - window->unk38 = window->unk2C; - window->unk44 = 1; -} - -bool8 sub_8008D8C(u32 strId) -{ - Window *strPtr = &gWindows[strId]; - return (strPtr->unk38 != 0); -} - -UNUSED static bool8 sub_8008DA8(void) -{ - return FALSE; -} - -UNUSED static void sub_8008DAC(s32 a0, s32 a1, s32 a2) -{ - gBgTilemaps[0][a1][a0] = a2; - gUnknown_20274A5 = TRUE; -} - -void sub_8008DC8(s32 a0, s32 a1, u16 a2, s32 a3) -{ - gBgTilemaps[0][a1][a0] = a2; - gBgTilemaps[1][a1][a0] = a3; - gUnknown_20274A5 = TRUE; -} - -UNUSED static void sub_8008DF4(s32 a0, s32 a1, u8 *a2) -{ - u8 r1; - - while (1) { - if (*a2 == 0) - break; - - r1 = *a2; - if (r1 >= 97 && r1 <= 122) { - r1 -= 32; - } - gBgTilemaps[0][a1][a0] = TILEMAP_PAL(15) | (r1 + 0x258); - a2++; - a0++; - } - gUnknown_20274A5 = TRUE; -} - -UNUSED static void sub_8008E58(s32 a0, s32 a1, u8 *a2, s32 a3) -{ - u8 r1; - - while (1) { - if (*a2 == 0) - break; - - r1 = *a2; - if (a3 == 0) - break; - - if (r1 >= 97 && r1 <= 122) { - r1 -= 32; - } - gBgTilemaps[0][a1][a0] = TILEMAP_PAL(15) | (r1 + 0x258); - a2++; - a0++; - a3--; - } - gUnknown_20274A5 = TRUE; -} - -s32 sub_8008ED0(const u8 *str) -{ - s32 ret = 0; - - while (1) { - const u8 *strPtr; - u32 chr; - - strPtr = xxx_get_next_char_from_string(str, &chr); - str = strPtr; - if (chr == 0) - break; - if (chr == '\r' || chr == '\n') - break; - if (chr == 0x82A0 || chr == 0x82A2) - continue; - if (chr == '\e') - break; - - if (chr == '#') { - if (*strPtr == 'n' || *strPtr == '[' || *strPtr == 'P') - break; - switch (*strPtr) { - case '=': - case '~': - str = strPtr + 2; - break; - case 'C': - case 'c': - str += 2; - break; - case 'R': - case 'r': - str++; - break; - case '+': - case 'W': - str = strPtr + 1; - break; - } - } - else if (chr == '`') { - ret += 6; - } - else { - const struct unkChar *ptr = GetCharacter(chr); - if (ptr != NULL) { - ret += ptr->unk6 + sCharacterSpacing; - } - } - } - - return ret; -} - -void PrintStringOnWindow2(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 lineSpacing) -{ - xxx_draw_string(gWindows, x, y, str, windowId, terminatingChr, 0, lineSpacing); -} - -void PrintStringOnWindow(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr) -{ - xxx_draw_string(gWindows, x, y, str, windowId, terminatingChr, 0, 13); -} - -UNUSED static void nullsub_170(void) -{ -} - -// Identical to PrintStringOnWindow -UNUSED static void UnusedPrintStringOnWindow(s32 x, u32 y, const u8 *str, u32 windowId, u32 terminatingChr) -{ - xxx_draw_string(gWindows, x, y, str, windowId, terminatingChr, 0, 13); -} - -UNUSED static void nullsub_171(void) -{ -} - -static void xxx_draw_string(Window *strArr, s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 characterSpacing, s32 lineSpacing) -{ - struct UnkDrawStringStruct sp; - u32 currChr; - - sp.unk0 = x; - sp.unk2 = y; - sp.unkC = x; - sp.unk10 = 7; - while (1) { - str = HandleTextFormat(strArr, str, &sp); - str = xxx_get_next_char_from_string(str, &currChr); - if (currChr == '\0' || currChr == terminatingChr) - break; - - if (currChr == 0x82A0) { - sCurrentCharmap = 0; - } - else if (currChr == 0x82A2) { - sCurrentCharmap = 1; - } - else if (currChr == '\e') { - break; - } - else if (currChr == '\r' || currChr == '\n') { - sp.unk0 = sp.unkC; - sp.unk2 += lineSpacing; - } - else if (currChr == '\x1D') { // ASCII group separator. - sp.unk0 = sp.unkC; - sp.unk2 += 5; - } - else if (currChr == '`') { - sp.unk0 += 6; - } - else if (characterSpacing == 0) { - sp.unk0 += xxx_draw_char(strArr, sp.unk0, sp.unk2, currChr, sp.unk10, windowId); - } - else { - const struct unkChar *chrPtr = GetCharacter(currChr); - if (chrPtr != NULL) { - s32 x = sp.unk0; - s32 x2 = sCharacterSpacing + 10; - x +=((x2 - chrPtr->unk6) / 2); - xxx_draw_char(strArr, x, sp.unk2, currChr, sp.unk10, windowId); - sp.unk0 += characterSpacing; - } - } - } -} - -static const u8 *sub_800915C(s16 *a0, const u8 *str) -{ - s32 a = 0; - - while (1) - { - if (*str == '.') { - str++; - break; - } - else if (*str >= '0' && *str <= '9') { - a *= 10; - a += (*str - '0'); - str++; - } - else { - break; - } - } - - *a0 = a; - return str; -} - -const u8 *xxx_handle_format_global(const u8 *str, struct UnkDrawStringStruct *unkStrPtr) -{ - return HandleTextFormat(gWindows, str, unkStrPtr); -} - -UNUSED static s32 sub_80091A8(s32 a0) -{ - return a0 + 1; -} - -static const u8 *HandleTextFormat(Window *windows, const u8 *str, struct UnkDrawStringStruct *sp) -{ - while (1) { - if (str[0] == '#') { - if (str[1] == '[') { - const u8 *strBefore = str; - str += 2; - sp->unk21 = 0; - while (*str != '\0') { - if (*str == ']') { - str++; - break; - } - str++; - } - if (sp->unk24 != NULL) { - const u8 *strNew = sp->unk24(strBefore, str, sp); - if (strNew != NULL) - str = strNew; - } - - if (sp->unk21 != 0) - break; - } - else if (str[1] == '=') { - sp->unk0 = str[2]; - str += 3; - if (*str == '.') - str++; - } - else if (str[1] == 'y') { - sp->unk2 = str[2]; - str += 3; - if (*str == '.') - str++; - } - else if (str[1] == '>') { - str = sub_800915C(&sp->unk0, str + 2); - } - else if (str[1] == '.') { - sp->unk0 += str[2]; - str += 3; - } - else if (str[1] == 'n') { - sp->unk0 = sp->unkC; - sp->unk2 += 11; - str += 2; - } - else if (str[1] == ':') { - sp->unk4 = sp->unk0; - str += 2; - } - else if (str[1] == ';') { - sp->unk0 = sp->unk4 + str[2]; - str += 3; - } - else if (str[1] == '+') { - str += 2; - sp->unk0 = (windows[0].width * 8) - sub_8008ED0(str); - sp->unk0 /= 2; - } - else if (str[1] == 'C') { - sp->unk14 = sp->unk10; - sp->unk10 = InterpretColorChar(str[2]); - str += 3; - } - else if (str[1] == '_') { - sp->unk14 = sp->unk10; - sp->unk10 = gUnknown_202749A[str[2]]; - str += 3; - if (*str == '.') - str++; - } - else if (str[1] == 'R') { - sp->unk10 = sp->unk14; - str += 2; - } - else if (str[1] == 'c') { - sp->unk18 = sp->unk10; - sp->unk10 = InterpretColorChar(str[2]); - str += 3; - } - else if (str[1] == 'r') { - sp->unk10 = sp->unk18; - str += 2; - } - else if (str[1] == 'S') { - sUnknown_20274A6[str[2] & 0x7F] = str[3] & 0x7F; - str += 4; - } - else if (str[1] == 'W') { - str += 2; - sp->unk8 = ((windows[0].x * 8) + sp->unk0) - 2; - sp->unkA = ((windows[0].y * 8) + sp->unk2) + 3; - sp->unk20 = 1; - break; - } - else if (str[1] == 'P') { - str += 2; - sp->unk2 = 9999; - sp->unk1C = 0; - sp->unk20 = 1; - break; - } - else if (str[1] == 'p') { - str += 2; - sp->unk2 = 9999; - sp->unk1C = 1; - sp->unk20 = 1; - break; - } - else if (str[1] == '~') { - sp->unk2C = str[2]; - sp->unk21 = 1; - str += 3; - } - else { - return str; - } - } - else { - break; - } - } - - return str; -} - -static void sub_8009388(void) -{ - s32 i, j; - - gBgTilemaps[0][0][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x279); - gBgTilemaps[1][0][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); - for (i = sUnknown_202B020; i < sUnknown_202B024; i++) { - gBgTilemaps[0][i][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x279); - gBgTilemaps[1][i][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); - for (j = 1; j < 32; j++) { - gBgTilemaps[0][i][j] = 0; - gBgTilemaps[1][i][j] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); - } - } -} - -void sub_8009408(s32 from, s32 to) -{ - s32 i, j; - - gBgTilemaps[0][0][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x279); - gBgTilemaps[1][0][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); - for (i = from; i < to; i++) { - gBgTilemaps[0][i][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x279); - gBgTilemaps[1][i][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); - for (j = 1; j < 32; j++) { - gBgTilemaps[0][i][j] = 0; - gBgTilemaps[1][i][j] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); - } - } - gUnknown_20274A5 = TRUE; -} - -UNUSED static void sub_8009488(s32 windowId) -{ - s32 i, j; - s32 y, x; - Window *window = &gWindows[windowId]; - - y = window->y; - for (i = 0; i < window->height; i++) { - x = window->x; - for (j = 0; j < window->width; j++) { - gBgTilemaps[0][y][x] &= TILEMAP_PAL(15) | TILEMAP_FLIP_HORIZONTAL(1) | TILEMAP_FLIP_VERTICAL(1); - gBgTilemaps[1][y][x] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); - x++; - } - y++; - } -} - -UNUSED static void nullsub_172(void) -{ -} - -void sub_8009524(s32 windowId) -{ - s32 i, j; - Window *window = &gWindows[windowId]; - s32 y = window->y - 1; - - for (i = 0; i < window->height + 2; i++) { - s32 x = window->x - 1; - for (j = 0; j < window->width + 2; j++) { - gBgTilemaps[0][y][x] &= TILEMAP_PAL(15) | TILEMAP_FLIP_HORIZONTAL(1) | TILEMAP_FLIP_VERTICAL(1); - gBgTilemaps[1][y][x] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); - x++; - } - y++; - } -} - -UNUSED static void nullsub_173(void) -{ -} - -void sub_80095CC(s32 a0, s32 a1) -{ - sUnknown_202B020 = a0; - sUnknown_202B024 = a1; -} - -UNUSED static void nullsub_174(void) -{ -} - -s32 sub_80095E4(s32 a0, s32 a1) -{ - s32 r1; - - if (a1 == 0) - a1 = 10; - r1 = a0 * a1; - - if ((r1 % 8) != 0) - return (r1 / 8) + 1; - else - return r1 / 8; -} - -// Same as sub_80095E4 except it doesn't check for a1 == 0 -s32 sub_8009614(s32 a0, s32 a1) -{ - s32 r1; - - r1 = a0 * a1; - - if ((r1 % 8) != 0) - return (r1 / 8) + 1; - else - return r1 / 8; -} - -static s32 InterpretColorChar(u8 a0) -{ - if (a0 < 16) - return a0; - if (a0 >= '0' && a0 <= '?') - return a0 - '0'; - - switch (a0) { - case 'H': - case 'I': - return 4; - case 'E': - case 'S': - case 'T': - return 15; - case 'G': - case 'M': - return 5; - case 'C': - case 'D': - case 'N': - return 6; - case 'W': - return 2; - - } - return 7; -} - -// These functions run from IWRAM for improved performance. -IWRAM_INIT void ScrollDownWindow(s32 windowId) -{ - ScrollDownWindowInternal(gWindows, windowId); -} - -IWRAM_INIT static void ScrollDownWindowInternal(Window *windows, s32 windowId) -{ - Window *window = &windows[windowId]; - - if (window->unk8 > 0) { - s32 i, j; - u32 *dstPtr; - s32 n; - s32 id8, id9; - - if (window->type == WINDOW_TYPE_WITH_HEADER) { - s32 unk4 = window->width; - s32 dstAdd = ((window->unk24 + 2) * 8); - dstAdd *= unk4; - dstPtr = window->unk18 + dstAdd; - n = window->unk8 - 2; - } - else { - dstPtr = window->unk18; - n = window->unk8; - } - - id8 = window->unk20 + 8; - id9 = window->unk20 + 9; - for (i = 0; i < window->width; i++) { - s32 to = n - 1; - u32 *loopPtr = dstPtr; - for (j = 0; j < to; j++) { - loopPtr[0] = loopPtr[2]; - loopPtr[1] = loopPtr[3]; - loopPtr[2] = loopPtr[4]; - loopPtr[3] = loopPtr[5]; - loopPtr[4] = loopPtr[6]; - loopPtr[5] = loopPtr[7]; - loopPtr[6] = loopPtr[id8]; - loopPtr[7] = loopPtr[id9]; - - loopPtr += id8; - } - - loopPtr[0] = loopPtr[2]; - loopPtr[1] = loopPtr[3]; - loopPtr[2] = loopPtr[4]; - loopPtr[3] = loopPtr[5]; - loopPtr[4] = loopPtr[6]; - loopPtr[5] = loopPtr[7]; - loopPtr[6] = 0; - loopPtr[7] = 0; - dstPtr += 8; - } - - window->unk30 = window->unk28; - window->unk34 = window->unk1C; - window->unk38 = window->unk2C; - window->unk44 = 1; - } -} - -IWRAM_INIT void ScrollUpWindow(s32 windowId) -{ - ScrollUpWindowInternal(gWindows, windowId); -} - -IWRAM_INIT static void ScrollUpWindowInternal(Window *windows, s32 windowId) -{ - Window *window = &windows[windowId]; - - if (window->unk8 > 0) { - s32 i, j; - u32 *dstPtr; - s32 n; - s32 id8; - s32 unk4, unk8, dstAdd; - - if (window->type == WINDOW_TYPE_WITH_HEADER) { - n = window->unk8 - 2; - } - else { - n = window->unk8; - } - - unk8 = window->unk8 - 1; - unk4 = window->width; - dstAdd = (unk8 * unk4) * 8; - dstPtr = window->unk18 + dstAdd; - - id8 = window->unk20 + 8; - for (i = 0; i < window->width; i++) { - u32 lastTwo = 0; - s32 to = n - 1; - u32 *loopPtr = dstPtr; - - if (n < 2) { - loopPtr[7] = loopPtr[5]; - loopPtr[6] = loopPtr[4]; - loopPtr[5] = loopPtr[3]; - loopPtr[4] = loopPtr[2]; - loopPtr[3] = loopPtr[1]; - loopPtr[2] = loopPtr[0]; - loopPtr[1] = lastTwo; - loopPtr[0] = lastTwo; - } - else { - u32 *ptr8 = dstPtr - id8; - for (j = 0; j < to; j++) { - loopPtr[7] = loopPtr[5]; - loopPtr[6] = loopPtr[4]; - loopPtr[5] = loopPtr[3]; - loopPtr[4] = loopPtr[2]; - loopPtr[3] = loopPtr[1]; - loopPtr[2] = loopPtr[0]; - loopPtr[1] = ptr8[7]; - loopPtr[0] = ptr8[6]; - - loopPtr -= id8; - ptr8 -= id8; - } - - loopPtr[7] = loopPtr[5]; - loopPtr[6] = loopPtr[4]; - loopPtr[5] = loopPtr[3]; - loopPtr[4] = loopPtr[2]; - loopPtr[3] = loopPtr[1]; - loopPtr[2] = loopPtr[0]; - loopPtr[1] = 0; - loopPtr[0] = 0; - } - dstPtr += 8; - } - - window->unk30 = window->unk28; - window->unk34 = window->unk1C; - window->unk38 = window->unk2C; - window->unk44 = 1; - } -} - -IWRAM_INIT void sub_82729A4(s32 id) -{ - sub_82729B8(gWindows, id); -} - -IWRAM_INIT static void sub_82729B8(Window *windows, s32 id) -{ - s32 i, j; - Window *window = &windows[id]; - u32 *dstPtr = window->unk18; - s32 id8 = window->unk20 + 8; - s32 id9 = window->unk20 + 9; - - for (i = 0; i < window->width; i++) { - u32 *loopPtr; - - dstPtr[3] = dstPtr[5]; - dstPtr[4] = dstPtr[6]; - dstPtr[5] = dstPtr[7]; - dstPtr[6] = dstPtr[id8]; - dstPtr[7] = dstPtr[id9]; - - loopPtr = dstPtr + id8; - for (j = 0; j < 5; j++) { - loopPtr[0] = loopPtr[2]; - loopPtr[1] = loopPtr[3]; - loopPtr[2] = loopPtr[4]; - loopPtr[3] = loopPtr[5]; - loopPtr[4] = loopPtr[6]; - loopPtr[5] = loopPtr[7]; - loopPtr[6] = loopPtr[id8]; - loopPtr[7] = loopPtr[id9]; - - loopPtr += id8; - } - - loopPtr[0] = loopPtr[2]; - loopPtr[1] = loopPtr[3]; - loopPtr[2] = loopPtr[4]; - loopPtr[3] = loopPtr[5]; - loopPtr[4] = 0; - loopPtr[5] = 0; - loopPtr[6] = 0; - loopPtr[7] = 0; - - dstPtr += 8; - } - - window->unk30 = window->unk28; - window->unk34 = window->unk1C; - window->unk38 = window->unk2C; - window->unk44 = 1; -} - -IWRAM_INIT void sub_8272A78(s32 id) -{ - sub_8272A8C(gWindows, id); -} - -IWRAM_INIT static void sub_8272A8C(Window *windows, s32 id) -{ - s32 i, j; - Window *window = &windows[id]; - u32 *dstPtr = window->unk18; - s32 id8 = window->unk20 + 8; - - for (i = 0; i < window->width; i++) { - u32 *loopPtr; - - dstPtr[3] = 0; - dstPtr[4] = dstPtr[5]; - dstPtr[5] = dstPtr[6]; - dstPtr[6] = dstPtr[7]; - dstPtr[7] = dstPtr[id8]; - - loopPtr = dstPtr + id8; - for (j = 0; j < 5; j++) { - loopPtr[0] = loopPtr[1]; - loopPtr[1] = loopPtr[2]; - loopPtr[2] = loopPtr[3]; - loopPtr[3] = loopPtr[4]; - loopPtr[4] = loopPtr[5]; - loopPtr[5] = loopPtr[6]; - loopPtr[6] = loopPtr[7]; - loopPtr[7] = loopPtr[id8]; - - loopPtr += id8; - } - - loopPtr[0] = loopPtr[1]; - loopPtr[1] = loopPtr[2]; - loopPtr[2] = loopPtr[3]; - loopPtr[3] = loopPtr[4]; - loopPtr[4] = loopPtr[5]; - loopPtr[5] = loopPtr[6]; - loopPtr[6] = loopPtr[7]; - loopPtr[7] = 0; - - dstPtr += 8; - } - - window->unk30 = window->unk28; - window->unk34 = window->unk1C; - window->unk38 = window->unk2C; - window->unk44 = 1; -} - -// Needed to match, because without it the alignment is different. -IWRAM_INIT static UNUSED u8 sMatchAlignment = 0; diff --git a/src/text_1.c b/src/text_1.c new file mode 100644 index 000000000..f050a32e7 --- /dev/null +++ b/src/text_1.c @@ -0,0 +1,1429 @@ +#include "global.h" +#include "globaldata.h" +#include "structs/str_text.h" +#include "bg_palette_buffer.h" +#include "code_800558C.h" +#include "code_8009804.h" +#include "cpu.h" +#include "decompress_at.h" +#include "def_filearchives.h" +#include "file_system.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" +#include "text_4.h" + +EWRAM_DATA Window gWindows[MAX_WINDOWS] = {0}; // NDS=020EDDEC +EWRAM_DATA CharMapStruct *gCharmaps[2] = { NULL }; +EWRAM_DATA s16 gCharacterSpacing = 0; +EWRAM_DATA u8 gUnknown_202749A[11] = {0}; +EWRAM_DATA bool8 gUnknown_20274A5 = FALSE; +EWRAM_DATA u8 gUnknown_20274A6[6] = {0}; +EWRAM_DATA s32 gCurrentCharmap = 0; +EWRAM_DATA static vu32 sUnknown_20274B0 = 0; +EWRAM_DATA static u32 sUnknown_20274B4[0xEC0] = {0}; +EWRAM_DATA static OpenedFile *sCharmapFiles[3] = { NULL }; +EWRAM_DATA static WindowTemplates sSavedWindows = {0}; +EWRAM_DATA s32 gUnknown_202B020 = 0; // NDS=020EDCEC +EWRAM_DATA s32 gUnknown_202B024 = 0; // NDS=020EDCE8 +EWRAM_DATA s32 gCharHeight[2] = {0}; +EWRAM_DATA u32 gTextShadowMask = 0; // Some text color info is stored; retrieve via "& 0xF" +EWRAM_DATA u8 gDrawTextShadow = 0; +// 4 bgs, 32x32 tiles, y dimension goes before x [bgId][y][x] +EWRAM_DATA ALIGNED(4) u16 gBgTilemaps[4][32][32] = {0}; + +EWRAM_INIT void (*ScrollDownWindowFunc)(s32 windowId) = ScrollDownWindow; +EWRAM_INIT void (*ScrollUpWindowFunc)(s32 windowId) = ScrollUpWindow; +EWRAM_INIT void (*gIwramTextFunc3)(s32 a0) = sub_82729A4; +EWRAM_INIT void (*gIwramTextFunc4)(s32 a0) = sub_8272A78; + +IWRAM_DATA ALIGNED(4) s16 gUnknown_3000E94[161] = {0}; + +#include "data/text.h" + +static void AddWindow(Window *windows, u32 *vram, u32 *, u16 *, u32 windowId, const WindowTemplate *winTemplate, bool8, s32 firstBlockId, DungeonPos *positionModifier, u8); +static void ShowWindowsInternal(const WindowTemplates *winTemplates, bool8, bool8, DungeonPos *positionModifier); +static void sub_800677C(Window *window, s32, u16 *, u8); +static void sub_80069CC(Window *window, s32, s32, s32, u16 *); +static void sub_8006AC4(Window *window, s32, s32, s32, u16 *); +static void sub_8006B70(Window *window, s32, s32, s32, u16 *); +static void sub_8006C44(Window *window, s32, u16 *, u8); +static void sub_8006E94(Window *, s32, u32, const WindowHeader *, u16 *); + +// arm9.bin::02005448 +void LoadCharmaps(void) +{ + s32 i; + s32 j; + s32 k; + + gCurrentCharmap = 0; + sCharmapFiles[0] = OpenFileAndGetFileDataPtr(sKanjiA_file_string, &gSystemFileArchive); + sCharmapFiles[1] = OpenFileAndGetFileDataPtr(sKanjiB_file_string, &gSystemFileArchive); + gCharmaps[0] = (CharMapStruct *) sCharmapFiles[0]->data; + gCharmaps[1] = (CharMapStruct *) sCharmapFiles[1]->data; + gCharHeight[0] = 11; + gCharHeight[1] = 12; + + for (k = 0; k < 4; k++) { + gWindows[k].width = 0; + gWindows[k].unk8 = 0; + gWindows[k].unk46 = 0; + } + + gCharacterSpacing = 0; + + for (i = 0; i < 20; i++) { + gBgTilemaps[0][i][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x279); + gBgTilemaps[1][i][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); + + for (j = 1; j < 32; j++) { + gBgTilemaps[0][i][j] = 0; + gBgTilemaps[1][i][j] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); + } + } + + gDrawTextShadow = 1; + gTextShadowMask = 0x88888888; + gUnknown_203B078 = NULL; + gUnknown_20274A5 = FALSE; + gUnknown_202B020 = 1; + gUnknown_202B024 = 20; + UpdateFadeInTile(0); +} + +// arm9.bin::0200538C +u32 UpdateFadeInTile(u32 a0) +{ + u32 r5 = sUnknown_20274B0; + u32 *r4 = (u32 *)(VRAM + 0x4F40); + const u32 *r2; + sUnknown_20274B0 = a0; + + if (a0 == 0 || a0 == 2) { + sub_800CDA8(2); + r2 = sFadeInNone; + } + else { + sub_800CDA8(1); + r2 = sFadeInDungeon; + } + + gTextShadowMask = 0x88888888; + *r4++ = *r2++; + *r4++ = *r2++; + *r4++ = *r2++; + *r4++ = *r2++; + *r4++ = *r2++; + *r4++ = *r2++; + *r4++ = *r2++; + *r4++ = *r2++; + return r5; +} + +// arm9.bin::0200537C +u32 sub_80063B0(void) +{ + return sUnknown_20274B0; +} + +#if (GAME_VERSION == VERSION_RED) +UNUSED static u8 UnusedSetTextShadow(u8 a0) +{ + u8 retval = gDrawTextShadow; + gDrawTextShadow = a0; + return retval; +} +#endif + +// arm9.bin::0200536C +void SelectCharmap(u32 a0) +{ + gCurrentCharmap = a0; +} + +// arm9.bin::02005314 +void SetCharacterMask(s32 a0) +{ + u32 retval; + if (a0 == 0) { + UNUSED u32 unusedVal = sUnknown_20274B0; + retval = 0x88888888; + } + else { + retval = (a0 & 0xF) | ((a0 & 0xF) << 4); // Must be one line for matching + retval |= ((a0 & 0xF) << 8); + retval |= ((a0 & 0xF) << 12); + retval |= ((a0 & 0xF) << 16); + retval |= ((a0 & 0xF) << 20); + retval |= ((a0 & 0xF) << 24); + retval |= ((a0 & 0xF) << 28); + } + gTextShadowMask = retval; +} + +// arm9.bin::020052E4 +void ShowWindows(const WindowTemplates *winTemplates, bool8 a1, bool8 a2) +{ + DungeonPos positionModifier = {0, 0}; + ShowWindowsInternal(winTemplates, a1, a2, &positionModifier); +} + +// red https://decomp.me/scratch/EN6n0 (includes removed code from pmd-blue) +// blue https://decomp.me/scratch/1y9BG +// arm9.bin::020051B0 +static void ShowWindowsInternal(const WindowTemplates *winTemplates, bool8 a1, bool8 a2, DungeonPos *positionModifier) +{ + s32 i; + s32 area = 2; + + if (winTemplates == NULL) + winTemplates = &sDummyWindows; + if (a2) + sub_8009388(); + + ResetWindowBgData(); + + for (i = 0; i < MAX_WINDOWS; i++) { + sSavedWindows.id[i] = winTemplates->id[i]; + + if (winTemplates->id[i].width != 0) { + AddWindow(gWindows, (u32 *)VRAM, sUnknown_20274B4, &gBgTilemaps[0][0][0], sUnknown_80B8804[i], &winTemplates->id[i], a1, area, positionModifier, 0); + sub_80089AC(&winTemplates->id[i], positionModifier); + area += winTemplates->id[i].width * winTemplates->id[i].unk10; + } + } + + // Needed to account for weird compiler LDRs + ASM_MATCH_TRICK(gUnknown_203B078); + ASM_MATCH_TRICK(gUnknown_3000E94[0]); + ASM_MATCH_TRICK(gUnknown_20274A5); + + gUnknown_203B078 = gUnknown_3000E94; + gUnknown_20274A5 = TRUE; +} + +// arm9.bin::0200508C +UNUSED static void nullsub_152(void) +{ + // Seems to be a 2nd version of the func above, probably for 2nd screen windows. +} + +// arm9.bin::02005040 +void RestoreSavedWindows(WindowTemplates *dst) +{ + s32 i; + + for (i = 0; i < MAX_WINDOWS; i++) + dst->id[i] = sSavedWindows.id[i]; +} + +#if (GAME_VERSION == VERSION_RED) +UNUSED static void nullsub_153(void) +{ +} +#endif + +// arm9.bin::02005030 +u32 sub_8006544(u32 index) +{ + return sUnknown_80B8814[index]; +} + +// arm9.bin::02004D54 +static void AddWindow(Window *windows, u32 *vram, u32 *a2, u16 *a3, u32 windowId, const WindowTemplate *winTemplate, bool8 a6, s32 firstBlockId, DungeonPos *positionModifier, u8 a9) +{ + Window *newWindow; + s32 x, y; + s32 numI; + u32 uVar1; + + newWindow = &windows[windowId]; + x = winTemplate->pos.x + positionModifier->x; + y = winTemplate->pos.y + positionModifier->y; + newWindow->x = x; + newWindow->y = y; + newWindow->width = winTemplate->width; + newWindow->unk8 = winTemplate->unk10; + newWindow->height = winTemplate->height; + newWindow->type = winTemplate->type; + newWindow->unk10 = firstBlockId; + + if (newWindow->type == WINDOW_TYPE_WITH_HEADER) + newWindow->unk14 = firstBlockId; + else + newWindow->unk14 = firstBlockId + winTemplate->unk12 * newWindow->width; + + newWindow->unk18 = &a2[newWindow->unk10 * 8]; + newWindow->unk1C = &a2[newWindow->unk14 * 8]; + newWindow->unk24 = winTemplate->unk12; + newWindow->unk28 = &vram[newWindow->unk14 * 8]; + + if (newWindow->type == WINDOW_TYPE_WITH_HEADER) + newWindow->unk2C = newWindow->width * (newWindow->height + winTemplate->unk12) * 32; + else + newWindow->unk2C = newWindow->width * newWindow->height * 32; + + newWindow->unk30 = 0; + newWindow->unk34 = 0; + newWindow->unk38 = 0; + newWindow->unk20 = (newWindow->width * 8) - 8; + newWindow->unk45 = newWindow->type == WINDOW_TYPE_0; + + if (newWindow->unk8 == 0) + return; + + if ((winTemplate->unk0 & 0xA0) != 0x80) { + s32 newY = y - 1; + s32 i, j; + + if (newWindow->type == WINDOW_TYPE_WITH_HEADER) { + uVar1 = a6 ? newWindow->unk14 : 0; + + sub_8006E94(newWindow, newY, uVar1, winTemplate->header, a3); + + newY = y + 2; + uVar1 = a6 ? newWindow->unk14 + newWindow->width * (winTemplate->unk12 + 2) : 0; + numI = newWindow->height - 2; + } + else { + sub_800677C(newWindow, newY, a3, a9); + + newY = y; + uVar1 = a6 ? newWindow->unk14 : 0; + numI = newWindow->height; + } + + for (i = 0; i < numI; i++) { + s32 newX = x - 1; + sub_80069CC(newWindow, newX, newY, i, a3); + newX = x; + + for (j = 0; j < newWindow->width; j++) { + sub_8006AC4(newWindow, newX, newY, uVar1, a3); + + newX++; + if (a6) + uVar1++; + } + + sub_8006B70(newWindow, newX, newY, i, a3); + newY++; + } + sub_8006C44(newWindow, newY, a3, a9); + } + + if ((winTemplate->unk0 & 0x80) == 0) + PrepareTextbox_8008C6C(windows, windowId); + + newWindow->unk46 = 0; +} + +// arm9.bin::02004B0C +static void sub_800677C(Window *window, s32 a1, u16 *a2, u8 a3) +{ + s32 iVar5; + s32 i; + + iVar5 = window->x - 1; + + if (a1 > 28) + return; + if (a1 < 0) + return; + + switch (window->type) { + case WINDOW_TYPE_0: + case WINDOW_TYPE_WITHOUT_BORDER: + case WINDOW_TYPE_2: + case WINDOW_TYPE_WITH_HEADER: + break; + case WINDOW_TYPE_NORMAL: + (a2 + a1 * 0x20)[iVar5] = 0xF2D8; + if (a3 != 0) + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF293; + else + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; + iVar5++; + for (i = 0; i < window->width; i++) { + (a2 + a1 * 0x20)[iVar5] = 0xF2D9; + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; + iVar5++; + } + + (a2 + a1 * 0x20)[iVar5] = 0xF6D8; + if (a3 != 0) + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF693; + else + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; + break; + case WINDOW_TYPE_4: + (a2 + a1 * 0x20)[iVar5] = 0xF2E8; + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; + iVar5++; + for (i = 0; i < window->width; i++) { + (a2 + a1 * 0x20)[iVar5] = 0xF2E9; + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; + iVar5++; + } + + (a2 + a1 * 0x20)[iVar5] = 0xF6E8; + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; + break; + case WINDOW_TYPE_FILL_TRANSPARENT: + (a2 + a1 * 0x20)[iVar5] = 0xF2DC; + iVar5++; + for (i = 0; i < window->width; i++) { + (a2 + a1 * 0x20)[iVar5] = 0xF2DD; + iVar5++; + } + + (a2 + a1 * 0x20)[iVar5] = 0xF6DC; + break; + case WINDOW_TYPE_7: + (a2 + a1 * 0x20)[iVar5] = 0xF293; + iVar5++; + for (i = 0; i < window->width; i++) { + (a2 + a1 * 0x20)[iVar5] = 0xF297; + iVar5++; + } + + (a2 + a1 * 0x20)[iVar5] = 0xF693; + break; + } +} + +// arm9.bin::020049D0 +static void sub_80069CC(Window *window, s32 a1, s32 a2, s32 a3, u16 *a4) +{ + if (a2 > 28) + return; + if (a2 < 0) + return; + + switch (window->type) { + case WINDOW_TYPE_WITHOUT_BORDER: + case WINDOW_TYPE_2: + break; + case WINDOW_TYPE_0: + if (a3 == 0) { + (a4 + a2 * 0x20)[a1] = 0xF297; + (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; + break; + } + if (a3 == window->height - 1) { + (a4 + a2 * 0x20)[a1] = 0xFA97; + (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; + break; + } + // Fallthrough + case WINDOW_TYPE_NORMAL: + case WINDOW_TYPE_WITH_HEADER: + (a4 + a2 * 0x20)[a1] = 0xF2DA; + (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; + break; + case WINDOW_TYPE_4: + (a4 + a2 * 0x20)[a1] = 0xF2EA; + (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; + break; + case WINDOW_TYPE_FILL_TRANSPARENT: + (a4 + a2 * 0x20)[a1] = 0xF2DE; + break; + case WINDOW_TYPE_7: + (a4 + a2 * 0x20)[a1] = 0xF2B6; + break; + } +} + +// arm9.bin::020048F0 +static void sub_8006AC4(Window *window, s32 a1, s32 a2, s32 a3, u16 *a4) +{ + if (a2 > 28) + return; + if (a2 < 0) + return; + + switch (window->type) { + case WINDOW_TYPE_2: + (a4 + a2 * 0x20)[a1] = a3 | 0xF000; + (a4 + a2 * 0x20)[a1 + 0x400] = 0xF278; + break; + case WINDOW_TYPE_0: + case WINDOW_TYPE_WITHOUT_BORDER: + case WINDOW_TYPE_NORMAL: + case WINDOW_TYPE_4: + case WINDOW_TYPE_WITH_HEADER: + (a4 + a2 * 0x20)[a1] = a3 | 0xF000; + (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; + break; + case WINDOW_TYPE_FILL_TRANSPARENT: + case WINDOW_TYPE_7: + (a4 + a2 * 0x20)[a1] = a3 | 0xF000; + break; + } +} + +// arm9.bin::020047B4 +static void sub_8006B70(Window *window, s32 a1, s32 a2, s32 a3, u16 *a4) +{ + if (a2 > 28) + return; + if (a2 < 0) + return; + + switch (window->type) { + case WINDOW_TYPE_WITHOUT_BORDER: + case WINDOW_TYPE_2: + break; + case WINDOW_TYPE_0: + if (a3 == 0) { + (a4 + a2 * 0x20)[a1] = 0xF697; + (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; + break; + } + if (a3 == window->height - 1) { + (a4 + a2 * 0x20)[a1] = 0xFE97; + (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; + break; + } + // Fallthrough + case WINDOW_TYPE_NORMAL: + case WINDOW_TYPE_WITH_HEADER: + (a4 + a2 * 0x20)[a1] = 0xF6DA; + (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; + break; + case WINDOW_TYPE_4: + (a4 + a2 * 0x20)[a1] = 0xF6EA; + (a4 + a2 * 0x20)[a1 + 0x400] = 0xF2DB; + break; + case WINDOW_TYPE_FILL_TRANSPARENT: + (a4 + a2 * 0x20)[a1] = 0xF6DE; + break; + case WINDOW_TYPE_7: + (a4 + a2 * 0x20)[a1] = 0xF6B6; + break; + } +} + +// arm9.bin::0200456C +static void sub_8006C44(Window *window, s32 a1, u16 *a2, u8 a3) +{ + s32 iVar5; + s32 i; + + iVar5 = window->x - 1; + + if (a1 > 28) + return; + if (a1 < 0) + return; + + switch (window->type) { + case WINDOW_TYPE_0: + case WINDOW_TYPE_WITHOUT_BORDER: + case WINDOW_TYPE_2: + break; + case WINDOW_TYPE_NORMAL: + case WINDOW_TYPE_WITH_HEADER: + (a2 + a1 * 0x20)[iVar5] = 0xFAD8; + if (a3 != 0) + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xFA93; + else + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; + iVar5++; + for (i = 0; i < window->width; i++) { + (a2 + a1 * 0x20)[iVar5] = 0xFAD9; + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; + iVar5++; + } + + (a2 + a1 * 0x20)[iVar5] = 0xFED8; + if (a3 != 0) + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xFE93; + else + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; + break; + case WINDOW_TYPE_4: + (a2 + a1 * 0x20)[iVar5] = 0xFAE8; + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; + iVar5++; + for (i = 0; i < window->width; i++) { + (a2 + a1 * 0x20)[iVar5] = 0xFAE9; + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; + iVar5++; + } + + (a2 + a1 * 0x20)[iVar5] = 0xFEE8; + (a2 + a1 * 0x20)[iVar5 + 0x400] = 0xF2DB; + break; + case WINDOW_TYPE_FILL_TRANSPARENT: + (a2 + a1 * 0x20)[iVar5] = 0xFADC; + iVar5++; + for (i = 0; i < window->width; i++) { + (a2 + a1 * 0x20)[iVar5] = 0xFADD; + iVar5++; + } + + (a2 + a1 * 0x20)[iVar5] = 0xFEDC; + break; + case WINDOW_TYPE_7: + (a2 + a1 * 0x20)[iVar5] = 0xFA93; + iVar5++; + for (i = 0; i < window->width; i++) { + (a2 + a1 * 0x20)[iVar5] = 0xFA97; + iVar5++; + } + + (a2 + a1 * 0x20)[iVar5] = 0xFE93; + break; + } +} + +// Not even close but I don't feel like continuing atm https://decomp.me/scratch/F58jg +// arm9.bin::02004054 +/* +static void sub_8006E94(Window *a0, s32 a1, u32 a2, const WindowHeader *a3, u16 *a4) +{ + s32 bVar1; + s32 iVar2; + s32 iVar3; + s32 sVar4; + u16 *puVar5; + u16 *puVar6; + u16 *puVar7; + s32 iVar8; + u16 *puVar9; + u16 *puVar10; + u16 *puVar11; + s32 local_44; + u32 local_3c; + u16 *local_30; + s32 local_2c; + u16 *local_24; + + iVar2 = a0->unk0; + bVar1 = -1; + + if (a1 > 28) + return; + if (a1 < 0) + return; + + (a4 + a1 * 0x20)[iVar2 - 1] = 0xF278; + (a4 + a1 * 0x20)[iVar2 - 1 + 0x400] = 0xF27A; + (a4 + a1 * 0x20)[iVar2 - 1 + 0x20] = 0xF278; + (a4 + a1 * 0x20)[iVar2 - 1 + 0x420] = 0xF27A; + (a4 + a1 * 0x20)[iVar2 - 1 + 0x40] = 0xF2D8; + (a4 + a1 * 0x20)[iVar2 - 1 + 0x440] = 0xF2DB; + + local_2c = iVar2 * 2; + puVar5 = a4 + a1 * 0x20 + iVar2 + 0x40; + puVar7 = a4 + a1 * 0x20 + iVar2 + 0x20; + local_30 = a4 + a1 * 0x20 + iVar2 + 0x400; + puVar11 = a4 + a1 * 0x20 + iVar2 + 0x420; + puVar9 = a4 + a1 * 0x20 + iVar2; + iVar8 = a1 * 0x40; + + for (local_3c = 0; local_3c < a3[0]; local_3c++) { + if (local_3c == a3[1]) { + bVar1 = TRUE; + *puVar9 = 0xF2E0; + *local_30 = 0xF2E2; + *puVar7 = 0xF2DA; + *puVar11 = 0xF2DB; + *puVar5 = 0xF6E7; + puVar9[0x440] = 0xF2DB; + puVar5++; + puVar7++; + local_30++; + puVar11++; + puVar9++; + local_2c += 2; + iVar2++; + + if (a2 == 0 || ++a2 == 0) + iVar3 = 0; + else + iVar3 = a2 + a0->unk4; + + local_24 = a4 + local_2c + iVar8 + 0x80; + puVar10 = a4 + local_2c + iVar8 + 0x40; + puVar6 = a4 + local_2c + iVar8; + + for (local_44 = 0; local_44 < a3[2]; local_44++) { + *puVar6 = 0xF2E1; + puVar6[0x400] = 0xF2E2; + *puVar10 = a2 | 0xF000; + puVar6[0x420] = 0xF2DB; + *local_24 = iVar3 | 0xF000; + puVar6[0x440] = 0xF2DB; + local_24++; + puVar10++; + puVar6++; + puVar5++; + puVar7++; + local_30++; + puVar11++; + puVar9++; + local_2c += 2; + iVar2++; + if (a2 != 0) + a2++; + + if (iVar3 != 0) + iVar3++; + } + + *puVar9 = 0xF6E0; + *local_30 = 0xF2E2; + *puVar7 = 0xF6DA; + *puVar11 = 0xF2DB; + *puVar5 = 0xF2E7; + puVar9[0x440] = 0xF2DB; + } + else { + if (bVar1) { + if ((a3[3] >> (local_3c & 0xFF) & 1) == 0) { + sVar4 = 107; + if (local_3c == a3[0] - 1) + sVar4 = 103; + + *puVar9 = (sVar4 + 0x278) | 0xF000; + *puVar7 = 0xF6EF; + *puVar5 = 0xF2D9; + } + else { + sVar4 = 31; + if (local_3c == a3[0] - 1) + sVar4 = 27; + + *puVar9 = (sVar4 + 0x278) | 0xF000; + *puVar7 = 0xF6B6; + *puVar5 = 0xF2D9; + } + *local_30 = 0xF27A; + *puVar11 = 0xF6DB; + } + else { + if ((a3[3] >> (local_3c & 0xFF) & 1) == 0) { + sVar4 = 107; + if (local_3c == 0) + sVar4 = 103; + + *puVar9 = (sVar4 + 0x278) | 0xF400; + *puVar7 = 0xF2EF; + *puVar5 = 0xF2D9; + } + else { + sVar4 = 31; + if (local_3c == 0) + sVar4 = 27; + + *puVar9 = (sVar4 + 0x278) | 0xF400; + *puVar7 = 0xF2B6; + *puVar5 = 0xF2D9; + } + *local_30 = 0xF27A; + *puVar11 = 0xF2DB; + } + puVar9[0x440] = 0xF2DB; + } + + local_2c += 2; + local_30++; + iVar2++; + puVar11++; + puVar5++; + puVar7++; + puVar9++; + if (a2 != 0) + a2++; + } + + iVar8 = a0->unk0 + a0->unk4; + if (iVar2 < iVar8) { + for (iVar3 = iVar8 - iVar2; iVar3 != 0; iVar3--) { + (a4 + a1 * 0x20)[iVar2 + iVar3] = 0xF278; + (a4 + a1 * 0x20)[iVar2 + 0x400 + iVar3] = 0xF27A; + (a4 + a1 * 0x20)[iVar2 + 0x20 + iVar3] = 0xF278; + (a4 + a1 * 0x20)[iVar2 + 0x420 + iVar3] = 0xF27A; + (a4 + a1 * 0x20)[iVar2 + 0x40 + iVar3] = 0xF2D9; + (a4 + a1 * 0x20)[iVar2 + 0x440 + iVar3] = 0xF2DB; + + if (a2 != 0) + a2++; + + iVar2 = iVar8; + } + } + + (a4 + a1 * 0x20)[iVar2] = 0xF278; + (a4 + a1 * 0x20)[iVar2 + 0x400] = 0xF27A; + (a4 + a1 * 0x20)[iVar2 + 0x20] = 0xF278; + (a4 + a1 * 0x20)[iVar2 + 0x420] = 0xF27A; + (a4 + a1 * 0x20)[iVar2 + 0x40] = 0xF6D8; + (a4 + a1 * 0x20)[iVar2 + 0x440] = 0xF2DB; +} +*/ +NAKED +static void sub_8006E94(Window *a0, s32 a1, u32 a2, const WindowHeader *a3, u16 *a4) +{ + asm_unified( + "\tpush {r4-r7,lr}\n" + "\tmov r7, r10\n" + "\tmov r6, r9\n" + "\tmov r5, r8\n" + "\tpush {r5-r7}\n" + "\tsub sp, 0x30\n" + "\tstr r0, [sp]\n" + "\tadds r4, r1, 0\n" + "\tadds r7, r2, 0\n" + "\tstr r3, [sp, 0x4]\n" + "\tmovs r1, 0\n" + "\tldrsh r0, [r0, r1]\n" + "\tmov r10, r0\n" + "\tmovs r2, 0x1\n" + "\tnegs r2, r2\n" + "\tadd r2, r10\n" + "\tmovs r3, 0\n" + "\tstr r3, [sp, 0x8]\n" + "\tcmp r4, 0x1C\n" + "\tble _08006EBE\n" + "\tb _080072FE\n" +"_08006EBE:\n" + "\tcmp r4, 0\n" + "\tbge _08006EC4\n" + "\tb _080072FE\n" +"_08006EC4:\n" + "\tlsls r1, r2, 1\n" + "\tlsls r4, 6\n" + "\tldr r6, [sp, 0x50]\n" + "\tadds r5, r4, r6\n" + "\tadds r1, r5\n" + "\tldr r0, _08006F9C\n" + "\tadds r3, r0, 0\n" + "\tstrh r3, [r1]\n" + "\tmovs r2, 0x80\n" + "\tlsls r2, 4\n" + "\tadds r0, r1, r2\n" + "\tldr r6, _08006FA0\n" + "\tadds r2, r6, 0\n" + "\tstrh r2, [r0]\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0x40\n" + "\tstrh r3, [r0]\n" + "\tmovs r0, 0x84\n" + "\tlsls r0, 4\n" + "\tadds r0, r1, r0\n" + "\tstrh r2, [r0]\n" + "\tadds r2, r1, 0\n" + "\tadds r2, 0x80\n" + "\tldr r3, _08006FA4\n" + "\tadds r0, r3, 0\n" + "\tstrh r0, [r2]\n" + "\tmovs r6, 0x88\n" + "\tlsls r6, 4\n" + "\tadds r1, r6\n" + "\tldr r2, _08006FA8\n" + "\tadds r0, r2, 0\n" + "\tstrh r0, [r1]\n" + "\tmov r12, r10\n" + "\tmovs r3, 0\n" + "\tstr r4, [sp, 0x18]\n" + "\tldr r4, [sp, 0x4]\n" + "\tldrb r4, [r4]\n" + "\tcmp r3, r4\n" + "\tblt _08006F14\n" + "\tb _08007238\n" +"_08006F14:\n" + "\tadds r2, r5, 0\n" + "\tmov r5, r12\n" + "\tlsls r1, r5, 1\n" + "\tldr r0, [sp, 0x50]\n" + "\tadds r0, 0x80\n" + "\tldr r6, [sp, 0x18]\n" + "\tadds r0, r6, r0\n" + "\tadds r0, r1\n" + "\tmov r9, r0\n" + "\tldr r0, [sp, 0x50]\n" + "\tadds r0, 0x40\n" + "\tadds r0, r6, r0\n" + "\tadds r0, r1\n" + "\tmov r8, r0\n" + "\tldr r4, [sp, 0x50]\n" + "\tmovs r5, 0x80\n" + "\tlsls r5, 4\n" + "\tadds r0, r4, r5\n" + "\tadds r0, r6, r0\n" + "\tadds r0, r1, r0\n" + "\tstr r0, [sp, 0x20]\n" + "\tmovs r6, 0x84\n" + "\tlsls r6, 4\n" + "\tadds r0, r4, r6\n" + "\tldr r4, [sp, 0x18]\n" + "\tadds r0, r4, r0\n" + "\tadds r0, r1\n" + "\tmov r10, r0\n" + "\tadds r4, r1, r2\n" + "\tldr r5, [sp, 0x18]\n" + "\tstr r5, [sp, 0x10]\n" + "\tstr r2, [sp, 0x1C]\n" + "\tstr r1, [sp, 0x24]\n" +"_08006F56:\n" + "\tldr r6, [sp, 0x4]\n" + "\tldrb r6, [r6, 0x1]\n" + "\tcmp r3, r6\n" + "\tbne _08006F60\n" + "\tb _080070C8\n" +"_08006F60:\n" + "\tldr r0, [sp, 0x8]\n" + "\tcmp r0, 0\n" + "\tbne _08007008\n" + "\tldr r1, [sp, 0x4]\n" + "\tldrb r0, [r1, 0x3]\n" + "\tasrs r0, r3\n" + "\tmovs r1, 0x1\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _08006FB8\n" + "\tmovs r1, 0x1F\n" + "\tcmp r3, 0\n" + "\tbne _08006F7C\n" + "\tmovs r1, 0x1B\n" +"_08006F7C:\n" + "\tmovs r2, 0x9E\n" + "\tlsls r2, 2\n" + "\tadds r0, r1, r2\n" + "\tldr r5, _08006FAC\n" + "\tadds r1, r5, 0\n" + "\torrs r0, r1\n" + "\tstrh r0, [r4]\n" + "\tldr r6, _08006FB0\n" + "\tadds r0, r6, 0\n" + "\tmov r1, r8\n" + "\tstrh r0, [r1]\n" + "\tldr r5, _08006FB4\n" + "\tmov r2, r9\n" + "\tstrh r5, [r2]\n" + "\tb _08006FDC\n" + "\t.align 2, 0\n" +"_08006F9C: .4byte 0x0000f278\n" +"_08006FA0: .4byte 0x0000f27a\n" +"_08006FA4: .4byte 0x0000f2d8\n" +"_08006FA8: .4byte 0x0000f2db\n" +"_08006FAC: .4byte 0xfffff400\n" +"_08006FB0: .4byte 0x0000f2b6\n" +"_08006FB4: .4byte 0x0000f2d9\n" +"_08006FB8:\n" + "\tmovs r1, 0x6B\n" + "\tcmp r3, 0\n" + "\tbne _08006FC0\n" + "\tmovs r1, 0x67\n" +"_08006FC0:\n" + "\tmovs r6, 0x9E\n" + "\tlsls r6, 2\n" + "\tadds r0, r1, r6\n" + "\tldr r2, _08006FF4\n" + "\tadds r1, r2, 0\n" + "\torrs r0, r1\n" + "\tstrh r0, [r4]\n" + "\tldr r5, _08006FF8\n" + "\tadds r0, r5, 0\n" + "\tmov r6, r8\n" + "\tstrh r0, [r6]\n" + "\tldr r1, _08006FFC\n" + "\tmov r0, r9\n" + "\tstrh r1, [r0]\n" +"_08006FDC:\n" + "\tldr r2, _08007000\n" + "\tadds r0, r2, 0\n" + "\tldr r5, [sp, 0x20]\n" + "\tstrh r0, [r5]\n" + "\tldr r0, _08007004\n" + "\tmov r6, r10\n" + "\tstrh r0, [r6]\n" + "\tmovs r1, 0x88\n" + "\tlsls r1, 4\n" + "\tadds r0, r4, r1\n" + "\tadds r2, 0x61\n" + "\tb _0800708E\n" + "\t.align 2, 0\n" +"_08006FF4: .4byte 0xfffff400\n" +"_08006FF8: .4byte 0x0000f2ef\n" +"_08006FFC: .4byte 0x0000f2d9\n" +"_08007000: .4byte 0x0000f27a\n" +"_08007004: .4byte 0x0000f2db\n" +"_08007008:\n" + "\tldr r5, [sp, 0x4]\n" + "\tldrb r0, [r5, 0x3]\n" + "\tasrs r0, r3\n" + "\tmovs r1, 0x1\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0800704C\n" + "\tldrb r0, [r5]\n" + "\tsubs r0, 0x1\n" + "\tmovs r1, 0x1F\n" + "\tcmp r3, r0\n" + "\tbne _08007022\n" + "\tmovs r1, 0x1B\n" +"_08007022:\n" + "\tmovs r6, 0x9E\n" + "\tlsls r6, 2\n" + "\tadds r0, r1, r6\n" + "\tldr r2, _08007040\n" + "\tadds r1, r2, 0\n" + "\torrs r0, r1\n" + "\tstrh r0, [r4]\n" + "\tldr r5, _08007044\n" + "\tadds r0, r5, 0\n" + "\tmov r6, r8\n" + "\tstrh r0, [r6]\n" + "\tldr r1, _08007048\n" + "\tmov r0, r9\n" + "\tstrh r1, [r0]\n" + "\tb _08007076\n" + "\t.align 2, 0\n" +"_08007040: .4byte 0xfffff000\n" +"_08007044: .4byte 0x0000f6b6\n" +"_08007048: .4byte 0x0000f2d9\n" +"_0800704C:\n" + "\tldr r2, [sp, 0x4]\n" + "\tldrb r0, [r2]\n" + "\tsubs r0, 0x1\n" + "\tmovs r1, 0x6B\n" + "\tcmp r3, r0\n" + "\tbne _0800705A\n" + "\tmovs r1, 0x67\n" +"_0800705A:\n" + "\tmovs r5, 0x9E\n" + "\tlsls r5, 2\n" + "\tadds r0, r1, r5\n" + "\tldr r6, _080070B0\n" + "\tadds r1, r6, 0\n" + "\torrs r0, r1\n" + "\tstrh r0, [r4]\n" + "\tldr r1, _080070B4\n" + "\tadds r0, r1, 0\n" + "\tmov r2, r8\n" + "\tstrh r0, [r2]\n" + "\tldr r6, _080070B8\n" + "\tmov r5, r9\n" + "\tstrh r6, [r5]\n" +"_08007076:\n" + "\tldr r1, _080070BC\n" + "\tadds r0, r1, 0\n" + "\tldr r2, [sp, 0x20]\n" + "\tstrh r0, [r2]\n" + "\tldr r5, _080070C0\n" + "\tadds r0, r5, 0\n" + "\tmov r6, r10\n" + "\tstrh r0, [r6]\n" + "\tmovs r1, 0x88\n" + "\tlsls r1, 4\n" + "\tadds r0, r4, r1\n" + "\tldr r2, _080070C4\n" +"_0800708E:\n" + "\tstrh r2, [r0]\n" + "\tmovs r5, 0x2\n" + "\tadd r9, r5\n" + "\tadd r8, r5\n" + "\tldr r6, [sp, 0x20]\n" + "\tadds r6, 0x2\n" + "\tstr r6, [sp, 0x20]\n" + "\tadd r10, r5\n" + "\tadds r4, 0x2\n" + "\tldr r0, [sp, 0x24]\n" + "\tadds r0, 0x2\n" + "\tstr r0, [sp, 0x24]\n" + "\tmovs r1, 0x1\n" + "\tadd r12, r1\n" + "\tadds r3, 0x1\n" + "\tstr r3, [sp, 0x14]\n" + "\tb _08007226\n" + "\t.align 2, 0\n" +"_080070B0: .4byte 0xfffff000\n" +"_080070B4: .4byte 0x0000f6ef\n" +"_080070B8: .4byte 0x0000f2d9\n" +"_080070BC: .4byte 0x0000f27a\n" +"_080070C0: .4byte 0x0000f6db\n" +"_080070C4: .4byte 0x0000f2db\n" +"_080070C8:\n" + "\tmovs r2, 0x1\n" + "\tstr r2, [sp, 0x8]\n" + "\tldr r5, _08007128\n" + "\tadds r0, r5, 0\n" + "\tstrh r0, [r4]\n" + "\tldr r6, _0800712C\n" + "\tadds r0, r6, 0\n" + "\tldr r1, [sp, 0x20]\n" + "\tstrh r0, [r1]\n" + "\tldr r2, _08007130\n" + "\tadds r0, r2, 0\n" + "\tmov r5, r8\n" + "\tstrh r0, [r5]\n" + "\tldr r0, _08007134\n" + "\tmov r6, r10\n" + "\tstrh r0, [r6]\n" + "\tldr r1, _08007138\n" + "\tadds r0, r1, 0\n" + "\tmov r2, r9\n" + "\tstrh r0, [r2]\n" + "\tmovs r5, 0x88\n" + "\tlsls r5, 4\n" + "\tadds r0, r4, r5\n" + "\tldr r6, _08007134\n" + "\tstrh r6, [r0]\n" + "\tmovs r0, 0x2\n" + "\tadd r9, r0\n" + "\tadd r8, r0\n" + "\tldr r1, [sp, 0x20]\n" + "\tadds r1, 0x2\n" + "\tstr r1, [sp, 0x20]\n" + "\tadd r10, r0\n" + "\tadds r4, 0x2\n" + "\tldr r2, [sp, 0x24]\n" + "\tadds r2, 0x2\n" + "\tstr r2, [sp, 0x24]\n" + "\tmovs r5, 0x1\n" + "\tadd r12, r5\n" + "\tcmp r7, 0\n" + "\tbeq _0800713C\n" + "\tadds r7, 0x1\n" + "\tcmp r7, 0\n" + "\tbeq _0800713C\n" + "\tldr r6, [sp]\n" + "\tmovs r1, 0x4\n" + "\tldrsh r0, [r6, r1]\n" + "\tadds r2, r7, r0\n" + "\tb _0800713E\n" + "\t.align 2, 0\n" +"_08007128: .4byte 0x0000f2e0\n" +"_0800712C: .4byte 0x0000f2e2\n" +"_08007130: .4byte 0x0000f2da\n" +"_08007134: .4byte 0x0000f2db\n" +"_08007138: .4byte 0x0000f6e7\n" +"_0800713C:\n" + "\tmovs r2, 0\n" +"_0800713E:\n" + "\tmovs r5, 0\n" + "\tstr r5, [sp, 0xC]\n" + "\tadds r3, 0x1\n" + "\tstr r3, [sp, 0x14]\n" + "\tldr r6, [sp, 0x4]\n" + "\tldrb r6, [r6, 0x2]\n" + "\tcmp r5, r6\n" + "\tbge _080071E0\n" + "\tldr r0, [sp, 0x50]\n" + "\tadds r0, 0x80\n" + "\tldr r1, [sp, 0x10]\n" + "\tadds r0, r1, r0\n" + "\tldr r3, [sp, 0x24]\n" + "\tadds r0, r3, r0\n" + "\tstr r0, [sp, 0x2C]\n" + "\tldr r0, [sp, 0x50]\n" + "\tadds r0, 0x40\n" + "\tadds r0, r1, r0\n" + "\tadds r5, r3, r0\n" + "\tldr r6, [sp, 0x1C]\n" + "\tadds r3, r6\n" +"_08007168:\n" + "\tldr r1, _08007310\n" + "\tadds r0, r1, 0\n" + "\tstrh r0, [r3]\n" + "\tmovs r6, 0x80\n" + "\tlsls r6, 4\n" + "\tadds r6, r3, r6\n" + "\tstr r6, [sp, 0x28]\n" + "\tadds r1, 0x1\n" + "\tadds r0, r1, 0\n" + "\tstrh r0, [r6]\n" + "\tadds r0, r7, 0\n" + "\tldr r6, _08007314\n" + "\torrs r0, r6\n" + "\tstrh r0, [r5]\n" + "\tmovs r1, 0x84\n" + "\tlsls r1, 4\n" + "\tadds r0, r3, r1\n" + "\tldr r6, _08007318\n" + "\tstrh r6, [r0]\n" + "\tadds r0, r2, 0\n" + "\tldr r1, _08007314\n" + "\torrs r0, r1\n" + "\tldr r6, [sp, 0x2C]\n" + "\tstrh r0, [r6]\n" + "\tmovs r1, 0x88\n" + "\tlsls r1, 4\n" + "\tadds r0, r3, r1\n" + "\tldr r6, _08007318\n" + "\tstrh r6, [r0]\n" + "\tldr r0, [sp, 0x2C]\n" + "\tadds r0, 0x2\n" + "\tstr r0, [sp, 0x2C]\n" + "\tadds r5, 0x2\n" + "\tadds r3, 0x2\n" + "\tmovs r1, 0x2\n" + "\tadd r9, r1\n" + "\tadd r8, r1\n" + "\tldr r6, [sp, 0x20]\n" + "\tadds r6, 0x2\n" + "\tstr r6, [sp, 0x20]\n" + "\tadd r10, r1\n" + "\tadds r4, 0x2\n" + "\tldr r0, [sp, 0x24]\n" + "\tadds r0, 0x2\n" + "\tstr r0, [sp, 0x24]\n" + "\tmovs r1, 0x1\n" + "\tadd r12, r1\n" + "\tcmp r7, 0\n" + "\tbeq _080071CC\n" + "\tadds r7, 0x1\n" +"_080071CC:\n" + "\tcmp r2, 0\n" + "\tbeq _080071D2\n" + "\tadds r2, 0x1\n" +"_080071D2:\n" + "\tldr r6, [sp, 0xC]\n" + "\tadds r6, 0x1\n" + "\tstr r6, [sp, 0xC]\n" + "\tldr r0, [sp, 0x4]\n" + "\tldrb r0, [r0, 0x2]\n" + "\tcmp r6, r0\n" + "\tblt _08007168\n" +"_080071E0:\n" + "\tldr r1, _0800731C\n" + "\tadds r0, r1, 0\n" + "\tstrh r0, [r4]\n" + "\tldr r2, _08007320\n" + "\tadds r0, r2, 0\n" + "\tldr r3, [sp, 0x20]\n" + "\tstrh r0, [r3]\n" + "\tldr r5, _08007324\n" + "\tadds r0, r5, 0\n" + "\tmov r6, r8\n" + "\tstrh r0, [r6]\n" + "\tldr r1, _08007318\n" + "\tmov r0, r10\n" + "\tstrh r1, [r0]\n" + "\tadds r2, 0x5\n" + "\tadds r0, r2, 0\n" + "\tmov r3, r9\n" + "\tstrh r0, [r3]\n" + "\tmovs r5, 0x88\n" + "\tlsls r5, 4\n" + "\tadds r0, r4, r5\n" + "\tstrh r1, [r0]\n" + "\tmovs r6, 0x2\n" + "\tadd r9, r6\n" + "\tadd r8, r6\n" + "\tldr r0, [sp, 0x20]\n" + "\tadds r0, 0x2\n" + "\tstr r0, [sp, 0x20]\n" + "\tadd r10, r6\n" + "\tadds r4, 0x2\n" + "\tldr r1, [sp, 0x24]\n" + "\tadds r1, 0x2\n" + "\tstr r1, [sp, 0x24]\n" + "\tmovs r2, 0x1\n" + "\tadd r12, r2\n" +"_08007226:\n" + "\tcmp r7, 0\n" + "\tbeq _0800722C\n" + "\tadds r7, 0x1\n" +"_0800722C:\n" + "\tldr r3, [sp, 0x14]\n" + "\tldr r5, [sp, 0x4]\n" + "\tldrb r5, [r5]\n" + "\tcmp r3, r5\n" + "\tbge _08007238\n" + "\tb _08006F56\n" +"_08007238:\n" + "\tldr r6, [sp]\n" + "\tmovs r0, 0\n" + "\tldrsh r1, [r6, r0]\n" + "\tmovs r2, 0x4\n" + "\tldrsh r0, [r6, r2]\n" + "\tadds r0, r1, r0\n" + "\tcmp r12, r0\n" + "\tbge _080072BC\n" + "\tldr r3, _08007328\n" + "\tadds r4, r3, 0\n" + "\tmov r8, r0\n" + "\tmov r5, r12\n" + "\tlsls r1, r5, 1\n" + "\tldr r0, [sp, 0x50]\n" + "\tadds r0, 0x80\n" + "\tldr r6, [sp, 0x18]\n" + "\tadds r0, r6, r0\n" + "\tadds r5, r1, r0\n" + "\tldr r0, [sp, 0x50]\n" + "\tadds r0, 0x40\n" + "\tadds r0, r6, r0\n" + "\tadds r3, r1, r0\n" + "\tldr r0, [sp, 0x50]\n" + "\tadds r6, r0\n" + "\tadds r2, r1, r6\n" + "\tmovs r1, 0x80\n" + "\tlsls r1, 4\n" + "\tmov r10, r1\n" + "\tmovs r6, 0x84\n" + "\tlsls r6, 4\n" + "\tmov r9, r6\n" + "\tmov r0, r8\n" + "\tmov r1, r12\n" + "\tsubs r0, r1\n" + "\tmov r12, r0\n" +"_0800727E:\n" + "\tstrh r4, [r2]\n" + "\tmov r6, r10\n" + "\tadds r0, r2, r6\n" + "\tldr r1, _0800732C\n" + "\tstrh r1, [r0]\n" + "\tstrh r4, [r3]\n" + "\tmov r6, r9\n" + "\tadds r0, r2, r6\n" + "\tstrh r1, [r0]\n" + "\tadds r1, 0x5F\n" + "\tadds r0, r1, 0\n" + "\tstrh r0, [r5]\n" + "\tmovs r6, 0x88\n" + "\tlsls r6, 4\n" + "\tadds r1, r2, r6\n" + "\tldr r6, _08007318\n" + "\tadds r0, r6, 0\n" + "\tstrh r0, [r1]\n" + "\tadds r5, 0x2\n" + "\tadds r3, 0x2\n" + "\tadds r2, 0x2\n" + "\tmovs r0, 0x1\n" + "\tnegs r0, r0\n" + "\tadd r12, r0\n" + "\tcmp r7, 0\n" + "\tbeq _080072B4\n" + "\tadds r7, 0x1\n" +"_080072B4:\n" + "\tmov r1, r12\n" + "\tcmp r1, 0\n" + "\tbne _0800727E\n" + "\tmov r12, r8\n" +"_080072BC:\n" + "\tmov r2, r12\n" + "\tlsls r1, r2, 1\n" + "\tldr r3, [sp, 0x18]\n" + "\tldr r4, [sp, 0x50]\n" + "\tadds r0, r3, r4\n" + "\tadds r1, r0\n" + "\tldr r5, _08007328\n" + "\tadds r3, r5, 0\n" + "\tstrh r3, [r1]\n" + "\tmovs r6, 0x80\n" + "\tlsls r6, 4\n" + "\tadds r0, r1, r6\n" + "\tldr r4, _0800732C\n" + "\tadds r2, r4, 0\n" + "\tstrh r2, [r0]\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0x40\n" + "\tstrh r3, [r0]\n" + "\tmovs r5, 0x84\n" + "\tlsls r5, 4\n" + "\tadds r0, r1, r5\n" + "\tstrh r2, [r0]\n" + "\tadds r2, r1, 0\n" + "\tadds r2, 0x80\n" + "\tldr r6, _08007330\n" + "\tadds r0, r6, 0\n" + "\tstrh r0, [r2]\n" + "\tmovs r0, 0x88\n" + "\tlsls r0, 4\n" + "\tadds r1, r0\n" + "\tldr r2, _08007318\n" + "\tadds r0, r2, 0\n" + "\tstrh r0, [r1]\n" +"_080072FE:\n" + "\tadd sp, 0x30\n" + "\tpop {r3-r5}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tmov r10, r5\n" + "\tpop {r4-r7}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.align 2, 0\n" +"_08007310: .4byte 0x0000f2e1\n" +"_08007314: .4byte 0xfffff000\n" +"_08007318: .4byte 0x0000f2db\n" +"_0800731C: .4byte 0x0000f6e0\n" +"_08007320: .4byte 0x0000f2e2\n" +"_08007324: .4byte 0x0000f6da\n" +"_08007328: .4byte 0x0000f278\n" +"_0800732C: .4byte 0x0000f27a\n" +"_08007330: .4byte 0x0000f6d8"); +} + +// arm9.bin::02003FB0 +void sub_8007334(s32 windowId) +{ + s32 i, j; + Window *window = &gWindows[windowId]; + s32 r5 = window->unk14; + s32 r6 = window->y; + for (i = 0; i < window->height; i++) { + s32 id = window->x; + for (j = 0; j < window->width; j++) { + gBgTilemaps[0][r6][id] &= ~(TILEMAP_TILE_NUM(0x3FF)); + gBgTilemaps[0][r6][id] |= r5; + id++; + r5++; + } + r6++; + } +} + +// arm9.bin::02003F0C +UNUSED static void nullsub_154(s32 windowId) +{ + // 2nd version of the func above +} + +// arm9.bin::02003ED4 +void sub_80073B8(s32 windowId) +{ + Window *window = &gWindows[windowId]; + + window->unk3C = &window->unk1C[(u32)window->unk2C >> 2]; + window->unk40 = window->unk1C; + window->unk46 = 1; +} + +// arm9.bin::02003E9C +UNUSED static void nullsub_155(s32 windowId) +{ + // 2nd version of the func above +} + +// arm9.bin::02003E08 +void sub_80073E0(s32 windowId) +{ + Window *window = &gWindows[windowId]; + + if (window->unk44 == 0) { + window->unk30 = &window->unk28[window->unk3C - window->unk1C]; + window->unk34 = window->unk3C; + window->unk38 = (window->unk40 - window->unk3C + 1) * 4; + + if (window->unk38 >= window->unk2C) + window->unk38 = window->unk2C; + + if (window->unk38 < 0) + window->unk38 = 0; + } + + window->unk46 = 0; +} + +// arm9.bin::02003D74 +UNUSED static void nullsub_156(s32 windowId) +{ + // 2nd version of the func above with gSubWindows instead of gMainWindows +} diff --git a/src/text_2.c b/src/text_2.c new file mode 100644 index 000000000..66ec61754 --- /dev/null +++ b/src/text_2.c @@ -0,0 +1,1291 @@ +#include "global.h" +#include "code_8009804.h" +#include "cpu.h" +#include "decompress_at.h" +#include "text_1.h" +#include "text_2.h" + +static const u32 sUnknown_80B8868[] = +{ + 0, 0xF, 0xFF, 0xFFF, 0xFFFF, 0xFFFFF, 0xFFFFFF, 0xFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFF0, 0xFFFFFF00, 0xFFFFF000, 0xFFFF0000, + 0xFFF00000, 0xFF000000, 0xF0000000 +}; + +static void AddUnderScoreHighlightInternal(Window *windows, u32 windowId, s32 x, s32 y, s32 width, u32 color); +static void DisplayMonPortrait(Window *a0, u16 a1[32][32], s32 a2, const u8 *compressedData, u32 a4); +static void DisplayMonPortraitFlipped(Window *windows, s32 windowId, const u8 *compressedData, s32 a3); +static u32 FlipPixelsHorizontally(u32 a0); +static s32 HexDigitValue(u8 chr); +static void nullsub_129(u32 windowId, s32 x, s32 y, s32 width, u32 color); +static void sub_8007AA4(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, u32 color); +static void sub_8007BA8(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, s32 color); +static void sub_8007D00(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, s32 color); +static void sub_8007E64(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 *a7, u32 a8); +static void sub_8008030(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 *a7, u32 a8); +static void sub_8008334(u32 *r7, u32 *r12); +static void sub_80084A4(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 a8); +static void sub_8008818(Window *windows, s32 windowId, s32 a2, s32 a3, s32 a4, s32 a5); +static bool8 xxx_update_bg_vram(Window *windows); + +// TODO: Find these funcs in blue. DTCM funcs + +// In NDS, this func is copied to 01FF9F34 +u32 xxx_call_draw_char(s32 x, s32 y, u32 a2, u32 color, u32 a4) +{ + return xxx_draw_char(gWindows, x, y, a2, color, a4); +} + +UNUSED static bool8 sub_8007464(void) +{ + return FALSE; +} + +// In NDS, this func is copied to 01FF994C +u32 xxx_draw_char(Window *windows, s32 x, s32 y, u32 a3, u32 color, u32 windowId) +{ + u32 *r3; + const unkShiftData *shiftData; + const unkChar *sp0; + const u16 *local_44; + const u16 *sp8; + const u16 *local_3c; + s32 i; + s32 xDiv8, yDiv8; + Window *window = &windows[windowId]; + s32 sp18 = gUnknown_80B853C[color & 0xF]; + u8 var_2C; + u32 r4; + u32 r2; + + if (gCurrentCharmap == 1) { + if (a3 == 0x70 || a3 == 0x6A || a3 == 0x71 || a3 == 0x79 || a3 == 0x67) + y += 2; + else if (a3 == 0x8199) + y -= 2; + } + + sp0 = GetCharacter(a3); + local_44 = sp0->unk0; + ASM_MATCH_TRICK(local_3c); // stack doesn't match without it + local_3c = sp0->unk0; + sp8 = sp0->unk0 - 3; + + if (gDrawTextShadow != 0) { + var_2C = (sp0->unkA >> 1) & 1; + } + else { + var_2C = 0; + } + + if (sp0->unkA & 1) { + r3 = window->unk18 + ((((y / 8) * window->width) + (x / 8)) * 8); + r3 += y - (y / 8 * 8); + shiftData = &gCharMasksOffsets[x - ((x / 8) * 8)]; + xDiv8 = x / 8; + yDiv8 = y / 8; + + if (yDiv8 < window->unk8) { + for (i = 0; i < gCharHeight[gCurrentCharmap]; i++) { + r2 = (local_44[1] << 0x10) | (local_44[0]); + if (r2 != 0) { + if (xDiv8 < window->width) { + *r3 |= (shiftData->bytesA & r2) << shiftData->shift_left; + if (window->unk3C > r3) + window->unk3C = r3; + if (window->unk40 < r3) + window->unk40 = r3; + } + if (xDiv8 < window->width - 1) { + r3 += 8; + r2 &= shiftData->bytesB; + *r3 |= (r2) >> shiftData->shift_right; + if (window->unk40 < r3) + window->unk40 = r3; + r3 -= 8; + } + } + + r2 = local_44[2]; + if (r2 != 0) { + if (xDiv8 < window->width - 1) { + r3 += 8; + *r3 |= (r2 & shiftData->bytesA) << shiftData->shift_left; + if (window->unk40 < r3) + window->unk40 = r3; + r3 -= 8; + } + if (xDiv8 < window->width - 2) { + r3 += 16; + *r3 |= (r2 & shiftData->bytesB) >> shiftData->shift_right; + if (window->unk40 < r3) + window->unk40 = r3; + r3 -= 16; + } + } + + local_44 += 3; + r3++; + y++; + if (y % 8 == 0) { + r3 += window->unk20; + yDiv8++; + if (yDiv8 >= window->unk8) + break; + } + } + } + } + else { + bool8 notFirstIteration = FALSE; + u32 r1; + + r3 = window->unk18 + ((((y / 8) * window->width) + (x / 8)) * 8); + r3 += y - (y / 8 * 8); + shiftData = &gCharMasksOffsets[x - ((x / 8) * 8)]; + xDiv8 = x / 8; + yDiv8 = y / 8; + + if (yDiv8 < window->unk8) { + for (i = 0; i < gCharHeight[gCurrentCharmap]; i++) { + r4 = (local_44[1] << 0x10) | (local_44[0]); + r2 = (0x11111111 & r4) + (sp18 & r4); + + if (var_2C != 0) { + r1 = ((local_3c[1] << 0x10) | local_3c[0]) << 4; + r1 |= r4; // This doesn't really do anything since r4 bits are cleared, but it's needed to match. + r1 &= ~(r4); + r1 &= gTextShadowMask; + r2 |= (r1); + if (notFirstIteration) { + r1 = (((sp8[1] << 0x10) | sp8[0]) << 4) ^ r4; + r1 &= ~(r4); + r2 |= (r1 & gTextShadowMask); + } + } + + if (r2 != 0) { + if (xDiv8 < window->width) { + *r3 |= (r2 & shiftData->bytesA) << shiftData->shift_left; + if (window->unk3C > r3) + window->unk3C = r3; + if (window->unk40 < r3) + window->unk40 = r3; + } + if (xDiv8 < window->width - 1) { + r3 += 8; + *r3 |= (r2 & shiftData->bytesB) >> shiftData->shift_right; + if (window->unk40 < r3) + window->unk40 = r3; + r3 -= 8; + } + } + + r4 = local_44[2]; + r2 = (0x11111111 & r4) + (sp18 & r4); + if (var_2C != 0) { + r1 = (local_3c[2] << 4) | ((local_3c[1] >> 0xC) & 0xF); + r1 |= r4; // This doesn't really do anything since r4 bits are cleared, but it's needed to match. + r1 &= ~(r4); + r1 &= gTextShadowMask; + r2 |= r1; + if (notFirstIteration) { + r1 = ((sp8[2] << 4) | ((sp8[1] >> 0xC) & 0xF)) ^ r4; + r1 &= ~(r4); + r1 &= gTextShadowMask; + r2 |= (r1); + } + } + + if (r2 != 0) { + if (xDiv8 < window->width - 1) { + r3 += 8; + *r3 |= (r2 & shiftData->bytesA) << shiftData->shift_left; + if (window->unk40 < r3) + window->unk40 = r3; + r3 -= 8; + } + if (xDiv8 < window->width - 2) { + r3 += 16; + *r3 |= (r2 & shiftData->bytesB) >> shiftData->shift_right; + if (window->unk40 < r3) + window->unk40 = r3; + r3 -= 16; + } + } + + notFirstIteration = TRUE; + local_44 += 3; + sp8 += 3; + local_3c += 3; + r3++; + y++; + if (y % 8 == 0) { + r3 += window->unk20; + yDiv8++; + if (yDiv8 >= window->unk8) + break; + } + } + } + } + + return sp0->unk6 + gCharacterSpacing; +} + +void AddDoubleUnderScoreHighlight(u32 windowId, s32 x, s32 y, s32 width, u32 color) +{ + AddUnderScoreHighlight(windowId, x, y, width, color); + AddUnderScoreHighlight(windowId, x, y + 1, width, gTextShadowMask & 0xF); +} + +UNUSED static void sub_80078E8(u32 a0, s32 x, s32 y, s32 a3, u32 color) +{ + nullsub_129(a0, x, y, a3, color); + nullsub_129(a0, x, y + 1, a3, gTextShadowMask & 0xF); +} + +void AddUnderScoreHighlight(u32 windowId, s32 x, s32 y, s32 width, u32 color) +{ + AddUnderScoreHighlightInternal(gWindows, windowId, x, y, width, color); +} + +static void nullsub_129(u32 windowId, s32 x, s32 y, s32 width, u32 color) +{ +} + +static void AddUnderScoreHighlightInternal(Window *windows, u32 windowId, s32 x, s32 y, s32 width, u32 color) +{ + u32 uVar4; + u32 *dest; + s32 r4; + const unkShiftData *shiftData; + Window *window; + s32 r6; + u32 r9; + + window = &windows[windowId]; + r9 = gUnknown_80B853C[color & 0xF]; + + r4 = y / 8; + + dest = window->unk18 + (((window->width * r4) + (x / 8)) * 8); + dest += (r4 * -8) + y; + r6 = x / 8; + + if (y / 8 >= window->unk8) { + return; + } + else { + const u32 unkBits[] = {0, 0xF, 0xFF, 0xFFF, 0xFFFF, 0xFFFFF, 0xFFFFFF, 0xFFFFFFF, 0xFFFFFFFF}; + + for (; width > 0; width -= 8) { + s32 currWidth = width; + if (currWidth > 7) + currWidth = 8; + + shiftData = &gCharMasksOffsets[x + (x / 8 * -8)]; + + uVar4 = unkBits[currWidth]; + uVar4 = (uVar4 & 0x11111111) + (uVar4 & r9); + + if (uVar4 != 0) { + if (r6 < window->width) { + dest[0] |= (shiftData->bytesA & uVar4) << shiftData->shift_left; + + if (window->unk3C > dest) + window->unk3C = dest; + if (window->unk40 < dest) + window->unk40 = dest; + } + + if (r6 < window->width - 1) { + dest += 8; + dest[0] |= (uVar4 & shiftData->bytesB) >> shiftData->shift_right; + + if (window->unk40 < dest) + window->unk40 = dest; + dest -= 8; + } + } + + r6++; + dest += 8; + } + } +} + +void sub_8007A78(u32 a0, s32 x, s32 y, s32 a3, u32 color) +{ + sub_8007AA4(gWindows, a0, x, y, a3, color); +} + +UNUSED static void nullsub_157(void) +{ +} + +static void sub_8007AA4(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, u32 color) +{ + Window *window = &windows[windowId]; + u32 ip = gUnknown_80B853C[color & 0xF] + 0x11111111; + const u32 unkBits[] = {0xF, 0xF0, 0xF00, 0xF000, 0xF0000, 0xF00000, 0xF000000, 0xF0000000}; + s32 r3 = y / 8; + u32 *dest = window->unk18 + ((window->width * r3 + x / 8) * 8); + s32 r2 = x / 8; + + dest += r3 * -8 + y; + ip &= unkBits[x & 7]; + + if (r2 < window->width) { + // This goto looks like a fakematch, but I couldn't get it to work otherwise. + goto LOOP_MIDDLE; + while (1) { + y++; + dest++; + if ((y % 8) == 0) + dest += window->unk20; + a4--; + + LOOP_MIDDLE: + if (a4 <= 0) + return; + if (r3 >= window->unk8) + return; + + dest[0] |= ip; + + if (window->unk3C > dest) + window->unk3C = dest; + if (window->unk40 < dest) + window->unk40 = dest; + } + } +} + +void sub_8007B7C(u32 a0, s32 x, s32 y, s32 a3, u32 color) +{ + sub_8007BA8(gWindows, a0, x, y, a3, color); +} + +UNUSED static void nullsub_158(void) +{ +} + +static void sub_8007BA8(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, s32 color) +{ + u32 *dst; + s32 i; + s32 xDiv8, yDiv8; + s32 j, k; + + Window *window = &windows[windowId]; + yDiv8 = y / 8; + if (yDiv8 >= window->unk8) + return; + + dst = window->unk18 + (((yDiv8 * window->width) + x / 8) * 8); + dst += y - (yDiv8 * 8); + + for (i = 0; i < color; i++) { + u32 *loopDst = dst; + xDiv8 = x / 8; + + for (j = 0; j < a4; j += 8) { + if (xDiv8 < window->width) { + u32 andBits = 0xF0000000; + u32 orBits = 0xE0000000; + u32 bits = 0; + u32 var = *loopDst; + + for (k = 0; k < 8; k++) { + if (!(var & andBits)) + bits |= orBits; + + andBits >>= 4; + orBits >>= 4; + } + + *loopDst |= bits; + if (window->unk3C > loopDst) + window->unk3C = loopDst; + if (window->unk40 < loopDst) + window->unk40 = loopDst; + + xDiv8++; + loopDst += 8; + } + else { + break; + } + } + + y++; + dst++; + if ((y % 8) == 0) { + dst += window->unk20; + yDiv8++; + if (yDiv8 >= window->unk8) + return; + } + } +} + +UNUSED static void sub_8007CD4(u32 a0, s32 a1, s32 a2, s32 a3, s32 a4) +{ + sub_8007D00(gWindows, a0, a1, a2, a3, a4); +} + +UNUSED static void nullsub_159(void) +{ +} + +// Very similar to sub_8007BA8. It clears bits instead of setting them. +static void sub_8007D00(Window *windows, u32 windowId, s32 x, s32 y, s32 a4, s32 color) +{ + u32 *dst; + s32 i; + s32 xDiv8, yDiv8; + s32 j, k; + + Window *window = &windows[windowId]; + yDiv8 = y / 8; + if (yDiv8 >= window->unk8) + return; + + dst = window->unk18 + (((yDiv8 * window->width) + x / 8) * 8); + dst += y - (yDiv8 * 8); + + for (i = 0; i < color; i++) { + u32 *loopDst = dst; + xDiv8 = x / 8; + + for (j = 0; j < a4; j += 8) { + if (xDiv8 < window->width) { + u32 andBits = 0xF0000000; + u32 equalBits = 0xE0000000; + u32 bits = 0; + u32 var = *loopDst; + + for (k = 0; k < 8; k++) { + if ((var & andBits) == equalBits) + bits |= andBits; + + andBits >>= 4; + equalBits >>= 4; + } + + *loopDst &= ~(bits); + if (window->unk3C > loopDst) + window->unk3C = loopDst; + if (window->unk40 < loopDst) + window->unk40 = loopDst; + + xDiv8++; + loopDst += 8; + } + else { + break; + } + } + + y++; + dst++; + if ((y % 8) == 0) { + dst += window->unk20; + yDiv8++; + if (yDiv8 >= window->unk8) + return; + } + } +} + +void sub_8007E20(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 *a5, u32 a6) +{ + sub_8007E64(gWindows, gBgTilemaps[0], a0, a1, a2, a3, a4, a5, a6); +} + +UNUSED static void nullsub_160(void) +{ +} + +static void sub_8007E64(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 *a7, u32 a8) +{ + s32 i, j; + Window *window = &a0[a2]; + + a3 /= 8; + a4 /= 8; + a5 /= 8; + a6 /= 8; + a8 *= 4096; + if (a4 < window->unk8) { + s32 id = (window->width * a4) + a3; + u32 *unk18Ptr = &window->unk18[id * 8]; + + for (i = 0; i < a6; i++) { + s32 xMaybe = a3; + u32 *loopUnk18Ptr = unk18Ptr; + for (j = 0; j < a5; j++) { + if (xMaybe < window->width) { + if (window->unk3C > loopUnk18Ptr) { + window->unk3C = loopUnk18Ptr; + } + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *a7; + if (window->unk40 < loopUnk18Ptr) { + window->unk40 = loopUnk18Ptr; + } + a7++; + a1[window->y + a4][window->x + xMaybe] &= 0xFFF; + a1[window->y + a4][window->x + xMaybe] |= a8; + } + else { + loopUnk18Ptr += 8; + a7 += 8; + } + xMaybe++; + } + a4++; + unk18Ptr += window->unk20; + unk18Ptr += 8; + if (a4 >= window->unk8) + break; + } + } +} + +static u32 FlipPixelsHorizontally(u32 a0) +{ + u32 r0; + + r0 = (a0 >> 28) & 0xF; + r0 |= (a0 >> 20) & 0xF0; + r0 |= (a0 >> 12) & 0xF00; + r0 |= (a0 >> 4) & 0xF000; + r0 |= (a0 << 4) & 0xF0000; + r0 |= (a0 << 12) & 0xF00000; + r0 |= (a0 << 20) & 0xF000000; + r0 |= (a0 << 28) & 0xF0000000; + + return r0; +} + +UNUSED static void sub_8007FEC(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 *a5, u32 a6) +{ + sub_8008030(gWindows, gBgTilemaps[0], a0, a1, a2, a3, a4, a5, a6); +} + +UNUSED static void nullsub_161(void) +{ +} + +// Similar to sub_8007E64 +static void sub_8008030(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 *a7, u32 a8) +{ + s32 i, j; + Window *window = &a0[a2]; + + a3 /= 8; + a4 /= 8; + a5 /= 8; + a6 /= 8; + a8 *= 4096; + if (a4 < window->unk8) { + u32 *unk18Ptr = &window->unk18[((window->width * a4) + (a3 + a5)) * 8]; + for (i = 0; i < a6; i++) { + s32 xMaybe = a3 + a5; + u32 *loopUnk18Ptr = unk18Ptr; + for (j = 0; j < a5; j++) { + xMaybe--; + loopUnk18Ptr -= 8; + if (xMaybe < window->width) { + if (window->unk3C > loopUnk18Ptr) { + window->unk3C = loopUnk18Ptr; + } + loopUnk18Ptr[0] = FlipPixelsHorizontally(*(a7++)); + loopUnk18Ptr[1] = FlipPixelsHorizontally(*(a7++)); + loopUnk18Ptr[2] = FlipPixelsHorizontally(*(a7++)); + loopUnk18Ptr[3] = FlipPixelsHorizontally(*(a7++)); + loopUnk18Ptr[4] = FlipPixelsHorizontally(*(a7++)); + loopUnk18Ptr[5] = FlipPixelsHorizontally(*(a7++)); + loopUnk18Ptr[6] = FlipPixelsHorizontally(*(a7++)); + loopUnk18Ptr[7] = FlipPixelsHorizontally(*(a7++)); + if (window->unk40 < loopUnk18Ptr + 8) { + window->unk40 = loopUnk18Ptr + 8; + } + a1[window->y + a4][window->x + xMaybe] &= 0xFFF; + a1[window->y + a4][window->x + xMaybe] |= a8; + } + else { + a7 += 8; + } + } + a4++; + unk18Ptr += window->unk20; + unk18Ptr += 8; + if (a4 >= window->unk8) + break; + } + } +} + +// Similar to sub_8007E64 +UNUSED static void sub_80081A4(s32 a0, s32 a3, s32 a4, s32 a7Id) +{ + s32 i, j, a5, a6; + Window *window = &gWindows[a0]; + const u32 *a7 = gUnknown_80B86B4[a7Id]; + + a3 /= 8; + a4 /= 8; + a5 = 2; + a6 = 2; + if (a4 < window->unk8) { + s32 id = (window->width * a4) + a3; + u32 *unk18Ptr = &window->unk28[id * 8]; + + for (i = 0; i < a6; i++) { + s32 xMaybe = a3; + u32 *loopUnk18Ptr = unk18Ptr; + for (j = 0; j < a5; j++) { + if (xMaybe < window->width) { + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *(a7++); + *(loopUnk18Ptr++) = *a7; + a7++; + } + else { + loopUnk18Ptr += 8; + a7 += 8; + } + xMaybe++; + } + a4++; + unk18Ptr += window->unk20; + unk18Ptr += 8; + if (a4 >= window->unk8) + break; + } + } +} + +void DisplayMonPortraitSprite(s32 a0, const u8 *compressedData, s32 a2) +{ + DisplayMonPortrait(gWindows, gBgTilemaps[0], a0, compressedData, a2); +} + +UNUSED static void nullsub_162(void) +{ +} + +static void DisplayMonPortrait(Window *a0, u16 a1[32][32], s32 a2, const u8 *compressedData, u32 a4) +{ + s32 i, j; + Window *window = &a0[a2]; + + a4 *= 4096; + DecompressAT((u8 *)window->unk18, (window->width * 32) * window->unk8, compressedData); + for (i = 0; i < window->unk8; i++) { + for (j = 0; j < window->width; j++) { + a1[window->y + i][window->x + j] &= 0xFFF; + a1[window->y + i][window->x + j] |= a4; + } + } + window->unk30 = window->unk28; + window->unk34 = window->unk1C; + window->unk38 = window->unk2C; + window->unk44 = 1; +} + +static void sub_8008334(u32 *r7, u32 *r12) +{ + s32 i; + u32 r2, r3; + u32 r4, r1; + + r4 = *r7; + r1 = *r12; + + r3 = 0; + r2 = 0; + + for (i = 0; i < 32; i += 4) { + r2 <<= 4; + r3 <<= 4; + r2 |= r4 & 0xF; + r3 |= r1 & 0xF; + r4 >>= 4; + r1 >>= 4; + } + *r7 = r3; + *r12 = r2; +} + +void DisplayMonPortraitSpriteFlipped(s32 a0, const u8 *compressedData, s32 a1) +{ + DisplayMonPortraitFlipped(gWindows, a0, compressedData, a1); +} + +UNUSED static void nullsub_163(void) +{ +} + +static void DisplayMonPortraitFlipped(Window *windows, s32 windowId, const u8 *compressedData, s32 a3) +{ + s32 i, j; + Window *window = &windows[windowId]; + + DisplayMonPortraitSprite(windowId, compressedData, a3); + for (i = 0; i < window->unk8; i++) { + s32 r8 = window->width / 2; + if (window->width & 1) + r8++; + for (j = 0; j < r8; j++) { + u32 *r4, *r5; + s32 unk4Mul = window->width * i; + + r4 = &window->unk18[(unk4Mul + j) * 8]; + unk4Mul--; + r5 = &window->unk18[(unk4Mul + (window->width - j)) * 8]; + + sub_8008334(r4++, r5++); + sub_8008334(r4++, r5++); + sub_8008334(r4++, r5++); + sub_8008334(r4++, r5++); + sub_8008334(r4++, r5++); + sub_8008334(r4++, r5++); + sub_8008334(r4++, r5++); + sub_8008334(r4++, r5++); + } + } +} + +UNUSED static void sub_8008468(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 a6) +{ + sub_80084A4(gWindows, gBgTilemaps[0], a0, a1, a2, a3, a4, a6); +} + +UNUSED static void nullsub_164(void) +{ +} + +// Effectively unused +static void sub_80084A4(Window *a0, u16 a1[32][32], u32 a2, s32 a3, s32 a4, s32 a5, s32 a6, u32 a8) +{ + s32 i, j; + Window *window = &a0[a2]; + + a3 /= 8; + a4 /= 8; + a5 /= 8; + a6 /= 8; + a8 *= 4096; + if (a4 < window->unk8) { + for (i = 0; i < a6; i++) { + s32 xMaybe = a3; + for (j = 0; j < a5; j++) { + if (xMaybe < window->width) { + a1[window->y + a4][window->x + xMaybe] &= 0xFFF; + a1[window->y + a4][window->x + xMaybe] |= a8; + } + xMaybe++; + } + a4++; + if (a4 >= window->unk8) + break; + } + } +} + +// Oddly similar to sub_803DEC8 +// In NDS, this func is copied to 01FF8E40 +const unkChar *GetCharacter(s32 chr) +{ + s32 r2, r4; + const unkChar *ret; + const unkChar *strPtr = gCharmaps[gCurrentCharmap]->unk4; + // TODO: create labels for these + if (chr > 63487 && chr < 65535) + { + s32 r2 = chr & 0xFF; + s32 r1 = (chr & 0xFF00) >> 8; + r2 -= 32; + r1 -= 248; + ret = &strPtr[r1 * 224 + r2]; + } + else + { + r4 = 0; + r2 = gCharmaps[gCurrentCharmap]->unk0 - 1; + while (r4 < r2) { + s32 r1 = (r4 + r2) / 2; + if (strPtr[r1].unk4 == chr) { + r4 = r1; + break; + } + else if (strPtr[r1].unk4 < chr) { + r4 = r1 + 1; + } + else { + r2 = r1; + } + } + + ret = &strPtr[r4]; + if (ret->unk4 != chr) + ret = &gUnknown_80B86A4; + + } + return ret; +} + +static s32 HexDigitValue(u8 chr) +{ + if (chr >= '0' && chr <= '9') + return chr - '0'; + else if (chr >= 'a' && chr <= 'f') + return (chr - 'a') + 10; + else + return 1; +} + +// In NDS, this func is copied to 01FF8D80 +const u8 *xxx_get_next_char_from_string(const u8 *a1, u32 *a0) +{ + s32 currChr = *a1; + if (currChr == 0x7E) { + s32 hexDigit; + + a1++; + hexDigit = (HexDigitValue(a1[0]) << 4) + HexDigitValue(a1[1]); + if (*a1 != '\0') { + a1++; + if (*a1 != '\0') { + a1++; + } + } + *a0 = hexDigit; + return a1; + } + else if ((currChr >= 0x81 && currChr <= 0x84) || currChr == 0x87) { + *a0 = a1[1] | (a1[0] << 8); + return a1 + 2; + } + else { + *a0 = currChr; + return a1 + 1; + } +} + +UNUSED static void nullsub_165(void) +{ +} + +UNUSED static void nullsub_166(void) +{ +} + +UNUSED static void nullsub_167(void) +{ +} + +UNUSED static void nullsub_168(void) +{ +} + +UNUSED static void sub_80086C8(Window *windows, s32 windowId, s32 a2, s32 a3, s32 a4, s32 a5) +{ + u32 *r5; + s32 r2, r0, r1; + Window *window = &windows[windowId]; + + if (a2 < 0) { + a4 += a2; + a2 = 0; + } + if (a3 < 0) { + a5 += a3; + a3 = 0; + } + + if (a4 + a2 > window->width * 8) { + a4 = (window->width * 8) - a2; + } + if (a3 + a5 > window->unk8 * 8) { + a5 = (window->unk8 * 8) - a3; + } + + r2 = window->width * (a3 / 8); + r0 = 8 * (r2 + (a2 / 8)); + r1 = a3 - ((a3 / 8) * 8); + r5 = &window->unk18[r0 + r1]; + while (a5 > 0) { + u32 *loopPtr; + s32 r4, r6; + + loopPtr = r5; + r4 = a4; + r6 = a2; + if (window->unk3C > r5) { + window->unk3C = r5; + } + + while (r4 > 0) { + s32 r3; + if (r4 < 8) { + r3 = r4; + *loopPtr &= sUnknown_80B8868[(r4 & 7) + 8]; + } + else if ((r6 & 7) != 0) { + r3 = 8 - (r6 & 7); + *loopPtr &= sUnknown_80B8868[r6 & 7]; + } + else { + r3 = 8; + *loopPtr = r6 & 7; + } + + loopPtr += 8; + r4 -= r3; + r6 += r3; + } + a5--; + a3++; + if (window->unk40 < r5) { + window->unk40 = r5; + } + r5++; + if (!(a3 & 7)) { + r5 = &r5[window->unk20]; + } + } +} + +void sub_80087EC(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4) +{ + sub_8008818(gWindows, a0, a1, a2, a3, a4); +} + +UNUSED static void nullsub_176(void) +{ +} + +static void sub_8008818(Window *windows, s32 windowId, s32 a2, s32 a3, s32 a4, s32 a5) +{ + s32 i, j; + Window *window = &windows[windowId]; + s32 a2Div = a2 / 8; + s32 a3Div = a3 / 8; + + for (i = 0; i < a5; i += 8) { + u32 *ptr = &window->unk18[((window->width * a3Div) + a2Div) * 8]; + for (j = 0; j < a4; j += 8) { + if (window->unk3C > ptr) { + window->unk3C = ptr; + } + *(ptr++) = 0; + *(ptr++) = 0; + *(ptr++) = 0; + *(ptr++) = 0; + *(ptr++) = 0; + *(ptr++) = 0; + *(ptr++) = 0; + *ptr = 0; + if (window->unk40 < ptr) { + window->unk40 = ptr; + } + ptr++; + } + a3Div++; + } +} + +// Might be copied to 01FF86B8 in NDS +bool8 xxx_call_update_bg_vram(void) +{ + bool8 ret = FALSE; + if (gUnknown_20274A5 != 0) { + gUnknown_20274A5 = FALSE; + sub_80099C0(); + } + ret = xxx_update_bg_vram(gWindows); + return ret; +} + +static bool8 xxx_update_bg_vram(Window *windows) +{ + s32 i, j; + u32 r5; + bool8 ret = FALSE; + + for (i = 0; i < MAX_WINDOWS; i++) { + Window *window = &windows[i]; + if (window->width == 0) + continue; + r5 = window->unk38; + if (r5 == 0) + continue; + + if (window->unk45) { + u32 *r2, *r1; + + CpuCopy(window->unk28, window->unk18, 0xD00); + // The reason for void casts is because we want to add 0xD00/r5 directly to pointers. Because pointers are u32, without the casts, it would multiply the value by 4. + r2 = (void *)(window->unk18) + 0xD00; + r1 = (void *)(window->unk28) + 0xD00; + for (j = 0; j < window->width; j++) { + *(r1++) = *(r2++); + *(r1++) = *(r2++); + *(r1++) = *(r2++); + *(r1++) = *(r2++); + *(r1++) = *(r2++); + *(r1++) = 0xDDDDDDDD; + *(r1++) = 0xEEEEEEEE; + *(r1++) = 0xFFFFFFFF; + r2 += 3; + } + window->unk38 = 0; + } + else { + CpuCopy(window->unk30, window->unk34, r5); + window->unk34 += (r5 / 4); + window->unk30 = (void *)(window->unk30) + r5; + window->unk38 -= r5; + } + + if (window->unk38 == 0) { + window->unk44 = 0; + } + ret = TRUE; + } + + return ret; +} + +void ResetWindowBgData(void) +{ + s32 i; + + for (i = 0; i < ARRAY_COUNT_INT(gUnknown_3000E94); i++) { + gUnknown_3000E94[i] = 0xF0F0; + } +} + +void sub_80089AC(const WindowTemplate *r4, DungeonPos *r5_Str) +{ + u8 *r6; + + if (r4->unk0 & 0x40) + return; + + r6 = (u8*) gUnknown_3000E94; + if (r4->type == WINDOW_TYPE_WITHOUT_BORDER) { + s32 r12 = (r4->pos.x + r5_Str->x) * 8; + s32 r5 = (r4->pos.y + r5_Str->y) * 8; + s32 r7 = (r4->pos.x + r5_Str->x + r4->width) * 8; + s32 r2 = (r4->pos.y + r5_Str->y + r4->height) * 8; + if (r4->height != 0) { + if (r5 < 0) + r5 = 0; + if (r2 < 0) + r2 = 0; + if (r5 > 160) + r5 = 160; + if (r2 > 160) + r2 = 160; + while (r5 < r2) { + s32 id = r5 * 2; + if (r6[id] == 240 && r6[id + 1] == 240) { + r6[id++] = r7; + r6[id] = r12; + } + else { + if (r6[id] < r7) { + r6[id] = r7; + } + id++; + if (r6[id] > r12) { + r6[id] = r12; + } + } + r5++; + } + } + } + else if (r4->type == WINDOW_TYPE_WITH_HEADER) { + s32 i; + s32 r9 = ((r4->pos.x + r5_Str->x) * 8) - 5; + s32 r5 = ((r4->pos.y + r5_Str->y) * 8) - 4; + s32 var_24 = ((r4->pos.x + r5_Str->x + r4->width) * 8) + 5; + s32 r8 = ((r4->pos.y + r5_Str->y + r4->height) * 8) + 5; + s32 r12 = ((r4->pos.x + r5_Str->x) * 8) + 3; + const WindowHeader *r2 = r4->header; + s32 tmp = r2->width - 1; + s32 r10 = (((tmp + r2->count + 2) * 8) + r12) - 4; + s32 r4 = r9 + ((r2->currId + 1) * 8); + s32 r7 = (r4 + ((r2->width + 2) * 8)) - 4; + + if (r5 < 0) + r5 = 0; + if (r8 < 0) + r8 = 0; + if (r5 > 160) + r5 = 160; + if (r8 > 160) + r8 = 160; + + for (i = 0; i < 4; i++) { + s32 id = r5 * 2; + if (r6[id] == 240 && r6[id + 1] == 240) { + r6[id++] = r7; + r6[id] = r4; + } + else { + if (r6[id] < r7) { + r6[id] = r7; + } + id++; + if (r6[id] > r4) { + r6[id] = r4; + } + } + r5++; + } + for (i = 0; i < 8; i++) { + s32 id = r5 * 2; + if (r6[id] == 240 && r6[id + 1] == 240) { + r6[id++] = r10; + r6[id] = r12; + } + else { + if (r6[id] < r10) { + r6[id] = r10; + } + id++; + if (r6[id] > r12) { + r6[id] = r12; + } + } + r5++; + } + + while (r5 < r8) { + s32 id = r5 * 2; + if (r6[id] == 240 && r6[id + 1] == 240) { + r6[id++] = var_24; + r6[id] = r9; + } + else { + if (r6[id] < var_24) { + r6[id] = var_24; + } + id++; + if (r6[id] > r9) { + r6[id] = r9; + } + } + r5++; + } + } + else { + s32 r8 = ((r4->pos.x + r5_Str->x) * 8) - 5; + s32 r3 = ((r4->pos.y + r5_Str->y) * 8) - 5; + s32 r12 = ((r4->pos.x + r5_Str->x + r4->width) * 8) + 5; + s32 r5 = ((r4->pos.y + r5_Str->y + r4->height) * 8) + 5; + if (r4->height != 0) { + if (r4->type == 0) { + r3 += 8; + r5 = ((r4->pos.y + r5_Str->y + r4->height) * 8) - 3; + } + if (r3 < 0) + r3 = 0; + if (r5 < 0) + r5 = 0; + if (r3 > 160) + r3 = 160; + if (r5 > 160) + r5 = 160; + while (r3 < r5) { + s32 id = r3 * 2; + if (r6[id] == 240 && r6[id + 1] == 240) { + r6[id++] = r12; + r6[id] = r8; + } + else { + if (r6[id] < r12) { + r6[id] = r12; + } + id++; + if (r6[id] > r8) { + r6[id] = r8; + } + } + r3++; + } + } + } +} + +void CallPrepareTextbox_8008C54(u32 strId) +{ + PrepareTextbox_8008C6C(gWindows, strId); +} + +UNUSED static void nullsub_169(void) +{ +} + +// Copied to 01ff8000 in NDS +void PrepareTextbox_8008C6C(Window *windows, u32 windowId) +{ + s32 i; + Window *window = &windows[windowId]; + + if (!window->unk45) { + s32 count = (window->width * window->unk8) * 32; + for (i = 0; i < count; i += 32) { + CpuClear(&window->unk18[i / 4u], 32); + } + } + else { + s32 count = (window->width * (window->unk8 - 1)) * 32; + u32 *ptr = window->unk18; + for (i = 0; i < window->width; i++) { + *(ptr++) = 0xFFFFFFFF; + *(ptr++) = 0xEEEEEEEE; + *(ptr++) = 0xDDDDDDDD; + *(ptr++) = 0; + *(ptr++) = 0; + *(ptr++) = 0; + *(ptr++) = 0; + *(ptr++) = 0; + } + for (i = 0; i < count; i += 32) { + CpuClear(ptr, 32); + ptr += 8; + } + } + + if (window->type == WINDOW_TYPE_WITH_HEADER) { + window->unk46 = 1; + AddUnderScoreHighlightInternal(windows, windowId, 0, 10, window->width * 8, 14); + AddUnderScoreHighlightInternal(windows, windowId, 0, 11, window->width * 8, 13); + window->unk46 = 0; + } + + window->unk30 = window->unk28; + window->unk34 = window->unk1C; + window->unk38 = window->unk2C; + window->unk44 = 1; +} diff --git a/src/text_3.c b/src/text_3.c new file mode 100644 index 000000000..4bdc2842c --- /dev/null +++ b/src/text_3.c @@ -0,0 +1,546 @@ +#include "global.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" + +static const u8 *HandleTextFormat(Window *windows, const u8 *str, UnkDrawStringStruct *sp); +static s32 InterpretColorChar(u8 a0); +static const u8 *sub_800915C(s16 *a0, const u8 *str); +static void xxx_draw_string(Window *strArr, s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 characterSpacing, s32 lineSpacing); + +// arm9.bin::02003D4C +bool8 sub_8008D8C(s32 windowId) +{ + Window *strPtr = &gWindows[windowId]; + return strPtr->unk38 != 0; +} + +#if (GAME_VERSION == VERSION_RED) +UNUSED static bool8 sub_8008DA8(void) +{ + return FALSE; +} + +UNUSED static void sub_8008DAC(s32 a0, s32 a1, s32 a2) +{ + gBgTilemaps[0][a1][a0] = a2; + gUnknown_20274A5 = TRUE; +} +#endif + +// Maybe arm9.bin::02003D08 +void sub_8008DC8(s32 x, s32 y, u16 bg0Val, u16 bg1Val) +{ + gBgTilemaps[0][y][x] = bg0Val; + gBgTilemaps[1][y][x] = bg1Val; + gUnknown_20274A5 = TRUE; +} + +// Maybe arm9.bin::02003C88 +UNUSED static void sub_8008DF4(s32 x, s32 y, u8 *src) +{ + u8 r1; + + while (TRUE) { + if (*src == 0) + break; + + r1 = *src; + if (r1 >= 97 && r1 <= 122) + r1 -= 32; + + gBgTilemaps[0][y][x] = TILEMAP_PAL(15) | (r1 + 0x258); + src++; + x++; + } + gUnknown_20274A5 = TRUE; +} + +#if (GAME_VERSION == VERSION_RED) +UNUSED static void sub_8008E58(s32 a0, s32 a1, u8 *a2, s32 a3) +{ + u8 r1; + + while (TRUE) { + if (*a2 == 0) + break; + + r1 = *a2; + if (a3 == 0) + break; + + if (r1 >= 97 && r1 <= 122) + r1 -= 32; + + gBgTilemaps[0][a1][a0] = TILEMAP_PAL(15) | (r1 + 0x258); + a2++; + a0++; + a3--; + } + gUnknown_20274A5 = TRUE; +} +#endif + +// arm9.bin::02003B34 +s32 sub_8008ED0(const u8 *str) +{ + s32 ret = 0; + + while (TRUE) { + const u8 *strPtr; + u32 chr; + + strPtr = xxx_get_next_char_from_string(str, &chr); + str = strPtr; + if (chr == '\0') + break; + if (chr == '\r' || chr == '\n') + break; + if (chr == 0x82A0 || chr == 0x82A2) + continue; + if (chr == '\e') + break; + + if (chr == '#') { + if (*strPtr == 'n' || *strPtr == '[' || *strPtr == 'P') + break; + switch (*strPtr) { + case '=': + case '~': + str = strPtr + 2; + break; + case 'C': + case 'c': + str += 2; + break; + case 'R': + case 'r': + str++; + break; + case '+': + case 'W': + str = strPtr + 1; + break; + } + } + else if (chr == '`') { + ret += 6; + } + else { + const unkChar *ptr = GetCharacter(chr); + if (ptr != NULL) { + ret += ptr->unk6 + gCharacterSpacing; + } + } + } + + return ret; +} + +// arm9.bin::02003AE8 +void PrintStringOnWindow2(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 lineSpacing) +{ + xxx_draw_string(gWindows, x, y, str, windowId, terminatingChr, 0, lineSpacing); +} + +// arm9.bin::02003A9C +void PrintStringOnWindow(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr) +{ + xxx_draw_string(gWindows, x, y, str, windowId, terminatingChr, 0, 13); +} + +// arm9.bin::02003A50 +UNUSED static void nullsub_170(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr) +{ + // 2nd version of the above func, with gSubWindows +} + +#if (GAME_VERSION == VERSION_RED) +// Identical to PrintStringOnWindow +UNUSED static void UnusedPrintStringOnWindow(s32 x, u32 y, const u8 *str, u32 windowId, u32 terminatingChr) +{ + xxx_draw_string(gWindows, x, y, str, windowId, terminatingChr, 0, 13); +} + +UNUSED static void nullsub_171(void) +{ +} +#endif + +// arm9.bin::020038A4 +static void xxx_draw_string(Window *strArr, s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 characterSpacing, s32 lineSpacing) +{ + UnkDrawStringStruct sp; + u32 currChr; + + sp.unk0 = x; + sp.unk2 = y; + sp.unkC = x; + sp.unk10 = 7; + while (TRUE) { + str = HandleTextFormat(strArr, str, &sp); + str = xxx_get_next_char_from_string(str, &currChr); + if (currChr == '\0' || currChr == terminatingChr) + break; + + if (currChr == 0x82A0) { + gCurrentCharmap = 0; + } + else if (currChr == 0x82A2) { + gCurrentCharmap = 1; + } + else if (currChr == '\e') { + break; + } + else if (currChr == '\r' || currChr == '\n') { + sp.unk0 = sp.unkC; + sp.unk2 += lineSpacing; + } + else if (currChr == '\x1D') { // ASCII group separator. + sp.unk0 = sp.unkC; + sp.unk2 += 5; + } + else if (currChr == '`') { + sp.unk0 += 6; + } + else if (characterSpacing == 0) { + sp.unk0 += xxx_draw_char(strArr, sp.unk0, sp.unk2, currChr, sp.unk10, windowId); + } + else { + const unkChar *chrPtr = GetCharacter(currChr); + if (chrPtr != NULL) { + s32 x = sp.unk0; + s32 x2 = gCharacterSpacing + 10; + x +=((x2 - chrPtr->unk6) / 2); + xxx_draw_char(strArr, x, sp.unk2, currChr, sp.unk10, windowId); + sp.unk0 += characterSpacing; + } + } + } +} + +// arm9.bin::02003864 +static const u8 *sub_800915C(s16 *a0, const u8 *str) +{ + s32 a = 0; + + while (TRUE) + { + if (*str == '.') { + str++; + break; + } + else if (*str >= '0' && *str <= '9') { + a *= 10; + a += (*str - '0'); + str++; + } + else { + break; + } + } + + *a0 = a; + return str; +} + +// arm9.bin::02003844 +const u8 *xxx_handle_format_global(const u8 *str, UnkDrawStringStruct *unkStrPtr) +{ + return HandleTextFormat(gWindows, str, unkStrPtr); +} + +#if (GAME_VERSION == VERSION_RED) +UNUSED static s32 sub_80091A8(s32 a0) +{ + return a0 + 1; +} +#endif + +// arm9.bin::02003514 +static const u8 *HandleTextFormat(Window *windows, const u8 *str, UnkDrawStringStruct *sp) +{ + while (TRUE) { + if (str[0] == '#') { + if (str[1] == '[') { + const u8 *strBefore = str; + str += 2; + sp->unk21 = 0; + while (*str != '\0') { + if (*str == ']') { + str++; + break; + } + str++; + } + if (sp->unk24 != NULL) { + const u8 *strNew = sp->unk24(strBefore, str, sp); + if (strNew != NULL) + str = strNew; + } + + if (sp->unk21 != 0) + break; + } + else if (str[1] == '=') { + sp->unk0 = str[2]; + str += 3; + if (*str == '.') + str++; + } + else if (str[1] == 'y') { + sp->unk2 = str[2]; + str += 3; + if (*str == '.') + str++; + } + else if (str[1] == '>') { + str = sub_800915C(&sp->unk0, str + 2); + } + else if (str[1] == '.') { + sp->unk0 += str[2]; + str += 3; + } + else if (str[1] == 'n') { + sp->unk0 = sp->unkC; + sp->unk2 += 11; + str += 2; + } + else if (str[1] == ':') { + sp->unk4 = sp->unk0; + str += 2; + } + else if (str[1] == ';') { + sp->unk0 = sp->unk4 + str[2]; + str += 3; + } + else if (str[1] == '+') { + str += 2; + sp->unk0 = (windows[0].width * 8) - sub_8008ED0(str); + sp->unk0 /= 2; + } + else if (str[1] == 'C') { + sp->unk14 = sp->unk10; + sp->unk10 = InterpretColorChar(str[2]); + str += 3; + } + else if (str[1] == '_') { + sp->unk14 = sp->unk10; + sp->unk10 = gUnknown_202749A[str[2]]; + str += 3; + if (*str == '.') + str++; + } + else if (str[1] == 'R') { + sp->unk10 = sp->unk14; + str += 2; + } + else if (str[1] == 'c') { + sp->unk18 = sp->unk10; + sp->unk10 = InterpretColorChar(str[2]); + str += 3; + } + else if (str[1] == 'r') { + sp->unk10 = sp->unk18; + str += 2; + } + else if (str[1] == 'S') { + gUnknown_20274A6[str[2] & 0x7F] = str[3] & 0x7F; + str += 4; + } + else if (str[1] == 'W') { + str += 2; + sp->unk8 = ((windows[0].x * 8) + sp->unk0) - 2; + sp->unkA = ((windows[0].y * 8) + sp->unk2) + 3; + sp->unk20 = 1; + break; + } + else if (str[1] == 'P') { + str += 2; + sp->unk2 = 9999; + sp->unk1C = 0; + sp->unk20 = 1; + break; + } + else if (str[1] == 'p') { + str += 2; + sp->unk2 = 9999; + sp->unk1C = 1; + sp->unk20 = 1; + break; + } + else if (str[1] == '~') { + sp->unk2C = str[2]; + sp->unk21 = 1; + str += 3; + } + else { + return str; + } + } + else { + break; + } + } + + return str; +} + +// arm9.bin::0200347C +void sub_8009388(void) +{ + s32 i, j; + + gBgTilemaps[0][0][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x279); + gBgTilemaps[1][0][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); + for (i = gUnknown_202B020; i < gUnknown_202B024; i++) { + gBgTilemaps[0][i][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x279); + gBgTilemaps[1][i][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); + for (j = 1; j < 32; j++) { + gBgTilemaps[0][i][j] = 0; + gBgTilemaps[1][i][j] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); + } + } +} + +#if (GAME_VERSION == VERSION_BLUE) +// Blue has an extra func: arm9.bin::02003410 +#endif + +// arm9.bin::02003380 +void sub_8009408(s32 from, s32 to) +{ + s32 i, j; + + gBgTilemaps[0][0][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x279); + gBgTilemaps[1][0][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); + for (i = from; i < to; i++) { + gBgTilemaps[0][i][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x279); + gBgTilemaps[1][i][0] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); + for (j = 1; j < 32; j++) { + gBgTilemaps[0][i][j] = 0; + gBgTilemaps[1][i][j] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); + } + } + gUnknown_20274A5 = TRUE; +} + +#if (GAME_VERSION == VERSION_RED) +UNUSED static void sub_8009488(s32 windowId) +{ + s32 i, j; + s32 y, x; + Window *window = &gWindows[windowId]; + + y = window->y; + for (i = 0; i < window->height; i++) { + x = window->x; + for (j = 0; j < window->width; j++) { + gBgTilemaps[0][y][x] &= TILEMAP_PAL(15) | TILEMAP_FLIP_HORIZONTAL(1) | TILEMAP_FLIP_VERTICAL(1); + gBgTilemaps[1][y][x] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); + x++; + } + y++; + } +} + +UNUSED static void nullsub_172(void) +{ +} +#endif + +// arm9.bin::020032DC +void sub_8009524(s32 windowId) +{ + s32 i, j; + Window *window = &gWindows[windowId]; + s32 y = window->y - 1; + + for (i = 0; i < window->height + 2; i++) { + s32 x = window->x - 1; + for (j = 0; j < window->width + 2; j++) { + gBgTilemaps[0][y][x] &= TILEMAP_PAL(15) | TILEMAP_FLIP_HORIZONTAL(1) | TILEMAP_FLIP_VERTICAL(1); + gBgTilemaps[1][y][x] = TILEMAP_PAL(15) | TILEMAP_TILE_NUM(0x27A); + x++; + } + y++; + } +} + +#if (GAME_VERSION == VERSION_RED) +UNUSED static void nullsub_173(void) +{ +} +#endif + +// arm9.bin::020032C0 +void sub_80095CC(s32 a0, s32 a1) +{ + gUnknown_202B020 = a0; + gUnknown_202B024 = a1; +} + +#if (GAME_VERSION == VERSION_RED) +UNUSED static void nullsub_174(void) +{ +} +#endif + +// arm9.bin::02003278 +s32 sub_80095E4(s32 a0, s32 a1) +{ + s32 r1; + + if (a1 == 0) + a1 = 10; + r1 = a0 * a1; + + if ((r1 % 8) != 0) + return (r1 / 8) + 1; + else + return r1 / 8; +} + +// arm9.bin::02003238 +// Same as sub_80095E4 except it doesn't check for a1 == 0 +s32 sub_8009614(s32 a0, s32 a1) +{ + s32 r1; + + r1 = a0 * a1; + + if ((r1 % 8) != 0) + return (r1 / 8) + 1; + else + return r1 / 8; +} + +// arm9.bin::02003158 +static s32 InterpretColorChar(u8 a0) +{ + if (a0 < 16) + return a0; + if (a0 >= '0' && a0 <= '?') + return a0 - '0'; + + switch (a0) { + case 'H': + case 'I': + return 4; + case 'E': + case 'S': + case 'T': + return 15; + case 'G': + case 'M': + return 5; + case 'C': + case 'D': + case 'N': + return 6; + case 'W': + return 2; + + } + return 7; +} diff --git a/src/text_4.c b/src/text_4.c new file mode 100644 index 000000000..e5677a77a --- /dev/null +++ b/src/text_4.c @@ -0,0 +1,263 @@ +#include "global.h" +#include "structs/str_text.h" +#include "text_1.h" +#include "text_4.h" + +// These functions run from IWRAM for improved performance. + +static void ScrollDownWindowInternal(Window *txtStructs, s32 id); +static void ScrollUpWindowInternal(Window *txtStructs, s32 id); +static void sub_82729B8(Window *txtStructs, s32 id); +static void sub_8272A8C(Window *txtStructs, s32 id); + +IWRAM_INIT void ScrollDownWindow(s32 windowId) +{ + ScrollDownWindowInternal(gWindows, windowId); +} + +IWRAM_INIT static void ScrollDownWindowInternal(Window *windows, s32 windowId) +{ + Window *window = &windows[windowId]; + + if (window->unk8 > 0) { + s32 i, j; + u32 *dstPtr; + s32 n; + s32 id8, id9; + + if (window->type == WINDOW_TYPE_WITH_HEADER) { + s32 unk4 = window->width; + s32 dstAdd = ((window->unk24 + 2) * 8); + dstAdd *= unk4; + dstPtr = window->unk18 + dstAdd; + n = window->unk8 - 2; + } + else { + dstPtr = window->unk18; + n = window->unk8; + } + + id8 = window->unk20 + 8; + id9 = window->unk20 + 9; + for (i = 0; i < window->width; i++) { + s32 to = n - 1; + u32 *loopPtr = dstPtr; + for (j = 0; j < to; j++) { + loopPtr[0] = loopPtr[2]; + loopPtr[1] = loopPtr[3]; + loopPtr[2] = loopPtr[4]; + loopPtr[3] = loopPtr[5]; + loopPtr[4] = loopPtr[6]; + loopPtr[5] = loopPtr[7]; + loopPtr[6] = loopPtr[id8]; + loopPtr[7] = loopPtr[id9]; + + loopPtr += id8; + } + + loopPtr[0] = loopPtr[2]; + loopPtr[1] = loopPtr[3]; + loopPtr[2] = loopPtr[4]; + loopPtr[3] = loopPtr[5]; + loopPtr[4] = loopPtr[6]; + loopPtr[5] = loopPtr[7]; + loopPtr[6] = 0; + loopPtr[7] = 0; + dstPtr += 8; + } + + window->unk30 = window->unk28; + window->unk34 = window->unk1C; + window->unk38 = window->unk2C; + window->unk44 = 1; + } +} + +IWRAM_INIT void ScrollUpWindow(s32 windowId) +{ + ScrollUpWindowInternal(gWindows, windowId); +} + +IWRAM_INIT static void ScrollUpWindowInternal(Window *windows, s32 windowId) +{ + Window *window = &windows[windowId]; + + if (window->unk8 > 0) { + s32 i, j; + u32 *dstPtr; + s32 n; + s32 id8; + s32 unk4, unk8, dstAdd; + + if (window->type == WINDOW_TYPE_WITH_HEADER) { + n = window->unk8 - 2; + } + else { + n = window->unk8; + } + + unk8 = window->unk8 - 1; + unk4 = window->width; + dstAdd = (unk8 * unk4) * 8; + dstPtr = window->unk18 + dstAdd; + + id8 = window->unk20 + 8; + for (i = 0; i < window->width; i++) { + u32 lastTwo = 0; + s32 to = n - 1; + u32 *loopPtr = dstPtr; + + if (n < 2) { + loopPtr[7] = loopPtr[5]; + loopPtr[6] = loopPtr[4]; + loopPtr[5] = loopPtr[3]; + loopPtr[4] = loopPtr[2]; + loopPtr[3] = loopPtr[1]; + loopPtr[2] = loopPtr[0]; + loopPtr[1] = lastTwo; + loopPtr[0] = lastTwo; + } + else { + u32 *ptr8 = dstPtr - id8; + for (j = 0; j < to; j++) { + loopPtr[7] = loopPtr[5]; + loopPtr[6] = loopPtr[4]; + loopPtr[5] = loopPtr[3]; + loopPtr[4] = loopPtr[2]; + loopPtr[3] = loopPtr[1]; + loopPtr[2] = loopPtr[0]; + loopPtr[1] = ptr8[7]; + loopPtr[0] = ptr8[6]; + + loopPtr -= id8; + ptr8 -= id8; + } + + loopPtr[7] = loopPtr[5]; + loopPtr[6] = loopPtr[4]; + loopPtr[5] = loopPtr[3]; + loopPtr[4] = loopPtr[2]; + loopPtr[3] = loopPtr[1]; + loopPtr[2] = loopPtr[0]; + loopPtr[1] = 0; + loopPtr[0] = 0; + } + dstPtr += 8; + } + + window->unk30 = window->unk28; + window->unk34 = window->unk1C; + window->unk38 = window->unk2C; + window->unk44 = 1; + } +} + +IWRAM_INIT void sub_82729A4(s32 id) +{ + sub_82729B8(gWindows, id); +} + +IWRAM_INIT static void sub_82729B8(Window *windows, s32 id) +{ + s32 i, j; + Window *window = &windows[id]; + u32 *dstPtr = window->unk18; + s32 id8 = window->unk20 + 8; + s32 id9 = window->unk20 + 9; + + for (i = 0; i < window->width; i++) { + u32 *loopPtr; + + dstPtr[3] = dstPtr[5]; + dstPtr[4] = dstPtr[6]; + dstPtr[5] = dstPtr[7]; + dstPtr[6] = dstPtr[id8]; + dstPtr[7] = dstPtr[id9]; + + loopPtr = dstPtr + id8; + for (j = 0; j < 5; j++) { + loopPtr[0] = loopPtr[2]; + loopPtr[1] = loopPtr[3]; + loopPtr[2] = loopPtr[4]; + loopPtr[3] = loopPtr[5]; + loopPtr[4] = loopPtr[6]; + loopPtr[5] = loopPtr[7]; + loopPtr[6] = loopPtr[id8]; + loopPtr[7] = loopPtr[id9]; + + loopPtr += id8; + } + + loopPtr[0] = loopPtr[2]; + loopPtr[1] = loopPtr[3]; + loopPtr[2] = loopPtr[4]; + loopPtr[3] = loopPtr[5]; + loopPtr[4] = 0; + loopPtr[5] = 0; + loopPtr[6] = 0; + loopPtr[7] = 0; + + dstPtr += 8; + } + + window->unk30 = window->unk28; + window->unk34 = window->unk1C; + window->unk38 = window->unk2C; + window->unk44 = 1; +} + +IWRAM_INIT void sub_8272A78(s32 id) +{ + sub_8272A8C(gWindows, id); +} + +IWRAM_INIT static void sub_8272A8C(Window *windows, s32 id) +{ + s32 i, j; + Window *window = &windows[id]; + u32 *dstPtr = window->unk18; + s32 id8 = window->unk20 + 8; + + for (i = 0; i < window->width; i++) { + u32 *loopPtr; + + dstPtr[3] = 0; + dstPtr[4] = dstPtr[5]; + dstPtr[5] = dstPtr[6]; + dstPtr[6] = dstPtr[7]; + dstPtr[7] = dstPtr[id8]; + + loopPtr = dstPtr + id8; + for (j = 0; j < 5; j++) { + loopPtr[0] = loopPtr[1]; + loopPtr[1] = loopPtr[2]; + loopPtr[2] = loopPtr[3]; + loopPtr[3] = loopPtr[4]; + loopPtr[4] = loopPtr[5]; + loopPtr[5] = loopPtr[6]; + loopPtr[6] = loopPtr[7]; + loopPtr[7] = loopPtr[id8]; + + loopPtr += id8; + } + + loopPtr[0] = loopPtr[1]; + loopPtr[1] = loopPtr[2]; + loopPtr[2] = loopPtr[3]; + loopPtr[3] = loopPtr[4]; + loopPtr[4] = loopPtr[5]; + loopPtr[5] = loopPtr[6]; + loopPtr[6] = loopPtr[7]; + loopPtr[7] = 0; + + dstPtr += 8; + } + + window->unk30 = window->unk28; + window->unk34 = window->unk1C; + window->unk38 = window->unk2C; + window->unk44 = 1; +} + +// Needed to match, because without it the alignment is different. +IWRAM_INIT static UNUSED u8 sMatchAlignment = 0; diff --git a/src/thank_you_wonder_mail.c b/src/thank_you_wonder_mail.c index 5455bd5b6..946b3fbf0 100644 --- a/src/thank_you_wonder_mail.c +++ b/src/thank_you_wonder_mail.c @@ -1,13 +1,12 @@ #include "global.h" #include "globaldata.h" +#include "constants/communication_error_codes.h" #include "code_800D090.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_801B3C0.h" #include "code_801C8C4.h" #include "code_802F204.h" #include "code_8094F88.h" -#include "constants/communication_error_codes.h" #include "cpu.h" #include "input.h" #include "items.h" @@ -19,8 +18,9 @@ #include "rescue_password_menu.h" #include "save.h" #include "save_write.h" +#include "string_format.h" +#include "text_1.h" #include "text_util.h" -#include "text.h" #include "thank_you_wonder_mail.h" #include "wonder_mail_4.h" #include "wonder_mail_5.h" @@ -241,7 +241,7 @@ u32 CreateThankYouMailPelipper(void) faceFile = GetDialogueSpriteDataPtr(MONSTER_PELIPPER); sUnknown_203B2C4->monPortrait.faceFile = faceFile; - sUnknown_203B2C4->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; + sUnknown_203B2C4->monPortrait.faceData = (PortraitGfx *) faceFile->data; sUnknown_203B2C4->monPortrait.spriteId = 0; sUnknown_203B2C4->monPortrait.flip = FALSE; sUnknown_203B2C4->monPortrait.unkE = 0; @@ -565,7 +565,7 @@ void sub_802A0C8(void) case 4: sUnknown_203B2C4->fallbackState = 0x10; sUnknown_203B2C4->mailIndex = sub_80307EC(); - RestoreUnkTextStruct_8006518(&sUnknown_203B2C4->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C4->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8030D40(sUnknown_203B2C4->mailIndex,0); @@ -601,7 +601,7 @@ void sub_802A174(void) break; case INFO_ACTION: sUnknown_203B2C4->fallbackState = 0x2b; - RestoreUnkTextStruct_8006518(&sUnknown_203B2C4->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C4->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8030D40(sUnknown_203B2C4->mailIndex,0); @@ -660,7 +660,7 @@ void sub_802A28C(void) case 4: sUnknown_203B2C4->fallbackState = 0x13; sUnknown_203B2C4->unk41C.id = sub_801CB24(); - RestoreUnkTextStruct_8006518(&sUnknown_203B2C4->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C4->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); InitItemDescriptionWindow(&sUnknown_203B2C4->unk41C); @@ -711,7 +711,7 @@ void sub_802A39C(void) break; case INFO_ACTION: sUnknown_203B2C4->fallbackState = 0x2b; - RestoreUnkTextStruct_8006518(&sUnknown_203B2C4->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C4->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); InitItemDescriptionWindow(&sUnknown_203B2C4->unk41C); @@ -1267,7 +1267,7 @@ void UpdateThankYouMailText(void) sub_80306A8(WONDER_MAIL_TYPE_THANK_YOU,0,0,6); break; case 0x11: - RestoreUnkTextStruct_8006518(&sUnknown_203B2C4->unk35C); + RestoreSavedWindows(&sUnknown_203B2C4->unk35C); SetMenuItems(sUnknown_203B2C4->unk21C,&sUnknown_203B2C4->unk35C,3,&gUnknown_80DED60,gUnknown_80DED78,TRUE,0,FALSE); sub_803092C(); sub_8035CF4(sUnknown_203B2C4->unk21C,3,TRUE); @@ -1283,7 +1283,7 @@ void UpdateThankYouMailText(void) } break; case 0x14: - RestoreUnkTextStruct_8006518(&sUnknown_203B2C4->unk35C); + RestoreSavedWindows(&sUnknown_203B2C4->unk35C); SetMenuItems(sUnknown_203B2C4->unk21C,&sUnknown_203B2C4->unk35C,3,&gUnknown_80DED48,gUnknown_80DED78,TRUE,0,FALSE); sub_801CCD8(); sub_8035CF4(sUnknown_203B2C4->unk21C,3,TRUE); @@ -1330,13 +1330,13 @@ void UpdateThankYouMailText(void) CreateDialogueBoxAndPortrait(gUnknown_80DF380,0,&sUnknown_203B2C4->monPortrait,0x10d); break; case PROCESS_THANK_YOU_PASSWORD: - RestoreUnkTextStruct_8006518(&sUnknown_203B2C4->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C4->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_80151C0(4,sUnknown_203B2C4->passwordBuffer); break; case 0x1a: - RestoreUnkTextStruct_8006518(&sUnknown_203B2C4->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C4->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8031D70(sUnknown_203B2C4->mailIndex,0); diff --git a/src/trade_items_menu.c b/src/trade_items_menu.c index fc9804dd8..53ec6cee5 100644 --- a/src/trade_items_menu.c +++ b/src/trade_items_menu.c @@ -1,10 +1,9 @@ #include "global.h" #include "globaldata.h" +#include "constants/communication_error_codes.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_801B3C0.h" #include "code_801C8C4.h" -#include "constants/communication_error_codes.h" #include "cpu.h" #include "input.h" #include "items.h" @@ -13,7 +12,9 @@ #include "menu_input.h" #include "other_menus2.h" #include "save_write.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" +#include "text_2.h" #include "trade_items_menu.h" static EWRAM_INIT struct TradeItemsMenu *sTradeItemsMenu = {NULL}; @@ -176,7 +177,7 @@ void sub_80365AC(void) sTradeItemsMenu->fallbackState = TRADE_ITEMS_SEND_ITEM_SELECTION; sTradeItemsMenu->itemToSend.id = sub_801CB24(); sTradeItemsMenu->itemToSend.quantity = 1; - RestoreUnkTextStruct_8006518(&sTradeItemsMenu->unk1E4); + RestoreSavedWindows(&sTradeItemsMenu->unk1E4); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); InitItemDescriptionWindow(&sTradeItemsMenu->itemToSend); @@ -200,7 +201,7 @@ void sub_8036674(void) break; case 4: // Info sTradeItemsMenu->fallbackState = 0x13; - RestoreUnkTextStruct_8006518(&sTradeItemsMenu->unk1E4); + RestoreSavedWindows(&sTradeItemsMenu->unk1E4); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); InitItemDescriptionWindow(&sTradeItemsMenu->itemToSend); @@ -505,7 +506,7 @@ void sub_8036B28(void) } break; case TRADE_ITEMS_SEND_ITEM_POPUP_MENU: - RestoreUnkTextStruct_8006518(&sTradeItemsMenu->unk184); + RestoreSavedWindows(&sTradeItemsMenu->unk184); SetMenuItems(sTradeItemsMenu->unk44,&sTradeItemsMenu->unk184,3,&sUnknown_80E60EC, sUnknown_80E6104,TRUE,0,FALSE); sub_801CCD8(); @@ -647,7 +648,7 @@ void sub_8036F30(void) void sub_8036F74(void) { - RestoreUnkTextStruct_8006518(&sTradeItemsMenu->unk184); + RestoreSavedWindows(&sTradeItemsMenu->unk184); sub_8036ECC(2, gTeamInventoryRef->teamStorage[sTradeItemsMenu->itemToSend.id]); sub_801CCD8(); sub_8035CF4(sTradeItemsMenu->unk44, 3, FALSE); diff --git a/src/unk_menu_203B360.c b/src/unk_menu_203B360.c index 2ecf24159..0b8e2d2d6 100644 --- a/src/unk_menu_203B360.c +++ b/src/unk_menu_203B360.c @@ -6,7 +6,7 @@ #include "memory.h" #include "menu_input.h" #include "sprite.h" -#include "text.h" +#include "text_1.h" #include "unk_menu_203B360.h" // Size: 0x1B4. Similar to SaveMenuWork @@ -57,7 +57,8 @@ ALIGNED(4) const u8 Caution_80E6F04[] = _("{CENTER_ALIGN}{COLOR RED}Caution!{RES static const u8 fill0[] = "pksdir0"; extern void sub_8038440(); -extern void sub_80384D0(); + +static void sub_80384D0(void); void sub_80382E4(s32 currMenu) { @@ -147,7 +148,7 @@ void sub_8038440(void) sUnknown_203B360->unk1B0 = 0; } -void sub_80384D0(void) +static void sub_80384D0(void) { if ((sUnknown_203B360->unk1B0 & 8) != 0) { AddSprite(&sUnknown_203B360->unk1A8, 0x100, NULL, NULL); diff --git a/src/wigglytuff_shop1.c b/src/wigglytuff_shop1.c index 858cbd1b1..6b76f5d25 100644 --- a/src/wigglytuff_shop1.c +++ b/src/wigglytuff_shop1.c @@ -1,15 +1,16 @@ #include "global.h" #include "globaldata.h" +#include "constants/input.h" #include "code_800D090.h" #include "code_80118A4.h" -#include "constants/input.h" #include "event_flag.h" #include "friend_area.h" #include "input.h" #include "items.h" #include "memory.h" #include "menu_input.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" #include "wigglytuff_shop1.h" static EWRAM_INIT WigglytuffShop1Work *sWigglytuffShop1Work = {NULL}; @@ -31,7 +32,7 @@ bool8 sub_80211AC(u32 mode, u32 a1) sWigglytuffShop1Work->mode = mode; sWigglytuffShop1Work->s40.s0.unk34 = a1; sWigglytuffShop1Work->s40.s0.unk38 = &sWigglytuffShop1Work->s40.s0.windows.id[sWigglytuffShop1Work->s40.s0.unk34]; - RestoreUnkTextStruct_8006518(&sWigglytuffShop1Work->s40.s0.windows); + RestoreSavedWindows(&sWigglytuffShop1Work->s40.s0.windows); sWigglytuffShop1Work->s40.s0.windows.id[sWigglytuffShop1Work->s40.s0.unk34] = sUnknown_80DC47C; sWigglytuffShop1Work->s40.s0.unk38->header = &sWigglytuffShop1Work->s40.unk9C; ResetUnusedInputStruct(); diff --git a/src/wigglytuff_shop2.c b/src/wigglytuff_shop2.c index db1635cfa..aff9e4615 100644 --- a/src/wigglytuff_shop2.c +++ b/src/wigglytuff_shop2.c @@ -10,7 +10,9 @@ #include "menu_input.h" #include "pokemon.h" #include "pokemon_3.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" #include "wigglytuff_shop2.h" static EWRAM_INIT WigglytuffShop2Work *sWigglytuffShop2Work = {NULL}; @@ -32,7 +34,7 @@ bool8 CreateWigglytuffShopFriendAreaMenu(u8 friendArea, bool8 a1, s32 a2) sub_8021A60(); sWigglytuffShop2Work->unk74 = a2; sWigglytuffShop2Work->unk78 = &sWigglytuffShop2Work->unk7C.id[a2]; - RestoreUnkTextStruct_8006518(&sWigglytuffShop2Work->unk7C); + RestoreSavedWindows(&sWigglytuffShop2Work->unk7C); sWigglytuffShop2Work->unk7C.id[sWigglytuffShop2Work->unk74] = sUnknown_80DC4D8; sub_8021820(); return TRUE; diff --git a/src/wigglytuff_shop3.c b/src/wigglytuff_shop3.c index 87c0e8bbc..0305df88c 100644 --- a/src/wigglytuff_shop3.c +++ b/src/wigglytuff_shop3.c @@ -1,7 +1,6 @@ #include "global.h" #include "globaldata.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_8023144.h" #include "code_8099360.h" #include "common_strings.h" @@ -12,7 +11,8 @@ #include "memory.h" #include "menu_input.h" #include "pokemon.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" #include "wigglytuff_shop1.h" #include "wigglytuff_shop2.h" #include "wigglytuff_shop3.h" @@ -71,7 +71,7 @@ bool8 CreateWigglytuffShop(u32 mode) file = GetDialogueSpriteDataPtr(MONSTER_WIGGLYTUFF); sWigglytuffShop3Work->monPortrait.faceFile = file; - sWigglytuffShop3Work->monPortrait.faceData = (struct PortraitGfx *) file->data; + sWigglytuffShop3Work->monPortrait.faceData = (PortraitGfx *) file->data; sWigglytuffShop3Work->monPortrait.spriteId = 0; sWigglytuffShop3Work->monPortrait.flip = FALSE; sWigglytuffShop3Work->monPortrait.unkE = 0; @@ -140,7 +140,7 @@ static void sub_8021D5C(void) { s32 i; - RestoreUnkTextStruct_8006518(&sWigglytuffShop3Work->unkD0); + RestoreSavedWindows(&sWigglytuffShop3Work->unkD0); switch (sWigglytuffShop3Work->state) { case WIGGLYTUFF_UNK9: diff --git a/src/wonder_mail.c b/src/wonder_mail.c index f5ed8de67..8528a1391 100644 --- a/src/wonder_mail.c +++ b/src/wonder_mail.c @@ -1,12 +1,11 @@ #include "global.h" #include "globaldata.h" +#include "constants/communication_error_codes.h" #include "code_80118A4.h" -#include "string_format.h" #include "code_8023868.h" #include "code_8024458.h" #include "code_8094F88.h" #include "code_80A26CC.h" -#include "constants/communication_error_codes.h" #include "cpu.h" #include "input.h" #include "items.h" @@ -18,7 +17,8 @@ #include "rescue_password_menu.h" #include "save.h" #include "save_write.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" #include "wonder_mail.h" #include "wonder_mail_4.h" #include "wonder_mail_5.h" @@ -198,7 +198,7 @@ u8 sub_8027F88(void) strcpy(gFormatBuffer_Monsters[0], monName); faceFile = GetDialogueSpriteDataPtr(MONSTER_PELIPPER); sUnknown_203B2C0->monPortrait.faceFile = faceFile; - sUnknown_203B2C0->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; + sUnknown_203B2C0->monPortrait.faceData = (PortraitGfx *) faceFile->data; sUnknown_203B2C0->monPortrait.spriteId = 0; sUnknown_203B2C0->monPortrait.flip = FALSE; sUnknown_203B2C0->monPortrait.unkE = 0; @@ -420,7 +420,7 @@ void sub_8028348(void) switch(sUnknown_203B2C0->state) { case 0x3B: - RestoreUnkTextStruct_8006518(&sUnknown_203B2C0->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C0->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8031D70(sUnknown_203B2C0->mailIndex, 0); @@ -462,7 +462,7 @@ void sub_8028348(void) } break; case 0x34: - RestoreUnkTextStruct_8006518(&sUnknown_203B2C0->unk35C); + RestoreSavedWindows(&sUnknown_203B2C0->unk35C); SetMenuItems(sUnknown_203B2C0->unk21C, &sUnknown_203B2C0->unk35C, 3, &gUnknown_80DDAE4, gUnknown_80DDAFC, TRUE, 0, FALSE); sub_8023DA4(); sub_8035CF4(sUnknown_203B2C0->unk21C, 3, TRUE); @@ -572,7 +572,7 @@ void sub_8028348(void) CreateDialogueBoxAndPortrait(gUnknown_80DE124, 0, &sUnknown_203B2C0->monPortrait,0x10d); break; case 0x27: - RestoreUnkTextStruct_8006518(&sUnknown_203B2C0->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C0->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_80151C0(4, sUnknown_203B2C0->passwordBuffer); @@ -617,7 +617,7 @@ void sub_8028348(void) break; case 0x20: case 0x2B: - RestoreUnkTextStruct_8006518(&sUnknown_203B2C0->unk35C); + RestoreSavedWindows(&sUnknown_203B2C0->unk35C); SetMenuItems(sUnknown_203B2C0->unk21C, &sUnknown_203B2C0->unk35C, 3, &gUnknown_80DDACC, gUnknown_80DDAFC, TRUE, 0, FALSE); sub_803092C(); sub_8035CF4(sUnknown_203B2C0->unk21C, 3, TRUE); @@ -1114,7 +1114,7 @@ void sub_8029044(void) case 4: sUnknown_203B2C0->fallbackState = 0x1F; sUnknown_203B2C0->mailIndex = sub_80307EC(); - RestoreUnkTextStruct_8006518(&sUnknown_203B2C0->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C0->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8030D40(sUnknown_203B2C0->mailIndex, 0); @@ -1150,7 +1150,7 @@ void sub_80290F0(void) break; case INFO_ACTION: sUnknown_203B2C0->fallbackState = DEFAULT_FALLBACK_STATE; - RestoreUnkTextStruct_8006518(&sUnknown_203B2C0->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C0->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8030D40(sUnknown_203B2C0->mailIndex, 0); @@ -1463,7 +1463,7 @@ void sub_80295D8(void) case 4: sUnknown_203B2C0->fallbackState = 0x2A; sUnknown_203B2C0->mailIndex = sub_80307EC(); - RestoreUnkTextStruct_8006518(&sUnknown_203B2C0->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C0->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8030D40(sUnknown_203B2C0->mailIndex, 0); @@ -1499,7 +1499,7 @@ void sub_8029684(void) break; case INFO_ACTION: sUnknown_203B2C0->fallbackState = DEFAULT_FALLBACK_STATE; - RestoreUnkTextStruct_8006518(&sUnknown_203B2C0->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C0->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8030D40(sUnknown_203B2C0->mailIndex, 0); @@ -1573,7 +1573,7 @@ void sub_80297D4(void) case 4: sUnknown_203B2C0->fallbackState = SELECT_HELPER_POKEMON; sUnknown_203B2C0->speciesNum = sub_8023B44(); - RestoreUnkTextStruct_8006518(&sUnknown_203B2C0->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C0->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8024458(sUnknown_203B2C0->speciesNum, 0); @@ -1599,7 +1599,7 @@ void sub_8029884(void) break; case INFO_ACTION: sUnknown_203B2C0->fallbackState = DEFAULT_FALLBACK_STATE; - RestoreUnkTextStruct_8006518(&sUnknown_203B2C0->unk3BC); + RestoreSavedWindows(&sUnknown_203B2C0->unk3BC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_8024458(sUnknown_203B2C0->speciesNum, 0); diff --git a/src/wonder_mail_2.c b/src/wonder_mail_2.c index a9f332180..7f4cb54c8 100644 --- a/src/wonder_mail_2.c +++ b/src/wonder_mail_2.c @@ -1,13 +1,12 @@ #include "global.h" #include "globaldata.h" +#include "constants/item.h" +#include "constants/wonder_mail.h" #include "code_800D090.h" -#include "string_format.h" #include "code_802F204.h" #include "code_8094F88.h" #include "code_8097670.h" #include "code_8099360.h" -#include "constants/item.h" -#include "constants/wonder_mail.h" #include "event_flag.h" #include "game_options.h" #include "input.h" @@ -17,14 +16,15 @@ #include "pokemon_mail.h" #include "save.h" #include "save_write.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" struct unkStruct_203B2C8 { // size: 0x140 /* 0x0 */ u8 currState; /* 0x1 */ u8 unk1; - /* 0x4 */ struct MonPortraitMsg monPortrait; + /* 0x4 */ MonPortraitMsg monPortrait; /* 0x14 */ u8 teamName[4]; // Figure out size of this buffer u8 fill18[0x114 - 0x18]; unkStruct_802F204 unk114; @@ -86,7 +86,7 @@ u8 sub_802B2D4(void) CopyYellowMonsterNametoBuffer(gSpeakerNameBuffer, MONSTER_PELIPPER); faceFile = GetDialogueSpriteDataPtr(MONSTER_PELIPPER); sUnknown_203B2C8->monPortrait.faceFile = faceFile; - sUnknown_203B2C8->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; + sUnknown_203B2C8->monPortrait.faceData = (PortraitGfx *) faceFile->data; sUnknown_203B2C8->monPortrait.spriteId = 0; sUnknown_203B2C8->monPortrait.flip = FALSE; sUnknown_203B2C8->monPortrait.unkE = 0; diff --git a/src/wonder_mail_3_mid.c b/src/wonder_mail_3_mid.c index f9b848b27..8ddca1b4f 100644 --- a/src/wonder_mail_3_mid.c +++ b/src/wonder_mail_3_mid.c @@ -1,15 +1,15 @@ #include "global.h" #include "globaldata.h" -#include "code_802DE84.h" -#include "memory.h" -#include "text.h" -#include "menu_input.h" #include "structs/str_802C39C.h" -#include "common_strings.h" -#include "code_803B050.h" -#include "wonder_mail_802CDD4.h" -#include "input.h" #include "structs/struct_sub80095e4.h" +#include "code_802DE84.h" +#include "code_803B050.h" +#include "common_strings.h" +#include "input.h" +#include "memory.h" +#include "menu_input.h" +#include "text_1.h" +#include "wonder_mail_802CDD4.h" struct unkStruct_203B30C { @@ -119,7 +119,7 @@ void sub_802F004(void) { s32 index; - RestoreUnkTextStruct_8006518(&gUnknown_203B30C->unkF0); + RestoreSavedWindows(&gUnknown_203B30C->unkF0); switch(gUnknown_203B30C->state) { case 2: diff --git a/src/wonder_mail_4.c b/src/wonder_mail_4.c index e5e8af37e..7e2677f1e 100644 --- a/src/wonder_mail_4.c +++ b/src/wonder_mail_4.c @@ -1,18 +1,19 @@ #include "global.h" #include "globaldata.h" -#include "code_80118A4.h" -#include "code_8094F88.h" #include "constants/input.h" #include "constants/wonder_mail.h" +#include "structs/str_802C39C.h" +#include "structs/struct_sub80095e4.h" +#include "code_80118A4.h" +#include "code_8094F88.h" #include "input.h" #include "items.h" #include "memory.h" #include "menu_input.h" #include "pokemon.h" #include "pokemon_mail.h" -#include "structs/str_802C39C.h" -#include "text.h" -#include "structs/struct_sub80095e4.h" +#include "text_1.h" +#include "text_2.h" #include "wonder_mail_4.h" struct unkStruct_203B320 @@ -87,7 +88,7 @@ u32 sub_80306A8(u32 wonderMailType, u32 r1, DungeonPos *r2, u32 r3) gUnknown_203B320->s28.s0.unk34 = r1; gUnknown_203B320->s28.s0.unk38 = &gUnknown_203B320->s28.s0.windows.id[gUnknown_203B320->s28.s0.unk34]; - RestoreUnkTextStruct_8006518(&gUnknown_203B320->s28.s0.windows); + RestoreSavedWindows(&gUnknown_203B320->s28.s0.windows); gUnknown_203B320->s28.s0.windows.id[gUnknown_203B320->s28.s0.unk34] = gUnknown_80E0854; gUnknown_203B320->s28.s0.unk38->header = &gUnknown_203B320->s28.unk9C; diff --git a/src/wonder_mail_5.c b/src/wonder_mail_5.c index 6ff971b1b..f62c37798 100644 --- a/src/wonder_mail_5.c +++ b/src/wonder_mail_5.c @@ -1,18 +1,19 @@ -#include "constants/input.h" #include "global.h" #include "globaldata.h" +#include "constants/input.h" +#include "constants/wonder_mail.h" +#include "structs/str_802C39C.h" #include "code_800D090.h" #include "code_80118A4.h" #include "code_8094F88.h" -#include "constants/wonder_mail.h" #include "dungeon.h" #include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon.h" #include "pokemon_mail.h" -#include "structs/str_802C39C.h" -#include "text.h" +#include "text_1.h" +#include "text_3.h" struct unkStruct_203B324 { @@ -64,7 +65,7 @@ bool8 sub_8030D40(u8 mailIndex, s32 windowID) sub_801317C(&gUnknown_203B324->unk0); gUnknown_203B324->windowID = windowID; gUnknown_203B324->unk14 = &gUnknown_203B324->unk18.id[windowID]; - RestoreUnkTextStruct_8006518(&gUnknown_203B324->unk18); + RestoreSavedWindows(&gUnknown_203B324->unk18); gUnknown_203B324->unk18.id[gUnknown_203B324->windowID] = gUnknown_80E091C; sub_8030DD4(); return TRUE; diff --git a/src/wonder_mail_6.c b/src/wonder_mail_6.c index 2a834a5bb..6a365f34e 100644 --- a/src/wonder_mail_6.c +++ b/src/wonder_mail_6.c @@ -1,12 +1,12 @@ #include "global.h" #include "globaldata.h" +#include "code_8094F88.h" #include "input.h" #include "memory.h" -#include "text.h" -#include "pokemon.h" -#include "code_8094F88.h" #include "menu_input.h" +#include "pokemon.h" #include "string_format.h" +#include "text_1.h" #include "wonder_mail_4.h" #include "wonder_mail_5.h" @@ -18,7 +18,7 @@ struct unkStruct_203B328 MenuStruct unk8; MenuStruct unk58; WindowTemplates unkA8; - /* 0x108 */ struct MonPortraitMsg monPortrait; + /* 0x108 */ MonPortraitMsg monPortrait; u32 wonderMailType; }; static EWRAM_INIT struct unkStruct_203B328 *gUnknown_203B328 = {NULL}; @@ -109,7 +109,7 @@ bool8 sub_8030F58(u32 wonderMailType) gUnknown_203B328->wonderMailType = wonderMailType; file = GetDialogueSpriteDataPtr(MONSTER_PELIPPER); gUnknown_203B328->monPortrait.faceFile = file; - gUnknown_203B328->monPortrait.faceData = (struct PortraitGfx *) file->data; + gUnknown_203B328->monPortrait.faceData = (PortraitGfx *) file->data; gUnknown_203B328->monPortrait.spriteId = 0; gUnknown_203B328->monPortrait.flip = FALSE; gUnknown_203B328->monPortrait.unkE = 0; @@ -180,7 +180,7 @@ void sub_80310E4(u32 newState) static void sub_80310FC(void) { - RestoreUnkTextStruct_8006518(&gUnknown_203B328->unkA8); + RestoreSavedWindows(&gUnknown_203B328->unkA8); switch(gUnknown_203B328->state) { case INIT_STATE: diff --git a/src/wonder_mail_802C10C.c b/src/wonder_mail_802C10C.c index fa8e3b35d..45e42f616 100644 --- a/src/wonder_mail_802C10C.c +++ b/src/wonder_mail_802C10C.c @@ -1,14 +1,15 @@ #include "global.h" #include "globaldata.h" +#include "constants/input.h" #include "code_80118A4.h" #include "code_803B050.h" #include "code_80958E8.h" -#include "constants/input.h" #include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon_mail.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" #include "wonder_mail_802C10C.h" static EWRAM_INIT struct unkStruct_203B2E0 *gUnknown_203B2E0 = {NULL}; @@ -17,7 +18,6 @@ static EWRAM_INIT u16 gUnknown_203B2E4 = {0}; #include "data/wonder_mail_802C10C.h" static s32 CountPelipperBoardSlots(void); - static void sub_802C328(void); bool8 sub_802C10C(s32 a0, DungeonPos *a1, s32 a2) @@ -30,7 +30,7 @@ bool8 sub_802C10C(s32 a0, DungeonPos *a1, s32 a2) gUnknown_203B2E0->unk8.s0.unk34 = a0; gUnknown_203B2E0->unk8.s0.unk38 = &gUnknown_203B2E0->unk8.s0.windows.id[a0]; - RestoreUnkTextStruct_8006518(&gUnknown_203B2E0->unk8.s0.windows); + RestoreSavedWindows(&gUnknown_203B2E0->unk8.s0.windows); gUnknown_203B2E0->unk8.s0.windows.id[gUnknown_203B2E0->unk8.s0.unk34] = sUnknown_80DFCB4; gUnknown_203B2E0->unk8.s0.unk38->header = &gUnknown_203B2E0->unk8.unk9C; diff --git a/src/wonder_mail_802C4C8.c b/src/wonder_mail_802C4C8.c index ff2627f21..46bf65841 100644 --- a/src/wonder_mail_802C4C8.c +++ b/src/wonder_mail_802C4C8.c @@ -1,17 +1,18 @@ #include "global.h" #include "globaldata.h" +#include "constants/input.h" +#include "structs/str_802C39C.h" +#include "structs/str_wonder_mail.h" #include "code_80118A4.h" #include "code_803B050.h" #include "code_80958E8.h" -#include "constants/input.h" #include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon_mail.h" +#include "text_1.h" +#include "text_2.h" #include "wonder_mail_802C10C.h" -#include "structs/str_802C39C.h" -#include "structs/str_wonder_mail.h" -#include "text.h" #include "wonder_mail_802C4C8.h" static EWRAM_INIT struct unkStruct_203B2E0* gUnknown_203B2E8 = {NULL}; @@ -31,7 +32,7 @@ bool8 sub_802C4C8(s32 a0, DungeonPos *a1, u32 a2) gUnknown_203B2E8 = MemoryAlloc(sizeof(struct unkStruct_203B2E0), 8); gUnknown_203B2E8->unk8.s0.unk34 = a0; gUnknown_203B2E8->unk8.s0.unk38 = &gUnknown_203B2E8->unk8.s0.windows.id[a0]; - RestoreUnkTextStruct_8006518(&gUnknown_203B2E8->unk8.s0.windows); + RestoreSavedWindows(&gUnknown_203B2E8->unk8.s0.windows); gUnknown_203B2E8->unk8.s0.windows.id[gUnknown_203B2E8->unk8.s0.unk34] = sUnknown_80DFCFC; gUnknown_203B2E8->unk8.s0.unk38->header = &gUnknown_203B2E8->unk8.unk9C; diff --git a/src/wonder_mail_802C860.c b/src/wonder_mail_802C860.c index 2c6fbad0b..e229f3697 100644 --- a/src/wonder_mail_802C860.c +++ b/src/wonder_mail_802C860.c @@ -1,17 +1,17 @@ #include "global.h" #include "globaldata.h" #include "code_80118A4.h" -#include "code_803B050.h" #include "code_802DE84.h" +#include "code_803B050.h" #include "code_80958E8.h" #include "code_80A26CC.h" #include "common_strings.h" #include "input.h" #include "memory.h" #include "menu_input.h" +#include "text_1.h" #include "wonder_mail_802C4C8.h" #include "wonder_mail_802C860.h" -#include "text.h" static EWRAM_INIT struct unkStruct_203B2F0 *sUnknown_203B2F0 = {NULL}; @@ -82,7 +82,7 @@ static void sub_802C928(void) { s32 i; - RestoreUnkTextStruct_8006518(&sUnknown_203B2F0->unk19C); + RestoreSavedWindows(&sUnknown_203B2F0->unk19C); switch (sUnknown_203B2F0->state) { case 2: diff --git a/src/wonder_mail_802CDD4.c b/src/wonder_mail_802CDD4.c index 57b794396..157e3ca06 100644 --- a/src/wonder_mail_802CDD4.c +++ b/src/wonder_mail_802CDD4.c @@ -1,16 +1,17 @@ #include "global.h" #include "globaldata.h" +#include "constants/input.h" +#include "structs/str_802C39C.h" +#include "structs/str_wonder_mail.h" +#include "structs/struct_sub80095e4.h" #include "code_80118A4.h" #include "code_803B050.h" -#include "constants/input.h" #include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon_mail.h" -#include "structs/str_802C39C.h" -#include "structs/struct_sub80095e4.h" -#include "structs/str_wonder_mail.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" #include "wonder_mail_802CDD4.h" static EWRAM_INIT struct_Sub80095E4_2 *sUnknown_203B2F4 = {NULL}; @@ -26,7 +27,7 @@ bool8 sub_802CDD4(u32 a0) sUnknown_203B2F4->s0.unk34 = a0; sUnknown_203B2F4->s0.unk38 = &sUnknown_203B2F4->s0.windows.id[sUnknown_203B2F4->s0.unk34]; - RestoreUnkTextStruct_8006518(&sUnknown_203B2F4->s0.windows); + RestoreSavedWindows(&sUnknown_203B2F4->s0.windows); sUnknown_203B2F4->s0.windows.id[sUnknown_203B2F4->s0.unk34] = sUnknown_80DFDA4; sUnknown_203B2F4->s0.unk38->header = &sUnknown_203B2F4->unk9C; sub_8012D34(sUnknown_203B2F4->s0.unk38, 4); diff --git a/src/wonder_mail_802D098.c b/src/wonder_mail_802D098.c index bdd9c22c1..7d865b023 100644 --- a/src/wonder_mail_802D098.c +++ b/src/wonder_mail_802D098.c @@ -1,19 +1,19 @@ #include "global.h" #include "globaldata.h" -#include "string_format.h" +#include "constants/dungeon.h" #include "code_802DE84.h" #include "code_803B050.h" #include "code_80958E8.h" #include "code_80972F4.h" -#include "code_8099360.h" #include "code_8099328.h" +#include "code_8099360.h" #include "common_strings.h" -#include "constants/dungeon.h" #include "input.h" #include "memory.h" #include "menu_input.h" #include "save.h" -#include "text.h" +#include "string_format.h" +#include "text_1.h" #include "wonder_mail_802C4C8.h" #include "wonder_mail_802D098.h" @@ -140,7 +140,7 @@ static void sub_802D1B8(void) { s32 i; - RestoreUnkTextStruct_8006518(&sUnknown_203B2F8->unk1A8); + RestoreSavedWindows(&sUnknown_203B2F8->unk1A8); switch (sUnknown_203B2F8->state) { case 13: diff --git a/src/wonder_mail_main_menu.c b/src/wonder_mail_main_menu.c index bbfd2148e..a06d38673 100644 --- a/src/wonder_mail_main_menu.c +++ b/src/wonder_mail_main_menu.c @@ -1,25 +1,25 @@ #include "global.h" #include "globaldata.h" -#include "code_80118A4.h" -#include "string_format.h" -#include "code_801B3C0.h" -#include "code_803B050.h" -#include "code_801C8C4.h" -#include "code_803D0D8.h" -#include "code_8094F88.h" #include "constants/communication_error_codes.h" #include "constants/wonder_mail.h" +#include "code_80118A4.h" +#include "code_801B3C0.h" +#include "code_801C8C4.h" +#include "code_803B050.h" +#include "code_803D0D8.h" +#include "code_8094F88.h" #include "cpu.h" #include "input.h" #include "memory.h" #include "other_menus2.h" #include "save.h" #include "save_write.h" -#include "text.h" -#include "wonder_mail_802D098.h" -#include "wonder_mail_main_menu.h" +#include "string_format.h" +#include "text_1.h" #include "wonder_mail_4.h" #include "wonder_mail_5.h" +#include "wonder_mail_802D098.h" +#include "wonder_mail_main_menu.h" #define SELECT_WONDER_MAIL_MODE_MAIN_SCREEN 0 #define SEND_WONDER_MAIL_MAIN_SCREEN 1 @@ -558,7 +558,7 @@ void WonderMailMainMenuCallback(void) CreateDialogueBoxAndPortrait(gUnknown_80E7C98,0,0,0x101); break; case PASSWORD_ENTRY_SCREEN: - RestoreUnkTextStruct_8006518(&gUnknown_203B3E8->unk1EC); + RestoreSavedWindows(&gUnknown_203B3E8->unk1EC); ResetUnusedInputStruct(); ShowWindows(NULL, TRUE, TRUE); sub_80151C0(5,gUnknown_203B3E8->PasswordEntryBuffer); diff --git a/src/world_map.c b/src/world_map.c index e4a39f00e..0a2623497 100644 --- a/src/world_map.c +++ b/src/world_map.c @@ -8,7 +8,8 @@ #include "code_800C9CC.h" #include "code_800D090.h" #include "code_80118A4.h" -#include "decompress.h" +#include "decompress_at.h" +#include "decompress_sir.h" #include "def_filearchives.h" #include "dungeon.h" #include "friend_area.h" @@ -19,7 +20,9 @@ #include "pokemon.h" #include "sprite.h" #include "string_format.h" -#include "text.h" +#include "text_1.h" +#include "text_2.h" +#include "text_3.h" #include "world_map.h" extern void sub_801178C(void); diff --git a/sym_ewram.txt b/sym_ewram.txt index 3d71fa257..fc7b31345 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -9,10 +9,10 @@ .include "src/input.o" .include "src/sprite.o" .include "src/code_800558C.o" - .include "src/text.o" + .include "src/text_1.o" .include "src/code_8009804.o" .include "src/file_system.o" - .include "src/decompress.o" + .include "src/decompress_at.o" .include "src/main.o" .include "src/reg_control.o" .include "src/music.o" diff --git a/sym_ewram_init.txt b/sym_ewram_init.txt index 5b7925143..516d9b496 100644 --- a/sym_ewram_init.txt +++ b/sym_ewram_init.txt @@ -5,7 +5,7 @@ .include "src/sprite.o" .include "src/code_800558C.o" .include "src/random.o" -.include "src/text.o" +.include "src/text_1.o" .include "src/code_8009804.o" .include "src/file_system.o" .include "src/main.o" diff --git a/sym_iwram.txt b/sym_iwram.txt index 908f47ef4..4eaa31e5f 100644 --- a/sym_iwram.txt +++ b/sym_iwram.txt @@ -6,7 +6,7 @@ gUnknown_3000400: /* 3000400 */ gUnknown_3000C00: /* 3000C00 */ .space 0x294 -.include "src/text.o" +.include "src/text_1.o" .include "src/music.o" .include "src/code_803E724.o" .include "src/code_8094D28.o" diff --git a/sym_iwram_init.txt b/sym_iwram_init.txt index 690170b75..08fa71ef3 100644 --- a/sym_iwram_init.txt +++ b/sym_iwram_init.txt @@ -12,4 +12,4 @@ .include "src/ground_object.o" .include "src/ground_effect.o" .include "src/ground_event.o" -.include "src/text.o" +.include "src/text_4.o" From f5edc87c17279593bb35c79e6784338eb6ab894a Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Fri, 21 Mar 2025 23:53:16 -0400 Subject: [PATCH 3/5] Fix build --- src/sprite.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sprite.c b/src/sprite.c index 418cb5ba6..2462d0dc6 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -659,8 +659,8 @@ void sub_800569C(DungeonPos *a0, axObject *a1, u8 a2) if (!(a1->axdata.flags >> 15) || a2 >= 4) return; - if (a1->axdata.paletteData != NULL) { - ptr = &((DungeonPos*)a1->axdata.paletteData)[a1->axdata.sub1.poseId * 4]; + if (a1->axdata.positions != NULL) { + ptr = &((DungeonPos*)a1->axdata.positions)[a1->axdata.sub1.poseId * 4]; ptr2 = &ptr[a2]; if (*&ptr2->x == 99 && *&ptr2->y == 99) { a0->x = 99; @@ -687,8 +687,8 @@ void sub_8005700(DungeonPos *a0, axObject *a1) if (!(a1->axdata.flags >> 15)) return; - if (a1->axdata.paletteData != NULL) { - ptr = &((DungeonPos*)a1->axdata.paletteData)[a1->axdata.sub1.poseId * 4]; + if (a1->axdata.positions != NULL) { + ptr = &((DungeonPos*)a1->axdata.positions)[a1->axdata.sub1.poseId * 4]; for (i = 0; i < 4; i++) { if (*&ptr[i].x == 99 && *&ptr[i].y == 99) { a0->x = 99; From 1910d8b718472ab5334f6fcb33697c2a9caac418 Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Sat, 22 Mar 2025 01:51:18 -0400 Subject: [PATCH 4/5] anon fixed matching for me --- include/gba/defines.h | 1 + include/structs/axdata.h | 8 ++++---- src/debug.c | 28 ++++++++++++++-------------- src/text_2.c | 14 +++++++------- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/include/gba/defines.h b/include/gba/defines.h index 5e1560240..111652019 100644 --- a/include/gba/defines.h +++ b/include/gba/defines.h @@ -16,6 +16,7 @@ #define NORETURN __attribute__((noreturn)) #define PACKED __attribute__((packed)) #define ALIGNED(n) __attribute__((aligned(n))) +#define ALIGNED_PACKED(n) __attribute__((packed, aligned(n))) #define SOUND_INFO_PTR (*(struct SoundInfo **)0x3007FF0) #define INTR_CHECK (*(u16 *)0x3007FF8) diff --git a/include/structs/axdata.h b/include/structs/axdata.h index 03a142f99..cdd8b44d6 100644 --- a/include/structs/axdata.h +++ b/include/structs/axdata.h @@ -29,21 +29,21 @@ typedef struct axdata1 } axdata1; // Size: 0x2 -typedef struct ax_pose_unk2 +typedef struct ALIGNED_PACKED(2) ax_pose_unk2 { u8 unk0; s8 unk1; -} ax_pose_unk2 __attribute__((packed, aligned(2))); +} ax_pose_unk2; // size: 0xA -typedef struct ax_pose +typedef struct ALIGNED_PACKED(2) ax_pose { /* 0x0 */ s16 sprite; /* 0x2 */ ax_pose_unk2 unk2; // Always {0, 0} in red (except for end markers {0xFF, 0xFF} and Latios Pose189...) /* 0x4 */ u16 flags1; /* 0x6 */ u16 flags2; /* 0x8 */ u16 flags3; -} ax_pose __attribute__((packed, aligned(2))); +} ax_pose; // size: 0xC typedef struct ax_anim diff --git a/src/debug.c b/src/debug.c index 3f1b75d13..0377a973d 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1,10 +1,21 @@ #include "global.h" #include "debug.h" -static EWRAM_INIT bool32 gNDS_DebugEnabled = {0}; // NDS=020EACE4 -static EWRAM_INIT u8 gUnknown_203B150 = {0}; +EWRAM_INIT static bool32 gNDS_DebugEnabled = {0}; // NDS=020EACE4 +EWRAM_INIT static u8 gUnknown_203B150 = {0}; -UNUSED static EWRAM_INIT const char *sUnusedEwramDebugStrings[] = +ALIGNED(4) static const char gFuncFileLineString[] = "func = '%s'\nfile = '%s' line = %5d"; + +ALIGNED(4) static const char gNotEntryText[] = "--- not entry ---"; +ALIGNED(4) static const char gFuncFileLineStringWPrefix[] = "%sfunc = '%s'\nfile = '%s' line = %5d\n"; + +ALIGNED(4) static const char gFuncFileLineString2[] = "func = '%s'\nfile = '%s' line = %5d\n"; + +ALIGNED(4) static const char debug_fill14[] = "pksdir0"; +ALIGNED(4) static const char gDebugPrintPrefix[] = " Print "; +ALIGNED(4) static const char debug_fill13[] = "pksdir0"; + +EWRAM_INIT UNUSED static const char *sUnusedEwramDebugStrings[] = { "Ground", "GroundScript", @@ -18,17 +29,6 @@ UNUSED static EWRAM_INIT const char *sUnusedEwramDebugStrings[] = "Performance", }; -ALIGNED(4) static const char gFuncFileLineString[] = "func = '%s'\nfile = '%s' line = %5d"; - -ALIGNED(4) static const char gNotEntryText[] = "--- not entry ---"; -ALIGNED(4) static const char gFuncFileLineStringWPrefix[] = "%sfunc = '%s'\nfile = '%s' line = %5d\n"; - -ALIGNED(4) static const char gFuncFileLineString2[] = "func = '%s'\nfile = '%s' line = %5d\n"; - -ALIGNED(4) static const char debug_fill14[] = "pksdir0"; -ALIGNED(4) static const char gDebugPrintPrefix[] = " Print "; -ALIGNED(4) static const char debug_fill13[] = "pksdir0"; - ALIGNED(4) static const char gNotMountText[] = "not mount log system"; ALIGNED(4) static const char debug_fill9[] = "pksdir0"; ALIGNED(4) static const char debug_fill10[] = "pksdir0"; diff --git a/src/text_2.c b/src/text_2.c index 66ec61754..cb4d1b051 100644 --- a/src/text_2.c +++ b/src/text_2.c @@ -5,13 +5,6 @@ #include "text_1.h" #include "text_2.h" -static const u32 sUnknown_80B8868[] = -{ - 0, 0xF, 0xFF, 0xFFF, 0xFFFF, 0xFFFFF, 0xFFFFFF, 0xFFFFFFF, - 0xFFFFFFFF, 0xFFFFFFF0, 0xFFFFFF00, 0xFFFFF000, 0xFFFF0000, - 0xFFF00000, 0xFF000000, 0xF0000000 -}; - static void AddUnderScoreHighlightInternal(Window *windows, u32 windowId, s32 x, s32 y, s32 width, u32 color); static void DisplayMonPortrait(Window *a0, u16 a1[32][32], s32 a2, const u8 *compressedData, u32 a4); static void DisplayMonPortraitFlipped(Window *windows, s32 windowId, const u8 *compressedData, s32 a3); @@ -904,6 +897,13 @@ UNUSED static void nullsub_168(void) { } +static const u32 sUnknown_80B8868[] = +{ + 0, 0xF, 0xFF, 0xFFF, 0xFFFF, 0xFFFFF, 0xFFFFFF, 0xFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFF0, 0xFFFFFF00, 0xFFFFF000, 0xFFFF0000, + 0xFFF00000, 0xFF000000, 0xF0000000 +}; + UNUSED static void sub_80086C8(Window *windows, s32 windowId, s32 a2, s32 a3, s32 a4, s32 a5) { u32 *r5; From 67c7d27eeac7f4310c67abf63cd5e9f1800df089 Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Sat, 22 Mar 2025 14:55:13 -0400 Subject: [PATCH 5/5] Move data back to c since it's not languagestrings --- src/data/text.h | 76 ------------------------------------------------ src/text_1.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 77 deletions(-) delete mode 100644 src/data/text.h diff --git a/src/data/text.h b/src/data/text.h deleted file mode 100644 index d6f2b6dbb..000000000 --- a/src/data/text.h +++ /dev/null @@ -1,76 +0,0 @@ -const u32 gUnknown_80B853C[16] = -{ - 0x66666666, - 0x00000000, - 0x11111111, - 0x22222222, - 0x33333333, - 0x44444444, - 0x55555555, - 0x66666666, - 0x77777777, - 0x88888888, - 0x99999999, - 0xAAAAAAAA, - 0xBBBBBBBB, - 0xCCCCCCCC, - 0xDDDDDDDD, - 0xEEEEEEEE, -}; - -static const WindowTemplates sDummyWindows = -{ - .id = { - [0] = WIN_TEMPLATE_DUMMY, - [1] = WIN_TEMPLATE_DUMMY, - [2] = WIN_TEMPLATE_DUMMY, - [3] = WIN_TEMPLATE_DUMMY, - } -}; - -const unkShiftData gCharMasksOffsets[8] = -{ - [0] = {.bytesA = 0xFFFFFFFF, .bytesB = 0x00000000, .shift_left = 0x00, .shift_right = 0x20}, - [1] = {.bytesA = 0x0FFFFFFF, .bytesB = 0xF0000000, .shift_left = 0x04, .shift_right = 0x1C}, - [2] = {.bytesA = 0x00FFFFFF, .bytesB = 0xFF000000, .shift_left = 0x08, .shift_right = 0x18}, - [3] = {.bytesA = 0x000FFFFF, .bytesB = 0xFFF00000, .shift_left = 0x0C, .shift_right = 0x14}, - [4] = {.bytesA = 0x0000FFFF, .bytesB = 0xFFFF0000, .shift_left = 0x10, .shift_right = 0x10}, - [5] = {.bytesA = 0x00000FFF, .bytesB = 0xFFFFF000, .shift_left = 0x14, .shift_right = 0x0C}, - [6] = {.bytesA = 0x000000FF, .bytesB = 0xFFFFFF00, .shift_left = 0x18, .shift_right = 0x08}, - [7] = {.bytesA = 0x0000000F, .bytesB = 0xFFFFFFF0, .shift_left = 0x1C, .shift_right = 0x04}, -}; - -static const u16 sUnknown_80B865C[] = -{ - 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, - 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, - 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, - 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, - 0xFF, 0, 0, 0, 0, 0, 0 -}; - -// Fallback character with bitmap? -const unkChar gUnknown_80B86A4 = -{ - .unk0 = sUnknown_80B865C, - .unk4 = 0x81A1, - .unk6 = 7, - .unk8 = 10, - .fill9 = 0, - .unkA = 0, - .fillB = 0, -}; - -// Very weird... -UNUSED static const u8 sByte8 = 8; - -const u32 gUnknown_80B86B4[][32] = INCBIN_U32("graphics/warning.4bpp"); - -static const u8 sKanjiA_file_string[] = "kanji_a"; -static const u8 sKanjiB_file_string[] = "kanji_b"; - -static const u32 sFadeInNone[8] = {0}; -static const u32 sFadeInDungeon[8] = {0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888}; - -static const u32 sUnknown_80B8804[4] = {0, 1, 2, 3}; -static const u32 sUnknown_80B8814[4] = {1, 2, 3, 0}; \ No newline at end of file diff --git a/src/text_1.c b/src/text_1.c index f050a32e7..7fb2877e5 100644 --- a/src/text_1.c +++ b/src/text_1.c @@ -39,7 +39,82 @@ EWRAM_INIT void (*gIwramTextFunc4)(s32 a0) = sub_8272A78; IWRAM_DATA ALIGNED(4) s16 gUnknown_3000E94[161] = {0}; -#include "data/text.h" +const u32 gUnknown_80B853C[16] = +{ + 0x66666666, + 0x00000000, + 0x11111111, + 0x22222222, + 0x33333333, + 0x44444444, + 0x55555555, + 0x66666666, + 0x77777777, + 0x88888888, + 0x99999999, + 0xAAAAAAAA, + 0xBBBBBBBB, + 0xCCCCCCCC, + 0xDDDDDDDD, + 0xEEEEEEEE, +}; + +static const WindowTemplates sDummyWindows = +{ + .id = { + [0] = WIN_TEMPLATE_DUMMY, + [1] = WIN_TEMPLATE_DUMMY, + [2] = WIN_TEMPLATE_DUMMY, + [3] = WIN_TEMPLATE_DUMMY, + } +}; + +const unkShiftData gCharMasksOffsets[8] = +{ + [0] = {.bytesA = 0xFFFFFFFF, .bytesB = 0x00000000, .shift_left = 0x00, .shift_right = 0x20}, + [1] = {.bytesA = 0x0FFFFFFF, .bytesB = 0xF0000000, .shift_left = 0x04, .shift_right = 0x1C}, + [2] = {.bytesA = 0x00FFFFFF, .bytesB = 0xFF000000, .shift_left = 0x08, .shift_right = 0x18}, + [3] = {.bytesA = 0x000FFFFF, .bytesB = 0xFFF00000, .shift_left = 0x0C, .shift_right = 0x14}, + [4] = {.bytesA = 0x0000FFFF, .bytesB = 0xFFFF0000, .shift_left = 0x10, .shift_right = 0x10}, + [5] = {.bytesA = 0x00000FFF, .bytesB = 0xFFFFF000, .shift_left = 0x14, .shift_right = 0x0C}, + [6] = {.bytesA = 0x000000FF, .bytesB = 0xFFFFFF00, .shift_left = 0x18, .shift_right = 0x08}, + [7] = {.bytesA = 0x0000000F, .bytesB = 0xFFFFFFF0, .shift_left = 0x1C, .shift_right = 0x04}, +}; + +static const u16 sUnknown_80B865C[] = +{ + 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, + 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, + 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, + 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, 0xFF, 0xFFFF, 0xFFFF, + 0xFF, 0, 0, 0, 0, 0, 0 +}; + +// Fallback character with bitmap? +const unkChar gUnknown_80B86A4 = +{ + .unk0 = sUnknown_80B865C, + .unk4 = 0x81A1, + .unk6 = 7, + .unk8 = 10, + .fill9 = 0, + .unkA = 0, + .fillB = 0, +}; + +// Very weird... +UNUSED static const u8 sByte8 = 8; + +const u32 gUnknown_80B86B4[][32] = INCBIN_U32("graphics/warning.4bpp"); + +static const u8 sKanjiA_file_string[] = "kanji_a"; +static const u8 sKanjiB_file_string[] = "kanji_b"; + +static const u32 sFadeInNone[8] = {0}; +static const u32 sFadeInDungeon[8] = {0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888, 0x88888888}; + +static const u32 sUnknown_80B8804[4] = {0, 1, 2, 3}; +static const u32 sUnknown_80B8814[4] = {1, 2, 3, 0}; static void AddWindow(Window *windows, u32 *vram, u32 *, u16 *, u32 windowId, const WindowTemplate *winTemplate, bool8, s32 firstBlockId, DungeonPos *positionModifier, u8); static void ShowWindowsInternal(const WindowTemplates *winTemplates, bool8, bool8, DungeonPos *positionModifier);