From f21c5ebea50685982daf1f81cda4c535615a6ef8 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 12 Nov 2017 23:58:05 -0500 Subject: [PATCH] through sub_800B1A0 --- asm/battle_tower.s | 4 +- asm/berry_blender.s | 14 +-- asm/cable_club.s | 12 +- asm/contest_link_80FC4F4.s | 2 +- asm/link.s | 203 +-------------------------------- asm/link_rfu.s | 4 +- asm/record_mixing.s | 6 +- asm/rom4.s | 18 +-- asm/rom6.s | 2 +- asm/rom_8011DC0.s | 2 +- asm/start_menu.s | 2 +- asm/trade.s | 28 ++--- asm/trainer_card.s | 2 +- common_syms/link.txt | 2 +- include/link.h | 4 +- include/reset_save_heap.h | 12 ++ include/strings.h | 3 + src/battle_2.c | 24 ++-- src/battle_controller_player.c | 4 +- src/battle_controllers.c | 4 +- src/evolution_scene.c | 4 +- src/link.c | 133 +++++++++++++++++---- src/main.c | 2 +- src/reshow_battle_screen.c | 2 +- 24 files changed, 200 insertions(+), 293 deletions(-) create mode 100644 include/reset_save_heap.h diff --git a/asm/battle_tower.s b/asm/battle_tower.s index c21a706f4..cd04f695d 100755 --- a/asm/battle_tower.s +++ b/asm/battle_tower.s @@ -5264,7 +5264,7 @@ _08164D14: ldrb r0, [r0] cmp r0, 0 beq _08164DB0 - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _08164DB0 @@ -5302,7 +5302,7 @@ _08164DB6: thumb_func_start sub_8164DCC sub_8164DCC: @ 8164DCC push {lr} - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08164DDA diff --git a/asm/berry_blender.s b/asm/berry_blender.s index 511120f2d..bee82b213 100644 --- a/asm/berry_blender.s +++ b/asm/berry_blender.s @@ -516,7 +516,7 @@ _0807FBBE: ldrb r0, [r0] cmp r0, 0 beq _0807FC14 - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _0807FC14 @@ -1122,7 +1122,7 @@ _08080126: bne _0808016A b _080804F8 _0808016A: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _08080174 @@ -3334,7 +3334,7 @@ sub_80814B0: @ 80814B0 ldrb r0, [r0] cmp r0, 0 beq _080814E4 - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _080814E4 @@ -4706,7 +4706,7 @@ sub_8081F94: @ 8081F94 ldrb r0, [r0] cmp r0, 0 beq _08081FB8 - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08081FB8 @@ -4852,7 +4852,7 @@ _080820EC: ldrb r0, [r0] cmp r0, 0 beq _0808218C - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _0808218C @@ -4968,7 +4968,7 @@ _080821D4: ldrb r0, [r0] cmp r0, 0 beq _08082254 - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08082254 @@ -6250,7 +6250,7 @@ sub_8082D28: @ 8082D28 lsls r0, 24 lsrs r1, r0, 24 _08082D3C: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08082DCC diff --git a/asm/cable_club.s b/asm/cable_club.s index 5b4e77619..ae818fdc9 100644 --- a/asm/cable_club.s +++ b/asm/cable_club.s @@ -2172,7 +2172,7 @@ sub_80B360C: @ 80B360C movs r5, 0x1 eors r0, r5 bl sub_813C2A0 - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _080B36B2 @@ -2512,7 +2512,7 @@ _080B391C: thumb_func_start sub_80B3924 sub_80B3924: @ 80B3924 push {lr} - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _080B3940 @@ -2552,7 +2552,7 @@ sub_80B3968: @ 80B3968 ldr r2, =0x00002211 adds r0, r2, 0 strh r0, [r1] - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _080B3994 @@ -2661,7 +2661,7 @@ _080B3A62: ldrb r0, [r0] cmp r0, 0 beq _080B3AA6 - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _080B3AA0 @@ -2752,7 +2752,7 @@ _080B3B20: beq _080B3B9E b _080B3BB8 _080B3B2A: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _080B3B40 @@ -2825,7 +2825,7 @@ _080B3BB8: thumb_func_start sub_80B3BC4 sub_80B3BC4: @ 80B3BC4 push {lr} - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _080B3BD6 diff --git a/asm/contest_link_80FC4F4.s b/asm/contest_link_80FC4F4.s index 135e04e5e..621e26038 100644 --- a/asm/contest_link_80FC4F4.s +++ b/asm/contest_link_80FC4F4.s @@ -147,7 +147,7 @@ sub_80FC5DC: @ 80FC5DC ldr r1, =gUnknown_02039F2A movs r0, 0x1 strb r0, [r1] - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0x1 bne _080FC60C diff --git a/asm/link.s b/asm/link.s index 931a7c26a..c5fcb39de 100644 --- a/asm/link.s +++ b/asm/link.s @@ -5,197 +5,6 @@ .text - thumb_func_start sub_800B138 -sub_800B138: @ 800B138 - push {lr} - sub sp, 0xC - ldr r1, =g2BlankTilesGfx - movs r0, 0 - movs r2, 0x20 - movs r3, 0 - bl LoadBgTiles - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x2 - movs r1, 0 - bl FillWindowPixelBuffer - ldr r0, =gUnknown_082ED224 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - ldr r0, =gText_CommErrorCheckConnections - str r0, [sp, 0x8] - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0x2 - movs r3, 0 - bl box_print - movs r0, 0x1 - bl PutWindowTilemap - movs r0, 0x2 - bl PutWindowTilemap - movs r0, 0x1 - movs r1, 0 - bl CopyWindowToVram - movs r0, 0x2 - movs r1, 0x3 - bl CopyWindowToVram - add sp, 0xC - pop {r0} - bx r0 - .pool - thumb_func_end sub_800B138 - - thumb_func_start sub_800B1A0 -sub_800B1A0: @ 800B1A0 - push {r4,lr} - sub sp, 0xC - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x1E - beq _0800B20C - cmp r0, 0x1E - bgt _0800B1C4 - cmp r0, 0 - beq _0800B1D8 - cmp r0, 0x2 - beq _0800B1F2 - b _0800B260 - .pool -_0800B1C4: - cmp r0, 0x5A - beq _0800B20C - cmp r0, 0x5A - bgt _0800B1D2 - cmp r0, 0x3C - beq _0800B20C - b _0800B260 -_0800B1D2: - cmp r0, 0x82 - beq _0800B214 - b _0800B260 -_0800B1D8: - ldr r0, =sLinkErrorBuffer - ldrb r0, [r0, 0x6] - cmp r0, 0 - beq _0800B1EC - bl sub_800B080 - b _0800B260 - .pool -_0800B1EC: - bl sub_800B138 - b _0800B260 -_0800B1F2: - movs r0, 0 - bl ShowBg - ldr r0, =sLinkErrorBuffer - ldrb r0, [r0, 0x6] - cmp r0, 0 - beq _0800B260 - movs r0, 0x1 - bl ShowBg - b _0800B260 - .pool -_0800B20C: - movs r0, 0x16 - bl PlaySE - b _0800B260 -_0800B214: - ldr r0, =gSerialIsRFU - ldrb r0, [r0] - cmp r0, 0x2 - bne _0800B244 - ldr r0, =gUnknown_082ED224 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - ldr r0, =gText_ABtnTitleScreen - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0x3 - movs r2, 0x2 - movs r3, 0x14 - bl box_print - b _0800B260 - .pool -_0800B244: - cmp r0, 0x1 - bne _0800B260 - ldr r0, =gUnknown_082ED224 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - ldr r0, =gText_ABtnRegistrationCounter - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0x3 - movs r2, 0x2 - movs r3, 0x14 - bl box_print -_0800B260: - ldr r0, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r0, r2 - ldrb r1, [r1] - cmp r1, 0xA0 - bne _0800B2D0 - ldr r4, =gSerialIsRFU - ldrb r2, [r4] - cmp r2, 0x1 - bne _0800B2A8 - ldrh r0, [r0, 0x2E] - ands r2, r0 - cmp r2, 0 - beq _0800B2C2 - movs r0, 0x15 - bl PlaySE - movs r0, 0 - strb r0, [r4] - ldr r1, =sLinkErrorBuffer - movs r0, 0 - strb r0, [r1, 0x6] - bl sub_81700F8 - b _0800B2C2 - .pool -_0800B2A8: - cmp r2, 0x2 - bne _0800B2C2 - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0800B2C2 - bl rfu_REQ_stopMode - bl rfu_waitREQComplete - bl DoSoftReset -_0800B2C2: - ldr r0, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r0, r2 - ldrb r1, [r1] - cmp r1, 0xA0 - beq _0800B2DC -_0800B2D0: - movs r2, 0x87 - lsls r2, 3 - adds r1, r0, r2 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_0800B2DC: - add sp, 0xC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_800B1A0 - thumb_func_start sub_800B2E8 sub_800B2E8: @ 800B2E8 ldr r0, =0x04000128 @@ -346,7 +155,7 @@ _0800B3F4: thumb_func_start HandleLinkConnection HandleLinkConnection: @ 800B40C push {r4,r5,lr} - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _0800B45C @@ -401,7 +210,7 @@ sub_800B488: @ 800B488 ldrb r0, [r0] cmp r0, 0 bne _0800B498 - ldr r1, =gSerialIsRFU + ldr r1, =gWirelessCommType movs r0, 0x1 strb r0, [r1] _0800B498: @@ -417,7 +226,7 @@ sub_800B4A4: @ 800B4A4 ldrb r1, [r0] cmp r1, 0 bne _0800B4B2 - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType strb r1, [r0] _0800B4B2: pop {r0} @@ -432,7 +241,7 @@ sub_800B4C0: @ 800B4C0 ldrb r1, [r0] cmp r1, 0 bne _0800B4CE - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType strb r1, [r0] _0800B4CE: pop {r0} @@ -443,7 +252,7 @@ _0800B4CE: thumb_func_start sub_800B4DC sub_800B4DC: @ 800B4DC push {lr} - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _0800B4FC @@ -477,7 +286,7 @@ _0800B514: thumb_func_start sub_800B518 sub_800B518: @ 800B518 - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] bx lr .pool diff --git a/asm/link_rfu.s b/asm/link_rfu.s index 934de184f..1e7f4a182 100644 --- a/asm/link_rfu.s +++ b/asm/link_rfu.s @@ -884,7 +884,7 @@ sub_800E3A8: @ 800E3A8 mov r5, r8 push {r5-r7} sub sp, 0x20 - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _0800E3BE @@ -5967,7 +5967,7 @@ sub_8010DB4: @ 8010DB4 cmp r0, 0 beq _08010DE4 _08010DDE: - ldr r1, =gSerialIsRFU + ldr r1, =gWirelessCommType movs r0, 0x2 strb r0, [r1] _08010DE4: diff --git a/asm/record_mixing.s b/asm/record_mixing.s index 1c84ba801..d6b331834 100644 --- a/asm/record_mixing.s +++ b/asm/record_mixing.s @@ -621,7 +621,7 @@ _080E726C: bne _080E730A movs r0, 0x4 strh r0, [r5] - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _080E7296 @@ -664,7 +664,7 @@ _080E72C0: ldr r0, [r0] bl Free bl sub_808729C - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _080E72F8 @@ -2393,7 +2393,7 @@ _080E80C0: lsls r0, 24 cmp r0, 0 bne _080E810A - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _080E80E8 diff --git a/asm/rom4.s b/asm/rom4.s index 819cbea81..575b18991 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -3395,7 +3395,7 @@ c2_8056854: @ 8086140 ldr r0, =c1_link_related bl set_callback1 bl sub_8086C2C - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08086174 @@ -3586,7 +3586,7 @@ sub_808631C: @ 808631C bne _0808632E bl CloseLink _0808632E: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08086348 @@ -3768,7 +3768,7 @@ _080864DA: bl cur_mapheader_run_tileset_funcs_after_some_cpuset b _08086506 _080864E0: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08086506 @@ -4056,7 +4056,7 @@ _08086766: bl cur_mapheader_run_tileset_funcs_after_some_cpuset b _08086792 _0808676C: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08086792 @@ -4565,7 +4565,7 @@ _08086BCA: thumb_func_start c1_link_related c1_link_related: @ 8086BD8 push {r4,lr} - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08086BF2 @@ -4631,7 +4631,7 @@ c1_link_related_func_set: @ 8086C50 thumb_func_start sub_8086C64 sub_8086C64: @ 8086C64 push {lr} - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08086C82 @@ -5029,7 +5029,7 @@ _08086FC0: movs r0, 0x11 strh r0, [r1] _08086FC6: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08086FFC @@ -5926,7 +5926,7 @@ _08087666: thumb_func_start sub_808766C sub_808766C: @ 808766C push {lr} - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _08087688 @@ -5946,7 +5946,7 @@ _0808768A: thumb_func_start sub_8087690 sub_8087690: @ 8087690 push {lr} - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _080876B0 diff --git a/asm/rom6.s b/asm/rom6.s index 20058db9d..d4ad771aa 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -11823,7 +11823,7 @@ _0813B790: b _0813B7C6 .pool _0813B7A8: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _0813B7B4 diff --git a/asm/rom_8011DC0.s b/asm/rom_8011DC0.s index 5a7c8f77e..a0be88e11 100644 --- a/asm/rom_8011DC0.s +++ b/asm/rom_8011DC0.s @@ -27729,7 +27729,7 @@ sub_8020C70: @ 8020C70 ldrb r0, [r0] cmp r0, 0 beq _08020C8E - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _08020CAC diff --git a/asm/start_menu.s b/asm/start_menu.s index 0da38ba4b..072bcfdc7 100644 --- a/asm/start_menu.s +++ b/asm/start_menu.s @@ -1712,7 +1712,7 @@ _080A05AC: movs r2, 0x10 movs r3, 0 bl BeginNormalPaletteFade - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _080A0620 diff --git a/asm/trade.s b/asm/trade.s index aafa9f245..25017bcfd 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -135,7 +135,7 @@ _08077258: thumb_func_start sub_8077260 sub_8077260: @ 8077260 push {lr} - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08077280 @@ -409,7 +409,7 @@ _080774B2: ldr r0, [r0] adds r0, 0xA8 strb r2, [r0] - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08077528 @@ -531,7 +531,7 @@ _08077600: ldr r0, [r0] adds r0, 0xA8 strb r2, [r0] - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 bne _0807762A @@ -543,7 +543,7 @@ _0807762A: b _08077B46 .pool _08077648: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08077680 @@ -1182,7 +1182,7 @@ _08077C28: b _080780D8 .pool _08077C3C: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08077C50 @@ -1780,7 +1780,7 @@ sub_807816C: @ 807816C adds r0, 0x7E ldrb r0, [r0] strb r0, [r1, 0x1] - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _080781B4 @@ -1809,7 +1809,7 @@ sub_80781C8: @ 80781C8 ldr r5, =gMain ldr r0, =sub_80773AC str r0, [r5, 0x8] - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08078220 @@ -4004,7 +4004,7 @@ sub_8079490: @ 8079490 ands r0, r1 cmp r0, 0 bne _080794C4 - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _080794B4 @@ -4029,7 +4029,7 @@ _080794C4: thumb_func_start sub_80794CC sub_80794CC: @ 80794CC push {lr} - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _08079518 @@ -7507,7 +7507,7 @@ _0807B0F0: ands r0, r1 cmp r0, 0 bne _0807B116 - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _0807B110 @@ -13831,7 +13831,7 @@ _0807EDC0: movs r0, 0x15 bl IncrementGameStat _0807EDCE: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _0807EDF6 @@ -14044,7 +14044,7 @@ _0807EFA4: lsrs r0, 24 cmp r0, 0x1 bne _0807F03A - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _0807EFD8 @@ -14071,7 +14071,7 @@ _0807EFE4: b _0807F03A .pool _0807EFF0: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _0807F028 @@ -14141,7 +14141,7 @@ c2_080543C4: @ 807F068 ldr r0, [r4] bl Free str r5, [r4] - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0 beq _0807F0B6 diff --git a/asm/trainer_card.s b/asm/trainer_card.s index 4f1183477..ddb0271a6 100644 --- a/asm/trainer_card.s +++ b/asm/trainer_card.s @@ -187,7 +187,7 @@ _080C2830: bl sub_80C4630 b _080C28D4 _080C2836: - ldr r0, =gSerialIsRFU + ldr r0, =gWirelessCommType ldrb r0, [r0] cmp r0, 0x1 bne _080C2852 diff --git a/common_syms/link.txt b/common_syms/link.txt index 657f97396..564802b1a 100644 --- a/common_syms/link.txt +++ b/common_syms/link.txt @@ -16,7 +16,7 @@ gUnknown_030030EC gUnknown_030030F0 gUnknown_030030F4 gSuppressLinkErrorMessage -gSerialIsRFU +gWirelessCommType gSavedLinkPlayerCount gSendCmd gSavedMultiplayerId diff --git a/include/link.h b/include/link.h index 2689f2596..60f7a27fa 100644 --- a/include/link.h +++ b/include/link.h @@ -163,7 +163,7 @@ extern u8 gShouldAdvanceLinkState; extern struct LinkPlayer gLinkPlayers[]; extern u16 word_3002910[]; extern bool8 gReceivedRemoteLinkPlayers; -extern bool8 gSerialIsRFU; +extern bool8 gWirelessCommType; void Task_DestroySelf(u8); void OpenLink(void); @@ -234,7 +234,7 @@ extern u8 gUnknown_030030EC[MAX_LINK_PLAYERS]; extern u8 gUnknown_030030F0[MAX_LINK_PLAYERS]; extern u16 gUnknown_030030F4; extern u8 gSuppressLinkErrorMessage; -extern bool8 gSerialIsRFU; +extern bool8 gWirelessCommType; extern bool8 gSavedLinkPlayerCount; extern u8 gSavedMultiplayerId; extern struct LinkTestBGInfo gLinkTestBGInfo; diff --git a/include/reset_save_heap.h b/include/reset_save_heap.h new file mode 100644 index 000000000..12fd186ec --- /dev/null +++ b/include/reset_save_heap.h @@ -0,0 +1,12 @@ +#ifndef GUARD_RESET_SAVE_HEAP_H +#define GUARD_RESET_SAVE_HEAP_H + +// Exported type declarations + +// Exported RAM declarations + +// Exported ROM declarations + +void sub_81700F8(void); + +#endif //GUARD_RESET_SAVE_HEAP_H diff --git a/include/strings.h b/include/strings.h index 299d637b8..f3efe88e4 100644 --- a/include/strings.h +++ b/include/strings.h @@ -77,5 +77,8 @@ extern const u8 gText_RegisteredDataDeleted[]; extern const u8 gUnknown_085EA79D[]; extern const u8 gText_CommErrorEllipsis[]; extern const u8 gText_MoveCloserToLinkPartner[]; +extern const u8 gText_CommErrorCheckConnections[]; +extern const u8 gText_ABtnTitleScreen[]; +extern const u8 gText_ABtnRegistrationCounter[]; #endif //GUARD_STRINGS_H diff --git a/src/battle_2.c b/src/battle_2.c index a69a16dac..41b2b1313 100644 --- a/src/battle_2.c +++ b/src/battle_2.c @@ -735,7 +735,7 @@ static void CB2_HandleStartBattle(void) sub_805EF14(); gBattleCommunication[MULTIUSE_STATE] = 1; } - if (gSerialIsRFU) + if (gWirelessCommType) sub_800E0E8(); break; case 1: @@ -759,7 +759,7 @@ static void CB2_HandleStartBattle(void) SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32); gBattleCommunication[MULTIUSE_STATE] = 2; } - if (gSerialIsRFU) + if (gWirelessCommType) sub_800DFB4(0, 0); } } @@ -930,7 +930,7 @@ static void CB2_HandleStartMultiPartnerBattle(void) sub_805EF14(); gBattleCommunication[MULTIUSE_STATE] = 1; } - if (gSerialIsRFU) + if (gWirelessCommType) sub_800E0E8(); // fall through case 1: @@ -961,7 +961,7 @@ static void CB2_HandleStartMultiPartnerBattle(void) gBattleCommunication[MULTIUSE_STATE] = 2; } - if (gSerialIsRFU) + if (gWirelessCommType) sub_800DFB4(0, 0); } } @@ -1238,14 +1238,14 @@ static void CB2_PreInitMultiBattle(void) if (sub_800A520() && !gPaletteFade.active) { gBattleCommunication[MULTIUSE_STATE]++; - if (gSerialIsRFU) + if (gWirelessCommType) sub_800ADF8(); else sub_800AC34(); } break; case 3: - if (gSerialIsRFU) + if (gWirelessCommType) { if (sub_8010500()) { @@ -1330,7 +1330,7 @@ static void CB2_HandleStartMultiBattle(void) sub_805EF14(); gBattleCommunication[MULTIUSE_STATE] = 1; } - if (gSerialIsRFU) + if (gWirelessCommType) sub_800E0E8(); break; case 1: @@ -1348,7 +1348,7 @@ static void CB2_HandleStartMultiBattle(void) SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32); gBattleCommunication[MULTIUSE_STATE]++; } - if (gSerialIsRFU) + if (gWirelessCommType) sub_800DFB4(0, 0); } } @@ -2133,12 +2133,12 @@ static void sub_8038F34(void) } break; case 8: - if (!gSerialIsRFU) + if (!gWirelessCommType) sub_800AC34(); gBattleCommunication[MULTIUSE_STATE]++; break; case 9: - if (!gMain.field_439_x4 || gSerialIsRFU || gReceivedRemoteLinkPlayers != 1) + if (!gMain.field_439_x4 || gWirelessCommType || gReceivedRemoteLinkPlayers != 1) { gMain.field_439_x4 = 0; SetMainCallback2(gMain.savedCallback); @@ -2317,13 +2317,13 @@ static void sub_803939C(void) case 8: if (--gBattleCommunication[1] == 0) { - if (gMain.field_439_x4 && !gSerialIsRFU) + if (gMain.field_439_x4 && !gWirelessCommType) sub_800AC34(); gBattleCommunication[MULTIUSE_STATE]++; } break; case 9: - if (!gMain.field_439_x4 || gSerialIsRFU || gReceivedRemoteLinkPlayers != 1) + if (!gMain.field_439_x4 || gWirelessCommType || gReceivedRemoteLinkPlayers != 1) { gMain.field_439_x4 = 0; if (!gPaletteFade.active) diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 2a882de99..9b6c3c46d 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -896,7 +896,7 @@ static void HandleMoveSwitchting(void) static void sub_80586F8(void) { - if (gSerialIsRFU == 0) + if (gWirelessCommType == 0) { if (gReceivedRemoteLinkPlayers == 0) { @@ -932,7 +932,7 @@ void sub_80587B0(void) { if (sub_800A520()) { - if (gSerialIsRFU == 0) + if (gWirelessCommType == 0) sub_800AC34(); else sub_800ADF8(); diff --git a/src/battle_controllers.c b/src/battle_controllers.c index b82a0a40e..b3d93d759 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -59,7 +59,7 @@ void HandleLinkBattleSetup(void) { if (gBattleTypeFlags & BATTLE_TYPE_LINK) { - if (gSerialIsRFU) + if (gWirelessCommType) sub_800B488(); if (!gReceivedRemoteLinkPlayers) OpenLink(); @@ -780,7 +780,7 @@ static void Task_HandleSendLinkBuffersData(u8 taskId) gTasks[taskId].data[11]++; break; case 2: - if (gSerialIsRFU) + if (gWirelessCommType) { gTasks[taskId].data[11]++; } diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 569dcfe35..03b9dec3f 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -402,7 +402,7 @@ static void CB2_TradeEvolutionSceneLoadGraphics(void) } break; case 6: - if (gSerialIsRFU) + if (gWirelessCommType) { sub_800E0E8(); sub_800DFB4(0, 0); @@ -1185,7 +1185,7 @@ static void Task_TradeEvolutionScene(u8 taskID) case 5: if (!gPaletteFade.active) { - if (gSerialIsRFU) + if (gWirelessCommType) sub_800E084(); Free(GetBgTilemapBuffer(3)); diff --git a/src/link.c b/src/link.c index 09f3b6d6f..1ee4ade4f 100644 --- a/src/link.c +++ b/src/link.c @@ -3,6 +3,7 @@ #include "global.h" #include "m4a.h" #include "malloc.h" +#include "reset_save_heap.h" #include "save.h" #include "bg.h" #include "window.h" @@ -21,6 +22,7 @@ #include "new_menu_helpers.h" #include "text.h" #include "strings.h" +#include "songs.h" #include "sound.h" #include "trade.h" #include "battle.h" @@ -84,7 +86,7 @@ bool8 gUnknown_030030EC[MAX_LINK_PLAYERS]; bool8 gUnknown_030030F0[MAX_LINK_PLAYERS]; u16 gUnknown_030030F4; u8 gSuppressLinkErrorMessage; -bool8 gSerialIsRFU; +bool8 gWirelessCommType; bool8 gSavedLinkPlayerCount; u16 gSendCmd[8]; u8 gSavedMultiplayerId; @@ -148,7 +150,7 @@ static void sub_800AD88(void); static void sub_800AE30(void); static void sub_800AE5C(void); static void sub_800AEB4(void); -void sub_800B1A0(void); +static void sub_800B1A0(void); u8 sub_800B2F8(void); void sub_800B4A4(void); void DisableSerial(void); @@ -340,7 +342,7 @@ void OpenLink(void) { int i; - if (!gSerialIsRFU) + if (!gWirelessCommType) { ResetSerial(); InitLink(); @@ -372,7 +374,7 @@ void OpenLink(void) void CloseLink(void) { gReceivedRemoteLinkPlayers = FALSE; - if (gSerialIsRFU) + if (gWirelessCommType) { sub_800EDD4(); } @@ -692,7 +694,7 @@ void BuildSendCmd(u16 command) void sub_8009F18(void) { - if (gSerialIsRFU) + if (gWirelessCommType) { sub_800F804(); } @@ -701,7 +703,7 @@ void sub_8009F18(void) bool32 sub_8009F3C(void) { - if (gSerialIsRFU) + if (gWirelessCommType) { return sub_800F7E4(); } @@ -722,7 +724,7 @@ static void sub_8009F70(void) void ClearLinkCallback(void) { - if (gSerialIsRFU) + if (gWirelessCommType) { Rfu_set_zero(); } @@ -734,7 +736,7 @@ void ClearLinkCallback(void) void ClearLinkCallback_2(void) { - if (gSerialIsRFU) + if (gWirelessCommType) { Rfu_set_zero(); } @@ -746,7 +748,7 @@ void ClearLinkCallback_2(void) u8 GetLinkPlayerCount(void) { - if (gSerialIsRFU) + if (gWirelessCommType) { return sub_80104F4(); } @@ -1004,7 +1006,7 @@ static void sub_800A3F8(void) void sub_800A418(void) { gUnknown_020223C0 = 0; - if (gSerialIsRFU) + if (gWirelessCommType) { sub_800F850(); } @@ -1026,7 +1028,7 @@ void sub_800A458(void) u8 GetMultiplayerId(void) { - if (gSerialIsRFU == TRUE) + if (gWirelessCommType == TRUE) { return rfu_get_multiplayer_id(); } @@ -1043,7 +1045,7 @@ u8 bitmask_all_link_players_but_self(void) bool8 SendBlock(u8 unused, const void *src, u16 size) { - if (gSerialIsRFU == TRUE) + if (gWirelessCommType == TRUE) { return sub_800FE84(src, size); } @@ -1052,7 +1054,7 @@ bool8 SendBlock(u8 unused, const void *src, u16 size) bool8 sub_800A4D8(u8 a0) { - if (gSerialIsRFU == TRUE) + if (gWirelessCommType == TRUE) { return sub_8010100(a0); } @@ -1067,7 +1069,7 @@ bool8 sub_800A4D8(u8 a0) bool8 sub_800A520(void) { - if (gSerialIsRFU == TRUE) + if (gWirelessCommType == TRUE) { return sub_8010500(); } @@ -1076,7 +1078,7 @@ bool8 sub_800A520(void) u8 GetBlockReceivedStatus(void) { - if (gSerialIsRFU == TRUE) + if (gWirelessCommType == TRUE) { return sub_800FCD8(); } @@ -1085,7 +1087,7 @@ u8 GetBlockReceivedStatus(void) static void SetBlockReceivedFlag(u8 who) { - if (gSerialIsRFU == TRUE) + if (gWirelessCommType == TRUE) { sub_800F6FC(who); } @@ -1099,7 +1101,7 @@ void ResetBlockReceivedFlags(void) { int i; - if (gSerialIsRFU == TRUE) + if (gWirelessCommType == TRUE) { for (i = 0; i < MAX_RFU_PLAYERS; i ++) { @@ -1117,7 +1119,7 @@ void ResetBlockReceivedFlags(void) void ResetBlockReceivedFlag(u8 who) { - if (gSerialIsRFU == TRUE) + if (gWirelessCommType == TRUE) { sub_800F728(who); } @@ -1394,7 +1396,7 @@ u8 GetLinkPlayerCount_2(void) bool8 IsLinkMaster(void) { - if (gSerialIsRFU) + if (gWirelessCommType) { return Rfu_IsMaster(); } @@ -1408,7 +1410,7 @@ u8 sub_800ABE8(void) void sub_800ABF4(u16 a0) { - if (gSerialIsRFU == TRUE) + if (gWirelessCommType == TRUE) { task_add_05_task_del_08FA224_when_no_RfuFunc(); } @@ -1425,7 +1427,7 @@ void sub_800ABF4(u16 a0) void sub_800AC34(void) { - if (gSerialIsRFU == TRUE) + if (gWirelessCommType == TRUE) { task_add_05_task_del_08FA224_when_no_RfuFunc(); } @@ -1480,7 +1482,7 @@ static void sub_800ACAC(void) void sub_800AD10(void) { - if (gSerialIsRFU == TRUE) + if (gWirelessCommType == TRUE) { task_add_05_task_del_08FA224_when_no_RfuFunc(); } @@ -1539,7 +1541,7 @@ static void sub_800AD88(void) void sub_800ADF8(void) { - if (gSerialIsRFU == TRUE) + if (gWirelessCommType == TRUE) { sub_8010434(); } @@ -1624,11 +1626,11 @@ void CB2_LinkError(void) FillPalette(0, 0, 2); ResetTasks(); remove_some_task(); - if (gSerialIsRFU) + if (gWirelessCommType) { if (!sLinkErrorBuffer.unk_06) { - gSerialIsRFU = 3; + gWirelessCommType = 3; } sub_800E604(); } @@ -1677,3 +1679,84 @@ void sub_800B080(void) CopyWindowToVram(0, 0); CopyWindowToVram(2, 3); } + +void sub_800B138(void) +{ + LoadBgTiles(0, g2BlankTilesGfx, 0x20, 0); + FillWindowPixelBuffer(1, 0x00); + FillWindowPixelBuffer(2, 0x00); + box_print(1, 3, 2, 0, gUnknown_082ED224, 0, gText_CommErrorCheckConnections); + PutWindowTilemap(1); + PutWindowTilemap(2); + CopyWindowToVram(1, 0); + CopyWindowToVram(2, 3); +} + +static void sub_800B1A0(void) +{ + switch (gMain.state) + { + case 00: + if (sLinkErrorBuffer.unk_06) + { + sub_800B080(); + } + else + { + sub_800B138(); + } + break; + case 02: + ShowBg(0); + if (sLinkErrorBuffer.unk_06) + { + ShowBg(1); + } + break; + case 30: + PlaySE(SE_BOO); + break; + case 60: + PlaySE(SE_BOO); + break; + case 90: + PlaySE(SE_BOO); + break; + case 130: + if (gWirelessCommType == 2) + { + box_print(0, 3, 2, 20, gUnknown_082ED224, 0, gText_ABtnTitleScreen); + } + else if (gWirelessCommType == 1) + { + box_print(0, 3, 2, 20, gUnknown_082ED224, 0, gText_ABtnRegistrationCounter); + } + break; + } + if (gMain.state == 160) + { + if (gWirelessCommType == 1) + { + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_PIN); + gWirelessCommType = 0; + sLinkErrorBuffer.unk_06 = 0; + sub_81700F8(); + } + } + else if (gWirelessCommType == 2) + { + if (gMain.newKeys & A_BUTTON) + { + rfu_REQ_stopMode(); + rfu_waitREQComplete(); + DoSoftReset(); + } + } + } + if (gMain.state != 160) + { + gMain.state ++; + } +} diff --git a/src/main.c b/src/main.c index a67bed035..c2baa23af 100644 --- a/src/main.c +++ b/src/main.c @@ -336,7 +336,7 @@ extern void ProcessDma3Requests(void); static void VBlankIntr(void) { - if (gSerialIsRFU != FALSE) + if (gWirelessCommType != FALSE) LinkVSync(); else if (gLinkVSyncDisabled == FALSE) sub_800B9B8(); diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index 87ad20ed7..b0f4dcbf4 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -177,7 +177,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void) ActionSelectionCreateCursorAt(gActionSelectionCursor[gBankInMenu], 0); - if (gSerialIsRFU != 0 && gReceivedRemoteLinkPlayers != 0) + if (gWirelessCommType != 0 && gReceivedRemoteLinkPlayers != 0) { sub_800E0E8(); sub_800DFB4(0, 0);