Start improving sprite movement engine (to do: identify bit flags)

Introduce maskbits N[, S]: optionally shift the bitmask
This commit is contained in:
Rangi 2018-05-23 12:48:14 -04:00
parent 4e776d4fa6
commit 32b92ca51c
8 changed files with 150 additions and 135 deletions

View File

@ -75,6 +75,16 @@ OVERHEAD EQU 3
const MAPOBJECT_F ; unused const MAPOBJECT_F ; unused
OBJECT_LENGTH EQU const_value 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_HEIGHT EQU 11
MAPOBJECT_SCREEN_WIDTH EQU 12 MAPOBJECT_SCREEN_WIDTH EQU 12
@ -119,7 +129,6 @@ MAPOBJECT_SCREEN_WIDTH EQU 12
const SPRITEMOVEDATA_GRASS ; 23 const SPRITEMOVEDATA_GRASS ; 23
const SPRITEMOVEDATA_SWIM_WANDER ; 24 const SPRITEMOVEDATA_SWIM_WANDER ; 24
NUM_SPRITEMOVEDATA EQU const_value NUM_SPRITEMOVEDATA EQU const_value
SPRITEMOVEDATA_FIELDS EQU 6
; MapObjectMovementPattern.Pointers indexes (see engine/overworld/map_objects.asm) ; MapObjectMovementPattern.Pointers indexes (see engine/overworld/map_objects.asm)
const_def const_def

View File

