Prev: 7082 Up: Map Next: 70D2
7087: Update the SRB for a blackboard or the speech bubble lip
Used by the routines at 7142, 71E8, 734E and 7432. Updates the screen refresh buffer (SRB) so that the character squares at (E,D) and (E+1,D) are marked dirty. Two character squares in a row are marked dirty to ensure that blackboard contents are properly displayed (characters written on a blackboard may cross character square boundaries).
Input
D Skool y-coordinate
E Skool x-coordinate
7087 LD A,($7F00) A=X: leftmost column of the skool on screen (0-64)
708A SUB $02 Return unless X-1<=E<=X+31 (i.e. unless the coordinates in DE correspond to a skool location that is currently on-screen or just off to the left)
708C JR C,$7090
708E CP E
708F RET NC
7090 ADD A,$21
7092 CP E
7093 RET C
7094 PUSH DE Store the skool coordinates
7095 SUB $20 A=E-X (-1, 0-31)
7097 CPL
7098 ADD A,E
7099 BIT 7,A Are the coordinates in DE on-screen?
709B JR Z,$709E Jump if so
709D INC A A=0
709E RLCA A=8x (x=0-31, the screen x-coordinate)
709F RLCA
70A0 RLCA
70A1 LD E,A Save this value in E briefly
70A2 AND $38 Modify the SET m,(HL) instruction at 70B9 below
70A4 ADD A,$C6
70A6 LD ($70BA),A
70A9 LD A,E Point HL at the appropriate byte in the screen refresh buffer
70AA RLCA
70AB RLCA
70AC AND $03
70AE LD E,A
70AF LD A,D
70B0 SUB $95
70B2 ADD A,A
70B3 ADD A,A
70B4 ADD A,E
70B5 LD E,A
70B6 LD D,$7F
70B8 EX DE,HL
70B9 SET 0,(HL) Set the appropriate bit in the SRB byte; this instruction is modified earlier in this routine to set the required bit
70BB LD A,($70BA)
70BE ADD A,$08 Was m=7?
70C0 JR NC,$70CA Jump if not
70C2 INC L Move to the next SRB byte
70C3 LD A,L A will be 0 if we wrapped round to the next row of the screen
70C4 AND $03
70C6 LD A,$C6 0xC6 will set n=0
70C8 JR Z,$70CF Jump if we wrapped round to the next row
70CA LD ($70CE),A Modify the SET n,(HL) instruction below so that n=m+1 mod 8
70CD SET 0,(HL) Set the appropriate bit in the SRB byte; this instruction is modified immediately before execution to set the required bit
70CF EX DE,HL
70D0 POP DE Restore the skool coordinates to DE
70D1 RET
Prev: 7082 Up: Map Next: 70D2