diff --git a/asm/link.s b/asm/link.s index 2142d593e5..e51ee1380b 100644 --- a/asm/link.s +++ b/asm/link.s @@ -5,173 +5,6 @@ .text - thumb_func_start sub_800A0C8 -sub_800A0C8: @ 800A0C8 - push {r4-r7,lr} - adds r5, r0, 0 - adds r6, r1, 0 - movs r7, 0 - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r4, [r0] - cmp r4, 0x1 - beq _0800A0DA - b _0800A214 -_0800A0DA: - bl sub_800ABAC - lsls r0, 24 - lsrs r0, 24 - cmp r5, r0 - bgt _0800A0EA - cmp r0, r6 - ble _0800A0FC -_0800A0EA: - ldr r1, =gUnknown_03000D5C - movs r0, 0x6 - str r0, [r1] - b _0800A22E - .pool -_0800A0FC: - bl GetLinkPlayerCount - lsls r0, 24 - cmp r0, 0 - bne _0800A10E - ldr r0, =gUnknown_0300306C - strb r4, [r0] - bl sub_80097E8 -_0800A10E: - movs r6, 0 - ldr r4, =gLinkPlayers - movs r5, 0 - b _0800A134 - .pool -_0800A120: - adds r0, r4, 0 - adds r0, 0x14 - adds r0, r5, r0 - ldr r1, [r0] - ldr r0, [r4, 0x14] - cmp r1, r0 - bne _0800A130 - adds r7, 0x1 -_0800A130: - adds r5, 0x1C - adds r6, 0x1 -_0800A134: - bl GetLinkPlayerCount - lsls r0, 24 - lsrs r0, 24 - cmp r6, r0 - blt _0800A120 - bl GetLinkPlayerCount - lsls r0, 24 - lsrs r0, 24 - cmp r7, r0 - bne _0800A1AC - ldr r0, =gLinkPlayers - ldr r1, [r0, 0x14] - ldr r0, =0x00001133 - cmp r1, r0 - bne _0800A19C - bl sub_807A728 - cmp r0, 0x1 - beq _0800A184 - cmp r0, 0x1 - bgt _0800A178 - cmp r0, 0 - beq _0800A19C - ldr r3, =gUnknown_03000D5C - b _0800A22C - .pool -_0800A178: - cmp r0, 0x2 - beq _0800A190 - ldr r3, =gUnknown_03000D5C - b _0800A22C - .pool -_0800A184: - ldr r1, =gUnknown_03000D5C - movs r0, 0x4 - b _0800A1A0 - .pool -_0800A190: - ldr r1, =gUnknown_03000D5C - movs r0, 0x5 - b _0800A1A0 - .pool -_0800A19C: - ldr r1, =gUnknown_03000D5C - movs r0, 0x1 -_0800A1A0: - str r0, [r1] - adds r3, r1, 0 - b _0800A22C - .pool -_0800A1AC: - ldr r6, =gUnknown_03000D5C - movs r0, 0x3 - str r0, [r6] - ldr r4, =gLinkPlayers - bl GetMultiplayerId - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r4, 0x14 - adds r1, r4 - ldr r5, [r1] - bl GetMultiplayerId - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r4 - ldr r1, [r1] - ldr r2, =0x00002266 - cmp r5, r2 - bne _0800A1EA - ldr r0, =0x00002277 - cmp r1, r0 - beq _0800A1F6 -_0800A1EA: - ldr r0, =0x00002277 - adds r3, r6, 0 - cmp r5, r0 - bne _0800A22C - cmp r1, r2 - bne _0800A22C -_0800A1F6: - ldr r1, =gSpecialVar_0x8005 - movs r0, 0x3 - strh r0, [r1] - ldr r3, =gUnknown_03000D5C - b _0800A22C - .pool -_0800A214: - ldr r0, =gUnknown_020229C8 - ldrh r1, [r0] - adds r1, 0x1 - strh r1, [r0] - lsls r1, 16 - movs r0, 0x96 - lsls r0, 18 - ldr r3, =gUnknown_03000D5C - cmp r1, r0 - bls _0800A22C - movs r0, 0x2 - str r0, [r3] -_0800A22C: - ldrb r0, [r3] -_0800A22E: - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_800A0C8 - thumb_func_start sub_800A23C sub_800A23C: @ 800A23C push {r4-r6,lr} diff --git a/include/trade.h b/include/trade.h new file mode 100644 index 0000000000..15438ff3fd --- /dev/null +++ b/include/trade.h @@ -0,0 +1,12 @@ +#ifndef GUARD_TRADE_H +#define GUARD_TRADE_H + +// Exported type declarations + +// Exported RAM declarations + +// Exported ROM declarations + +int sub_807A728(void); + +#endif //GUARD_TRADE_H diff --git a/src/link.c b/src/link.c index 66c7c58017..5d5d22cf56 100644 --- a/src/link.c +++ b/src/link.c @@ -13,6 +13,7 @@ #include "gpu_regs.h" #include "palette.h" #include "task.h" +#include "trade.h" #include "link.h" // Static type declarations @@ -768,3 +769,76 @@ void sub_800A0AC(void) gUnknown_020229C8 = 0; sub_8009734(); } + +u8 sub_800A0C8(int lower, int upper) +{ + int i; + int count; + u32 index; + u8 cmpVal; + u32 linkType1; + u32 linkType2; + + count = 0; + if (gReceivedRemoteLinkPlayers == TRUE) + { + cmpVal = sub_800ABAC(); + if (lower > cmpVal || cmpVal > upper) + { + gUnknown_03000D5C = 6; + return 6; + } + else + { + if (GetLinkPlayerCount() == 0) + { + gUnknown_0300306C = TRUE; + sub_80097E8(); + } + for (i = 0, index = 0; i < GetLinkPlayerCount(); index ++, i ++) + { + if (gLinkPlayers[index].linkType == gLinkPlayers[0].linkType) + { + count ++; + } + } + if (count == GetLinkPlayerCount()) + { + if (gLinkPlayers[0].linkType == 0x1133) + { + switch (sub_807A728()) + { + case 1: + gUnknown_03000D5C = 4; + break; + case 2: + gUnknown_03000D5C = 5; + break; + case 0: + gUnknown_03000D5C = 1; + break; + } + } + else + { + gUnknown_03000D5C = 1; + } + } + else + { + gUnknown_03000D5C = 3; + linkType1 = gLinkPlayers[GetMultiplayerId()].linkType; + linkType2 = gLinkPlayers[GetMultiplayerId() ^ 1].linkType; + if ((linkType1 == 0x2266 && linkType2 == 0x2277) || (linkType1 == 0x2277 && linkType2 == 0x2266)) + { + gSpecialVar_0x8005 = 3; + } + } + } + } + else if (++ gUnknown_020229C8 > 600) + { + gUnknown_03000D5C = 2; + } + return gUnknown_03000D5C; +}