Prev: F64F Up: Map Next: F6AA
F650: 'W' pressed - write on a blackboard
The address of this routine is found in the table of keypress handling routines at 6880. It is called from the main loop at 6767 when 'W' is pressed.
F650 LD HL,$7FFB 7FFB holds ERIC's status flags
F653 BIT 7,(HL) Is ERIC sitting or lying down?
F655 RET NZ Return if so
F656 CALL $6648 Is ERIC on a staircase?
F659 RET NZ Return if so
F65A CP $A9 Is ERIC on the bottom floor?
F65C RET Z Return if so
F65D CP $9B Set the zero flag if ERIC's on the top floor
F65F LD BC,$302C C=44, B=48 (x-coordinates of the edges of the 'writing zone' for the Reading Room blackboard)
F662 LD A,E A=ERIC's x-coordinate
F663 JR Z,$F66F Jump if ERIC's on the top floor
F665 LD BC,$201C C=28, B=32 (x-coordinates of the edges of the writing zone for the White Room blackboard)
F668 CP $28 Is ERIC to the left of the White Room wall?
F66A JR C,$F66F Jump if so
F66C LD BC,$2F2B C=43, B=47 (x-coordinates of the edges of the writing zone for the Exam Room blackboard)
Now C and B hold the x-coordinates of the left and right edges of the writing zone for the blackboard closest to ERIC.
F66F CP C Return if ERIC is not standing close enough to the blackboard to write on it
F670 RET C
F671 CP B
F673 SET 5,(HL) Set bit 5 of ERIC's status flags at 7FFB: ERIC is writing on a blackboard
F677 CALL $7128 Get the blackboard identifier in A
F67A LD L,A HL=7FED (Reading Room), 7FEF (White Room) or 7FF1 (Exam Room)
F67B LD H,$7F
F67E SUB $B4 B=0x38 (Reading Room), 0x3A (White Room) or 0x3C (Exam Room)
F680 LD B,A
F681 LD A,(HL) A=number of the character who last wrote on this board
F682 LD (HL),$AC Signal that ERIC (0xAC) wrote on this board
F684 XOR $80 C=0x80 (bit 7 set) if the board is clean, <0x80 (bit 7 reset) if not
F686 LD C,A
F687 LD A,B HL=7FA8 (Reading Room blackboard), 7FAE (White Room blackboard), or 7FB4 (Exam Room blackboard)
F688 ADD A,A
F689 ADD A,B
F68B LD B,$04 Prepare the 4 slots in the blackboard buffer that will store the first 4 characters written on the board by ERIC; each slot will have bit 7 set if the board was clean before ERIC started writing
F68D LD (HL),C
F691 LD (HL),$01 ERIC will start writing at pixel column 1
This entry point is used by the routine at F6AA.
F693 LD HL,$AC60 Point HL at byte 0x60 of ERIC's buffer
F696 LD B,(HL) Pick up ERIC's animatory state in B, and his coordinates in DE
F697 INC L
F698 LD D,(HL)
F699 INC L
F69A LD E,(HL)
F69B LD A,$57 Set 7FFC (which holds the ASCII code of the last keypress) to 'W' (upper case, so ERIC can write fast)
F69D LD ($7FFC),A
F6A0 LD H,D Copy ERIC's coordinates to HL
F6A2 LD A,B A=ERIC's current animatory state
F6A3 AND $80 A=0x0D or 0x8D: ERIC with arm up, as if writing
F6A5 ADD A,$0D
F6A7 JP $653C Raise ERIC's arm
Prev: F64F Up: Map Next: F6AA