From a2a66181fb32b7af72920b52e4ae28b9a99eb336 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 10 Sep 2017 23:05:23 +0200 Subject: [PATCH 1/2] decompile script.s --- asm/battle_setup.s | 28 +- asm/braille_puzzles.s | 8 +- asm/cable_car.s | 2 +- asm/cable_club.s | 24 +- asm/contest.s | 4 +- asm/contest_link_80F57C4.s | 14 +- asm/daycare.s | 4 +- asm/decoration.s | 12 +- asm/egg_hatch.s | 2 +- asm/field_control_avatar.s | 2 +- asm/field_effect.s | 42 +- asm/field_player_avatar.s | 18 +- asm/field_poison.s | 4 +- asm/field_tasks.s | 2 +- asm/fldeff_80F9BCC.s | 14 +- asm/fldeff_strength.s | 2 +- asm/item_use.s | 12 +- asm/lilycove_lady.s | 4 +- asm/link.s | 36 +- asm/mauville_old_man.s | 6 +- asm/mystery_event_script.s | 48 +- asm/player_pc.s | 2 +- asm/porthole.s | 2 +- asm/record_mixing.s | 2 +- asm/rom4.s | 54 +- asm/rom6.s | 38 +- asm/rom_80AEFFC.s | 94 +- asm/rom_80C6FA0.s | 10 +- asm/rom_815A0D4.s | 2 +- asm/rom_818E9AC.s | 32 +- asm/rom_81BE66C.s | 12 +- asm/roulette.s | 6 +- asm/scrcmd.s | 496 +++++------ asm/script.s | 879 ------------------- asm/script_menu.s | 6 +- asm/script_pokemon_util_80F87D8.s | 2 +- asm/secret_base.s | 10 +- asm/shop.s | 10 +- asm/start_menu.s | 14 +- asm/trade.s | 2 +- asm/trader.s | 6 +- asm/trainer_see.s | 2 +- asm/truck_scene.s | 4 +- asm/weather.s | 2 +- data/data3.s | 2 +- data/event_script_command_function_table.inc | 2 +- data/event_scripts.s | 2 +- include/script.h | 9 +- include/util.h | 15 + ld_script.txt | 2 +- src/safari_zone.c | 4 +- src/script.c | 434 +++++++++ sym_bss.txt | 13 +- 53 files changed, 1012 insertions(+), 1446 deletions(-) delete mode 100644 asm/script.s create mode 100644 include/util.h create mode 100644 src/script.c diff --git a/asm/battle_setup.s b/asm/battle_setup.s index 43f30e0ec..aea1be97c 100644 --- a/asm/battle_setup.s +++ b/asm/battle_setup.s @@ -108,7 +108,7 @@ sub_80B06B0: @ 80B06B0 thumb_func_start sub_80B06BC sub_80B06BC: @ 80B06BC push {r4,lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic bl sub_808BCF4 ldr r1, =gMain @@ -150,7 +150,7 @@ _080B06F2: thumb_func_start sub_80B072C sub_80B072C: @ 80B072C push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic bl sub_808BCF4 ldr r1, =gMain @@ -179,7 +179,7 @@ sub_80B072C: @ 80B072C thumb_func_start sub_80B077C sub_80B077C: @ 80B077C push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic bl sub_808BCF4 ldr r1, =gMain @@ -201,7 +201,7 @@ sub_80B077C: @ 80B077C thumb_func_start sub_80B07B4 sub_80B07B4: @ 80B07B4 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic bl sub_808BCF4 ldr r1, =gMain @@ -283,7 +283,7 @@ sub_80B086C: @ 80B086C lsls r1, 1 movs r2, 0x5 bl CreateMaleMon - bl script_env_2_enable + bl ScriptContext2_Enable ldr r1, =gMain ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music str r0, [r1, 0x8] @@ -302,7 +302,7 @@ sub_80B086C: @ 80B086C thumb_func_start sub_80B08A8 sub_80B08A8: @ 80B08A8 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable ldr r1, =gMain ldr r0, =sub_80B0B6C str r0, [r1, 0x8] @@ -328,7 +328,7 @@ sub_80B08A8: @ 80B08A8 thumb_func_start sub_80B08EC sub_80B08EC: @ 80B08EC push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable ldr r1, =gMain ldr r0, =sub_80B0B6C str r0, [r1, 0x8] @@ -355,7 +355,7 @@ sub_80B08EC: @ 80B08EC thumb_func_start sub_80B0934 sub_80B0934: @ 80B0934 push {r4,lr} - bl script_env_2_enable + bl ScriptContext2_Enable ldr r1, =gMain ldr r0, =sub_80B0B6C str r0, [r1, 0x8] @@ -457,7 +457,7 @@ _080B09FE: thumb_func_start sub_80B0A18 sub_80B0A18: @ 80B0A18 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable ldr r1, =gMain ldr r0, =sub_80B0B6C str r0, [r1, 0x8] @@ -494,7 +494,7 @@ _080B0A5A: thumb_func_start sub_80B0A74 sub_80B0A74: @ 80B0A74 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable ldr r1, =gMain ldr r0, =sub_80B0B6C str r0, [r1, 0x8] @@ -1895,7 +1895,7 @@ SingleTrainerWantsBattle: @ 80B162C bl TrainerBattleConfigure ldr r0, =gUnknown_08271354 bl ScriptContext1_SetupScript - bl script_env_2_enable + bl ScriptContext2_Enable pop {r4} pop {r0} bx r0 @@ -1933,7 +1933,7 @@ TwoTrainersWantBattleExecuteScript: @ 80B16A4 push {lr} ldr r0, =gUnknown_08271354 bl ScriptContext1_SetupScript - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 .pool @@ -2213,7 +2213,7 @@ _080B18E8: _080B1908: bl task_add_01_battle_start_with_music_and_stats _080B190C: - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop pop {r4} pop {r0} bx r0 @@ -2315,7 +2315,7 @@ sub_80B19EC: @ 80B19EC ldr r0, =sub_80B1994 str r0, [r1, 0x8] bl task_add_01_battle_start_with_music_and_stats - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop pop {r0} bx r0 .pool diff --git a/asm/braille_puzzles.s b/asm/braille_puzzles.s index f01b19f9c..ceaddbdf0 100644 --- a/asm/braille_puzzles.s +++ b/asm/braille_puzzles.s @@ -73,7 +73,7 @@ sub_817963C: @ 817963C bl PlaySE ldr r0, =0x000008af bl FlagSet - bl script_env_2_disable + bl ScriptContext2_Disable pop {r0} bx r0 .pool @@ -218,7 +218,7 @@ sub_8179778: @ 8179778 bne _081797D0 adds r0, r5, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts bl InstallCameraPanAheadCallback _081797D0: pop {r4,r5} @@ -326,7 +326,7 @@ sub_8179860: @ 8179860 movs r0, 0x8B lsls r0, 4 bl FlagSet - bl script_env_2_disable + bl ScriptContext2_Disable pop {r0} bx r0 .pool @@ -421,7 +421,7 @@ sub_8179944: @ 8179944 bl PlaySE ldr r0, =0x000008b2 bl FlagSet - bl script_env_2_disable + bl ScriptContext2_Disable pop {r0} bx r0 .pool diff --git a/asm/cable_car.s b/asm/cable_car.s index cefd2ef89..9307c54ff 100644 --- a/asm/cable_car.s +++ b/asm/cable_car.s @@ -31,7 +31,7 @@ _0814FC8E: sub_814FC9C: @ 814FC9C push {lr} sub sp, 0x4 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =sub_814FC70 movs r1, 0x1 bl CreateTask diff --git a/asm/cable_club.s b/asm/cable_club.s index 156fac66c..21713e0be 100644 --- a/asm/cable_club.s +++ b/asm/cable_club.s @@ -999,7 +999,7 @@ _080B2BEC: adds r0, r1 ldrh r0, [r0, 0x12] bl sub_80B241C - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts lsls r0, r4, 24 lsrs r0, 24 bl DestroyTask @@ -1093,7 +1093,7 @@ sub_80B2CB0: @ 80B2CB0 adds r4, r0 ldrh r0, [r4, 0x12] bl sub_80B241C - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts ldrb r0, [r4, 0x12] bl RemoveWindow adds r0, r5, 0 @@ -1124,7 +1124,7 @@ sub_80B2CEC: @ 80B2CEC bl sub_8098374 ldrb r0, [r4, 0x12] bl RemoveWindow - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r5, 0 bl DestroyTask pop {r4,r5} @@ -1152,7 +1152,7 @@ sub_80B2D2C: @ 80B2D2C ldrb r0, [r4, 0x12] bl RemoveWindow bl textbox_close - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r5, 0 bl DestroyTask pop {r4,r5} @@ -1429,7 +1429,7 @@ _080B2F82: b _080B2FC6 .pool _080B2FA8: - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r6, 0 bl DestroyTask b _080B2FC6 @@ -1438,7 +1438,7 @@ _080B2FB4: ldrb r0, [r0] cmp r0, 0 bne _080B2FC6 - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r6, 0 bl DestroyTask _080B2FC6: @@ -2342,7 +2342,7 @@ _080B37B8: bl sub_8197AE8 adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _080B37CC: pop {r4,r5} pop {r0} @@ -2362,7 +2362,7 @@ sub_80B37D4: @ 80B37D4 adds r1, r4, 0 adds r2, r5, 0 bl SetTaskFuncWithFollowupFunc - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop pop {r4,r5} pop {r0} bx r0 @@ -2396,7 +2396,7 @@ _080B3824: beq _080B3870 b _080B3884 _080B382E: - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0x1 movs r1, 0 bl fade_screen @@ -2467,7 +2467,7 @@ _080B38BC: beq _080B3908 b _080B391C _080B38C6: - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0x1 movs r1, 0 bl fade_screen @@ -2575,7 +2575,7 @@ sub_80B39A4: @ 80B39A4 ldr r0, =sub_80B3728 movs r1, 0x50 bl CreateTask - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop pop {r0} bx r0 .pool @@ -2695,7 +2695,7 @@ sub_80B3AAC: @ 80B3AAC ldrb r0, [r0] cmp r0, 0 bne _080B3AC4 - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r4, 0 bl DestroyTask _080B3AC4: diff --git a/asm/contest.s b/asm/contest.s index e0ea14adb..9425e262d 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -5599,8 +5599,8 @@ _080DA860: thumb_func_start sub_80DA874 sub_80DA874: @ 80DA874 push {lr} - bl script_env_2_disable - bl script_env_2_enable_and_set_ctx_running + bl ScriptContext2_Disable + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_80DA874 diff --git a/asm/contest_link_80F57C4.s b/asm/contest_link_80F57C4.s index 39a8f5209..19aabe85f 100644 --- a/asm/contest_link_80F57C4.s +++ b/asm/contest_link_80F57C4.s @@ -5196,7 +5196,7 @@ _080F83FE: sub_80F840C: @ 80F840C push {lr} sub sp, 0x4 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =sub_80F83E0 movs r1, 0xA bl CreateTask @@ -5252,7 +5252,7 @@ _080F8476: sub_80F8484: @ 80F8484 push {lr} sub sp, 0x4 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =sub_80F8458 movs r1, 0xA bl CreateTask @@ -5285,7 +5285,7 @@ sub_80F84C4: @ 80F84C4 adds r5, r0, 0 lsls r5, 24 lsrs r5, 24 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r6, =sub_80FC580 adds r0, r6, 0 movs r1, 0 @@ -5599,8 +5599,8 @@ _080F874C: negs r3, r3 movs r0, 0 bl saved_warp2_set - bl script_env_2_disable - bl script_env_2_enable_and_set_ctx_running + bl ScriptContext2_Disable + bl EnableBothScriptContexts _080F877E: pop {r4-r6} pop {r0} @@ -5639,8 +5639,8 @@ sub_80F87B4: @ 80F87B4 bne _080F87D0 adds r0, r1, 0 bl DestroyTask - bl script_env_2_disable - bl script_env_2_enable_and_set_ctx_running + bl ScriptContext2_Disable + bl EnableBothScriptContexts _080F87D0: pop {r0} bx r0 diff --git a/asm/daycare.s b/asm/daycare.s index e3470d9f2..711d63e42 100644 --- a/asm/daycare.s +++ b/asm/daycare.s @@ -3100,7 +3100,7 @@ _0807124E: bl RemoveWindow adds r0, r5, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts b _080712B4 .pool _08071284: @@ -3122,7 +3122,7 @@ _08071284: bl RemoveWindow adds r0, r5, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _080712B4: pop {r4,r5} pop {r0} diff --git a/asm/decoration.s b/asm/decoration.s index 53eca818a..f56567375 100644 --- a/asm/decoration.s +++ b/asm/decoration.s @@ -161,7 +161,7 @@ sub_8126ABC: @ 8126ABC ldr r1, =gUnknown_0203A150 movs r0, 0 strb r0, [r1] - bl script_env_2_enable + bl ScriptContext2_Enable bl sub_8126A88 bl sub_8126C08 pop {r0} @@ -4132,7 +4132,7 @@ c1_overworld_prev_quest: @ 8128BEC b _08128C4C .pool _08128C10: - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 @@ -4198,7 +4198,7 @@ _08128C9C: b _08128CAC .pool _08128CA8: - bl script_env_2_enable + bl ScriptContext2_Enable _08128CAC: ldrh r0, [r4, 0x4] adds r0, 0x1 @@ -4225,7 +4225,7 @@ _08128CCA: thumb_func_start sub_8128CD4 sub_8128CD4: @ 8128CD4 push {r4,lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl pal_fill_black ldr r0, =sub_8128C64 movs r1, 0x8 @@ -5796,7 +5796,7 @@ _08129928: b _08129994 .pool _08129954: - bl script_env_2_enable + bl ScriptContext2_Enable adds r0, r5, 0 bl sub_8127814 bl pal_fill_black @@ -6956,7 +6956,7 @@ _0812A2FC: b _0812A30C .pool _0812A308: - bl script_env_2_enable + bl ScriptContext2_Enable _0812A30C: ldrh r0, [r4, 0x4] adds r0, 0x1 diff --git a/asm/egg_hatch.s b/asm/egg_hatch.s index 48f6ae7b3..52a659663 100644 --- a/asm/egg_hatch.s +++ b/asm/egg_hatch.s @@ -468,7 +468,7 @@ sub_807172C: @ 807172C thumb_func_start sub_8071740 sub_8071740: @ 8071740 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =sub_8071760 movs r1, 0xA bl CreateTask diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index e0345e188..f3321f27a 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -689,7 +689,7 @@ _0809C442: adds r1, r0, 0 ldr r0, =gScriptLastTalked ldrb r0, [r0] - bl sub_8099188 + bl GetRamScript adds r1, r0, 0 _0809C44E: pop {r4-r7} diff --git a/asm/field_effect.s b/asm/field_effect.s index b19e7a509..c2f98a3e3 100644 --- a/asm/field_effect.s +++ b/asm/field_effect.s @@ -1960,7 +1960,7 @@ mapldr_080842E8: @ 80B69FC ldr r0, =task00_8084310 movs r1, 0 bl CreateTask - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic ldr r1, =gUnknown_03005DAC movs r0, 0 @@ -2056,7 +2056,7 @@ mapldr_08084390: @ 80B6AA4 movs r1, 0x3 bl FieldObjectTurn _080B6AE6: - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic ldr r1, =gUnknown_03005DAC movs r0, 0 @@ -2099,7 +2099,7 @@ _080B6B3E: lsls r0, 24 cmp r0, 0 bne _080B6B58 - bl script_env_2_disable + bl ScriptContext2_Disable bl sub_809757C adds r0, r5, 0 bl DestroyTask @@ -2115,7 +2115,7 @@ sub_80B6B68: @ 80B6B68 push {lr} bl sub_8085784 bl pal_fill_for_maplights - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic ldr r0, =sub_80B6B94 movs r1, 0 @@ -2457,7 +2457,7 @@ sub_80B6E18: @ 80B6E18 ldr r1, =gUnknown_02037590 movs r0, 0 strb r0, [r1, 0x6] - bl script_env_2_disable + bl ScriptContext2_Disable bl CameraObjectReset1 bl sub_809757C bl InstallCameraPanAheadCallback @@ -2782,7 +2782,7 @@ sub_80B70B4: @ 80B70B4 push {lr} bl sub_8085784 bl pal_fill_for_maplights - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =sub_80B70DC movs r1, 0 bl CreateTask @@ -3076,7 +3076,7 @@ sub_80B72F4: @ 80B72F4 cmp r0, 0 beq _080B7338 bl CameraObjectReset1 - bl script_env_2_disable + bl ScriptContext2_Disable movs r0, 0x4 bl GetGoSpeed0AnimId adds r1, r0, 0 @@ -3161,7 +3161,7 @@ _080B7396: sub_80B73D0: @ 80B73D0 push {r4,lr} adds r4, r0, 0 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r1, =gUnknown_02037590 movs r0, 0x1 strb r0, [r1, 0x6] @@ -3180,7 +3180,7 @@ waterfall_1_do_anim_probably: @ 80B73F0 push {r4,r5,lr} adds r4, r0, 0 adds r5, r1, 0 - bl script_env_2_enable + bl ScriptContext2_Enable adds r0, r5, 0 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive lsls r0, 24 @@ -3267,7 +3267,7 @@ _080B748E: lsrs r4, r0, 24 cmp r4, 0 bne _080B74C4 - bl script_env_2_disable + bl ScriptContext2_Disable ldr r0, =gUnknown_02037590 strb r4, [r0, 0x6] ldr r0, =sub_80B7384 @@ -3362,7 +3362,7 @@ dive_1_lock: @ 80B7544 dive_2_unknown: @ 80B7558 push {r4,lr} adds r4, r0, 0 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r1, =gUnknown_02038C08 movs r2, 0x26 ldrsh r0, [r4, r2] @@ -3749,7 +3749,7 @@ mapldr_080851BC: @ 80B7868 push {lr} bl sub_8085784 bl pal_fill_for_maplights - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =gUnknown_03005DAC movs r1, 0 str r1, [r0] @@ -3918,7 +3918,7 @@ sub_80B79BC: @ 80B79BC ldr r1, =gUnknown_02037590 movs r0, 0 strb r0, [r1, 0x6] - bl script_env_2_disable + bl ScriptContext2_Disable bl sub_809757C ldr r0, =sub_80B7890 bl FindTaskIdByFunc @@ -4286,7 +4286,7 @@ _080B7CC4: thumb_func_start sub_80B7CC8 sub_80B7CC8: @ 80B7CC8 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic ldr r0, =sub_80B7CE4 movs r1, 0x50 @@ -4460,7 +4460,7 @@ mapldr_080859D4: @ 80B7E48 push {lr} bl sub_8085784 bl pal_fill_for_maplights - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic ldr r1, =gUnknown_03005DAC movs r0, 0 @@ -4582,7 +4582,7 @@ _080B7F32: negs r0, r0 ands r0, r1 strb r0, [r6, 0x1] - bl script_env_2_disable + bl ScriptContext2_Disable bl sub_809757C ldr r0, =sub_80B7E94 bl FindTaskIdByFunc @@ -4671,7 +4671,7 @@ sub_80B7FDC: @ 80B7FDC sub_80B800C: @ 80B800C push {r4,lr} adds r4, r0, 0 - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic bl CameraObjectReset2 bl player_get_direction_lower_nybble @@ -4905,7 +4905,7 @@ mapldr_08085D88: @ 80B8200 push {lr} bl sub_8085784 bl pal_fill_for_maplights - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic ldr r1, =gUnknown_03005DAC movs r0, 0 @@ -5192,7 +5192,7 @@ sub_80B8410: @ 80B8410 lsrs r0, 28 cmp r1, r0 bne _080B8484 - bl script_env_2_disable + bl ScriptContext2_Disable bl CameraObjectReset1 bl sub_809757C ldr r0, =sub_80B8250 @@ -6333,7 +6333,7 @@ sub_80B8DB4: @ 80B8DB4 mov r6, r8 push {r6} adds r4, r0, 0 - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic ldr r5, =gUnknown_02037590 movs r0, 0x1 @@ -6528,7 +6528,7 @@ sub_80B8F24: @ 80B8F24 movs r1, 0x1 bl sub_81555AC bl sub_809757C - bl script_env_2_disable + bl ScriptContext2_Disable movs r0, 0x9 bl FieldEffectActiveListRemove ldr r0, =sub_80B8D84 diff --git a/asm/field_player_avatar.s b/asm/field_player_avatar.s index f706c43bf..6947746ef 100644 --- a/asm/field_player_avatar.s +++ b/asm/field_player_avatar.s @@ -3452,7 +3452,7 @@ _0808C360: sub_808C3A4: @ 808C3A4 push {r4,lr} adds r4, r0, 0 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r1, =gUnknown_02037590 movs r0, 0x1 strb r0, [r1, 0x6] @@ -3574,7 +3574,7 @@ sub_808C484: @ 808C484 ldr r1, =gUnknown_02037590 movs r0, 0 strb r0, [r1, 0x6] - bl script_env_2_disable + bl ScriptContext2_Disable ldr r0, =taskFF_bump_boulder bl FindTaskIdByFunc lsls r0, 24 @@ -3752,7 +3752,7 @@ sub_808C61C: @ 808C61C ldr r1, =gUnknown_02037590 movs r0, 0x1 strb r0, [r1, 0x6] - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0x2D bl PlaySE movs r0, 0x1 @@ -3872,7 +3872,7 @@ sub_808C6FC: @ 808C6FC lsrs r1, 24 adds r0, r5, 0 bl FieldObjectSetSpecialAnim - bl script_env_2_disable + bl ScriptContext2_Disable ldr r1, =gUnknown_02037590 movs r0, 0 strb r0, [r1, 0x6] @@ -3895,7 +3895,7 @@ sub_808C750: @ 808C750 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl script_env_2_enable + bl ScriptContext2_Enable bl sav1_reset_battle_music_maybe bl sub_8085898 ldr r2, =gUnknown_02037590 @@ -4008,7 +4008,7 @@ sub_808C814: @ 808C814 bl FieldObjectSetSpecialAnim movs r0, 0 strb r0, [r6, 0x6] - bl script_env_2_disable + bl ScriptContext2_Disable ldrb r1, [r4, 0x1A] lsls r0, r1, 4 adds r0, r1 @@ -4082,7 +4082,7 @@ _0808C8D2: fish0: @ 808C8F8 push {r4,lr} adds r4, r0, 0 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r1, =gUnknown_02037590 movs r0, 0x1 strb r0, [r1, 0x6] @@ -4636,7 +4636,7 @@ _0808CD58: ldr r1, =gUnknown_02037590 movs r0, 0 strb r0, [r1, 0x6] - bl script_env_2_disable + bl ScriptContext2_Disable ldrh r0, [r5, 0x26] lsls r0, 24 lsrs r0, 24 @@ -4857,7 +4857,7 @@ fishF: @ 808CF2C bne _0808CF68 ldr r0, =gUnknown_02037590 strb r1, [r0, 0x6] - bl script_env_2_disable + bl ScriptContext2_Disable bl sub_809757C movs r0, 0 movs r1, 0x1 diff --git a/asm/field_poison.s b/asm/field_poison.s index 9312fa285..8948b2762 100644 --- a/asm/field_poison.s +++ b/asm/field_poison.s @@ -227,7 +227,7 @@ _080F9714: ldr r0, =gScriptResult strh r1, [r0] _080F9718: - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r6, 0 bl DestroyTask _080F9722: @@ -243,7 +243,7 @@ sub_80F972C: @ 80F972C ldr r0, =sub_80F9654 movs r1, 0x50 bl CreateTask - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop pop {r0} bx r0 .pool diff --git a/asm/field_tasks.s b/asm/field_tasks.s index fb99bbc0e..0abd11da4 100644 --- a/asm/field_tasks.s +++ b/asm/field_tasks.s @@ -80,7 +80,7 @@ sub_809D908: @ 809D908 lsls r1, 3 ldr r0, =gTasks + 0x8 adds r4, r1, r0 - bl script_env_2_is_enabled + bl ScriptContext2_IsEnabled lsls r0, 24 cmp r0, 0 bne _0809D930 diff --git a/asm/fldeff_80F9BCC.s b/asm/fldeff_80F9BCC.s index 7f8fdab68..dffc7c780 100644 --- a/asm/fldeff_80F9BCC.s +++ b/asm/fldeff_80F9BCC.s @@ -769,7 +769,7 @@ sub_80FA1D8: @ 80FA1D8 push {lr} movs r1, 0x37 bl FieldEffectStop - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_80FA1D8 @@ -942,7 +942,7 @@ sub_80FA33C: @ 80FA33C push {lr} movs r1, 0x38 bl FieldEffectStop - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_80FA33C @@ -1077,7 +1077,7 @@ sub_80FA448: @ 80FA448 push {lr} movs r1, 0x39 bl FieldEffectStop - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_80FA448 @@ -1195,7 +1195,7 @@ _080FA540: bl CurrentMapDrawMetatileAt movs r0, 0x3D bl FieldEffectActiveListRemove - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r5, 0 bl DestroyTask b _080FA574 @@ -1801,7 +1801,7 @@ _080FAA5E: sub_80FAA7C: @ 80FAA7C push {r4,lr} sub sp, 0x4 - bl script_env_2_enable + bl ScriptContext2_Enable mov r4, sp adds r4, 0x2 mov r0, sp @@ -2012,7 +2012,7 @@ sub_80FAC68: @ 80FAC68 push {lr} movs r1, 0x34 bl FieldEffectStop - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_80FAC68 @@ -2414,7 +2414,7 @@ sub_80FAFD4: @ 80FAFD4 bl SetPlayerAvatarTransitionFlags adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r4} pop {r0} bx r0 diff --git a/asm/fldeff_strength.s b/asm/fldeff_strength.s index 412eaff5d..3dc64467e 100644 --- a/asm/fldeff_strength.s +++ b/asm/fldeff_strength.s @@ -85,7 +85,7 @@ sub_8145E74: @ 8145E74 push {lr} movs r0, 0x28 bl FieldEffectActiveListRemove - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_8145E74 diff --git a/asm/item_use.s b/asm/item_use.s index 3f97bb2d1..733b24470 100644 --- a/asm/item_use.s +++ b/asm/item_use.s @@ -218,7 +218,7 @@ CleanUpAfterFailingToUseRegisteredKeyItemOnField: @ 80FD1F8 adds r0, r4, 0 bl DestroyTask bl sub_80984F4 - bl script_env_2_disable + bl ScriptContext2_Disable pop {r4} pop {r0} bx r0 @@ -396,7 +396,7 @@ _080FD378: bl GetOnOffBike _080FD37E: bl sub_80984F4 - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r4, 0 bl DestroyTask pop {r4} @@ -687,7 +687,7 @@ sub_80FD5CC: @ 80FD5CC movs r1, 0x1 bl sub_8197434 bl sub_80984F4 - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r4, 0 bl DestroyTask pop {r4} @@ -1665,7 +1665,7 @@ sub_80FDD74: @ 80FDD74 ldrh r0, [r0] movs r1, 0x1 bl RemoveBagItem - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =gUnknown_08274482 bl ScriptContext1_SetupScript adds r0, r4, 0 @@ -1727,7 +1727,7 @@ sub_80FDE08: @ 80FDE08 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =gUnknown_082744C0 bl ScriptContext1_SetupScript adds r0, r4, 0 @@ -1786,7 +1786,7 @@ sub_80FDE7C: @ 80FDE7C adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =gUnknown_08242CFC bl ScriptContext1_SetupScript adds r0, r4, 0 diff --git a/asm/lilycove_lady.s b/asm/lilycove_lady.s index f2d2f24e4..debcc3fbe 100644 --- a/asm/lilycove_lady.s +++ b/asm/lilycove_lady.s @@ -652,7 +652,7 @@ sub_818DEDC: @ 818DEDC thumb_func_start sub_818DEF4 sub_818DEF4: @ 818DEF4 push {lr} - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_818DEF4 @@ -1415,7 +1415,7 @@ sub_818E538: @ 818E538 thumb_func_start sub_818E564 sub_818E564: @ 818E564 push {lr} - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_818E564 diff --git a/asm/link.s b/asm/link.s index 1fd881b99..e052aec63 100644 --- a/asm/link.s +++ b/asm/link.s @@ -18888,7 +18888,7 @@ _08012ED0: strb r0, [r6, 0xC] b _08012F50 _08012EE6: - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r4, 0 bl DestroyTask ldr r1, =gScriptResult @@ -18897,7 +18897,7 @@ _08012EE6: b _08012F50 .pool _08012EFC: - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r4, 0 bl DestroyTask ldr r1, =gScriptResult @@ -21551,7 +21551,7 @@ _08014764: ldrb r0, [r0] cmp r0, 0x44 beq _0801477C - bl script_env_2_disable + bl ScriptContext2_Disable _0801477C: add sp, 0x4 pop {r4} @@ -21673,12 +21673,12 @@ _080148B8: adds r0, r4, 0 bl DestroyTask _080148C2: - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts movs r0, 0x1 strh r0, [r7] b _080149B2 _080148CC: - bl script_env_context_is_running + bl ScriptContext1_IsScriptSetUp lsls r0, 24 cmp r0, 0 bne _080149B2 @@ -21756,7 +21756,7 @@ _08014980: strh r0, [r7] b _080149B2 _08014986: - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r4, 0 bl DestroyTask b _080149B2 @@ -21771,7 +21771,7 @@ _0801499C: cmp r0, 0 bne _080149B2 bl sub_800E084 - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r4, 0 bl DestroyTask _080149B2: @@ -23529,7 +23529,7 @@ _08015A02: strh r1, [r4] bl _08016878 _08015A0A: - bl script_env_2_is_enabled + bl ScriptContext2_IsEnabled lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -26501,7 +26501,7 @@ sub_80173B0: @ 80173B0 thumb_func_start sub_80173D4 sub_80173D4: @ 80173D4 push {lr} - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_80173D4 @@ -28285,7 +28285,7 @@ sub_801818C: @ 801818C push {r4,lr} adds r4, r0, 0 bl sub_80173B0 - bl script_env_2_disable + bl ScriptContext2_Disable bl sub_8098524 ldr r1, =gUnknown_02022C2C movs r0, 0 @@ -28311,7 +28311,7 @@ _080181BC: thumb_func_start sub_80181CC sub_80181CC: @ 80181CC push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl sub_80983E8 pop {r0} bx r0 @@ -31424,7 +31424,7 @@ sub_8019B3C: @ 8019B3C b _08019B9E .pool _08019B84: - bl script_env_2_is_enabled + bl ScriptContext2_IsEnabled lsls r0, 24 cmp r0, 0 bne _08019B96 @@ -34149,7 +34149,7 @@ sub_801B1E8: @ 801B1E8 bl sub_801B330 bl sub_801B368 bl sub_801B9F8 - bl killram + bl ClearRamScript bl sub_809D4D8 bl sub_809D570 ldr r0, =gSaveBlock2Ptr @@ -48339,8 +48339,8 @@ _08022494: bl RemoveWindow adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running - bl script_env_2_disable + bl EnableBothScriptContexts + bl ScriptContext2_Disable mov r0, r9 b _080224BE _080224BA: @@ -48362,7 +48362,7 @@ _080224C0: thumb_func_start sub_80224D0 sub_80224D0: @ 80224D0 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =sub_8022250 movs r1, 0 bl CreateTask @@ -59368,7 +59368,7 @@ _08027BC8: bl RemoveWindow adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _08027BE2: add sp, 0x8 pop {r4-r7} @@ -72365,7 +72365,7 @@ _0802E4DC: bl RemoveWindow adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _0802E4F6: add sp, 0x8 pop {r4-r7} diff --git a/asm/mauville_old_man.s b/asm/mauville_old_man.s index a1a9342dd..05d15601c 100644 --- a/asm/mauville_old_man.s +++ b/asm/mauville_old_man.s @@ -339,7 +339,7 @@ sub_8120340: @ 8120340 ldr r0, =gSpecialVar_0x8004 ldrb r0, [r0] bl sub_81206C0 - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop pop {r0} bx r0 .pool @@ -1231,7 +1231,7 @@ _08120A7E: ldr r0, =gMPlay_SE2 movs r1, 0x2 bl m4aMPlayFadeOutTemporarily - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r6, 0 bl DestroyTask b _08120B50 @@ -2398,7 +2398,7 @@ _08121364: bl sub_80E2A78 adds r0, r6, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _08121376: pop {r4-r6} pop {r0} diff --git a/asm/mystery_event_script.s b/asm/mystery_event_script.s index af9b0a745..07c940f58 100644 --- a/asm/mystery_event_script.s +++ b/asm/mystery_event_script.s @@ -59,10 +59,10 @@ sub_8153820: @ 8153820 adds r5, r1, 0 ldr r1, =gUnknown_082DED2C ldr r2, =gUnknown_082DED2C + 0x44 - bl script_env_init + bl InitScriptContext adds r0, r4, 0 adds r1, r5, 0 - bl script_setup_bytecode_script + bl SetupBytecodeScript str r5, [r4, 0x64] movs r0, 0 str r0, [r4, 0x68] @@ -78,7 +78,7 @@ sub_8153820: @ 8153820 sub_8153850: @ 8153850 push {r4,lr} adds r4, r0, 0 - bl script_main_handler + bl RunScriptCommand lsls r0, 24 cmp r0, 0 beq _08153868 @@ -317,7 +317,7 @@ _08153A1A: thumb_func_start script_status_stop_and_ret_1 script_status_stop_and_ret_1: @ 8153A24 push {lr} - bl script_stop + bl StopScript movs r0, 0x1 pop {r1} bx r1 @@ -327,23 +327,23 @@ script_status_stop_and_ret_1: @ 8153A24 sub_8153A30: @ 8153A30 push {r4-r7,lr} adds r7, r0, 0 - bl script_read_word + bl ScriptReadWord str r0, [r7, 0x68] adds r0, r7, 0 - bl script_read_halfword + bl ScriptReadHalfword adds r5, r0, 0 lsls r5, 16 lsrs r5, 16 adds r0, r7, 0 - bl script_read_word + bl ScriptReadWord adds r6, r0, 0 adds r0, r7, 0 - bl script_read_halfword + bl ScriptReadHalfword adds r4, r0, 0 lsls r4, 16 lsrs r4, 16 adds r0, r7, 0 - bl script_read_word + bl ScriptReadWord adds r3, r0, 0 adds r0, r5, 0 adds r1, r6, 0 @@ -388,7 +388,7 @@ sub_8153A94: @ 8153A94 adds r0, 0x1 str r0, [r4, 0x8] adds r0, r4, 0 - bl script_read_word + bl ScriptReadWord ldr r1, [r4, 0x68] subs r0, r1 ldr r1, [r4, 0x64] @@ -413,7 +413,7 @@ _08153ABE: sub_8153ACC: @ 8153ACC push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord ldr r1, [r4, 0x68] subs r0, r1 ldr r1, [r4, 0x64] @@ -435,7 +435,7 @@ sub_8153AE8: @ 8153AE8 bl sub_80E162C mov r8, r0 adds r0, r7, 0 - bl script_read_word + bl ScriptReadWord adds r4, r0, 0 ldr r0, [r7, 0x68] subs r4, r0 @@ -547,14 +547,14 @@ sub_8153BE4: @ 8153BE4 adds r1, 0x1 str r1, [r4, 0x8] adds r0, r4, 0 - bl script_read_word + bl ScriptReadWord adds r5, r0, 0 ldr r0, [r4, 0x68] subs r5, r0 ldr r0, [r4, 0x64] adds r5, r0 adds r0, r4, 0 - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 ldr r0, [r4, 0x68] subs r1, r0 @@ -567,7 +567,7 @@ sub_8153BE4: @ 8153BE4 adds r0, r5, 0 mov r2, r9 mov r3, r8 - bl sub_80990FC + bl InitRamScript movs r0, 0 add sp, 0x4 pop {r3,r4} @@ -626,7 +626,7 @@ sub_8153C9C: @ 8153C9C ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword adds r2, r0, 0 lsls r2, 16 lsrs r2, 16 @@ -646,7 +646,7 @@ sub_8153CC8: @ 8153CC8 push {r7} sub sp, 0x88 adds r6, r0, 0 - bl script_read_word + bl ScriptReadWord ldr r1, [r6, 0x68] subs r0, r1 ldr r1, [r6, 0x64] @@ -751,7 +751,7 @@ _08153DB6: sub_8153DD4: @ 8153DD4 push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 ldr r0, [r4, 0x68] subs r1, r0 @@ -797,17 +797,17 @@ sub_8153E1C: @ 8153E1C sub_8153E40: @ 8153E40 push {r4-r6,lr} adds r6, r0, 0 - bl script_read_word + bl ScriptReadWord adds r5, r0, 0 adds r0, r6, 0 - bl script_read_word + bl ScriptReadWord adds r4, r0, 0 ldr r0, [r6, 0x68] subs r4, r0 ldr r0, [r6, 0x64] adds r4, r0 adds r0, r6, 0 - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 ldr r0, [r6, 0x68] subs r1, r0 @@ -833,17 +833,17 @@ _08153E7E: sub_8153E88: @ 8153E88 push {r4-r6,lr} adds r6, r0, 0 - bl script_read_word + bl ScriptReadWord adds r5, r0, 0 adds r0, r6, 0 - bl script_read_word + bl ScriptReadWord adds r4, r0, 0 ldr r0, [r6, 0x68] subs r4, r0 ldr r0, [r6, 0x64] adds r4, r0 adds r0, r6, 0 - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 ldr r0, [r6, 0x68] subs r1, r0 diff --git a/asm/player_pc.s b/asm/player_pc.s index 1f5e0c332..92b8d46c9 100644 --- a/asm/player_pc.s +++ b/asm/player_pc.s @@ -389,7 +389,7 @@ _0816B174: b _0816B184 .pool _0816B180: - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _0816B184: adds r0, r4, 0 bl DestroyTask diff --git a/asm/porthole.s b/asm/porthole.s index 2ba6ec83a..0efe88773 100644 --- a/asm/porthole.s +++ b/asm/porthole.s @@ -246,7 +246,7 @@ sub_80FB768: @ 80FB768 ldr r0, =sub_80FB5E8 movs r1, 0x50 bl CreateTask - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 .pool diff --git a/asm/record_mixing.s b/asm/record_mixing.s index 0ff65e485..a28af9a9a 100644 --- a/asm/record_mixing.s +++ b/asm/record_mixing.s @@ -677,7 +677,7 @@ _080E72F8: bl sub_8197434 adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _080E730A: pop {r4,r5} pop {r0} diff --git a/asm/rom4.s b/asm/rom4.s index 8fb7ca8ad..9acdbec0a 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -3015,7 +3015,7 @@ c1_overworld_normal: @ 8085DAC adds r1, r5, 0 adds r2, r4, 0 bl process_overworld_input - bl script_env_2_is_enabled + bl ScriptContext2_IsEnabled lsls r0, 24 cmp r0, 0 bne _08085DFA @@ -3023,7 +3023,7 @@ c1_overworld_normal: @ 8085DAC bl sub_809C014 cmp r0, 0x1 bne _08085DF0 - bl script_env_2_enable + bl ScriptContext2_Enable bl HideMapNamePopUpWindow b _08085DFA _08085DF0: @@ -3059,7 +3059,7 @@ _08085E18: @ void c2_overworld_basic() c2_overworld_basic: @ 8085E24 push {lr} - bl script_env_2_run_current_script + bl ScriptContext2_RunScript bl RunTasks bl AnimateSprites bl CameraUpdate @@ -3172,8 +3172,8 @@ CB2_NewGame: @ 8085EF8 bl NewGameInitData bl player_avatar_init_params_reset bl PlayTimeCounter_Start - bl script_env_1_init - bl script_env_2_disable + bl ScriptContext1_Init + bl ScriptContext2_Disable ldr r1, =gUnknown_03005DAC ldr r0, =sub_80FB4E0 str r0, [r1] @@ -3212,8 +3212,8 @@ c2_whiteout: @ 8085F58 bl ResetSafariZoneFlag_ bl sub_8084620 bl player_avatar_init_params_reset - bl script_env_1_init - bl script_env_2_disable + bl ScriptContext1_Init + bl ScriptContext2_Disable ldr r1, =gUnknown_03005DAC ldr r0, =sub_80AF3C8 str r0, [r1] @@ -3238,8 +3238,8 @@ _08085FB0: c2_load_new_map: @ 8085FCC push {lr} bl sub_808631C - bl script_env_1_init - bl script_env_2_disable + bl ScriptContext1_Init + bl ScriptContext2_Disable movs r0, 0 bl set_callback1 ldr r0, =c2_change_map @@ -3278,8 +3278,8 @@ sub_8086024: @ 8086024 cmp r0, 0 bne _08086046 bl sub_808631C - bl script_env_1_init - bl script_env_2_disable + bl ScriptContext1_Init + bl ScriptContext2_Disable movs r0, 0 bl set_callback1 _08086046: @@ -3408,8 +3408,8 @@ _08086174: ldr r0, =sub_80AF214 _08086178: str r0, [r1] - bl script_env_1_init - bl script_env_2_disable + bl ScriptContext1_Init + bl ScriptContext2_Disable bl c2_exit_to_overworld_2_switch pop {r0} bx r0 @@ -3546,8 +3546,8 @@ _080862BA: bl sub_8087D74 _080862BE: bl PlayTimeCounter_Start - bl script_env_1_init - bl script_env_2_disable + bl ScriptContext1_Init + bl ScriptContext2_Disable bl sub_8195E10 bl sav2_x1_query_bit1 cmp r0, 0x1 @@ -3711,8 +3711,8 @@ _08086414: .4byte _0808650E _0808644C: bl overworld_bg_setup - bl script_env_1_init - bl script_env_2_disable + bl ScriptContext1_Init + bl ScriptContext2_Disable bl MoveSaveBlocks_ResetHeap_ bl sub_80867D8 b _08086506 @@ -5170,7 +5170,7 @@ _080870A2: sub_80870B0: @ 80870B0 push {r4,lr} adds r4, r0, 0 - bl script_env_2_is_enabled + bl ScriptContext2_IsEnabled lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -5212,7 +5212,7 @@ sub_80870EC: @ 80870EC thumb_func_start sub_80870F8 sub_80870F8: @ 80870F8 push {r4,lr} - bl script_env_2_is_enabled + bl ScriptContext2_IsEnabled lsls r0, 24 lsrs r0, 24 movs r4, 0x11 @@ -5237,7 +5237,7 @@ sub_808711C: @ 808711C cmp r0, 0x2 bhi _08087134 movs r4, 0x1A - bl script_env_2_disable + bl ScriptContext2_Disable ldr r0, =sub_80870EC bl c1_link_related_func_set _08087134: @@ -5256,7 +5256,7 @@ sub_8087140: @ 8087140 cmp r0, 0x2 bhi _08087158 movs r4, 0x1A - bl script_env_2_disable + bl ScriptContext2_Disable ldr r0, =sub_80870EC bl c1_link_related_func_set _08087158: @@ -5751,7 +5751,7 @@ _0808750A: thumb_func_start sub_8087510 sub_8087510: @ 8087510 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 thumb_func_end sub_8087510 @@ -5762,7 +5762,7 @@ sub_808751C: @ 808751C movs r0, 0x6 bl PlaySE bl sub_809FA9C - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 thumb_func_end sub_808751C @@ -5775,7 +5775,7 @@ sub_8087530: @ 8087530 bl PlaySE adds r0, r4, 0 bl ScriptContext1_SetupScript - bl script_env_2_enable + bl ScriptContext2_Enable pop {r4} pop {r0} bx r0 @@ -5788,7 +5788,7 @@ sub_808754C: @ 808754C bl PlaySE ldr r0, =gUnknown_082774EF bl ScriptContext1_SetupScript - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 .pool @@ -5802,7 +5802,7 @@ sub_8087568: @ 8087568 bl PlaySE adds r0, r4, 0 bl ScriptContext1_SetupScript - bl script_env_2_enable + bl ScriptContext2_Enable pop {r4} pop {r0} bx r0 @@ -5813,7 +5813,7 @@ sub_8087584: @ 8087584 push {lr} ldr r0, =gUnknown_08277509 bl ScriptContext1_SetupScript - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 .pool diff --git a/asm/rom6.s b/asm/rom6.s index 5f604448d..65b3d9b94 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -67,7 +67,7 @@ task08_080C9820: @ 813549C lsls r0, 24 lsrs r5, r0, 24 adds r6, r5, 0 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r1, =gUnknown_02037590 movs r0, 0x1 strb r0, [r1, 0x6] @@ -344,7 +344,7 @@ sub_8135714: @ 8135714 bl PlaySE movs r0, 0x25 bl FieldEffectActiveListRemove - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_8135714 @@ -4353,7 +4353,7 @@ sub_81379D8: @ 81379D8 lsls r0, 24 cmp r0, 0 beq _081379F2 - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r4, 0 bl DestroyTask _081379F2: @@ -4640,7 +4640,7 @@ sub_8137C28: @ 8137C28 push {lr} ldr r0, =sub_8174194 bl SetMainCallback2 - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 .pool @@ -4663,7 +4663,7 @@ sub_8137C3C: @ 8137C3C mapldr_080CA5C0: @ 8137C5C push {lr} sub sp, 0x4 - bl script_env_2_enable + bl ScriptContext2_Enable bl sub_8085784 bl sp109_CreatePCMenu bl sub_80E2514 @@ -4707,7 +4707,7 @@ sub_8137CB4: @ 8137CB4 push {lr} ldr r0, =sub_8177888 bl SetMainCallback2 - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 .pool @@ -4721,7 +4721,7 @@ Special_ViewWallClock: @ 8137CC8 str r1, [r0, 0x8] ldr r0, =Cb2_ViewWallClock bl SetMainCallback2 - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 .pool @@ -6192,7 +6192,7 @@ sub_8138910: @ 8138910 bne _08138970 adds r0, r6, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts b _08138970 .pool _0813896C: @@ -7829,7 +7829,7 @@ sub_8139620: @ 8139620 lsls r0, 24 lsrs r0, 24 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_8139620 @@ -8488,7 +8488,7 @@ sub_8139AF4: @ 8139AF4 bl PlaySE adds r0, r5, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts bl InstallCameraPanAheadCallback _08139B54: pop {r4,r5} @@ -9406,7 +9406,7 @@ sub_813A2DC: @ 813A2DC lsls r0, 3 ldr r1, =gTasks adds r6, r0, r1 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =gUnknown_0203AB68 movs r5, 0 strh r5, [r0] @@ -9680,7 +9680,7 @@ _0813A558: bl sub_813A738 ldr r0, =sub_813A600 str r0, [r6] - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _0813A566: pop {r4-r6} pop {r0} @@ -9741,7 +9741,7 @@ sub_813A570: @ 813A570 bl RemoveWindow adds r0, r5, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts add sp, 0x4 pop {r4,r5} pop {r0} @@ -9784,7 +9784,7 @@ sub_813A630: @ 813A630 lsrs r2, r0, 24 cmp r2, 0xFF bne _0813A64C - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts b _0813A65C .pool _0813A64C: @@ -9808,7 +9808,7 @@ sub_813A664: @ 813A664 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl script_env_2_enable + bl ScriptContext2_Enable adds r0, r4, 0 bl sub_813A694 ldr r1, =gTasks @@ -10975,7 +10975,7 @@ _0813B05C: movs r0, 0x2 _0813B06A: strh r0, [r1] - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _0813B070: adds r0, r7, 0 bl DestroyTask @@ -11092,7 +11092,7 @@ sub_813B160: @ 813B160 lsls r0, 24 cmp r0, 0 bne _0813B17C - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r4, 0 bl DestroyTask _0813B17C: @@ -11833,7 +11833,7 @@ _0813B7B4: ldr r1, =gUnknown_0203AB70 ldr r1, [r1] str r1, [r0] - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r4, 0 bl DestroyTask _0813B7C6: @@ -12026,7 +12026,7 @@ _0813B8F4: bne _0813B94E mov r0, r9 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _0813B94E: pop {r3-r5} mov r8, r3 diff --git a/asm/rom_80AEFFC.s b/asm/rom_80AEFFC.s index 8d28c089d..566947ba3 100644 --- a/asm/rom_80AEFFC.s +++ b/asm/rom_80AEFFC.s @@ -163,7 +163,7 @@ _080AF120: thumb_func_start sub_80AF128 sub_80AF128: @ 80AF128 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl sub_8085784 bl pal_fill_black ldr r0, =task0A_nop_for_a_while @@ -184,7 +184,7 @@ task0A_asap_script_env_2_enable_and_set_ctx_running: @ 80AF148 bne _080AF160 adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _080AF160: pop {r4} pop {r0} @@ -194,7 +194,7 @@ _080AF160: thumb_func_start sub_80AF168 sub_80AF168: @ 80AF168 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl sub_8085784 bl pal_fill_black ldr r0, =task0A_asap_script_env_2_enable_and_set_ctx_running @@ -208,7 +208,7 @@ sub_80AF168: @ 80AF168 thumb_func_start sub_80AF188 sub_80AF188: @ 80AF188 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl pal_fill_black ldr r0, =task0A_asap_script_env_2_enable_and_set_ctx_running movs r1, 0xA @@ -268,7 +268,7 @@ _080AF1FC: bl sub_80AF71C cmp r0, 0x1 bne _080AF20E - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r5, 0 bl DestroyTask _080AF20E: @@ -280,7 +280,7 @@ _080AF20E: thumb_func_start sub_80AF214 sub_80AF214: @ 80AF214 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl sub_8085784 bl palette_bg_faded_fill_black ldr r0, =task_mpl_807DD60 @@ -347,7 +347,7 @@ _080AF298: cmp r0, 0x1 bne _080AF2AE bl sub_8009F18 - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r5, 0 bl DestroyTask _080AF2AE: @@ -396,7 +396,7 @@ _080AF2F2: _080AF2FA: bl sub_8009F18 bl sub_8086C2C - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r5, 0 bl DestroyTask _080AF30C: @@ -408,7 +408,7 @@ _080AF30C: thumb_func_start sub_80AF314 sub_80AF314: @ 80AF314 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl sub_8085784 bl palette_bg_faded_fill_black ldr r0, =sub_80AF234 @@ -471,7 +471,7 @@ mapldr_default: @ 80AF398 bl sub_8085784 bl pal_fill_for_maplights bl sub_80AF334 - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 thumb_func_end mapldr_default @@ -482,7 +482,7 @@ sub_80AF3B0: @ 80AF3B0 bl sub_8085784 bl sub_80AF08C bl sub_80AF334 - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 thumb_func_end sub_80AF3B0 @@ -497,7 +497,7 @@ sub_80AF3C8: @ 80AF3C8 _080AF3D6: bl pal_fill_black bl sub_80AF334 - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 thumb_func_end sub_80AF3C8 @@ -512,7 +512,7 @@ sub_80AF3E8: @ 80AF3E8 ldr r0, =task0A_mpl_807E31C movs r1, 0xA bl CreateTask - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 .pool @@ -528,7 +528,7 @@ sub_80AF40C: @ 80AF40C ldr r0, =task_map_chg_seq_0807E2CC movs r1, 0xA bl CreateTask - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0xE bl sub_8085540 pop {r0} @@ -655,7 +655,7 @@ _080AF536: strh r0, [r5, 0x8] b _080AF54A _080AF540: - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r4, 0 bl DestroyTask _080AF54A: @@ -744,7 +744,7 @@ _080AF5EC: strh r0, [r5, 0x8] b _080AF60A _080AF600: - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r4, 0 bl DestroyTask _080AF60A: @@ -773,7 +773,7 @@ task_map_chg_seq_0807E2CC: @ 80AF610 .pool _080AF634: bl player_bitmagic - bl script_env_2_enable + bl ScriptContext2_Enable ldrh r0, [r4, 0x8] adds r0, 0x1 strh r0, [r4, 0x8] @@ -783,7 +783,7 @@ _080AF644: cmp r0, 0 beq _080AF65A bl sub_809757C - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r5, 0 bl DestroyTask _080AF65A: @@ -819,7 +819,7 @@ sub_80AF688: @ 80AF688 ldr r0, =sub_80AF660 movs r1, 0x50 bl CreateTask - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 .pool @@ -842,7 +842,7 @@ task_mpl_807E3C8: @ 80AF6B0 bl sub_80AF71C cmp r0, 0x1 bne _080AF6CC - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r4, 0 bl DestroyTask bl sub_80984F4 @@ -855,7 +855,7 @@ _080AF6CC: thumb_func_start sub_80AF6D4 sub_80AF6D4: @ 80AF6D4 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl pal_fill_black ldr r0, =task_mpl_807E3C8 movs r1, 0xA @@ -868,7 +868,7 @@ sub_80AF6D4: @ 80AF6D4 thumb_func_start sub_80AF6F0 sub_80AF6F0: @ 80AF6F0 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl sub_8085784 bl pal_fill_black ldr r0, =task_mpl_807E3C8 @@ -908,7 +908,7 @@ _080AF730: thumb_func_start sub_80AF734 sub_80AF734: @ 80AF734 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl music_something bl sub_80AF0B4 bl play_some_sound @@ -928,7 +928,7 @@ sub_80AF734: @ 80AF734 thumb_func_start sp13E_warp_to_last_warp sp13E_warp_to_last_warp: @ 80AF76C push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl music_something bl sub_80AF0B4 bl play_some_sound @@ -946,7 +946,7 @@ sp13E_warp_to_last_warp: @ 80AF76C thumb_func_start sub_80AF79C sub_80AF79C: @ 80AF79C push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl music_something movs r0, 0x3 movs r1, 0x8 @@ -966,7 +966,7 @@ sub_80AF79C: @ 80AF79C thumb_func_start sub_80AF7D0 sub_80AF7D0: @ 80AF7D0 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =gUnknown_03005DAC ldr r1, =mapldr_default str r1, [r0] @@ -996,7 +996,7 @@ sub_80AF80C: @ 80AF80C adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl script_env_2_enable + bl ScriptContext2_Enable adds r0, r4, 0 movs r1, 0xA bl sub_80B6E4C @@ -1008,7 +1008,7 @@ sub_80AF80C: @ 80AF80C thumb_func_start sub_80AF828 sub_80AF828: @ 80AF828 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0xA bl sub_80B75D8 pop {r0} @@ -1018,7 +1018,7 @@ sub_80AF828: @ 80AF828 thumb_func_start sub_80AF838 sub_80AF838: @ 80AF838 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0xA bl sub_80B7A74 pop {r0} @@ -1028,7 +1028,7 @@ sub_80AF838: @ 80AF838 thumb_func_start sub_80AF848 sub_80AF848: @ 80AF848 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl music_something bl sub_80AF0B4 movs r0, 0x2D @@ -1049,7 +1049,7 @@ sub_80AF87C: @ 80AF87C push {lr} movs r0, 0x1 bl sub_8085540 - bl script_env_2_enable + bl ScriptContext2_Enable bl save_serialize_npcs bl music_something bl sub_80AF0B4 @@ -1069,7 +1069,7 @@ sub_80AF87C: @ 80AF87C thumb_func_start sub_80AF8B8 sub_80AF8B8: @ 80AF8B8 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl sub_80AF0B4 ldr r0, =sub_80AFA0C movs r1, 0xA @@ -1107,7 +1107,7 @@ _080AF908: beq _080AF92E b _080AF93E _080AF90E: - bl script_env_2_enable + bl ScriptContext2_Enable b _080AF926 _080AF914: bl sub_80AF710 @@ -1138,7 +1138,7 @@ _080AF93E: thumb_func_start sub_80AF948 sub_80AF948: @ 80AF948 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl music_something bl sub_80AF0B4 movs r0, 0x9 @@ -1252,7 +1252,7 @@ _080AFA34: b _080AFA7C _080AFA3A: bl player_bitmagic - bl script_env_2_enable + bl ScriptContext2_Enable b _080AFA64 _080AFA44: bl sub_80AF710 @@ -1480,7 +1480,7 @@ _080AFC1C: b _080AFC56 _080AFC22: bl player_bitmagic - bl script_env_2_enable + bl ScriptContext2_Enable b _080AFC3E _080AFC2C: bl sub_80AF710 @@ -1511,7 +1511,7 @@ _080AFC56: thumb_func_start sub_80AFC60 sub_80AFC60: @ 80AFC60 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl music_something bl sub_80AF0B4 bl play_some_sound @@ -1932,7 +1932,7 @@ sub_80AFF90: @ 80AFF90 lsls r0, 24 cmp r0, 0 bne _080AFFAC - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r4, 0 bl DestroyTask _080AFFAC: @@ -2088,7 +2088,7 @@ _080B00B6: movs r1, 0x50 bl sub_80AFFDC bl sub_80AFFB8 - bl script_env_2_enable + bl ScriptContext2_Enable add sp, 0x8 pop {r4,r5} pop {r0} @@ -2172,7 +2172,7 @@ task0A_mpl_807E31C: @ 80B0160 .pool _080B0184: bl player_bitmagic - bl script_env_2_enable + bl ScriptContext2_Enable bl sub_808D194 ldrh r0, [r4, 0x8] adds r0, 0x1 @@ -2186,7 +2186,7 @@ _080B0198: cmp r0, 0x1 beq _080B01B6 bl sub_809757C - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r5, 0 bl DestroyTask _080B01B6: @@ -2223,7 +2223,7 @@ _080B01E4: b _080B023A _080B01EE: bl player_bitmagic - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0x2D bl PlaySE bl sub_808D1C8 @@ -2263,7 +2263,7 @@ _080B023A: thumb_func_start sub_80B0244 sub_80B0244: @ 80B0244 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =sub_80AFA0C movs r1, 0xA bl CreateTask @@ -2278,7 +2278,7 @@ sub_80B0244: @ 80B0244 thumb_func_start sub_80B0268 sub_80B0268: @ 80B0268 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =gUnknown_03005DAC ldr r1, =mapldr_default str r1, [r0] @@ -2500,7 +2500,7 @@ _080B0450: lsls r0, 24 cmp r0, 0 bne _080B052C - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts movs r0, 0x3 strh r0, [r5] b _080B052C @@ -2590,7 +2590,7 @@ _080B04F2: ldrh r1, [r5, 0x14] movs r0, 0x4A bl SetGpuReg - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r4, 0 bl DestroyTask _080B052C: @@ -2688,7 +2688,7 @@ task50_0807F0C8: @ 80B05CC bne _080B05E8 adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _080B05E8: pop {r4} pop {r0} diff --git a/asm/rom_80C6FA0.s b/asm/rom_80C6FA0.s index c58388b92..570116cd3 100644 --- a/asm/rom_80C6FA0.s +++ b/asm/rom_80C6FA0.s @@ -564,8 +564,8 @@ _080C73D0: lsrs r0, 24 movs r1, 0x1 bl sub_819746C - bl script_env_2_disable - bl script_env_2_enable_and_set_ctx_running + bl ScriptContext2_Disable + bl EnableBothScriptContexts ldrh r0, [r5, 0x26] lsls r0, 24 lsrs r0, 24 @@ -769,7 +769,7 @@ sub_80C7578: @ 80C7578 movs r0, 0 strh r0, [r1, 0x8] strh r0, [r1, 0xA] - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 .pool @@ -25376,7 +25376,7 @@ _080D41D4: movs r0, 0 str r0, [r6] bl sub_80984F4 - bl script_env_2_disable + bl ScriptContext2_Disable bl unown_chamber_related lsls r0, 24 lsrs r0, 24 @@ -25537,7 +25537,7 @@ sub_80D4354: @ 80D4354 bl PlaySE movs r0, 0x2 bl FieldEffectActiveListRemove - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_80D4354 diff --git a/asm/rom_815A0D4.s b/asm/rom_815A0D4.s index e6441f17b..bd09771b0 100644 --- a/asm/rom_815A0D4.s +++ b/asm/rom_815A0D4.s @@ -12499,7 +12499,7 @@ sub_8160624: @ 8160624 sub_8160638: @ 8160638 push {lr} sub sp, 0x4 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =sub_8160664 movs r1, 0xA bl CreateTask diff --git a/asm/rom_818E9AC.s b/asm/rom_818E9AC.s index 89694f630..3fac8c672 100644 --- a/asm/rom_818E9AC.s +++ b/asm/rom_818E9AC.s @@ -13886,7 +13886,7 @@ task_prev_quest: @ 81960A8 ldrb r0, [r0, 0x7] cmp r0, 0 bne _081960C2 - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic bl sub_808B864 bl sub_808BCF4 @@ -14297,7 +14297,7 @@ sub_81963F0: @ 81963F0 bl FieldObjectClearAnimIfSpecialAnimFinished bl sub_80D338C bl sub_809757C - bl script_env_2_disable + bl ScriptContext2_Disable _08196446: movs r0, 0x1 b _08196456 @@ -32722,7 +32722,7 @@ _0819F9DC: thumb_func_start sub_819FA50 sub_819FA50: @ 819FA50 push {lr} - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_819FA50 @@ -34416,7 +34416,7 @@ _081A0768: bl sub_81A07E8 adds r0, r5, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _081A0778: pop {r4,r5} pop {r0} @@ -34801,12 +34801,12 @@ sub_81A0A34: @ 81A0A34 ldrh r0, [r0] cmp r0, 0 beq _081A0A64 - ldr r0, =script_env_2_enable_and_set_ctx_running + ldr r0, =EnableBothScriptContexts bl sub_81A172C b _081A0A68 .pool _081A0A64: - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _081A0A68: pop {r4} pop {r0} @@ -35033,7 +35033,7 @@ _081A0C66: b _081A0C7A .pool _081A0C74: - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts b _081A0C8E _081A0C7A: ldr r0, =gStringVar4 @@ -35052,7 +35052,7 @@ _081A0C8E: thumb_func_start sub_81A0C9C sub_81A0C9C: @ 81A0C9C push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic bl sub_808B864 bl sub_808BCF4 @@ -48555,7 +48555,7 @@ _081A7F1C: lsls r0, 24 cmp r0, 0 beq _081A7F30 - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r4, 0 bl DestroyTask _081A7F30: @@ -58748,7 +58748,7 @@ _081AD550: lsrs r6, r0, 24 cmp r6, 0x1 bne _081AD5C4 - bl script_env_2_enable + bl ScriptContext2_Enable bl player_bitmagic bl sub_808B864 bl sub_808BCF4 @@ -81419,8 +81419,8 @@ task_hm_without_phase_2: @ 81B93E0 beq _081B93FE adds r0, r4, 0 bl DestroyTask - bl script_env_2_disable - bl script_env_2_enable_and_set_ctx_running + bl ScriptContext2_Disable + bl EnableBothScriptContexts _081B93FE: pop {r4} pop {r0} @@ -81430,7 +81430,7 @@ _081B93FE: thumb_func_start sub_81B9404 sub_81B9404: @ 81B9404 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0x1 movs r1, 0 bl fade_screen @@ -81506,7 +81506,7 @@ _081B9486: thumb_func_start sub_81B94B0 sub_81B94B0: @ 81B94B0 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0x1 movs r1, 0 bl fade_screen @@ -81556,7 +81556,7 @@ _081B9508: thumb_func_start sub_81B951C sub_81B951C: @ 81B951C push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0x1 movs r1, 0 bl fade_screen @@ -81677,7 +81677,7 @@ _081B9614: thumb_func_start sub_81B9620 sub_81B9620: @ 81B9620 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0x1 movs r1, 0 bl fade_screen diff --git a/asm/rom_81BE66C.s b/asm/rom_81BE66C.s index d7a5aac86..119556f70 100644 --- a/asm/rom_81BE66C.s +++ b/asm/rom_81BE66C.s @@ -266,7 +266,7 @@ sub_81BE808: @ 81BE808 blt _081BE882 adds r0, r5, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _081BE882: add sp, 0x4 pop {r4,r5} @@ -459,7 +459,7 @@ sub_81BEA00: @ 81BEA00 bl FreeSpriteTilesByTag adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r4} pop {r0} bx r0 @@ -839,7 +839,7 @@ _081BED1C: bl CreateTask adds r0, r5, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _081BED40: add sp, 0xC pop {r4,r5} @@ -1159,7 +1159,7 @@ _081BEFF0: _081BEFF8: mov r0, r10 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _081BF002: ldr r0, =gTasks mov r2, r10 @@ -1404,7 +1404,7 @@ _081BF1CC: b _081BF228 .pool _081BF224: - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _081BF228: ldr r0, =gTasks lsls r1, r7, 2 @@ -12035,7 +12035,7 @@ sub_81C4F10: @ 81C4F10 thumb_func_start sub_81C4F24 sub_81C4F24: @ 81C4F24 push {lr} - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0x1 movs r1, 0 bl fade_screen diff --git a/asm/roulette.s b/asm/roulette.s index c39b82ab0..5742e089f 100644 --- a/asm/roulette.s +++ b/asm/roulette.s @@ -4590,7 +4590,7 @@ sub_814297C: @ 814297C movs r1, 0 bl sub_819746C bl HideCoinsWindow - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r4, 0 bl DestroyTask pop {r4} @@ -4624,7 +4624,7 @@ sub_81429A0: @ 81429A0 movs r0, 0 movs r1, 0x1 bl sub_819746C - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r4, 0 bl DestroyTask _081429DE: @@ -4829,7 +4829,7 @@ _08142BB0: thumb_func_start sub_8142BC8 sub_8142BC8: @ 8142BC8 push {r4,lr} - bl script_env_2_enable + bl ScriptContext2_Enable bl GetCoins lsls r0, 16 lsrs r0, 16 diff --git a/asm/scrcmd.s b/asm/scrcmd.s index 26c6f6824..2cef4b0b0 100644 --- a/asm/scrcmd.s +++ b/asm/scrcmd.s @@ -20,7 +20,7 @@ s01_nop: @ 80992D0 thumb_func_start s02_end s02_end: @ 80992D4 push {lr} - bl script_stop + bl StopScript movs r0, 0 pop {r1} bx r1 @@ -30,10 +30,10 @@ s02_end: @ 80992D4 s24_execute_ASM_2: @ 80992E0 push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r4} pop {r1} @@ -43,7 +43,7 @@ s24_execute_ASM_2: @ 80992E0 thumb_func_start s25_extended_cmd s25_extended_cmd: @ 80992F8 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 ldr r1, =gUnknown_081DBA64 lsrs r0, 14 @@ -60,14 +60,14 @@ s25_extended_cmd: @ 80992F8 s26_extended_cmd_setvar: @ 8099318 push {r4-r6,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer adds r6, r0, 0 ldr r4, =gUnknown_081DBA64 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 14 adds r0, r4 @@ -84,7 +84,7 @@ s26_extended_cmd_setvar: @ 8099318 thumb_func_start s23_execute_ASM s23_execute_ASM: @ 809934C push {lr} - bl script_read_word + bl ScriptReadWord bl _call_via_r0 movs r0, 0 pop {r1} @@ -94,7 +94,7 @@ s23_execute_ASM: @ 809934C thumb_func_start s27_set_to_waitstate s27_set_to_waitstate: @ 809935C push {lr} - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 pop {r1} bx r1 @@ -104,10 +104,10 @@ s27_set_to_waitstate: @ 809935C s05_goto: @ 8099368 push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 adds r0, r4, 0 - bl script_jump + bl ScriptJump movs r0, 0 pop {r4} pop {r1} @@ -117,7 +117,7 @@ s05_goto: @ 8099368 thumb_func_start s03_return s03_return: @ 8099380 push {lr} - bl script_return + bl ScriptReturn movs r0, 0 pop {r1} bx r1 @@ -127,10 +127,10 @@ s03_return: @ 8099380 s04_call: @ 809938C push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 adds r0, r4, 0 - bl script_call + bl ScriptCall movs r0, 0 pop {r4} pop {r1} @@ -147,7 +147,7 @@ s06_if_jump: @ 80993A4 adds r0, 0x1 str r0, [r5, 0x8] adds r0, r5, 0 - bl script_read_word + bl ScriptReadWord adds r2, r0, 0 ldr r1, =gUnknown_085102C0 lsls r0, r4, 1 @@ -160,7 +160,7 @@ s06_if_jump: @ 80993A4 bne _080993D2 adds r0, r5, 0 adds r1, r2, 0 - bl script_jump + bl ScriptJump _080993D2: movs r0, 0 pop {r4,r5} @@ -178,7 +178,7 @@ s07_if_call: @ 80993E0 adds r0, 0x1 str r0, [r5, 0x8] adds r0, r5, 0 - bl script_read_word + bl ScriptReadWord adds r2, r0, 0 ldr r1, =gUnknown_085102C0 lsls r0, r4, 1 @@ -191,7 +191,7 @@ s07_if_call: @ 80993E0 bne _0809940E adds r0, r5, 0 adds r1, r2, 0 - bl script_call + bl ScriptCall _0809940E: movs r0, 0 pop {r4,r5} @@ -206,7 +206,7 @@ sB8_set_virtual_address: @ 809941C push {r4,lr} ldr r4, [r0, 0x8] subs r4, 0x1 - bl script_read_word + bl ScriptReadWord ldr r1, =gUnknown_020375C4 subs r0, r4 str r0, [r1] @@ -222,13 +222,13 @@ sB8_set_virtual_address: @ 809941C sB9_virtual_jump: @ 8099438 push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 ldr r0, =gUnknown_020375C4 ldr r0, [r0] subs r1, r0 adds r0, r4, 0 - bl script_jump + bl ScriptJump movs r0, 0 pop {r4} pop {r1} @@ -240,13 +240,13 @@ sB9_virtual_jump: @ 8099438 sBA_virtual_call: @ 809945C push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 ldr r0, =gUnknown_020375C4 ldr r0, [r0] subs r1, r0 adds r0, r4, 0 - bl script_call + bl ScriptCall movs r0, 0 pop {r4} pop {r1} @@ -263,7 +263,7 @@ sBB_virtual_if_jump: @ 8099480 adds r0, 0x1 str r0, [r5, 0x8] adds r0, r5, 0 - bl script_read_word + bl ScriptReadWord ldr r1, =gUnknown_020375C4 ldr r1, [r1] subs r2, r0, r1 @@ -278,7 +278,7 @@ sBB_virtual_if_jump: @ 8099480 bne _080994B2 adds r0, r5, 0 adds r1, r2, 0 - bl script_jump + bl ScriptJump _080994B2: movs r0, 0 pop {r4,r5} @@ -296,7 +296,7 @@ sBC_virtual_if_call: @ 80994C4 adds r0, 0x1 str r0, [r5, 0x8] adds r0, r5, 0 - bl script_read_word + bl ScriptReadWord ldr r1, =gUnknown_020375C4 ldr r1, [r1] subs r2, r0, r1 @@ -311,7 +311,7 @@ sBC_virtual_if_call: @ 80994C4 bne _080994F6 adds r0, r5, 0 adds r1, r2, 0 - bl script_call + bl ScriptCall _080994F6: movs r0, 0 pop {r4,r5} @@ -336,7 +336,7 @@ s08_jumpstd: @ 8099508 bcs _08099528 ldr r1, [r1] adds r0, r2, 0 - bl script_jump + bl ScriptJump _08099528: movs r0, 0 pop {r1} @@ -360,7 +360,7 @@ s09_callstd: @ 8099538 bcs _08099558 ldr r1, [r1] adds r0, r2, 0 - bl script_call + bl ScriptCall _08099558: movs r0, 0 pop {r1} @@ -396,7 +396,7 @@ s0A_jumpstd_if: @ 8099568 bcs _080995A0 ldr r1, [r1] adds r0, r3, 0 - bl script_jump + bl ScriptJump _080995A0: movs r0, 0 pop {r4} @@ -433,7 +433,7 @@ s0B_callstd_if: @ 80995B4 bcs _080995EC ldr r1, [r1] adds r0, r3, 0 - bl script_call + bl ScriptCall _080995EC: movs r0, 0 pop {r4} @@ -447,7 +447,7 @@ s0C_restore_execution_after_sCF: @ 8099600 push {lr} ldr r1, =gUnknown_020375C0 ldr r1, [r1] - bl script_jump + bl ScriptJump movs r0, 0 pop {r1} bx r1 @@ -458,9 +458,9 @@ s0C_restore_execution_after_sCF: @ 8099600 s0D_endscript_killram: @ 8099614 push {r4,lr} adds r4, r0, 0 - bl killram + bl ClearRamScript adds r0, r4, 0 - bl script_stop + bl StopScript movs r0, 0x1 pop {r4} pop {r1} @@ -491,7 +491,7 @@ s0F_u32_var_to_const: @ 8099644 adds r0, 0x1 str r0, [r4, 0x8] adds r0, r4, 0 - bl script_read_word + bl ScriptReadWord lsls r5, 2 adds r4, 0x64 adds r4, r5 @@ -512,7 +512,7 @@ s12_u32_var_to_ptr: @ 8099668 adds r0, 0x1 str r0, [r4, 0x8] adds r0, r4, 0 - bl script_read_word + bl ScriptReadWord lsls r5, 2 adds r4, 0x64 adds r4, r5 @@ -532,7 +532,7 @@ s11_u8_ptr_to_const: @ 809968C ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_word + bl ScriptReadWord strb r4, [r0] movs r0, 0 pop {r4} @@ -569,7 +569,7 @@ s13_u8_var_to_ptr: @ 80996C0 adds r0, 0x1 str r0, [r4, 0x8] adds r0, r4, 0 - bl script_read_word + bl ScriptReadWord lsls r5, 2 adds r4, 0x64 adds r4, r5 @@ -605,10 +605,10 @@ s14_u32_var_to_var: @ 80996E4 s15_u8_ptr_to_ptr: @ 8099704 push {r4,r5,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord adds r5, r0, 0 adds r0, r4, 0 - bl script_read_word + bl ScriptReadWord ldrb r0, [r0] strb r0, [r5] movs r0, 0 @@ -621,13 +621,13 @@ s15_u8_ptr_to_ptr: @ 8099704 s16_u16_gvar_to_const: @ 8099720 push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer adds r4, r0, 0 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword strh r0, [r4] movs r0, 0 pop {r4,r5} @@ -639,13 +639,13 @@ s16_u16_gvar_to_const: @ 8099720 s19_u16_gvar_gvar: @ 8099744 push {r4,r5,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer adds r5, r0, 0 adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer @@ -661,13 +661,13 @@ s19_u16_gvar_gvar: @ 8099744 s1A_u16_gvar_gvar: @ 8099770 push {r4,r5,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer adds r5, r0, 0 adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -764,7 +764,7 @@ s1D_cmp_u8_var_ptr: @ 8099814 adds r2, 0x1 str r2, [r4, 0x8] adds r0, r4, 0 - bl script_read_word + bl ScriptReadWord ldrb r1, [r0] adds r0, r5, 0 bl compare_012 @@ -779,7 +779,7 @@ s1D_cmp_u8_var_ptr: @ 8099814 s1E_cmp_u8_ptr_var: @ 8099840 push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord ldrb r0, [r0] ldr r3, [r4, 0x8] ldrb r2, [r3] @@ -802,7 +802,7 @@ s1E_cmp_u8_ptr_var: @ 8099840 s1F_cmp_u8_ptr_const: @ 809986C push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord ldrb r0, [r0] ldr r2, [r4, 0x8] ldrb r1, [r2] @@ -820,10 +820,10 @@ s1F_cmp_u8_ptr_const: @ 809986C s20_cmp_u8_ptr_ptr: @ 809988C push {r4,r5,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord ldrb r5, [r0] adds r0, r4, 0 - bl script_read_word + bl ScriptReadWord ldrb r1, [r0] adds r0, r5, 0 bl compare_012 @@ -838,13 +838,13 @@ s20_cmp_u8_ptr_ptr: @ 809988C s21_cmp_u16_gvar_const: @ 80998B0 push {r4,r5,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer ldrh r5, [r0] adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword adds r1, r0, 0 lsls r1, 16 lsrs r1, 16 @@ -861,13 +861,13 @@ s21_cmp_u16_gvar_const: @ 80998B0 s22_cmp_u16_gvar_gvar: @ 80998E0 push {r4,r5,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer adds r5, r0, 0 adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer @@ -886,13 +886,13 @@ s22_cmp_u16_gvar_gvar: @ 80998E0 s17_u16_gvar_add_const: @ 8099914 push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer adds r4, r0, 0 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword ldrh r1, [r4] adds r0, r1 strh r0, [r4] @@ -906,13 +906,13 @@ s17_u16_gvar_add_const: @ 8099914 sub_809993C: @ 809993C push {r4,r5,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer adds r5, r0, 0 adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -928,7 +928,7 @@ sub_809993C: @ 809993C thumb_func_start s8F_get_random_val s8F_get_random_val: @ 809996C push {r4,r5,lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -953,7 +953,7 @@ s8F_get_random_val: @ 809996C sub_80999A0: @ 80999A0 push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -961,7 +961,7 @@ sub_80999A0: @ 80999A0 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -985,7 +985,7 @@ sub_80999A0: @ 80999A0 sub_80999E4: @ 80999E4 push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -993,7 +993,7 @@ sub_80999E4: @ 80999E4 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1017,7 +1017,7 @@ sub_80999E4: @ 80999E4 sub_8099A28: @ 8099A28 push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1025,7 +1025,7 @@ sub_8099A28: @ 8099A28 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1049,7 +1049,7 @@ sub_8099A28: @ 8099A28 sub_8099A6C: @ 8099A6C push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1057,7 +1057,7 @@ sub_8099A6C: @ 8099A6C lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1080,7 +1080,7 @@ sub_8099A6C: @ 8099A6C thumb_func_start s48_get_item_type s48_get_item_type: @ 8099AB0 push {r4,lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1102,7 +1102,7 @@ s48_get_item_type: @ 8099AB0 sub_8099ADC: @ 8099ADC push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1110,7 +1110,7 @@ sub_8099ADC: @ 8099ADC lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1134,7 +1134,7 @@ sub_8099ADC: @ 8099ADC sub_8099B20: @ 8099B20 push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1142,7 +1142,7 @@ sub_8099B20: @ 8099B20 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1165,7 +1165,7 @@ sub_8099B20: @ 8099B20 thumb_func_start sub_8099B64 sub_8099B64: @ 8099B64 push {r4,lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1186,7 +1186,7 @@ sub_8099B64: @ 8099B64 thumb_func_start sub_8099B90 sub_8099B90: @ 8099B90 push {r4,lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1207,7 +1207,7 @@ sub_8099B90: @ 8099B90 thumb_func_start sub_8099BBC sub_8099BBC: @ 8099BBC push {r4,lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1228,7 +1228,7 @@ sub_8099BBC: @ 8099BBC thumb_func_start sub_8099BE8 sub_8099BE8: @ 8099BE8 push {r4,lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1250,7 +1250,7 @@ sub_8099BE8: @ 8099BE8 @ int s29_flag_set(script_env *env) s29_flag_set: @ 8099C14 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl FlagSet @@ -1263,7 +1263,7 @@ s29_flag_set: @ 8099C14 @ int s2A_flag_clear(script_env *env) s2A_flag_clear: @ 8099C28 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl FlagReset @@ -1277,7 +1277,7 @@ s2A_flag_clear: @ 8099C28 s2B_flag_check: @ 8099C3C push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl FlagGet @@ -1313,7 +1313,7 @@ s9A_unknown: @ 8099C70 str r1, [r0, 0x8] adds r0, r2, 0 bl sub_80B009C - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 pop {r1} bx r1 @@ -1323,7 +1323,7 @@ s9A_unknown: @ 8099C70 @ int s99_unknown(script_env *env) s99_unknown: @ 8099C8C push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1367,7 +1367,7 @@ s97_screen_special_effect: @ 8099CC8 bl fade_screen ldr r1, =sub_8099CA8 adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r4} pop {r1} @@ -1392,7 +1392,7 @@ s98_refade_with_timer: @ 8099CF0 bl fade_screen ldr r1, =sub_8099CA8 adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r4} pop {r1} @@ -1440,7 +1440,7 @@ _08099D60: _08099D72: ldr r1, =sub_8099CA8 adds r0, r5, 0 - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r4,r5} pop {r1} @@ -1473,12 +1473,12 @@ _08099DAE: s28_pause: @ 8099DB4 push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword ldr r1, =gUnknown_020375C8 strh r0, [r1] ldr r1, =s28_pause_asm adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r4} pop {r1} @@ -1491,7 +1491,7 @@ s28_pause: @ 8099DB4 s2C_unknown: @ 8099DD8 push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1499,7 +1499,7 @@ s2C_unknown: @ 8099DD8 lsls r4, 24 lsrs r4, 24 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1552,7 +1552,7 @@ s2E_unknown: @ 8099E1C @ int sA4_set_weather_data(script_env *env) sA4_set_weather_data: @ 8099E54 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1603,7 +1603,7 @@ sA6_activate_per_step_callback_eg_ash: @ 8099E88 @ int sA7_set_new_map_footer(script_env *env) sA7_set_new_map_footer: @ 8099EA0 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1637,7 +1637,7 @@ s39_warp_sfx: @ 8099EBC adds r1, 0x1 str r1, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1645,7 +1645,7 @@ s39_warp_sfx: @ 8099EBC lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1702,7 +1702,7 @@ s3A_warp_new_music: @ 8099F44 adds r1, 0x1 str r1, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1710,7 +1710,7 @@ s3A_warp_new_music: @ 8099F44 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1767,7 +1767,7 @@ s3B_warp_keep_music: @ 8099FCC adds r1, 0x1 str r1, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1775,7 +1775,7 @@ s3B_warp_keep_music: @ 8099FCC lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1890,7 +1890,7 @@ s3D_warp_v4: @ 809A0C8 adds r1, 0x1 str r1, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1898,7 +1898,7 @@ s3D_warp_v4: @ 809A0C8 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1954,7 +1954,7 @@ sub_809A150: @ 809A150 adds r1, 0x1 str r1, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -1962,7 +1962,7 @@ sub_809A150: @ 809A150 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2018,7 +2018,7 @@ s3E_set_new_map: @ 809A1D8 adds r1, 0x1 str r1, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2026,7 +2026,7 @@ s3E_set_new_map: @ 809A1D8 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2080,7 +2080,7 @@ s3F_set_new_map_DMA: @ 809A258 adds r1, 0x1 str r1, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2088,7 +2088,7 @@ s3F_set_new_map_DMA: @ 809A258 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2144,7 +2144,7 @@ sub_809A2DC: @ 809A2DC adds r1, 0x1 str r1, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2152,7 +2152,7 @@ sub_809A2DC: @ 809A2DC lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2206,7 +2206,7 @@ sub_809A35C: @ 809A35C adds r1, 0x1 str r1, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2214,7 +2214,7 @@ sub_809A35C: @ 809A35C lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2268,7 +2268,7 @@ sC4_unknown: @ 809A3DC adds r1, 0x1 str r1, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2276,7 +2276,7 @@ sC4_unknown: @ 809A3DC lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2314,13 +2314,13 @@ sC4_unknown: @ 809A3DC s42_get_map_camera_pos: @ 809A45C push {r4,r5,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer adds r5, r0, 0 adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer @@ -2356,7 +2356,7 @@ s43_get_player_party_count: @ 809A498 thumb_func_start s2F_music_play s2F_music_play: @ 809A4B4 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl PlaySE @@ -2385,7 +2385,7 @@ _0809A4DA: s30_music_check: @ 809A4E0 push {lr} ldr r1, =s30_music_check_asm - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r1} bx r1 @@ -2395,7 +2395,7 @@ s30_music_check: @ 809A4E0 thumb_func_start s31_PlayFanfare s31_PlayFanfare: @ 809A4F4 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl PlayFanfare @@ -2418,7 +2418,7 @@ s32_fanfare_wait_asm: @ 809A508 s32_fanfare_wait: @ 809A518 push {lr} ldr r1, =s32_fanfare_wait_asm - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r1} bx r1 @@ -2430,7 +2430,7 @@ s32_fanfare_wait: @ 809A518 s33_play_music: @ 809A52C push {r4,r5,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r2, r0, 16 adds r5, r2, 0 @@ -2454,7 +2454,7 @@ _0809A54C: thumb_func_start s34_unknown s34_unknown: @ 809A55C push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl sav1_set_battle_music_maybe @@ -2475,7 +2475,7 @@ s35_fade_to_default: @ 809A570 thumb_func_start s36_fade_to_music s36_fade_to_music: @ 809A57C push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl sub_80858C4 @@ -2504,7 +2504,7 @@ _0809A5AA: _0809A5B0: ldr r1, =IsBGMPausedOrStopped adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r4} pop {r1} @@ -2538,7 +2538,7 @@ _0809A5E2: s4F_execute_movement: @ 809A5E8 push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2546,7 +2546,7 @@ s4F_execute_movement: @ 809A5E8 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_word + bl ScriptReadWord adds r3, r0, 0 lsls r0, r4, 24 lsrs r0, 24 @@ -2568,7 +2568,7 @@ s4F_execute_movement: @ 809A5E8 s50_execute_movement_remote: @ 809A62C push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2576,7 +2576,7 @@ s50_execute_movement_remote: @ 809A62C lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_word + bl ScriptReadWord adds r3, r0, 0 ldr r0, [r5, 0x8] ldrb r2, [r0] @@ -2618,7 +2618,7 @@ s51a_0806B288: @ 809A670 s51_waitmove: @ 809A698 push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2641,7 +2641,7 @@ _0809A6B4: strh r0, [r1] ldr r1, =s51a_0806B288 adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r4} pop {r1} @@ -2653,7 +2653,7 @@ _0809A6B4: s52_waitmove_remote: @ 809A6EC push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2677,7 +2677,7 @@ _0809A708: strh r1, [r0] ldr r1, =s51a_0806B288 adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r4} pop {r1} @@ -2688,7 +2688,7 @@ _0809A708: thumb_func_start s53_hide_sprite s53_hide_sprite: @ 809A740 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2709,7 +2709,7 @@ s53_hide_sprite: @ 809A740 s54_hide_sprite_set_coords: @ 809A768 push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2732,7 +2732,7 @@ s54_hide_sprite_set_coords: @ 809A768 thumb_func_start s55_show_sprite s55_show_sprite: @ 809A798 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2753,7 +2753,7 @@ s55_show_sprite: @ 809A798 s56_show_sprite_set_coords: @ 809A7C0 push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2778,7 +2778,7 @@ s57_move_sprites: @ 809A7F0 push {r4-r6,lr} sub sp, 0x4 adds r6, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2786,7 +2786,7 @@ s57_move_sprites: @ 809A7F0 lsls r5, 16 lsrs r5, 16 adds r0, r6, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2794,7 +2794,7 @@ s57_move_sprites: @ 809A7F0 lsls r4, 16 lsrs r4, 16 adds r0, r6, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2824,7 +2824,7 @@ s57_move_sprites: @ 809A7F0 s63_new_sprite_location_permanent: @ 809A858 push {r4-r6,lr} adds r6, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2832,7 +2832,7 @@ s63_new_sprite_location_permanent: @ 809A858 lsls r5, 16 lsrs r5, 16 adds r0, r6, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2840,7 +2840,7 @@ s63_new_sprite_location_permanent: @ 809A858 lsls r4, 16 lsrs r4, 16 adds r0, r6, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2863,7 +2863,7 @@ s63_new_sprite_location_permanent: @ 809A858 thumb_func_start s64_set_sprite_top_left_corner s64_set_sprite_top_left_corner: @ 809A8B0 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2884,7 +2884,7 @@ s64_set_sprite_top_left_corner: @ 809A8B0 s58_npc_f1_clear_x20: @ 809A8D8 push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2909,7 +2909,7 @@ s58_npc_f1_clear_x20: @ 809A8D8 s59_npc_f1_set_x20: @ 809A908 push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2934,7 +2934,7 @@ s59_npc_f1_set_x20: @ 809A908 sA8_unknown: @ 809A938 push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -2964,7 +2964,7 @@ sA8_unknown: @ 809A938 sA9_unknown: @ 809A974 push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -3016,7 +3016,7 @@ _0809A9CC: s5B_npc_set_direction: @ 809A9DC push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -3042,7 +3042,7 @@ s5B_npc_set_direction: @ 809A9DC s65_set_sprite_behaviour: @ 809AA10 push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -3075,7 +3075,7 @@ sAA_create_new_sprite: @ 809AA38 adds r0, 0x1 str r0, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -3083,7 +3083,7 @@ sAA_create_new_sprite: @ 809AA38 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -3141,7 +3141,7 @@ sub_809AAC4: @ 809AAC4 bl sub_80983E8 ldr r1, =sub_80983C4 adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 b _0809AAE6 .pool @@ -3177,14 +3177,14 @@ _0809AAFC: bl sub_80984A0 ldr r1, =sub_809847C adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript b _0809AB38 .pool _0809AB2C: bl sub_80983E8 ldr r1, =sub_80983C4 adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript _0809AB38: movs r0, 0x1 _0809AB3A: @@ -3262,7 +3262,7 @@ _0809AB9E: s67_execute_box: @ 809ABD4 push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord cmp r0, 0 bne _0809ABE2 ldr r0, [r4, 0x64] @@ -3278,7 +3278,7 @@ _0809ABE2: sub_809ABF0: @ 809ABF0 push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord cmp r0, 0 bne _0809ABFE ldr r0, [r4, 0x64] @@ -3294,7 +3294,7 @@ _0809ABFE: s9B_unknown: @ 809AC0C push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord adds r3, r0, 0 cmp r3, 0 bne _0809AC1C @@ -3321,7 +3321,7 @@ sub_809AC3C: @ 809AC3C push {r4,r5,lr} sub sp, 0xC adds r5, r0, 0 - bl script_read_word + bl ScriptReadWord adds r4, r0, 0 cmp r4, 0 bne _0809AC4E @@ -3351,7 +3351,7 @@ _0809AC4E: sub_809AC78: @ 809AC78 push {lr} ldr r1, =sub_809833C - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r1} bx r1 @@ -3394,7 +3394,7 @@ _0809ACBA: sub_809ACC0: @ 809ACC0 push {lr} ldr r1, =sub_809AC98 - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r1} bx r1 @@ -3420,7 +3420,7 @@ s6E_yes_no: @ 809ACD4 movs r0, 0 b _0809ACFC _0809ACF6: - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 _0809ACFC: pop {r1} @@ -3452,7 +3452,7 @@ s6F_multichoice: @ 809AD00 movs r0, 0 b _0809AD34 _0809AD2E: - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 _0809AD34: pop {r4,r5} @@ -3493,7 +3493,7 @@ sub_809AD3C: @ 809AD3C movs r0, 0 b _0809AD80 _0809AD7A: - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 _0809AD80: add sp, 0x4 @@ -3543,7 +3543,7 @@ sub_809AD90: @ 809AD90 movs r0, 0 b _0809ADD4 _0809ADCE: - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 _0809ADD4: add sp, 0x4 @@ -3576,7 +3576,7 @@ sub_809ADEC: @ 809ADEC sub_809ADF8: @ 809ADF8 push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -3605,7 +3605,7 @@ s76_close_picture_box: @ 809AE28 cmp r1, 0 beq _0809AE40 adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 b _0809AE42 _0809AE40: @@ -3629,7 +3629,7 @@ sub_809AE48: @ 809AE48 bl sub_812FDA8 _0809AE5C: bl sub_80F8ADC - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 pop {r1} bx r1 @@ -3641,7 +3641,7 @@ sub_809AE6C: @ 809AE6C mov r7, r8 push {r7} sub sp, 0x20 - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 ldr r4, =gStringVar4 adds r1, 0x6 @@ -3789,7 +3789,7 @@ sub_809AF94: @ 809AF94 thumb_func_start sBD_virtual_message sBD_virtual_message: @ 809AFA0 push {lr} - bl script_read_word + bl ScriptReadWord ldr r1, =gUnknown_020375C4 ldr r1, [r1] subs r0, r1 @@ -3807,7 +3807,7 @@ s7D_load_pokename: @ 809AFBC ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -3871,7 +3871,7 @@ s7F_load_pokename_team: @ 809B048 ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -3904,7 +3904,7 @@ s80_load_item_name: @ 809B090 ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -3931,7 +3931,7 @@ sub_809B0C4: @ 809B0C4 adds r0, 0x1 str r0, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -3939,7 +3939,7 @@ sub_809B0C4: @ 809B0C4 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -3966,7 +3966,7 @@ sub_809B114: @ 809B114 ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -3994,7 +3994,7 @@ s82_load_item_name: @ 809B150 ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4024,7 +4024,7 @@ s83_load_textvar_var: @ 809B190 ldrb r5, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4057,7 +4057,7 @@ s84_load_textvar_std_expression: @ 809B1D4 ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4086,7 +4086,7 @@ sub_809B214: @ 809B214 ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4112,7 +4112,7 @@ s85_load_textvar_pointer: @ 809B248 ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 ldr r0, =gUnknown_085102D4 lsls r4, 2 @@ -4129,7 +4129,7 @@ s85_load_textvar_pointer: @ 809B248 thumb_func_start sBE_virtual_load_text sBE_virtual_load_text: @ 809B270 push {lr} - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 ldr r0, =gUnknown_020375C4 ldr r0, [r0] @@ -4149,7 +4149,7 @@ sBF_virtual_load_textbuffer: @ 809B294 ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_word + bl ScriptReadWord adds r1, r0, 0 ldr r0, =gUnknown_020375C4 ldr r0, [r0] @@ -4173,7 +4173,7 @@ sC6_load_textvar_box_label: @ 809B2C8 ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4202,7 +4202,7 @@ s79_give_pokemon: @ 809B304 push {r5,r6} sub sp, 0x8 adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4215,7 +4215,7 @@ s79_give_pokemon: @ 809B304 adds r0, 0x1 str r0, [r4, 0x8] adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4223,10 +4223,10 @@ s79_give_pokemon: @ 809B304 lsls r5, 16 lsrs r5, 16 adds r0, r4, 0 - bl script_read_word + bl ScriptReadWord mov r8, r0 adds r0, r4, 0 - bl script_read_word + bl ScriptReadWord ldr r1, [r4, 0x8] ldrb r2, [r1] adds r1, 0x1 @@ -4256,7 +4256,7 @@ s79_give_pokemon: @ 809B304 thumb_func_start s7A_create_egg s7A_create_egg: @ 809B384 push {r4,lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4284,7 +4284,7 @@ s7B_change_pokedata_AP: @ 809B3B0 ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword adds r1, r0, 0 lsls r1, 16 lsrs r1, 16 @@ -4300,7 +4300,7 @@ s7B_change_pokedata_AP: @ 809B3B0 thumb_func_start sub_809B3DC sub_809B3DC: @ 809B3DC push {r4-r7,lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r7, r0, 16 ldr r1, =gScriptResult @@ -4361,7 +4361,7 @@ _0809B44A: s90_AddMoney: @ 809B458 push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord adds r2, r0, 0 ldr r0, [r4, 0x8] ldrb r1, [r0] @@ -4389,7 +4389,7 @@ _0809B47E: s91_SubtractMoney: @ 809B48C push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord adds r2, r0, 0 ldr r0, [r4, 0x8] ldrb r1, [r0] @@ -4417,7 +4417,7 @@ _0809B4B2: s92_check_money: @ 809B4C0 push {r4,lr} adds r4, r0, 0 - bl script_read_word + bl ScriptReadWord adds r2, r0, 0 ldr r0, [r4, 0x8] ldrb r1, [r0] @@ -4613,7 +4613,7 @@ sub_809B604: @ 809B604 s60_check_trainer_flag: @ 809B618 push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4630,7 +4630,7 @@ s60_check_trainer_flag: @ 809B618 thumb_func_start s61_set_trainer_flag s61_set_trainer_flag: @ 809B63C push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4645,7 +4645,7 @@ s61_set_trainer_flag: @ 809B63C thumb_func_start s62_unset_trainer_flag s62_unset_trainer_flag: @ 809B658 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4661,7 +4661,7 @@ s62_unset_trainer_flag: @ 809B658 sB6_load_battle: @ 809B674 push {r4-r6,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword adds r5, r0, 0 lsls r5, 16 lsrs r5, 16 @@ -4670,7 +4670,7 @@ sB6_load_battle: @ 809B674 adds r0, 0x1 str r0, [r4, 0x8] adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword adds r2, r0, 0 lsls r2, 16 lsrs r2, 16 @@ -4687,7 +4687,7 @@ sB6_load_battle: @ 809B674 sub_809B6A8: @ 809B6A8 push {lr} bl sub_80B08A8 - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 pop {r1} bx r1 @@ -4696,9 +4696,9 @@ sub_809B6A8: @ 809B6A8 thumb_func_start s86_pokemart s86_pokemart: @ 809B6B8 push {lr} - bl script_read_word + bl ScriptReadWord bl CreatePokemartMenu - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 pop {r1} bx r1 @@ -4707,9 +4707,9 @@ s86_pokemart: @ 809B6B8 thumb_func_start s87_pokemartdecor s87_pokemartdecor: @ 809B6CC push {lr} - bl script_read_word + bl ScriptReadWord bl CreateDecorationShop1Menu - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 pop {r1} bx r1 @@ -4718,9 +4718,9 @@ s87_pokemartdecor: @ 809B6CC thumb_func_start s88_pokemartbp s88_pokemartbp: @ 809B6E0 push {lr} - bl script_read_word + bl ScriptReadWord bl CreateDecorationShop2Menu - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 pop {r1} bx r1 @@ -4729,7 +4729,7 @@ s88_pokemartbp: @ 809B6E0 thumb_func_start s89_open_casino_game1 s89_open_casino_game1: @ 809B6F4 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4737,7 +4737,7 @@ s89_open_casino_game1: @ 809B6F4 lsrs r0, 24 ldr r1, =c2_exit_to_overworld_1_continue_scripts_restart_music bl sub_812A540 - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 pop {r1} bx r1 @@ -4782,7 +4782,7 @@ _0809B750: thumb_func_start sub_809B758 sub_809B758: @ 809B758 push {r4,lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4804,7 +4804,7 @@ sub_809B758: @ 809B758 sub_809B784: @ 809B784 push {lr} bl sub_81B9404 - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 pop {r1} bx r1 @@ -4814,7 +4814,7 @@ sub_809B784: @ 809B784 sub_809B794: @ 809B794 push {lr} bl sub_80F840C - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 pop {r1} bx r1 @@ -4824,7 +4824,7 @@ sub_809B794: @ 809B794 sub_809B7A4: @ 809B7A4 push {lr} bl sub_80F8484 - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 pop {r1} bx r1 @@ -4836,7 +4836,7 @@ sub_809B7B4: @ 809B7B4 ldr r0, =gUnknown_02039F2C ldrb r0, [r0] bl sub_80F84C4 - bl script_env_2_set_ctx_paused + bl ScriptContext1_Stop movs r0, 0x1 pop {r1} bx r1 @@ -4846,7 +4846,7 @@ sub_809B7B4: @ 809B7B4 thumb_func_start s9C_execute_HM s9C_execute_HM: @ 809B7CC push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4870,7 +4870,7 @@ s9D_set_HM_animation_data: @ 809B7F4 ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4910,7 +4910,7 @@ _0809B83E: s9E_checkarray_HM_animation: @ 809B844 push {r4,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4918,7 +4918,7 @@ s9E_checkarray_HM_animation: @ 809B844 strh r0, [r1] ldr r1, =sub_809B824 adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r4} pop {r1} @@ -4929,7 +4929,7 @@ s9E_checkarray_HM_animation: @ 809B844 thumb_func_start s9F_changeposition_fly s9F_changeposition_fly: @ 809B870 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4957,7 +4957,7 @@ sA0_check_gender: @ 809B88C sA1_play_cry: @ 809B8A4 push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4965,7 +4965,7 @@ sA1_play_cry: @ 809B8A4 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -4984,7 +4984,7 @@ sA1_play_cry: @ 809B8A4 sub_809B8DC: @ 809B8DC push {lr} ldr r1, =IsCryFinished - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r1} bx r1 @@ -4995,28 +4995,28 @@ sub_809B8DC: @ 809B8DC sA2_setmaptile: @ 809B8F0 push {r4-r7,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet lsls r0, 16 lsrs r6, r0, 16 adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet lsls r0, 16 lsrs r5, r0, 16 adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet lsls r0, 16 lsrs r7, r0, 16 adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5054,7 +5054,7 @@ _0809B966: sAC_open_door: @ 809B970 push {r4,r5,lr} adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5062,7 +5062,7 @@ sAC_open_door: @ 809B970 lsls r5, 16 lsrs r5, 16 adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5094,7 +5094,7 @@ sAC_open_door: @ 809B970 sub_809B9C8: @ 809B9C8 push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5102,7 +5102,7 @@ sub_809B9C8: @ 809B9C8 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5143,7 +5143,7 @@ _0809BA1E: sub_809BA24: @ 809BA24 push {lr} ldr r1, =sub_809BA0C - bl script_setup_asm_script + bl SetupNativeScript movs r0, 0x1 pop {r1} bx r1 @@ -5154,7 +5154,7 @@ sub_809BA24: @ 809BA24 sub_809BA38: @ 809BA38 push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5162,7 +5162,7 @@ sub_809BA38: @ 809BA38 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5187,7 +5187,7 @@ sub_809BA38: @ 809BA38 sub_809BA7C: @ 809BA7C push {r4,r5,lr} adds r5, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5195,7 +5195,7 @@ sub_809BA7C: @ 809BA7C lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5224,17 +5224,17 @@ sub_809BAC0: @ 809BAC0 adds r0, 0x1 str r0, [r4, 0x8] adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet adds r0, r4, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5253,7 +5253,7 @@ sub_809BAFC: @ 809BAFC thumb_func_start sB3_get_coin_amount sB3_get_coin_amount: @ 809BB00 push {r4,lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl GetVarPointer @@ -5269,7 +5269,7 @@ sB3_get_coin_amount: @ 809BB00 thumb_func_start sub_809BB20 sub_809BB20: @ 809BB20 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5298,7 +5298,7 @@ _0809BB4C: thumb_func_start sub_809BB58 sub_809BB58: @ 809BB58 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5327,7 +5327,7 @@ _0809BB84: thumb_func_start sub_809BB90 sub_809BB90: @ 809BB90 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5354,7 +5354,7 @@ sub_809BBB4: @ 809BBB4 thumb_func_start ScrCmd_MossdeepGymSwitch ScrCmd_MossdeepGymSwitch: @ 809BBC0 push {lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5411,7 +5411,7 @@ _0809BC0C: bl sub_8098630 ldr r1, =sub_8098734 adds r0, r4, 0 - bl script_setup_asm_script + bl SetupNativeScript _0809BC2E: movs r0, 0x1 _0809BC30: @@ -5428,7 +5428,7 @@ sCD_set_obedient_bit: @ 809BC44 movs r2, 0x1 mov r1, sp strb r2, [r1] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5451,7 +5451,7 @@ sCD_set_obedient_bit: @ 809BC44 thumb_func_start sCE_check_obedient_bit sCE_check_obedient_bit: @ 809BC7C push {r4,lr} - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5486,7 +5486,7 @@ sCF_execute_RAM_script_DMA: @ 809BCB4 str r0, [r1] adds r0, r4, 0 adds r1, r2, 0 - bl script_jump + bl ScriptJump _0809BCD0: movs r0, 0 pop {r4} @@ -5516,7 +5516,7 @@ sD1_warp_v5: @ 809BCDC adds r1, 0x1 str r1, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5524,7 +5524,7 @@ sD1_warp_v5: @ 809BCDC lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5568,7 +5568,7 @@ sub_809BD70: @ 809BD70 push {r4,lr} sub sp, 0x4 adds r4, r0, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5620,7 +5620,7 @@ sub_809BDD0: @ 809BDD0 ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5648,7 +5648,7 @@ sub_809BE0C: @ 809BE0C ldrb r4, [r1] adds r1, 0x1 str r1, [r0, 0x8] - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5698,7 +5698,7 @@ sub_809BE54: @ 809BE54 adds r1, 0x1 str r1, [r5, 0x8] adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet @@ -5706,7 +5706,7 @@ sub_809BE54: @ 809BE54 lsls r4, 16 lsrs r4, 16 adds r0, r5, 0 - bl script_read_halfword + bl ScriptReadHalfword lsls r0, 16 lsrs r0, 16 bl VarGet diff --git a/asm/script.s b/asm/script.s deleted file mode 100644 index 1b49440d6..000000000 --- a/asm/script.s +++ /dev/null @@ -1,879 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start script_env_init -@ void script_env_init(script_env *env, int a2, int a3) -script_env_init: @ 8098CB8 - push {lr} - adds r3, r0, 0 - movs r0, 0 - strb r0, [r3, 0x1] - str r0, [r3, 0x8] - strb r0, [r3] - str r0, [r3, 0x4] - str r1, [r3, 0x5C] - str r2, [r3, 0x60] - movs r2, 0 - movs r1, 0x3 - adds r0, r3, 0 - adds r0, 0x70 -_08098CD2: - str r2, [r0] - subs r0, 0x4 - subs r1, 0x1 - cmp r1, 0 - bge _08098CD2 - adds r1, r3, 0 - adds r1, 0xC - movs r2, 0 - adds r0, r3, 0 - adds r0, 0x58 -_08098CE6: - str r2, [r0] - subs r0, 0x4 - cmp r0, r1 - bge _08098CE6 - pop {r0} - bx r0 - thumb_func_end script_env_init - - thumb_func_start script_setup_bytecode_script -@ int script_setup_bytecode_script(script_env *env, void *script_ptr) -script_setup_bytecode_script: @ 8098CF4 - str r1, [r0, 0x8] - movs r1, 0x1 - strb r1, [r0, 0x1] - movs r0, 0x1 - bx lr - thumb_func_end script_setup_bytecode_script - - thumb_func_start script_setup_asm_script -script_setup_asm_script: @ 8098D00 - movs r2, 0x2 - strb r2, [r0, 0x1] - str r1, [r0, 0x4] - bx lr - thumb_func_end script_setup_asm_script - - thumb_func_start script_stop -@ void script_stop(script_env *env) -script_stop: @ 8098D08 - movs r1, 0 - strb r1, [r0, 0x1] - str r1, [r0, 0x8] - bx lr - thumb_func_end script_stop - - thumb_func_start script_main_handler -@ int script_main_handler(script_env *env) -script_main_handler: @ 8098D10 - push {r4,lr} - adds r4, r0, 0 - ldrb r0, [r4, 0x1] - cmp r0, 0 - bne _08098D1E -_08098D1A: - movs r0, 0 - b _08098D90 -_08098D1E: - ldrb r0, [r4, 0x1] - cmp r0, 0x1 - beq _08098D56 - cmp r0, 0x1 - bgt _08098D2E - cmp r0, 0 - beq _08098D1A - b _08098D8E -_08098D2E: - cmp r0, 0x2 - bne _08098D8E - ldr r0, [r4, 0x4] - cmp r0, 0 - beq _08098D52 - bl _call_via_r0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08098D8E - strb r0, [r4, 0x1] - b _08098D8E -_08098D48: - strb r2, [r4, 0x1] - b _08098D1A -_08098D4C: - movs r0, 0 - strb r0, [r4, 0x1] - b _08098D90 -_08098D52: - movs r0, 0x1 - strb r0, [r4, 0x1] -_08098D56: - ldr r2, [r4, 0x8] - cmp r2, 0 - beq _08098D48 - ldr r0, =gUnknown_085102BC - ldr r0, [r0] - cmp r2, r0 - bne _08098D6C -_08098D64: - swi 0x2 - b _08098D64 - .pool -_08098D6C: - ldrb r1, [r2] - adds r0, r2, 0x1 - str r0, [r4, 0x8] - lsls r1, 2 - ldr r0, [r4, 0x5C] - adds r1, r0, r1 - ldr r0, [r4, 0x60] - cmp r1, r0 - bcs _08098D4C - ldr r1, [r1] - adds r0, r4, 0 - bl _call_via_r1 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08098D56 -_08098D8E: - movs r0, 0x1 -_08098D90: - pop {r4} - pop {r1} - bx r1 - thumb_func_end script_main_handler - - thumb_func_start script_stack_push -@ int script_stack_push(script_env *env, int value) -script_stack_push: @ 8098D98 - push {lr} - adds r2, r0, 0 - adds r3, r1, 0 - ldrb r1, [r2] - adds r0, r1, 0x1 - cmp r0, 0x13 - bgt _08098DBA - lsls r0, r1, 2 - adds r1, r2, 0 - adds r1, 0xC - adds r1, r0 - str r3, [r1] - ldrb r0, [r2] - adds r0, 0x1 - strb r0, [r2] - movs r0, 0 - b _08098DBC -_08098DBA: - movs r0, 0x1 -_08098DBC: - pop {r1} - bx r1 - thumb_func_end script_stack_push - - thumb_func_start script_stack_pop -@ int script_stack_pop(script_env *env) -script_stack_pop: @ 8098DC0 - push {lr} - adds r2, r0, 0 - ldrb r0, [r2] - cmp r0, 0 - beq _08098DDC - subs r0, 0x1 - strb r0, [r2] - ldrb r1, [r2] - lsls r1, 2 - adds r0, r2, 0 - adds r0, 0xC - adds r0, r1 - ldr r0, [r0] - b _08098DDE -_08098DDC: - movs r0, 0 -_08098DDE: - pop {r1} - bx r1 - thumb_func_end script_stack_pop - - thumb_func_start script_jump -@ void script_jump(script_env *env, int address) -script_jump: @ 8098DE4 - str r1, [r0, 0x8] - bx lr - thumb_func_end script_jump - - thumb_func_start script_call -@ void script_call(script_env *env, int address) -script_call: @ 8098DE8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, [r4, 0x8] - bl script_stack_push - str r5, [r4, 0x8] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end script_call - - thumb_func_start script_return -@ void script_return(script_env *env) -script_return: @ 8098DFC - push {r4,lr} - adds r4, r0, 0 - bl script_stack_pop - str r0, [r4, 0x8] - pop {r4} - pop {r0} - bx r0 - thumb_func_end script_return - - thumb_func_start script_read_halfword -@ int script_read_halfword(script_env *env) -script_read_halfword: @ 8098E0C - adds r3, r0, 0 - ldr r2, [r3, 0x8] - ldrb r0, [r2] - adds r2, 0x1 - str r2, [r3, 0x8] - ldrb r1, [r2] - lsls r1, 8 - orrs r0, r1 - adds r2, 0x1 - str r2, [r3, 0x8] - bx lr - thumb_func_end script_read_halfword - - thumb_func_start script_read_word -@ int script_read_word(script_env *env) -script_read_word: @ 8098E24 - push {r4-r6,lr} - adds r3, r0, 0 - ldr r0, [r3, 0x8] - ldrb r6, [r0] - adds r0, 0x1 - str r0, [r3, 0x8] - ldrb r5, [r0] - adds r2, r0, 0x1 - str r2, [r3, 0x8] - ldrb r4, [r0, 0x1] - adds r1, r2, 0x1 - str r1, [r3, 0x8] - ldrb r0, [r2, 0x1] - adds r1, 0x1 - str r1, [r3, 0x8] - lsls r0, 8 - adds r0, r4 - lsls r0, 8 - adds r0, r5 - lsls r0, 8 - adds r0, r6 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end script_read_word - - thumb_func_start script_env_2_enable -script_env_2_enable: @ 8098E54 - ldr r1, =gUnknown_03000F2C - movs r0, 0x1 - strb r0, [r1] - bx lr - .pool - thumb_func_end script_env_2_enable - - thumb_func_start script_env_2_disable -@ void script_env_2_disable() -script_env_2_disable: @ 8098E60 - ldr r1, =gUnknown_03000F2C - movs r0, 0 - strb r0, [r1] - bx lr - .pool - thumb_func_end script_env_2_disable - - thumb_func_start script_env_2_is_enabled -@ int script_env_2_is_enabled() -script_env_2_is_enabled: @ 8098E6C - ldr r0, =gUnknown_03000F2C - ldrb r0, [r0] - bx lr - .pool - thumb_func_end script_env_2_is_enabled - - thumb_func_start script_env_context_is_running -@ int script_env_context_is_running() -script_env_context_is_running: @ 8098E78 - push {lr} - ldr r0, =gUnknown_03000E38 - ldrb r0, [r0] - cmp r0, 0 - beq _08098E8C - movs r0, 0 - b _08098E8E - .pool -_08098E8C: - movs r0, 0x1 -_08098E8E: - pop {r1} - bx r1 - thumb_func_end script_env_context_is_running - - thumb_func_start script_env_1_init -script_env_1_init: @ 8098E94 - push {lr} - ldr r0, =gUnknown_03000E40 - ldr r1, =gEventScriptCommandFunctionTable - ldr r2, =gUnknown_081DBA08 - bl script_env_init - ldr r1, =gUnknown_03000E38 - movs r0, 0x2 - strb r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end script_env_1_init - - thumb_func_start script_env_2_run_current_script -script_env_2_run_current_script: @ 8098EBC - push {r4,lr} - ldr r4, =gUnknown_03000E38 - ldrb r0, [r4] - cmp r0, 0x2 - beq _08098EF0 - cmp r0, 0x1 - beq _08098EF0 - bl script_env_2_enable - ldr r0, =gUnknown_03000E40 - bl script_main_handler - lsls r0, 24 - cmp r0, 0 - beq _08098EE8 - movs r0, 0x1 - b _08098EF2 - .pool -_08098EE8: - movs r0, 0x2 - strb r0, [r4] - bl script_env_2_disable -_08098EF0: - movs r0, 0 -_08098EF2: - pop {r4} - pop {r1} - bx r1 - thumb_func_end script_env_2_run_current_script - - thumb_func_start ScriptContext1_SetupScript -ScriptContext1_SetupScript: @ 8098EF8 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, =gUnknown_03000E40 - ldr r1, =gEventScriptCommandFunctionTable - ldr r2, =gUnknown_081DBA08 - adds r0, r4, 0 - bl script_env_init - adds r0, r4, 0 - adds r1, r5, 0 - bl script_setup_bytecode_script - bl script_env_2_enable - ldr r1, =gUnknown_03000E38 - movs r0, 0 - strb r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end ScriptContext1_SetupScript - - thumb_func_start script_env_2_set_ctx_paused -script_env_2_set_ctx_paused: @ 8098F30 - ldr r1, =gUnknown_03000E38 - movs r0, 0x1 - strb r0, [r1] - bx lr - .pool - thumb_func_end script_env_2_set_ctx_paused - - thumb_func_start script_env_2_enable_and_set_ctx_running -script_env_2_enable_and_set_ctx_running: @ 8098F3C - push {lr} - ldr r1, =gUnknown_03000E38 - movs r0, 0 - strb r0, [r1] - bl script_env_2_enable - pop {r0} - bx r0 - .pool - thumb_func_end script_env_2_enable_and_set_ctx_running - - thumb_func_start ScriptContext2_RunNewScript -@ void ScriptContext2_RunNewScript(void *script_ptr) -ScriptContext2_RunNewScript: @ 8098F50 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, =gUnknown_03000EB8 - ldr r1, =gEventScriptCommandFunctionTable - ldr r2, =gUnknown_081DBA08 - adds r0, r4, 0 - bl script_env_init - adds r0, r4, 0 - adds r1, r5, 0 - bl script_setup_bytecode_script -_08098F68: - ldr r0, =gUnknown_03000EB8 - bl script_main_handler - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08098F68 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end ScriptContext2_RunNewScript - - thumb_func_start mapheader_get_tagged_pointer -mapheader_get_tagged_pointer: @ 8098F88 - push {lr} - lsls r0, 24 - lsrs r1, r0, 24 - ldr r0, =gMapHeader - ldr r2, [r0, 0x8] - cmp r2, 0 - beq _08098F9C -_08098F96: - ldrb r0, [r2] - cmp r0, 0 - bne _08098FA4 -_08098F9C: - movs r0, 0 - b _08098FC2 - .pool -_08098FA4: - cmp r0, r1 - beq _08098FAC - adds r2, 0x5 - b _08098F96 -_08098FAC: - adds r2, 0x1 - ldrb r0, [r2] - ldrb r1, [r2, 0x1] - lsls r1, 8 - adds r0, r1 - ldrb r1, [r2, 0x2] - lsls r1, 16 - adds r0, r1 - ldrb r1, [r2, 0x3] - lsls r1, 24 - adds r0, r1 -_08098FC2: - pop {r1} - bx r1 - thumb_func_end mapheader_get_tagged_pointer - - thumb_func_start mapheader_run_script_by_tag -mapheader_run_script_by_tag: @ 8098FC8 - push {lr} - lsls r0, 24 - lsrs r0, 24 - bl mapheader_get_tagged_pointer - cmp r0, 0 - beq _08098FDA - bl ScriptContext2_RunNewScript -_08098FDA: - pop {r0} - bx r0 - thumb_func_end mapheader_run_script_by_tag - - thumb_func_start mapheader_get_first_match_from_tagged_ptr_list -@ int mapheader_get_first_match_from_tagged_ptr_list(int tag) -mapheader_get_first_match_from_tagged_ptr_list: @ 8098FE0 - push {r4-r6,lr} - lsls r0, 24 - lsrs r0, 24 - bl mapheader_get_tagged_pointer - adds r6, r0, 0 - cmp r6, 0 - beq _08098FFC -_08098FF0: - ldrb r1, [r6] - ldrb r0, [r6, 0x1] - lsls r0, 8 - orrs r1, r0 - cmp r1, 0 - bne _08099000 -_08098FFC: - movs r0, 0 - b _0809903A -_08099000: - adds r6, 0x2 - ldrb r5, [r6] - ldrb r0, [r6, 0x1] - lsls r0, 8 - orrs r5, r0 - adds r6, 0x2 - adds r0, r1, 0 - bl VarGet - adds r4, r0, 0 - adds r0, r5, 0 - bl VarGet - lsls r4, 16 - lsls r0, 16 - cmp r4, r0 - beq _08099026 - adds r6, 0x4 - b _08098FF0 -_08099026: - ldrb r0, [r6] - ldrb r1, [r6, 0x1] - lsls r1, 8 - adds r0, r1 - ldrb r1, [r6, 0x2] - lsls r1, 16 - adds r0, r1 - ldrb r1, [r6, 0x3] - lsls r1, 24 - adds r0, r1 -_0809903A: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end mapheader_get_first_match_from_tagged_ptr_list - - thumb_func_start mapheader_run_script_with_tag_x1 -mapheader_run_script_with_tag_x1: @ 8099040 - push {lr} - movs r0, 0x1 - bl mapheader_run_script_by_tag - pop {r0} - bx r0 - thumb_func_end mapheader_run_script_with_tag_x1 - - thumb_func_start mapheader_run_script_with_tag_x3 -mapheader_run_script_with_tag_x3: @ 809904C - push {lr} - movs r0, 0x3 - bl mapheader_run_script_by_tag - pop {r0} - bx r0 - thumb_func_end mapheader_run_script_with_tag_x3 - - thumb_func_start mapheader_run_script_with_tag_x5 -mapheader_run_script_with_tag_x5: @ 8099058 - push {lr} - movs r0, 0x5 - bl mapheader_run_script_by_tag - pop {r0} - bx r0 - thumb_func_end mapheader_run_script_with_tag_x5 - - thumb_func_start mapheader_run_script_with_tag_x7 -mapheader_run_script_with_tag_x7: @ 8099064 - push {lr} - movs r0, 0x7 - bl mapheader_run_script_by_tag - pop {r0} - bx r0 - thumb_func_end mapheader_run_script_with_tag_x7 - - thumb_func_start mapheader_run_script_with_tag_x6 -mapheader_run_script_with_tag_x6: @ 8099070 - push {lr} - movs r0, 0x6 - bl mapheader_run_script_by_tag - pop {r0} - bx r0 - thumb_func_end mapheader_run_script_with_tag_x6 - - thumb_func_start mapheader_run_first_tag2_script_list_match -@ int mapheader_run_first_tag2_script_list_match() -mapheader_run_first_tag2_script_list_match: @ 809907C - push {lr} - movs r0, 0x2 - bl mapheader_get_first_match_from_tagged_ptr_list - cmp r0, 0 - beq _08099090 - bl ScriptContext1_SetupScript - movs r0, 0x1 - b _08099092 -_08099090: - movs r0, 0 -_08099092: - pop {r1} - bx r1 - thumb_func_end mapheader_run_first_tag2_script_list_match - - thumb_func_start mapheader_run_first_tag4_script_list_match -@ void mapheader_run_first_tag4_script_list_match() -mapheader_run_first_tag4_script_list_match: @ 8099098 - push {lr} - movs r0, 0x4 - bl mapheader_get_first_match_from_tagged_ptr_list - cmp r0, 0 - beq _080990A8 - bl ScriptContext2_RunNewScript -_080990A8: - pop {r0} - bx r0 - thumb_func_end mapheader_run_first_tag4_script_list_match - - thumb_func_start sub_80990AC -sub_80990AC: @ 80990AC - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x0000372c - adds r0, r1 - movs r1, 0xFA - lsls r1, 2 - bl CalcCRC16WithTable - lsls r0, 16 - lsrs r0, 16 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80990AC - - thumb_func_start killram -killram: @ 80990D0 - push {lr} - sub sp, 0x4 - movs r0, 0 - str r0, [sp] - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r0, =0x00003728 - adds r1, r0 - ldr r2, =0x050000fb - mov r0, sp - bl CpuSet - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end killram - - thumb_func_start sub_80990FC -sub_80990FC: @ 80990FC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - str r0, [sp] - ldr r0, [sp, 0x24] - lsls r1, 16 - lsrs r1, 16 - mov r8, r1 - lsls r2, 24 - lsrs r2, 24 - mov r9, r2 - lsls r3, 24 - lsrs r7, r3, 24 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =gSaveBlock1Ptr - mov r10, r0 - ldr r5, [r0] - ldr r1, =0x0000372c - adds r4, r5, r1 - bl killram - ldr r0, =0x000003e3 - cmp r8, r0 - bhi _08099174 - movs r0, 0x33 - strb r0, [r4] - mov r2, r9 - strb r2, [r4, 0x1] - strb r7, [r4, 0x2] - strb r6, [r4, 0x3] - ldr r1, =0x00003730 - adds r0, r5, r1 - ldr r1, [sp] - mov r2, r8 - bl memcpy - bl sub_80990AC - mov r2, r10 - ldr r1, [r2] - ldr r2, =0x00003728 - adds r1, r2 - str r0, [r1] - movs r0, 0x1 - b _08099176 - .pool -_08099174: - movs r0, 0 -_08099176: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80990FC - - thumb_func_start sub_8099188 -@ u32 sub_8099188(u8 a1, u32 script) -sub_8099188: @ 8099188 - push {r4-r7,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r3, r0, 24 - ldr r6, =gSaveBlock1Ptr - ldr r5, [r6] - ldr r0, =0x0000372c - adds r2, r5, r0 - ldr r7, =gUnknown_020375C0 - movs r0, 0 - str r0, [r7] - ldrb r0, [r2] - cmp r0, 0x33 - bne _080991F0 - ldrb r1, [r2, 0x1] - movs r0, 0x4 - ldrsb r0, [r5, r0] - cmp r1, r0 - bne _080991F0 - ldrb r1, [r2, 0x2] - movs r0, 0x5 - ldrsb r0, [r5, r0] - cmp r1, r0 - bne _080991F0 - ldrb r0, [r2, 0x3] - cmp r0, r3 - bne _080991F0 - bl sub_80990AC - ldr r1, [r6] - ldr r2, =0x00003728 - adds r1, r2 - ldr r1, [r1] - cmp r0, r1 - bne _080991EC - str r4, [r7] - ldr r1, =0x00003730 - adds r0, r5, r1 - b _080991F2 - .pool -_080991EC: - bl killram -_080991F0: - adds r0, r4, 0 -_080991F2: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_8099188 - - thumb_func_start sub_80991F8 -sub_80991F8: @ 80991F8 - push {r4,lr} - ldr r4, =gSaveBlock1Ptr - ldr r0, [r4] - ldr r2, =0x0000372c - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0x33 - bne _0809923C - ldrb r0, [r1, 0x1] - cmp r0, 0xFF - bne _0809923C - ldrb r0, [r1, 0x2] - cmp r0, 0xFF - bne _0809923C - ldrb r0, [r1, 0x3] - cmp r0, 0xFF - bne _0809923C - bl sub_80990AC - ldr r1, [r4] - ldr r2, =0x00003728 - adds r1, r2 - ldr r1, [r1] - cmp r0, r1 - bne _0809923C - movs r0, 0x1 - b _0809923E - .pool -_0809923C: - movs r0, 0 -_0809923E: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80991F8 - - thumb_func_start sub_8099244 -sub_8099244: @ 8099244 - push {r4-r6,lr} - ldr r6, =gSaveBlock1Ptr - ldr r5, [r6] - ldr r0, =0x0000372c - adds r4, r5, r0 - bl sub_801B27C - cmp r0, 0 - beq _08099298 - ldrb r0, [r4] - cmp r0, 0x33 - bne _08099298 - ldrb r0, [r4, 0x1] - cmp r0, 0xFF - bne _08099298 - ldrb r0, [r4, 0x2] - cmp r0, 0xFF - bne _08099298 - ldrb r0, [r4, 0x3] - cmp r0, 0xFF - bne _08099298 - bl sub_80990AC - ldr r1, [r6] - ldr r2, =0x00003728 - adds r1, r2 - ldr r1, [r1] - cmp r0, r1 - bne _08099294 - ldr r1, =0x00003730 - adds r0, r5, r1 - b _0809929A - .pool -_08099294: - bl killram -_08099298: - movs r0, 0 -_0809929A: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8099244 - - thumb_func_start sub_80992A0 -sub_80992A0: @ 80992A0 - push {lr} - sub sp, 0x4 - adds r2, r0, 0 - lsls r1, 16 - lsrs r1, 16 - ldr r0, =0x000003e3 - cmp r1, r0 - bls _080992B2 - adds r1, r0, 0 -_080992B2: - movs r0, 0xFF - str r0, [sp] - adds r0, r2, 0 - movs r2, 0xFF - movs r3, 0xFF - bl sub_80990FC - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80992A0 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/script_menu.s b/asm/script_menu.s index 41e4dcec8..6c5e6d2bd 100644 --- a/asm/script_menu.s +++ b/asm/script_menu.s @@ -371,7 +371,7 @@ _080E20EC: bl sub_80E2A78 adds r0, r6, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _080E20FC: pop {r4-r6} pop {r0} @@ -477,7 +477,7 @@ _080E21B8: _080E21BA: adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _080E21C4: pop {r4} pop {r0} @@ -668,7 +668,7 @@ _080E2350: bl sub_80E2A78 adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _080E2360: pop {r4,r5} pop {r0} diff --git a/asm/script_pokemon_util_80F87D8.s b/asm/script_pokemon_util_80F87D8.s index b8c618635..c0bcb5a6e 100644 --- a/asm/script_pokemon_util_80F87D8.s +++ b/asm/script_pokemon_util_80F87D8.s @@ -1063,7 +1063,7 @@ sub_80F9088: @ 80F9088 lsrs r0, 24 cmp r0, 0x1 bne _080F90D4 - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r5, 0 bl DestroyTask b _080F90D4 diff --git a/asm/secret_base.s b/asm/secret_base.s index 8c105ced6..286033edd 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -765,7 +765,7 @@ sub_80E90C8: @ 80E90C8 lsrs r0, 24 cmp r0, 0x1 bne _080E90F8 - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r4, 0 bl DestroyTask _080E90F8: @@ -779,7 +779,7 @@ _080E90F8: sub_80E9108: @ 80E9108 push {r4,lr} sub sp, 0x4 - bl script_env_2_enable + bl ScriptContext2_Enable bl HideMapNamePopUpWindow mov r4, sp adds r4, 0x2 @@ -1467,7 +1467,7 @@ _080E96CC: beq _080E96F4 b _080E9714 _080E96D2: - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0x1 strh r0, [r4, 0x8] b _080E9714 @@ -1491,7 +1491,7 @@ _080E96F4: str r1, [r0] ldr r0, =c2_load_new_map bl SetMainCallback2 - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r5, 0 bl DestroyTask _080E9714: @@ -2171,7 +2171,7 @@ sub_80E9C9C: @ 80E9C9C ldr r0, =gTasks + 0x8 mov r8, r0 adds r5, r7, r0 - bl script_env_2_enable + bl ScriptContext2_Enable bl sub_80E9BA8 lsls r0, 24 lsrs r0, 24 diff --git a/asm/shop.s b/asm/shop.s index a7ec60c54..e5be4cd20 100644 --- a/asm/shop.s +++ b/asm/shop.s @@ -13,7 +13,7 @@ CreateShopMenu: @ 80DFA78 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r5, =gUnknown_02039F60 strb r4, [r5, 0xF] cmp r4, 0 @@ -251,7 +251,7 @@ HandleShopMenuQuit: @ 80DFC68 ldrb r0, [r5, 0xE] bl RemoveWindow bl SaveRecordedItemPurchasesForTVShow - bl script_env_2_disable + bl ScriptContext2_Disable adds r0, r4, 0 bl DestroyTask ldr r5, [r5] @@ -2812,7 +2812,7 @@ CreatePokemartMenu: @ 80E1284 adds r0, r4, 0 bl SetShopItemsForSale bl ClearItemPurchases - ldr r0, =script_env_2_enable_and_set_ctx_running + ldr r0, =EnableBothScriptContexts bl SetShopMenuCallback pop {r4} pop {r0} @@ -2829,7 +2829,7 @@ CreateDecorationShop1Menu: @ 80E12A8 bl CreateShopMenu adds r0, r4, 0 bl SetShopItemsForSale - ldr r0, =script_env_2_enable_and_set_ctx_running + ldr r0, =EnableBothScriptContexts bl SetShopMenuCallback pop {r4} pop {r0} @@ -2846,7 +2846,7 @@ CreateDecorationShop2Menu: @ 80E12C8 bl CreateShopMenu adds r0, r4, 0 bl SetShopItemsForSale - ldr r0, =script_env_2_enable_and_set_ctx_running + ldr r0, =EnableBothScriptContexts bl SetShopMenuCallback pop {r4} pop {r0} diff --git a/asm/start_menu.s b/asm/start_menu.s index 44d477050..f71df1046 100644 --- a/asm/start_menu.s +++ b/asm/start_menu.s @@ -362,7 +362,7 @@ sub_809FA9C: @ 809FA9C _0809FAB2: ldr r0, =sub_809FA34 bl sub_809F9D0 - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 .pool @@ -731,7 +731,7 @@ sub_809FDD4: @ 809FDD4 bl sub_80984F4 ldr r0, =sub_809FA34 bl sub_809F9D0 - bl script_env_2_enable + bl ScriptContext2_Enable pop {r0} bx r0 .pool @@ -805,7 +805,7 @@ _0809FE7C: movs r1, 0x1 bl sub_8197DF8 bl sub_80984F4 - bl script_env_2_disable + bl ScriptContext2_Disable bl sub_81A9EC8 movs r0, 0x1 b _0809FE96 @@ -867,7 +867,7 @@ _0809FF00: movs r1, 0x1 bl sub_8197DF8 bl sub_80984F4 - bl script_env_2_disable + bl ScriptContext2_Disable ldr r0, =gUnknown_08252C88 bl ScriptContext1_SetupScript movs r0, 0x1 @@ -985,7 +985,7 @@ _0809FFFC: _080A0000: adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _080A000A: pop {r4} pop {r0} @@ -2022,7 +2022,7 @@ sub_80A08A4: @ 80A08A4 bne _080A08C0 adds r0, r4, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts _080A08C0: pop {r4} pop {r0} @@ -2072,7 +2072,7 @@ sub_80A0914: @ 80A0914 bl sub_819746C bl remove_start_menu_window_maybe bl sub_80984F4 - bl script_env_2_disable + bl ScriptContext2_Disable pop {r0} bx r0 thumb_func_end sub_80A0914 diff --git a/asm/trade.s b/asm/trade.s index bccb4b04a..6a46acb8c 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -14165,7 +14165,7 @@ _0807F0BE: sub_807F0E4: @ 807F0E4 push {lr} sub sp, 0x4 - bl script_env_2_enable + bl ScriptContext2_Enable ldr r0, =sub_807F110 movs r1, 0xA bl CreateTask diff --git a/asm/trader.s b/asm/trader.s index b5d8d47bc..bddf53324 100644 --- a/asm/trader.s +++ b/asm/trader.s @@ -257,7 +257,7 @@ _08133C18: bl schedule_bg_copy_tilemap_to_vram adds r0, r5, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r4,r5} pop {r0} bx r0 @@ -468,7 +468,7 @@ _08133DFC: _08133E04: adds r0, r6, 0 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r4-r6} pop {r0} bx r0 @@ -484,7 +484,7 @@ sub_8133E1C: @ 8133E1C movs r1, 0 strh r1, [r2] bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 .pool diff --git a/asm/trainer_see.s b/asm/trainer_see.s index 3b0fb7a7b..cd9715a5c 100644 --- a/asm/trainer_see.s +++ b/asm/trainer_see.s @@ -1282,7 +1282,7 @@ sub_80B45BC: @ 80B45BC lsls r0, 24 lsrs r0, 24 bl DestroyTask - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts pop {r0} bx r0 thumb_func_end sub_80B45BC diff --git a/asm/truck_scene.s b/asm/truck_scene.s index b9e9f1b35..bc3388cb6 100644 --- a/asm/truck_scene.s +++ b/asm/truck_scene.s @@ -503,7 +503,7 @@ _080FB492: bl PlaySE adds r0, r5, 0 bl DestroyTask - bl script_env_2_disable + bl ScriptContext2_Disable _080FB4D8: pop {r4,r5} pop {r0} @@ -527,7 +527,7 @@ sub_80FB4E0: @ 80FB4E0 movs r1, 0xA bl MapGridSetMetatileIdAt bl DrawWholeMapView - bl script_env_2_enable + bl ScriptContext2_Enable movs r0, 0 str r0, [sp] ldr r1, =gPlttBufferFaded diff --git a/asm/weather.s b/asm/weather.s index 769d77c6b..6612fd66c 100644 --- a/asm/weather.s +++ b/asm/weather.s @@ -3127,7 +3127,7 @@ _080AC910: strh r0, [r4, 0x8] b _080AC922 _080AC918: - bl script_env_2_enable_and_set_ctx_running + bl EnableBothScriptContexts adds r0, r5, 0 bl DestroyTask _080AC922: diff --git a/data/data3.s b/data/data3.s index 8e223c9f6..dac15b02e 100644 --- a/data/data3.s +++ b/data/data3.s @@ -1208,7 +1208,7 @@ gUnknown_0851017C:: @ 851017C gUnknown_0851021C:: @ 851021C .incbin "baserom.gba", 0x51021c, 0xa0 -gUnknown_085102BC:: @ 85102BC +gNullScriptPtr:: @ 85102BC .incbin "baserom.gba", 0x5102bc, 0x4 gUnknown_085102C0:: @ 85102C0 diff --git a/data/event_script_command_function_table.inc b/data/event_script_command_function_table.inc index 835e58f05..f44cdb7db 100644 --- a/data/event_script_command_function_table.inc +++ b/data/event_script_command_function_table.inc @@ -1,5 +1,5 @@ .align 2 -gEventScriptCommandFunctionTable:: @ 81DB67C +gScriptCmdTable:: @ 81DB67C .4byte s00_nop .4byte s01_nop .4byte s02_end diff --git a/data/event_scripts.s b/data/event_scripts.s index 3bfd9fdfd..cef599407 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -6,7 +6,7 @@ @ 81DB67C .include "data/event_script_command_function_table.inc" -gUnknown_081DBA08:: @ 81DBA08 +gScriptCmdTableEnd:: @ 81DBA08 .incbin "baserom.gba", 0x1dba08, 0x4 gSpecialVars:: @ 81DBA0C diff --git a/include/script.h b/include/script.h index 2a738698c..ec6a212bc 100644 --- a/include/script.h +++ b/include/script.h @@ -23,9 +23,9 @@ struct ScriptContext void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, void *cmdTableEnd); u8 SetupBytecodeScript(struct ScriptContext *ctx, const u8 *ptr); -void SetupNativeScript(struct ScriptContext *ctx, void *ptr); +void SetupNativeScript(struct ScriptContext *ctx, bool8 (*ptr)(void)); void StopScript(struct ScriptContext *ctx); -u8 RunScriptCommand(struct ScriptContext *ctx); +bool8 RunScriptCommand(struct ScriptContext *ctx); u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr); const u8 *ScriptPop(struct ScriptContext *ctx); void ScriptJump(struct ScriptContext *ctx, u8 *ptr); @@ -37,6 +37,7 @@ void ScriptContext2_Enable(void); void ScriptContext2_Disable(void); bool8 ScriptContext2_IsEnabled(void); void ScriptContext1_Init(void); +bool8 ScriptContext1_IsScriptSetUp(void); bool8 ScriptContext2_RunScript(void); void ScriptContext1_SetupScript(const u8 *ptr); void ScriptContext1_Stop(void); @@ -48,6 +49,7 @@ u8 *mapheader_get_first_match_from_tagged_ptr_list(u8 tag); void mapheader_run_script_with_tag_x1(void); void mapheader_run_script_with_tag_x3(void); void mapheader_run_script_with_tag_x5(void); +void mapheader_run_script_with_tag_x7(void); void mapheader_run_script_with_tag_x6(void); bool8 mapheader_run_first_tag2_script_list_match(void); void mapheader_run_first_tag4_script_list_match(void); @@ -55,5 +57,8 @@ u32 CalculateRamScriptChecksum(void); void ClearRamScript(void); bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId); u8 *GetRamScript(u8 objectId, u8 *script); +bool32 sub_80991F8(void); +u8 *sub_8099244(void); +void sub_80992A0(u8 *script, u16 scriptSize); #endif // GUARD_SCRIPT_H diff --git a/include/util.h b/include/util.h new file mode 100644 index 000000000..69ef329ad --- /dev/null +++ b/include/util.h @@ -0,0 +1,15 @@ +#ifndef GUARD_UTIL_H +#define GUARD_UTIL_H + +#include "sprite.h" + +extern const u8 gMiscBlank_Gfx[]; +extern const u32 gBitTable[]; + +u8 CreateInvisibleSpriteWithCallback(void (*)(struct Sprite *)); +void StoreWordInTwoHalfwords(u16 *, u32); +void LoadWordFromTwoHalfwords(u16 *, u32 *); +u16 CalcCRC16(u8 *data, s32 length); +u16 CalcCRC16WithTable(u8 *data, s32 length); + +#endif // GUARD_UTIL_H diff --git a/ld_script.txt b/ld_script.txt index d4af583ba..584a57c6f 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -99,7 +99,7 @@ SECTIONS { asm/field_message_box.o(.text); asm/map_obj_lock.o(.text); src/text_window.o(.text); - asm/script.o(.text); + src/script.o(.text); asm/scrcmd.o(.text); asm/field_control_avatar.o(.text); src/event_data.o(.text); diff --git a/src/safari_zone.c b/src/safari_zone.c index 37ee664cd..fdfdd961a 100644 --- a/src/safari_zone.c +++ b/src/safari_zone.c @@ -34,7 +34,7 @@ extern void c2_exit_to_overworld_2_switch(void); extern void c2_exit_to_overworld_1_continue_scripts_restart_music(void); extern void c2_load_new_map(void); extern void sub_80AF6F0(void); -extern void script_env_2_set_ctx_paused(void); +extern void ScriptContext1_Stop(void); extern void warp_in(void); extern void GetXYCoordsOneStepInFrontOfPlayer(s16* x, s16* y); extern void PlayerGetDestCoords(s16* x, s16* y); @@ -124,7 +124,7 @@ void sub_80FC190(void) else if (gBattleOutcome == BATTLE_CAUGHT) { ScriptContext1_SetupScript(gUnknown_082A4B9B); - script_env_2_set_ctx_paused(); + ScriptContext1_Stop(); SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); } } diff --git a/src/script.c b/src/script.c new file mode 100644 index 000000000..b1847f38b --- /dev/null +++ b/src/script.c @@ -0,0 +1,434 @@ +#include "global.h" +#include "script.h" +#include "event_data.h" +#include "util.h" + +#define RAM_SCRIPT_MAGIC 51 + +extern u8* gUnknown_020375C0; + +extern bool32 sub_801B27C(void); + +// ewram bss +IWRAM_DATA u8 sScriptContext1Status; +IWRAM_DATA u32 sUnusedVariable1; +IWRAM_DATA struct ScriptContext sScriptContext1; +IWRAM_DATA u32 sUnusedVariable2; +IWRAM_DATA struct ScriptContext sScriptContext2; +IWRAM_DATA bool8 sScriptContext2Enabled; + +extern ScrCmdFunc gScriptCmdTable[]; +extern ScrCmdFunc gScriptCmdTableEnd[]; +extern void *gNullScriptPtr; + +void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, void *cmdTableEnd) +{ + s32 i; + + ctx->mode = 0; + ctx->scriptPtr = 0; + ctx->stackDepth = 0; + ctx->nativePtr = 0; + ctx->cmdTable = cmdTable; + ctx->cmdTableEnd = cmdTableEnd; + + for (i = 0; i < 4; i++) + ctx->data[i] = 0; + + for (i = 0; i < 20; i++) + ctx->stack[i] = 0; +} + +u8 SetupBytecodeScript(struct ScriptContext *ctx, const u8 *ptr) +{ + ctx->scriptPtr = ptr; + ctx->mode = 1; + return 1; +} + +void SetupNativeScript(struct ScriptContext *ctx, bool8 (*ptr)(void)) +{ + ctx->mode = 2; + ctx->nativePtr = ptr; +} + +void StopScript(struct ScriptContext *ctx) +{ + ctx->mode = 0; + ctx->scriptPtr = 0; +} + +bool8 RunScriptCommand(struct ScriptContext *ctx) +{ + if (ctx->mode == 0) + return FALSE; + + switch (ctx->mode) + { + case 0: + return FALSE; + case 2: + if (ctx->nativePtr) + { + if (ctx->nativePtr() == TRUE) + ctx->mode = 1; + return TRUE; + } + ctx->mode = 1; + case 1: + while (1) + { + u8 cmdCode; + ScrCmdFunc *func; + + if (!ctx->scriptPtr) + { + ctx->mode = 0; + return FALSE; + } + + if (ctx->scriptPtr == gNullScriptPtr) + { + while (1) + asm("svc 2"); // HALT + } + + cmdCode = *(ctx->scriptPtr); + ctx->scriptPtr++; + func = &ctx->cmdTable[cmdCode]; + + if (func >= ctx->cmdTableEnd) + { + ctx->mode = 0; + return FALSE; + } + + if ((*func)(ctx) == 1) + return TRUE; + } + } + + return TRUE; +} + +u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr) +{ + if (ctx->stackDepth + 1 >= 20) + { + return 1; + } + else + { + ctx->stack[ctx->stackDepth] = ptr; + ctx->stackDepth++; + return 0; + } +} + +const u8 *ScriptPop(struct ScriptContext *ctx) +{ + if (ctx->stackDepth == 0) + return NULL; + + ctx->stackDepth--; + return ctx->stack[ctx->stackDepth]; +} + +void ScriptJump(struct ScriptContext *ctx, u8 *ptr) +{ + ctx->scriptPtr = ptr; +} + +void ScriptCall(struct ScriptContext *ctx, u8 *ptr) +{ + ScriptPush(ctx, ctx->scriptPtr); + ctx->scriptPtr = ptr; +} + +void ScriptReturn(struct ScriptContext *ctx) +{ + ctx->scriptPtr = ScriptPop(ctx); +} + +u16 ScriptReadHalfword(struct ScriptContext *ctx) +{ + u16 value = *(ctx->scriptPtr++); + value |= *(ctx->scriptPtr++) << 8; + return value; +} + +u32 ScriptReadWord(struct ScriptContext *ctx) +{ + u32 value0 = *(ctx->scriptPtr++); + u32 value1 = *(ctx->scriptPtr++); + u32 value2 = *(ctx->scriptPtr++); + u32 value3 = *(ctx->scriptPtr++); + return (((((value3 << 8) + value2) << 8) + value1) << 8) + value0; +} + +void ScriptContext2_Enable(void) +{ + sScriptContext2Enabled = TRUE; +} + +void ScriptContext2_Disable(void) +{ + sScriptContext2Enabled = FALSE; +} + +bool8 ScriptContext2_IsEnabled(void) +{ + return sScriptContext2Enabled; +} + +bool8 ScriptContext1_IsScriptSetUp(void) +{ + if (sScriptContext1Status == 0) + return TRUE; + else + return FALSE; +} + +void ScriptContext1_Init(void) +{ + InitScriptContext(&sScriptContext1, gScriptCmdTable, gScriptCmdTableEnd); + sScriptContext1Status = 2; +} + +bool8 ScriptContext2_RunScript(void) +{ + if (sScriptContext1Status == 2) + return 0; + + if (sScriptContext1Status == 1) + return 0; + + ScriptContext2_Enable(); + + if (!RunScriptCommand(&sScriptContext1)) + { + sScriptContext1Status = 2; + ScriptContext2_Disable(); + return 0; + } + + return 1; +} + +void ScriptContext1_SetupScript(const u8 *ptr) +{ + InitScriptContext(&sScriptContext1, gScriptCmdTable, gScriptCmdTableEnd); + SetupBytecodeScript(&sScriptContext1, ptr); + ScriptContext2_Enable(); + sScriptContext1Status = 0; +} + +void ScriptContext1_Stop(void) +{ + sScriptContext1Status = 1; +} + +void EnableBothScriptContexts(void) +{ + sScriptContext1Status = 0; + ScriptContext2_Enable(); +} + +void ScriptContext2_RunNewScript(const u8 *ptr) +{ + InitScriptContext(&sScriptContext2, &gScriptCmdTable, &gScriptCmdTableEnd); + SetupBytecodeScript(&sScriptContext2, ptr); + while (RunScriptCommand(&sScriptContext2) == TRUE); +} + +u8 *mapheader_get_tagged_pointer(u8 tag) +{ + u8 *mapScripts = gMapHeader.mapScripts; + + if (!mapScripts) + return NULL; + + while (1) + { + if (!*mapScripts) + return NULL; + if (*mapScripts == tag) + { + mapScripts++; + return (u8 *)(mapScripts[0] + (mapScripts[1] << 8) + (mapScripts[2] << 16) + (mapScripts[3] << 24)); + } + mapScripts += 5; + } +} + +void mapheader_run_script_by_tag(u8 tag) +{ + u8 *ptr = mapheader_get_tagged_pointer(tag); + if (ptr) + ScriptContext2_RunNewScript(ptr); +} + +u8 *mapheader_get_first_match_from_tagged_ptr_list(u8 tag) +{ + u8 *ptr = mapheader_get_tagged_pointer(tag); + + if (!ptr) + return NULL; + + while (1) + { + u16 varIndex1; + u16 varIndex2; + varIndex1 = ptr[0] | (ptr[1] << 8); + if (!varIndex1) + return NULL; + ptr += 2; + varIndex2 = ptr[0] | (ptr[1] << 8); + ptr += 2; + if (VarGet(varIndex1) == VarGet(varIndex2)) + return (u8 *)(ptr[0] + (ptr[1] << 8) + (ptr[2] << 16) + (ptr[3] << 24)); + ptr += 4; + } +} + +void mapheader_run_script_with_tag_x1(void) +{ + mapheader_run_script_by_tag(1); +} + +void mapheader_run_script_with_tag_x3(void) +{ + mapheader_run_script_by_tag(3); +} + +void mapheader_run_script_with_tag_x5(void) +{ + mapheader_run_script_by_tag(5); +} + +void mapheader_run_script_with_tag_x7(void) +{ + mapheader_run_script_by_tag(7); +} + +void mapheader_run_script_with_tag_x6(void) +{ + mapheader_run_script_by_tag(6); +} + +bool8 mapheader_run_first_tag2_script_list_match(void) +{ + u8 *ptr = mapheader_get_first_match_from_tagged_ptr_list(2); + + if (!ptr) + return 0; + + ScriptContext1_SetupScript(ptr); + return 1; +} + +void mapheader_run_first_tag4_script_list_match(void) +{ + u8 *ptr = mapheader_get_first_match_from_tagged_ptr_list(4); + if (ptr) + ScriptContext2_RunNewScript(ptr); +} + +u32 CalculateRamScriptChecksum(void) +{ + return CalcCRC16WithTable((u8*)(&gSaveBlock1Ptr->ramScript.data), sizeof(gSaveBlock1Ptr->ramScript.data)); +} + +void ClearRamScript(void) +{ + CpuFill32(0, &gSaveBlock1Ptr->ramScript, sizeof(struct RamScript)); +} + +bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId) +{ + struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data; + + ClearRamScript(); + + if (scriptSize > sizeof(scriptData->script)) + return FALSE; + + scriptData->magic = RAM_SCRIPT_MAGIC; + scriptData->mapGroup = mapGroup; + scriptData->mapNum = mapNum; + scriptData->objectId = objectId; + memcpy(scriptData->script, script, scriptSize); + gSaveBlock1Ptr->ramScript.checksum = CalculateRamScriptChecksum(); + return TRUE; +} + +u8 *GetRamScript(u8 objectId, u8 *script) +{ + struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data; + gUnknown_020375C0 = NULL; + if (scriptData->magic != RAM_SCRIPT_MAGIC) + return script; + if (scriptData->mapGroup != gSaveBlock1Ptr->location.mapGroup) + return script; + if (scriptData->mapNum != gSaveBlock1Ptr->location.mapNum) + return script; + if (scriptData->objectId != objectId) + return script; + if (CalculateRamScriptChecksum() != gSaveBlock1Ptr->ramScript.checksum) + { + ClearRamScript(); + return script; + } + else + { + gUnknown_020375C0 = script; + return scriptData->script; + } +} + +bool32 sub_80991F8(void) +{ + struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data; + if (scriptData->magic != RAM_SCRIPT_MAGIC) + return FALSE; + if (scriptData->mapGroup != 0xFF) + return FALSE; + if (scriptData->mapNum != 0xFF) + return FALSE; + if (scriptData->objectId != 0xFF) + return FALSE; + if (CalculateRamScriptChecksum() != gSaveBlock1Ptr->ramScript.checksum) + return FALSE; + return TRUE; +} + +u8 *sub_8099244(void) +{ + struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data; + if (!sub_801B27C()) + return NULL; + if (scriptData->magic != RAM_SCRIPT_MAGIC) + return NULL; + if (scriptData->mapGroup != 0xFF) + return NULL; + if (scriptData->mapNum != 0xFF) + return NULL; + if (scriptData->objectId != 0xFF) + return NULL; + if (CalculateRamScriptChecksum() != gSaveBlock1Ptr->ramScript.checksum) + { + ClearRamScript(); + return NULL; + } + else + { + return scriptData->script; + } +} + +void sub_80992A0(u8 *script, u16 scriptSize) +{ + if (scriptSize > sizeof(gSaveBlock1Ptr->ramScript.data.script)) + scriptSize = sizeof(gSaveBlock1Ptr->ramScript.data.script); + InitRamScript(script, scriptSize, 0xFF, 0xFF, 0xFF); +} diff --git a/sym_bss.txt b/sym_bss.txt index 12588e445..4a61c2ff1 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -175,18 +175,9 @@ gUnknown_03000E2C: @ 3000E2C gUnknown_03000E30: @ 3000E30 .space 0x8 -gUnknown_03000E38: @ 3000E38 - .space 0x8 - -gUnknown_03000E40: @ 3000E40 - .space 0x78 - -gUnknown_03000EB8: @ 3000EB8 - .space 0x74 - -gUnknown_03000F2C: @ 3000F2C - .space 0x4 +.include "src/script.o" +.align 2 gUnknown_03000F30: @ 3000F30 .space 0x4 From 4d84618732acd1a67f8e15d5464ed20056ba5641 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 12 Sep 2017 10:41:30 +0200 Subject: [PATCH 2/2] make vars static in script s --- src/script.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/script.c b/src/script.c index b1847f38b..b2809a137 100644 --- a/src/script.c +++ b/src/script.c @@ -10,12 +10,12 @@ extern u8* gUnknown_020375C0; extern bool32 sub_801B27C(void); // ewram bss -IWRAM_DATA u8 sScriptContext1Status; -IWRAM_DATA u32 sUnusedVariable1; -IWRAM_DATA struct ScriptContext sScriptContext1; -IWRAM_DATA u32 sUnusedVariable2; -IWRAM_DATA struct ScriptContext sScriptContext2; -IWRAM_DATA bool8 sScriptContext2Enabled; +IWRAM_DATA static u8 sScriptContext1Status; +IWRAM_DATA static u32 sUnusedVariable1; +IWRAM_DATA static struct ScriptContext sScriptContext1; +IWRAM_DATA static u32 sUnusedVariable2; +IWRAM_DATA static struct ScriptContext sScriptContext2; +IWRAM_DATA static bool8 sScriptContext2Enabled; extern ScrCmdFunc gScriptCmdTable[]; extern ScrCmdFunc gScriptCmdTableEnd[];