Routines

25554: Return play area region identifier in A


Used by routines at 25700, 25843 and 32379

D y-coordinate of play area
E x-coordinate of play area

The value returned in A (corresponding to the location in DE) is as follows:
189 Top floor, left of left study door in boys' skool
190 Middle floor, left of far wall of science lab storeroom
191 Anywhere on bottom floor (or in mid-air!)
192 Assembly hall stage
193 Near middle-floor window in boys' skool
194 Top floor, right of left study door in boys' skool
195 Middle floor, girls' skool
196 Top floor, girls' skool

Or if the entry point at 25557 is used:
0 None of the places below
1 Playground
2 Various places in boys' skool outside classrooms
3 Assembly hall
4 Dining hall
5 Revision library, just outside yellow room door
6 Science lab
7 Blue room
8 Yellow room

The carry flag is set upon return to the caller of this routine unless the coordinates in DE correspond to a location exactly on the assembly hall stage or the top, middle or bottom floor (i.e. not on a staircase).

25554 CDA36D CALL 28067 Divert back to the calling routine with the carry flag reset if the character is on the assembly hall stage

This entry point is used by the routine at 32000 with ERIC's coordinates in DE (B=185, C=59):
25557 7A LD A,D D contains the y-coordinate
25558 04 INC B Set B to 183 (186) if D≤6 (top floor), 184 (187) if 7≤D≤13 (middle floor), or 185 (188) if 14≤D≤18 (bottom floor)
25559 D607 SUB 7
25561 30FB JR NC,25558
25563 FEFC CP 252 Does D=3, 10 or 17 (top, middle, bottom floor)?
25565 2804 JR Z,25571 Jump if so
25567 37 SCF Signal: D does not correspond exactly to top, middle or bottom floor
25568 00 NOP
25569 00 NOP
25570 00 NOP
25571 F5 PUSH AF Save carry flag temporarily (note: C=59)
25572 0C INC C
25573 0A LD A,(BC)
25574 0C INC C
25575 BB CP E
25576 38FA JR C,25572
25578 F1 POP AF Restore the carry flag (reset if D=3, 10 or 17; set otherwise)
25579 0A LD A,(BC) A holds value in range 189-196 or 0-8 (see tables above)
25580 C9 RET

The value picked up from (BC) can be determined from the tables below. The x-coordinate compared with that in E is shown in the column labelled "x", and the value returned (the first one such that E≤(BC)) is shown in the column labelled "A".
C=60 C=62 C=64 C=66 C=68
x A x A x A x A x A
B=183 72 189 96 194 159 191 224 196 top floor
B=184 63 190 76 191 96 193 159 191 224 195 middle floor
B=185 224 191 bottom floor

C=60 C=62 C=64 C=66 C=68 C=70
x A x A x A x A x A x A
B=186 23 7 29 2 40 5 63 8 224 0 top floor
B=187 30 2 53 6 224 0 middle floor
B=188 42 2 63 4 77 3 96 2 159 1 224 0 bottom floor