diff --git a/asm/battle_5.s b/asm/battle_5.s index 4d02a5942..f2d6797f9 100644 --- a/asm/battle_5.s +++ b/asm/battle_5.s @@ -59,13 +59,13 @@ _08056F3E: bl AllocZeroed ldr r1, [r5] str r0, [r1, 0x1C] - ldr r4, =gUnknown_020244A0 + ldr r4, =gLinkBattleSendBuffer movs r5, 0x80 lsls r5, 5 adds r0, r5, 0 bl AllocZeroed str r0, [r4] - ldr r4, =gUnknown_020244A4 + ldr r4, =gLinkBattleRecvBuffer adds r0, r5, 0 bl AllocZeroed str r0, [r4] @@ -160,11 +160,11 @@ _0805703C: str r5, [r0, 0x1C] bl Free str r5, [r6] - ldr r4, =gUnknown_020244A0 + ldr r4, =gLinkBattleSendBuffer ldr r0, [r4] bl Free str r5, [r4] - ldr r4, =gUnknown_020244A4 + ldr r4, =gLinkBattleRecvBuffer ldr r0, [r4] bl Free str r5, [r4] diff --git a/asm/battle_7.s b/asm/battle_7.s index 7aea39cff..a51670cd3 100644 --- a/asm/battle_7.s +++ b/asm/battle_7.s @@ -1801,7 +1801,7 @@ _0805E056: movs r4, 0 cmp r4, r5 bcs _0805E076 - ldr r7, =gBanksBySide + ldr r7, =gBanksByIdentity ldr r6, =gUnknown_0832C108 _0805E060: adds r0, r4, r7 @@ -1874,14 +1874,14 @@ _0805E0F0: _0805E100: cmp r4, 0x4 bne _0805E110 - ldr r0, =gBanksBySide + ldr r0, =gBanksByIdentity ldrb r0, [r0] b _0805E198 .pool _0805E110: cmp r4, 0x5 bne _0805E1AC - ldr r0, =gBanksBySide + ldr r0, =gBanksByIdentity ldrb r0, [r0, 0x1] b _0805E198 .pool @@ -1916,28 +1916,28 @@ _0805E150: _0805E160: cmp r4, 0x6 bne _0805E170 - ldr r0, =gBanksBySide + ldr r0, =gBanksByIdentity ldrb r0, [r0] b _0805E198 .pool _0805E170: cmp r4, 0x7 bne _0805E180 - ldr r0, =gBanksBySide + ldr r0, =gBanksByIdentity ldrb r0, [r0, 0x1] b _0805E198 .pool _0805E180: cmp r4, 0x8 bne _0805E190 - ldr r0, =gBanksBySide + ldr r0, =gBanksByIdentity ldrb r0, [r0, 0x2] b _0805E198 .pool _0805E190: cmp r5, 0x9 bne _0805E1AC - ldr r0, =gBanksBySide + ldr r0, =gBanksByIdentity ldrb r0, [r0, 0x3] _0805E198: lsls r0, 3 @@ -2038,7 +2038,7 @@ _0805E252: _0805E260: ldrb r0, [r4] bl sub_8072B18 - ldr r0, =gBanksBySide + ldr r0, =gBanksByIdentity ldrb r1, [r4] adds r0, r1, r0 ldrb r0, [r0] diff --git a/asm/battle_anim.s b/asm/battle_anim.s index 645700d53..458ddbbaf 100644 --- a/asm/battle_anim.s +++ b/asm/battle_anim.s @@ -5,8 +5,8 @@ .text - thumb_func_start sub_80A3934 -sub_80A3934: @ 80A3934 + thumb_func_start ClearBattleAnimationVars +ClearBattleAnimationVars: @ 80A3934 push {r4-r7,lr} mov r7, r9 mov r6, r8 @@ -84,7 +84,7 @@ _080A3994: pop {r0} bx r0 .pool - thumb_func_end sub_80A3934 + thumb_func_end ClearBattleAnimationVars thumb_func_start move_anim_start_t1 move_anim_start_t1: @ 80A3A10 diff --git a/asm/battle_anim_80FE840.s b/asm/battle_anim_80FE840.s index 58eb2ebf0..582b01831 100644 --- a/asm/battle_anim_80FE840.s +++ b/asm/battle_anim_80FE840.s @@ -10676,7 +10676,7 @@ _08103D54: strh r0, [r3, 0x4] b _08103DB6 _08103D5C: - ldr r1, =gBanksBySide + ldr r1, =gBanksByIdentity ldr r0, =gAnimationBankTarget ldrb r0, [r0] adds r0, r1 @@ -27474,7 +27474,7 @@ sub_810C560: @ 810C560 lsls r0, 8 strh r0, [r5, 0x3C] _0810C594: - ldr r3, =gBanksBySide + ldr r3, =gBanksByIdentity ldrb r0, [r7] adds r0, r3 ldrb r1, [r0] @@ -27699,7 +27699,7 @@ _0810C736: lsls r0, 24 cmp r0, 0 bne _0810C78C - ldr r1, =gBanksBySide + ldr r1, =gBanksByIdentity ldrb r0, [r6] adds r0, r1 ldrb r1, [r0] @@ -27843,7 +27843,7 @@ _0810C85A: lsls r0, 24 cmp r0, 0 bne _0810C8B4 - ldr r1, =gBanksBySide + ldr r1, =gBanksByIdentity ldr r0, =gAnimationBankTarget ldrb r0, [r0] adds r0, r1 @@ -28771,7 +28771,7 @@ _0810D000: negs r0, r0 lsrs r4, r0, 16 _0810D012: - ldr r0, =gBanksBySide + ldr r0, =gBanksByIdentity add r0, r8 ldrb r1, [r0] adds r0, r7, 0 diff --git a/asm/battle_interface.s b/asm/battle_interface.s index d9bb3d8cc..b1bb7df96 100755 --- a/asm/battle_interface.s +++ b/asm/battle_interface.s @@ -514,7 +514,7 @@ _08072694: _08072716: str r0, [sp] _08072718: - ldr r0, =gBanksBySide + ldr r0, =gBanksByIdentity add r0, r10 ldrb r1, [r0] lsls r0, r1, 1 diff --git a/asm/berry_blender.s b/asm/berry_blender.s index 277a49d2f..e6e1c93d1 100644 --- a/asm/berry_blender.s +++ b/asm/berry_blender.s @@ -1275,7 +1275,7 @@ _080802AC: strh r0, [r1] adds r5, 0x1 _080802D4: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -1295,7 +1295,7 @@ _080802EC: bl sub_807FD90 b _08080336 _08080302: - bl sub_8009FCC + bl GetLinkPlayerCount ldr r2, =gUnknown_020322A4 ldr r1, [r2] adds r1, 0x7C @@ -6091,7 +6091,7 @@ _08082BEE: lsls r0, 24 lsrs r5, r0, 24 _08082BF4: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -6104,7 +6104,7 @@ _08082C0C: lsls r0, 24 lsrs r5, r0, 24 _08082C12: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -6118,7 +6118,7 @@ _08082C12: cmp r0, 0 bne _08082C0C _08082C2E: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -6132,7 +6132,7 @@ _08082C48: lsls r0, 24 lsrs r5, r0, 24 _08082C4E: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -6149,7 +6149,7 @@ _08082C6A: ldr r4, =gUnknown_03003110 adds r0, r4, 0 bl sub_8081F94 - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r5, r0 diff --git a/asm/cable_club.s b/asm/cable_club.s index d5d3af151..194a25351 100644 --- a/asm/cable_club.s +++ b/asm/cable_club.s @@ -1059,7 +1059,7 @@ _080B2C5C: lsls r0, 24 lsrs r4, r0, 24 _080B2C7E: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r4, r0 @@ -1361,7 +1361,7 @@ _080B2F0C: movs r0, 0 mov r8, r0 mov r9, r0 - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r5, r0, 24 movs r4, 0 @@ -1980,11 +1980,11 @@ _080B3474: bl sub_800B524 lsls r0, r4, 24 lsrs r0, 24 - bl sub_800A5EC + bl ResetBlockReceivedFlag adds r5, 0x1C adds r4, 0x1 _080B349A: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r4, r0 @@ -2080,7 +2080,7 @@ _080B3574: beq _080B35F8 b _080B35FE _080B357A: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r3, r0, 24 movs r4, 0 diff --git a/asm/contest.s b/asm/contest.s index 561c79857..c2bf16d84 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -1048,7 +1048,7 @@ _080D8004: bl sub_80DC594 bl sub_80DC5E8 bl sub_80DC7EC - ldr r1, =gBanksBySide + ldr r1, =gBanksByIdentity strb r4, [r1] movs r0, 0x1 strb r0, [r1, 0x1] @@ -13606,7 +13606,7 @@ sub_80DE864: @ 80DE864 movs r1, 0 movs r2, 0x14 bl memset - bl sub_80A3934 + bl ClearBattleAnimationVars ldr r1, =gBattleMonForms movs r2, 0 adds r0, r1, 0x3 diff --git a/asm/contest_link_80FC4F4.s b/asm/contest_link_80FC4F4.s index ad22946c5..c4e3863c1 100644 --- a/asm/contest_link_80FC4F4.s +++ b/asm/contest_link_80FC4F4.s @@ -50,7 +50,7 @@ sub_80FC530: @ 80FC530 cmp r4, 0 beq _080FC552 adds r0, r5, 0 - bl sub_800A5EC + bl ResetBlockReceivedFlag movs r0, 0x1 b _080FC554 _080FC552: @@ -141,7 +141,7 @@ sub_80FC5DC: @ 80FC5DC bl GetMultiplayerId ldr r1, =gUnknown_02039F25 strb r0, [r1] - bl sub_8009FCC + bl GetLinkPlayerCount ldr r4, =gUnknown_02039F30 strb r0, [r4] ldr r1, =gUnknown_02039F2A diff --git a/asm/dewford_trend.s b/asm/dewford_trend.s index c3a7b192c..40df2d6a0 100644 --- a/asm/dewford_trend.s +++ b/asm/dewford_trend.s @@ -492,7 +492,7 @@ sub_812287C: @ 812287C bl Free b _08122980 _081228B0: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 mov r9, r0 diff --git a/asm/link.s b/asm/link.s index fb20b1fb2..0c632ed9b 100644 --- a/asm/link.s +++ b/asm/link.s @@ -545,7 +545,7 @@ _08009888: movs r6, 0 strh r0, [r4] adds r0, r5, 0 - bl sub_800A5EC + bl ResetBlockReceivedFlag ldrh r0, [r4] cmp r0, r8 beq _080098C4 @@ -1371,8 +1371,8 @@ _08009FC4: .pool thumb_func_end sub_8009FAC - thumb_func_start sub_8009FCC -sub_8009FCC: @ 8009FCC + thumb_func_start GetLinkPlayerCount +GetLinkPlayerCount: @ 8009FCC push {lr} ldr r0, =gLinkVSyncDisabled ldrb r0, [r0] @@ -1392,14 +1392,14 @@ _08009FEC: _08009FF4: pop {r1} bx r1 - thumb_func_end sub_8009FCC + thumb_func_end GetLinkPlayerCount thumb_func_start sub_8009FF8 sub_8009FF8: @ 8009FF8 push {r4-r7,lr} adds r6, r0, 0 adds r5, r1, 0 - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r4, r0, 24 movs r2, 0 @@ -1442,7 +1442,7 @@ sub_800A03C: @ 800A03C thumb_func_start sub_800A040 sub_800A040: @ 800A040 push {lr} - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r0, 0x4 @@ -1546,7 +1546,7 @@ _0800A0EA: b _0800A22E .pool _0800A0FC: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 cmp r0, 0 bne _0800A10E @@ -1572,12 +1572,12 @@ _0800A130: adds r5, 0x1C adds r6, 0x1 _0800A134: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r6, r0 blt _0800A120 - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r7, r0 @@ -1714,12 +1714,12 @@ _0800A266: lsls r0, 24 lsrs r4, r0, 24 _0800A26C: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r4, r0 bcc _0800A24C - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r6, r0 @@ -2181,8 +2181,8 @@ _0800A5E2: .pool thumb_func_end ResetBlockReceivedFlags - thumb_func_start sub_800A5EC -sub_800A5EC: @ 800A5EC + thumb_func_start ResetBlockReceivedFlag +ResetBlockReceivedFlag: @ 800A5EC push {lr} lsls r0, 24 lsrs r1, r0, 24 @@ -2206,7 +2206,7 @@ _0800A616: pop {r0} bx r0 .pool - thumb_func_end sub_800A5EC + thumb_func_end ResetBlockReceivedFlag thumb_func_start sub_800A620 sub_800A620: @ 800A620 @@ -2697,7 +2697,7 @@ _0800A9E2: lsrs r4, r0, 24 adds r5, 0x1 _0800A9EE: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -3044,7 +3044,7 @@ _0800AC96: thumb_func_start sub_800ACAC sub_800ACAC: @ 800ACAC push {r4,lr} - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r2, r0, 24 movs r3, 0 @@ -3142,7 +3142,7 @@ _0800AD72: thumb_func_start sub_800AD88 sub_800AD88: @ 800AD88 push {r4,r5,lr} - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r3, r0, 24 movs r1, 0 @@ -3239,7 +3239,7 @@ _0800AE46: thumb_func_start sub_800AE5C sub_800AE5C: @ 800AE5C push {r4,lr} - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r2, r0, 24 movs r1, 0 @@ -9671,7 +9671,7 @@ _0800E1C8: lsls r0, 24 lsrs r5, r0, 24 _0800E1E6: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 subs r0, 0x1 @@ -9965,7 +9965,7 @@ _0800E428: ble _0800E3FC mov r4, r9 _0800E434: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r4, r0 @@ -10019,7 +10019,7 @@ _0800E4A6: adds r5, 0x1C adds r4, 0x1 _0800E4AC: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r4, r0 @@ -13627,7 +13627,7 @@ sub_80102B8: @ 80102B8 bl sub_800FD14 strh r4, [r5] _080102E6: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r2, r0, 24 movs r1, 0 @@ -13734,7 +13734,7 @@ sub_8010390: @ 8010390 b _0801041C .pool _080103CC: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r2, r0, 24 movs r1, 0x1 @@ -14607,7 +14607,7 @@ sub_8010A70: @ 8010A70 adds r1, r4, 0 bl CpuSet movs r0, 0 - bl sub_800A5EC + bl ResetBlockReceivedFlag _08010A9C: add sp, 0x4 pop {r4,r5} @@ -14683,7 +14683,7 @@ _08010B40: b _08010CF0 _08010B4A: adds r0, r4, 0 - bl sub_800A5EC + bl ResetBlockReceivedFlag movs r0, 0xF0 lsls r0, 7 bl sub_800FD14 @@ -14713,7 +14713,7 @@ _08010B78: b _08010CF0 _08010B8C: adds r0, r4, 0 - bl sub_800A5EC + bl ResetBlockReceivedFlag lsls r2, r4, 8 ldr r0, =gBlockRecvBuffer adds r2, r0 @@ -14845,7 +14845,7 @@ _08010C94: ldr r2, =0x0100007e bl CpuSet movs r0, 0 - bl sub_800A5EC + bl ResetBlockReceivedFlag ldr r1, =gUnknown_03005000 ldr r5, =0x00000ce8 adds r0, r1, r5 @@ -14947,7 +14947,7 @@ _08010D82: ldr r0, =gBlockRecvBuffer bl sub_8010A14 movs r0, 0 - bl sub_800A5EC + bl ResetBlockReceivedFlag ldr r0, =gReceivedRemoteLinkPlayers strb r4, [r0] adds r0, r5, 0 @@ -15290,7 +15290,7 @@ _08011048: strb r0, [r1, 0x3] adds r4, 0x1 _08011054: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r4, r0 @@ -20950,12 +20950,12 @@ _08014138: adds r5, 0x1C adds r4, 0x1 _08014152: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r4, r0 blt _08014138 - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r0, 0x2 @@ -21159,7 +21159,7 @@ sub_8014304: @ 8014304 strh r1, [r0] ldr r0, =0x00004087 bl VarSet - bl sub_8009FCC + bl GetLinkPlayerCount ldr r1, =gUnknown_03005DB8 strb r0, [r1] bl GetMultiplayerId @@ -39108,7 +39108,7 @@ sub_801D978: @ 801D978 push {lr} lsls r0, 24 lsrs r0, 24 - bl sub_800A5EC + bl ResetBlockReceivedFlag pop {r0} bx r0 thumb_func_end sub_801D978 @@ -39697,7 +39697,7 @@ sub_801DDD0: @ 801DDD0 strb r5, [r4, 0x16] movs r0, 0xFF strb r0, [r4, 0x1A] - bl sub_8009FCC + bl GetLinkPlayerCount strb r0, [r4, 0xD] bl GetMultiplayerId strb r0, [r4, 0x13] @@ -42285,7 +42285,7 @@ _0801F30A: movs r0, 0x1 strh r0, [r4] _0801F30E: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 adds r2, r0, 0 @@ -42361,7 +42361,7 @@ _0801F3A2: strh r1, [r4, 0x4] lsls r0, r1, 24 lsrs r0, 24 - bl sub_800A5EC + bl ResetBlockReceivedFlag movs r1, 0x2 ldrsh r0, [r4, r1] lsls r0, 8 @@ -42446,7 +42446,7 @@ _0801F448: ldrsh r0, [r4, r3] cmp r0, 0 beq _0801F47C - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r0, 0x2 @@ -45504,7 +45504,7 @@ _08020C8E: b _08020CF8 .pool _08020CAC: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 mov r8, r0 @@ -53271,7 +53271,7 @@ _08024B2C: _08024B6A: ldr r0, [sp, 0x10] strb r1, [r0] - bl sub_8009FCC + bl GetLinkPlayerCount mov r1, r8 strb r0, [r1] bl GetMultiplayerId @@ -57700,7 +57700,7 @@ _08026EF6: adds r4, 0xC adds r5, 0x1 _08026EFE: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -59511,7 +59511,7 @@ _08027C76: thumb_func_start sub_8027D20 sub_8027D20: @ 8027D20 push {lr} - bl sub_8009FCC + bl GetLinkPlayerCount ldr r1, =gUnknown_02022C98 ldr r1, [r1] adds r1, 0x24 @@ -64891,7 +64891,7 @@ sub_802AA48: @ 802AA48 sub_802AA60: @ 802AA60 push {r4,lr} adds r4, r0, 0 - bl sub_8009FCC + bl GetLinkPlayerCount movs r2, 0 strb r0, [r4, 0x5] adds r1, r4, 0 @@ -68775,7 +68775,7 @@ _0802C8A4: thumb_func_start sub_802C8AC sub_802C8AC: @ 802C8AC push {lr} - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 pop {r1} diff --git a/asm/record_mixing.s b/asm/record_mixing.s index aacc5baa0..7bf84bc2c 100644 --- a/asm/record_mixing.s +++ b/asm/record_mixing.s @@ -1135,7 +1135,7 @@ _080E76DC: bl memcpy _080E76E4: mov r0, r8 - bl sub_800A5EC + bl ResetBlockReceivedFlag mov r0, r9 lsls r1, r0, 1 adds r1, r5, r1 @@ -1162,7 +1162,7 @@ _080E7714: lsrs r0, 24 mov r8, r0 _080E771C: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r8, r0 @@ -1179,7 +1179,7 @@ _080E771C: adds r1, 0x1 strh r1, [r0, 0x8] _080E773E: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 ldr r4, [sp, 0x8] @@ -1312,7 +1312,7 @@ sub_80E7820: @ 80E7820 sub_80E7830: @ 80E7830 push {r4,lr} adds r4, r0, 0 - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r0, 0x3 @@ -1738,7 +1738,7 @@ sub_80E7B60: @ 80E7B60 ldr r0, =gLinkPlayers ldrh r0, [r0, 0x4] bl SeedRng2 - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r4, r0, 24 movs r0, 0 @@ -1931,7 +1931,7 @@ _080E7CFA: lsrs r0, 16 mov r8, r0 _080E7D04: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r8, r0 @@ -3557,7 +3557,7 @@ sub_80E89AC: @ 80E89AC adds r6, r0, 0 mov r8, r1 mov r9, r2 - bl sub_8009FCC + bl GetLinkPlayerCount adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 diff --git a/asm/recorded_battle.s b/asm/recorded_battle.s index e742cbe7d..2209312c2 100644 --- a/asm/recorded_battle.s +++ b/asm/recorded_battle.s @@ -125,7 +125,7 @@ _08184EAC: bl GetMultiplayerId ldr r1, =gUnknown_0203C7B4 strb r0, [r1] - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 mov r10, r0 @@ -505,7 +505,7 @@ _081851D0: adds r4, 0x1C adds r5, 0x1 _081851DA: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r5, r0 diff --git a/asm/rom3.s b/asm/rom3.s index 649097eb6..ab32fa315 100644 --- a/asm/rom3.s +++ b/asm/rom3.s @@ -5,2134 +5,7 @@ .text - thumb_func_start HandleLinkBattleSetup -HandleLinkBattleSetup: @ 8032654 - push {lr} - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08032686 - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - beq _0803266E - bl sub_800B488 -_0803266E: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _0803267A - bl sub_8009734 -_0803267A: - ldr r0, =task00_08081A90 - movs r1, 0 - bl CreateTask - bl sub_8033244 -_08032686: - pop {r0} - bx r0 - .pool - thumb_func_end HandleLinkBattleSetup - thumb_func_start SetUpBattleVarsAndBirchZigzagoon -SetUpBattleVarsAndBirchZigzagoon: @ 803269C - push {r4-r7,lr} - sub sp, 0x14 - ldr r0, =gBattleMainFunc - ldr r1, =nullsub_20 - str r1, [r0] - movs r0, 0 - str r0, [sp, 0x10] - movs r1, 0 - ldr r7, =gBattleBankFunc - ldr r6, =gActionSelectionCursor - movs r2, 0 - ldr r5, =gMoveSelectionCursor - ldr r4, =nullsub_21 - ldr r3, =gBanksBySide -_080326B8: - lsls r0, r1, 2 - adds r0, r7 - str r4, [r0] - adds r1, r3 - movs r0, 0xFF - strb r0, [r1] - ldr r0, [sp, 0x10] - adds r0, r6 - strb r2, [r0] - ldr r0, [sp, 0x10] - adds r0, r5 - strb r2, [r0] - ldr r0, [sp, 0x10] - adds r0, 0x1 - str r0, [sp, 0x10] - adds r1, r0, 0 - cmp r1, 0x3 - ble _080326B8 - bl HandleLinkBattleSetup - ldr r0, =gBattleExecBuffer - movs r5, 0 - str r5, [r0] - bl sub_80A3934 - bl ClearBattleMonForms - movs r0, 0xF - bl BattleAI_HandleItemUseBeforeAISetup - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08032728 - bl ZeroEnemyPartyMons - ldr r4, =gEnemyParty - movs r1, 0x90 - lsls r1, 1 - str r5, [sp] - str r5, [sp, 0x4] - str r5, [sp, 0x8] - str r5, [sp, 0xC] - adds r0, r4, 0 - movs r2, 0x2 - movs r3, 0x20 - bl CreateMon - str r5, [sp, 0x10] - adds r0, r4, 0 - movs r1, 0xC - add r2, sp, 0x10 - bl SetMonData -_08032728: - ldr r0, =gUnknown_02022FF4 - str r5, [r0] - ldr r0, =gUnknown_0202428C - strb r5, [r0] - add sp, 0x14 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end SetUpBattleVarsAndBirchZigzagoon - - thumb_func_start sub_8032768 -sub_8032768: @ 8032768 - push {r4,r5,lr} - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - bne _08032784 - movs r0, 0x1 - bl sub_8184DA4 - b _0803278A - .pool -_08032784: - movs r0, 0x2 - bl sub_8184DA4 -_0803278A: - ldr r4, =gBattleTypeFlags - ldr r0, [r4] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - bne _0803279C - bl sub_8185EB8 -_0803279C: - ldr r0, [r4] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080327B0 - bl b_setup_bx_link - b _080327B4 - .pool -_080327B0: - bl b_setup_bx -_080327B4: - bl sub_8033050 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - bne _080327E2 - movs r4, 0 - ldr r0, =gNoOfAllBanks - ldrb r1, [r0] - cmp r4, r1 - bge _080327E2 - adds r5, r0, 0 -_080327D0: - lsls r0, r4, 24 - lsrs r0, 24 - movs r1, 0 - bl sub_81B8D64 - adds r4, 0x1 - ldrb r0, [r5] - cmp r4, r0 - blt _080327D0 -_080327E2: - movs r4, 0 - ldr r3, =gBattleStruct - movs r2, 0xD2 - lsls r2, 1 - movs r1, 0 -_080327EC: - ldr r0, [r3] - adds r0, r4, r0 - adds r0, r2 - strb r1, [r0] - adds r4, 0x1 - cmp r4, 0x5F - bls _080327EC - movs r4, 0 - ldr r3, =gBattleStruct - movs r2, 0x81 - lsls r2, 2 - movs r1, 0 -_08032804: - ldr r0, [r3] - adds r0, r4, r0 - adds r0, r2 - strb r1, [r0] - adds r4, 0x1 - cmp r4, 0x67 - bls _08032804 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8032768 - - thumb_func_start b_setup_bx -b_setup_bx: @ 8032824 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gBattleTypeFlags - ldr r3, [r0] - movs r5, 0x80 - lsls r5, 15 - ands r5, r3 - cmp r5, 0 - beq _080328E4 - ldr r1, =gBattleMainFunc - ldr r0, =BeginBattleIntro - str r0, [r1] - movs r4, 0x80 - lsls r4, 17 - ands r4, r3 - cmp r4, 0 - beq _08032874 - ldr r2, =gBattleBankFunc - ldr r0, =SetBankFuncToRecordedPlayerBufferRunCommand - str r0, [r2] - ldr r1, =gBanksBySide - movs r0, 0 - strb r0, [r1] - b _0803287E - .pool -_08032874: - ldr r2, =gBattleBankFunc - ldr r0, =SetBankFuncToPlayerBufferRunCommand - str r0, [r2] - ldr r1, =gBanksBySide - strb r4, [r1] -_0803287E: - ldr r3, =SetBankFuncToOpponentBufferRunCommand - str r3, [r2, 0x4] - movs r0, 0x1 - strb r0, [r1, 0x1] - ldr r0, =SetBankFuncToPlayerPartnerBufferRunCommand - str r0, [r2, 0x8] - movs r0, 0x2 - strb r0, [r1, 0x2] - str r3, [r2, 0xC] - movs r0, 0x3 - strb r0, [r1, 0x3] - ldr r1, =gNoOfAllBanks - movs r0, 0x4 - strb r0, [r1] - movs r0, 0 - movs r1, 0 - bl sub_81B8D64 - movs r0, 0x1 - movs r1, 0 - bl sub_81B8D64 - movs r0, 0x2 - movs r1, 0x1 - bl sub_81B8D64 - movs r0, 0x3 - movs r1, 0x1 - bl sub_81B8D64 - ldr r0, =gBattlePartyID - movs r1, 0 - strh r1, [r0] - strh r1, [r0, 0x2] - movs r1, 0x3 - b _08032A76 - .pool -_080328E4: - movs r7, 0x1 - adds r0, r3, 0 - ands r0, r7 - cmp r0, 0 - beq _080328F0 - b _080329E0 -_080328F0: - ldr r0, =gBattleMainFunc - ldr r2, =BeginBattleIntro - str r2, [r0] - movs r1, 0x80 - ands r1, r3 - mov r12, r2 - cmp r1, 0 - beq _08032918 - ldr r1, =gBattleBankFunc - ldr r0, =SetBankFuncToSafariBufferRunCommand - b _08032934 - .pool -_08032918: - movs r0, 0x80 - lsls r0, 2 - ands r3, r0 - cmp r3, 0 - beq _08032930 - ldr r1, =gBattleBankFunc - ldr r0, =SetBankFuncToWallyBufferRunCommand - b _08032934 - .pool -_08032930: - ldr r1, =gBattleBankFunc - ldr r0, =SetBankFuncToPlayerBufferRunCommand -_08032934: - str r0, [r1] - mov r10, r1 - ldr r4, =gBanksBySide - movs r0, 0 - mov r9, r0 - mov r1, r9 - strb r1, [r4] - mov r5, r10 - ldr r2, =SetBankFuncToOpponentBufferRunCommand - mov r8, r2 - str r2, [r5, 0x4] - movs r6, 0x1 - strb r6, [r4, 0x1] - ldr r2, =gNoOfAllBanks - movs r7, 0x2 - strb r7, [r2] - ldr r0, =gBattleTypeFlags - ldr r3, [r0] - movs r0, 0x80 - lsls r0, 17 - ands r0, r3 - cmp r0, 0 - bne _08032964 - b _08032CB2 -_08032964: - movs r1, 0x80 - lsls r1, 18 - ands r1, r3 - cmp r1, 0 - beq _080329CC - movs r1, 0x80 - lsls r1, 24 - ands r1, r3 - cmp r1, 0 - beq _080329B4 - mov r1, r12 - ldr r0, =gBattleMainFunc - str r1, [r0] - ldr r0, =SetBankFuncToRecordedPlayerBufferRunCommand - str r0, [r5] - mov r1, r9 - strb r1, [r4] - ldr r0, =SetBankFuncToRecordedOpponentBufferRunCommand - str r0, [r5, 0x4] - strb r6, [r4, 0x1] - strb r7, [r2] - b _08032CB2 - .pool -_080329B4: - ldr r0, =SetBankFuncToRecordedPlayerBufferRunCommand - str r0, [r5, 0x4] - strb r1, [r4, 0x1] - ldr r0, =SetBankFuncToRecordedOpponentBufferRunCommand - str r0, [r5] - strb r6, [r4] - strb r7, [r2] - b _08032CB2 - .pool -_080329CC: - ldr r0, =SetBankFuncToRecordedPlayerBufferRunCommand - mov r2, r10 - str r0, [r2] - strb r1, [r4] - mov r0, r8 - str r0, [r2, 0x4] - strb r6, [r4, 0x1] - b _08032CB2 - .pool -_080329E0: - ldr r1, =BeginBattleIntro - ldr r2, =gBattleMainFunc - str r1, [r2] - ldr r2, =gBattleBankFunc - ldr r0, =SetBankFuncToPlayerBufferRunCommand - str r0, [r2] - ldr r4, =gBanksBySide - strb r5, [r4] - ldr r6, =SetBankFuncToOpponentBufferRunCommand - str r6, [r2, 0x4] - strb r7, [r4, 0x1] - str r0, [r2, 0x8] - movs r0, 0x2 - mov r12, r0 - mov r1, r12 - strb r1, [r4, 0x2] - str r6, [r2, 0xC] - movs r0, 0x3 - mov r8, r0 - mov r1, r8 - strb r1, [r4, 0x3] - ldr r0, =gNoOfAllBanks - mov r10, r0 - movs r1, 0x4 - mov r9, r1 - strb r1, [r0] - movs r0, 0x80 - lsls r0, 17 - ands r0, r3 - cmp r0, 0 - bne _08032A20 - b _08032CB2 -_08032A20: - movs r1, 0xA0 - lsls r1, 1 - adds r0, r3, 0 - ands r0, r1 - cmp r0, r1 - bne _08032AA0 - ldr r0, =BeginBattleIntro - ldr r1, =gBattleMainFunc - str r0, [r1] - ldr r0, =SetBankFuncToRecordedPlayerBufferRunCommand - str r0, [r2] - strb r5, [r4] - str r6, [r2, 0x4] - strb r7, [r4, 0x1] - str r0, [r2, 0x8] - mov r0, r12 - strb r0, [r4, 0x2] - str r6, [r2, 0xC] - mov r1, r8 - strb r1, [r4, 0x3] - mov r0, r9 - mov r2, r10 - strb r0, [r2] - movs r0, 0 - movs r1, 0 - bl sub_81B8D64 - movs r0, 0x1 - movs r1, 0 - bl sub_81B8D64 - movs r0, 0x2 - movs r1, 0x1 - bl sub_81B8D64 - movs r0, 0x3 - movs r1, 0x1 - bl sub_81B8D64 - ldr r0, =gBattlePartyID - strh r5, [r0] - strh r5, [r0, 0x2] - mov r1, r8 -_08032A76: - strh r1, [r0, 0x4] - strh r1, [r0, 0x6] - b _08032CB2 - .pool -_08032AA0: - movs r5, 0x40 - ands r5, r3 - cmp r5, 0 - bne _08032AAA - b _08032C3C -_08032AAA: - ldr r0, =gUnknown_0203C7B4 - ldrb r5, [r0] - movs r0, 0 - mov r10, r0 - ldr r1, =gLinkPlayers - mov r12, r1 - adds r7, r4, 0 - mov r8, r0 - ldr r6, =gBattlePartyID - movs r4, 0 - movs r2, 0x3 - mov r9, r2 -_08032AC2: - mov r1, r12 - adds r0, r4, r1 - ldrh r0, [r0, 0x18] - cmp r0, 0x2 - bgt _08032AE4 - cmp r0, 0x1 - bge _08032AFC - cmp r0, 0 - beq _08032AE8 - b _08032B06 - .pool -_08032AE4: - cmp r0, 0x3 - bne _08032B06 -_08032AE8: - ldr r0, =gLinkPlayers - adds r0, r4, r0 - ldrb r0, [r0, 0x18] - movs r1, 0 - bl sub_81B8D64 - b _08032B06 - .pool -_08032AFC: - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - bl sub_81B8D64 -_08032B06: - cmp r10, r5 - bne _08032B56 - ldr r0, =gLinkPlayers - adds r3, r4, r0 - ldrh r1, [r3, 0x18] - lsls r1, 2 - ldr r2, =gBattleBankFunc - adds r1, r2 - ldr r2, =SetBankFuncToRecordedPlayerBufferRunCommand - str r2, [r1] - ldrh r1, [r3, 0x18] - mov r12, r0 - cmp r1, 0x2 - bgt _08032B38 - cmp r1, 0x1 - bge _08032B4C - cmp r1, 0 - beq _08032B3C - b _08032C2C - .pool -_08032B38: - cmp r1, 0x3 - bne _08032C2C -_08032B3C: - mov r1, r12 - adds r0, r4, r1 - ldrh r1, [r0, 0x18] - adds r1, r7 - mov r2, r8 - strb r2, [r1] - ldrh r0, [r0, 0x18] - b _08032C12 -_08032B4C: - adds r1, r7 - movs r0, 0x2 - strb r0, [r1] - ldrh r0, [r3, 0x18] - b _08032C24 -_08032B56: - ldr r2, =gLinkPlayers - adds r0, r4, r2 - ldrh r1, [r0, 0x18] - movs r3, 0x1 - adds r0, r3, 0 - ands r0, r1 - mov r12, r2 - cmp r0, 0 - bne _08032B80 - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - add r0, r12 - ldrh r1, [r0, 0x18] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _08032B92 - b _08032BD8 - .pool -_08032B80: - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - add r0, r12 - ldrh r1, [r0, 0x18] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _08032BD8 -_08032B92: - mov r0, r12 - adds r2, r4, r0 - ldrh r0, [r2, 0x18] - lsls r0, 2 - ldr r1, =gBattleBankFunc - adds r0, r1 - ldr r1, =SetBankFuncToRecordedPlayerBufferRunCommand - str r1, [r0] - ldrh r1, [r2, 0x18] - cmp r1, 0x2 - bgt _08032BBC - cmp r1, 0x1 - bge _08032BD0 - cmp r1, 0 - beq _08032BC0 - b _08032C2C - .pool -_08032BBC: - cmp r1, 0x3 - bne _08032C2C -_08032BC0: - mov r2, r12 - adds r0, r4, r2 - ldrh r1, [r0, 0x18] - adds r1, r7 - mov r2, r8 - strb r2, [r1] - ldrh r0, [r0, 0x18] - b _08032C12 -_08032BD0: - adds r1, r7 - movs r0, 0x2 - strb r0, [r1] - b _08032C22 -_08032BD8: - mov r0, r12 - adds r2, r4, r0 - ldrh r0, [r2, 0x18] - lsls r0, 2 - ldr r1, =gBattleBankFunc - adds r0, r1 - ldr r1, =SetBankFuncToRecordedOpponentBufferRunCommand - str r1, [r0] - ldrh r0, [r2, 0x18] - cmp r0, 0x2 - bgt _08032C00 - cmp r0, 0x1 - bge _08032C1C - cmp r0, 0 - beq _08032C04 - b _08032C2C - .pool -_08032C00: - cmp r0, 0x3 - bne _08032C2C -_08032C04: - mov r0, r12 - adds r2, r4, r0 - ldrh r0, [r2, 0x18] - adds r0, r7 - movs r1, 0x1 - strb r1, [r0] - ldrh r0, [r2, 0x18] -_08032C12: - lsls r0, 1 - adds r0, r6 - mov r1, r8 - strh r1, [r0] - b _08032C2C -_08032C1C: - adds r0, r7 - mov r1, r9 - strb r1, [r0] -_08032C22: - ldrh r0, [r2, 0x18] -_08032C24: - lsls r0, 1 - adds r0, r6 - mov r2, r9 - strh r2, [r0] -_08032C2C: - adds r4, 0x1C - movs r0, 0x1 - add r10, r0 - mov r1, r10 - cmp r1, 0x3 - bgt _08032C3A - b _08032AC2 -_08032C3A: - b _08032CB2 -_08032C3C: - movs r1, 0x4 - ands r1, r3 - cmp r1, 0 - beq _08032C7C - ldr r0, =SetBankFuncToRecordedPlayerBufferRunCommand - str r0, [r2] - strb r5, [r4] - str r0, [r2, 0x8] - mov r0, r12 - strb r0, [r4, 0x2] - movs r0, 0x80 - lsls r0, 18 - ands r3, r0 - cmp r3, 0 - beq _08032C70 - ldr r0, =SetBankFuncToRecordedOpponentBufferRunCommand - str r0, [r2, 0x4] - strb r7, [r4, 0x1] - str r0, [r2, 0xC] - mov r1, r8 - strb r1, [r4, 0x3] - b _08032CB2 - .pool -_08032C70: - str r6, [r2, 0x4] - strb r7, [r4, 0x1] - str r6, [r2, 0xC] - mov r2, r8 - strb r2, [r4, 0x3] - b _08032CB2 -_08032C7C: - ldr r0, =SetBankFuncToRecordedPlayerBufferRunCommand - str r0, [r2, 0x4] - strb r1, [r4, 0x1] - str r0, [r2, 0xC] - mov r0, r12 - strb r0, [r4, 0x3] - movs r0, 0x80 - lsls r0, 18 - ands r3, r0 - cmp r3, 0 - beq _08032CA8 - ldr r0, =SetBankFuncToRecordedOpponentBufferRunCommand - str r0, [r2] - strb r7, [r4] - str r0, [r2, 0x8] - mov r1, r8 - strb r1, [r4, 0x2] - b _08032CB2 - .pool -_08032CA8: - str r6, [r2] - strb r7, [r4] - str r6, [r2, 0x8] - mov r2, r8 - strb r2, [r4, 0x2] -_08032CB2: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end b_setup_bx - - thumb_func_start b_setup_bx_link -b_setup_bx_link: @ 8032CC0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r4, =gBattleTypeFlags - ldr r1, [r4] - movs r5, 0x1 - adds r3, r1, 0 - ands r3, r5 - cmp r3, 0 - bne _08032D48 - movs r4, 0x4 - ands r4, r1 - cmp r4, 0 - beq _08032D1C - ldr r1, =gBattleMainFunc - ldr r0, =BeginBattleIntro - str r0, [r1] - ldr r2, =gBattleBankFunc - ldr r0, =SetBankFuncToPlayerBufferRunCommand - str r0, [r2] - ldr r1, =gBanksBySide - strb r3, [r1] - ldr r0, =SetBankFuncToLinkOpponentBufferRunCommand - str r0, [r2, 0x4] - strb r5, [r1, 0x1] - ldr r1, =gNoOfAllBanks - movs r0, 0x2 - b _0803303A - .pool -_08032D1C: - ldr r2, =gBattleBankFunc - ldr r0, =SetBankFuncToPlayerBufferRunCommand - str r0, [r2, 0x4] - ldr r1, =gBanksBySide - strb r4, [r1, 0x1] - ldr r0, =SetBankFuncToLinkOpponentBufferRunCommand - str r0, [r2] - strb r5, [r1] - ldr r1, =gNoOfAllBanks - movs r0, 0x2 - b _0803303A - .pool -_08032D48: - movs r0, 0x41 - ands r0, r1 - cmp r0, 0x1 - bne _08032DD0 - movs r6, 0x4 - adds r3, r6, 0 - ands r3, r1 - cmp r3, 0 - beq _08032D98 - ldr r1, =gBattleMainFunc - ldr r0, =BeginBattleIntro - str r0, [r1] - ldr r2, =gBattleBankFunc - ldr r4, =SetBankFuncToPlayerBufferRunCommand - str r4, [r2] - ldr r1, =gBanksBySide - movs r0, 0 - strb r0, [r1] - ldr r3, =SetBankFuncToLinkOpponentBufferRunCommand - str r3, [r2, 0x4] - strb r5, [r1, 0x1] - str r4, [r2, 0x8] - movs r0, 0x2 - strb r0, [r1, 0x2] - str r3, [r2, 0xC] - movs r0, 0x3 - strb r0, [r1, 0x3] - b _08032DB4 - .pool -_08032D98: - ldr r2, =gBattleBankFunc - ldr r0, =SetBankFuncToPlayerBufferRunCommand - str r0, [r2, 0x4] - ldr r1, =gBanksBySide - strb r3, [r1, 0x1] - ldr r3, =SetBankFuncToLinkOpponentBufferRunCommand - str r3, [r2] - strb r5, [r1] - str r0, [r2, 0xC] - movs r0, 0x2 - strb r0, [r1, 0x3] - str r3, [r2, 0x8] - movs r0, 0x3 - strb r0, [r1, 0x2] -_08032DB4: - ldr r0, =gNoOfAllBanks - strb r6, [r0] - b _0803303C - .pool -_08032DD0: - movs r0, 0x80 - lsls r0, 1 - ands r0, r1 - cmp r0, 0 - beq _08032E8C - movs r4, 0x4 - adds r3, r4, 0 - ands r3, r1 - cmp r3, 0 - beq _08032E1C - ldr r1, =gBattleMainFunc - ldr r0, =BeginBattleIntro - str r0, [r1] - ldr r2, =gBattleBankFunc - ldr r0, =SetBankFuncToPlayerBufferRunCommand - str r0, [r2] - ldr r1, =gBanksBySide - movs r0, 0 - strb r0, [r1] - ldr r3, =SetBankFuncToOpponentBufferRunCommand - str r3, [r2, 0x4] - strb r5, [r1, 0x1] - ldr r0, =SetBankFuncToLinkPartnerBufferRunCommand - b _08032E2E - .pool -_08032E1C: - ldr r2, =gBattleBankFunc - ldr r0, =SetBankFuncToLinkPartnerBufferRunCommand - str r0, [r2] - ldr r1, =gBanksBySide - strb r3, [r1] - ldr r3, =SetBankFuncToLinkOpponentBufferRunCommand - str r3, [r2, 0x4] - strb r5, [r1, 0x1] - ldr r0, =SetBankFuncToPlayerBufferRunCommand -_08032E2E: - str r0, [r2, 0x8] - movs r0, 0x2 - strb r0, [r1, 0x2] - str r3, [r2, 0xC] - movs r0, 0x3 - strb r0, [r1, 0x3] - ldr r0, =gNoOfAllBanks - strb r4, [r0] - movs r0, 0 - movs r1, 0 - bl sub_81B8D64 - movs r0, 0x1 - movs r1, 0 - bl sub_81B8D64 - movs r0, 0x2 - movs r1, 0x1 - bl sub_81B8D64 - movs r0, 0x3 - movs r1, 0x1 - bl sub_81B8D64 - ldr r0, =gBattlePartyID - movs r1, 0 - strh r1, [r0] - strh r1, [r0, 0x2] - movs r1, 0x3 - strh r1, [r0, 0x4] - strh r1, [r0, 0x6] - b _0803303C - .pool -_08032E8C: - bl GetMultiplayerId - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, [r4] - movs r1, 0x4 - ands r0, r1 - cmp r0, 0 - beq _08032EA4 - ldr r1, =gBattleMainFunc - ldr r0, =BeginBattleIntro - str r0, [r1] -_08032EA4: - movs r0, 0 - mov r10, r0 - ldr r1, =gLinkPlayers - mov r12, r1 - ldr r7, =gBanksBySide - mov r8, r0 - ldr r6, =gBattlePartyID - movs r4, 0 - movs r2, 0x3 - mov r9, r2 -_08032EB8: - mov r1, r12 - adds r0, r4, r1 - ldrh r0, [r0, 0x18] - cmp r0, 0x2 - bgt _08032EE0 - cmp r0, 0x1 - bge _08032EF8 - cmp r0, 0 - beq _08032EE4 - b _08032F02 - .pool -_08032EE0: - cmp r0, 0x3 - bne _08032F02 -_08032EE4: - ldr r0, =gLinkPlayers - adds r0, r4, r0 - ldrb r0, [r0, 0x18] - movs r1, 0 - bl sub_81B8D64 - b _08032F02 - .pool -_08032EF8: - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - bl sub_81B8D64 -_08032F02: - cmp r10, r5 - bne _08032F52 - ldr r0, =gLinkPlayers - adds r3, r4, r0 - ldrh r1, [r3, 0x18] - lsls r1, 2 - ldr r2, =gBattleBankFunc - adds r1, r2 - ldr r2, =SetBankFuncToPlayerBufferRunCommand - str r2, [r1] - ldrh r1, [r3, 0x18] - mov r12, r0 - cmp r1, 0x2 - bgt _08032F34 - cmp r1, 0x1 - bge _08032F48 - cmp r1, 0 - beq _08032F38 - b _08033028 - .pool -_08032F34: - cmp r1, 0x3 - bne _08033028 -_08032F38: - mov r1, r12 - adds r0, r4, r1 - ldrh r1, [r0, 0x18] - adds r1, r7 - mov r2, r8 - strb r2, [r1] - ldrh r0, [r0, 0x18] - b _0803300E -_08032F48: - adds r1, r7 - movs r0, 0x2 - strb r0, [r1] - ldrh r0, [r3, 0x18] - b _08033020 -_08032F52: - ldr r2, =gLinkPlayers - adds r0, r4, r2 - ldrh r1, [r0, 0x18] - movs r3, 0x1 - adds r0, r3, 0 - ands r0, r1 - mov r12, r2 - cmp r0, 0 - bne _08032F7C - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - add r0, r12 - ldrh r1, [r0, 0x18] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _08032F8E - b _08032FD4 - .pool -_08032F7C: - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - add r0, r12 - ldrh r1, [r0, 0x18] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _08032FD4 -_08032F8E: - mov r0, r12 - adds r2, r4, r0 - ldrh r0, [r2, 0x18] - lsls r0, 2 - ldr r1, =gBattleBankFunc - adds r0, r1 - ldr r1, =SetBankFuncToLinkPartnerBufferRunCommand - str r1, [r0] - ldrh r1, [r2, 0x18] - cmp r1, 0x2 - bgt _08032FB8 - cmp r1, 0x1 - bge _08032FCC - cmp r1, 0 - beq _08032FBC - b _08033028 - .pool -_08032FB8: - cmp r1, 0x3 - bne _08033028 -_08032FBC: - mov r2, r12 - adds r0, r4, r2 - ldrh r1, [r0, 0x18] - adds r1, r7 - mov r2, r8 - strb r2, [r1] - ldrh r0, [r0, 0x18] - b _0803300E -_08032FCC: - adds r1, r7 - movs r0, 0x2 - strb r0, [r1] - b _0803301E -_08032FD4: - mov r0, r12 - adds r2, r4, r0 - ldrh r0, [r2, 0x18] - lsls r0, 2 - ldr r1, =gBattleBankFunc - adds r0, r1 - ldr r1, =SetBankFuncToLinkOpponentBufferRunCommand - str r1, [r0] - ldrh r0, [r2, 0x18] - cmp r0, 0x2 - bgt _08032FFC - cmp r0, 0x1 - bge _08033018 - cmp r0, 0 - beq _08033000 - b _08033028 - .pool -_08032FFC: - cmp r0, 0x3 - bne _08033028 -_08033000: - mov r0, r12 - adds r2, r4, r0 - ldrh r0, [r2, 0x18] - adds r0, r7 - movs r1, 0x1 - strb r1, [r0] - ldrh r0, [r2, 0x18] -_0803300E: - lsls r0, 1 - adds r0, r6 - mov r1, r8 - strh r1, [r0] - b _08033028 -_08033018: - adds r0, r7 - mov r1, r9 - strb r1, [r0] -_0803301E: - ldrh r0, [r2, 0x18] -_08033020: - lsls r0, 1 - adds r0, r6 - mov r2, r9 - strh r2, [r0] -_08033028: - adds r4, 0x1C - movs r0, 0x1 - add r10, r0 - mov r1, r10 - cmp r1, 0x3 - bgt _08033036 - b _08032EB8 -_08033036: - ldr r1, =gNoOfAllBanks - movs r0, 0x4 -_0803303A: - strb r0, [r1] -_0803303C: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end b_setup_bx_link - - thumb_func_start sub_8033050 -sub_8033050: @ 8033050 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08033068 - b _0803319C -_08033068: - movs r0, 0 - mov r8, r0 - b _0803317A - .pool -_08033074: - movs r5, 0 - movs r0, 0x1 - add r0, r8 - mov r10, r0 - ldr r0, =gBanksBySide - add r0, r8 - mov r9, r0 - mov r0, r8 - lsls r6, r0, 1 - movs r7, 0 -_08033088: - mov r0, r8 - cmp r0, 0x1 - bgt _080330F0 - mov r0, r9 - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080330A8 - ldr r0, =gPlayerParty - b _080330AA - .pool -_080330A8: - ldr r0, =gEnemyParty -_080330AA: - adds r4, r7, r0 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _08033170 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - cmp r0, 0 - beq _08033170 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - beq _08033170 - adds r0, r4, 0 - movs r1, 0x2D - bl GetMonData - cmp r0, 0 - bne _08033170 - ldr r0, =gBattlePartyID - adds r0, r6, r0 - strh r5, [r0] - b _08033178 - .pool -_080330F0: - mov r0, r9 - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08033118 - ldr r0, =gPlayerParty - adds r4, r7, r0 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _08033170 - adds r0, r4, 0 - movs r1, 0xB - b _0803312C - .pool -_08033118: - ldr r0, =gEnemyParty - adds r4, r7, r0 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _08033170 - adds r0, r4, 0 - movs r1, 0x41 -_0803312C: - bl GetMonData - cmp r0, 0 - beq _08033170 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - beq _08033170 - adds r0, r4, 0 - movs r1, 0x2D - bl GetMonData - cmp r0, 0 - bne _08033170 - ldr r1, =gBattlePartyID - mov r0, r8 - subs r0, 0x2 - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - cmp r0, r5 - beq _08033170 - adds r0, r6, r1 - strh r5, [r0] - b _08033178 - .pool -_08033170: - adds r7, 0x64 - adds r5, 0x1 - cmp r5, 0x5 - ble _08033088 -_08033178: - mov r8, r10 -_0803317A: - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r8, r0 - bge _08033184 - b _08033074 -_08033184: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 8 - ands r0, r1 - cmp r0, 0 - beq _0803319C - ldr r0, =gBattlePartyID - movs r1, 0 - strh r1, [r0, 0x2] - movs r1, 0x3 - strh r1, [r0, 0x6] -_0803319C: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8033050 - - thumb_func_start dp01_prepare_buffer -dp01_prepare_buffer: @ 80331B8 - push {r4-r6,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r3, r0, 24 - adds r5, r3, 0 - lsls r2, 16 - lsrs r2, 16 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080331E4 - adds r0, r3, 0 - adds r1, r2, 0 - adds r2, r4, 0 - bl PrepareBufferDataTransferLink - b _08033236 - .pool -_080331E4: - cmp r5, 0 - beq _080331EE - cmp r5, 0x1 - beq _08033218 - b _08033236 -_080331EE: - movs r3, 0 - cmp r3, r2 - bge _08033236 - ldr r6, =gBattleBufferA - ldr r5, =gActiveBank -_080331F8: - ldrb r0, [r5] - lsls r0, 9 - adds r0, r3, r0 - adds r0, r6 - ldrb r1, [r4] - strb r1, [r0] - adds r4, 0x1 - adds r3, 0x1 - cmp r3, r2 - blt _080331F8 - b _08033236 - .pool -_08033218: - movs r3, 0 - cmp r3, r2 - bge _08033236 - ldr r6, =gBattleBufferB - ldr r5, =gActiveBank -_08033222: - ldrb r0, [r5] - lsls r0, 9 - adds r0, r3, r0 - adds r0, r6 - ldrb r1, [r4] - strb r1, [r0] - adds r4, 0x1 - adds r3, 0x1 - cmp r3, r2 - blt _08033222 -_08033236: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end dp01_prepare_buffer - - thumb_func_start sub_8033244 -sub_8033244: @ 8033244 - push {r4-r6,lr} - ldr r0, =task00_wireless_something - movs r1, 0 - bl CreateTask - ldr r2, =gUnknown_02022D08 - strb r0, [r2] - ldr r5, =gTasks - ldrb r1, [r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - movs r6, 0 - movs r4, 0 - strh r4, [r0, 0x1E] - ldrb r1, [r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - strh r4, [r0, 0x20] - ldrb r1, [r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - strh r4, [r0, 0x22] - ldrb r1, [r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - strh r4, [r0, 0x24] - ldrb r1, [r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - strh r4, [r0, 0x26] - ldr r0, =sub_803375C - movs r1, 0 - bl CreateTask - ldr r2, =gUnknown_02022D09 - strb r0, [r2] - ldrb r1, [r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - strh r4, [r0, 0x20] - ldrb r1, [r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - strh r4, [r0, 0x22] - ldrb r1, [r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - strh r4, [r0, 0x24] - ldrb r1, [r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - strh r4, [r0, 0x26] - ldr r0, =gUnknown_02022D0A - strb r6, [r0] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8033244 - - thumb_func_start PrepareBufferDataTransferLink -PrepareBufferDataTransferLink: @ 80332F4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - mov r9, r2 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 16 - lsrs r1, 16 - mov r12, r1 - movs r1, 0x3 - mov r0, r12 - bics r0, r1 - adds r0, 0x4 - mov r8, r0 - ldr r2, =gTasks - ldr r3, =gUnknown_02022D08 - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r4, r0, r2 - movs r1, 0x24 - ldrsh r0, [r4, r1] - add r0, r8 - adds r0, 0x9 - movs r1, 0x80 - lsls r1, 5 - adds r5, r2, 0 - cmp r0, r1 - ble _08033346 - ldrh r0, [r4, 0x24] - movs r2, 0 - strh r0, [r4, 0x20] - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - strh r2, [r0, 0x24] -_08033346: - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - movs r2, 0x24 - ldrsh r1, [r0, r2] - ldr r4, =gUnknown_020244A0 - ldr r0, [r4] - adds r0, r1 - strb r6, [r0] - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - movs r7, 0x24 - ldrsh r1, [r0, r7] - ldr r0, [r4] - adds r1, r0 - ldr r0, =gActiveBank - ldrb r0, [r0] - strb r0, [r1, 0x1] - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - movs r2, 0x24 - ldrsh r1, [r0, r2] - ldr r0, [r4] - adds r1, r0 - ldr r0, =gBankAttacker - ldrb r0, [r0] - strb r0, [r1, 0x2] - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - movs r7, 0x24 - ldrsh r1, [r0, r7] - ldr r0, [r4] - adds r1, r0 - ldr r0, =gBankTarget - ldrb r0, [r0] - strb r0, [r1, 0x3] - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - movs r1, 0x24 - ldrsh r0, [r0, r1] - ldr r1, [r4] - adds r0, r1 - mov r2, r8 - strb r2, [r0, 0x4] - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - movs r7, 0x24 - ldrsh r1, [r0, r7] - ldr r0, [r4] - adds r1, r0 - movs r0, 0xFF - lsls r0, 8 - mov r2, r8 - ands r0, r2 - asrs r0, 8 - strb r0, [r1, 0x5] - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - movs r7, 0x24 - ldrsh r1, [r0, r7] - ldr r0, [r4] - adds r1, r0 - ldr r0, =gAbsentBankFlags - ldrb r0, [r0] - strb r0, [r1, 0x6] - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r5 - movs r2, 0x24 - ldrsh r1, [r0, r2] - ldr r0, [r4] - adds r1, r0 - ldr r0, =gEffectBank - ldrb r0, [r0] - strb r0, [r1, 0x7] - movs r2, 0 - cmp r2, r12 - bge _08033434 - mov r10, r5 - adds r6, r3, 0 -_08033412: - ldrb r1, [r6] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - add r0, r10 - movs r7, 0x24 - ldrsh r1, [r0, r7] - ldr r0, [r4] - adds r1, r2, r1 - adds r1, r0 - mov r7, r9 - adds r0, r7, r2 - ldrb r0, [r0] - strb r0, [r1, 0x8] - adds r2, 0x1 - cmp r2, r12 - blt _08033412 -_08033434: - ldrb r0, [r3] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r5 - ldrh r0, [r1, 0x24] - add r0, r8 - adds r0, 0x8 - strh r0, [r1, 0x24] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end PrepareBufferDataTransferLink - - thumb_func_start task00_wireless_something -task00_wireless_something: @ 8033474 - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r2, 0x1E - ldrsh r0, [r0, r2] - adds r7, r1, 0 - cmp r0, 0x5 - bls _08033490 - b _08033640 -_08033490: - lsls r0, 2 - ldr r1, =_080334A4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080334A4: - .4byte _080334BC - .4byte _080334CA - .4byte _080334E6 - .4byte _08033570 - .4byte _080335E6 - .4byte _08033624 -_080334BC: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r7 - movs r1, 0x64 - strh r1, [r0, 0x1C] - b _080334F6 -_080334CA: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r1, r0, r7 - ldrh r0, [r1, 0x1C] - subs r0, 0x1 - strh r0, [r1, 0x1C] - lsls r0, 16 - cmp r0, 0 - beq _080334E0 - b _08033640 -_080334E0: - ldrh r0, [r1, 0x1E] - adds r0, 0x1 - b _0803363E -_080334E6: - ldr r0, =gLinkVSyncDisabled - ldrb r0, [r0] - cmp r0, 0 - beq _08033504 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r7 -_080334F6: - ldrh r1, [r0, 0x1E] - adds r1, 0x1 - strh r1, [r0, 0x1E] - b _08033640 - .pool -_08033504: - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 1 - ands r0, r1 - cmp r0, 0 - beq _0803351C - movs r5, 0x2 - b _0803352A - .pool -_0803351C: - movs r0, 0x40 - ands r1, r0 - movs r0, 0x2 - cmp r1, 0 - beq _08033528 - movs r0, 0x4 -_08033528: - adds r5, r0, 0 -_0803352A: - bl sub_800ABAC - lsls r0, 24 - lsrs r0, 24 - cmp r0, r5 - bcs _08033538 - b _08033640 -_08033538: - bl sub_800ABBC - lsls r0, 24 - cmp r0, 0 - beq _0803355C - bl sub_800A620 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x1E] - adds r0, 0x1 - b _0803363E - .pool -_0803355C: - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x1E] - adds r0, 0x1 - b _0803363E - .pool -_08033570: - lsls r1, r4, 2 - adds r0, r1, r4 - lsls r0, 3 - adds r2, r0, r7 - movs r3, 0x26 - ldrsh r5, [r2, r3] - movs r0, 0x24 - ldrsh r6, [r2, r0] - mov r12, r6 - cmp r5, r12 - beq _08033640 - ldrh r0, [r2, 0x22] - movs r6, 0x22 - ldrsh r3, [r2, r6] - cmp r3, 0 - bne _080335E0 - cmp r5, r12 - ble _080335A0 - movs r6, 0x20 - ldrsh r0, [r2, r6] - cmp r5, r0 - bne _080335A0 - strh r3, [r2, 0x20] - strh r3, [r2, 0x26] -_080335A0: - adds r4, r1, r4 - lsls r4, 3 - adds r4, r7 - movs r0, 0x26 - ldrsh r1, [r4, r0] - ldr r5, =gUnknown_020244A0 - ldr r0, [r5] - adds r1, r0 - ldrb r0, [r1, 0x4] - ldrb r1, [r1, 0x5] - lsls r1, 8 - orrs r0, r1 - adds r0, 0x8 - lsls r0, 16 - lsrs r6, r0, 16 - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x26 - ldrsh r2, [r4, r1] - ldr r1, [r5] - adds r1, r2 - adds r2, r6, 0 - bl SendBlock - ldrh r0, [r4, 0x1E] - adds r0, 0x1 - strh r0, [r4, 0x1E] - b _08033640 - .pool -_080335E0: - subs r0, 0x1 - strh r0, [r2, 0x22] - b _08033640 -_080335E6: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - beq _08033640 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - movs r3, 0x26 - ldrsh r2, [r1, r3] - ldr r0, =gUnknown_020244A0 - ldr r0, [r0] - adds r2, r0 - ldrb r0, [r2, 0x4] - ldrb r2, [r2, 0x5] - lsls r2, 8 - movs r3, 0x1 - strh r3, [r1, 0x22] - orrs r0, r2 - ldrh r6, [r1, 0x26] - adds r0, r6 - adds r0, 0x8 - strh r0, [r1, 0x26] - b _0803363C - .pool -_08033624: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r1, r0, r7 - ldrh r0, [r1, 0x22] - subs r0, 0x1 - strh r0, [r1, 0x22] - lsls r0, 16 - cmp r0, 0 - bne _08033640 - movs r0, 0x1 - strh r0, [r1, 0x22] -_0803363C: - movs r0, 0x3 -_0803363E: - strh r0, [r1, 0x1E] -_08033640: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end task00_wireless_something - - thumb_func_start sub_8033648 -sub_8033648: @ 8033648 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - beq _08033738 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x20 - ands r0, r1 - cmp r0, 0 - beq _08033738 - bl sub_8011BD0 - movs r4, 0 - ldr r0, =gBlockRecvBuffer - mov r10, r0 - b _0803372C - .pool -_08033680: - bl GetBlockReceivedStatus - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gBitTable - lsls r1, r4, 2 - adds r1, r2 - ldr r1, [r1] - ands r0, r1 - adds r1, r4, 0x1 - mov r9, r1 - cmp r0, 0 - beq _08033726 - adds r0, r4, 0 - bl sub_800A5EC - lsls r0, r4, 8 - mov r4, r10 - adds r3, r0, r4 - ldr r1, =gBlockRecvBuffer + 4 - adds r0, r1 - ldrh r6, [r0] - ldr r7, =gTasks - ldr r4, =gUnknown_02022D09 - mov r12, r4 - ldrb r1, [r4] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r2, r0, r7 - movs r0, 0x24 - ldrsh r1, [r2, r0] - adds r0, r6, 0 - adds r0, 0x9 - adds r1, r0 - movs r0, 0x80 - lsls r0, 5 - cmp r1, r0 - ble _080336E0 - ldrh r0, [r2, 0x24] - strh r0, [r2, 0x20] - ldrb r1, [r4] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - movs r1, 0 - strh r1, [r0, 0x24] -_080336E0: - ldr r2, =gUnknown_020244A4 - mov r4, r12 - ldrb r1, [r4] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - movs r4, 0x24 - ldrsh r1, [r0, r4] - ldr r0, [r2] - adds r5, r0, r1 - adds r4, r3, 0 - movs r2, 0 - adds r3, r6, 0 - adds r3, 0x8 - mov r8, r7 - mov r7, r12 - cmp r2, r3 - bge _08033714 -_08033706: - adds r0, r5, r2 - adds r1, r4, r2 - ldrb r1, [r1] - strb r1, [r0] - adds r2, 0x1 - cmp r2, r3 - blt _08033706 -_08033714: - ldrb r0, [r7] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - add r1, r8 - ldrh r0, [r1, 0x24] - adds r0, r6, r0 - adds r0, 0x8 - strh r0, [r1, 0x24] -_08033726: - mov r1, r9 - lsls r0, r1, 24 - lsrs r4, r0, 24 -_0803372C: - bl sub_8009FCC - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - bcc _08033680 -_08033738: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8033648 - - thumb_func_start sub_803375C -sub_803375C: @ 803375C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r3, r0, r1 - movs r0, 0x26 - ldrsh r2, [r3, r0] - movs r4, 0x24 - ldrsh r0, [r3, r4] - cmp r2, r0 - bne _08033780 - b _0803389C -_08033780: - cmp r2, r0 - ble _08033792 - movs r4, 0x20 - ldrsh r0, [r3, r4] - cmp r2, r0 - bne _08033792 - movs r0, 0 - strh r0, [r3, 0x20] - strh r0, [r3, 0x26] -_08033792: - lsls r2, r7, 2 - adds r0, r2, r7 - lsls r0, 3 - adds r5, r0, r1 - movs r0, 0x26 - ldrsh r1, [r5, r0] - ldr r3, =gUnknown_020244A4 - mov r8, r3 - ldr r0, [r3] - adds r3, r1, r0 - ldrb r4, [r3, 0x1] - ldrb r6, [r3, 0x4] - ldrb r0, [r3, 0x5] - lsls r0, 8 - orrs r6, r0 - ldrb r0, [r3] - mov r9, r2 - cmp r0, 0x1 - beq _0803385C - cmp r0, 0x1 - bgt _080337CC - cmp r0, 0 - beq _080337D2 - b _0803388A - .pool -_080337CC: - cmp r0, 0x2 - beq _08033874 - b _0803388A -_080337D2: - ldr r2, =gBattleExecBuffer - ldr r1, =gBitTable - lsls r0, r4, 2 - adds r0, r1 - ldr r1, [r2] - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _0803389C - lsls r0, r4, 9 - ldr r1, =gBattleBufferA - adds r0, r1 - adds r1, r3, 0 - adds r1, 0x8 - adds r2, r6, 0 - bl memcpy - adds r0, r4, 0 - bl sub_803F850 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x4 - ands r0, r1 - cmp r0, 0 - bne _0803388A - ldr r2, =gBankAttacker - movs r4, 0x26 - ldrsh r0, [r5, r4] - mov r3, r8 - ldr r1, [r3] - adds r0, r1 - ldrb r0, [r0, 0x2] - strb r0, [r2] - ldr r2, =gBankTarget - movs r4, 0x26 - ldrsh r0, [r5, r4] - adds r0, r1 - ldrb r0, [r0, 0x3] - strb r0, [r2] - ldr r2, =gAbsentBankFlags - movs r3, 0x26 - ldrsh r0, [r5, r3] - adds r0, r1 - ldrb r0, [r0, 0x6] - strb r0, [r2] - ldr r2, =gEffectBank - movs r4, 0x26 - ldrsh r0, [r5, r4] - adds r0, r1 - ldrb r0, [r0, 0x7] - strb r0, [r2] - b _0803388A - .pool -_0803385C: - lsls r0, r4, 9 - ldr r1, =gBattleBufferB - adds r0, r1 - adds r1, r3, 0 - adds r1, 0x8 - adds r2, r6, 0 - bl memcpy - b _0803388A - .pool -_08033874: - ldrb r2, [r3, 0x8] - ldr r3, =gBattleExecBuffer - ldr r1, =gBitTable - lsls r0, r4, 2 - adds r0, r1 - lsls r2, 2 - ldr r1, [r0] - lsls r1, r2 - ldr r0, [r3] - bics r0, r1 - str r0, [r3] -_0803388A: - ldr r0, =gTasks - mov r2, r9 - adds r1, r2, r7 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x26] - adds r0, r6, r0 - adds r0, 0x8 - strh r0, [r1, 0x26] -_0803389C: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_803375C thumb_func_start EmitGetMonData EmitGetMonData: @ 80338B4 @@ -2147,7 +20,7 @@ EmitGetMonData: @ 80338B4 strb r2, [r1, 0x2] strb r3, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4} pop {r0} bx r0 @@ -2168,7 +41,7 @@ dp01_build_cmdbuf_x01_a_b_0: @ 80338D8 strb r2, [r1, 0x2] strb r4, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4,r5} pop {r0} bx r0 @@ -2204,7 +77,7 @@ _08033920: _0803392E: adds r2, r5, 0x3 adds r0, r6, 0 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4-r6} pop {r0} bx r0 @@ -2240,7 +113,7 @@ _0803396C: adds r2, r4, 0x3 adds r0, r6, 0 adds r1, r5, 0 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4-r6} pop {r0} bx r0 @@ -2258,7 +131,7 @@ EmitLoadMonSprite: @ 8033980 strb r2, [r1, 0x1] strb r2, [r1, 0x2] strb r2, [r1, 0x3] - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -2277,7 +150,7 @@ EmitSwitchInAnim: @ 80339A0 strb r2, [r1, 0x2] strb r3, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4} pop {r0} bx r0 @@ -2295,7 +168,7 @@ EmitReturnPokeToBall: @ 80339C4 strb r2, [r1] strb r3, [r1, 0x1] movs r2, 0x2 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -2313,7 +186,7 @@ EmitDrawTrainerPic: @ 80339E4 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -2331,7 +204,7 @@ EmitTrainerSlide: @ 8033A04 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -2349,7 +222,7 @@ EmitTrainerSlideBack: @ 8033A24 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -2367,7 +240,7 @@ EmitFaintAnimation: @ 8033A44 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -2385,7 +258,7 @@ dp01_build_cmdbuf_x0B_B_B_B: @ 8033A64 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -2403,7 +276,7 @@ dp01_build_cmdbuf_x0C_C_C_C: @ 8033A84 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -2420,7 +293,7 @@ EmitBallThrow: @ 8033AA4 strb r2, [r1] strb r3, [r1, 0x1] movs r2, 0x2 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -2458,7 +331,7 @@ _08033AF2: adds r2, 0x2 adds r0, r6, 0 adds r1, r5, 0 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4-r6} pop {r0} bx r0 @@ -2559,7 +432,7 @@ _08033BB6: mov r0, r9 adds r1, r4, 0 movs r2, 0x2C - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer add sp, 0x4 pop {r3,r4} mov r8, r3 @@ -2676,7 +549,7 @@ _08033C88: mov r0, r10 mov r1, r9 movs r2, 0x44 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r3-r5} mov r8, r3 mov r9, r4 @@ -2775,7 +648,7 @@ _08033D7C: mov r0, r10 mov r1, r9 movs r2, 0x44 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r3-r5} mov r8, r3 mov r9, r4 @@ -2802,7 +675,7 @@ EmitChooseAction: @ 8033DE4 lsrs r2, 8 strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4} pop {r0} bx r0 @@ -2821,7 +694,7 @@ EmitCmd13: @ 8033E10 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -2853,7 +726,7 @@ _08033E4C: bls _08033E4C adds r0, r6, 0 movs r2, 0x18 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4-r6} pop {r0} bx r0 @@ -2881,7 +754,7 @@ _08033E7E: ble _08033E7E adds r0, r5, 0 movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4,r5} pop {r0} bx r0 @@ -2913,7 +786,7 @@ _08033EBA: ble _08033EBA adds r0, r5, 0 movs r2, 0x8 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4-r6} pop {r0} bx r0 @@ -2932,7 +805,7 @@ dp01_build_cmdbuf_x17_17_17_17: @ 8033EDC strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -2960,7 +833,7 @@ EmitHealthBarUpdate: @ 8033EFC strb r1, [r3, 0x3] adds r1, r3, 0 movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4} pop {r0} bx r0 @@ -2988,7 +861,7 @@ EmitExpUpdate: @ 8033F34 asrs r2, 8 strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4} pop {r0} bx r0 @@ -3031,7 +904,7 @@ EmitStatusIconUpdate: @ 8033F68 lsrs r2, 24 strb r2, [r1, 0x8] movs r2, 0x9 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4-r6} pop {r0} bx r0 @@ -3062,7 +935,7 @@ EmitStatusAnimation: @ 8033FBC lsrs r2, 24 strb r2, [r1, 0x5] movs r2, 0x6 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4} pop {r0} bx r0 @@ -3080,7 +953,7 @@ dp01_build_cmdbuf_x1C_a: @ 8033FF8 strb r2, [r1] strb r3, [r1, 0x1] movs r2, 0x2 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3119,7 +992,7 @@ _08034048: lsrs r2, 16 adds r0, r6, 0 adds r1, r5, 0 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4-r6} pop {r0} bx r0 @@ -3174,7 +1047,7 @@ _080340B0: lsls r2, 16 lsrs r2, 16 adds r0, r6, 0 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4-r6} pop {r0} bx r0 @@ -3213,7 +1086,7 @@ _080340F6: lsrs r2, 16 adds r0, r6, 0 adds r1, r5, 0 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4-r6} pop {r0} bx r0 @@ -3252,7 +1125,7 @@ _0803413E: lsrs r2, 16 adds r0, r6, 0 adds r1, r5, 0 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4-r6} pop {r0} bx r0 @@ -3275,7 +1148,7 @@ EmitCmd_x21: @ 8034158 lsrs r2, 8 strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4} pop {r0} bx r0 @@ -3305,7 +1178,7 @@ _08034198: adds r0, r5, 0 adds r1, r2, 0 movs r2, 0x5 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4,r5} pop {r0} bx r0 @@ -3329,7 +1202,7 @@ dp01_build_cmdbuf_x23_aa_0: @ 80341BC strb r4, [r3, 0x3] adds r1, r3, 0 movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4} pop {r0} bx r0 @@ -3353,7 +1226,7 @@ dp01_build_cmdbuf_x24_aa_0: @ 80341E8 strb r4, [r3, 0x3] adds r1, r3, 0 movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4} pop {r0} bx r0 @@ -3372,7 +1245,7 @@ dp01_build_cmdbuf_x25_25_25_25: @ 8034214 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3389,7 +1262,7 @@ dp01_build_cmdbuf_x26_a: @ 8034234 strb r2, [r1] strb r3, [r1, 0x1] movs r2, 0x2 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3407,7 +1280,7 @@ dp01_build_cmdbuf_x27_27_27_27: @ 8034254 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3425,7 +1298,7 @@ dp01_build_cmdbuf_x28_28_28_28: @ 8034274 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3443,7 +1316,7 @@ EmitHitAnimation: @ 8034294 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3461,7 +1334,7 @@ Emit_x2A: @ 80342B4 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3484,7 +1357,7 @@ EmitEffectivenessSound: @ 80342D4 strb r4, [r3, 0x3] adds r1, r3, 0 movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4} pop {r0} bx r0 @@ -3507,7 +1380,7 @@ EmitPlaySound: @ 8034300 strb r2, [r4, 0x3] adds r1, r4, 0 movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4} pop {r0} bx r0 @@ -3526,7 +1399,7 @@ EmitFaintingCry: @ 803432C strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3543,7 +1416,7 @@ EmitIntroSlide: @ 803434C strb r2, [r1] strb r3, [r1, 0x1] movs r2, 0x2 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3561,7 +1434,7 @@ EmitIntroTrainerBallThrow: @ 803436C strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3599,7 +1472,7 @@ _080343B4: ble _080343B4 adds r0, r5, 0 movs r2, 0x34 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4,r5} pop {r0} bx r0 @@ -3618,7 +1491,7 @@ EmitCmd49: @ 80343D4 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3636,7 +1509,7 @@ Emit_x32: @ 80343F4 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3655,7 +1528,7 @@ EmitSpriteInvisibility: @ 8034414 strb r2, [r1, 0x2] strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3677,7 +1550,7 @@ EmitBattleAnimation: @ 8034438 lsrs r2, 8 strb r2, [r1, 0x3] movs r2, 0x4 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4} pop {r0} bx r0 @@ -3711,7 +1584,7 @@ _08034490: ldrb r2, [r1, 0x2] adds r2, 0x4 adds r0, r5, 0 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4,r5} pop {r0} bx r0 @@ -3729,7 +1602,7 @@ EmitResetActionMoveSelection: @ 80344A8 strb r2, [r1] strb r3, [r1, 0x1] movs r2, 0x2 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r0} bx r0 .pool @@ -3765,7 +1638,7 @@ Emit_x37: @ 80344C8 adds r2, 0x6 adds r0, r5, 0 adds r1, r4, 0 - bl dp01_prepare_buffer + bl PrepareBufferDataTransfer pop {r4,r5} pop {r0} bx r0 diff --git a/asm/rom6.s b/asm/rom6.s index 2ed9d888e..5eff527fe 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -5399,7 +5399,7 @@ sub_8138240: @ 8138240 bl GetMultiplayerId lsls r0, 24 lsrs r7, r0, 24 - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r5, r0, 24 movs r4, 0 @@ -11676,7 +11676,7 @@ _0813B62E: ldrh r0, [r0] strh r0, [r5] movs r0, 0x1 - bl sub_800A5EC + bl ResetBlockReceivedFlag ldr r0, =gSpecialVar_0x8004 ldrh r0, [r0] cmp r0, 0x1 @@ -11756,7 +11756,7 @@ _0813B6E4: ldrh r0, [r0] strh r0, [r1] movs r0, 0 - bl sub_800A5EC + bl ResetBlockReceivedFlag _0813B708: ldr r1, =gTasks lsls r0, r4, 2 diff --git a/asm/rom_80A5C6C.s b/asm/rom_80A5C6C.s index cf09bf148..3be09f93e 100644 --- a/asm/rom_80A5C6C.s +++ b/asm/rom_80A5C6C.s @@ -1810,7 +1810,7 @@ _080A6A04: GetBankSide: @ 80A6A30 lsls r0, 24 lsrs r0, 24 - ldr r1, =gBanksBySide + ldr r1, =gBanksByIdentity adds r0, r1 ldrb r1, [r0] movs r0, 0x1 @@ -1823,7 +1823,7 @@ GetBankSide: @ 80A6A30 GetBankIdentity: @ 80A6A44 lsls r0, 24 lsrs r0, 24 - ldr r1, =gBanksBySide + ldr r1, =gBanksByIdentity adds r0, r1 ldrb r0, [r0] bx lr @@ -1840,7 +1840,7 @@ GetBankByIdentity: @ 80A6A54 ldrb r2, [r0] cmp r1, r2 bcs _080A6A7E - ldr r4, =gBanksBySide + ldr r4, =gBanksByIdentity ldrb r0, [r4] cmp r0, r3 beq _080A6A7E @@ -1883,7 +1883,7 @@ sub_80A6A90: @ 80A6A90 b _080A6B18 .pool _080A6ABC: - ldr r0, =gBanksBySide + ldr r0, =gBanksByIdentity adds r0, r4, r0 ldrb r0, [r0] cmp r0, 0xFF diff --git a/asm/secret_base.s b/asm/secret_base.s index 0290e9f7f..0e47eaf4f 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -4494,7 +4494,7 @@ sub_80EAF80: @ 80EAF80 bne _080EAF9A b _080EB16A _080EAF9A: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r0, 0x2 diff --git a/asm/trade.s b/asm/trade.s index d4c54cef6..ba0655019 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -125,7 +125,7 @@ sub_8077234: @ 8077234 _08077250: lsls r0, r4, 24 lsrs r0, 24 - bl sub_800A5EC + bl ResetBlockReceivedFlag _08077258: pop {r4} pop {r0} @@ -6603,7 +6603,7 @@ _0807A97C: adds r4, 0x1C adds r5, 0x1 _0807A980: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -6632,7 +6632,7 @@ _0807A9B0: adds r4, 0x1C adds r5, 0x1 _0807A9B4: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -12903,7 +12903,7 @@ _0807E504: strb r6, [r0] _0807E514: movs r0, 0 - bl sub_800A5EC + bl ResetBlockReceivedFlag _0807E51A: movs r0, 0x2 ands r0, r5 @@ -12924,7 +12924,7 @@ _0807E51A: strb r1, [r0] _0807E53C: movs r0, 0x1 - bl sub_800A5EC + bl ResetBlockReceivedFlag _0807E542: pop {r4-r6} pop {r0} diff --git a/asm/tv.s b/asm/tv.s index d61392fa1..bdd74e730 100644 --- a/asm/tv.s +++ b/asm/tv.s @@ -7992,7 +7992,7 @@ _080F0270: lsls r0, 24 lsrs r4, r0, 24 _080F0276: - bl sub_8009FCC + bl GetLinkPlayerCount lsls r0, 24 lsrs r0, 24 cmp r4, r0 @@ -8107,7 +8107,7 @@ sub_80F0358: @ 80F0358 str r0, [sp, 0x8] add r0, sp, 0x1C str r0, [sp, 0xC] - bl sub_8009FCC + bl GetLinkPlayerCount ldr r1, =gUnknown_03001174 strb r0, [r1] _080F0384: @@ -9329,7 +9329,7 @@ sub_80F0D60: @ 80F0D60 str r0, [sp, 0x8] add r0, sp, 0x1C str r0, [sp, 0xC] - bl sub_8009FCC + bl GetLinkPlayerCount ldr r1, =gUnknown_03001175 strb r0, [r1] movs r0, 0 diff --git a/include/battle.h b/include/battle.h index a60f450ce..4a29e8488 100644 --- a/include/battle.h +++ b/include/battle.h @@ -27,7 +27,9 @@ #define BIT_SIDE 0x1 #define BIT_MON 0x2 +#define GET_BANK_IDENTITY(bank)((gBanksByIdentity[bank])) #define GET_BANK_SIDE(bank)((GetBankIdentity(bank) & BIT_SIDE)) +#define GET_BANK_SIDE2(bank)((GET_BANK_IDENTITY(bank) & BIT_SIDE)) #define BATTLE_TYPE_DOUBLE 0x0001 #define BATTLE_TYPE_LINK 0x0002 @@ -654,7 +656,9 @@ struct BattleStruct u8 field_1A1; bool8 overworldWeatherDone; u8 atkCancellerTracker; - u8 field_1A4[240]; + u8 field_1A4[96]; + u8 field_204[104]; + u8 field_26C[40]; u8 field_294[4]; u8 field_298[8]; u8 field_2A0; @@ -891,6 +895,11 @@ struct BattleSpriteData extern struct BattleSpriteData *gBattleSpritesDataPtr; +#define BATTLE_BUFFER_LINK_SIZE 0x1000 + +extern u8 *gLinkBattleSendBuffer; +extern u8 *gLinkBattleRecvBuffer; + // Move this somewhere else #include "sprite.h" diff --git a/include/battle_2.h b/include/battle_2.h index 677bf0505..ceec2aa00 100644 --- a/include/battle_2.h +++ b/include/battle_2.h @@ -17,6 +17,8 @@ void RunBattleScriptCommands_PopCallbacksStack(void); void RunBattleScriptCommands(void); u32 sub_80397C4(u32 setId, u32 tableId); void sub_8039E9C(struct Sprite *sprite); +void nullsub_20(void); +void BeginBattleIntro(void); extern const u8 gStatusConditionString_PoisonJpn[8]; extern const u8 gStatusConditionString_SleepJpn[8]; diff --git a/include/battle_anim.h b/include/battle_anim.h new file mode 100644 index 000000000..fa546b192 --- /dev/null +++ b/include/battle_anim.h @@ -0,0 +1,6 @@ +#ifndef GUARD_BATTLE_ANIM_H +#define GUARD_BATTLE_ANIM_H + +void ClearBattleAnimationVars(void); + +#endif // GUARD_BATTLE_ANIM_H diff --git a/include/battle_controllers.h b/include/battle_controllers.h index e36c95fbe..b36878210 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -46,7 +46,13 @@ struct ChooseMoveStruct u8 monType2; }; -// rom3.s, emitters +// general functions +void HandleLinkBattleSetup(void); +void SetUpBattleVarsAndBirchZigzagoon(void); +void sub_8032768(void); +void sub_8033648(void); + +// emitters void EmitSetMonData(u8 bufferId, u8 request, u8 c, u8 bytes, void *data); void EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct* disableStructPtr, u8 multihit); void EmitHealthBarUpdate(u8 bufferId, u16 hpValue); @@ -86,4 +92,34 @@ void EmitResetActionMoveSelection(u8 bufferId, u8 caseId); void EmitBallThrow(u8 bufferId, u8 caseId); void EmitCmd_x21(u8 bufferId, u8 arg1, u16 arg2); +// player controller +void SetBankFuncToPlayerBufferRunCommand(void); +void nullsub_21(void); +void ActionSelectionCreateCursorAt(u8 cursorPos, u8 unused); +void ActionSelectionDestroyCursorAt(u8 cursorPos); + +// recorded player controller +void SetBankFuncToRecordedPlayerBufferRunCommand(void); + +// opponent controller +void SetBankFuncToOpponentBufferRunCommand(void); + +// player partner controller +void SetBankFuncToPlayerPartnerBufferRunCommand(void); + +// safari controller +void SetBankFuncToSafariBufferRunCommand(void); + +// wally controller +void SetBankFuncToWallyBufferRunCommand(void); + +// recorded opponent controller +void SetBankFuncToRecordedOpponentBufferRunCommand(void); + +// link opponent +void SetBankFuncToLinkOpponentBufferRunCommand(void); + +// link partner +void SetBankFuncToLinkPartnerBufferRunCommand(void); + #endif // GUARD_BATTLE_CONTROLLERS_H diff --git a/include/link.h b/include/link.h index 012c90480..fa39af699 100644 --- a/include/link.h +++ b/include/link.h @@ -141,6 +141,7 @@ extern u8 gShouldAdvanceLinkState; extern struct LinkPlayer gLinkPlayers[]; extern u16 word_3002910[]; extern bool8 gReceivedRemoteLinkPlayers; +extern bool8 gLinkVSyncDisabled; void Task_DestroySelf(u8); void OpenLink(void); @@ -183,6 +184,12 @@ bool8 sub_800A520(void); bool8 sub_8010500(void); void sub_800DFB4(u8, u8); void sub_800ADF8(void); -u8 sub_8009FCC(void); +u8 GetLinkPlayerCount(void); +void sub_800B488(void); +void sub_8009734(void); +void sub_800A620(void); +void sub_8011BD0(void); +u8 sub_800ABAC(void); +u8 sub_800ABBC(void); #endif // GUARD_LINK_H diff --git a/include/recorded_battle.h b/include/recorded_battle.h index 65ad998e6..2d8135e41 100644 --- a/include/recorded_battle.h +++ b/include/recorded_battle.h @@ -3,6 +3,7 @@ extern u32 gRecordedBattleRngSeed; +void sub_8184DA4(u8 arg0); void sub_8185F84(void); void sub_8184E58(void); void RecordedBattle_SetBankAction(u8 bank, u8 action); @@ -15,5 +16,6 @@ u8 MoveRecordedBattleToSaveData(void); void sub_818603C(u8); void sub_8185FD0(void); void sub_8186444(void); +void sub_8185EB8(void); #endif // GUARD_RECORDED_BATTLE_H diff --git a/ld_script.txt b/ld_script.txt index 887f24811..b27015351 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -54,6 +54,7 @@ SECTIONS { asm/link.o(.text); src/rtc.o(.text); asm/main_menu.o(.text); + src/battle_controllers.o(.text); asm/rom3.o(.text); src/decompress.o(.text); asm/battle_1.o(.text); diff --git a/src/battle_2.c b/src/battle_2.c index c4da02e36..734b8c308 100644 --- a/src/battle_2.c +++ b/src/battle_2.c @@ -207,9 +207,6 @@ extern const u8 BattleScript_ActionSwitch[]; extern const u8 BattleScript_PrintFailedToRunString[]; // functions -extern void HandleLinkBattleSetup(void); // rom_3 -extern void SetUpBattleVarsAndBirchZigzagoon(void); // rom_3 -extern void sub_8032768(void); // rom_3 extern void dp12_8087EA4(void); extern void sub_80356D0(void); extern void GetFrontierTrainerName(u8* dst, u16 trainerId); // battle tower diff --git a/src/battle_controllers.c b/src/battle_controllers.c new file mode 100644 index 000000000..cfa4aae71 --- /dev/null +++ b/src/battle_controllers.c @@ -0,0 +1,928 @@ +#include "global.h" +#include "battle.h" +#include "battle_controllers.h" +#include "link.h" +#include "task.h" +#include "battle_ai_script_commands.h" +#include "battle_anim.h" +#include "pokemon.h" +#include "species.h" +#include "recorded_battle.h" +#include "util.h" + +extern u32 gBattleTypeFlags; +extern u32 gBattleExecBuffer; +extern void (*gBattleMainFunc)(void); +extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); +extern u8 gBanksByIdentity[BATTLE_BANKS_COUNT]; +extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; +extern u8 gMoveSelectionCursor[BATTLE_BANKS_COUNT]; +extern u8 gNoOfAllBanks; +extern u8 gActiveBank; +extern u8 gUnknown_0202428C; +extern u32 gUnknown_02022FF4; +extern u8 gUnknown_0203C7B4; +extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; +extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; +extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; +extern u8 gUnknown_02022D08; +extern u8 gUnknown_02022D09; +extern u8 gUnknown_02022D0A; +extern u8 gBankAttacker; +extern u8 gBankTarget; +extern u8 gAbsentBankFlags; +extern u8 gEffectBank; + +extern void task00_08081A90(u8 taskId); // cable_club +extern void sub_81B8D64(u8 bank, u8 arg1); // party_menu + +// this file's funcionts +static void sub_8033244(void); +static void SetControllersVariablesInLinkBattle(void); +static void SetControllersVariables(void); +static void sub_8033050(void); +void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data); +static void Task_HandleSendLinkBuffersData(u8 taskId); +static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId); + +void HandleLinkBattleSetup(void) +{ + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + if (gLinkVSyncDisabled) + sub_800B488(); + if (!gReceivedRemoteLinkPlayers) + sub_8009734(); + CreateTask(task00_08081A90, 0); + sub_8033244(); + } +} + +void SetUpBattleVarsAndBirchZigzagoon(void) +{ + s32 i; + + gBattleMainFunc = nullsub_20; + + for (i = 0; i < BATTLE_BANKS_COUNT; i++) + { + gBattleBankFunc[i] = nullsub_21; + gBanksByIdentity[i] = 0xFF; + gActionSelectionCursor[i] = 0; + gMoveSelectionCursor[i] = 0; + } + + HandleLinkBattleSetup(); + gBattleExecBuffer = 0; + ClearBattleAnimationVars(); + ClearBattleMonForms(); + BattleAI_HandleItemUseBeforeAISetup(0xF); + + if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE) + { + ZeroEnemyPartyMons(); + CreateMon(&gEnemyParty[0], SPECIES_ZIGZAGOON, 2, 32, 0, 0, 0, 0); + i = 0; + SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, &i); + } + + gUnknown_02022FF4 = 0; + gUnknown_0202428C = 0; +} + +void sub_8032768(void) +{ + s32 i; + u8 *data; + + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + sub_8184DA4(1); + else + sub_8184DA4(2); + + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) + sub_8185EB8(); + + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + SetControllersVariablesInLinkBattle(); + else + SetControllersVariables(); + + sub_8033050(); + + if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) + { + for (i = 0; i < gNoOfAllBanks; i++) + sub_81B8D64(i, 0); + } + + for (i = 0; i < sizeof(gBattleStruct->field_1A4); i++) + *(gBattleStruct->field_1A4 + i) = 0; + + for (i = 0; i < sizeof(gBattleStruct->field_204); i++) + *(gBattleStruct->field_204 + i) = 0; +} + +static void SetControllersVariables(void) +{ + s32 i; + + if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) + { + gBattleMainFunc = BeginBattleIntro; + + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) + { + gBattleBankFunc[0] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; + + gBattleBankFunc[2] = SetBankFuncToPlayerPartnerBufferRunCommand; + gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; + + gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; + } + else + { + gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; + + gBattleBankFunc[2] = SetBankFuncToPlayerPartnerBufferRunCommand; + gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; + + gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; + } + + gNoOfAllBanks = 4; + + sub_81B8D64(0, 0); + sub_81B8D64(1, 0); + sub_81B8D64(2, 1); + sub_81B8D64(3, 1); + + gBattlePartyID[0] = 0; + gBattlePartyID[1] = 0; + gBattlePartyID[2] = 3; + gBattlePartyID[3] = 3; + } + else if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) + { + gBattleMainFunc = BeginBattleIntro; + + if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) + gBattleBankFunc[0] = SetBankFuncToSafariBufferRunCommand; + else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) + gBattleBankFunc[0] = SetBankFuncToWallyBufferRunCommand; + else + gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + + gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; + + gNoOfAllBanks = 2; + + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) + { + if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + { + if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + { + gBattleMainFunc = BeginBattleIntro; + + gBattleBankFunc[0] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[1] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; + + gNoOfAllBanks = 2; + } + else // see how the banks are switched + { + gBattleBankFunc[1] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[0] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_OPPONENT_MON1; + + gNoOfAllBanks = 2; + } + } + else + { + gBattleBankFunc[0] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; + } + } + } + else + { + gBattleMainFunc = BeginBattleIntro; + + gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; + + gBattleBankFunc[2] = SetBankFuncToPlayerBufferRunCommand; + gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; + + gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; + + gNoOfAllBanks = 4; + + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) + { + if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) + { + gBattleMainFunc = BeginBattleIntro; + + gBattleBankFunc[0] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBanksByIdentity[0] = 0; + + gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[1] = 1; + + gBattleBankFunc[2] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBanksByIdentity[2] = 2; + + gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[3] = 3; + + gNoOfAllBanks = 4; + + sub_81B8D64(0, 0); + sub_81B8D64(1, 0); + sub_81B8D64(2, 1); + sub_81B8D64(3, 1); + + gBattlePartyID[0] = 0; + gBattlePartyID[1] = 0; + gBattlePartyID[2] = 3; + gBattlePartyID[3] = 3; + } + else if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + u8 var; // multiplayer Id in a recorded battle? + + for (var = gUnknown_0203C7B4, i = 0; i < BATTLE_BANKS_COUNT; i++) + { + switch (gLinkPlayers[i].lp_field_18) + { + case 0: + case 3: + sub_81B8D64(gLinkPlayers[i].lp_field_18, 0); + break; + case 1: + case 2: + sub_81B8D64(gLinkPlayers[i].lp_field_18, 1); + break; + } + + if (i == var) + { + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToRecordedPlayerBufferRunCommand; + switch (gLinkPlayers[i].lp_field_18) + { + case 0: + case 3: + gBanksByIdentity[gLinkPlayers[i].lp_field_18] = IDENTITY_PLAYER_MON1; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; + break; + case 1: + case 2: + gBanksByIdentity[gLinkPlayers[i].lp_field_18] = IDENTITY_PLAYER_MON2; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; + break; + } + } + else if ((!(gLinkPlayers[i].lp_field_18 & 1) && !(gLinkPlayers[var].lp_field_18 & 1)) + || ((gLinkPlayers[i].lp_field_18 & 1) && (gLinkPlayers[var].lp_field_18 & 1))) + { + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToRecordedPlayerBufferRunCommand; + switch (gLinkPlayers[i].lp_field_18) + { + case 0: + case 3: + gBanksByIdentity[gLinkPlayers[i].lp_field_18] = IDENTITY_PLAYER_MON1; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; + break; + case 1: + case 2: + gBanksByIdentity[gLinkPlayers[i].lp_field_18] = IDENTITY_PLAYER_MON2; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; + break; + } + } + else + { + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToRecordedOpponentBufferRunCommand; + switch (gLinkPlayers[i].lp_field_18) + { + case 0: + case 3: + gBanksByIdentity[gLinkPlayers[i].lp_field_18] = IDENTITY_OPPONENT_MON1; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; + break; + case 1: + case 2: + gBanksByIdentity[gLinkPlayers[i].lp_field_18] = IDENTITY_OPPONENT_MON2; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; + break; + } + } + } + } + else if (gBattleTypeFlags & BATTLE_TYPE_WILD) + { + gBattleBankFunc[0] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[2] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; + + if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + { + gBattleBankFunc[1] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; + + gBattleBankFunc[3] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; + } + else + { + gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; + + gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; + } + } + else + { + gBattleBankFunc[1] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[3] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBanksByIdentity[3] = IDENTITY_PLAYER_MON2; + + if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + { + gBattleBankFunc[0] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_OPPONENT_MON1; + + gBattleBankFunc[2] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBanksByIdentity[2] = IDENTITY_OPPONENT_MON2; + } + else + { + gBattleBankFunc[0] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_OPPONENT_MON1; + + gBattleBankFunc[2] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[2] = IDENTITY_OPPONENT_MON2; + } + } + } + } +} + +static void SetControllersVariablesInLinkBattle(void) +{ + s32 i; + u8 multiplayerId; + + if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) + { + if (gBattleTypeFlags & BATTLE_TYPE_WILD) + { + gBattleMainFunc = BeginBattleIntro; + + gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[1] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; + + gNoOfAllBanks = 2; + } + else + { + gBattleBankFunc[1] = SetBankFuncToPlayerBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[0] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_OPPONENT_MON1; + + gNoOfAllBanks = 2; + } + } + else if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + if (gBattleTypeFlags & BATTLE_TYPE_WILD) + { + gBattleMainFunc = BeginBattleIntro; + + gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[1] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; + + gBattleBankFunc[2] = SetBankFuncToPlayerBufferRunCommand; + gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; + + gBattleBankFunc[3] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; + + gNoOfAllBanks = 4; + } + else + { + gBattleBankFunc[1] = SetBankFuncToPlayerBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[0] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_OPPONENT_MON1; + + gBattleBankFunc[3] = SetBankFuncToPlayerBufferRunCommand; + gBanksByIdentity[3] = IDENTITY_PLAYER_MON2; + + gBattleBankFunc[2] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksByIdentity[2] = IDENTITY_OPPONENT_MON2; + + gNoOfAllBanks = 4; + } + } + else if (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) + { + if (gBattleTypeFlags & BATTLE_TYPE_WILD) + { + gBattleMainFunc = BeginBattleIntro; + + gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; + + gBattleBankFunc[2] = SetBankFuncToLinkPartnerBufferRunCommand; + gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; + + gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; + + gNoOfAllBanks = 4; + } + else + { + gBattleBankFunc[0] = SetBankFuncToLinkPartnerBufferRunCommand; + gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; + + gBattleBankFunc[1] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; + + gBattleBankFunc[2] = SetBankFuncToPlayerBufferRunCommand; + gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; + + gBattleBankFunc[3] = SetBankFuncToLinkOpponentBufferRunCommand; + gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; + + gNoOfAllBanks = 4; + } + + sub_81B8D64(0, 0); + sub_81B8D64(1, 0); + sub_81B8D64(2, 1); + sub_81B8D64(3, 1); + gBattlePartyID[0] = 0; + gBattlePartyID[1] = 0; + gBattlePartyID[2] = 3; + gBattlePartyID[3] = 3; + } + else + { + multiplayerId = GetMultiplayerId(); + + if (gBattleTypeFlags & BATTLE_TYPE_WILD) + gBattleMainFunc = BeginBattleIntro; + + for (i = 0; i < BATTLE_BANKS_COUNT; i++) + { + switch (gLinkPlayers[i].lp_field_18) + { + case 0: + case 3: + sub_81B8D64(gLinkPlayers[i].lp_field_18, 0); + break; + case 1: + case 2: + sub_81B8D64(gLinkPlayers[i].lp_field_18, 1); + break; + } + + if (i == multiplayerId) + { + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToPlayerBufferRunCommand; + switch (gLinkPlayers[i].lp_field_18) + { + case 0: + case 3: + gBanksByIdentity[gLinkPlayers[i].lp_field_18] = 0; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; + break; + case 1: + case 2: + gBanksByIdentity[gLinkPlayers[i].lp_field_18] = 2; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; + break; + } + } + else + { + if ((!(gLinkPlayers[i].lp_field_18 & 1) && !(gLinkPlayers[multiplayerId].lp_field_18 & 1)) + || ((gLinkPlayers[i].lp_field_18 & 1) && (gLinkPlayers[multiplayerId].lp_field_18 & 1))) + { + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToLinkPartnerBufferRunCommand; + switch (gLinkPlayers[i].lp_field_18) + { + case 0: + case 3: + gBanksByIdentity[gLinkPlayers[i].lp_field_18] = 0; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; + break; + case 1: + case 2: + gBanksByIdentity[gLinkPlayers[i].lp_field_18] = 2; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; + break; + } + } + else + { + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToLinkOpponentBufferRunCommand; + switch (gLinkPlayers[i].lp_field_18) + { + case 0: + case 3: + gBanksByIdentity[gLinkPlayers[i].lp_field_18] = 1; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; + break; + case 1: + case 2: + gBanksByIdentity[gLinkPlayers[i].lp_field_18] = 3; + gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; + break; + } + } + } + } + + gNoOfAllBanks = 4; + } +} + +static void sub_8033050(void) +{ + s32 i, j; + + if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) + { + for (i = 0; i < gNoOfAllBanks; i++) + { + for (j = 0; j < 6; j++) + { + if (i < 2) + { + if (GET_BANK_SIDE2(i) == SIDE_PLAYER) + { + if (GetMonData(&gPlayerParty[j], MON_DATA_HP) != 0 + && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != SPECIES_NONE + && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&gPlayerParty[j], MON_DATA_IS_EGG) == 0) + { + gBattlePartyID[i] = j; + break; + } + } + else + { + if (GetMonData(&gEnemyParty[j], MON_DATA_HP) != 0 + && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_NONE + && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&gEnemyParty[j], MON_DATA_IS_EGG) == 0) + { + gBattlePartyID[i] = j; + break; + } + } + } + else + { + if (GET_BANK_SIDE2(i) == SIDE_PLAYER) + { + if (GetMonData(&gPlayerParty[j], MON_DATA_HP) != 0 + && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES) != SPECIES_NONE // Probably a typo by Game Freak. The rest use SPECIES2. + && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&gPlayerParty[j], MON_DATA_IS_EGG) == 0 + && gBattlePartyID[i - 2] != j) + { + gBattlePartyID[i] = j; + break; + } + } + else + { + if (GetMonData(&gEnemyParty[j], MON_DATA_HP) != 0 + && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_NONE + && GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&gEnemyParty[j], MON_DATA_IS_EGG) == 0 + && gBattlePartyID[i - 2] != j) + { + gBattlePartyID[i] = j; + break; + } + } + } + } + } + + if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) + gBattlePartyID[1] = 0, gBattlePartyID[3] = 3; + } +} + +void PrepareBufferDataTransfer(u8 bufferId, u8 *data, u16 size) +{ + s32 i; + + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + PrepareBufferDataTransferLink(bufferId, size, data); + } + else + { + switch (bufferId) + { + case 0: + for (i = 0; i < size; i++) + { + gBattleBufferA[gActiveBank][i] = *data; + data++; + } + break; + case 1: + for (i = 0; i < size; i++) + { + gBattleBufferB[gActiveBank][i] = *data; + data++; + } + break; + } + } +} + +static void sub_8033244(void) +{ + gUnknown_02022D08 = CreateTask(Task_HandleSendLinkBuffersData, 0); + gTasks[gUnknown_02022D08].data[11] = 0; + gTasks[gUnknown_02022D08].data[12] = 0; + gTasks[gUnknown_02022D08].data[13] = 0; + gTasks[gUnknown_02022D08].data[14] = 0; + gTasks[gUnknown_02022D08].data[15] = 0; + + gUnknown_02022D09 = CreateTask(Task_HandleCopyReceivedLinkBuffersData, 0); + gTasks[gUnknown_02022D09].data[12] = 0; + gTasks[gUnknown_02022D09].data[13] = 0; + gTasks[gUnknown_02022D09].data[14] = 0; + gTasks[gUnknown_02022D09].data[15] = 0; + + gUnknown_02022D0A = 0; +} + +enum +{ + LINK_BUFF_BUFFER_ID, + LINK_BUFF_ACTIVE_BANK, + LINK_BUFF_ATTACKER, + LINK_BUFF_TARGET, + LINK_BUFF_SIZE_LO, + LINK_BUFF_SIZE_HI, + LINK_BUFF_ABSENT_BANK_FLAGS, + LINK_BUFF_EFFECT_BANK, + LINK_BUFF_DATA +}; + +void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data) +{ + s32 alignedSize; + s32 i; + + alignedSize = size - size % 4 + 4; + if (gTasks[gUnknown_02022D08].data[14] + alignedSize + LINK_BUFF_DATA + 1 > BATTLE_BUFFER_LINK_SIZE) + { + gTasks[gUnknown_02022D08].data[12] = gTasks[gUnknown_02022D08].data[14]; + gTasks[gUnknown_02022D08].data[14] = 0; + } + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_BUFFER_ID] = bufferId; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ACTIVE_BANK] = gActiveBank; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ATTACKER] = gBankAttacker; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_TARGET] = gBankTarget; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_SIZE_LO] = alignedSize; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_SIZE_HI] = (alignedSize & 0x0000FF00) >> 8; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ABSENT_BANK_FLAGS] = gAbsentBankFlags; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_EFFECT_BANK] = gEffectBank; + + for (i = 0; i < size; i++) + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_DATA + i] = data[i]; + + gTasks[gUnknown_02022D08].data[14] = gTasks[gUnknown_02022D08].data[14] + alignedSize + LINK_BUFF_DATA; +} + +static void Task_HandleSendLinkBuffersData(u8 taskId) +{ + u16 var; + u16 blockSize; + + switch (gTasks[taskId].data[11]) + { + case 0: + gTasks[taskId].data[10] = 100; + gTasks[taskId].data[11]++; + break; + case 1: + gTasks[taskId].data[10]--; + if (gTasks[taskId].data[10] == 0) + gTasks[taskId].data[11]++; + break; + case 2: + if (gLinkVSyncDisabled) + { + gTasks[taskId].data[11]++; + } + else + { + if (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) + var = 2; + else + var = (gBattleTypeFlags & BATTLE_TYPE_MULTI) ? 4 : 2; + + if (sub_800ABAC() >= var) + { + if (sub_800ABBC()) + { + sub_800A620(); + gTasks[taskId].data[11]++; + } + else + { + gTasks[taskId].data[11]++; + } + } + } + break; + case 3: + if (gTasks[taskId].data[15] != gTasks[taskId].data[14]) + { + if (gTasks[taskId].data[13] == 0) + { + if (gTasks[taskId].data[15] > gTasks[taskId].data[14] + && gTasks[taskId].data[15] == gTasks[taskId].data[12]) + { + gTasks[taskId].data[12] = 0; + gTasks[taskId].data[15] = 0; + } + blockSize = (gLinkBattleSendBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_LO] | (gLinkBattleSendBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_HI] << 8)) + LINK_BUFF_DATA; + SendBlock(bitmask_all_link_players_but_self(), &gLinkBattleSendBuffer[gTasks[taskId].data[15]], blockSize); + gTasks[taskId].data[11]++; + } + else + { + gTasks[taskId].data[13]--; + break; + } + } + break; + case 4: + if (sub_800A520()) + { + blockSize = gLinkBattleSendBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_LO] | (gLinkBattleSendBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_HI] << 8); + gTasks[taskId].data[13] = 1; + gTasks[taskId].data[15] = gTasks[taskId].data[15] + blockSize + LINK_BUFF_DATA; + gTasks[taskId].data[11] = 3; + } + break; + case 5: + gTasks[taskId].data[13]--; + if (gTasks[taskId].data[13] == 0) + { + gTasks[taskId].data[13] = 1; + gTasks[taskId].data[11] = 3; + } + break; + } +} + +// fix me +void sub_8033648(void) +{ + u8 i; + s32 j; + u16 r6; + u8 *recvBuffer; + u8 *dest; + u8 *src; + + if (gReceivedRemoteLinkPlayers != 0 && (gBattleTypeFlags & BATTLE_TYPE_20)) + { + sub_8011BD0(); + for (i = 0; i < GetLinkPlayerCount(); i++) + { + if (GetBlockReceivedStatus() & gBitTable[i]) + { + ResetBlockReceivedFlag(i); + recvBuffer = (u8 *)gBlockRecvBuffer[i]; + #ifndef NONMATCHING + asm(""); + recvBuffer = (u8 *)&gBlockRecvBuffer[i]; + #endif + r6 = gBlockRecvBuffer[i][2]; + + if (gTasks[gUnknown_02022D09].data[14] + 9 + r6 > 0x1000) + { + gTasks[gUnknown_02022D09].data[12] = gTasks[gUnknown_02022D09].data[14]; + gTasks[gUnknown_02022D09].data[14] = 0; + } + + dest = &gLinkBattleRecvBuffer[gTasks[gUnknown_02022D09].data[14]]; + src = recvBuffer; + + for (j = 0; j < r6 + 8; j++) + dest[j] = src[j]; + + gTasks[gUnknown_02022D09].data[14] = gTasks[gUnknown_02022D09].data[14] + r6 + 8; + } + } + } +} + +static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId) +{ + u16 blockSize; + u8 bank; + u8 var; + + if (gTasks[taskId].data[15] != gTasks[taskId].data[14]) + { + if (gTasks[taskId].data[15] > gTasks[taskId].data[14] + && gTasks[taskId].data[15] == gTasks[taskId].data[12]) + { + gTasks[taskId].data[12] = 0; + gTasks[taskId].data[15] = 0; + } + bank = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_ACTIVE_BANK]; + blockSize = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_LO] | (gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_HI] << 8); + + switch (gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 0]) + { + case 0: + if (gBattleExecBuffer & gBitTable[bank]) + return; + + memcpy(gBattleBufferA[bank], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 8], blockSize); + sub_803F850(bank); + + if (!(gBattleTypeFlags & BATTLE_TYPE_WILD)) + { + gBankAttacker = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 2]; + gBankTarget = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 3]; + gAbsentBankFlags = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 6]; + gEffectBank = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 7]; + } + break; + case 1: + memcpy(gBattleBufferB[bank], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 8], blockSize); + break; + case 2: + var = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA]; + gBattleExecBuffer &= ~(gBitTable[bank] << (var * 4)); + break; + } + + gTasks[taskId].data[15] = gTasks[taskId].data[15] + blockSize + LINK_BUFF_DATA; + } +} diff --git a/src/battle_util.c b/src/battle_util.c index c6762dd99..636e27bdf 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -353,7 +353,7 @@ void sub_803F850(u8 arg0) { s32 i; - for (i = 0; i < sub_8009FCC(); i++) + for (i = 0; i < GetLinkPlayerCount(); i++) gBattleExecBuffer |= gBitTable[arg0] << (i << 2); gBattleExecBuffer &= ~(0x10000000 << arg0); diff --git a/sym_ewram.txt b/sym_ewram.txt index 944a51b62..495d233f9 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -282,7 +282,7 @@ gNoOfAllBanks: @ 202406C gBattlePartyID: @ 202406E .space 0x8 -gBanksBySide: @ 2024076 +gBanksByIdentity: @ 2024076 .space 0x4 gActionsByTurnOrder: @ 202407A @@ -471,10 +471,10 @@ gBattleScripting: @ 2024474 gBattleStruct: @ 202449C .space 0x4 -gUnknown_020244A0: @ 20244A0 +gLinkBattleSendBuffer: @ 20244A0 .space 0x4 -gUnknown_020244A4: @ 20244A4 +gLinkBattleRecvBuffer: @ 20244A4 .space 0x4 gBattleResources: @ 20244A8