From b346bac98b9328ad2da85e89b885ea09f247e98d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 12 Nov 2017 21:31:08 -0500 Subject: [PATCH] through GetLinkPlayerCount_2 --- asm/cable_club.s | 20 ++++++++++---------- asm/link.s | 22 ---------------------- asm/mystery_event_menu.s | 2 +- asm/pokenav.s | 8 ++++---- asm/record_mixing.s | 10 +++++----- asm/trade.s | 4 ++-- common_syms/link.txt | 2 +- include/link.h | 3 +-- src/battle_controllers.c | 2 +- src/link.c | 23 +++++++++++++++++------ 10 files changed, 42 insertions(+), 54 deletions(-) diff --git a/asm/cable_club.s b/asm/cable_club.s index df8e248ad2..e00866a1c1 100644 --- a/asm/cable_club.s +++ b/asm/cable_club.s @@ -178,7 +178,7 @@ _080B24C8: b _080B24F2 _080B24CC: ldr r4, =gStringVar1 - bl sub_800ABAC + bl GetLinkPlayerCount_2 adds r1, r0, 0 lsls r1, 24 lsrs r1, 24 @@ -404,7 +404,7 @@ sub_80B2688: @ 80B2688 push {r4,r5,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r5, r0, 24 adds r0, r4, 0 @@ -506,7 +506,7 @@ sub_80B275C: @ 80B275C mov r9, r0 mov r7, r8 add r7, r9 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r5, r0, 24 adds r0, r4, 0 @@ -585,7 +585,7 @@ sub_80B2804: @ 80B2804 bne _080B2898 bl sub_800AA48 adds r4, r0, 0 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r4, 24 lsls r0, 24 cmp r4, r0 @@ -652,7 +652,7 @@ sub_80B28A8: @ 80B28A8 lsrs r0, 24 cmp r0, 0x1 beq _080B290A - bl sub_800ABAC + bl GetLinkPlayerCount_2 adds r4, r0, 0 bl sub_800AA48 lsls r4, 24 @@ -735,7 +735,7 @@ _080B2984: b _080B29E4 .pool _080B2994: - bl sub_800ABAC + bl GetLinkPlayerCount_2 ldr r4, =gUnknown_03005DB8 strb r0, [r4] bl GetMultiplayerId @@ -825,7 +825,7 @@ _080B2A4E: b _080B2ACE .pool _080B2A6C: - bl sub_800ABAC + bl GetLinkPlayerCount_2 ldr r4, =gUnknown_03005DB8 strb r0, [r4] bl GetMultiplayerId @@ -1640,7 +1640,7 @@ sub_80B3194: @ 80B3194 lsls r0, 24 lsrs r4, r0, 24 adds r5, r4, 0 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -1681,7 +1681,7 @@ sub_80B31E8: @ 80B31E8 lsrs r5, r0, 24 bl sub_800AA48 adds r4, r0, 0 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r4, 24 lsls r0, 24 cmp r4, r0 @@ -2779,7 +2779,7 @@ _080B3B54: strh r0, [r5, 0x2] b _080B3B96 _080B3B68: - bl sub_800ABAC + bl GetLinkPlayerCount_2 adds r4, r0, 0 bl sub_800AA48 lsls r4, 24 diff --git a/asm/link.s b/asm/link.s index 70fd1fedea..5c517544ec 100644 --- a/asm/link.s +++ b/asm/link.s @@ -5,28 +5,6 @@ .text - thumb_func_start sub_800AB98 -sub_800AB98: @ 800AB98 - ldr r0, =gSavedLinkPlayerCount - movs r1, 0 - strb r1, [r0] - ldr r0, =gUnknown_03003120 - strb r1, [r0] - bx lr - .pool - thumb_func_end sub_800AB98 - - thumb_func_start sub_800ABAC -sub_800ABAC: @ 800ABAC - ldr r0, =gLinkStatus - ldr r0, [r0] - movs r1, 0x1C - ands r0, r1 - lsrs r0, 2 - bx lr - .pool - thumb_func_end sub_800ABAC - thumb_func_start sub_800ABBC sub_800ABBC: @ 800ABBC push {lr} diff --git a/asm/mystery_event_menu.s b/asm/mystery_event_menu.s index a1a90cd4de..ad9da463e8 100644 --- a/asm/mystery_event_menu.s +++ b/asm/mystery_event_menu.s @@ -282,7 +282,7 @@ _08178BCC: _08178BDA: b _08178E34 _08178BDC: - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r2, r0, 24 cmp r2, 0x2 diff --git a/asm/pokenav.s b/asm/pokenav.s index 1ccb893afe..414ca36725 100755 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -28132,7 +28132,7 @@ sub_81D4EC0: @ 81D4EC0 lsls r0, 24 cmp r0, 0 beq _081D4EDC - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 cmp r0, 0x2 @@ -28190,7 +28190,7 @@ _081D4F38: lsls r0, 24 cmp r0, 0 beq _081D4F88 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -28212,7 +28212,7 @@ _081D4F54: strb r0, [r4] b _081D500C _081D4F6C: - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 cmp r0, 0x2 @@ -28506,7 +28506,7 @@ _081D51D0: b _081D535A .pool _081D51F4: - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 diff --git a/asm/record_mixing.s b/asm/record_mixing.s index 89507d3f37..9de2911ea9 100644 --- a/asm/record_mixing.s +++ b/asm/record_mixing.s @@ -765,7 +765,7 @@ _080E73B0: movs r0, 0x65 b _080E7564 _080E73B8: - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r4, r0, 24 bl sub_800ABBC @@ -796,7 +796,7 @@ _080E73EA: _080E73F8: bl sub_800AA48 adds r4, r0, 0 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r4, 24 lsls r0, 24 cmp r4, r0 @@ -808,7 +808,7 @@ _080E740C: strh r4, [r5, 0x20] lsls r4, 16 asrs r4, 16 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 lsls r1, r0, 4 @@ -824,7 +824,7 @@ _080E742A: _080E7432: bl sub_800AA48 adds r4, r0, 0 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r4, 24 lsls r0, 24 cmp r4, r0 @@ -868,7 +868,7 @@ _080E746E: b _080E7564 .pool _080E7490: - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 movs r1, 0 diff --git a/asm/trade.s b/asm/trade.s index c32fd4209b..8235dc0df8 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -464,7 +464,7 @@ _0807757A: b _08077B22 .pool _0807758C: - bl sub_800ABAC + bl GetLinkPlayerCount_2 adds r4, r0, 0 bl sub_800AA48 lsls r4, 24 @@ -7373,7 +7373,7 @@ _0807AFBC: bne _0807AFC8 b _0807B0DC _0807AFC8: - bl sub_800ABAC + bl GetLinkPlayerCount_2 adds r4, r0, 0 bl sub_800AA48 lsls r4, 24 diff --git a/common_syms/link.txt b/common_syms/link.txt index 7ac33a8691..9b168d932e 100644 --- a/common_syms/link.txt +++ b/common_syms/link.txt @@ -19,7 +19,7 @@ gSuppressLinkErrorMessage gSerialIsRFU gSavedLinkPlayerCount gSendCmd -gUnknown_03003120 +gSavedMultiplayerId gReceivedRemoteLinkPlayers gLinkTestBGInfo gLinkCallback diff --git a/include/link.h b/include/link.h index 6231dd9e40..605d32aec8 100644 --- a/include/link.h +++ b/include/link.h @@ -205,7 +205,6 @@ void sub_800ADF8(void); void sub_800B488(void); void sub_800A620(void); void sub_8011BD0(void); -u8 sub_800ABAC(void); u8 sub_800ABBC(void); void sub_800AC34(void); @@ -234,7 +233,7 @@ extern u16 gUnknown_030030F4; extern u8 gSuppressLinkErrorMessage; extern bool8 gSerialIsRFU; extern bool8 gSavedLinkPlayerCount; -extern u8 gUnknown_03003120; +extern u8 gSavedMultiplayerId; extern struct LinkTestBGInfo gLinkTestBGInfo; extern void (*gLinkCallback)(void); extern bool8 gShouldAdvanceLinkState; diff --git a/src/battle_controllers.c b/src/battle_controllers.c index ce96fff6ae..431f5d97a8 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -791,7 +791,7 @@ static void Task_HandleSendLinkBuffersData(u8 taskId) else var = (gBattleTypeFlags & BATTLE_TYPE_MULTI) ? 4 : 2; - if (sub_800ABAC() >= var) + if (GetLinkPlayerCount_2() >= var) { if (sub_800ABBC()) { diff --git a/src/link.c b/src/link.c index 5ca08dd274..d6cc1b5def 100644 --- a/src/link.c +++ b/src/link.c @@ -79,7 +79,7 @@ u8 gSuppressLinkErrorMessage; bool8 gSerialIsRFU; bool8 gSavedLinkPlayerCount; u16 gSendCmd[8]; -u8 gUnknown_03003120; +u8 gSavedMultiplayerId; bool8 gReceivedRemoteLinkPlayers; struct LinkTestBGInfo gLinkTestBGInfo; void (*gLinkCallback)(void); @@ -468,7 +468,7 @@ void HandleReceiveRemoteLinkPlayer(u8 who) count = 0; gUnknown_03003078[who] = FALSE; - for (i = 0; i < sub_800ABAC(); i ++) + for (i = 0; i < GetLinkPlayerCount_2(); i ++) { count += gUnknown_03003078[i]; } @@ -800,7 +800,7 @@ u8 GetLinkPlayerDataExchangeStatusTimed(int lower, int upper) count = 0; if (gReceivedRemoteLinkPlayers == TRUE) { - cmpVal = sub_800ABAC(); + cmpVal = GetLinkPlayerCount_2(); if (lower > cmpVal || cmpVal > upper) { sPlayerDataExchangeStatus = EXCHANGE_STAT_6; @@ -1282,7 +1282,7 @@ void sub_800AA04(u8 a0) int i; gSavedLinkPlayerCount = a0; - gUnknown_03003120 = GetMultiplayerId(); + gSavedMultiplayerId = GetMultiplayerId(); for (i = 0; i < MAX_RFU_PLAYERS; i ++) { gSavedLinkPlayers[i] = gLinkPlayers[i]; @@ -1296,7 +1296,7 @@ u8 sub_800AA48(void) u8 sub_800AA54(void) { - return gUnknown_03003120; + return gSavedMultiplayerId; } bool8 sub_800AA60(void) @@ -1324,7 +1324,7 @@ bool8 sub_800AA60(void) } if (count == gSavedLinkPlayerCount) { - if (sub_800ABAC() == gSavedLinkPlayerCount) + if (GetLinkPlayerCount_2() == gSavedLinkPlayerCount) { return TRUE; } @@ -1357,3 +1357,14 @@ void sub_800AB18(void) } } } + +void sub_800AB98(void) +{ + gSavedLinkPlayerCount = 0; + gSavedMultiplayerId = 0; +} + +u8 GetLinkPlayerCount_2(void) +{ + return EXTRACT_PLAYER_COUNT(gLinkStatus); +}