Prev: EF0A Up: Map Next: EF50
EF38: Calculate Monster Position?
Used by the routines at EDC2 and F352.
Input
DE 16-bit number to add to HL if facing left
HL 16-bit number to add to HL if facing right
Output
BC The new monster co-ordinates
TODO; this is likely used for punching collision detection.
Set the co-ordinates for where to draw.
Monster_CalculatePosition EF38 LD BC,($D24D) BC=*Active_MonsterXPosition/Active_MonsterYPosition.
Which number is added is determined by which direction the monster is facing.
EF3C LD A,($D247) A=*Flag_Orientation (will be 00 or 01).
Moves the orientation flag into the carry flag.
EF3F RRCA Rotate A right one position, setting the carry flag if bit 0 was set.
EF40 JR C,Monster_CalculatePosition_FacingLeft Jump to Monster_CalculatePosition_FacingLeft if the carry flag is set.
If the monster is facing right; add HL to BC.
EF42 LD A,B B+=H.
EF43 ADD A,H
EF44 LD B,A
EF45 LD A,C C+=L.
EF46 ADD A,L
EF47 LD C,A
EF48 RET Return.
If the monster is facing left; add DE to BC.
Monster_CalculatePosition_FacingLeft EF49 LD A,B B+=D.
EF4A ADD A,D
EF4B LD B,A
EF4C LD A,C C+=E.
EF4D ADD A,E
EF4E LD C,A
EF4F RET Return.
Prev: EF0A Up: Map Next: EF50