From 9d4acb9635b3b74d5ae4edee70d673f49c0aab74 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 9 Oct 2017 15:40:08 +0200 Subject: [PATCH 1/4] some work on international string util --- asm/international_string_util.s | 121 ---------------------------- include/international_string_util.h | 20 +++++ ld_script.txt | 1 + src/coins.c | 2 +- src/international_string_util.c | 57 +++++++++++++ 5 files changed, 79 insertions(+), 122 deletions(-) create mode 100644 include/international_string_util.h create mode 100644 src/international_string_util.c diff --git a/asm/international_string_util.s b/asm/international_string_util.s index 7c52fc41a..fe04a1396 100755 --- a/asm/international_string_util.s +++ b/asm/international_string_util.s @@ -5,127 +5,6 @@ .text - thumb_func_start GetStringCenterAlignXOffset -@ s32 GetStringCenterAlignXOffset(u8 fontId, u8 *str, s32 totalWidth) -GetStringCenterAlignXOffset: @ 81DB35C - push {lr} - movs r3, 0 - bl GetStringCenterAlignXOffsetWithLetterSpacing - pop {r1} - bx r1 - thumb_func_end GetStringCenterAlignXOffset - - thumb_func_start GetStringRightAlignXOffset -@ s32 GetStringRightAlignXOffset(u8 fontId, u8 *str, s32 totalWidth) -GetStringRightAlignXOffset: @ 81DB368 - push {lr} - movs r3, 0 - bl GetStringWidthDifference - pop {r1} - bx r1 - thumb_func_end GetStringRightAlignXOffset - - thumb_func_start GetStringCenterAlignXOffsetWithLetterSpacing -@ s32 GetStringCenterAlignXOffsetWithLetterSpacing(u8 fontId, u8 *str, s32 totalWidth, s16 letterSpacing) -GetStringCenterAlignXOffsetWithLetterSpacing: @ 81DB374 - push {lr} - bl GetStringWidthDifference - lsrs r1, r0, 31 - adds r0, r1 - asrs r0, 1 - pop {r1} - bx r1 - thumb_func_end GetStringCenterAlignXOffsetWithLetterSpacing - - thumb_func_start GetStringWidthDifference -@ s32 GetStringWidthDifference(u8 fontId, u8 *str, s32 totalWidth, s16 letterSpacing) -GetStringWidthDifference: @ 81DB384 - push {r4,lr} - adds r4, r2, 0 - adds r2, r3, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r2, 16 - asrs r2, 16 - bl GetStringWidth - cmp r4, r0 - bgt _081DB39E - movs r0, 0 - b _081DB3A0 -_081DB39E: - subs r0, r4, r0 -_081DB3A0: - pop {r4} - pop {r1} - bx r1 - thumb_func_end GetStringWidthDifference - - thumb_func_start GetMaxWidthInMenuTable -GetMaxWidthInMenuTable: @ 81DB3A8 - push {r4-r6,lr} - movs r6, 0 - cmp r6, r1 - bge _081DB3CC - adds r5, r0, 0 - adds r4, r1, 0 -_081DB3B4: - ldr r1, [r5] - movs r0, 0x1 - movs r2, 0 - bl GetStringWidth - cmp r0, r6 - ble _081DB3C4 - adds r6, r0, 0 -_081DB3C4: - adds r5, 0x8 - subs r4, 0x1 - cmp r4, 0 - bne _081DB3B4 -_081DB3CC: - adds r0, r6, 0 - bl convert_pixel_width_to_tile_width - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end GetMaxWidthInMenuTable - - thumb_func_start sub_81DB3D8 -sub_81DB3D8: @ 81DB3D8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - mov r8, r0 - adds r7, r1, 0 - adds r5, r2, 0 - movs r6, 0 - movs r4, 0 - cmp r6, r5 - bge _081DB40A -_081DB3EC: - adds r0, r7, r4 - ldrb r0, [r0] - lsls r0, 3 - add r0, r8 - ldr r1, [r0] - movs r0, 0x1 - movs r2, 0 - bl GetStringWidth - cmp r0, r6 - ble _081DB404 - adds r6, r0, 0 -_081DB404: - adds r4, 0x1 - cmp r4, r5 - blt _081DB3EC -_081DB40A: - adds r0, r6, 0 - bl convert_pixel_width_to_tile_width - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_81DB3D8 thumb_func_start sub_81DB41C sub_81DB41C: @ 81DB41C diff --git a/include/international_string_util.h b/include/international_string_util.h new file mode 100644 index 000000000..2aa3e18f8 --- /dev/null +++ b/include/international_string_util.h @@ -0,0 +1,20 @@ +#ifndef GUARD_INTERNATIONAL_STRING_UTIL_H +#define GUARD_INTERNATIONAL_STRING_UTIL_H + +s32 GetStringCenterAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth); +s32 GetStringRightAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth); +s32 GetStringCenterAlignXOffsetWithLetterSpacing(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing); +s32 GetStringWidthDifference(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing); +s32 GetMaxWidthInMenuTable(const u8 **str, s32 arg1); +s32 sub_81DB3D8(const u8 **str, u8* arg1, s32 arg2); +// sub_81DB41C +// sub_81DB468 +// sub_81DB494 +// sub_81DB4DC +// sub_81DB52C +// sub_81DB554 +// sub_81DB5AC +// sub_81DB5E8 +// sub_81DB620 + +#endif // GUARD_INTERNATIONAL_STRING_UTIL_H diff --git a/ld_script.txt b/ld_script.txt index 82588be3a..cc32361f2 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -264,6 +264,7 @@ SECTIONS { asm/unk_sprite_file.o(.text); asm/unk_transition.o(.text); asm/unk_transition_2.o(.text); + src/international_string_util.o(.text); asm/international_string_util.o(.text); } =0 diff --git a/src/coins.c b/src/coins.c index 4ee601b22..9c2d35168 100644 --- a/src/coins.c +++ b/src/coins.c @@ -5,12 +5,12 @@ #include "text_window.h" #include "string_util.h" #include "menu.h" +#include "international_string_util.h" #define MAX_COINS 9999 EWRAM_DATA u8 sCoinsWindowId = 0; -extern s32 GetStringRightAlignXOffset(u8 fontId, u8 *str, s32 totalWidth); extern void sub_819746C(u8 windowId, bool8 copyToVram); extern const u8 gText_Coins[]; diff --git a/src/international_string_util.c b/src/international_string_util.c new file mode 100644 index 000000000..c77b4f8ff --- /dev/null +++ b/src/international_string_util.c @@ -0,0 +1,57 @@ +#include "global.h" +#include "international_string_util.h" +#include "text.h" + +extern s32 convert_pixel_width_to_tile_width(s32 a0); // script menu + +s32 GetStringCenterAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth) +{ + return GetStringCenterAlignXOffsetWithLetterSpacing(fontId, str, totalWidth, 0); +} + +s32 GetStringRightAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth) +{ + return GetStringWidthDifference(fontId, str, totalWidth, 0); +} + +s32 GetStringCenterAlignXOffsetWithLetterSpacing(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing) +{ + return GetStringWidthDifference(fontId, str, totalWidth, letterSpacing) / 2; +} + +s32 GetStringWidthDifference(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing) +{ + s32 stringWidth = GetStringWidth(fontId, str, letterSpacing); + if (totalWidth > stringWidth) + return totalWidth - stringWidth; + else + return 0; +} + +s32 GetMaxWidthInMenuTable(const u8 **str, s32 arg1) +{ + s32 i, var; + + for (var = 0, i = 0; i < arg1; i++) + { + s32 stringWidth = GetStringWidth(1, str[i * 2], 0); + if (stringWidth > var) + var = stringWidth; + } + + return convert_pixel_width_to_tile_width(var); +} + +s32 sub_81DB3D8(const u8 **str, u8* arg1, s32 arg2) +{ + s32 i, var; + + for (var = 0, i = 0; i < arg2; i++) + { + s32 stringWidth = GetStringWidth(1, str[arg1[i] * 2], 0); + if (stringWidth > var) + var = stringWidth; + } + + return convert_pixel_width_to_tile_width(var); +} From c78679ae66c71836b23e59e001c45235117cab2f Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 13 Oct 2017 17:22:50 +0200 Subject: [PATCH 2/4] rom3 decomp start --- asm/battle_5.s | 8 +- asm/battle_7.s | 16 +- asm/battle_anim.s | 6 +- asm/battle_anim_80FE840.s | 10 +- asm/battle_interface.s | 2 +- asm/berry_blender.s | 14 +- asm/cable_club.s | 10 +- asm/contest.s | 4 +- asm/contest_link_80FC4F4.s | 4 +- asm/dewford_trend.s | 2 +- asm/link.s | 86 +- asm/record_mixing.s | 14 +- asm/recorded_battle.s | 4 +- asm/rom3.s | 2239 +--------------------------------- asm/rom6.s | 6 +- asm/rom_80A5C6C.s | 8 +- asm/secret_base.s | 2 +- asm/trade.s | 10 +- asm/tv.s | 6 +- include/battle.h | 11 +- include/battle_2.h | 2 + include/battle_anim.h | 6 + include/battle_controllers.h | 38 +- include/link.h | 9 +- include/recorded_battle.h | 2 + ld_script.txt | 1 + src/battle_2.c | 3 - src/battle_controllers.c | 928 ++++++++++++++ src/battle_util.c | 2 +- sym_ewram.txt | 6 +- 30 files changed, 1160 insertions(+), 2299 deletions(-) create mode 100644 include/battle_anim.h create mode 100644 src/battle_controllers.c 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 From 20d158cf4a17e8d362cdafbf13906c59d9916e24 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 13 Oct 2017 19:46:27 +0200 Subject: [PATCH 3/4] start decompiling emitters --- asm/rom3.s | 751 ++--------------------------------- include/battle_controllers.h | 97 ++++- include/battle_util.h | 1 + src/battle_controllers.c | 254 ++++++++++++ sym_ewram.txt | 2 +- 5 files changed, 378 insertions(+), 727 deletions(-) diff --git a/asm/rom3.s b/asm/rom3.s index ab32fa315..eb650e7ff 100644 --- a/asm/rom3.s +++ b/asm/rom3.s @@ -7,687 +7,12 @@ - thumb_func_start EmitGetMonData -EmitGetMonData: @ 80338B4 - push {r4,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022D10 - movs r3, 0 - strb r3, [r1] - strb r4, [r1, 0x1] - strb r2, [r1, 0x2] - strb r3, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end EmitGetMonData - - thumb_func_start dp01_build_cmdbuf_x01_a_b_0 -dp01_build_cmdbuf_x01_a_b_0: @ 80338D8 - push {r4,r5,lr} - adds r5, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022D10 - movs r4, 0 - movs r3, 0x1 - strb r3, [r1] - strb r5, [r1, 0x1] - strb r2, [r1, 0x2] - strb r4, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x01_a_b_0 - - thumb_func_start EmitSetMonData -EmitSetMonData: @ 8033900 - push {r4-r6,lr} - ldr r4, [sp, 0x10] - lsls r0, 24 - lsrs r6, r0, 24 - lsls r3, 24 - lsrs r5, r3, 24 - ldr r0, =gUnknown_02022D10 - movs r3, 0x2 - strb r3, [r0] - strb r1, [r0, 0x1] - strb r2, [r0, 0x2] - adds r1, r0, 0 - cmp r5, 0 - beq _0803392E - adds r3, r1, 0x3 - adds r2, r5, 0 -_08033920: - ldrb r0, [r4] - strb r0, [r3] - adds r4, 0x1 - adds r3, 0x1 - subs r2, 0x1 - cmp r2, 0 - bne _08033920 -_0803392E: - adds r2, r5, 0x3 - adds r0, r6, 0 - bl PrepareBufferDataTransfer - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end EmitSetMonData - - thumb_func_start sub_8033940 -sub_8033940: @ 8033940 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r2, 24 - lsrs r4, r2, 24 - ldr r0, =gUnknown_02022D10 - movs r2, 0x3 - strb r2, [r0] - strb r1, [r0, 0x1] - strb r4, [r0, 0x2] - adds r5, r0, 0 - cmp r4, 0 - beq _0803396C - adds r1, r5, 0x3 - adds r2, r4, 0 -_0803395E: - ldrb r0, [r3] - strb r0, [r1] - adds r3, 0x1 - adds r1, 0x1 - subs r2, 0x1 - cmp r2, 0 - bne _0803395E -_0803396C: - adds r2, r4, 0x3 - adds r0, r6, 0 - adds r1, r5, 0 - bl PrepareBufferDataTransfer - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8033940 - - thumb_func_start EmitLoadMonSprite -EmitLoadMonSprite: @ 8033980 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022D10 - movs r2, 0x4 - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitLoadMonSprite - - thumb_func_start EmitSwitchInAnim -EmitSwitchInAnim: @ 80339A0 - push {r4,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022D10 - movs r3, 0x5 - strb r3, [r1] - strb r4, [r1, 0x1] - strb r2, [r1, 0x2] - strb r3, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end EmitSwitchInAnim - - thumb_func_start EmitReturnPokeToBall -EmitReturnPokeToBall: @ 80339C4 - push {lr} - adds r3, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022D10 - movs r2, 0x6 - strb r2, [r1] - strb r3, [r1, 0x1] - movs r2, 0x2 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitReturnPokeToBall - - thumb_func_start EmitDrawTrainerPic -EmitDrawTrainerPic: @ 80339E4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022D10 - movs r2, 0x7 - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitDrawTrainerPic - - thumb_func_start EmitTrainerSlide -EmitTrainerSlide: @ 8033A04 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022D10 - movs r2, 0x8 - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitTrainerSlide - - thumb_func_start EmitTrainerSlideBack -EmitTrainerSlideBack: @ 8033A24 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022D10 - movs r2, 0x9 - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitTrainerSlideBack - - thumb_func_start EmitFaintAnimation -EmitFaintAnimation: @ 8033A44 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022D10 - movs r2, 0xA - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitFaintAnimation - - thumb_func_start dp01_build_cmdbuf_x0B_B_B_B -dp01_build_cmdbuf_x0B_B_B_B: @ 8033A64 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022D10 - movs r2, 0xB - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x0B_B_B_B - - thumb_func_start dp01_build_cmdbuf_x0C_C_C_C -dp01_build_cmdbuf_x0C_C_C_C: @ 8033A84 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022D10 - movs r2, 0xC - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x0C_C_C_C - - thumb_func_start EmitBallThrow -EmitBallThrow: @ 8033AA4 - push {lr} - adds r3, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_02022D10 - movs r2, 0xD - strb r2, [r1] - strb r3, [r1, 0x1] - movs r2, 0x2 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitBallThrow - - thumb_func_start sub_8033AC4 -sub_8033AC4: @ 8033AC4 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 24 - lsrs r4, r1, 24 - ldr r1, =gUnknown_02022D10 - movs r0, 0xE - strb r0, [r1] - strb r4, [r1, 0x1] - lsls r0, r4, 1 - adds r0, r4 - adds r5, r1, 0 - cmp r0, 0 - beq _08033AF2 - adds r1, r5, 0x2 - adds r3, r0, 0 -_08033AE4: - ldrb r0, [r2] - strb r0, [r1] - adds r2, 0x1 - adds r1, 0x1 - subs r3, 0x1 - cmp r3, 0 - bne _08033AE4 -_08033AF2: - lsls r2, r4, 1 - adds r2, r4 - adds r2, 0x2 - adds r0, r6, 0 - adds r1, r5, 0 - bl PrepareBufferDataTransfer - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8033AC4 - - thumb_func_start EmitMoveAnimation -EmitMoveAnimation: @ 8033B0C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - ldr r4, [sp, 0x20] - ldr r5, [sp, 0x24] - ldr r6, [sp, 0x2C] - mov r8, r6 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - lsls r1, 16 - lsrs r1, 16 - lsls r3, 16 - lsrs r3, 16 - ldr r7, =gUnknown_02022D10 - movs r0, 0 - mov r12, r0 - movs r0, 0xF - strb r0, [r7] - strb r1, [r7, 0x1] - lsrs r1, 8 - strb r1, [r7, 0x2] - strb r2, [r7, 0x3] - strb r3, [r7, 0x4] - movs r6, 0xFF - lsls r6, 8 - lsrs r3, 8 - strb r3, [r7, 0x5] - strb r4, [r7, 0x6] - adds r0, r4, 0 - ands r0, r6 - asrs r0, 8 - strb r0, [r7, 0x7] - movs r0, 0xFF - lsls r0, 16 - ands r0, r4 - asrs r0, 16 - strb r0, [r7, 0x8] - lsrs r4, 24 - strb r4, [r7, 0x9] - strb r5, [r7, 0xA] - mov r0, r8 - strb r0, [r7, 0xB] - mov r0, r12 - str r0, [sp] - movs r0, 0xE - movs r1, 0 - movs r2, 0xD - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _08033BAC - str r0, [sp] - movs r0, 0xE - movs r1, 0 - movs r2, 0x4D - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - bne _08033BAC - ldr r0, =gBattleWeather - ldrh r0, [r0] - strb r0, [r7, 0xC] - ands r6, r0 - lsrs r0, r6, 8 - strb r0, [r7, 0xD] - adds r4, r7, 0 - b _08033BB6 - .pool -_08033BAC: - ldr r0, =gUnknown_02022D10 - movs r1, 0 - strb r1, [r0, 0xC] - strb r1, [r0, 0xD] - adds r4, r0, 0 -_08033BB6: - movs r0, 0 - strb r0, [r4, 0xE] - strb r0, [r4, 0xF] - adds r0, r4, 0 - adds r0, 0x10 - ldr r1, [sp, 0x28] - movs r2, 0x1C - bl memcpy - mov r0, r9 - adds r1, r4, 0 - movs r2, 0x2C - bl PrepareBufferDataTransfer - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end EmitMoveAnimation - - thumb_func_start EmitPrintString -EmitPrintString: @ 8033BE4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - lsls r1, 16 - lsrs r1, 16 - ldr r2, =gUnknown_02022D10 - movs r0, 0x10 - strb r0, [r2] - ldr r0, =gBattleOutcome - ldrb r0, [r0] - strb r0, [r2, 0x1] - strb r1, [r2, 0x2] - lsrs r1, 8 - strb r1, [r2, 0x3] - adds r0, r2, 0x4 - mov r12, r0 - ldr r4, =gCurrentMove - ldrh r0, [r4] - strh r0, [r2, 0x4] - ldr r0, =gLastUsedMove - ldrh r0, [r0] - mov r1, r12 - strh r0, [r1, 0x2] - ldr r0, =gLastUsedItem - ldrh r0, [r0] - strh r0, [r1, 0x4] - ldr r0, =gLastUsedAbility - ldrb r0, [r0] - strb r0, [r1, 0x6] - ldr r0, =gBattleScripting - ldrb r0, [r0, 0x17] - strb r0, [r1, 0x7] - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r1, r0, 0 - adds r1, 0x52 - ldrb r1, [r1] - mov r3, r12 - strb r1, [r3, 0x8] - adds r0, 0xB1 - ldrb r0, [r0] - strb r0, [r3, 0x9] - ldr r0, =gStringBank - ldrb r0, [r0] - strb r0, [r3, 0xA] - ldr r3, =gBattleMoves - ldrh r1, [r4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrb r0, [r0, 0x2] - mov r7, r12 - strb r0, [r7, 0xB] - movs r3, 0 - mov r9, r2 - ldr r0, =gBattleTextBuff3 - mov r8, r0 - adds r2, 0x10 - ldr r0, =gBattleMons - adds r4, r0, 0 - adds r4, 0x20 -_08033C6A: - adds r1, r2, r3 - ldrb r0, [r4] - strb r0, [r1] - adds r4, 0x58 - adds r3, 0x1 - cmp r3, 0x3 - ble _08033C6A - movs r3, 0 - mov r5, r12 - adds r5, 0x10 - mov r4, r12 - adds r4, 0x20 - ldr r6, =gBattleTextBuff2 - mov r2, r12 - adds r2, 0x30 -_08033C88: - adds r1, r5, r3 - ldr r7, =gBattleTextBuff1 - adds r0, r3, r7 - ldrb r0, [r0] - strb r0, [r1] - adds r1, r4, r3 - adds r0, r3, r6 - ldrb r0, [r0] - strb r0, [r1] - adds r1, r2, r3 - mov r7, r8 - adds r0, r3, r7 - ldrb r0, [r0] - strb r0, [r1] - adds r3, 0x1 - cmp r3, 0xF - ble _08033C88 - mov r0, r10 - mov r1, r9 - movs r2, 0x44 - bl PrepareBufferDataTransfer - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end EmitPrintString - - thumb_func_start EmitPrintStringPlayerOnly -EmitPrintStringPlayerOnly: @ 8033CFC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - lsls r1, 16 - lsrs r1, 16 - ldr r2, =gUnknown_02022D10 - movs r0, 0x11 - strb r0, [r2] - strb r0, [r2, 0x1] - strb r1, [r2, 0x2] - lsrs r1, 8 - strb r1, [r2, 0x3] - adds r0, r2, 0x4 - mov r12, r0 - ldr r0, =gCurrentMove - ldrh r0, [r0] - strh r0, [r2, 0x4] - ldr r0, =gLastUsedMove - ldrh r0, [r0] - mov r1, r12 - strh r0, [r1, 0x2] - ldr r0, =gLastUsedItem - ldrh r0, [r0] - strh r0, [r1, 0x4] - ldr r0, =gLastUsedAbility - ldrb r0, [r0] - strb r0, [r1, 0x6] - ldr r0, =gBattleScripting - ldrb r0, [r0, 0x17] - strb r0, [r1, 0x7] - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x52 - ldrb r0, [r0] - strb r0, [r1, 0x8] - movs r3, 0 - mov r9, r2 - ldr r7, =gBattleTextBuff3 - mov r8, r7 - mov r4, r9 - adds r4, 0x10 - ldr r0, =gBattleMons - adds r2, r0, 0 - adds r2, 0x20 -_08033D5E: - adds r1, r4, r3 - ldrb r0, [r2] - strb r0, [r1] - adds r2, 0x58 - adds r3, 0x1 - cmp r3, 0x3 - ble _08033D5E - movs r3, 0 - mov r5, r12 - adds r5, 0x10 - mov r4, r12 - adds r4, 0x20 - ldr r6, =gBattleTextBuff2 - mov r2, r12 - adds r2, 0x30 -_08033D7C: - adds r1, r5, r3 - ldr r7, =gBattleTextBuff1 - adds r0, r3, r7 - ldrb r0, [r0] - strb r0, [r1] - adds r1, r4, r3 - adds r0, r3, r6 - ldrb r0, [r0] - strb r0, [r1] - adds r1, r2, r3 - mov r7, r8 - adds r0, r3, r7 - ldrb r0, [r0] - strb r0, [r1] - adds r3, 0x1 - cmp r3, 0xF - ble _08033D7C - mov r0, r10 - mov r1, r9 - movs r2, 0x44 - bl PrepareBufferDataTransfer - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end EmitPrintStringPlayerOnly - - thumb_func_start EmitChooseAction -EmitChooseAction: @ 8033DE4 - push {r4,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r2, 16 - lsrs r2, 16 - ldr r1, =gUnknown_02022D10 - movs r3, 0x12 - strb r3, [r1] - strb r4, [r1, 0x1] - strb r2, [r1, 0x2] - lsrs r2, 8 - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end EmitChooseAction - thumb_func_start EmitCmd13 EmitCmd13: @ 8033E10 push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x13 strb r2, [r1] strb r2, [r1, 0x1] @@ -706,7 +31,7 @@ EmitChooseMove: @ 8033E30 adds r5, r3, 0 lsls r0, 24 lsrs r6, r0, 24 - ldr r3, =gUnknown_02022D10 + ldr r3, =gBattleBuffersTransferData movs r4, 0 movs r0, 0x14 strb r0, [r3] @@ -739,7 +64,7 @@ EmitOpenBag: @ 8033E6C adds r4, r1, 0 lsls r0, 24 lsrs r5, r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r0, 0x15 strb r0, [r1] movs r2, 0 @@ -767,7 +92,7 @@ EmitChoosePokemon: @ 8033EA0 ldr r6, [sp, 0x10] lsls r0, 24 lsrs r5, r0, 24 - ldr r4, =gUnknown_02022D10 + ldr r4, =gBattleBuffersTransferData movs r0, 0x16 strb r0, [r4] strb r1, [r4, 0x1] @@ -798,7 +123,7 @@ dp01_build_cmdbuf_x17_17_17_17: @ 8033EDC push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x17 strb r2, [r1] strb r2, [r1, 0x1] @@ -818,7 +143,7 @@ EmitHealthBarUpdate: @ 8033EFC lsrs r0, 24 lsls r1, 16 lsrs r1, 16 - ldr r3, =gUnknown_02022D10 + ldr r3, =gBattleBuffersTransferData movs r4, 0 movs r2, 0x18 strb r2, [r3] @@ -848,7 +173,7 @@ EmitExpUpdate: @ 8033F34 lsrs r0, 24 lsls r2, 16 lsrs r2, 16 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r3, 0x19 strb r3, [r1] strb r4, [r1, 0x1] @@ -874,7 +199,7 @@ EmitStatusIconUpdate: @ 8033F68 adds r4, r1, 0 lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r3, 0x1A strb r3, [r1] strb r4, [r1, 0x1] @@ -917,7 +242,7 @@ EmitStatusAnimation: @ 8033FBC adds r4, r1, 0 lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r3, 0x1B strb r3, [r1] strb r4, [r1, 0x1] @@ -948,7 +273,7 @@ dp01_build_cmdbuf_x1C_a: @ 8033FF8 adds r3, r1, 0 lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x1C strb r2, [r1] strb r3, [r1, 0x1] @@ -966,7 +291,7 @@ dp01_build_cmdbuf_x1D_1D_numargs_varargs: @ 8034018 lsrs r6, r0, 24 lsls r1, 16 lsrs r4, r1, 16 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r0, 0x1D strb r0, [r1] strb r0, [r1, 0x1] @@ -1007,7 +332,7 @@ sub_8034060: @ 8034060 lsrs r6, r0, 24 lsls r2, 16 lsrs r5, r2, 16 - ldr r2, =gUnknown_02022D10 + ldr r2, =gBattleBuffersTransferData movs r0, 0x1E strb r0, [r2] strb r1, [r2, 0x1] @@ -1061,7 +386,7 @@ sub_80340C8: @ 80340C8 lsrs r6, r0, 24 lsls r1, 16 lsrs r4, r1, 16 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r0, 0x1F strb r0, [r1] strb r4, [r1, 0x1] @@ -1100,7 +425,7 @@ sub_8034110: @ 8034110 lsrs r6, r0, 24 lsls r1, 16 lsrs r4, r1, 16 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r0, 0x20 strb r0, [r1] strb r4, [r1, 0x1] @@ -1140,7 +465,7 @@ EmitCmd_x21: @ 8034158 lsrs r0, 24 lsls r2, 16 lsrs r2, 16 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r3, 0x21 strb r3, [r1] strb r4, [r1, 0x1] @@ -1161,7 +486,7 @@ dp01_build_cmdbuf_x22_a_three_bytes: @ 8034184 adds r4, r2, 0 lsls r0, 24 lsrs r5, r0, 24 - ldr r2, =gUnknown_02022D10 + ldr r2, =gBattleBuffersTransferData movs r0, 0x22 strb r0, [r2] strb r1, [r2, 0x1] @@ -1192,7 +517,7 @@ dp01_build_cmdbuf_x23_aa_0: @ 80341BC lsrs r0, 24 lsls r1, 16 lsrs r1, 16 - ldr r3, =gUnknown_02022D10 + ldr r3, =gBattleBuffersTransferData movs r4, 0 movs r2, 0x23 strb r2, [r3] @@ -1216,7 +541,7 @@ dp01_build_cmdbuf_x24_aa_0: @ 80341E8 lsrs r0, 24 lsls r1, 16 lsrs r1, 16 - ldr r3, =gUnknown_02022D10 + ldr r3, =gBattleBuffersTransferData movs r4, 0 movs r2, 0x24 strb r2, [r3] @@ -1238,7 +563,7 @@ dp01_build_cmdbuf_x25_25_25_25: @ 8034214 push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x25 strb r2, [r1] strb r2, [r1, 0x1] @@ -1257,7 +582,7 @@ dp01_build_cmdbuf_x26_a: @ 8034234 adds r3, r1, 0 lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x26 strb r2, [r1] strb r3, [r1, 0x1] @@ -1273,7 +598,7 @@ dp01_build_cmdbuf_x27_27_27_27: @ 8034254 push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x27 strb r2, [r1] strb r2, [r1, 0x1] @@ -1291,7 +616,7 @@ dp01_build_cmdbuf_x28_28_28_28: @ 8034274 push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x28 strb r2, [r1] strb r2, [r1, 0x1] @@ -1309,7 +634,7 @@ EmitHitAnimation: @ 8034294 push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x29 strb r2, [r1] strb r2, [r1, 0x1] @@ -1327,7 +652,7 @@ Emit_x2A: @ 80342B4 push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x2A strb r2, [r1] strb r2, [r1, 0x1] @@ -1347,7 +672,7 @@ EmitEffectivenessSound: @ 80342D4 lsrs r0, 24 lsls r1, 16 lsrs r1, 16 - ldr r3, =gUnknown_02022D10 + ldr r3, =gBattleBuffersTransferData movs r4, 0 movs r2, 0x2B strb r2, [r3] @@ -1371,7 +696,7 @@ EmitPlaySound: @ 8034300 lsrs r0, 24 lsls r1, 16 lsrs r1, 16 - ldr r4, =gUnknown_02022D10 + ldr r4, =gBattleBuffersTransferData movs r3, 0x2C strb r3, [r4] strb r1, [r4, 0x1] @@ -1392,7 +717,7 @@ EmitFaintingCry: @ 803432C push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x2D strb r2, [r1] strb r2, [r1, 0x1] @@ -1411,7 +736,7 @@ EmitIntroSlide: @ 803434C adds r3, r1, 0 lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x2E strb r2, [r1] strb r3, [r1, 0x1] @@ -1427,7 +752,7 @@ EmitIntroTrainerBallThrow: @ 803436C push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x2F strb r2, [r1] strb r2, [r1, 0x1] @@ -1448,7 +773,7 @@ EmitDrawPartyStatusSummary: @ 803438C lsrs r5, r0, 24 lsls r2, 24 lsrs r2, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r3, 0x30 strb r3, [r1] movs r0, 0x7F @@ -1484,7 +809,7 @@ EmitCmd49: @ 80343D4 push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x31 strb r2, [r1] strb r2, [r1, 0x1] @@ -1502,7 +827,7 @@ Emit_x32: @ 80343F4 push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x32 strb r2, [r1] strb r2, [r1, 0x1] @@ -1521,7 +846,7 @@ EmitSpriteInvisibility: @ 8034414 adds r3, r1, 0 lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x33 strb r2, [r1] strb r3, [r1, 0x1] @@ -1542,7 +867,7 @@ EmitBattleAnimation: @ 8034438 lsrs r0, 24 lsls r2, 16 lsrs r2, 16 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r3, 0x34 strb r3, [r1] strb r4, [r1, 0x1] @@ -1564,7 +889,7 @@ EmitLinkStandbyMsg: @ 8034464 lsrs r5, r0, 24 lsls r2, 24 lsrs r2, 24 - ldr r4, =gUnknown_02022D10 + ldr r4, =gBattleBuffersTransferData movs r0, 0x35 strb r0, [r4] strb r1, [r4, 0x1] @@ -1580,7 +905,7 @@ _0803448C: strb r2, [r4, 0x2] strb r2, [r4, 0x3] _08034490: - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData ldrb r2, [r1, 0x2] adds r2, 0x4 adds r0, r5, 0 @@ -1597,7 +922,7 @@ EmitResetActionMoveSelection: @ 80344A8 adds r3, r1, 0 lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02022D10 + ldr r1, =gBattleBuffersTransferData movs r2, 0x36 strb r2, [r1] strb r3, [r1, 0x1] @@ -1614,7 +939,7 @@ Emit_x37: @ 80344C8 adds r5, r0, 0 lsls r5, 24 lsrs r5, 24 - ldr r4, =gUnknown_02022D10 + ldr r4, =gBattleBuffersTransferData movs r0, 0x37 strb r0, [r4] strb r1, [r4, 0x1] diff --git a/include/battle_controllers.h b/include/battle_controllers.h index b36878210..475dcd348 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -46,6 +46,69 @@ struct ChooseMoveStruct u8 monType2; }; +enum +{ + CONTROLLER_GETMONDATA, + CONTROLLER_GETRAWMONDATA, + CONTROLLER_SETMONDATA, + CONTROLLER_SETRAWMONDATA, + CONTROLLER_LOADMONSPRITE, + CONTROLLER_SWITCHINANIM, + CONTROLLER_RETURNPOKETOBALL, + CONTROLLER_DRAWTRAINERPIC, + CONTROLLER_TRAINERSLIDE, + CONTROLLER_TRAINERSLIDEBACK, + CONTROLLER_FAINTANIMATION, + CONTROLLER_11, + CONTROLLER_12, + CONTROLLER_BALLTHROW, + CONTROLLER_PAUSE, + CONTROLLER_MOVEANIMATION, + CONTROLLER_PRINTSTRING, + CONTROLLER_PRINTSTRINGPLAYERONLY, + CONTROLLER_CHOOSEACTION, + CONTROLLER_19, + CONTROLLER_20, + CONTROLLER_OPENBAG, + CONTROLLER_22, + CONTROLLER_23, + CONTROLLER_HEALTHBARUPDATE, + CONTROLLER_EXPBARUPDATE, + CONTROLLER_STATUSICONUPDATE, + CONTROLLER_STATUSANIMATION, + CONTROLLER_STATUSXOR, + CONTROLLER_29, + CONTROLLER_DMATRANSFER, + CONTROLLER_31, + CONTROLLER_32, + CONTROLLER_33, + CONTROLLER_34, + CONTROLLER_35, + CONTROLLER_36, + CONTROLLER_37, + CONTROLLER_38, + CONTROLLER_39, + CONTROLLER_40, + CONTROLLER_HITANIMATION, + CONTROLLER_42, + CONTROLLER_EFFECTIVENESSSOUND, + CONTROLLER_44, + CONTROLLER_FAINTINGCRY, + CONTROLLER_INTROSLIDE, + CONTROLLER_TRAINERBALLTHROW, + CONTROLLER_48, + CONTROLLER_49, + CONTROLLER_50, + CONTROLLER_SPRITEINVISIBILITY, + CONTROLLER_BATTLEANIMATION, + CONTROLLER_LINKSTANDBYMSG, + CONTROLLER_RESETACTIONMOVESELECTION, + CONTROLLER_55, + CONTROLLER_56 +}; + +#define LAST_CONTROLLER_CMD_ID CONTROLLER_56 + 1 + // general functions void HandleLinkBattleSetup(void); void SetUpBattleVarsAndBirchZigzagoon(void); @@ -53,24 +116,36 @@ void sub_8032768(void); void sub_8033648(void); // emitters +void EmitGetMonData(u8 bufferId, u8 arg1, u8 arg2); +void EmitGetRawMonData(u8 bufferId, u8 monId, u8 bytes); // unused 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 EmitSetRawMonData(u8 bufferId, u8 monId, u8 bytes, void *data); // unused +void EmitLoadMonSprite(u8 bufferId); +void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit); +void EmitReturnPokeToBall(u8 bufferId, u8 arg1); +void EmitDrawTrainerPic(u8 bufferId); +void EmitTrainerSlide(u8 bufferId); +void EmitTrainerSlideBack(u8 bufferId); +void EmitFaintAnimation(u8 bufferId); +void EmitCmd11(u8 bufferId); // unused +void EmitCmd12(u8 bufferId); // unused +void EmitBallThrow(u8 bufferId, u8 caseId); +void EmitPause(u8 bufferId, u8 toWait, void *data); // unused +void EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct *disableStructPtr, u8 multihit); +void EmitPrintString(u8 bufferId, u16 stringId); +void EmitPrintStringPlayerOnly(u8 bufferId, u16 stringId); +void EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2); + + void EmitHealthBarUpdate(u8 bufferId, u16 hpValue); void EmitEffectivenessSound(u8 bufferId, u16 songId); void EmitPlaySound(u8 bufferId, u16 songId, u8 arg2); -void EmitPrintStringPlayerOnly(u8 bufferId, u16 stringId); -void EmitFaintAnimation(u8 bufferId); void Emit_x2A(u8 bufferId); void EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints); void EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument); void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible); -void EmitReturnPokeToBall(u8 bufferId, u8 arg1); -void EmitGetMonData(u8 bufferId, u8 arg1, u8 arg2); -void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit); void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4); void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2); -void EmitTrainerSlide(u8 bufferId); -void EmitTrainerSlideBack(u8 bufferId); void EmitFaintingCry(u8 bufferId); void Emit_x37(u8 bufferId, u8 arg1); void EmitHitAnimation(u8 bufferId); @@ -80,16 +155,12 @@ void EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status); void EmitCmd13(u8 bufferId); void EmitStatusIconUpdate(u8 bufferId, u32 status1, u32 status2); void EmitIntroSlide(u8 bufferId, u8 terrainId); -void EmitDrawTrainerPic(u8 bufferId); -void EmitLoadMonSprite(u8 bufferId); void EmitIntroTrainerBallThrow(u8 bufferId); -void EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2); void EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct* movePpData); void EmitOpenBag(u8 bufferId, u8* arg1); void Emit_x32(u8 bufferId); -void EmitPrintString(u8 bufferId, u16 stringId); + void EmitResetActionMoveSelection(u8 bufferId, u8 caseId); -void EmitBallThrow(u8 bufferId, u8 caseId); void EmitCmd_x21(u8 bufferId, u8 arg1, u16 arg2); // player controller diff --git a/include/battle_util.h b/include/battle_util.h index c1ff7d8ab..b21b250c4 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -33,6 +33,7 @@ #define ITEMEFFECT_ON_SWITCH_IN 0x0 #define WEATHER_HAS_EFFECT ((!AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_CLOUD_NINE, 0, 0) && !AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_AIR_LOCK, 0, 0))) +#define WEATHER_HAS_EFFECT2 ((!AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_CLOUD_NINE, 0, 0) && !AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_AIR_LOCK, 0, 0))) #define BS_GET_TARGET 0 #define BS_GET_ATTACKER 1 diff --git a/src/battle_controllers.c b/src/battle_controllers.c index cfa4aae71..58a595730 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -9,6 +9,8 @@ #include "species.h" #include "recorded_battle.h" #include "util.h" +#include "abilities.h" +#include "battle_message.h" extern u32 gBattleTypeFlags; extern u32 gBattleExecBuffer; @@ -25,6 +27,7 @@ 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 gBattleBuffersTransferData[0x100]; extern u8 gUnknown_02022D08; extern u8 gUnknown_02022D09; extern u8 gUnknown_02022D0A; @@ -32,6 +35,9 @@ extern u8 gBankAttacker; extern u8 gBankTarget; extern u8 gAbsentBankFlags; extern u8 gEffectBank; +extern u16 gBattleWeather; + +extern const struct BattleMove gBattleMoves[]; extern void task00_08081A90(u8 taskId); // cable_club extern void sub_81B8D64(u8 bank, u8 arg1); // party_menu @@ -926,3 +932,251 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId) gTasks[taskId].data[15] = gTasks[taskId].data[15] + blockSize + LINK_BUFF_DATA; } } + +void EmitGetMonData(u8 bufferId, u8 arg1, u8 arg2) +{ + gBattleBuffersTransferData[0] = CONTROLLER_GETMONDATA; + gBattleBuffersTransferData[1] = arg1; + gBattleBuffersTransferData[2] = arg2; + gBattleBuffersTransferData[3] = 0; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitGetRawMonData(u8 bufferId, u8 monId, u8 bytes) +{ + gBattleBuffersTransferData[0] = CONTROLLER_GETRAWMONDATA; + gBattleBuffersTransferData[1] = monId; + gBattleBuffersTransferData[2] = bytes; + gBattleBuffersTransferData[3] = 0; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitSetMonData(u8 bufferId, u8 request, u8 c, u8 bytes, void *data) +{ + s32 i; + + gBattleBuffersTransferData[0] = CONTROLLER_SETMONDATA; + gBattleBuffersTransferData[1] = request; + gBattleBuffersTransferData[2] = c; + for (i = 0; i < bytes; i++) + gBattleBuffersTransferData[3 + i] = *(u8*)(data++); + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 3 + bytes); +} + +void EmitSetRawMonData(u8 bufferId, u8 monId, u8 bytes, void *data) +{ + s32 i; + + gBattleBuffersTransferData[0] = CONTROLLER_SETRAWMONDATA; + gBattleBuffersTransferData[1] = monId; + gBattleBuffersTransferData[2] = bytes; + for (i = 0; i < bytes; i++) + gBattleBuffersTransferData[3 + i] = *(u8*)(data++); + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, bytes + 3); +} + +void EmitLoadMonSprite(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_LOADMONSPRITE; + gBattleBuffersTransferData[1] = 4; + gBattleBuffersTransferData[2] = 4; + gBattleBuffersTransferData[3] = 4; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit) +{ + gBattleBuffersTransferData[0] = CONTROLLER_SWITCHINANIM; + gBattleBuffersTransferData[1] = partyId; + gBattleBuffersTransferData[2] = dontClearSubstituteBit; + gBattleBuffersTransferData[3] = 5; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +// TODO: change Poke to Mon to be consistent +void EmitReturnPokeToBall(u8 bufferId, u8 arg1) +{ + gBattleBuffersTransferData[0] = CONTROLLER_RETURNPOKETOBALL; + gBattleBuffersTransferData[1] = arg1; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 2); +} + +void EmitDrawTrainerPic(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_DRAWTRAINERPIC; + gBattleBuffersTransferData[1] = 7; + gBattleBuffersTransferData[2] = 7; + gBattleBuffersTransferData[3] = 7; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitTrainerSlide(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_TRAINERSLIDE; + gBattleBuffersTransferData[1] = 8; + gBattleBuffersTransferData[2] = 8; + gBattleBuffersTransferData[3] = 8; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitTrainerSlideBack(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_TRAINERSLIDEBACK; + gBattleBuffersTransferData[1] = 9; + gBattleBuffersTransferData[2] = 9; + gBattleBuffersTransferData[3] = 9; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitFaintAnimation(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_FAINTANIMATION; + gBattleBuffersTransferData[1] = 10; + gBattleBuffersTransferData[2] = 10; + gBattleBuffersTransferData[3] = 10; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitCmd11(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_11; + gBattleBuffersTransferData[1] = 11; + gBattleBuffersTransferData[2] = 11; + gBattleBuffersTransferData[3] = 11; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitCmd12(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_12; + gBattleBuffersTransferData[1] = 12; + gBattleBuffersTransferData[2] = 12; + gBattleBuffersTransferData[3] = 12; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitBallThrow(u8 bufferId, u8 caseId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_BALLTHROW; + gBattleBuffersTransferData[1] = caseId; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 2); +} + +void EmitPause(u8 bufferId, u8 toWait, void *data) +{ + s32 i; + + gBattleBuffersTransferData[0] = CONTROLLER_PAUSE; + gBattleBuffersTransferData[1] = toWait; + for (i = 0; i < toWait * 3; i++) + gBattleBuffersTransferData[2 + i] = *(u8*)(data++); + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, toWait * 3 + 2); +} + +void EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct *disableStructPtr, u8 multihit) +{ + gBattleBuffersTransferData[0] = CONTROLLER_MOVEANIMATION; + gBattleBuffersTransferData[1] = move; + gBattleBuffersTransferData[2] = (move & 0xFF00) >> 8; + gBattleBuffersTransferData[3] = turnOfMove; + gBattleBuffersTransferData[4] = movePower; + gBattleBuffersTransferData[5] = (movePower & 0xFF00) >> 8; + gBattleBuffersTransferData[6] = dmg; + gBattleBuffersTransferData[7] = (dmg & 0x0000FF00) >> 8; + gBattleBuffersTransferData[8] = (dmg & 0x00FF0000) >> 16; + gBattleBuffersTransferData[9] = (dmg & 0xFF000000) >> 24; + gBattleBuffersTransferData[10] = friendship; + gBattleBuffersTransferData[11] = multihit; + if (WEATHER_HAS_EFFECT2) + { + gBattleBuffersTransferData[12] = gBattleWeather; + gBattleBuffersTransferData[13] = (gBattleWeather & 0xFF00) >> 8; + } + else + { + gBattleBuffersTransferData[12] = 0; + gBattleBuffersTransferData[13] = 0; + } + gBattleBuffersTransferData[14] = 0; + gBattleBuffersTransferData[15] = 0; + memcpy(&gBattleBuffersTransferData[16], disableStructPtr, sizeof(struct DisableStruct)); + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 16 + sizeof(struct DisableStruct)); +} + +extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern u16 gCurrentMove; +extern u16 gLastUsedMove; +extern u16 gLastUsedItem; +extern u8 gBattleOutcome; +extern u8 gLastUsedAbility; +extern u8 gStringBank; + +void EmitPrintString(u8 bufferId, u16 stringID) +{ + s32 i; + struct StringInfoBattle* stringInfo; + + gBattleBuffersTransferData[0] = CONTROLLER_PRINTSTRING; + gBattleBuffersTransferData[1] = gBattleOutcome; + gBattleBuffersTransferData[2] = stringID; + gBattleBuffersTransferData[3] = (stringID & 0xFF00) >> 8; + + stringInfo = (struct StringInfoBattle*)(&gBattleBuffersTransferData[4]); + stringInfo->currentMove = gCurrentMove; + stringInfo->lastMove = gLastUsedMove; + stringInfo->lastItem = gLastUsedItem; + stringInfo->lastAbility = gLastUsedAbility; + stringInfo->scrActive = gBattleScripting.bank; + stringInfo->unk1605E = gBattleStruct->field_52; + stringInfo->hpScale = gBattleStruct->hpScale; + stringInfo->StringBank = gStringBank; + stringInfo->moveType = gBattleMoves[gCurrentMove].type; + + for (i = 0; i < BATTLE_BANKS_COUNT; i++) + stringInfo->abilities[i] = gBattleMons[i].ability; + for (i = 0; i < TEXT_BUFF_ARRAY_COUNT; i++) + { + stringInfo->textBuffs[0][i] = gBattleTextBuff1[i]; + stringInfo->textBuffs[1][i] = gBattleTextBuff2[i]; + stringInfo->textBuffs[2][i] = gBattleTextBuff3[i]; + } + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, sizeof(struct StringInfoBattle) + 4); +} + +void EmitPrintStringPlayerOnly(u8 bufferId, u16 stringID) +{ + s32 i; + struct StringInfoBattle* stringInfo; + + gBattleBuffersTransferData[0] = CONTROLLER_PRINTSTRINGPLAYERONLY; + gBattleBuffersTransferData[1] = 17; + gBattleBuffersTransferData[2] = stringID; + gBattleBuffersTransferData[3] = (stringID & 0xFF00) >> 8; + + stringInfo = (struct StringInfoBattle*)(&gBattleBuffersTransferData[4]); + stringInfo->currentMove = gCurrentMove; + stringInfo->lastMove = gLastUsedMove; + stringInfo->lastItem = gLastUsedItem; + stringInfo->lastAbility = gLastUsedAbility; + stringInfo->scrActive = gBattleScripting.bank; + stringInfo->unk1605E = gBattleStruct->field_52; + + for (i = 0; i < BATTLE_BANKS_COUNT; i++) + stringInfo->abilities[i] = gBattleMons[i].ability; + for (i = 0; i < TEXT_BUFF_ARRAY_COUNT; i++) + { + stringInfo->textBuffs[0][i] = gBattleTextBuff1[i]; + stringInfo->textBuffs[1][i] = gBattleTextBuff2[i]; + stringInfo->textBuffs[2][i] = gBattleTextBuff3[i]; + } + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, sizeof(struct StringInfoBattle) + 4); +} + +void EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2) +{ + gBattleBuffersTransferData[0] = CONTROLLER_CHOOSEACTION; + gBattleBuffersTransferData[1] = arg1; + gBattleBuffersTransferData[2] = arg2; + gBattleBuffersTransferData[3] = (arg2 & 0xFF00) >> 8; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} diff --git a/sym_ewram.txt b/sym_ewram.txt index 495d233f9..368e2b84a 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -196,7 +196,7 @@ gUnknown_02022D0A: @ 2022D0A gUnknown_02022D0C: @ 2022D0C .space 0x4 -gUnknown_02022D10: @ 2022D10 +gBattleBuffersTransferData: @ 2022D10 .space 0x100 gUnknown_02022E10: @ 2022E10 From 14e41d6c508e5c425dff8f2c4933ae4c8b7ab762 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 14 Oct 2017 11:34:26 +0200 Subject: [PATCH 4/4] rom3 is decompiled --- asm/battle_controller_linkopponent.s | 2 +- asm/battle_controller_linkpartner.s | 2 +- asm/battle_controller_opponent.s | 18 +- asm/battle_controller_player.s | 38 +- asm/battle_controller_player_partner.s | 10 +- asm/battle_controller_recorded_opponent.s | 10 +- asm/battle_controller_recorded_player.s | 12 +- asm/battle_controller_safari.s | 6 +- asm/battle_controller_wally.s | 10 +- asm/rom3.s | 971 ---------------------- include/battle_controllers.h | 75 +- include/link.h | 1 - include/recorded_battle.h | 1 + ld_script.txt | 1 - src/battle_2.c | 4 +- src/battle_ai_switch_items.c | 18 +- src/battle_controllers.c | 407 ++++++++- src/battle_script_commands.c | 34 +- 18 files changed, 514 insertions(+), 1106 deletions(-) delete mode 100644 asm/rom3.s diff --git a/asm/battle_controller_linkopponent.s b/asm/battle_controller_linkopponent.s index bf350a8bc..ee8cf7154 100644 --- a/asm/battle_controller_linkopponent.s +++ b/asm/battle_controller_linkopponent.s @@ -1572,7 +1572,7 @@ _0806513A: lsrs r1, 16 movs r0, 0x1 mov r2, sp - bl dp01_build_cmdbuf_x1D_1D_numargs_varargs + bl EmitDataTransfer bl LinkOpponentBufferExecCompleted add sp, 0x100 pop {r4-r6} diff --git a/asm/battle_controller_linkpartner.s b/asm/battle_controller_linkpartner.s index b26943cf5..37d8f8346 100644 --- a/asm/battle_controller_linkpartner.s +++ b/asm/battle_controller_linkpartner.s @@ -1113,7 +1113,7 @@ _0814B872: lsrs r1, 16 movs r0, 0x1 mov r2, sp - bl dp01_build_cmdbuf_x1D_1D_numargs_varargs + bl EmitDataTransfer bl LinkPartnerBufferExecCompleted add sp, 0x100 pop {r4-r6} diff --git a/asm/battle_controller_opponent.s b/asm/battle_controller_opponent.s index 424e4159d..056d92147 100644 --- a/asm/battle_controller_opponent.s +++ b/asm/battle_controller_opponent.s @@ -1666,7 +1666,7 @@ _0805FFEA: lsrs r1, 16 movs r0, 0x1 mov r2, sp - bl dp01_build_cmdbuf_x1D_1D_numargs_varargs + bl EmitDataTransfer bl OpponentBufferExecCompleted add sp, 0x100 pop {r4-r6} @@ -2607,7 +2607,7 @@ _08060806: ldrb r1, [r0] movs r0, 0x1 adds r2, r4, 0 - bl dp01_build_cmdbuf_x1D_1D_numargs_varargs + bl EmitDataTransfer bl OpponentBufferExecCompleted add sp, 0x58 pop {r4-r7} @@ -5243,7 +5243,7 @@ sub_8061FB8: @ 8061FB8 movs r0, 0x1 movs r1, 0xA _08061FD6: - bl EmitCmd_x21 + bl EmitCmd33 _08061FDA: bl OpponentBufferExecCompleted b _08062156 @@ -5347,7 +5347,7 @@ _0806209C: movs r0, 0x1 movs r1, 0xA adds r2, r4, 0 - bl EmitCmd_x21 + bl EmitCmd33 b _08061FDA .pool _080620C4: @@ -5378,7 +5378,7 @@ _080620C6: movs r0, 0x1 movs r1, 0xA adds r2, r4, 0 - bl EmitCmd_x21 + bl EmitCmd33 b _08062152 .pool _08062108: @@ -5401,7 +5401,7 @@ _08062108: orrs r2, r4 movs r0, 0x1 movs r1, 0xA - bl EmitCmd_x21 + bl EmitCmd33 b _08062152 .pool _0806213C: @@ -5413,7 +5413,7 @@ _0806213C: orrs r2, r4 movs r0, 0x1 movs r1, 0xA - bl EmitCmd_x21 + bl EmitCmd33 _08062152: bl OpponentBufferExecCompleted _08062156: @@ -5435,7 +5435,7 @@ sub_806215C: @ 806215C adds r0, 0xC0 ldrb r1, [r0] movs r0, 0x1 - bl dp01_build_cmdbuf_x23_aa_0 + bl EmitCmd35 bl OpponentBufferExecCompleted pop {r0} bx r0 @@ -5550,7 +5550,7 @@ _0806225A: lsrs r1, 24 movs r0, 0x1 movs r2, 0 - bl dp01_build_cmdbuf_x22_a_three_bytes + bl EmitCmd34 bl OpponentBufferExecCompleted pop {r4-r7} pop {r0} diff --git a/asm/battle_controller_player.s b/asm/battle_controller_player.s index 047c62f6b..d9c22e13a 100644 --- a/asm/battle_controller_player.s +++ b/asm/battle_controller_player.s @@ -226,7 +226,7 @@ _0805764C: movs r0, 0x1 movs r1, 0x3 movs r2, 0 - bl EmitCmd_x21 + bl EmitCmd33 b _080577C2 _08057658: movs r0, 0x20 @@ -393,7 +393,7 @@ _080577B2: movs r1, 0xC _080577BC: movs r2, 0 - bl EmitCmd_x21 + bl EmitCmd33 _080577C2: bl PlayerBufferExecCompleted b _080577E8 @@ -518,7 +518,7 @@ _080578A0: orrs r2, r0 movs r0, 0x1 movs r1, 0xA - bl EmitCmd_x21 + bl EmitCmd33 ldrb r0, [r4] movs r1, 0x1 bl dp11b_obj_free @@ -1086,7 +1086,7 @@ _08057E14: _08057E1C: movs r0, 0x1 movs r1, 0xA - bl EmitCmd_x21 + bl EmitCmd33 bl PlayerBufferExecCompleted b _08057F9E .pool @@ -3413,7 +3413,7 @@ _080591FE: lsrs r2, 16 movs r0, 0x1 movs r1, 0xB - bl EmitCmd_x21 + bl EmitCmd33 strb r5, [r4] bl IsDoubleBattle lsls r0, 24 @@ -3686,7 +3686,7 @@ _08059430: lsrs r2, 16 movs r0, 0x1 movs r1, 0xB - bl EmitCmd_x21 + bl EmitCmd33 strb r5, [r4] ldr r0, =sub_8059544 str r0, [r6] @@ -4059,14 +4059,14 @@ sub_8059828: @ 8059828 ldrb r1, [r0] ldr r2, =gUnknown_0203CF00 movs r0, 0x1 - bl dp01_build_cmdbuf_x22_a_three_bytes + bl EmitCmd34 b _0805987A .pool _08059870: movs r0, 0x1 movs r1, 0x6 movs r2, 0 - bl dp01_build_cmdbuf_x22_a_three_bytes + bl EmitCmd34 _0805987A: ldr r1, =gBattleBufferA ldr r0, =gActiveBank @@ -4130,7 +4130,7 @@ sub_80598E0: @ 80598E0 ldr r0, =gScriptItemId ldrh r1, [r0] movs r0, 0x1 - bl dp01_build_cmdbuf_x23_aa_0 + bl EmitCmd35 bl PlayerBufferExecCompleted _08059906: pop {r0} @@ -4291,14 +4291,14 @@ _08059A2C: movs r0, 0x1 movs r1, 0xE movs r2, 0 - bl EmitCmd_x21 + bl EmitCmd33 b _08059A76 .pool _08059A6C: movs r0, 0x1 movs r1, 0xD movs r2, 0 - bl EmitCmd_x21 + bl EmitCmd33 _08059A76: bl PlayerBufferExecCompleted _08059A7A: @@ -4772,7 +4772,7 @@ _08059E4E: lsrs r1, 16 movs r0, 0x1 mov r2, sp - bl dp01_build_cmdbuf_x1D_1D_numargs_varargs + bl EmitDataTransfer bl PlayerBufferExecCompleted add sp, 0x100 pop {r4-r6} @@ -5713,7 +5713,7 @@ _0805A66A: ldrb r1, [r0] movs r0, 0x1 adds r2, r4, 0 - bl dp01_build_cmdbuf_x1D_1D_numargs_varargs + bl EmitDataTransfer bl PlayerBufferExecCompleted add sp, 0x58 pop {r4-r7} @@ -8658,7 +8658,7 @@ sub_805C158: @ 805C158 lsrs r2, 16 movs r0, 0x1 movs r1, 0xA - bl EmitCmd_x21 + bl EmitCmd33 bl PlayerBufferExecCompleted _0805C194: pop {r0} @@ -8826,7 +8826,7 @@ _0805C2C8: lsrs r1, 24 movs r0, 0x1 mov r2, r12 - bl dp01_build_cmdbuf_x22_a_three_bytes + bl EmitCmd34 bl PlayerBufferExecCompleted b _0805C3BC .pool @@ -9378,7 +9378,7 @@ sub_805C80C: @ 805C80C movs r0, 0x1 movs r1, 0 movs r2, 0 - bl EmitCmd_x21 + bl EmitCmd33 bl PlayerBufferExecCompleted pop {r0} bx r0 @@ -9390,7 +9390,7 @@ sub_805C820: @ 805C820 movs r0, 0x1 movs r1, 0 movs r2, 0 - bl dp01_build_cmdbuf_x22_a_three_bytes + bl EmitCmd34 bl PlayerBufferExecCompleted pop {r0} bx r0 @@ -9401,7 +9401,7 @@ sub_805C834: @ 805C834 push {lr} movs r0, 0x1 movs r1, 0 - bl dp01_build_cmdbuf_x23_aa_0 + bl EmitCmd35 bl PlayerBufferExecCompleted pop {r0} bx r0 @@ -9412,7 +9412,7 @@ sub_805C848: @ 805C848 push {lr} movs r0, 0x1 movs r1, 0 - bl dp01_build_cmdbuf_x24_aa_0 + bl EmitCmd36 bl PlayerBufferExecCompleted pop {r0} bx r0 diff --git a/asm/battle_controller_player_partner.s b/asm/battle_controller_player_partner.s index 35ee3a733..d519f5daa 100644 --- a/asm/battle_controller_player_partner.s +++ b/asm/battle_controller_player_partner.s @@ -645,7 +645,7 @@ _081BB2E2: lsrs r2, 16 movs r0, 0x1 movs r1, 0xB - bl EmitCmd_x21 + bl EmitCmd33 strb r5, [r4] bl IsDoubleBattle lsls r0, 24 @@ -918,7 +918,7 @@ _081BB514: lsrs r2, 16 movs r0, 0x1 movs r1, 0xB - bl EmitCmd_x21 + bl EmitCmd33 strb r5, [r4] ldr r0, =sub_81BB628 str r0, [r6] @@ -1688,7 +1688,7 @@ _081BBCBE: lsrs r1, 16 movs r0, 0x1 mov r2, sp - bl dp01_build_cmdbuf_x1D_1D_numargs_varargs + bl EmitDataTransfer bl PlayerPartnerBufferExecCompleted add sp, 0x100 pop {r4-r6} @@ -5068,7 +5068,7 @@ _081BDB3C: orrs r2, r5 movs r0, 0x1 movs r1, 0xA - bl EmitCmd_x21 + bl EmitCmd33 bl PlayerPartnerBufferExecCompleted pop {r4-r6} pop {r0} @@ -5138,7 +5138,7 @@ _081BDBD0: lsrs r1, 24 movs r0, 0x1 movs r2, 0 - bl dp01_build_cmdbuf_x22_a_three_bytes + bl EmitCmd34 bl PlayerPartnerBufferExecCompleted pop {r4-r6} pop {r0} diff --git a/asm/battle_controller_recorded_opponent.s b/asm/battle_controller_recorded_opponent.s index 562b55d4d..19185a25a 100644 --- a/asm/battle_controller_recorded_opponent.s +++ b/asm/battle_controller_recorded_opponent.s @@ -1553,7 +1553,7 @@ _0818727E: lsrs r1, 16 movs r0, 0x1 mov r2, sp - bl dp01_build_cmdbuf_x1D_1D_numargs_varargs + bl EmitDataTransfer bl RecordedOpponentBufferExecCompleted add sp, 0x100 pop {r4-r6} @@ -4754,7 +4754,7 @@ sub_8188EF0: @ 8188EF0 lsrs r1, 24 movs r0, 0x1 movs r2, 0 - bl EmitCmd_x21 + bl EmitCmd33 bl RecordedOpponentBufferExecCompleted pop {r0} bx r0 @@ -4785,7 +4785,7 @@ sub_8188F20: @ 8188F20 lsrs r2, 16 movs r0, 0x1 movs r1, 0xA - bl EmitCmd_x21 + bl EmitCmd33 b _08188F6C .pool _08188F48: @@ -4803,7 +4803,7 @@ _08188F48: orrs r2, r4 movs r0, 0x1 movs r1, 0xA - bl EmitCmd_x21 + bl EmitCmd33 _08188F6C: bl RecordedOpponentBufferExecCompleted pop {r4,r5} @@ -4839,7 +4839,7 @@ sub_8188F88: @ 8188F88 ldrb r1, [r0] movs r0, 0x1 movs r2, 0 - bl dp01_build_cmdbuf_x22_a_three_bytes + bl EmitCmd34 bl RecordedOpponentBufferExecCompleted pop {r4} pop {r0} diff --git a/asm/battle_controller_recorded_player.s b/asm/battle_controller_recorded_player.s index f7dfc0fed..969313747 100644 --- a/asm/battle_controller_recorded_player.s +++ b/asm/battle_controller_recorded_player.s @@ -1489,7 +1489,7 @@ _0818A646: lsrs r1, 16 movs r0, 0x1 mov r2, sp - bl dp01_build_cmdbuf_x1D_1D_numargs_varargs + bl EmitDataTransfer bl RecordedPlayerBufferExecCompleted add sp, 0x100 pop {r4-r6} @@ -4861,7 +4861,7 @@ sub_818C49C: @ 818C49C lsrs r1, 24 movs r0, 0x1 movs r2, 0 - bl EmitCmd_x21 + bl EmitCmd33 bl RecordedPlayerBufferExecCompleted _0818C4C6: pop {r0} @@ -4897,7 +4897,7 @@ _0818C508: lsrs r1, 24 movs r0, 0x1 movs r2, 0 - bl EmitCmd_x21 + bl EmitCmd33 bl RecordedPlayerBufferExecCompleted _0818C522: pop {r0} @@ -4929,7 +4929,7 @@ sub_818C538: @ 818C538 lsrs r2, 16 movs r0, 0x1 movs r1, 0xA - bl EmitCmd_x21 + bl EmitCmd33 b _0818C584 .pool _0818C560: @@ -4947,7 +4947,7 @@ _0818C560: orrs r2, r4 movs r0, 0x1 movs r1, 0xA - bl EmitCmd_x21 + bl EmitCmd33 _0818C584: bl RecordedPlayerBufferExecCompleted pop {r4,r5} @@ -4983,7 +4983,7 @@ sub_818C5A0: @ 818C5A0 ldrb r1, [r0] movs r0, 0x1 movs r2, 0 - bl dp01_build_cmdbuf_x22_a_three_bytes + bl EmitCmd34 bl RecordedPlayerBufferExecCompleted pop {r4} pop {r0} diff --git a/asm/battle_controller_safari.s b/asm/battle_controller_safari.s index a45ae6cee..d7efd69fe 100644 --- a/asm/battle_controller_safari.s +++ b/asm/battle_controller_safari.s @@ -103,13 +103,13 @@ _0815942A: movs r1, 0x7 _0815942E: movs r2, 0 - bl EmitCmd_x21 + bl EmitCmd33 b _08159440 _08159436: movs r0, 0x1 movs r1, 0x8 movs r2, 0 - bl EmitCmd_x21 + bl EmitCmd33 _08159440: bl SafariBufferExecCompleted b _0815954E @@ -399,7 +399,7 @@ sub_8159698: @ 8159698 ldr r0, =gScriptItemId ldrh r1, [r0] movs r0, 0x1 - bl dp01_build_cmdbuf_x23_aa_0 + bl EmitCmd35 bl SafariBufferExecCompleted _081596BE: pop {r0} diff --git a/asm/battle_controller_wally.s b/asm/battle_controller_wally.s index de17547a1..d028f3bac 100644 --- a/asm/battle_controller_wally.s +++ b/asm/battle_controller_wally.s @@ -153,7 +153,7 @@ _081684CE: movs r1, 0x9 _081684E4: movs r2, 0 - bl EmitCmd_x21 + bl EmitCmd33 bl WallyBufferExecCompleted ldr r1, [r4] adds r1, 0x94 @@ -208,7 +208,7 @@ _08168540: movs r0, 0x1 movs r1, 0x1 movs r2, 0 - bl EmitCmd_x21 + bl EmitCmd33 bl WallyBufferExecCompleted _08168564: pop {r4,r5} @@ -311,7 +311,7 @@ sub_8168610: @ 8168610 ldr r0, =gScriptItemId ldrh r1, [r0] movs r0, 0x1 - bl dp01_build_cmdbuf_x23_aa_0 + bl EmitCmd35 bl WallyBufferExecCompleted _08168636: pop {r0} @@ -975,7 +975,7 @@ _08168BFA: lsrs r1, 16 movs r0, 0x1 mov r2, sp - bl dp01_build_cmdbuf_x1D_1D_numargs_varargs + bl EmitDataTransfer bl WallyBufferExecCompleted add sp, 0x100 pop {r4-r6} @@ -3777,7 +3777,7 @@ _0816A550: lsls r2, 1 movs r0, 0x1 movs r1, 0xA - bl EmitCmd_x21 + bl EmitCmd33 bl WallyBufferExecCompleted _0816A574: pop {r4} diff --git a/asm/rom3.s b/asm/rom3.s deleted file mode 100644 index 7ed49bd4d..000000000 --- a/asm/rom3.s +++ /dev/null @@ -1,971 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start EmitCmd13 -EmitCmd13: @ 8033E10 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x13 - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitCmd13 - - thumb_func_start EmitChooseMove -EmitChooseMove: @ 8033E30 - push {r4-r6,lr} - adds r5, r3, 0 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r3, =gBattleBuffersTransferData - movs r4, 0 - movs r0, 0x14 - strb r0, [r3] - strb r1, [r3, 0x1] - strb r2, [r3, 0x2] - strb r4, [r3, 0x3] - movs r2, 0 - adds r1, r3, 0 - adds r4, r1, 0x4 -_08033E4C: - adds r0, r5, r2 - ldrb r0, [r0] - strb r0, [r4] - adds r4, 0x1 - adds r2, 0x1 - cmp r2, 0x13 - bls _08033E4C - adds r0, r6, 0 - movs r2, 0x18 - bl PrepareBufferDataTransfer - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end EmitChooseMove - - thumb_func_start EmitOpenBag -EmitOpenBag: @ 8033E6C - push {r4,r5,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r0, 0x15 - strb r0, [r1] - movs r2, 0 - adds r3, r1, 0x1 -_08033E7E: - adds r0, r4, r2 - ldrb r0, [r0] - strb r0, [r3] - adds r3, 0x1 - adds r2, 0x1 - cmp r2, 0x2 - ble _08033E7E - adds r0, r5, 0 - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end EmitOpenBag - - thumb_func_start EmitChoosePokemon -EmitChoosePokemon: @ 8033EA0 - push {r4-r6,lr} - ldr r6, [sp, 0x10] - lsls r0, 24 - lsrs r5, r0, 24 - ldr r4, =gBattleBuffersTransferData - movs r0, 0x16 - strb r0, [r4] - strb r1, [r4, 0x1] - strb r2, [r4, 0x2] - strb r3, [r4, 0x3] - movs r2, 0 - adds r1, r4, 0 - adds r3, r1, 0x4 -_08033EBA: - adds r0, r6, r2 - ldrb r0, [r0] - strb r0, [r3] - adds r3, 0x1 - adds r2, 0x1 - cmp r2, 0x2 - ble _08033EBA - adds r0, r5, 0 - movs r2, 0x8 - bl PrepareBufferDataTransfer - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end EmitChoosePokemon - - thumb_func_start dp01_build_cmdbuf_x17_17_17_17 -dp01_build_cmdbuf_x17_17_17_17: @ 8033EDC - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x17 - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x17_17_17_17 - - thumb_func_start EmitHealthBarUpdate -EmitHealthBarUpdate: @ 8033EFC - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r1, 16 - ldr r3, =gBattleBuffersTransferData - movs r4, 0 - movs r2, 0x18 - strb r2, [r3] - strb r4, [r3, 0x1] - strb r1, [r3, 0x2] - lsls r1, 16 - asrs r1, 16 - movs r2, 0xFF - lsls r2, 8 - ands r1, r2 - asrs r1, 8 - strb r1, [r3, 0x3] - adds r1, r3, 0 - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end EmitHealthBarUpdate - - thumb_func_start EmitExpUpdate -EmitExpUpdate: @ 8033F34 - push {r4,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r2, 16 - lsrs r2, 16 - ldr r1, =gBattleBuffersTransferData - movs r3, 0x19 - strb r3, [r1] - strb r4, [r1, 0x1] - strb r2, [r1, 0x2] - lsls r2, 16 - asrs r2, 16 - movs r3, 0xFF - lsls r3, 8 - ands r2, r3 - asrs r2, 8 - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end EmitExpUpdate - - thumb_func_start EmitStatusIconUpdate -EmitStatusIconUpdate: @ 8033F68 - push {r4-r6,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r3, 0x1A - strb r3, [r1] - strb r4, [r1, 0x1] - movs r6, 0xFF - lsls r6, 8 - adds r3, r4, 0 - ands r3, r6 - lsrs r3, 8 - strb r3, [r1, 0x2] - movs r5, 0xFF - lsls r5, 16 - adds r3, r4, 0 - ands r3, r5 - lsrs r3, 16 - strb r3, [r1, 0x3] - lsrs r4, 24 - strb r4, [r1, 0x4] - strb r2, [r1, 0x5] - adds r3, r2, 0 - ands r3, r6 - lsrs r3, 8 - strb r3, [r1, 0x6] - adds r3, r2, 0 - ands r3, r5 - lsrs r3, 16 - strb r3, [r1, 0x7] - lsrs r2, 24 - strb r2, [r1, 0x8] - movs r2, 0x9 - bl PrepareBufferDataTransfer - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end EmitStatusIconUpdate - - thumb_func_start EmitStatusAnimation -EmitStatusAnimation: @ 8033FBC - push {r4,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r3, 0x1B - strb r3, [r1] - strb r4, [r1, 0x1] - strb r2, [r1, 0x2] - movs r3, 0xFF - lsls r3, 8 - ands r3, r2 - lsrs r3, 8 - strb r3, [r1, 0x3] - movs r3, 0xFF - lsls r3, 16 - ands r3, r2 - lsrs r3, 16 - strb r3, [r1, 0x4] - lsrs r2, 24 - strb r2, [r1, 0x5] - movs r2, 0x6 - bl PrepareBufferDataTransfer - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end EmitStatusAnimation - - thumb_func_start dp01_build_cmdbuf_x1C_a -dp01_build_cmdbuf_x1C_a: @ 8033FF8 - push {lr} - adds r3, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x1C - strb r2, [r1] - strb r3, [r1, 0x1] - movs r2, 0x2 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x1C_a - - thumb_func_start dp01_build_cmdbuf_x1D_1D_numargs_varargs -dp01_build_cmdbuf_x1D_1D_numargs_varargs: @ 8034018 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 16 - lsrs r4, r1, 16 - ldr r1, =gBattleBuffersTransferData - movs r0, 0x1D - strb r0, [r1] - strb r0, [r1, 0x1] - strb r4, [r1, 0x2] - lsrs r0, r4, 8 - strb r0, [r1, 0x3] - adds r5, r1, 0 - cmp r4, 0 - beq _08034048 - adds r1, r5, 0x4 - adds r3, r4, 0 -_0803403A: - ldrb r0, [r2] - strb r0, [r1] - adds r2, 0x1 - adds r1, 0x1 - subs r3, 0x1 - cmp r3, 0 - bne _0803403A -_08034048: - adds r2, r4, 0x4 - lsls r2, 16 - lsrs r2, 16 - adds r0, r6, 0 - adds r1, r5, 0 - bl PrepareBufferDataTransfer - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x1D_1D_numargs_varargs - - thumb_func_start sub_8034060 -sub_8034060: @ 8034060 - push {r4-r6,lr} - adds r4, r3, 0 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r2, 16 - lsrs r5, r2, 16 - ldr r2, =gBattleBuffersTransferData - movs r0, 0x1E - strb r0, [r2] - strb r1, [r2, 0x1] - movs r3, 0xFF - lsls r3, 8 - adds r0, r1, 0 - ands r0, r3 - lsrs r0, 8 - strb r0, [r2, 0x2] - movs r0, 0xFF - lsls r0, 16 - ands r0, r1 - lsrs r0, 16 - strb r0, [r2, 0x3] - lsrs r1, 24 - strb r1, [r2, 0x4] - strb r5, [r2, 0x5] - adds r0, r5, 0 - ands r0, r3 - lsrs r0, 8 - strb r0, [r2, 0x6] - adds r1, r2, 0 - cmp r5, 0 - beq _080340B0 - adds r3, r1, 0x7 - adds r2, r5, 0 -_080340A2: - ldrb r0, [r4] - strb r0, [r3] - adds r4, 0x1 - adds r3, 0x1 - subs r2, 0x1 - cmp r2, 0 - bne _080340A2 -_080340B0: - adds r2, r5, 0x7 - lsls r2, 16 - lsrs r2, 16 - adds r0, r6, 0 - bl PrepareBufferDataTransfer - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8034060 - - thumb_func_start sub_80340C8 -sub_80340C8: @ 80340C8 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 16 - lsrs r4, r1, 16 - ldr r1, =gBattleBuffersTransferData - movs r0, 0x1F - strb r0, [r1] - strb r4, [r1, 0x1] - lsrs r0, r4, 8 - strb r0, [r1, 0x2] - adds r5, r1, 0 - cmp r4, 0 - beq _080340F6 - adds r1, r5, 0x3 - adds r3, r4, 0 -_080340E8: - ldrb r0, [r2] - strb r0, [r1] - adds r2, 0x1 - adds r1, 0x1 - subs r3, 0x1 - cmp r3, 0 - bne _080340E8 -_080340F6: - adds r2, r4, 0x3 - lsls r2, 16 - lsrs r2, 16 - adds r0, r6, 0 - adds r1, r5, 0 - bl PrepareBufferDataTransfer - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80340C8 - - thumb_func_start sub_8034110 -sub_8034110: @ 8034110 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 16 - lsrs r4, r1, 16 - ldr r1, =gBattleBuffersTransferData - movs r0, 0x20 - strb r0, [r1] - strb r4, [r1, 0x1] - lsrs r0, r4, 8 - strb r0, [r1, 0x2] - adds r5, r1, 0 - cmp r4, 0 - beq _0803413E - adds r1, r5, 0x3 - adds r3, r4, 0 -_08034130: - ldrb r0, [r2] - strb r0, [r1] - adds r2, 0x1 - adds r1, 0x1 - subs r3, 0x1 - cmp r3, 0 - bne _08034130 -_0803413E: - adds r2, r4, 0x3 - lsls r2, 16 - lsrs r2, 16 - adds r0, r6, 0 - adds r1, r5, 0 - bl PrepareBufferDataTransfer - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8034110 - - thumb_func_start EmitCmd_x21 -EmitCmd_x21: @ 8034158 - push {r4,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r2, 16 - lsrs r2, 16 - ldr r1, =gBattleBuffersTransferData - movs r3, 0x21 - strb r3, [r1] - strb r4, [r1, 0x1] - strb r2, [r1, 0x2] - lsrs r2, 8 - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end EmitCmd_x21 - - thumb_func_start dp01_build_cmdbuf_x22_a_three_bytes -dp01_build_cmdbuf_x22_a_three_bytes: @ 8034184 - push {r4,r5,lr} - adds r4, r2, 0 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r2, =gBattleBuffersTransferData - movs r0, 0x22 - strb r0, [r2] - strb r1, [r2, 0x1] - movs r3, 0 - adds r1, r2, 0x2 -_08034198: - adds r0, r4, r3 - ldrb r0, [r0] - strb r0, [r1] - adds r1, 0x1 - adds r3, 0x1 - cmp r3, 0x2 - ble _08034198 - adds r0, r5, 0 - adds r1, r2, 0 - movs r2, 0x5 - bl PrepareBufferDataTransfer - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x22_a_three_bytes - - thumb_func_start dp01_build_cmdbuf_x23_aa_0 -dp01_build_cmdbuf_x23_aa_0: @ 80341BC - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r1, 16 - ldr r3, =gBattleBuffersTransferData - movs r4, 0 - movs r2, 0x23 - strb r2, [r3] - strb r1, [r3, 0x1] - lsrs r1, 8 - strb r1, [r3, 0x2] - strb r4, [r3, 0x3] - adds r1, r3, 0 - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x23_aa_0 - - thumb_func_start dp01_build_cmdbuf_x24_aa_0 -dp01_build_cmdbuf_x24_aa_0: @ 80341E8 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r1, 16 - ldr r3, =gBattleBuffersTransferData - movs r4, 0 - movs r2, 0x24 - strb r2, [r3] - strb r1, [r3, 0x1] - lsrs r1, 8 - strb r1, [r3, 0x2] - strb r4, [r3, 0x3] - adds r1, r3, 0 - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x24_aa_0 - - thumb_func_start dp01_build_cmdbuf_x25_25_25_25 -dp01_build_cmdbuf_x25_25_25_25: @ 8034214 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x25 - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x25_25_25_25 - - thumb_func_start dp01_build_cmdbuf_x26_a -dp01_build_cmdbuf_x26_a: @ 8034234 - push {lr} - adds r3, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x26 - strb r2, [r1] - strb r3, [r1, 0x1] - movs r2, 0x2 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x26_a - - thumb_func_start dp01_build_cmdbuf_x27_27_27_27 -dp01_build_cmdbuf_x27_27_27_27: @ 8034254 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x27 - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x27_27_27_27 - - thumb_func_start dp01_build_cmdbuf_x28_28_28_28 -dp01_build_cmdbuf_x28_28_28_28: @ 8034274 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x28 - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end dp01_build_cmdbuf_x28_28_28_28 - - thumb_func_start EmitHitAnimation -EmitHitAnimation: @ 8034294 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x29 - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitHitAnimation - - thumb_func_start Emit_x2A -Emit_x2A: @ 80342B4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x2A - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end Emit_x2A - - thumb_func_start EmitEffectivenessSound -EmitEffectivenessSound: @ 80342D4 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r1, 16 - ldr r3, =gBattleBuffersTransferData - movs r4, 0 - movs r2, 0x2B - strb r2, [r3] - strb r1, [r3, 0x1] - lsrs r1, 8 - strb r1, [r3, 0x2] - strb r4, [r3, 0x3] - adds r1, r3, 0 - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end EmitEffectivenessSound - - thumb_func_start EmitPlaySound -EmitPlaySound: @ 8034300 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r1, 16 - ldr r4, =gBattleBuffersTransferData - movs r3, 0x2C - strb r3, [r4] - strb r1, [r4, 0x1] - lsrs r1, 8 - strb r1, [r4, 0x2] - strb r2, [r4, 0x3] - adds r1, r4, 0 - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end EmitPlaySound - - thumb_func_start EmitFaintingCry -EmitFaintingCry: @ 803432C - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x2D - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitFaintingCry - - thumb_func_start EmitIntroSlide -EmitIntroSlide: @ 803434C - push {lr} - adds r3, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x2E - strb r2, [r1] - strb r3, [r1, 0x1] - movs r2, 0x2 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitIntroSlide - - thumb_func_start EmitIntroTrainerBallThrow -EmitIntroTrainerBallThrow: @ 803436C - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x2F - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitIntroTrainerBallThrow - - thumb_func_start EmitDrawPartyStatusSummary -EmitDrawPartyStatusSummary: @ 803438C - push {r4,r5,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r2, 24 - lsrs r2, 24 - ldr r1, =gBattleBuffersTransferData - movs r3, 0x30 - strb r3, [r1] - movs r0, 0x7F - ands r0, r2 - strb r0, [r1, 0x1] - movs r0, 0x80 - ands r0, r2 - lsls r0, 24 - lsrs r0, 31 - strb r0, [r1, 0x2] - strb r3, [r1, 0x3] - movs r2, 0 - adds r3, r1, 0x4 -_080343B4: - adds r0, r4, r2 - ldrb r0, [r0] - strb r0, [r3] - adds r3, 0x1 - adds r2, 0x1 - cmp r2, 0x2F - ble _080343B4 - adds r0, r5, 0 - movs r2, 0x34 - bl PrepareBufferDataTransfer - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end EmitDrawPartyStatusSummary - - thumb_func_start EmitCmd49 -EmitCmd49: @ 80343D4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x31 - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitCmd49 - - thumb_func_start Emit_x32 -Emit_x32: @ 80343F4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x32 - strb r2, [r1] - strb r2, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end Emit_x32 - - thumb_func_start EmitSpriteInvisibility -EmitSpriteInvisibility: @ 8034414 - push {lr} - adds r3, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x33 - strb r2, [r1] - strb r3, [r1, 0x1] - strb r2, [r1, 0x2] - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitSpriteInvisibility - - thumb_func_start EmitBattleAnimation -EmitBattleAnimation: @ 8034438 - push {r4,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r2, 16 - lsrs r2, 16 - ldr r1, =gBattleBuffersTransferData - movs r3, 0x34 - strb r3, [r1] - strb r4, [r1, 0x1] - strb r2, [r1, 0x2] - lsrs r2, 8 - strb r2, [r1, 0x3] - movs r2, 0x4 - bl PrepareBufferDataTransfer - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end EmitBattleAnimation - - thumb_func_start EmitLinkStandbyMsg -EmitLinkStandbyMsg: @ 8034464 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r2, 24 - lsrs r2, 24 - ldr r4, =gBattleBuffersTransferData - movs r0, 0x35 - strb r0, [r4] - strb r1, [r4, 0x1] - cmp r2, 0 - beq _0803448C - adds r0, r4, 0x4 - bl sub_81850DC - strb r0, [r4, 0x2] - strb r0, [r4, 0x3] - b _08034490 - .pool -_0803448C: - strb r2, [r4, 0x2] - strb r2, [r4, 0x3] -_08034490: - ldr r1, =gBattleBuffersTransferData - ldrb r2, [r1, 0x2] - adds r2, 0x4 - adds r0, r5, 0 - bl PrepareBufferDataTransfer - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end EmitLinkStandbyMsg - - thumb_func_start EmitResetActionMoveSelection -EmitResetActionMoveSelection: @ 80344A8 - push {lr} - adds r3, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleBuffersTransferData - movs r2, 0x36 - strb r2, [r1] - strb r3, [r1, 0x1] - movs r2, 0x2 - bl PrepareBufferDataTransfer - pop {r0} - bx r0 - .pool - thumb_func_end EmitResetActionMoveSelection - - thumb_func_start Emit_x37 -Emit_x37: @ 80344C8 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r4, =gBattleBuffersTransferData - movs r0, 0x37 - strb r0, [r4] - strb r1, [r4, 0x1] - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r0, =0x00000ca9 - adds r1, r0 - ldrb r0, [r1] - lsls r0, 28 - lsrs r0, 31 - strb r0, [r4, 0x2] - ldrb r0, [r1] - lsls r0, 28 - lsrs r0, 31 - strb r0, [r4, 0x3] - adds r0, r4, 0x6 - bl sub_81850DC - strb r0, [r4, 0x4] - strb r0, [r4, 0x5] - ldrb r2, [r4, 0x4] - adds r2, 0x6 - adds r0, r5, 0 - adds r1, r4, 0 - bl PrepareBufferDataTransfer - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Emit_x37 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/battle_controllers.h b/include/battle_controllers.h index 475dcd348..4bc6b7b84 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -54,7 +54,7 @@ enum CONTROLLER_SETRAWMONDATA, CONTROLLER_LOADMONSPRITE, CONTROLLER_SWITCHINANIM, - CONTROLLER_RETURNPOKETOBALL, + CONTROLLER_RETURNMONTOBALL, CONTROLLER_DRAWTRAINERPIC, CONTROLLER_TRAINERSLIDE, CONTROLLER_TRAINERSLIDEBACK, @@ -68,17 +68,17 @@ enum CONTROLLER_PRINTSTRINGPLAYERONLY, CONTROLLER_CHOOSEACTION, CONTROLLER_19, - CONTROLLER_20, + CONTROLLER_CHOOSEMOVE, CONTROLLER_OPENBAG, - CONTROLLER_22, + CONTROLLER_CHOOSEPOKEMON, CONTROLLER_23, CONTROLLER_HEALTHBARUPDATE, - CONTROLLER_EXPBARUPDATE, + CONTROLLER_EXPUPDATE, CONTROLLER_STATUSICONUPDATE, CONTROLLER_STATUSANIMATION, CONTROLLER_STATUSXOR, - CONTROLLER_29, - CONTROLLER_DMATRANSFER, + CONTROLLER_DATATRANSFER, + CONTROLLER_DMA3TRANSFER, CONTROLLER_31, CONTROLLER_32, CONTROLLER_33, @@ -92,11 +92,11 @@ enum CONTROLLER_HITANIMATION, CONTROLLER_42, CONTROLLER_EFFECTIVENESSSOUND, - CONTROLLER_44, + CONTROLLER_PLAYFANFAREORBGM, CONTROLLER_FAINTINGCRY, CONTROLLER_INTROSLIDE, - CONTROLLER_TRAINERBALLTHROW, - CONTROLLER_48, + CONTROLLER_INTROTRAINERBALLTHROW, + CONTROLLER_DRAWPARTYSTATUSSUMMARY, CONTROLLER_49, CONTROLLER_50, CONTROLLER_SPRITEINVISIBILITY, @@ -114,6 +114,7 @@ void HandleLinkBattleSetup(void); void SetUpBattleVarsAndBirchZigzagoon(void); void sub_8032768(void); void sub_8033648(void); +void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data); // emitters void EmitGetMonData(u8 bufferId, u8 arg1, u8 arg2); @@ -122,7 +123,7 @@ void EmitSetMonData(u8 bufferId, u8 request, u8 c, u8 bytes, void *data); void EmitSetRawMonData(u8 bufferId, u8 monId, u8 bytes, void *data); // unused void EmitLoadMonSprite(u8 bufferId); void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit); -void EmitReturnPokeToBall(u8 bufferId, u8 arg1); +void EmitReturnMonToBall(u8 bufferId, u8 arg1); void EmitDrawTrainerPic(u8 bufferId); void EmitTrainerSlide(u8 bufferId); void EmitTrainerSlideBack(u8 bufferId); @@ -135,33 +136,43 @@ void EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 void EmitPrintString(u8 bufferId, u16 stringId); void EmitPrintStringPlayerOnly(u8 bufferId, u16 stringId); void EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2); - - -void EmitHealthBarUpdate(u8 bufferId, u16 hpValue); -void EmitEffectivenessSound(u8 bufferId, u16 songId); -void EmitPlaySound(u8 bufferId, u16 songId, u8 arg2); -void Emit_x2A(u8 bufferId); -void EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints); -void EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument); -void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible); +void EmitCmd19(u8 bufferId); +void EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData); +void EmitOpenBag(u8 bufferId, u8* arg1); void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4); -void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2); -void EmitFaintingCry(u8 bufferId); -void Emit_x37(u8 bufferId, u8 arg1); -void EmitHitAnimation(u8 bufferId); -void EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2); -void EmitCmd49(u8 bufferId); -void EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status); -void EmitCmd13(u8 bufferId); +void EmitCmd23(u8 bufferId); // unused +void EmitHealthBarUpdate(u8 bufferId, u16 hpValue); +void EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints); void EmitStatusIconUpdate(u8 bufferId, u32 status1, u32 status2); +void EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status); +void EmitStatusXor(u8 bufferId, u8 b); // unused +void EmitDataTransfer(u8 bufferId, u16 size, void *data); +void EmitDMA3Transfer(u8 bufferId, void *dst, u16 size, void *data); // unused +void EmitPlayBGM(u8 bufferId, u16 songId, void *unusedDumbDataParameter); // unused +void EmitCmd32(u8 bufferId, u16 size, void *c); // unused +void EmitCmd33(u8 bufferId, u8 arg1, u16 arg2); +void EmitCmd34(u8 bufferId, u8 b, u8 *c); +void EmitCmd35(u8 bufferId, u16 b); +void EmitCmd36(u8 bufferId, u16 b); +void EmitCmd37(u8 bufferId); +void EmitCmd38(u8 bufferId, u8 b); +void EmitCmd39(u8 bufferId); +void EmitCmd40(u8 bufferId); +void EmitHitAnimation(u8 bufferId); +void EmitCmd42(u8 bufferId); +void EmitEffectivenessSound(u8 bufferId, u16 songId); +void EmitPlayFanfareOrBGM(u8 bufferId, u16 songId, bool8 playBGM); +void EmitFaintingCry(u8 bufferId); void EmitIntroSlide(u8 bufferId, u8 terrainId); void EmitIntroTrainerBallThrow(u8 bufferId); -void EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct* movePpData); -void EmitOpenBag(u8 bufferId, u8* arg1); -void Emit_x32(u8 bufferId); - +void EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2); +void EmitCmd49(u8 bufferId); +void EmitCmd50(u8 bufferId); +void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible); +void EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument); +void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2); void EmitResetActionMoveSelection(u8 bufferId, u8 caseId); -void EmitCmd_x21(u8 bufferId, u8 arg1, u16 arg2); +void EmitCmd55(u8 bufferId, u8 arg1); // player controller void SetBankFuncToPlayerBufferRunCommand(void); diff --git a/include/link.h b/include/link.h index 7965a4b1d..b8835ce04 100644 --- a/include/link.h +++ b/include/link.h @@ -185,7 +185,6 @@ bool8 sub_800A520(void); bool8 sub_8010500(void); void sub_800DFB4(u8, u8); void sub_800ADF8(void); -u8 GetLinkPlayerCount(void); void sub_800B488(void); void sub_8009734(void); void sub_800A620(void); diff --git a/include/recorded_battle.h b/include/recorded_battle.h index 2d8135e41..6b80e220f 100644 --- a/include/recorded_battle.h +++ b/include/recorded_battle.h @@ -17,5 +17,6 @@ void sub_818603C(u8); void sub_8185FD0(void); void sub_8186444(void); void sub_8185EB8(void); +u8 sub_81850DC(u8 *arg0); #endif // GUARD_RECORDED_BATTLE_H diff --git a/ld_script.txt b/ld_script.txt index 5a9dace28..029068874 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -55,7 +55,6 @@ SECTIONS { 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); src/battle_2.o(.text); diff --git a/src/battle_2.c b/src/battle_2.c index 7db3fd38e..16c07114a 100644 --- a/src/battle_2.c +++ b/src/battle_2.c @@ -4080,7 +4080,7 @@ static void HandleTurnActionSelectionState(void) if (gBattleMons[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].status2 & STATUS2_MULTIPLETURNS || gBattleMons[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].status2 & STATUS2_RECHARGE) { - Emit_x32(0); + EmitCmd50(0); MarkBufferBankForExecution(gActiveBank); return; } @@ -4108,7 +4108,7 @@ static void HandleTurnActionSelectionState(void) { RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 3); } - Emit_x32(0); + EmitCmd50(0); MarkBufferBankForExecution(gActiveBank); return; } diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 661759a98..d86be6fad 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -39,7 +39,7 @@ static bool8 ShouldSwitchIfPerishSong(void) && gDisableStructs[gActiveBank].perishSong1 == 0) { *(gBattleStruct->field_294 + gActiveBank) = 6; - EmitCmd_x21(1, 2, 0); + EmitCmd33(1, 2, 0); return TRUE; } @@ -121,7 +121,7 @@ static bool8 ShouldSwitchIfWonderGuard(void) { // we found a mon *(gBattleStruct->field_294 + gActiveBank) = i; - EmitCmd_x21(1, 2, 0); + EmitCmd33(1, 2, 0); return TRUE; } } @@ -221,7 +221,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) { // we found a mon *(gBattleStruct->field_294 + gActiveBank) = i; - EmitCmd_x21(1, 2, 0); + EmitCmd33(1, 2, 0); return TRUE; } } @@ -241,13 +241,13 @@ static bool8 ShouldSwitchIfNaturalCure(void) if ((gUnknown_02024250[gActiveBank] == 0 || gUnknown_02024250[gActiveBank] == 0xFFFF) && Random() & 1) { *(gBattleStruct->field_294 + gActiveBank) = 6; - EmitCmd_x21(1, 2, 0); + EmitCmd33(1, 2, 0); return TRUE; } else if (gBattleMoves[gUnknown_02024250[gActiveBank]].power == 0 && Random() & 1) { *(gBattleStruct->field_294 + gActiveBank) = 6; - EmitCmd_x21(1, 2, 0); + EmitCmd33(1, 2, 0); return TRUE; } @@ -258,7 +258,7 @@ static bool8 ShouldSwitchIfNaturalCure(void) if (Random() & 1) { *(gBattleStruct->field_294 + gActiveBank) = 6; - EmitCmd_x21(1, 2, 0); + EmitCmd33(1, 2, 0); return TRUE; } @@ -426,7 +426,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) if (moveFlags & MOVESTATUS_SUPEREFFECTIVE && Random() % moduloPercent == 0) { *(gBattleStruct->field_294 + gActiveBank) = i; - EmitCmd_x21(1, 2, 0); + EmitCmd33(1, 2, 0); return TRUE; } } @@ -611,7 +611,7 @@ void AI_TrySwitchOrUseItem(void) } } - EmitCmd_x21(1, 0, (gActiveBank ^ BIT_SIDE) << 8); + EmitCmd33(1, 0, (gActiveBank ^ BIT_SIDE) << 8); } #define TYPE_FORESIGHT 0xFE @@ -940,7 +940,7 @@ static bool8 ShouldUseItem(void) if (shouldUse) { - EmitCmd_x21(1, 1, 0); + EmitCmd33(1, 1, 0); *(gBattleStruct->field_C0 + (gActiveBank / 2) * 2) = item; gBattleResources->battleHistory->trainerItems[i] = 0; return shouldUse; diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 58a595730..9ac18c72f 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -36,6 +36,13 @@ extern u8 gBankTarget; extern u8 gAbsentBankFlags; extern u8 gEffectBank; extern u16 gBattleWeather; +extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern u16 gCurrentMove; +extern u16 gLastUsedMove; +extern u16 gLastUsedItem; +extern u8 gBattleOutcome; +extern u8 gLastUsedAbility; +extern u8 gStringBank; extern const struct BattleMove gBattleMoves[]; @@ -43,11 +50,10 @@ 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 CreateTasksForSendRecvLinkBuffers(void); static void SetControllersVariablesInLinkBattle(void); static void SetControllersVariables(void); -static void sub_8033050(void); -void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data); +static void SetBattlePartyIds(void); static void Task_HandleSendLinkBuffersData(u8 taskId); static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId); @@ -60,7 +66,7 @@ void HandleLinkBattleSetup(void) if (!gReceivedRemoteLinkPlayers) sub_8009734(); CreateTask(task00_08081A90, 0); - sub_8033244(); + CreateTasksForSendRecvLinkBuffers(); } } @@ -114,7 +120,7 @@ void sub_8032768(void) else SetControllersVariables(); - sub_8033050(); + SetBattlePartyIds(); if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { @@ -602,7 +608,7 @@ static void SetControllersVariablesInLinkBattle(void) } } -static void sub_8033050(void) +static void SetBattlePartyIds(void) { s32 i, j; @@ -672,7 +678,7 @@ static void sub_8033050(void) } } -void PrepareBufferDataTransfer(u8 bufferId, u8 *data, u16 size) +static void PrepareBufferDataTransfer(u8 bufferId, u8 *data, u16 size) { s32 i; @@ -702,7 +708,7 @@ void PrepareBufferDataTransfer(u8 bufferId, u8 *data, u16 size) } } -static void sub_8033244(void) +static void CreateTasksForSendRecvLinkBuffers(void) { gUnknown_02022D08 = CreateTask(Task_HandleSendLinkBuffersData, 0); gTasks[gUnknown_02022D08].data[11] = 0; @@ -993,10 +999,9 @@ void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit) PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); } -// TODO: change Poke to Mon to be consistent -void EmitReturnPokeToBall(u8 bufferId, u8 arg1) +void EmitReturnMonToBall(u8 bufferId, u8 arg1) { - gBattleBuffersTransferData[0] = CONTROLLER_RETURNPOKETOBALL; + gBattleBuffersTransferData[0] = CONTROLLER_RETURNMONTOBALL; gBattleBuffersTransferData[1] = arg1; PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 2); } @@ -1103,14 +1108,6 @@ void EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 16 + sizeof(struct DisableStruct)); } -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; -extern u16 gCurrentMove; -extern u16 gLastUsedMove; -extern u16 gLastUsedItem; -extern u8 gBattleOutcome; -extern u8 gLastUsedAbility; -extern u8 gStringBank; - void EmitPrintString(u8 bufferId, u16 stringID) { s32 i; @@ -1180,3 +1177,375 @@ void EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2) gBattleBuffersTransferData[3] = (arg2 & 0xFF00) >> 8; PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); } + +void EmitCmd19(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_19; + gBattleBuffersTransferData[1] = 19; + gBattleBuffersTransferData[2] = 19; + gBattleBuffersTransferData[3] = 19; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData) +{ + s32 i; + + gBattleBuffersTransferData[0] = CONTROLLER_CHOOSEMOVE; + gBattleBuffersTransferData[1] = isDoubleBattle; + gBattleBuffersTransferData[2] = NoPpNumber; + gBattleBuffersTransferData[3] = 0; + for (i = 0; i < sizeof(*movePpData); i++) + gBattleBuffersTransferData[4 + i] = *((u8*)(movePpData) + i); + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, sizeof(*movePpData) + 4); +} + +void EmitOpenBag(u8 bufferId, u8 *arg1) +{ + s32 i; + + gBattleBuffersTransferData[0] = CONTROLLER_OPENBAG; + for (i = 0; i < 3; i++) + gBattleBuffersTransferData[1 + i] = arg1[i]; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4) +{ + s32 i; + + gBattleBuffersTransferData[0] = CONTROLLER_CHOOSEPOKEMON; + gBattleBuffersTransferData[1] = caseId; + gBattleBuffersTransferData[2] = arg2; + gBattleBuffersTransferData[3] = abilityId; + for (i = 0; i < 3; i++) + gBattleBuffersTransferData[4 + i] = arg4[i]; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 8); // but only 7 bytes were written +} + +void EmitCmd23(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_23; + gBattleBuffersTransferData[1] = 23; + gBattleBuffersTransferData[2] = 23; + gBattleBuffersTransferData[3] = 23; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +// why is the argument u16 if it's being cast to s16 anyway? +void EmitHealthBarUpdate(u8 bufferId, u16 hpValue) +{ + gBattleBuffersTransferData[0] = CONTROLLER_HEALTHBARUPDATE; + gBattleBuffersTransferData[1] = 0; + gBattleBuffersTransferData[2] = (s16)hpValue; + gBattleBuffersTransferData[3] = ((s16)hpValue & 0xFF00) >> 8; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +// why is the argument u16 if it's being cast to s16 anyway? +void EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints) +{ + gBattleBuffersTransferData[0] = CONTROLLER_EXPUPDATE; + gBattleBuffersTransferData[1] = partyId; + gBattleBuffersTransferData[2] = (s16)expPoints; + gBattleBuffersTransferData[3] = ((s16)expPoints & 0xFF00) >> 8; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitStatusIconUpdate(u8 bufferId, u32 status1, u32 status2) +{ + gBattleBuffersTransferData[0] = CONTROLLER_STATUSICONUPDATE; + gBattleBuffersTransferData[1] = status1; + gBattleBuffersTransferData[2] = (status1 & 0x0000FF00) >> 8; + gBattleBuffersTransferData[3] = (status1 & 0x00FF0000) >> 16; + gBattleBuffersTransferData[4] = (status1 & 0xFF000000) >> 24; + gBattleBuffersTransferData[5] = status2; + gBattleBuffersTransferData[6] = (status2 & 0x0000FF00) >> 8; + gBattleBuffersTransferData[7] = (status2 & 0x00FF0000) >> 16; + gBattleBuffersTransferData[8] = (status2 & 0xFF000000) >> 24; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 9); +} + +void EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status) +{ + gBattleBuffersTransferData[0] = CONTROLLER_STATUSANIMATION; + gBattleBuffersTransferData[1] = status2; + gBattleBuffersTransferData[2] = status; + gBattleBuffersTransferData[3] = (status & 0x0000FF00) >> 8; + gBattleBuffersTransferData[4] = (status & 0x00FF0000) >> 16; + gBattleBuffersTransferData[5] = (status & 0xFF000000) >> 24; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 6); +} + +void EmitStatusXor(u8 bufferId, u8 b) +{ + gBattleBuffersTransferData[0] = CONTROLLER_STATUSXOR; + gBattleBuffersTransferData[1] = b; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 2); +} + +void EmitDataTransfer(u8 bufferId, u16 size, void *data) +{ + s32 i; + + gBattleBuffersTransferData[0] = CONTROLLER_DATATRANSFER; + gBattleBuffersTransferData[1] = 29; + gBattleBuffersTransferData[2] = size; + gBattleBuffersTransferData[3] = (size & 0xFF00) >> 8; + for (i = 0; i < size; i++) + gBattleBuffersTransferData[4 + i] = *(u8*)(data++); + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, size + 4); +} + +void EmitDMA3Transfer(u8 bufferId, void *dst, u16 size, void *data) +{ + s32 i; + + gBattleBuffersTransferData[0] = CONTROLLER_DMA3TRANSFER; + gBattleBuffersTransferData[1] = (u32)(dst); + gBattleBuffersTransferData[2] = ((u32)(dst) & 0x0000FF00) >> 8; + gBattleBuffersTransferData[3] = ((u32)(dst) & 0x00FF0000) >> 16; + gBattleBuffersTransferData[4] = ((u32)(dst) & 0xFF000000) >> 24; + gBattleBuffersTransferData[5] = size; + gBattleBuffersTransferData[6] = (size & 0xFF00) >> 8; + for (i = 0; i < size; i++) + gBattleBuffersTransferData[7 + i] = *(u8*)(data++); + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, size + 7); +} + +void EmitPlayBGM(u8 bufferId, u16 songId, void *unusedDumbDataParameter) +{ + s32 i; + + gBattleBuffersTransferData[0] = CONTROLLER_31; + gBattleBuffersTransferData[1] = songId; + gBattleBuffersTransferData[2] = (songId & 0xFF00) >> 8; + for (i = 0; i < songId; i++) // ???? + gBattleBuffersTransferData[3 + i] = *(u8*)(unusedDumbDataParameter++); + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, songId + 3); +} + +void EmitCmd32(u8 bufferId, u16 size, void *data) +{ + s32 i; + + gBattleBuffersTransferData[0] = CONTROLLER_32; + gBattleBuffersTransferData[1] = size; + gBattleBuffersTransferData[2] = (size & 0xFF00) >> 8; + for (i = 0; i < size; i++) + gBattleBuffersTransferData[3 + i] = *(u8*)(data++); + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, size + 3); +} + +void EmitCmd33(u8 bufferId, u8 arg1, u16 arg2) +{ + gBattleBuffersTransferData[0] = CONTROLLER_33; + gBattleBuffersTransferData[1] = arg1; + gBattleBuffersTransferData[2] = arg2; + gBattleBuffersTransferData[3] = (arg2 & 0xFF00) >> 8; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitCmd34(u8 bufferId, u8 b, u8 *c) +{ + s32 i; + + gBattleBuffersTransferData[0] = CONTROLLER_34; + gBattleBuffersTransferData[1] = b; + for (i = 0; i < 3; i++) + gBattleBuffersTransferData[2 + i] = c[i]; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 5); +} + +void EmitCmd35(u8 bufferId, u16 b) +{ + gBattleBuffersTransferData[0] = CONTROLLER_35; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = (b & 0xFF00) >> 8; + gBattleBuffersTransferData[3] = 0; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitCmd36(u8 bufferId, u16 b) +{ + gBattleBuffersTransferData[0] = CONTROLLER_36; + gBattleBuffersTransferData[1] = b; + gBattleBuffersTransferData[2] = (b & 0xFF00) >> 8; + gBattleBuffersTransferData[3] = 0; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitCmd37(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_37; + gBattleBuffersTransferData[1] = 37; + gBattleBuffersTransferData[2] = 37; + gBattleBuffersTransferData[3] = 37; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitCmd38(u8 bufferId, u8 b) +{ + gBattleBuffersTransferData[0] = CONTROLLER_38; + gBattleBuffersTransferData[1] = b; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 2); +} + +void EmitCmd39(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_39; + gBattleBuffersTransferData[1] = 39; + gBattleBuffersTransferData[2] = 39; + gBattleBuffersTransferData[3] = 39; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitCmd40(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_40; + gBattleBuffersTransferData[1] = 40; + gBattleBuffersTransferData[2] = 40; + gBattleBuffersTransferData[3] = 40; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitHitAnimation(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_HITANIMATION; + gBattleBuffersTransferData[1] = 41; + gBattleBuffersTransferData[2] = 41; + gBattleBuffersTransferData[3] = 41; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitCmd42(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_42; + gBattleBuffersTransferData[1] = 42; + gBattleBuffersTransferData[2] = 42; + gBattleBuffersTransferData[3] = 42; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitEffectivenessSound(u8 bufferId, u16 songId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_EFFECTIVENESSSOUND; + gBattleBuffersTransferData[1] = songId; + gBattleBuffersTransferData[2] = (songId & 0xFF00) >> 8; + gBattleBuffersTransferData[3] = 0; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitPlayFanfareOrBGM(u8 bufferId, u16 songId, bool8 playBGM) +{ + gBattleBuffersTransferData[0] = CONTROLLER_PLAYFANFAREORBGM; + gBattleBuffersTransferData[1] = songId; + gBattleBuffersTransferData[2] = (songId & 0xFF00) >> 8; + gBattleBuffersTransferData[3] = playBGM; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitFaintingCry(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_FAINTINGCRY; + gBattleBuffersTransferData[1] = 45; + gBattleBuffersTransferData[2] = 45; + gBattleBuffersTransferData[3] = 45; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitIntroSlide(u8 bufferId, u8 terrainId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_INTROSLIDE; + gBattleBuffersTransferData[1] = terrainId; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 2); +} + +void EmitIntroTrainerBallThrow(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_INTROTRAINERBALLTHROW; + gBattleBuffersTransferData[1] = 47; + gBattleBuffersTransferData[2] = 47; + gBattleBuffersTransferData[3] = 47; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2) +{ + s32 i; + + gBattleBuffersTransferData[0] = CONTROLLER_DRAWPARTYSTATUSSUMMARY; + gBattleBuffersTransferData[1] = arg2 & 0x7F; + gBattleBuffersTransferData[2] = (arg2 & 0x80) >> 7; + gBattleBuffersTransferData[3] = 48; + for (i = 0; i < (s32)(sizeof(struct HpAndStatus) * 6); i++) + gBattleBuffersTransferData[4 + i] = *(i + (u8*)(hpAndStatus)); + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, sizeof(struct HpAndStatus) * 6 + 4); +} + +void EmitCmd49(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_49; + gBattleBuffersTransferData[1] = 49; + gBattleBuffersTransferData[2] = 49; + gBattleBuffersTransferData[3] = 49; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitCmd50(u8 bufferId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_50; + gBattleBuffersTransferData[1] = 50; + gBattleBuffersTransferData[2] = 50; + gBattleBuffersTransferData[3] = 50; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible) +{ + gBattleBuffersTransferData[0] = CONTROLLER_SPRITEINVISIBILITY; + gBattleBuffersTransferData[1] = isInvisible; + gBattleBuffersTransferData[2] = 51; + gBattleBuffersTransferData[3] = 51; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument) +{ + gBattleBuffersTransferData[0] = CONTROLLER_BATTLEANIMATION; + gBattleBuffersTransferData[1] = animationId; + gBattleBuffersTransferData[2] = argument; + gBattleBuffersTransferData[3] = (argument & 0xFF00) >> 8; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 4); +} + +void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2) +{ + bool8 arg2_ = arg2; + gBattleBuffersTransferData[0] = CONTROLLER_LINKSTANDBYMSG; + gBattleBuffersTransferData[1] = arg1; + + if (arg2_) + gBattleBuffersTransferData[3] = gBattleBuffersTransferData[2] = sub_81850DC(&gBattleBuffersTransferData[4]); + else + gBattleBuffersTransferData[3] = gBattleBuffersTransferData[2] = 0; + + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, gBattleBuffersTransferData[2] + 4); +} + +void EmitResetActionMoveSelection(u8 bufferId, u8 caseId) +{ + gBattleBuffersTransferData[0] = CONTROLLER_RESETACTIONMOVESELECTION; + gBattleBuffersTransferData[1] = caseId; + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, 2); +} + +void EmitCmd55(u8 bufferId, u8 arg1) +{ + gBattleBuffersTransferData[0] = CONTROLLER_55; + gBattleBuffersTransferData[1] = arg1; + gBattleBuffersTransferData[2] = gSaveBlock2Ptr->field_CA9_b; + gBattleBuffersTransferData[3] = gSaveBlock2Ptr->field_CA9_b; + gBattleBuffersTransferData[5] = gBattleBuffersTransferData[4] = sub_81850DC(&gBattleBuffersTransferData[6]); + PrepareBufferDataTransfer(bufferId, gBattleBuffersTransferData, gBattleBuffersTransferData[4] + 6); +} diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index fb6a8272b..a1e5767ad 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -349,7 +349,7 @@ static void atk51_switch_handle_order(void); static void atk52_switch_in_effects(void); static void atk53_trainer_slide(void); static void atk54_effectiveness_sound(void); -static void atk55_play_sound(void); +static void atk55_play_fanfare(void); static void atk56_fainting_cry(void); static void atk57(void); static void atk58_return_to_ball(void); @@ -601,7 +601,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk52_switch_in_effects, atk53_trainer_slide, atk54_effectiveness_sound, - atk55_play_sound, + atk55_play_fanfare, atk56_fainting_cry, atk57, atk58_return_to_ball, @@ -5308,7 +5308,7 @@ static void atk4B_return_atk_to_ball(void) gActiveBank = gBankAttacker; if (!(gHitMarker & HITMARKER_FAINTED(gActiveBank))) { - EmitReturnPokeToBall(0, 0); + EmitReturnMonToBall(0, 0); MarkBufferBankForExecution(gActiveBank); } gBattlescriptCurrInstr++; @@ -5627,7 +5627,7 @@ static void atk50_openpartyscreen(void) { gAbsentBankFlags |= gBitTable[gActiveBank]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); - Emit_x2A(0); + EmitCmd42(0); MarkBufferBankForExecution(gActiveBank); } else if (!gSpecialStatuses[gActiveBank].flag40) @@ -5649,7 +5649,7 @@ static void atk50_openpartyscreen(void) { gAbsentBankFlags |= gBitTable[gActiveBank]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); - Emit_x2A(0); + EmitCmd42(0); MarkBufferBankForExecution(gActiveBank); } else if (!gSpecialStatuses[gActiveBank].flag40) @@ -5670,7 +5670,7 @@ static void atk50_openpartyscreen(void) { gAbsentBankFlags |= gBitTable[gActiveBank]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); - Emit_x2A(0); + EmitCmd42(0); MarkBufferBankForExecution(gActiveBank); } else if (!gSpecialStatuses[gActiveBank].flag40) @@ -5692,7 +5692,7 @@ static void atk50_openpartyscreen(void) { gAbsentBankFlags |= gBitTable[gActiveBank]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); - Emit_x2A(0); + EmitCmd42(0); MarkBufferBankForExecution(gActiveBank); } else if (!gSpecialStatuses[gActiveBank].flag40) @@ -5755,7 +5755,7 @@ static void atk50_openpartyscreen(void) { gAbsentBankFlags |= gBitTable[gActiveBank]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); - Emit_x2A(0); + EmitCmd42(0); MarkBufferBankForExecution(gActiveBank); } else if (!gSpecialStatuses[gActiveBank].flag40) @@ -5771,7 +5771,7 @@ static void atk50_openpartyscreen(void) { gAbsentBankFlags |= gBitTable[gActiveBank]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); - Emit_x2A(0); + EmitCmd42(0); MarkBufferBankForExecution(gActiveBank); } else if (!gSpecialStatuses[gActiveBank].flag40) @@ -6031,10 +6031,10 @@ static void atk54_effectiveness_sound(void) gBattlescriptCurrInstr += 3; } -static void atk55_play_sound(void) +static void atk55_play_fanfare(void) { gActiveBank = gBankAttacker; - EmitPlaySound(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1), 0); + EmitPlayFanfareOrBGM(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1), FALSE); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 3; @@ -6052,7 +6052,7 @@ static void atk56_fainting_cry(void) static void atk57(void) { gActiveBank = GetBankByIdentity(0); - Emit_x37(0, gBattleOutcome); + EmitCmd55(0, gBattleOutcome); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 1; @@ -6061,7 +6061,7 @@ static void atk57(void) static void atk58_return_to_ball(void) { gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - EmitReturnPokeToBall(0, 1); + EmitReturnMonToBall(0, 1); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 2; @@ -7137,7 +7137,7 @@ static void atk76_various(void) gDisableStructs[1].truantUnknownBit = 1; break; case 13: - EmitCmd13(0); + EmitCmd19(0); MarkBufferBankForExecution(gActiveBank); break; case 14: @@ -7162,7 +7162,7 @@ static void atk76_various(void) gActiveBank = 1; if (gBattleMons[gActiveBank].hp != 0) { - EmitReturnPokeToBall(0, 0); + EmitReturnMonToBall(0, 0); MarkBufferBankForExecution(gActiveBank); } break; @@ -7172,7 +7172,7 @@ static void atk76_various(void) gActiveBank = 3; if (gBattleMons[gActiveBank].hp != 0) { - EmitReturnPokeToBall(0, 0); + EmitReturnMonToBall(0, 0); MarkBufferBankForExecution(gActiveBank); } } @@ -7197,7 +7197,7 @@ static void atk76_various(void) gBattleOutcome = BATTLE_OPPONENT_TELEPORTED; break; case VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC: - EmitPlaySound(0, BGM_KACHI1, 1); + EmitPlayFanfareOrBGM(0, BGM_KACHI1, TRUE); MarkBufferBankForExecution(gActiveBank); break; }