Prev: A38C Up: Map Next: A3ED
A3BB: Set route
This fetches the current target coordinates using get_target then assigns the result into the vischar (HL).
Used by the routine at set_hero_route.
Input
HL Points to route.step.
Output
BC Preserved.
set_route A3BB XOR A Clear the entered_move_a_character flag so that the vischar pointed to by IY is used for character events
A3BC LD ($A13E),A
A3BF PUSH BC Preserve for callers
A3C0 PUSH HL Preserve route.step pointer
A3C1 DEC L Point HL at route.index
A3C2 CALL get_target Get our next target: a location, a door or 'route ends'. The result is returned in A, target pointer returned in HL
A3C5 POP DE Restore route.step pointer to DE
A3C6 INC E Point DE at vischar.target
A3C7 LDI Copy target across
A3C9 LDI
A3CB CP $FF Did get_target return get_target_ROUTE_ENDS? ($FF)
A3CD JP NZ,set_route_not_end Jump if not
Result was 'route ends'
A3D0 LD A,E Point DE at the vischar's start
A3D1 SUB $06
A3D3 LD E,A
A3D4 PUSH DE Assign current vischar to IY
A3D5 POP IY
A3D7 EX DE,HL Swap vischar pointer into HL
A3D8 INC L Point HL at route
A3D9 INC L
A3DA CALL get_target_assign_pos Call get_target_assign_pos so that the end-of-route handling code is invoked if required. Note: This seems like something of a waste as get_target is (appears to be) called again with the same arguments as above
A3DD POP BC Restore
A3DE RET Return
Result was a location or a door
set_route_not_end A3DF CP $80 Did get_target return get_target_DOOR? ($80)
A3E1 JP NZ,set_route_exit Jump if not (it must be get_target_LOCATION)
set_route_door A3E4 LD A,E Point DE at vischar.flags
A3E5 SUB $05
A3E7 LD E,A
A3E8 EX DE,HL Swap vischar pointer into HL
A3E9 SET 6,(HL) Set the vischar_FLAGS_TARGET_IS_DOOR flag
set_route_exit A3EB POP BC Restore
A3EC RET Return
Prev: A38C Up: Map Next: A3ED