Prev: F5FB Up: Map Next: F686
F600: Make a character go to a location
Used by many command lists to make a character go to a specified place.
Input
H Character number (0xD7-0xE5)
F600 CALL $7CC8 Collect the destination coordinates from the command list
F603 JR $F616
This entry point is used by the command lists at 61EA, FCF4, FD16, FD30, FD4E, FD6E and FD86 to make a character carry Sam to a location.
F605 CALL $7CC8 Collect the destination coordinates from the command list
F608 LD (HL),$0A Change the address of the primary command routine in bytes 0x08 and 0x09 of the character's buffer to F60A (below)
F60A CALL $F698 Exit now if the character is midstride
F60D CALL $ED8C Determine the next move the character should make to reach his destination
F610 AND A Has the character reached his destination?
F611 JR Z,$F61F Move to the next command in the command list if so
F613 JP $7327 Move the character one step towards his destination
The character is not carrying Sam.
F616 LD (HL),$18 Change the address of the primary command routine in bytes 0x08 and 0x09 of the character's buffer to F618 (below)
F618 CALL $F698 Exit now if the character is midstride
F61B CALL $ED8C Determine the next move the character should make to reach his destination
F61E AND A Has the character reached his destination?
F61F JP Z,$F280 Move to the next command in the command list if so
F622 CP $05 Is the character standing next to a closed door?
F624 JR NC,$F67C Jump if so
F626 PUSH AF Save the direction indicator
F627 LD BC,$F5CE Point BC at the interruptible subcommand routine at F5CE
F62A LD L,$0D Pick up the location/destination indicator from byte 0x0D of the character's buffer
F62C LD A,(HL)
F62D AND A Is the character on the sidewalk or the road (or on the front steps of the hotel but heading somewhere other than the hotel)?
F62E JR NZ,$F64B Jump if not
F630 LD BC,$F5FB Point BC at the interruptible subcommand routine at F5FB
F633 LD L,$10 Place the x- or y-coordinate of the character's intermediate destination into byte 0x10 of his buffer
F635 LD (HL),E
F636 LD L,$0F Copy the interruptible subcommand routine address in BC (F5AC, F5CE or F5FB) into bytes 0x0E and 0x0F of the character's buffer
F638 LD (HL),B
F639 DEC L
F63A LD (HL),C
F63B POP AF Restore the direction indicator (1-4) to A
This entry point is used by the routines at 72B1 and 7A82.
F63C DEC A Does the character need to move right next to reach his destination?
F63D JP Z,$EBAE Jump if so
F640 DEC A Does the character need to move left?
F641 JP Z,$EBBB Jump if so
F644 DEC A Does the character need to move up?
F645 JP Z,$EB9B Jump if so
F648 JP $EBA0 Make the character move down
The character is not on the sidewalk or road.
F64B DEC A Is the character's destination in a region other than the one he's in at the moment?
F64C JR NZ,$F66B Jump if so
F64E LD L,$02 Collect the character's y-coordinate from byte 0x02 of his buffer
F650 LD A,(HL)
F651 CP $1F Is the character on or below the level of the first floor?
F653 JR NC,$F662 Jump if so
F655 LD L,$0A Point HL at byte 0x0A of the character's buffer
F657 LD E,(HL) E=character's destination x-coordinate
F658 INC L L=0x0B
F659 CP (HL) Is the character's y-coordinate the same as that of his destination?
F65A JR Z,$F633 If so, send the character to his destination x-coordinate (on the same floor)
F65C LD E,(HL) E=character's destination y-coordinate
F65D LD BC,$F5AC Point BC at the interruptible subcommand routine at F5AC
F660 JR $F633 Send the character up or down the stairs towards his destination
The character is in the same region as his destination, and on or below the level of the first floor.
F662 LD L,$04 Byte 0x04 of the character's buffer holds his z-coordinate
F664 BIT 0,(HL) Is the character indoors (z=1)?
F666 CALL NZ,$F485 If so, make him consider flipping a light switch
F669 JR $F63B Move the character one step closer to his destination
The character's destination is in a region other than the one he's in at the moment.
F66B LD L,$02 Collect the character's y-coordinate from byte 0x02 of his buffer
F66D LD A,(HL)
F66E LD E,$1F This is the y-coordinate of the first floor
F670 CP E Is the character above the first floor?
F671 JR C,$F65D Jump if so to send him down to the first floor
F673 LD L,$04 Byte 0x04 of the character's buffer holds his z-coordinate
F675 BIT 0,(HL) Is the character indoors (z=1)?
F677 CALL NZ,$F5A0 If so, make him consider flipping a light switch off before leaving
F67A JR $F63B Move the character one step closer to his destination
The character is standing next to a closed door. This entry point is used by the routines at 72B1 and 7A82.
F67C JP Z,$F32C Jump if the character is standing behind a closed door
F67F LD L,$0F Prepare the MSB of the address of the interruptible subcommand routine at F346 in byte 0x0F of the character's buffer
F681 LD (HL),$F3
F683 JP $F338 Prepare the LSB and raise the character's arm
Prev: F5FB Up: Map Next: F686