Routines |
Prev: A3F8 | Up: Map | Next: A420 |
This is the common tail of the previous two routines. It uses the character index (in A) to assign a "walk to bed" route to the specified character.
Used by the routines at character_bed_state and character_bed_vischar.
|
||||||||||
character_bed_common | A404 | INC HL | Clear route's step | |||||||
A405 | LD (HL),$00 | |||||||||
A407 | CP $13 | Is the character a hostile? (its index less than or equal to character_19_GUARD_DOG_4) | ||||||||
A409 | JP Z,character_bed_hostile | Jump to hostile handling if so | ||||||||
A40C | JP C,character_bed_hostile | |||||||||
A40F | SUB $0D | Compute the route index by subtracting 13 from the character index, e.g. character 20 is assigned route 7 | ||||||||
A411 | JR character_bed_common_0 | Jump to end part | ||||||||
character_bed_hostile | A413 | BIT 0,A | Does this hostile have an odd numbered character index? | |||||||
A415 | LD A,$0D | Set the default route index to 13 | ||||||||
A417 | JR Z,character_bed_common_0 | Jump to exit if it had an even numbered character index | ||||||||
A419 | LD (HL),$01 | Otherwise reverse its route by setting the route step to 1 and setting the reversed route flag | ||||||||
A41B | OR $80 | |||||||||
character_bed_common_0 | A41D | DEC HL | Save route index | |||||||
A41E | LD (HL),A | |||||||||
A41F | RET | Return |
Prev: A3F8 | Up: Map | Next: A420 |