From e75f0b4f80670bd3b6a28257f10770911869ea08 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Tue, 16 Oct 2018 21:47:08 -0500 Subject: [PATCH] Port/decompile field_control_avatar --- asm/field_control_avatar.s | 2512 ----------------- asm/party_menu.s | 2 +- common_syms/field_control_avatar.txt | 1 + data/event_scripts.s | 42 +- .../events.inc | 2 +- .../scripts.inc | 2 +- .../LittlerootTown_MaysHouse_2F/events.inc | 2 +- .../LittlerootTown_MaysHouse_2F/scripts.inc | 2 +- data/maps/SootopolisCity/scripts.inc | 2 +- data/scripts/cable_club.inc | 16 +- data/scripts/day_care.inc | 2 +- data/scripts/field_move_scripts.inc | 8 +- data/scripts/secret_power_tm.inc | 4 +- data/scripts/tv.inc | 2 +- data/specials.inc | 2 +- include/battle_frontier_1.h | 6 + include/constants/flags.h | 2 +- include/daycare.h | 2 +- include/event_scripts.h | 4 +- include/field_control_avatar.h | 40 +- include/field_player_avatar.h | 3 + include/field_poison.h | 2 +- include/field_screen.h | 4 + include/field_specials.h | 9 + include/fldeff_80F9BCC.h | 2 + include/global.fieldmap.h | 16 +- include/item_menu.h | 1 + include/metatile_behavior.h | 10 +- include/pokemon.h | 43 +- include/pokenav.h | 8 + include/rom_81BE66C.h | 12 - include/script.h | 4 +- include/secret_base.h | 6 + ld_script.txt | 2 +- src/battle_controller_player.c | 2 +- src/battle_controller_player_partner.c | 2 +- src/battle_interface.c | 2 +- src/battle_script_commands.c | 4 +- src/battle_setup.c | 12 +- src/berry.c | 6 +- src/data/pokemon/experience_tables.h | 2 +- src/daycare.c | 6 +- src/event_object_movement.c | 5 +- src/field_control_avatar.c | 1058 +++++++ src/field_poison.c | 2 +- src/field_specials.c | 2 +- src/metatile_behavior.c | 8 +- src/overworld.c | 14 +- src/pokemon.c | 12 +- src/pokemon_summary_screen.c | 4 +- src/rom_8011DC0.c | 2 +- src/scrcmd.c | 6 +- src/script.c | 6 +- src/secret_base.c | 8 +- sym_common.txt | 4 +- sym_ewram.txt | 9 +- 56 files changed, 1277 insertions(+), 2676 deletions(-) delete mode 100644 asm/field_control_avatar.s create mode 100644 common_syms/field_control_avatar.txt create mode 100644 include/battle_frontier_1.h delete mode 100644 include/rom_81BE66C.h create mode 100644 src/field_control_avatar.c diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s deleted file mode 100644 index c299d6633a..0000000000 --- a/asm/field_control_avatar.s +++ /dev/null @@ -1,2512 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start FieldClearPlayerInput -FieldClearPlayerInput: @ 809BEDC - push {r4,r5,lr} - movs r1, 0x2 - negs r1, r1 - movs r3, 0x3 - negs r3, r3 - movs r4, 0x5 - negs r4, r4 - movs r5, 0x9 - negs r5, r5 - movs r2, 0 - strb r2, [r0] - ldrb r2, [r0, 0x1] - ands r1, r2 - ands r1, r3 - ands r1, r4 - ands r1, r5 - strb r1, [r0, 0x1] - movs r1, 0 - strb r1, [r0, 0x2] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end FieldClearPlayerInput - - thumb_func_start FieldGetPlayerInput -@ void FieldGetPlayerInput(overworld_input_data *input_data, char buttons_new, char buttons_held) -FieldGetPlayerInput: @ 809BF08 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r4, r0, 0 - lsls r1, 16 - lsrs r5, r1, 16 - lsls r2, 16 - lsrs r2, 16 - mov r8, r2 - ldr r0, =gPlayerAvatar - ldrb r6, [r0, 0x3] - ldrb r0, [r0, 0x2] - mov r9, r0 - bl cur_mapdata_block_role_at_player_pos - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsForcedMovementTile - lsls r0, 24 - lsrs r7, r0, 24 - cmp r6, 0x2 - bne _0809BF3C - cmp r7, 0 - beq _0809BF40 -_0809BF3C: - cmp r6, 0 - bne _0809BFA2 -_0809BF40: - bl GetPlayerSpeed - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x4 - beq _0809BF8C - movs r0, 0x8 - ands r0, r5 - cmp r0, 0 - beq _0809BF5C - ldrb r0, [r4] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r4] -_0809BF5C: - movs r0, 0x4 - ands r0, r5 - cmp r0, 0 - beq _0809BF6C - ldrb r0, [r4] - movs r1, 0x8 - orrs r0, r1 - strb r0, [r4] -_0809BF6C: - movs r0, 0x1 - ands r0, r5 - cmp r0, 0 - beq _0809BF7C - ldrb r0, [r4] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r4] -_0809BF7C: - movs r0, 0x2 - ands r0, r5 - cmp r0, 0 - beq _0809BF8C - ldrb r0, [r4] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r4] -_0809BF8C: - movs r0, 0xF0 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - beq _0809BFA2 - ldrb r0, [r4] - movs r1, 0x10 - orrs r0, r1 - movs r1, 0x20 - orrs r0, r1 - strb r0, [r4] -_0809BFA2: - cmp r7, 0 - bne _0809BFC8 - cmp r6, 0x2 - bne _0809BFB8 - mov r0, r9 - cmp r0, 0x2 - bne _0809BFB8 - ldrb r0, [r4] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r4] -_0809BFB8: - cmp r7, 0 - bne _0809BFC8 - cmp r6, 0x2 - bne _0809BFC8 - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] -_0809BFC8: - movs r0, 0x40 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - beq _0809BFDC - movs r0, 0x2 - b _0809C004 - .pool -_0809BFDC: - movs r0, 0x80 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - beq _0809BFEA - movs r0, 0x1 - b _0809C004 -_0809BFEA: - movs r0, 0x20 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - beq _0809BFF8 - movs r0, 0x3 - b _0809C004 -_0809BFF8: - movs r0, 0x10 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - beq _0809C006 - movs r0, 0x4 -_0809C004: - strb r0, [r4, 0x2] -_0809C006: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end FieldGetPlayerInput - - thumb_func_start sub_809C014 -@ int sub_809C014(overworld_input_data *input_data) -sub_809C014: @ 809C014 - push {r4-r6,lr} - sub sp, 0x8 - adds r5, r0, 0 - ldr r0, =gSpecialVar_LastTalked - movs r1, 0 - strh r1, [r0] - ldr r0, =gSelectedEventObject - strb r1, [r0] - bl GetPlayerFacingDirection - lsls r0, 24 - lsrs r6, r0, 24 - mov r4, sp - mov r0, sp - bl player_get_pos_to_and_height - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0x2 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 16 - lsrs r4, r0, 16 - bl CheckForTrainersWantingBattle - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C14E - bl mapheader_run_first_tag2_script_list_match - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C14E - ldrb r1, [r5] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0809C070 - bl sub_809C89C - cmp r0, 0x1 - beq _0809C14E -_0809C070: - ldrb r1, [r5] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0809C096 - movs r0, 0x5 - bl IncrementGameStat - bl increment_var_x4026_on_birth_island_modulo_100 - mov r0, sp - adds r1, r4, 0 - adds r2, r6, 0 - bl sub_809C8DC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C14E -_0809C096: - ldrb r1, [r5] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0809C0AE - adds r0, r4, 0 - bl is_it_battle_time_3 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C14E -_0809C0AE: - ldrb r1, [r5] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _0809C0D0 - ldrb r0, [r5, 0x2] - cmp r0, r6 - bne _0809C0D0 - mov r0, sp - adds r1, r4, 0 - adds r2, r6, 0 - bl mapheader_run_first_tag2_script_list_match_conditionally - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C14E -_0809C0D0: - mov r4, sp - mov r0, sp - bl player_get_next_pos_and_height - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0x2 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 16 - lsrs r4, r0, 16 - ldrb r1, [r5] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0809C106 - mov r0, sp - adds r1, r4, 0 - adds r2, r6, 0 - bl sub_809C1FC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C14E -_0809C106: - ldrb r1, [r5] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0809C128 - ldrb r0, [r5, 0x2] - cmp r0, r6 - bne _0809C128 - mov r0, sp - adds r1, r4, 0 - adds r2, r6, 0 - bl map_warp_consider_2_to_inside - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C14E -_0809C128: - ldrb r1, [r5] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0809C13A - bl sub_809C868 - cmp r0, 0x1 - beq _0809C14E -_0809C13A: - ldrb r1, [r5] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0809C15C - movs r0, 0x6 - bl PlaySE - bl ShowStartMenu -_0809C14E: - movs r0, 0x1 - b _0809C172 - .pool -_0809C15C: - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - beq _0809C170 - bl UseRegisteredKeyItemOnField - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C14E -_0809C170: - movs r0, 0 -_0809C172: - add sp, 0x8 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_809C014 - - thumb_func_start player_get_pos_to_and_height -player_get_pos_to_and_height: @ 809C17C - push {r4,lr} - adds r4, r0, 0 - adds r1, r4, 0x2 - bl PlayerGetDestCoords - bl PlayerGetZCoord - strb r0, [r4, 0x4] - pop {r4} - pop {r0} - bx r0 - thumb_func_end player_get_pos_to_and_height - - thumb_func_start player_get_next_pos_and_height -player_get_next_pos_and_height: @ 809C194 - push {r4,r5,lr} - sub sp, 0x4 - adds r5, r0, 0 - adds r1, r5, 0x2 - bl GetXYCoordsOneStepInFrontOfPlayer - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl PlayerGetDestCoords - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r4, r2] - bl MapGridGetZCoordAt - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _0809C1C6 - bl PlayerGetZCoord -_0809C1C6: - strb r0, [r5, 0x4] - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end player_get_next_pos_and_height - - thumb_func_start cur_mapdata_block_role_at_player_pos -cur_mapdata_block_role_at_player_pos: @ 809C1D0 - push {r4,lr} - sub sp, 0x4 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl PlayerGetDestCoords - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 16 - lsrs r0, 16 - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end cur_mapdata_block_role_at_player_pos - - thumb_func_start sub_809C1FC -sub_809C1FC: @ 809C1FC - push {r4,lr} - lsls r2, 24 - lsrs r2, 24 - lsls r1, 24 - lsrs r1, 24 - bl TryGetScriptOnPressingA - adds r4, r0, 0 - cmp r4, 0 - bne _0809C214 - movs r0, 0 - b _0809C24C -_0809C214: - ldr r0, =gUnknown_081F860D - cmp r4, r0 - beq _0809C244 - ldr r0, =gUnknown_081F9553 - cmp r4, r0 - beq _0809C244 - ldr r0, =gUnknown_0823B4BB - cmp r4, r0 - beq _0809C244 - ldr r0, =gUnknown_0823B589 - cmp r4, r0 - beq _0809C244 - ldr r0, =EventScript_2766A2 - cmp r4, r0 - beq _0809C244 - ldr r0, =EventScript_2766A6 - cmp r4, r0 - beq _0809C244 - ldr r0, =EventScript_271D92 - cmp r4, r0 - beq _0809C244 - movs r0, 0x5 - bl PlaySE -_0809C244: - adds r0, r4, 0 - bl ScriptContext1_SetupScript - movs r0, 0x1 -_0809C24C: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_809C1FC - - thumb_func_start TryGetScriptOnPressingA -TryGetScriptOnPressingA: @ 809C270 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - lsls r1, 24 - lsrs r5, r1, 24 - mov r8, r5 - lsls r2, 24 - lsrs r4, r2, 24 - adds r7, r4, 0 - adds r1, r5, 0 - adds r2, r4, 0 - bl TryGetEventObjectScript - cmp r0, 0 - bne _0809C2BC - adds r0, r6, 0 - adds r1, r5, 0 - adds r2, r4, 0 - bl TryGetInvisibleEventObjectScript - cmp r0, 0 - bne _0809C2BC - adds r0, r6, 0 - adds r1, r5, 0 - adds r2, r4, 0 - bl TryGetMetatileBehaviorScript - cmp r0, 0 - bne _0809C2BC - adds r0, r6, 0 - mov r1, r8 - adds r2, r7, 0 - bl TryGetFieldMoveScript - cmp r0, 0 - bne _0809C2BC - movs r0, 0 -_0809C2BC: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end TryGetScriptOnPressingA - - thumb_func_start sub_809C2C8 -sub_809C2C8: @ 809C2C8 - push {r4-r6,lr} - adds r4, r0, 0 - lsls r2, 24 - lsrs r6, r2, 24 - movs r1, 0 - ldrsh r0, [r4, r1] - movs r2, 0x2 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsCounter - lsls r0, 24 - cmp r0, 0 - bne _0809C2F0 - ldrh r0, [r4] - ldrh r1, [r4, 0x2] - b _0809C30E -_0809C2F0: - ldr r1, =gDirectionToVectors - lsls r2, r6, 3 - adds r0, r2, r1 - ldr r3, [r0] - ldrh r0, [r4] - adds r0, r3 - lsls r0, 16 - lsrs r0, 16 - adds r1, 0x4 - adds r2, r1 - ldr r2, [r2] - ldrh r1, [r4, 0x2] - adds r1, r2 - lsls r1, 16 - lsrs r1, 16 -_0809C30E: - ldrb r2, [r4, 0x4] - bl GetEventObjectIdByXYZ - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x10 - beq _0809C32E - ldr r1, =gEventObjects - lsls r2, r3, 3 - adds r0, r2, r3 - lsls r0, 2 - adds r0, r1 - ldrb r0, [r0, 0x8] - adds r5, r1, 0 - cmp r0, 0xFF - bne _0809C33C -_0809C32E: - movs r0, 0 - b _0809C36E - .pool -_0809C33C: - movs r4, 0 - ldr r1, =gLinkPlayerEventObjects -_0809C340: - ldrb r0, [r1] - cmp r0, 0x1 - bne _0809C34C - ldrb r0, [r1, 0x2] - cmp r0, r3 - beq _0809C32E -_0809C34C: - adds r1, 0x4 - adds r4, 0x1 - cmp r4, 0x3 - ble _0809C340 - ldr r0, =gSelectedEventObject - strb r3, [r0] - ldr r1, =gSpecialVar_LastTalked - adds r0, r2, r3 - lsls r0, 2 - adds r0, r5 - ldrb r0, [r0, 0x8] - strh r0, [r1] - ldr r0, =gSpecialVar_Facing - strh r6, [r0] - adds r0, r3, 0 - bl GetEventObjectScriptPointerByEventObjectId -_0809C36E: - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_809C2C8 - - thumb_func_start TryGetEventObjectScript -TryGetEventObjectScript: @ 809C384 - push {r4-r7,lr} - adds r5, r0, 0 - lsls r1, 24 - lsrs r6, r1, 24 - lsls r2, 24 - lsrs r7, r2, 24 - ldrh r0, [r5] - ldrh r1, [r5, 0x2] - ldrb r2, [r5, 0x4] - bl GetEventObjectIdByXYZ - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x10 - beq _0809C3B4 - ldr r1, =gEventObjects - lsls r2, r4, 3 - adds r0, r2, r4 - lsls r0, 2 - adds r0, r1 - ldrb r0, [r0, 0x8] - adds r3, r1, 0 - cmp r0, 0xFF - bne _0809C40C -_0809C3B4: - adds r0, r6, 0 - bl MetatileBehavior_IsCounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C400 - ldr r1, =gDirectionToVectors - lsls r2, r7, 3 - adds r0, r2, r1 - ldr r3, [r0] - ldrh r0, [r5] - adds r0, r3 - lsls r0, 16 - lsrs r0, 16 - adds r1, 0x4 - adds r2, r1 - ldr r2, [r2] - ldrh r1, [r5, 0x2] - adds r1, r2 - lsls r1, 16 - lsrs r1, 16 - ldrb r2, [r5, 0x4] - bl GetEventObjectIdByXYZ - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x10 - beq _0809C400 - ldr r1, =gEventObjects - lsls r2, r4, 3 - adds r0, r2, r4 - lsls r0, 2 - adds r0, r1 - ldrb r0, [r0, 0x8] - adds r3, r1, 0 - cmp r0, 0xFF - bne _0809C40C -_0809C400: - movs r0, 0 - b _0809C44E - .pool -_0809C40C: - ldr r0, =gSelectedEventObject - strb r4, [r0] - ldr r1, =gSpecialVar_LastTalked - adds r0, r2, r4 - lsls r0, 2 - adds r0, r3 - ldrb r0, [r0, 0x8] - strh r0, [r1] - ldr r0, =gSpecialVar_Facing - strh r7, [r0] - bl InTrainerHill - cmp r0, 0x1 - bne _0809C43C - bl sub_81D62AC - b _0809C442 - .pool -_0809C43C: - adds r0, r4, 0 - bl GetEventObjectScriptPointerByEventObjectId -_0809C442: - adds r1, r0, 0 - ldr r0, =gSpecialVar_LastTalked - ldrb r0, [r0] - bl GetRamScript - adds r1, r0, 0 -_0809C44E: - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end TryGetEventObjectScript - - thumb_func_start TryGetInvisibleEventObjectScript -@ signed int TryGetInvisibleEventObjectScript(int a1, int a2, u8 playerFacingDirection) -TryGetInvisibleEventObjectScript: @ 809C458 - push {r4,r5,lr} - lsls r2, 24 - lsrs r5, r2, 24 - ldr r4, =gMapHeader - ldrh r1, [r0] - subs r1, 0x7 - lsls r1, 16 - lsrs r1, 16 - ldrh r2, [r0, 0x2] - subs r2, 0x7 - lsls r2, 16 - lsrs r2, 16 - ldrb r3, [r0, 0x4] - adds r0, r4, 0 - bl FindInvisibleEventObjectByPosition - cmp r0, 0 - beq _0809C4CC - ldr r2, [r0, 0x8] - cmp r2, 0 - bne _0809C490 - ldr r0, =EventScript_TestSignpostMsg - b _0809C532 - .pool -_0809C490: - ldrb r0, [r0, 0x5] - cmp r0, 0x8 - bhi _0809C530 - lsls r0, 2 - ldr r1, =_0809C4A4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0809C4A4: - .4byte _0809C530 - .4byte _0809C4C8 - .4byte _0809C4D0 - .4byte _0809C4D6 - .4byte _0809C4DC - .4byte _0809C4E2 - .4byte _0809C4E2 - .4byte _0809C4E2 - .4byte _0809C510 -_0809C4C8: - cmp r5, 0x2 - beq _0809C530 -_0809C4CC: - movs r0, 0 - b _0809C532 -_0809C4D0: - cmp r5, 0x1 - beq _0809C530 - b _0809C4CC -_0809C4D6: - cmp r5, 0x4 - beq _0809C530 - b _0809C4CC -_0809C4DC: - cmp r5, 0x3 - beq _0809C530 - b _0809C4CC -_0809C4E2: - ldr r1, =gSpecialVar_0x8004 - lsrs r0, r2, 16 - movs r3, 0xFA - lsls r3, 1 - adds r0, r3 - strh r0, [r1] - ldr r0, =gSpecialVar_0x8005 - strh r2, [r0] - ldrh r0, [r1] - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C4CC - ldr r0, =EventScript_271CB7 - b _0809C532 - .pool -_0809C510: - cmp r5, 0x2 - bne _0809C4CC - ldr r0, =gSpecialVar_0x8004 - strh r2, [r0] - bl sub_80E9680 - lsls r0, 24 - cmp r0, 0 - beq _0809C4CC - ldr r0, =EventScript_2759F1 - b _0809C532 - .pool -_0809C530: - adds r0, r2, 0 -_0809C532: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end TryGetInvisibleEventObjectScript - - thumb_func_start TryGetMetatileBehaviorScript -TryGetMetatileBehaviorScript: @ 809C538 - push {r4-r6,lr} - adds r6, r0, 0 - lsls r1, 24 - lsrs r5, r1, 24 - lsls r2, 24 - lsrs r4, r2, 24 - adds r0, r5, 0 - adds r1, r4, 0 - bl MetatileBehavior_IsPlayerFacingTVScreen - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C55C - ldr r0, =EventScript_27EE0B - b _0809C7E4 - .pool -_0809C55C: - adds r0, r5, 0 - bl MetatileBehavior_IsPC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C574 - ldr r0, =EventScript_271D92 - b _0809C7E4 - .pool -_0809C574: - adds r0, r5, 0 - bl MetatileBehavior_IsClosedSootopolisGymDoor - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C58C - ldr r0, =SootopolisCity_EventScript_1E615D - b _0809C7E4 - .pool -_0809C58C: - adds r0, r5, 0 - bl MetatileBehavior_IsUnknownClosedDoor - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C5A4 - ldr r0, =SkyPillar_Outside_EventScript_2393F9 - b _0809C7E4 - .pool -_0809C5A4: - adds r0, r5, 0 - bl MetatileBehavior_IsCableBoxResults1 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C5B4 - b _0809C6E4 -_0809C5B4: - adds r0, r5, 0 - bl MetatileBehavior_IsPokeblockFeeder - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C5CC - ldr r0, =EventScript_2A4BAC - b _0809C7E4 - .pool -_0809C5CC: - adds r0, r5, 0 - bl MetatileBehavior_IsTrickHousePuzzleDoor - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C5E4 - ldr r0, =Route110_TrickHouseEntrance_EventScript_26A22A - b _0809C7E4 - .pool -_0809C5E4: - adds r0, r5, 0 - bl MetatileBehavior_IsRegionMap - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C5FC - ldr r0, =EventScript_27208F - b _0809C7E4 - .pool -_0809C5FC: - adds r0, r5, 0 - bl MetatileBehavior_IsRunningShoesInstruction - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C614 - ldr r0, =EventScript_292DE5 - b _0809C7E4 - .pool -_0809C614: - adds r0, r5, 0 - bl MetatileBehavior_IsPictureBookShelf - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C62C - ldr r0, =EventScript_2725CE - b _0809C7E4 - .pool -_0809C62C: - adds r0, r5, 0 - bl MetatileBehavior_IsBookShelf - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C644 - ldr r0, =EventScript_2725D7 - b _0809C7E4 - .pool -_0809C644: - adds r0, r5, 0 - bl MetatileBehavior_IsPokeCenterBookShelf - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C65C - ldr r0, =EventScript_2725E0 - b _0809C7E4 - .pool -_0809C65C: - adds r0, r5, 0 - bl MetatileBehavior_IsVase - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C674 - ldr r0, =EventScript_2725E9 - b _0809C7E4 - .pool -_0809C674: - adds r0, r5, 0 - bl MetatileBehavior_IsTrashCan - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C68C - ldr r0, =EventScript_2725F2 - b _0809C7E4 - .pool -_0809C68C: - adds r0, r5, 0 - bl MetatileBehavior_IsShopShelf - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C6A4 - ldr r0, =EventScript_2725FB - b _0809C7E4 - .pool -_0809C6A4: - adds r0, r5, 0 - bl MetatileBehavior_IsBlueprint - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C6BC - ldr r0, =EventScript_272604 - b _0809C7E4 - .pool -_0809C6BC: - adds r0, r5, 0 - adds r1, r4, 0 - bl MetatileBehavior_IsPlayerFacingWirelessBoxResults - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C6D4 - ldr r0, =OldaleTown_PokemonCenter_2F_EventScript_277B8A - b _0809C7E4 - .pool -_0809C6D4: - adds r0, r5, 0 - adds r1, r4, 0 - bl MetatileBehavior_IsCableBoxResults2 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C6EC -_0809C6E4: - ldr r0, =gUnknown_08277365 - b _0809C7E4 - .pool -_0809C6EC: - adds r0, r5, 0 - bl MetatileBehavior_IsQuestionnaire - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C704 - ldr r0, =EventScript_27381B - b _0809C7E4 - .pool -_0809C704: - adds r0, r5, 0 - bl MetatileBehavior_IsTrainerHillTimer - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C71C - ldr r0, =TrainerHill_1F_EventScript_2C8393 - b _0809C7E4 - .pool -_0809C71C: - movs r4, 0x4 - ldrsb r4, [r6, r4] - movs r1, 0 - ldrsh r0, [r6, r1] - movs r2, 0x2 - ldrsh r1, [r6, r2] - bl MapGridGetZCoordAt - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - bne _0809C7D0 - adds r0, r5, 0 - bl MetatileBehavior_IsSecretBasePC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C74C - ldr r0, =gUnknown_0823B4BB - b _0809C7E4 - .pool -_0809C74C: - adds r0, r5, 0 - bl MetatileBehavior_IsSecretBaseRegisterPC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C764 - ldr r0, =gUnknown_0823B589 - b _0809C7E4 - .pool -_0809C764: - adds r0, r5, 0 - bl MetatileBehavior_IsSecretBaseSandOrnament - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C77C - ldr r0, =gUnknown_0823B684 - b _0809C7E4 - .pool -_0809C77C: - adds r0, r5, 0 - bl MetatileBehavior_IsSecretBaseTvOrShield - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C794 - ldr r0, =gUnknown_0823B68C - b _0809C7E4 - .pool -_0809C794: - adds r0, r5, 0 - bl MetatileBehavior_IsMB_C6 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C7A8 - bl sub_80EB56C - b _0809C7E2 -_0809C7A8: - adds r0, r5, 0 - bl MetatileBehavior_IsLargeMatCenter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C7BC - bl sub_80EB9E0 - b _0809C7E2 -_0809C7BC: - adds r0, r5, 0 - bl MetatileBehavior_IsSecretBaseLargeMatEdge - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C7E2 - bl sub_80EBB28 - b _0809C7E2 -_0809C7D0: - adds r0, r5, 0 - bl MetatileBehavior_IsSecretBasePoster - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C7E2 - bl sub_80EB498 -_0809C7E2: - movs r0, 0 -_0809C7E4: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end TryGetMetatileBehaviorScript - - thumb_func_start TryGetFieldMoveScript -TryGetFieldMoveScript: @ 809C7EC - push {r4,lr} - lsls r1, 24 - lsrs r4, r1, 24 - ldr r0, =0x0000086b - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C824 - bl PartyHasMonWithSurf - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C824 - bl IsPlayerFacingSurfableFishableWater - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C824 - ldr r0, =EventScript_271EA0 - b _0809C862 - .pool -_0809C824: - adds r0, r4, 0 - bl MetatileBehavior_IsWaterfall - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C860 - ldr r0, =0x0000086e - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C858 - bl IsPlayerSurfingNorth - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C858 - ldr r0, =EventScript_290A49 - b _0809C862 - .pool -_0809C858: - ldr r0, =EventScript_290A83 - b _0809C862 - .pool -_0809C860: - movs r0, 0 -_0809C862: - pop {r4} - pop {r1} - bx r1 - thumb_func_end TryGetFieldMoveScript - - thumb_func_start sub_809C868 -sub_809C868: @ 809C868 - push {lr} - ldr r0, =0x0000086d - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _0809C894 - bl sub_809D1E8 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _0809C894 - ldr r0, =EventScript_290B0F - bl ScriptContext1_SetupScript - movs r0, 0x1 - b _0809C896 - .pool -_0809C894: - movs r0, 0 -_0809C896: - pop {r1} - bx r1 - thumb_func_end sub_809C868 - - thumb_func_start sub_809C89C -sub_809C89C: @ 809C89C - push {lr} - ldr r0, =0x0000086d - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _0809C8D4 - ldr r0, =gMapHeader - ldrb r0, [r0, 0x17] - cmp r0, 0x5 - bne _0809C8D4 - bl sub_809D1E8 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C8D4 - ldr r0, =EventScript_290B5A - bl ScriptContext1_SetupScript - movs r0, 0x1 - b _0809C8D6 - .pool -_0809C8D4: - movs r0, 0 -_0809C8D6: - pop {r1} - bx r1 - thumb_func_end sub_809C89C - - thumb_func_start sub_809C8DC -sub_809C8DC: @ 809C8DC - push {r4-r6,lr} - adds r5, r0, 0 - lsls r1, 16 - lsrs r4, r1, 16 - adds r6, r4, 0 - bl mapheader_trigger_activate_at__run_now - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C92E - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_809CC9C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C92E - adds r0, r4, 0 - bl sub_809C96C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C92E - adds r0, r6, 0 - bl per_step_scripts - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C92E - bl UpdateRepelCounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809C92E - movs r0, 0 - b _0809C930 -_0809C92E: - movs r0, 0x1 -_0809C930: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_809C8DC - - thumb_func_start mapheader_trigger_activate_at__run_now -mapheader_trigger_activate_at__run_now: @ 809C938 - push {r4,lr} - ldr r4, =gMapHeader - ldrh r1, [r0] - subs r1, 0x7 - lsls r1, 16 - lsrs r1, 16 - ldrh r2, [r0, 0x2] - subs r2, 0x7 - lsls r2, 16 - lsrs r2, 16 - ldrb r3, [r0, 0x4] - adds r0, r4, 0 - bl mapheader_trigger_activate_at - cmp r0, 0 - beq _0809C964 - bl ScriptContext1_SetupScript - movs r0, 0x1 - b _0809C966 - .pool -_0809C964: - movs r0, 0 -_0809C966: - pop {r4} - pop {r1} - bx r1 - thumb_func_end mapheader_trigger_activate_at__run_now - - thumb_func_start sub_809C96C -sub_809C96C: @ 809C96C - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsCrackedFloorHole - lsls r0, 24 - cmp r0, 0 - beq _0809C988 - ldr r0, =gUnknown_082A8337 - b _0809C996 - .pool -_0809C988: - adds r0, r4, 0 - bl MetatileBehavior_IsBattlePyramidWarp - lsls r0, 24 - cmp r0, 0 - beq _0809C9A4 - ldr r0, =BattleFrontier_BattlePyramidEmptySquare_EventScript_252BE8 -_0809C996: - bl ScriptContext1_SetupScript - movs r0, 0x1 - b _0809C9EA - .pool -_0809C9A4: - adds r0, r4, 0 - bl MetatileBehavior_IsSecretBaseGlitterMat - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C9B8 - bl sub_80FA9D0 - b _0809C9E8 -_0809C9B8: - adds r0, r4, 0 - bl MetatileBehavior_IsSecretBaseSoundMat - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809C9E8 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl PlayerGetDestCoords - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileIdAt - lsls r0, 16 - asrs r0, 16 - bl sub_80FA970 -_0809C9E8: - movs r0, 0 -_0809C9EA: - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_809C96C - - thumb_func_start per_step_scripts -per_step_scripts: @ 809C9F4 - push {r4,lr} - lsls r0, 16 - lsrs r4, r0, 16 - bl InUnionRoom - cmp r0, 0x1 - bne _0809CA04 - b _0809CB24 -_0809CA04: - bl IncrementRematchStepCounter - bl AdjustFriendship_step - bl sub_81D4998 - ldr r0, =gPlayerAvatar - ldrb r1, [r0] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - bne _0809CAF8 - lsls r0, r4, 24 - lsrs r0, 24 - bl MetatileBehavior_IsForcedMovementTile - lsls r0, 24 - cmp r0, 0 - bne _0809CAF8 - bl overworld_poison_step - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CA48 - ldr r0, =EventScript_2736BC - bl ScriptContext1_SetupScript - b _0809CB28 - .pool -_0809CA48: - bl DoEggActions_CheckHatch - lsls r0, 24 - cmp r0, 0 - beq _0809CA64 - movs r0, 0xD - bl IncrementGameStat - ldr r0, =Route117_PokemonDayCare_EventScript_291FC0 - bl ScriptContext1_SetupScript - b _0809CB28 - .pool -_0809CA64: - bl sub_813B3B0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CA7C - ldr r0, =gUnknown_08273D1F - bl ScriptContext1_SetupScript - b _0809CB28 - .pool -_0809CA7C: - bl ShouldDoBrailleRegicePuzzle - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CA94 - ldr r0, =IslandCave_EventScript_238EAF - bl ScriptContext1_SetupScript - b _0809CB28 - .pool -_0809CA94: - bl is_tile_that_overrides_player_control - cmp r0, 0x1 - bne _0809CAA8 - ldr r0, =MauvilleCity_EventScript_1DF7BA - bl ScriptContext1_SetupScript - b _0809CB28 - .pool -_0809CAA8: - bl sub_8138120 - cmp r0, 0x1 - bne _0809CABC - ldr r0, =Route119_EventScript_1F49EC - bl ScriptContext1_SetupScript - b _0809CB28 - .pool -_0809CABC: - bl sub_8138168 - cmp r0, 0x1 - bne _0809CAD0 - ldr r0, =LittlerootTown_ProfessorBirchsLab_EventScript_1FA4D6 - bl ScriptContext1_SetupScript - b _0809CB28 - .pool -_0809CAD0: - bl sub_81381B0 - cmp r0, 0x1 - bne _0809CAE4 - ldr r0, =RustboroCity_Gym_EventScript_21307B - bl ScriptContext1_SetupScript - b _0809CB28 - .pool -_0809CAE4: - bl sub_81381F8 - cmp r0, 0x1 - bne _0809CAF8 - ldr r0, =MossdeepCity_SpaceCenter_2F_EventScript_224175 - bl ScriptContext1_SetupScript - b _0809CB28 - .pool -_0809CAF8: - bl SafariZoneTakeStep - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809CB28 - movs r0, 0x1 - bl CountSSTidalStep - cmp r0, 0x1 - bne _0809CB1C - ldr r0, =SSTidalCorridor_EventScript_23C050 - bl ScriptContext1_SetupScript - b _0809CB28 - .pool -_0809CB1C: - bl sub_8196034 - cmp r0, 0 - bne _0809CB28 -_0809CB24: - movs r0, 0 - b _0809CB2A -_0809CB28: - movs r0, 0x1 -_0809CB2A: - pop {r4} - pop {r1} - bx r1 - thumb_func_end per_step_scripts - - thumb_func_start sub_809CB30 -sub_809CB30: @ 809CB30 - push {lr} - ldr r0, =0x0000402a - movs r1, 0 - bl VarSet - pop {r0} - bx r0 - .pool - thumb_func_end sub_809CB30 - - thumb_func_start AdjustFriendship_step -AdjustFriendship_step: @ 809CB44 - push {r4,r5,lr} - ldr r0, =0x0000402a - bl GetVarPointer - ldrh r1, [r0] - adds r1, 0x1 - strh r1, [r0] - ldrh r1, [r0] - movs r2, 0x7F - ands r1, r2 - strh r1, [r0] - cmp r1, 0 - bne _0809CB72 - ldr r5, =gPlayerParty - movs r4, 0x5 -_0809CB62: - adds r0, r5, 0 - movs r1, 0x5 - bl AdjustFriendship - adds r5, 0x64 - subs r4, 0x1 - cmp r4, 0 - bge _0809CB62 -_0809CB72: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end AdjustFriendship_step - - thumb_func_start ResetPoisonStepCounter -ResetPoisonStepCounter: @ 809CB80 - push {lr} - ldr r0, =0x0000402b - movs r1, 0 - bl VarSet - pop {r0} - bx r0 - .pool - thumb_func_end ResetPoisonStepCounter - - thumb_func_start overworld_poison_step -overworld_poison_step: @ 809CB94 - push {lr} - ldr r0, =gMapHeader - ldrb r0, [r0, 0x17] - cmp r0, 0x9 - beq _0809CBD4 - ldr r0, =0x0000402b - bl GetVarPointer - ldrh r1, [r0] - adds r1, 0x1 - strh r1, [r0] - ldrh r1, [r0] - movs r2, 0x3 - ands r1, r2 - strh r1, [r0] - cmp r1, 0 - bne _0809CBD4 - bl overworld_poison - cmp r0, 0x1 - beq _0809CBD4 - cmp r0, 0x1 - ble _0809CBD4 - cmp r0, 0x2 - bne _0809CBD4 - movs r0, 0x1 - b _0809CBD6 - .pool -_0809CBD4: - movs r0, 0 -_0809CBD6: - pop {r1} - bx r1 - thumb_func_end overworld_poison_step - - thumb_func_start prev_quest_postbuffer_cursor_backup_reset -prev_quest_postbuffer_cursor_backup_reset: @ 809CBDC - ldr r1, =gUnknown_020375D4 - movs r0, 0 - strb r0, [r1] - bx lr - .pool - thumb_func_end prev_quest_postbuffer_cursor_backup_reset - - thumb_func_start is_it_battle_time_3 -is_it_battle_time_3: @ 809CBE8 - push {r4-r7,lr} - lsls r0, 16 - lsrs r4, r0, 16 - adds r7, r4, 0 - ldr r6, =gUnknown_020375D4 - ldrb r0, [r6] - cmp r0, 0x3 - bhi _0809CC0C - adds r0, 0x1 - strb r0, [r6] - ldr r0, =gUnknown_020375D6 - strh r4, [r0] - movs r0, 0 - b _0809CC30 - .pool -_0809CC0C: - ldr r5, =gUnknown_020375D6 - ldrh r1, [r5] - adds r0, r4, 0 - bl StandardWildEncounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809CC28 - strh r4, [r5] - movs r0, 0 - b _0809CC30 - .pool -_0809CC28: - movs r0, 0 - strb r0, [r6] - strh r7, [r5] - movs r0, 0x1 -_0809CC30: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end is_it_battle_time_3 - - thumb_func_start mapheader_run_first_tag2_script_list_match_conditionally -mapheader_run_first_tag2_script_list_match_conditionally: @ 809CC38 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r7, r0, 0 - adds r4, r1, 0 - adds r5, r2, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gMapHeader - mov r8, r0 - adds r1, r7, 0 - bl map_warp_check_packed - lsls r0, 24 - lsrs r6, r0, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl is_non_stair_warp_tile - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CC90 - lsls r0, r6, 24 - asrs r4, r0, 24 - movs r0, 0x1 - negs r0, r0 - cmp r4, r0 - beq _0809CC90 - bl StoreInitialPlayerAvatarState - mov r0, r8 - adds r1, r4, 0 - adds r2, r7, 0 - bl sub_809CEB0 - bl sub_80AF734 - movs r0, 0x1 - b _0809CC92 - .pool -_0809CC90: - movs r0, 0 -_0809CC92: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end mapheader_run_first_tag2_script_list_match_conditionally - - thumb_func_start sub_809CC9C -sub_809CC9C: @ 809CC9C - push {r4-r7,lr} - adds r6, r0, 0 - lsls r1, 16 - lsrs r5, r1, 16 - ldr r7, =gMapHeader - adds r0, r7, 0 - adds r1, r6, 0 - bl map_warp_check_packed - lsls r0, 24 - asrs r4, r0, 24 - movs r0, 0x1 - negs r0, r0 - cmp r4, r0 - beq _0809CD8A - adds r0, r5, 0 - bl is_warp_tile - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CD8A - bl StoreInitialPlayerAvatarState - adds r0, r7, 0 - adds r1, r4, 0 - adds r2, r6, 0 - bl sub_809CEB0 - lsls r0, r5, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsEscalator - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CCF8 - adds r0, r4, 0 - bl sub_80AF80C - movs r0, 0x1 - b _0809CD8C - .pool -_0809CCF8: - adds r0, r4, 0 - bl MetatileBehavior_IsLavaridgeB1FWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CD0E - bl sub_80AF828 - movs r0, 0x1 - b _0809CD8C -_0809CD0E: - adds r0, r4, 0 - bl MetatileBehavior_IsLavaridge1FWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CD24 - bl sub_80AF838 - movs r0, 0x1 - b _0809CD8C -_0809CD24: - adds r0, r4, 0 - bl MetatileBehavior_IsAquaHideoutWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CD3A - bl sub_80AF848 - movs r0, 0x1 - b _0809CD8C -_0809CD3A: - adds r0, r4, 0 - bl MetatileBehavior_IsWarpOrBridge - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CD50 - bl sub_80B0268 - movs r0, 0x1 - b _0809CD8C -_0809CD50: - adds r0, r4, 0 - bl MetatileBehavior_IsMtPyreHole - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CD6C - ldr r0, =gUnknown_082A8350 - bl ScriptContext1_SetupScript - movs r0, 0x1 - b _0809CD8C - .pool -_0809CD6C: - adds r0, r4, 0 - bl MetatileBehavior_IsMossdeepGymWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CD82 - bl sub_80AF87C - movs r0, 0x1 - b _0809CD8C -_0809CD82: - bl sub_80AF734 - movs r0, 0x1 - b _0809CD8C -_0809CD8A: - movs r0, 0 -_0809CD8C: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_809CC9C - - thumb_func_start is_warp_tile -is_warp_tile: @ 809CD94 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsWarpDoor - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809CE2A - adds r0, r4, 0 - bl MetatileBehavior_IsLadder - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809CE2A - adds r0, r4, 0 - bl MetatileBehavior_IsEscalator - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809CE2A - adds r0, r4, 0 - bl MetatileBehavior_IsNonAnimDoor - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809CE2A - adds r0, r4, 0 - bl MetatileBehavior_IsLavaridgeB1FWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809CE2A - adds r0, r4, 0 - bl MetatileBehavior_IsLavaridge1FWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809CE2A - adds r0, r4, 0 - bl MetatileBehavior_IsAquaHideoutWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809CE2A - adds r0, r4, 0 - bl MetatileBehavior_IsMtPyreHole - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809CE2A - adds r0, r4, 0 - bl MetatileBehavior_IsMossdeepGymWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809CE2A - adds r0, r4, 0 - bl MetatileBehavior_IsWarpOrBridge - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0809CE2A - movs r0, 0 - b _0809CE2C -_0809CE2A: - movs r0, 0x1 -_0809CE2C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end is_warp_tile - - thumb_func_start is_non_stair_warp_tile -is_non_stair_warp_tile: @ 809CE34 - push {lr} - lsls r0, 16 - lsrs r0, 16 - lsls r1, 24 - lsrs r1, 24 - adds r2, r1, 0 - cmp r1, 0x2 - beq _0809CE58 - cmp r1, 0x2 - bgt _0809CE4E - cmp r1, 0x1 - beq _0809CE62 - b _0809CE84 -_0809CE4E: - cmp r2, 0x3 - beq _0809CE6C - cmp r2, 0x4 - beq _0809CE76 - b _0809CE84 -_0809CE58: - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsNorthArrowWarp - b _0809CE7E -_0809CE62: - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsSouthArrowWarp - b _0809CE7E -_0809CE6C: - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsWestArrowWarp - b _0809CE7E -_0809CE76: - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsEastArrowWarp -_0809CE7E: - lsls r0, 24 - lsrs r0, 24 - b _0809CE86 -_0809CE84: - movs r0, 0 -_0809CE86: - pop {r1} - bx r1 - thumb_func_end is_non_stair_warp_tile - - thumb_func_start map_warp_check_packed -map_warp_check_packed: @ 809CE8C - push {lr} - adds r3, r1, 0 - ldrh r1, [r3] - subs r1, 0x7 - lsls r1, 16 - lsrs r1, 16 - ldrh r2, [r3, 0x2] - subs r2, 0x7 - lsls r2, 16 - lsrs r2, 16 - ldrb r3, [r3, 0x4] - bl map_warp_check - lsls r0, 24 - asrs r0, 24 - pop {r1} - bx r1 - thumb_func_end map_warp_check_packed - - thumb_func_start sub_809CEB0 -sub_809CEB0: @ 809CEB0 - push {r4-r7,lr} - adds r7, r2, 0 - lsls r1, 24 - lsrs r4, r1, 24 - bl GetCurrentTrainerHillMapId - lsls r0, 24 - lsrs r5, r0, 24 - adds r6, r5, 0 - cmp r5, 0 - beq _0809CF00 - bl sub_81D6490 - lsls r0, 24 - lsrs r0, 24 - cmp r5, r0 - bne _0809CEF0 - lsls r0, r4, 24 - adds r4, r0, 0 - cmp r4, 0 - bne _0809CEE8 - ldr r0, =gMapHeader - ldr r0, [r0, 0x4] - ldr r5, [r0, 0x8] - b _0809CF0E - .pool -_0809CEE8: - bl sub_81D6120 - adds r5, r0, 0 - b _0809CF0E -_0809CEF0: - cmp r6, 0x5 - bne _0809CF00 - lsls r4, 24 - lsrs r0, r4, 24 - bl sub_81D6134 - adds r5, r0, 0 - b _0809CF0E -_0809CF00: - ldr r0, =gMapHeader - ldr r0, [r0, 0x4] - lsls r2, r4, 24 - asrs r1, r2, 21 - ldr r0, [r0, 0x8] - adds r5, r0, r1 - adds r4, r2, 0 -_0809CF0E: - ldrb r0, [r5, 0x6] - cmp r0, 0x7F - bne _0809CF20 - ldrb r0, [r5, 0x5] - bl copy_saved_warp2_bank_and_enter_x_to_warp1 - b _0809CF6E - .pool -_0809CF20: - movs r0, 0x7 - ldrsb r0, [r5, r0] - movs r1, 0x6 - ldrsb r1, [r5, r1] - movs r2, 0x5 - ldrsb r2, [r5, r2] - bl warp1_set_2 - movs r1, 0 - ldrsh r0, [r7, r1] - movs r2, 0x2 - ldrsh r1, [r7, r2] - bl sub_8084D5C - ldrb r0, [r5, 0x7] - ldrb r1, [r5, 0x6] - bl Overworld_GetMapHeaderByGroupAndId - ldr r1, [r0, 0x4] - ldrb r0, [r5, 0x5] - ldr r1, [r1, 0x8] - lsls r0, 3 - adds r0, r1 - ldrb r0, [r0, 0x6] - cmp r0, 0x7F - bne _0809CF6E - asrs r3, r4, 24 - lsls r0, r3, 3 - adds r0, r1 - ldrb r0, [r0, 0x5] - ldr r1, =gSaveBlock1Ptr - ldr r2, [r1] - movs r1, 0x4 - ldrsb r1, [r2, r1] - ldrb r2, [r2, 0x5] - lsls r2, 24 - asrs r2, 24 - bl saved_warp2_set -_0809CF6E: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_809CEB0 - - thumb_func_start map_warp_consider_2_to_inside -map_warp_consider_2_to_inside: @ 809CF78 - push {r4-r7,lr} - adds r5, r0, 0 - lsls r1, 16 - lsrs r0, r1, 16 - adds r7, r0, 0 - lsls r2, 24 - lsrs r2, 24 - cmp r2, 0x2 - bne _0809CFFC - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsOpenSecretBaseDoor - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CFB0 - ldr r0, =gMapHeader - ldr r1, [r0, 0x4] - adds r0, r5, 0 - bl sub_80E9668 - movs r0, 0x1 - b _0809CFFE - .pool -_0809CFB0: - adds r0, r4, 0 - bl MetatileBehavior_IsWarpDoor - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CFFC - ldr r6, =gMapHeader - adds r0, r6, 0 - adds r1, r5, 0 - bl map_warp_check_packed - lsls r0, 24 - asrs r4, r0, 24 - movs r0, 0x1 - negs r0, r0 - cmp r4, r0 - beq _0809CFFC - adds r0, r7, 0 - bl is_warp_tile - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809CFFC - bl StoreInitialPlayerAvatarState - adds r0, r6, 0 - adds r1, r4, 0 - adds r2, r5, 0 - bl sub_809CEB0 - bl sub_80AF7D0 - movs r0, 0x1 - b _0809CFFE - .pool -_0809CFFC: - movs r0, 0 -_0809CFFE: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end map_warp_consider_2_to_inside - - thumb_func_start map_warp_check -map_warp_check: @ 809D004 - push {r4-r6,lr} - lsls r1, 16 - lsrs r6, r1, 16 - lsls r2, 16 - lsrs r5, r2, 16 - lsls r3, 24 - lsrs r4, r3, 24 - ldr r0, [r0, 0x4] - ldr r1, [r0, 0x8] - ldrb r3, [r0, 0x1] - movs r2, 0 - cmp r2, r3 - bge _0809D042 -_0809D01E: - ldrh r0, [r1] - cmp r0, r6 - bne _0809D03A - ldrh r0, [r1, 0x2] - cmp r0, r5 - bne _0809D03A - ldrb r0, [r1, 0x4] - cmp r0, r4 - beq _0809D034 - cmp r0, 0 - bne _0809D03A -_0809D034: - lsls r0, r2, 24 - asrs r0, 24 - b _0809D046 -_0809D03A: - adds r2, 0x1 - adds r1, 0x8 - cmp r2, r3 - blt _0809D01E -_0809D042: - movs r0, 0x1 - negs r0, r0 -_0809D046: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end map_warp_check - - thumb_func_start trigger_activate -trigger_activate: @ 809D04C - push {r4,lr} - adds r4, r0, 0 - cmp r4, 0 - beq _0809D082 - ldr r1, [r4, 0xC] - cmp r1, 0 - bne _0809D062 - ldrb r0, [r4, 0x6] - bl DoCoordEventWeather - b _0809D082 -_0809D062: - ldrh r0, [r4, 0x6] - cmp r0, 0 - beq _0809D07C - ldrh r0, [r4, 0x6] - bl VarGet - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r4, 0x8] - cmp r0, r1 - bne _0809D082 - ldr r0, [r4, 0xC] - b _0809D084 -_0809D07C: - adds r0, r1, 0 - bl ScriptContext2_RunNewScript -_0809D082: - movs r0, 0 -_0809D084: - pop {r4} - pop {r1} - bx r1 - thumb_func_end trigger_activate - - thumb_func_start mapheader_trigger_activate_at -mapheader_trigger_activate_at: @ 809D08C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r1, 16 - lsrs r1, 16 - mov r10, r1 - lsls r2, 16 - lsrs r2, 16 - mov r9, r2 - lsls r3, 24 - lsrs r3, 24 - mov r8, r3 - ldr r0, [r0, 0x4] - ldr r1, [r0, 0xC] - ldrb r7, [r0, 0x2] - movs r6, 0 - cmp r6, r7 - bge _0809D0E2 - adds r5, r1, 0 - adds r4, r5, 0 -_0809D0B8: - ldrh r0, [r4] - cmp r0, r10 - bne _0809D0D8 - ldrh r0, [r4, 0x2] - cmp r0, r9 - bne _0809D0D8 - ldrb r0, [r4, 0x4] - cmp r0, r8 - beq _0809D0CE - cmp r0, 0 - bne _0809D0D8 -_0809D0CE: - adds r0, r5, 0 - bl trigger_activate - cmp r0, 0 - bne _0809D0E4 -_0809D0D8: - adds r4, 0x10 - adds r5, 0x10 - adds r6, 0x1 - cmp r6, r7 - blt _0809D0B8 -_0809D0E2: - movs r0, 0 -_0809D0E4: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end mapheader_trigger_activate_at - - thumb_func_start sub_809D0F4 -sub_809D0F4: @ 809D0F4 - push {r4,lr} - ldr r4, =gMapHeader - ldrh r1, [r0] - subs r1, 0x7 - lsls r1, 16 - lsrs r1, 16 - ldrh r2, [r0, 0x2] - subs r2, 0x7 - lsls r2, 16 - lsrs r2, 16 - ldrb r3, [r0, 0x4] - adds r0, r4, 0 - bl mapheader_trigger_activate_at - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_809D0F4 - - thumb_func_start FindInvisibleEventObjectByPosition -@ int FindInvisibleEventObjectByPosition(struct mapheader *mapHeader, u16 x, u16 y, u8 elevation) -FindInvisibleEventObjectByPosition: @ 809D11C - push {r4-r7,lr} - lsls r1, 16 - lsrs r7, r1, 16 - lsls r2, 16 - lsrs r6, r2, 16 - lsls r3, 24 - lsrs r5, r3, 24 - ldr r0, [r0, 0x4] - ldr r4, [r0, 0x10] - ldrb r3, [r0, 0x3] - movs r2, 0 - cmp r2, r3 - bcs _0809D162 -_0809D136: - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r1, r0, r4 - ldrh r0, [r1] - cmp r0, r7 - bne _0809D158 - ldrh r0, [r1, 0x2] - cmp r0, r6 - bne _0809D158 - ldrb r0, [r1, 0x4] - cmp r0, r5 - beq _0809D154 - cmp r0, 0 - bne _0809D158 -_0809D154: - adds r0, r1, 0 - b _0809D164 -_0809D158: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, r3 - bcc _0809D136 -_0809D162: - movs r0, 0 -_0809D164: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end FindInvisibleEventObjectByPosition - - thumb_func_start dive_warp -dive_warp: @ 809D16C - push {r4,r5,lr} - adds r4, r0, 0 - lsls r1, 16 - lsrs r5, r1, 16 - ldr r0, =gMapHeader - ldrb r0, [r0, 0x17] - cmp r0, 0x5 - bne _0809D1A4 - lsls r0, r5, 24 - lsrs r0, 24 - bl MetatileBehavior_IsUnableToEmerge - lsls r0, 24 - cmp r0, 0 - bne _0809D1A4 - ldrh r0, [r4] - subs r0, 0x7 - lsls r0, 16 - lsrs r0, 16 - ldrh r1, [r4, 0x2] - subs r1, 0x7 - lsls r1, 16 - lsrs r1, 16 - bl SetDiveWarpEmerge - b _0809D1C8 - .pool -_0809D1A4: - lsls r0, r5, 24 - lsrs r0, 24 - bl MetatileBehavior_IsDiveable - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809D1E0 - ldrh r0, [r4] - subs r0, 0x7 - lsls r0, 16 - lsrs r0, 16 - ldrh r1, [r4, 0x2] - subs r1, 0x7 - lsls r1, 16 - lsrs r1, 16 - bl SetDiveWarpDive -_0809D1C8: - lsls r0, 24 - cmp r0, 0 - beq _0809D1E0 - bl StoreInitialPlayerAvatarState - bl sp13E_warp_to_last_warp - movs r0, 0xE9 - bl PlaySE - movs r0, 0x1 - b _0809D1E2 -_0809D1E0: - movs r0, 0 -_0809D1E2: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end dive_warp - - thumb_func_start sub_809D1E8 -sub_809D1E8: @ 809D1E8 - push {r4,r5,lr} - sub sp, 0x4 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl PlayerGetDestCoords - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gMapHeader - ldrb r0, [r0, 0x17] - cmp r0, 0x5 - bne _0809D244 - adds r0, r5, 0 - bl MetatileBehavior_IsUnableToEmerge - lsls r0, 24 - cmp r0, 0 - bne _0809D244 - mov r0, sp - ldrh r0, [r0] - subs r0, 0x7 - lsls r0, 16 - lsrs r0, 16 - ldrh r1, [r4] - subs r1, 0x7 - lsls r1, 16 - lsrs r1, 16 - bl SetDiveWarpEmerge - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809D274 - movs r0, 0x1 - b _0809D276 - .pool -_0809D244: - adds r0, r5, 0 - bl MetatileBehavior_IsDiveable - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809D274 - mov r0, sp - ldrh r0, [r0] - subs r0, 0x7 - lsls r0, 16 - lsrs r0, 16 - ldrh r1, [r4] - subs r1, 0x7 - lsls r1, 16 - lsrs r1, 16 - bl SetDiveWarpDive - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0809D274 - movs r0, 0x2 - b _0809D276 -_0809D274: - movs r0, 0 -_0809D276: - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_809D1E8 - - thumb_func_start GetEventObjectScriptPointerForComparison -@ u8 *GetEventObjectScriptPointerForComparison() -GetEventObjectScriptPointerForComparison: @ 809D280 - push {r4,r5,lr} - sub sp, 0x8 - bl GetPlayerMovementDirection - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - mov r5, sp - mov r0, sp - bl player_get_next_pos_and_height - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0x2 - ldrsh r1, [r5, r2] - bl MapGridGetMetatileBehaviorAt - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - mov r0, sp - adds r2, r4, 0 - bl TryGetEventObjectScript - add sp, 0x8 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end GetEventObjectScriptPointerForComparison - - thumb_func_start sub_809D2BC -sub_809D2BC: @ 809D2BC - push {r4,lr} - sub sp, 0x8 - bl GetPlayerMovementDirection - mov r4, sp - mov r0, sp - bl player_get_pos_to_and_height - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0x2 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - ldr r4, =gMapHeader - adds r0, r4, 0 - mov r1, sp - bl map_warp_check_packed - adds r1, r0, 0 - lsls r1, 24 - asrs r1, 24 - adds r0, r4, 0 - mov r2, sp - bl sub_809CEB0 - movs r0, 0 - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_809D2BC - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/party_menu.s b/asm/party_menu.s index 67fdab266a..53a66378c5 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -10499,7 +10499,7 @@ sub_81B5958: @ 81B5958 thumb_func_start sub_81B5974 sub_81B5974: @ 81B5974 push {lr} - bl sub_809D1E8 + bl TrySetDiveWarp ldr r1, =gFieldEffectArguments lsls r0, 24 lsrs r0, 24 diff --git a/common_syms/field_control_avatar.txt b/common_syms/field_control_avatar.txt new file mode 100644 index 0000000000..0f336a407d --- /dev/null +++ b/common_syms/field_control_avatar.txt @@ -0,0 +1 @@ +gSelectedEventObject diff --git a/data/event_scripts.s b/data/event_scripts.s index dc308f8b15..77c0f44ccf 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -431,7 +431,7 @@ gStdScripts_End:: @ 81DC2CC .include "data/maps/SecretBase_YellowCave3/scripts.inc" .include "data/maps/SecretBase_YellowCave4/scripts.inc" -gUnknown_0823B4BB:: @ 823B4BB +EventScript_SecretBasePC:: @ 823B4BB lockall playse 2 message Text_276805 @@ -492,7 +492,7 @@ EventScript_23B585:: @ 823B585 special sub_80E9C88 end -gUnknown_0823B589:: @ 823B589 +EventScript_RecordMixingSecretBasePC:: @ 823B589 lockall message Text_276805 playse 2 @@ -581,13 +581,13 @@ EventScript_23B680:: @ 823B680 special sub_80EBB28 end -gUnknown_0823B684:: @ 823B684 +EventScript_SecretBaseSandOrnament:: @ 823B684 special sub_80EBE7C dofieldeffect 52 waitstate end -gUnknown_0823B68C:: @ 823B68C +EventScript_SecretBaseShieldOrToyTV:: @ 823B68C special sub_80FAC78 compare VAR_RESULT, 0 goto_eq EventScript_23B6BC @@ -1685,7 +1685,7 @@ EventScript_271CA1:: @ 8271CA1 setvar VAR_RESULT, 0 return -EventScript_271CB7:: @ 8271CB7 +EventScript_HiddenItemScript:: @ 8271CB7 lockall waitse giveitem VAR_0x8005, 1 @@ -1761,7 +1761,7 @@ EventScript_271D89:: @ 8271D89 release end -EventScript_271D92:: @ 8271D92 +EventScript_PC:: @ 8271D92 lockall setvar VAR_0x8004, 0 special DoPCTurnOnEffect @@ -1902,7 +1902,7 @@ Route109_EventScript_271E95:: @ 8271E95 setvar VAR_0x4096, 0 return -EventScript_271EA0:: @ 8271EA0 +EventScript_UseSurf:: @ 8271EA0 checkpartymove MOVE_SURF compare VAR_RESULT, 6 goto_eq EventScript_271ED6 @@ -2201,7 +2201,7 @@ SSTidalRooms_EventScript_272083:: @ 8272083 fadescreen 0 return -EventScript_27208F:: @ 827208F +EventScript_RegionMap:: @ 827208F lockall msgbox LittlerootTown_BrendansHouse_2F_Text_1F8820, 4 fadescreen 1 @@ -3074,31 +3074,31 @@ Movement_2725CB:: @ 82725CB walk_up step_end -EventScript_2725CE:: @ 82725CE +EventScript_PictureBookShelf:: @ 82725CE msgbox Text_2A81E5, 3 end -EventScript_2725D7:: @ 82725D7 +EventScript_BookShelf:: @ 82725D7 msgbox Text_2A820D, 3 end -EventScript_2725E0:: @ 82725E0 +EventScript_PokemonCenterBookshelf:: @ 82725E0 msgbox Text_2A8232, 3 end -EventScript_2725E9:: @ 82725E9 +EventScript_Vase:: @ 82725E9 msgbox Text_2A8276, 3 end -EventScript_2725F2:: @ 82725F2 +EventScript_TrashCan:: @ 82725F2 msgbox Text_2A82B3, 3 end -EventScript_2725FB:: @ 82725FB +EventScript_ShopShelf:: @ 82725FB msgbox Text_2A82BF, 3 end -EventScript_272604:: @ 8272604 +EventScript_Blueprint:: @ 8272604 msgbox Text_2A82F7, 3 end @@ -3322,7 +3322,7 @@ EventScript_2736B3:: @ 82736B3 msgbox gUnknown_08272C98, 3 end -EventScript_2736BC:: @ 82736BC +EventScript_Poison:: @ 82736BC lockall special sub_80F972C waitstate @@ -3565,7 +3565,7 @@ RustboroCity_DevonCorp_2F_EventScript_273811:: @ 8273811 release end -EventScript_27381B:: @ 827381B +EventScript_Questionnaire:: @ 827381B lockall msgbox gUnknown_0827339F, 5 compare VAR_RESULT, 0 @@ -5859,7 +5859,7 @@ EventScript_2926F8:: @ 82926F8 .include "data/scripts/players_house.inc" -EventScript_292DE5:: @ 8292DE5 +EventScript_RunningShoesManual:: @ 8292DE5 msgbox LittlerootTown_BrendansHouse_1F_Text_1F7F66, 3 end @@ -6010,7 +6010,7 @@ MirageTower_3F_MapScript2_2A8327: @ 82A8327 MtPyre_2F_MapScript2_2A8327: @ 82A8327 SkyPillar_2F_MapScript2_2A8327: @ 82A8327 SkyPillar_4F_MapScript2_2A8327: @ 82A8327 - map_script_2 VAR_ICE_STEP_COUNT, 0, gUnknown_082A8337 + map_script_2 VAR_ICE_STEP_COUNT, 0, EventScript_FallDownHole .2byte 0 GraniteCave_B1F_MapScript1_2A8331: @ 82A8331 @@ -6020,7 +6020,7 @@ MtPyre_2F_MapScript1_2A8331: @ 82A8331 copyvar VAR_ICE_STEP_COUNT, 0x1 end -gUnknown_082A8337:: @ 82A8337 +EventScript_FallDownHole:: @ 82A8337 lockall delay 20 applymovement 255, GraniteCave_B1F_Movement_2A8369 @@ -11691,7 +11691,7 @@ TrainerHill_Roof_MapScript2_2C8381: @ 82C8381 map_script_2 VAR_TEMP_1, 1, TrainerHill_1F_EventScript_2C83DF .2byte 0 -TrainerHill_1F_EventScript_2C8393:: @ 82C8393 +EventScript_TrainerHillTimer:: @ 82C8393 lockall setvar VAR_0x8004, 7 special sp194_trainer_tower diff --git a/data/maps/LittlerootTown_BrendansHouse_2F/events.inc b/data/maps/LittlerootTown_BrendansHouse_2F/events.inc index 815acaa82b..8ea295cdf8 100644 --- a/data/maps/LittlerootTown_BrendansHouse_2F/events.inc +++ b/data/maps/LittlerootTown_BrendansHouse_2F/events.inc @@ -20,7 +20,7 @@ LittlerootTown_BrendansHouse_2F_MapWarps: @ 852D320 warp_def 7, 1, 0, 2, MAP_LITTLEROOT_TOWN_BRENDANS_HOUSE_1F LittlerootTown_BrendansHouse_2F_MapBGEvents: @ 852D328 - bg_event 0, 1, 0, BG_EVENT_PLAYER_FACING_NORTH, gUnknown_081F860D + bg_event 0, 1, 0, BG_EVENT_PLAYER_FACING_NORTH, EventScript_PlayerPCMale bg_event 1, 1, 0, BG_EVENT_PLAYER_FACING_ANY, LittlerootTown_BrendansHouse_2F_EventScript_1F8656 bg_event 5, 1, 0, BG_EVENT_PLAYER_FACING_ANY, LittlerootTown_BrendansHouse_2F_EventScript_292781 bg_event 3, 1, 0, BG_EVENT_PLAYER_FACING_ANY, LittlerootTown_BrendansHouse_2F_EventScript_1F865F diff --git a/data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc b/data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc index 429c933fc1..2382305bba 100644 --- a/data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc +++ b/data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc @@ -245,7 +245,7 @@ LittlerootTown_BrendansHouse_2F_Movement_1F8609: @ 81F8609 walk_in_place_fastest_left step_end -gUnknown_081F860D:: @ 81F860D +EventScript_PlayerPCMale:: @ 81F860D lockall checkplayergender compare VAR_RESULT, 0 diff --git a/data/maps/LittlerootTown_MaysHouse_2F/events.inc b/data/maps/LittlerootTown_MaysHouse_2F/events.inc index 6d541e1e3b..a9d7001b7d 100644 --- a/data/maps/LittlerootTown_MaysHouse_2F/events.inc +++ b/data/maps/LittlerootTown_MaysHouse_2F/events.inc @@ -23,7 +23,7 @@ LittlerootTown_MaysHouse_2F_MapBGEvents: @ 852D608 bg_event 5, 1, 0, BG_EVENT_PLAYER_FACING_ANY, LittlerootTown_MaysHouse_2F_EventScript_1F865F bg_event 7, 1, 0, BG_EVENT_PLAYER_FACING_ANY, LittlerootTown_MaysHouse_2F_EventScript_1F8656 bg_event 3, 1, 0, BG_EVENT_PLAYER_FACING_ANY, LittlerootTown_MaysHouse_2F_EventScript_29278D - bg_event 8, 1, 0, BG_EVENT_PLAYER_FACING_ANY, gUnknown_081F9553 + bg_event 8, 1, 0, BG_EVENT_PLAYER_FACING_ANY, EventScript_PlayerPCFemale LittlerootTown_MaysHouse_2F_MapEvents:: @ 852D638 map_events LittlerootTown_MaysHouse_2F_EventObjects, LittlerootTown_MaysHouse_2F_MapWarps, 0x0, LittlerootTown_MaysHouse_2F_MapBGEvents diff --git a/data/maps/LittlerootTown_MaysHouse_2F/scripts.inc b/data/maps/LittlerootTown_MaysHouse_2F/scripts.inc index 5501f5ad5a..14e2694451 100644 --- a/data/maps/LittlerootTown_MaysHouse_2F/scripts.inc +++ b/data/maps/LittlerootTown_MaysHouse_2F/scripts.inc @@ -301,7 +301,7 @@ LittlerootTown_BrendansHouse_2F_EventScript_1F954A:: @ 81F954A msgbox LittlerootTown_BrendansHouse_2F_Text_1F9BE7, 4 return -gUnknown_081F9553:: @ 81F9553 +EventScript_PlayerPCFemale:: @ 81F9553 lockall checkplayergender compare VAR_RESULT, 0 diff --git a/data/maps/SootopolisCity/scripts.inc b/data/maps/SootopolisCity/scripts.inc index 5de8c7d120..06ceba8c05 100644 --- a/data/maps/SootopolisCity/scripts.inc +++ b/data/maps/SootopolisCity/scripts.inc @@ -927,7 +927,7 @@ SootopolisCity_EventScript_1E6154:: @ 81E6154 msgbox SootopolisCity_Text_1E65C8, 3 end -SootopolisCity_EventScript_1E615D:: @ 81E615D +EventScript_ClosedSootopolisDoor:: @ 81E615D msgbox SootopolisCity_Text_1E6604, 3 end diff --git a/data/scripts/cable_club.inc b/data/scripts/cable_club.inc index 08f5accca6..ce3dea1706 100644 --- a/data/scripts/cable_club.inc +++ b/data/scripts/cable_club.inc @@ -474,7 +474,7 @@ OldaleTown_PokemonCenter_2F_EventScript_276FBD:: @ 8276FBD release compare VAR_0x8004, 5 goto_eq OldaleTown_PokemonCenter_2F_EventScript_277036 - special sub_809D2BC + special SetCableClubWarp warp MAP_SINGLE_BATTLE_COLOSSEUM, 255, 6, 8 special sub_80AF948 waitstate @@ -486,7 +486,7 @@ OldaleTown_PokemonCenter_2F_EventScript_27702B:: @ 827702B return OldaleTown_PokemonCenter_2F_EventScript_277036:: @ 8277036 - special sub_809D2BC + special SetCableClubWarp warp MAP_DOUBLE_BATTLE_COLOSSEUM, 255, 5, 8 special sub_80AF948 waitstate @@ -576,7 +576,7 @@ OldaleTown_PokemonCenter_2F_EventScript_27713A:: @ 827713A closedoor 9, 1 waitdooranim release - special sub_809D2BC + special SetCableClubWarp setwarp MAP_TRADE_CENTER, 255, 5, 8 special sub_80AF948 waitstate @@ -651,7 +651,7 @@ OldaleTown_PokemonCenter_2F_EventScript_27724C:: @ 827724C closedoor 9, 1 waitdooranim release - special sub_809D2BC + special SetCableClubWarp setwarp MAP_RECORD_CORNER, 255, 8, 9 special sub_80AF948 waitstate @@ -702,7 +702,7 @@ MossdeepCity_GameCorner_1F_EventScript_2772F9:: @ 82772F9 end OldaleTown_PokemonCenter_2F_EventScript_277306:: @ 8277306 - special sub_809D2BC + special SetCableClubWarp special sub_80AF948 waitstate end @@ -784,7 +784,7 @@ MossdeepCity_GameCorner_1F_Movement_277360: @ 8277360 walk_up step_end -gUnknown_08277365:: @ 8277365 +EventScript_CableBoxResults:: @ 8277365 lockall setvar VAR_0x8004, 0 special ShowLinkBattleRecords @@ -1050,7 +1050,7 @@ OldaleTown_PokemonCenter_2F_EventScript_27759F:: @ 827759F closedoor 5, 1 waitdooranim special sub_8018090 - special sub_809D2BC + special SetCableClubWarp warpteleport2 MAP_UNION_ROOM, 255, 7, 11 waitstate special UnionRoomSpecial @@ -1392,7 +1392,7 @@ OldaleTown_PokemonCenter_2F_EventScript_277B3A:: @ 8277B3A waitstate end -OldaleTown_PokemonCenter_2F_EventScript_277B8A:: @ 8277B8A +EventScript_WirelessBoxResults:: @ 8277B8A lockall checkflag FLAG_SYS_POKEDEX_GET goto_if 0, OldaleTown_PokemonCenter_2F_EventScript_27733F diff --git a/data/scripts/day_care.inc b/data/scripts/day_care.inc index d9b8a89ac3..7b306a2614 100644 --- a/data/scripts/day_care.inc +++ b/data/scripts/day_care.inc @@ -289,7 +289,7 @@ Route117_PokemonDayCare_EventScript_291F95:: @ 8291F95 release end -Route117_PokemonDayCare_EventScript_291FC0:: @ 8291FC0 +EventScript_EggHatch:: @ 8291FC0 lockall msgbox Text_292668, 4 special EggHatch diff --git a/data/scripts/field_move_scripts.inc b/data/scripts/field_move_scripts.inc index d0936b9c12..aba6bec97a 100644 --- a/data/scripts/field_move_scripts.inc +++ b/data/scripts/field_move_scripts.inc @@ -223,7 +223,7 @@ FieryPath_Text_290A16: @ 8290A16 .string "STRENGTH made it possible to move\n" .string "boulders around.$" -EventScript_290A49:: @ 8290A49 +EventScript_UseWaterfall:: @ 8290A49 lockall checkpartymove MOVE_WATERFALL compare VAR_RESULT, 6 @@ -237,7 +237,7 @@ EventScript_290A49:: @ 8290A49 dofieldeffect 43 goto EventScript_290A8C -EventScript_290A83:: @ 8290A83 +EventScript_CannotUseWaterfall:: @ 8290A83 lockall EventScript_290A84:: @ 8290A84 @@ -258,7 +258,7 @@ Text_290AC3: @ 8290AC3 Text_290AFC: @ 8290AFC .string "{STR_VAR_1} used WATERFALL.$" -EventScript_290B0F:: @ 8290B0F +EventScript_UseDive:: @ 8290B0F lockall checkpartymove MOVE_DIVE compare VAR_RESULT, 6 @@ -283,7 +283,7 @@ EventScript_290B58:: @ 8290B58 releaseall end -EventScript_290B5A:: @ 8290B5A +EventScript_UseDiveUnderwater:: @ 8290B5A lockall checkpartymove MOVE_DIVE compare VAR_RESULT, 6 diff --git a/data/scripts/secret_power_tm.inc b/data/scripts/secret_power_tm.inc index 76a4ee8f14..33e7f2e5b7 100644 --- a/data/scripts/secret_power_tm.inc +++ b/data/scripts/secret_power_tm.inc @@ -104,10 +104,10 @@ Route111_Movement_276696: @ 8276696 walk_down step_end -EventScript_2766A2:: @ 82766A2 +EventScript_SecretPower1:: @ 82766A2 special sub_80EB290 end -EventScript_2766A6:: @ 82766A6 +EventScript_SecretPower2:: @ 82766A6 special sub_80EB2C8 end diff --git a/data/scripts/tv.inc b/data/scripts/tv.inc index 8d1ac83eba..2292e9984f 100644 --- a/data/scripts/tv.inc +++ b/data/scripts/tv.inc @@ -1,4 +1,4 @@ -EventScript_27EE0B:: @ 827EE0B +EventScript_TV:: @ 827EE0B lockall incrementgamestat 44 special ResetTVShowState diff --git a/data/specials.inc b/data/specials.inc index 4d11cf3048..cec36932ab 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -9,7 +9,7 @@ .align 2 gSpecials:: @ 81DBA64 def_special HealPlayerParty - def_special sub_809D2BC + def_special SetCableClubWarp def_special sub_80AF948 def_special sub_80AF9F8 def_special sub_80B36EC diff --git a/include/battle_frontier_1.h b/include/battle_frontier_1.h new file mode 100644 index 0000000000..bc777914a3 --- /dev/null +++ b/include/battle_frontier_1.h @@ -0,0 +1,6 @@ +#ifndef GUARD_BATTLE_FRONTIER_1_H +#define GUARD_BATTLE_FRONTIER_1_H + +bool32 sub_8196034(void); + +#endif // GUARD_BATTLE_FRONTIER_1_H diff --git a/include/constants/flags.h b/include/constants/flags.h index a74dffccf9..ff403a2999 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -501,7 +501,7 @@ #define FLAG_0x1F1 0x1F1 #define FLAG_0x1F2 0x1F2 #define FLAG_0x1F3 0x1F3 -#define FLAG_0x1F4 0x1F4 +#define FLAG_HIDDEN_ITEMS_START 0x1F4 #define FLAG_0x1F5 0x1F5 #define FLAG_0x1F6 0x1F6 #define FLAG_0x1F7 0x1F7 diff --git a/include/daycare.h b/include/daycare.h index 7db44e0240..ecd875865c 100644 --- a/include/daycare.h +++ b/include/daycare.h @@ -15,7 +15,7 @@ void TriggerPendingDaycareEgg(void); void RejectEggFromDayCare(void); void CreateEgg(struct Pokemon *mon, u16 species, bool8 setHotSpringsLocation); void GiveEggFromDaycare(void); -bool8 DoEggActions_CheckHatch(void); +bool8 ShouldEggHatch(void); u16 GetSelectedMonNickAndSpecies(void); void GetDaycareMonNicknames(void); u8 GetDaycareState(void); diff --git a/include/event_scripts.h b/include/event_scripts.h index 4f85156aab..5b8b74d8b4 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -19,8 +19,8 @@ extern const u8 EventScript_TryDoDoubleTrainerBattle[]; extern const u8 EventScript_271362[]; extern const u8 EventScript_TryDoDoubleRematchBattle[]; extern const u8 EventScript_2713D1[]; -extern const u8 EventScript_2766A2[]; -extern const u8 EventScript_2766A6[]; +extern const u8 EventScript_SecretPower1[]; +extern const u8 EventScript_SecretPower2[]; extern const u8 gTVBravoTrainerText00[]; diff --git a/include/field_control_avatar.h b/include/field_control_avatar.h index 0ff1834cac..536f218a3e 100644 --- a/include/field_control_avatar.h +++ b/include/field_control_avatar.h @@ -3,22 +3,22 @@ struct FieldInput { - u8 pressedAButton:1; - u8 input_field_0_1:1; - u8 pressedStartButton:1; - u8 pressedSelectButton:1; - u8 input_field_0_4:1; - u8 input_field_0_5:1; - u8 input_field_0_6:1; - u8 pressedBButton:1; - u8 input_field_1_0:1; - u8 input_field_1_1:1; - u8 input_field_1_2:1; - u8 input_field_1_3:1; - u8 input_field_1_4:1; - u8 input_field_1_5:1; - u8 input_field_1_6:1; - u8 input_field_1_7:1; + bool8 pressedAButton:1; + bool8 checkStandardWildEncounter:1; + bool8 pressedStartButton:1; + bool8 pressedSelectButton:1; + bool8 input_field_0_4:1; + bool8 input_field_0_5:1; + bool8 tookStep:1; + bool8 pressedBButton:1; + bool8 input_field_1_0:1; + bool8 input_field_1_1:1; + bool8 input_field_1_2:1; + bool8 input_field_1_3:1; + bool8 input_field_1_4:1; + bool8 input_field_1_5:1; + bool8 input_field_1_6:1; + bool8 input_field_1_7:1; u8 dpadDirection; u8 input_field_3; }; @@ -28,15 +28,15 @@ void FieldGetPlayerInput(struct FieldInput *pStruct, u16 keys, u16 heldKeys); int sub_809C014(struct FieldInput *pStruct); u8 *sub_80682A8(struct MapPosition *, u8, u8); void overworld_poison_timer_set(void); -void prev_quest_postbuffer_cursor_backup_reset(void); +void RestartWildEncounterImmunitySteps(void); u8 *sub_8068E24(struct MapPosition *); -u8 *GetEventObjectScriptPointerPlayerFacing(void); -bool8 mapheader_trigger_activate_at__run_now(struct MapPosition *); +const u8 *GetEventObjectScriptPointerPlayerFacing(void); bool8 sub_8068870(u16 a); bool8 sub_8068894(void); bool8 sub_8068A64(struct MapPosition *, u16); u8 sub_8068F18(void); bool8 dive_warp(struct MapPosition *position, u16 b); -void sub_809D2BC(void); +int SetCableClubWarp(void); +u8 TrySetDiveWarp(void); #endif // GUARD_FIELDCONTROLAVATAR_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index b11b5e21ad..ee2cbb3c87 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -44,6 +44,9 @@ u8 GetPlayerAvatarGraphicsIdByCurrentState(void); void SetPlayerAvatarStateMask(u8 a); u8 GetPlayerAvatarGraphicsIdByStateId(u8 a); u8 GetJumpSpecialMovementAction(u32); +bool8 PartyHasMonWithSurf(void); +bool8 IsPlayerFacingSurfableFishableWater(void); +bool8 IsPlayerSurfingNorth(void); bool8 ForcedMovement_None(void); bool8 ForcedMovement_Slip(void); diff --git a/include/field_poison.h b/include/field_poison.h index d1a4c823b8..6a1ba17f28 100644 --- a/include/field_poison.h +++ b/include/field_poison.h @@ -14,6 +14,6 @@ enum { }; void sub_80F972C(void); -unsigned int overworld_poison(void); +int DoPoisonFieldEffect(void); #endif //GUARD_FIELD_POISON_H diff --git a/include/field_screen.h b/include/field_screen.h index bf15024053..021d2b9e9a 100644 --- a/include/field_screen.h +++ b/include/field_screen.h @@ -16,5 +16,9 @@ void sub_80AC3E4(void); void PreservePaletteInWeather(u8); void sub_80AF128(void); void sub_80AB104(u8); +void sub_80AF80C(u8); +void sub_80AF828(void); +void sub_80AF838(void); +void sub_80B0268(void); #endif //GUARD_FIELD_SCREEN_H diff --git a/include/field_specials.h b/include/field_specials.h index 4709f95512..0e2daf9c32 100644 --- a/include/field_specials.h +++ b/include/field_specials.h @@ -6,5 +6,14 @@ u8 sub_813B260(void); u16 get_unknown_box_id(void); bool8 InMultiBattleRoom(void); void sub_813BF10(void); +void increment_var_x4026_on_birth_island_modulo_100(void); +bool8 sub_813B3B0(void); +bool8 ShouldDoBrailleRegicePuzzle(void); +bool32 is_tile_that_overrides_player_control(void); +bool32 sub_8138120(void); +bool32 sub_8138168(void); +bool32 sub_81381B0(void); +bool32 sub_81381F8(void); +bool32 CountSSTidalStep(u16 delta); #endif // GUARD_FIELD_SPECIALS_H diff --git a/include/fldeff_80F9BCC.h b/include/fldeff_80F9BCC.h index ba775cd6db..87a20d290a 100644 --- a/include/fldeff_80F9BCC.h +++ b/include/fldeff_80F9BCC.h @@ -12,6 +12,8 @@ void sub_80FA794(s16 x, s16 y); void CreateRecordMixingSprite(void); void DestroyRecordMixingSprite(void); void overworld_poison_effect(void); +void sub_80FA970(s16); +void sub_80FA9D0(void); bool8 sub_80FADE4(u16, u8); #endif //GUARD_FLDEFF_80F9BCC_H diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 4bec8e0c7c..66d5b5e4c3 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -63,17 +63,16 @@ struct EventObjectTemplate struct WarpEvent { s16 x, y; - s8 warpId; - u8 mapGroup; + u8 elevation; + u8 warpId; u8 mapNum; - u8 unk7; + u8 mapGroup; }; struct CoordEvent { s16 x, y; - u8 unk4; - u8 filler_5; + u8 elevation; u16 trigger; u16 index; u8 filler_A[0x2]; @@ -83,16 +82,15 @@ struct CoordEvent struct BgEvent { u16 x, y; - u8 unk4; + u8 elevation; u8 kind; - // 0x2 padding for the union beginning. union { // carried over from diego's FR/LG work, seems to be the same struct // in gen 3, "kind" (0x3 in BgEvent struct) determines the method to read the union. u8 *script; - // hidden item type probably + // hidden item type struct { - u8 filler6[0x2]; + u16 item; u16 hiddenItemId; // flag offset to determine flag lookup } hiddenItem; diff --git a/include/item_menu.h b/include/item_menu.h index 59316e9483..b80d0628e0 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -58,5 +58,6 @@ void sub_81AAC28(void); void bag_menu_mail_related(void); void CB2_BagMenuFromStartMenu(void); u8 sub_81ABB2C(u8 pocketId); +bool8 UseRegisteredKeyItemOnField(void); #endif //GUARD_item_menu_H diff --git a/include/metatile_behavior.h b/include/metatile_behavior.h index edffc711fd..8301a22f27 100644 --- a/include/metatile_behavior.h +++ b/include/metatile_behavior.h @@ -50,7 +50,7 @@ bool8 MetatileBehavior_IsSecretBaseCave(u8); bool8 MetatileBehavior_IsSecretBaseTree(u8); bool8 MetatileBehavior_IsSecretBaseShrub(u8); bool8 MetatileBehavior_IsSecretBasePC(u8); -bool8 MetatileBehavior_IsSecretBaseRegisterPC(u8); +bool8 MetatileBehavior_IsRecordMixingSecretBasePC(u8); bool8 MetatileBehavior_IsMB_B2(u8); bool8 MetatileBehavior_IsBlockDecoration(u8); bool8 MetatileBehavior_IsSecretBaseImpassable(u8); @@ -67,7 +67,7 @@ bool8 MetatileBehavior_IsSecretBaseBreakableDoor(u8); bool8 MetatileBehavior_IsSecretBaseSoundMat(u8); bool8 MetatileBehavior_IsSecretBaseGlitterMat(u8); bool8 MetatileBehavior_IsSecretBaseSandOrnament(u8); -bool8 MetatileBehavior_IsSecretBaseTvOrShield(u8); +bool8 MetatileBehavior_IsSecretBaseShieldOrToyTV(u8); bool8 MetatileBehavior_IsPlayerRoomPCOn(u8); bool8 MetatileBehavior_HasRipples(u8); bool8 MetatileBehavior_IsPuddle(u8); @@ -106,14 +106,14 @@ bool8 MetatileBehavior_IsPacifilogHorizontalLog2(u8); bool8 MetatileBehavior_IsPacifidlogLog(u8); bool8 MetatileBehavior_IsTrickHousePuzzleDoor(u8); bool8 MetatileBehavior_IsRegionMap(u8); -bool8 MetatileBehavior_IsClosedSootopolisGymDoor(u8); +bool8 MetatileBehavior_IsClosedSootopolisDoor(u8); bool8 MetatileBehavior_IsUnknownClosedDoor(u8); bool8 MetatileBehavior_IsRoulette(u8); bool8 MetatileBehavior_IsPokeblockFeeder(u8); bool8 MetatileBehavior_IsSecretBaseJumpMat(u8); bool8 MetatileBehavior_IsSecretBaseSpinMat(u8); bool8 MetatileBehavior_IsLavaridgeB1FWarp(u8); -bool8 MetatileBehavior_IsLavaridgeB1FWarp(u8); +bool8 MetatileBehavior_IsLavaridge1FWarp(u8); bool8 MetatileBehavior_IsAquaHideoutWarp(u8); bool8 MetatileBehavior_IsWarpOrBridge(u8); bool8 MetatileBehavior_IsMossdeepGymWarp(u8); @@ -130,7 +130,7 @@ bool8 MetatileBehavior_IsHorizontalRail(u8); bool8 MetatileBehavior_IsSeaweed(u8); bool8 MetatileBehavior_IsRunningDisallowed(u8); bool8 MetatileBehavior_IsCuttableGrass(u8); -bool8 MetatileBehavior_IsRunningShoesInstruction(u8); +bool8 MetatileBehavior_IsRunningShoesManual(u8); bool8 MetatileBehavior_IsPictureBookShelf(u8); bool8 MetatileBehavior_IsBookShelf(u8); bool8 MetatileBehavior_IsPokeCenterBookShelf(u8); diff --git a/include/pokemon.h b/include/pokemon.h index d261fba859..8259e7d34e 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -94,6 +94,8 @@ #define MON_DATA_SPATK2 87 #define MON_DATA_SPDEF2 88 +#define MAX_LEVEL 100 + #define OT_ID_RANDOM_NO_SHINY 2 #define OT_ID_PRESET 1 #define OT_ID_PLAYER_ID 0 @@ -110,10 +112,47 @@ #define MON_FEMALE 0xFE #define MON_GENDERLESS 0xFF +#define TYPE_NORMAL 0x00 +#define TYPE_FIGHTING 0x01 +#define TYPE_FLYING 0x02 +#define TYPE_POISON 0x03 +#define TYPE_GROUND 0x04 +#define TYPE_ROCK 0x05 +#define TYPE_BUG 0x06 +#define TYPE_GHOST 0x07 +#define TYPE_STEEL 0x08 +#define TYPE_MYSTERY 0x09 +#define TYPE_FIRE 0x0a +#define TYPE_WATER 0x0b +#define TYPE_GRASS 0x0c +#define TYPE_ELECTRIC 0x0d +#define TYPE_PSYCHIC 0x0e +#define TYPE_ICE 0x0f +#define TYPE_DRAGON 0x10 +#define TYPE_DARK 0x11 + +#define FRIENDSHIP_EVENT_GROW_LEVEL 0x0 +#define FRIENDSHIP_EVENT_VITAMIN 0x1 // unused +#define FRIENDSHIP_EVENT_BATTLE_ITEM 0x2 // unused +#define FRIENDSHIP_EVENT_LEAGUE_BATTLE 0x3 +#define FRIENDSHIP_EVENT_LEARN_TMHM 0x4 +#define FRIENDSHIP_EVENT_WALKING 0x5 +#define FRIENDSHIP_EVENT_FAINT_SMALL 0x6 +#define FRIENDSHIP_EVENT_FAINT_OUTSIDE_BATTLE 0x7 +#define FRIENDSHIP_EVENT_FAINT_LARGE 0x8 + +#define STATUS_PRIMARY_NONE 0x0 +#define STATUS_PRIMARY_POISON 0x1 +#define STATUS_PRIMARY_PARALYSIS 0x2 +#define STATUS_PRIMARY_SLEEP 0x3 +#define STATUS_PRIMARY_FREEZE 0x4 +#define STATUS_PRIMARY_BURN 0x5 +#define STATUS_PRIMARY_POKERUS 0x6 +#define STATUS_PRIMARY_FAINTED 0x7 + #define MAX_TOTAL_EVS 510 #define NUM_STATS 6 #define UNOWN_FORM_COUNT 28 -#define MAX_MON_LEVEL 100 struct PokemonSubstruct0 { @@ -421,7 +460,7 @@ extern const u8 gFacilityClassToTrainerClass[]; extern const struct BaseStats gBaseStats[]; extern const u8 *const gItemEffectTable[]; extern const struct Evolution gEvolutionTable[][EVOS_PER_MON]; -extern const u32 gExperienceTables[][MAX_MON_LEVEL + 1]; +extern const u32 gExperienceTables[][MAX_LEVEL + 1]; extern const u16 *const gLevelUpLearnsets[]; extern const u8 gUnknown_08329D22[]; extern const u8 gUnknown_08329D26[]; diff --git a/include/pokenav.h b/include/pokenav.h index b595e2be91..1fde8aa44f 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -28,5 +28,13 @@ u16 sub_81D2C3C(void); void sub_81D2C50(void); u8 sub_81D28C8(const struct ListMenuItem *items, u16 numChoices); void sub_81D2824(u16); +bool32 InTrainerHill(void); +bool8 EventObjectIsFarawayIslandMew(struct EventObject *); +u32 sub_81D427C(void); +void sub_81D4998(void); +u8 GetCurrentTrainerHillMapId(void); +u8 sub_81D6490(void); +const struct WarpEvent *sub_81D6120(void); +const struct WarpEvent *sub_81D6134(u8); #endif //GUARD_POKENAV_H diff --git a/include/rom_81BE66C.h b/include/rom_81BE66C.h deleted file mode 100644 index 900daf4e73..0000000000 --- a/include/rom_81BE66C.h +++ /dev/null @@ -1,12 +0,0 @@ -// -// Created by Scott Norton on 9/6/17. -// - -#ifndef GUARD_ROM_81BE66C_H -#define GUARD_ROM_81BE66C_H - -bool32 InTrainerHill(void); -bool8 EventObjectIsFarawayIslandMew(struct EventObject *); -u32 sub_81D427C(void); - -#endif //GUARD_ROM_81BE66C_H diff --git a/include/script.h b/include/script.h index 2b5f8c2ce7..755ff19a38 100644 --- a/include/script.h +++ b/include/script.h @@ -55,8 +55,8 @@ bool8 mapheader_run_first_tag2_script_list_match(void); void mapheader_run_first_tag4_script_list_match(void); u32 CalculateRamScriptChecksum(void); void ClearRamScript(void); -bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId); -u8 *GetRamScript(u8 objectId, u8 *script); +bool8 InitRamScript(const u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId); +const u8 *GetRamScript(u8 objectId, const u8 *script); bool32 sub_80991F8(void); u8 *sub_8099244(void); void sub_80992A0(u8 *script, u16 scriptSize); diff --git a/include/secret_base.h b/include/secret_base.h index c205336981..4fa0d0c4ad 100644 --- a/include/secret_base.h +++ b/include/secret_base.h @@ -16,5 +16,11 @@ void sub_80E8EE0(struct MapEvents const *events); void sub_80E9238(u8 flagIn); bool8 CurrentMapIsSecretBase(void); void sub_80EA3E4(u8 taskId); +bool8 sub_80E9680(void); +void sub_80EB498(void); +void sub_80EB56C(void); +void sub_80EB9E0(void); +void sub_80EBB28(void); +void sub_80E9668(const struct MapPosition *position, const struct MapEvents *events); #endif //GUARD_SECRET_BASE_H diff --git a/ld_script.txt b/ld_script.txt index 50ce3bb6df..9592d5cf6e 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -99,7 +99,7 @@ SECTIONS { src/text_window.o(.text); src/script.o(.text); src/scrcmd.o(.text); - asm/field_control_avatar.o(.text); + src/field_control_avatar.o(.text); src/event_data.o(.text); src/coord_event_weather.o(.text); src/field_tasks.o(.text); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 57a4efa9ff..02479a1bee 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -2710,7 +2710,7 @@ static void PlayerHandleExpUpdate(void) { u8 monId = gBattleBufferA[gActiveBattler][1]; - if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_MON_LEVEL) + if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_LEVEL) { PlayerBufferExecCompleted(); } diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 7795c56566..c72847bd22 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -1597,7 +1597,7 @@ static void PlayerPartnerHandleExpUpdate(void) { u8 monId = gBattleBufferA[gActiveBattler][1]; - if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_MON_LEVEL) + if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_LEVEL) { PlayerPartnerBufferExecCompleted(); } diff --git a/src/battle_interface.c b/src/battle_interface.c index d2750bf9d4..691e760a88 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -2341,7 +2341,7 @@ static void MoveBattleBarGraphically(u8 battlerId, u8 whichBar) &gBattleSpritesDataPtr->battleBars[battlerId].currValue, array, B_EXPBAR_PIXELS / 8); level = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_LEVEL); - if (level == MAX_MON_LEVEL) + if (level == MAX_LEVEL) { for (i = 0; i < 8; i++) array[i] = 0; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 685f0db7a3..cdc996a4d9 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3347,7 +3347,7 @@ static void atk23_getexp(void) gBattleScripting.atk23_state = 5; gBattleMoveDamage = 0; // used for exp } - else if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) == MAX_MON_LEVEL) + else if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) == MAX_LEVEL) { *(&gBattleStruct->sentInPokes) >>= 1; gBattleScripting.atk23_state = 5; @@ -3430,7 +3430,7 @@ static void atk23_getexp(void) if (gBattleControllerExecFlags == 0) { gBattleBufferB[gBattleStruct->expGetterBattlerId][0] = 0; - if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_HP) && GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) != MAX_MON_LEVEL) + if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_HP) && GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) != MAX_LEVEL) { gBattleResources->statsBeforeLvlUp->hp = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP); gBattleResources->statsBeforeLvlUp->atk = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK); diff --git a/src/battle_setup.c b/src/battle_setup.c index f9fab3d172..db173a38e1 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -56,8 +56,8 @@ extern bool8 InBattlePyramid(void); extern bool8 InBattlePike(void); extern bool32 InTrainerHill(void); extern bool32 FieldPoisonEffectIsRunning(void); -extern void prev_quest_postbuffer_cursor_backup_reset(void); -extern void ResetPoisonStepCounter(void); +extern void RestartWildEncounterImmunitySteps(void); +extern void ClearPoisonStepCounter(void); extern void sub_81BE72C(void); extern void sub_808BCF4(void); extern void sub_80EECC8(void); @@ -354,8 +354,8 @@ static void Task_BattleStart(u8 taskId) { overworld_free_bg_tilemaps(); SetMainCallback2(CB2_InitBattle); - prev_quest_postbuffer_cursor_backup_reset(); - ResetPoisonStepCounter(); + RestartWildEncounterImmunitySteps(); + ClearPoisonStepCounter(); DestroyTask(taskId); } break; @@ -921,8 +921,8 @@ static void CB2_StartFirstBattle(void) gMain.savedCallback = CB2_EndFirstBattle; FreeAllWindowBuffers(); SetMainCallback2(CB2_InitBattle); - prev_quest_postbuffer_cursor_backup_reset(); - ResetPoisonStepCounter(); + RestartWildEncounterImmunitySteps(); + ClearPoisonStepCounter(); IncrementGameStat(GAME_STAT_TOTAL_BATTLES); IncrementGameStat(GAME_STAT_WILD_BATTLES); sub_80EECC8(); diff --git a/src/berry.c b/src/berry.c index ea216b61c4..66cf914099 100644 --- a/src/berry.c +++ b/src/berry.c @@ -11,7 +11,7 @@ extern u8 EventObjectGetBerryTreeId(u8 eventObjectId); extern void sub_8092EF0(u8 mapId, u8 mapNumber, u8 mapGroup); extern void CB2_ChooseBerry(void); -extern const u8* GetEventObjectScriptPointerForComparison(void); +extern const u8* GetEventObjectScriptPointerPlayerFacing(void); extern bool8 IsBerryTreeSparkling(u8, u8, u8); extern u16 gSpecialVar_ItemId; @@ -930,7 +930,7 @@ bool32 EventObjectInteractionWaterBerryTree(void) bool8 IsPlayerFacingPlantedBerryTree(void) { - if (GetEventObjectScriptPointerForComparison() == BerryTreeScript + if (GetEventObjectScriptPointerPlayerFacing() == BerryTreeScript && GetStageByBerryTreeId(EventObjectGetBerryTreeId(gSelectedEventObject)) == 0) return TRUE; else @@ -939,7 +939,7 @@ bool8 IsPlayerFacingPlantedBerryTree(void) bool8 TryToWaterBerryTree(void) { - if (GetEventObjectScriptPointerForComparison() != BerryTreeScript) + if (GetEventObjectScriptPointerPlayerFacing() != BerryTreeScript) return FALSE; else return EventObjectInteractionWaterBerryTree(); diff --git a/src/data/pokemon/experience_tables.h b/src/data/pokemon/experience_tables.h index 58474b6f19..9fd5a2fae5 100644 --- a/src/data/pokemon/experience_tables.h +++ b/src/data/pokemon/experience_tables.h @@ -18,7 +18,7 @@ :(n <= 36) ? ((n + 14) * CUBE(n) / 50) \ : (((n / 2) + 32) * CUBE(n) / 50) -const u32 gExperienceTables[][MAX_MON_LEVEL + 1] = +const u32 gExperienceTables[][MAX_LEVEL + 1] = { { // Medium Fast 0, // 0 diff --git a/src/daycare.c b/src/daycare.c index 934cdea439..c80a8b743a 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -241,7 +241,7 @@ static void ApplyDaycareExperience(struct Pokemon *mon) bool8 firstMove; u16 learnedMove; - for (i = 0; i < MAX_MON_LEVEL; i++) + for (i = 0; i < MAX_LEVEL; i++) { // Add the mon's gained daycare experience level by level until it can't level up anymore. if (TryIncrementMonLevel(mon)) @@ -278,7 +278,7 @@ static u16 TakeSelectedPokemonFromDaycare(struct DaycareMon *daycareMon) species = GetBoxMonData(&daycareMon->mon, MON_DATA_SPECIES); BoxMonToMon(&daycareMon->mon, &pokemon); - if (GetMonData(&pokemon, MON_DATA_LEVEL) != MAX_MON_LEVEL) + if (GetMonData(&pokemon, MON_DATA_LEVEL) != MAX_LEVEL) { experience = GetMonData(&pokemon, MON_DATA_EXP) + daycareMon->steps; SetMonData(&pokemon, MON_DATA_EXP, &experience); @@ -949,7 +949,7 @@ static bool8 _DoEggActions_CheckHatch(struct DayCare *daycare) return FALSE; // no hatching } -bool8 DoEggActions_CheckHatch(void) +bool8 ShouldEggHatch(void) { return _DoEggActions_CheckHatch(&gSaveBlock1Ptr->daycare); } diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 8c5c92473d..57f72b2843 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -17,7 +17,6 @@ #include "pokenav.h" #include "random.h" #include "rom_818CFC8.h" -#include "rom_81BE66C.h" #include "sprite.h" #include "trainer_see.h" #include "util.h" @@ -2638,10 +2637,10 @@ void sub_808F28C(u8 localId, u8 mapNum, u8 mapGroup, u8 decorCat) switch (decorCat) { case DECORCAT_DOLL: - OverrideMovementTypeForEventObject(&gEventObjects[eventObjectId], EventScript_2766A2); + OverrideMovementTypeForEventObject(&gEventObjects[eventObjectId], EventScript_SecretPower1); break; case DECORCAT_CUSHION: - OverrideMovementTypeForEventObject(&gEventObjects[eventObjectId], EventScript_2766A6); + OverrideMovementTypeForEventObject(&gEventObjects[eventObjectId], EventScript_SecretPower2); break; } } diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c new file mode 100644 index 0000000000..fef403c040 --- /dev/null +++ b/src/field_control_avatar.c @@ -0,0 +1,1058 @@ +#include "global.h" +#include "battle_setup.h" +#include "battle_frontier_1.h" +#include "bike.h" +#include "coord_event_weather.h" +#include "daycare.h" +#include "event_data.h" +#include "event_object_movement.h" +#include "fieldmap.h" +#include "field_control_avatar.h" +#include "field_fadetransition.h" +#include "field_player_avatar.h" +#include "field_poison.h" +#include "field_screen.h" +#include "field_specials.h" +#include "fldeff_80F9BCC.h" +#include "item_menu.h" +#include "link.h" +#include "metatile_behavior.h" +#include "overworld.h" +#include "pokemon.h" +#include "pokenav.h" +#include "safari_zone.h" +#include "script.h" +#include "secret_base.h" +#include "sound.h" +#include "start_menu.h" +#include "trainer_see.h" +#include "wild_encounter.h" +#include "constants/bg_event_constants.h" +#include "constants/map_types.h" +#include "constants/songs.h" + +static EWRAM_DATA u8 sWildEncounterImmunitySteps = 0; +static EWRAM_DATA u16 sPreviousPlayerMetatileBehavior = 0; + +u8 gSelectedEventObject; + +//scripts +extern const u8 EventScript_PlayerPCMale[]; +extern const u8 EventScript_PlayerPCFemale[]; +extern const u8 EventScript_SecretBasePC[]; +extern const u8 EventScript_RecordMixingSecretBasePC[]; +extern const u8 EventScript_SecretPower1[]; +extern const u8 EventScript_SecretPower2[]; +extern const u8 EventScript_PC[]; +extern const u8 EventScript_TestSignpostMsg[]; +extern const u8 EventScript_HiddenItemScript[]; +extern const u8 EventScript_2759F1[]; +extern const u8 EventScript_TV[]; +extern const u8 EventScript_ClosedSootopolisDoor[]; +extern const u8 SkyPillar_Outside_EventScript_2393F9[]; +extern const u8 EventScript_CableBoxResults[]; +extern const u8 EventScript_2A4BAC[]; +extern const u8 Route110_TrickHouseEntrance_EventScript_26A22A[]; +extern const u8 EventScript_RegionMap[]; +extern const u8 EventScript_RunningShoesManual[]; +extern const u8 EventScript_PictureBookShelf[]; +extern const u8 EventScript_BookShelf[]; +extern const u8 EventScript_PokemonCenterBookshelf[]; +extern const u8 EventScript_Vase[]; +extern const u8 EventScript_TrashCan[]; +extern const u8 EventScript_ShopShelf[]; +extern const u8 EventScript_Blueprint[]; +extern const u8 EventScript_WirelessBoxResults[]; +extern const u8 EventScript_CableBoxResults[]; +extern const u8 EventScript_Questionnaire[]; +extern const u8 EventScript_TrainerHillTimer[]; +extern const u8 EventScript_SecretBaseSandOrnament[]; +extern const u8 EventScript_SecretBaseShieldOrToyTV[]; +extern const u8 EventScript_UseSurf[]; +extern const u8 EventScript_UseWaterfall[]; +extern const u8 EventScript_CannotUseWaterfall[]; +extern const u8 EventScript_UseDive[]; +extern const u8 EventScript_UseDiveUnderwater[]; +extern const u8 EventScript_FallDownHole[]; +extern const u8 BattleFrontier_BattlePyramidEmptySquare_EventScript_252BE8[]; +extern const u8 EventScript_Poison[]; +extern const u8 EventScript_EggHatch[]; +extern const u8 gUnknown_08273D1F[]; +extern const u8 IslandCave_EventScript_238EAF[]; +extern const u8 MauvilleCity_EventScript_1DF7BA[]; +extern const u8 Route119_EventScript_1F49EC[]; +extern const u8 LittlerootTown_ProfessorBirchsLab_EventScript_1FA4D6[]; +extern const u8 RustboroCity_Gym_EventScript_21307B[]; +extern const u8 MossdeepCity_SpaceCenter_2F_EventScript_224175[]; +extern const u8 SSTidalCorridor_EventScript_23C050[]; +extern const u8 gUnknown_082A8350[]; + +static void GetPlayerPosition(struct MapPosition *); +static void GetInFrontOfPlayerPosition(struct MapPosition *); +static u16 GetPlayerCurMetatileBehavior(int); +static bool8 TryStartInteractionScript(struct MapPosition*, u16, u8); +static const u8 *GetInteractionScript(struct MapPosition*, u8, u8); +static const u8 *GetInteractedEventObjectScript(struct MapPosition *, u8, u8); +static const u8 *GetInteractedBackgroundEventScript(struct MapPosition *, u8, u8); +static const u8 *GetInteractedMetatileScript(struct MapPosition *, u8, u8); +static const u8 *GetInteractedWaterScript(struct MapPosition *, u8, u8); +static bool32 TrySetupDiveDownScript(void); +static bool32 TrySetupDiveEmergeScript(void); +static bool8 TryStartStepBasedScript(struct MapPosition *, u16, u16); +static bool8 CheckStandardWildEncounter(u16); +static bool8 mapheader_run_first_tag2_script_list_match_conditionally(struct MapPosition *, u16, u8); +static bool8 IsWarpMetatileBehavior(u16); +static bool8 IsArrowWarpMetatileBehavior(u16, u8); +static s8 GetWarpEventAtMapPosition(struct MapHeader *, struct MapPosition *); +static void sub_809CEB0(struct MapHeader *, s8, struct MapPosition *); +static bool8 map_warp_consider_2_to_inside(struct MapPosition *, u16, u8); +static s8 GetWarpEventAtPosition(struct MapHeader *, u16, u16, u8); +static u8 *GetCoordEventScriptAtPosition(struct MapHeader *, u16, u16, u8); +static struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *, u16, u16, u8); +static bool8 TryStartCoordEventScript(struct MapPosition *); +static bool8 TryStartWarpEventScript(struct MapPosition *, u16); +static bool8 TryStartMiscWalkingScripts(u16); +static bool8 TryStartStepCountScript(u16); +static void UpdateHappinessStepCounter(void); +static bool8 UpdatePoisonStepCounter(void); + +void FieldClearPlayerInput(struct FieldInput *input) +{ + input->pressedAButton = FALSE; + input->checkStandardWildEncounter = FALSE; + input->pressedStartButton = FALSE; + input->pressedSelectButton = FALSE; + input->input_field_0_4 = FALSE; + input->input_field_0_5 = FALSE; + input->tookStep = FALSE; + input->pressedBButton = FALSE; + input->input_field_1_0 = FALSE; + input->input_field_1_1 = FALSE; + input->input_field_1_2 = FALSE; + input->input_field_1_3 = FALSE; + input->dpadDirection = 0; +} + +void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys) +{ + u8 tileTransitionState = gPlayerAvatar.tileTransitionState; + u8 runningState = gPlayerAvatar.runningState; + bool8 forcedMove = MetatileBehavior_IsForcedMovementTile(GetPlayerCurMetatileBehavior(runningState)); + + if ((tileTransitionState == T_TILE_CENTER && forcedMove == FALSE) || tileTransitionState == T_NOT_MOVING) + { + if (GetPlayerSpeed() != 4) + { + if (newKeys & START_BUTTON) + input->pressedStartButton = TRUE; + if (newKeys & SELECT_BUTTON) + input->pressedSelectButton = TRUE; + if (newKeys & A_BUTTON) + input->pressedAButton = TRUE; + if (newKeys & B_BUTTON) + input->pressedBButton = TRUE; + } + + if (heldKeys & (DPAD_UP | DPAD_DOWN | DPAD_LEFT | DPAD_RIGHT)) + { + input->input_field_0_4 = TRUE; + input->input_field_0_5 = TRUE; + } + } + + if (forcedMove == FALSE) + { + if (tileTransitionState == T_TILE_CENTER && runningState == MOVING) + input->tookStep = TRUE; + if (forcedMove == FALSE && tileTransitionState == T_TILE_CENTER) + input->checkStandardWildEncounter = TRUE; + } + + if (heldKeys & DPAD_UP) + input->dpadDirection = DIR_NORTH; + else if (heldKeys & DPAD_DOWN) + input->dpadDirection = DIR_SOUTH; + else if (heldKeys & DPAD_LEFT) + input->dpadDirection = DIR_WEST; + else if (heldKeys & DPAD_RIGHT) + input->dpadDirection = DIR_EAST; +} + +int sub_809C014(struct FieldInput *input) +{ + struct MapPosition position; + u8 playerDirection; + u16 metatileBehavior; + + gSpecialVar_LastTalked = 0; + gSelectedEventObject = 0; + + playerDirection = GetPlayerFacingDirection(); + GetPlayerPosition(&position); + metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y); + + if (CheckForTrainersWantingBattle() == TRUE) + return TRUE; + + if (mapheader_run_first_tag2_script_list_match() == 1) + return TRUE; + + if (input->pressedBButton && TrySetupDiveEmergeScript() == TRUE) + return TRUE; + if (input->tookStep) + { + IncrementGameStat(GAME_STAT_STEPS); + increment_var_x4026_on_birth_island_modulo_100(); + if (TryStartStepBasedScript(&position, metatileBehavior, playerDirection) == TRUE) + return TRUE; + } + if (input->checkStandardWildEncounter && CheckStandardWildEncounter(metatileBehavior) == TRUE) + return TRUE; + if (input->input_field_0_4 && input->dpadDirection == playerDirection) + { + if (mapheader_run_first_tag2_script_list_match_conditionally(&position, metatileBehavior, playerDirection) == TRUE) + return TRUE; + } + + GetInFrontOfPlayerPosition(&position); + metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y); + if (input->pressedAButton && TryStartInteractionScript(&position, metatileBehavior, playerDirection) == TRUE) + return TRUE; + + if (input->input_field_0_5 && input->dpadDirection == playerDirection) + { + if (map_warp_consider_2_to_inside(&position, metatileBehavior, playerDirection) == TRUE) + return TRUE; + } + if (input->pressedAButton && TrySetupDiveDownScript() == TRUE) + return TRUE; + if (input->pressedStartButton) + { + PlaySE(SE_WIN_OPEN); + ShowStartMenu(); + return TRUE; + } + if (input->pressedSelectButton && UseRegisteredKeyItemOnField() == TRUE) + return TRUE; + + return FALSE; +} + +static void GetPlayerPosition(struct MapPosition *position) +{ + PlayerGetDestCoords(&position->x, &position->y); + position->height = PlayerGetZCoord(); +} + +static void GetInFrontOfPlayerPosition(struct MapPosition *position) +{ + s16 x, y; + + GetXYCoordsOneStepInFrontOfPlayer(&position->x, &position->y); + PlayerGetDestCoords(&x, &y); + if (MapGridGetZCoordAt(x, y) != 0) + position->height = PlayerGetZCoord(); + else + position->height = 0; +} + +static u16 GetPlayerCurMetatileBehavior(int runningState) +{ + s16 x, y; + + PlayerGetDestCoords(&x, &y); + return MapGridGetMetatileBehaviorAt(x, y); +} + +static bool8 TryStartInteractionScript(struct MapPosition *position, u16 metatileBehavior, u8 direction) +{ + const u8 *script = GetInteractionScript(position, metatileBehavior, direction); + if (script == NULL) + return FALSE; + + // Don't play interaction sound for certain scripts. + if (script != EventScript_PlayerPCMale + && script != EventScript_PlayerPCFemale + && script != EventScript_SecretBasePC + && script != EventScript_RecordMixingSecretBasePC + && script != EventScript_SecretPower1 + && script != EventScript_SecretPower2 + && script != EventScript_PC) + PlaySE(SE_SELECT); + + ScriptContext1_SetupScript(script); + return TRUE; +} + +static const u8 *GetInteractionScript(struct MapPosition *position, u8 metatileBehavior, u8 direction) +{ + const u8 *script = GetInteractedEventObjectScript(position, metatileBehavior, direction); + if (script != NULL) + return script; + + script = GetInteractedBackgroundEventScript(position, metatileBehavior, direction); + if (script != NULL) + return script; + + script = GetInteractedMetatileScript(position, metatileBehavior, direction); + if (script != NULL) + return script; + + script = GetInteractedWaterScript(position, metatileBehavior, direction); + if (script != NULL) + return script; + + return NULL; +} + +const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatileBehavior, u8 direction) +{ + u8 eventObjectId; + s32 i; + + if (!MetatileBehavior_IsCounter(MapGridGetMetatileBehaviorAt(position->x, position->y))) + eventObjectId = GetEventObjectIdByXYZ(position->x, position->y, position->height); + else + eventObjectId = GetEventObjectIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height); + + if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == 0xFF) + return NULL; + + for (i = 0; i < 4; i++) + { + if (gLinkPlayerEventObjects[i].active == TRUE && gLinkPlayerEventObjects[i].eventObjId == eventObjectId) + return NULL; + } + + gSelectedEventObject = eventObjectId; + gSpecialVar_LastTalked = gEventObjects[eventObjectId].localId; + gSpecialVar_Facing = direction; + return GetEventObjectScriptPointerByEventObjectId(eventObjectId); +} + +static const u8 *GetInteractedEventObjectScript(struct MapPosition *position, u8 metatileBehavior, u8 direction) +{ + u8 eventObjectId; + const u8 *script; + + eventObjectId = GetEventObjectIdByXYZ(position->x, position->y, position->height); + if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == 0xFF) + { + if (MetatileBehavior_IsCounter(metatileBehavior) != TRUE) + return NULL; + + // Look for an event object on the other side of the counter. + eventObjectId = GetEventObjectIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height); + if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == 0xFF) + return NULL; + } + + gSelectedEventObject = eventObjectId; + gSpecialVar_LastTalked = gEventObjects[eventObjectId].localId; + gSpecialVar_Facing = direction; + + if (InTrainerHill() == TRUE) + { + script = sub_81D62AC(); + } + else + { + script = GetEventObjectScriptPointerByEventObjectId(eventObjectId); + } + script = GetRamScript(gSpecialVar_LastTalked, script); + return script; +} + +static const u8 *GetInteractedBackgroundEventScript(struct MapPosition *position, u8 metatileBehavior, u8 direction) +{ + struct BgEvent *bgEvent = GetBackgroundEventAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height); + + if (bgEvent == NULL) + return NULL; + if (bgEvent->bgUnion.script == NULL) + return EventScript_TestSignpostMsg; + + switch (bgEvent->kind) + { + case BG_EVENT_PLAYER_FACING_ANY: + default: + return bgEvent->bgUnion.script; + case BG_EVENT_PLAYER_FACING_NORTH: + if (direction != DIR_NORTH) + return NULL; + break; + case BG_EVENT_PLAYER_FACING_SOUTH: + if (direction != DIR_SOUTH) + return NULL; + break; + case BG_EVENT_PLAYER_FACING_EAST: + if (direction != DIR_EAST) + return NULL; + break; + case BG_EVENT_PLAYER_FACING_WEST: + if (direction != DIR_WEST) + return NULL; + break; + case 5: + case 6: + case BG_EVENT_HIDDEN_ITEM: + gSpecialVar_0x8004 = ((u32)bgEvent->bgUnion.script >> 16) + FLAG_HIDDEN_ITEMS_START; + gSpecialVar_0x8005 = (u32)bgEvent->bgUnion.script; + if (FlagGet(gSpecialVar_0x8004) == TRUE) + return NULL; + return EventScript_HiddenItemScript; + case BG_EVENT_SECRET_BASE: + if (direction == DIR_NORTH) + { + gSpecialVar_0x8004 = bgEvent->bgUnion.secretBaseId; + if (sub_80E9680()) + return EventScript_2759F1; + } + return NULL; + } + + return bgEvent->bgUnion.script; +} + +static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 metatileBehavior, u8 direction) +{ + s8 height; + + if (MetatileBehavior_IsPlayerFacingTVScreen(metatileBehavior, direction) == TRUE) + return EventScript_TV; + if (MetatileBehavior_IsPC(metatileBehavior) == TRUE) + return EventScript_PC; + if (MetatileBehavior_IsClosedSootopolisDoor(metatileBehavior) == TRUE) + return EventScript_ClosedSootopolisDoor; + if (MetatileBehavior_IsUnknownClosedDoor(metatileBehavior) == TRUE) + return SkyPillar_Outside_EventScript_2393F9; + if (MetatileBehavior_IsCableBoxResults1(metatileBehavior) == TRUE) + return EventScript_CableBoxResults; + if (MetatileBehavior_IsPokeblockFeeder(metatileBehavior) == TRUE) + return EventScript_2A4BAC; + if (MetatileBehavior_IsTrickHousePuzzleDoor(metatileBehavior) == TRUE) + return Route110_TrickHouseEntrance_EventScript_26A22A; + if (MetatileBehavior_IsRegionMap(metatileBehavior) == TRUE) + return EventScript_RegionMap; + if (MetatileBehavior_IsRunningShoesManual(metatileBehavior) == TRUE) + return EventScript_RunningShoesManual; + if (MetatileBehavior_IsPictureBookShelf(metatileBehavior) == TRUE) + return EventScript_PictureBookShelf; + if (MetatileBehavior_IsBookShelf(metatileBehavior) == TRUE) + return EventScript_BookShelf; + if (MetatileBehavior_IsPokeCenterBookShelf(metatileBehavior) == TRUE) + return EventScript_PokemonCenterBookshelf; + if (MetatileBehavior_IsVase(metatileBehavior) == TRUE) + return EventScript_Vase; + if (MetatileBehavior_IsTrashCan(metatileBehavior) == TRUE) + return EventScript_TrashCan; + if (MetatileBehavior_IsShopShelf(metatileBehavior) == TRUE) + return EventScript_ShopShelf; + if (MetatileBehavior_IsBlueprint(metatileBehavior) == TRUE) + return EventScript_Blueprint; + if (MetatileBehavior_IsPlayerFacingWirelessBoxResults(metatileBehavior, direction) == TRUE) + return EventScript_WirelessBoxResults; + if (MetatileBehavior_IsCableBoxResults2(metatileBehavior, direction) == TRUE) + return EventScript_CableBoxResults; + if (MetatileBehavior_IsQuestionnaire(metatileBehavior) == TRUE) + return EventScript_Questionnaire; + if (MetatileBehavior_IsTrainerHillTimer(metatileBehavior) == TRUE) + return EventScript_TrainerHillTimer; + + height = position->height; + if (height == MapGridGetZCoordAt(position->x, position->y)) + { + if (MetatileBehavior_IsSecretBasePC(metatileBehavior) == TRUE) + return EventScript_SecretBasePC; + if (MetatileBehavior_IsRecordMixingSecretBasePC(metatileBehavior) == TRUE) + return EventScript_RecordMixingSecretBasePC; + if (MetatileBehavior_IsSecretBaseSandOrnament(metatileBehavior) == TRUE) + return EventScript_SecretBaseSandOrnament; + if (MetatileBehavior_IsSecretBaseShieldOrToyTV(metatileBehavior) == TRUE) + return EventScript_SecretBaseShieldOrToyTV; + if (MetatileBehavior_IsMB_C6(metatileBehavior) == TRUE) + { + sub_80EB56C(); + return NULL; + } + if (MetatileBehavior_IsLargeMatCenter(metatileBehavior) == TRUE) + { + sub_80EB9E0(); + return NULL; + } + if (MetatileBehavior_IsSecretBaseLargeMatEdge(metatileBehavior) == TRUE) + { + sub_80EBB28(); + return NULL; + } + } + else if (MetatileBehavior_IsSecretBasePoster(metatileBehavior) == TRUE) + { + sub_80EB498(); + return NULL; + } + + return NULL; +} + +static const u8 *GetInteractedWaterScript(struct MapPosition *unused1, u8 metatileBehavior, u8 direction) +{ + if (FlagGet(FLAG_BADGE05_GET) == TRUE && PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE) + return EventScript_UseSurf; + + if (MetatileBehavior_IsWaterfall(metatileBehavior) == TRUE) + { + if (FlagGet(FLAG_BADGE08_GET) == TRUE && IsPlayerSurfingNorth() == TRUE) + return EventScript_UseWaterfall; + else + return EventScript_CannotUseWaterfall; + } + return NULL; +} + +static bool32 TrySetupDiveDownScript(void) +{ + if (FlagGet(FLAG_BADGE07_GET) && TrySetDiveWarp() == 2) + { + ScriptContext1_SetupScript(EventScript_UseDive); + return TRUE; + } + return FALSE; +} + +static bool32 TrySetupDiveEmergeScript(void) +{ + if (FlagGet(FLAG_BADGE07_GET) && gMapHeader.mapType == MAP_TYPE_UNDERWATER && TrySetDiveWarp() == 1) + { + ScriptContext1_SetupScript(EventScript_UseDiveUnderwater); + return TRUE; + } + return FALSE; +} + +static bool8 TryStartStepBasedScript(struct MapPosition *position, u16 metatileBehavior, u16 direction) +{ + if (TryStartCoordEventScript(position) == TRUE) + return TRUE; + if (TryStartWarpEventScript(position, metatileBehavior) == TRUE) + return TRUE; + if (TryStartMiscWalkingScripts(metatileBehavior) == TRUE) + return TRUE; + if (TryStartStepCountScript(metatileBehavior) == TRUE) + return TRUE; + if (UpdateRepelCounter() == TRUE) + return TRUE; + return FALSE; +} + +static bool8 TryStartCoordEventScript(struct MapPosition *position) +{ + u8 *script = GetCoordEventScriptAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height); + + if (script == NULL) + return FALSE; + ScriptContext1_SetupScript(script); + return TRUE; +} + +static bool8 TryStartMiscWalkingScripts(u16 metatileBehavior) +{ + s16 x; + s16 y; + + if (MetatileBehavior_IsCrackedFloorHole(metatileBehavior)) + { + ScriptContext1_SetupScript(EventScript_FallDownHole); + return TRUE; + } + else if (MetatileBehavior_IsBattlePyramidWarp(metatileBehavior)) + { + ScriptContext1_SetupScript(BattleFrontier_BattlePyramidEmptySquare_EventScript_252BE8); + return TRUE; + } + else if (MetatileBehavior_IsSecretBaseGlitterMat(metatileBehavior) == TRUE) + { + sub_80FA9D0(); + return FALSE; + } + else if (MetatileBehavior_IsSecretBaseSoundMat(metatileBehavior) == TRUE) + { + PlayerGetDestCoords(&x, &y); + sub_80FA970(MapGridGetMetatileIdAt(x, y)); + return FALSE; + } + return FALSE; +} + +static bool8 TryStartStepCountScript(u16 metatileBehavior) +{ + if (InUnionRoom() == TRUE) + { + return FALSE; + } + + IncrementRematchStepCounter(); + UpdateHappinessStepCounter(); + sub_81D4998(); + + if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_6) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior)) + { + if (UpdatePoisonStepCounter() == TRUE) + { + ScriptContext1_SetupScript(EventScript_Poison); + return TRUE; + } + if (ShouldEggHatch()) + { + IncrementGameStat(GAME_STAT_HATCHED_EGGS); + ScriptContext1_SetupScript(EventScript_EggHatch); + return TRUE; + } + if (sub_813B3B0() == TRUE) + { + ScriptContext1_SetupScript(gUnknown_08273D1F); + return TRUE; + } + if (ShouldDoBrailleRegicePuzzle() == TRUE) + { + ScriptContext1_SetupScript(IslandCave_EventScript_238EAF); + return TRUE; + } + if (is_tile_that_overrides_player_control() == TRUE) + { + ScriptContext1_SetupScript(MauvilleCity_EventScript_1DF7BA); + return TRUE; + } + if (sub_8138120() == TRUE) + { + ScriptContext1_SetupScript(Route119_EventScript_1F49EC); + return TRUE; + } + if (sub_8138168() == TRUE) + { + ScriptContext1_SetupScript(LittlerootTown_ProfessorBirchsLab_EventScript_1FA4D6); + return TRUE; + } + if (sub_81381B0() == TRUE) + { + ScriptContext1_SetupScript(RustboroCity_Gym_EventScript_21307B); + return TRUE; + } + if (sub_81381F8() == TRUE) + { + ScriptContext1_SetupScript(MossdeepCity_SpaceCenter_2F_EventScript_224175); + return TRUE; + } + } + + if (SafariZoneTakeStep() == TRUE) + return TRUE; + if (CountSSTidalStep(1) == TRUE) + { + ScriptContext1_SetupScript(SSTidalCorridor_EventScript_23C050); + return TRUE; + } + if (sub_8196034()) + return TRUE; + return FALSE; +} + +void Unref_ClearHappinessStepCounter(void) +{ + VarSet(VAR_HAPPINESS_STEP_COUNTER, 0); +} + +static void UpdateHappinessStepCounter(void) +{ + u16 *ptr = GetVarPointer(VAR_HAPPINESS_STEP_COUNTER); + int i; + + (*ptr)++; + (*ptr) %= 128; + if (*ptr == 0) + { + struct Pokemon *mon = gPlayerParty; + for (i = 0; i < PARTY_SIZE; i++) + { + AdjustFriendship(mon, FRIENDSHIP_EVENT_WALKING); + mon++; + } + } +} + +void ClearPoisonStepCounter(void) +{ + VarSet(VAR_POISON_STEP_COUNTER, 0); +} + +static bool8 UpdatePoisonStepCounter(void) +{ + u16 *ptr; + + if (gMapHeader.mapType != MAP_TYPE_SECRET_BASE) + { + ptr = GetVarPointer(VAR_POISON_STEP_COUNTER); + (*ptr)++; + (*ptr) %= 4; + if (*ptr == 0) + { + switch (DoPoisonFieldEffect()) + { + case 0: + return FALSE; + case 1: + return FALSE; + case 2: + return TRUE; + } + } + } + return FALSE; +} + +void RestartWildEncounterImmunitySteps(void) +{ + // Starts at 0 and counts up to 4 steps. + sWildEncounterImmunitySteps = 0; +} + +static bool8 CheckStandardWildEncounter(u16 metatileBehavior) +{ + if (sWildEncounterImmunitySteps < 4) + { + sWildEncounterImmunitySteps++; + sPreviousPlayerMetatileBehavior = metatileBehavior; + return FALSE; + } + + if (StandardWildEncounter(metatileBehavior, sPreviousPlayerMetatileBehavior) == TRUE) + { + sWildEncounterImmunitySteps = 0; + sPreviousPlayerMetatileBehavior = metatileBehavior; + return TRUE; + } + + sPreviousPlayerMetatileBehavior = metatileBehavior; + return FALSE; +} + +static bool8 mapheader_run_first_tag2_script_list_match_conditionally(struct MapPosition *position, u16 metatileBehavior, u8 direction) +{ + s8 warpEventId = GetWarpEventAtMapPosition(&gMapHeader, position); + + if (IsArrowWarpMetatileBehavior(metatileBehavior, direction) == TRUE && warpEventId != -1) + { + StoreInitialPlayerAvatarState(); + sub_809CEB0(&gMapHeader, warpEventId, position); + sub_80AF734(); + return TRUE; + } + return FALSE; +} + +static bool8 TryStartWarpEventScript(struct MapPosition *position, u16 metatileBehavior) +{ + s8 warpEventId = GetWarpEventAtMapPosition(&gMapHeader, position); + + if (warpEventId != -1 && IsWarpMetatileBehavior(metatileBehavior) == TRUE) + { + StoreInitialPlayerAvatarState(); + sub_809CEB0(&gMapHeader, warpEventId, position); + if (MetatileBehavior_IsEscalator(metatileBehavior) == TRUE) + { + sub_80AF80C(metatileBehavior); + return TRUE; + } + if (MetatileBehavior_IsLavaridgeB1FWarp(metatileBehavior) == TRUE) + { + sub_80AF828(); + return TRUE; + } + if (MetatileBehavior_IsLavaridge1FWarp(metatileBehavior) == TRUE) + { + sub_80AF838(); + return TRUE; + } + if (MetatileBehavior_IsAquaHideoutWarp(metatileBehavior) == TRUE) + { + sub_80AF848(); + return TRUE; + } + if (MetatileBehavior_IsWarpOrBridge(metatileBehavior) == TRUE) + { + sub_80B0268(); + return TRUE; + } + if (MetatileBehavior_IsMtPyreHole(metatileBehavior) == TRUE) + { + ScriptContext1_SetupScript(gUnknown_082A8350); + return TRUE; + } + if (MetatileBehavior_IsMossdeepGymWarp(metatileBehavior) == TRUE) + { + sub_80AF87C(); + return TRUE; + } + sub_80AF734(); + return TRUE; + } + return FALSE; +} + +static bool8 IsWarpMetatileBehavior(u16 metatileBehavior) +{ + if (MetatileBehavior_IsWarpDoor(metatileBehavior) != TRUE + && MetatileBehavior_IsLadder(metatileBehavior) != TRUE + && MetatileBehavior_IsEscalator(metatileBehavior) != TRUE + && MetatileBehavior_IsNonAnimDoor(metatileBehavior) != TRUE + && MetatileBehavior_IsLavaridgeB1FWarp(metatileBehavior) != TRUE + && MetatileBehavior_IsLavaridge1FWarp(metatileBehavior) != TRUE + && MetatileBehavior_IsAquaHideoutWarp(metatileBehavior) != TRUE + && MetatileBehavior_IsMtPyreHole(metatileBehavior) != TRUE + && MetatileBehavior_IsMossdeepGymWarp(metatileBehavior) != TRUE + && MetatileBehavior_IsWarpOrBridge(metatileBehavior) != TRUE) + return FALSE; + return TRUE; +} + +static bool8 IsArrowWarpMetatileBehavior(u16 metatileBehavior, u8 direction) +{ + switch (direction) + { + case DIR_NORTH: + return MetatileBehavior_IsNorthArrowWarp(metatileBehavior); + case DIR_SOUTH: + return MetatileBehavior_IsSouthArrowWarp(metatileBehavior); + case DIR_WEST: + return MetatileBehavior_IsWestArrowWarp(metatileBehavior); + case DIR_EAST: + return MetatileBehavior_IsEastArrowWarp(metatileBehavior); + } + return FALSE; +} + +static s8 GetWarpEventAtMapPosition(struct MapHeader *mapHeader, struct MapPosition *position) +{ + return GetWarpEventAtPosition(mapHeader, position->x - 7, position->y - 7, position->height); +} + +static void sub_809CEB0(struct MapHeader *unused, s8 warpEventId, struct MapPosition *position) +{ + const struct WarpEvent *warpEvent; + + u8 trainerHillMapId = GetCurrentTrainerHillMapId(); + + if (trainerHillMapId) + { + if (trainerHillMapId == sub_81D6490()) + { + if (warpEventId == 0) + { + warpEvent = &gMapHeader.events->warps[0]; + } + else + { + warpEvent = sub_81D6120(); + } + } + else if (trainerHillMapId == 5) + { + warpEvent = sub_81D6134(warpEventId); + } + else + { + warpEvent = &gMapHeader.events->warps[warpEventId]; + } + } + else + { + warpEvent = &gMapHeader.events->warps[warpEventId]; + } + + if (warpEvent->mapNum == 0x7F) + { + copy_saved_warp2_bank_and_enter_x_to_warp1(warpEvent->warpId); + } + else + { + const struct MapHeader *mapHeader; + + warp1_set_2(warpEvent->mapGroup, warpEvent->mapNum, warpEvent->warpId); + sub_8084D5C(position->x, position->y); + mapHeader = Overworld_GetMapHeaderByGroupAndId(warpEvent->mapGroup, warpEvent->mapNum); + if (mapHeader->events->warps[warpEvent->warpId].mapNum == 0x7F) + saved_warp2_set(mapHeader->events->warps[warpEventId].warpId, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, warpEventId); + } +} + +static bool8 map_warp_consider_2_to_inside(struct MapPosition *position, u16 metatileBehavior, u8 direction) +{ + s8 warpEventId; + + if (direction == DIR_NORTH) + { + if (MetatileBehavior_IsOpenSecretBaseDoor(metatileBehavior) == TRUE) + { + sub_80E9668(position, gMapHeader.events); + return TRUE; + } + if (MetatileBehavior_IsWarpDoor(metatileBehavior) == TRUE) + { + warpEventId = GetWarpEventAtMapPosition(&gMapHeader, position); + if (warpEventId != -1 && IsWarpMetatileBehavior(metatileBehavior) == TRUE) + { + StoreInitialPlayerAvatarState(); + sub_809CEB0(&gMapHeader, warpEventId, position); + sub_80AF7D0(); + return TRUE; + } + } + } + return FALSE; +} + +static s8 GetWarpEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation) +{ + s32 i; + struct WarpEvent *warpEvent = mapHeader->events->warps; + u8 warpCount = mapHeader->events->warpCount; + + for (i = 0; i < warpCount; i++, warpEvent++) + { + if ((u16)warpEvent->x == x && (u16)warpEvent->y == y) + { + if (warpEvent->elevation == elevation || warpEvent->elevation == 0) + return i; + } + } + return -1; +} + +static u8 *TryRunCoordEventScript(struct CoordEvent *coordEvent) +{ + if (coordEvent != NULL) + { + if (coordEvent->script == NULL) + { + DoCoordEventWeather(coordEvent->trigger); + return NULL; + } + if (coordEvent->trigger == 0) + { + ScriptContext2_RunNewScript(coordEvent->script); + return NULL; + } + if (VarGet(coordEvent->trigger) == (u8)coordEvent->index) + return coordEvent->script; + } + return NULL; +} + +static u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation) +{ + s32 i; + struct CoordEvent *coordEvents = mapHeader->events->coordEvents; + u8 coordEventCount = mapHeader->events->coordEventCount; + + for (i = 0; i < coordEventCount; i++) + { + if ((u16)coordEvents[i].x == x && (u16)coordEvents[i].y == y) + { + if (coordEvents[i].elevation == elevation || coordEvents[i].elevation == 0) + { + u8 *script = TryRunCoordEventScript(&coordEvents[i]); + if (script != NULL) + return script; + } + } + } + return NULL; +} + +u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position) +{ + return GetCoordEventScriptAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height); +} + +static struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation) +{ + u8 i; + struct BgEvent *bgEvents = mapHeader->events->bgEvents; + u8 bgEventCount = mapHeader->events->bgEventCount; + + for (i = 0; i < bgEventCount; i++) + { + if ((u16)bgEvents[i].x == x && (u16)bgEvents[i].y == y) + { + if (bgEvents[i].elevation == elevation || bgEvents[i].elevation == 0) + return &bgEvents[i]; + } + } + return NULL; +} + +bool8 dive_warp(struct MapPosition *position, u16 metatileBehavior) +{ + if (gMapHeader.mapType == MAP_TYPE_UNDERWATER && !MetatileBehavior_IsUnableToEmerge(metatileBehavior)) + { + if (SetDiveWarpEmerge(position->x - 7, position->y - 7)) + { + StoreInitialPlayerAvatarState(); + sp13E_warp_to_last_warp(); + PlaySE(SE_W291); + return TRUE; + } + } + else if (MetatileBehavior_IsDiveable(metatileBehavior) == TRUE) + { + if (SetDiveWarpDive(position->x - 7, position->y - 7)) + { + StoreInitialPlayerAvatarState(); + sp13E_warp_to_last_warp(); + PlaySE(SE_W291); + return TRUE; + } + } + return FALSE; +} + +u8 TrySetDiveWarp(void) +{ + s16 x, y; + u8 metatileBehavior; + + PlayerGetDestCoords(&x, &y); + metatileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (gMapHeader.mapType == MAP_TYPE_UNDERWATER && !MetatileBehavior_IsUnableToEmerge(metatileBehavior)) + { + if (SetDiveWarpEmerge(x - 7, y - 7) == TRUE) + return 1; + } + else if (MetatileBehavior_IsDiveable(metatileBehavior) == TRUE) + { + if (SetDiveWarpDive(x - 7, y - 7) == TRUE) + return 2; + } + return 0; +} + +const u8 *GetEventObjectScriptPointerPlayerFacing(void) +{ + u8 direction; + struct MapPosition position; + + direction = GetPlayerMovementDirection(); + GetInFrontOfPlayerPosition(&position); + return GetInteractedEventObjectScript(&position, MapGridGetMetatileBehaviorAt(position.x, position.y), direction); +} + +int SetCableClubWarp(void) +{ + struct MapPosition position; + + GetPlayerMovementDirection(); //unnecessary + GetPlayerPosition(&position); + MapGridGetMetatileBehaviorAt(position.x, position.y); //unnecessary + sub_809CEB0(&gMapHeader, GetWarpEventAtMapPosition(&gMapHeader, &position), &position); + return 0; +} diff --git a/src/field_poison.c b/src/field_poison.c index 98819c450b..6a519d90ca 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -111,7 +111,7 @@ void sub_80F972C(void) ScriptContext1_Stop(); } -unsigned int overworld_poison(void) +int DoPoisonFieldEffect(void) { int i; unsigned int hp; diff --git a/src/field_specials.c b/src/field_specials.c index 1139793759..fcef56f14a 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -3668,7 +3668,7 @@ bool32 sub_813B374(void) } } -bool32 sub_813B3B0(void) +bool8 sub_813B3B0(void) { static const u8 gUnknown_085B3410[] = { 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c }; diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index 5a7d4ae833..dd594f075a 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -679,7 +679,7 @@ bool8 MetatileBehavior_IsSecretBasePC(u8 metatileBehavior) return FALSE; } -bool8 MetatileBehavior_IsSecretBaseRegisterPC(u8 metatileBehavior) +bool8 MetatileBehavior_IsRecordMixingSecretBasePC(u8 metatileBehavior) { if (metatileBehavior == MB_SECRET_BASE_REGISTER_PC) return TRUE; @@ -815,7 +815,7 @@ bool8 MetatileBehavior_IsSecretBaseSandOrnament(u8 metatileBehavior) return FALSE; } -bool8 MetatileBehavior_IsSecretBaseTvOrShield(u8 metatileBehavior) +bool8 MetatileBehavior_IsSecretBaseShieldOrToyTV(u8 metatileBehavior) { if (metatileBehavior == MB_SECRET_BASE_TV_SHIELD) return TRUE; @@ -1164,7 +1164,7 @@ bool8 MetatileBehavior_IsRegionMap(u8 metatileBehavior) return FALSE; } -bool8 MetatileBehavior_IsClosedSootopolisGymDoor(u8 metatileBehavior) +bool8 MetatileBehavior_IsClosedSootopolisDoor(u8 metatileBehavior) { if (metatileBehavior == MB_CLOSED_SOOTOPOLIS_DOOR) return TRUE; @@ -1365,7 +1365,7 @@ bool8 MetatileBehavior_IsCuttableGrass(u8 metatileBehavior) return FALSE; } -bool8 MetatileBehavior_IsRunningShoesInstruction(u8 metatileBehavior) +bool8 MetatileBehavior_IsRunningShoesManual(u8 metatileBehavior) { if (metatileBehavior == MB_RUNNING_SHOES_INSTRUCTION) return TRUE; diff --git a/src/overworld.c b/src/overworld.c index 683679218c..94c3f83282 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -107,7 +107,7 @@ extern void sub_80A0A2C(void); extern void not_trainer_hill_battle_pyramid(void); extern void apply_map_tileset2_palette(const struct MapLayout *); extern void copy_map_tileset2_to_vram_2(const struct MapLayout *); -extern void prev_quest_postbuffer_cursor_backup_reset(void); +extern void RestartWildEncounterImmunitySteps(void); extern void ShowMapNamePopup(void); extern bool32 InTrainerHill(void); extern bool32 sub_808651C(void); @@ -164,8 +164,8 @@ extern bool32 sub_8009F3C(void); extern void sub_8010198(void); extern u32 sub_800B4DC(void); extern bool32 sub_80B39D4(u8); -extern const u8* sub_809C2C8(struct MapPosition *a1, u8, u8); -extern u8 *sub_809D0F4(void*); +extern const u8* GetInteractedLinkPlayerScript(struct MapPosition *a1, u8, u8); +extern u8 *GetCoordEventScriptAtMapPosition(void*); extern u8 sub_808BD6C(u8); extern u8 sub_808BD7C(u8); extern void UpdateEventObjectSpriteVisibility(struct Sprite*, u8); @@ -827,7 +827,7 @@ void mliX_load_map(u8 mapGroup, u8 mapNum) TrySetMapSaveWarpStatus(); ClearTempFieldEventData(); ResetCyclingRoadChallengeData(); - prev_quest_postbuffer_cursor_backup_reset(); + RestartWildEncounterImmunitySteps(); TryUpdateRandomTrainerRematches(mapGroup, mapNum); DoTimeBasedEvents(); SetSav1WeatherFromCurrMapHeader(); @@ -876,7 +876,7 @@ static void mli0_load_map(u32 a1) TrySetMapSaveWarpStatus(); ClearTempFieldEventData(); ResetCyclingRoadChallengeData(); - prev_quest_postbuffer_cursor_backup_reset(); + RestartWildEncounterImmunitySteps(); TryUpdateRandomTrainerRematches(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum); if (a1 != 1) DoTimeBasedEvents(); @@ -2706,7 +2706,7 @@ static u8 *sub_8087370(struct UnkStruct_8054FF8 *a1) { if (a1->c != 2) return 0; - return sub_809D0F4(&a1->sub); + return GetCoordEventScriptAtMapPosition(&a1->sub); } static bool32 sub_8087388(struct UnkStruct_8054FF8 *a1) @@ -2747,7 +2747,7 @@ static const u8 *sub_80873B4(struct UnkStruct_8054FF8 *a1) return EventScript_TradeRoom_ReadTrainerCard2; } - return sub_809C2C8(&unkStruct, a1->field_C, a1->d); + return GetInteractedLinkPlayerScript(&unkStruct, a1->field_C, a1->d); } static u16 sub_8087480(const u8 *script) diff --git a/src/pokemon.c b/src/pokemon.c index 40f7e94b24..7227d28cb8 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3251,7 +3251,7 @@ u8 GetLevelFromMonExp(struct Pokemon *mon) u32 exp = GetMonData(mon, MON_DATA_EXP, NULL); s32 level = 1; - while (level <= MAX_MON_LEVEL && gExperienceTables[gBaseStats[species].growthRate][level] <= exp) + while (level <= MAX_LEVEL && gExperienceTables[gBaseStats[species].growthRate][level] <= exp) level++; return level - 1; @@ -3263,7 +3263,7 @@ u8 GetLevelFromBoxMonExp(struct BoxPokemon *boxMon) u32 exp = GetBoxMonData(boxMon, MON_DATA_EXP, NULL); s32 level = 1; - while (level <= MAX_MON_LEVEL && gExperienceTables[gBaseStats[species].growthRate][level] <= exp) + while (level <= MAX_LEVEL && gExperienceTables[gBaseStats[species].growthRate][level] <= exp) level++; return level - 1; @@ -5145,7 +5145,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov retVal = FALSE; } if ((itemEffect[cmdIndex] & 0x40) // raise level - && GetMonData(mon, MON_DATA_LEVEL, NULL) != MAX_MON_LEVEL) + && GetMonData(mon, MON_DATA_LEVEL, NULL) != MAX_LEVEL) { dataUnsigned = gExperienceTables[gBaseStats[GetMonData(mon, MON_DATA_SPECIES, NULL)].growthRate][GetMonData(mon, MON_DATA_LEVEL, NULL) + 1]; SetMonData(mon, MON_DATA_EXP, &dataUnsigned); @@ -6430,12 +6430,12 @@ bool8 TryIncrementMonLevel(struct Pokemon *mon) u16 species = GetMonData(mon, MON_DATA_SPECIES, 0); u8 nextLevel = GetMonData(mon, MON_DATA_LEVEL, 0) + 1; u32 expPoints = GetMonData(mon, MON_DATA_EXP, 0); - if (expPoints > gExperienceTables[gBaseStats[species].growthRate][MAX_MON_LEVEL]) + if (expPoints > gExperienceTables[gBaseStats[species].growthRate][MAX_LEVEL]) { - expPoints = gExperienceTables[gBaseStats[species].growthRate][MAX_MON_LEVEL]; + expPoints = gExperienceTables[gBaseStats[species].growthRate][MAX_LEVEL]; SetMonData(mon, MON_DATA_EXP, &expPoints); } - if (nextLevel > MAX_MON_LEVEL || expPoints < gExperienceTables[gBaseStats[species].growthRate][nextLevel]) + if (nextLevel > MAX_LEVEL || expPoints < gExperienceTables[gBaseStats[species].growthRate][nextLevel]) { return FALSE; } diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index df596749e6..db2a079098 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -2533,7 +2533,7 @@ static void DrawExperienceProgressBar(struct Pokemon *unused) u16 *r9; u8 i; - if (summary->level < MAX_MON_LEVEL) + if (summary->level < MAX_LEVEL) { u32 expBetweenLevels = gExperienceTables[gBaseStats[summary->species].growthRate][summary->level + 1] - gExperienceTables[gBaseStats[summary->species].growthRate][summary->level]; u32 expSinceLastLevel = summary->exp - gExperienceTables[gBaseStats[summary->species].growthRate][summary->level]; @@ -3349,7 +3349,7 @@ static void PrintExpPointsNextLevel(void) offset = GetStringRightAlignXOffset(1, gStringVar1, 42) + 2; SummaryScreen_PrintTextOnWindow(windowId, gStringVar1, offset, 1, 0, 0); - if (sum->level < MAX_MON_LEVEL) + if (sum->level < MAX_LEVEL) expToNextLevel = gExperienceTables[gBaseStats[sum->species].growthRate][sum->level + 1] - sum->exp; else expToNextLevel = 0; diff --git a/src/rom_8011DC0.c b/src/rom_8011DC0.c index dc94cb9d59..bf16a20fc3 100644 --- a/src/rom_8011DC0.c +++ b/src/rom_8011DC0.c @@ -1646,7 +1646,7 @@ void sub_8014304(s8 mapGroup, s8 mapNum, s32 x, s32 y, u16 arg4) VarSet(VAR_0x4087, arg4); gFieldLinkPlayerCount = GetLinkPlayerCount(); gUnknown_03005DB4 = GetMultiplayerId(); - sub_809D2BC(); + SetCableClubWarp(); Overworld_SetWarpDestination(mapGroup, mapNum, -1, x, y); WarpIntoMap(); } diff --git a/src/scrcmd.c b/src/scrcmd.c index acaf785762..fa3e219968 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -52,7 +52,7 @@ typedef u16 (*SpecialFunc)(void); typedef void (*NativeFunc)(void); -extern u32 gUnknown_020375C0; +extern const u8 *gUnknown_020375C0; static EWRAM_DATA u32 gUnknown_020375C4 = 0; static EWRAM_DATA u16 sPauseCounter = 0; @@ -284,7 +284,7 @@ bool8 ScrCmd_callstd_if(struct ScriptContext *ctx) bool8 ScrCmd_gotoram(struct ScriptContext *ctx) { - ScriptJump(ctx, (const u8 *)gUnknown_020375C0); + ScriptJump(ctx, gUnknown_020375C0); return FALSE; } @@ -2223,7 +2223,7 @@ bool8 ScrCmd_cmdCF(struct ScriptContext *ctx) if (v1) { - ((u8*)gUnknown_020375C0) = ctx->scriptPtr; + gUnknown_020375C0 = ctx->scriptPtr; ScriptJump(ctx, v1); } return FALSE; diff --git a/src/script.c b/src/script.c index 8c868128b7..c61ae71838 100644 --- a/src/script.c +++ b/src/script.c @@ -5,7 +5,7 @@ #define RAM_SCRIPT_MAGIC 51 -extern u8* gUnknown_020375C0; +extern const u8* gUnknown_020375C0; extern bool32 sub_801B27C(void); @@ -344,7 +344,7 @@ void ClearRamScript(void) CpuFill32(0, &gSaveBlock1Ptr->ramScript, sizeof(struct RamScript)); } -bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId) +bool8 InitRamScript(const u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId) { struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data; @@ -362,7 +362,7 @@ bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objec return TRUE; } -u8 *GetRamScript(u8 objectId, u8 *script) +const u8 *GetRamScript(u8 objectId, const u8 *script) { struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data; gUnknown_020375C0 = NULL; diff --git a/src/secret_base.c b/src/secret_base.c index 441bdef04d..a684f39825 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -596,13 +596,13 @@ void sub_80E95D4(void) VarSet(VAR_OBJ_GFX_ID_F, gUnknown_0858D060[sub_80EA20C(VarGet(VAR_0x4054))]); } -void sub_80E9608(struct Coords16 *coords, struct MapEvents *events) +void sub_80E9608(const struct MapPosition *position, const struct MapEvents *events) { s16 bgEventIdx; for (bgEventIdx = 0; bgEventIdx < events->bgEventCount; bgEventIdx ++) { - if (events->bgEvents[bgEventIdx].kind == BG_EVENT_SECRET_BASE && coords->x == events->bgEvents[bgEventIdx].x + 7 && coords->y == events->bgEvents[bgEventIdx].y + 7) + if (events->bgEvents[bgEventIdx].kind == BG_EVENT_SECRET_BASE && position->x == events->bgEvents[bgEventIdx].x + 7 && position->y == events->bgEvents[bgEventIdx].y + 7) { sCurSecretBaseId = events->bgEvents[bgEventIdx].bgUnion.secretBaseId; break; @@ -610,9 +610,9 @@ void sub_80E9608(struct Coords16 *coords, struct MapEvents *events) } } -void sub_80E9668(struct Coords16 *coords, struct MapEvents *events) +void sub_80E9668(const struct MapPosition *position, const struct MapEvents *events) { - sub_80E9608(coords, events); + sub_80E9608(position, events); sub_80E8B6C(); ScriptContext1_SetupScript(EventScript_275BB7); } diff --git a/sym_common.txt b/sym_common.txt index 282ef7f722..70c6e48715 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -26,9 +26,7 @@ gBGTilemapBuffers3: @ 3005DA4 .include "overworld.o" .include "fieldmap.o" .include "field_camera.o" - -gSelectedEventObject: @ 3005DF0 - .space 0x4 + .include "field_control_avatar.o" gMenuCallback: @ 3005DF4 .space 0x4 diff --git a/sym_ewram.txt b/sym_ewram.txt index 8ac8871f8a..7219e38c1b 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -234,14 +234,7 @@ gUnknown_020375C0: @ 20375C0 .space 0x4 .include "src/scrcmd.o" - - .align 2 -gUnknown_020375D4: @ 20375D4 - .space 0x2 - -gUnknown_020375D6: @ 20375D6 - .space 0x2 - + .include "src/field_control_avatar.o" .include "src/event_data.o" .include "src/start_menu.o" .include "src/tileset_anims.o"