Prev: 61194 Up: Map Next: 61264
61240: Calculate Monster Position?
Used by the routines at 60866 and 62290.
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 61240 LD BC,(53837) BC=*Active_MonsterXPosition/Active_MonsterYPosition.
Which number is added is determined by which direction the monster is facing.
61244 LD A,(53831) A=*Flag_Orientation (will be 0 or 1).
Moves the orientation flag into the carry flag.
61247 RRCA Rotate A right one position, setting the carry flag if bit 0 was set.
61248 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.
61250 LD A,B B+=H.
61251 ADD A,H
61252 LD B,A
61253 LD A,C C+=L.
61254 ADD A,L
61255 LD C,A
61256 RET Return.
If the monster is facing left; add DE to BC.
Monster_CalculatePosition_FacingLeft 61257 LD A,B B+=D.
61258 ADD A,D
61259 LD B,A
61260 LD A,C C+=E.
61261 ADD A,E
61262 LD C,A
61263 RET Return.
Prev: 61194 Up: Map Next: 61264