| Routines

26453: Get the identifier and coordinates of the blackboard close to a character

Used by the routines at 24133, 26513, 26752, 28658 and 61696. If the character is not standing at a blackboard, the routine returns with the carry flag set. Otherwise the routine returns with the carry flag reset, B holding the blackboard identifier (the LSB of 32596, 32602, 32608, 32614 or 32620), and DE holding the coordinates of the top left-hand square of the board.
Input
H | Character number (200-204, 206)
26453 | LD B,3 | There are three blackboards on the top floors
26455 | LD DE,54071 | The table at 54071 contains the x-coordinates of the left edges of the blackboards
26458 | LD L,2 | Byte 2 of the character's buffer holds his y-coordinate
26460 | LD A,(HL) | Pick this up in A
26461 | DEC L | L=1
26462 | CP B | Is the character on the top floor?
26463 | JR Z,26472 | Jump if so
26465 | LD E,58 | DE=54074
26467 | DEC B | B=2 (two blackboards on the middle floors)
26468 | CP 10 | Is the character on the middle floor?
26470 | JR NZ,26484 | Jump if not
26472 | LD A,(DE) | A=x-coordinate of the left edge of a blackboard
26473 | CP (HL) | Is the character to the left of this blackboard?
26474 | JR NC,26484 | Jump if so
26476 | ADD A,4 | Is the character no more than 4 (or 12, if coming from 28658) spaces to the right of the left edge of this blackboard?
26478 | CP (HL)
26479 | JR NC,26486 | Jump if so
26481 | INC E | Next blackboard
26482 | DJNZ 26472 |
26484 | SCF | Signal: the character is not standing at a blackboard
26485 | RET |
The character is standing close enough to the blackboard (to either write on it or start wiping it).
26486 | EX DE,HL | Now HL points to the blackboard info table
26487 | LD A,(HL) | A=x-coordinate of the left edge of the blackboard (from the table at 54071)
26488 | INC H |
26489 | LD B,(HL) | B=blackboard identifier (from the table at 54327)
26490 | INC H |
26491 | LD H,(HL) | H=y-coordinate of the top row of the blackboard (from the table at 54583)
26492 | LD L,A | Pass the x-coordinate to L
26493 | AND A | Clear the carry flag to indicate success
26494 | EX DE,HL | DE=coordinates of the top-left corner of the blackboard
26495 | RET |
The contents of the blackboard info tables are as follows:
x | ID | y | Room
--- | --- | --- | ---
3 | 84 | 3 | Blue Room
41 | 90 | 3 | Yellow Room
161 | 96 | 3 | Top-floor room in the girls' skool
32 | 102 | 9 | Science Lab
161 | 108 | 9 | Middle-floor room in the girls' skool