From bf4a73a67cca44a01b8449aafb0d717551415a6b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 29 Mar 2019 16:24:48 -0400 Subject: [PATCH] through sub_8017E00 --- asm/union_room.s | 216 ----------------------------------------------- src/union_room.c | 109 ++++++++++++++++++++---- 2 files changed, 93 insertions(+), 232 deletions(-) diff --git a/asm/union_room.s b/asm/union_room.s index a8cbeeae2..4c68877a2 100755 --- a/asm/union_room.s +++ b/asm/union_room.s @@ -5,222 +5,6 @@ .text - thumb_func_start sub_8017CF8 -sub_8017CF8: @ 8017CF8 - lsls r0, 5 - adds r0, r1 - ldrb r0, [r0, 0xB] - lsls r0, 31 - lsrs r0, 31 - bx lr - thumb_func_end sub_8017CF8 - - thumb_func_start sub_8017D04 -sub_8017D04: @ 8017D04 - push {r4-r6,lr} - adds r5, r0, 0 - movs r0, 0xCE - lsls r0, 1 - cmp r1, r0 - bne _08017D44 - movs r4, 0 - b _08017D2E -_08017D14: - movs r0, 0x64 - muls r0, r4 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0x41 - bl GetMonData - adds r1, r0, 0 - movs r0, 0xCE - lsls r0, 1 - cmp r1, r0 - beq _08017D74 - adds r4, 0x1 -_08017D2E: - ldr r0, =gPlayerPartyCount - ldrb r0, [r0] - cmp r4, r0 - blt _08017D14 - movs r0, 0x2 - b _08017D90 - .pool -_08017D44: - movs r4, 0 - ldr r0, =gPlayerPartyCount - ldrb r0, [r0] - cmp r4, r0 - bge _08017D8E - ldr r6, =gBaseStats -_08017D50: - movs r0, 0x64 - muls r0, r4 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0x41 - bl GetMonData - adds r1, r0, 0 - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r1, r0, r6 - ldrb r0, [r1, 0x6] - cmp r0, r5 - beq _08017D74 - ldrb r0, [r1, 0x7] - cmp r0, r5 - bne _08017D84 -_08017D74: - movs r0, 0 - b _08017D90 - .pool -_08017D84: - adds r4, 0x1 - ldr r0, =gPlayerPartyCount - ldrb r0, [r0] - cmp r4, r0 - blt _08017D50 -_08017D8E: - movs r0, 0x1 -_08017D90: - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8017D04 - - thumb_func_start sub_8017D9C -sub_8017D9C: @ 8017D9C - push {lr} - adds r3, r0, 0 - cmp r1, 0x44 - beq _08017DD8 - cmp r1, 0x44 - bgt _08017DAE - cmp r1, 0x41 - beq _08017DB8 - b _08017DF6 -_08017DAE: - cmp r1, 0x45 - beq _08017DC8 - cmp r1, 0x48 - beq _08017DE8 - b _08017DF6 -_08017DB8: - ldr r0, =gUnknown_082EEA68 - lsls r1, r2, 2 - adds r1, r0 - ldr r1, [r1] - b _08017DDA - .pool -_08017DC8: - ldr r0, =gUnknown_082EED3C - lsls r1, r2, 2 - adds r1, r0 - ldr r1, [r1] - b _08017DDA - .pool -_08017DD8: - ldr r1, =gUnknown_082EF7B0 -_08017DDA: - adds r0, r3, 0 - bl StringExpandPlaceholders - b _08017DF6 - .pool -_08017DE8: - ldr r0, =gUnknown_082EEB08 - lsls r1, r2, 2 - adds r1, r0 - ldr r1, [r1] - adds r0, r3, 0 - bl StringExpandPlaceholders -_08017DF6: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8017D9C - - thumb_func_start sub_8017E00 -sub_8017E00: @ 8017E00 - push {r4-r6,lr} - adds r5, r0, 0 - lsls r1, 24 - lsrs r4, r1, 24 - adds r6, r4, 0 - bl GetMultiplayerId - lsls r0, 24 - lsrs r3, r0, 24 - ldr r2, =gLinkPlayers - movs r0, 0x1 - adds r1, r3, 0 - eors r1, r0 - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x13] - cmp r4, 0x44 - beq _08017E54 - cmp r4, 0x44 - bgt _08017E38 - cmp r4, 0x41 - beq _08017E3E - b _08017E94 - .pool -_08017E38: - cmp r6, 0x45 - beq _08017E78 - b _08017E94 -_08017E3E: - ldr r2, =gUnknown_082EE984 - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 3 - adds r1, r0 - b _08017E66 - .pool -_08017E54: - ldr r2, =gUnknown_082EE984 - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 3 - adds r1, r0 - adds r2, 0x8 -_08017E66: - adds r1, r2 - ldr r1, [r1] - adds r0, r5, 0 - bl StringCopy - b _08017E94 - .pool -_08017E78: - ldr r2, =gUnknown_082EE984 - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 3 - adds r1, r0 - adds r2, 0x4 - adds r1, r2 - ldr r1, [r1] - adds r0, r5, 0 - bl StringCopy -_08017E94: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8017E00 - thumb_func_start sub_8017EA0 sub_8017EA0: @ 8017EA0 push {r4-r7,lr} diff --git a/src/union_room.c b/src/union_room.c index fdd76221f..078bf9887 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -129,7 +129,7 @@ s32 sub_8017CB0(struct UnkStruct_x20 * arg, s32 arg1); bool32 sub_8018024(void); u32 sub_8017984(s32 arg0); void sub_8018220(u8 *unused, struct UnkStruct_URoom *arg1, bool8 arg2); -void sub_8017D9C(u8 *dst, u32 arg1, u32 playerGender); +void sub_8017D9C(u8 *dst, s32 arg1, u32 playerGender); u32 sub_80179AC(struct UnkStruct_x20 *arg0); void sub_8017E00(u8 *dst, u8 arg1); void sub_8019F04(u8 *spriteIds); @@ -423,23 +423,27 @@ ALIGNED(4) const u8 gUnknown_082EE92C[] = _("The trade will be started.{PAUSE 60 ALIGNED(4) const u8 gUnknown_082EE94C[] = _("The battle will be started.{PAUSE 60}"); ALIGNED(4) const u8 gUnknown_082EE96C[] = _("Entering the chat…{PAUSE 60}"); -const u8 *const gUnknown_082EE984[][3] = { +const u8 *const gUnknown_082EE984[][2][3] = { { - gUnknown_082EE94C, - gUnknown_082EE96C, - gUnknown_082EE92C + { + gUnknown_082EE94C, + gUnknown_082EE96C, + gUnknown_082EE92C + }, { + gUnknown_082EE94C, + gUnknown_082EE96C, + gUnknown_082EE92C + } }, { - gUnknown_082EE94C, - gUnknown_082EE96C, - gUnknown_082EE92C - }, { - gUnknown_082EE880, - gUnknown_082EE8B8, - gUnknown_082EE92C - }, { - gUnknown_082EE8D4, - gUnknown_082EE904, - gUnknown_082EE92C + { + gUnknown_082EE880, + gUnknown_082EE8B8, + gUnknown_082EE92C + }, { + gUnknown_082EE8D4, + gUnknown_082EE904, + gUnknown_082EE92C + } } }; @@ -5016,3 +5020,76 @@ s32 sub_8017CB0(struct UnkStruct_x20 * arg, s32 arg1) return -1; } + +s32 sub_8017CF8(s32 arg1, struct UnkStruct_Main0 *arg0) +{ + return arg0->arr[arg1].unk.field_0.playerGender; +} + +s32 sub_8017D04(u32 type, u32 species) +{ + s32 i; + + if (species == SPECIES_EGG) + { + for (i = 0; i < gPlayerPartyCount; i++) + { + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + if (species == SPECIES_EGG) + { + return 0; + } + } + return 2; + } + else + { + for (i = 0; i < gPlayerPartyCount; i++) + { + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + if (gBaseStats[species].type1 == type || gBaseStats[species].type2 == type) + { + return 0; + } + } + return 1; + } +} + +void sub_8017D9C(u8 *dst, s32 arg1, u32 playerGender) +{ + switch (arg1) + { + case 0x41: + StringExpandPlaceholders(dst, gUnknown_082EEA68[playerGender]); + break; + case 0x45: + StringExpandPlaceholders(dst, gUnknown_082EED3C[playerGender]); + break; + case 0x44: + StringExpandPlaceholders(dst, gUnknown_082EF7B0); + break; + case 0x48: + StringExpandPlaceholders(dst, gUnknown_082EEB08[playerGender]); + break; + } +} + +void sub_8017E00(u8 *dst, u8 arg1) +{ + u8 mpId = GetMultiplayerId(); + u8 gender = gLinkPlayers[mpId ^ 1].gender; + + switch (arg1) + { + case 0x41: + StringCopy(dst, gUnknown_082EE984[mpId][gender][0]); + break; + case 0x44: + StringCopy(dst, gUnknown_082EE984[mpId][gender][2]); + break; + case 0x45: + StringCopy(dst, gUnknown_082EE984[mpId][gender][1]); + break; + } +}