Prev: 50167 Up: Map Next: 50466
50200: Draw Block Shape Three
Used by the routine at DrawBlockShape.
Draws a block whose shape number is 9 to 16. DrawBlockShape has already copied the shape's steps into this routine. The shape number chooses the edges: shapes below 11 use one edge, 11 and 12 leave the edges alone, 13 and 14 use two, and 15 and 16 lengthen the row count by 14 as well. Each column is drawn a row at a time by DrawBlockRow.
The shape number is in A. It chooses how many edge steps this column adds, and which edges are written before a single-row column.
DrawBlockShapeThree 50200 PUSH HL Remember the screen address.
50201 LD L,1 One edge step for a shape below 11.
50203 LD H,L
50204 CP 11
50206 JR C,DrawBlockShapeThree_Steps
50208 INC H Two edge steps for shape 13 or 14.
50209 CP 13
50211 JR Z,DrawBlockShapeThree_Steps
50213 CP 14
50215 JR Z,DrawBlockShapeThree_Steps
50217 INC L None for shape 11 or 12 and three for a higher shape.
50218 INC H
50219 CP 14
50221 JR NC,DrawBlockShapeThree_Steps
50223 LD H,0
DrawBlockShapeThree_Steps 50225 LD A,L Remember how many steps this column adds.
50226 LD (50436),A
50229 LD A,H Remember the edge choice.
50230 LD (50287),A
50233 LD (50417),A
50236 XOR A Clear the running total of steps.
50237 LD (50434),A
50240 LD A,(50133) Copy the row count into the row loop.
50243 LD (50281),A
50246 LD HL,(50136) Copy the row routine and the four steps from the shape.
50249 LD (50379),HL
50252 LD HL,(50140)
50255 LD (50383),HL
50258 LD HL,(50145)
50261 LD (50388),HL
50264 LD HL,(50154)
50267 LD (50451),HL
50270 LD HL,(50160)
50273 LD (50457),HL
50276 POP HL Restore the screen address.
DrawBlockShapeThree_Rows 50277 PUSH BC Remember the column count and both addresses.
50278 PUSH HL
50279 PUSH DE
50280 LD B,0 Take the row count.
The edges are changed only when a single row remains, and only for an edge choice other than zero.
DrawBlockShapeThree_Columns 50282 PUSH BC Remember the row count.
50283 DEC B Change the edges only when a single row remains.
50284 JR NZ,DrawBlockShapeThree_Draw
50286 LD A,0 Read the edge choice.
50288 AND A Leave the edges as they are when the choice is zero.
50289 JR Z,DrawBlockShapeThree_Draw
50291 RRA The low bit of the choice selects the wide edges.
50292 JR C,DrawBlockShapeThree_Wide
50294 LD A,(50434) Read the running total of steps.
50297 RRA Use the narrow edges only when that total is odd.
50298 JR NC,DrawBlockShapeThree_Draw
50300 LD (IY+6),8 Set the edges to 8.
50304 LD A,8
50306 LD (50824),A
50309 LD (50842),A
50312 LD (50869),A
50315 ADD A,6
50317 LD (50986),A
50320 JR DrawBlockShapeThree_Draw
DrawBlockShapeThree_Wide 50322 LD (IY+6),24 Set the edges to 24.
50326 LD B,A
50327 LD A,24
50329 LD (50824),A
50332 LD (50842),A
50335 LD (50869),A
50338 ADD A,6
50340 LD (50986),A
50343 RR B A choice of three also sets the edges to 16 and lengthens the rows.
50345 JR NC,DrawBlockShapeThree_Draw
50347 LD (IY+6),16
50351 LD A,16
50353 LD (50824),A
50356 LD (50842),A
50359 LD (50869),A
50362 ADD A,6
50364 LD (50986),A
50367 LD A,(50665)
50370 ADD A,14
50372 LD (50665),A
50375 LD (51001),A
DrawBlockShapeThree_Draw 50378 CALL DrawBlockRow Draw this row. The routine is patched.
50381 EXX Step both addresses on by the shape's row steps.
50382 LD BC,0
50385 ADD HL,BC
50386 EX DE,HL
50387 LD BC,0
50390 ADD HL,BC
50391 EX DE,HL
50392 POP BC Repeat for the remaining rows.
50393 DJNZ DrawBlockShapeThree_Columns
50395 POP HL Restore the screen address.
50396 LD (IY+6),24 Put the edges back to 24.
50400 LD A,24
50402 LD (50869),A
50405 LD (50824),A
50408 LD (50842),A
50411 ADD A,6
50413 LD (50986),A
50416 LD A,0 A choice of three shortens the row count again.
50418 CP 3
50420 JR NZ,DrawBlockShapeThree_0
50422 LD A,(50665)
50425 SUB 14
50427 LD (50665),A
50430 LD (51001),A
DrawBlockShapeThree_0 50433 LD A,0 Add this column's steps to the running total.
50435 ADD A,0
50437 LD (50434),A
50440 RRA Shorten the remaining rows when the total overflows.
50441 JR C,DrawBlockShapeThree_1
50443 LD A,(50281)
50446 DEC A
50447 LD (50281),A
DrawBlockShapeThree_1 50450 LD BC,0 Step the screen address on by the column step.
50453 ADD HL,BC
50454 EX DE,HL
50455 POP HL Restore the sprite address and step it on too.
50456 LD BC,0
50459 ADD HL,BC
50460 POP BC Repeat for the remaining columns.
50461 DEC B
50462 JP NZ,DrawBlockShapeThree_Rows
50465 RET Return.
Prev: 50167 Up: Map Next: 50466