![]() |
Routines |
Prev: 7AD7 | Up: Map |
Used by the routines at 7BA0, F5DA and F78E. Returns with one of the following values in A depending on the relative locations of the follower and his target:
|
||||||||||||||||||||||||
7ADC | LD L,$61 | Byte 0x61 of the follower's buffer holds his y-coordinate | ||||||||||||||||||||||
7ADE | LD A,(HL) | Pick this up in A | ||||||||||||||||||||||
7ADF | CP $9B | Is the follower on the top floor? | ||||||||||||||||||||||
7AE1 | JR Z,$7AF8 | Jump if so | ||||||||||||||||||||||
7AE3 | CP $A2 | Is the follower on the middle floor? | ||||||||||||||||||||||
7AE5 | JR Z,$7AF8 | Jump if so | ||||||||||||||||||||||
7AE7 | CP $A9 | Is the follower on the bottom floor? | ||||||||||||||||||||||
7AE9 | JR Z,$7AF8 | Jump if so | ||||||||||||||||||||||
The follower is on a staircase. Find out whether he's going up or down and set A accordingly to make him continue.
|
||||||||||||||||||||||||
7AEB | LD L,$62 | Byte 0x62 of the follower's buffer holds his x-coordinate | ||||||||||||||||||||||
7AED | LD A,(HL) | Pick this up in A | ||||||||||||||||||||||
7AEE | LD L,$60 | Byte 0x60 holds the follower's animatory state | ||||||||||||||||||||||
7AF0 | ADD A,$50 | Set bit 7 of A if the follower is on a staircase at the right of the skool | ||||||||||||||||||||||
7AF2 | XOR (HL) | A=1 if the follower is going upstairs, 2 if he's going downstairs | ||||||||||||||||||||||
7AF3 | AND $80 | |||||||||||||||||||||||
7AF5 | RLCA | |||||||||||||||||||||||
7AF6 | INC A | |||||||||||||||||||||||
7AF7 | RET | |||||||||||||||||||||||
The follower is not on a staircase. Which way should he go?
|
||||||||||||||||||||||||
7AF8 | CP D | Is the follower on the same floor as the target? | ||||||||||||||||||||||
7AF9 | JR NZ,$7B3D | Jump if not | ||||||||||||||||||||||
The follower is on the same floor as the target. However, there may be a wall between them.
|
||||||||||||||||||||||||
7AFB | INC L | Pick up the follower's x-coordinate in A | ||||||||||||||||||||||
7AFC | LD A,(HL) | |||||||||||||||||||||||
7AFD | SUB E | Is the follower in the same spot as his target? | ||||||||||||||||||||||
7AFE | RET Z | Return if so | ||||||||||||||||||||||
7AFF | DEC L | Pick up the follower's y-coordinate in A | ||||||||||||||||||||||
7B00 | LD A,(HL) | |||||||||||||||||||||||
7B01 | CP $A9 | Is the follower on the bottom floor? | ||||||||||||||||||||||
7B03 | JR NZ,$7B0D | Jump if not | ||||||||||||||||||||||
The follower and target are both on the bottom floor, so the follower should simply move either left or right.
|
||||||||||||||||||||||||
7B05 | INC HL | L=0x62 | ||||||||||||||||||||||
7B06 | LD A,(HL) | A=follower's x-coordinate | ||||||||||||||||||||||
7B07 | CP E | Set the carry flag if the follower should go right | ||||||||||||||||||||||
7B08 | LD A,$03 | A=3 if the follower should go left, 4 if he should go right | ||||||||||||||||||||||
7B0A | ADC A,$00 | |||||||||||||||||||||||
7B0C | RET | |||||||||||||||||||||||
The follower and target are both on the middle floor or both on the top floor.
|
||||||||||||||||||||||||
7B0D | CP $A2 | Set the zero flag if the follower and target are on the middle floor | ||||||||||||||||||||||
7B0F | INC HL | L=0x62 | ||||||||||||||||||||||
7B10 | LD A,$39 | This is the x-coordinate of the wall between the Reading and Map Rooms | ||||||||||||||||||||||
7B12 | JR NZ,$7B16 | Jump if the follower and target are on the top floor | ||||||||||||||||||||||
7B14 | LD A,$26 | This is the x-coordinate of the wall between the White and Exam Rooms | ||||||||||||||||||||||
7B16 | CP (HL) | Compare the follower's x-coordinate with that of the wall | ||||||||||||||||||||||
7B17 | JR C,$7B2B | Jump if the follower is to the right of the wall | ||||||||||||||||||||||
7B19 | CP E | Is the target character to the left of the wall? | ||||||||||||||||||||||
7B1A | JR NC,$7B06 | Jump if so | ||||||||||||||||||||||
The follower is on the left side of the skool and must go downstairs to get to the target on the other side of the skool.
|
||||||||||||||||||||||||
7B1C | LD A,(HL) | A=follower's x-coordinate | ||||||||||||||||||||||
7B1D | CP $0C | This is the x-coordinate of the tops of the staircases at the left of the skool | ||||||||||||||||||||||
7B1F | JR NZ,$7B08 | Jump unless the follower is at the top of a staircase | ||||||||||||||||||||||
7B21 | LD L,$60 | Byte 0x60 of the follower's buffer holds his animatory state | ||||||||||||||||||||||
7B23 | LD A,$04 | A=4 will make the follower turn round if facing left | ||||||||||||||||||||||
7B25 | BIT 7,(HL) | Is the follower facing left? | ||||||||||||||||||||||
7B27 | RET Z | Return if so | ||||||||||||||||||||||
7B28 | LD A,$02 | A=2 will make the follower go down the stairs | ||||||||||||||||||||||
7B2A | RET | |||||||||||||||||||||||
The follower is on the right side of the skool. Is the target there too?
|
||||||||||||||||||||||||
7B2B | CP E | Is the target character to the right of the wall? | ||||||||||||||||||||||
7B2C | JR C,$7B06 | Jump if so | ||||||||||||||||||||||
7B2E | LD A,(HL) | A=follower's x-coordinate | ||||||||||||||||||||||
7B2F | CP $4D | This is the x-coordinate of the tops of the staircases at the right of the skool | ||||||||||||||||||||||
7B31 | JR NZ,$7B08 | Jump unless the follower is at the top of a staircase | ||||||||||||||||||||||
7B33 | LD L,$60 | Byte 0x60 of the follower's buffer holds his animatory state | ||||||||||||||||||||||
7B35 | LD A,$03 | A=3 will make the follower turn round if facing right | ||||||||||||||||||||||
7B37 | BIT 7,(HL) | Is the follower facing right? | ||||||||||||||||||||||
7B39 | RET NZ | Return if so | ||||||||||||||||||||||
7B3A | LD A,$02 | A=2 will make the follower go down the stairs | ||||||||||||||||||||||
7B3C | RET | |||||||||||||||||||||||
The follower and target are on different floors.
|
||||||||||||||||||||||||
7B3D | JR NC,$7B4D | Jump if the target is on a floor above the follower | ||||||||||||||||||||||
7B3F | CP $A2 | Set the zero flag if the follower is on the middle floor | ||||||||||||||||||||||
7B41 | INC HL | L=0x62 | ||||||||||||||||||||||
7B42 | LD A,$39 | This is the x-coordinate of the wall between the Reading and Map Rooms | ||||||||||||||||||||||
7B44 | JR NZ,$7B48 | Jump if the follower is on the top floor | ||||||||||||||||||||||
7B46 | LD A,$26 | This is the x-coordinate of the wall between the White and Exam Rooms | ||||||||||||||||||||||
7B48 | CP (HL) | Compare the follower's x-coordinate with that of the wall | ||||||||||||||||||||||
7B49 | JR NC,$7B1C | Jump if the follower is to the left of the wall (and so needs to go to the top of a staircase on the left) | ||||||||||||||||||||||
7B4B | JR C,$7B2E | Jump if the follower is to the right of the wall (and so needs to go to the top of a staircase on the right) | ||||||||||||||||||||||
The target is on a floor above the follower. Which staircase should the follower use?
|
||||||||||||||||||||||||
7B4D | LD A,D | A=target's y-coordinate | ||||||||||||||||||||||
7B4E | LD D,$9B | This is the y-coordinate of the top floor | ||||||||||||||||||||||
7B50 | CP $A2 | This is the y-coordinate of the middle floor | ||||||||||||||||||||||
7B52 | LD A,$39 | This is the x-coordinate of the wall between the Reading and Map Rooms | ||||||||||||||||||||||
7B54 | JR C,$7B5A | Jump if the target is above the middle floor | ||||||||||||||||||||||
7B56 | LD D,$A2 | This is the y-coordinate of the middle floor | ||||||||||||||||||||||
7B58 | LD A,$26 | This is the x-coordinate of the wall between the White and Exam Rooms | ||||||||||||||||||||||
7B5A | CP E | Compare the target's x-coordinate with that of the wall | ||||||||||||||||||||||
7B5B | LD E,$61 | Signal: target is to the right of the wall | ||||||||||||||||||||||
7B5D | JR C,$7B61 | Jump if the target is to the right of the wall | ||||||||||||||||||||||
7B5F | LD E,$01 | Signal: target is to the left of the wall | ||||||||||||||||||||||
7B61 | LD A,(HL) | A=follower's y-coordinate | ||||||||||||||||||||||
7B62 | CP $A9 | Set the zero flag if the follower is on the bottom floor | ||||||||||||||||||||||
7B64 | INC HL | L=0x62 | ||||||||||||||||||||||
7B65 | JR NZ,$7B86 | Jump if the follower is on the middle floor | ||||||||||||||||||||||
7B67 | LD A,$13 | This is the x-coordinate of the bottoms of the staircases at the left of the skool | ||||||||||||||||||||||
7B69 | DEC E | Is the target to the left of the wall? | ||||||||||||||||||||||
7B6A | JR Z,$7B6E | Jump if so | ||||||||||||||||||||||
7B6C | LD A,$46 | This is the x-coordinate of the bottoms of the staircases at the right of the skool | ||||||||||||||||||||||
7B6E | CP (HL) | Compare this with the follower's x-coordinate | ||||||||||||||||||||||
7B6F | CCF | Set the carry flag if the follower should go right | ||||||||||||||||||||||
7B70 | JR NZ,$7B08 | Jump if the follower is not at the bottom of a staircase | ||||||||||||||||||||||
7B72 | LD L,$60 | Byte 0x60 of the follower's buffer holds his animatory state | ||||||||||||||||||||||
7B74 | CP $13 | This is the x-coordinate of the bottoms of the staircases at the left of the skool | ||||||||||||||||||||||
7B76 | LD A,$01 | A=1 will make the follower go upstairs | ||||||||||||||||||||||
7B78 | JR Z,$7B80 | Jump if the follower should go up a staircase at the left of the skool | ||||||||||||||||||||||
7B7A | BIT 7,(HL) | Is the follower facing right? | ||||||||||||||||||||||
7B7C | RET NZ | Jump if so | ||||||||||||||||||||||
7B7D | LD A,$04 | A=3 will make the follower turn round and face right | ||||||||||||||||||||||
7B7F | RET | |||||||||||||||||||||||
7B80 | BIT 7,(HL) | Is the follower facing left? | ||||||||||||||||||||||
7B82 | RET Z | Return (with A=1) if so | ||||||||||||||||||||||
7B83 | LD A,$03 | A=3 will make the follower turn round and face left | ||||||||||||||||||||||
7B85 | RET | |||||||||||||||||||||||
The follower is on the middle floor, and the target is on the top floor.
|
||||||||||||||||||||||||
7B86 | LD A,$26 | This is the x-coordinate of the wall between the White and Exam Rooms | ||||||||||||||||||||||
7B88 | CP (HL) | Compare this with the follower's x-coordinate | ||||||||||||||||||||||
7B89 | LD A,$61 | Signal: follower is to the right of the wall | ||||||||||||||||||||||
7B8B | JR C,$7B8F | Jump if the follower is to the right of the wall | ||||||||||||||||||||||
7B8D | LD A,$01 | Signal: follower is to the left of the wall | ||||||||||||||||||||||
7B8F | CP E | Is the target on the same side of the skool? | ||||||||||||||||||||||
7B90 | JR Z,$7B67 | Jump if so (follower must go up the nearest staircase) | ||||||||||||||||||||||
7B92 | CCF | Set the carry flag if the follower must go down a staircase at the right of the skool, and reset it if he must go down a staircase at the left of the skool | ||||||||||||||||||||||
7B93 | JR $7B49 |
Prev: 7AD7 | Up: Map |