| Routines

28807: Update the SRB for a blackboard or the speech bubble lip

Used by the routines at 28994, 29160, 29518 and 29746. 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
28807 | LD A,(32512) | A=X: leftmost column of the skool on screen (0-64)
28810 | SUB 2 | 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)
28812 | JR C,28816
28814 | CP E
28815 | RET NC
28816 | ADD A,33
28818 | CP E
28819 | RET C
28820 | PUSH DE | Store the skool coordinates
28821 | SUB 32 | A=E-X (-1, 0-31)
28823 | CPL
28824 | ADD A,E
28825 | BIT 7,A | Are the coordinates in DE on-screen?
28827 | JR Z,28830 | Jump if so
28829 | INC A | A=0
28830 | RLCA | A=8x (x=0-31, the screen x-coordinate)
28831 | RLCA
28832 | RLCA
28833 | LD E,A | Save this value in E briefly
28834 | AND 56 | Modify the SET m,(HL) instruction at 28857 below
28836 | ADD A,198
28838 | LD (28858),A
28841 | LD A,E | Point HL at the appropriate byte in the screen refresh buffer
28842 | RLCA
28843 | RLCA
28844 | AND 3
28846 | LD E,A
28847 | LD A,D
28848 | SUB 149
28850 | ADD A,A
28851 | ADD A,A
28852 | ADD A,E
28853 | LD E,A
28854 | LD D,127
28856 | EX DE,HL
28857 | SET 0,(HL) | Set the appropriate bit in the SRB byte; this instruction is modified earlier in this routine to set the required bit
28859 | LD A,(28858) |
28862 | ADD A,8 | Was m=7?
28864 | JR NC,28874 | Jump if not
28866 | INC L | Move to the next SRB byte
28867 | LD A,L | A will be 0 if we wrapped round to the next row of the screen
28868 | AND 3
28870 | LD A,198 | 198 will set n=0
28872 | JR Z,28879 | Jump if we wrapped round to the next row
28874 | LD (28878),A | Modify the SET n,(HL) instruction below so that n=m+1 mod 8
28877 | SET 0,(HL) | Set the appropriate bit in the SRB byte; this instruction is modified immediately before execution to set the required bit
28879 | EX DE,HL |
28880 | POP DE | Restore the skool coordinates to DE
28881 | RET |