Prev: DF33 Up: Map Next: DFCD
DFBC: Calculate servant/icon cursor graphic horizontal/vertical direction & speed
Used by the routines at E958 and E987.
Input
A Left/right control value (from EAFD) or up/down control value (from EAFE)
C Horizontal/vertical movement speed at EB01/EB02
Identifies if the servant/cursor is moving, in which direction, and adds/subtracts movement speed accordingly. Deals with both vertical and horizontal movement.
Returns the calculated value (either zero for no movement, or a positive/negative value) in the H register. This is later used to calculate the sprite's new vertical/horizontal position.
Called from E95F (horizontal movement) and E98E (vertical movement).
DFBC CP $00 Is there any movement in the direction being checked (horizontal/vertical)?
DFBE JR Z,$DFCA If there isn't, set movement offset to 0 and RET
DFC0 NEG Positive/negative values stored are the opposite of Maroc's movement, so make negative (otherwise player controls will appear reversed)
DFC2 LD B,A Temp store in B register
DFC3 ADD A,C Add the speed to the direction
DFC4 LD H,A ...and store in H
The next 3 instructions set a 'terminal velocity' speed. It ensures speed is reset to 0 when a certain speed (128) is reached:
DFC5 XOR B Compare with adjusted speed (retain where bits are different)
DFC6 AND $80 Check bit 7 - if this bit is set, the servant has reached terminal speed (in either direction)
DFC8 JR Z,$DFCC However, the screen size means this speed can't be reached, so a NZ (non-zero) result shouldn't normally happen
DFCA LD H,$00 If terminal velocity has been reached, set movement/speed back to zero
DFCC RET
Prev: DF33 Up: Map Next: DFCD