Prev: 84FA Up: Map Next: 852B
8500: Paint PLANES and the sprites into the render buffer, back to front
Used by the routine at DRAW_VIEW.
PLANES holds, per place, one of $01, $02 ... $20 (a block at that height) or $FF (nothing). This paints every $01 place, then every $02, and so on up to $40 -- a pass with no blocks in it, for anything standing on top of a six-high block -- using CPIR to find each next one. The sprites are threaded in by distance: BC counts down the places to the next sprite across all the passes, so when CPIR runs BC out before finding a block, it is time to draw a sprite (DRAW_HERE).
DRAW_SCENE 8500 LD IX,SPRITE_LIST BC = the count to the first sprite.
8504 CALL NEXT_SPRITE
8507 LD DE,$001F Row step for the drawers; start with height bit $01.
850A LD A,$01
850C LD HL,$B6FF
850F JR DRAW_SCENE_1
This entry point is used by the routine at DRAW_HERE.
DRAW_SCENE_0 8511 EX AF,AF' The next height's bit; past $40, done.
8512 RLCA
8513 CP $80
8515 RET Z
8516 DEC HL HL was one past the end; back to the last place.
DRAW_SCENE_1 8517 LD (HL),A A sentinel, so the CPIR stops at the end.
8518 LD HL,PLANES From the first place.
This entry point is used by the routines at BLOCK_DRAWN and DRAW_HERE.
DRAW_SCENE_2 851B CPIR Find the next place at this height -- or run out of count first.
851D JP PO,DRAW_HERE
8520 EX AF,AF' Found the sentinel: the next height.
8521 LD A,H
8522 CP $B7
8524 JR Z,DRAW_SCENE_0
8526 PUSH HL Draw the block through the pointer SELECT_BLOCK_DRAWER set.
8527 DEC HL
8528 JP (IY)
852A NOP Never reached: the JP (IY) before it does not fall through, and the block drawers come back at BLOCK_DRAWN. A spare byte.
Prev: 84FA Up: Map Next: 852B