Prev: 6980 Up: Map Next: 69CA
6992: Update the display
Used by the routines at 6500, 6767, 7ED6 and B4E8. Goes through the screen refresh buffer (SRB) and for every set bit found, updates the corresponding character square on-screen.
6992 LD HL,$7F0C Point HL at the first byte of the SRB
6995 LD B,$54 B will count the bytes in the screen refresh buffer
6997 LD A,(HL) Pick up an SRB byte
6998 AND A Any character squares in this segment need refreshing?
6999 JR Z,$69C6 Jump if not
699B PUSH BC Save the SRB byte counter
699C LD A,L D=y-coordinate of the segment of 8 character squares to which this SRB byte corresponds
699D AND $7C
699F RRCA
69A0 RRCA
69A1 ADD A,$95
69A3 LD D,A
69A4 LD A,L E=x-coordinate of the leftmost character square in the segment
69A5 AND $03
69A7 RLCA
69A8 RLCA
69A9 RLCA
69AA LD E,A
69AB LD A,($7F00)
69AE ADD A,E
69AF LD E,A
69B0 DEC E
Here we enter a loop to check each SRB byte for set bits.
69B1 PUSH HL Save the pointer to the SRB byte
69B2 INC E Set DE to the coordinates of the next character square in the current segment
69B3 RR (HL) Push an SRB bit into the carry flag, and 0 into bit 7 of the SRB byte
69B5 JR C,$69BB Refresh the corresponding character square if the bit was set
69B7 JR NZ,$69B2 Jump back until all set bits in the SRB byte have been checked
69B9 JR $69C4 Move to the next SRB byte
We have found a set bit in the current SRB byte. Refresh the corresponding tile on screen.
69BB PUSH DE
69BC CALL $610B Print the character square at (E,D)
69BF POP DE
69C0 POP HL Restore the pointer to the SRB byte
69C1 AND A Clear the carry flag so that bit 7 of the SRB byte will be reset, and jump back to check the next bit
69C2 JR $69B1
There are no set bits remaining in the current SRB byte. Move on to the next.
69C4 POP HL Restore the pointer to the SRB byte
69C5 POP BC Restore the SRB byte counter to B
69C6 INC L Move to the next byte in the screen refresh buffer
69C7 DJNZ $6997 Jump back until every byte in the SRB has been checked
69C9 RET
Prev: 6980 Up: Map Next: 69CA