diff --git a/constants/map_data_constants.asm b/constants/map_data_constants.asm index 32a56518c..ac00e4260 100644 --- a/constants/map_data_constants.asm +++ b/constants/map_data_constants.asm @@ -2,19 +2,14 @@ ; height of north/south connections DEF MAP_BORDER EQU 3 -; connection directions - const_def - const EAST_F - const WEST_F - const SOUTH_F - const NORTH_F +; wCurMapConnections : \1 +; connection directions : BIT_\1 + bit_const_def + shift_const EAST ; $01 (BIT_EAST ; 0) + shift_const WEST ; $02 (BIT_WEST ; 1) + shift_const SOUTH ; $04 (BIT_SOUTH ; 2) + shift_const NORTH ; $08 (BIT_NORTH ; 4) -; wCurMapConnections - const_def - shift_const EAST ; 1 - shift_const WEST ; 2 - shift_const SOUTH ; 4 - shift_const NORTH ; 8 ; wWarpEntries DEF MAX_WARP_EVENTS EQU 32 diff --git a/constants/sprite_data_constants.asm b/constants/sprite_data_constants.asm index e8c028d22..95f97b771 100644 --- a/constants/sprite_data_constants.asm +++ b/constants/sprite_data_constants.asm @@ -14,12 +14,7 @@ DEF NPC_CHANGE_FACING EQU $E0 ; player direction constants bit_const_def - const PLAYER_DIR_BIT_RIGHT ; 0 - const PLAYER_DIR_BIT_LEFT ; 1 - const PLAYER_DIR_BIT_DOWN ; 2 - const PLAYER_DIR_BIT_UP ; 3 - -DEF PLAYER_DIR_RIGHT EQU 1 << PLAYER_DIR_BIT_RIGHT -DEF PLAYER_DIR_LEFT EQU 1 << PLAYER_DIR_BIT_LEFT -DEF PLAYER_DIR_DOWN EQU 1 << PLAYER_DIR_BIT_DOWN -DEF PLAYER_DIR_UP EQU 1 << PLAYER_DIR_BIT_UP + shift_const PLAYER_DIR_RIGHT ; $01 (BIT_PLAYER_DIR_RIGHT ; 0) + shift_const PLAYER_DIR_LEFT ; $02 (BIT_PLAYER_DIR_LEFT ; 1) + shift_const PLAYER_DIR_DOWN ; $04 (BIT_PLAYER_DIR_DOWN ; 2) + shift_const PLAYER_DIR_UP ; $08 (BIT_PLAYER_DIR_UP ; 3) diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index c4ce13de6..539f878ac 100644 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -726,13 +726,13 @@ ItemUseSurfboard: ; uses a simulated button press to make the player move forward .makePlayerMoveForward ld a, [wPlayerDirection] ; direction the player is going - bit PLAYER_DIR_BIT_UP, a + bit BIT_PLAYER_DIR_UP, a ld b, PAD_UP jr nz, .storeSimulatedButtonPress - bit PLAYER_DIR_BIT_DOWN, a + bit BIT_PLAYER_DIR_DOWN, a ld b, PAD_DOWN jr nz, .storeSimulatedButtonPress - bit PLAYER_DIR_BIT_LEFT, a + bit BIT_PLAYER_DIR_LEFT, a ld b, PAD_LEFT jr nz, .storeSimulatedButtonPress ld b, PAD_RIGHT diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index a353c4f1e..27fa1f69c 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -29,22 +29,22 @@ UpdatePlayerSprite: jr nz, .moving ld a, [wPlayerMovingDirection] ; check if down - bit PLAYER_DIR_BIT_DOWN, a + bit BIT_PLAYER_DIR_DOWN, a jr z, .checkIfUp xor a ; ld a, SPRITE_FACING_DOWN jr .next .checkIfUp - bit PLAYER_DIR_BIT_UP, a + bit BIT_PLAYER_DIR_UP, a jr z, .checkIfLeft ld a, SPRITE_FACING_UP jr .next .checkIfLeft - bit PLAYER_DIR_BIT_LEFT, a + bit BIT_PLAYER_DIR_LEFT, a jr z, .checkIfRight ld a, SPRITE_FACING_LEFT jr .next .checkIfRight - bit PLAYER_DIR_BIT_RIGHT, a + bit BIT_PLAYER_DIR_RIGHT, a jr z, .notMoving ld a, SPRITE_FACING_RIGHT jr .next @@ -415,17 +415,17 @@ MakeNPCFacePlayer: jr nz, NotYetMoving res BIT_FACE_PLAYER, [hl] ld a, [wPlayerDirection] - bit PLAYER_DIR_BIT_UP, a + bit BIT_PLAYER_DIR_UP, a jr z, .notFacingDown ld c, SPRITE_FACING_DOWN jr .facingDirectionDetermined .notFacingDown - bit PLAYER_DIR_BIT_DOWN, a + bit BIT_PLAYER_DIR_DOWN, a jr z, .notFacingUp ld c, SPRITE_FACING_UP jr .facingDirectionDetermined .notFacingUp - bit PLAYER_DIR_BIT_LEFT, a + bit BIT_PLAYER_DIR_LEFT, a jr z, .notFacingRight ld c, SPRITE_FACING_RIGHT jr .facingDirectionDetermined diff --git a/home/overworld.asm b/home/overworld.asm index e994f6942..b462f7500 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -2047,22 +2047,22 @@ LoadMapHeader:: ld a, [wCurMapConnections] ld b, a ; check north - bit NORTH_F, b + bit BIT_NORTH, b jr z, .checkSouth ld de, wNorthConnectionHeader call CopyMapConnectionHeader .checkSouth - bit SOUTH_F, b + bit BIT_SOUTH, b jr z, .checkWest ld de, wSouthConnectionHeader call CopyMapConnectionHeader .checkWest - bit WEST_F, b + bit BIT_WEST, b jr z, .checkEast ld de, wWestConnectionHeader call CopyMapConnectionHeader .checkEast - bit EAST_F, b + bit BIT_EAST, b jr z, .getObjectDataPointer ld de, wEastConnectionHeader call CopyMapConnectionHeader diff --git a/macros/const.asm b/macros/const.asm index fcec8b83d..0b4c1f124 100644 --- a/macros/const.asm +++ b/macros/const.asm @@ -77,8 +77,14 @@ MACRO? const_export ENDM MACRO? shift_const - DEF \1 EQU 1 << const_value - DEF const_value += const_inc + IF (const_format != $FFFFFFFF) && ((const_inc > 0 && const_value > const_limit) || (const_inc < 0 && const_value < const_limit)) + DEF failed_const_value = 1 << const_value + fail "Constant value cannot be {const_size_compare} than {const_limit}. Attempted to use constant value {const_value} to define constant \1 for shifted value {failed_const_value}." + ELSE + DEF BIT_\1 EQU const_value + DEF \1 EQU 1 << const_value + DEF const_value += const_inc + ENDC ENDM MACRO? const_skip