![]() |
Routines |
| Prev: CB23 | Up: Map | Next: CB61 |
|
This is called when get_target has run out of targets on the current route.
Used by the routine at spawn_character.
|
||||
|
If not the hero's vischar ...
|
||||
| route_ended | CB2D | LD A,L | Is this the hero's vischar? | |
| CB2E | CP $02 | |||
| CB30 | JP Z,do_character_event | Jump if so | ||
|
Non-player ...
|
||||
| CB33 | LD A,(IY+$00) | Load vischar.character | ||
| CB36 | AND $1F | Mask with vischar_CHARACTER_MASK to get character index | ||
| CB38 | JR NZ,route_ended_0 | Jump if not character_0_COMMANDANT | ||
|
Call character_event at the end of commandant route 36.
|
||||
| CB3A | LD A,(HL) | Fetch route.index | ||
| CB3B | AND $7F | Mask off routeindexflag_REVERSED | ||
| CB3D | CP $24 | Is it routeindex_36_GO_TO_SOLITARY? | ||
| CB3F | JR Z,do_character_event | Jump if so | ||
| CB41 | XOR A | Force next if statement to be taken | ||
|
Reverse the route for guards 1..11. They have fixed roles so either stand still or march back and forth along their route.
|
||||
| route_ended_0 | CB42 | CP $0C | Is the character index <= character_11_GUARD_11? | |
| CB44 | JR C,reverse_route | Jump if so | ||
|
We arrive here if: - vischar is the hero, or - character is character_0_COMMANDANT and (route.index & $7F) == 36, or - character is >= character_12_GUARD_12
|
||||
| do_character_event | CB46 | PUSH HL | ||
| CB47 | CALL character_event | character_event() | ||
| CB4A | POP HL | |||
| CB4B | LD A,(HL) | Fetch route.index | ||
| CB4C | AND A | Is it routeindex_0_HALT? | ||
| CB4D | RET Z | Return 0 if so | ||
| CB4E | JR get_target_assign_pos | Otherwise exit via get_target_assign_pos() // re-enters/loops? | ||
|
We arrive here if: - vischar is not the hero, and - character is character_0_COMMANDANT and (route.index & $7F) != 36, or - character is character_1_GUARD_1 .. character_11_GUARD_11
|
||||
| reverse_route | CB50 | LD A,(HL) | Toggle route direction flag routeindexflag_REVERSED ($80) | |
| CB51 | XOR $80 | |||
| CB53 | LD (HL),A | |||
| CB54 | INC HL | |||
|
Pattern: [-2]+1
|
||||
| CB55 | BIT 7,A | If the route is reversed then step backwards, otherwise forwards | ||
| CB57 | JR Z,route_ended_1 | |||
| CB59 | DEC (HL) | |||
| CB5A | DEC (HL) | |||
| route_ended_1 | CB5B | INC (HL) | ||
| CB5C | DEC HL | |||
| CB5D | XOR A | Return 0 | ||
| CB5E | RET | |||
| CB5F | DEFB $18,$09 | Unreferenced bytes | ||
| Prev: CB23 | Up: Map | Next: CB61 |