Prev: 26845 Up: Map Next: 26909
26849: Update the SRB so that the speech bubble is not corrupted
Used by the routines at 25248, 26910 and 27144. 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.
26849 LD HL,32760 32760 holds the LSB of the SRB address corresponding to the lip of the speech bubble (or 0 if there is no bubble on-screen)
26852 LD A,(HL)
26853 LD L,A L=0 (and HL=32512) if no one is speaking
26854 AND A Is anyone speaking at the moment?
26855 RET Z Return if not
26856 LD L,255 HL=32767
26858 LD A,(HL) A=leftmost column of the play area on screen
26859 LD L,250 HL=32762, which holds the column of the play area that was at the far left of the screen the last time this routine was called
26861 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
26862 LD (HL),A Update 32762 to the current leftmost column on-screen
26863 LD L,248 HL=32760
26865 JR Z,26888 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 32760 accordingly.
26867 LD A,(HL) A=LSB of the speech bubble lip SRB address
26868 JR NC,26883 Jump if the screen has scrolled left
The screen has scrolled right since the last time this routine was called.
26870 AND 3 A=0-3 (quarter of the screen occupied by the bubble before the scroll)
26872 CP 3 Was the bubble in the rightmost quarter?
26874 JR NZ,26880 Jump if not
The speech bubble has been scrolled off the screen.
26876 LD (HL),0 Set 32760 to 0 (the bubble is no longer on-screen)
26878 LD L,(HL) L=0
26879 RET Return with the carry flag reset
26880 INC (HL) The speech bubble has been scrolled to the right (and is still on-screen)
26881 JR 26888
The screen has scrolled left since the last time this routine was called.
26883 AND 3 A=0-3 (quarter of the screen occupied by the bubble before the scroll)
26885 JR Z,26876 Jump if the bubble was in the leftmost quarter (and is therefore no longer on-screen)
26887 DEC (HL) The speech bubble has been scrolled to the left (and is still on-screen)
Now that 32760 has been adjusted to compensate for any recent scrolling of the screen, adjust the appropriate SRB bytes for the speech bubble and lip.
26888 LD L,(HL) HL=address of the SRB byte corresponding to the lip of the speech bubble
26889 LD A,(32761) The bit set in A corresponds to the bit of the SRB byte that corresponds to the lip of the speech bubble
26892 CPL
26893 AND (HL) Make sure this bit is reset
26894 LD (HL),A Restore the SRB byte with the relevant bit reset
26895 LD A,L
26896 ADD A,252 Reset the bits of the SRB corresponding to the bottom line of the speech bubble
26898 LD L,A
26899 LD (HL),0
26901 ADD A,252 Reset the bits of the SRB corresponding to the top line of the speech bubble
26903 LD L,A
26904 LD (HL),0
26906 LD L,(HL) L=0
26907 SCF Signal: the speech bubble is still on-screen
26908 RET
Prev: 26845 Up: Map Next: 26909