And yet more enemies, an underground hand and a devil skeleton. Nothing spectacularely new.
The devil skeleton is behaving mostly like the mummy. Walk back and forth, if a player is seen, speed towards him.
!zone BehaviourDevil
BehaviourDevil
lda SPRITE_HITBACK,x
beq .NoHitBack
dec SPRITE_HITBACK,x
lda SPRITE_HITBACK_DIRECTION,x
beq .HitBackRight
;move left
jsr ObjectMoveLeftBlocking
rts
.HitBackRight
jsr ObjectMoveRightBlocking
rts
.NoHitBack
jsr ObjectMoveDownBlocking
beq .NotFalling
rts
.NotFalling
inc SPRITE_ANIM_DELAY,x
lda SPRITE_ANIM_DELAY,x
cmp #8bne .NoAnimUpdate
lda #0
sta SPRITE_ANIM_DELAY,x
inc SPRITE_ANIM_POS,x
lda SPRITE_ANIM_POS,x
cmp #3bne .NoWrap
lda #0
.NoWrap
sta SPRITE_ANIM_POS,x
clc
asl
adc SPRITE_DIRECTION,x
adc #SPRITE_DEVIL_WALK_R_1
sta SPRITE_POINTER_BASE,x
.NoAnimUpdate
lda SPRITE_CHAR_POS_Y,x
cmp SPRITE_CHAR_POS_Y
bne .NoPlayerInSight
;player on same height;looking at the player?
jsr LookingAtPlayer
beq .NoPlayerInSight
lda SPRITE_DIRECTION,x
beq .AttackRight
;attack to left
jsr ObjectMoveLeftBlocking
jsr ObjectMoveLeftBlocking
beq .ToggleDirection
rts
.AttackRight;attack to left
jsr ObjectMoveRightBlocking
jsr ObjectMoveRightBlocking
beq .ToggleDirection
rts
.NoPlayerInSight
lda DELAYED_GENERIC_COUNTER
and #$03beq .MovementUpdate
rts
.MovementUpdate
inc SPRITE_MOVE_POS,x
lda SPRITE_MOVE_POS,x
and #$03
sta SPRITE_MOVE_POS,x
lda SPRITE_DIRECTION,x
beq .MoveRight
;move left
jsr ObjectWalkLeft
beq .ToggleDirection
rts
.MoveRight
jsr ObjectWalkRight
beq .ToggleDirection
rts
.ToggleDirection
lda SPRITE_DIRECTION,x
eor #1
sta SPRITE_DIRECTION,x
clc
adc #SPRITE_DEVIL_WALK_R_1
sta SPRITE_POINTER_BASE,x
rts
The hand is a bit more interesting. It is stationary, but usually stays underground. In intervals the hand rises and tries to grab at the player.
;------------------------------------------------------------
;simply appear and hide again
;state 128 = invisible
; 0 = rising/hiding
;------------------------------------------------------------
!zone BehaviourHand
BehaviourHand
lda DELAYED_GENERIC_COUNTER
and #$03
beq .MovementUpdate
.NoMovement
rts
.MovementUpdate
lda SPRITE_STATE,x
bne .HiddenState
inc SPRITE_ANIM_DELAY,x
lda SPRITE_ANIM_DELAY,x
cmp #3
bne .NoMovement
lda #0
sta SPRITE_ANIM_DELAY,x
inc SPRITE_ANIM_POS,x
lda SPRITE_ANIM_POS,x
cmp #6
beq .EnterHiddenState
.UpdateHandSprite
ldy SPRITE_ANIM_POS,x
lda HAND_ANIM_TABLE,y
sta SPRITE_POINTER_BASE,x
lda HAND_COLOR_TABLE,y
sta VIC_SPRITE_COLOR,x
rts
.EnterHiddenState
lda #SPRITE_INVISIBLE
sta SPRITE_POINTER_BASE,x
jsr GenerateRandomNumber
sta SPRITE_MOVE_POS,x
lda #128
sta SPRITE_STATE,x
.StillHidden
rts
.HiddenStatedec SPRITE_MOVE_POS,x
bne .StillHidden
;unhiding
lda #0
sta SPRITE_STATE,x
sta SPRITE_ANIM_DELAY,x
sta SPRITE_ANIM_POS,x
jmp .UpdateHandSprite
Note that also for the hand the empty sprite comes to use. It's basically an empty image to avoid disabling and enabling the sprite. This however comes at the cost of 63 bytes for the image.