@ -5,304 +5,304 @@ SpriteMovementData:: ; 4273
db SPRITEMOVEFN_00 ; movement function db SPRITEMOVEFN_00 ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000010 ; flags1 db 1 << 1 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_STILL ; SPRITEMOVEDATA_STILL
db SPRITEMOVEFN_STANDING ; movement function db SPRITEMOVEFN_STANDING ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00001100 ; flags1 db 1 << 2 | 1 << 3 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_WANDER ; SPRITEMOVEDATA_WANDER
db SPRITEMOVEFN_RANDOM_WALK_XY ; movement function db SPRITEMOVEFN_RANDOM_WALK_XY ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_SPINRANDOM_SLOW ; SPRITEMOVEDATA_SPINRANDOM_SLOW
db SPRITEMOVEFN_SLOW_RANDOM_SPIN ; movement function db SPRITEMOVEFN_SLOW_RANDOM_SPIN ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_WALK_UP_DOWN ; SPRITEMOVEDATA_WALK_UP_DOWN
db SPRITEMOVEFN_RANDOM_WALK_Y ; movement function db SPRITEMOVEFN_RANDOM_WALK_Y ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_WALK_LEFT_RIGHT ; SPRITEMOVEDATA_WALK_LEFT_RIGHT
db SPRITEMOVEFN_RANDOM_WALK_X ; movement function db SPRITEMOVEFN_RANDOM_WALK_X ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_STANDING_DOWN ; SPRITEMOVEDATA_STANDING_DOWN
db SPRITEMOVEFN_STANDING ; movement function db SPRITEMOVEFN_STANDING ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_STANDING_UP ; SPRITEMOVEDATA_STANDING_UP
db SPRITEMOVEFN_STANDING ; movement function db SPRITEMOVEFN_STANDING ; movement function
db UP ; facing db UP ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_STANDING_LEFT ; SPRITEMOVEDATA_STANDING_LEFT
db SPRITEMOVEFN_STANDING ; movement function db SPRITEMOVEFN_STANDING ; movement function
db LEFT ; facing db LEFT ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_STANDING_RIGHT ; SPRITEMOVEDATA_STANDING_RIGHT
db SPRITEMOVEFN_STANDING ; movement function db SPRITEMOVEFN_STANDING ; movement function
db RIGHT ; facing db RIGHT ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_SPINRANDOM_FAST ; SPRITEMOVEDATA_SPINRANDOM_FAST
db SPRITEMOVEFN_FAST_RANDOM_SPIN ; movement function db SPRITEMOVEFN_FAST_RANDOM_SPIN ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_PLAYER ; SPRITEMOVEDATA_PLAYER
db SPRITEMOVEFN_OBEY_DPAD ; movement function db SPRITEMOVEFN_OBEY_DPAD ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000010 ; flags1 db 1 << 1 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_0C ; SPRITEMOVEDATA_0C
db SPRITEMOVEFN_08 ; movement function db SPRITEMOVEFN_08 ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_0D ; SPRITEMOVEDATA_0D
db SPRITEMOVEFN_09 ; movement function db SPRITEMOVEFN_09 ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_0E ; SPRITEMOVEDATA_0E
db SPRITEMOVEFN_0A ; movement function db SPRITEMOVEFN_0A ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_0F ; SPRITEMOVEDATA_0F
db SPRITEMOVEFN_0B ; movement function db SPRITEMOVEFN_0B ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_10 ; SPRITEMOVEDATA_10
db SPRITEMOVEFN_0C ; movement function db SPRITEMOVEFN_0C ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_11 ; SPRITEMOVEDATA_11
db SPRITEMOVEFN_0D ; movement function db SPRITEMOVEFN_0D ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_12 ; SPRITEMOVEDATA_12
db SPRITEMOVEFN_0E ; movement function db SPRITEMOVEFN_0E ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_FOLLOWING ; SPRITEMOVEDATA_FOLLOWING
db SPRITEMOVEFN_FOLLOW ; movement function db SPRITEMOVEFN_FOLLOW ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000010 ; flags1 db 1 << 1 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_SCRIPTED ; SPRITEMOVEDATA_SCRIPTED
db SPRITEMOVEFN_SCRIPTED ; movement function db SPRITEMOVEFN_SCRIPTED ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000010 ; flags1 db 1 << 1 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_BIGDOLLSYM ; SPRITEMOVEDATA_BIGDOLLSYM
db SPRITEMOVEFN_BIG_SNORLAX ; movement function db SPRITEMOVEFN_BIG_SNORLAX ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_BIG_DOLL_SYM ; action db OBJECT_ACTION_BIG_DOLL_SYM ; action
db %00101110 ; flags1 db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1
db %00000001 ; flags2 db 1 << 0 ; flags2
db %11000000 ; palette flags db 1 << 6 | 1 << 7 ; palette flags
; SPRITEMOVEDATA_POKEMON ; SPRITEMOVEDATA_POKEMON
db SPRITEMOVEFN_BOUNCE ; movement function db SPRITEMOVEFN_BOUNCE ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_BOUNCE ; action db OBJECT_ACTION_BOUNCE ; action
db %00101110 ; flags1 db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_SUDOWOODO ; SPRITEMOVEDATA_SUDOWOODO
db SPRITEMOVEFN_STANDING ; movement function db SPRITEMOVEFN_STANDING ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00001100 ; flags1 db 1 << 2 | 1 << 3 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_SMASHABLE_ROCK ; SPRITEMOVEDATA_SMASHABLE_ROCK
db SPRITEMOVEFN_STANDING ; movement function db SPRITEMOVEFN_STANDING ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00101110 ; flags1 db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1
db %00010000 ; flags2 db 1 << 4 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_STRENGTH_BOULDER ; SPRITEMOVEDATA_STRENGTH_BOULDER
db SPRITEMOVEFN_STRENGTH ; movement function db SPRITEMOVEFN_STRENGTH ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00101110 ; flags1 db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %01000000 ; palette flags db 1 << 6 ; palette flags
; SPRITEMOVEDATA_FOLLOWNOTEXACT ; SPRITEMOVEDATA_FOLLOWNOTEXACT
db SPRITEMOVEFN_FOLLOWNOTEXACT ; movement function db SPRITEMOVEFN_FOLLOWNOTEXACT ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000010 ; flags1 db 1 << 1 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_SHADOW ; SPRITEMOVEDATA_SHADOW
db SPRITEMOVEFN_SHADOW ; movement function db SPRITEMOVEFN_SHADOW ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_00 ; action db OBJECT_ACTION_00 ; action
db %10001110 ; flags1 db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1
db %00000001 ; flags2 db 1 << 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_EMOTE ; SPRITEMOVEDATA_EMOTE
db SPRITEMOVEFN_EMOTE ; movement function db SPRITEMOVEFN_EMOTE ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_EMOTE ; action db OBJECT_ACTION_EMOTE ; action
db %10001110 ; flags1 db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1
db %00000010 ; flags2 db 1 << 1 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_SCREENSHAKE ; SPRITEMOVEDATA_SCREENSHAKE
db SPRITEMOVEFN_SCREENSHAKE ; movement function db SPRITEMOVEFN_SCREENSHAKE ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_00 ; action db OBJECT_ACTION_00 ; action
db %10000010 ; flags1 db 1 << 1 | 1 << 7 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_SPINCOUNTERCLOCKWISE ; SPRITEMOVEDATA_SPINCOUNTERCLOCKWISE
db SPRITEMOVEFN_SPIN_COUNTERCLOCKWISE ; movement function db SPRITEMOVEFN_SPIN_COUNTERCLOCKWISE ; movement function
db LEFT ; facing db LEFT ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_SPINCLOCKWISE ; SPRITEMOVEDATA_SPINCLOCKWISE
db SPRITEMOVEFN_SPIN_CLOCKWISE ; movement function db SPRITEMOVEFN_SPIN_CLOCKWISE ; movement function
db RIGHT ; facing db RIGHT ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_BIGDOLLASYM ; SPRITEMOVEDATA_BIGDOLLASYM
db SPRITEMOVEFN_STRENGTH ; movement function db SPRITEMOVEFN_STRENGTH ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_BIG_DOLL_ASYM ; action db OBJECT_ACTION_BIG_DOLL_ASYM ; action
db %00101110 ; flags1 db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1
db %00000001 ; flags2 db 1 << 0 ; flags2
db %11000000 ; palette flags db 1 << 6 | 1 << 7 ; palette flags
; SPRITEMOVEDATA_BIGDOLL ; SPRITEMOVEDATA_BIGDOLL
db SPRITEMOVEFN_STRENGTH ; movement function db SPRITEMOVEFN_STRENGTH ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_BIG_DOLL ; action db OBJECT_ACTION_BIG_DOLL ; action
db %00101110 ; flags1 db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1
db %00000001 ; flags2 db 1 << 0 ; flags2
db %11000000 ; palette flags db 1 << 6 | 1 << 7 ; palette flags
; SPRITEMOVEDATA_BOULDERDUST ; SPRITEMOVEDATA_BOULDERDUST
db SPRITEMOVEFN_BOULDERDUST ; movement function db SPRITEMOVEFN_BOULDERDUST ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_BOULDER_DUST ; action db OBJECT_ACTION_BOULDER_DUST ; action
db %10001110 ; flags1 db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1
db %00000001 ; flags2 db 1 << 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_GRASS ; SPRITEMOVEDATA_GRASS
db SPRITEMOVEFN_GRASS ; movement function db SPRITEMOVEFN_GRASS ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_GRASS_SHAKE ; action db OBJECT_ACTION_GRASS_SHAKE ; action
db %10001110 ; flags1 db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1
db %00000010 ; flags2 db 1 << 1 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; SPRITEMOVEDATA_SWIM_WANDER ; SPRITEMOVEDATA_SWIM_WANDER
db SPRITEMOVEFN_RANDOM_WALK_XY ; movement function db SPRITEMOVEFN_RANDOM_WALK_XY ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00100000 ; palette flags db 1 << 5 ; palette flags
; 25 ; 25
db SPRITEMOVEFN_00 ; movement function db SPRITEMOVEFN_00 ; movement function
db DOWN ; facing db DOWN ; facing
db OBJECT_ACTION_STAND ; action db OBJECT_ACTION_STAND ; action
db %00000000 ; flags1 db 0 ; flags1
db %00000000 ; flags2 db 0 ; flags2
db %00000000 ; palette flags db 0 ; palette flags
; 4357 ; 4357

