diff --git a/asm/union_room.s b/asm/union_room.s index a310dcaa6..ec5d82918 100755 --- a/asm/union_room.s +++ b/asm/union_room.s @@ -5,250 +5,6 @@ .text - thumb_func_start sub_8017580 -sub_8017580: @ 8017580 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0 - beq _080175D8 - ldr r2, =gUnknown_082F045C - mov r8, r2 - movs r5, 0 - mov r9, r5 - movs r6, 0x4 - negs r6, r6 - mov r12, r6 - adds r2, r0, 0 - adds r2, 0x18 - adds r4, r0, 0 - movs r7, 0xFF - mov r10, r7 - adds r3, r1, 0 -_080175AC: - adds r1, r4, 0 - mov r0, r8 - ldm r0!, {r5-r7} - stm r1!, {r5-r7} - ldm r0!, {r5-r7} - stm r1!, {r5-r7} - mov r0, r10 - strh r0, [r2] - ldrb r1, [r2, 0x2] - mov r0, r12 - ands r0, r1 - movs r1, 0x5 - negs r1, r1 - ands r0, r1 - strb r0, [r2, 0x2] - mov r5, r9 - strb r5, [r2, 0x3] - adds r2, 0x20 - adds r4, 0x20 - subs r3, 0x1 - cmp r3, 0 - bne _080175AC -_080175D8: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8017580 - - thumb_func_start sub_80175EC -sub_80175EC: @ 80175EC - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r1, =gUnknown_082F045C - mov r12, r1 - movs r5, 0x2 - negs r5, r5 - mov r8, r5 - adds r2, r0, 0 - adds r2, 0x18 - adds r3, r0, 0 - movs r4, 0x3 -_08017604: - adds r1, r3, 0 - mov r0, r12 - ldm r0!, {r5-r7} - stm r1!, {r5-r7} - ldm r0!, {r5-r7} - stm r1!, {r5-r7} - ldrb r1, [r2] - mov r0, r8 - ands r0, r1 - strb r0, [r2] - adds r2, 0x1C - adds r3, 0x1C - subs r4, 0x1 - cmp r4, 0 - bge _08017604 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80175EC - - thumb_func_start sub_8017630 -sub_8017630: @ 8017630 - push {r4-r6,lr} - adds r5, r0, 0 - adds r6, r1, 0 - movs r2, 0 - adds r4, r5, 0x2 - adds r3, r6, 0x2 -_0801763C: - adds r0, r4, r2 - adds r1, r3, r2 - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bne _08017664 - adds r2, 0x1 - cmp r2, 0x1 - ble _0801763C - movs r2, 0 - adds r4, r5, 0 - adds r4, 0x10 - adds r3, r6, 0 - adds r3, 0x10 -_08017658: - adds r0, r4, r2 - adds r1, r3, r2 - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - beq _08017668 -_08017664: - movs r0, 0x1 - b _08017670 -_08017668: - adds r2, 0x1 - cmp r2, 0x7 - ble _08017658 - movs r0, 0 -_08017670: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8017630 - - thumb_func_start sub_8017678 -sub_8017678: @ 8017678 - push {r4-r6,lr} - adds r5, r0, 0 - adds r6, r1, 0 - ldrb r3, [r5, 0xA] - movs r0, 0x7F - ldrb r2, [r6, 0xA] - adds r1, r0, 0 - ands r1, r3 - ands r0, r2 - cmp r1, r0 - bne _080176DC - movs r0, 0x80 - adds r1, r0, 0 - ands r1, r3 - ands r0, r2 - cmp r1, r0 - bne _080176DC - movs r2, 0 - adds r4, r5, 0x4 - adds r3, r6, 0x4 -_080176A0: - adds r0, r4, r2 - adds r1, r3, r2 - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bne _080176DC - adds r2, 0x1 - cmp r2, 0x3 - ble _080176A0 - ldrh r2, [r5, 0x8] - ldr r0, =0x000003ff - ldrh r3, [r6, 0x8] - adds r1, r0, 0 - ands r1, r2 - ands r0, r3 - cmp r1, r0 - bne _080176DC - ldrb r2, [r5, 0x9] - movs r0, 0xFC - ldrb r3, [r6, 0x9] - adds r1, r0, 0 - ands r1, r2 - ands r0, r3 - cmp r1, r0 - bne _080176DC - movs r0, 0 - b _080176DE - .pool -_080176DC: - movs r0, 0x1 -_080176DE: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8017678 - - thumb_func_start sub_80176E4 -sub_80176E4: @ 80176E4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - mov r8, r0 - movs r7, 0xFF - movs r6, 0 - adds r4, r1, 0 - adds r4, 0x18 - adds r5, r1, 0 -_080176F6: - ldrb r1, [r4] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0801771E - mov r0, r8 - adds r1, r5, 0 - bl sub_8017630 - lsls r0, 24 - cmp r0, 0 - bne _0801771E - lsls r0, r6, 24 - lsrs r7, r0, 24 - ldrb r0, [r4] - movs r2, 0x2 - negs r2, r2 - adds r1, r2, 0 - ands r0, r1 - strb r0, [r4] -_0801771E: - adds r4, 0x1C - adds r5, 0x1C - adds r6, 0x1 - cmp r6, 0x3 - ble _080176F6 - adds r0, r7, 0 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80176E4 - thumb_func_start sub_8017734 sub_8017734: @ 8017734 push {r4-r7,lr} diff --git a/src/union_room.c b/src/union_room.c index 7a45724e5..620a13e58 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -228,7 +228,7 @@ u32 sub_8013B8C(struct UnkStruct_Group *arg0, s32 id); void sub_8013BD8(struct UnkStruct_Group *arg0, s32 id); void sub_80173D4(void); void sub_80177B8(u8 arg0, u8 arg1, u8 arg2, struct UnkStruct_x20 *arg3, u8 arg4, u8 id); -bool32 sub_8017678(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1); +bool32 sub_8017678(struct UnkStruct_Shared *arg0, struct UnkStruct_Shared *arg1); u32 sub_8018120(struct TradeUnkStruct *arg0, u8 multiplayerId); void sub_801807C(struct TradeUnkStruct *arg0); void sub_801AC54(void); @@ -1456,7 +1456,7 @@ u8 sub_8013E44(void) { if (data->field_0->arr[i].field_1A_0 == 1) { - if (sub_8017678(&data->field_0->arr[i], &data->field_4->arr[id])) + if (sub_8017678(&data->field_0->arr[i].unk, &data->field_4->arr[id].unk0)) { data->field_0->arr[i].unk = data->field_4->arr[id].unk0; data->field_0->arr[i].field_1B = 0x40; @@ -3423,7 +3423,7 @@ u8 sub_8016B00(void) { if (structPtr->field_0->arr[j].field_1A_0 == 1) { - if (sub_8017678(&structPtr->field_0->arr[j], &structPtr->field_4->arr[i])) + if (sub_8017678(&structPtr->field_0->arr[j].unk, &structPtr->field_4->arr[i].unk0)) { structPtr->field_0->arr[j].unk = structPtr->field_4->arr[i].unk0; structPtr->field_0->arr[j].field_1B = 0x40; @@ -4015,3 +4015,103 @@ void sub_80173E0(u8 windowId, u8 arg1, const u8 *str, u8 arg3, u8 arg4, u8 arg5) AddTextPrinter(&sp0, 0xFF, NULL); } + +void sub_8017580(struct UnkStruct_x20 *arg0, u8 count) +{ + s32 i; + + for (i = 0; i < count; i++) + { + arg0[i].unk = gUnknown_082F045C; + arg0[i].field_18 = 0xFF; + arg0[i].field_1A_0 = 0; + arg0[i].field_1A_1 = 0; + arg0[i].field_1B = 0; + } +} + +void sub_80175EC(struct UnkStruct_Main4 *arg0, u8 count) +{ + s32 i; + + for (i = 0; i < 4; i++) + { + arg0->arr[i].unk0 = gUnknown_082F045C; + arg0->arr[i].unk18 = 0; + } +} + +bool8 sub_8017630(struct UnkStruct_Shared* arg0, const struct UnkStruct_Shared* arg1) +{ + s32 i; + + for (i = 0; i < 2; i++) + { + if (arg0->field_0.unk_00.playerTrainerId[i] != arg1->field_0.unk_00.playerTrainerId[i]) + { + return TRUE; + } + } + + for (i = 0; i < 8; i++) + { + if (arg0->playerName[i] != arg1->playerName[i]) + { + return TRUE; + } + } + + return FALSE; +} + +bool32 sub_8017678(struct UnkStruct_Shared *arg0, struct UnkStruct_Shared *arg1) +{ + s32 i; + + if (arg0->field_0.unk_0a_0 != arg1->field_0.unk_0a_0) + { + return TRUE; + } + + if (arg0->field_0.unk_0a_7 != arg1->field_0.unk_0a_7) + { + return TRUE; + } + + for (i = 0; i < 4; i++) + { + if (arg0->field_0.unk_04[i] != arg1->field_0.unk_04[i]) + { + return TRUE; + } + } + + if (arg0->field_0.species != arg1->field_0.species) + { + return TRUE; + } + + if (arg0->field_0.type != arg1->field_0.type) + { + return TRUE; + } + + return FALSE; +} + +u32 sub_80176E4(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1) +{ + u8 result = 0xFF; + s32 i; + + for (i = 0; i < 4; i++) + { + if (arg1[i].unk18 && !sub_8017630(&arg0->unk, &arg1[i].unk0)) + { + result = i; + arg1[i].unk18 = FALSE; + } + } + + return result; +}