Prev: C556 Up: Map Next: C629
C59A: Draw Block Row
Used by the routines at DrawBlockShape, DrawBlockShapeTwo and DrawBlockShapeThree.
Draws one row of a block into the screen buffer. A row outside the view is left undrawn. The tile is the word at 666E indexed by the patched row count, and FlipBlockData flips it when its top bit differs. Two masked bytes are drawn, then the routine steps up one screen row, for the height of the row.
Input
HL The first coordinate of the position
DE The second coordinate of the position
The position arrives in the alternate registers. A row whose page, column or size is outside the view is left undrawn.
DrawBlockRow C59A PUSH HL Take the position from the alternate registers.
C59B PUSH DE
C59C EXX
C59D POP DE
C59E POP HL
C59F LD A,H Return unless the row is on the drawable page.
C5A0 CP $80
C5A2 RET NZ
C5A3 LD A,L Return when the column is past the view.
C5A4 CP $B1
C5A6 RET NC
C5A7 ADD A,(IY+$05) Return when the row size does not reach the view.
C5AA CP $C0
C5AC RET C
C5AD LD A,D Return unless the other address is on the same page.
C5AE CP $80
C5B0 RET NZ
C5B1 LD H,E Keep the row.
C5B2 LD B,(IY+$06) Take the shape's position byte as the height.
C5B5 LD A,E Start with no column offset.
C5B6 LD C,$00
C5B8 SUB B The row starts above the view when it is below that position.
C5B9 JR C,DrawBlockRow_Above
C5BB CP $78 A row at 78 or beyond is off the view.
C5BD RET NC
C5BE LD A,H Shorten a row that starts above the drawable page.
C5BF SUB $7F
C5C1 JR C,DrawBlockRow_Tile
C5C3 LD C,A Shorten the height by four times that overflow.
C5C4 SLA C
C5C6 SLA C
C5C8 NEG
C5CA ADD A,B
C5CB LD B,A
C5CC LD H,$7F Start the row at 7F.
C5CE JR DrawBlockRow_Tile
DrawBlockRow_Above C5D0 LD B,H Use the whole height when the row starts above the position.
C5D1 INC B
DrawBlockRow_Tile C5D2 LD A,L A column of B0 needs no extra offset.
C5D3 CP $B0
C5D5 JR Z,DrawBlockRow_Draw
C5D7 LD A,(IY+$05) A row size of 10 is not drawn.
C5DA CP $10
C5DC RET Z
C5DD LD A,(IY+$06) The offset is four times the position byte.
C5E0 ADD A,A
C5E1 ADD A,A
C5E2 ADD A,C
C5E3 LD C,A
DrawBlockRow_Draw C5E4 LD A,H Keep the row number.
C5E5 LD HL,$666E Look the tile up. The index and its high byte are patched.
C5E8 LD E,$00
C5EA LD D,$00
C5EC ADD HL,DE Add the index.
C5ED LD E,A Keep the row number.
C5EE LD A,(HL) Read the tile address.
C5EF INC HL
C5F0 LD H,(HL)
C5F1 LD L,A
C5F2 LD A,$00 Compare the tile with the patched top bit.
C5F4 XOR (HL)
C5F5 CALL NZ,FlipBlockData Flip the tile when they differ.
C5F8 LD A,L Add the column offset to the tile address.
C5F9 ADD A,C
C5FA LD L,A
C5FB JR NC,DrawBlockRow_Offset
C5FD INC H Count the carry in the high byte.
DrawBlockRow_Offset C5FE INC HL Remember the stack and read the tile through it.
C5FF LD ($5CDA),SP
C603 LD SP,HL
C604 EX DE,HL Turn the row number into a screen address, 18 bytes per row.
C605 ADD HL,HL
C606 ADD HL,HL
C607 ADD HL,HL
C608 LD E,L
C609 LD D,H
C60A ADD HL,HL
C60B ADD HL,DE
C60C LD DE,($5CBB) Add the strip address.
C610 ADD HL,DE
This entry point is used by the routine at DrawBlockBytes.
DrawBlockRow_Loop C611 POP DE Draw one byte of the row.
C612 LD A,E
C613 CPL
C614 AND (HL)
C615 OR D
C616 LD (HL),A
C617 INC HL
C618 POP DE Draw the other byte of the row.
C619 LD A,E
C61A CPL
C61B AND (HL)
C61C OR D
C61D LD (HL),A
C61E LD DE,$FFE7 Step up to the next row of the screen.
C621 ADD HL,DE
C622 DJNZ DrawBlockRow_Loop Repeat for the remaining rows.
C624 LD SP,($5CDA) Restore the stack pointer.
C628 RET Return.
Prev: C556 Up: Map Next: C629