Prev: 54839 Up: Map Next: 55748
55188: Draw Clipped Wide Sprite
Draws a 2-byte-wide, 12-row entity sprite to the screen by toggling each row's pixel data against the existing screen content. Reads the sprite type and screen position from the entity record, looks up the pixel data address in Sprite_Pixel_Data_Table, then renders twelve rows of two bytes each. Each row is bounds-checked against the play area (16 top / 185 bottom); rows outside the play area are skipped. Alternate registers carry the Y position and column offset across all twelve rows.
Input
HL Entity record pointer
Draw_Clipped_Wide_Sprite 55188 LD B,H Stash the entity record pointer in BC and read the sprite type.
55189 LD C,L
55190 LD E,(HL)
55191 SLA E Double the sprite type and look up the pixel data address in Sprite_Pixel_Data_Table.
55193 LD D,0
55195 LD HL,50700
55198 ADD HL,DE
55199 LD E,(HL)
55200 INC HL
55201 LD D,(HL)
55202 LD H,B Restore the entity record pointer and advance to the screen column byte.
55203 LD L,C
55204 INC HL
55205 LD B,70 Load the screen column, stash it in D', and advance to the screen row byte.
55207 LD C,(HL)
55208 LD A,C
55209 EXX
55210 LD D,A
55211 EXX
55212 INC HL
55213 SLA C Shift the column into the screen address high byte.
55215 RL B
55217 PUSH BC Stash the screen address high byte on the stack.
55218 LD A,(HL) Load the screen row byte, extract the block-row bits via three right rotations, and combine with the column to build the screen address in BC.
55219 AND A
55220 LD HL,0
55223 RRA
55224 RR L
55226 RRA
55227 RR L
55229 RRA
55230 RR L
55232 EXX
55233 LD C,A
55234 EXX
55235 LD A,L
55236 RRCA
55237 LD L,A
55238 RRCA
55239 ADD A,L
55240 LD L,A
55241 ADD HL,DE
55242 LD B,H
55243 LD C,L
55244 POP HL
55245 EXX
55246 LD A,D
55247 EXX
Row 1: return if below the play area, skip if above, else draw.
55248 CP 185 Return if the entity's Y position is below the play area bottom (185).
55250 RET NC
55251 CP 16 Skip row 1 if above the play area top (16).
55253 JR C,Draw_Clipped_Wide_Sprite_Row2
55255 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
55256 LD A,C
55257 EXX
55258 ADD A,(HL)
55259 LD E,A
55260 INC HL
55261 LD D,(HL)
55262 INC HL
55263 EX DE,HL
55264 LD A,(BC)
55265 XOR (HL)
55266 LD (HL),A
55267 INC BC
55268 INC HL
55269 LD A,(BC)
55270 XOR (HL)
55271 LD (HL),A
55272 EX DE,HL
55273 DEC BC
Row 2: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row2 55274 INC BC Advance the sprite data pointer past the skipped row.
55275 INC BC
55276 EXX Advance Y by the row stride and decrement the step count.
55277 LD A,B
55278 ADD A,D
55279 LD D,A
55280 LD A,B
55281 EXX
55282 DEC A
Draw_Clipped_Wide_Sprite_Row2_Stride 55283 INC HL Step HL forward to the next pixel row.
55284 INC HL
55285 DEC A
55286 JR NZ,Draw_Clipped_Wide_Sprite_Row2_Stride
55288 EXX Reload the Y position and return if below the play area bottom.
55289 LD A,D
55290 EXX
55291 CP 185
55293 RET NC
55294 CP 16 Skip row 2 if above the play area top.
55296 JR C,Draw_Clipped_Wide_Sprite_Row3
55298 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
55299 LD A,C
55300 EXX
55301 ADD A,(HL)
55302 LD E,A
55303 INC HL
55304 LD D,(HL)
55305 INC HL
55306 EX DE,HL
55307 LD A,(BC)
55308 XOR (HL)
55309 LD (HL),A
55310 INC BC
55311 INC HL
55312 LD A,(BC)
55313 XOR (HL)
55314 LD (HL),A
55315 EX DE,HL
55316 DEC BC
Row 3: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row3 55317 INC BC Advance the sprite data pointer past the skipped row.
55318 INC BC
55319 EXX Advance Y by the row stride and decrement the step count.
55320 LD A,B
55321 ADD A,D
55322 LD D,A
55323 LD A,B
55324 EXX
55325 DEC A
Draw_Clipped_Wide_Sprite_Row3_Stride 55326 INC HL Step HL forward to the next pixel row.
55327 INC HL
55328 DEC A
55329 JR NZ,Draw_Clipped_Wide_Sprite_Row3_Stride
55331 EXX Reload the Y position and return if below the play area bottom.
55332 LD A,D
55333 EXX
55334 CP 185
55336 RET NC
55337 CP 16 Skip row 3 if above the play area top.
55339 JR C,Draw_Clipped_Wide_Sprite_Row4
55341 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
55342 LD A,C
55343 EXX
55344 ADD A,(HL)
55345 LD E,A
55346 INC HL
55347 LD D,(HL)
55348 INC HL
55349 EX DE,HL
55350 LD A,(BC)
55351 XOR (HL)
55352 LD (HL),A
55353 INC BC
55354 INC HL
55355 LD A,(BC)
55356 XOR (HL)
55357 LD (HL),A
55358 EX DE,HL
55359 DEC BC
Row 4: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row4 55360 INC BC Advance the sprite data pointer past the skipped row.
55361 INC BC
55362 EXX Advance Y by the row stride and decrement the step count.
55363 LD A,B
55364 ADD A,D
55365 LD D,A
55366 LD A,B
55367 EXX
55368 DEC A
Draw_Clipped_Wide_Sprite_Row4_Stride 55369 INC HL Step HL forward to the next pixel row.
55370 INC HL
55371 DEC A
55372 JR NZ,Draw_Clipped_Wide_Sprite_Row4_Stride
55374 EXX Reload the Y position and return if below the play area bottom.
55375 LD A,D
55376 EXX
55377 CP 185
55379 RET NC
55380 CP 16 Skip row 4 if above the play area top.
55382 JR C,Draw_Clipped_Wide_Sprite_Row5
55384 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
55385 LD A,C
55386 EXX
55387 ADD A,(HL)
55388 LD E,A
55389 INC HL
55390 LD D,(HL)
55391 INC HL
55392 EX DE,HL
55393 LD A,(BC)
55394 XOR (HL)
55395 LD (HL),A
55396 INC BC
55397 INC HL
55398 LD A,(BC)
55399 XOR (HL)
55400 LD (HL),A
55401 EX DE,HL
55402 DEC BC
Row 5: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row5 55403 INC BC Advance the sprite data pointer past the skipped row.
55404 INC BC
55405 EXX Advance Y by the row stride and decrement the step count.
55406 LD A,B
55407 ADD A,D
55408 LD D,A
55409 LD A,B
55410 EXX
55411 DEC A
Draw_Clipped_Wide_Sprite_Row5_Stride 55412 INC HL Step HL forward to the next pixel row.
55413 INC HL
55414 DEC A
55415 JR NZ,Draw_Clipped_Wide_Sprite_Row5_Stride
55417 EXX Reload the Y position and return if below the play area bottom.
55418 LD A,D
55419 EXX
55420 CP 185
55422 RET NC
55423 CP 16 Skip row 5 if above the play area top.
55425 JR C,Draw_Clipped_Wide_Sprite_Row6
55427 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
55428 LD A,C
55429 EXX
55430 ADD A,(HL)
55431 LD E,A
55432 INC HL
55433 LD D,(HL)
55434 INC HL
55435 EX DE,HL
55436 LD A,(BC)
55437 XOR (HL)
55438 LD (HL),A
55439 INC BC
55440 INC HL
55441 LD A,(BC)
55442 XOR (HL)
55443 LD (HL),A
55444 EX DE,HL
55445 DEC BC
Row 6: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row6 55446 INC BC Advance the sprite data pointer past the skipped row.
55447 INC BC
55448 EXX Advance Y by the row stride and decrement the step count.
55449 LD A,B
55450 ADD A,D
55451 LD D,A
55452 LD A,B
55453 EXX
55454 DEC A
Draw_Clipped_Wide_Sprite_Row6_Stride 55455 INC HL Step HL forward to the next pixel row.
55456 INC HL
55457 DEC A
55458 JR NZ,Draw_Clipped_Wide_Sprite_Row6_Stride
55460 EXX Reload the Y position and return if below the play area bottom.
55461 LD A,D
55462 EXX
55463 CP 185
55465 RET NC
55466 CP 16 Skip row 6 if above the play area top.
55468 JR C,Draw_Clipped_Wide_Sprite_Row7
55470 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
55471 LD A,C
55472 EXX
55473 ADD A,(HL)
55474 LD E,A
55475 INC HL
55476 LD D,(HL)
55477 INC HL
55478 EX DE,HL
55479 LD A,(BC)
55480 XOR (HL)
55481 LD (HL),A
55482 INC BC
55483 INC HL
55484 LD A,(BC)
55485 XOR (HL)
55486 LD (HL),A
55487 EX DE,HL
55488 DEC BC
Row 7: crosses a character-cell boundary; the Y step doubles to advance to the next screen-third.
Draw_Clipped_Wide_Sprite_Row7 55489 INC BC Advance the sprite data pointer past the skipped row.
55490 INC BC
55491 EXX Advance the Y position to the next character row boundary in alternate registers.
55492 LD A,B
55493 ADD A,A
55494 DEC A
55495 ADD A,D
55496 LD D,A
55497 LD A,B
55498 ADD A,A
55499 EXX
55500 DEC A Adjust the loop counter for the double-height step.
55501 DEC A
Draw_Clipped_Wide_Sprite_Row7_Stride 55502 INC HL Step HL forward to the next pixel row.
55503 INC HL
55504 DEC A
55505 JR NZ,Draw_Clipped_Wide_Sprite_Row7_Stride
55507 EXX Reload the Y position and return if below the play area bottom.
55508 LD A,D
55509 EXX
55510 CP 185
55512 RET NC
55513 CP 16 Skip row 7 if above the play area top.
55515 JR C,Draw_Clipped_Wide_Sprite_Row8
55517 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
55518 LD A,C
55519 EXX
55520 ADD A,(HL)
55521 LD E,A
55522 INC HL
55523 LD D,(HL)
55524 INC HL
55525 EX DE,HL
55526 LD A,(BC)
55527 XOR (HL)
55528 LD (HL),A
55529 INC BC
55530 INC HL
55531 LD A,(BC)
55532 XOR (HL)
55533 LD (HL),A
55534 EX DE,HL
55535 DEC BC
Row 8: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row8 55536 INC BC Advance the sprite data pointer past the skipped row.
55537 INC BC
55538 EXX Advance Y by the row stride and decrement the step count.
55539 LD A,B
55540 ADD A,D
55541 LD D,A
55542 LD A,B
55543 EXX
55544 DEC A
Draw_Clipped_Wide_Sprite_Row8_Stride 55545 INC HL Step HL forward to the next pixel row.
55546 INC HL
55547 DEC A
55548 JR NZ,Draw_Clipped_Wide_Sprite_Row8_Stride
55550 EXX Reload the Y position and return if below the play area bottom.
55551 LD A,D
55552 EXX
55553 CP 185
55555 RET NC
55556 CP 16 Skip row 8 if above the play area top.
55558 JR C,Draw_Clipped_Wide_Sprite_Row9
55560 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
55561 LD A,C
55562 EXX
55563 ADD A,(HL)
55564 LD E,A
55565 INC HL
55566 LD D,(HL)
55567 INC HL
55568 EX DE,HL
55569 LD A,(BC)
55570 XOR (HL)
55571 LD (HL),A
55572 INC BC
55573 INC HL
55574 LD A,(BC)
55575 XOR (HL)
55576 LD (HL),A
55577 EX DE,HL
55578 DEC BC
Row 9: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row9 55579 INC BC Advance the sprite data pointer past the skipped row.
55580 INC BC
55581 EXX Advance Y by the row stride and decrement the step count.
55582 LD A,B
55583 ADD A,D
55584 LD D,A
55585 LD A,B
55586 EXX
55587 DEC A
Draw_Clipped_Wide_Sprite_Row9_Stride 55588 INC HL Step HL forward to the next pixel row.
55589 INC HL
55590 DEC A
55591 JR NZ,Draw_Clipped_Wide_Sprite_Row9_Stride
55593 EXX Reload the Y position and return if below the play area bottom.
55594 LD A,D
55595 EXX
55596 CP 185
55598 RET NC
55599 CP 16 Skip row 9 if above the play area top.
55601 JR C,Draw_Clipped_Wide_Sprite_Row10
55603 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
55604 LD A,C
55605 EXX
55606 ADD A,(HL)
55607 LD E,A
55608 INC HL
55609 LD D,(HL)
55610 INC HL
55611 EX DE,HL
55612 LD A,(BC)
55613 XOR (HL)
55614 LD (HL),A
55615 INC BC
55616 INC HL
55617 LD A,(BC)
55618 XOR (HL)
55619 LD (HL),A
55620 EX DE,HL
55621 DEC BC
Row 10: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row10 55622 INC BC Advance the sprite data pointer past the skipped row.
55623 INC BC
55624 EXX Advance Y by the row stride and decrement the step count.
55625 LD A,B
55626 ADD A,D
55627 LD D,A
55628 LD A,B
55629 EXX
55630 DEC A
Draw_Clipped_Wide_Sprite_Row10_Stride 55631 INC HL Step HL forward to the next pixel row.
55632 INC HL
55633 DEC A
55634 JR NZ,Draw_Clipped_Wide_Sprite_Row10_Stride
55636 EXX Reload the Y position and return if below the play area bottom.
55637 LD A,D
55638 EXX
55639 CP 185
55641 RET NC
55642 CP 16 Skip row 10 if above the play area top.
55644 JR C,Draw_Clipped_Wide_Sprite_Row11
55646 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
55647 LD A,C
55648 EXX
55649 ADD A,(HL)
55650 LD E,A
55651 INC HL
55652 LD D,(HL)
55653 INC HL
55654 EX DE,HL
55655 LD A,(BC)
55656 XOR (HL)
55657 LD (HL),A
55658 INC BC
55659 INC HL
55660 LD A,(BC)
55661 XOR (HL)
55662 LD (HL),A
55663 EX DE,HL
55664 DEC BC
Row 11: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row11 55665 INC BC Advance the sprite data pointer past the skipped row.
55666 INC BC
55667 EXX Advance Y by the row stride and decrement the step count.
55668 LD A,B
55669 ADD A,D
55670 LD D,A
55671 LD A,B
55672 EXX
55673 DEC A
Draw_Clipped_Wide_Sprite_Row11_Stride 55674 INC HL Step HL forward to the next pixel row.
55675 INC HL
55676 DEC A
55677 JR NZ,Draw_Clipped_Wide_Sprite_Row11_Stride
55679 EXX Reload the Y position and return if below the play area bottom.
55680 LD A,D
55681 EXX
55682 CP 185
55684 RET NC
55685 CP 16 Skip row 11 if above the play area top.
55687 JR C,Draw_Clipped_Wide_Sprite_Row12
55689 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
55690 LD A,C
55691 EXX
55692 ADD A,(HL)
55693 LD E,A
55694 INC HL
55695 LD D,(HL)
55696 INC HL
55697 EX DE,HL
55698 LD A,(BC)
55699 XOR (HL)
55700 LD (HL),A
55701 INC BC
55702 INC HL
55703 LD A,(BC)
55704 XOR (HL)
55705 LD (HL),A
55706 EX DE,HL
55707 DEC BC
Row 12 (final): advance sprite data if skipped, step Y, step row table, draw and return.
Draw_Clipped_Wide_Sprite_Row12 55708 INC BC Advance the sprite data pointer past the skipped row.
55709 INC BC
55710 EXX Advance Y by the row stride and decrement the step count.
55711 LD A,B
55712 ADD A,D
55713 LD D,A
55714 LD A,B
55715 EXX
55716 DEC A
Draw_Clipped_Wide_Sprite_Row12_Stride 55717 INC HL Step HL forward to the next pixel row.
55718 INC HL
55719 DEC A
55720 JR NZ,Draw_Clipped_Wide_Sprite_Row12_Stride
55722 EXX Reload the Y position and return if below the play area bottom.
55723 LD A,D
55724 EXX
55725 CP 185
55727 RET NC
55728 CP 16 Return if row 12 is above the play area top.
55730 RET C
55731 EXX Compute the screen address, toggle the sprite row's two pixel bytes onto the screen, and return.
55732 LD A,C
55733 EXX
55734 ADD A,(HL)
55735 LD E,A
55736 INC HL
55737 LD D,(HL)
55738 EX DE,HL
55739 LD A,(BC)
55740 XOR (HL)
55741 LD (HL),A
55742 INC BC
55743 INC HL
55744 LD A,(BC)
55745 XOR (HL)
55746 LD (HL),A
55747 RET
Prev: 54839 Up: Map Next: 55748