diff --git a/asm/field_fadetransition.s b/asm/field_fadetransition.s deleted file mode 100644 index 1f489ceb3..000000000 --- a/asm/field_fadetransition.s +++ /dev/null @@ -1,1221 +0,0 @@ - .include "constants/gba_constants.inc" - .include "constants/species_constants.inc" - .include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start task_mpl_807DD60 -task_mpl_807DD60: @ 80809CC - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r2, _080809F0 @ =gTasks - adds r4, r0, r2 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _08080A06 - cmp r0, 0x1 - bgt _080809F4 - cmp r0, 0 - beq _080809FA - b _08080A36 - .align 2, 0 -_080809F0: .4byte gTasks -_080809F4: - cmp r0, 0x2 - beq _08080A24 - b _08080A36 -_080809FA: - bl sub_8083664 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0xA] - b _08080A1C -_08080A06: - movs r1, 0xA - ldrsh r0, [r4, r1] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldrb r0, [r1, 0x4] - cmp r0, 0x1 - beq _08080A36 - bl pal_fill_for_map_transition -_08080A1C: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08080A36 -_08080A24: - bl sub_8080E70 - cmp r0, 0x1 - bne _08080A36 - bl ScriptContext2_Disable - adds r0, r5, 0 - bl DestroyTask -_08080A36: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end task_mpl_807DD60 - - thumb_func_start sub_8080A3C -sub_8080A3C: @ 8080A3C - push {lr} - bl ScriptContext2_Enable - bl sub_8053E90 - bl palette_bg_fill_black - ldr r0, _08080A58 @ =task_mpl_807DD60 - movs r1, 0xA - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_08080A58: .4byte task_mpl_807DD60 - thumb_func_end sub_8080A3C - - thumb_func_start sub_8080A5C -sub_8080A5C: @ 8080A5C - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, _08080A80 @ =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _08080A90 - cmp r0, 0x1 - bgt _08080A84 - cmp r0, 0 - beq _08080A8A - b _08080ABC - .align 2, 0 -_08080A80: .4byte gTasks -_08080A84: - cmp r0, 0x2 - beq _08080AA6 - b _08080ABC -_08080A8A: - bl sub_80084A4 - b _08080A9E -_08080A90: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _08080ABC - bl pal_fill_for_map_transition -_08080A9E: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08080ABC -_08080AA6: - bl sub_8080E70 - cmp r0, 0x1 - bne _08080ABC - bl sub_8007B14 - bl ScriptContext2_Disable - adds r0, r5, 0 - bl DestroyTask -_08080ABC: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8080A5C - - thumb_func_start sub_8080AC4 -sub_8080AC4: @ 8080AC4 - push {lr} - bl ScriptContext2_Enable - bl sub_8053E90 - bl palette_bg_fill_black - ldr r0, _08080AE0 @ =sub_8080A5C - movs r1, 0xA - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_08080AE0: .4byte sub_8080A5C - thumb_func_end sub_8080AC4 - - thumb_func_start sub_8080AE4 -sub_8080AE4: @ 8080AE4 - push {r4,lr} - sub sp, 0x4 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl PlayerGetDestCoords - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsDoor - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08080B1C - ldr r1, _08080B18 @ =sub_8080B9C - b _08080B2E - .align 2, 0 -_08080B18: .4byte sub_8080B9C -_08080B1C: - adds r0, r4, 0 - bl MetatileBehavior_IsNonAnimDoor - lsls r0, 24 - lsrs r0, 24 - ldr r1, _08080B40 @ =task_map_chg_seq_0807E2CC - cmp r0, 0x1 - bne _08080B2E - ldr r1, _08080B44 @ =task_map_chg_seq_0807E20C -_08080B2E: - adds r0, r1, 0 - movs r1, 0xA - bl CreateTask - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08080B40: .4byte task_map_chg_seq_0807E2CC -_08080B44: .4byte task_map_chg_seq_0807E20C - thumb_func_end sub_8080AE4 - - thumb_func_start mapldr_default -mapldr_default: @ 8080B48 - push {lr} - bl sub_8053E90 - bl pal_fill_for_map_transition - bl sub_8080AE4 - bl ScriptContext2_Enable - pop {r0} - bx r0 - thumb_func_end mapldr_default - - thumb_func_start sub_8080B60 -sub_8080B60: @ 8080B60 - push {lr} - bl sub_8053E90 - bl pal_fill_black - bl sub_8080AE4 - bl ScriptContext2_Enable - pop {r0} - bx r0 - thumb_func_end sub_8080B60 - - thumb_func_start sub_8080B78 -sub_8080B78: @ 8080B78 - push {lr} - bl sub_8053E90 - bl pal_fill_for_map_transition - movs r0, 0x2E - bl PlaySE - ldr r0, _08080B98 @ =task_map_chg_seq_0807E2CC - movs r1, 0xA - bl CreateTask - bl ScriptContext2_Enable - pop {r0} - bx r0 - .align 2, 0 -_08080B98: .4byte task_map_chg_seq_0807E2CC - thumb_func_end sub_8080B78 - - thumb_func_start sub_8080B9C -sub_8080B9C: @ 8080B9C - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, _08080BC8 @ =gTasks - adds r5, r0, r1 - adds r6, r5, 0 - adds r6, 0xC - adds r7, r5, 0 - adds r7, 0xE - movs r2, 0x8 - ldrsh r0, [r5, r2] - adds r2, r1, 0 - cmp r0, 0x4 - bhi _08080CAE - lsls r0, 2 - ldr r1, _08080BCC @ =_08080BD0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_08080BC8: .4byte gTasks -_08080BCC: .4byte _08080BD0 - .align 2, 0 -_08080BD0: - .4byte _08080BE4 - .4byte _08080C08 - .4byte _08080C40 - .4byte _08080C84 - .4byte _08080CA4 -_08080BE4: - movs r0, 0 - bl sub_8080958 - bl FreezeMapObjects - adds r0, r6, 0 - adds r1, r7, 0 - bl PlayerGetDestCoords - movs r1, 0 - ldrsh r0, [r6, r1] - movs r2, 0 - ldrsh r1, [r7, r2] - bl FieldSetDoorOpened - movs r0, 0x1 - strh r0, [r5, 0x8] - b _08080CAE -_08080C08: - bl sub_8080E70 - cmp r0, 0 - beq _08080CAE - movs r0, 0x1 - bl sub_8080958 - movs r0, 0xFF - movs r1, 0 - movs r2, 0 - bl GetFieldObjectIdByLocalIdAndMap - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, _08080C3C @ =gMapObjects - adds r0, r1 - movs r1, 0x8 - bl FieldObjectSetSpecialAnim - movs r0, 0x2 - strh r0, [r5, 0x8] - b _08080CAE - .align 2, 0 -_08080C3C: .4byte gMapObjects -_08080C40: - bl walkrun_is_standing_still - lsls r0, 24 - cmp r0, 0 - beq _08080CAE - movs r1, 0 - ldrsh r0, [r6, r1] - movs r2, 0 - ldrsh r1, [r7, r2] - bl FieldAnimateDoorClose - lsls r0, 24 - asrs r0, 24 - strh r0, [r5, 0xA] - movs r0, 0xFF - movs r1, 0 - movs r2, 0 - bl GetFieldObjectIdByLocalIdAndMap - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, _08080C80 @ =gMapObjects - adds r0, r1 - bl FieldObjectClearAnimIfSpecialAnimFinished - movs r0, 0x3 - strh r0, [r5, 0x8] - b _08080CAE - .align 2, 0 -_08080C80: .4byte gMapObjects -_08080C84: - movs r1, 0xA - ldrsh r0, [r5, r1] - cmp r0, 0 - blt _08080C9A - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldrb r0, [r1, 0x4] - cmp r0, 0x1 - beq _08080CAE -_08080C9A: - bl UnfreezeMapObjects - movs r0, 0x4 - strh r0, [r5, 0x8] - b _08080CAE -_08080CA4: - bl ScriptContext2_Disable - adds r0, r4, 0 - bl DestroyTask -_08080CAE: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8080B9C - - thumb_func_start task_map_chg_seq_0807E20C -task_map_chg_seq_0807E20C: @ 8080CB4 - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, _08080CE0 @ =gTasks - adds r5, r0, r1 - adds r6, r5, 0 - adds r6, 0xC - adds r7, r5, 0 - adds r7, 0xE - movs r1, 0x8 - ldrsh r0, [r5, r1] - cmp r0, 0x1 - beq _08080D06 - cmp r0, 0x1 - bgt _08080CE4 - cmp r0, 0 - beq _08080CEE - b _08080D6E - .align 2, 0 -_08080CE0: .4byte gTasks -_08080CE4: - cmp r0, 0x2 - beq _08080D50 - cmp r0, 0x3 - beq _08080D64 - b _08080D6E -_08080CEE: - movs r0, 0 - bl sub_8080958 - bl FreezeMapObjects - adds r0, r6, 0 - adds r1, r7, 0 - bl PlayerGetDestCoords - movs r0, 0x1 - strh r0, [r5, 0x8] - b _08080D6E -_08080D06: - bl sub_8080E70 - cmp r0, 0 - beq _08080D6E - movs r0, 0x1 - bl sub_8080958 - movs r0, 0xFF - movs r1, 0 - movs r2, 0 - bl GetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 3 - adds r4, r0 - lsls r4, 2 - ldr r0, _08080D4C @ =gMapObjects - adds r4, r0 - bl player_get_direction_lower_nybble - lsls r0, 24 - lsrs r0, 24 - bl GetGoSpeed0AnimId - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl FieldObjectSetSpecialAnim - movs r0, 0x2 - strh r0, [r5, 0x8] - b _08080D6E - .align 2, 0 -_08080D4C: .4byte gMapObjects -_08080D50: - bl walkrun_is_standing_still - lsls r0, 24 - cmp r0, 0 - beq _08080D6E - bl UnfreezeMapObjects - movs r0, 0x3 - strh r0, [r5, 0x8] - b _08080D6E -_08080D64: - bl ScriptContext2_Disable - adds r0, r4, 0 - bl DestroyTask -_08080D6E: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end task_map_chg_seq_0807E20C - - thumb_func_start task_map_chg_seq_0807E2CC -task_map_chg_seq_0807E2CC: @ 8080D74 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, _08080D94 @ =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _08080D98 - cmp r0, 0x1 - beq _08080DA8 - b _08080DBE - .align 2, 0 -_08080D94: .4byte gTasks -_08080D98: - bl FreezeMapObjects - bl ScriptContext2_Enable - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08080DBE -_08080DA8: - bl sub_8080E70 - cmp r0, 0 - beq _08080DBE - bl UnfreezeMapObjects - bl ScriptContext2_Disable - adds r0, r5, 0 - bl DestroyTask -_08080DBE: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end task_map_chg_seq_0807E2CC - - thumb_func_start sub_8080DC4 -sub_8080DC4: @ 8080DC4 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_8080E70 - cmp r0, 0x1 - bne _08080DE0 - adds r0, r4, 0 - bl DestroyTask - ldr r0, _08080DE8 @ =sub_80712B4 - movs r1, 0x50 - bl CreateTask -_08080DE0: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08080DE8: .4byte sub_80712B4 - thumb_func_end sub_8080DC4 - - thumb_func_start atk17_seteffectuser -atk17_seteffectuser: @ 8080DEC - push {lr} - bl pal_fill_black - ldr r0, _08080E00 @ =sub_8080DC4 - bl CreateStartMenuTask - bl ScriptContext2_Enable - pop {r0} - bx r0 - .align 2, 0 -_08080E00: .4byte sub_8080DC4 - thumb_func_end atk17_seteffectuser - - thumb_func_start task_mpl_807E3C8 -task_mpl_807E3C8: @ 8080E04 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_8080E70 - cmp r0, 0x1 - bne _08080E20 - bl ScriptContext2_Disable - adds r0, r4, 0 - bl DestroyTask - bl sub_8064E2C -_08080E20: - pop {r4} - pop {r0} - bx r0 - thumb_func_end task_mpl_807E3C8 - - thumb_func_start sub_8080E28 -sub_8080E28: @ 8080E28 - push {lr} - bl ScriptContext2_Enable - bl pal_fill_black - ldr r0, _08080E40 @ =task_mpl_807E3C8 - movs r1, 0xA - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_08080E40: .4byte task_mpl_807E3C8 - thumb_func_end sub_8080E28 - - thumb_func_start sub_8080E44 -sub_8080E44: @ 8080E44 - push {lr} - bl ScriptContext2_Enable - bl sub_8053E90 - bl pal_fill_black - ldr r0, _08080E60 @ =task_mpl_807E3C8 - movs r1, 0xA - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_08080E60: .4byte task_mpl_807E3C8 - thumb_func_end sub_8080E44 - - thumb_func_start sub_8080E64 -sub_8080E64: @ 8080E64 - ldr r0, _08080E6C @ =gPaletteFade - ldrb r0, [r0, 0x7] - lsrs r0, 7 - bx lr - .align 2, 0 -_08080E6C: .4byte gPaletteFade - thumb_func_end sub_8080E64 - - thumb_func_start sub_8080E70 -sub_8080E70: @ 8080E70 - push {lr} - bl sub_807D770 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08080E82 - movs r0, 0 - b _08080E84 -_08080E82: - movs r0, 0x1 -_08080E84: - pop {r1} - bx r1 - thumb_func_end sub_8080E70 - - thumb_func_start sub_8080E88 -sub_8080E88: @ 8080E88 - push {lr} - bl ScriptContext2_Enable - bl sub_8053FF8 - bl fade_8080918 - bl PlayRainSoundEffect - movs r0, 0x9 - bl PlaySE - ldr r0, _08080EB4 @ =gFieldCallback - ldr r1, _08080EB8 @ =mapldr_default - str r1, [r0] - ldr r0, _08080EBC @ =task0A_fade_n_map_maybe - movs r1, 0xA - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_08080EB4: .4byte gFieldCallback -_08080EB8: .4byte mapldr_default -_08080EBC: .4byte task0A_fade_n_map_maybe - thumb_func_end sub_8080E88 - - thumb_func_start sp13E_warp_to_last_warp -sp13E_warp_to_last_warp: @ 8080EC0 - push {lr} - bl ScriptContext2_Enable - bl sub_8053FF8 - bl fade_8080918 - bl PlayRainSoundEffect - ldr r0, _08080EE4 @ =gFieldCallback - ldr r1, _08080EE8 @ =mapldr_default - str r1, [r0] - ldr r0, _08080EEC @ =task0A_fade_n_map_maybe - movs r1, 0xA - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_08080EE4: .4byte gFieldCallback -_08080EE8: .4byte mapldr_default -_08080EEC: .4byte task0A_fade_n_map_maybe - thumb_func_end sp13E_warp_to_last_warp - - thumb_func_start sub_8080EF0 -sub_8080EF0: @ 8080EF0 - push {lr} - bl ScriptContext2_Enable - ldr r0, _08080F08 @ =gFieldCallback - ldr r1, _08080F0C @ =mapldr_default - str r1, [r0] - ldr r0, _08080F10 @ =sub_808115C - movs r1, 0xA - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_08080F08: .4byte gFieldCallback -_08080F0C: .4byte mapldr_default -_08080F10: .4byte sub_808115C - thumb_func_end sub_8080EF0 - - thumb_func_start sp13F_fall_to_last_warp -sp13F_fall_to_last_warp: @ 8080F14 - push {lr} - bl sp13E_warp_to_last_warp - ldr r1, _08080F24 @ =gFieldCallback - ldr r0, _08080F28 @ =sub_8086748 - str r0, [r1] - pop {r0} - bx r0 - .align 2, 0 -_08080F24: .4byte gFieldCallback -_08080F28: .4byte sub_8086748 - thumb_func_end sp13F_fall_to_last_warp - - thumb_func_start sub_8080F2C -sub_8080F2C: @ 8080F2C - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl ScriptContext2_Enable - adds r0, r4, 0 - movs r1, 0xA - bl sub_8086A2C - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8080F2C - - thumb_func_start sub_8080F48 -sub_8080F48: @ 8080F48 - push {lr} - bl ScriptContext2_Enable - movs r0, 0xA - bl sub_80871B8 - pop {r0} - bx r0 - thumb_func_end sub_8080F48 - - thumb_func_start sub_8080F58 -sub_8080F58: @ 8080F58 - push {lr} - bl ScriptContext2_Enable - movs r0, 0xA - bl sub_8087654 - pop {r0} - bx r0 - thumb_func_end sub_8080F58 - - thumb_func_start sub_8080F68 -sub_8080F68: @ 8080F68 - push {lr} - bl ScriptContext2_Enable - bl sub_8053FF8 - bl fade_8080918 - movs r0, 0x2D - bl PlaySE - ldr r0, _08080F90 @ =task0A_fade_n_map_maybe - movs r1, 0xA - bl CreateTask - ldr r1, _08080F94 @ =gFieldCallback - ldr r0, _08080F98 @ =sub_8080B78 - str r0, [r1] - pop {r0} - bx r0 - .align 2, 0 -_08080F90: .4byte task0A_fade_n_map_maybe -_08080F94: .4byte gFieldCallback -_08080F98: .4byte sub_8080B78 - thumb_func_end sub_8080F68 - - thumb_func_start sub_8080F9C -sub_8080F9C: @ 8080F9C - push {lr} - bl ScriptContext2_Enable - bl fade_8080918 - ldr r0, _08080FB8 @ =task0A_fade_n_map_maybe - movs r1, 0xA - bl CreateTask - ldr r1, _08080FBC @ =gFieldCallback - ldr r0, _08080FC0 @ =sub_80C791C - str r0, [r1] - pop {r0} - bx r0 - .align 2, 0 -_08080FB8: .4byte task0A_fade_n_map_maybe -_08080FBC: .4byte gFieldCallback -_08080FC0: .4byte sub_80C791C - thumb_func_end sub_8080F9C - - thumb_func_start sub_8080FC4 -sub_8080FC4: @ 8080FC4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, _08080FE8 @ =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _08080FF8 - cmp r0, 0x1 - bgt _08080FEC - cmp r0, 0 - beq _08080FF2 - b _08081022 - .align 2, 0 -_08080FE8: .4byte gTasks -_08080FEC: - cmp r0, 0x2 - beq _08081012 - b _08081022 -_08080FF2: - bl ScriptContext2_Enable - b _0808100A -_08080FF8: - bl sub_8080E64 - cmp r0, 0 - bne _08081022 - bl sub_8054034 - lsls r0, 24 - cmp r0, 0 - beq _08081022 -_0808100A: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08081022 -_08081012: - bl warp_in - ldr r0, _08081028 @ =sub_8054588 - bl SetMainCallback2 - adds r0, r5, 0 - bl DestroyTask -_08081022: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08081028: .4byte sub_8054588 - thumb_func_end sub_8080FC4 - - thumb_func_start DoCableClubWarp -DoCableClubWarp: @ 808102C - push {lr} - bl ScriptContext2_Enable - bl sub_8053FF8 - bl fade_8080918 - movs r0, 0x9 - bl PlaySE - ldr r0, _0808104C @ =sub_8080FC4 - movs r1, 0xA - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_0808104C: .4byte sub_8080FC4 - thumb_func_end DoCableClubWarp - - thumb_func_start sub_8081050 -sub_8081050: @ 8081050 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, _08081074 @ =gTasks + 0x8 - adds r4, r0, r1 - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _08081096 - cmp r0, 0x1 - bgt _08081078 - cmp r0, 0 - beq _0808107E - b _080810CC - .align 2, 0 -_08081074: .4byte gTasks + 0x8 -_08081078: - cmp r0, 0x2 - beq _080810B4 - b _080810CC -_0808107E: - bl ClearLinkCallback_2 - movs r0, 0x1 - movs r1, 0 - bl fade_screen - bl sub_8053FF8 - movs r0, 0x9 - bl PlaySE - b _080810AC -_08081096: - bl sub_8080E64 - cmp r0, 0 - bne _080810CC - bl sub_8054034 - lsls r0, 24 - cmp r0, 0 - beq _080810CC - bl sub_800832C -_080810AC: - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - b _080810CC -_080810B4: - ldr r0, _080810D4 @ =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - bne _080810CC - bl warp_in - ldr r0, _080810D8 @ =CB2_LoadMap - bl SetMainCallback2 - adds r0, r5, 0 - bl DestroyTask -_080810CC: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_080810D4: .4byte gReceivedRemoteLinkPlayers -_080810D8: .4byte CB2_LoadMap - thumb_func_end sub_8081050 - - thumb_func_start sub_80810DC -sub_80810DC: @ 80810DC - push {lr} - ldr r0, _080810EC @ =sub_8081050 - movs r1, 0xA - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_080810EC: .4byte sub_8081050 - thumb_func_end sub_80810DC - - thumb_func_start task0A_fade_n_map_maybe -task0A_fade_n_map_maybe: @ 80810F0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, _08081114 @ =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _08081128 - cmp r0, 0x1 - bgt _08081118 - cmp r0, 0 - beq _0808111E - b _08081152 - .align 2, 0 -_08081114: .4byte gTasks -_08081118: - cmp r0, 0x2 - beq _08081142 - b _08081152 -_0808111E: - bl FreezeMapObjects - bl ScriptContext2_Enable - b _0808113A -_08081128: - bl sub_8080E64 - cmp r0, 0 - bne _08081152 - bl sub_8054034 - lsls r0, 24 - cmp r0, 0 - beq _08081152 -_0808113A: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08081152 -_08081142: - bl warp_in - ldr r0, _08081158 @ =CB2_LoadMap - bl SetMainCallback2 - adds r0, r5, 0 - bl DestroyTask -_08081152: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08081158: .4byte CB2_LoadMap - thumb_func_end task0A_fade_n_map_maybe - - thumb_func_start sub_808115C -sub_808115C: @ 808115C - push {r4-r6,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, _0808118C @ =gTasks - adds r5, r1, r0 - adds r4, r5, 0 - adds r4, 0xC - adds r6, r5, 0 - adds r6, 0xE - movs r2, 0x8 - ldrsh r1, [r5, r2] - adds r2, r0, 0 - cmp r1, 0x4 - bls _08081180 - b _080812BC -_08081180: - lsls r0, r1, 2 - ldr r1, _08081190 @ =_08081194 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_0808118C: .4byte gTasks -_08081190: .4byte _08081194 - .align 2, 0 -_08081194: - .4byte _080811A8 - .4byte _080811E4 - .4byte _08081240 - .4byte _0808128C - .4byte _080812A8 -_080811A8: - bl FreezeMapObjects - adds r0, r4, 0 - adds r1, r6, 0 - bl PlayerGetDestCoords - movs r1, 0 - ldrsh r0, [r4, r1] - movs r2, 0 - ldrsh r1, [r6, r2] - subs r1, 0x1 - bl sub_8058790 - lsls r0, 16 - lsrs r0, 16 - bl PlaySE - movs r1, 0 - ldrsh r0, [r4, r1] - movs r2, 0 - ldrsh r1, [r6, r2] - subs r1, 0x1 - bl FieldAnimateDoorOpen - lsls r0, 24 - asrs r0, 24 - strh r0, [r5, 0xA] - movs r0, 0x1 - strh r0, [r5, 0x8] - b _080812BC -_080811E4: - movs r1, 0xA - ldrsh r0, [r5, r1] - cmp r0, 0 - blt _080811FA - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldrb r0, [r1, 0x4] - cmp r0, 0x1 - beq _080812BC -_080811FA: - movs r0, 0xFF - movs r1, 0 - movs r2, 0 - bl GetFieldObjectIdByLocalIdAndMap - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r4, _0808123C @ =gMapObjects - adds r0, r4 - bl FieldObjectClearAnimIfSpecialAnimActive - movs r0, 0xFF - movs r1, 0 - movs r2, 0 - bl GetFieldObjectIdByLocalIdAndMap - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0x9 - bl FieldObjectSetSpecialAnim - movs r0, 0x2 - strh r0, [r5, 0x8] - b _080812BC - .align 2, 0 -_0808123C: .4byte gMapObjects -_08081240: - bl walkrun_is_standing_still - lsls r0, 24 - cmp r0, 0 - beq _080812BC - movs r2, 0 - ldrsh r0, [r4, r2] - movs r2, 0 - ldrsh r1, [r6, r2] - subs r1, 0x1 - bl FieldAnimateDoorClose - lsls r0, 24 - asrs r0, 24 - strh r0, [r5, 0xA] - movs r0, 0xFF - movs r1, 0 - movs r2, 0 - bl GetFieldObjectIdByLocalIdAndMap - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, _08081288 @ =gMapObjects - adds r0, r1 - bl FieldObjectClearAnimIfSpecialAnimFinished - movs r0, 0 - bl sub_8080958 - movs r0, 0x3 - strh r0, [r5, 0x8] - b _080812BC - .align 2, 0 -_08081288: .4byte gMapObjects -_0808128C: - movs r1, 0xA - ldrsh r0, [r5, r1] - cmp r0, 0 - blt _080812A2 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldrb r0, [r1, 0x4] - cmp r0, 0x1 - beq _080812BC -_080812A2: - movs r0, 0x4 - strh r0, [r5, 0x8] - b _080812BC -_080812A8: - bl sub_8053FF8 - bl fade_8080918 - bl PlayRainSoundEffect - movs r0, 0 - strh r0, [r5, 0x8] - ldr r0, _080812C4 @ =task0A_fade_n_map_maybe - str r0, [r5] -_080812BC: - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_080812C4: .4byte task0A_fade_n_map_maybe - thumb_func_end sub_808115C - - thumb_func_start sub_80812C8 -sub_80812C8: @ 80812C8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, _080812EC @ =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _08081300 - cmp r0, 0x1 - bgt _080812F0 - cmp r0, 0 - beq _080812F6 - b _0808132A - .align 2, 0 -_080812EC: .4byte gTasks -_080812F0: - cmp r0, 0x2 - beq _0808131A - b _0808132A -_080812F6: - bl FreezeMapObjects - bl ScriptContext2_Enable - b _08081312 -_08081300: - bl sub_8080E64 - cmp r0, 0 - bne _0808132A - bl sub_8054034 - lsls r0, 24 - cmp r0, 0 - beq _0808132A -_08081312: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _0808132A -_0808131A: - bl warp_in - ldr r0, _08081330 @ =sub_8054534 - bl SetMainCallback2 - adds r0, r5, 0 - bl DestroyTask -_0808132A: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08081330: .4byte sub_8054534 - thumb_func_end sub_80812C8 - - thumb_func_start sub_8081334 -sub_8081334: @ 8081334 - push {lr} - bl ScriptContext2_Enable - bl sub_8053FF8 - bl fade_8080918 - bl PlayRainSoundEffect - movs r0, 0x9 - bl PlaySE - ldr r0, _08081360 @ =gFieldCallback - ldr r1, _08081364 @ =sub_8080B60 - str r1, [r0] - ldr r0, _08081368 @ =sub_80812C8 - movs r1, 0xA - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_08081360: .4byte gFieldCallback -_08081364: .4byte sub_8080B60 -_08081368: .4byte sub_80812C8 - thumb_func_end sub_8081334 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/field_effect.h b/include/field_effect.h index bf80ca0dc..ea02c4131 100644 --- a/include/field_effect.h +++ b/include/field_effect.h @@ -130,6 +130,8 @@ void PokeballGlowEffect_5(struct Sprite *); void PokeballGlowEffect_6(struct Sprite *); void PokeballGlowEffect_7(struct Sprite *); +void sub_8086748(void); + bool8 sub_80867AC(struct Task *); bool8 sub_8086854(struct Task *); bool8 sub_8086870(struct Task *); @@ -138,6 +140,8 @@ bool8 sub_808699C(struct Task *); bool8 sub_80869B8(struct Task *); bool8 sub_80869F8(struct Task *); +void sub_8086A2C(u8, u8); + bool8 sub_8086AA0(struct Task *); bool8 sub_8086AC0(struct Task *); bool8 sub_8086B30(struct Task *); @@ -163,6 +167,8 @@ bool8 sub_8087124(struct Task *); bool8 dive_2_unknown(struct Task *); bool8 dive_3_unknown(struct Task *); +void sub_80871B8(u8); + bool8 sub_808722C(struct Task *, struct MapObject *, struct Sprite *); bool8 sub_8087264(struct Task *, struct MapObject *, struct Sprite *); bool8 sub_8087298(struct Task *, struct MapObject *, struct Sprite *); @@ -175,6 +181,8 @@ bool8 sub_80874FC(struct Task *, struct MapObject *, struct Sprite *); bool8 sub_8087548(struct Task *, struct MapObject *, struct Sprite *); bool8 sub_808759C(struct Task *, struct MapObject *, struct Sprite *); +void sub_8087654(u8); + bool8 sub_80876C8(struct Task *, struct MapObject *, struct Sprite *); bool8 sub_80876F8(struct Task *, struct MapObject *, struct Sprite *); bool8 sub_8087774(struct Task *, struct MapObject *, struct Sprite *); diff --git a/include/field_fadetransition.h b/include/field_fadetransition.h index 764adfc9a..111dc92a6 100644 --- a/include/field_fadetransition.h +++ b/include/field_fadetransition.h @@ -16,7 +16,7 @@ void sub_8080B60(void); void atk17_seteffectuser(void); void sub_8080E28(void); void sub_8080E44(void); -int sub_8080E70(void); +bool32 sub_8080E70(void); void sub_8080E88(void); void sub_8080E88(); void sp13E_warp_to_last_warp(void); diff --git a/include/field_special_scene.h b/include/field_special_scene.h index ef3f07120..d674f09df 100644 --- a/include/field_special_scene.h +++ b/include/field_special_scene.h @@ -9,5 +9,6 @@ void Task_Truck3(u8 taskId); void Task_HandleTruckSequence(u8 taskId); void ExecuteTruckSequence(void); void EndTruckSequence(u8); +void sub_80C791C(void); #endif // GUARD_FIELD_SPECIAL_SCENE_H diff --git a/include/rom4.h b/include/rom4.h index fabd25302..8d5b1bfa2 100644 --- a/include/rom4.h +++ b/include/rom4.h @@ -99,7 +99,7 @@ void sub_8053F0C(void); void sub_8053F84(void); void sub_8053FB0(u16); // is_warp1_light_level_8_or_9 -// sub_8053FF8 +void sub_8053FF8(void); bool8 sub_8054034(void); void sub_8054044(void); // sub_8054050 @@ -129,8 +129,8 @@ void CB2_NewGame(void); void CB2_WhiteOut(void); void CB2_LoadMap(void); void CB2_LoadMap2(void); -// sub_8054534 -// sub_8054588 +void sub_8054534(void); +void sub_8054588(void); void c2_80567AC(void); void c2_exit_to_overworld_2_switch(void); void c2_exit_to_overworld_2_local(void); diff --git a/ld_script.txt b/ld_script.txt index 1a958bd5d..c895c4d06 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -127,7 +127,6 @@ SECTIONS { src/field_weather.o(.text); asm/field_weather.o(.text); src/field_fadetransition.o(.text); - asm/field_fadetransition.o(.text); src/field_screen_effect.o(.text); src/battle_setup.o(.text); asm/cable_club.o(.text); diff --git a/src/field_fadetransition.c b/src/field_fadetransition.c index 364d55e51..e614d899a 100644 --- a/src/field_fadetransition.c +++ b/src/field_fadetransition.c @@ -1,26 +1,41 @@ #include "global.h" -#include "gba/syscall.h" +#include "cable_club.h" +#include "fieldmap.h" +#include "field_door.h" +#include "field_effect.h" #include "field_fadetransition.h" +#include "field_map_obj.h" +#include "field_map_obj_helpers.h" #include "field_player_avatar.h" +#include "field_special_scene.h" #include "field_weather.h" #include "fldeff_flash.h" -#include "global.fieldmap.h" +#include "link.h" +#include "main.h" +#include "map_obj_lock.h" +#include "metatile_behavior.h" +#include "palette.h" #include "rom4.h" #include "script.h" +#include "songs.h" +#include "sound.h" +#include "start_menu.h" #include "task.h" -extern u16 gPlttBufferFaded[]; +void sub_8080B9C(u8); +void task_map_chg_seq_0807E20C(u8); +void task_map_chg_seq_0807E2CC(u8); +void task0A_fade_n_map_maybe(u8); +void sub_808115C(u8); void palette_bg_fill_white(void) { - u32 source_color = 0x7fff7fff; - CpuFastSet(&source_color, gPlttBufferFaded, 0x100 | (1 << 24)); + CpuFastFill16(RGB_WHITE, gPlttBufferFaded, PLTT_SIZE); } void palette_bg_fill_black(void) { - u32 source_color = 0; - CpuFastSet(&source_color, gPlttBufferFaded, 0x100 | (1 << 24)); + CpuFastFill16(RGB_BLACK, gPlttBufferFaded, PLTT_SIZE); } void pal_fill_for_map_transition(void) @@ -64,7 +79,7 @@ void sub_8080958(u8 arg) void task0A_asap_script_env_2_enable_and_set_ctx_running(u8 taskID) { - if (sub_8080E70() == 1) + if (sub_8080E70() == TRUE) { DestroyTask(taskID); EnableBothScriptContexts(); @@ -76,12 +91,536 @@ void sub_8080990(void) ScriptContext2_Enable(); sub_8053E90(); pal_fill_black(); - CreateTask(&task0A_asap_script_env_2_enable_and_set_ctx_running, 0x0a); + CreateTask(task0A_asap_script_env_2_enable_and_set_ctx_running, 10); } void sub_80809B0(void) { ScriptContext2_Enable(); pal_fill_black(); - CreateTask(&task0A_asap_script_env_2_enable_and_set_ctx_running, 0x0a); + CreateTask(task0A_asap_script_env_2_enable_and_set_ctx_running, 10); +} + +void task_mpl_807DD60(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + task->data[1] = sub_8083664(); + task->data[0]++; + break; + case 1: + if (gTasks[task->data[1]].isActive != TRUE) + { + pal_fill_for_map_transition(); + task->data[0]++; + } + break; + case 2: + if (sub_8080E70() == TRUE) + { + ScriptContext2_Disable(); + DestroyTask(taskId); + } + } +} + +void sub_8080A3C(void) +{ + ScriptContext2_Enable(); + sub_8053E90(); + palette_bg_fill_black(); + CreateTask(task_mpl_807DD60, 10); +} + +void sub_8080A5C(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + sub_80084A4(); + task->data[0]++; + break; + case 1: + if (sub_8007ECC()) + { + pal_fill_for_map_transition(); + task->data[0]++; + } + break; + case 2: + if (sub_8080E70() == TRUE) + { + sub_8007B14(); + ScriptContext2_Disable(); + DestroyTask(taskId); + } + } +} + +void sub_8080AC4(void) +{ + ScriptContext2_Enable(); + sub_8053E90(); + palette_bg_fill_black(); + CreateTask(sub_8080A5C, 10); +} + +void sub_8080AE4(void) +{ + s16 x, y; + u8 behavior; + TaskFunc func; + PlayerGetDestCoords(&x, &y); + behavior = MapGridGetMetatileBehaviorAt(x, y); + if (MetatileBehavior_IsDoor(behavior) == TRUE) + func = sub_8080B9C; + else if (MetatileBehavior_IsNonAnimDoor(behavior) == TRUE) + func = task_map_chg_seq_0807E20C; + else + func = task_map_chg_seq_0807E2CC; + CreateTask(func, 10); +} + +void mapldr_default(void) +{ + sub_8053E90(); + pal_fill_for_map_transition(); + sub_8080AE4(); + ScriptContext2_Enable(); +} + +void sub_8080B60(void) +{ + sub_8053E90(); + pal_fill_black(); + sub_8080AE4(); + ScriptContext2_Enable(); +} + +void sub_8080B78(void) +{ + sub_8053E90(); + pal_fill_for_map_transition(); + PlaySE(SE_TK_WARPOUT); + CreateTask(task_map_chg_seq_0807E2CC, 10); + ScriptContext2_Enable(); +} + +void sub_8080B9C(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + s16 *x = &task->data[2]; + s16 *y = &task->data[3]; + + switch (task->data[0]) + { + case 0: + sub_8080958(0); + FreezeMapObjects(); + PlayerGetDestCoords(x, y); + FieldSetDoorOpened(*x, *y); + task->data[0] = 1; + break; + case 1: + if (sub_8080E70()) + { + u8 mapObjId; + sub_8080958(1); + mapObjId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); + FieldObjectSetSpecialAnim(&gMapObjects[mapObjId], 8); + task->data[0] = 2; + } + break; + case 2: + if (walkrun_is_standing_still()) + { + u8 mapObjId; + task->data[1] = FieldAnimateDoorClose(*x, *y); + mapObjId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); + FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[mapObjId]); + task->data[0] = 3; + } + break; + case 3: + if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE) + { + UnfreezeMapObjects(); + task->data[0] = 4; + } + break; + case 4: + ScriptContext2_Disable(); + DestroyTask(taskId); + break; + } +} + +void task_map_chg_seq_0807E20C(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + s16 *x = &task->data[2]; + s16 *y = &task->data[3]; + + switch (task->data[0]) + { + case 0: + sub_8080958(0); + FreezeMapObjects(); + PlayerGetDestCoords(x, y); + task->data[0] = 1; + break; + case 1: + if (sub_8080E70()) + { + u8 mapObjId; + sub_8080958(1); + mapObjId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); + FieldObjectSetSpecialAnim(&gMapObjects[mapObjId], GetGoSpeed0AnimId(player_get_direction_lower_nybble())); + task->data[0] = 2; + } + break; + case 2: + if (walkrun_is_standing_still()) + { + UnfreezeMapObjects(); + task->data[0] = 3; + } + break; + case 3: + ScriptContext2_Disable(); + DestroyTask(taskId); + break; + } +} + +void task_map_chg_seq_0807E2CC(u8 taskId) +{ + switch (gTasks[taskId].data[0]) + { + case 0: + FreezeMapObjects(); + ScriptContext2_Enable(); + gTasks[taskId].data[0]++; + break; + case 1: + if (sub_8080E70()) + { + UnfreezeMapObjects(); + ScriptContext2_Disable(); + DestroyTask(taskId); + } + break; + } +} + +void sub_8080DC4(u8 taskId) +{ + if (sub_8080E70() == TRUE) + { + DestroyTask(taskId); + CreateTask(sub_80712B4, 80); + } +} + +void atk17_seteffectuser(void) +{ + pal_fill_black(); + CreateStartMenuTask(sub_8080DC4); + ScriptContext2_Enable(); +} + +void task_mpl_807E3C8(u8 taskId) +{ + if (sub_8080E70() == 1) + { + ScriptContext2_Disable(); + DestroyTask(taskId); + sub_8064E2C(); + } +} + +void sub_8080E28(void) +{ + ScriptContext2_Enable(); + pal_fill_black(); + CreateTask(task_mpl_807E3C8, 10); +} + +void sub_8080E44(void) +{ + ScriptContext2_Enable(); + sub_8053E90(); + pal_fill_black(); + CreateTask(task_mpl_807E3C8, 10); +} + +bool32 sub_8080E64(void) +{ + return gPaletteFade.active; +} + +bool32 sub_8080E70(void) +{ + if (sub_807D770() == TRUE) + return TRUE; + else + return FALSE; +} + +void sub_8080E88(void) +{ + ScriptContext2_Enable(); + sub_8053FF8(); + fade_8080918(); + PlayRainSoundEffect(); + PlaySE(SE_KAIDAN); + gFieldCallback = mapldr_default; + CreateTask(task0A_fade_n_map_maybe, 10); +} + +void sp13E_warp_to_last_warp(void) +{ + ScriptContext2_Enable(); + sub_8053FF8(); + fade_8080918(); + PlayRainSoundEffect(); + gFieldCallback = mapldr_default; + CreateTask(task0A_fade_n_map_maybe, 10); +} + +void sub_8080EF0(void) +{ + ScriptContext2_Enable(); + gFieldCallback = mapldr_default; + CreateTask(sub_808115C, 10); +} + +void sp13F_fall_to_last_warp(void) +{ + sp13E_warp_to_last_warp(); + gFieldCallback = sub_8086748; +} + +void sub_8080F2C(u8 metatileBehavior) +{ + ScriptContext2_Enable(); + sub_8086A2C(metatileBehavior, 10); +} + +void sub_8080F48(void) +{ + ScriptContext2_Enable(); + sub_80871B8(10); +} + +void sub_8080F58(void) +{ + ScriptContext2_Enable(); + sub_8087654(10); +} + +void sub_8080F68(void) +{ + ScriptContext2_Enable(); + sub_8053FF8(); + fade_8080918(); + PlaySE(SE_TK_WARPIN); + CreateTask(task0A_fade_n_map_maybe, 10); + gFieldCallback = sub_8080B78; +} + +void sub_8080F9C(void) +{ + ScriptContext2_Enable(); + fade_8080918(); + CreateTask(task0A_fade_n_map_maybe, 10); + gFieldCallback = sub_80C791C; +} + +void sub_8080FC4(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + ScriptContext2_Enable(); + task->data[0]++; + break; + case 1: + if (!sub_8080E64() && sub_8054034()) + { + task->data[0]++; + } + break; + case 2: + warp_in(); + SetMainCallback2(sub_8054588); + DestroyTask(taskId); + break; + } +} + +void DoCableClubWarp(void) +{ + ScriptContext2_Enable(); + sub_8053FF8(); + fade_8080918(); + PlaySE(SE_KAIDAN); + CreateTask(sub_8080FC4, 10); +} + +void sub_8081050(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + switch (data[0]) + { + case 0: + ClearLinkCallback_2(); + fade_screen(1, 0); + sub_8053FF8(); + PlaySE(SE_KAIDAN); + data[0]++; + break; + case 1: + if (!sub_8080E64() && sub_8054034()) + { + sub_800832C(); + data[0]++; + } + break; + case 2: + if (!gReceivedRemoteLinkPlayers) + { + warp_in(); + SetMainCallback2(CB2_LoadMap); + DestroyTask(taskId); + } + break; + } +} + +void sub_80810DC(void) +{ + CreateTask(sub_8081050, 10); +} + +void task0A_fade_n_map_maybe(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + FreezeMapObjects(); + ScriptContext2_Enable(); + task->data[0]++; + break; + case 1: + if (!sub_8080E64() && sub_8054034()) + { + task->data[0]++; + } + break; + case 2: + warp_in(); + SetMainCallback2(CB2_LoadMap); + DestroyTask(taskId); + break; + } +} + +void sub_808115C(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + s16 *x = &task->data[2]; + s16 *y = &task->data[3]; + + switch (task->data[0]) + { + case 0: + FreezeMapObjects(); + PlayerGetDestCoords(x, y); + PlaySE(sub_8058790(*x, *y - 1)); + task->data[1] = FieldAnimateDoorOpen(*x, *y - 1); + task->data[0] = 1; + break; + case 1: + if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE) + { + u8 mapObjId; + mapObjId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); + FieldObjectClearAnimIfSpecialAnimActive(&gMapObjects[mapObjId]); + mapObjId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); + FieldObjectSetSpecialAnim(&gMapObjects[mapObjId], 9); + task->data[0] = 2; + } + break; + case 2: + if (walkrun_is_standing_still()) + { + u8 mapObjId; + task->data[1] = FieldAnimateDoorClose(*x, *y - 1); + mapObjId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); + FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[mapObjId]); + sub_8080958(0); + task->data[0] = 3; + } + break; + case 3: + if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE) + { + task->data[0] = 4; + } + break; + case 4: + sub_8053FF8(); + fade_8080918(); + PlayRainSoundEffect(); + task->data[0] = 0; + task->func = task0A_fade_n_map_maybe; + break; + } +} + +void sub_80812C8(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + FreezeMapObjects(); + ScriptContext2_Enable(); + task->data[0]++; + break; + case 1: + if (!sub_8080E64() && sub_8054034()) + { + task->data[0]++; + } + break; + case 2: + warp_in(); + SetMainCallback2(sub_8054534); + DestroyTask(taskId); + break; + } +} + +void sub_8081334(void) +{ + ScriptContext2_Enable(); + sub_8053FF8(); + fade_8080918(); + PlayRainSoundEffect(); + PlaySE(SE_KAIDAN); + gFieldCallback = sub_8080B60; + CreateTask(sub_80812C8, 10); }