Prev: C2F6 Up: Map Next: C32F
C319: Which way an object faces
Used by the routines at HANDLE_LEFT_RIGHT and CALC_PLYR_DUV.
The facing, 0 to 3, from the two bits that store it: bit 6 of the flags (the sprite mirrored) gives 2, and bit 2 of the graphic adds 1. By the steps each facing is given (WALK_STEP_TBL), 0 faces lower U, 1 higher U, 2 higher V and 3 lower V. Knight Lore's is the same with bit 3 of the graphic; Pentagram's counts 2 for a sprite not mirrored.
Input
IX the object
Output
A the facing
GET_SPRITE_DIR C319 PUSH HL L = 8 if the sprite is mirrored
C31A LD A,(IX+$07)
C31D RRCA
C31E RRCA
C31F RRCA
C320 AND $08
C322 LD L,A
C323 LD A,(IX+$00) With the graphic's bit 2
C326 AND $04
C328 OR L
C329 RRCA Down to bits 1 and 0; HL kept
C32A RRCA
C32B AND $03
C32D POP HL
C32E RET
Prev: C2F6 Up: Map Next: C32F