+
+ inc de ;set y-pos
+ inc hl ;where to place??
+ ld a,(hl) ;load placeInfo
+ dec a ;is it 1?
+ jr z,random_enemy ;yes: create random value <51 in a
+ dec a ;is it 2?
+ jr z,lure_enemy ;yes: create a 100% luring enemy
+ ;otherwise?
+halflure_enemy: ;yes (of course it is): pick one (50% lure)
+ ld a,(timer) ;look at frame-number
+ and %00000001 ;make random if odd frame nr.
+ jr nz,random_enemy ;1st possibility: random enemy
+lure_enemy: ;2nd possibility: luring enemy
+ ld a,(y) ;place at same y-pos as YOUR ship
+ jr ypos_OK
+
+random_enemy:
+ call Random ;make a (in a) random value 0-255
+ cp 51 ;y may not be more than 51
+ jr c,ypos_OK ;OK if a<51
+ and %00111111 ;a = 0..63
+ sub 13 ;a = -13..50
+ jr c,random_enemy ;not OK if a<0
+
+ypos_OK: ;random value successfully created
+ ld (de),a ;save y-position
+
+ ld hl,add2enemy-3 ;offset to xtra enemy info
+ add hl,de ;hl points to <xtra info: move>
+ ld (hl),1 ;set move-counter to 1
+ inc hl ;hl to <xtra info: fire>
+ ld (hl),1 ;set time-to-fire to 1 frame (fires directly)
+ ret ;return
+
+Random:
+ ld a,(RanPos) ;a handy random-var.
+ ld hl,x ;add your x-coord for randomness
+ adc a,(hl)
+ ld hl,y ;add your y-coord for randomness
+ adc a,(hl)
+ ld (RanPos),a ;save altered random-var
+ ret ;RanPos also in #a