Routines

26849: Update SRB so that speech bubbles are not corrupted


Used by routines at 25248, 26910 and 27144. Returns with the carry flag set if the speech bubble is on-screen.

26849 21F87F LD HL,32760
26852 7E LD A,(HL)
26853 6F LD L,A
26854 A7 AND A
26855 C8 RET Z Return if no one is speaking
26856 2EFF LD L,255 HL=32767
26858 7E LD A,(HL) A=column of play area at far left of screen
26859 2EFA LD L,250 HL=32762
26861 BE CP (HL)
26862 77 LD (HL),A
26863 2EF8 LD L,248 HL=32760
26865 2815 JR Z,26888 Jump if the screen hasn't scrolled since the last time this routine was called
26867 7E LD A,(HL)
26868 300D JR NC,26883 Jump if the screen has scrolled right
26870 E603 AND 3 A=quarter of screen occupied by bubble before scroll
26872 FE03 CP 3 Was it the rightmost quarter?
26874 2004 JR NZ,26880 Jump if not
26876 3600 LD (HL),0 Set 32760 to 0 (the talking character is no longer on-screen)
26878 6E LD L,(HL)
26879 C9 RET Return with the carry flag reset
26880 34 INC (HL) The speech bubble has been scrolled to the right
26881 1805 JR 26888
26883 E603 AND 3 Was the bubble at the far left of the screen?
26885 28F5 JR Z,26876 Jump if so (it's no longer on-screen)
26887 35 DEC (HL) The speech bubble has been scrolled to the left
26888 6E LD L,(HL) HL=address of SRB byte corresponding to lip of speech bubble
26889 3AF97F LD A,(32761) The bit set in A corresponds to the bit of the SRB byte which corresponds to the lip of the speech bubble
26892 2F CPL
26893 A6 AND (HL) Make sure this bit is reset (do not refresh it)
26894 77 LD (HL),A Restore the SRB byte with the relevant bit reset
26895 7D LD A,L
26896 C6FC ADD A,252 Reset the bits of the SRB corresponding to the bottom line of the speech bubble
26898 6F LD L,A
26899 3600 LD (HL),0
26901 C6FC ADD A,252 Reset the bits of the SRB corresponding to the top line of the speech bubble
26903 6F LD L,A
26904 3600 LD (HL),0
26906 6E LD L,(HL)
26907 37 SCF Signal: speech bubble is still on-screen
26908 C9 RET