Prev: 670A Up: Map Next: 6755
670C: Update the SRB for a blackboard
Used by the routines at 6791 and 680F. 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 y-coordinate of the play area
E x-coordinate of the play area
670C LD A,($7FFF) A=leftmost column of the play area on screen
670F SUB $02
6711 JR C,$6715 Jump if the far left wall of the boys' skool is on-screen
6713 CP E Is the leftmost point requiring refresh off-screen to the left by at least two character squares?
6714 RET NC Return if so (nothing to do)
6715 ADD A,$21 A=column of the play area at the far right of the screen
6717 CP E Is the leftmost point requiring refresh off-screen to the right?
6718 RET C Return if so (nothing to do)
6719 PUSH DE Save the coordinates for now
671A SUB $20 A=screen x-coordinate corresponding to the play area x-coordinate in E (-1, 0-31)
671C CPL
671D ADD A,E
671E BIT 7,A Is the leftmost point requiring refresh on-screen?
6720 JR Z,$6723 Jump if so
6722 INC A A=0
6723 RLCA A=8x (x=column of the screen containing the first character square to be refreshed)
6724 RLCA
6725 RLCA
6726 LD E,A Store this in E temporarily
6727 AND $38 Set the instruction at 673C below to SET n,(HL) where n is the appropriate bit in the SRB byte
6729 CPL
672A DEC A
672B LD ($673D),A
672E PUSH AF
672F LD A,E A=8x again
6730 RLCA Point HL at the appropriate byte of the SRB
6731 RLCA
6732 AND $03
6734 ADD A,D
6735 ADD A,D
6736 ADD A,D
6737 ADD A,D
6738 LD E,A
6739 LD D,$7F
673B EX DE,HL
673C SET 0,(HL) Set the appropriate bit in the SRB byte for the leftmost character square that needs refreshing; this instruction is modified earlier in this routine to set the required bit
673E POP AF
673F ADD A,$38
6741 JR C,$674B Jump unless we've just set bit 0 of an SRB byte
6743 INC L Next SRB byte
6744 LD A,L Does this SRB byte correspond to the first byte of the next row of the screen?
6745 AND $03
6747 JR Z,$6752 If so, skip it
6749 LD A,$FE Otherwise set bit 7 in this SRB byte
674B OR $C0
674D LD ($6751),A Set the instruction at 6750 below to SET m,(HL) where m is the appropriate bit in the SRB byte
6750 SET 0,(HL) Set the appropriate bit in the SRB byte for the rightmost character square that needs refreshing; this instruction is modified immediately before execution to set the required bit
6752 EX DE,HL Restore the original contents of HL
6753 POP DE Restore the play area coordinates to DE
6754 RET
Prev: 670A Up: Map Next: 6755