Prev: 36805 Up: Map Next: 36904
36852: Draw a sprite
Used by the routines at 34252 (to draw Willy on the title screen), 34574 (to draw the remaining lives), 35140 (to draw Willy, the boot and the plinth during the game over sequence), 36266 (to draw horizontal guardians), 36344 (to draw Eugene in Eugene's Lair), 36469 (to draw the Skylabs in Skylab Landing Bay), 36593 (to draw vertical guardians), 36805 (to draw the portal in the current cavern), 36904 (to draw Willy above ground and the swordfish graphic over the portal in The Final Barrier) and 37173 (to draw the Kong Beast in Miner Willy meets the Kong Beast and Return of the Alien Kong Beast). If C=1 on entry, this routine returns with the zero flag reset if any of the set bits in the sprite being drawn collides with a set bit in the background.
Input
C Drawing mode: 0 (overwrite) or 1 (blend)
DE Address of sprite graphic data
HL Address to draw at
36852 LD B,16 There are 16 rows of pixels to draw
36854 BIT 0,C Set the zero flag if we're in overwrite mode
36856 LD A,(DE) Pick up a sprite graphic byte
36857 JR Z,36863 Jump if we're in overwrite mode
36859 AND (HL) Return with the zero flag reset if any of the set bits in the sprite graphic byte collide with a set bit in the background (e.g. in Willy's sprite)
36860 RET NZ
36861 LD A,(DE) Pick up the sprite graphic byte again
36862 OR (HL) Blend it with the background byte
36863 LD (HL),A Copy the graphic byte to its destination cell
36864 INC L Move HL along to the next cell on the right
36865 INC DE Point DE at the next sprite graphic byte
36866 BIT 0,C Set the zero flag if we're in overwrite mode
36868 LD A,(DE) Pick up a sprite graphic byte
36869 JR Z,36875 Jump if we're in overwrite mode
36871 AND (HL) Return with the zero flag reset if any of the set bits in the sprite graphic byte collide with a set bit in the background (e.g. in Willy's sprite)
36872 RET NZ
36873 LD A,(DE) Pick up the sprite graphic byte again
36874 OR (HL) Blend it with the background byte
36875 LD (HL),A Copy the graphic byte to its destination cell
36876 DEC L Move HL to the next pixel row down in the cell on the left
36877 INC H
36878 INC DE Point DE at the next sprite graphic byte
36879 LD A,H Have we drawn the bottom pixel row in this pair of cells yet?
36880 AND 7
36882 JR NZ,36900 Jump if not
36884 LD A,H Otherwise move HL to the top pixel row in the cell below
36885 SUB 8
36887 LD H,A
36888 LD A,L
36889 ADD A,32
36891 LD L,A
36892 AND 224 Was the last pair of cells at y-coordinate 7 or 15?
36894 JR NZ,36900 Jump if not
36896 LD A,H Otherwise adjust HL to account for the movement from the top or middle third of the screen to the next one down
36897 ADD A,8
36899 LD H,A
36900 DJNZ 36854 Jump back until all 16 rows of pixels have been drawn
36902 XOR A Set the zero flag (to indicate no collision)
36903 RET
Prev: 36805 Up: Map Next: 36904