diff --git a/asm/lilycove_lady.s b/asm/lilycove_lady.s index 0f66eae84..bb044a01e 100644 --- a/asm/lilycove_lady.s +++ b/asm/lilycove_lady.s @@ -5,132 +5,6 @@ .text - thumb_func_start sub_818E13C -sub_818E13C: @ 818E13C - push {r4-r7,lr} - movs r7, 0x1 - ldr r5, =gUnknown_0203CD68 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r2, =0x00003b58 - adds r0, r1, r2 - str r0, [r5] - ldrb r0, [r0, 0x18] - cmp r0, 0xFF - bne _0818E174 - ldr r0, =gStringVar1 - ldr r1, =gUnknown_085EEB7E - bl StringCopy7 - movs r7, 0 - b _0818E1DC - .pool -_0818E174: - ldr r4, =gStringVar1 - ldr r0, =0x00003b70 - adds r1, r0 - adds r0, r4, 0 - bl StringCopy7 - ldr r0, [r5] - adds r0, 0x2D - ldrb r1, [r0] - adds r0, r4, 0 - bl ConvertInternationalString - ldr r0, [r5] - adds r0, 0x18 - bl sub_818E258 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r6, =gSaveBlock2Ptr - ldr r0, [r6] - bl sub_818E258 - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - bne _0818E1DC - ldr r0, [r5] - movs r2, 0 - cmp r2, r4 - bcs _0818E1DC - ldr r1, [r6] - ldrb r0, [r0, 0x18] - ldrb r1, [r1] - cmp r0, r1 - bne _0818E1DA -_0818E1BA: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, r4 - bcs _0818E1DC - ldr r0, =gUnknown_0203CD68 - ldr r1, [r0] - adds r1, 0x18 - adds r1, r2 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - adds r0, r2 - ldrb r1, [r1] - ldrb r0, [r0] - cmp r1, r0 - beq _0818E1BA -_0818E1DA: - movs r7, 0x2 -_0818E1DC: - adds r0, r7, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_818E13C - - thumb_func_start sub_818E1F4 -sub_818E1F4: @ 818E1F4 - push {r4-r6,lr} - ldr r3, =gUnknown_0203CD68 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r2, =0x00003b58 - adds r0, r1, r2 - str r0, [r3] - movs r5, 0 - movs r4, 0 - ldr r0, =0x00003b78 - adds r1, r0 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldrh r1, [r1] - adds r6, r3, 0 - adds r3, r0, 0 - ldrb r2, [r2, 0xA] - cmp r1, r2 - bne _0818E23A -_0818E21A: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bhi _0818E23C - ldr r1, [r6] - lsls r0, r4, 1 - adds r1, 0x20 - adds r1, r0 - ldr r0, [r3] - adds r0, 0xA - adds r0, r4 - ldrh r1, [r1] - ldrb r0, [r0] - cmp r1, r0 - beq _0818E21A -_0818E23A: - movs r5, 0x1 -_0818E23C: - adds r0, r5, 0 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_818E1F4 - thumb_func_start sub_818E258 sub_818E258: @ 818E258 push {lr} diff --git a/include/global.h b/include/global.h index 84c70a16e..569345355 100644 --- a/include/global.h +++ b/include/global.h @@ -674,9 +674,8 @@ struct LilycoveLadyQuiz /*0x002*/ u16 unk_002[9]; /*0x014*/ u16 unk_014; /*0x016*/ u16 unk_016; - /*0x018*/ u8 unk_018; - /*0x019*/ u8 filler_019[7]; - /*0x020*/ u16 unk_020[4]; + /*0x018*/ u8 playerName[8]; + /*0x020*/ u16 playerTrainerId[4]; /*0x028*/ u16 unk_028; /*0x02a*/ u8 unk_02a; /*0x02b*/ u8 unk_02b; @@ -690,9 +689,8 @@ struct LilycoveLadyFavour /*0x001*/ u8 unk_001; /*0x002*/ u8 unk_002; /*0x003*/ u8 unk_003; - /*0x004*/ u8 unk_004[8]; + /*0x004*/ u8 playerName[8]; /*0x00c*/ u8 unk_00c; - /*0x00d*/ u8 filler_00d; /*0x00e*/ u16 itemId; /*0x010*/ u16 unk_010; /*0x012*/ u8 language; diff --git a/src/lilycove_lady.c b/src/lilycove_lady.c index 93c3cce67..196867369 100644 --- a/src/lilycove_lady.c +++ b/src/lilycove_lady.c @@ -23,6 +23,7 @@ void sub_818E674(void); bool32 sub_811F8D8(u16); u8 sub_818E13C(void); bool8 sub_818E1F4(void); +u8 sub_818E258(const u8 *); extern const u16 gUnknown_0860B074[5]; extern const u16 gUnknown_0860B07E[3]; @@ -32,6 +33,7 @@ extern const u16 gUnknown_0860B304[6]; extern const u16 *const gUnknown_0860B1A4[16]; extern const u16 gUnknown_0860B1E4[16]; extern const u16 gUnknown_0860B204[16]; +extern const u8 gUnknown_085EEB7E[8]; EWRAM_DATA struct LilycoveLadyFavour *gUnknown_0203CD64 = NULL; EWRAM_DATA struct LilycoveLadyQuiz *gUnknown_0203CD68 = NULL; @@ -144,7 +146,7 @@ void SetLilycoveFavourLady(void) gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour; gUnknown_0203CD64->id = LILYCOVE_LADY_FAVOUR; gUnknown_0203CD64->unk_001 = 0; - gUnknown_0203CD64->unk_004[0] = EOS; + gUnknown_0203CD64->playerName[0] = EOS; gUnknown_0203CD64->unk_002 = 0; gUnknown_0203CD64->unk_003= 0; gUnknown_0203CD64->itemId = ITEM_NONE; @@ -190,9 +192,9 @@ void sub_818DC2C(void) bool8 sub_818DC60(void) { gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour; - if (gUnknown_0203CD64->unk_004[0] != EOS) + if (gUnknown_0203CD64->playerName[0] != EOS) { - StringCopy7(gStringVar3, gUnknown_0203CD64->unk_004); + StringCopy7(gStringVar3, gUnknown_0203CD64->playerName); ConvertInternationalString(gStringVar3, gUnknown_0203CD64->language); return TRUE; } @@ -219,7 +221,7 @@ void sub_818DCF4(const u8 *src, u8 *dest) void sub_818DD14(void) { gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour; - sub_818DCF4(gUnknown_0203CD64->unk_004, gStringVar3); + sub_818DCF4(gUnknown_0203CD64->playerName, gStringVar3); ConvertInternationalString(gStringVar3, gUnknown_0203CD64->language); } @@ -245,7 +247,7 @@ bool8 sub_818DD84(u16 itemId) gUnknown_0203CD64->unk_001 = 1; sub_818DCAC(gStringVar2, itemId); gUnknown_0203CD64->itemId = itemId; - sub_818DCF4(gSaveBlock2Ptr->playerName, gUnknown_0203CD64->unk_004); + sub_818DCF4(gSaveBlock2Ptr->playerName, gUnknown_0203CD64->playerName); gUnknown_0203CD64->language = gGameLanguage; response = FALSE; for (i = 0; i < len; i ++) @@ -311,7 +313,7 @@ void sub_818DF00(void) { u8 v0; u8 i; - + v0 = Random() % 16; for (i = 0; i < 9; i ++) { @@ -320,7 +322,7 @@ void sub_818DF00(void) gUnknown_0203CD68->unk_014 = gUnknown_0860B1E4[v0]; gUnknown_0203CD68->unk_028 = gUnknown_0860B204[v0]; gUnknown_0203CD68->unk_02b = v0; - gUnknown_0203CD68->unk_018 = 0xFF; + gUnknown_0203CD68->playerName[0] = EOS; } void SetLilycoveQuizLady(void) @@ -338,7 +340,7 @@ void SetLilycoveQuizLady(void) gUnknown_0203CD68->unk_016 = -1; for (i = 0; i < 4; i ++) { - gUnknown_0203CD68->unk_020[i] = 0; + gUnknown_0203CD68->playerTrainerId[i] = 0; } gUnknown_0203CD68->unk_028 = 0; gUnknown_0203CD68->unk_02a = 0; @@ -398,7 +400,7 @@ u8 sub_818E06C(void) quiz->unk_014 = gUnknown_0860B1E4[i]; quiz->unk_028 = gUnknown_0860B204[i]; quiz->unk_02b = i; - quiz->unk_018 = 0xFF; + quiz->playerName[0] = EOS; } rv = sub_818E13C(); if (rv == 0) @@ -414,3 +416,135 @@ u8 sub_818E06C(void) return 0; } } + +#ifdef NONMATCHING +u8 sub_818E13C(void) +{ + u8 retval; + u8 len; + u8 i; + + retval = 1; + gUnknown_0203CD68 = &gSaveBlock1Ptr->lilycoveLady.quiz; + if (gUnknown_0203CD68->playerName[0] == EOS) + { + StringCopy7(gStringVar1, gUnknown_085EEB7E); + retval = 0; + } + else + { + StringCopy7(gStringVar1, gUnknown_0203CD68->playerName); + ConvertInternationalString(gStringVar1, gUnknown_0203CD68->language); + len = sub_818E258(gUnknown_0203CD68->playerName); + if (len == sub_818E258(gSaveBlock2Ptr->playerName)) + { + for (i = 0; i < len; i ++) + { + if (gUnknown_0203CD68->playerName[i] != gSaveBlock2Ptr->playerName[i]) + { + retval = 2; + break; + } + } + } + + } + return retval; +} +#else +__attribute__((naked)) u8 sub_818E13C(void) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tmovs r7, 0x1\n" + "\tldr r5, =gUnknown_0203CD68\n" + "\tldr r0, =gSaveBlock1Ptr\n" + "\tldr r1, [r0]\n" + "\tldr r2, =0x00003b58\n" + "\tadds r0, r1, r2\n" + "\tstr r0, [r5]\n" + "\tldrb r0, [r0, 0x18]\n" + "\tcmp r0, 0xFF\n" + "\tbne _0818E174\n" + "\tldr r0, =gStringVar1\n" + "\tldr r1, =gUnknown_085EEB7E\n" + "\tbl StringCopy7\n" + "\tmovs r7, 0\n" + "\tb _0818E1DC\n" + "\t.pool\n" + "_0818E174:\n" + "\tldr r4, =gStringVar1\n" + "\tldr r0, =0x00003b70\n" + "\tadds r1, r0\n" + "\tadds r0, r4, 0\n" + "\tbl StringCopy7\n" + "\tldr r0, [r5]\n" + "\tadds r0, 0x2D\n" + "\tldrb r1, [r0]\n" + "\tadds r0, r4, 0\n" + "\tbl ConvertInternationalString\n" + "\tldr r0, [r5]\n" + "\tadds r0, 0x18\n" + "\tbl sub_818E258\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tldr r6, =gSaveBlock2Ptr\n" + "\tldr r0, [r6]\n" + "\tbl sub_818E258\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tcmp r4, r0\n" + "\tbne _0818E1DC\n" + "\tldr r0, [r5]\n" + "\tmovs r2, 0\n" + "\tcmp r2, r4\n" + "\tbcs _0818E1DC\n" + "\tldr r1, [r6]\n" + "\tldrb r0, [r0, 0x18]\n" + "\tldrb r1, [r1]\n" + "\tcmp r0, r1\n" + "\tbne _0818E1DA\n" + "_0818E1BA:\n" + "\tadds r0, r2, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r2, r0, 24\n" + "\tcmp r2, r4\n" + "\tbcs _0818E1DC\n" + "\tldr r0, =gUnknown_0203CD68\n" + "\tldr r1, [r0]\n" + "\tadds r1, 0x18\n" + "\tadds r1, r2\n" + "\tldr r0, =gSaveBlock2Ptr\n" + "\tldr r0, [r0]\n" + "\tadds r0, r2\n" + "\tldrb r1, [r1]\n" + "\tldrb r0, [r0]\n" + "\tcmp r1, r0\n" + "\tbeq _0818E1BA\n" + "_0818E1DA:\n" + "\tmovs r7, 0x2\n" + "_0818E1DC:\n" + "\tadds r0, r7, 0\n" + "\tpop {r4-r7}\n" + "\tpop {r1}\n" + "\tbx r1\n" + "\t.pool"); +} +#endif + +u8 sub_818E1F4(void) +{ + u8 response; + u8 i; + + gUnknown_0203CD68 = &gSaveBlock1Ptr->lilycoveLady.quiz; + response = 0; + for (i = 0; i < 4; i ++) + { + if (gUnknown_0203CD68->playerTrainerId[i] != gSaveBlock2Ptr->playerTrainerId[i]) + { + response = 1; + break; + } + } + return response; +}