Prev: 49502 Up: Map Next: 50167
50049: Draw Block Shape
Used by the routine at DrawBlock.
Copies the four step bytes of the shape into this routine and sign-extends each one, then draws the block. A shape below 9 and shape 17 is drawn here a row at a time. Shapes 9 to 16 are drawn by DrawBlockShapeThree and shapes 18 to 21 by DrawBlockShapeTwo. DrawBlock patches in the shape number and the row count.
Input
IY The shape
Each step byte of the shape is sign-extended into a word that the row loops add to the screen address and the sprite address.
DrawBlockShape 50049 LD A,(IY+1) Read the shape's first step.
50052 LD (50140),A Keep it as the low byte of a row step.
50055 RLA Sign-extend it when its top bit is set.
50056 LD A,0
50058 JR NC,DrawBlockShape_High
50060 DEC A The high byte is 255.
DrawBlockShape_High 50061 LD (50141),A Keep the high byte of the row step.
50064 LD A,(IY+2) Read the shape's second step.
50067 LD (50145),A Keep it as the low byte of the other row step.
50070 RLA Sign-extend it when its top bit is set.
50071 LD A,0
50073 JR NC,DrawBlockShape_High2
50075 DEC A The high byte is 255.
DrawBlockShape_High2 50076 LD (50146),A Keep that high byte.
50079 LD A,(IY+4) Read the shape's fourth byte.
50082 LD (50154),A Keep it as the low byte of a column step.
50085 RLA Sign-extend it when its top bit is set.
50086 LD A,0
50088 JR NC,DrawBlockShape_High3
50090 DEC A The high byte is 255.
DrawBlockShape_High3 50091 LD (50155),A Keep that high byte.
50094 LD A,(IY+3) Read the shape's third byte.
50097 LD (50160),A Keep it as the low byte of the other column step.
50100 RLA Sign-extend it when its top bit is set.
50101 LD A,0
50103 JR NC,DrawBlockShape_High4
50105 DEC A The high byte is 255.
DrawBlockShape_High4 50106 LD (50161),A Keep that high byte.
50109 LD A,0 Read the shape number. The byte is patched.
50111 CP 9 A shape below 9 is drawn here.
50113 JR C,DrawBlockShape_Second
50115 CP 17 Shapes 9 to 16 use the third shape.
50117 JP C,DrawBlockShapeThree
DrawBlockShape_Second 50120 CP 18 Shape 17 is drawn here.
50122 JR C,DrawBlockShape_Rows
50124 CP 22 Shapes 18 to 21 use the second shape.
50126 JP C,DrawBlockShapeTwo
DrawBlockShape_Rows 50129 PUSH BC Remember the column count and both addresses.
50130 PUSH HL
50131 PUSH DE
50132 LD B,0 Take the patched row count.
DrawBlockShape_Loop 50134 PUSH BC Remember how many rows remain.
50135 CALL DrawBlockRow Draw this row.
This entry point is used by the routine at DrawBlockShapeTwo.
DrawBlockShape_Resume 50138 EXX Step both addresses on by the row steps.
50139 LD BC,0
50142 ADD HL,BC
50143 EX DE,HL
50144 LD BC,0
50147 ADD HL,BC
50148 EX DE,HL
50149 POP BC Bring the row count back.
50150 DJNZ DrawBlockShape_Loop Repeat for the remaining rows.
50152 POP HL Restore the screen address.
50153 LD BC,0 Step on by the column step.
50156 ADD HL,BC
50157 EX DE,HL Switch the addresses.
50158 POP HL Restore the sprite address.
50159 LD BC,0 Step it on by the other column step.
50162 ADD HL,BC
50163 POP BC Bring the column count back.
50164 DJNZ DrawBlockShape_Rows Repeat for the remaining columns.
50166 RET Return.
Prev: 49502 Up: Map Next: 50167