Prev: B264 Up: Map Next: B2DB
B288: Move a character left or right
Used by the routines at A92C, AAB2, AADD, AB09, AB26, AB43, AB60, AB9B, B09F, B3C3 and F0C0.
Input
IY Current character buffer (BC67 - BC6B)
B288 CALL $A921 Is this character the active one?
B28B JR Z,$B29E Jump forward if it is.
B28D LD A,($B951) Get the current room number.
B290 CP (IY+$0F) Is the player in this room?
B293 JR Z,$B29E Jump forward if they are.
B295 LD A,(IY+$5F) Flip the movement flag. (BCC6)
B298 XOR $01
B29A LD (IY+$5F),A
B29D RET Z Return if this is zero.
Update the frame number.
B29E LD A,(IY+$00) Get the frame number and increment it.
B2A1 INC A
B2A2 CP $06 If the frame is greater than 5, reset it to 0.
B2A4 JR C,$B2A7
B2A6 XOR A
B2A7 LD (IY+$00),A Store the new frame number.
Check for any movement.
B2AA LD A,(IY+$3C) Get the movement flag. (BCA3)
B2AD CP $01 Is the character facing right?
B2AF JR NZ,$B2C6 Move forward if not.
Move right.
B2B1 LD A,(IY-$3C) Get the current direction of the sprite.
B2B4 OR A Is it 0 (left)?
B2B5 CALL Z,$81D4 If so, need to change direction.
B2B8 LD A,(IY+$05) Get the X co-ordinate.
B2BB ADD A,$02 Add 2.
B2BD CP $F0 If it's greater than F0 set it to that.
B2BF JR C,$B2D5
B2C1 LD A,$F0
B2C3 JP $B2D5
Move left.
B2C6 LD A,(IY-$3C) Get the direction flag. (BCA3)
B2C9 OR A Is it 0?
B2CA CALL NZ,$81D4 If it isn't, it must be facing left, so change direction.
B2CD LD A,(IY+$05) Get the X co-ordinate.
B2D0 SUB $02 Subtract 2.
B2D2 JR NC,$B2D5 If it's less than 0, set it to that.
B2D4 XOR A
B2D5 LD (IY+$05),A Set the new X co-ordinate
B2D8 JP $E2FC Play a footstep and return.
Prev: B264 Up: Map Next: B2DB