Prev: 46272 Up: Map Next: 46400
46312: Draw Shifted Rows
Draws the rows of a sprite that is shifted by one to three pixels, using the stack pointer to read the sprite data. The shifted bytes are found in the tables that start at the page in H, and one more byte than the width is drawn. There are four entry points, which are for widths of four, three, two and one bytes. The address in the table at RowRoutineTable is the entry point for the width.
Input
DE The address in the screen buffer
H The page of the table for the shift
B The number of rows
SP The sprite data
DrawShiftedRows 46312 POP BC Draw one byte of the shifted sprite.
46313 LD L,C
46314 AND (HL)
46315 LD L,B
46316 XOR (HL)
46317 CPL
46318 LD (DE),A
46319 INC DE
46320 INC H
46321 LD L,C
46322 LD A,(DE)
46323 AND (HL)
46324 LD L,B
46325 XOR (HL)
46326 CPL
46327 DEC H
DrawShiftedRows_Three 46328 POP BC Draw one byte of the shifted sprite.
46329 LD L,C
46330 AND (HL)
46331 LD L,B
46332 XOR (HL)
46333 CPL
46334 LD (DE),A
46335 INC DE
46336 INC H
46337 LD L,C
46338 LD A,(DE)
46339 AND (HL)
46340 LD L,B
46341 XOR (HL)
46342 CPL
46343 DEC H
This entry point is used by the routine at DrawBlockBytes.
DrawShiftedRows_Two 46344 POP BC Draw one byte of the shifted sprite.
46345 LD L,C
46346 AND (HL)
46347 LD L,B
46348 XOR (HL)
46349 CPL
46350 LD (DE),A
46351 INC DE
46352 INC H
46353 LD L,C
46354 LD A,(DE)
46355 AND (HL)
46356 LD L,B
46357 XOR (HL)
46358 CPL
46359 DEC H
This entry point is used by the routine at DrawNeedleTip.
DrawShiftedRows_One 46360 POP BC Draw one byte of the shifted sprite.
46361 LD L,C
46362 AND (HL)
46363 LD L,B
46364 XOR (HL)
46365 CPL
46366 LD (DE),A
46367 INC DE
46368 INC H
46369 LD L,C
46370 LD A,(DE)
46371 AND (HL)
46372 LD L,B
46373 XOR (HL)
46374 CPL
46375 DEC H
The row count is held in the alternate accumulator. The width subtracted below, and the two jumps, are patched before the routine is entered.
DrawShiftedRows_Store 46376 LD (DE),A Write the prepared byte.
46377 EX AF,AF' Count a row, and finish when none remain.
46378 DEC A
46379 JR Z,DrawShiftedRows_Return
46381 EX AF,AF' Bring the sprite byte back.
46382 LD A,E Step back by the patched width.
46383 SUB 0
46385 LD E,A
46386 LD A,(DE) Read the first byte of the next row.
DrawShiftedRows_Step 46387 JP NC,DrawShiftedRows_Step Stay on this page if the step did not borrow.
46390 DEC D Move to the previous page and read its byte.
46391 LD A,(DE)
DrawShiftedRows_Patched 46392 JP DrawShiftedRows_Patched Draw the next row. The target is patched.
DrawShiftedRows_Return 46395 LD SP,(23770) Restore the stack pointer.
46399 RET Return.
Prev: 46272 Up: Map Next: 46400