+explosion_stuff:
+ rra
+ add a,a
+ add a,a
+ add a,a
+ ld c,a
+ ld b,0
+ ld ix,spr_explosion
+ add ix,bc
+ inc hl
+ ld d,(hl)
+ inc hl
+ jr display_common
+
+;------------------------- fire bullet ----------------------------------------
+
+Fire_bullet:
+ ld a,%00111111
+ out (1),a
+; ld a,(your_status)
+; or a
+; ret nz
+ ld hl,just_fired
+ nop
+ in a,(1)
+ bit 4,a
+ jr z,fire
+ ld (hl),0 ;not fired
+ ret
+
+fire: ld a,(hl)
+ or a ;can't fire when 1
+ ret nz
+ ld (hl),1 ;just fired
+
+ ld hl,ybullets
+ ld de,3
+ ld b,10
+
+find_ybullet:
+ ld a,(hl)
+ or a
+ jr z,found_ybullet ;0 = no bullet here
+ add hl,de
+ djnz find_ybullet ;look next bullet
+ ret
+
+found_ybullet:
+ ld (hl),1 ;use bullet
+ inc hl
+ ld a,(x)
+ add a,3
+ ld (hl),a ;set x
+ ld a,(y)
+ add a,2
+ inc hl
+ ld (hl),a ;set y
+ ret
+
+;------------------------ handle bullets --------------------------------------
+
+remove_bullet:
+ dec hl
+ ld (hl),0 ;dump this bullet!
+ ret
+
+Handle_bullets:
+ ld hl,ybullets
+ ld b,10
+scan_your_bullets:
+ push bc
+ push hl
+ ld (temp1),hl
+ ld a,(hl)
+ inc hl
+ dec a
+ call z,bullet_type1
+ pop hl
+ pop bc
+ ld de,3
+ add hl,de
+ djnz scan_your_bullets
+ ret
+
+bullet_type1:
+ ld a,(hl) ;d = X
+ inc a ;move right
+ cp $5a ;off screen?
+ jr z,remove_bullet
+ inc a ;move right
+ cp $5a ;off screen?
+ jr z,remove_bullet
+ ld (hl),a ;save new pos.
+ ld d,a
+ inc hl
+ ld e,(hl) ;e = Y
+ ld ix,spr_bullet01
+ push de
+ call drw_spr ;display bullet
+ pop de
+ ld b,20
+ ld hl,enemies
+
+hit_enemies: ;Hits with normal enemies
+ push hl
+
+ ld a,(hl)
+ dec a
+ jr nz,nohit ;no hit when enemy_occ <> 1
+
+ inc hl
+ inc hl
+ ld a,(hl) ;check x
+ sub d
+ add a,5
+ jp m,nohit
+ cp 8
+ jr nc,nohit
+
+ inc hl
+ ld a,(hl) ;check y
+ sub e
+ add a,5
+ jp m,nohit
+ cp 10
+ jr nc,nohit
+
+ xor a
+ push hl
+ ld hl,(temp1)
+ ld (hl),a ;remove bullet
+ pop hl
+
+ dec hl
+ dec hl
+ ld (hl),a ;explosionFrame 0
+ dec hl
+ ld (hl),2 ;set to explode
+
+ pop hl
+ ret
+
+nohit: pop hl
+ inc hl
+ inc hl
+ inc hl
+ inc hl
+ djnz hit_enemies ;check next enemy
+ ret