Prev: B985 Up: Map Next: B9C6
B990: Make Bullet Hole
Used by the routine at HandleMuzzleFlash.
Puts a bullet hole (an object of type 10) in a random place on the screen, in the first free slot of the first thirteen, which are searched downwards from the thirteenth. It makes a burst of noise and removes the muzzle flash.
MakeBulletHole B990 LD HL,$A33D Point HL at the thirteenth object slot.
B993 LD DE,$FFF0 Set the distance to the previous slot.
B996 LD B,$0D Set the number of slots to thirteen.
MakeBulletHole_Loop B998 LD A,(HL) Fetch the type of the object in the slot.
B999 AND A Test whether the slot is in use.
B99A JR Z,MakeBulletHole_Found Jump to MakeBulletHole_Found if it is free.
B99C ADD HL,DE Move on to the previous slot.
B99D DJNZ MakeBulletHole_Loop Loop back until all the slots have been checked.
B99F RET Return.
Place a bullet hole in the free slot.
MakeBulletHole_Found B9A0 EX DE,HL Swap the address of the slot into DE.
B9A1 PUSH DE Copy the address of the slot into IY (using the stack).
B9A2 POP IY
B9A4 LD HL,$B9C6 Point HL at BulletHoleTemplate.
B9A7 LD BC,$0010 Set the size of an object slot in BC.
B9AA LDIR Copy the template into the slot.
B9AC LD A,($A218) Fetch a random number.
B9AF AND %01111111 Keep a number from 00 to 7F.
B9B1 ADD A,$38 Add 38 to give the horizontal position.
B9B3 LD (IY+$02),A Set the horizontal position of the hole.
B9B6 LD A,($A219) Fetch another random number.
B9B9 AND %00111111 Keep a number from 00 to 3F.
B9BB ADD A,$60 Add 60 to give the vertical position.
B9BD LD (IY+$04),A Set the vertical position of the hole.
B9C0 CALL PlayStatic Make a burst of noise.
Remove the muzzle flash.
B9C3 JP HandleBody_Remove Jump to HandleBody_Remove.
Prev: B985 Up: Map Next: B9C6