Prev: A373 Up: Map Next: A3BB
A38C: Set character route
This finds the charstruct, or vischar, of the specified character index (A) and stores the route (A',C) in it.
Input
A Character index.
A' Route index.
C Route step.
Output
BC Preserved.
set_character_route A38C CALL get_character_struct Get a pointer to the character struct in HL for character index A
A38F BIT 6,(HL) Is the character on-screen? characterstruct_FLAG_ON_SCREEN
A391 JP Z,set_character_struct_route It's not - jump to characterstruct setting code
set_vischar_route A394 PUSH BC Save route step
A395 LD A,(HL) A = *HL & characterstruct_CHARACTER_MASK;
A396 AND $1F
Search non-player characters to see if this character is already on-screen.
A398 LD B,$07 There are seven non-player vischars
A39A LD DE,$0020 Prepare the vischar stride
A39D LD HL,$8020 Point HL at the second visible character
Start loop
set_character_route_0 A3A0 CP (HL) Is this the character we want?
A3A1 JR Z,set_character_route_vischar_found Jump if so
A3A3 ADD HL,DE Advance the vischar pointer
A3A4 DJNZ set_character_route_0 ...loop
A3A6 POP BC Restore
A3A7 JR set_character_route_exit Jump to exit (note: why not just RET here?)
A3A9 DEFB $19 Unreferenced byte
set_character_struct_route A3AA INC HL Advance HL to point to the characterstruct's route
A3AB INC HL
A3AC INC HL
A3AD INC HL
A3AE INC HL
A3AF CALL store_route Store the route at HL
set_character_route_exit A3B2 RET Return
set_character_route_vischar_found A3B3 POP BC Restore route step
A3B4 INC L Reset vischar_FLAGS_TARGET_IS_DOOR flag
A3B5 RES 6,(HL)
A3B7 INC L
A3B8 CALL store_route Store the route at HL
FALL THROUGH into set_route.
Prev: A373 Up: Map Next: A3BB