From 6b6c98e7d0d1f0095bd1a62f1d5855b460b49f5c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 29 Mar 2019 19:41:32 -0400 Subject: [PATCH] through sub_80180E8 --- asm/union_room.s | 180 ----------------------------------------------- src/union_room.c | 92 +++++++++++++++++++++++- 2 files changed, 90 insertions(+), 182 deletions(-) diff --git a/asm/union_room.s b/asm/union_room.s index 6a2fa91e1..9bbbf52e5 100755 --- a/asm/union_room.s +++ b/asm/union_room.s @@ -5,186 +5,6 @@ .text - thumb_func_start sub_8017FD8 -sub_8017FD8: @ 8017FD8 - push {lr} - adds r2, r0, 0 - ldr r0, =gRecvCmds - ldrh r1, [r0, 0x2] - cmp r1, 0 - beq _08017FFC - cmp r1, 0x51 - beq _08017FEC - cmp r1, 0x52 - bne _08017FFC -_08017FEC: - adds r0, r2, 0 - adds r0, 0x98 - strh r1, [r0] - movs r0, 0x1 - b _08017FFE - .pool -_08017FFC: - movs r0, 0 -_08017FFE: - pop {r1} - bx r1 - thumb_func_end sub_8017FD8 - - thumb_func_start InUnionRoom -InUnionRoom: @ 8018004 - push {lr} - movs r2, 0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldrh r1, [r0, 0x4] - ldr r0, =0x00003c19 - cmp r1, r0 - bne _08018016 - movs r2, 0x1 -_08018016: - adds r0, r2, 0 - pop {r1} - bx r1 - .pool - thumb_func_end InUnionRoom - - thumb_func_start sub_8018024 -sub_8018024: @ 8018024 - push {r4-r6,lr} - movs r6, 0 - movs r5, 0 - ldr r0, =gPlayerPartyCount - ldrb r0, [r0] - cmp r6, r0 - bge _08018064 -_08018032: - movs r0, 0x64 - adds r1, r5, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x38 - bl GetMonData - cmp r0, 0x1E - bhi _0801805A - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - beq _0801805A - adds r6, 0x1 -_0801805A: - adds r5, 0x1 - ldr r0, =gPlayerPartyCount - ldrb r0, [r0] - cmp r5, r0 - blt _08018032 -_08018064: - cmp r6, 0x1 - bgt _08018074 - movs r0, 0 - b _08018076 - .pool -_08018074: - movs r0, 0x1 -_08018076: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8018024 - - thumb_func_start sub_801807C -sub_801807C: @ 801807C - movs r1, 0 - strh r1, [r0] - strh r1, [r0, 0x2] - str r1, [r0, 0x4] - strh r1, [r0, 0xA] - strh r1, [r0, 0xC] - strh r1, [r0, 0xE] - strh r1, [r0, 0x10] - str r1, [r0, 0x14] - bx lr - thumb_func_end sub_801807C - - thumb_func_start sub_8018090 -sub_8018090: @ 8018090 - push {lr} - ldr r0, =gUnknown_02022C40 - bl sub_801807C - pop {r0} - bx r0 - .pool - thumb_func_end sub_8018090 - - thumb_func_start sub_80180A0 -sub_80180A0: @ 80180A0 - push {r4,r5,lr} - adds r5, r1, 0 - movs r1, 0x64 - adds r4, r0, 0 - muls r4, r1 - ldr r0, =gPlayerParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - strh r0, [r5, 0xA] - adds r0, r4, 0 - movs r1, 0x38 - bl GetMonData - strh r0, [r5, 0xC] - adds r0, r4, 0 - movs r1, 0 - bl GetMonData - str r0, [r5, 0x4] - ldrh r1, [r5, 0xA] - movs r0, 0xCE - lsls r0, 1 - cmp r1, r0 - beq _080180E0 - movs r0, 0 - b _080180E2 - .pool -_080180E0: - movs r0, 0x1 -_080180E2: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80180A0 - - thumb_func_start sub_80180E8 -sub_80180E8: @ 80180E8 - push {r4,r5,lr} - adds r5, r1, 0 - movs r1, 0x64 - adds r4, r0, 0 - muls r4, r1 - ldr r0, =gPlayerParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - strh r0, [r5, 0xE] - adds r0, r4, 0 - movs r1, 0x38 - bl GetMonData - strh r0, [r5, 0x10] - adds r0, r4, 0 - movs r1, 0 - bl GetMonData - str r0, [r5, 0x14] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80180E8 - thumb_func_start sub_8018120 sub_8018120: @ 8018120 push {r4-r7,lr} diff --git a/src/union_room.c b/src/union_room.c index a1002b9b5..d3a9c95a0 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -107,8 +107,8 @@ bool32 sub_8016F1C(struct UnkLinkRfuStruct_02022B14 *arg0, s16 arg1); u8 sub_8016DF0(struct UnkStruct_Main4 *arg0, struct UnkStruct_Main4 *arg1, u32 arg2); void sub_8019F2C(void); void sub_8019E70(u8 *arg0, s32 arg1); -bool32 sub_80180A0(u8 monId, struct TradeUnkStruct *arg1); -void sub_80180E8(u8 monId, struct TradeUnkStruct *arg1); +bool32 sub_80180A0(u32 monId, struct TradeUnkStruct *arg1); +void sub_80180E8(u32 monId, struct TradeUnkStruct *arg1); bool32 sub_801A2A8(struct UnkStruct_Main0 *arg0, s16 *arg1, s16 *arg2, u8 *arg3); void sub_80181CC(void); bool32 sub_8017940(void); @@ -5150,3 +5150,91 @@ s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3) return result; } + +bool32 sub_8017FD8(struct UnkStruct_URoom *arg0) +{ + if (gRecvCmds[0][1] != 0) + { + if (gRecvCmds[0][1] == 0x51) + { + arg0->field_98 = 0x51; + return TRUE; + } + else if (gRecvCmds[0][1] == 0x52) + { + arg0->field_98 = 0x52; + return TRUE; + } + } + return FALSE; +} + +bool32 InUnionRoom(void) +{ + return gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(UNION_ROOM) + && gSaveBlock1Ptr->location.mapNum == MAP_NUM(UNION_ROOM) + ? TRUE : FALSE; +} + +bool32 sub_8018024(void) +{ + s32 i; + s32 count = 0; + + for (i = 0; i < gPlayerPartyCount; i++) + { + if ( GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) <= 30 + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) + { + count++; + } + } + + if (count > 1) + { + return TRUE; + } + else + { + return FALSE; + } +} + +void sub_801807C(struct TradeUnkStruct *arg0) +{ + arg0->field_0 = 0; + arg0->field_2 = 0; + arg0->field_4 = 0; + arg0->field_A = 0; + arg0->field_C = 0; + arg0->species = 0; + arg0->level = 0; + arg0->personality = 0; +} + +void sub_8018090(void) +{ + sub_801807C(&gUnknown_02022C40); +} + +bool32 sub_80180A0(u32 monId, struct TradeUnkStruct *arg1) +{ + arg1->field_A = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); + arg1->field_C = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); + arg1->field_4 = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY); + if (arg1->field_A == SPECIES_EGG) + { + return TRUE; + } + else + { + return FALSE; + } +} + +void sub_80180E8(u32 monId, struct TradeUnkStruct *arg1) +{ + arg1->species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); + arg1->level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); + arg1->personality = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY); +}