View File

@ -1055,7 +1055,7 @@ AI_Smart_TrapTarget: ; 38a71
jr nz, .asm_38a91 jr nz, .asm_38a91
ld a, [wPlayerSubStatus1] ld a, [wPlayerSubStatus1]
and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE and 1 << SUBSTATUS_IN_LOVE | 1 << SUBSTATUS_ROLLOUT | 1 << SUBSTATUS_IDENTIFIED | 1 << SUBSTATUS_NIGHTMARE
jr nz, .asm_38a91 jr nz, .asm_38a91
; Else, 50% chance to greatly encourage this move if it's the player's Pokemon first turn. ; Else, 50% chance to greatly encourage this move if it's the player's Pokemon first turn.
@ -1847,7 +1847,7 @@ AI_Smart_MeanLook: ; 38dfb
; 80% chance to greatly encourage this move if the player is either ; 80% chance to greatly encourage this move if the player is either
; in love, identified, stuck in Rollout, or has a Nightmare. ; in love, identified, stuck in Rollout, or has a Nightmare.
ld a, [wPlayerSubStatus1] ld a, [wPlayerSubStatus1]
and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE and 1 << SUBSTATUS_IN_LOVE | 1 << SUBSTATUS_ROLLOUT | 1 << SUBSTATUS_IDENTIFIED | 1 << SUBSTATUS_NIGHTMARE
jr nz, .asm_38e26 jr nz, .asm_38e26
; Otherwise, discourage this move unless the player only has not very effective moves against the enemy. ; Otherwise, discourage this move unless the player only has not very effective moves against the enemy.

