| Routines

62A0: Update the display

Used by the routines at 51DC, 6E00, F28E and F6EA. Goes through the screen refresh buffer (SRB) and for every set bit found, updates the corresponding character square on-screen.
62A0 | CALL $68E1 | Update the SRB so that speech bubbles are not corrupted by moving characters
62A3 | LD B,$54 | 21 screen rows, 4 bytes (32 bits) per row
62A5 | LD A,(HL) | Pick up a byte from the screen refresh buffer
62A6 | AND A | Anything need updating in this particular 8-tile segment?
62A7 | JR Z,$62CC | Jump if not
62A9 | PUSH BC | Save the SRB byte counter
62AA | LD A,L | For this particular byte of the SRB, compute the corresponding screen row number (0-20) in D
62AB | AND $FC
62AD | RRCA
62AE | RRCA
62AF | LD D,A
62B0 | LD A,L | Also for this particular SRB byte, compute the column of the screen (0, 8, 16 or 24) corresponding to bit 7
62B1 | AND $03
62B3 | ADD A,A
62B4 | ADD A,A
62B5 | ADD A,A
62B6 | DEC A |
62B7 | LD E,A |
62B8 | INC E |
62B9 | SLA (HL) | Does a character square need printing?
62BB | JR C,$62C1 | Jump if so
62BD | JR NZ,$62B8 | Jump back if there are still non-zero bits left in this SRB byte
62BF | JR $62CB | Jump forward to consider the next SRB byte
We found a set bit in the current SRB byte. Print the corresponding character square.
62C1 | PUSH HL | Save the SRB pointer
62C2 | PUSH DE | Save the screen (row,column) pointer
62C3 | EX DE,HL | Switch the screen (row,column) pointer to HL
62C4 | CALL $606C | Print the character square at this row and column
62C7 | POP DE | Restore the screen (row,column) pointer to DE
62C8 | POP HL | Restore the SRB pointer to HL
62C9 | JR $62B8 | Examine the next bit of the current SRB byte
There are no set bits remaining in the current SRB byte. Move to the next SRB byte.
62CB | POP BC | Restore the SRB byte counter to B
62CC | INC L | Point HL at the next SRB byte
62CD | DJNZ $62A5 | Jump back until all 84 SRB bytes have been dealt with
62CF | RET |