| Routines

29746: Remove the speech bubble

Used by the routines at 31130 and 32470.
Input
H | Number of the character who is speaking (152-169)
29746 | PUSH HL | Save the character number
29747 | CALL 29394 | Is the speech bubble off-screen?
29750 | JR C,29815 | Jump if so
29752 | CALL 29735 | Update the SRB for the part of the screen hidden by the speech bubble
First, restore the original attribute bytes for the area of the screen occupied by the speech bubble.
29755 | LD DE,(32612) | Copy the speech bubble lip coordinates from 32612 to DE
29759 | CALL 28807 | Update the SRB for the part of the screen hidden by the lip
29762 | LD HL,32512 | 32512 holds the leftmost column of the skool on screen (0-64)
29765 | LD A,E | E=screen x-coordinate of the speech bubble lip (0-31)
29766 | SUB (HL)
29767 | LD E,A
29768 | LD A,D | A=screen y-coordinate of the speech bubble lip (2-17)
29769 | SUB 152
29771 | RRCA | Set DE to the attribute file address corresponding to the lip of the speech bubble
29772 | RRCA
29773 | RRCA
29774 | LD D,A
29775 | AND 224
29777 | ADD A,E
29778 | LD E,A
29779 | LD A,D
29780 | AND 3
29782 | ADD A,88
29784 | LD D,A
29785 | LD L,103 | Pick up the attribute byte for the part of screen hidden by the speech bubble lip from 32615 and restore it to the attribute file
29787 | LD A,(HL)
29788 | LD (DE),A
29789 | EX DE,HL | Point DE at the attribute file address corresponding to the top left corner of the speech bubble
29790 | LD BC,65472
29793 | ADD HL,BC
29794 | LD A,L
29795 | AND 248
29797 | LD L,A
29798 | EX DE,HL
29799 | LD BC,8 | Restore the attribute bytes of the part of the screen overwritten by the top row of the speech bubble (stored at 32632 by the routine at 29518)
29802 | LD L,120
29804 | LDIR
29806 | LD C,24 | Point DE at the attribute file address corresponding to the bottom left corner of the speech bubble
29808 | EX DE,HL
29809 | ADD HL,BC
29810 | EX DE,HL
29811 | LD C,8 | Restore the attribute bytes of the part of the screen overwritten by the bottom row of the speech bubble (stored at 32640 by the routine at 29518)
29813 | LDIR
Next, restore the skool UDG references and attribute bytes for the area of the skool occupied by the speech bubble.
29815 | LD DE,(32612) | Copy the speech bubble lip coordinates from 32612 to DE
29819 | LD HL,32614 | Pick up the UDG reference for the part of the skool occupied by the speech bubble lip and restore it
29822 | LD A,(HL)
29823 | INC L
29824 | LD (DE),A
29825 | SET 7,E | Pick up the attribute byte for the part of the skool occupied by the speech bubble lip and restore it
29827 | LD A,(HL)
29828 | INC L
29829 | LD (DE),A
29830 | LD A,E | DE=coordinates of the top left corner of the speech bubble
29831 | AND 120
29833 | DEC D
29834 | DEC D
29835 | LD E,A
29836 | LD BC,8 | Restore the UDG references of the part of the skool overwritten by the top row of the speech bubble (stored at 32616 by the routine at 29518)
29839 | LDIR
29841 | INC D | Restore the UDG references of the part of the skool overwritten by the bottom row of the speech bubble (stored at 32624 by the routine at 29518)
29842 | LD C,8
29844 | LD E,A
29845 | LDIR
29847 | ADD A,128 | Point DE at the skool graphic data attribute byte corresponding to the top-left corner of the speech bubble
29849 | LD E,A
29850 | DEC D
29851 | LD C,8 | Restore the attribute bytes of the part of the skool overwritten by the top row of the speech bubble (stored at 32632 by the routine at 29518)
29853 | LDIR
29855 | INC D | Restore the attribute bytes of the part of the skool overwritten by the bottom row of the speech bubble (stored at 32640 by the routine at 29518)
29856 | LD C,8
29858 | LD E,A
29859 | LDIR
Finally, clear the speech bubble lip coordinates (at 32612) to indicate that no one is speaking.
29861 | LD (32612),BC | Set the speech bubble lip coordinates at to (0,0)
29865 | POP HL | Restore the speaker's character number to H
29866 | XOR A |
29867 | RET |