View File

@ -364,7 +364,7 @@ CantMove: ; 341f0
ld a, BATTLE_VARS_SUBSTATUS3 ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarAddr call GetBattleVarAddr
ld a, [hl] ld a, [hl]
and $ff ^ (1<<SUBSTATUS_BIDE + 1<<SUBSTATUS_RAMPAGE + 1<<SUBSTATUS_CHARGED) and $ff ^ (1 << SUBSTATUS_BIDE | 1 << SUBSTATUS_RAMPAGE | 1 << SUBSTATUS_CHARGED)
ld [hl], a ld [hl], a
call ResetFuryCutterCount call ResetFuryCutterCount

View File

@ -1497,29 +1497,29 @@ CalcMonStatC: ; e17b
jr z, .Special jr z, .Special
cp STAT_SDEF cp STAT_SDEF
jr z, .Special jr z, .Special
; DV_HP = (DV_ATK & 1) << 3 + (DV_DEF & 1) << 2 + (DV_SPD & 1) << 1 + (DV_SPC & 1) ; DV_HP = (DV_ATK & 1) << 3 | (DV_DEF & 1) << 2 | (DV_SPD & 1) << 1 | (DV_SPC & 1)
push bc push bc
ld a, [hl] ld a, [hl]
swap a swap a
and $1 and 1
add a add a
add a add a
add a add a
ld b, a ld b, a
ld a, [hli] ld a, [hli]
and $1 and 1
add a add a
add a add a
add b add b
ld b, a ld b, a
ld a, [hl] ld a, [hl]
swap a swap a
and $1 and 1
add a add a
add b add b
ld b, a ld b, a
ld a, [hl] ld a, [hl]
and $1 and 1
add b add b
pop bc pop bc
jr .GotDV jr .GotDV

View File

