diff --git a/asm/union_room.s b/asm/union_room.s index ec5d82918..2b1092c34 100755 --- a/asm/union_room.s +++ b/asm/union_room.s @@ -5,345 +5,6 @@ .text - thumb_func_start sub_8017734 -sub_8017734: @ 8017734 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r3, r0, 0 - mov r8, r1 - lsls r2, 24 - lsrs r6, r2, 24 - ldrb r1, [r1, 0x18] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080177A8 - movs r5, 0 - cmp r5, r6 - bge _080177A8 - movs r0, 0x4 - negs r0, r0 - mov r9, r0 - movs r1, 0x2 - negs r1, r1 - mov r12, r1 - adds r2, r3, 0 - adds r2, 0x18 - adds r1, r3, 0 -_08017766: - ldrb r0, [r2, 0x2] - movs r3, 0x3 - ands r3, r0 - cmp r3, 0 - bne _0801779E - mov r0, r8 - ldm r0!, {r4,r6,r7} - stm r1!, {r4,r6,r7} - ldm r0!, {r4,r6,r7} - stm r1!, {r4,r6,r7} - strh r3, [r2] - ldrb r1, [r2, 0x2] - mov r0, r9 - ands r0, r1 - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2, 0x2] - movs r0, 0x40 - strb r0, [r2, 0x3] - mov r0, r8 - ldrb r1, [r0, 0x18] - mov r0, r12 - ands r0, r1 - mov r1, r8 - strb r0, [r1, 0x18] - lsls r0, r5, 24 - lsrs r0, 24 - b _080177AA -_0801779E: - adds r2, 0x20 - adds r1, 0x20 - adds r5, 0x1 - cmp r5, r6 - blt _08017766 -_080177A8: - movs r0, 0xFF -_080177AA: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_8017734 - - thumb_func_start sub_80177B8 -sub_80177B8: @ 80177B8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x10 - adds r4, r1, 0 - adds r6, r3, 0 - ldr r3, [sp, 0x2C] - ldr r1, [sp, 0x30] - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r4, 24 - lsrs r4, 24 - lsls r2, 24 - lsrs r7, r2, 24 - lsls r3, 24 - lsrs r3, 24 - mov r9, r3 - lsls r1, 24 - lsrs r1, 24 - ldr r5, =gStringVar4 - adds r1, 0x1 - adds r0, r5, 0 - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r1, =gText_Colon - adds r0, r5, 0 - bl StringAppend - str r7, [sp] - movs r0, 0 - str r0, [sp, 0x4] - mov r0, r8 - movs r1, 0x1 - adds r2, r5, 0 - adds r3, r4, 0 - bl sub_80173E0 - adds r4, 0x12 - lsls r4, 24 - lsrs r4, 24 - ldrb r0, [r6, 0xA] - lsls r0, 25 - lsrs r2, r0, 25 - ldrb r1, [r6, 0x1A] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0x1 - bne _08017884 - movs r0, 0x40 - ands r2, r0 - cmp r2, 0 - bne _08017884 - adds r0, r5, 0 - adds r1, r6, 0 - bl sub_8018404 - str r7, [sp] - mov r0, r9 - str r0, [sp, 0x4] - mov r0, r8 - movs r1, 0x1 - adds r2, r5, 0 - adds r3, r4, 0 - bl sub_80173E0 - ldrb r1, [r6, 0x2] - ldrb r0, [r6, 0x3] - lsls r0, 8 - orrs r1, r0 - add r0, sp, 0x8 - movs r2, 0x2 - movs r3, 0x5 - bl ConvertIntToDecimalStringN - ldr r1, =gText_UnkCtrlCodeF907 - adds r0, r5, 0 - bl StringCopy - adds r0, r5, 0 - add r1, sp, 0x8 - bl StringAppend - movs r0, 0x1 - adds r1, r5, 0 - movs r2, 0x88 - bl GetStringRightAlignXOffset - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - str r7, [sp] - mov r0, r9 - str r0, [sp, 0x4] - mov r0, r8 - movs r1, 0x1 - adds r2, r5, 0 - bl sub_80173E0 -_08017884: - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80177B8 - - thumb_func_start sub_80178A0 -sub_80178A0: @ 80178A0 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x10 - adds r5, r3, 0 - ldr r3, [sp, 0x2C] - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - lsls r1, 24 - lsrs r6, r1, 24 - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - lsls r3, 24 - lsrs r7, r3, 24 - ldrb r1, [r5, 0x1A] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0x1 - bne _0801792A - ldr r4, =gStringVar4 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8018404 - mov r0, r8 - str r0, [sp] - str r7, [sp, 0x4] - mov r0, r9 - movs r1, 0x1 - adds r2, r4, 0 - adds r3, r6, 0 - bl sub_80173E0 - ldrb r1, [r5, 0x2] - ldrb r0, [r5, 0x3] - lsls r0, 8 - orrs r1, r0 - add r0, sp, 0x8 - movs r2, 0x2 - movs r3, 0x5 - bl ConvertIntToDecimalStringN - ldr r1, =gText_UnkCtrlCodeF907 - adds r0, r4, 0 - bl StringCopy - adds r0, r4, 0 - add r1, sp, 0x8 - bl StringAppend - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0x68 - bl GetStringRightAlignXOffset - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - mov r0, r8 - str r0, [sp] - str r7, [sp, 0x4] - mov r0, r9 - movs r1, 0x1 - adds r2, r4, 0 - bl sub_80173E0 -_0801792A: - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80178A0 - - thumb_func_start sub_8017940 -sub_8017940: @ 8017940 - push {r4,lr} - sub sp, 0x4 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl GetXYCoordsOneStepInFrontOfPlayer - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0x9 - bne _08017978 - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, 0x8 - bne _08017978 - ldr r0, =gPlayerAvatar - ldrb r0, [r0, 0x3] - cmp r0, 0x2 - beq _0801796E - cmp r0, 0 - bne _08017978 -_0801796E: - movs r0, 0x1 - b _0801797A - .pool -_08017978: - movs r0, 0 -_0801797A: - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8017940 - - thumb_func_start sub_8017984 -sub_8017984: @ 8017984 - push {lr} - cmp r0, 0x4 - beq _0801799C - cmp r0, 0x4 - ble _080179A4 - cmp r0, 0x5 - beq _08017998 - cmp r0, 0x8 - beq _080179A0 - b _080179A4 -_08017998: - movs r0, 0x1 - b _080179A6 -_0801799C: - movs r0, 0x2 - b _080179A6 -_080179A0: - movs r0, 0x3 - b _080179A6 -_080179A4: - movs r0, 0 -_080179A6: - pop {r1} - bx r1 - thumb_func_end sub_8017984 - - thumb_func_start sub_80179AC -sub_80179AC: @ 80179AC - push {r4,lr} - sub sp, 0x20 - adds r4, r0, 0 - mov r0, sp - adds r1, r4, 0 - bl sub_8018404 - adds r4, 0x2 - adds r0, r4, 0 - bl ReadAsU16 - lsls r0, 16 - lsrs r0, 16 - mov r1, sp - bl sub_800E540 - add sp, 0x20 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80179AC - thumb_func_start sub_80179D4 sub_80179D4: @ 80179D4 push {r4-r6,lr} diff --git a/src/union_room.c b/src/union_room.c index 620a13e58..4c9cb3886 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -35,6 +35,7 @@ #include "field_screen_effect.h" #include "script_pokemon_util_80F87D8.h" #include "international_string_util.h" +#include "field_player_avatar.h" #include "mevent.h" struct UnkStruct_Shared @@ -222,7 +223,7 @@ void sub_80149C4(void); u8 sub_80132D4(struct UnkStruct_Main0 *arg0); void sub_80178A0(u8 arg0, u8 arg1, u8 arg2, struct UnkStruct_x20 *arg3, u8 arg4, u8 id); u32 sub_80176E4(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1); -u8 sub_8017734(struct UnkStruct_x20 *arg0, struct UnkStruct_Shared *arg1, u8 arg2); +u8 sub_8017734(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1, u8 arg2); u8 sub_8013E44(void); u32 sub_8013B8C(struct UnkStruct_Group *arg0, s32 id); void sub_8013BD8(struct UnkStruct_Group *arg0, s32 id); @@ -267,7 +268,7 @@ s32 sub_8017178(u8 *arg0, u8 *arg1, u8 *arg2, const struct WindowTemplate *winTe s32 sub_80172A0(u8 *arg0, u8 *arg1, u8 *arg2, u8 *arg3, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate, struct UnkStruct_Main0 *arg6); s32 sub_8017CB0(struct UnkStruct_Main0 * arg); bool32 sub_8018024(void); -u32 sub_8017984(u32 arg0); +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); u32 sub_80179AC(struct UnkStruct_x20 *arg0); @@ -380,6 +381,8 @@ extern const struct UnkStruct_Shared gUnknown_082F045C; extern const u8 *const gUnknown_082F04D8[22]; +extern const u8 gText_Colon[]; + // code void nullsub_89(void) { @@ -973,7 +976,7 @@ u8 sub_80132D4(struct UnkStruct_Main0 *arg0) } for (id = 0; id < 4; id++) - sub_8017734(data->field_0->arr, &data->field_4->arr[id].unk0, 5); + sub_8017734(data->field_0->arr, &data->field_4->arr[id], 5); if (ret != 2) { @@ -1498,7 +1501,7 @@ u8 sub_8013E44(void) for (id = 0; id < 4; id++) { - if (sub_8017734(data->field_0->arr, &data->field_4->arr[id].unk0, 16) != 0xFF) + if (sub_8017734(data->field_0->arr, &data->field_4->arr[id], 16) != 0xFF) ret = 1; } @@ -3465,7 +3468,7 @@ u8 sub_8016B00(void) } for (i = 0; i < 4; i++) { - if (sub_8017734(&structPtr->field_0->arr[0], &structPtr->field_4->arr[i].unk0, 8) != 0xFF) + if (sub_8017734(&structPtr->field_0->arr[0], &structPtr->field_4->arr[i], 8) != 0xFF) r7 = 1; } @@ -4115,3 +4118,105 @@ u32 sub_80176E4(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1) return result; } + +u8 sub_8017734(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1, u8 arg2) +{ + s32 i; + + if (arg1->unk18) + { + for (i = 0; i < arg2; i++) + { + if (arg0[i].field_1A_0 == 0) + { + arg0[i].unk = arg1->unk0; + arg0[i].field_18 = 0; + arg0[i].field_1A_0 = 1; + arg0[i].field_1B = 64; + arg1->unk18 = FALSE; + return i; + } + } + } + + return 0xFF; +} + +void sub_80177B8(u8 arg0, u8 arg1, u8 arg2, struct UnkStruct_x20 *arg3, u8 arg4, u8 id) +{ + u8 r2; + u8 sp0[6]; + + ConvertIntToDecimalStringN(gStringVar4, id + 1, STR_CONV_MODE_LEADING_ZEROS, 2); + StringAppend(gStringVar4, gText_Colon); + sub_80173E0(arg0, 1, gStringVar4, arg1, arg2, 0); + arg1 += 18; + r2 = arg3->unk.field_0.unk_0a_0; + if (arg3->field_1A_0 == 1 && !(r2 & 0x40)) + { + sub_8018404(gStringVar4, arg3); + sub_80173E0(arg0, 1, gStringVar4, arg1, arg2, arg4); + ConvertIntToDecimalStringN(sp0, arg3->unk.field_0.unk_00.playerTrainerId[0] | (arg3->unk.field_0.unk_00.playerTrainerId[1] << 8), STR_CONV_MODE_LEADING_ZEROS, 5); + StringCopy(gStringVar4, gText_UnkCtrlCodeF907); + StringAppend(gStringVar4, sp0); + sub_80173E0(arg0, 1, gStringVar4, GetStringRightAlignXOffset(1, gStringVar4, 0x88), arg2, arg4); + } +} + +void sub_80178A0(u8 arg0, u8 arg1, u8 arg2, struct UnkStruct_x20 *arg3, u8 arg4, u8 id) +{ + u8 sp0[6]; + + if (arg3->field_1A_0 == 1) + { + sub_8018404(gStringVar4, arg3); + sub_80173E0(arg0, 1, gStringVar4, arg1, arg2, arg4); + ConvertIntToDecimalStringN(sp0, arg3->unk.field_0.unk_00.playerTrainerId[0] | (arg3->unk.field_0.unk_00.playerTrainerId[1] << 8), STR_CONV_MODE_LEADING_ZEROS, 5); + StringCopy(gStringVar4, gText_UnkCtrlCodeF907); + StringAppend(gStringVar4, sp0); + sub_80173E0(arg0, 1, gStringVar4, GetStringRightAlignXOffset(1, gStringVar4, 0x68), arg2, arg4); + } +} + +bool32 sub_8017940(void) +{ + s16 x, y; + GetXYCoordsOneStepInFrontOfPlayer(&x, &y); + if (x != 9) + { + return FALSE; + } + if (y != 8) + { + return FALSE; + } + if (gPlayerAvatar.tileTransitionState == 2 || gPlayerAvatar.tileTransitionState == 0) + { + return TRUE; + } + + return FALSE; +} + +u32 sub_8017984(s32 arg0) +{ + switch (arg0) + { + case 5: + return 1; + case 4: + return 2; + case 8: + return 3; + case 3: + default: + return 0; + } +} + +u32 sub_80179AC(struct UnkStruct_x20 *arg0) +{ + u8 sp0[30]; + sub_8018404(sp0, arg0); + return sub_800E540(ReadAsU16(arg0->unk.field_0.unk_00.playerTrainerId), sp0); +}