From 077089f0e5bd90701fe7ba080e6b25bc67848aed Mon Sep 17 00:00:00 2001 From: EternalCode Date: Sun, 3 Dec 2017 20:46:56 -0500 Subject: [PATCH] fldeff_teleport file completed --- asm/fldeff_teleport.s | 84 ------------------------------------------- ld_script.txt | 2 +- src/fldeff_teleport.c | 54 ++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 85 deletions(-) delete mode 100644 asm/fldeff_teleport.s create mode 100644 src/fldeff_teleport.c diff --git a/asm/fldeff_teleport.s b/asm/fldeff_teleport.s deleted file mode 100644 index 17bab1496..000000000 --- a/asm/fldeff_teleport.s +++ /dev/null @@ -1,84 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start SetUpFieldMove_Teleport -SetUpFieldMove_Teleport: @ 817C8BC - push {lr} - ldr r0, =gMapHeader - ldrb r0, [r0, 0x17] - bl is_light_level_1_2_3_or_6 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0817C8D8 - movs r0, 0 - b _0817C8E6 - .pool -_0817C8D8: - ldr r1, =gUnknown_03005DB0 - ldr r0, =hm_add_c3_launch_phase_2 - str r0, [r1] - ldr r1, =gUnknown_0203CEEC - ldr r0, =hm_teleport_run_dp02scr - str r0, [r1] - movs r0, 0x1 -_0817C8E6: - pop {r1} - bx r1 - .pool - thumb_func_end SetUpFieldMove_Teleport - - thumb_func_start hm_teleport_run_dp02scr -hm_teleport_run_dp02scr: @ 817C8FC - push {lr} - bl sub_808469C - movs r0, 0x3F - bl FieldEffectStart - bl GetCursorSelectionMonId - ldr r1, =gFieldEffectArguments - lsls r0, 24 - lsrs r0, 24 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end hm_teleport_run_dp02scr - - thumb_func_start FldEff_UseTeleport -FldEff_UseTeleport: @ 817C91C - push {lr} - bl oei_task_add - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r2, =sub_817C94C - lsrs r0, r2, 16 - strh r0, [r1, 0x18] - strh r2, [r1, 0x1A] - movs r0, 0x1 - bl SetPlayerAvatarTransitionFlags - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end FldEff_UseTeleport - - thumb_func_start sub_817C94C -sub_817C94C: @ 817C94C - push {lr} - movs r0, 0x3F - bl FieldEffectActiveListRemove - bl sub_80B7FC8 - pop {r0} - bx r0 - thumb_func_end sub_817C94C - - .align 2, 0 @ Don't pad with nop. diff --git a/ld_script.txt b/ld_script.txt index e71b63e6c..a3c4b498e 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -226,7 +226,7 @@ SECTIONS { asm/intro_credits_graphics.o(.text); src/evolution_graphics.o(.text); src/bard_music.o(.text); - asm/fldeff_teleport.o(.text); + src/fldeff_teleport.o(.text); asm/battle_link_817C95C.o(.text); asm/pokemon_animation.o(.text); src/recorded_battle.o(.text); diff --git a/src/fldeff_teleport.c b/src/fldeff_teleport.c new file mode 100644 index 000000000..3ca72d787 --- /dev/null +++ b/src/fldeff_teleport.c @@ -0,0 +1,54 @@ +#include "global.h" +#include "field_effect.h" +#include "task.h" + +extern bool8 is_light_level_1_2_3_or_6(u8 mapType); +extern void* hm_add_c3_launch_phase_2(void); +extern void hm_teleport_run_dp02scr(void); +extern void* gUnknown_0203CEEC; +extern void* gUnknown_03005DB0; +extern void sub_808469C(void); +extern u8 GetCursorSelectionMonId(void); +extern void sub_817C94C(void); +extern u8 oei_task_add(void); +extern void FieldEffectActiveListRemove(u8 id); +extern void sub_80B7FC8(void); + +// 817C8BC +bool8 SetUpFieldMove_Teleport() +{ + if (is_light_level_1_2_3_or_6(gMapHeader.mapType) == TRUE) + { + gUnknown_03005DB0 = hm_add_c3_launch_phase_2; + gUnknown_0203CEEC = hm_teleport_run_dp02scr; + return TRUE; + } + return FALSE; +} + +// 817C8FC +void hm_teleport_run_dp02scr() +{ + sub_808469C(); + FieldEffectStart(0x3F); + gFieldEffectArguments[0] = (u32)GetCursorSelectionMonId(); +} + +extern void SetPlayerAvatarTransitionFlags(u8); +// 817C91C +u8 FldEff_UseTeleport() +{ + u8 taskID = oei_task_add(); + gTasks[taskID].data[8] = (u32)sub_817C94C >> 16; + gTasks[taskID].data[9] = (u32)sub_817C94C; + SetPlayerAvatarTransitionFlags(1); + return 0; +} + +void sub_817C94C() +{ + FieldEffectActiveListRemove(0x3F); + sub_80B7FC8(); +} + +