@ -482,10 +482,10 @@ GetSpriteMovementFunction:: ; 1a2f
xor a xor a
.ok .ok
ld hl, SpriteMovementData ld hl, SpriteMovementData + SPRITEMOVEATTR_MOVEMENT
ld e, a ld e, a
ld d, 0 ld d, 0
rept SPRITEMOVEDATA_FIELDS rept NUM_SPRITEMOVEDATA_FIELDS
add hl, de add hl, de
endr endr
ld a, [hl] ld a, [hl]
@ -497,15 +497,15 @@ GetInitialFacing:: ; 1a47
push de push de
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, SpriteMovementData + 1 ; init facing ld hl, SpriteMovementData + SPRITEMOVEATTR_FACING
rept SPRITEMOVEDATA_FIELDS rept NUM_SPRITEMOVEDATA_FIELDS
add hl, de add hl, de
endr endr
ld a, BANK(SpriteMovementData) ld a, BANK(SpriteMovementData)
call GetFarByte call GetFarByte
add a add a
add a add a
and $c maskbits NUM_DIRECTIONS, 2
pop de pop de
pop bc pop bc
ret ret
@ -537,8 +537,8 @@ CopySpriteMovementData:: ; 1a61
push de push de
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, SpriteMovementData + 1 ; init facing ld hl, SpriteMovementData + SPRITEMOVEATTR_FACING
rept SPRITEMOVEDATA_FIELDS rept NUM_SPRITEMOVEDATA_FIELDS
add hl, de add hl, de
endr endr
ld b, h ld b, h
@ -549,7 +549,7 @@ endr
inc bc inc bc
rlca rlca
rlca rlca
and %00001100 maskbits NUM_DIRECTIONS, 2
ld hl, OBJECT_FACING ld hl, OBJECT_FACING
add hl, de add hl, de
ld [hl], a ld [hl], a
@ -654,7 +654,7 @@ SetSpriteDirection:: ; 1af8
and %11110011 and %11110011
ld e, a ld e, a
pop af pop af
and %00001100 maskbits NUM_DIRECTIONS, 2
or e or e
ld [hl], a ld [hl], a
ret ret
@ -664,6 +664,6 @@ GetSpriteDirection:: ; 1b07
ld hl, OBJECT_FACING ld hl, OBJECT_FACING
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
and %00001100 maskbits NUM_DIRECTIONS, 2
ret ret
; 1b0f ; 1b0f

View File

@ -36,8 +36,10 @@ jumptable: MACRO
ENDM ENDM
maskbits: MACRO maskbits: MACRO
; masks just enough bits to cover the argument ; masks just enough bits to cover the first argument
; the second argument is an optional shift amount
; e.g. "maskbits 26" becomes "and %00011111" (since 26 - 1 = %00011001) ; e.g. "maskbits 26" becomes "and %00011111" (since 26 - 1 = %00011001)
; and "maskbits 3, 2" becomes "and %00001100" (since "maskbits 3" becomes %00000011)
; example usage in rejection sampling: ; example usage in rejection sampling:
; .loop ; .loop
; call Random ; call Random
@ -50,7 +52,11 @@ if x + 1 < (\1)
x = x << 1 | 1 x = x << 1 | 1
endc endc
endr endr
if _NARG == 2
and x << (\2)
else
and x and x
endc
ENDM ENDM
calc_sine_wave: MACRO calc_sine_wave: MACRO

View File

@ -83,7 +83,7 @@ EnableMobile: ; 100082
call DoubleSpeed call DoubleSpeed
xor a xor a
ld [rIF], a ld [rIF], a
ld a, 1 << VBLANK + 1 << LCD_STAT + 1 << TIMER + 1 << SERIAL ld a, 1 << VBLANK | 1 << LCD_STAT | 1 << TIMER | 1 << SERIAL
ld [rIE], a ld [rIE], a
xor a xor a
ld [hMapAnims], a ld [hMapAnims], a