Prev: 55168 Up: Map Next: 55313
55210: Draw Lines
Used by the routine at PrintSprite.
Draws the lines of a sprite one after the other. For each line the code jumps into the unrolled code, at a place that depends on the width of the sprite, and that is set by the jump that is changed by PrintSprite. The code for a sprite that is not on a byte boundary takes a pair of bytes off the stack, which are the mask and the data, shifts them across the two bytes of the buffer that they fall into with the table of shifted bytes in H, and keeps what is left of the second byte to go with the next pair.
DrawLines 55210 EX AF,AF' Stash the number of lines left.
55211 LD A,(BC) Fetch the first byte of the buffer.
DrawLines_Jump 55212 JR DrawLines_Jump Jump into the unrolled code. The jump is changed to go to the right place.
The first pair of a sprite that has five.
55214 POP DE Take the mask and the data of the pair off the stack.
55215 LD L,E Combine the byte that is carried with the first part of the shifted mask and data.
55216 AND (HL)
55217 LD L,D
55218 XOR (HL)
55219 CPL
55220 LD (BC),A Store the byte in the buffer and move on to the next one.
55221 INC BC
55222 INC H Switch to the table of the part that spills over into the next byte.
55223 LD L,E
55224 LD A,(BC) Fetch the next byte of the buffer.
55225 AND (HL) Combine it with the second part of the shifted mask and data.
55226 LD L,D
55227 XOR (HL)
55228 CPL
55229 DEC H Switch back to the first table.
The second pair of a sprite that has four or five.
55230 POP DE Take the mask and the data of the pair off the stack.
55231 LD L,E Combine the byte that is carried with the first part of the shifted mask and data.
55232 AND (HL)
55233 LD L,D
55234 XOR (HL)
55235 CPL
55236 LD (BC),A Store the byte in the buffer and move on to the next one.
55237 INC BC
55238 INC H Switch to the table of the part that spills over into the next byte.
55239 LD L,E
55240 LD A,(BC) Fetch the next byte of the buffer.
55241 AND (HL) Combine it with the second part of the shifted mask and data.
55242 LD L,D
55243 XOR (HL)
55244 CPL
55245 DEC H Switch back to the first table.
The third pair of a sprite that has three or more.
55246 POP DE Take the mask and the data of the pair off the stack.
55247 LD L,E Combine the byte that is carried with the first part of the shifted mask and data.
55248 AND (HL)
55249 LD L,D
55250 XOR (HL)
55251 CPL
55252 LD (BC),A Store the byte in the buffer and move on to the next one.
55253 INC BC
55254 INC H Switch to the table of the part that spills over into the next byte.
55255 LD L,E
55256 LD A,(BC) Fetch the next byte of the buffer.
55257 AND (HL) Combine it with the second part of the shifted mask and data.
55258 LD L,D
55259 XOR (HL)
55260 CPL
55261 DEC H Switch back to the first table.
The fourth pair of a sprite that has two or more.
55262 POP DE Take the mask and the data of the pair off the stack.
55263 LD L,E Combine the byte that is carried with the first part of the shifted mask and data.
55264 AND (HL)
55265 LD L,D
55266 XOR (HL)
55267 CPL
55268 LD (BC),A Store the byte in the buffer and move on to the next one.
55269 INC BC
55270 INC H Switch to the table of the part that spills over into the next byte.
55271 LD L,E
55272 LD A,(BC) Fetch the next byte of the buffer.
55273 AND (HL) Combine it with the second part of the shifted mask and data.
55274 LD L,D
55275 XOR (HL)
55276 CPL
55277 DEC H Switch back to the first table.
The last pair.
55278 POP DE Take the mask and the data of the pair off the stack.
55279 LD L,E Combine the byte that is carried with the first part of the shifted mask and data.
55280 AND (HL)
55281 LD L,D
55282 XOR (HL)
55283 CPL
55284 LD (BC),A Store the byte in the buffer and move on to the next one.
55285 INC BC
55286 INC H Switch to the table of the part that spills over into the next byte.
55287 LD L,E
55288 LD A,(BC) Fetch the next byte of the buffer.
55289 AND (HL) Combine it with the second part of the shifted mask and data.
55290 LD L,D
55291 XOR (HL)
55292 CPL
55293 DEC H Switch back to the first table.
55294 LD (BC),A Store the last byte of the line.
This entry point is used by the routine at DrawAlignedColumns.
DrawLines_Next 55295 LD A,C Fetch the low byte of the address in the buffer.
55296 ADD A,0 Add the step to the start of the next line, which is changed for the width of the sprite.
55298 LD C,A Store it.
55299 LD A,B Fetch the high byte of the address in the buffer.
55300 ADC A,0 Add the carry, as the step is a single byte.
55302 LD B,A Store it.
55303 EX AF,AF' Restore the number of lines left.
55304 DEC A Count down the lines.
55305 JP NZ,DrawLines Jump to DrawLines until all of the lines are drawn.
55308 LD SP,(23465) Restore the stack pointer from SavedStackPointer.
55312 RET Return.
View the equivalent code in;
Prev: 55168 Up: Map Next: 55313