![]() |
Routines |
| 0 | Character is at the destination | 1 | Character is ascending (or about to ascend) a staircase | 2 | Character is descending (or about to descend) a staircase | 3 | Character must go left to reach destination | 4 | Character must go right to reach destination |
| DE | Destination coordinates |
| H | Character number |
| 25843 | PUSH DE | Save the destination coordinates temporarily |
| 25844 | CALL 28242 | Is the character on a staircase? |
| 25847 | JR NC,25860 | Jump if not |
| 25849 | LD L,0 | Point HL at byte 0 of the character's buffer |
| 25851 | XOR (HL) | Compare the staircase's direction with the character's |
| 25852 | RLCA | Set the carry flag if the character is descending the staircase |
| 25853 | LD A,1 | A=1 if the character is ascending the staircase, 2 if descending |
| 25855 | ADC A,0 | |
| 25857 | POP DE | Restore the destination coordinates to DE |
| 25858 | SCF | Signal: character is on a staircase |
| 25859 | RET |
| 25860 | CALL 25554 | Get the region identifier for the character's current location |
| 25863 | LD L,A | Copy this to L |
| 25864 | POP DE | Restore the destination coordinates to DE |
| 25865 | CALL 25554 | Get the region identifier for the destination coordinates |
| 25868 | CP L | Compare current and destination regions |
| 25869 | LD D,L | D=region ID for the character's current location |
| 25870 | LD L,1 | Point HL at byte 1 of the character's buffer |
| 25872 | JR NZ,25909 | Jump if the character is not in the same region as his destination |
| 25874 | LD A,E | A=destination x-coordinate |
| 25875 | SUB (HL) | Is the character already at his destination? |
| 25876 | RET Z | Return if so (with the carry flag reset) |
| 25877 | SBC A,A | A=3 if the character must go left, 4 if right to reach the destination |
| 25878 | ADD A,4 | |
| 25880 | PUSH AF | Save this value briefly |
| 25881 | LD L,0 | Point HL at byte 0 of the character's buffer |
| 25883 | RRCA | Set bit 7 of A if the character is facing the right way to reach his destination |
| 25884 | XOR (HL) | |
| 25885 | RLCA | Push bit 7 of A into the carry flag |
| 25886 | JR C,25891 | Jump if the character is facing the right way to reach his destination |
| 25888 | POP AF | A=3 (go left) or 4 (go right) |
| 25889 | AND A | Clear the carry flag (character is not on a staircase) |
| 25890 | RET |
| 25891 | CALL 28767 | Check for closed doors in front of the character |
| 25894 | JR NC,25888 | Jump if there are none |
| 25896 | LD A,H | A=character number |
| 25897 | CP 210 | Is this ERIC (in demo mode)? |
| 25899 | JR NZ,25905 | Jump if not |
| 25901 | POP AF | A=3 (go left) or 4 (go right) |
| 25902 | XOR 7 | 3 (go left) becomes 4 (go right) and vice versa for ERIC |
| 25904 | RET | Return with the carry flag reset and C holding the door identifier |
| 25905 | POP AF | A=3 (go left) or 4 (go right) |
| 25906 | ADD A,8 | Set bit 3 (A=11, 12): closed door ahead |
| 25908 | RET | Return with the carry flag reset and C holding the door identifier |
| 25909 | SUB 129 | A=identifier for the top or bottom of the staircase (see 25700) |
| 25911 | LD E,A | |
| 25912 | LD A,(DE) | |
| 25913 | LD D,A | A=x-coordinate of the top or bottom of the staircase the character will have to go to first in order to reach his destination |
| 25914 | LD E,68 | |
| 25916 | LD A,(DE) | |
| 25917 | CP (HL) | Is the character standing at this staircase already? |
| 25918 | JR NZ,25875 | Jump if not |
| 25920 | INC E | Point DE at the staircase direction indicator |
| 25921 | DEC L | Point HL at byte 0 of the character's buffer |
| 25922 | LD A,(DE) | A=0 if the character must face left to negotiate the stairs, 128 (bit 7 set) if right |
| 25923 | XOR (HL) | Set the carry flag if the character is facing the wrong way |
| 25924 | RLCA | |
| 25925 | JR NC,25934 | Jump if the character is facing the right way to negotiate the stairs |
| 25927 | LD A,(HL) | A=character's animatory state |
| 25928 | RLCA | A=3 if the character's facing right, 4 if facing left |
| 25929 | SBC A,A | |
| 25930 | ADD A,4 | |
| 25932 | AND A | Clear the carry flag (character is not on a staircase) |
| 25933 | RET |
| 25934 | INC E | A=LSB of the routine to make the character ascend (56/25656) or descend (77/25677) the stairs |
| 25935 | LD A,(DE) | |
| 25936 | AND 1 | A=1 if the character must ascend the stairs, 2 if descend |
| 25938 | INC A | |
| 25939 | RET | Return with the carry flag reset |