shithub: pokecrystal

Download patch

ref: c5d18de8ff9b587a7987cc2cde793386f1eaf217
parent: 32b92ca51c73f1ad9be169bef476b9c93687e2a4
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Wed May 23 09:15:07 EDT 2018

Use known sprite movement data flag constants

--- a/constants/map_object_constants.asm
+++ b/constants/map_object_constants.asm
@@ -44,16 +44,24 @@
 OW_RIGHT EQU RIGHT << 2
 
 ; object_struct OBJECT_FLAGS1 bit flags
-INVISIBLE    EQU 0
-FIXED_FACING EQU 2
-SLIDING      EQU 3
-EMOTE_OBJECT EQU 7
+INVISIBLE_F    EQU 0
+FIXED_FACING_F EQU 2
+SLIDING_F      EQU 3
+EMOTE_OBJECT_F EQU 7
 
+INVISIBLE    EQU 1 << INVISIBLE_F
+FIXED_FACING EQU 1 << FIXED_FACING_F
+SLIDING      EQU 1 << SLIDING_F
+EMOTE_OBJECT EQU 1 << EMOTE_OBJECT_F
+
 ; object_struct OBJECT_FLAGS2 bit flags
-LOW_PRIORITY  EQU 0
-HIGH_PRIORITY EQU 1
-OVERHEAD      EQU 3
+LOW_PRIORITY_F  EQU 0
+HIGH_PRIORITY_F EQU 1
+OVERHEAD_F      EQU 3
 
+LOW_PRIORITY  EQU 1 << LOW_PRIORITY_F
+HIGH_PRIORITY EQU 1 << HIGH_PRIORITY_F
+OVERHEAD      EQU 1 << OVERHEAD_F
 
 ; map_object struct members (see macros/wram.asm)
 	const_def
--- a/data/sprites/map_objects.asm
+++ b/data/sprites/map_objects.asm
@@ -13,7 +13,7 @@
 	db SPRITEMOVEFN_STANDING ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_STAND ; action
-	db 1 << 2 | 1 << 3 ; flags1
+	db FIXED_FACING | SLIDING ; flags1
 	db 0 ; flags2
 	db 0 ; palette flags
 
@@ -173,8 +173,8 @@
 	db SPRITEMOVEFN_BIG_SNORLAX ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_BIG_DOLL_SYM ; action
-	db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1
-	db 1 << 0 ; flags2
+	db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1
+	db LOW_PRIORITY ; flags2
 	db 1 << 6 | 1 << 7 ; palette flags
 
 ; SPRITEMOVEDATA_POKEMON
@@ -181,7 +181,7 @@
 	db SPRITEMOVEFN_BOUNCE ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_BOUNCE ; action
-	db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1
+	db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1
 	db 0 ; flags2
 	db 0 ; palette flags
 
@@ -189,7 +189,7 @@
 	db SPRITEMOVEFN_STANDING ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_STAND ; action
-	db 1 << 2 | 1 << 3 ; flags1
+	db FIXED_FACING | SLIDING ; flags1
 	db 0 ; flags2
 	db 0 ; palette flags
 
@@ -197,7 +197,7 @@
 	db SPRITEMOVEFN_STANDING ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_STAND ; action
-	db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1
+	db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1
 	db 1 << 4 ; flags2
 	db 0 ; palette flags
 
@@ -205,7 +205,7 @@
 	db SPRITEMOVEFN_STRENGTH ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_STAND ; action
-	db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1
+	db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1
 	db 0 ; flags2
 	db 1 << 6 ; palette flags
 
@@ -221,8 +221,8 @@
 	db SPRITEMOVEFN_SHADOW ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_00 ; action
-	db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1
-	db 1 << 0 ; flags2
+	db 1 << 1 | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1
+	db LOW_PRIORITY ; flags2
 	db 0 ; palette flags
 
 ; SPRITEMOVEDATA_EMOTE
@@ -229,8 +229,8 @@
 	db SPRITEMOVEFN_EMOTE ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_EMOTE ; action
-	db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1
-	db 1 << 1 ; flags2
+	db 1 << 1 | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1
+	db HIGH_PRIORITY ; flags2
 	db 0 ; palette flags
 
 ; SPRITEMOVEDATA_SCREENSHAKE
