![]() |
Routines |
| Prev: 46159 | Up: Map | Next: 46304 |
|
Used by the routine at DrawObject.
Draws the rows of a sprite, which is shifted if its x co-ordinate is not a multiple of eight. Both ways of drawing a sprite arrive here with the number of rows to draw in A.
The shifted code has one unit for each byte column, and the jump at DrawLines_Jump is patched with a displacement that enters the run at the first unit that is needed. Each unit takes a pair of sprite bytes, and uses the shift tables built by BuildLookupTables to split each into the part that goes into the byte of the buffer, and the part that goes into the next byte. The table for the high part is in the page in H, and the table for the low part is in the next page.
For the aligned rows, the displacement jumps into the run of units of DrawAlignedColumns instead.
|
||||||||||||
| DrawLines | 46201 | EX AF,AF' | Stash the number of rows in AF'. | |||||||||
| 46202 | LD A,(BC) | Fetch the first byte of the buffer row. | ||||||||||
| DrawLines_Jump | 46203 | JR DrawLines_Jump | Jump into the run of units. The displacement is patched at 46204. | |||||||||
|
The first unit of the run, which is used by sprites of five bytes wide.
|
||||||||||||
| DrawLines_FirstUnit | 46205 | POP DE | Fetch the mask byte into E and the pixel byte into D. | |||||||||
| 46206 | LD L,E | Look up the mask byte. | ||||||||||
| 46207 | AND (HL) | Clear the buffer bits under the high part of the mask. | ||||||||||
| 46208 | LD L,D | Merge in the high part of the pixel byte. | ||||||||||
| 46209 | XOR (HL) | |||||||||||
| 46210 | CPL | |||||||||||
| 46211 | LD (BC),A | Write the byte to the buffer. | ||||||||||
| 46212 | INC BC | Move on to the next byte of the buffer. | ||||||||||
| 46213 | INC H | Switch to the page of the low parts. | ||||||||||
| 46214 | LD L,E | Fetch the next byte of the buffer, and look up the mask byte again. | ||||||||||
| 46215 | LD A,(BC) | |||||||||||
| 46216 | AND (HL) | Clear the buffer bits under the low part of the mask. | ||||||||||
| 46217 | LD L,D | Merge in the low part of the pixel byte. | ||||||||||
| 46218 | XOR (HL) | |||||||||||
| 46219 | CPL | |||||||||||
| 46220 | DEC H | Switch back to the page of the high parts. | ||||||||||
|
The second unit, which is used by sprites of four bytes wide.
|
||||||||||||
| 46221 | POP DE | Draw the second byte column. | ||||||||||
| 46222 | LD L,E | |||||||||||
| 46223 | AND (HL) | |||||||||||
| 46224 | LD L,D | |||||||||||
| 46225 | XOR (HL) | |||||||||||
| 46226 | CPL | |||||||||||
| 46227 | LD (BC),A | |||||||||||
| 46228 | INC BC | |||||||||||
| 46229 | INC H | |||||||||||
| 46230 | LD L,E | |||||||||||
| 46231 | LD A,(BC) | |||||||||||
| 46232 | AND (HL) | |||||||||||
| 46233 | LD L,D | |||||||||||
| 46234 | XOR (HL) | |||||||||||
| 46235 | CPL | |||||||||||
| 46236 | DEC H | |||||||||||
|
The third unit, which is used by sprites of three bytes wide.
|
||||||||||||
| 46237 | POP DE | Draw the third byte column. | ||||||||||
| 46238 | LD L,E | |||||||||||
| 46239 | AND (HL) | |||||||||||
| 46240 | LD L,D | |||||||||||
| 46241 | XOR (HL) | |||||||||||
| 46242 | CPL | |||||||||||
| 46243 | LD (BC),A | |||||||||||
| 46244 | INC BC | |||||||||||
| 46245 | INC H | |||||||||||
| 46246 | LD L,E | |||||||||||
| 46247 | LD A,(BC) | |||||||||||
| 46248 | AND (HL) | |||||||||||
| 46249 | LD L,D | |||||||||||
| 46250 | XOR (HL) | |||||||||||
| 46251 | CPL | |||||||||||
| 46252 | DEC H | |||||||||||
|
The fourth unit, which is used by sprites of two bytes wide.
|
||||||||||||
| 46253 | POP DE | Draw the fourth byte column. | ||||||||||
| 46254 | LD L,E | |||||||||||
| 46255 | AND (HL) | |||||||||||
| 46256 | LD L,D | |||||||||||
| 46257 | XOR (HL) | |||||||||||
| 46258 | CPL | |||||||||||
| 46259 | LD (BC),A | |||||||||||
| 46260 | INC BC | |||||||||||
| 46261 | INC H | |||||||||||
| 46262 | LD L,E | |||||||||||
| 46263 | LD A,(BC) | |||||||||||
| 46264 | AND (HL) | |||||||||||
| 46265 | LD L,D | |||||||||||
| 46266 | XOR (HL) | |||||||||||
| 46267 | CPL | |||||||||||
| 46268 | DEC H | |||||||||||
|
The last unit, which is used by sprites of one byte wide.
|
||||||||||||
| 46269 | POP DE | Draw the last byte column. | ||||||||||
| 46270 | LD L,E | |||||||||||
| 46271 | AND (HL) | |||||||||||
| 46272 | LD L,D | |||||||||||
| 46273 | XOR (HL) | |||||||||||
| 46274 | CPL | |||||||||||
| 46275 | LD (BC),A | |||||||||||
| 46276 | INC BC | |||||||||||
| 46277 | INC H | |||||||||||
| 46278 | LD L,E | |||||||||||
| 46279 | LD A,(BC) | |||||||||||
| 46280 | AND (HL) | |||||||||||
| 46281 | LD L,D | |||||||||||
| 46282 | XOR (HL) | |||||||||||
| 46283 | CPL | |||||||||||
| 46284 | DEC H | |||||||||||
|
Write the last byte of the row and move to the next row.
|
||||||||||||
| 46285 | LD (BC),A | Write the last byte to the buffer. | ||||||||||
|
This entry point is used by the routine at DrawAlignedColumns.
|
||||||||||||
| DrawLines_FinishRow | 46286 | LD A,C | Fetch the low byte of the buffer address. | |||||||||
| 46287 | ADD A,0 | Add the amount that takes the address to the start of the next row. This is patched at 46288. | ||||||||||
| 46289 | LD C,A | Set the low byte of the buffer address. | ||||||||||
| 46290 | LD A,B | Fetch the high byte of the buffer address. | ||||||||||
| 46291 | ADC A,0 | Add the carry. | ||||||||||
| 46293 | LD B,A | Set the high byte of the buffer address. | ||||||||||
| 46294 | EX AF,AF' | Fetch the row counter. | ||||||||||
| 46295 | DEC A | Count down the rows and jump to DrawLines until they are drawn. | ||||||||||
| 46296 | JP NZ,DrawLines | |||||||||||
| 46299 | LD SP,(42775) | Restore the stack pointer from SavedStackPointer. | ||||||||||
| 46303 | RET | Return. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: 46159 | Up: Map | Next: 46304 |