Routines |
Prev: F78D | Up: Map | Next: F7DA |
|
||||||||
F78E | LD A,$FF | Adjust the length of the lesson to allow the character enough time to find ERIC | ||||||
F790 | CALL $FA04 | |||||||
This routine places F79E into bytes 0x6F and 0x70 of the character's buffer, but also uses byte 0x69 (which normally holds the LSB of a routine address) for coordination. When byte 0x69 holds 0xA0 (the LSB of the routine at 7BA0), ERIC's coordinates are compared with those of the character looking for him, and the decision is made whether to keep moving. If the character does need to keep moving, 7BDF is called, which either (a) turns the character round, or (b) puts the character midstride, and places 0xFB (the LSB of the routine at 7BFB) into byte 0x69. When byte 0x69 holds 0xFB, this routine jumps to 7BFB to move the character from the midstride position, and set byte 0x69 back to 0xA0.
|
||||||||
F793 | LD L,$69 | Initialise byte 0x69 to 0xA0, so on this first pass we compare ERIC's location with that of his chaser | ||||||
F795 | LD (HL),$A0 | |||||||
F797 | LD L,$6F | Place F79E into bytes 0x6F and 0x70 of the character's buffer (thus setting the character's uninterruptible subcommand) | ||||||
F799 | LD (HL),$9E | |||||||
F79B | INC L | |||||||
F79C | LD (HL),$F7 | |||||||
Subsequent calls to this routine will enter at this point, by virtue of its address being placed into bytes 0x6F and 0x70 of the character's buffer.
|
||||||||
F79E | LD A,H | A=number of the character looking for ERIC | ||||||
F79F | CP $A3 | Is MR WACKER looking for ERIC? | ||||||
F7A1 | CALL Z,$7DEA | If so, make him walk fast | ||||||
F7A4 | LD L,$69 | Is the character midstride? | ||||||
F7A6 | LD A,(HL) | |||||||
F7A7 | CP $FB | |||||||
F7A9 | JP Z,$7BFB | Finish the stride if so | ||||||
The character looking for ERIC is not midstride at the moment. Decide which way (if any) he should go to find ERIC.
|
||||||||
F7AC | CALL $79FD | Get ERIC's coordinates in DE | ||||||
F7AF | LD L,$61 | Byte 0x61 of the character's buffer holds his y-coordinate | ||||||
F7B1 | LD A,(HL) | Pick this up in A | ||||||
F7B2 | CP D | Set the zero flag if ERIC is on same floor | ||||||
F7B3 | CALL $F9E5 | Compare this character's coordinates with ERIC's | ||||||
F7B6 | JR NZ,$F7D4 | Jump if this character is on a staircase or more than 3 y-coordinates away from ERIC | ||||||
F7B8 | INC L | L=0x62 | ||||||
F7B9 | LD A,(HL) | A=character's x-coordinate | ||||||
F7BA | SUB E | Does it match ERIC's x-coordinate? | ||||||
F7BB | JR NZ,$F7CC | Jump if not | ||||||
The character looking for ERIC is within 3 x-coordinates and 3 y-coordinates of ERIC's location, and is not on a staircase. In other words, ERIC has been found.
|
||||||||
F7BD | LD A,($7FFB) | Check ERIC's status flags at 7FFB, and return if ERIC is firing, hitting, jumping, being spoken to by a little boy, knocked out, or writing on a blackboard | ||||||
F7C0 | AND $7F | |||||||
F7C2 | RET NZ | |||||||
F7C3 | LD L,$70 | Remove the address of the entry point at F79E from bytes 0x6F and 0x70 of the character's buffer | ||||||
F7C5 | LD (HL),A | |||||||
F7C6 | LD L,$6A | Remove any interruptible subcommand routine address from bytes 0x69 and 0x6A of the character's buffer | ||||||
F7C8 | LD (HL),A | |||||||
F7C9 | JP $62A8 | Move to the next command in the command list | ||||||
The character looking for ERIC is within 3 y-coordinates of ERIC's location, but not at the same x-coordinate. Is he close enough, though?
|
||||||||
F7CC | JR NC,$F7D0 | Jump if the character is to the right of ERIC | ||||||
F7CE | NEG | Get the absolute x-coordinate distance between the character and ERIC | ||||||
F7D0 | CP $04 | Is ERIC less than 4 x-coordinates away? | ||||||
F7D2 | JR C,$F7BD | Jump if so (that's close enough) | ||||||
The character has not yet found ERIC.
|
||||||||
F7D4 | CALL $7ADC | Determine this character's next move | ||||||
F7D7 | JP $7BDF | Set him off in the appropriate direction |
Prev: F78D | Up: Map | Next: F7DA |