Prev: 47493 Up: Map Next: 47558
47504: Make Bullet Hole
Used by the routine at HandleMuzzleFlash.
Puts a bullet hole (an object of type 16) 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 47504 LD HL,41789 Point HL at the thirteenth object slot.
47507 LD DE,65520 Set the distance to the previous slot.
47510 LD B,13 Set the number of slots to thirteen.
MakeBulletHole_Loop 47512 LD A,(HL) Fetch the type of the object in the slot.
47513 AND A Test whether the slot is in use.
47514 JR Z,MakeBulletHole_Found Jump to MakeBulletHole_Found if it is free.
47516 ADD HL,DE Move on to the previous slot.
47517 DJNZ MakeBulletHole_Loop Loop back until all the slots have been checked.
47519 RET Return.
Place a bullet hole in the free slot.
MakeBulletHole_Found 47520 EX DE,HL Swap the address of the slot into DE.
47521 PUSH DE Copy the address of the slot into IY (using the stack).
47522 POP IY
47524 LD HL,47558 Point HL at BulletHoleTemplate.
47527 LD BC,16 Set the size of an object slot in BC.
47530 LDIR Copy the template into the slot.
47532 LD A,(41496) Fetch a random number.
47535 AND %01111111 Keep a number from 0 to 127.
47537 ADD A,56 Add 56 to give the horizontal position.
47539 LD (IY+2),A Set the horizontal position of the hole.
47542 LD A,(41497) Fetch another random number.
47545 AND %00111111 Keep a number from 0 to 63.
47547 ADD A,96 Add 96 to give the vertical position.
47549 LD (IY+4),A Set the vertical position of the hole.
47552 CALL PlayStatic Make a burst of noise.
Remove the muzzle flash.
47555 JP HandleBody_Remove Jump to HandleBody_Remove.
Prev: 47493 Up: Map Next: 47558