From 35c69388140243c391b925fd8b9012d2d1703810 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Sat, 13 Oct 2018 12:41:10 -0500 Subject: [PATCH] Port/decompile cable_club.s --- asm/battle_frontier_2.s | 4 +- asm/battle_tower.s | 2 +- asm/cable_club.s | 2487 ----------------- asm/script_pokemon_util_80F87D8.s | 6 +- asm/trainer_card.s | 12 +- data/cable_club.s | 16 - .../scripts.inc | 2 +- .../MossdeepCity_SpaceCenter_2F/scripts.inc | 2 +- .../scripts.inc | 2 +- data/scripts/cable_club.inc | 14 +- data/specials.inc | 2 +- include/cable_club.h | 1 + include/field_message_box.h | 10 + include/field_specials.h | 1 + include/link.h | 8 + include/menu.h | 1 + include/overworld.h | 3 + include/rom_8011DC0.h | 2 + include/script_pokemon_util_80F87D8.h | 1 + include/strings.h | 8 + include/trainer_card.h | 9 +- ld_script.txt | 3 +- src/battle_controllers.c | 2 +- src/battle_dome.c | 4 +- src/cable_club.c | 1190 +++++++- src/field_message_box.c | 2 +- src/mystery_event_menu.c | 2 +- src/rom_8011DC0.c | 4 +- src/start_menu.c | 4 +- 29 files changed, 1250 insertions(+), 2554 deletions(-) delete mode 100644 asm/cable_club.s delete mode 100644 data/cable_club.s diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index 4df690e59..72be464fd 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -4152,7 +4152,7 @@ _081A1AEA: cmp r3, r0 blt _081A1AEA _081A1B00: - bl sub_80F94E8 + bl ReducePlayerPartyToThree pop {r4-r7} pop {r0} bx r0 @@ -17008,7 +17008,7 @@ _081A87EC: ldrh r1, [r0] movs r0, 0x64 muls r0, r1 - ldr r1, =gBattleScripting + 0x14 + ldr r1, =gPlayerParty - 100 adds r0, r1 ldr r1, =0x00000e12 adds r3, r1 diff --git a/asm/battle_tower.s b/asm/battle_tower.s index 2312b63bd..654083aea 100644 --- a/asm/battle_tower.s +++ b/asm/battle_tower.s @@ -3475,7 +3475,7 @@ _08163FCC: adds r1, r0, 0 movs r0, 0x64 muls r0, r1 - ldr r1, =gBattleScripting + 0x14 + ldr r1, =gPlayerParty - 100 adds r0, r1 movs r1, 0x2C muls r1, r4 diff --git a/asm/cable_club.s b/asm/cable_club.s deleted file mode 100644 index 692ee3b81..000000000 --- a/asm/cable_club.s +++ /dev/null @@ -1,2487 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_80B2634 -sub_80B2634: @ 80B2634 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r4, r1, r0 - movs r3, 0 - ldrsh r2, [r4, r3] - cmp r2, 0 - bne _080B266C - bl OpenLinkTimed - bl sub_800AB98 - bl ResetLinkPlayers - ldr r0, =gUnknown_08550594 - bl AddWindow - strh r0, [r4, 0xA] - b _080B2678 - .pool -_080B266C: - cmp r2, 0x9 - ble _080B2678 - subs r0, 0x8 - adds r0, r1, r0 - ldr r1, =sub_80B2688 - str r1, [r0] -_080B2678: - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2634 - - thumb_func_start sub_80B2688 -sub_80B2688: @ 80B2688 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl GetLinkPlayerCount_2 - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r4, 0 - bl sub_80B252C - cmp r0, 0x1 - beq _080B26FC - adds r0, r4, 0 - bl sub_80B2578 - cmp r0, 0x1 - beq _080B26FC - cmp r5, 0x1 - bls _080B26FC - movs r0, 0x1 - bl SetSuppressLinkErrorMessage - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r4, r0, r1 - movs r0, 0 - strh r0, [r4, 0xE] - bl IsLinkMaster - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B26EC - movs r0, 0x15 - bl PlaySE - ldr r0, =OldaleTown_PokemonCenter_2F_Text_2780B3 - bl ShowFieldAutoScrollMessage - ldr r0, =sub_80B270C - b _080B26FA - .pool -_080B26EC: - movs r0, 0x16 - bl PlaySE - ldr r0, =OldaleTown_PokemonCenter_2F_Text_278131 - bl ShowFieldAutoScrollMessage - ldr r0, =sub_80B2918 -_080B26FA: - str r0, [r4] -_080B26FC: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2688 - - thumb_func_start sub_80B270C -sub_80B270C: @ 80B270C - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl sub_80B252C - cmp r0, 0x1 - beq _080B274C - adds r0, r4, 0 - bl sub_80B25CC - cmp r0, 0x1 - beq _080B274C - adds r0, r4, 0 - bl sub_80B24F8 - cmp r0, 0x1 - beq _080B274C - bl textbox_any_visible - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0 - bne _080B274C - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - strh r2, [r1, 0xE] - ldr r0, =sub_80B275C - str r0, [r1] -_080B274C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B270C - - thumb_func_start sub_80B275C -sub_80B275C: @ 80B275C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - mov r8, r0 - ldr r0, =gTasks + 0x8 - mov r9, r0 - mov r7, r8 - add r7, r9 - bl GetLinkPlayerCount_2 - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r4, 0 - bl sub_80B252C - cmp r0, 0x1 - beq _080B27E4 - adds r0, r4, 0 - bl sub_80B25CC - cmp r0, 0x1 - beq _080B27E4 - adds r0, r4, 0 - bl sub_80B24F8 - cmp r0, 0x1 - beq _080B27E4 - adds r6, r5, 0 - adds r0, r4, 0 - adds r1, r6, 0 - bl sub_80B243C - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080B27E4 - movs r1, 0x2 - ldrsh r0, [r7, r1] - cmp r5, r0 - blt _080B27E4 - adds r0, r6, 0 - bl sub_800AA04 - ldrh r0, [r7, 0xA] - bl sub_80B241C - ldr r0, =gStringVar1 - adds r1, r5, 0 - movs r2, 0 - movs r3, 0x1 - bl ConvertIntToDecimalStringN - ldr r0, =OldaleTown_PokemonCenter_2F_Text_2780F2 - bl ShowFieldAutoScrollMessage - mov r0, r9 - subs r0, 0x8 - add r0, r8 - ldr r1, =sub_80B2804 - str r1, [r0] -_080B27E4: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B275C - - thumb_func_start sub_80B2804 -sub_80B2804: @ 80B2804 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - adds r6, r5, 0 - adds r0, r5, 0 - bl sub_80B252C - cmp r0, 0x1 - beq _080B2898 - adds r0, r5, 0 - bl sub_80B25CC - cmp r0, 0x1 - beq _080B2898 - adds r0, r5, 0 - bl sub_80B24F8 - cmp r0, 0x1 - beq _080B2898 - bl textbox_any_visible - lsls r0, 24 - cmp r0, 0 - bne _080B2898 - bl sub_800AA48 - adds r4, r0, 0 - bl GetLinkPlayerCount_2 - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bne _080B2852 - ldr r0, =gMain - ldrh r1, [r0, 0x2C] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080B2878 -_080B2852: - ldr r0, =OldaleTown_PokemonCenter_2F_Text_2780B3 - bl ShowFieldAutoScrollMessage - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_80B270C - str r1, [r0] - b _080B2898 - .pool -_080B2878: - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080B2898 - movs r0, 0x5 - bl PlaySE - bl sub_800A620 - ldr r0, =gTasks - lsls r1, r6, 2 - adds r1, r6 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_80B28A8 - str r0, [r1] -_080B2898: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2804 - - thumb_func_start sub_80B28A8 -sub_80B28A8: @ 80B28A8 - 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 r5, r0, r1 - ldrb r7, [r5, 0xA] - ldrb r6, [r5, 0xC] - adds r0, r4, 0 - bl sub_80B24F8 - cmp r0, 0x1 - beq _080B290A - adds r0, r4, 0 - bl sub_80B2D6C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080B290A - bl GetLinkPlayerCount_2 - adds r4, r0, 0 - bl sub_800AA48 - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - beq _080B28F4 - ldr r0, =sub_80B2D2C - b _080B2908 - .pool -_080B28F4: - ldr r4, =gSpecialVar_Result - adds r0, r7, 0 - adds r1, r6, 0 - bl sub_80B2478 - strh r0, [r4] - lsls r0, 16 - cmp r0, 0 - beq _080B290A - ldr r0, =sub_80B2A08 -_080B2908: - str r0, [r5] -_080B290A: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B28A8 - - thumb_func_start sub_80B2918 -sub_80B2918: @ 80B2918 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r7, r0, r1 - ldrb r6, [r7, 0xA] - ldrb r5, [r7, 0xC] - adds r0, r4, 0 - bl sub_80B252C - cmp r0, 0x1 - beq _080B29E6 - adds r0, r4, 0 - bl sub_80B24F8 - cmp r0, 0x1 - beq _080B29E6 - ldr r4, =gSpecialVar_Result - adds r0, r6, 0 - adds r1, r5, 0 - bl sub_80B2478 - adds r1, r0, 0 - strh r1, [r4] - lsls r0, r1, 16 - lsrs r2, r0, 16 - cmp r2, 0 - beq _080B29E6 - subs r0, r1, 0x3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bhi _080B297C - bl sub_800AC34 - bl HideFieldMessageBox - ldr r0, =sub_80B2CB0 - b _080B29E4 - .pool -_080B297C: - cmp r2, 0x7 - beq _080B2984 - cmp r2, 0x9 - bne _080B2994 -_080B2984: - bl CloseLink - bl HideFieldMessageBox - ldr r0, =sub_80B2CB0 - b _080B29E4 - .pool -_080B2994: - bl GetLinkPlayerCount_2 - ldr r4, =gFieldLinkPlayerCount - strb r0, [r4] - bl GetMultiplayerId - ldr r1, =gUnknown_03005DB4 - strb r0, [r1] - ldrb r0, [r4] - bl sub_800AA04 - ldr r4, =gBlockSendBuffer - adds r0, r4, 0 - bl sub_80C30A4 - ldr r0, =gUnknown_0203CEF8 - mov r8, r0 - ldrb r0, [r0] - movs r6, 0x64 - muls r0, r6 - ldr r5, =gBattleScripting + 0x14 - adds r0, r5 - movs r1, 0xB - movs r2, 0 - bl GetMonData - adds r1, r4, 0 - adds r1, 0x54 - strh r0, [r1] - mov r1, r8 - ldrb r0, [r1, 0x1] - muls r0, r6 - adds r0, r5 - movs r1, 0xB - movs r2, 0 - bl GetMonData - adds r4, 0x56 - strh r0, [r4] - ldr r0, =sub_80B2C30 -_080B29E4: - str r0, [r7] -_080B29E6: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2918 - - thumb_func_start sub_80B2A08 -sub_80B2A08: @ 80B2A08 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r7, r0, 24 - adds r0, r7, 0 - bl sub_80B24F8 - cmp r0, 0x1 - beq _080B2ACE - ldr r0, =gSpecialVar_Result - ldrh r0, [r0] - cmp r0, 0x4 - bne _080B2A38 - bl Link_AnyPartnersPlayingRubyOrSapphire - cmp r0, 0 - bne _080B2A4A - bl sub_800AC34 - b _080B2A4E - .pool -_080B2A38: - cmp r0, 0x3 - bne _080B2A42 - bl sub_800AC34 - b _080B2A4E -_080B2A42: - cmp r0, 0x7 - beq _080B2A4A - cmp r0, 0x9 - bne _080B2A6C -_080B2A4A: - bl CloseLink -_080B2A4E: - bl HideFieldMessageBox - ldr r0, =gTasks - lsls r1, r7, 2 - adds r1, r7 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_80B2CB0 - str r0, [r1] - b _080B2ACE - .pool -_080B2A6C: - bl GetLinkPlayerCount_2 - ldr r4, =gFieldLinkPlayerCount - strb r0, [r4] - bl GetMultiplayerId - ldr r1, =gUnknown_03005DB4 - strb r0, [r1] - ldrb r0, [r4] - bl sub_800AA04 - ldr r4, =gBlockSendBuffer - adds r0, r4, 0 - bl sub_80C30A4 - ldr r0, =gUnknown_0203CEF8 - mov r8, r0 - ldrb r0, [r0] - movs r6, 0x64 - muls r0, r6 - ldr r5, =gBattleScripting + 0x14 - adds r0, r5 - movs r1, 0xB - movs r2, 0 - bl GetMonData - adds r1, r4, 0 - adds r1, 0x54 - strh r0, [r1] - mov r1, r8 - ldrb r0, [r1, 0x1] - muls r0, r6 - adds r0, r5 - movs r1, 0xB - movs r2, 0 - bl GetMonData - adds r4, 0x56 - strh r0, [r4] - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_80B2C30 - str r1, [r0] - movs r0, 0x2 - bl sub_800A4D8 -_080B2ACE: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2A08 - - thumb_func_start sub_80B2AF4 -sub_80B2AF4: @ 80B2AF4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - str r0, [sp] - str r1, [sp, 0x4] - movs r2, 0 - movs r7, 0 - ldr r1, =gStringVar1 - movs r0, 0xFF - strb r0, [r1] - ldr r1, =gStringVar2 - movs r0, 0x1 - negs r0, r0 - strb r0, [r1] - movs r1, 0 - movs r0, 0xB - mov r10, r0 - ldr r0, =gSpeciesNames - mov r9, r0 -_080B2B20: - lsls r0, r1, 1 - adds r1, 0x1 - mov r8, r1 - ldr r1, [sp] - adds r4, r0, r1 - ldr r5, [sp, 0x4] - movs r6, 0x1 -_080B2B2E: - ldrh r0, [r4] - ldrh r1, [r5] - cmp r0, r1 - bne _080B2B5E - cmp r7, 0 - bne _080B2B48 - mov r1, r10 - muls r1, r0 - add r1, r9 - ldr r0, =gStringVar1 - bl StringCopy - movs r2, 0x1 -_080B2B48: - cmp r7, 0x1 - bne _080B2B5C - ldrh r0, [r4] - mov r1, r10 - muls r1, r0 - add r1, r9 - ldr r0, =gStringVar2 - bl StringCopy - movs r2, 0x1 -_080B2B5C: - adds r7, 0x1 -_080B2B5E: - adds r5, 0x2 - subs r6, 0x1 - cmp r6, 0 - bge _080B2B2E - mov r1, r8 - cmp r1, 0x1 - ble _080B2B20 - ldr r0, =gSpecialVar_0x8005 - strh r7, [r0] - adds r0, r2, 0 - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B2AF4 - - thumb_func_start task_map_chg_seq_0807EC34 -task_map_chg_seq_0807EC34: @ 80B2B94 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - ldr r1, =gTrainerCards - ldrh r0, [r5] - cmp r0, 0x1 - bne _080B2C10 - ldr r0, =gLinkType - ldrh r2, [r0] - ldr r0, =0x00002266 - cmp r2, r0 - beq _080B2BB2 - adds r0, 0x11 - cmp r2, r0 - bne _080B2BEC -_080B2BB2: - adds r0, r1, 0 - adds r0, 0x54 - adds r1, 0xB8 - bl sub_80B2AF4 - cmp r0, 0 - beq _080B2BEC - movs r0, 0xB - strh r0, [r5] - bl sub_800AC34 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_80B2CB0 - str r1, [r0] - b _080B2C22 - .pool -_080B2BEC: - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldrh r0, [r0, 0x12] - bl sub_80B241C - bl EnableBothScriptContexts - lsls r0, r4, 24 - lsrs r0, 24 - bl DestroyTask - b _080B2C22 - .pool -_080B2C10: - bl sub_800AC34 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_80B2CB0 - str r0, [r1] -_080B2C22: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end task_map_chg_seq_0807EC34 - - thumb_func_start sub_80B2C30 -sub_80B2C30: @ 80B2C30 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r5, 0 - bl sub_80B24F8 - cmp r0, 0x1 - beq _080B2C9C - bl GetBlockReceivedStatus - adds r4, r0, 0 - bl sub_800A9A8 - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bne _080B2C9C - movs r4, 0 - ldr r6, =gLinkPlayers - b _080B2C7E - .pool -_080B2C5C: - movs r0, 0x64 - muls r0, r4 - ldr r1, =gTrainerCards - adds r0, r1 - lsls r1, r4, 8 - ldr r2, =gBlockRecvBuffer - adds r1, r2 - lsls r2, r4, 3 - subs r2, r4 - lsls r2, 2 - adds r2, r6 - ldrb r2, [r2] - bl sub_80C3120 - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 -_080B2C7E: - bl GetLinkPlayerCount - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - bcc _080B2C5C - movs r0, 0 - bl SetSuppressLinkErrorMessage - bl ResetBlockReceivedFlags - ldr r0, =gSpecialVar_Result - adds r1, r5, 0 - bl task_map_chg_seq_0807EC34 -_080B2C9C: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2C30 - - thumb_func_start sub_80B2CB0 -sub_80B2CB0: @ 80B2CB0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _080B2CDE - ldr r0, =gTasks - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - adds r4, r0 - ldrh r0, [r4, 0x12] - bl sub_80B241C - bl EnableBothScriptContexts - ldrb r0, [r4, 0x12] - bl RemoveWindow - adds r0, r5, 0 - bl DestroyTask -_080B2CDE: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2CB0 - - thumb_func_start sub_80B2CEC -sub_80B2CEC: @ 80B2CEC - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r1, =gSpecialVar_Result - movs r0, 0x5 - strh r0, [r1] - ldr r0, =gTasks - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - adds r4, r0 - ldrh r0, [r4, 0x12] - bl sub_80B241C - bl sub_8098374 - ldrb r0, [r4, 0x12] - bl RemoveWindow - bl EnableBothScriptContexts - adds r0, r5, 0 - bl DestroyTask - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2CEC - - thumb_func_start sub_80B2D2C -sub_80B2D2C: @ 80B2D2C - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r1, =gSpecialVar_Result - movs r0, 0x6 - strh r0, [r1] - ldr r0, =gTasks - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - adds r4, r0 - ldrh r0, [r4, 0x12] - bl sub_80B241C - ldrb r0, [r4, 0x12] - bl RemoveWindow - bl HideFieldMessageBox - bl EnableBothScriptContexts - adds r0, r5, 0 - bl DestroyTask - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2D2C - - thumb_func_start sub_80B2D6C -sub_80B2D6C: @ 80B2D6C - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r2, r1, r2 - ldrh r0, [r2, 0x10] - adds r0, 0x1 - strh r0, [r2, 0x10] - lsls r0, 16 - movs r1, 0x96 - lsls r1, 18 - cmp r0, r1 - bgt _080B2D94 - movs r0, 0 - b _080B2D9A - .pool -_080B2D94: - ldr r0, =sub_80B2D2C - str r0, [r2] - movs r0, 0x1 -_080B2D9A: - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B2D6C - - thumb_func_start sub_80B2DA4 -sub_80B2DA4: @ 80B2DA4 - push {r4,lr} - movs r3, 0x2 - movs r2, 0x2 - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - cmp r0, 0x2 - beq _080B2DDC - cmp r0, 0x2 - bgt _080B2DC0 - cmp r0, 0x1 - beq _080B2DCA - b _080B2E34 - .pool -_080B2DC0: - cmp r0, 0x5 - beq _080B2DEC - cmp r0, 0x9 - beq _080B2E00 - b _080B2E34 -_080B2DCA: - movs r3, 0x2 - ldr r1, =gLinkType - ldr r4, =0x00002233 - b _080B2E30 - .pool -_080B2DDC: - movs r3, 0x2 - ldr r1, =gLinkType - ldr r4, =0x00002244 - b _080B2E30 - .pool -_080B2DEC: - movs r3, 0x4 - movs r2, 0x4 - ldr r1, =gLinkType - ldr r4, =0x00002255 - b _080B2E30 - .pool -_080B2E00: - movs r3, 0x2 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _080B2E2C - ldr r1, =gLinkType - ldr r4, =0x00002266 - b _080B2E30 - .pool -_080B2E2C: - ldr r1, =gLinkType - ldr r4, =0x00002277 -_080B2E30: - adds r0, r4, 0 - strh r0, [r1] -_080B2E34: - adds r0, r3, 0 - adds r1, r2, 0 - bl sub_80B236C - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2DA4 - - thumb_func_start sub_80B2E4C -sub_80B2E4C: @ 80B2E4C - push {lr} - ldr r1, =gLinkType - ldr r2, =0x00001133 - adds r0, r2, 0 - strh r0, [r1] - ldr r1, =gBattleTypeFlags - movs r0, 0 - str r0, [r1] - movs r0, 0x2 - movs r1, 0x2 - bl sub_80B236C - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2E4C - - thumb_func_start sub_80B2E74 -sub_80B2E74: @ 80B2E74 - push {lr} - ldr r1, =gSpecialVar_Result - movs r0, 0 - strh r0, [r1] - ldr r1, =gLinkType - ldr r2, =0x00003311 - adds r0, r2, 0 - strh r0, [r1] - ldr r1, =gBattleTypeFlags - movs r0, 0 - str r0, [r1] - movs r0, 0x2 - movs r1, 0x4 - bl sub_80B236C - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2E74 - - thumb_func_start sub_80B2EA8 -sub_80B2EA8: @ 80B2EA8 - push {r4,lr} - ldr r4, =sub_80B2EE4 - adds r0, r4, 0 - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xFF - bne _080B2ED4 - adds r0, r4, 0 - movs r1, 0x50 - bl CreateTask - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r0, r1 - movs r1, 0 - strh r1, [r0, 0x8] -_080B2ED4: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2EA8 - - thumb_func_start sub_80B2EE4 -sub_80B2EE4: @ 80B2EE4 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - movs r1, 0x8 - ldrsh r0, [r0, r1] - cmp r0, 0 - beq _080B2F0C - cmp r0, 0x1 - beq _080B2FB4 - b _080B2FC6 - .pool -_080B2F0C: - ldr r0, =gSpecialVar_Result - ldrh r0, [r0] - cmp r0, 0x1 - bne _080B2FA8 - movs r7, 0 - movs r0, 0 - mov r8, r0 - mov r9, r0 - bl GetLinkPlayerCount - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - cmp r7, r5 - bge _080B2F74 - ldr r0, =gLinkPlayers - ldrb r2, [r0] - ldrh r3, [r0, 0x1A] - subs r1, r2, 0x1 - mov r12, r0 - cmp r1, 0x1 - bhi _080B2F4A - b _080B2F6E - .pool -_080B2F44: - movs r1, 0x1 - mov r8, r1 - b _080B2F56 -_080B2F4A: - cmp r2, 0x3 - bne _080B2F56 - cmp r3, 0x1 - bne _080B2F56 - movs r0, 0x1 - mov r9, r0 -_080B2F56: - adds r4, 0x1 - cmp r4, r5 - bge _080B2F74 - lsls r0, r4, 3 - subs r0, r4 - lsls r0, 2 - add r0, r12 - ldrb r2, [r0] - ldrh r3, [r0, 0x1A] - subs r0, r2, 0x1 - cmp r0, 0x1 - bhi _080B2F4A -_080B2F6E: - cmp r3, 0x1 - bne _080B2F44 - movs r7, 0x1 -_080B2F74: - mov r1, r8 - cmp r1, 0 - beq _080B2F82 - mov r0, r9 - cmp r0, 0 - beq _080B2F82 - movs r7, 0x1 -_080B2F82: - cmp r7, 0 - beq _080B2FA8 - ldr r1, =gSpecialVar_Result - movs r0, 0xC - strh r0, [r1] - bl sub_800AD10 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - movs r1, 0x1 - strh r1, [r0, 0x8] - b _080B2FC6 - .pool -_080B2FA8: - bl EnableBothScriptContexts - adds r0, r6, 0 - bl DestroyTask - b _080B2FC6 -_080B2FB4: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _080B2FC6 - bl EnableBothScriptContexts - adds r0, r6, 0 - bl DestroyTask -_080B2FC6: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2EE4 - - thumb_func_start sub_80B2FD8 -sub_80B2FD8: @ 80B2FD8 - push {lr} - ldr r1, =gLinkType - ldr r2, =0x00004411 - adds r0, r2, 0 - strh r0, [r1] - ldr r1, =gBattleTypeFlags - movs r0, 0 - str r0, [r1] - movs r0, 0x2 - movs r1, 0x4 - bl sub_80B236C - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B2FD8 - - thumb_func_start sub_80B3000 -sub_80B3000: @ 80B3000 - push {lr} - ldr r1, =gLinkType - ldr r2, =0x00006601 - adds r0, r2, 0 - strh r0, [r1] - ldr r1, =gBattleTypeFlags - movs r0, 0 - str r0, [r1] - movs r0, 0x4 - movs r1, 0x4 - bl sub_80B236C - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3000 - - thumb_func_start sub_80B3028 -sub_80B3028: @ 80B3028 - push {lr} - ldr r1, =gLinkType - ldr r2, =0x00006602 - adds r0, r2, 0 - strh r0, [r1] - ldr r1, =gBattleTypeFlags - movs r0, 0 - str r0, [r1] - movs r0, 0x2 - movs r1, 0x4 - bl sub_80B236C - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3028 - - thumb_func_start sub_80B3050 -sub_80B3050: @ 80B3050 - push {lr} - ldr r0, =sub_80B3144 - bl FuncIsActiveTask - lsls r0, 24 - cmp r0, 0 - beq _080B3068 - movs r0, 0xFF - b _080B3134 - .pool -_080B3068: - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - subs r0, 0x1 - cmp r0, 0x8 - bhi _080B3128 - lsls r0, 2 - ldr r1, =_080B3084 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080B3084: - .4byte _080B30A8 - .4byte _080B30B8 - .4byte _080B3110 - .4byte _080B3120 - .4byte _080B30C8 - .4byte _080B3128 - .4byte _080B3128 - .4byte _080B3128 - .4byte _080B30D8 -_080B30A8: - ldr r1, =gLinkType - ldr r2, =0x00002233 - b _080B3124 - .pool -_080B30B8: - ldr r1, =gLinkType - ldr r2, =0x00002244 - b _080B3124 - .pool -_080B30C8: - ldr r1, =gLinkType - ldr r2, =0x00002255 - b _080B3124 - .pool -_080B30D8: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _080B3100 - ldr r1, =gLinkType - ldr r2, =0x00002266 - b _080B3124 - .pool -_080B3100: - ldr r1, =gLinkType - ldr r2, =0x00002277 - b _080B3124 - .pool -_080B3110: - ldr r1, =gLinkType - ldr r2, =0x00001111 - b _080B3124 - .pool -_080B3120: - ldr r1, =gLinkType - ldr r2, =0x00003322 -_080B3124: - adds r0, r2, 0 - strh r0, [r1] -_080B3128: - ldr r0, =sub_80B3144 - movs r1, 0x50 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 -_080B3134: - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B3050 - - thumb_func_start sub_80B3144 -sub_80B3144: @ 80B3144 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r4, r1, r0 - movs r3, 0 - ldrsh r2, [r4, r3] - cmp r2, 0 - bne _080B3178 - bl OpenLink - bl ResetLinkPlayers - ldr r0, =task00_08081A90 - movs r1, 0x50 - bl CreateTask - b _080B3184 - .pool -_080B3178: - cmp r2, 0x9 - ble _080B3184 - subs r0, 0x8 - adds r0, r1, r0 - ldr r1, =sub_80B3194 - str r1, [r0] -_080B3184: - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3144 - - thumb_func_start sub_80B3194 -sub_80B3194: @ 80B3194 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r5, r4, 0 - bl GetLinkPlayerCount_2 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _080B31DA - bl IsLinkMaster - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B31CC - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_80B31E8 - b _080B31D8 - .pool -_080B31CC: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_80B3220 -_080B31D8: - str r0, [r1] -_080B31DA: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3194 - - thumb_func_start sub_80B31E8 -sub_80B31E8: @ 80B31E8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - bl sub_800AA48 - adds r4, r0, 0 - bl GetLinkPlayerCount_2 - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bne _080B3212 - bl sub_800A620 - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_80B3220 - str r0, [r1] -_080B3212: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B31E8 - - thumb_func_start sub_80B3220 -sub_80B3220: @ 80B3220 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0x1 - bne _080B3248 - bl IsLinkPlayerDataExchangeComplete - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B3248 - bl sub_800AB18 - bl sub_8009F18 - adds r0, r4, 0 - bl DestroyTask -_080B3248: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3220 - - thumb_func_start sub_80B3254 -sub_80B3254: @ 80B3254 - push {lr} - bl SaveGame - pop {r0} - bx r0 - thumb_func_end sub_80B3254 - - thumb_func_start sub_80B3260 -sub_80B3260: @ 80B3260 - push {lr} - cmp r0, 0x2 - beq _080B3284 - cmp r0, 0x2 - bgt _080B3270 - cmp r0, 0x1 - beq _080B327A - b _080B32A6 -_080B3270: - cmp r0, 0x5 - beq _080B3290 - cmp r0, 0x9 - beq _080B32A0 - b _080B32A6 -_080B327A: - ldr r1, =gBattleTypeFlags - movs r0, 0xA - b _080B32A4 - .pool -_080B3284: - ldr r1, =gBattleTypeFlags - movs r0, 0xB - b _080B32A4 - .pool -_080B3290: - bl sub_80F94E8 - ldr r1, =gBattleTypeFlags - movs r0, 0x4B - b _080B32A4 - .pool -_080B32A0: - ldr r1, =gBattleTypeFlags - ldr r0, =0x0000014b -_080B32A4: - str r0, [r1] -_080B32A6: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3260 - - thumb_func_start sub_80B32B4 -sub_80B32B4: @ 80B32B4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x5 - bhi _080B33A0 - lsls r0, 2 - ldr r1, =_080B32E0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080B32E0: - .4byte _080B32F8 - .4byte _080B3318 - .4byte _080B3328 - .4byte _080B3338 - .4byte _080B333E - .4byte _080B3354 -_080B32F8: - movs r0, 0x1 - movs r1, 0 - bl FadeScreen - ldr r1, =gLinkType - ldr r2, =0x00002211 - adds r0, r2, 0 - strh r0, [r1] - bl ClearLinkCallback_2 - b _080B3346 - .pool -_080B3318: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - b _080B3342 - .pool -_080B3328: - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x14 - ble _080B33A0 - b _080B3346 -_080B3338: - bl sub_800AC34 - b _080B3346 -_080B333E: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] -_080B3342: - cmp r0, 0 - bne _080B33A0 -_080B3346: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _080B33A0 - .pool -_080B3354: - ldr r0, =gLinkPlayers - ldr r0, [r0, 0x4] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080B3370 - ldr r0, =0x000001dd - bl PlayMapChosenOrBattleBGM - b _080B3378 - .pool -_080B3370: - movs r0, 0xEE - lsls r0, 1 - bl PlayMapChosenOrBattleBGM -_080B3378: - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - bl sub_80B3260 - bl overworld_free_bg_tilemaps - ldr r1, =gTrainerBattleOpponent_A - movs r2, 0x80 - lsls r2, 4 - adds r0, r2, 0 - strh r0, [r1] - ldr r0, =CB2_InitBattle - bl SetMainCallback2 - ldr r1, =gMain - ldr r0, =sub_80B360C - str r0, [r1, 0x8] - adds r0, r5, 0 - bl DestroyTask -_080B33A0: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B32B4 - - thumb_func_start sub_80B33BC -sub_80B33BC: @ 80B33BC - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - movs r1, 0 - ldrsh r0, [r6, r1] - cmp r0, 0x7 - bls _080B33D6 - b _080B3532 -_080B33D6: - lsls r0, 2 - ldr r1, =_080B33E8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080B33E8: - .4byte _080B3408 - .4byte _080B342C - .4byte _080B3444 - .4byte _080B3458 - .4byte _080B34B0 - .4byte _080B34C4 - .4byte _080B34CE - .4byte _080B34DE -_080B3408: - movs r0, 0x1 - movs r1, 0 - bl FadeScreen - ldr r0, =gLinkType - ldr r2, =0x00002211 - adds r1, r2, 0 - strh r1, [r0] - bl ClearLinkCallback_2 - movs r0, 0x1 - strh r0, [r6] - b _080B3532 - .pool -_080B342C: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _080B343A - b _080B3532 -_080B343A: - movs r0, 0x2 - strh r0, [r6] - b _080B3532 - .pool -_080B3444: - ldr r1, =gLocalLinkPlayer - movs r0, 0 - movs r2, 0x1C - bl SendBlock - movs r0, 0x3 - strh r0, [r6] - b _080B3532 - .pool -_080B3458: - bl GetBlockReceivedStatus - adds r4, r0, 0 - bl sub_800A9D8 - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bne _080B3532 - movs r4, 0 - ldr r5, =gLinkPlayers - b _080B349A - .pool -_080B3474: - lsls r1, r4, 8 - ldr r2, =gBlockRecvBuffer - adds r0, r5, 0 - adds r1, r2 - ldm r1!, {r2,r3,r7} - stm r0!, {r2,r3,r7} - ldm r1!, {r2,r3,r7} - stm r0!, {r2,r3,r7} - ldr r1, [r1] - str r1, [r0] - adds r0, r5, 0 - bl sub_800B524 - lsls r0, r4, 24 - lsrs r0, 24 - bl ResetBlockReceivedFlag - adds r5, 0x1C - adds r4, 0x1 -_080B349A: - bl GetLinkPlayerCount - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - blt _080B3474 - movs r0, 0x4 - strh r0, [r6] - b _080B3532 - .pool -_080B34B0: - ldrh r0, [r6, 0x2] - adds r0, 0x1 - strh r0, [r6, 0x2] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x14 - ble _080B3532 - movs r0, 0x5 - strh r0, [r6] - b _080B3532 -_080B34C4: - bl sub_800ADF8 - movs r0, 0x6 - strh r0, [r6] - b _080B3532 -_080B34CE: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - beq _080B3532 - movs r0, 0x7 - strh r0, [r6] - b _080B3532 -_080B34DE: - ldr r0, =gLinkPlayers - ldr r0, [r0, 0x4] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080B34FC - ldr r0, =0x000001dd - bl PlayMapChosenOrBattleBGM - b _080B3504 - .pool -_080B34FC: - movs r0, 0xEE - lsls r0, 1 - bl PlayMapChosenOrBattleBGM -_080B3504: - ldr r1, =gLinkPlayers - ldr r0, =0x00002211 - str r0, [r1, 0x14] - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - bl sub_80B3260 - bl overworld_free_bg_tilemaps - ldr r1, =gTrainerBattleOpponent_A - movs r3, 0x80 - lsls r3, 4 - adds r0, r3, 0 - strh r0, [r1] - ldr r0, =CB2_InitBattle - bl SetMainCallback2 - ldr r1, =gMain - ldr r0, =sub_80B360C - str r0, [r1, 0x8] - adds r0, r4, 0 - bl DestroyTask -_080B3532: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B33BC - - thumb_func_start sub_80B3554 -sub_80B3554: @ 80B3554 - push {r4,lr} - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x1 - beq _080B35E0 - cmp r0, 0x1 - bgt _080B3574 - cmp r0, 0 - beq _080B357A - b _080B35FE - .pool -_080B3574: - cmp r0, 0x2 - beq _080B35F8 - b _080B35FE -_080B357A: - bl GetLinkPlayerCount - lsls r0, 24 - lsrs r3, r0, 24 - movs r4, 0 - movs r2, 0 - cmp r4, r3 - bge _080B35AC - ldr r1, =gLinkPlayers - ldrb r0, [r1] - subs r0, 0x4 - cmp r0, 0x1 - bls _080B35B0 -_080B3594: - adds r2, 0x1 - cmp r2, r3 - bge _080B35AC - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r0, [r0] - subs r0, 0x4 - cmp r0, 0x1 - bhi _080B3594 - movs r4, 0x1 -_080B35AC: - cmp r4, 0 - beq _080B35C8 -_080B35B0: - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - movs r1, 0x2 - strb r1, [r0] - b _080B35FE - .pool -_080B35C8: - bl sub_800AC34 - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0] - b _080B35FE - .pool -_080B35E0: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _080B35FE - ldr r0, =CB2_ReturnToField - bl SetMainCallback2 - b _080B35FE - .pool -_080B35F8: - ldr r0, =CB2_ReturnToField - bl SetMainCallback2 -_080B35FE: - bl RunTasks - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3554 - - thumb_func_start sub_80B360C -sub_80B360C: @ 80B360C - push {r4,r5,lr} - ldr r2, =gBattleTypeFlags - ldr r0, [r2] - movs r1, 0x21 - negs r1, r1 - ands r0, r1 - str r0, [r2] - bl Overworld_ResetMapMusic - bl LoadPlayerParty - bl SavePlayerBag - bl sub_813BF10 - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - subs r0, 0x1 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bhi _080B36B2 - ldr r0, =gUnknown_03005DB4 - ldrb r0, [r0] - movs r5, 0x1 - eors r0, r5 - bl UpdatePlayerLinkBattleRecords - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _080B36B2 - ldr r0, =gBattleOutcome - ldrb r0, [r0] - cmp r0, 0x1 - beq _080B3670 - cmp r0, 0x2 - beq _080B3694 - b _080B36B2 - .pool -_080B3670: - ldr r4, =gLinkPlayers - bl GetMultiplayerId - eors r0, r5 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r4, 0x4 - adds r1, r4 - ldr r1, [r1] - movs r0, 0 - bl sub_801B990 - b _080B36B2 - .pool -_080B3694: - ldr r4, =gLinkPlayers - bl GetMultiplayerId - eors r0, r5 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r4, 0x4 - adds r1, r4 - ldr r1, [r1] - movs r0, 0x1 - bl sub_801B990 -_080B36B2: - bl InUnionRoom - cmp r0, 0x1 - bne _080B36CC - ldr r1, =gMain - ldr r0, =sub_80B3554 - b _080B36D0 - .pool -_080B36CC: - ldr r1, =gMain - ldr r0, =c2_8056854 -_080B36D0: - str r0, [r1, 0x8] - ldr r0, =sub_80A0514 - bl SetMainCallback2 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B360C - - thumb_func_start sub_80B36EC -sub_80B36EC: @ 80B36EC - push {lr} - ldr r0, =gSpecialVar_0x8004 - ldrh r1, [r0] - subs r0, r1, 0x1 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bls _080B3706 - adds r0, r1, 0 - cmp r0, 0x5 - beq _080B3706 - cmp r0, 0x9 - bne _080B370E -_080B3706: - bl LoadPlayerParty - bl SavePlayerBag -_080B370E: - movs r0, 0x7F - bl copy_saved_warp2_bank_and_enter_x_to_warp1 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B36EC - - thumb_func_start sub_80B371C -sub_80B371C: @ 80B371C - push {lr} - bl sub_80872B0 - pop {r0} - bx r0 - thumb_func_end sub_80B371C - - thumb_func_start sub_80B3728 -sub_80B3728: @ 80B3728 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks - adds r5, r0, r1 - movs r1, 0x8 - ldrsh r0, [r5, r1] - cmp r0, 0x1 - beq _080B376C - cmp r0, 0x1 - bgt _080B3750 - cmp r0, 0 - beq _080B375A - b _080B37CC - .pool -_080B3750: - cmp r0, 0x2 - beq _080B378C - cmp r0, 0x3 - beq _080B37B8 - b _080B37CC -_080B375A: - ldr r0, =OldaleTown_PokemonCenter_2F_Text_278091 - bl ShowFieldMessage - movs r0, 0x1 - strh r0, [r5, 0x8] - b _080B37CC - .pool -_080B376C: - bl IsFieldMessageBoxHidden - lsls r0, 24 - cmp r0, 0 - beq _080B37CC - bl sub_8087288 - ldr r0, =gSpecialVar_0x8005 - ldrb r0, [r0] - bl sub_8009628 - movs r0, 0x2 - strh r0, [r5, 0x8] - b _080B37CC - .pool -_080B378C: - bl sub_8087214 - cmp r0, 0x1 - beq _080B379E - cmp r0, 0x1 - bcc _080B37CC - cmp r0, 0x2 - beq _080B37B2 - b _080B37CC -_080B379E: - bl HideFieldMessageBox - movs r0, 0 - strh r0, [r5, 0x8] - bl sub_80872C4 - adds r0, r4, 0 - bl SwitchTaskToFollowupFunc - b _080B37CC -_080B37B2: - movs r0, 0x3 - strh r0, [r5, 0x8] - b _080B37CC -_080B37B8: - bl sub_808729C - movs r0, 0x1 - bl sub_8197AE8 - adds r0, r4, 0 - bl DestroyTask - bl EnableBothScriptContexts -_080B37CC: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80B3728 - - thumb_func_start sub_80B37D4 -sub_80B37D4: @ 80B37D4 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, =sub_80B3728 - adds r0, r4, 0 - movs r1, 0x50 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - adds r1, r4, 0 - adds r2, r5, 0 - bl SetTaskFuncWithFollowupFunc - bl ScriptContext1_Stop - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B37D4 - - thumb_func_start sub_80B37FC -sub_80B37FC: @ 80B37FC - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _080B3840 - cmp r0, 0x1 - bgt _080B3824 - cmp r0, 0 - beq _080B382E - b _080B3884 - .pool -_080B3824: - cmp r0, 0x2 - beq _080B3854 - cmp r0, 0x3 - beq _080B3870 - b _080B3884 -_080B382E: - bl ScriptContext2_Enable - movs r0, 0x1 - movs r1, 0 - bl FadeScreen - bl ClearLinkCallback_2 - b _080B3864 -_080B3840: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _080B3884 - b _080B3864 - .pool -_080B3854: - ldr r1, =gUnknown_02032298 - movs r0, 0 - strb r0, [r1] - strb r0, [r1, 0x1] - bl m4aMPlayAllStop - bl sub_800AC34 -_080B3864: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _080B3884 - .pool -_080B3870: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _080B3884 - ldr r0, =sub_80773AC - bl SetMainCallback2 - adds r0, r5, 0 - bl DestroyTask -_080B3884: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B37FC - - thumb_func_start sub_80B3894 -sub_80B3894: @ 80B3894 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _080B38D8 - cmp r0, 0x1 - bgt _080B38BC - cmp r0, 0 - beq _080B38C6 - b _080B391C - .pool -_080B38BC: - cmp r0, 0x2 - beq _080B38EC - cmp r0, 0x3 - beq _080B3908 - b _080B391C -_080B38C6: - bl ScriptContext2_Enable - movs r0, 0x1 - movs r1, 0 - bl FadeScreen - bl Rfu_set_zero - b _080B38FC -_080B38D8: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _080B391C - b _080B38FC - .pool -_080B38EC: - ldr r1, =gUnknown_02032298 - movs r0, 0 - strb r0, [r1] - strb r0, [r1, 0x1] - bl m4aMPlayAllStop - bl sub_800ADF8 -_080B38FC: - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - b _080B391C - .pool -_080B3908: - bl sub_800A520 - lsls r0, 24 - cmp r0, 0 - beq _080B391C - bl sub_8013F78 - adds r0, r5, 0 - bl DestroyTask -_080B391C: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80B3894 - - thumb_func_start sub_80B3924 -sub_80B3924: @ 80B3924 - push {lr} - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _080B3940 - ldr r0, =sub_80B3894 - bl sub_80B37D4 - b _080B3946 - .pool -_080B3940: - ldr r0, =sub_80B37FC - bl sub_80B37D4 -_080B3946: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3924 - - thumb_func_start sub_80B3950 -sub_80B3950: @ 80B3950 - push {lr} - ldr r0, =sub_80B37FC - movs r1, 0x50 - bl CreateTask - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3950 - - thumb_func_start nullsub_37 -nullsub_37: @ 80B3964 - bx lr - thumb_func_end nullsub_37 - - thumb_func_start sub_80B3968 -sub_80B3968: @ 80B3968 - push {lr} - ldr r1, =gLinkType - ldr r2, =0x00002211 - adds r0, r2, 0 - strh r0, [r1] - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _080B3994 - ldr r0, =sub_80B33BC - bl sub_80B37D4 - b _080B399A - .pool -_080B3994: - ldr r0, =sub_80B32B4 - bl sub_80B37D4 -_080B399A: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3968 - - thumb_func_start sub_80B39A4 -sub_80B39A4: @ 80B39A4 - push {lr} - ldr r0, =sub_80B3728 - movs r1, 0x50 - bl CreateTask - bl ScriptContext1_Stop - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B39A4 - - thumb_func_start sp02A_crash_sound -sp02A_crash_sound: @ 80B39BC - push {lr} - ldr r0, =gSpecialVar_0x8006 - ldrb r0, [r0] - ldr r1, =CB2_ReturnToFieldContinueScriptPlayMapMusic - bl sub_80C4E74 - pop {r0} - bx r0 - .pool - thumb_func_end sp02A_crash_sound - - thumb_func_start sub_80B39D4 -sub_80B39D4: @ 80B39D4 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gSpecialVar_0x8006 - strh r4, [r0] - ldr r0, =gStringVar1 - lsls r1, r4, 3 - subs r1, r4 - lsls r1, 2 - ldr r2, =gLinkPlayers + 8 - adds r1, r2 - bl StringCopy - adds r0, r4, 0 - bl sub_80C4904 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - beq _080B3A28 - ldr r0, =gStringVar2 - ldr r2, =gUnknown_0855059C - subs r1, 0x1 - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - bl StringCopy - movs r0, 0x1 - b _080B3A2A - .pool -_080B3A28: - movs r0, 0 -_080B3A2A: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80B39D4 - - thumb_func_start task00_08081A90 -task00_08081A90: @ 80B3A30 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r5, r4, 0 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks - adds r0, r1 - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] - lsls r1, 16 - movs r0, 0x96 - lsls r0, 17 - cmp r1, r0 - ble _080B3A62 - bl CloseLink - ldr r0, =CB2_LinkError - bl SetMainCallback2 - adds r0, r4, 0 - bl DestroyTask -_080B3A62: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - beq _080B3AA6 - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - bne _080B3AA0 - bl sub_800AA60 - lsls r0, 24 - cmp r0, 0 - bne _080B3A86 - bl CloseLink - ldr r0, =CB2_LinkError - bl SetMainCallback2 -_080B3A86: - adds r0, r4, 0 - bl DestroyTask - b _080B3AA6 - .pool -_080B3AA0: - adds r0, r5, 0 - bl DestroyTask -_080B3AA6: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end task00_08081A90 - - thumb_func_start sub_80B3AAC -sub_80B3AAC: @ 80B3AAC - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _080B3AC4 - bl EnableBothScriptContexts - adds r0, r4, 0 - bl DestroyTask -_080B3AC4: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3AAC - - thumb_func_start sub_80B3AD0 -sub_80B3AD0: @ 80B3AD0 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl sub_800AC34 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_80B3AAC - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3AD0 - - thumb_func_start sub_80B3AF8 -sub_80B3AF8: @ 80B3AF8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r5, r0, r1 - movs r1, 0 - ldrsh r0, [r5, r1] - cmp r0, 0x1 - beq _080B3B54 - cmp r0, 0x1 - bgt _080B3B20 - cmp r0, 0 - beq _080B3B2A - b _080B3BB8 - .pool -_080B3B20: - cmp r0, 0x2 - beq _080B3B68 - cmp r0, 0x3 - beq _080B3B9E - b _080B3BB8 -_080B3B2A: - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _080B3B40 - adds r0, r4, 0 - bl DestroyTask - b _080B3BB8 - .pool -_080B3B40: - bl OpenLink - ldr r0, =task00_08081A90 - movs r1, 0x1 - bl CreateTask - b _080B3B96 - .pool -_080B3B54: - ldrh r0, [r5, 0x2] - adds r0, 0x1 - strh r0, [r5, 0x2] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xB - ble _080B3BB8 - movs r0, 0 - strh r0, [r5, 0x2] - b _080B3B96 -_080B3B68: - bl GetLinkPlayerCount_2 - adds r4, r0, 0 - bl sub_800AA48 - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bcc _080B3BB8 - bl IsLinkMaster - lsls r0, 24 - cmp r0, 0 - beq _080B3B96 - ldrh r0, [r5, 0x2] - adds r0, 0x1 - strh r0, [r5, 0x2] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1E - ble _080B3BB8 - bl sub_800A620 -_080B3B96: - ldrh r0, [r5] - adds r0, 0x1 - strh r0, [r5] - b _080B3BB8 -_080B3B9E: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0x1 - bne _080B3BB8 - bl IsLinkPlayerDataExchangeComplete - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080B3BB8 - adds r0, r4, 0 - bl DestroyTask -_080B3BB8: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3AF8 - - thumb_func_start sub_80B3BC4 -sub_80B3BC4: @ 80B3BC4 - push {lr} - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - bne _080B3BD6 - ldr r1, =gLinkType - ldr r2, =0x00002288 - adds r0, r2, 0 - strh r0, [r1] -_080B3BD6: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B3BC4 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/script_pokemon_util_80F87D8.s b/asm/script_pokemon_util_80F87D8.s index b7388b41b..1202473ee 100644 --- a/asm/script_pokemon_util_80F87D8.s +++ b/asm/script_pokemon_util_80F87D8.s @@ -1606,8 +1606,8 @@ _080F94D6: .pool thumb_func_end sub_80F94B8 - thumb_func_start sub_80F94E8 -sub_80F94E8: @ 80F94E8 + thumb_func_start ReducePlayerPartyToThree +ReducePlayerPartyToThree: @ 80F94E8 push {r4-r7,lr} sub sp, 0x198 add r0, sp, 0x190 @@ -1662,6 +1662,6 @@ _080F9538: pop {r0} bx r0 .pool - thumb_func_end sub_80F94E8 + thumb_func_end ReducePlayerPartyToThree .align 2, 0 @ Don't pad with nop. diff --git a/asm/trainer_card.s b/asm/trainer_card.s index 2c38140c6..e0cb5e21e 100644 --- a/asm/trainer_card.s +++ b/asm/trainer_card.s @@ -1141,8 +1141,8 @@ _080C308C: .pool thumb_func_end sub_80C3020 - thumb_func_start sub_80C30A4 -sub_80C30A4: @ 80C30A4 + thumb_func_start TrainerCard_GenerateCardForPlayer +TrainerCard_GenerateCardForPlayer: @ 80C30A4 push {r4,lr} adds r4, r0, 0 movs r1, 0 @@ -1197,7 +1197,7 @@ _080C3108: pop {r0} bx r0 .pool - thumb_func_end sub_80C30A4 + thumb_func_end TrainerCard_GenerateCardForPlayer thumb_func_start sub_80C3120 sub_80C3120: @ 80C3120 @@ -4558,8 +4558,8 @@ _080C4E44: .pool thumb_func_end sub_80C4DDC - thumb_func_start sub_80C4E74 -sub_80C4E74: @ 80C4E74 + thumb_func_start TrainerCard_ShowLinkCard +TrainerCard_ShowLinkCard: @ 80C4E74 push {r4-r6,lr} adds r4, r0, 0 adds r6, r1, 0 @@ -4600,7 +4600,7 @@ sub_80C4E74: @ 80C4E74 pop {r0} bx r0 .pool - thumb_func_end sub_80C4E74 + thumb_func_end TrainerCard_ShowLinkCard thumb_func_start sub_80C4EE4 sub_80C4EE4: @ 80C4EE4 diff --git a/data/cable_club.s b/data/cable_club.s deleted file mode 100644 index f62b0b90a..000000000 --- a/data/cable_club.s +++ /dev/null @@ -1,16 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 - - .align 2 -gUnknown_08550594:: @ 8550594 - window_template 0x00, 0x10, 0x0b, 0x0b, 0x02, 0x0f, 0x0125 - - .align 2 -gUnknown_0855059C:: @ 855059C - .4byte gText_BronzeCard - .4byte gText_CopperCard - .4byte gText_SilverCard - .4byte gText_GoldCard diff --git a/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc b/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc index 2b07b7ea4..e0f2c3c5e 100644 --- a/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc +++ b/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc @@ -929,7 +929,7 @@ BattleFrontier_BattleTowerLobby_EventScript_23F2B7:: @ 823F2B7 BattleFrontier_BattleTowerLobby_EventScript_23F2C5:: @ 823F2C5 setvar VAR_0x8004, 9 - message OldaleTown_PokemonCenter_2F_Text_278091 + message gText_PleaseWaitForLink waitmessage setvar VAR_0x8005, 0 special sub_80B2DA4 diff --git a/data/maps/MossdeepCity_SpaceCenter_2F/scripts.inc b/data/maps/MossdeepCity_SpaceCenter_2F/scripts.inc index 0052f09aa..36bfc422a 100644 --- a/data/maps/MossdeepCity_SpaceCenter_2F/scripts.inc +++ b/data/maps/MossdeepCity_SpaceCenter_2F/scripts.inc @@ -260,7 +260,7 @@ MossdeepCity_SpaceCenter_2F_EventScript_22400C:: @ 822400C goto MossdeepCity_SpaceCenter_2F_EventScript_223FDA MossdeepCity_SpaceCenter_2F_EventScript_224032:: @ 8224032 - special sub_80F94E8 + special ReducePlayerPartyToThree setvar VAR_0x8004, 2 setvar VAR_0x8005, 4 special sub_81A1780 diff --git a/data/maps/SootopolisCity_MysteryEventsHouse_1F/scripts.inc b/data/maps/SootopolisCity_MysteryEventsHouse_1F/scripts.inc index 652ac791a..36d0edd3a 100644 --- a/data/maps/SootopolisCity_MysteryEventsHouse_1F/scripts.inc +++ b/data/maps/SootopolisCity_MysteryEventsHouse_1F/scripts.inc @@ -106,7 +106,7 @@ SootopolisCity_MysteryEventsHouse_1F_EventScript_227A58:: @ 8227A58 compare VAR_RESULT, 0 goto_eq SootopolisCity_MysteryEventsHouse_1F_EventScript_227AE2 special SavePlayerParty - special sub_80F94E8 + special ReducePlayerPartyToThree msgbox SootopolisCity_MysteryEventsHouse_1F_Text_227D21, 4 closemessage compare VAR_FACING, 2 diff --git a/data/scripts/cable_club.inc b/data/scripts/cable_club.inc index 96e36dcf9..08f5accca 100644 --- a/data/scripts/cable_club.inc +++ b/data/scripts/cable_club.inc @@ -430,7 +430,7 @@ OldaleTown_PokemonCenter_2F_EventScript_276F60:: @ 8276F60 call OldaleTown_PokemonCenter_2F_EventScript_27134F compare VAR_RESULT, 0 goto_eq OldaleTown_PokemonCenter_2F_EventScript_2772EC - message OldaleTown_PokemonCenter_2F_Text_278091 + message gText_PleaseWaitForLink waitmessage special sub_80B2DA4 waitstate @@ -532,7 +532,7 @@ OldaleTown_PokemonCenter_2F_EventScript_2770B2:: @ 82770B2 call OldaleTown_PokemonCenter_2F_EventScript_27134F compare VAR_RESULT, 0 goto_eq OldaleTown_PokemonCenter_2F_EventScript_2772EC - message OldaleTown_PokemonCenter_2F_Text_278091 + message gText_PleaseWaitForLink waitmessage special sub_80B2E4C waitstate @@ -607,7 +607,7 @@ OldaleTown_PokemonCenter_2F_EventScript_2771DB:: @ 82771DB call OldaleTown_PokemonCenter_2F_EventScript_27134F compare VAR_RESULT, 0 goto_eq OldaleTown_PokemonCenter_2F_EventScript_2772EC - message OldaleTown_PokemonCenter_2F_Text_278091 + message gText_PleaseWaitForLink waitmessage special sub_80B2E74 waitstate @@ -1675,21 +1675,21 @@ OldaleTown_PokemonCenter_2F_Text_278061: @ 8278061 .string "A POKéMON holding the {STR_VAR_1}\n" .string "BERRY can’t be traded.$" -OldaleTown_PokemonCenter_2F_Text_278091:: @ 8278091 +gText_PleaseWaitForLink:: @ 8278091 .string "Please wait.\n" .string "… … B Button: Cancel$" -OldaleTown_PokemonCenter_2F_Text_2780B3:: @ 82780B3 +gText_ConfirmLinkWhenPlayersReady:: @ 82780B3 .string "When all players are ready…\n" .string "A Button: Confirm\l" .string "B Button: Cancel$" -OldaleTown_PokemonCenter_2F_Text_2780F2:: @ 82780F2 +gText_ConfirmStartLinkWithXPlayers:: @ 82780F2 .string "Start link with {STR_VAR_1} players.\n" .string "A Button: Confirm\l" .string "B Button: Cancel$" -OldaleTown_PokemonCenter_2F_Text_278131:: @ 8278131 +gText_AwaitingLinkup:: @ 8278131 .string "Awaiting linkup…\n" .string "… … B Button: Cancel$" diff --git a/data/specials.inc b/data/specials.inc index 5d31c425f..07da8edab 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -259,7 +259,7 @@ gSpecials:: @ 81DBA64 def_special sub_80F9490 def_special ValidateEReaderTrainer def_special GetBestBattleTowerStreak - def_special sub_80F94E8 + def_special ReducePlayerPartyToThree def_special BedroomPC def_special PlayerPC def_special FieldShowRegionMap diff --git a/include/cable_club.h b/include/cable_club.h index 8be376721..ebdc82b46 100644 --- a/include/cable_club.h +++ b/include/cable_club.h @@ -14,5 +14,6 @@ u8 sub_80B3050(void); void sub_80B360C(void); bool32 sub_80B2AF4(u16 *arg0, u16 *arg1); void sub_80B3AF8(u8 taskId); +void task00_08081A90(u8 taskId); #endif //GUARD_CABLE_CLUB_H diff --git a/include/field_message_box.h b/include/field_message_box.h index 432c9078b..e3deee4d6 100644 --- a/include/field_message_box.h +++ b/include/field_message_box.h @@ -1,10 +1,20 @@ #ifndef GUARD_FIELD_MESSAGE_BOX_H #define GUARD_FIELD_MESSAGE_BOX_H +enum +{ + FIELD_MESSAGE_BOX_HIDDEN, + FIELD_MESSAGE_BOX_UNUSED, + FIELD_MESSAGE_BOX_NORMAL, + FIELD_MESSAGE_BOX_AUTO_SCROLL, +}; + bool8 ShowFieldMessage(const u8 *message); bool8 sub_8098238(const u8 *message); bool8 ShowFieldAutoScrollMessage(const u8 *message); void HideFieldMessageBox(void); bool8 IsFieldMessageBoxHidden(void); +u8 GetFieldMessageBoxMode(void); +void sub_8098374(void); #endif // GUARD_FIELD_MESSAGE_BOX_H diff --git a/include/field_specials.h b/include/field_specials.h index c1f70a399..4709f9551 100644 --- a/include/field_specials.h +++ b/include/field_specials.h @@ -5,5 +5,6 @@ u8 GetLeadMonIndex(void); u8 sub_813B260(void); u16 get_unknown_box_id(void); bool8 InMultiBattleRoom(void); +void sub_813BF10(void); #endif // GUARD_FIELD_SPECIALS_H diff --git a/include/link.h b/include/link.h index eb44ed04e..f12f0990f 100644 --- a/include/link.h +++ b/include/link.h @@ -259,6 +259,8 @@ void sub_800AF18(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, u8 un void sub_800B348(void); void sub_800B3A4(u32 who); bool32 sub_800A07C(void); +void sub_800AB98(void); +void sub_800AA04(u8 a0); extern u16 gLinkPartnersHeldKeys[6]; extern u32 gLinkDebugSeed; @@ -293,6 +295,7 @@ extern u32 gFiller_0300315c; extern u32 gFiller_03004138; extern u32 gFiller_0300413C; extern u32 gFiller_03003080; +extern struct LinkPlayer gLocalLinkPlayer; bool32 Link_AnyPartnersPlayingRubyOrSapphire(void); bool32 sub_800A03C(void); @@ -303,5 +306,10 @@ bool8 sub_800A4D8(u8 a0); u8 sub_800A9D8(void); u8 sub_800A0C8(s32, s32); u16 *sub_801B058(void); +u8 sub_800A9A8(void); +void sub_800AD10(void); +void sub_800AB18(void); +void sub_8009F18(void); +bool8 sub_800AA60(void); #endif // GUARD_LINK_H diff --git a/include/menu.h b/include/menu.h index cddab0870..2689b026c 100644 --- a/include/menu.h +++ b/include/menu.h @@ -87,5 +87,6 @@ void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left void sub_8199C30(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette); void sub_8199D3C(void *ptr, int delta, int width, int height, bool32 is8BPP); void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyToVram); +void sub_8197AE8(bool8 copyToVram); #endif // GUARD_MENU_H diff --git a/include/overworld.h b/include/overworld.h index f6856ab0c..3dce20ab2 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -25,6 +25,9 @@ extern u16 *gBGTilemapBuffers3; extern void (*gFieldCallback)(void); +extern u8 gUnknown_03005DB4; +extern u8 gFieldLinkPlayerCount; + // Exported ROM declarations extern const struct UCoords32 gDirectionToVectors[]; diff --git a/include/rom_8011DC0.h b/include/rom_8011DC0.h index f71e5d97d..b6ca0e248 100644 --- a/include/rom_8011DC0.h +++ b/include/rom_8011DC0.h @@ -9,5 +9,7 @@ void sub_8018438(void); u16 mevent_081445C0(u8); +void sub_801B990(u32, u32); +u8 sub_8013F78(void); #endif //GUARD_rom_8011DC0_H diff --git a/include/script_pokemon_util_80F87D8.h b/include/script_pokemon_util_80F87D8.h index 555b3428b..68aec7eb6 100644 --- a/include/script_pokemon_util_80F87D8.h +++ b/include/script_pokemon_util_80F87D8.h @@ -3,5 +3,6 @@ #define GUARD_SCRIPT_POKEMON_UTIL_80F87D8_H u16 sub_80F903C(void); +void ReducePlayerPartyToThree(void); #endif // GUARD_SCRIPT_POKEMON_UTIL_80F87D8_H diff --git a/include/strings.h b/include/strings.h index 54644a7cb..1a254c2ad 100644 --- a/include/strings.h +++ b/include/strings.h @@ -844,5 +844,13 @@ extern const u8 gText_TwoDashes[]; extern const u8 *const gReturnToXStringsTable2[]; extern const u8 gText_XPLink[]; +extern const u8 gText_ConfirmLinkWhenPlayersReady[]; +extern const u8 gText_ConfirmStartLinkWithXPlayers[]; +extern const u8 gText_AwaitingLinkup[]; +extern const u8 gText_PleaseWaitForLink[]; +extern const u8 gText_BronzeCard[]; +extern const u8 gText_CopperCard[]; +extern const u8 gText_SilverCard[]; +extern const u8 gText_GoldCard[]; #endif //GUARD_STRINGS_H diff --git a/include/trainer_card.h b/include/trainer_card.h index af603444f..d80a5fa52 100644 --- a/include/trainer_card.h +++ b/include/trainer_card.h @@ -27,13 +27,16 @@ struct TrainerCard /*0x24*/ u32 money; /*0x28*/ u16 var_28[4]; /*0x30*/ u8 playerName[8]; - /*0x38*/ u8 emeraldAddedUnknownFields[0x64-0x38]; + /*0x38*/ u8 emeraldAddedUnknownFields[0x54-0x38]; + /*0x54*/ u16 monSpecies[2]; + /*0x58*/ u8 emeraldAddedUnknownFields2[0x64-0x58]; }; extern struct TrainerCard gTrainerCards[4]; void sub_80C3120(struct TrainerCard *arg0, u16 *arg1, u8 gameVersion); -void sub_80C4E74(u8 arg0, void (*callback)(void)); -void sub_80C30A4(u16 *arg0); +void TrainerCard_ShowLinkCard(u8 arg0, void (*callback)(void)); +void TrainerCard_GenerateCardForPlayer(struct TrainerCard *); +u8 sub_80C4904(u8); #endif // GUARD_TRAINER_CARD_H diff --git a/ld_script.txt b/ld_script.txt index 371077e53..da119cd4a 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -119,7 +119,6 @@ SECTIONS { asm/field_screen.o(.text); src/battle_setup.o(.text); src/cable_club.o(.text); - asm/cable_club.o(.text); src/trainer_see.o(.text); src/wild_encounter.o(.text); src/field_effect.o(.text); @@ -427,7 +426,7 @@ SECTIONS { src/title_screen.o(.rodata); data/field_screen.o(.rodata); src/battle_setup.o(.rodata); - data/cable_club.o(.rodata); + src/cable_club.o(.rodata); src/trainer_see.o(.rodata); src/wild_encounter.o(.rodata); src/field_effect.o(.rodata); diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 63154ae8b..56ff34528 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -1,6 +1,7 @@ #include "global.h" #include "battle.h" #include "battle_controllers.h" +#include "cable_club.h" #include "link.h" #include "task.h" #include "battle_ai_script_commands.h" @@ -18,7 +19,6 @@ extern u8 gUnknown_02022D0A; static EWRAM_DATA u8 sBattleBuffersTransferData[0x100] = {}; -extern void task00_08081A90(u8 taskId); // cable_club extern void sub_81B8D64(u8 battlerId, u8 arg1); // party_menu // this file's funcionts diff --git a/src/battle_dome.c b/src/battle_dome.c index 82384b43a..8de1c058c 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -68,7 +68,7 @@ extern bool8 sub_81A3610(void); extern u16 sub_81A4FF0(u8); extern u8 GetFrontierTrainerFrontSpriteId(u16); extern u8 GetFrontierOpponentClass(u16); -extern void sub_80F94E8(void); +extern void ReducePlayerPartyToThree(void); extern u8 gUnknown_0203CEF8[]; extern u16 gBattle_BG0_X; @@ -6132,7 +6132,7 @@ static void sub_8194E44(void) static void sub_8194EB4(void) { - sub_80F94E8(); + ReducePlayerPartyToThree(); } static void sub_8194EC0(void) diff --git a/src/cable_club.c b/src/cable_club.c index 489d1b9f7..c54df5f24 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -1,17 +1,74 @@ #include "global.h" #include "main.h" +#include "battle.h" +#include "battle_records.h" +#include "battle_setup.h" +#include "cable_club.h" +#include "data2.h" +#include "event_data.h" +#include "field_message_box.h" +#include "field_specials.h" +#include "field_weather.h" #include "international_string_util.h" #include "link.h" +#include "link_rfu.h" +#include "load_save.h" +#include "m4a.h" #include "menu.h" -#include "task.h" +#include "overworld.h" +#include "palette.h" +#include "rom_8011DC0.h" +#include "script.h" +#include "script_pokemon_util_80F87D8.h" +#include "sound.h" +#include "start_menu.h" #include "string_util.h" #include "strings.h" +#include "task.h" +#include "trade.h" +#include "trainer_card.h" +#include "window.h" +#include "constants/songs.h" -extern void sub_80B2634(u8 taskId); -extern void sub_80B2CEC(u8 taskId); -extern void sub_80B2D2C(u8 taskId); +extern u8 gUnknown_02032298[2]; +extern u8 gUnknown_0203CEF8[]; -void sub_80B236C(u8 arg0, u8 arg1) +static const struct WindowTemplate gUnknown_08550594 = { + .priority = 0, + .tilemapLeft = 16, + .tilemapTop = 11, + .width = 11, + .height = 2, + .paletteNum = 15, + .baseBlock = 0x0125, +}; +static const u8 *const gTrainerCardColorNames[] = { + gText_BronzeCard, + gText_CopperCard, + gText_SilverCard, + gText_GoldCard +}; + +static void sub_80B2634(u8 taskId); +static void sub_80B2688(u8 taskId); +static void sub_80B270C(u8 taskId); +static void sub_80B275C(u8 taskId); +static void sub_80B2804(u8 taskId); +static void sub_80B28A8(u8 taskId); +static void sub_80B2918(u8 taskId); +static void sub_80B2A08(u8 taskId); +static void sub_80B2C30(u8 taskId); +static void sub_80B2CB0(u8 taskId); +static void sub_80B2CEC(u8 taskId); +static void sub_80B2D2C(u8 taskId); +static bool8 sub_80B2D6C(u8 taskId); +static void sub_80B2EE4(u8 taskId); +static void sub_80B3144(u8 taskId); +static void sub_80B3194(u8 taskId); +static void sub_80B31E8(u8 taskId); +static void sub_80B3220(u8 taskId); + +static void sub_80B236C(u8 arg0, u8 arg1) { if (FindTaskIdByFunc(sub_80B2634) == 0xFF) { @@ -23,7 +80,7 @@ void sub_80B236C(u8 arg0, u8 arg1) } } -void sub_80B23B0(u16 windowId, u32 value) +static void sub_80B23B0(u16 windowId, u32 value) { u8 xPos; @@ -35,13 +92,13 @@ void sub_80B23B0(u16 windowId, u32 value) CopyWindowToVram(windowId, 3); } -void sub_80B241C(u16 windowId) +static void sub_80B241C(u16 windowId) { sub_819746C(windowId, FALSE); CopyWindowToVram(windowId, 3); } -void sub_80B243C(u8 taskId, u8 arg1) +static void sub_80B243C(u8 taskId, u8 arg1) { s16 *data = gTasks[taskId].data; @@ -55,7 +112,7 @@ void sub_80B243C(u8 taskId, u8 arg1) } } -u32 sub_80B2478(u8 lower, u8 upper) +static u32 sub_80B2478(u8 lower, u8 upper) { int playerCount; @@ -80,7 +137,7 @@ u32 sub_80B2478(u8 lower, u8 upper) } } -bool32 sub_80B24F8(u8 taskId) +static bool32 sub_80B24F8(u8 taskId) { if (HasLinkErrorOccurred() == TRUE) { @@ -90,7 +147,7 @@ bool32 sub_80B24F8(u8 taskId) return FALSE; } -bool32 sub_80B252C(u8 taskId) +static bool32 sub_80B252C(u8 taskId) { if ((gMain.newKeys & B_BUTTON) && IsLinkConnectionEstablished() == FALSE) @@ -102,7 +159,7 @@ bool32 sub_80B252C(u8 taskId) return FALSE; } -bool32 sub_80B2578(u8 taskId) +static bool32 sub_80B2578(u8 taskId) { if (IsLinkConnectionEstablished()) SetSuppressLinkErrorMessage(TRUE); @@ -116,7 +173,7 @@ bool32 sub_80B2578(u8 taskId) return FALSE; } -bool32 sub_80B25CC(u8 taskId) +static bool32 sub_80B25CC(u8 taskId) { if (GetSioMultiSI() == 1) { @@ -126,7 +183,7 @@ bool32 sub_80B25CC(u8 taskId) return FALSE; } -void sub_80B2600(u8 taskId) +static void sub_80B2600(u8 taskId) { gTasks[taskId].data[0]++; if (gTasks[taskId].data[0] == 10) @@ -135,3 +192,1108 @@ void sub_80B2600(u8 taskId) DestroyTask(taskId); } } + +static void sub_80B2634(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + if (data[0] == 0) + { + OpenLinkTimed(); + sub_800AB98(); + ResetLinkPlayers(); + data[5] = AddWindow(&gUnknown_08550594); + } + else if (data[0] > 9) + { + gTasks[taskId].func = sub_80B2688; + } + data[0]++; +} + +static void sub_80B2688(u8 taskId) +{ + u32 playerCount = GetLinkPlayerCount_2(); + + if (sub_80B252C(taskId) == TRUE + || sub_80B2578(taskId) == TRUE + || playerCount < 2) + return; + + SetSuppressLinkErrorMessage(TRUE); + gTasks[taskId].data[3] = 0; + if (IsLinkMaster() == TRUE) + { + PlaySE(SE_PIN); + ShowFieldAutoScrollMessage(gText_ConfirmLinkWhenPlayersReady); + gTasks[taskId].func = sub_80B270C; + } + else + { + PlaySE(SE_BOO); + ShowFieldAutoScrollMessage(gText_AwaitingLinkup); + gTasks[taskId].func = sub_80B2918; + } +} + +static void sub_80B270C(u8 taskId) +{ + if (sub_80B252C(taskId) == TRUE + || sub_80B25CC(taskId) == TRUE + || sub_80B24F8(taskId) == TRUE) + return; + + if (GetFieldMessageBoxMode() == FIELD_MESSAGE_BOX_HIDDEN) + { + gTasks[taskId].data[3] = 0; + gTasks[taskId].func = sub_80B275C; + } +} + +static void sub_80B275C(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + s32 linkPlayerCount = GetLinkPlayerCount_2(); + + if (sub_80B252C(taskId) == TRUE + || sub_80B25CC(taskId) == TRUE + || sub_80B24F8(taskId) == TRUE) + return; + + sub_80B243C(taskId, linkPlayerCount); + + if (!(gMain.newKeys & A_BUTTON)) + return; + + if (linkPlayerCount < data[1]) + return; + + sub_800AA04(linkPlayerCount); + sub_80B241C(data[5]); + ConvertIntToDecimalStringN(gStringVar1, linkPlayerCount, STR_CONV_MODE_LEFT_ALIGN, 1); + ShowFieldAutoScrollMessage(gText_ConfirmStartLinkWithXPlayers); + gTasks[taskId].func = sub_80B2804; +} + +static void sub_80B2804(u8 taskId) +{ + if (sub_80B252C(taskId) == TRUE + || sub_80B25CC(taskId) == TRUE + || sub_80B24F8(taskId) == TRUE) + return; + + if (GetFieldMessageBoxMode() == FIELD_MESSAGE_BOX_HIDDEN) + { + if (sub_800AA48() != GetLinkPlayerCount_2()) + { + ShowFieldAutoScrollMessage(gText_ConfirmLinkWhenPlayersReady); + gTasks[taskId].func = sub_80B270C; + } + else if (gMain.heldKeys & B_BUTTON) + { + ShowFieldAutoScrollMessage(gText_ConfirmLinkWhenPlayersReady); + gTasks[taskId].func = sub_80B270C; + } + else if (gMain.heldKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + sub_800A620(); + gTasks[taskId].func = sub_80B28A8; + } + } +} + +static void sub_80B28A8(u8 taskId) +{ + u8 local1 = gTasks[taskId].data[1]; + u8 local2 = gTasks[taskId].data[2]; + + if (sub_80B24F8(taskId) == TRUE + || sub_80B2D6C(taskId) == TRUE) + return; + + if (GetLinkPlayerCount_2() != sub_800AA48()) + { + gTasks[taskId].func = sub_80B2D2C; + } + else + { + gSpecialVar_Result = sub_80B2478(local1, local2); + if (gSpecialVar_Result != 0) + gTasks[taskId].func = sub_80B2A08; + } +} + +static void sub_80B2918(u8 taskId) +{ + u8 local1, local2; + struct TrainerCard *card; + + local1 = gTasks[taskId].data[1]; + local2 = gTasks[taskId].data[2]; + + if (sub_80B252C(taskId) == TRUE + || sub_80B24F8(taskId) == TRUE) + return; + + gSpecialVar_Result = sub_80B2478(local1, local2); + if (gSpecialVar_Result == 0) + return; + if (gSpecialVar_Result == 3 || gSpecialVar_Result == 4) + { + sub_800AC34(); + HideFieldMessageBox(); + gTasks[taskId].func = sub_80B2CB0; + } + else if (gSpecialVar_Result == 7 || gSpecialVar_Result == 9) + { + CloseLink(); + HideFieldMessageBox(); + gTasks[taskId].func = sub_80B2CB0; + } + else + { + gFieldLinkPlayerCount = GetLinkPlayerCount_2(); + gUnknown_03005DB4 = GetMultiplayerId(); + sub_800AA04(gFieldLinkPlayerCount); + card = (struct TrainerCard *)gBlockSendBuffer; + TrainerCard_GenerateCardForPlayer(card); + card->monSpecies[0] = GetMonData(&gPlayerParty[gUnknown_0203CEF8[0] - 1], MON_DATA_SPECIES, NULL); + card->monSpecies[1] = GetMonData(&gPlayerParty[gUnknown_0203CEF8[1] - 1], MON_DATA_SPECIES, NULL); + gTasks[taskId].func = sub_80B2C30; + } +} + +static void sub_80B2A08(u8 taskId) +{ + struct TrainerCard *card; + + if (sub_80B24F8(taskId) == TRUE) + return; + + if (gSpecialVar_Result == 4) + { + if (!Link_AnyPartnersPlayingRubyOrSapphire()) + { + sub_800AC34(); + HideFieldMessageBox(); + gTasks[taskId].func = sub_80B2CB0; + } + else + { + CloseLink(); + HideFieldMessageBox(); + gTasks[taskId].func = sub_80B2CB0; + } + } + else if (gSpecialVar_Result == 3) + { + sub_800AC34(); + HideFieldMessageBox(); + gTasks[taskId].func = sub_80B2CB0; + } + else if (gSpecialVar_Result == 7 || gSpecialVar_Result == 9) + { + CloseLink(); + HideFieldMessageBox(); + gTasks[taskId].func = sub_80B2CB0; + } + else + { + gFieldLinkPlayerCount = GetLinkPlayerCount_2(); + gUnknown_03005DB4 = GetMultiplayerId(); + sub_800AA04(gFieldLinkPlayerCount); + card = (struct TrainerCard *)gBlockSendBuffer; + TrainerCard_GenerateCardForPlayer(card); + card->monSpecies[0] = GetMonData(&gPlayerParty[gUnknown_0203CEF8[0] - 1], MON_DATA_SPECIES, NULL); + card->monSpecies[1] = GetMonData(&gPlayerParty[gUnknown_0203CEF8[1] - 1], MON_DATA_SPECIES, NULL); + gTasks[taskId].func = sub_80B2C30; + sub_800A4D8(2); + } +} + +bool32 sub_80B2AF4(u16 *arg0, u16 *arg1) +{ + int i; + int j; + bool32 result = FALSE; + int k = 0; + + gStringVar1[0] = EOS; + gStringVar2[0] = EOS; + + for (i = 0; i < 2; i++) + { + for (j = 0; j < 2; j++) + { + if (arg0[i] == arg1[j]) + { + if (k == 0) + { + StringCopy(gStringVar1, gSpeciesNames[arg0[i]]); + result = TRUE; + } + + if (k == 1) + { + StringCopy(gStringVar2, gSpeciesNames[arg0[i]]); + result = TRUE; + } + + k++; + } + } + } + + gSpecialVar_0x8005 = k; + + return result; +} + +static void task_map_chg_seq_0807EC34(u16 *a0, u32 taskId) +{ + struct TrainerCard *trainerCards = gTrainerCards; + + if (*a0 == 1) + { + if (gLinkType == 0x2266 || gLinkType == 0x2277) + { + if (sub_80B2AF4(trainerCards[0].monSpecies, trainerCards[1].monSpecies)) + { + *a0 = 11; + sub_800AC34(); + gTasks[taskId].func = sub_80B2CB0; + } + else + { + sub_80B241C(gTasks[taskId].data[5]); + EnableBothScriptContexts(); + DestroyTask(taskId); + } + } + else + { + sub_80B241C(gTasks[taskId].data[5]); + EnableBothScriptContexts(); + DestroyTask(taskId); + } + } + else + { + sub_800AC34(); + gTasks[taskId].func = sub_80B2CB0; + } +} + +static void sub_80B2C30(u8 taskId) +{ + u8 index; + struct TrainerCard *trainerCards; + + if (sub_80B24F8(taskId) == TRUE) + return; + + if (GetBlockReceivedStatus() != sub_800A9A8()) + return; + + for (index = 0; index < GetLinkPlayerCount(); index++) + { + sub_80C3120(&gTrainerCards[index], gBlockRecvBuffer[index], gLinkPlayers[index].version); + } + + SetSuppressLinkErrorMessage(FALSE); + ResetBlockReceivedFlags(); + task_map_chg_seq_0807EC34(&gSpecialVar_Result, taskId); +} + +static void sub_80B2CB0(u8 taskId) +{ + if (gReceivedRemoteLinkPlayers == FALSE) + { + sub_80B241C(gTasks[taskId].data[5]); + EnableBothScriptContexts(); + RemoveWindow(gTasks[taskId].data[5]); + DestroyTask(taskId); + } +} + +static void sub_80B2CEC(u8 taskId) +{ + gSpecialVar_Result = 5; + sub_80B241C(gTasks[taskId].data[5]); + sub_8098374(); + RemoveWindow(gTasks[taskId].data[5]); + EnableBothScriptContexts(); + DestroyTask(taskId); +} + +static void sub_80B2D2C(u8 taskId) +{ + gSpecialVar_Result = 6; + sub_80B241C(gTasks[taskId].data[5]); + RemoveWindow(gTasks[taskId].data[5]); + HideFieldMessageBox(); + EnableBothScriptContexts(); + DestroyTask(taskId); +} + +static bool8 sub_80B2D6C(u8 taskId) +{ + gTasks[taskId].data[4]++; + if (gTasks[taskId].data[4] > 600) + { + gTasks[taskId].func = sub_80B2D2C; + return TRUE; + } + + return FALSE; +} + +void sub_80B2DA4(u8 arg0) +{ + u8 r3 = 2; + u8 r2 = 2; + + switch (gSpecialVar_0x8004) + { + case 1: + r3 = 2; + gLinkType = 0x2233; + break; + case 2: + r3 = 2; + gLinkType = 0x2244; + break; + case 5: + r3 = 4; + r2 = 4; + gLinkType = 0x2255; + break; + case 9: + r3 = 2; + if (gSaveBlock2Ptr->frontier.lvlMode == 0) + { + gLinkType = 0x2266; + } + else + { + gLinkType = 0x2277; + } + break; + } + + sub_80B236C(r3, r2); +} + +void sub_80B2E4C(void) +{ + gLinkType = 0x1133; + gBattleTypeFlags = 0; + sub_80B236C(2, 2); +} + +void sub_80B2E74(void) +{ + gSpecialVar_Result = 0; + gLinkType = 0x3311; + gBattleTypeFlags = 0; + sub_80B236C(2, 4); +} + +void sub_80B2EA8(void) +{ + u32 taskId = FindTaskIdByFunc(sub_80B2EE4); + + if (taskId == 0xFF) + { + taskId = CreateTask(sub_80B2EE4, 80); + gTasks[taskId].data[0] = 0; + } +} + +static void sub_80B2EE4(u8 taskId) +{ + int playerCount; + int i; + + switch (gTasks[taskId].data[0]) + { + case 0: + if (gSpecialVar_Result == 1) + { + bool32 unk = FALSE; + bool32 isEnglishRSLinked = FALSE; + bool32 isJapaneseEmeraldLinked = FALSE; + + playerCount = GetLinkPlayerCount(); + for (i = 0; i < playerCount; i++) + { + u32 version = (u8)gLinkPlayers[i].version; + u32 language = gLinkPlayers[i].language; + + if (version == VERSION_RUBY || version == VERSION_SAPPHIRE) + { + if (language == LANGUAGE_JAPANESE) + { + unk = TRUE; + break; + } + else + { + isEnglishRSLinked = TRUE; + } + } + else if (version == VERSION_EMERALD) + { + if (language == LANGUAGE_JAPANESE) + { + isJapaneseEmeraldLinked = TRUE; + } + } + } + + if (isEnglishRSLinked && isJapaneseEmeraldLinked) + { + unk = TRUE; + } + + if (unk) + { + gSpecialVar_Result = 12; + sub_800AD10(); + gTasks[taskId].data[0] = 1; + return; + } + } + EnableBothScriptContexts(); + DestroyTask(taskId); + break; + case 1: + if (gReceivedRemoteLinkPlayers == FALSE) + { + EnableBothScriptContexts(); + DestroyTask(taskId); + } + break; + } +} + +void sub_80B2FD8(void) +{ + gLinkType = 0x4411; + gBattleTypeFlags = 0; + sub_80B236C(2, 4); +} + +void sub_80B3000(void) +{ + gLinkType = 0x6601; + gBattleTypeFlags = 0; + sub_80B236C(4, 4); +} + +void sub_80B3028(void) +{ + gLinkType = 0x6602; + gBattleTypeFlags = 0; + sub_80B236C(2, 4); +} + +u8 sub_80B3050(void) +{ + if (FuncIsActiveTask(sub_80B3144) != FALSE) + return 0xFF; + + switch (gSpecialVar_0x8004) + { + case 1: + gLinkType = 0x2233; + break; + case 2: + gLinkType = 0x2244; + break; + case 5: + gLinkType = 0x2255; + break; + case 9: + if (gSaveBlock2Ptr->frontier.lvlMode == 0) + { + gLinkType = 0x2266; + } + else + { + gLinkType = 0x2277; + } + break; + case 3: + gLinkType = 0x1111; + break; + case 4: + gLinkType = 0x3322; + break; + } + + return CreateTask(sub_80B3144, 80); +} + +static void sub_80B3144(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + if (data[0] == 0) + { + OpenLink(); + ResetLinkPlayers(); + CreateTask(task00_08081A90, 80); + } + else if (data[0] >= 10) + { + gTasks[taskId].func = sub_80B3194; + } + data[0]++; +} + +static void sub_80B3194(u8 taskId) +{ + if (GetLinkPlayerCount_2() >= 2) + { + if (IsLinkMaster() == TRUE) + gTasks[taskId].func = sub_80B31E8; + else + gTasks[taskId].func = sub_80B3220; + } +} + +static void sub_80B31E8(u8 taskId) +{ + if (sub_800AA48() == GetLinkPlayerCount_2()) + { + sub_800A620(); + gTasks[taskId].func = sub_80B3220; + } +} + +static void sub_80B3220(u8 taskId) +{ + if (gReceivedRemoteLinkPlayers == TRUE + && IsLinkPlayerDataExchangeComplete() == TRUE) + { + sub_800AB18(); + sub_8009F18(); + DestroyTask(taskId); + } +} + +void sub_80B3254(void) +{ + SaveGame(); +} + +static void sub_80B3260(int a0) +{ + switch (a0) + { + case 1: + gBattleTypeFlags = BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER; + break; + case 2: + gBattleTypeFlags = BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER; + break; + case 5: + ReducePlayerPartyToThree(); + gBattleTypeFlags = BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER | BATTLE_TYPE_MULTI; + break; + case 9: + gBattleTypeFlags = BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER | BATTLE_TYPE_MULTI; + break; + } +} + +static void sub_80B32B4(u8 taskId) +{ + struct Task* task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + FadeScreen(1, 0); + gLinkType = 0x2211; + ClearLinkCallback_2(); + task->data[0]++; + break; + case 1: + if (!gPaletteFade.active) + task->data[0]++; + break; + case 2: + task->data[1]++; + if (task->data[1] > 20) + task->data[0]++; + break; + case 3: + sub_800AC34(); + task->data[0]++; + break; + case 4: + if (!gReceivedRemoteLinkPlayers) + task->data[0]++; + break; + case 5: + if (gLinkPlayers[0].trainerId & 1) + PlayMapChosenOrBattleBGM(MUS_BATTLE32); + else + PlayMapChosenOrBattleBGM(MUS_BATTLE20); + + sub_80B3260(gSpecialVar_0x8004); + overworld_free_bg_tilemaps(); + gTrainerBattleOpponent_A = 0x800; + SetMainCallback2(CB2_InitBattle); + gMain.savedCallback = sub_80B360C; + DestroyTask(taskId); + break; + } +} + +static void sub_80B33BC(u8 taskId) +{ + int i; + s16* data = gTasks[taskId].data; + + switch (data[0]) + { + case 0: + FadeScreen(1, 0); + gLinkType = 0x2211; + ClearLinkCallback_2(); + data[0] = 1; + break; + case 1: + if (!gPaletteFade.active) + data[0] = 2; + break; + case 2: + SendBlock(0, &gLocalLinkPlayer, sizeof(gLocalLinkPlayer)); + data[0] = 3; + break; + case 3: + if (GetBlockReceivedStatus() == sub_800A9D8()) + { + for (i = 0; i < GetLinkPlayerCount(); i++) + { + struct LinkPlayer *player = (struct LinkPlayer *)gBlockRecvBuffer[i]; + gLinkPlayers[i] = *player; + sub_800B524(&gLinkPlayers[i]); + ResetBlockReceivedFlag(i); + } + data[0] = 4; + } + break; + case 4: + data[1]++; + if (data[1] > 20) + data[0] = 5; + break; + case 5: + sub_800ADF8(); + data[0] = 6; + break; + case 6: + if (sub_800A520()) + { + data[0] = 7; + } + break; + case 7: + if (gLinkPlayers[0].trainerId & 1) + PlayMapChosenOrBattleBGM(MUS_BATTLE32); + else + PlayMapChosenOrBattleBGM(MUS_BATTLE20); + + gLinkPlayers[0].linkType = 0x2211; + sub_80B3260(gSpecialVar_0x8004); + overworld_free_bg_tilemaps(); + gTrainerBattleOpponent_A = 0x800; + SetMainCallback2(CB2_InitBattle); + gMain.savedCallback = sub_80B360C; + DestroyTask(taskId); + break; + } +} + +static void sub_80B3554(void) +{ + u8 playerCount; + int i; + bool32 r4; + + switch (gMain.state) + { + case 0: + playerCount = GetLinkPlayerCount(); + r4 = FALSE; + for (i = 0; i < playerCount; i++) + { + u32 version = (u8)gLinkPlayers[i].version; + if (version == VERSION_FIRE_RED || version == VERSION_LEAF_GREEN) + { + r4 = TRUE; + break; + } + } + + if (r4) + { + gMain.state = 2; + } + else + { + sub_800AC34(); + gMain.state = 1; + } + break; + case 1: + if (gReceivedRemoteLinkPlayers == FALSE) + { + SetMainCallback2(CB2_ReturnToField); + } + break; + case 2: + SetMainCallback2(CB2_ReturnToField); + break; + } + RunTasks(); +} + +void sub_80B360C(void) +{ + gBattleTypeFlags &= ~BATTLE_TYPE_20; + Overworld_ResetMapMusic(); + LoadPlayerParty(); + SavePlayerBag(); + sub_813BF10(); + + if (gSpecialVar_0x8004 == 1 || gSpecialVar_0x8004 == 2) + { + UpdatePlayerLinkBattleRecords(gUnknown_03005DB4 ^ 1); + if (gWirelessCommType) + { + switch (gBattleOutcome) + { + case B_OUTCOME_WON: + sub_801B990(0, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId); + break; + case B_OUTCOME_LOST: + sub_801B990(1, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId); + break; + } + } + } + + if (InUnionRoom() == TRUE) + { + gMain.savedCallback = sub_80B3554; + } + else + { + gMain.savedCallback = c2_8056854; + } + + SetMainCallback2(sub_80A0514); +} + +void sub_80B36EC(void) +{ + if (gSpecialVar_0x8004 == 1 || gSpecialVar_0x8004 == 2 || gSpecialVar_0x8004 == 5 || gSpecialVar_0x8004 == 9) + { + LoadPlayerParty(); + SavePlayerBag(); + } + copy_saved_warp2_bank_and_enter_x_to_warp1(0x7F); +} + +void sub_80B371C(void) +{ + sub_80872B0(); +} + +static void sub_80B3728(u8 taskId) +{ + struct Task* task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + ShowFieldMessage(gText_PleaseWaitForLink); + task->data[0] = 1; + break; + case 1: + if (IsFieldMessageBoxHidden()) + { + sub_8087288(); + sub_8009628(gSpecialVar_0x8005); + task->data[0] = 2; + } + break; + case 2: + switch (sub_8087214()) + { + case 0: + break; + case 1: + HideFieldMessageBox(); + task->data[0] = 0; + sub_80872C4(); + SwitchTaskToFollowupFunc(taskId); + break; + case 2: + task->data[0] = 3; + break; + } + break; + case 3: + sub_808729C(); + sub_8197AE8(TRUE); + DestroyTask(taskId); + EnableBothScriptContexts(); + break; + } +} + +void sub_80B37D4(TaskFunc followupFunc) +{ + u8 taskId = CreateTask(sub_80B3728, 80); + SetTaskFuncWithFollowupFunc(taskId, sub_80B3728, followupFunc); + ScriptContext1_Stop(); +} + +static void sub_80B37FC(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + ScriptContext2_Enable(); + FadeScreen(1, 0); + ClearLinkCallback_2(); + task->data[0]++; + break; + case 1: + if (!gPaletteFade.active) + task->data[0]++; + break; + case 2: + gUnknown_02032298[0] = 0; + gUnknown_02032298[1] = 0; + m4aMPlayAllStop(); + sub_800AC34(); + task->data[0]++; + break; + case 3: + if (!gReceivedRemoteLinkPlayers) + { + SetMainCallback2(sub_80773AC); + DestroyTask(taskId); + } + break; + } +} + +static void sub_80B3894(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + switch (data[0]) + { + case 0: + ScriptContext2_Enable(); + FadeScreen(1, 0); + Rfu_set_zero(); + data[0]++; + break; + case 1: + if (!gPaletteFade.active) + data[0]++; + break; + case 2: + gUnknown_02032298[0] = 0; + gUnknown_02032298[1] = 0; + m4aMPlayAllStop(); + sub_800ADF8(); + data[0]++; + break; + case 3: + if (sub_800A520()) + { + sub_8013F78(); + DestroyTask(taskId); + } + break; + } +} + +void sub_80B3924(void) +{ + if (gWirelessCommType != 0) + { + sub_80B37D4(sub_80B3894); + } + else + { + sub_80B37D4(sub_80B37FC); + } +} + +static void sub_80B3950(void) +{ + CreateTask(sub_80B37FC, 80); +} + +void nullsub_37(void) +{ + +} + +void sub_80B3968(void) +{ + gLinkType = 0x2211; + + if (gWirelessCommType != 0) + { + sub_80B37D4(sub_80B33BC); + } + else + { + sub_80B37D4(sub_80B32B4); + } +} + +static void sub_80B39A4(void) +{ + u8 taskId = CreateTask(sub_80B3728, 80); + ScriptContext1_Stop(); +} + +void sp02A_crash_sound(void) +{ + TrainerCard_ShowLinkCard(gSpecialVar_0x8006, CB2_ReturnToFieldContinueScriptPlayMapMusic); +} + +bool32 sub_80B39D4(u8 linkPlayerIndex) +{ + u32 trainerCardColorIndex; + + gSpecialVar_0x8006 = linkPlayerIndex; + StringCopy(gStringVar1, gLinkPlayers[linkPlayerIndex].name); + + trainerCardColorIndex = sub_80C4904(linkPlayerIndex); + if (trainerCardColorIndex == 0) + return FALSE; + + StringCopy(gStringVar2, gTrainerCardColorNames[trainerCardColorIndex - 1]); + return TRUE; +} + +void task00_08081A90(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + task->data[0]++; + if (task->data[0] > 300) + { + CloseLink(); + SetMainCallback2(CB2_LinkError); + DestroyTask(taskId); + } + + if (gReceivedRemoteLinkPlayers) + { + if (gWirelessCommType == 0) + { + if (!sub_800AA60()) + { + CloseLink(); + SetMainCallback2(CB2_LinkError); + } + DestroyTask(taskId); + } + else + { + DestroyTask(taskId); + } + } +} + +static void sub_80B3AAC(u8 taskId) +{ + if (!gReceivedRemoteLinkPlayers) + { + EnableBothScriptContexts(); + DestroyTask(taskId); + } +} + +static void sub_80B3AD0(u8 taskId) +{ + sub_800AC34(); + gTasks[taskId].func = sub_80B3AAC; +} + +void sub_80B3AF8(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + switch (data[0]) + { + case 0: + if (gWirelessCommType != 0) + { + DestroyTask(taskId); + } + else + { + OpenLink(); + CreateTask(task00_08081A90, 1); + data[0]++; + } + break; + case 1: + if (++data[1] > 11) + { + data[1] = 0; + data[0]++; + } + break; + case 2: + if (GetLinkPlayerCount_2() >= sub_800AA48()) + { + if (IsLinkMaster()) + { + if (++data[1] > 30) + { + sub_800A620(); + data[0]++; + } + } + else + { + data[0]++; + } + } + break; + case 3: + if (gReceivedRemoteLinkPlayers == TRUE && IsLinkPlayerDataExchangeComplete() == TRUE) + { + DestroyTask(taskId); + } + break; + } +} + +void sub_80B3BC4(void) +{ + if (gWirelessCommType == 0) + { + gLinkType = 0x2288; + } +} diff --git a/src/field_message_box.c b/src/field_message_box.c index 19859ec0f..f45b6607d 100755 --- a/src/field_message_box.c +++ b/src/field_message_box.c @@ -131,7 +131,7 @@ void HideFieldMessageBox(void) gUnknown_020375BC = 0; } -u8 textbox_any_visible(void) +u8 GetFieldMessageBoxMode(void) { return gUnknown_020375BC; } diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c index 8dcb960b7..7e09a4d70 100644 --- a/src/mystery_event_menu.c +++ b/src/mystery_event_menu.c @@ -151,7 +151,7 @@ static void CB2_MysteryEventMenu(void) if (!IsTextPrinterActive(0)) { gMain.state++; - gLinkType = 21761; + gLinkType = 0x5501; OpenLink(); } break; diff --git a/src/rom_8011DC0.c b/src/rom_8011DC0.c index 56c31f89f..dc94cb9d5 100644 --- a/src/rom_8011DC0.c +++ b/src/rom_8011DC0.c @@ -1609,7 +1609,7 @@ void sub_80141A4(void) break; case 1: if (!FuncIsActiveTask(sub_80140E0)) - sub_80C4E74(GetMultiplayerId() ^ 1, CB2_ReturnToField); + TrainerCard_ShowLinkCard(GetMultiplayerId() ^ 1, CB2_ReturnToField); break; } @@ -1675,7 +1675,7 @@ void sub_80143E4(void *arg0, bool32 arg1) { u16 *argAsU16Ptr = arg0; - sub_80C30A4(argAsU16Ptr); + TrainerCard_GenerateCardForPlayer((struct TrainerCard *)argAsU16Ptr); if (arg1) argAsU16Ptr[48] = sub_801B39C(); else diff --git a/src/start_menu.c b/src/start_menu.c index 9d10aeaa4..dcb2c4154 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -88,7 +88,7 @@ extern void CB2_PartyMenuFromStartMenu(void); extern void CB2_PokeNav(void); extern void sub_80C4DDC(void (*)(void)); extern void sub_80C51C4(void (*)(void)); -extern void sub_80C4E74(u8, void (*)(void)); +extern void TrainerCard_ShowLinkCard(u8, void (*)(void)); extern void ScriptUnfreezeEventObjects(void); extern void sub_81A9EC8(void); extern void save_serialize_map(void); @@ -750,7 +750,7 @@ static bool8 StartMenuLinkModePlayerNameCallback(void) { play_some_sound(); overworld_free_bg_tilemaps(); - sub_80C4E74(gUnknown_03005DB4, CB2_ReturnToFieldWithOpenMenu); + TrainerCard_ShowLinkCard(gUnknown_03005DB4, CB2_ReturnToFieldWithOpenMenu); return TRUE; }