@@ -237,7 +237,7 @@
 	db SPRITEMOVEFN_SCREENSHAKE ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_00 ; action
-	db 1 << 1 | 1 << 7 ; flags1
+	db 1 << 1 | EMOTE_OBJECT ; flags1
 	db 0 ; flags2
 	db 0 ; palette flags
 
@@ -261,8 +261,8 @@
 	db SPRITEMOVEFN_STRENGTH ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_BIG_DOLL_ASYM ; action
-	db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1
-	db 1 << 0 ; flags2
+	db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1
+	db LOW_PRIORITY ; flags2
 	db 1 << 6 | 1 << 7 ; palette flags
 
 ; SPRITEMOVEDATA_BIGDOLL
@@ -269,8 +269,8 @@
 	db SPRITEMOVEFN_STRENGTH ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_BIG_DOLL ; action
-	db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1
-	db 1 << 0 ; flags2
+	db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1
+	db LOW_PRIORITY ; flags2
 	db 1 << 6 | 1 << 7 ; palette flags
 
 ; SPRITEMOVEDATA_BOULDERDUST
@@ -277,8 +277,8 @@
 	db SPRITEMOVEFN_BOULDERDUST ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_BOULDER_DUST ; action
-	db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1
-	db 1 << 0 ; flags2
+	db 1 << 1 | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1
+	db LOW_PRIORITY ; flags2
 	db 0 ; palette flags
 
 ; SPRITEMOVEDATA_GRASS
@@ -285,8 +285,8 @@
 	db SPRITEMOVEFN_GRASS ; movement function
 	db DOWN ; facing
 	db OBJECT_ACTION_GRASS_SHAKE ; action
-	db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1
-	db 1 << 1 ; flags2
+	db 1 << 1 | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1
+	db HIGH_PRIORITY ; flags2
 	db 0 ; palette flags
 
 ; SPRITEMOVEDATA_SWIM_WANDER
--- a/engine/overworld/map_object_action.asm
+++ b/engine/overworld/map_object_action.asm
@@ -47,7 +47,7 @@
 SetFacingStepAction: ; 44c1
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	bit SLIDING, [hl]
+	bit SLIDING_F, [hl]
 	jp nz, SetFacingCurrent
 
 	ld hl, OBJECT_STEP_FRAME
@@ -59,7 +59,7 @@
 
 	rrca
 	rrca
-	and %00000011
+	maskbits NUM_DIRECTIONS
 	ld d, a
 
 	call GetSpriteDirection
@@ -74,7 +74,7 @@
 SetFacingSkyfall: ; 44e4
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	bit SLIDING, [hl]
+	bit SLIDING_F, [hl]
 	jp nz, SetFacingCurrent
 
 	ld hl, OBJECT_STEP_FRAME
@@ -86,7 +86,7 @@
 
 	rrca
 	rrca
-	and %00000011
+	maskbits NUM_DIRECTIONS
 	ld d, a
 
 	call GetSpriteDirection
@@ -101,7 +101,7 @@
 SetFacingBumpAction: ; 4508
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	bit SLIDING, [hl]
+	bit SLIDING_F, [hl]
 	jp nz, SetFacingCurrent
 
 	ld hl, OBJECT_STEP_FRAME
@@ -112,7 +112,7 @@
 	rrca
 	rrca
 	rrca
-	and %00000011
+	maskbits NUM_DIRECTIONS
 	ld d, a
 
 	call GetSpriteDirection
@@ -245,7 +245,7 @@
 	ld a, [hl]
 	inc a
 	ld [hl], a
-	and %00001100
+	maskbits NUM_DIRECTIONS, 2
 	rrca
 	rrca
 	add FACING_WEIRD_TREE_0
--- a/engine/overworld/map_objects.asm
+++ b/engine/overworld/map_objects.asm
@@ -146,7 +146,7 @@
 .HandleObjectAction:
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	bit INVISIBLE, [hl]
+	bit INVISIBLE_F, [hl]
 	jr nz, SetFacingStanding
 	ld hl, OBJECT_FLAGS2
 	add hl, bc
