diff --git a/data/data_8106A4C.s b/data/data_8106A4C.s index ea2317b5d..002a4b90d 100644 --- a/data/data_8106A4C.s +++ b/data/data_8106A4C.s @@ -257,101 +257,3 @@ gUnknown_8106D8C: @ 8106D8C @ ??? .align 2,0 .string "pksdir0\0" - -@ sub_8067A80 - sub_806806C - .align 2,0 - .string "pksdir0\0" - .align 2,0 - - .global gUnknown_8106DA4 -gUnknown_8106DA4: @ 8106DA4 - .byte 0x01, 0x00, 0x38, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x38, 0x00, 0x68, 0x00, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00 - - .global gUnknown_8106DC8 -gUnknown_8106DC8: @ 8106DC8 - .byte 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x11, 0x00, 0x0e, 0x00, 0x12, 0x00, 0x02, 0x00, 0x08, 0xf3, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00 - .byte 0x15, 0x00, 0x04, 0x00, 0x07, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - - .global gUnknown_8106E28 -gUnknown_8106E28: @ 8106E28 - .string "{POKEMON_0}\0" - .align 2,0 - - .global gUnknown_8106E2C -gUnknown_8106E2C: @ 8106E2C - .byte 0x87, 0x42, 0x00, 0x00 - - .global gUnknown_8106E30 -gUnknown_8106E30: @ 8106E30 - .byte 0x87, 0x40, 0x00, 0x00 - - .global gUnknown_8106E34 -gUnknown_8106E34: @ 8106E34 - .string "{MOVE_ITEM_0}{color CYAN}$v02:{POKEMON_0}{reset}\0" - .align 2,0 - - .global gUnknown_8106E48 -gUnknown_8106E48: @ 8106E48 - .string "{MOVE_ITEM_0}{color YELLOW}$v02:{POKEMON_0}{reset}\0" - .align 2,0 - - .global gUnknown_8106E5C -gUnknown_8106E5C: @ 8106E5C - .string "Press {B_BUTTON}\n" - .string "if OK.\0" - .align 2,0 - - .global gUnknown_8106E6C -gUnknown_8106E6C: @ 8106E6C - .string "Say bye to\n" - .string "{VALUE_0} more\0" - .align 2,0 - - .global gUnknown_8106E80 -gUnknown_8106E80: @ 8106E80 - .byte 0x02, 0x00, 0x00, 0x00 - .byte 0x03, 0x00, 0x00, 0x00 - .byte 0x04, 0x00, 0x00, 0x00 - .byte 0x05, 0x00, 0x00, 0x00 - -@ sub_8068614 - sub_806A3D4 - .string "pksdir0\0" - .align 2,0 - - .global gUnknown_8106E98 -gUnknown_8106E98: @ 8106E98 - .string "palet\0" - .align 2,0 - - .global gUnknown_8106EA0 -gUnknown_8106EA0: @ 8106EA0 - .string "ax%03d\0" - .align 2,0 - - .global gUnknown_8106EA8 -gUnknown_8106EA8: @ 8106EA8 - .string "talkp%d\0" - .align 2,0 - - .global gUnknown_8106EB0 -gUnknown_8106EB0: @ 8106EB0 - .string "talk%d\0" - -@ ??? - .align 2,0 - .string "pksdir0\0" - -@ sub_806C51C - sub_806E100 - .align 2,0 - .string "pksdir0\0" - .align 2,0 - - .global gUnknown_8106EC8 -gUnknown_8106EC8: @ 8106EC8 -.byte 0x00, 0x01, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07 -.byte 0x07, 0x07, 0x05, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x05 -.byte 0x06, 0x07, 0x07, 0x07, 0x07, 0x0b, 0x07 - - diff --git a/data/data_8106A4C_2.s b/data/data_8106A4C_2.s new file mode 100644 index 000000000..c7152ee35 --- /dev/null +++ b/data/data_8106A4C_2.s @@ -0,0 +1,40 @@ + .section .rodata + +.align 2,0 +@ sub_8068614 - sub_806A3D4 + .string "pksdir0\0" + .align 2,0 + + .global gUnknown_8106E98 +gUnknown_8106E98: @ 8106E98 + .string "palet\0" + .align 2,0 + + .global gUnknown_8106EA0 +gUnknown_8106EA0: @ 8106EA0 + .string "ax%03d\0" + .align 2,0 + + .global gUnknown_8106EA8 +gUnknown_8106EA8: @ 8106EA8 + .string "talkp%d\0" + .align 2,0 + + .global gUnknown_8106EB0 +gUnknown_8106EB0: @ 8106EB0 + .string "talk%d\0" + +@ ??? + .align 2,0 + .string "pksdir0\0" + +@ sub_806C51C - sub_806E100 + .align 2,0 + .string "pksdir0\0" + .align 2,0 + + .global gUnknown_8106EC8 +gUnknown_8106EC8: @ 8106EC8 +.byte 0x00, 0x01, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07 +.byte 0x07, 0x07, 0x05, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x05 +.byte 0x06, 0x07, 0x07, 0x07, 0x07, 0x0b, 0x07 diff --git a/include/global.h b/include/global.h index 6674e8d79..f6fb1b249 100644 --- a/include/global.h +++ b/include/global.h @@ -31,6 +31,17 @@ static inline s16 Self_s16(s16 a) return a; } +// Needed to match a couple of functions. +static inline void InlineStrcpy(u8 *dst, const u8 *src) +{ + strcpy(dst, src); +} + +static inline void InlineStrncpy(u8 *dst, const u8 *src, s32 n) +{ + strncpy(dst, src, n); +} + // Sometimes incrementing and decrementing a variable changes how registers are allocated, which helps with matching functions. Functionality-wise this doesn't do anything. #ifdef NONMATCHING #define ASM_MATCH_TRICK(a) {;} diff --git a/ld_script.txt b/ld_script.txt index 6c9cb7146..a5b09e9c8 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -533,6 +533,8 @@ SECTIONS { src/dungeon_message.o(.rodata); src/dungeon_move.o(.rodata); data/data_8106A4C.o(.rodata); + src/code_8066D04.o(.rodata); + data/data_8106A4C_2.o(.rodata); src/code_806CD90.o(.rodata); src/type_effectiveness.o(.data); data/data_8106F7C.o(.rodata); diff --git a/src/code_8066D04.c b/src/code_8066D04.c index 19382a04d..27e13b120 100644 --- a/src/code_8066D04.c +++ b/src/code_8066D04.c @@ -1,4 +1,5 @@ #include "global.h" +#include "globaldata.h" #include "code_8045A00.h" #include "dungeon_message.h" #include "code_807CD9C.h" @@ -70,19 +71,13 @@ extern const u8 *const gUnknown_80F9114; extern const u8 *const gMonDisappointedAndLeft; extern const u8 *const gSendMonBackQ; extern const u8 *const gSendMonBackWithItemQ; -extern const u8 gUnknown_8106E28[]; -extern const u8 gUnknown_8106E5C[]; -extern const u8 gUnknown_8106E30[]; -extern const u8 gUnknown_8106E6C[]; -extern const u8 gUnknown_8106E48[]; -extern const u8 gUnknown_8106E2C[]; -extern const u8 gUnknown_8106E34[]; extern const u8 *const gMonWentBack; extern const u8 *const gMonCringing; extern const u8 *const gMonParalyzed; extern const u8 *const gUnknown_80FC690; extern s32 gUnknown_202EE6C; +extern u32 gUnknown_202F208; extern void sub_8071DA4(Entity *); extern void sub_806A1B0(Entity *); @@ -112,6 +107,14 @@ extern void sub_8045DB4(DungeonPos *, u32); extern bool8 sub_80461C8(DungeonPos *, u32); extern bool32 sub_8055A00(Entity *attacker, s32 firstMoveId, s32 var_34, s32 itemId, s32 arg_0); extern bool8 sub_8044B28(void); +Entity *sub_806773C(Entity *entity); +void sub_8067558(Entity *entity, Entity *targetEntity, s32 a2); +void sub_8067794(Entity *entity, Entity *targetEntity, s32 a2); +extern void sub_807EF84(void); +extern void sub_80845E0(Entity *entity); +extern void sub_8084448(Entity *entity); +extern void sub_806A3D4(u8 *dst, s32 _a1, s32 id, bool32 _a3); +extern Entity * sub_80696A8(Entity *target); void HandlePickUpPlayerAction(Entity *entity) { @@ -161,7 +164,6 @@ void HandleSetItemAction(Entity *param_1, bool8 param_2) } } - void HandleUnsetItemAction(Entity *entity,bool8 enableMessage) { Item *item; @@ -186,7 +188,6 @@ void HandleUnsetItemAction(Entity *entity,bool8 enableMessage) } } - void HandleGiveItemAction(Entity *param_1) { Entity *entity; @@ -264,7 +265,6 @@ void HandleGiveItemAction(Entity *param_1) } } - void HandleTakeItemAction(Entity *param_1) { Entity *entity; @@ -662,15 +662,6 @@ void sub_80671A0(Entity *entity) } } -Entity *sub_806773C(Entity *entity); -void sub_8067558(Entity *entity, Entity *targetEntity, s32 a2); -void sub_8067794(Entity *entity, Entity *targetEntity, s32 a2); -extern void sub_807EF84(void); -extern void sub_80845E0(Entity *entity); -extern void sub_8084448(Entity *entity); -extern void sub_806A3D4(u8 *dst, s32 _a1, s32 id, bool32 _a3); -extern Entity * sub_80696A8(Entity *target); - void HandleTalkFieldAction(Entity *entity) { sub_8067558(entity, sub_806773C(entity), -1); @@ -850,8 +841,6 @@ void HandleUseMovePlayerAction(Entity *entity) } } -extern u32 gUnknown_202F208; - void sub_8067904(Entity *entity, u16 moveId) { Move move; @@ -928,12 +917,52 @@ void sub_806806C(PokemonStruct1 *a0); void sub_805FC30(UnkTextStruct3 *a0, s32 a1); extern void sub_803EAF0(u32, u8 *); -extern const u8 gUnknown_8106DA4[]; +extern const s32 gUnknown_8106E80[]; extern MenuInputStruct gUnknown_202EE10; -extern const UnkTextStruct3 gUnknown_8106DC8; -extern s32 gUnknown_202F30C; -extern s32 gUnknown_202F310; -extern UnkTextStruct2_sub2 gUnknown_202F308; + +static EWRAM_DATA UnkTextStruct2_sub2 gUnknown_202F308 = {0}; +static EWRAM_DATA s32 gUnknown_202F30C = 0; +EWRAM_DATA s32 gUnknown_202F310 = 0; + +// It's likely a struct only used in Blue version. Touchpad maybe? +static const u8 gUnknown_8106DA4[] = { + 0x01, 0, 0x38, 0, 0, 0, 0x18, 0, 0x18, 0, 0, 0, 0x02, 0, 0x38, 0, 0x68, 0, 0x18, 0, 0x18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +static const UnkTextStruct3 gUnknown_8106DC8 = { + .a0 = { + [0] = + { + .unk0 = 0, + .unk4 = 0x06, + .unk8 = {0x02, 0x02}, + .unkC = 0x11, + .unkE = 0x0E, + .unk10 = 0x12, + .unk12 = 0x02, + .unk14 = &gUnknown_202F308 + }, + [1] = + { + .unk0 = 0, + .unk4 = 0x03, + .unk8 = {0x15, 0x04}, + .unkC = 0x07, + .unkE = 0x04, + .unk10 = 0x04, + .unk12 = 0, + .unk14 = NULL + }, + [2] = + { + .unk4 = 0x03, + }, + [3] = + { + .unk4 = 0x03, + } + } +}; void sub_8067A80(u8 a0, s32 a1, s32 a2, PokemonStruct1 **a3) { @@ -1184,7 +1213,7 @@ void sub_8067F00(u8 a0, PokemonStruct1 **a1, s32 a2_, s32 a3, s32 a4) sub_80073B8(0); WriteFriendAreaName(gFormatBuffer_Monsters[0], a0, FALSE); - PrintFormattedStringOnWindow(12, 0, gUnknown_8106E28, 0, '\0'); + PrintFormattedStringOnWindow(12, 0, _("{POKEMON_0}"), 0, '\0'); i = 0; while (i < 10) { if (a2 >= 0) { @@ -1196,17 +1225,17 @@ void sub_8067F00(u8 a0, PokemonStruct1 **a1, s32 a2_, s32 a3, s32 a4) sub_808D930(gFormatBuffer_Monsters[1], a1[a2]->speciesNum); gFormatArgs[0] = a2 + 1; if (a1[a2]->unk0 & 0x8000) { - strcpy(gFormatBuffer_Items[0], gUnknown_8106E2C); + InlineStrcpy(gFormatBuffer_Items[0], _("{STAR_BULLET}")); } else { - strcpy(gFormatBuffer_Items[0], gUnknown_8106E30); + InlineStrcpy(gFormatBuffer_Items[0], _("{ICON_BLANK}")); } if (a1[a2]->unk0 & 0x4000) { - PrintFormattedStringOnWindow(7, y, gUnknown_8106E34, 0, '\0'); + PrintFormattedStringOnWindow(7, y, _("{MOVE_ITEM_0}{color CYAN}$v02:{POKEMON_0}{reset}"), 0, '\0'); } else { - PrintFormattedStringOnWindow(7, y, gUnknown_8106E48, 0, '\0'); + PrintFormattedStringOnWindow(7, y, _("{MOVE_ITEM_0}{color YELLOW}$v02:{POKEMON_0}{reset}"), 0, '\0'); } } @@ -1218,25 +1247,22 @@ void sub_8067F00(u8 a0, PokemonStruct1 **a1, s32 a2_, s32 a3, s32 a4) sub_80073E0(0); sub_80073B8(1); if (gUnknown_202F310 >= a4) { - PrintFormattedStringOnWindow(8, 2, gUnknown_8106E5C, 1, '\0'); + PrintFormattedStringOnWindow(8, 2, _("Press {B_BUTTON}\nif OK."), 1, '\0'); } else { gFormatArgs[0] = a4 - gUnknown_202F310; - PrintFormattedStringOnWindow(8, 2, gUnknown_8106E6C, 1, '\0'); + PrintFormattedStringOnWindow(8, 2, _("Say bye to\n{VALUE_0} more"), 1, '\0'); } sub_80073E0(1); } -extern const s32 gUnknown_8106E80[]; - void sub_806806C(PokemonStruct1 *a0) { struct unkStruct_808FF20 unkStruct; u8 var_C8[48]; UnkTextStruct3 spTxtStruct = {0}; - s32 spF8[4]; - s32 r7, r8; + s32 r7; spTxtStruct.a0[0].unk4 = 6; spTxtStruct.a0[0].unk8.unk0.separate.unk0 = 2; @@ -1256,8 +1282,8 @@ void sub_806806C(PokemonStruct1 *a0) gUnknown_202EE10.menuIndex = 0; while (1) { - r8 = 0; - memcpy(spF8, gUnknown_8106E80, sizeof(spF8)); + bool32 loopBreak = FALSE; + s32 spF8[4] = {2, 3, 4, 5}; gUnknown_202F308.f0 = 4; gUnknown_202F308.f1 = r7; @@ -1343,18 +1369,18 @@ void sub_806806C(PokemonStruct1 *a0) if ((gRealInputs.pressed & A_BUTTON) || gUnknown_202EE10.unk28.a_button) { sub_8083D08(); - r8 = 1; + loopBreak = TRUE; break; } if ((gRealInputs.pressed & B_BUTTON) || gUnknown_202EE10.unk28.b_button) { sub_8083D30(); - r8 = 1; + loopBreak = TRUE; break; } } sub_803E46C(0x37); - if (r8 != 0) { + if (loopBreak) { break; } } diff --git a/src/dungeon_message.c b/src/dungeon_message.c index dab15b7da..a6e0362ff 100644 --- a/src/dungeon_message.c +++ b/src/dungeon_message.c @@ -65,17 +65,6 @@ EWRAM_INIT u8 gUnknown_203B434 = 1; #define FLAG_CAN_SCROLL_UP 0x1 #define FLAG_CAN_SCROLL_DOWN 0x2 -// Needed to match :shrug: -static inline void InlineStrcpy(u8 *dst, const u8 *src) -{ - strcpy(dst, src); -} - -static inline void InlineStrncpy(u8 *dst, const u8 *src, s32 n) -{ - strncpy(dst, src, n); -} - void sub_80521D0(void) { s32 i; diff --git a/sym_ewram.txt b/sym_ewram.txt index 0069640b5..7e5738f9f 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -248,13 +248,7 @@ gUnknown_202F2FC: /* 202F2FC (sub_8065FB4 - sub_8066358) */ gUnknown_202F300: /* 202F300 (sub_8066434) */ .space 0x8 -gUnknown_202F308: /* 202F308 (sub_8067A80 - sub_806806C) */ - .space 0x4 -gUnknown_202F30C: /* 202F30C (sub_8067A80 - sub_8067A80) */ - .space 0x4 -gUnknown_202F310: /* 202F310 (sub_8067A80 - sub_8068310) */ - .space 0x4 - + .include "src/code_8066D04.o" .include "src/dungeon_movement.o" .include "src/code_80718D8.o"