Prev: CA11 Up: Map Next: CA81
CA49: Vischar move Y
This moves a character on the Y axis.
Used by the routine at character_behaviour.
Nearly identical to vischar_move_x above.
Input
HL Pointer to vischar.target.
IY Pointer to visible character block.
Output
A New input: input_LEFT + input_DOWN (5) if y > pos.y, input_RIGHT + input_UP (7) if y < pos.y, input_NONE (0) if y == pos.y
F Z set if zero returned, NZ otherwise
HL Pointer to visible character block + 4. (Ready to pass into vischar_move_x)
vischar_move_y CA49 LD A,(HL) Read vischar.target.y (target position)
CA4A CALL multiply_by_8 Multiply it by 1, 4 or 8 (self modified by C9DD)
CA4D LD A,L Point HL at vischar.mi.pos.y (current position)
CA4E ADD A,$0C
CA50 LD L,A
CA51 LD E,(HL) Read vischar.mi.pos.y
CA52 INC L
CA53 LD D,(HL)
CA54 EX DE,HL Free up HL
CA55 SBC HL,BC Compute the delta: current position - target position
CA57 JR Z,vmy_equal Jump if it's zero
CA59 JP M,vmy_negative Jump if it's negative
The delta was positive
vmy_positive CA5C LD A,H Delta >= 256?
CA5D AND A
CA5E JR NZ,vmy_delta_too_big Jump if so
CA60 LD A,L Delta < 3?
CA61 CP $03
CA63 JR C,vmy_equal Jump if it's in range
The delta was three or greater
vmy_delta_too_big CA65 LD A,$05 Return input_LEFT + input_DOWN (3 + 2)
CA67 RET
The delta was negative
vmy_negative CA68 LD A,H Delta < -256?
CA69 CP $FF
CA6B JR NZ,vmy_delta_too_small Jump if so
CA6D LD A,L Delta >= -2?
CA6E CP $FE
CA70 JP NC,vmy_equal Jump if it's in range
The delta was less than negative three
vmy_delta_too_small CA73 LD A,$07 Return input_RIGHT + input_UP (6 + 1)
CA75 RET
The delta was -2..2
vmy_equal CA76 EX DE,HL Move vischar back into HL
CA77 LD A,L Point HL at vischar->mi.pos.y
CA78 SUB $0E
CA7A LD L,A
CA7B RES 5,(IY+$07) Clear vischar.counter_and_flags flag vischar_BYTE7_Y_DOMINANT so that next time we'll use vischar_move_x in preference
CA7F XOR A Return input_NONE (0)
CA80 RET
Prev: CA11 Up: Map Next: CA81