Prev: 68DD Up: Map Next: 691D
68E1: Update the SRB so that the speech bubble is not corrupted
Used by the routines at 62A0, 691E and 6A08. Resets the bits in the screen refresh buffer (SRB) that correspond to the speech bubble and lip, so that they are not overwritten by sprite tiles when the display is updated. Returns with the carry flag set if the speech bubble is on-screen, and with HL pointing at the first byte of the SRB.
68E1 LD HL,$7FF8 7FF8 holds the LSB of the SRB address corresponding to the lip of the speech bubble (or 0 if there is no bubble on-screen)
68E4 LD A,(HL)
68E5 LD L,A L=0 (and HL=7F00) if no one is speaking
68E6 AND A Is anyone speaking at the moment?
68E7 RET Z Return if not
68E8 LD L,$FF HL=7FFF
68EA LD A,(HL) A=leftmost column of the play area on screen
68EB LD L,$FA HL=7FFA, which holds the column of the play area that was at the far left of the screen the last time this routine was called
68ED CP (HL) Set the zero flag if the screen hasn't scrolled, set the carry flag if the screen has scrolled right, or reset the carry flag if it has scrolled left
68EE LD (HL),A Update 7FFA to the current leftmost column on-screen
68EF LD L,$F8 HL=7FF8
68F1 JR Z,$6908 Jump if the screen hasn't scrolled since the last time this routine was called
The screen has scrolled since the last time this routine was called. Check which way it scrolled and update 7FF8 accordingly.
68F3 LD A,(HL) A=LSB of the speech bubble lip SRB address
68F4 JR NC,$6903 Jump if the screen has scrolled left
The screen has scrolled right since the last time this routine was called.
68F6 AND $03 A=0-3 (quarter of the screen occupied by the bubble before the scroll)
68F8 CP $03 Was the bubble in the rightmost quarter?
68FA JR NZ,$6900 Jump if not
The speech bubble has been scrolled off the screen.
68FC LD (HL),$00 Set 7FF8 to 0 (the bubble is no longer on-screen)
68FE LD L,(HL) L=0
68FF RET Return with the carry flag reset
6900 INC (HL) The speech bubble has been scrolled to the right (and is still on-screen)
6901 JR $6908
The screen has scrolled left since the last time this routine was called.
6903 AND $03 A=0-3 (quarter of the screen occupied by the bubble before the scroll)
6905 JR Z,$68FC Jump if the bubble was in the leftmost quarter (and is therefore no longer on-screen)
6907 DEC (HL) The speech bubble has been scrolled to the left (and is still on-screen)
Now that 7FF8 has been adjusted to compensate for any recent scrolling of the screen, adjust the appropriate SRB bytes for the speech bubble and lip.
6908 LD L,(HL) HL=address of the SRB byte corresponding to the lip of the speech bubble
6909 LD A,($7FF9) The bit set in A corresponds to the bit of the SRB byte that corresponds to the lip of the speech bubble
690C CPL
690D AND (HL) Make sure this bit is reset
690E LD (HL),A Restore the SRB byte with the relevant bit reset
690F LD A,L
6910 ADD A,$FC Reset the bits of the SRB corresponding to the bottom line of the speech bubble
6912 LD L,A
6913 LD (HL),$00
6915 ADD A,$FC Reset the bits of the SRB corresponding to the top line of the speech bubble
6917 LD L,A
6918 LD (HL),$00
691A LD L,(HL) L=0
691B SCF Signal: the speech bubble is still on-screen
691C RET
Prev: 68DD Up: Map Next: 691D