From 32b92ca51c73f1ad9be169bef476b9c93687e2a4 Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 23 May 2018 12:48:14 -0400 Subject: [PATCH] Start improving sprite movement engine (to do: identify bit flags) Introduce maskbits N[, S]: optionally shift the bitmask --- constants/map_object_constants.asm | 11 +- data/sprites/map_objects.asm | 228 ++++++++++++++--------------- engine/battle/ai/scoring.asm | 4 +- engine/battle/effect_commands.asm | 2 +- engine/pokemon/move_mon.asm | 10 +- home/map_objects.asm | 20 +-- macros/code.asm | 8 +- mobile/mobile_40.asm | 2 +- 8 files changed, 150 insertions(+), 135 deletions(-) diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index 73685d4ec..43207a4dd 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -75,6 +75,16 @@ OVERHEAD EQU 3 const MAPOBJECT_F ; unused OBJECT_LENGTH EQU const_value +; SpriteMovementData struct members (see data/sprites/map_objects.asm) + const_def + const SPRITEMOVEATTR_MOVEMENT ; 0 + const SPRITEMOVEATTR_FACING ; 1 + const SPRITEMOVEATTR_ACTION ; 2 + const SPRITEMOVEATTR_FLAGS1 ; 3 + const SPRITEMOVEATTR_FLAGS2 ; 4 + const SPRITEMOVEATTR_PALFLAGS ; 5 +NUM_SPRITEMOVEDATA_FIELDS EQU const_value + MAPOBJECT_SCREEN_HEIGHT EQU 11 MAPOBJECT_SCREEN_WIDTH EQU 12 @@ -119,7 +129,6 @@ MAPOBJECT_SCREEN_WIDTH EQU 12 const SPRITEMOVEDATA_GRASS ; 23 const SPRITEMOVEDATA_SWIM_WANDER ; 24 NUM_SPRITEMOVEDATA EQU const_value -SPRITEMOVEDATA_FIELDS EQU 6 ; MapObjectMovementPattern.Pointers indexes (see engine/overworld/map_objects.asm) const_def diff --git a/data/sprites/map_objects.asm b/data/sprites/map_objects.asm index 8821f8a1b..0e19b3787 100644 --- a/data/sprites/map_objects.asm +++ b/data/sprites/map_objects.asm @@ -5,304 +5,304 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_00 ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000010 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_STILL db SPRITEMOVEFN_STANDING ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00001100 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 2 | 1 << 3 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_WANDER db SPRITEMOVEFN_RANDOM_WALK_XY ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SPINRANDOM_SLOW db SPRITEMOVEFN_SLOW_RANDOM_SPIN ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_WALK_UP_DOWN db SPRITEMOVEFN_RANDOM_WALK_Y ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_WALK_LEFT_RIGHT db SPRITEMOVEFN_RANDOM_WALK_X ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_STANDING_DOWN db SPRITEMOVEFN_STANDING ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_STANDING_UP db SPRITEMOVEFN_STANDING ; movement function db UP ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_STANDING_LEFT db SPRITEMOVEFN_STANDING ; movement function db LEFT ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_STANDING_RIGHT db SPRITEMOVEFN_STANDING ; movement function db RIGHT ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SPINRANDOM_FAST db SPRITEMOVEFN_FAST_RANDOM_SPIN ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_PLAYER db SPRITEMOVEFN_OBEY_DPAD ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000010 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_0C db SPRITEMOVEFN_08 ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_0D db SPRITEMOVEFN_09 ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_0E db SPRITEMOVEFN_0A ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_0F db SPRITEMOVEFN_0B ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_10 db SPRITEMOVEFN_0C ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_11 db SPRITEMOVEFN_0D ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_12 db SPRITEMOVEFN_0E ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_FOLLOWING db SPRITEMOVEFN_FOLLOW ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000010 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SCRIPTED db SPRITEMOVEFN_SCRIPTED ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000010 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_BIGDOLLSYM db SPRITEMOVEFN_BIG_SNORLAX ; movement function db DOWN ; facing db OBJECT_ACTION_BIG_DOLL_SYM ; action - db %00101110 ; flags1 - db %00000001 ; flags2 - db %11000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 1 << 0 ; flags2 + db 1 << 6 | 1 << 7 ; palette flags ; SPRITEMOVEDATA_POKEMON db SPRITEMOVEFN_BOUNCE ; movement function db DOWN ; facing db OBJECT_ACTION_BOUNCE ; action - db %00101110 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SUDOWOODO db SPRITEMOVEFN_STANDING ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00001100 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 2 | 1 << 3 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SMASHABLE_ROCK db SPRITEMOVEFN_STANDING ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00101110 ; flags1 - db %00010000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 1 << 4 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_STRENGTH_BOULDER db SPRITEMOVEFN_STRENGTH ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00101110 ; flags1 - db %00000000 ; flags2 - db %01000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 0 ; flags2 + db 1 << 6 ; palette flags ; SPRITEMOVEDATA_FOLLOWNOTEXACT db SPRITEMOVEFN_FOLLOWNOTEXACT ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000010 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SHADOW db SPRITEMOVEFN_SHADOW ; movement function db DOWN ; facing db OBJECT_ACTION_00 ; action - db %10001110 ; flags1 - db %00000001 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1 + db 1 << 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_EMOTE db SPRITEMOVEFN_EMOTE ; movement function db DOWN ; facing db OBJECT_ACTION_EMOTE ; action - db %10001110 ; flags1 - db %00000010 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1 + db 1 << 1 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SCREENSHAKE db SPRITEMOVEFN_SCREENSHAKE ; movement function db DOWN ; facing db OBJECT_ACTION_00 ; action - db %10000010 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 7 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SPINCOUNTERCLOCKWISE db SPRITEMOVEFN_SPIN_COUNTERCLOCKWISE ; movement function db LEFT ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SPINCLOCKWISE db SPRITEMOVEFN_SPIN_CLOCKWISE ; movement function db RIGHT ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_BIGDOLLASYM db SPRITEMOVEFN_STRENGTH ; movement function db DOWN ; facing db OBJECT_ACTION_BIG_DOLL_ASYM ; action - db %00101110 ; flags1 - db %00000001 ; flags2 - db %11000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 1 << 0 ; flags2 + db 1 << 6 | 1 << 7 ; palette flags ; SPRITEMOVEDATA_BIGDOLL db SPRITEMOVEFN_STRENGTH ; movement function db DOWN ; facing db OBJECT_ACTION_BIG_DOLL ; action - db %00101110 ; flags1 - db %00000001 ; flags2 - db %11000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 1 << 0 ; flags2 + db 1 << 6 | 1 << 7 ; palette flags ; SPRITEMOVEDATA_BOULDERDUST db SPRITEMOVEFN_BOULDERDUST ; movement function db DOWN ; facing db OBJECT_ACTION_BOULDER_DUST ; action - db %10001110 ; flags1 - db %00000001 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1 + db 1 << 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_GRASS db SPRITEMOVEFN_GRASS ; movement function db DOWN ; facing db OBJECT_ACTION_GRASS_SHAKE ; action - db %10001110 ; flags1 - db %00000010 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1 + db 1 << 1 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SWIM_WANDER db SPRITEMOVEFN_RANDOM_WALK_XY ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00100000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 1 << 5 ; palette flags ; 25 db SPRITEMOVEFN_00 ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; 4357 diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm index e83682427..567737c1f 100644 --- a/engine/battle/ai/scoring.asm +++ b/engine/battle/ai/scoring.asm @@ -1055,7 +1055,7 @@ AI_Smart_TrapTarget: ; 38a71 jr nz, .asm_38a91 ld a, [wPlayerSubStatus1] - and 1<