Routines |
Prev: 25940 | Up: Map | Next: 26062 |
|
||||||||
25944 | LD L,0 | Point HL at byte 0 of the character's buffer | ||||||
25946 | BIT 0,(HL) | Is the teacher midstride? | ||||||
25948 | JR Z,25963 | Jump if not | ||||||
This entry point is used by the routines at 32379, 61595 and 62794 to make the teacher who his chasing ERIC finish his stride.
|
||||||||
25950 | CALL 25012 | Update the SRB for the teacher's current animatory state and location | ||||||
25953 | LD B,A | Save the animatory state in B temporarily | ||||||
25954 | LD L,15 | Byte 15 holds the y-coordinate adjustment to make as the teacher finishes this stride: 0 normally, 1 if descending a staircase (see later in this routine) | ||||||
25956 | LD A,(HL) | |||||||
25957 | ADD A,D | Make the appropriate y-coordinate adjustment | ||||||
25958 | LD D,A | |||||||
25959 | LD A,B | Restore the animatory state to A | ||||||
25960 | JP 25600 | Make the teacher finish his stride | ||||||
The teacher is not midstride. Is he close enough to ERIC to stop the chase?
|
||||||||
25963 | CALL 28242 | Is the teacher on a staircase? | ||||||
25966 | JR C,26007 | Jump if so | ||||||
25968 | LD DE,(53761) | Pick up ERIC's coordinates in DE | ||||||
25972 | LD L,0 | Byte 0 holds the teacher's animatory state | ||||||
25974 | BIT 7,(HL) | Is the teacher facing left? | ||||||
25976 | LD L,1 | |||||||
25978 | JR Z,25984 | Jump if so | ||||||
25980 | LD A,E | A=ERIC's x-coordinate | ||||||
25981 | SUB (HL) | Subtract that of the teacher | ||||||
25982 | JR 25986 | |||||||
25984 | LD A,(HL) | A=teacher's x-coordinate | ||||||
25985 | SUB E | Subtract that of ERIC | ||||||
25986 | CP 4 | Is ERIC less than 4 horizontal spaces in front of the teacher? | ||||||
25988 | JR NC,26004 | Jump if not | ||||||
25990 | INC L | L=2 | ||||||
25991 | LD A,(HL) | A=teacher's y-coordinate | ||||||
25992 | SUB 4 | |||||||
25994 | JR C,25999 | Jump if the teacher's on the top floor | ||||||
25996 | CP D | Is ERIC at least 4 vertical spaces above the teacher? | ||||||
25997 | JR NC,26004 | Jump if so | ||||||
25999 | ADD A,7 | Set the carry flag if ERIC is at least 4 vertical spaces below the teacher | ||||||
26001 | CP D | |||||||
26002 | CCF | Return if ERIC is within 3 vertical spaces either side of the teacher | ||||||
26003 | RET C | |||||||
The teacher is not close enough to ERIC yet to stop chasing him. Now to figure out the teacher's next move.
|
||||||||
26004 | CALL 25534 | D=ERIC's y-coordinate (or the y-coordinate of the floor he's closest to if his feet are not on the floor) | ||||||
26007 | CALL 25843 | Work out how the teacher can reach ERIC from here | ||||||
26010 | BIT 3,A | Is there a closed door in the way? | ||||||
26012 | JP NZ,28834 | Open it if so | ||||||
There is no closed door in the way. Is the teacher on a staircase?
|
||||||||
26015 | LD BC,0 | Initialise the staircase indicator to 0 | ||||||
26018 | CP 2 | Is the teacher descending a staircase? | ||||||
26020 | JR NZ,26023 | Jump if not | ||||||
26022 | INC B | B=1 (teacher is descending a staircase) | ||||||
26023 | JR NC,26026 | Jump if the teacher is not ascending a staircase | ||||||
26025 | DEC C | C=-1 (teacher is ascending a staircase) | ||||||
26026 | CP 3 | Is the teacher on a staircase? | ||||||
26028 | JR C,26045 | Jump if so | ||||||
26030 | LD L,0 | Byte 0 holds the teacher's animatory state | ||||||
26032 | CP 4 | Set the carry flag if the teacher should go left | ||||||
26034 | BIT 7,(HL) | Set the zero flag if the teacher is facing left | ||||||
26036 | JR C,26043 | Jump if the teacher must go left to reach ERIC | ||||||
26038 | JR NZ,26045 | Jump if the teacher is facing right | ||||||
26040 | JP 25648 | Turn the teacher round | ||||||
26043 | JR NZ,26040 | Turn the teacher round if he's facing right | ||||||
Now BC is still 0 if the teacher is not on a staircase. Otherwise, B=1 and C=0 if he's descending a staircase, or B=0 and C=-1 if he's ascending a staircase. The value in B is the y-coordinate adjustment to make when the teacher finishes this stride later, and the value in C is the y-coordinate adjustment to make as he goes midstride now.
|
||||||||
26045 | LD L,15 | Set byte 15 of teacher's buffer to 1 if the teacher is descending a staircase, or 0 if he's ascending a staircase or not on one | ||||||
26047 | LD (HL),B | |||||||
26048 | PUSH BC | |||||||
26049 | CALL 25012 | Update the SRB for the teacher's current animatory state and location | ||||||
26052 | POP BC | |||||||
26053 | BIT 0,C | Is the teacher ascending a staircase? | ||||||
26055 | JR Z,26058 | Jump if not | ||||||
26057 | DEC D | Up a stair as the teacher goes midstride | ||||||
26058 | INC A | One foot forward (midstride) | ||||||
26059 | JP 24880 | Update the teacher's animatory state and location and update the SRB |
Prev: 25940 | Up: Map | Next: 26062 |