Prev: BD5E Up: Map Next: BDE4
BDA6: 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 BDC5.
Input
A Shift amount (self-modified into the code)
HL Screen buffer address
IX Pointer to sprite data (IX+03 = one-indexed frame number)
Look up the sprite graphic data address.
Draw_2Wide_Sprite_Column BDA6 LD ($BDC5),A Self-modify the shift jump offset at BDC5.
BDA9 PUSH HL Stash the screen buffer address on the stack.
BDAA LD DE,$A763 Point DE at Graphics_ChickFrame_01 (2-wide sprite frame table base).
BDAD LD A,(IX+$03) Load the frame ID from *IX+03 and decrement to make it zero-indexed.
BDB0 DEC A
BDB1 LD L,A Multiply the frame index by 08 and add to the table base to get the graphic data address.
BDB2 LD H,$00
BDB4 ADD HL,HL
BDB5 ADD HL,HL
BDB6 ADD HL,HL
BDB7 ADD HL,DE
BDB8 EX DE,HL Exchange so DE points to the sprite graphic data.
BDB9 POP HL Restore the screen buffer address from the stack.
Draw eight pixel rows of the sprite across two columns.
BDBA LD B,$08 Set the row counter to 08 in B.
BDBC LD C,$07 Set the row boundary mask to 07 in C.
Draw_2Wide_Row_Loop BDBE PUSH DE Stash the graphic data pointer and screen buffer address on the stack.
BDBF PUSH HL
BDC0 LD A,(DE) Load the graphic byte from *DE into L; set H to 00.
BDC1 LD L,A
BDC2 LD H,$00
BDC4 JR Shift_Fine Jump into the shift sequence (self-modified offset controls the number of shifts applied).
BDC6 ADD HL,HL Shift HL left five positions (coarse shift).
BDC7 ADD HL,HL
BDC8 ADD HL,HL
BDC9 ADD HL,HL
BDCA ADD HL,HL
Shift_Fine BDCB ADD HL,HL Shift HL left three more positions (fine shift); the total shift spreads the sprite byte across H and L.
BDCC ADD HL,HL
BDCD ADD HL,HL
BDCE POP DE Restore the screen buffer address onto the stack and copy to DE.
BDCF PUSH DE
BDD0 EX DE,HL OR the high byte of the shifted data onto the first screen column at *HL.
BDD1 LD A,D
BDD2 OR (HL)
BDD3 LD (HL),A
BDD4 INC L Advance to the next column and OR the low byte onto the second screen column at *HL.
BDD5 LD A,E
BDD6 OR (HL)
BDD7 LD (HL),A
BDD8 POP HL Restore the screen buffer address and graphic data pointer from the stack.
BDD9 POP DE
BDDA INC H Advance to the next pixel row in the screen buffer.
BDDB INC DE Advance to the next graphic byte.
BDDC 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.
BDDD AND C
BDDE CALL Z,Adjust_Screen_Address
BDE1 DJNZ Draw_2Wide_Row_Loop Decrease the row counter and loop back to Draw_2Wide_Row_Loop until all 08 rows are drawn.
BDE3 RET Return.
Prev: BD5E Up: Map Next: BDE4