| Routines

63D2: Get the play area region identifier for a given location

Used by the routines at 6464, 64F3 and 7E7B. The value returned in A (corresponding to the location in DE) is as follows:
ID | Region
--- | ---
0xBD | Top floor, left of the left study door in the boys' skool
0xBE | Middle floor, left of the far wall of the Science Lab storeroom
0xBF | Anywhere on the bottom floor (or in mid-air!)
0xC0 | Assembly hall stage
0xC1 | Near the middle-floor window in the boys' skool
0xC2 | Top floor, right of the left study door in the boys' skool
0xC3 | Middle floor, girls' skool
0xC4 | Top floor, girls' skool
Or if the entry point at 63D5 is used (for ERIC's location):
ID | Region
--- | ---
0x00 | None of the places below (ERIC is never allowed here)
0x01 | Playground
0x02 | Various places in the boys' skool outside classrooms
0x03 | Assembly hall
0x04 | Dining hall
0x05 | Revision Library, outside the Yellow Room door
0x06 | Science Lab
0x07 | Blue Room
0x08 | Yellow Room
The carry flag is set upon return to the caller of this routine if the coordinates in DE correspond to a location on a staircase.
Input
D | y-coordinate of the play area (3-17)
E | x-coordinate of the play area (0-190)
63D2 | CALL $6DA3 | Divert back to the calling routine with A=0xC0 and the carry flag reset if the character is on the assembly hall stage; otherwise return here with B=0xB6 and C=0x3B
This entry point is used by the routine at 7D00 with ERIC's coordinates in DE, B=0xB9, and C=0x3B.
63D5 | LD A,D | A=y-coordinate
63D6 | INC B | Set B to 0xB7 (0xBA) if D<=0x06 (top floor), 0xB8 (0xBB) if 0x07<=D<=0x0D (middle floor), or 0xB9 (0xBC) if 0x0E<=D<=0x12 (bottom floor)
63D7 | SUB $07
63D9 | JR NC,$63D6
Now BC will be used to index one of the skool region tables that contain the location identifiers:
Address | Region
--- | ---
B73C | Top floor
B83C | Middle floor
B93C | Bottom floor
BA3C | Top floor (ERIC)
BB3C | Middle floor (ERIC)
BC3C | Bottom floor (ERIC)
63DB | CP $FC | Does D=0x03, 0x0A or 0x11 (top, middle, bottom floor)?
63DD | JR Z,$63E3 | Jump if so
63DF | SCF | Signal: D does not correspond exactly to the top, middle or bottom floor
63E0 | NOP |
63E1 | NOP
63E2 | NOP
63E3 | PUSH AF | Save the carry flag temporarily
63E4 | INC C | Point BC at the appropriate entry in one of the region tables
63E5 | LD A,(BC)
63E6 | INC C
63E7 | CP E
63E8 | JR C,$63E4
63EA | POP AF | Restore the carry flag (reset if D=0x03, 0x0A or 0x11; set otherwise)
63EB | LD A,(BC) | A=region identifier (0xBD-0xC4 or 0x00-0x08; see the tables above)
63EC | RET |