Prev: 48478 Up: Map Next: 48612
48550: Draw 2-Wide Sprite Column
Used by the routine at Draw_Sprites.
Draws a two-column-wide sprite to the screen buffer. Looks up the sprite graphic data from the frame table at Graphics_ChickFrame_01, then shifts and ORs the pixel data across two adjacent screen columns. The shift amount is self-modified at 48581.
Input
A Shift amount (self-modified into the code)
HL Screen buffer address
IX Pointer to sprite data (IX+3 = one-indexed frame number)
Look up the sprite graphic data address.
Draw_2Wide_Sprite_Column 48550 LD (48581),A Self-modify the shift jump offset at 48581.
48553 PUSH HL Stash the screen buffer address on the stack.
48554 LD DE,42851 Point DE at Graphics_ChickFrame_01 (2-wide sprite frame table base).
48557 LD A,(IX+3) Load the frame ID from *IX+3 and decrement to make it zero-indexed.
48560 DEC A
48561 LD L,A Multiply the frame index by 8 and add to the table base to get the graphic data address.
48562 LD H,0
48564 ADD HL,HL
48565 ADD HL,HL
48566 ADD HL,HL
48567 ADD HL,DE
48568 EX DE,HL Exchange so DE points to the sprite graphic data.
48569 POP HL Restore the screen buffer address from the stack.
Draw eight pixel rows of the sprite across two columns.
48570 LD B,8 Set the row counter to 8 in B.
48572 LD C,7 Set the row boundary mask to 7 in C.
Draw_2Wide_Row_Loop 48574 PUSH DE Stash the graphic data pointer and screen buffer address on the stack.
48575 PUSH HL
48576 LD A,(DE) Load the graphic byte from *DE into L; set H to 0.
48577 LD L,A
48578 LD H,0
48580 JR Shift_Fine Jump into the shift sequence (self-modified offset controls the number of shifts applied).
48582 ADD HL,HL Shift HL left five positions (coarse shift).
48583 ADD HL,HL
48584 ADD HL,HL
48585 ADD HL,HL
48586 ADD HL,HL
Shift_Fine 48587 ADD HL,HL Shift HL left three more positions (fine shift); the total shift spreads the sprite byte across H and L.
48588 ADD HL,HL
48589 ADD HL,HL
48590 POP DE Restore the screen buffer address onto the stack and copy to DE.
48591 PUSH DE
48592 EX DE,HL OR the high byte of the shifted data onto the first screen column at *HL.
48593 LD A,D
48594 OR (HL)
48595 LD (HL),A
48596 INC L Advance to the next column and OR the low byte onto the second screen column at *HL.
48597 LD A,E
48598 OR (HL)
48599 LD (HL),A
48600 POP HL Restore the screen buffer address and graphic data pointer from the stack.
48601 POP DE
48602 INC H Advance to the next pixel row in the screen buffer.
48603 INC DE Advance to the next graphic byte.
48604 LD A,H If the pixel row has crossed a character boundary (masked with C), call Adjust_Screen_Address to adjust the screen buffer address.
48605 AND C
48606 CALL Z,Adjust_Screen_Address
48609 DJNZ Draw_2Wide_Row_Loop Decrease the row counter and loop back to Draw_2Wide_Row_Loop until all 8 rows are drawn.
48611 RET Return.
Prev: 48478 Up: Map Next: 48612