#config scanner=4 #config weapon=5 #config engine=0 #def maxspeed #def arc mov arc, 64 mov maxspeed, 100 opo 11, maxspeed opo 22, 20 ;lay mine 1 opo 22, 20 ;lay mine 2 :100 ipo 1, ax ;find speed cmp ax, 0 ;speed=0? je 400 ;move in opposite direction opo 17, arc ;set scan arc ipo 7, ax ;scan cmp ax, 1500 ;target? jgr 200 ;if no target turn the turret ipo 8, ax ;get accuracy mpy ax, arc shr ax, 1 ;ax now gives direction of enemy (i hope) opo 12, ax ;turn turret to where enemy is ipo 4, bx ;put turret offset to bx shr bx, 1 opo 14, bx ;turn to face enemy cmp arc, 5 jls 300 ;if arc is 4 goto firing shr arc, 1 ;arc/2 jne 100 je 100 :200 mov arc, 64 ;set scan arc to max opo 12, arc ;turn turret by 2 * scan width opo 17, arc jne 100 ;goto scanning again je 100 ;goto scanning again :300 ipo 2, ax ;get heat cmp ax, 300 jgr 100 ;if too hot don't fire :301 opo 15 ;fire jne 100 ;goto scanning again je 100 ;goto scanning again :400 neg maxspeed ;change direction of speed opo 11, maxspeed ; jne 100 ; je 100 ;