diff --git a/asm/link.s b/asm/link.s index e51ee1380..ff0bfb3c9 100644 --- a/asm/link.s +++ b/asm/link.s @@ -5,96 +5,6 @@ .text - thumb_func_start sub_800A23C -sub_800A23C: @ 800A23C - push {r4-r6,lr} - movs r6, 0 - movs r4, 0 - ldr r5, =gLinkPlayers - b _0800A26C - .pool -_0800A24C: - lsls r0, r4, 3 - subs r0, r4 - lsls r0, 2 - adds r1, r5, 0 - adds r1, 0x14 - adds r0, r1 - ldr r1, [r0] - ldr r0, [r5, 0x14] - cmp r1, r0 - bne _0800A266 - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_0800A266: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 -_0800A26C: - bl GetLinkPlayerCount - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - bcc _0800A24C - bl GetLinkPlayerCount - lsls r0, 24 - lsrs r0, 24 - cmp r6, r0 - bne _0800A290 - movs r2, 0x1 - ldr r0, =gUnknown_03000D5C - str r2, [r0] - b _0800A298 - .pool -_0800A290: - movs r2, 0 - ldr r1, =gUnknown_03000D5C - movs r0, 0x3 - str r0, [r1] -_0800A298: - adds r0, r2, 0 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_800A23C - - thumb_func_start GetLinkPlayerTrainerId -GetLinkPlayerTrainerId: @ 800A2A4 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gLinkPlayers - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r2, 0x4 - adds r1, r2 - ldr r0, [r1] - bx lr - .pool - thumb_func_end GetLinkPlayerTrainerId - - thumb_func_start sub_800A2BC -sub_800A2BC: @ 800A2BC - push {r4,r5,lr} - ldr r5, =gLinkPlayers - movs r4, 0x4 -_0800A2C2: - adds r0, r5, 0 - movs r1, 0 - movs r2, 0x1C - bl memset - adds r5, 0x1C - subs r4, 0x1 - cmp r4, 0 - bge _0800A2C2 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_800A2BC - thumb_func_start sub_800A2E0 sub_800A2E0: @ 800A2E0 ldr r1, =gUnknown_03000D10 diff --git a/src/link.c b/src/link.c index 5d5d22cf5..3cb485b49 100644 --- a/src/link.c +++ b/src/link.c @@ -842,3 +842,45 @@ u8 sub_800A0C8(int lower, int upper) } return gUnknown_03000D5C; } + +bool8 sub_800A23C(void) +{ + u8 i; + u8 count; + bool8 retval; + + count = 0; + for (i = 0; i < GetLinkPlayerCount(); i ++) + { + if (gLinkPlayers[i].linkType == gLinkPlayers[0].linkType) + { + count ++; + } + } + if (count == GetLinkPlayerCount()) + { + retval = TRUE; + gUnknown_03000D5C = 1; + } + else + { + retval = FALSE; + gUnknown_03000D5C = 3; + } + return retval; +} + +u32 GetLinkPlayerTrainerId(u8 who) +{ + return gLinkPlayers[who].trainerId; +} + +void sub_800A2BC(void) +{ + int i; + + for (i = 0; i <= MAX_LINK_PLAYERS; i ++) + { + gLinkPlayers[i] = (struct LinkPlayer){}; + } +}