@@ -161,7 +161,7 @@
 Function4440: ; 4440
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	bit INVISIBLE, [hl]
+	bit INVISIBLE_F, [hl]
 	jr nz, SetFacingStanding
 asm_4448:
 	ld de, ObjectActionPairPointers + 2 ; use second column
@@ -233,7 +233,7 @@
 UpdateTallGrassFlags: ; 463f
 	ld hl, OBJECT_FLAGS2
 	add hl, bc
-	bit OVERHEAD, [hl]
+	bit OVERHEAD_F, [hl]
 	jr z, .ok
 	ld hl, OBJECT_NEXT_TILE
 	add hl, bc
@@ -260,13 +260,13 @@
 .set
 	ld hl, OBJECT_FLAGS2
 	add hl, bc
-	set OVERHEAD, [hl]
+	set OVERHEAD_F, [hl]
 	ret
 
 .reset
 	ld hl, OBJECT_FLAGS2
 	add hl, bc
-	res OVERHEAD, [hl]
+	res OVERHEAD_F, [hl]
 	ret
 ; 4679
 
@@ -298,7 +298,7 @@
 	ld [hl], a
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	bit FIXED_FACING, [hl]
+	bit FIXED_FACING_F, [hl]
 	jr nz, GetNextTile
 	add a
 	add a
@@ -2155,7 +2155,7 @@
 	push af
 	ld hl, OBJECT_FLAGS1
 	add hl, de
-	bit EMOTE_OBJECT, [hl]
+	bit EMOTE_OBJECT_F, [hl]
 	jr z, .next
 	ld hl, OBJECT_SPRITE
 	add hl, de
@@ -2918,10 +2918,10 @@
 	ld e, PRIORITY_LOW
 	ld hl, OBJECT_FLAGS2
 	add hl, bc
-	bit LOW_PRIORITY, [hl]
+	bit LOW_PRIORITY_F, [hl]
 	jr nz, .add
 	ld e, PRIORITY_NORM
-	bit HIGH_PRIORITY, [hl]
+	bit HIGH_PRIORITY_F, [hl]
 	jr z, .add
 	ld e, PRIORITY_HIGH
 	jr .add
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -377,7 +377,7 @@
 Movement_remove_sliding: ; 5293
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	res SLIDING, [hl]
+	res SLIDING_F, [hl]
 	jp ContinueReadingMovement
 ; 529c
 
@@ -384,7 +384,7 @@
 Movement_set_sliding: ; 529c
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	set SLIDING, [hl]
+	set SLIDING_F, [hl]
 	jp ContinueReadingMovement
 ; 52a5
 
@@ -391,7 +391,7 @@
 Movement_remove_fixed_facing: ; 52a5
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	res FIXED_FACING, [hl]
+	res FIXED_FACING_F, [hl]
 	jp ContinueReadingMovement
 ; 52ae
 
@@ -398,7 +398,7 @@
 Movement_fix_facing: ; 52ae
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	set FIXED_FACING, [hl]
+	set FIXED_FACING_F, [hl]
 	jp ContinueReadingMovement
 ; 52b7
 
@@ -405,7 +405,7 @@
 Movement_show_object: ; 52b7
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	res INVISIBLE, [hl]
+	res INVISIBLE_F, [hl]
 	jp ContinueReadingMovement
 ; 52c0
 
@@ -412,7 +412,7 @@
 Movement_hide_object: ; 52c0
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	set INVISIBLE, [hl]
+	set INVISIBLE_F, [hl]
 	jp ContinueReadingMovement
 ; 52c9
 
@@ -838,7 +838,7 @@
 
 	ld hl, OBJECT_FLAGS2
 	add hl, bc
-	res OVERHEAD, [hl]
+	res OVERHEAD_F, [hl]
 
 	ld hl, OBJECT_ACTION
 	add hl, bc
--- a/engine/overworld/scripting.asm
+++ b/engine/overworld/scripting.asm
@@ -1071,7 +1071,7 @@
 	jr c, .not_visible ; STILL_SPRITE
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	bit FIXED_FACING, [hl]
+	bit FIXED_FACING_F, [hl]
 	jr nz, .not_visible
 	pop de
 	ld a, e