From 741b8adf9a43989182ff3648bf14e3236d4b5ce9 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 30 Jan 2018 23:23:35 +0100 Subject: [PATCH] decompile mystery event menu --- asm/cable_club.s | 42 +- asm/link.s | 108 +-- asm/main_menu.s | 2 +- asm/mystery_event_menu.s | 669 ------------------ asm/overworld.s | 2 +- asm/pokenav.s | 32 +- asm/record_mixing.s | 12 +- asm/trade.s | 18 +- data/mystery_event_menu.s | 12 - data/scripts/cable_club.inc | 34 +- .../maps/BattleFrontier_BattleTowerLobby.inc | 8 +- .../maps/LilycoveCity_ContestLobby.inc | 6 +- data/scripts/pokeblocks.inc | 8 +- data/specials.inc | 2 +- include/link.h | 8 +- include/mystery_event_menu.h | 6 + include/strings.h | 8 + ld_script.txt | 4 +- src/battle_controllers.c | 6 +- src/mystery_event_menu.c | 303 ++++++++ sym_common.txt | 2 +- sym_ewram.txt | 4 +- 22 files changed, 465 insertions(+), 831 deletions(-) delete mode 100644 asm/mystery_event_menu.s delete mode 100644 data/mystery_event_menu.s create mode 100644 include/mystery_event_menu.h create mode 100644 src/mystery_event_menu.c diff --git a/asm/cable_club.s b/asm/cable_club.s index 611b87eef..76eba625c 100644 --- a/asm/cable_club.s +++ b/asm/cable_club.s @@ -178,7 +178,7 @@ _080B24C8: b _080B24F2 _080B24CC: ldr r4, =gStringVar1 - bl sub_800ABAC + bl GetLinkPlayerCount_2 adds r1, r0, 0 lsls r1, 24 lsrs r1, 24 @@ -239,7 +239,7 @@ sub_80B252C: @ 80B252C ands r0, r1 cmp r0, 0 beq _080B2570 - bl sub_800B320 + bl IsLinkConnectionEstablished lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -269,7 +269,7 @@ sub_80B2578: @ 80B2578 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_800B320 + bl IsLinkConnectionEstablished lsls r0, 24 cmp r0, 0 beq _080B258E @@ -404,7 +404,7 @@ sub_80B2688: @ 80B2688 push {r4,r5,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r5, r0, 24 adds r0, r4, 0 @@ -426,7 +426,7 @@ sub_80B2688: @ 80B2688 adds r4, r0, r1 movs r0, 0 strh r0, [r4, 0xE] - bl sub_800ABBC + bl IsLinkMaster lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -506,7 +506,7 @@ sub_80B275C: @ 80B275C mov r9, r0 mov r7, r8 add r7, r9 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r5, r0, 24 adds r0, r4, 0 @@ -585,7 +585,7 @@ sub_80B2804: @ 80B2804 bne _080B2898 bl sub_800AA48 adds r4, r0, 0 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r4, 24 lsls r0, 24 cmp r4, r0 @@ -652,7 +652,7 @@ sub_80B28A8: @ 80B28A8 lsrs r0, 24 cmp r0, 0x1 beq _080B290A - bl sub_800ABAC + bl GetLinkPlayerCount_2 adds r4, r0, 0 bl sub_800AA48 lsls r4, 24 @@ -729,13 +729,13 @@ _080B297C: cmp r2, 0x9 bne _080B2994 _080B2984: - bl sub_80097E8 + bl CloseLink bl HideFieldMessageBox ldr r0, =sub_80B2CB0 b _080B29E4 .pool _080B2994: - bl sub_800ABAC + bl GetLinkPlayerCount_2 ldr r4, =gUnknown_03005DB8 strb r0, [r4] bl GetMultiplayerId @@ -812,7 +812,7 @@ _080B2A42: cmp r0, 0x9 bne _080B2A6C _080B2A4A: - bl sub_80097E8 + bl CloseLink _080B2A4E: bl HideFieldMessageBox ldr r0, =gTasks @@ -825,7 +825,7 @@ _080B2A4E: b _080B2ACE .pool _080B2A6C: - bl sub_800ABAC + bl GetLinkPlayerCount_2 ldr r4, =gUnknown_03005DB8 strb r0, [r4] bl GetMultiplayerId @@ -1610,7 +1610,7 @@ sub_80B3144: @ 80B3144 ldrsh r2, [r4, r3] cmp r2, 0 bne _080B3178 - bl sub_8009734 + bl OpenLink bl sub_800A2BC ldr r0, =task00_08081A90 movs r1, 0x50 @@ -1640,12 +1640,12 @@ sub_80B3194: @ 80B3194 lsls r0, 24 lsrs r4, r0, 24 adds r5, r4, 0 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 bls _080B31DA - bl sub_800ABBC + bl IsLinkMaster lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -1681,7 +1681,7 @@ sub_80B31E8: @ 80B31E8 lsrs r5, r0, 24 bl sub_800AA48 adds r4, r0, 0 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r4, 24 lsls r0, 24 cmp r4, r0 @@ -2651,7 +2651,7 @@ task00_08081A90: @ 80B3A30 lsls r0, 17 cmp r1, r0 ble _080B3A62 - bl sub_80097E8 + bl CloseLink ldr r0, =c2_800ACD4 bl SetMainCallback2 adds r0, r4, 0 @@ -2669,7 +2669,7 @@ _080B3A62: lsls r0, 24 cmp r0, 0 bne _080B3A86 - bl sub_80097E8 + bl CloseLink ldr r0, =c2_800ACD4 bl SetMainCallback2 _080B3A86: @@ -2761,7 +2761,7 @@ _080B3B2A: b _080B3BB8 .pool _080B3B40: - bl sub_8009734 + bl OpenLink ldr r0, =task00_08081A90 movs r1, 0x1 bl CreateTask @@ -2779,14 +2779,14 @@ _080B3B54: strh r0, [r5, 0x2] b _080B3B96 _080B3B68: - bl sub_800ABAC + bl GetLinkPlayerCount_2 adds r4, r0, 0 bl sub_800AA48 lsls r4, 24 lsls r0, 24 cmp r4, r0 bcc _080B3BB8 - bl sub_800ABBC + bl IsLinkMaster lsls r0, 24 cmp r0, 0 beq _080B3B96 diff --git a/asm/link.s b/asm/link.s index 1ad160340..c6df00f1b 100644 --- a/asm/link.s +++ b/asm/link.s @@ -15,7 +15,7 @@ sub_80093CC: @ 80093CC cmp r0, r1 beq _080093F4 bl sub_800B4A4 - bl sub_80097E8 + bl CloseLink bl RestoreSerialTimer3IntrHandlers movs r0, 0 b _080093FE @@ -29,15 +29,15 @@ _080093FE: bx r1 thumb_func_end sub_80093CC - thumb_func_start sub_8009404 -sub_8009404: @ 8009404 + thumb_func_start Task_DestroySelf +Task_DestroySelf: @ 8009404 push {lr} lsls r0, 24 lsrs r0, 24 bl DestroyTask pop {r0} bx r0 - thumb_func_end sub_8009404 + thumb_func_end Task_DestroySelf thumb_func_start sub_8009414 sub_8009414: @ 8009414 @@ -210,7 +210,7 @@ sub_8009570: @ 8009570 ldr r2, =0x00001111 adds r0, r2, 0 strh r0, [r1] - bl sub_8009734 + bl OpenLink ldr r0, =gMain ldrh r0, [r0, 0x24] bl SeedRng @@ -236,7 +236,7 @@ _080095A0: lsls r1, 5 movs r0, 0 bl SetGpuReg - ldr r0, =sub_8009404 + ldr r0, =Task_DestroySelf movs r1, 0 bl CreateTask bl RunTasks @@ -384,8 +384,8 @@ _08009726: .pool thumb_func_end task02_080097CC - thumb_func_start sub_8009734 -sub_8009734: @ 8009734 + thumb_func_start OpenLink +OpenLink: @ 8009734 push {r4-r6,lr} ldr r0, =gLinkVSyncDisabled ldrb r4, [r0] @@ -443,10 +443,10 @@ _080097BE: pop {r0} bx r0 .pool - thumb_func_end sub_8009734 + thumb_func_end OpenLink - thumb_func_start sub_80097E8 -sub_80097E8: @ 80097E8 + thumb_func_start CloseLink +CloseLink: @ 80097E8 push {r4,lr} ldr r0, =gReceivedRemoteLinkPlayers movs r4, 0 @@ -464,7 +464,7 @@ _080097FC: pop {r0} bx r0 .pool - thumb_func_end sub_80097E8 + thumb_func_end CloseLink thumb_func_start sub_8009818 sub_8009818: @ 8009818 @@ -698,7 +698,7 @@ _080099FC: bls _080099FC ldrh r0, [r4] strh r0, [r5] - ldr r0, =gUnknown_030030E0 + ldr r0, =gLinkStatus ldr r0, [r0] movs r1, 0x40 ands r0, r1 @@ -717,7 +717,7 @@ _080099FC: _08009A34: bl sub_800AEB4 _08009A38: - ldr r0, =gUnknown_030030E0 + ldr r0, =gLinkStatus ldrh r0, [r0] _08009A3C: pop {r4,r5} @@ -745,7 +745,7 @@ _08009A70: adds r5, r0 adds r4, 0x1 _08009A78: - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 cmp r4, r0 @@ -1378,7 +1378,7 @@ GetLinkPlayerCount: @ 8009FCC ldrb r0, [r0] cmp r0, 0 bne _08009FEC - ldr r0, =gUnknown_030030E0 + ldr r0, =gLinkStatus ldr r0, [r0] movs r1, 0x1C ands r0, r1 @@ -1514,7 +1514,7 @@ sub_800A0AC: @ 800A0AC str r1, [r0] ldr r0, =gUnknown_020229C8 strh r1, [r0] - bl sub_8009734 + bl OpenLink pop {r0} bx r0 .pool @@ -1532,7 +1532,7 @@ sub_800A0C8: @ 800A0C8 beq _0800A0DA b _0800A214 _0800A0DA: - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -1552,7 +1552,7 @@ _0800A0FC: bne _0800A10E ldr r0, =gUnknown_0300306C strb r4, [r0] - bl sub_80097E8 + bl CloseLink _0800A10E: movs r6, 0 ldr r4, =gLinkPlayers @@ -2211,7 +2211,7 @@ _0800A616: thumb_func_start sub_800A620 sub_800A620: @ 800A620 push {lr} - ldr r0, =gUnknown_030030E0 + ldr r0, =gLinkStatus ldr r1, [r0] movs r0, 0x20 ands r0, r1 @@ -2499,7 +2499,7 @@ _0800A81C: thumb_func_start sub_800A824 sub_800A824: @ 800A824 push {lr} - ldr r0, =gUnknown_030030E0 + ldr r0, =gLinkStatus ldr r0, [r0] movs r1, 0x20 ands r0, r1 @@ -2534,7 +2534,7 @@ task00_link_test: @ 800A850 movs r2, 0x1 movs r3, 0x2 bl sub_800A6E8 - ldr r4, =gUnknown_030030E0 + ldr r4, =gLinkStatus ldr r0, [r4] movs r1, 0xF movs r2, 0x1 @@ -2606,7 +2606,7 @@ task00_link_test: @ 800A850 movs r2, 0x6 movs r3, 0x1 bl sub_800A6E8 - bl sub_800B320 + bl IsLinkConnectionEstablished lsls r0, 24 lsrs r0, 24 movs r1, 0x19 @@ -2807,7 +2807,7 @@ _0800AAB4: ldrb r0, [r0] cmp r3, r0 bne _0800AAE4 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 mov r1, r9 @@ -2887,7 +2887,7 @@ _0800AB5A: ldr r1, =gUnknown_0300306C movs r0, 0x1 strb r0, [r1] - bl sub_80097E8 + bl CloseLink ldr r0, =c2_800ACD4 bl SetMainCallback2 _0800AB6A: @@ -2918,25 +2918,25 @@ sub_800AB98: @ 800AB98 .pool thumb_func_end sub_800AB98 - thumb_func_start sub_800ABAC -sub_800ABAC: @ 800ABAC - ldr r0, =gUnknown_030030E0 + thumb_func_start GetLinkPlayerCount_2 +GetLinkPlayerCount_2: @ 800ABAC + ldr r0, =gLinkStatus ldr r0, [r0] movs r1, 0x1C ands r0, r1 lsrs r0, 2 bx lr .pool - thumb_func_end sub_800ABAC + thumb_func_end GetLinkPlayerCount_2 - thumb_func_start sub_800ABBC -sub_800ABBC: @ 800ABBC + thumb_func_start IsLinkMaster +IsLinkMaster: @ 800ABBC push {lr} ldr r0, =gLinkVSyncDisabled ldrb r0, [r0] cmp r0, 0 bne _0800ABDC - ldr r0, =gUnknown_030030E0 + ldr r0, =gLinkStatus ldr r0, [r0] lsrs r0, 5 movs r1, 0x1 @@ -2950,7 +2950,7 @@ _0800ABDC: _0800ABE4: pop {r1} bx r1 - thumb_func_end sub_800ABBC + thumb_func_end IsLinkMaster thumb_func_start sub_800ABE8 sub_800ABE8: @ 800ABE8 @@ -3074,7 +3074,7 @@ _0800ACD0: ldr r0, =gUnknown_03002748 movs r4, 0x1 strb r4, [r0] - bl sub_80097E8 + bl CloseLink ldr r1, =gUnknown_03003140 movs r0, 0 str r0, [r1] @@ -3178,7 +3178,7 @@ _0800ADB6: ldr r0, =gUnknown_03002748 movs r4, 0x1 strb r4, [r0] - bl sub_80097E8 + bl CloseLink ldr r1, =gUnknown_03003140 movs r0, 0 str r0, [r1] @@ -3290,7 +3290,7 @@ sub_800AEB4: @ 800AEB4 ldrb r0, [r0] cmp r0, 0 beq _0800AEF4 - ldr r0, =gUnknown_030030E0 + ldr r0, =gLinkStatus ldr r2, [r0] movs r0, 0xFE lsls r0, 11 @@ -3315,7 +3315,7 @@ _0800AEEA: ldr r1, =gUnknown_0300306C movs r0, 0x1 strb r0, [r1] - bl sub_80097E8 + bl CloseLink _0800AEF4: pop {r0} bx r0 @@ -3426,7 +3426,7 @@ _0800AF8C: ldr r1, =gSoftResetDisabled movs r0, 0 strb r0, [r1] - ldr r0, =sub_8009404 + ldr r0, =Task_DestroySelf movs r1, 0 bl CreateTask bl StopMapMusic @@ -3740,16 +3740,16 @@ _0800B314: .pool thumb_func_end sub_800B2F8 - thumb_func_start sub_800B320 -sub_800B320: @ 800B320 - ldr r0, =gUnknown_030030E0 + thumb_func_start IsLinkConnectionEstablished +IsLinkConnectionEstablished: @ 800B320 + ldr r0, =gLinkStatus ldr r0, [r0] lsrs r0, 6 movs r1, 0x1 ands r0, r1 bx lr .pool - thumb_func_end sub_800B320 + thumb_func_end IsLinkConnectionEstablished thumb_func_start sub_800B330 sub_800B330: @ 800B330 @@ -3864,7 +3864,7 @@ HandleLinkConnection: @ 800B40C ldr r1, =gSendCmd ldr r2, =gRecvCmds bl sub_800B638 - ldr r4, =gUnknown_030030E0 + ldr r4, =gLinkStatus str r0, [r4] ldr r0, =gUnknown_030022EC bl sub_80099E0 @@ -15025,7 +15025,7 @@ _08010E20: ldrb r1, [r0] movs r1, 0x2 strb r1, [r0] - bl sub_80097E8 + bl CloseLink b _08010E8E .pool _08010E5C: @@ -16613,7 +16613,7 @@ sub_8011AFC: @ 8011AFC adds r0, r2, 0 strh r0, [r1] bl sub_800B488 - bl sub_8009734 + bl OpenLink ldr r0, =gMain ldrh r0, [r0, 0x24] bl SeedRng @@ -18142,7 +18142,7 @@ _08012848: movs r2, 0 bl sub_8010F84 bl sub_800B488 - bl sub_8009734 + bl OpenLink ldrb r1, [r4] movs r0, 0xF ands r0, r1 @@ -19650,7 +19650,7 @@ _08013590: movs r2, 0 bl sub_8010F84 bl sub_800B488 - bl sub_8009734 + bl OpenLink bl sub_8011C5C movs r0, 0x70 bl AllocZeroed @@ -20398,7 +20398,7 @@ _08013CD0: movs r2, 0 bl sub_8010F84 bl sub_800B488 - bl sub_8009734 + bl OpenLink bl sub_8011C5C movs r0, 0x1 bl sub_80111B0 @@ -21897,7 +21897,7 @@ _08014AB0: movs r1, 0 bl sub_8010FA0 bl sub_800B488 - bl sub_8009734 + bl OpenLink movs r0, 0x2 bl sub_8011C10 movs r0, 0x1 @@ -22435,7 +22435,7 @@ _08014FA4: movs r2, 0 bl sub_8010F84 bl sub_800B488 - bl sub_8009734 + bl OpenLink bl sub_8011C5C movs r0, 0x70 bl AllocZeroed @@ -22823,7 +22823,7 @@ _08015358: movs r2, 0 bl sub_8010F84 bl sub_800B488 - bl sub_8009734 + bl OpenLink bl sub_8011C5C movs r0, 0x70 bl AllocZeroed @@ -23373,7 +23373,7 @@ _08015878: ldrh r2, [r2, 0xC] bl sub_8010FCC bl sub_800B488 - bl sub_8009734 + bl OpenLink bl sub_8011C84 ldr r0, [r6, 0x8] movs r1, 0x1 @@ -25223,7 +25223,7 @@ _080169BE: movs r2, 0 bl sub_8010F84 bl sub_800B488 - bl sub_8009734 + bl OpenLink bl sub_8011C84 movs r0, 0x1 bl sub_80111B0 @@ -31098,7 +31098,7 @@ _080198FE: b _08019922 .pool _0801990C: - bl sub_80097E8 + bl CloseLink ldr r0, [r5, 0x10] bl Free adds r0, r4, 0 diff --git a/asm/main_menu.s b/asm/main_menu.s index 9d6cba40f..08e0c3103 100644 --- a/asm/main_menu.s +++ b/asm/main_menu.s @@ -1495,7 +1495,7 @@ _08030478: b _0803048A .pool _08030480: - ldr r0, =sub_8178974 + ldr r0, =CB2_InitMysteryEventMenu b _0803048A .pool _08030488: diff --git a/asm/mystery_event_menu.s b/asm/mystery_event_menu.s deleted file mode 100644 index 34b8cadd6..000000000 --- a/asm/mystery_event_menu.s +++ /dev/null @@ -1,669 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8178944 -sub_8178944: @ 8178944 - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_8178944 - - thumb_func_start sub_8178958 -sub_8178958: @ 8178958 - push {lr} - movs r2, 0 - ldr r1, =gLinkPlayers - ldrh r0, [r1, 0x1A] - ldrh r1, [r1, 0x36] - cmp r0, r1 - bne _08178968 - movs r2, 0x1 -_08178968: - adds r0, r2, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8178958 - - thumb_func_start sub_8178974 -sub_8178974: @ 8178974 - push {r4,lr} - sub sp, 0x8 - bl ResetSpriteData - bl FreeAllSpritePalettes - bl ResetTasks - ldr r0, =sub_8178944 - bl SetVBlankCallback - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_085EFD64 - movs r0, 0 - movs r2, 0x1 - bl InitBgsFromTemplates - ldr r0, =gUnknown_085EFD68 - bl InitWindows - lsls r0, 16 - cmp r0, 0 - beq _08178A22 - bl DeactivateAllTextPrinters - movs r4, 0 -_081789AC: - lsls r0, r4, 24 - lsrs r0, 24 - movs r1, 0 - bl FillWindowPixelBuffer - adds r4, 0x1 - cmp r4, 0x1 - ble _081789AC - movs r0, 0x1E - str r0, [sp] - movs r0, 0x14 - str r0, [sp, 0x4] - movs r0, 0 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl FillBgTilemapBufferRect_Palette0 - movs r0, 0 - movs r1, 0x1 - movs r2, 0xD0 - bl sub_809882C - movs r0, 0xE0 - bl sub_81978B0 - movs r1, 0xA0 - lsls r1, 1 - movs r0, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - ldr r0, =sub_8009404 - movs r1, 0 - bl CreateTask - bl StopMapMusic - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl RunTextPrinters - bl UpdatePaletteFade - movs r0, 0 - movs r1, 0 - movs r2, 0x2 - bl FillPalette - ldr r0, =sub_8178A78 - bl SetMainCallback2 -_08178A22: - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8178974 - - thumb_func_start sub_8178A40 -sub_8178A40: @ 8178A40 - push {r4-r6,lr} - adds r6, r0, 0 - adds r4, r1, 0 - movs r5, 0x1 - cmp r4, 0 - bne _08178A54 - ldr r1, =gText_EventSafelyLoaded - bl StringCopy - movs r5, 0 -_08178A54: - cmp r4, 0x2 - bne _08178A5A - movs r5, 0 -_08178A5A: - cmp r4, 0x1 - bne _08178A66 - ldr r1, =gText_LoadErrorEndingSession - adds r0, r6, 0 - bl StringCopy -_08178A66: - adds r0, r5, 0 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8178A40 - - thumb_func_start sub_8178A78 -sub_8178A78: @ 8178A78 - push {r4-r6,lr} - sub sp, 0x8 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r1, r2 - ldrb r0, [r0] - adds r4, r1, 0 - cmp r0, 0x10 - bls _08178A8E - b _08178E58 -_08178A8E: - lsls r0, 2 - ldr r1, =_08178AA0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08178AA0: - .4byte _08178AE4 - .4byte _08178B12 - .4byte _08178B48 - .4byte _08178B80 - .4byte _08178BCC - .4byte _08178BDC - .4byte _08178C54 - .4byte _08178D28 - .4byte _08178D38 - .4byte _08178D58 - .4byte _08178D60 - .4byte _08178D74 - .4byte _08178DBC - .4byte _08178DE0 - .4byte _08178E0C - .4byte _08178E24 - .4byte _08178E48 -_08178AE4: - movs r0, 0 - movs r1, 0x1 - movs r2, 0x1 - movs r3, 0xD - bl SetWindowBorderStyle - movs r0, 0 - bl PutWindowTilemap - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - movs r0, 0 - bl ShowBg - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - b _08178E30 -_08178B12: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08178B20 - b _08178E58 -_08178B20: - ldr r1, =gText_LinkStandby2 - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - movs r2, 0x1 - movs r3, 0x2 - bl sub_8178EC4 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _08178E3C - .pool -_08178B48: - movs r0, 0 - bl IsTextPrinterActive - lsls r0, 16 - cmp r0, 0 - beq _08178B56 - b _08178E58 -_08178B56: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r1, =gLinkType - ldr r2, =0x00005501 - adds r0, r2, 0 - strh r0, [r1] - bl sub_8009734 - b _08178E58 - .pool -_08178B80: - ldr r0, =gUnknown_030030E0 - ldr r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - bne _08178B8E - b _08178D00 -_08178B8E: - movs r0, 0x1C - ands r1, r0 - cmp r1, 0x4 - bhi _08178B98 - b _08178D00 -_08178B98: - movs r0, 0x15 - bl PlaySE - ldr r1, =gText_PressAToLoadEvent - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - movs r2, 0x1 - movs r3, 0x2 - bl sub_8178EC4 - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08178D00 - .pool -_08178BCC: - movs r0, 0 - bl IsTextPrinterActive - lsls r0, 16 - cmp r0, 0 - beq _08178BDA - b _08178E58 -_08178BDA: - b _08178E34 -_08178BDC: - bl sub_800ABAC - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x2 - bne _08178CD0 - ldr r4, =gMain - ldrh r1, [r4, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08178C38 - movs r0, 0x5 - bl PlaySE - bl sub_800A620 - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0x1 - movs r3, 0xD - bl SetWindowBorderStyle - ldr r1, =gText_LoadingEvent - movs r0, 0 - str r0, [sp] - movs r0, 0x1 - movs r2, 0x1 - movs r3, 0x2 - bl sub_8178EC4 - movs r0, 0x1 - bl PutWindowTilemap - movs r0, 0x1 - movs r1, 0x3 - bl CopyWindowToVram - movs r2, 0x87 - lsls r2, 3 - adds r1, r4, r2 - b _08178E3C - .pool -_08178C38: - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _08178C42 - b _08178E58 -_08178C42: - movs r0, 0x5 - bl PlaySE - bl sub_80097E8 - movs r0, 0x87 - lsls r0, 3 - adds r1, r4, r0 - b _08178D1E -_08178C54: - bl sub_800B320 - lsls r0, 24 - cmp r0, 0 - beq _08178D00 - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _08178C68 - b _08178E58 -_08178C68: - movs r0, 0x2 - movs r1, 0x2 - bl sub_800A0C8 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bne _08178CAC - bl sub_800AC34 - ldr r4, =gStringVar4 - adds r0, r4, 0 - movs r1, 0x1 - bl sub_8178A40 - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - adds r1, r4, 0 - movs r2, 0x1 - movs r3, 0x2 - bl sub_8178EC4 - ldr r0, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r2 - b _08178CF2 - .pool -_08178CAC: - bl sub_8178958 - lsls r0, 24 - cmp r0, 0 - beq _08178CCC - ldr r1, =gText_DontRemoveCableTurnOff - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - movs r2, 0x1 - movs r3, 0x2 - bl sub_8178EC4 - b _08178E34 - .pool -_08178CCC: - bl sub_80097E8 -_08178CD0: - ldr r4, =gStringVar4 - adds r0, r4, 0 - movs r1, 0x1 - bl sub_8178A40 - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - adds r1, r4, 0 - movs r2, 0x1 - movs r3, 0x2 - bl sub_8178EC4 - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 -_08178CF2: - movs r1, 0xD - strb r1, [r0] - b _08178E58 - .pool -_08178D00: - ldr r4, =gMain - ldrh r1, [r4, 0x2E] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _08178D0E - b _08178E58 -_08178D0E: - movs r0, 0x5 - bl PlaySE - bl sub_80097E8 - movs r2, 0x87 - lsls r2, 3 - adds r1, r4, r2 -_08178D1E: - movs r0, 0xF - strb r0, [r1] - b _08178E58 - .pool -_08178D28: - movs r0, 0 - bl IsTextPrinterActive - lsls r0, 16 - cmp r0, 0 - beq _08178D36 - b _08178E58 -_08178D36: - b _08178E34 -_08178D38: - bl GetBlockReceivedStatus - lsls r0, 24 - cmp r0, 0 - bne _08178D44 - b _08178E58 -_08178D44: - bl ResetBlockReceivedFlags - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _08178E3C - .pool -_08178D58: - movs r0, 0x87 - lsls r0, 3 - adds r1, r4, r0 - b _08178E3C -_08178D60: - bl sub_800AC34 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _08178E3C - .pool -_08178D74: - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r6, [r0] - cmp r6, 0 - bne _08178E58 - ldr r5, =0x0201c000 - adds r0, r5, 0 - bl RunMysteryEventScript - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - str r6, [sp, 0x4] - ldr r2, =0x050001f5 - add r0, sp, 0x4 - adds r1, r5, 0 - bl CpuSet - ldr r0, =gStringVar4 - adds r1, r4, 0 - bl sub_8178A40 - lsls r0, 24 - cmp r0, 0 - bne _08178E34 - movs r0, 0 - bl TrySavingData - b _08178E34 - .pool -_08178DBC: - ldr r1, =gStringVar4 - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - movs r2, 0x1 - movs r3, 0x2 - bl sub_8178EC4 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _08178E3C - .pool -_08178DE0: - movs r0, 0 - bl IsTextPrinterActive - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, 0 - bne _08178E58 - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - ldr r0, =gUnknown_0203BCF8 - strb r2, [r0] - b _08178E58 - .pool -_08178E0C: - ldrh r1, [r4, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08178E58 - movs r0, 0x5 - bl PlaySE - movs r2, 0x87 - lsls r2, 3 - adds r1, r4, r2 - b _08178E3C -_08178E24: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 -_08178E30: - bl BeginNormalPaletteFade -_08178E34: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 -_08178E3C: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08178E58 - .pool -_08178E48: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08178E58 - bl DoSoftReset -_08178E58: - ldr r0, =gUnknown_030030E0 - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08178E98 - bl sub_800ABBC - lsls r0, 24 - cmp r0, 0 - bne _08178E98 - bl sub_80097E8 - ldr r4, =gStringVar4 - adds r0, r4, 0 - movs r1, 0x1 - bl sub_8178A40 - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - adds r1, r4, 0 - movs r2, 0x1 - movs r3, 0x2 - bl sub_8178EC4 - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - movs r1, 0xD - strb r1, [r0] -_08178E98: - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl RunTextPrinters - bl UpdatePaletteFade - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8178A78 - - thumb_func_start sub_8178EC4 -sub_8178EC4: @ 8178EC4 - push {r4-r6,lr} - mov r6, r10 - mov r5, r9 - mov r4, r8 - push {r4-r6} - sub sp, 0x1C - adds r5, r0, 0 - mov r10, r1 - adds r6, r2, 0 - ldr r4, [sp, 0x38] - lsls r5, 24 - lsrs r5, 24 - lsls r6, 24 - lsrs r6, 24 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0 - mov r9, r0 - movs r1, 0x1 - mov r8, r1 - add r0, sp, 0x14 - mov r1, r8 - strb r1, [r0] - adds r1, r0, 0 - movs r0, 0x2 - strb r0, [r1, 0x1] - movs r0, 0x3 - strb r0, [r1, 0x2] - adds r0, r1, 0 - ldrb r0, [r0] - lsls r1, r0, 4 - orrs r1, r0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - str r3, [sp, 0x18] - bl FillWindowPixelBuffer - mov r0, r9 - str r0, [sp] - mov r1, r8 - str r1, [sp, 0x4] - add r0, sp, 0x14 - str r0, [sp, 0x8] - lsls r4, 24 - asrs r4, 24 - str r4, [sp, 0xC] - mov r1, r10 - str r1, [sp, 0x10] - adds r0, r5, 0 - movs r1, 0x1 - adds r2, r6, 0 - ldr r3, [sp, 0x18] - bl AddTextPrinterParameterized2 - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8178EC4 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/overworld.s b/asm/overworld.s index 2858fb6d3..7dccbb0d1 100644 --- a/asm/overworld.s +++ b/asm/overworld.s @@ -3584,7 +3584,7 @@ sub_808631C: @ 808631C lsrs r0, 24 cmp r0, 0x1 bne _0808632E - bl sub_80097E8 + bl CloseLink _0808632E: ldr r0, =gLinkVSyncDisabled ldrb r0, [r0] diff --git a/asm/pokenav.s b/asm/pokenav.s index 896d9aae0..f74028687 100644 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -28072,7 +28072,7 @@ sub_81D4E30: @ 81D4E30 ldr r2, =0x00005503 adds r0, r2, 0 strh r0, [r1] - bl sub_8009734 + bl OpenLink movs r0, 0x1 bl sub_800B330 pop {r0} @@ -28128,11 +28128,11 @@ _081D4EBA: thumb_func_start sub_81D4EC0 sub_81D4EC0: @ 81D4EC0 push {lr} - bl sub_800ABBC + bl IsLinkMaster lsls r0, 24 cmp r0, 0 beq _081D4EDC - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 cmp r0, 0x2 @@ -28186,11 +28186,11 @@ _081D4F20: .4byte _081D4FEC .4byte _081D4FF8 _081D4F38: - bl sub_800ABBC + bl IsLinkMaster lsls r0, 24 cmp r0, 0 beq _081D4F88 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -28212,7 +28212,7 @@ _081D4F54: strb r0, [r4] b _081D500C _081D4F6C: - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 cmp r0, 0x2 @@ -28248,7 +28248,7 @@ _081D4FA0: movs r0, 0x5 b _081D500E _081D4FB6: - bl sub_800B320 + bl IsLinkConnectionEstablished lsls r0, 24 cmp r0, 0 beq _081D500C @@ -28447,7 +28447,7 @@ _081D515C: beq _081D5166 b _081D52FC _081D5166: - bl sub_80097E8 + bl CloseLink b _081D525C _081D516C: adds r0, r4, 0 @@ -28500,20 +28500,20 @@ _081D51D0: beq _081D51F4 movs r0, 0x5 bl PlaySE - bl sub_80097E8 + bl CloseLink adds r0, r4, 0 bl sub_81D505C b _081D535A .pool _081D51F4: - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 bls _081D5210 adds r0, r4, 0 bl sub_81D505C - bl sub_80097E8 + bl CloseLink movs r0, 0x7 strb r0, [r4, 0x8] b _081D548A @@ -28523,7 +28523,7 @@ _081D5210: beq _081D522E movs r0, 0x5 bl PlaySE - bl sub_80097E8 + bl CloseLink adds r0, r4, 0 bl sub_81D505C movs r0, 0x8 @@ -28537,7 +28537,7 @@ _081D522E: bne _081D523C b _081D548A _081D523C: - bl sub_80097E8 + bl CloseLink bl sub_81D4E30 adds r0, r4, 0 bl sub_81D505C @@ -28654,13 +28654,13 @@ _081D5340: _081D5350: movs r0, 0x5 bl PlaySE - bl sub_80097E8 + bl CloseLink _081D535A: movs r0, 0x17 strb r0, [r4, 0x8] b _081D548A _081D5360: - bl sub_80097E8 + bl CloseLink movs r0, 0x15 strb r0, [r4, 0x8] b _081D548A @@ -28670,7 +28670,7 @@ _081D536A: cmp r0, 0 beq _081D537A _081D5374: - bl sub_80097E8 + bl CloseLink b _081D53C0 _081D537A: bl GetBlockReceivedStatus diff --git a/asm/record_mixing.s b/asm/record_mixing.s index b7bcca4a8..e54c3a1fb 100644 --- a/asm/record_mixing.s +++ b/asm/record_mixing.s @@ -765,10 +765,10 @@ _080E73B0: movs r0, 0x65 b _080E7564 _080E73B8: - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r4, r0, 24 - bl sub_800ABBC + bl IsLinkMaster lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -796,7 +796,7 @@ _080E73EA: _080E73F8: bl sub_800AA48 adds r4, r0, 0 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r4, 24 lsls r0, 24 cmp r4, r0 @@ -808,7 +808,7 @@ _080E740C: strh r4, [r5, 0x20] lsls r4, 16 asrs r4, 16 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 lsls r1, r0, 4 @@ -824,7 +824,7 @@ _080E742A: _080E7432: bl sub_800AA48 adds r4, r0, 0 - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r4, 24 lsls r0, 24 cmp r4, r0 @@ -868,7 +868,7 @@ _080E746E: b _080E7564 .pool _080E7490: - bl sub_800ABAC + bl GetLinkPlayerCount_2 lsls r0, 24 lsrs r0, 24 movs r1, 0 diff --git a/asm/trade.s b/asm/trade.s index dd0477560..0126baa6a 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -416,12 +416,12 @@ _080774B2: cmp r0, 0 beq _08077528 bl sub_800B488 - bl sub_8009734 + bl OpenLink bl sub_8011BA4 b _08077B46 .pool _08077528: - bl sub_8009734 + bl OpenLink ldr r0, =gMain movs r7, 0x87 lsls r7, 3 @@ -466,7 +466,7 @@ _0807757A: b _08077B22 .pool _0807758C: - bl sub_800ABAC + bl GetLinkPlayerCount_2 adds r4, r0, 0 bl sub_800AA48 lsls r4, 24 @@ -475,7 +475,7 @@ _0807758C: bcs _080775A0 b _08077B46 _080775A0: - bl sub_800ABBC + bl IsLinkMaster lsls r0, 24 cmp r0, 0 beq _080775D8 @@ -7026,7 +7026,7 @@ _0807AC92: lsls r0, 1 cmp r1, r0 bls _0807ACC4 - bl sub_80097E8 + bl CloseLink ldr r0, =c2_800ACD4 bl SetMainCallback2 ldr r1, [r4] @@ -7264,7 +7264,7 @@ _0807AEAC: ldr r2, =0x00001144 adds r0, r2, 0 strh r0, [r1] - bl sub_80097E8 + bl CloseLink _0807AEC0: ldr r4, =gUnknown_020322A0 movs r5, 0x80 @@ -7332,7 +7332,7 @@ _0807AF58: adds r0, 0xFA movs r1, 0x1 strb r1, [r0] - bl sub_8009734 + bl OpenLink ldr r1, =gMain movs r2, 0x87 lsls r2, 3 @@ -7369,13 +7369,13 @@ _0807AFAC: b _0807B0E4 .pool _0807AFBC: - bl sub_800ABBC + bl IsLinkMaster lsls r0, 24 cmp r0, 0 bne _0807AFC8 b _0807B0DC _0807AFC8: - bl sub_800ABAC + bl GetLinkPlayerCount_2 adds r4, r0, 0 bl sub_800AA48 lsls r4, 24 diff --git a/data/mystery_event_menu.s b/data/mystery_event_menu.s deleted file mode 100644 index bb8330497..000000000 --- a/data/mystery_event_menu.s +++ /dev/null @@ -1,12 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - -gUnknown_085EFD64:: @ 85EFD64 - .4byte 0x1F8 - -gUnknown_085EFD68:: @ 85EFD68 - window_template 0, 4, 15, 22, 4, 14, 20 - window_template 0, 7, 6, 16, 4, 14, 0x6C - null_window_template diff --git a/data/scripts/cable_club.inc b/data/scripts/cable_club.inc index bcd92d1c2..b8aef7c3d 100644 --- a/data/scripts/cable_club.inc +++ b/data/scripts/cable_club.inc @@ -231,7 +231,7 @@ OldaleTown_PokemonCenter_2F_EventScript_276C9D:: @ 8276C9D end OldaleTown_PokemonCenter_2F_EventScript_276CB5:: @ 8276CB5 - special sub_80097E8 + special CloseLink setvar VAR_0x4087, 0 compare VAR_0x8007, 0 goto_eq OldaleTown_PokemonCenter_2F_EventScript_276DD5 @@ -254,7 +254,7 @@ OldaleTown_PokemonCenter_2F_EventScript_276CE7:: @ 8276CE7 end OldaleTown_PokemonCenter_2F_EventScript_276CFF:: @ 8276CFF - special sub_80097E8 + special CloseLink setvar VAR_0x4087, 0 compare VAR_0x8007, 0 goto_eq OldaleTown_PokemonCenter_2F_EventScript_276DD5 @@ -276,7 +276,7 @@ OldaleTown_PokemonCenter_2F_EventScript_276D2C:: @ 8276D2C end OldaleTown_PokemonCenter_2F_EventScript_276D44:: @ 8276D44 - special sub_80097E8 + special CloseLink setvar VAR_0x4087, 0 applymovement 255, OldaleTown_PokemonCenter_2F_Movement_27734F waitmovement 0 @@ -501,25 +501,25 @@ OldaleTown_PokemonCenter_2F_EventScript_277046:: @ 8277046 end OldaleTown_PokemonCenter_2F_EventScript_277072:: @ 8277072 - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_27833D, 4 goto OldaleTown_PokemonCenter_2F_EventScript_2770A5 end OldaleTown_PokemonCenter_2F_EventScript_277083:: @ 8277083 - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_278307, 4 goto OldaleTown_PokemonCenter_2F_EventScript_2770A5 end OldaleTown_PokemonCenter_2F_EventScript_277094:: @ 8277094 - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_2782D1, 4 goto OldaleTown_PokemonCenter_2F_EventScript_2770A5 end OldaleTown_PokemonCenter_2F_EventScript_2770A5:: @ 82770A5 - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_278372, 4 release end @@ -658,45 +658,45 @@ OldaleTown_PokemonCenter_2F_EventScript_27724C:: @ 827724C end OldaleTown_PokemonCenter_2F_EventScript_2772AB:: @ 82772AB - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_278565, 4 release end OldaleTown_PokemonCenter_2F_EventScript_2772B8:: @ 82772B8 - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_2785C9, 4 release end BattleFrontier_BattleTowerLobby_EventScript_2772C5:: @ 82772C5 OldaleTown_PokemonCenter_2F_EventScript_2772C5:: @ 82772C5 - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_27821C, 4 release end BattleFrontier_BattleTowerLobby_EventScript_2772D2:: @ 82772D2 OldaleTown_PokemonCenter_2F_EventScript_2772D2:: @ 82772D2 - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_2781C7, 4 release end OldaleTown_PokemonCenter_2F_EventScript_2772DF:: @ 82772DF - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_278255, 4 release end OldaleTown_PokemonCenter_2F_EventScript_2772EC:: @ 82772EC - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_278291, 4 release end MossdeepCity_GameCorner_1F_EventScript_2772F9:: @ 82772F9 - special sub_80097E8 + special CloseLink msgbox MossdeepCity_GameCorner_1F_Text_278D51, 4 release end @@ -708,19 +708,19 @@ OldaleTown_PokemonCenter_2F_EventScript_277306:: @ 8277306 end OldaleTown_PokemonCenter_2F_EventScript_27730E:: @ 827730E - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_2782A8, 4 release end OldaleTown_PokemonCenter_2F_EventScript_27731B:: @ 827731B - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_2785E9, 4 release end OldaleTown_PokemonCenter_2F_EventScript_277328:: @ 8277328 - special sub_80097E8 + special CloseLink msgbox OldaleTown_PokemonCenter_2F_Text_278651, 4 release end diff --git a/data/scripts/maps/BattleFrontier_BattleTowerLobby.inc b/data/scripts/maps/BattleFrontier_BattleTowerLobby.inc index 7c0762417..def3dd122 100644 --- a/data/scripts/maps/BattleFrontier_BattleTowerLobby.inc +++ b/data/scripts/maps/BattleFrontier_BattleTowerLobby.inc @@ -725,7 +725,7 @@ BattleFrontier_BattleTowerLobby_EventScript_23F0E3:: @ 823F0E3 special copy_player_party_from_sav1 BattleFrontier_BattleTowerLobby_EventScript_23F0E6:: @ 823F0E6 - special sub_80097E8 + special CloseLink msgbox BattleFrontier_BattleTowerLobby_Text_23FD07, 4 BattleFrontier_BattleTowerLobby_EventScript_23F0F1:: @ 823F0F1 @@ -951,7 +951,7 @@ BattleFrontier_BattleTowerLobby_EventScript_23F2C5:: @ 823F2C5 end BattleFrontier_BattleTowerLobby_EventScript_23F327:: @ 823F327 - special sub_80097E8 + special CloseLink compare VAR_0x8005, 3 goto_eq BattleFrontier_BattleTowerLobby_EventScript_23F33F msgbox BattleFrontier_BattleTowerLobby_Text_278255, 4 @@ -966,13 +966,13 @@ BattleFrontier_BattleTowerLobby_EventScript_23F33F:: @ 823F33F BattleFrontier_BattleTowerLobby_EventScript_23F351:: @ 823F351 msgbox BattleFrontier_BattleTowerLobby_Text_241240, 4 - special sub_80097E8 + special CloseLink msgbox BattleFrontier_BattleTowerLobby_Text_2782A8, 4 release end BattleFrontier_BattleTowerLobby_EventScript_23F366:: @ 823F366 - special sub_80097E8 + special CloseLink compare VAR_0x8005, 0 call_if 1, BattleFrontier_BattleTowerLobby_EventScript_23F394 compare VAR_0x8005, 1 diff --git a/data/scripts/maps/LilycoveCity_ContestLobby.inc b/data/scripts/maps/LilycoveCity_ContestLobby.inc index 3b7d6a2f2..beb96e171 100644 --- a/data/scripts/maps/LilycoveCity_ContestLobby.inc +++ b/data/scripts/maps/LilycoveCity_ContestLobby.inc @@ -709,7 +709,7 @@ LilycoveCity_ContestLobby_EventScript_21A971:: @ 821A971 end LilycoveCity_ContestLobby_EventScript_21A97F:: @ 821A97F - special sub_80097E8 + special CloseLink msgbox LilycoveCity_ContestLobby_Text_27BD4F, 4 release end @@ -811,13 +811,13 @@ LilycoveCity_ContestLobby_EventScript_21AAE1:: @ 821AAE1 end LilycoveCity_ContestLobby_EventScript_21AAEF:: @ 821AAEF - special sub_80097E8 + special CloseLink msgbox LilycoveCity_ContestLobby_Text_27821C, 4 release end LilycoveCity_ContestLobby_EventScript_21AAFC:: @ 821AAFC - special sub_80097E8 + special CloseLink msgbox LilycoveCity_ContestLobby_Text_27C879, 4 release end diff --git a/data/scripts/pokeblocks.inc b/data/scripts/pokeblocks.inc index 0f705c841..39cca8244 100644 --- a/data/scripts/pokeblocks.inc +++ b/data/scripts/pokeblocks.inc @@ -655,25 +655,25 @@ LilycoveCity_ContestLobby_EventScript_29416C:: @ 829416C end LilycoveCity_ContestLobby_EventScript_294176:: @ 8294176 - special sub_80097E8 + special CloseLink msgbox LilycoveCity_ContestLobby_Text_2781C7, 4 releaseall end LilycoveCity_ContestLobby_EventScript_294183:: @ 8294183 - special sub_80097E8 + special CloseLink msgbox LilycoveCity_ContestLobby_Text_278255, 4 releaseall end LilycoveCity_ContestLobby_EventScript_294190:: @ 8294190 - special sub_80097E8 + special CloseLink msgbox gUnknown_08272D9C, 4 releaseall end LilycoveCity_ContestLobby_EventScript_29419D:: @ 829419D - special sub_80097E8 + special CloseLink msgbox LilycoveCity_ContestLobby_Text_27821C, 4 releaseall end diff --git a/data/specials.inc b/data/specials.inc index 332c58bca..ac4a47b69 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -40,7 +40,7 @@ gSpecials:: @ 81DBA64 def_special sub_80B2E4C def_special sub_80B2E74 def_special sub_80B2EA8 - def_special sub_80097E8 + def_special CloseLink def_special sub_80B3968 def_special sub_80B3924 def_special nullsub_37 diff --git a/include/link.h b/include/link.h index fe5429497..1c9795d29 100644 --- a/include/link.h +++ b/include/link.h @@ -143,8 +143,9 @@ extern struct LinkPlayer gLinkPlayers[]; extern u16 word_3002910[]; extern bool8 gReceivedRemoteLinkPlayers; extern bool8 gLinkVSyncDisabled; +extern u32 gLinkStatus; -void Task_DestroySelf(u8); +void Task_DestroySelf(u8 taskId); void OpenLink(void); void CloseLink(void); u16 LinkMain2(u16 *); @@ -188,11 +189,10 @@ bool8 sub_8010500(void); void sub_800DFB4(u8, u8); void sub_800ADF8(void); void sub_800B488(void); -void sub_8009734(void); +void OpenLink(void); void sub_800A620(void); void sub_8011BD0(void); -u8 sub_800ABAC(void); -u8 sub_800ABBC(void); void sub_800AC34(void); +u8 sub_800A0C8(s32, s32); #endif // GUARD_LINK_H diff --git a/include/mystery_event_menu.h b/include/mystery_event_menu.h new file mode 100644 index 000000000..8801789d9 --- /dev/null +++ b/include/mystery_event_menu.h @@ -0,0 +1,6 @@ +#ifndef GUARD_MYSTERY_EVENT_MENU_H +#define GUARD_MYSTERY_EVENT_MENU_H + +void CB2_InitMysteryEventMenu(void); + +#endif // GUARD_MYSTERY_EVENT_MENU_H diff --git a/include/strings.h b/include/strings.h index 806a2e405..305007c5d 100644 --- a/include/strings.h +++ b/include/strings.h @@ -202,4 +202,12 @@ extern const u8 gText_ButtonMode[]; extern const u8 gText_MaleSymbol[]; extern const u8 gText_FemaleSymbol[]; +// mystery event menu text +extern const u8 gText_EventSafelyLoaded[]; +extern const u8 gText_LoadErrorEndingSession[]; +extern const u8 gText_PressAToLoadEvent[]; +extern const u8 gText_LoadingEvent[]; +extern const u8 gText_DontRemoveCableTurnOff[]; +extern const u8 gText_LinkStandby2[]; + #endif //GUARD_STRINGS_H diff --git a/ld_script.txt b/ld_script.txt index 314ad0e62..5d4cf0554 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -230,7 +230,7 @@ SECTIONS { src/lottery_corner.o(.text); src/diploma.o(.text); asm/berry_tag_screen.o(.text); - asm/mystery_event_menu.o(.text); + src/mystery_event_menu.o(.text); src/save_failed_screen.o(.text); src/braille_puzzles.o(.text); src/pokeblock_feed.o(.text); @@ -505,7 +505,7 @@ SECTIONS { src/diploma.o(.rodata); data/strings.o(.rodata); data/berry_tag_screen.o(.rodata); - data/mystery_event_menu.o(.rodata); + src/mystery_event_menu.o(.rodata); src/save_failed_screen.o(.rodata); data/braille_puzzles.o(.rodata); src/pokeblock_feed.o(.rodata); diff --git a/src/battle_controllers.c b/src/battle_controllers.c index c6d47e71e..c28b6ef3b 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -64,7 +64,7 @@ void HandleLinkBattleSetup(void) if (gLinkVSyncDisabled) sub_800B488(); if (!gReceivedRemoteLinkPlayers) - sub_8009734(); + OpenLink(); CreateTask(task00_08081A90, 0); CreateTasksForSendRecvLinkBuffers(); } @@ -793,9 +793,9 @@ static void Task_HandleSendLinkBuffersData(u8 taskId) else var = (gBattleTypeFlags & BATTLE_TYPE_MULTI) ? 4 : 2; - if (sub_800ABAC() >= var) + if (GetLinkPlayerCount_2() >= var) { - if (sub_800ABBC()) + if (IsLinkMaster()) { sub_800A620(); gTasks[taskId].data[11]++; diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c new file mode 100644 index 000000000..0478f50cd --- /dev/null +++ b/src/mystery_event_menu.c @@ -0,0 +1,303 @@ +#include "global.h" +#include "mystery_event_menu.h" +#include "link.h" +#include "main.h" +#include "menu.h" +#include "mystery_event_script.h" +#include "palette.h" +#include "save.h" +#include "constants/songs.h" +#include "sound.h" +#include "sprite.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" +#include "text.h" +#include "bg.h" +#include "window.h" +#include "gpu_regs.h" +#include "text_window.h" +#include "new_menu_helpers.h" +#include "decompress.h" + +// this file's functions +static void CB2_MysteryEventMenu(void); +static void PrintMysteryMenuText(u8 windowId, const u8 *text, u8 x, u8 y, s32 speed); + +// EWRAM vars +static EWRAM_DATA u8 sUnknown_0203BCF8 = 0; // set but unused + +// const rom data +static const struct BgTemplate sBgTemplates[] = +{ + { + .bg = 0, + .charBaseIndex = 2, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0 + } +}; + +static const struct WindowTemplate sWindowTemplates[] = +{ + {0, 4, 15, 22, 4, 14, 20}, + {0, 7, 6, 16, 4, 14, 0x6C}, + DUMMY_WIN_TEMPLATE +}; + +// code +static void VBlankCB(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +static bool8 CheckLanguageMatch(void) +{ + return (gLinkPlayers[0].language == gLinkPlayers[1].language); +} + +void CB2_InitMysteryEventMenu(void) +{ + ResetSpriteData(); + FreeAllSpritePalettes(); + ResetTasks(); + SetVBlankCallback(VBlankCB); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates)); + if (InitWindows(sWindowTemplates)) + { + s32 i; + + DeactivateAllTextPrinters(); + for (i = 0; i < 2; i++) + FillWindowPixelBuffer(i, 0); + + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x1E, 0x14); + sub_809882C(0, 1u, 0xD0u); + sub_81978B0(0xE0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + CreateTask(Task_DestroySelf, 0); + StopMapMusic(); + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + RunTextPrinters(); + UpdatePaletteFade(); + FillPalette(0, 0, 2); + SetMainCallback2(CB2_MysteryEventMenu); + } +} + +static bool8 GetEventLoadMessage(u8 *dest, u32 status) +{ + bool8 retVal = TRUE; + + if (status == 0) + { + StringCopy(dest, gText_EventSafelyLoaded); + retVal = FALSE; + } + + if (status == 2) + retVal = FALSE; + + if (status == 1) + StringCopy(dest, gText_LoadErrorEndingSession); + + return retVal; +} + +static void CB2_MysteryEventMenu(void) +{ + switch (gMain.state) + { + case 0: + SetWindowBorderStyle(0, 1, 1, 0xD); + PutWindowTilemap(0); + CopyWindowToVram(0, 3); + ShowBg(0); + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + gMain.state++; + break; + case 1: + if (!gPaletteFade.active) + { + PrintMysteryMenuText(0, gText_LinkStandby2, 1, 2, 1); + gMain.state++; + } + break; + case 2: + if (!IsTextPrinterActive(0)) + { + gMain.state++; + gLinkType = 21761; + OpenLink(); + } + break; + case 3: + if ((gLinkStatus & 0x20) && (gLinkStatus & 0x1C) > 4) + { + PlaySE(SE_PIN); + PrintMysteryMenuText(0, gText_PressAToLoadEvent, 1, 2, 1); + gMain.state++; + } + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + CloseLink(); + gMain.state = 15; + } + break; + case 4: + if (!IsTextPrinterActive(0)) + gMain.state++; + break; + case 5: + if (GetLinkPlayerCount_2() == 2) + { + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + sub_800A620(); + SetWindowBorderStyle(1, 1, 1, 0xD); + PrintMysteryMenuText(1, gText_LoadingEvent, 1, 2, 0); + PutWindowTilemap(1); + CopyWindowToVram(1, 3); + gMain.state++; + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + CloseLink(); + gMain.state = 15; + } + } + else + { + GetEventLoadMessage(gStringVar4, 1); + PrintMysteryMenuText(0, gStringVar4, 1, 2, 1); + gMain.state = 13; + } + break; + case 6: + if (IsLinkConnectionEstablished()) + { + if (gReceivedRemoteLinkPlayers != 0) + { + if (sub_800A0C8(2, 2) == 3) + { + sub_800AC34(); + GetEventLoadMessage(gStringVar4, 1); + PrintMysteryMenuText(0, gStringVar4, 1, 2, 1); + gMain.state = 13; + } + else if (CheckLanguageMatch()) + { + PrintMysteryMenuText(0, gText_DontRemoveCableTurnOff, 1, 2, 1); + gMain.state++; + } + else + { + CloseLink(); + GetEventLoadMessage(gStringVar4, 1); + PrintMysteryMenuText(0, gStringVar4, 1, 2, 1); + gMain.state = 13; + } + } + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + CloseLink(); + gMain.state = 15; + } + break; + case 7: + if (!IsTextPrinterActive(0)) + gMain.state++; + break; + case 8: + if (GetBlockReceivedStatus()) + { + ResetBlockReceivedFlags(); + gMain.state++; + } + break; + case 9: + gMain.state++; + break; + case 10: + sub_800AC34(); + gMain.state++; + break; + case 11: + if (gReceivedRemoteLinkPlayers == 0) + { + u16 unkVal = RunMysteryEventScript(gDecompressionBuffer); + CpuFill32(0, gDecompressionBuffer, 0x7D4); + if (!GetEventLoadMessage(gStringVar4, unkVal)) + TrySavingData(NORMAL_SAVE); + gMain.state++; + } + break; + case 12: + PrintMysteryMenuText(0, gStringVar4, 1, 2, 1); + gMain.state++; + break; + case 13: + if (!IsTextPrinterActive(0)) + { + gMain.state++; + sUnknown_0203BCF8 = 0; + } + break; + case 14: + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + gMain.state++; + } + break; + case 15: + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gMain.state++; + break; + case 16: + if (!gPaletteFade.active) + DoSoftReset(); + break; + } + + if (gLinkStatus & 0x40 && !IsLinkMaster()) + { + CloseLink(); + GetEventLoadMessage(gStringVar4, 1); + PrintMysteryMenuText(0, gStringVar4, 1, 2, 1); + gMain.state = 13; + } + + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + RunTextPrinters(); + UpdatePaletteFade(); +} + +static void PrintMysteryMenuText(u8 windowId, const u8 *text, u8 x, u8 y, s32 speed) +{ + struct TextColor textColor; + u8 letterSpacing = 0; + u8 lineSpacing = 1; + textColor.fgColor = 1; + textColor.bgColor = 2; + textColor.shadowColor = 3; + + FillWindowPixelBuffer(windowId, (textColor.fgColor) | (textColor.fgColor << 4)); + AddTextPrinterParameterized2(windowId, 1, x, y, letterSpacing, lineSpacing, &textColor, speed, text); +} diff --git a/sym_common.txt b/sym_common.txt index 590597459..4918ca425 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -84,7 +84,7 @@ gUnknown_03003092: @ 3003092 gUnknown_03003094: @ 3003094 .space 0x4C -gUnknown_030030E0: @ 30030E0 +gLinkStatus: @ 30030E0 .space 0x4 gUnknown_030030E4: @ 30030E4 diff --git a/sym_ewram.txt b/sym_ewram.txt index c04f524d8..ac8b8762f 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1299,9 +1299,7 @@ gUnknown_0203BCE8: @ 203BCE8 gUnknown_0203BCF4: @ 203BCF4 .space 0x4 -gUnknown_0203BCF8: @ 203BCF8 - .space 0x4 - + .include "src/mystery_event_menu.o" .include "src/save_failed_screen.o" gBraillePuzzleCallbackFlag: @ 203BD14