Prev: 41161 Up: Map Next: 41220
41163: Draw Icon
Used by the routines at RechargeBattery and QueueProgram.
Draws the pixels of a sprite that is three bytes wide, without its mask. The sprite is drawn from the bottom upwards, leaving out its first two rows (at the bottom) and its last row (at the top). This is used to draw the picture that shows the lives that are left.
Input
DE Address of the height byte of the sprite
HL Screen address of the bottom left of the icon
Output
HL Screen address four characters to the right of the icon
DrawIcon 41163 PUSH HL Save the screen address...
41164 PUSH DE ...and the sprite address.
41165 LD A,(DE) Fetch the height of the sprite...
41166 SUB 3 ...and take three rows off it, as that is the number that are drawn.
41168 LD B,A Use that as the counter.
41169 LD A,E Skip the height byte and the first two rows of the sprite.
41170 ADD A,13
41172 LD E,A
41173 LD A,D
41174 ADC A,0
41176 LD D,A
41177 EX DE,HL Point HL at the sprite data and DE at the screen.
Each row of the sprite has three pairs of bytes. The mask byte and the other byte are combined to find the pixels.
DrawIcon_Row 41178 LD A,(HL) Fetch the first mask byte...
41179 INC HL ...and move on to the other byte.
41180 XOR (HL) Combine the two...
41181 LD (DE),A ...and write the pixels to the screen.
41182 INC E Move on to the next byte of the screen.
41183 INC HL Move on to the next pair.
41184 LD A,(HL) Fetch the second mask byte...
41185 INC HL ...and move on to the other byte.
41186 XOR (HL) Combine the two...
41187 LD (DE),A ...and write the pixels to the screen.
41188 INC E Move on to the next byte of the screen.
41189 INC HL Move on to the next pair.
41190 LD A,(HL) Fetch the third mask byte...
41191 INC HL ...and move on to the other byte.
41192 XOR (HL) Combine the two...
41193 LD (DE),A ...and write the pixels to the screen.
41194 INC HL Move on to the next row of the sprite.
41195 DEC E Move back to the start of the row on the screen.
41196 DEC E
41197 LD A,D Move up one pixel row on the screen.
41198 DEC D
41199 AND 7 Jump if that is still inside the same character row.
41201 JR NZ,DrawIcon_NextRow
41203 LD A,D Otherwise go back to the bottom pixel row of the character row...
41204 ADD A,8
41206 LD D,A
41207 LD A,E ...and move up to the next character row.
41208 SUB 32
41210 LD E,A
DrawIcon_NextRow 41211 DJNZ DrawIcon_Row Loop back until every row has been drawn.
41213 POP DE Restore the sprite address...
41214 POP HL ...and the screen address.
41215 LD A,L Move four characters to the right.
41216 ADD A,4
41218 LD L,A
41219 RET Return.
Prev: 41161 Up: Map Next: 41220