Prev: 27898 Up: Map Next: 27982
27927: Get the location of the tile in front of a sprite
Used by the routines at 25399, 25562 and 27842.
Input
A Sprite animation frame
HL Sprite location
Output
HL Location of the tile in front of the sprite
27927 AND 3 Keep only bits 0 and 1 of the animation frame (which indicate the direction that the sprite is facing). (This instruction is redundant.)
27929 CP 0 Is the sprite facing up?
27931 JR Z,27950 Jump if so.
27933 CP 1 Is the sprite facing right?
27935 JR Z,27962 Jump if so.
27937 CP 2 Is the sprite facing down?
27939 JR Z,27971 Jump if so.
The sprite is facing left.
27941 DEC L Point HL at the tile to the left of the sprite's current location.
27942 JR NC,27981 This jump is always made.
27944 LD A,H This code is never executed.
27945 SUB 8
27947 LD H,A
27948 JR 27981
The sprite is facing up.
27950 LD A,L Point HL at the tile above the sprite's current location.
27951 SUB 32
27953 LD L,A
27954 JR NC,27981
27956 LD A,H
27957 SUB 8
27959 LD H,A
27960 JR 27981
The sprite is facing right.
27962 INC L Point HL at the tile to the right of the sprite's current location.
27963 JR NZ,27981
27965 LD A,H
27966 ADD A,8
27968 LD H,A
27969 JR 27981
The sprite is facing down.
27971 LD A,L Point HL at the tile below the sprite's current location.
27972 ADD A,32
27974 LD L,A
27975 JR NC,27981
27977 LD A,H
27978 ADD A,8
27980 LD H,A
27981 RET
Prev: 27898 Up: Map Next: 27982