Prev: 6CFA Up: Map Next: 6D4E
6D17: Get the location of the tile in front of a sprite
Used by the routines at 6337, 63DA and 6CC2.
Input
A Sprite animation frame
HL Sprite location
Output
HL Location of the tile in front of the sprite
6D17 AND $03 Keep only bits 0 and 1 of the animation frame (which indicate the direction that the sprite is facing). (This instruction is redundant.)
6D19 CP $00 Is the sprite facing up?
6D1B JR Z,$6D2E Jump if so.
6D1D CP $01 Is the sprite facing right?
6D1F JR Z,$6D3A Jump if so.
6D21 CP $02 Is the sprite facing down?
6D23 JR Z,$6D43 Jump if so.
The sprite is facing left.
6D25 DEC L Point HL at the tile to the left of the sprite's current location.
6D26 JR NC,$6D4D This jump is always made.
6D28 LD A,H This code is never executed.
6D29 SUB $08
6D2B LD H,A
6D2C JR $6D4D
The sprite is facing up.
6D2E LD A,L Point HL at the tile above the sprite's current location.
6D2F SUB $20
6D31 LD L,A
6D32 JR NC,$6D4D
6D34 LD A,H
6D35 SUB $08
6D37 LD H,A
6D38 JR $6D4D
The sprite is facing right.
6D3A INC L Point HL at the tile to the right of the sprite's current location.
6D3B JR NZ,$6D4D
6D3D LD A,H
6D3E ADD A,$08
6D40 LD H,A
6D41 JR $6D4D
The sprite is facing down.
6D43 LD A,L Point HL at the tile below the sprite's current location.
6D44 ADD A,$20
6D46 LD L,A
6D47 JR NC,$6D4D
6D49 LD A,H
6D4A ADD A,$08
6D4C LD H,A
6D4D RET
Prev: 6CFA Up: Map Next: 6D4E