| Routines

63270: Check whether ERIC has jumped up to the safe or a shield (2)

Continues from 62750. Checks whether ERIC has jumped up to the safe or a shield, and makes it flash or unflash as appropriate.
Input
DE | Coordinates of ERIC's hand
63270 | LD A,(32746) | Pick up the game mode indicator from 32746
63273 | CP 2 | Are all the shields flashing?
63275 | JP NZ,28130 | Jump if not (to check whether ERIC touched a shield)
63278 | LD A,D | A=y-coordinate of ERIC's hand
63279 | CP 161 | This is the y-coordinate of the spot just under the safe in the staff room
63281 | RET NZ | Return if ERIC is not on the middle floor
63282 | LD A,E | A=x-coordinate of ERIC's hand
63283 | CP 10 | Has ERIC jumped up to the safe?
63285 | RET NZ | Return if not
ERIC has jumped up to the safe. Can he open it?
63286 | LD HL,32749 | 32749 holds the number of the character who last wrote on the Reading Room blackboard
63289 | LD DE,32680 | 32680=Reading Room blackboard contents buffer
63292 | LD C,3 | There are 3 blackboards
63294 | LD A,(HL) | A=number of the character who last wrote on this board
63295 | INC HL | Move HL along to the next blackboard
63296 | INC HL
63297 | CP 172 | Did ERIC write on this blackboard?
63299 | JR NZ,63322 | Jump if not
ERIC wrote on this blackboard. Check whether he wrote the safe combination code.
63301 | PUSH HL |
63302 | LD L,159 | HL=32671 (which holds the safe combination code)
63304 | LD B,4 | There are 4 characters in the safe combination code
63306 | PUSH DE | Save the pointer to the blackboard contents buffer
63307 | LD A,(DE) | A=character written on the blackboard by ERIC
63308 | AND 95 | Convert to upper case
63310 | INC E | Move DE along to the next character on the blackboard
63311 | CP (HL) | Does the character on the blackboard match a safe combination letter?
63312 | JR NZ,63318 | Jump if not
63314 | INC L | Move to the next letter of the safe combination code
63315 | DJNZ 63307 | Jump back until all four letters have been checked
63317 | XOR A | Set the zero flag to indicate a match
63318 | POP DE | Restore the blackboard contents buffer pointer to DE
63319 | POP HL |
63320 | JR Z,63330 | Jump if ERIC got the right combination
63322 | LD A,E | Point DE at the next blackboard contents buffer (32686 or 32692)
63323 | ADD A,6
63325 | LD E,A
63326 | DEC C | Decrease the blackboard counter
63327 | JR NZ,63294 | Jump back until all three blackboards have been checked
63329 | RET |
ERIC got the right combination.
63330 | CALL 63668 | Add 1000 to the score and play a celebratory tune
63333 | LD HL,41354 | Point HL at the attribute byte for the safe
63336 | SET 7,(HL) | Alter the attribute byte of the safe in the skool attribute data to make it flash
63338 | EX DE,HL | Point DE at the attribute byte for the safe
63339 | CALL 62674 | Get the attribute file address of the safe in HL
63342 | RET C | Return if the safe is off-screen (unlikely!)
63343 | SET 7,(HL) | Adjust the on-screen attribute byte of the safe to make it flash
63345 | RET |