Routines

26958: Print speech bubble


Used by routine at 27144. Returns with the carry flag set if the character is off-screen.

H Number of character about to speak (200-204, 208)

26958 3AFF7F LD A,(32767) A=column of play area at far left of screen
26961 47 LD B,A
26962 2E01 LD L,1
26964 7E LD A,(HL) A=character's x-coordinate
26965 3C INC A
26966 90 SUB B
26967 D8 RET C Return with carry set if the character is off-screen to the left
26968 FE20 CP 32
26970 3F CCF
26971 D8 RET C Return with carry set if the character is off-screen to the right
26972 4F LD C,A 1≤C≤31 (relative x-coordinate of "lip" of speech bubble)
26973 E607 AND 7
26975 C678 ADD A,120
26977 5F LD E,A Point DE at an entry in the table at 57720
26978 16E1 LD D,225
26980 1A LD A,(DE) Now the bit set in A corresponds to the bit that needs to be set in the SRB for the lip of the speech bubble
26981 32F97F LD (32761),A Store this
26984 79 LD A,C A=x-coordinate of lip of speech bubble
26985 0F RRCA
26986 0F RRCA
26987 0F RRCA
26988 E603 AND 3
26990 5F LD E,A E=0, 1, 2 or 3 (quarter of screen in which bubble will be printed)
26991 7C LD A,H A=number of character about to speak
26992 2C INC L L=2
26993 FED0 CP 208 Is EINSTEIN about to speak?
26995 9F SBC A,A
26996 86 ADD A,(HL) A=y-coordinate of lip of speech bubble
26997 E5 PUSH HL
26998 87 ADD A,A Set up 32760 as follows:
Bits Contents
0-1 Quarter of screen in which to print bubble
2-6 y-coordinate of lip of bubble
This is the LSB of the address of the SRB byte for the lip
26999 87 ADD A,A
27000 6F LD L,A
27001 83 ADD A,E
27002 32F87F LD (32760),A
27005 78 LD A,B Put the current column of the play area at the far left of the screen into 32762 for safekeeping
27006 32FA7F LD (32762),A
27009 260B LD H,11
27011 29 ADD HL,HL
27012 29 ADD HL,HL
27013 29 ADD HL,HL
27014 7D LD A,L
27015 81 ADD A,C
27016 6F LD L,A HL=attribute file address for lip of speech bubble
27017 11E098 LD DE,39136 39136: Lip UDG
27020 CD3D69 CALL 26941 Print the lip of the speech bubble
27023 01E0FF LD BC,65504 BC=–32
27026 09 ADD HL,BC Up a line
27027 E5 PUSH HL
27028 7D LD A,L
27029 E6F8 AND 248
27031 6F LD L,A
27032 09 ADD HL,BC HL=attribute file address for top left corner of speech bubble
27033 11E099 LD DE,39392 39392: Top left corner UDG
27036 CD3D69 CALL 26941 Print the top left corner of the speech bubble
27039 0E06 LD C,6 6 UDGs in the top middle section of the speech bubble
27041 11E09A LD DE,39648 39648: Top-middle section UDG
27044 2C INC L
27045 CD3D69 CALL 26941 Print a top-middle section UDG
27048 0D DEC C
27049 20F6 JR NZ,27041 Jump back until all of the top middle section has been printed
27051 11E09B LD DE,39904 39904: Top right corner UDG
27054 2C INC L
27055 CD3D69 CALL 26941 Print the top right corner of the speech bubble
27058 0E19 LD C,25
27060 09 ADD HL,BC HL=attribute file address for bottom left corner of speech bubble
27061 11E09C LD DE,40160 40160: Bottom left corner UDG
27064 CD3D69 CALL 26941 Print the bottom left corner of the speech bubble
27067 0E06 LD C,6 6 UDGs in the bottom middle section of the speech bubble
27069 11E09D LD DE,40416 40416: Bottom-middle section UDG
27072 2C INC L
27073 CD3D69 CALL 26941 Print a bottom-middle section UDG
27076 0D DEC C
27077 20F6 JR NZ,27069 Jump back until all of the bottom middle section has been printed
27079 2C INC L
27080 11E09E LD DE,40672 40672: Bottom right corner UDG
27083 CD3D69 CALL 26941 Print the bottom right corner of the speech bubble
27086 E1 POP HL Retrieve attribute file address for spot above lip of speech bubble
27087 7C LD A,H
27088 E60B AND 11
27090 87 ADD A,A
27091 87 ADD A,A
27092 87 ADD A,A
27093 C607 ADD A,7
27095 67 LD H,A HL=address of bottom pixel line of character square above lip
27096 3642 LD (HL),66 "Open" the part above the lip (previously closed by a middle section UDG)
27098 21405B LD HL,23360
27101 2D DEC L Clear the 64 bytes from 23296 to 23359
27102 3600 LD (HL),0
27104 20FB JR NZ,27101
27106 E1 POP HL
27107 A7 AND A Return with the carry flag reset to signal that the speech bubble has been printed
27108 C9 RET