From 439b741bb5dea8ad709208c61459b66ca6f4f577 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Thu, 28 Nov 2024 21:04:14 -0500 Subject: [PATCH] Identify more bit flags --- constants/battle_anim_constants.asm | 2 + constants/battle_constants.asm | 6 ++ constants/hardware_constants.asm | 10 ++- constants/input_constants.asm | 33 +++----- constants/item_data_constants.asm | 9 +-- constants/map_data_constants.asm | 8 +- constants/map_object_constants.asm | 64 ++++++---------- constants/map_setup_constants.asm | 3 + constants/menu_constants.asm | 67 +++++++++------- constants/music_constants.asm | 8 +- constants/printer_constants.asm | 25 ++++-- constants/ram_constants.asm | 59 +++++++++++--- constants/text_constants.asm | 13 +--- constants/trainer_data_constants.asm | 21 ++--- data/maps/setup_script_pointers.asm | 10 ++- data/maps/setup_scripts.asm | 4 + docs/bugs_and_glitches.md | 4 +- docs/design_flaws.md | 11 ++- engine/battle/ai/move.asm | 7 +- engine/battle/ai/redundant.asm | 2 +- engine/battle/core.asm | 12 +-- engine/battle/effect_commands.asm | 28 +++---- engine/battle/move_effects/rollout.asm | 2 +- engine/battle/read_trainer_party.asm | 4 +- engine/battle_anims/anim_commands.asm | 4 +- engine/battle_anims/core.asm | 2 +- engine/battle_anims/functions.asm | 9 ++- engine/debug/debug_room.asm | 4 +- engine/events/battle_tower/battle_tower.asm | 2 +- engine/events/field_moves.asm | 12 ++- engine/events/map_name_sign.asm | 6 +- engine/events/mom.asm | 8 +- engine/games/card_flip.asm | 2 +- engine/items/tmhm.asm | 8 +- engine/link/link.asm | 6 +- engine/link/link_trade.asm | 2 +- engine/link/mystery_gift.asm | 4 +- engine/math/print_num.asm | 22 +++--- engine/menus/intro_menu.asm | 12 +-- engine/menus/main_menu.asm | 6 +- engine/menus/menu.asm | 85 +++++++++++---------- engine/menus/scrolling_menu.asm | 40 +++++----- engine/movie/credits.asm | 12 ++- engine/overworld/events.asm | 30 ++++---- engine/overworld/map_objects.asm | 18 ++--- engine/overworld/map_setup.asm | 2 +- engine/overworld/npc_movement.asm | 2 +- engine/overworld/overworld.asm | 28 +++---- engine/overworld/player_movement.asm | 2 +- engine/overworld/player_object.asm | 2 +- engine/overworld/scripting.asm | 10 +-- engine/overworld/warp_connection.asm | 4 +- engine/pokemon/bills_pc.asm | 8 +- engine/pokemon/learn.asm | 2 +- engine/pokemon/mon_menu.asm | 24 +++--- engine/pokemon/mon_submenu.asm | 8 +- engine/pokemon/party_menu.asm | 3 +- engine/pokemon/stats_screen.asm | 32 ++++---- engine/printer/printer.asm | 6 +- engine/printer/printer_serial.asm | 4 +- engine/rtc/reset_password.asm | 2 +- engine/rtc/restart_clock.asm | 12 +-- engine/rtc/rtc.asm | 29 ++++--- engine/rtc/timeset.asm | 6 +- engine/tilesets/map_palettes.asm | 4 +- engine/tilesets/timeofday_pals.asm | 2 +- home/audio.asm | 24 +++--- home/double_speed.asm | 8 +- home/game_time.asm | 4 +- home/joypad.asm | 8 +- home/map.asm | 2 +- home/menu.asm | 34 ++++----- home/printer.asm | 2 +- home/serial.asm | 4 +- home/time.asm | 12 +-- macros/const.asm | 2 +- mobile/mobile_45_sprite_engine.asm | 4 +- ram/wram.asm | 9 +-- 78 files changed, 539 insertions(+), 472 deletions(-) diff --git a/constants/battle_anim_constants.asm b/constants/battle_anim_constants.asm index 558c38b5d7b..369c9947b11 100644 --- a/constants/battle_anim_constants.asm +++ b/constants/battle_anim_constants.asm @@ -22,6 +22,8 @@ DEF BATTLEANIMSTRUCT_VAR2 rb ; 10 DEF BATTLEANIMSTRUCT_LENGTH EQU _RS DEF NUM_BATTLE_ANIM_STRUCTS EQU 10 ; see wActiveAnimObjects +DEF BATTLEANIMSTRUCT_OAMFLAGS_FIX_COORDS_F EQU 0 + ; wBattleAnimTileDict size (see wram.asm) DEF NUM_BATTLEANIMTILEDICT_ENTRIES EQU 5 diff --git a/constants/battle_constants.asm b/constants/battle_constants.asm index 1d6871e68da..802971d7205 100644 --- a/constants/battle_constants.asm +++ b/constants/battle_constants.asm @@ -24,6 +24,11 @@ DEF EFFECTIVE EQU 10 DEF NOT_VERY_EFFECTIVE EQU 05 DEF NO_EFFECT EQU 00 +; wTypeModifier +DEF EFFECTIVENESS_MASK EQU %01111111 + const_def 7 + shift_const STAB_DAMAGE + ; enemy AI behavior DEF BASE_AI_SWITCH_SCORE EQU 10 @@ -218,6 +223,7 @@ DEF ALL_STATUS EQU (1 << PSN) | (1 << BRN) | (1 << FRZ) | (1 << PAR) | SLP_MASK const SCREENS_SAFEGUARD const SCREENS_LIGHT_SCREEN const SCREENS_REFLECT + const SCREENS_UNUSED ; values in wBattleWeather const_def diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm index c0b511a02ed..f170ad606b3 100644 --- a/constants/hardware_constants.asm +++ b/constants/hardware_constants.asm @@ -20,9 +20,9 @@ DEF RTC_M EQU $09 ; Minutes 0-59 (0-3Bh) DEF RTC_H EQU $0a ; Hours 0-23 (0-17h) DEF RTC_DL EQU $0b ; Lower 8 bits of Day Counter (0-FFh) DEF RTC_DH EQU $0c ; Upper 1 bit of Day Counter, Carry Bit, Halt Flag - ; Bit 0 Most significant bit of Day Counter (Bit 8) - ; Bit 6 Halt (0=Active, 1=Stop Timer) - ; Bit 7 Day Counter Carry Bit (1=Counter Overflow) +DEF RTC_DH_HI EQU 0 ; Most significant bit of Day Counter (Bit 8) +DEF RTC_DH_HALT EQU 6 ; Halt (0=Active, 1=Stop Timer) +DEF RTC_DH_OVERFLOW EQU 7 ; Day Counter Carry Bit (1=Counter Overflow) ; interrupt flags DEF VBLANK EQU 0 @@ -49,6 +49,8 @@ DEF PRIORITY EQU 1 << OAM_PRIORITY ; $80 ; Hardware registers DEF rJOYP EQU $ff00 ; Joypad (R/W) +DEF rJOYP_BUTTONS EQU 4 +DEF rJOYP_DPAD EQU 5 DEF rSB EQU $ff01 ; Serial transfer data (R/W) DEF rSC EQU $ff02 ; Serial Transfer Control (R/W) DEF rSC_ON EQU 7 @@ -125,6 +127,8 @@ DEF rWY EQU $ff4a ; Window Y Position (R/W) DEF rWX EQU $ff4b ; Window X Position minus 7 (R/W) DEF rLCDMODE EQU $ff4c DEF rKEY1 EQU $ff4d ; CGB Mode Only - Prepare Speed Switch +DEF KEY1_PREPARE EQU 0 ; 0=No, 1=Prepare (R/W) +DEF KEY1_DBLSPEED EQU 7 ; 0=Normal Speed, 1=Double Speed (R) DEF rVBK EQU $ff4f ; CGB Mode Only - VRAM Bank DEF rBLCK EQU $ff50 DEF rHDMA1 EQU $ff51 ; CGB Mode Only - New DMA Source, High diff --git a/constants/input_constants.asm b/constants/input_constants.asm index 5319758325a..8febf47d9ef 100644 --- a/constants/input_constants.asm +++ b/constants/input_constants.asm @@ -1,26 +1,15 @@ ; joypad buttons const_def - const A_BUTTON_F ; 0 - const B_BUTTON_F ; 1 - const SELECT_F ; 2 - const START_F ; 3 - const D_RIGHT_F ; 4 - const D_LEFT_F ; 5 - const D_UP_F ; 6 - const D_DOWN_F ; 7 + shift_const A_BUTTON ; 0 + shift_const B_BUTTON ; 1 + shift_const SELECT ; 2 + shift_const START ; 3 + shift_const D_RIGHT ; 4 + shift_const D_LEFT ; 5 + shift_const D_UP ; 6 + shift_const D_DOWN ; 7 -DEF NO_INPUT EQU %00000000 -DEF A_BUTTON EQU 1 << A_BUTTON_F -DEF B_BUTTON EQU 1 << B_BUTTON_F -DEF SELECT EQU 1 << SELECT_F -DEF START EQU 1 << START_F -DEF D_RIGHT EQU 1 << D_RIGHT_F -DEF D_LEFT EQU 1 << D_LEFT_F -DEF D_UP EQU 1 << D_UP_F -DEF D_DOWN EQU 1 << D_DOWN_F +DEF NO_INPUT EQU %00000000 -DEF BUTTONS EQU A_BUTTON | B_BUTTON | SELECT | START -DEF D_PAD EQU D_RIGHT | D_LEFT | D_UP | D_DOWN - -DEF R_DPAD EQU %00100000 -DEF R_BUTTONS EQU %00010000 +DEF BUTTONS EQU A_BUTTON | B_BUTTON | SELECT | START +DEF D_PAD EQU D_RIGHT | D_LEFT | D_UP | D_DOWN diff --git a/constants/item_data_constants.asm b/constants/item_data_constants.asm index faf201dda82..cdcbcde046a 100644 --- a/constants/item_data_constants.asm +++ b/constants/item_data_constants.asm @@ -30,12 +30,11 @@ DEF NUM_ITEM_TYPES EQU const_value - 1 const ITEMMENU_CLOSE ; 6 ; item actions -DEF CANT_SELECT_F EQU 6 -DEF CANT_TOSS_F EQU 7 + const_def 6 + shift_const CANT_SELECT ; 6 + shift_const CANT_TOSS ; 7 -DEF NO_LIMITS EQU 0 -DEF CANT_SELECT EQU 1 << CANT_SELECT_F -DEF CANT_TOSS EQU 1 << CANT_TOSS_F +DEF NO_LIMITS EQU 0 ; pack pockets const_def diff --git a/constants/map_data_constants.asm b/constants/map_data_constants.asm index 84c374f7d84..d84a901d69d 100644 --- a/constants/map_data_constants.asm +++ b/constants/map_data_constants.asm @@ -56,14 +56,8 @@ DEF NUM_MAP_PALETTES EQU const_value const FISHGROUP_QWILFISH_NO_SWARM DEF NUM_FISHGROUPS EQU const_value - 1 -; connection directions (see data/maps/data.asm) - const_def - const EAST_F - const WEST_F - const SOUTH_F - const NORTH_F - ; wMapConnections +; connection directions (see data/maps/data.asm) const_def shift_const EAST shift_const WEST diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index cb46f549ab7..3c478b9b113 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -45,56 +45,36 @@ DEF OW_RIGHT EQU RIGHT << 2 ; object_struct OBJECT_FLAGS1 bit flags const_def - const INVISIBLE_F ; 0 - const WONT_DELETE_F ; 1 - const FIXED_FACING_F ; 2 - const SLIDING_F ; 3 - const NOCLIP_TILES_F ; 4 - const MOVE_ANYWHERE_F ; 5 - const NOCLIP_OBJS_F ; 6 - const EMOTE_OBJECT_F ; 7 - -DEF INVISIBLE EQU 1 << INVISIBLE_F -DEF WONT_DELETE EQU 1 << WONT_DELETE_F -DEF FIXED_FACING EQU 1 << FIXED_FACING_F -DEF SLIDING EQU 1 << SLIDING_F -DEF NOCLIP_TILES EQU 1 << NOCLIP_TILES_F -DEF MOVE_ANYWHERE EQU 1 << MOVE_ANYWHERE_F -DEF NOCLIP_OBJS EQU 1 << NOCLIP_OBJS_F -DEF EMOTE_OBJECT EQU 1 << EMOTE_OBJECT_F + shift_const INVISIBLE ; 0 + shift_const WONT_DELETE ; 1 + shift_const FIXED_FACING ; 2 + shift_const SLIDING ; 3 + shift_const NOCLIP_TILES ; 4 + shift_const MOVE_ANYWHERE ; 5 + shift_const NOCLIP_OBJS ; 6 + shift_const EMOTE_OBJECT ; 7 ; object_struct OBJECT_FLAGS2 bit flags const_def - const LOW_PRIORITY_F ; 0 - const HIGH_PRIORITY_F ; 1 - const OBJ_FLAGS2_2 ; 2 - const OVERHEAD_F ; 3 - const USE_OBP1_F ; 4 - const FROZEN_F ; 5 - const OBJ_FLAGS2_6 ; 6 - const OBJ_FLAGS2_7 ; 7 - -DEF LOW_PRIORITY EQU 1 << LOW_PRIORITY_F -DEF HIGH_PRIORITY EQU 1 << HIGH_PRIORITY_F -DEF OVERHEAD EQU 1 << OVERHEAD_F -DEF USE_OBP1 EQU 1 << USE_OBP1_F + shift_const LOW_PRIORITY ; 0 + shift_const HIGH_PRIORITY ; 1 + shift_const BOULDER_MOVING ; 2 + shift_const OVERHEAD ; 3 + shift_const USE_OBP1 ; 4 + shift_const FROZEN ; 5 + shift_const OFF_SCREEN ; 6 + shift_const OBJ_FLAGS2_7 ; 7 ; object_struct OBJECT_PALETTE bit flags const_def 5 - const SWIMMING_F ; 5 - const STRENGTH_BOULDER_F ; 6 - const BIG_OBJECT_F ; 7 - -DEF SWIMMING EQU 1 << SWIMMING_F -DEF STRENGTH_BOULDER EQU 1 << STRENGTH_BOULDER_F -DEF BIG_OBJECT EQU 1 << BIG_OBJECT_F + shift_const SWIMMING ; 5 + shift_const STRENGTH_BOULDER ; 6 + shift_const BIG_OBJECT ; 7 ; facing attribute bit flags -DEF RELATIVE_ATTRIBUTES_F EQU 1 -DEF ABSOLUTE_TILE_ID_F EQU 2 - -DEF RELATIVE_ATTRIBUTES EQU 1 << RELATIVE_ATTRIBUTES_F -DEF ABSOLUTE_TILE_ID EQU 1 << ABSOLUTE_TILE_ID_F + const_def 1 + shift_const RELATIVE_ATTRIBUTES ; 1 + shift_const ABSOLUTE_TILE_ID ; 2 ; map_object struct members (see macros/ram.asm) ; struct initialized by object_event macro (see macros/scripts/maps.asm) diff --git a/constants/map_setup_constants.asm b/constants/map_setup_constants.asm index 42d806a4b8c..dc0bee6a6bf 100644 --- a/constants/map_setup_constants.asm +++ b/constants/map_setup_constants.asm @@ -22,3 +22,6 @@ DEF NUM_MAPSETUP_SCRIPTS EQU const_value - $f1 const MAPCALLBACK_CMDQUEUE const MAPCALLBACK_SPRITES const MAPCALLBACK_NEWMAP + +; see data/maps/setup_script_pointers.asm +DEF MAPSETUPSCRIPT_HAS_PARAM_F EQU 7 diff --git a/constants/menu_constants.asm b/constants/menu_constants.asm index 63b0f5d7e42..f3ce138ee92 100644 --- a/constants/menu_constants.asm +++ b/constants/menu_constants.asm @@ -1,41 +1,56 @@ ; MenuHeader flags const_def - shift_const MENU_RESTORE_TILES ; Will be set if MENU_BACKUP_TILES(_2) is set. - shift_const MENU_UNUSED_1 - shift_const MENU_UNUSED_2 - shift_const MENU_NO_CLICK_SFX - shift_const MENU_SPRITE_ANIMS - shift_const MENU_UNUSED_3 - shift_const MENU_BACKUP_TILES - shift_const MENU_BACKUP_TILES_2 + shift_const MENU_RESTORE_TILES ; 0 + const_skip 2 + shift_const MENU_NO_CLICK_SFX ; 3 + shift_const MENU_SPRITE_ANIMS ; 4 + shift_const MENU_UNUSED ; 5 + shift_const MENU_BACKUP_TILES ; 6 + shift_const MENU_BACKUP_TILES_2 ; 7 ; VerticalMenu/DoNthMenu/SetUpMenu/_2DMenu MenuData flags ; Per flag the comment specifies which menus actually implement it const_def - shift_const STATICMENU_DISABLE_B ; VerticalMenu/_2DMenu - shift_const STATICMENU_ENABLE_SELECT ; VerticalMenu/_2DMenu - shift_const STATICMENU_ENABLE_LEFT_RIGHT ; DoNthMenu/SetUpMenu - shift_const STATICMENU_ENABLE_START ; DoNthMenu/SetUpMenu - shift_const STATICMENU_PLACE_TITLE ; VerticalMenu - shift_const STATICMENU_WRAP ; All - shift_const STATICMENU_NO_TOP_SPACING ; VerticalMenu/_2DMenu - shift_const STATICMENU_CURSOR ; VerticalMenu/_2DMenu + shift_const STATICMENU_DISABLE_B ; 0 ; VerticalMenu/_2DMenu + shift_const STATICMENU_ENABLE_SELECT ; 1 ; VerticalMenu/_2DMenu + shift_const STATICMENU_ENABLE_LEFT_RIGHT ; 2 ; DoNthMenu/SetUpMenu + shift_const STATICMENU_ENABLE_START ; 3 ; DoNthMenu/SetUpMenu + shift_const STATICMENU_PLACE_TITLE ; 4 ; VerticalMenu + shift_const STATICMENU_WRAP ; 5 ; All + shift_const STATICMENU_NO_TOP_SPACING ; 6 ; VerticalMenu/_2DMenu + shift_const STATICMENU_CURSOR ; 7 ; VerticalMenu/_2DMenu ; ScrollingMenu MenuData flags const_def - shift_const SCROLLINGMENU_CALL_FUNCTION1_CANCEL - shift_const SCROLLINGMENU_CALL_FUNCTION3_NO_SWITCH - shift_const SCROLLINGMENU_ENABLE_LEFT - shift_const SCROLLINGMENU_ENABLE_RIGHT - shift_const SCROLLINGMENU_DISPLAY_ARROWS - shift_const SCROLLINGMENU_ENABLE_FUNCTION3 - shift_const SCROLLINGMENU_ENABLE_START - shift_const SCROLLINGMENU_ENABLE_SELECT + shift_const SCROLLINGMENU_CALL_FUNCTION1_CANCEL ; 0 + shift_const SCROLLINGMENU_CALL_FUNCTION3_NO_SWITCH ; 1 + shift_const SCROLLINGMENU_ENABLE_RIGHT ; 2 + shift_const SCROLLINGMENU_ENABLE_LEFT ; 3 + shift_const SCROLLINGMENU_DISPLAY_ARROWS ; 4 + shift_const SCROLLINGMENU_ENABLE_FUNCTION3 ; 5 + shift_const SCROLLINGMENU_ENABLE_START ; 6 + shift_const SCROLLINGMENU_ENABLE_SELECT ; 7 ; ScrollingMenu items structure format const_def 1 - const SCROLLINGMENU_ITEMS_NORMAL - const SCROLLINGMENU_ITEMS_QUANTITY + const SCROLLINGMENU_ITEMS_NORMAL ; 1 + const SCROLLINGMENU_ITEMS_QUANTITY ; 2 + +; _2DMenu more flags + const_def + shift_const _2DMENU_EXIT_RIGHT ; 0 + shift_const _2DMENU_EXIT_LEFT ; 1 + shift_const _2DMENU_EXIT_UP ; 2 + shift_const _2DMENU_EXIT_DOWN ; 3 + shift_const _2DMENU_WRAP_LEFT_RIGHT ; 4 + shift_const _2DMENU_WRAP_UP_DOWN ; 5 + shift_const _2DMENU_ENABLE_SPRITE_ANIMS ; 6 + shift_const _2DMENU_DISABLE_JOYPAD_FILTER ; 7 + +; _2DMenu more flags 2 + const_def + const_skip 7 + shift_const _2DMENU_EXITING ; 7 ; MonMenuOptions indexes (see data/mon_menu.asm) ; used by PokemonActionSubmenu (see engine/pokemon/mon_menu.asm) diff --git a/constants/music_constants.asm b/constants/music_constants.asm index d64fa57611d..e471d77f381 100644 --- a/constants/music_constants.asm +++ b/constants/music_constants.asm @@ -108,12 +108,14 @@ DEF NUM_MUSIC_SONGS EQU const_value ; GetMapMusic picks music for this value (see home/map.asm) -DEF MUSIC_MAHOGANY_MART EQU $64 +; this overlaps with a Crystal song ID, but not one that is used for map music +DEF MUSIC_MAHOGANY_MART EQU MUSIC_SUICUNE_BATTLE ; ExitPokegearRadio_HandleMusic uses these values DEF RESTART_MAP_MUSIC EQU $fe DEF ENTER_MAP_MUSIC EQU $ff ; GetMapMusic picks music for this bit flag -DEF RADIO_TOWER_MUSIC_F EQU 7 -DEF RADIO_TOWER_MUSIC EQU 1 << RADIO_TOWER_MUSIC_F + const_def 7 + shift_const RADIO_TOWER_MUSIC +assert NUM_MUSIC_SONGS <= RADIO_TOWER_MUSIC, "song IDs overlap RADIO_TOWER_MUSIC" diff --git a/constants/printer_constants.asm b/constants/printer_constants.asm index f0b8b4818ea..ceaa7f601d8 100644 --- a/constants/printer_constants.asm +++ b/constants/printer_constants.asm @@ -1,9 +1,20 @@ ; wPrinterStatus const_def 1 - const PRINTER_STATUS_CHECKING - const PRINTER_STATUS_TRANSMITTING - const PRINTER_STATUS_PRINTING - const PRINTER_ERROR_1 - const PRINTER_ERROR_2 - const PRINTER_ERROR_3 - const PRINTER_ERROR_4 + const PRINTER_STATUS_CHECKING ; 1 + const PRINTER_STATUS_TRANSMITTING ; 2 + const PRINTER_STATUS_PRINTING ; 3 + const PRINTER_ERROR_1 ; 4 + const PRINTER_ERROR_2 ; 5 + const PRINTER_ERROR_3 ; 6 + const PRINTER_ERROR_4 ; 7 + +; wPrinterStatusFlags + const_def 5 + shift_const PRINTER_STATUS_ERROR_3 ; 5 + shift_const PRINTER_STATUS_ERROR_4 ; 6 + shift_const PRINTER_STATUS_ERROR_1 ; 7 + +; wPrinterConnectionOpen + const_def + const PRINTER_CONNECTION_OPEN + const PRINTER_CONNECTION_SUCCESS diff --git a/constants/ram_constants.asm b/constants/ram_constants.asm index 822d478201b..3e020cc3434 100644 --- a/constants/ram_constants.asm +++ b/constants/ram_constants.asm @@ -29,6 +29,9 @@ DEF GAME_TIMER_MOBILE_F EQU 7 DEF JOYPAD_DISABLE_MON_FAINT_F EQU 6 DEF JOYPAD_DISABLE_SGB_TRANSFER_F EQU 7 +; wInBattleTowerBattle:: +DEF IN_BATTLE_TOWER_BATTLE_F EQU 0 + ; wOptions1:: DEF TEXT_DELAY_MASK EQU %111 const_def 4 @@ -69,6 +72,9 @@ DEF GBPRINTER_DARKEST EQU $7f const_def const MENU_ACCOUNT ; 0 +; wDST:: +DEF DST_F EQU 7 + ; wWalkingDirection:: const_def -1 const STANDING ; -1 @@ -97,6 +103,11 @@ DEF LAST_12_SPRITE_OAM_STRUCTS_RESERVED_F EQU 1 DEF TEXT_STATE_F EQU 6 DEF SCRIPTED_MOVEMENT_STATE_F EQU 7 +; wSpriteFlags:: +DEF SPRITES_VRAM_BANK_0_F EQU 5 +DEF SPRITES_SKIP_WALKING_GFX_F EQU 6 +DEF SPRITES_SKIP_STANDING_GFX_F EQU 7 + ; wPokemonWithdrawDepositParameter:: DEF PC_WITHDRAW EQU 0 DEF PC_DEPOSIT EQU 1 @@ -119,21 +130,23 @@ DEF INIT_OTHER_ITEM_LIST EQU 3 DEF INIT_PLAYEROT_LIST EQU 4 DEF INIT_MON_LIST EQU 5 +; wMapNameSignFlags:: + const_def 1 + const SHOWN_MAP_NAME_SIGN ; 1 + ; wTimeOfDay:: const_def - const MORN_F ; 0 - const DAY_F ; 1 - const NITE_F ; 2 - const DARKNESS_F ; 3 + shift_const MORN ; 0 + shift_const DAY ; 1 + shift_const NITE ; 2 + shift_const DARKNESS ; 3 DEF NUM_DAYTIMES EQU const_value -DEF MORN EQU 1 << MORN_F -DEF DAY EQU 1 << DAY_F -DEF NITE EQU 1 << NITE_F -DEF DARKNESS EQU 1 << DARKNESS_F - DEF ANYTIME EQU MORN | DAY | NITE +; wTimeOfDayPalFlags:: +DEF FORCED_PALSET_F EQU 7 + ; wTimeOfDayPalset:: DEF DARKNESS_PALSET EQU (DARKNESS_F << 6) | (DARKNESS_F << 4) | (DARKNESS_F << 2) | DARKNESS_F @@ -144,6 +157,10 @@ DEF DARKNESS_PALSET EQU (DARKNESS_F << 6) | (DARKNESS_F << 4) | (DARKNESS_F << 2 const BATTLEANIM_IN_LOOP_F ; 2 const BATTLEANIM_KEEPSPRITES_F ; 3 +; wBattleScriptFlags:: +DEF BATTLESCRIPT_WILD_F EQU 0 +DEF BATTLESCRIPT_SCRIPTED_F EQU 7 + ; wPlayerSpriteSetupFlags:: DEF PLAYERSPRITESETUP_FACING_MASK EQU %11 DEF PLAYERSPRITESETUP_FEMALE_TO_MALE_F EQU 2 @@ -167,7 +184,20 @@ DEF PLAYERGENDER_FEMALE_F EQU 0 const MAPEVENTS_OFF ; 1 ; wScriptFlags:: -DEF SCRIPT_RUNNING EQU 2 + const_def + const UNUSED_SCRIPT_FLAG_0 ; 0 + const UNUSED_SCRIPT_FLAG_1 ; 1 + const SCRIPT_RUNNING ; 2 + const RUN_DEFERRED_SCRIPT ; 3 + +; wEnabledPlayerEvents:: + const_def + const PLAYEREVENTS_COUNT_STEPS ; 0 + const PLAYEREVENTS_COORD_EVENTS ; 1 + const PLAYEREVENTS_WARPS_AND_CONNECTIONS ; 2 + const_skip + const PLAYEREVENTS_WILD_ENCOUNTERS ; 4 + const PLAYEREVENTS_UNUSED ; 5 ; wScriptMode:: const_def @@ -180,6 +210,9 @@ DEF SCRIPT_RUNNING EQU 2 DEF SPAWN_LANCE EQU 1 DEF SPAWN_RED EQU 2 +; wGameTimeCap:: +DEF GAME_TIME_CAPPED EQU 0 + ; wCurDay:: const_def const SUNDAY ; 0 @@ -325,6 +358,12 @@ DEF DAYCARELADY_ACTIVE_F EQU 7 const UNLOCKED_UNOWNS_X_TO_Z_F DEF NUM_UNLOCKED_UNOWN_SETS EQU const_value +; sRTCStatusFlags:: + const_def 5 + shift_const RTC_DAYS_EXCEED_139 ; 5 + shift_const RTC_DAYS_EXCEED_255 ; 6 + shift_const RTC_RESET ; 7 + ; hVBlank:: ; VBlankHandlers indexes (see home/vblank.asm) const_def diff --git a/constants/text_constants.asm b/constants/text_constants.asm index 67ed07ef2e7..ecbc726885c 100644 --- a/constants/text_constants.asm +++ b/constants/text_constants.asm @@ -33,16 +33,11 @@ DEF TEXTBOX_INNERY EQU TEXTBOX_Y + 2 ; see gfx/frames/*.png DEF TEXTBOX_FRAME_TILES EQU 6 -; PrintNum bit flags +; PrintNum bit flags (see engine/math/print_num.asm) const_def 5 - const PRINTNUM_MONEY_F ; 5 - const PRINTNUM_LEFTALIGN_F ; 6 - const PRINTNUM_LEADINGZEROS_F ; 7 - -; PrintNum arguments (see engine/math/print_num.asm) -DEF PRINTNUM_MONEY EQU 1 << PRINTNUM_MONEY_F -DEF PRINTNUM_LEFTALIGN EQU 1 << PRINTNUM_LEFTALIGN_F -DEF PRINTNUM_LEADINGZEROS EQU 1 << PRINTNUM_LEADINGZEROS_F + shift_const PRINTNUM_MONEY ; 5 + shift_const PRINTNUM_LEFTALIGN ; 6 + shift_const PRINTNUM_LEADINGZEROS ; 7 ; character sets (see charmap.asm) DEF FIRST_REGULAR_TEXT_CHAR EQU $60 diff --git a/constants/trainer_data_constants.asm b/constants/trainer_data_constants.asm index b08de9deb7a..51aef938b94 100644 --- a/constants/trainer_data_constants.asm +++ b/constants/trainer_data_constants.asm @@ -24,20 +24,13 @@ DEF NO_AI EQU 0 ; TRNATTR_AI_ITEM_SWITCH bit flags const_def - const SWITCH_OFTEN_F ; 0 - const SWITCH_RARELY_F ; 1 - const SWITCH_SOMETIMES_F ; 2 - const_skip ; 3 - const ALWAYS_USE_F ; 4 - const UNKNOWN_USE_F ; 5 - const CONTEXT_USE_F ; 6 - -DEF SWITCH_OFTEN EQU 1 << SWITCH_OFTEN_F -DEF SWITCH_RARELY EQU 1 << SWITCH_RARELY_F -DEF SWITCH_SOMETIMES EQU 1 << SWITCH_SOMETIMES_F -DEF ALWAYS_USE EQU 1 << ALWAYS_USE_F -DEF UNKNOWN_USE EQU 1 << UNKNOWN_USE_F -DEF CONTEXT_USE EQU 1 << CONTEXT_USE_F + shift_const SWITCH_OFTEN ; 0 + shift_const SWITCH_RARELY ; 1 + shift_const SWITCH_SOMETIMES ; 2 + const_skip + shift_const ALWAYS_USE ; 4 + shift_const UNKNOWN_USE ; 5 + shift_const CONTEXT_USE ; 6 ; TrainerTypes indexes (see engine/battle/read_trainer_party.asm) const_def diff --git a/data/maps/setup_script_pointers.asm b/data/maps/setup_script_pointers.asm index 18b4ec0ae11..597c4db2843 100644 --- a/data/maps/setup_script_pointers.asm +++ b/data/maps/setup_script_pointers.asm @@ -1,6 +1,14 @@ MACRO add_mapsetup \1_MapSetupCmd: - dba \1 + ; A second argument of TRUE indicates taking a parameter. + if _NARG < 2 + dba \1 + elif \2 + db (1 << MAPSETUPSCRIPT_HAS_PARAM_F) | BANK(\1) + dw \1 + else + dba \1 + endc ENDM MapSetupCommands: diff --git a/data/maps/setup_scripts.asm b/data/maps/setup_scripts.asm index efa4fe584bc..259fa9fd081 100644 --- a/data/maps/setup_scripts.asm +++ b/data/maps/setup_scripts.asm @@ -18,6 +18,10 @@ MapSetupScripts: ; valid commands are listed in MapSetupCommands (see data/maps/setup_script_pointers.asm) MACRO mapsetup db (\1_MapSetupCmd - MapSetupCommands) / 3 + ; `mapsetup` takes a parameter if `add_mapsetup` indicates taking one. + if _NARG == 2 + db \2 ; param + endc ENDM MapSetupScript_Teleport: diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 3ff088b30b1..0cd2ce33719 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -1297,7 +1297,7 @@ Pryce's dialog ("That BADGE will raise the SPECIAL stats of POKéMON.") implies .FutureSight: -; BUG: AI does not discourage Future Sight when it's already been used (see docs/bugs_and_glitches.md) - ld a, [wEnemyScreens] -- bit 5, a +- bit SCREENS_UNUSED, a + ld a, [wEnemyFutureSightCount] + and a ret @@ -2008,7 +2008,7 @@ Finally, edit [engine/battle/read_trainer_party.asm](https://github.com/pret/pok + ld [wCurPartyLevel], a + + ld a, [wInBattleTowerBattle] -+ bit 0, a ++ bit IN_BATTLE_TOWER_BATTLE_F, a + ret nz + + ld a, [wLinkMode] diff --git a/docs/design_flaws.md b/docs/design_flaws.md index 6b08afe6d3d..e67421271fa 100644 --- a/docs/design_flaws.md +++ b/docs/design_flaws.md @@ -248,7 +248,8 @@ Redefine the special music constants in [constants/music_constants.asm](https:// ```diff -; GetMapMusic picks music for this value (see home/map.asm) --DEF MUSIC_MAHOGANY_MART EQU $64 +-; this overlaps with a Crystal song ID, but not one that is used for map music +-DEF MUSIC_MAHOGANY_MART EQU MUSIC_SUICUNE_BATTLE +; GetMapMusic picks music for these values (see home/map.asm) +DEF MUSIC_MAHOGANY_MART EQU $fc +DEF MUSIC_RADIO_TOWER EQU $fd @@ -256,10 +257,12 @@ Redefine the special music constants in [constants/music_constants.asm](https:// ; ExitPokegearRadio_HandleMusic uses these values DEF RESTART_MAP_MUSIC EQU $fe DEF ENTER_MAP_MUSIC EQU $ff -- + -; GetMapMusic picks music for this bit flag --DEF RADIO_TOWER_MUSIC_F EQU 7 --DEF RADIO_TOWER_MUSIC EQU 1 << RADIO_TOWER_MUSIC_F +- const_def 7 +- shift_const RADIO_TOWER_MUSIC +-assert NUM_MUSIC_SONGS <= RADIO_TOWER_MUSIC, "song IDs overlap RADIO_TOWER_MUSIC" ++assert NUM_MUSIC_SONGS <= MUSIC_MAHOGANY_MART, "song IDs overlap special values" ``` Edit `GetMapMusic`: diff --git a/engine/battle/ai/move.asm b/engine/battle/ai/move.asm index adf458f0a54..7ada6b05701 100644 --- a/engine/battle/ai/move.asm +++ b/engine/battle/ai/move.asm @@ -64,10 +64,11 @@ AIChooseMove: .ApplyLayers: ld hl, TrainerClassAttributes + TRNATTR_AI_MOVE_WEIGHTS - ; If we have a battle in BattleTower just load the Attributes of the first trainer class in wTrainerClass (Falkner) - ; so we have always the same AI, regardless of the loaded class of trainer + ; If we have a battle in Battle Tower, just load the attributes of the first + ; trainer class in TrainerClassAttributes (Falkner), so we have always the + ; same AI, regardless of the loaded class of trainer. ld a, [wInBattleTowerBattle] - bit 0, a + bit IN_BATTLE_TOWER_BATTLE_F, a jr nz, .battle_tower_skip ld a, [wTrainerClass] diff --git a/engine/battle/ai/redundant.asm b/engine/battle/ai/redundant.asm index 6525bde24e5..bb9338fb700 100644 --- a/engine/battle/ai/redundant.asm +++ b/engine/battle/ai/redundant.asm @@ -178,7 +178,7 @@ AI_Redundant: .FutureSight: ; BUG: AI does not discourage Future Sight when it's already been used (see docs/bugs_and_glitches.md) ld a, [wEnemyScreens] - bit 5, a + bit SCREENS_UNUSED, a ret .Heal: diff --git a/engine/battle/core.asm b/engine/battle/core.asm index d4d87c17a71..0eb1b516850 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -2365,7 +2365,7 @@ WinTrainerBattle: ret nz ld a, [wInBattleTowerBattle] - bit 0, a + bit IN_BATTLE_TOWER_BATTLE_F, a jr nz, .battle_tower call BattleWinSlideInEnemyTrainerFrontpic @@ -2913,7 +2913,7 @@ LostBattle: ld [wBattleEnded], a ld a, [wInBattleTowerBattle] - bit 0, a + bit IN_BATTLE_TOWER_BATTLE_F, a jr nz, .battle_tower ld a, [wBattleType] @@ -5972,9 +5972,9 @@ LoadEnemyMon: and a jp nz, InitEnemyMon -; and also not in a BattleTower-Battle +; and also not in a Battle Tower battle ld a, [wInBattleTowerBattle] - bit 0, a + bit IN_BATTLE_TOWER_BATTLE_F, a jp nz, InitEnemyMon ; Make sure everything knows what species we're working with @@ -6982,7 +6982,7 @@ GiveExperiencePoints: ret nz ld a, [wInBattleTowerBattle] - bit 0, a + bit IN_BATTLE_TOWER_BATTLE_F, a ret nz call .EvenlyDivideExpAmongParticipants @@ -8346,7 +8346,7 @@ CheckPayDay: ld hl, BattleText_PlayerPickedUpPayDayMoney call StdBattleTextbox ld a, [wInBattleTowerBattle] - bit 0, a + bit IN_BATTLE_TOWER_BATTLE_F, a ret z call ClearTilemap call ClearBGPalettes diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index 65eec4fb8b6..39019fb40a0 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -1285,7 +1285,7 @@ BattleCommand_Stab: ld [wCurDamage + 1], a ld hl, wTypeModifier - set 7, [hl] + set STAB_DAMAGE_F, [hl] .SkipStab: ld a, BATTLE_VARS_MOVE_TYPE @@ -1324,7 +1324,7 @@ BattleCommand_Stab: push bc inc hl ld a, [wTypeModifier] - and %10000000 + and STAB_DAMAGE ld b, a ; If the target is immune to the move, treat it as a miss and calculate the damage as 0 ld a, [hl] @@ -1390,7 +1390,7 @@ BattleCommand_Stab: ld a, [wTypeMatchup] ld b, a ld a, [wTypeModifier] - and %10000000 + and STAB_DAMAGE or b ld [wTypeModifier], a ret @@ -2198,7 +2198,7 @@ GetFailureResultText: ld hl, DoesntAffectText ld de, DoesntAffectText ld a, [wTypeModifier] - and $7f + and EFFECTIVENESS_MASK jr z, .got_text ld a, BATTLE_VARS_MOVE_EFFECT call GetBattleVar @@ -2223,7 +2223,7 @@ GetFailureResultText: ret nz ld a, [wTypeModifier] - and $7f + and EFFECTIVENESS_MASK ret z ld hl, wCurDamage @@ -2268,7 +2268,7 @@ BattleCommand_BideFailText: ret z ld a, [wTypeModifier] - and $7f + and EFFECTIVENESS_MASK jp z, PrintDoesntAffect jp PrintButItFailed @@ -2323,7 +2323,7 @@ BattleCommand_SuperEffectiveLoopText: BattleCommand_SuperEffectiveText: ld a, [wTypeModifier] - and $7f + and EFFECTIVENESS_MASK cp EFFECTIVE ret z ld hl, SuperEffectiveText @@ -3673,7 +3673,7 @@ BattleCommand_PoisonTarget: and a ret nz ld a, [wTypeModifier] - and $7f + and EFFECTIVENESS_MASK ret z call CheckIfTargetIsPoisonType ret z @@ -3701,7 +3701,7 @@ BattleCommand_PoisonTarget: BattleCommand_Poison: ld hl, DoesntAffectText ld a, [wTypeModifier] - and $7f + and EFFECTIVENESS_MASK jp z, .failed call CheckIfTargetIsPoisonType @@ -3937,7 +3937,7 @@ BattleCommand_BurnTarget: and a jp nz, Defrost ld a, [wTypeModifier] - and $7f + and EFFECTIVENESS_MASK ret z call CheckMoveTypeMatchesTarget ; Don't burn a Fire-type ret z @@ -4001,7 +4001,7 @@ BattleCommand_FreezeTarget: and a ret nz ld a, [wTypeModifier] - and $7f + and EFFECTIVENESS_MASK ret z ld a, [wBattleWeather] cp WEATHER_SUN @@ -4052,7 +4052,7 @@ BattleCommand_ParalyzeTarget: and a ret nz ld a, [wTypeModifier] - and $7f + and EFFECTIVENESS_MASK ret z call GetOpponentItem ld a, b @@ -5420,7 +5420,7 @@ BattleCommand_HeldFlinch: BattleCommand_OHKO: call ResetDamage ld a, [wTypeModifier] - and $7f + and EFFECTIVENESS_MASK jr z, .no_effect ld hl, wEnemyMonLevel ld de, wBattleMonLevel @@ -5834,7 +5834,7 @@ BattleCommand_Paralyze: bit PAR, a jr nz, .paralyzed ld a, [wTypeModifier] - and $7f + and EFFECTIVENESS_MASK jr z, .didnt_affect call GetOpponentItem ld a, b diff --git a/engine/battle/move_effects/rollout.asm b/engine/battle/move_effects/rollout.asm index 1734d1be025..c7582eeec04 100644 --- a/engine/battle/move_effects/rollout.asm +++ b/engine/battle/move_effects/rollout.asm @@ -46,7 +46,7 @@ BattleCommand_RolloutPower: ld a, BATTLE_VARS_SUBSTATUS1 call GetBattleVarAddr - res 6, [hl] + res SUBSTATUS_ROLLOUT, [hl] ret .hit diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm index 238c316f633..f2b978b9b36 100644 --- a/engine/battle/read_trainer_party.asm +++ b/engine/battle/read_trainer_party.asm @@ -1,6 +1,6 @@ ReadTrainerParty: ld a, [wInBattleTowerBattle] - bit 0, a + bit IN_BATTLE_TOWER_BATTLE_F, a ret nz ld a, [wLinkMode] @@ -323,7 +323,7 @@ ComputeTrainerReward: Battle_GetTrainerName:: ld a, [wInBattleTowerBattle] - bit 0, a + bit IN_BATTLE_TOWER_BATTLE_F, a ld hl, wOTPlayerName jp nz, CopyTrainerName diff --git a/engine/battle_anims/anim_commands.asm b/engine/battle_anims/anim_commands.asm index bcdb40eb89e..97ffe22949f 100644 --- a/engine/battle_anims/anim_commands.asm +++ b/engine/battle_anims/anim_commands.asm @@ -26,7 +26,7 @@ _PlayBattleAnim: ld c, VBLANK_CUTSCENE ldh a, [rKEY1] - bit 7, a ; check CGB double speed mode + bit KEY1_DBLSPEED, a jr nz, .got_speed ld c, VBLANK_CUTSCENE_CGB @@ -1319,7 +1319,7 @@ PlayHitSound: .okay ld a, [wTypeModifier] - and $7f + and EFFECTIVENESS_MASK ret z cp EFFECTIVE diff --git a/engine/battle_anims/core.asm b/engine/battle_anims/core.asm index 2f2232e90f8..9e314681b7f 100644 --- a/engine/battle_anims/core.asm +++ b/engine/battle_anims/core.asm @@ -236,7 +236,7 @@ InitBattleAnimBuffer: add hl, bc ld a, [hl] ld [wBattleAnimTempOAMFlags], a - bit 0, [hl] + bit BATTLEANIMSTRUCT_OAMFLAGS_FIX_COORDS_F, [hl] ret z ld hl, BATTLEANIMSTRUCT_XCOORD diff --git a/engine/battle_anims/functions.asm b/engine/battle_anims/functions.asm index 9b157ed95a2..ad7ef70bdf3 100644 --- a/engine/battle_anims/functions.asm +++ b/engine/battle_anims/functions.asm @@ -813,6 +813,9 @@ BattleAnimFunc_FireBlast: ret BattleAnimFunc_RazorLeaf: +; Object moves at an arc +; Obj Param: Bit 6 defines offset from base frameset BATTLE_ANIM_FRAMESET_RAZOR_LEAF_2 +; Rest defines arc radius call BattleAnim_AnonJumptable .anon_dw dw .zero @@ -941,7 +944,7 @@ BattleAnimFunc_RazorLeaf: call ReinitBattleAnimFrameset ld hl, BATTLEANIMSTRUCT_OAMFLAGS add hl, bc - res 5, [hl] + res OAM_X_FLIP, [hl] .four .five .six @@ -1314,7 +1317,7 @@ BattleAnimFunc_WaterGun: ld hl, BATTLEANIMSTRUCT_OAMFLAGS add hl, bc ld a, [hl] - and $1 + and 1 << BATTLEANIMSTRUCT_OAMFLAGS_FIX_COORDS_F ld [hl], a .two ld hl, BATTLEANIMSTRUCT_YOFFSET @@ -2032,7 +2035,7 @@ BattleAnimFunc_Kick: inc [hl] ld hl, BATTLEANIMSTRUCT_OAMFLAGS add hl, bc - set 0, [hl] + set BATTLEANIMSTRUCT_OAMFLAGS_FIX_COORDS_F, [hl] ld hl, BATTLEANIMSTRUCT_FIX_Y add hl, bc ld [hl], $90 diff --git a/engine/debug/debug_room.asm b/engine/debug/debug_room.asm index 56108c1728e..108e7ea7d41 100644 --- a/engine/debug/debug_room.asm +++ b/engine/debug/debug_room.asm @@ -372,7 +372,7 @@ DebugRoomMenu_TimerReset: ld a, BANK(sRTCStatusFlags) call OpenSRAM ld hl, sRTCStatusFlags - set 7, [hl] + set RTC_RESET_F, [hl] call CloseSRAM ret @@ -607,7 +607,7 @@ DebugRoom_EditPagedValues: call DelayFrame call JoyTextDelay ldh a, [hJoyLast] - bit 1, a + bit B_BUTTON_F, a jr nz, .done ld hl, .continue push hl diff --git a/engine/events/battle_tower/battle_tower.asm b/engine/events/battle_tower/battle_tower.asm index 2b4627e8260..da6438df7b9 100644 --- a/engine/events/battle_tower/battle_tower.asm +++ b/engine/events/battle_tower/battle_tower.asm @@ -219,7 +219,7 @@ RunBattleTowerTrainer: ld a, [wInBattleTowerBattle] push af - or 1 + or 1 << IN_BATTLE_TOWER_BATTLE_F ld [wInBattleTowerBattle], a xor a diff --git a/engine/events/field_moves.asm b/engine/events/field_moves.asm index 6abcc09ca48..78d5774f0a0 100644 --- a/engine/events/field_moves.asm +++ b/engine/events/field_moves.asm @@ -234,17 +234,21 @@ Cut_SpawnLeaf: pop de ret +; cut leaf spawn coords table bits +DEF CUT_LEAF_SPAWN_RIGHT_F EQU 0 +DEF CUT_LEAF_SPAWN_BOTTOM_F EQU 1 + Cut_GetLeafSpawnCoords: ld de, 0 ld a, [wPlayerMetatileX] - bit 0, a + bit 0, a ; even or odd? jr z, .left_side - set 0, e + set CUT_LEAF_SPAWN_RIGHT_F, e .left_side ld a, [wPlayerMetatileY] - bit 0, a + bit 0, a ; even or odd? jr z, .top_side - set 1, e + set CUT_LEAF_SPAWN_BOTTOM_F, e .top_side ld a, [wPlayerDirection] and %00001100 diff --git a/engine/events/map_name_sign.asm b/engine/events/map_name_sign.asm index b11a0e0c4c4..46786207723 100644 --- a/engine/events/map_name_sign.asm +++ b/engine/events/map_name_sign.asm @@ -26,9 +26,9 @@ InitMapNameSign:: ld [wCurLandmark], a .not_gate - ld hl, wEnteredMapFromContinue - bit 1, [hl] - res 1, [hl] + ld hl, wMapNameSignFlags + bit SHOWN_MAP_NAME_SIGN, [hl] + res SHOWN_MAP_NAME_SIGN, [hl] jr nz, .dont_do_map_sign call .CheckMovingWithinLandmark diff --git a/engine/events/mom.asm b/engine/events/mom.asm index e7621ae4fac..e0c53935766 100644 --- a/engine/events/mom.asm +++ b/engine/events/mom.asm @@ -284,7 +284,7 @@ BankOfMom: DSTChecks: ; check the time; avoid changing DST if doing so would change the current day ld a, [wDST] - bit 7, a + bit DST_F, a ldh a, [hHours] jr z, .NotDST and a ; within one hour of 00:00? @@ -313,14 +313,14 @@ DSTChecks: call .ClearBox bccoord 1, 14 ld a, [wDST] - bit 7, a + bit DST_F, a jr z, .SetDST ld hl, .TimesetAskNotDSTText call PrintTextboxTextAt call YesNoBox ret c ld a, [wDST] - res 7, a + res DST_F, a ld [wDST], a call .SetClockBack call .ClearBox @@ -335,7 +335,7 @@ DSTChecks: call YesNoBox ret c ld a, [wDST] - set 7, a + set DST_F, a ld [wDST], a call .SetClockForward call .ClearBox diff --git a/engine/games/card_flip.asm b/engine/games/card_flip.asm index 3109454b6c5..c193349db99 100644 --- a/engine/games/card_flip.asm +++ b/engine/games/card_flip.asm @@ -72,7 +72,7 @@ _CardFlip: call WaitSFX call ClearBGPalettes ld hl, wOptions - res 4, [hl] + res NO_TEXT_SCROLL, [hl] ret .CardFlip: diff --git a/engine/items/tmhm.asm b/engine/items/tmhm.asm index 404cd6135f4..6bb6b2e96f2 100644 --- a/engine/items/tmhm.asm +++ b/engine/items/tmhm.asm @@ -225,7 +225,7 @@ TMHM_JoypadLoop: xor a ldh [hBGMapMode], a ld a, [w2DMenuFlags2] - bit 7, a + bit _2DMENU_EXITING_F, a jp nz, TMHM_ScrollPocket ld a, b ld [wMenuJoypad], a @@ -301,8 +301,8 @@ TMHM_ExitPocket: TMHM_ScrollPocket: ld a, b - bit 7, a - jr nz, .skip + bit D_DOWN_F, a + jr nz, .down ld hl, wTMHMPocketScrollPosition ld a, [hl] and a @@ -311,7 +311,7 @@ TMHM_ScrollPocket: call TMHM_DisplayPocketItems jp TMHM_ShowTMMoveDescription -.skip +.down call TMHM_GetCurrentPocketPosition ld b, 5 .loop diff --git a/engine/link/link.asm b/engine/link/link.asm index 693a6fb509e..f01f24820de 100644 --- a/engine/link/link.asm +++ b/engine/link/link.asm @@ -1281,7 +1281,7 @@ LinkTrade_OTPartyMenu: ld [wMenuCursorX], a ln a, 1, 0 ld [w2DMenuCursorOffsets], a - ld a, MENU_UNUSED_3 + ld a, MENU_UNUSED ld [w2DMenuFlags1], a xor a ld [w2DMenuFlags2], a @@ -1345,7 +1345,7 @@ LinkTrade_PlayerPartyMenu: ld [wMenuCursorX], a ln a, 1, 0 ld [w2DMenuCursorOffsets], a - ld a, MENU_UNUSED_3 + ld a, MENU_UNUSED ld [w2DMenuFlags1], a xor a ld [w2DMenuFlags2], a @@ -1755,7 +1755,7 @@ LinkTrade: call Call_ExitMenu call WaitBGMap2 pop af - bit 1, a + bit B_BUTTON_F, a jr nz, .canceled ld a, [wMenuCursorY] dec a diff --git a/engine/link/link_trade.asm b/engine/link/link_trade.asm index 2beee33c5f0..212bfdefe7a 100644 --- a/engine/link/link_trade.asm +++ b/engine/link/link_trade.asm @@ -330,7 +330,7 @@ LinkTradeMenu: .TryAnims: ld a, [w2DMenuFlags1] - bit 6, a + bit _2DMENU_ENABLE_SPRITE_ANIMS_F, a jr z, .skip_anims farcall PlaySpriteAnimationsAndDelayFrame .skip_anims diff --git a/engine/link/mystery_gift.asm b/engine/link/mystery_gift.asm index d00141b61a2..0577afe9a87 100644 --- a/engine/link/mystery_gift.asm +++ b/engine/link/mystery_gift.asm @@ -1259,7 +1259,7 @@ ReceiveEmptyIRDataBlock: MysteryGift_UpdateJoypad: ; We can only get four inputs at a time. ; We take d-pad first for no particular reason. - ld a, R_DPAD + ld a, 1 << rJOYP_DPAD ldh [rJOYP], a ; Read twice to give the request time to take. ldh a, [rJOYP] @@ -1276,7 +1276,7 @@ MysteryGift_UpdateJoypad: ; Buttons make 8 total inputs (A, B, Select, Start). ; We can fit this into one byte. - ld a, R_BUTTONS + ld a, 1 << rJOYP_BUTTONS ldh [rJOYP], a ; Wait for input to stabilize. rept 6 diff --git a/engine/math/print_num.asm b/engine/math/print_num.asm index 09a10128b20..8a2f36fcd9c 100644 --- a/engine/math/print_num.asm +++ b/engine/math/print_num.asm @@ -11,17 +11,17 @@ _PrintNum:: push bc - bit 5, b + bit PRINTNUM_MONEY_F, b jr z, .main - bit 7, b + bit PRINTNUM_LEADINGZEROS_F, b jr nz, .moneyflag - bit 6, b + bit PRINTNUM_LEFTALIGN_F, b jr z, .main .moneyflag ; 101xxxxx or 011xxxxx ld a, "¥" ld [hli], a - res 5, b ; 100xxxxx or 010xxxxx + res PRINTNUM_MONEY_F, b ; 100xxxxx or 010xxxxx .main xor a @@ -184,11 +184,11 @@ _PrintNum:: ldh a, [hPrintNumBuffer + 0] and a jr nz, .stop - bit 5, d + bit PRINTNUM_MONEY_F, d jr z, .stop ld a, "¥" ld [hli], a - res 5, d + res PRINTNUM_MONEY_F, d .stop pop af @@ -262,11 +262,11 @@ _PrintNum:: ldh a, [hPrintNumBuffer + 0] and a jr nz, .done - bit 5, d + bit PRINTNUM_MONEY_F, d jr z, .done ld a, "¥" ld [hli], a - res 5, d + res PRINTNUM_MONEY_F, d .done ld a, "0" add c @@ -281,7 +281,7 @@ _PrintNum:: .PrintLeadingZero: ; prints a leading zero unless they are turned off in the flags - bit 7, d ; print leading zeroes? + bit PRINTNUM_LEADINGZEROS_F, d ret z ld [hl], "0" ret @@ -289,9 +289,9 @@ _PrintNum:: .AdvancePointer: ; increments the pointer unless leading zeroes are not being printed, ; the number is left-aligned, and no nonzero digits have been printed yet - bit 7, d ; print leading zeroes? + bit PRINTNUM_LEADINGZEROS_F, d jr nz, .inc - bit 6, d ; left alignment or right alignment? + bit PRINTNUM_LEFTALIGN_F, d jr z, .inc ldh a, [hPrintNumBuffer + 0] and a diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm index 617d6542a91..e1d23fd2bda 100644 --- a/engine/menus/intro_menu.asm +++ b/engine/menus/intro_menu.asm @@ -443,7 +443,7 @@ ConfirmContinue: Continue_CheckRTC_RestartClock: call CheckRTCStatus - and %10000000 ; Day count exceeded 16383 + and RTC_RESET jr z, .pass farcall RestartClock ld a, c @@ -464,8 +464,8 @@ FinishContinueFunction: ld hl, wGameTimerPaused set GAME_TIMER_COUNTING_F, [hl] res GAME_TIMER_MOBILE_F, [hl] - ld hl, wEnteredMapFromContinue - set 1, [hl] + ld hl, wMapNameSignFlags + set SHOWN_MAP_NAME_SIGN, [hl] farcall OverworldLoop ld a, [wSpawnAfterChampion] cp SPAWN_RED @@ -478,7 +478,7 @@ FinishContinueFunction: DisplaySaveInfoOnContinue: call CheckRTCStatus - and %10000000 + and RTC_RESET jr z, .clock_ok lb de, 4, 8 call DisplayContinueDataWithRTCError @@ -1266,7 +1266,7 @@ ResetClock: jp Init UpdateTitleTrailSprite: ; unreferenced - ; If bit 0 or 1 of [wTitleScreenTimer] is set, we don't need to be here. + ; Only update every 4 seconds, when the low 2 bits of [wTitleScreenTimer] are 0. ld a, [wTitleScreenTimer] and %00000011 ret nz @@ -1279,7 +1279,7 @@ UpdateTitleTrailSprite: ; unreferenced add hl, hl ld de, .TitleTrailCoords add hl, de - ; If bit 2 of [wTitleScreenTimer] is set, get the second coords; else, get the first coords + ; Every 8 seconds (i.e. every other update), get the second coords; else, get the first coords ld a, [wTitleScreenTimer] and %00000100 srl a diff --git a/engine/menus/main_menu.asm b/engine/menus/main_menu.asm index 15c73d852d8..33fba12cf7f 100644 --- a/engine/menus/main_menu.asm +++ b/engine/menus/main_menu.asm @@ -242,7 +242,7 @@ MainMenuJoypadLoop: .loop call MainMenu_PrintCurrentTimeAndDay ld a, [w2DMenuFlags1] - set 5, a + set _2DMENU_WRAP_UP_DOWN_F, a ld [w2DMenuFlags1], a call GetScrollingMenuJoypad ld a, [wMenuJoypad] @@ -281,7 +281,7 @@ MainMenu_PrintCurrentTimeAndDay: .PlaceBox: call CheckRTCStatus - and %10000000 ; Day count exceeded 16383 + and RTC_RESET jr nz, .TimeFail hlcoord 0, 14 ld b, 2 @@ -298,7 +298,7 @@ MainMenu_PrintCurrentTimeAndDay: and a ret z call CheckRTCStatus - and $80 + and RTC_RESET jp nz, .PrintTimeNotSet call UpdateTime call GetWeekday diff --git a/engine/menus/menu.asm b/engine/menus/menu.asm index 8f01d27e36e..4004d9c1bd0 100644 --- a/engine/menus/menu.asm +++ b/engine/menus/menu.asm @@ -68,7 +68,7 @@ Get2DMenuSelection: call MenuClickSound Mobile_GetMenuSelection: ld a, [wMenuDataFlags] - bit 1, a + bit STATICMENU_ENABLE_SELECT_F, a jr z, .skip call GetMenuJoypad bit SELECT_F, a @@ -76,7 +76,7 @@ Mobile_GetMenuSelection: .skip ld a, [wMenuDataFlags] - bit 0, a + bit STATICMENU_DISABLE_B_F, a jr nz, .skip2 call GetMenuJoypad bit B_BUTTON_F, a @@ -218,10 +218,10 @@ Init2DMenuCursorPosition: ld [hli], a ld [hld], a ld a, [wMenuDataFlags] - bit 5, a + bit STATICMENU_WRAP_F, a ret z - set 5, [hl] - set 4, [hl] + set _2DMENU_WRAP_UP_DOWN_F, [hl] + set _2DMENU_WRAP_LEFT_RIGHT_F, [hl] ret .InitFlags_b: @@ -233,11 +233,11 @@ Init2DMenuCursorPosition: .InitFlags_c: ld hl, wMenuDataFlags ld a, A_BUTTON - bit 0, [hl] + bit STATICMENU_DISABLE_B_F, [hl] jr nz, .skip or B_BUTTON .skip - bit 1, [hl] + bit STATICMENU_ENABLE_SELECT_F, [hl] jr z, .skip2 or SELECT .skip2 @@ -248,7 +248,7 @@ _StaticMenuJoypad:: call Place2DMenuCursor _ScrollingMenuJoypad:: ld hl, w2DMenuFlags2 - res 7, [hl] + res _2DMENU_DISABLE_JOYPAD_FILTER_F, [hl] ldh a, [hBGMapMode] push af call MenuJoypadLoop @@ -258,7 +258,7 @@ _ScrollingMenuJoypad:: MobileMenuJoypad: ld hl, w2DMenuFlags2 - res 7, [hl] + res _2DMENU_DISABLE_JOYPAD_FILTER_F, [hl] ldh a, [hBGMapMode] push af call Move2DMenuCursor @@ -282,7 +282,7 @@ Function241d5: ; unreferenced call _2DMenuInterpretJoypad jr c, .done ld a, [w2DMenuFlags1] - bit 7, a + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, a jr nz, .done call GetMenuJoypad ld c, a @@ -303,7 +303,7 @@ Function241d5: ; unreferenced farcall Function100337 ret c ld a, [w2DMenuFlags1] - bit 7, a + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, a jr z, .loop2 and a ret @@ -317,7 +317,7 @@ MenuJoypadLoop: call _2DMenuInterpretJoypad jr c, .done ld a, [w2DMenuFlags1] - bit 7, a + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, a jr nz, .done call GetMenuJoypad ld b, a @@ -346,14 +346,14 @@ Do2DMenuRTCJoypad: call Menu_WasButtonPressed ret c ld a, [w2DMenuFlags1] - bit 7, a + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, a jr z, .loopRTC and a ret Menu_WasButtonPressed: ld a, [w2DMenuFlags1] - bit 6, a + bit _2DMENU_ENABLE_SPRITE_ANIMS_F, a jr z, .skip_to_joypad callfar PlaySpriteAnimationsAndDelayFrame @@ -390,7 +390,7 @@ _2DMenuInterpretJoypad: .set_bit_7 ld hl, w2DMenuFlags2 - set 7, [hl] + set _2DMENU_EXITING_F, [hl] scf ret @@ -405,9 +405,9 @@ _2DMenuInterpretJoypad: .check_wrap_around_down ld a, [w2DMenuFlags1] - bit 5, a + bit _2DMENU_WRAP_UP_DOWN_F, a jr nz, .wrap_around_down - bit 3, a + bit _2DMENU_EXIT_DOWN_F, a jp nz, .set_bit_7 xor a ret @@ -428,9 +428,9 @@ _2DMenuInterpretJoypad: .check_wrap_around_up ld a, [w2DMenuFlags1] - bit 5, a + bit _2DMENU_WRAP_UP_DOWN_F, a jr nz, .wrap_around_up - bit 2, a + bit _2DMENU_EXIT_UP_F, a jp nz, .set_bit_7 xor a ret @@ -452,9 +452,9 @@ _2DMenuInterpretJoypad: .check_wrap_around_left ld a, [w2DMenuFlags1] - bit 4, a + bit _2DMENU_WRAP_LEFT_RIGHT_F, a jr nz, .wrap_around_left - bit 1, a + bit _2DMENU_EXIT_LEFT_F, a jp nz, .set_bit_7 xor a ret @@ -476,9 +476,9 @@ _2DMenuInterpretJoypad: .check_wrap_around_right ld a, [w2DMenuFlags1] - bit 4, a + bit _2DMENU_WRAP_LEFT_RIGHT_F, a jr nz, .wrap_around_right - bit 0, a + bit _2DMENU_EXIT_RIGHT_F, a jp nz, .set_bit_7 xor a ret @@ -575,34 +575,35 @@ _PushWindow:: dec b jr nz, .loop -; If bit 6 or 7 of the menu flags is set, set bit 0 of the address -; at 7:[wWindowStackPointer], and draw the menu using the coordinates from the header. -; Otherwise, reset bit 0 of 7:[wWindowStackPointer]. +; If bit MENU_BACKUP_TILES_F or MENU_BACKUP_TILES_2_F of the menu flags is set, +; also set bit MENU_RESTORE_TILES_F of the address at 7:[wWindowStackPointer], +; and draw the menu using the coordinates from the header. +; Otherwise, reset bit MENU_RESTORE_TILES_F of 7:[wWindowStackPointer]. ld a, [wMenuFlags] - bit 6, a - jr nz, .bit_6 - bit 7, a - jr z, .not_bit_7 + bit MENU_BACKUP_TILES_F, a + jr nz, .backup_tiles + bit MENU_BACKUP_TILES_2_F, a + jr z, .no_backup_tiles -.bit_6 +.backup_tiles ld hl, wWindowStackPointer ld a, [hli] ld h, [hl] ld l, a - set 0, [hl] + set MENU_RESTORE_TILES_F, [hl] call MenuBoxCoord2Tile call .copy call MenuBoxCoord2Attr call .copy jr .done -.not_bit_7 +.no_backup_tiles pop hl ; last-pushed register was de push hl ld a, [hld] ld l, [hl] ld h, a - res 0, [hl] + res MENU_RESTORE_TILES_F, [hl] .done pop hl @@ -672,7 +673,7 @@ _ExitMenu:: ld [wWindowStackPointer + 1], a call PopWindow ld a, [wMenuFlags] - bit 0, a + bit MENU_RESTORE_TILES_F, a jr z, .loop ld d, h ld e, l @@ -741,7 +742,7 @@ _InitVerticalMenuCursor:: ld hl, w2DMenuCursorInitY ld a, [wMenuBorderTopCoord] inc a - bit 6, b + bit STATICMENU_NO_TOP_SPACING_F, b jr nz, .skip_offset inc a .skip_offset @@ -757,15 +758,15 @@ _InitVerticalMenuCursor:: ld a, 1 ld [hli], a ; w2DMenuFlags1 - ld [hl], $0 - bit 5, b + ld [hl], 0 + bit STATICMENU_WRAP_F, b jr z, .skip_bit_5 - set 5, [hl] + set _2DMENU_WRAP_UP_DOWN_F, [hl] .skip_bit_5 ld a, [wMenuFlags] - bit 4, a + bit MENU_SPRITE_ANIMS_F, a jr z, .skip_bit_6 - set 6, [hl] + set _2DMENU_ENABLE_SPRITE_ANIMS_F, [hl] .skip_bit_6 inc hl ; w2DMenuFlags2 @@ -776,7 +777,7 @@ _InitVerticalMenuCursor:: ld [hli], a ; wMenuJoypadFilter ld a, A_BUTTON - bit 0, b + bit STATICMENU_DISABLE_B_F, b jr nz, .skip_bit_1 add B_BUTTON .skip_bit_1 diff --git a/engine/menus/scrolling_menu.asm b/engine/menus/scrolling_menu.asm index 3b674754817..2d19b770989 100644 --- a/engine/menus/scrolling_menu.asm +++ b/engine/menus/scrolling_menu.asm @@ -110,7 +110,7 @@ ScrollingMenuJoyAction: .select ld a, [wMenuDataFlags] - bit 7, a + bit SCROLLINGMENU_ENABLE_SELECT_F, a jp z, xor_a_dec_a ld a, [wMenuCursorY] dec a @@ -127,7 +127,7 @@ ScrollingMenuJoyAction: .start ld a, [wMenuDataFlags] - bit 6, a + bit SCROLLINGMENU_ENABLE_START_F, a jp z, xor_a_dec_a ld a, START scf @@ -135,10 +135,10 @@ ScrollingMenuJoyAction: .d_left ld hl, w2DMenuFlags2 - bit 7, [hl] + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, [hl] jp z, xor_a_dec_a ld a, [wMenuDataFlags] - bit 3, a + bit SCROLLINGMENU_ENABLE_LEFT_F, a jp z, xor_a_dec_a ld a, D_LEFT scf @@ -146,10 +146,10 @@ ScrollingMenuJoyAction: .d_right ld hl, w2DMenuFlags2 - bit 7, [hl] + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, [hl] jp z, xor_a_dec_a ld a, [wMenuDataFlags] - bit 2, a + bit SCROLLINGMENU_ENABLE_RIGHT_F, a jp z, xor_a_dec_a ld a, D_RIGHT scf @@ -157,7 +157,7 @@ ScrollingMenuJoyAction: .d_up ld hl, w2DMenuFlags2 - bit 7, [hl] + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, [hl] jp z, xor_a ld hl, wMenuScrollPosition ld a, [hl] @@ -171,7 +171,7 @@ ScrollingMenuJoyAction: .d_down ld hl, w2DMenuFlags2 - bit 7, [hl] + bit _2DMENU_DISABLE_JOYPAD_FILTER_F, [hl] jp z, xor_a ld hl, wMenuScrollPosition ld a, [wMenuData_ScrollingMenuHeight] @@ -277,15 +277,15 @@ ScrollingMenu_InitFlags: ld [w2DMenuNumRows], a ld a, 1 ld [w2DMenuNumCols], a - ld a, $8c - bit 2, c + ld a, _2DMENU_EXIT_UP | _2DMENU_EXIT_DOWN | _2DMENU_DISABLE_JOYPAD_FILTER + bit SCROLLINGMENU_ENABLE_RIGHT_F, c jr z, .skip_set_0 - set 0, a + set _2DMENU_EXIT_RIGHT_F, a .skip_set_0 - bit 3, c + bit SCROLLINGMENU_ENABLE_LEFT_F, c jr z, .skip_set_1 - set 1, a + set _2DMENU_EXIT_LEFT_F, a .skip_set_1 ld [w2DMenuFlags1], a @@ -294,12 +294,12 @@ ScrollingMenu_InitFlags: ld a, $20 ld [w2DMenuCursorOffsets], a ld a, A_BUTTON | B_BUTTON | D_UP | D_DOWN - bit 7, c + bit SCROLLINGMENU_ENABLE_SELECT_F, c jr z, .disallow_select add SELECT .disallow_select - bit 6, c + bit SCROLLINGMENU_ENABLE_START_F, c jr z, .disallow_start add START @@ -345,7 +345,7 @@ ScrollingMenu_ValidateSwitchItem: ScrollingMenu_UpdateDisplay: call ClearWholeMenuBox ld a, [wMenuDataFlags] - bit 4, a ; place arrows + bit SCROLLINGMENU_DISPLAY_ARROWS_F, a jr z, .okay ld a, [wMenuScrollPosition] and a @@ -385,7 +385,7 @@ ScrollingMenu_UpdateDisplay: cp b jr nz, .loop ld a, [wMenuDataFlags] - bit 4, a ; place arrows + bit SCROLLINGMENU_DISPLAY_ARROWS_F, a jr z, .done ld a, [wMenuBorderBottomCoord] ld b, a @@ -399,7 +399,7 @@ ScrollingMenu_UpdateDisplay: .cancel ld a, [wMenuDataFlags] - bit 0, a ; call function on cancel + bit SCROLLINGMENU_CALL_FUNCTION1_CANCEL_F, a jr nz, .call_function ld de, .CancelString call PlaceString @@ -468,9 +468,9 @@ ScrollingMenu_PlaceCursor: ScrollingMenu_CheckCallFunction3: ld a, [wMenuDataFlags] - bit 5, a ; call function 3 + bit SCROLLINGMENU_ENABLE_FUNCTION3_F, a ret z - bit 1, a ; call function 3 if not switching items + bit SCROLLINGMENU_CALL_FUNCTION3_NO_SWITCH_F, a jr z, .call ld a, [wSwitchItem] and a diff --git a/engine/movie/credits.asm b/engine/movie/credits.asm index 13ef6edf661..ab5af136460 100644 --- a/engine/movie/credits.asm +++ b/engine/movie/credits.asm @@ -1,10 +1,14 @@ +DEF ALLOW_SKIPPING_CREDITS_F EQU 6 + + SECTION "Credits", ROMX Credits:: - bit 6, b ; Hall Of Fame - ld a, $0 + ; Don't allow skipping credits the first time they're viewed in the Hall of Fame + bit STATUSFLAGS_HALL_OF_FAME_F, b + ld a, 0 jr z, .okay - ld a, $40 + ld a, 1 << ALLOW_SKIPPING_CREDITS_F .okay ld [wJumptableIndex], a @@ -119,7 +123,7 @@ Credits_HandleBButton: and B_BUTTON ret z ld a, [wJumptableIndex] - bit 6, a + bit ALLOW_SKIPPING_CREDITS_F, a ret z ld hl, wCreditsPos ld a, [hli] diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index b069a7dd0b5..619338a8b73 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -32,67 +32,67 @@ EnableEvents:: CheckEnabledMapEventsBit5: ld hl, wEnabledPlayerEvents - bit 5, [hl] + bit PLAYEREVENTS_UNUSED, [hl] ret DisableWarpsConnections: ; unreferenced ld hl, wEnabledPlayerEvents - res 2, [hl] + res PLAYEREVENTS_WARPS_AND_CONNECTIONS, [hl] ret DisableCoordEvents: ; unreferenced ld hl, wEnabledPlayerEvents - res 1, [hl] + res PLAYEREVENTS_COORD_EVENTS, [hl] ret DisableStepCount: ; unreferenced ld hl, wEnabledPlayerEvents - res 0, [hl] + res PLAYEREVENTS_COUNT_STEPS, [hl] ret DisableWildEncounters: ; unreferenced ld hl, wEnabledPlayerEvents - res 4, [hl] + res PLAYEREVENTS_WILD_ENCOUNTERS, [hl] ret EnableWarpsConnections: ; unreferenced ld hl, wEnabledPlayerEvents - set 2, [hl] + set PLAYEREVENTS_WARPS_AND_CONNECTIONS, [hl] ret EnableCoordEvents: ; unreferenced ld hl, wEnabledPlayerEvents - set 1, [hl] + set PLAYEREVENTS_COORD_EVENTS, [hl] ret EnableStepCount: ; unreferenced ld hl, wEnabledPlayerEvents - set 0, [hl] + set PLAYEREVENTS_COUNT_STEPS, [hl] ret EnableWildEncounters: ld hl, wEnabledPlayerEvents - set 4, [hl] + set PLAYEREVENTS_WILD_ENCOUNTERS, [hl] ret CheckWarpConnectionsEnabled: ld hl, wEnabledPlayerEvents - bit 2, [hl] + bit PLAYEREVENTS_WARPS_AND_CONNECTIONS, [hl] ret CheckCoordEventsEnabled: ld hl, wEnabledPlayerEvents - bit 1, [hl] + bit PLAYEREVENTS_COORD_EVENTS, [hl] ret CheckStepCountEnabled: ld hl, wEnabledPlayerEvents - bit 0, [hl] + bit PLAYEREVENTS_COUNT_STEPS, [hl] ret CheckWildEncountersEnabled: ld hl, wEnabledPlayerEvents - bit 4, [hl] + bit PLAYEREVENTS_WILD_ENCOUNTERS, [hl] ret StartMap: @@ -424,13 +424,13 @@ endr call CallScript ld hl, wScriptFlags - res 3, [hl] + res RUN_DEFERRED_SCRIPT, [hl] farcall EnableScriptMode farcall ScriptEvents ld hl, wScriptFlags - bit 3, [hl] + bit RUN_DEFERRED_SCRIPT, [hl] jr z, .nope ld hl, wDeferredScriptAddr diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index 9d0cdbf524e..4049cdd9f8f 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -36,7 +36,7 @@ HandleObjectStep: CheckObjectStillVisible: ld hl, OBJECT_FLAGS2 add hl, bc - res OBJ_FLAGS2_6, [hl] + res OFF_SCREEN_F, [hl] ld a, [wXCoord] ld e, a ld hl, OBJECT_MAP_X @@ -62,7 +62,7 @@ CheckObjectStillVisible: .ok ld hl, OBJECT_FLAGS2 add hl, bc - set OBJ_FLAGS2_6, [hl] + set OFF_SCREEN_F, [hl] ld a, [wXCoord] ld e, a ld hl, OBJECT_INIT_X @@ -99,7 +99,7 @@ CheckObjectStillVisible: .yes2 ld hl, OBJECT_FLAGS2 add hl, bc - set OBJ_FLAGS2_6, [hl] + set OFF_SCREEN_F, [hl] and a ret @@ -147,7 +147,7 @@ HandleObjectAction: jr nz, SetFacingStanding ld hl, OBJECT_FLAGS2 add hl, bc - bit OBJ_FLAGS2_6, [hl] + bit OFF_SCREEN_F, [hl] jr nz, SetFacingStanding bit FROZEN_F, [hl] jr nz, _CallFrozenObjectAction @@ -663,8 +663,8 @@ MovementFunction_Strength: jr z, .on_pit ld hl, OBJECT_FLAGS2 add hl, bc - bit OBJ_FLAGS2_2, [hl] - res OBJ_FLAGS2_2, [hl] + bit BOULDER_MOVING_F, [hl] + res BOULDER_MOVING_F, [hl] jr z, .ok ld hl, OBJECT_RANGE add hl, bc @@ -1667,7 +1667,7 @@ StepFunction_StrengthBoulder: pop bc ld hl, OBJECT_FLAGS2 add hl, bc - res OBJ_FLAGS2_2, [hl] + res BOULDER_MOVING_F, [hl] call CopyCoordsTileToLastCoordsTile ld hl, OBJECT_WALKING add hl, bc @@ -2194,7 +2194,7 @@ RespawnPlayerAndOpponent: ld a, PLAYER call RespawnObject ld a, [wBattleScriptFlags] - bit 7, a + bit BATTLESCRIPT_SCRIPTED_F, a jr z, .skip_opponent ldh a, [hLastTalked] and a @@ -2905,7 +2905,7 @@ InitSprites: ld hl, OBJECT_FLAGS2 add hl, bc ld e, [hl] - bit OBJ_FLAGS2_7, e + bit OBJ_FLAGS2_7_F, e jr z, .not_priority or PRIORITY .not_priority diff --git a/engine/overworld/map_setup.asm b/engine/overworld/map_setup.asm index b9e908286c0..bf2046a094a 100644 --- a/engine/overworld/map_setup.asm +++ b/engine/overworld/map_setup.asm @@ -41,7 +41,7 @@ ReadMapSetupScript: ; Bit 7 of the bank indicates a parameter. ; This is left unused. - bit 7, b + bit MAPSETUPSCRIPT_HAS_PARAM_F, b jr z, .go pop de diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index 1b1f9e173e4..bf5a88ddf73 100644 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -321,7 +321,7 @@ IsNPCAtCoord: ld hl, OBJECT_FLAGS1 add hl, bc - bit 7, [hl] + bit EMOTE_OBJECT_F, [hl] jr nz, .next ld hl, OBJECT_PALETTE diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm index d8b9f7d4cc1..a0a61350d82 100644 --- a/engine/overworld/overworld.asm +++ b/engine/overworld/overworld.asm @@ -15,23 +15,23 @@ _UpdatePlayerSprite:: call GetUsedSprite ret -_RefreshSprites: ; mobile +LoadStandingSpritesGFX: ; mobile ld hl, wSpriteFlags ld a, [hl] push af - res 7, [hl] - set 6, [hl] + res SPRITES_SKIP_STANDING_GFX_F, [hl] + set SPRITES_SKIP_WALKING_GFX_F, [hl] call LoadUsedSpritesGFX pop af ld [wSpriteFlags], a ret -_ClearSprites: ; mobile +LoadWalkingSpritesGFX: ; mobile ld hl, wSpriteFlags ld a, [hl] push af - set 7, [hl] - res 6, [hl] + set SPRITES_SKIP_STANDING_GFX_F, [hl] + res SPRITES_SKIP_WALKING_GFX_F, [hl] call LoadUsedSpritesGFX pop af ld [wSpriteFlags], a @@ -147,7 +147,7 @@ LoadUsedSpritesGFX: LoadMiscTiles: ld a, [wSpriteFlags] - bit 6, a + bit SPRITES_SKIP_WALKING_GFX_F, a ret nz ld c, EMOTE_SHADOW @@ -524,7 +524,7 @@ GetUsedSprites: .loop ld a, [wSpriteFlags] - res 5, a + res SPRITES_VRAM_BANK_0_F, a ld [wSpriteFlags], a ld a, [hli] @@ -535,11 +535,11 @@ GetUsedSprites: ld a, [hli] ldh [hUsedSpriteTile], a - bit 7, a + bit 7, a ; tiles $80+ are in VRAM bank 0 jr z, .dont_set ld a, [wSpriteFlags] - set 5, a ; load VBank0 + set SPRITES_VRAM_BANK_0_F, a ld [wSpriteFlags], a .dont_set @@ -563,7 +563,7 @@ GetUsedSprite: push de push bc ld a, [wSpriteFlags] - bit 7, a + bit SPRITES_SKIP_STANDING_GFX_F, a jr nz, .skip call .CopyToVram @@ -581,9 +581,9 @@ endr pop hl ld a, [wSpriteFlags] - bit 5, a + bit SPRITES_VRAM_BANK_0_F, a jr nz, .done - bit 6, a + bit SPRITES_SKIP_WALKING_GFX_F, a jr nz, .done ldh a, [hUsedSpriteIndex] @@ -618,7 +618,7 @@ endr ldh a, [rVBK] push af ld a, [wSpriteFlags] - bit 5, a + bit SPRITES_VRAM_BANK_0_F, a ld a, $1 jr z, .bankswitch ld a, $0 diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm index 50d7f84a553..145787c1689 100644 --- a/engine/overworld/player_movement.asm +++ b/engine/overworld/player_movement.asm @@ -665,7 +665,7 @@ ENDM ld hl, OBJECT_FLAGS2 add hl, bc - set 2, [hl] + set BOULDER_MOVING_F, [hl] ld a, [wWalkingDirection] ld d, a diff --git a/engine/overworld/player_object.asm b/engine/overworld/player_object.asm index c3b376f39a0..e76c0e38789 100644 --- a/engine/overworld/player_object.asm +++ b/engine/overworld/player_object.asm @@ -159,7 +159,7 @@ CopyObjectStruct:: ld hl, OBJECT_FLAGS2 add hl, de - set 5, [hl] + set FROZEN_F, [hl] ret CopyMapObjectToObjectStruct: diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm index 787490e7d86..7c7d2ffe884 100644 --- a/engine/overworld/scripting.asm +++ b/engine/overworld/scripting.asm @@ -1184,7 +1184,7 @@ Script_reloadmapafterbattle: jp ScriptJump .notblackedout - bit 0, d + bit BATTLESCRIPT_WILD_F, d jr z, .was_wild farcall MomTriesToBuySomething jr .done @@ -1393,7 +1393,7 @@ Script_sdefer: call GetScriptByte ld [wDeferredScriptAddr + 1], a ld hl, wScriptFlags - set 3, [hl] + set RUN_DEFERRED_SCRIPT, [hl] ret Script_checkscene: @@ -2260,7 +2260,7 @@ Script_end: ld a, SCRIPT_OFF ld [wScriptMode], a ld hl, wScriptFlags - res 0, [hl] + res UNUSED_SCRIPT_FLAG_0, [hl] call StopScript ret @@ -2269,7 +2269,7 @@ Script_endcallback: jr c, .dummy .dummy ld hl, wScriptFlags - res 0, [hl] + res UNUSED_SCRIPT_FLAG_0, [hl] call StopScript ret @@ -2310,7 +2310,7 @@ Script_endall: ld a, SCRIPT_OFF ld [wScriptMode], a ld hl, wScriptFlags - res 0, [hl] + res UNUSED_SCRIPT_FLAG_0, [hl] call StopScript ret diff --git a/engine/overworld/warp_connection.asm b/engine/overworld/warp_connection.asm index 501f1088229..02a84c460a8 100644 --- a/engine/overworld/warp_connection.asm +++ b/engine/overworld/warp_connection.asm @@ -390,7 +390,7 @@ CheckMovingOffEdgeOfMap:: GetMapScreenCoords:: ld hl, wOverworldMapBlocks ld a, [wXCoord] - bit 0, a + bit 0, a ; even or odd? jr nz, .odd_x ; even x srl a @@ -408,7 +408,7 @@ GetMapScreenCoords:: ld c, a ld b, 0 ld a, [wYCoord] - bit 0, a + bit 0, a ; even or odd? jr nz, .odd_y ; even y srl a diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm index 64bfb4ad133..c9d12432701 100644 --- a/engine/pokemon/bills_pc.asm +++ b/engine/pokemon/bills_pc.asm @@ -1918,6 +1918,10 @@ ReleasePKMN_ByePKMN: call DelayFrames ret +; move pkmn w/o mail jumptable bits +DEF MOVE_MON_FROM_PARTY_F EQU 0 +DEF MOVE_MON_TO_PARTY_F EQU 1 + MovePKMNWithoutMail_InsertMon: push hl push de @@ -1941,13 +1945,13 @@ MovePKMNWithoutMail_InsertMon: ld a, [wBillsPC_BackupLoadedBox] and a jr nz, .moving_from_box - set 0, c + set MOVE_MON_FROM_PARTY_F, c .moving_from_box ld a, [wBillsPC_LoadedBox] and a jr nz, .moving_to_box - set 1, c + set MOVE_MON_TO_PARTY_F, c .moving_to_box ld hl, .Jumptable diff --git a/engine/pokemon/learn.asm b/engine/pokemon/learn.asm index c7728249ee5..573f070ad3e 100644 --- a/engine/pokemon/learn.asm +++ b/engine/pokemon/learn.asm @@ -169,7 +169,7 @@ ForgetMove: call SafeLoadTempTilemapToTilemap pop af pop hl - bit 1, a + bit B_BUTTON_F, a jr nz, .cancel push hl ld a, [wMenuCursorY] diff --git a/engine/pokemon/mon_menu.asm b/engine/pokemon/mon_menu.asm index 2d13bd1ba5a..4a5960a9266 100644 --- a/engine/pokemon/mon_menu.asm +++ b/engine/pokemon/mon_menu.asm @@ -177,7 +177,7 @@ SwitchPartyMons: call DelayFrame farcall PartyMenuSelect - bit 1, b + bit B_BUTTON_F, b jr c, .DontSwitch farcall _SwitchPartyMons @@ -815,7 +815,7 @@ ChooseMoveToDelete: call Load2DMenuData call SetUpMoveList ld hl, w2DMenuFlags1 - set 6, [hl] + set _2DMENU_ENABLE_SPRITE_ANIMS_F, [hl] jr .enter_loop .loop @@ -842,7 +842,7 @@ ChooseMoveToDelete: xor a ld [wSwitchMon], a ld hl, w2DMenuFlags1 - res 6, [hl] + res _2DMENU_ENABLE_SPRITE_ANIMS_F, [hl] call ClearSprites call ClearTilemap pop af @@ -851,7 +851,8 @@ ChooseMoveToDelete: DeleteMoveScreen2DMenuData: db 3, 1 ; cursor start y, x db 3, 1 ; rows, columns - db $40, $00 ; flags + db _2DMENU_ENABLE_SPRITE_ANIMS ; flags 1 + db 0 ; flags 2 dn 2, 0 ; cursor offset db D_UP | D_DOWN | A_BUTTON | B_BUTTON ; accepted buttons @@ -883,18 +884,18 @@ MoveScreenLoop: .loop call SetUpMoveList ld hl, w2DMenuFlags1 - set 6, [hl] + set _2DMENU_ENABLE_SPRITE_ANIMS_F, [hl] jr .skip_joy .joy_loop call ScrollingMenuJoypad - bit 1, a + bit B_BUTTON_F, a jp nz, .b_button - bit 0, a + bit A_BUTTON_F, a jp nz, .a_button - bit 4, a + bit D_RIGHT_F, a jp nz, .d_right - bit 5, a + bit D_LEFT_F, a jp nz, .d_left .skip_joy @@ -1073,14 +1074,15 @@ MoveScreenLoop: xor a ld [wSwappingMove], a ld hl, w2DMenuFlags1 - res 6, [hl] + res _2DMENU_ENABLE_SPRITE_ANIMS_F, [hl] call ClearSprites jp ClearTilemap MoveScreen2DMenuData: db 3, 1 ; cursor start y, x db 3, 1 ; rows, columns - db $40, $00 ; flags + db _2DMENU_ENABLE_SPRITE_ANIMS ; flags 1 + db 0 ; flags 2 dn 2, 0 ; cursor offsets db D_UP | D_DOWN | D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON ; accepted buttons diff --git a/engine/pokemon/mon_submenu.asm b/engine/pokemon/mon_submenu.asm index 8d7da929781..ed4a2c008a5 100644 --- a/engine/pokemon/mon_submenu.asm +++ b/engine/pokemon/mon_submenu.asm @@ -39,13 +39,13 @@ MonSubmenu: MonMenuLoop: .loop - ld a, MENU_UNUSED_3 | MENU_BACKUP_TILES_2 ; flags + ld a, MENU_UNUSED | MENU_BACKUP_TILES_2 ; flags ld [wMenuDataFlags], a ld a, [wMonSubmenuCount] ld [wMenuDataItems], a call InitVerticalMenuCursor ld hl, w2DMenuFlags1 - set 6, [hl] + set _2DMENU_ENABLE_SPRITE_ANIMS_F, [hl] call StaticMenuJoypad ld de, SFX_READ_TEXT_2 call PlaySFX @@ -255,11 +255,11 @@ BattleMonMenu: call WaitBGMap call CopyMenuData ld a, [wMenuDataFlags] - bit 7, a + bit STATICMENU_CURSOR_F, a jr z, .set_carry call InitVerticalMenuCursor ld hl, w2DMenuFlags1 - set 6, [hl] + set _2DMENU_ENABLE_SPRITE_ANIMS_F, [hl] call StaticMenuJoypad ld de, SFX_READ_TEXT_2 call PlaySFX diff --git a/engine/pokemon/party_menu.asm b/engine/pokemon/party_menu.asm index d022f0f6551..f1b00b50c05 100644 --- a/engine/pokemon/party_menu.asm +++ b/engine/pokemon/party_menu.asm @@ -661,7 +661,8 @@ InitPartyMenuNoCancel: PartyMenu2DMenuData: db 1, 0 ; cursor start y, x db 0, 1 ; rows, columns - db $60, $00 ; flags + db _2DMENU_WRAP_UP_DOWN | _2DMENU_ENABLE_SPRITE_ANIMS ; flags 1 + db 0 ; flags 2 dn 2, 0 ; cursor offset db 0 ; accepted buttons diff --git a/engine/pokemon/stats_screen.asm b/engine/pokemon/stats_screen.asm index adfe6c63f29..53027d6b88c 100644 --- a/engine/pokemon/stats_screen.asm +++ b/engine/pokemon/stats_screen.asm @@ -5,6 +5,10 @@ DEF NUM_STAT_PAGES EQU const_value - 1 DEF STAT_PAGE_MASK EQU %00000011 + const_def 4 + const STATS_SCREEN_PLACE_FRONTPIC ; 4 + const STATS_SCREEN_ANIMATE_MON ; 5 + const STATS_SCREEN_ANIMATE_EGG ; 6 BattleStatsScreenInit: ld a, [wLinkMode] @@ -118,9 +122,9 @@ StatsScreenPointerTable: StatsScreen_WaitAnim: ld hl, wStatsScreenFlags - bit 6, [hl] + bit STATS_SCREEN_ANIMATE_EGG, [hl] jr nz, .try_anim - bit 5, [hl] + bit STATS_SCREEN_ANIMATE_MON, [hl] jr nz, .finish call DelayFrame ret @@ -129,10 +133,10 @@ StatsScreen_WaitAnim: farcall SetUpPokeAnim jr nc, .finish ld hl, wStatsScreenFlags - res 6, [hl] + res STATS_SCREEN_ANIMATE_EGG, [hl] .finish ld hl, wStatsScreenFlags - res 5, [hl] + res STATS_SCREEN_ANIMATE_MON, [hl] farcall HDMATransferTilemapToWRAMBank3 ret @@ -150,7 +154,7 @@ StatsScreen_Exit: MonStatsInit: ld hl, wStatsScreenFlags - res 6, [hl] + res STATS_SCREEN_ANIMATE_EGG, [hl] call ClearBGPalettes call ClearTilemap farcall HDMATransferTilemapToWRAMBank3 @@ -160,7 +164,7 @@ MonStatsInit: jr z, .egg call StatsScreen_InitUpperHalf ld hl, wStatsScreenFlags - set 4, [hl] + set STATS_SCREEN_PLACE_FRONTPIC, [hl] ld h, 4 call StatsScreen_SetJumptableIndex ret @@ -220,7 +224,7 @@ if DEF(_DEBUG) hlcoord 8, 17 call PlaceString ld hl, wStatsScreenFlags - set 5, [hl] + set STATS_SCREEN_ANIMATE_MON, [hl] pop hl pop de pop bc @@ -235,7 +239,7 @@ endc StatsScreen_LoadPage: call StatsScreen_LoadGFX ld hl, wStatsScreenFlags - res 4, [hl] + res STATS_SCREEN_PLACE_FRONTPIC, [hl] ld a, [wJumptableIndex] inc a ld [wJumptableIndex], a @@ -533,7 +537,7 @@ StatsScreen_LoadGFX: call .PageTilemap call .LoadPals ld hl, wStatsScreenFlags - bit 4, [hl] + bit STATS_SCREEN_PLACE_FRONTPIC, [hl] jr nz, .place_frontpic call SetDefaultBGPAndOBP ret @@ -559,7 +563,7 @@ StatsScreen_LoadGFX: farcall LoadStatsScreenPals call DelayFrame ld hl, wStatsScreenFlags - set 5, [hl] + set STATS_SCREEN_ANIMATE_MON, [hl] ret .PageTilemap: @@ -853,7 +857,7 @@ StatsScreen_PlaceFrontpic: .AnimateMon: ld hl, wStatsScreenFlags - set 5, [hl] + set STATS_SCREEN_ANIMATE_MON, [hl] ld a, [wCurPartySpecies] cp UNOWN jr z, .unown @@ -895,7 +899,7 @@ StatsScreen_PlaceFrontpic: ld e, ANIM_MON_MENU predef LoadMonAnimation ld hl, wStatsScreenFlags - set 6, [hl] + set STATS_SCREEN_ANIMATE_EGG, [hl] ret StatsScreen_GetAnimationParam: @@ -1038,7 +1042,7 @@ endc hlcoord 1, 9 call PlaceString ld hl, wStatsScreenFlags - set 5, [hl] + set STATS_SCREEN_ANIMATE_MON, [hl] call SetDefaultBGPAndOBP call DelayFrame hlcoord 0, 0 @@ -1104,7 +1108,7 @@ StatsScreen_AnimateEgg: ld d, $0 predef LoadMonAnimation ld hl, wStatsScreenFlags - set 6, [hl] + set STATS_SCREEN_ANIMATE_EGG, [hl] ret StatsScreen_LoadPageIndicators: diff --git a/engine/printer/printer.asm b/engine/printer/printer.asm index 0f0ba4278b9..e4cd871ed30 100644 --- a/engine/printer/printer.asm +++ b/engine/printer/printer.asm @@ -524,12 +524,12 @@ CheckPrinterStatus: jr z, .error_2 .printer_connected ld a, [wPrinterStatusFlags] - and %11100000 + and PRINTER_STATUS_ERROR_3 | PRINTER_STATUS_ERROR_4 | PRINTER_STATUS_ERROR_1 ret z ; no error - bit 7, a + bit PRINTER_STATUS_ERROR_1_F, a jr nz, .error_1 - bit 6, a + bit PRINTER_STATUS_ERROR_4_F, a jr nz, .error_4 ; paper error ld a, PRINTER_ERROR_3 diff --git a/engine/printer/printer_serial.asm b/engine/printer/printer_serial.asm index f3c0709b935..a0c8d1e465f 100644 --- a/engine/printer/printer_serial.asm +++ b/engine/printer/printer_serial.asm @@ -8,7 +8,7 @@ Printer_StartTransmission: ldh [rSC], a ld [wPrinterOpcode], a ld hl, wPrinterConnectionOpen - set 0, [hl] + set PRINTER_CONNECTION_OPEN, [hl] ld a, [wGBPrinterBrightness] ld [wPrinterExposureTime], a xor a @@ -199,7 +199,7 @@ Printer_CheckConnectionStatus: cp $0 jr nz, .printer_error ld hl, wPrinterConnectionOpen - set 1, [hl] + set PRINTER_CONNECTION_SUCCESS, [hl] ld a, $5 ld [wHandshakeFrameDelay], a call _Printer_NextSection diff --git a/engine/rtc/reset_password.asm b/engine/rtc/reset_password.asm index 58577840319..cc8fcd7eb0a 100644 --- a/engine/rtc/reset_password.asm +++ b/engine/rtc/reset_password.asm @@ -19,7 +19,7 @@ _ResetClock: jr c, .wrongpassword ld a, BANK(sRTCStatusFlags) call OpenSRAM - ld a, $80 + ld a, RTC_RESET ld [sRTCStatusFlags], a call CloseSRAM ld hl, .PasswordAskResetText diff --git a/engine/rtc/restart_clock.asm b/engine/rtc/restart_clock.asm index 450d89a8175..263c1b44f56 100644 --- a/engine/rtc/restart_clock.asm +++ b/engine/rtc/restart_clock.asm @@ -121,17 +121,17 @@ RestartClock: push af call .PrintTime pop af - bit 0, a + bit A_BUTTON_F, a jr nz, .press_A - bit 1, a + bit B_BUTTON_F, a jr nz, .press_B - bit 6, a + bit D_UP_F, a jr nz, .pressed_up - bit 7, a + bit D_DOWN_F, a jr nz, .pressed_down - bit 5, a + bit D_LEFT_F, a jr nz, .pressed_left - bit 4, a + bit D_RIGHT_F, a jr nz, .pressed_right jr .joy_loop diff --git a/engine/rtc/rtc.asm b/engine/rtc/rtc.asm index d4d7a1ef34f..f46f26344c4 100644 --- a/engine/rtc/rtc.asm +++ b/engine/rtc/rtc.asm @@ -5,7 +5,7 @@ StopRTC: ; unreferenced ld a, RTC_DH ld [MBC3SRamBank], a ld a, [MBC3RTC] - set 6, a ; halt + set RTC_DH_HALT, a ld [MBC3RTC], a call CloseSRAM ret @@ -17,7 +17,7 @@ StartRTC: ld a, RTC_DH ld [MBC3SRamBank], a ld a, [MBC3RTC] - res 6, a ; halt + res RTC_DH_HALT, a ld [MBC3RTC], a call CloseSRAM ret @@ -80,7 +80,7 @@ SaveRTC: ld hl, MBC3RTC ld a, RTC_DH ld [MBC3SRamBank], a - res 7, [hl] + res RTC_DH_OVERFLOW, [hl] ld a, BANK(sRTCStatusFlags) ld [MBC3SRamBank], a xor a @@ -93,9 +93,7 @@ StartClock:: call _FixDays call FixDays jr nc, .skip_set - ; bit 5: Day count exceeds 139 - ; bit 6: Day count exceeds 255 - call RecordRTCStatus ; set flag on sRTCStatusFlags + call RecordRTCStatus .skip_set call StartRTC @@ -103,27 +101,26 @@ StartClock:: _FixDays: ld hl, hRTCDayHi - bit 7, [hl] - jr nz, .set_bit_7 - bit 6, [hl] - jr nz, .set_bit_7 + bit RTC_DH_OVERFLOW, [hl] + jr nz, .reset_rtc + bit RTC_DH_HALT, [hl] + jr nz, .reset_rtc xor a ret -.set_bit_7 - ; Day count exceeds 16383 - ld a, %10000000 - call RecordRTCStatus ; set bit 7 on sRTCStatusFlags +.reset_rtc + ld a, RTC_RESET + call RecordRTCStatus ret ClockContinue: call CheckRTCStatus ld c, a - and %11000000 ; Day count exceeded 255 or 16383 + and RTC_RESET | RTC_DAYS_EXCEED_255 jr nz, .time_overflow ld a, c - and %00100000 ; Day count exceeded 139 + and RTC_DAYS_EXCEED_139 jr z, .dont_update call UpdateTime diff --git a/engine/rtc/timeset.asm b/engine/rtc/timeset.asm index 725706011d8..f97dcfaf65c 100644 --- a/engine/rtc/timeset.asm +++ b/engine/rtc/timeset.asm @@ -541,7 +541,7 @@ SetDayOfWeek: InitialSetDSTFlag: ld a, [wDST] - set 7, a + set DST_F, a ld [wDST], a hlcoord 1, 14 lb bc, 3, 18 @@ -568,7 +568,7 @@ InitialSetDSTFlag: InitialClearDSTFlag: ld a, [wDST] - res 7, a + res DST_F, a ld [wDST], a hlcoord 1, 14 lb bc, 3, 18 @@ -631,7 +631,7 @@ MrChrono: ; unreferenced inc hl ld a, [wDST] - bit 7, a + bit DST_F, a jr z, .off ld [hl], "O" diff --git a/engine/tilesets/map_palettes.asm b/engine/tilesets/map_palettes.asm index de6bf1d374e..2be20780a23 100644 --- a/engine/tilesets/map_palettes.asm +++ b/engine/tilesets/map_palettes.asm @@ -37,7 +37,7 @@ _LoadOverworldAttrmapPals:: .next pop hl ld [de], a - res 7, [hl] + res OAM_TILE_BANK + 4, [hl] inc hl inc de dec c @@ -81,7 +81,7 @@ _ScrollBGMapPalettes:: .next pop hl ld [de], a - res 7, [hl] + res OAM_TILE_BANK + 4, [hl] inc hl inc de dec c diff --git a/engine/tilesets/timeofday_pals.asm b/engine/tilesets/timeofday_pals.asm index 053a9769a12..1f5adaf683e 100644 --- a/engine/tilesets/timeofday_pals.asm +++ b/engine/tilesets/timeofday_pals.asm @@ -15,7 +15,7 @@ _TimeOfDayPals:: ; forced pals? ld hl, wTimeOfDayPalFlags - bit 7, [hl] + bit FORCED_PALSET_F, [hl] jr nz, .dontchange ; do we need to bother updating? diff --git a/home/audio.asm b/home/audio.asm index 6f7be3ebd84..fd47f1e623f 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -229,16 +229,16 @@ WaitSFX:: .wait ld hl, wChannel5Flags1 - bit 0, [hl] + bit SOUND_CHANNEL_ON, [hl] jr nz, .wait ld hl, wChannel6Flags1 - bit 0, [hl] + bit SOUND_CHANNEL_ON, [hl] jr nz, .wait ld hl, wChannel7Flags1 - bit 0, [hl] + bit SOUND_CHANNEL_ON, [hl] jr nz, .wait ld hl, wChannel8Flags1 - bit 0, [hl] + bit SOUND_CHANNEL_ON, [hl] jr nz, .wait pop hl @@ -250,16 +250,16 @@ IsSFXPlaying:: push hl ld hl, wChannel5Flags1 - bit 0, [hl] + bit SOUND_CHANNEL_ON, [hl] jr nz, .playing ld hl, wChannel6Flags1 - bit 0, [hl] + bit SOUND_CHANNEL_ON, [hl] jr nz, .playing ld hl, wChannel7Flags1 - bit 0, [hl] + bit SOUND_CHANNEL_ON, [hl] jr nz, .playing ld hl, wChannel8Flags1 - bit 0, [hl] + bit SOUND_CHANNEL_ON, [hl] jr nz, .playing pop hl @@ -504,16 +504,16 @@ PlaceBCDNumberSprite:: ; unreferenced CheckSFX:: ; Return carry if any SFX channels are active. ld a, [wChannel5Flags1] - bit 0, a + bit SOUND_CHANNEL_ON, a jr nz, .playing ld a, [wChannel6Flags1] - bit 0, a + bit SOUND_CHANNEL_ON, a jr nz, .playing ld a, [wChannel7Flags1] - bit 0, a + bit SOUND_CHANNEL_ON, a jr nz, .playing ld a, [wChannel8Flags1] - bit 0, a + bit SOUND_CHANNEL_ON, a jr nz, .playing and a ret diff --git a/home/double_speed.asm b/home/double_speed.asm index b3839e320b6..37fc2293b0e 100644 --- a/home/double_speed.asm +++ b/home/double_speed.asm @@ -7,21 +7,21 @@ DoubleSpeed:: ld hl, rKEY1 - bit 7, [hl] + bit KEY1_DBLSPEED, [hl] jr z, SwitchSpeed ret NormalSpeed:: ld hl, rKEY1 - bit 7, [hl] + bit KEY1_DBLSPEED, [hl] ret z SwitchSpeed:: - set 0, [hl] + set KEY1_PREPARE, [hl] xor a ldh [rIF], a ldh [rIE], a - ld a, $30 + ld a, (1 << rJOYP_BUTTONS) | (1 << rJOYP_DPAD) ldh [rJOYP], a stop ; rgbasm adds a nop after this instruction by default ret diff --git a/home/game_time.asm b/home/game_time.asm index 749c0c6a527..70c06a63f28 100644 --- a/home/game_time.asm +++ b/home/game_time.asm @@ -38,7 +38,7 @@ GameTimer:: ; Is the timer already capped? ld hl, wGameTimeCap - bit 0, [hl] + bit GAME_TIME_CAPPED, [hl] ret nz ; +1 frame @@ -103,7 +103,7 @@ GameTimer:: jr c, .ok ld hl, wGameTimeCap - set 0, [hl] + set GAME_TIME_CAPPED, [hl] ld a, 59 ; 999:59:59.00 ld [wGameTimeMinutes], a diff --git a/home/joypad.asm b/home/joypad.asm index 9612427ebd5..52cccf41183 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -38,7 +38,7 @@ UpdateJoypad:: ; We can only get four inputs at a time. ; We take d-pad first for no particular reason. - ld a, R_DPAD + ld a, 1 << rJOYP_DPAD ldh [rJOYP], a ; Read twice to give the request time to take. ldh a, [rJOYP] @@ -55,7 +55,7 @@ UpdateJoypad:: ; Buttons make 8 total inputs (A, B, Select, Start). ; We can fit this into one byte. - ld a, R_BUTTONS + ld a, 1 << rJOYP_BUTTONS ldh [rJOYP], a ; Wait for input to stabilize. rept 6 @@ -68,7 +68,7 @@ endr ld b, a ; Reset the joypad register since we're done with it. - ld a, $30 + ld a, (1 << rJOYP_BUTTONS) | (1 << rJOYP_DPAD) ldh [rJOYP], a ; To get the delta we xor the last frame's input with the new one. @@ -427,7 +427,7 @@ PromptButton:: .blink_cursor ldh a, [hVBlankCounter] - and %00010000 ; bit 4, a + and 1 << 4 ; blink every 2**4 = 16 frames jr z, .cursor_off ld a, "▼" jr .load_cursor_state diff --git a/home/map.asm b/home/map.asm index 91213c91da2..3fda77af6f5 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1003,7 +1003,7 @@ ExecuteCallbackScript:: ld hl, wScriptFlags ld a, [hl] push af - set 1, [hl] + set UNUSED_SCRIPT_FLAG_1, [hl] farcall EnableScriptMode farcall ScriptEvents pop af diff --git a/home/menu.asm b/home/menu.asm index 126198809d0..4af41be7d92 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -193,7 +193,7 @@ PlaceVerticalMenuItems:: jr nz, .loop ld a, [wMenuDataFlags] - bit 4, a + bit STATICMENU_PLACE_TITLE_F, a ret z call MenuBoxCoord2Tile @@ -218,20 +218,20 @@ GetMenuTextStartCoord:: ld a, [wMenuBorderLeftCoord] ld c, a inc c -; bit 6: if not set, leave extra room on top +; if not set, leave extra room on top ld a, [wMenuDataFlags] - bit 6, a - jr nz, .bit_6_set + bit STATICMENU_NO_TOP_SPACING_F, a + jr nz, .no_top_spacing inc b -.bit_6_set -; bit 7: if set, leave extra room on the left +.no_top_spacing +; if set, leave extra room on the left ld a, [wMenuDataFlags] - bit 7, a - jr z, .bit_7_clear + bit STATICMENU_CURSOR_F, a + jr z, .no_cursor inc c -.bit_7_clear +.no_cursor ret ClearMenuBoxInterior:: @@ -374,12 +374,12 @@ VerticalMenu:: call ApplyTilemap call CopyMenuData ld a, [wMenuDataFlags] - bit 7, a + bit STATICMENU_CURSOR_F, a jr z, .cancel call InitVerticalMenuCursor call StaticMenuJoypad call MenuClickSound - bit 1, a + bit B_BUTTON_F, a jr z, .okay .cancel scf @@ -525,7 +525,7 @@ SetUpMenu:: call MenuWriteText call InitMenuCursorAndButtonPermissions ld hl, w2DMenuFlags1 - set 7, [hl] + set _2DMENU_DISABLE_JOYPAD_FILTER_F, [hl] ret DrawVariableLengthMenuBox:: @@ -621,13 +621,13 @@ InitMenuCursorAndButtonPermissions:: call InitVerticalMenuCursor ld hl, wMenuJoypadFilter ld a, [wMenuDataFlags] - bit 3, a - jr z, .disallow_select + bit STATICMENU_ENABLE_START_F, a + jr z, .disallow_start set START_F, [hl] -.disallow_select +.disallow_start ld a, [wMenuDataFlags] - bit 2, a + bit STATICMENU_ENABLE_LEFT_RIGHT_F, a jr z, .disallow_left_right set D_LEFT_F, [hl] set D_RIGHT_F, [hl] @@ -795,7 +795,7 @@ MenuClickSound:: and A_BUTTON | B_BUTTON jr z, .nosound ld hl, wMenuFlags - bit 3, [hl] + bit MENU_NO_CLICK_SFX_F, [hl] jr nz, .nosound call PlayClickSFX .nosound diff --git a/home/printer.asm b/home/printer.asm index 745399a5d26..6fe1f4f9d8a 100644 --- a/home/printer.asm +++ b/home/printer.asm @@ -5,7 +5,7 @@ PrinterReceive:: AskSerial:: ; send out a handshake while serial int is off ld a, [wPrinterConnectionOpen] - bit 0, a + bit PRINTER_CONNECTION_OPEN, a ret z ; if we're still interpreting data, don't try to receive diff --git a/home/serial.asm b/home/serial.asm index 6ab98e888f0..fd2a2c137d8 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -11,7 +11,7 @@ Serial:: jr nz, .mobile ld a, [wPrinterConnectionOpen] - bit 0, a + bit PRINTER_CONNECTION_OPEN, a jr nz, .printer ldh a, [hSerialConnectionStatus] @@ -62,7 +62,7 @@ Serial:: ldh [rDIV], a .delay_loop ldh a, [rDIV] - bit 7, a + bit 7, a ; wait until rDIV has incremented from 3 to $80 or more jr nz, .delay_loop ld a, (0 << rSC_ON) | (0 << rSC_CLOCK) diff --git a/home/time.asm b/home/time.asm index 0b51dea79a9..4d79a4307bb 100644 --- a/home/time.asm +++ b/home/time.asm @@ -72,10 +72,10 @@ FixDays:: ; check if day count > 255 (bit 8 set) ldh a, [hRTCDayHi] ; DH - bit 0, a + bit RTC_DH_HI, a jr z, .daylo ; reset dh (bit 8) - res 0, a + res RTC_DH_HI, a ldh [hRTCDayHi], a ; mod 140 @@ -93,7 +93,7 @@ FixDays:: ldh [hRTCDayLo], a ; flag for sRTCStatusFlags - ld a, %01000000 + ld a, RTC_DAYS_EXCEED_255 jr .set .daylo @@ -112,7 +112,7 @@ FixDays:: ldh [hRTCDayLo], a ; flag for sRTCStatusFlags - ld a, %00100000 + ld a, RTC_DAYS_EXCEED_139 .set ; update clock with modded day value @@ -227,7 +227,7 @@ SetClock:: ; this block is totally pointless ld [hl], RTC_DH ld a, [de] - bit 6, a ; halt + bit RTC_DH_HALT, a ld [de], a ; seconds @@ -249,7 +249,7 @@ SetClock:: ; day hi ld [hl], RTC_DH ldh a, [hRTCDayHi] - res 6, a ; make sure timer is active + res RTC_DH_HALT, a ; make sure timer is active ld [de], a ; cleanup diff --git a/macros/const.asm b/macros/const.asm index 4b7acdda105..261fdef0556 100644 --- a/macros/const.asm +++ b/macros/const.asm @@ -20,7 +20,7 @@ ENDM MACRO shift_const DEF \1 EQU 1 << const_value - DEF const_value += const_inc + const \1_F ENDM MACRO const_skip diff --git a/mobile/mobile_45_sprite_engine.asm b/mobile/mobile_45_sprite_engine.asm index 3b313b3c581..9784835ce0f 100644 --- a/mobile/mobile_45_sprite_engine.asm +++ b/mobile/mobile_45_sprite_engine.asm @@ -659,7 +659,7 @@ Function1163c0: ld bc, 16 * SPRITEOAMSTRUCT_LENGTH call ByteFill call DelayFrame - farcall _RefreshSprites + farcall LoadStandingSpritesGFX ld b, SCGB_MAPPALS call GetSGBLayout ldh a, [rSVBK] @@ -677,7 +677,7 @@ Function1163c0: ld a, $90 ldh [hWY], a call UpdateSprites - farcall _ClearSprites + farcall LoadWalkingSpritesGFX pop af ldh [rSVBK], a farcall HDMATransferTilemapAndAttrmap_Overworld diff --git a/ram/wram.asm b/ram/wram.asm index 39257904d79..28fd8b4322e 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -516,6 +516,7 @@ wAlreadyFailed:: db wBattleParticipantsIncludingFainted:: db wBattleLowHealthAlarm:: db wPlayerMinimized:: db + wPlayerScreens:: ; bit ; 0 spikes @@ -1762,10 +1763,7 @@ wJoypadDisable:: ds 1 -wInBattleTowerBattle:: -; 0 not in BattleTower-Battle -; 1 BattleTower-Battle - db +wInBattleTowerBattle:: db ds 1 @@ -2803,6 +2801,7 @@ wMapStatus:: db wMapEventStatus:: db wScriptFlags:: +; bit 2: running script ; bit 3: run deferred script db ds 1 @@ -2951,7 +2950,7 @@ wObjectMasks:: ds NUM_OBJECTS wVariableSprites:: ds $100 - SPRITE_VARS -wEnteredMapFromContinue:: db +wMapNameSignFlags:: db ds 2 wTimeOfDayPal:: db ds 4