diff --git a/asm/link.s b/asm/link.s index 559bed0901..cc36859711 100644 --- a/asm/link.s +++ b/asm/link.s @@ -5,73 +5,6 @@ .text - thumb_func_start sub_8009628 -sub_8009628: @ 8009628 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_020229CC - strh r0, [r1, 0x18] - bx lr - .pool - thumb_func_end sub_8009628 - - thumb_func_start sub_8009638 -sub_8009638: @ 8009638 - push {r4,r5,lr} - ldr r5, =gUnknown_020229CC - ldr r4, =gSaveBlock2Ptr - ldr r1, [r4] - ldrb r2, [r1, 0xA] - ldrb r0, [r1, 0xB] - lsls r0, 8 - orrs r2, r0 - ldrb r0, [r1, 0xC] - lsls r0, 16 - orrs r2, r0 - ldrb r0, [r1, 0xD] - lsls r0, 24 - orrs r2, r0 - str r2, [r5, 0x4] - adds r0, r5, 0 - adds r0, 0x8 - bl StringCopy - ldr r0, [r4] - ldrb r0, [r0, 0x8] - strb r0, [r5, 0x13] - ldr r0, =gUnknown_020229C6 - ldrh r0, [r0] - str r0, [r5, 0x14] - ldr r0, =gGameLanguage - ldrb r0, [r0] - strh r0, [r5, 0x1A] - ldr r0, =gGameVersion - ldrb r0, [r0] - movs r2, 0x80 - lsls r2, 7 - adds r1, r2, 0 - adds r0, r1 - strh r0, [r5] - movs r0, 0x80 - lsls r0, 8 - strh r0, [r5, 0x2] - bl IsNationalPokedexEnabled - strb r0, [r5, 0x10] - ldr r0, =0x0000087f - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _0800969E - ldrb r0, [r5, 0x10] - movs r1, 0x10 - orrs r0, r1 - strb r0, [r5, 0x10] -_0800969E: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8009638 - thumb_func_start sub_80096BC sub_80096BC: @ 80096BC push {lr} diff --git a/include/flags.h b/include/flags.h index 7d825feba4..ce93af9851 100644 --- a/include/flags.h +++ b/include/flags.h @@ -42,7 +42,7 @@ #define FLAG_VISITED_MOSSDEEP_CITY CODE_FLAGS + 0x1C #define FLAG_VISITED_SOOTOPOLIS_CITY CODE_FLAGS + 0x1D #define FLAG_VISITED_EVER_GRANDE_CITY CODE_FLAGS + 0x1E - +#define SYS_UNKNOWN_87F CODE_FLAGS + 0x1F #define SYS_UNKNOWN_880 CODE_FLAGS + 0x20 #define SYS_USE_FLASH CODE_FLAGS + 0x28 diff --git a/src/link.c b/src/link.c index 3c1bd13b1d..f95c1acb73 100644 --- a/src/link.c +++ b/src/link.c @@ -3,6 +3,8 @@ #include "global.h" #include "librfu.h" #include "rng.h" +#include "string_util.h" +#include "event_data.h" #include "gpu_regs.h" #include "palette.h" #include "task.h" @@ -56,6 +58,7 @@ IWRAM_DATA void *gUnknown_03000DAC; IWRAM_DATA bool32 gUnknown_03000DB0; u16 gUnknown_020229C6 = 0; +struct LinkPlayer gUnknown_020229CC = {}; // Static ROM declarations @@ -178,3 +181,24 @@ void sub_8009570(void) CreateTask(task00_link_test, 0); SetMainCallback2(c2_08009A8C); } + +void sub_8009628(u8 a0) +{ + gUnknown_020229CC.lp_field_18 = a0; +} + +void sub_8009638(void) +{ + gUnknown_020229CC.trainerId = gSaveBlock2Ptr->playerTrainerId[0] | (gSaveBlock2Ptr->playerTrainerId[1] << 8) | (gSaveBlock2Ptr->playerTrainerId[2] << 16) | (gSaveBlock2Ptr->playerTrainerId[3] << 24); + StringCopy(gUnknown_020229CC.name, gSaveBlock2Ptr->playerName); + gUnknown_020229CC.gender = gSaveBlock2Ptr->playerGender; + gUnknown_020229CC.linkType = gUnknown_020229C6; + gUnknown_020229CC.language = gGameLanguage; + gUnknown_020229CC.version = gGameVersion + 0x4000; + gUnknown_020229CC.lp_field_2 = 0x8000; + gUnknown_020229CC.name[8] = IsNationalPokedexEnabled(); + if (FlagGet(SYS_UNKNOWN_87F)) + { + gUnknown_020229CC.name[8] |= 0x10; + } +}