DE | Destination coordinates |
H | Character number |
1 | Character is ascending staircase |
2 | Character is descending staircase |
3 | Character must go left to reach destination |
4 | Character must go right to reach destination |
11 | Character must go left, and also faces closed door |
12 | Character must go right, and also faces closed door |
25843 | D5 | PUSH DE | |
25844 | CD526E | CALL 28242 | Is the character on a staircase? |
25847 | 300B | JR NC,25860 | Jump if not |
25849 | 2E00 | LD L,0 | NB: A=0 if staircase goes up and to the left, 128 if up and right |
25851 | AE | XOR (HL) | |
25852 | 07 | RLCA | Set carry if character is descending staircase |
25853 | 3E01 | LD A,1 | |
25855 | CE00 | ADC A,0 | A=2 if character is ascending staircase, 1 if descending |
25857 | D1 | POP DE | |
25858 | 37 | SCF | |
25859 | C9 | RET | Return with carry flag set and zero flag reset |
25860 | CDD263 | CALL 25554 | Get play area region identifier for character's current location |
25863 | 6F | LD L,A | |
25864 | D1 | POP DE | |
25865 | CDD263 | CALL 25554 | Get play area region identifier for destination coordinates in DE |
25868 | BD | CP L | |
25869 | 55 | LD D,L | |
25870 | 2E01 | LD L,1 | |
25872 | 2023 | JR NZ,25909 | Jump if the character is not in the same region as his destination |
25874 | 7B | LD A,E | |
25875 | 96 | SUB (HL) | |
25876 | C8 | RET Z | Return with carry flag reset and zero flag set if the character is already at his destination |
25877 | 9F | SBC A,A | |
25878 | C604 | ADD A,4 | A=4 if character must go right, 3 if left to reach destination |
25880 | F5 | PUSH AF | |
25881 | 2E00 | LD L,0 | |
25883 | 0F | RRCA | |
25884 | AE | XOR (HL) | |
25885 | 07 | RLCA | |
25886 | 3803 | JR C,25891 | Jump if the character is facing right way to reach destination |
25888 | F1 | POP AF | |
25889 | A7 | AND A | |
25890 | C9 | RET | Return with carry flag reset and zero flag reset |
25891 | CD5F70 | CALL 28767 | Check for closed doors in front of the character |
25894 | 30F8 | JR NC,25888 | Jump if there are none |
25896 | 7C | LD A,H | A=character number |
25897 | FED2 | CP 210 | Is this ERIC? |
25899 | 2004 | JR NZ,25905 | Jump if not |
25901 | F1 | POP AF | |
25902 | EE07 | XOR 7 | 3 (go left) becomes 4 (go right) and vice versa for ERIC |
25904 | C9 | RET | Return with carry and zero flags reset and C holding door identifier |
25905 | F1 | POP AF | |
25906 | C608 | ADD A,8 | Set bit 3 (A=11, 12): closed door ahead |
25908 | C9 | RET | Return with carry and zero flags reset |
25909 | D681 | SUB 129 | |
25911 | 5F | LD E,A | |
25912 | 1A | LD A,(DE) | A=top or bottom of staircase identifier (see 25700) |
25913 | 57 | LD D,A | |
25914 | 1E44 | LD E,68 | |
25916 | 1A | LD A,(DE) | A=x-coordinate of top or bottom of staircase character will have to go to first in order to reach destination |
25917 | BE | CP (HL) | Is the character standing at this staircase already? |
25918 | 20D3 | JR NZ,25875 | Jump if not |
25920 | 1C | INC E | |
25921 | 2D | DEC L | |
25922 | 1A | LD A,(DE) | A=0 if character must face left to negotiate stairs, 128 if right |
25923 | AE | XOR (HL) | |
25924 | 07 | RLCA | |
25925 | 3007 | JR NC,25934 | Jump if the character is facing the right way to negotiate stairs |
25927 | 7E | LD A,(HL) | A=character's animatory state |
25928 | 07 | RLCA | |
25929 | 9F | SBC A,A | |
25930 | C604 | ADD A,4 | A=4 if character's facing left, 3 if right |
25932 | A7 | AND A | |
25933 | C9 | RET | Return with carry and zero flags reset |
25934 | 1C | INC E | |
25935 | 1A | LD A,(DE) | A=LSB of routine to make character ascend or descend stairs |
25936 | E601 | AND 1 | |
25938 | 3C | INC A | A=1 if character must ascend stairs, 2 if descend |
25939 | C9 | RET | Return with carry and zero flags reset |