#config scanner= 1 #config weapon= 3 #config armor=1 #config engine= 3 #config heatsinks=4 #config mines= 0 #config shield= #msg Watch your six! :) mov ax, 1 int 3 ; Keepshift on. !begin mov dx, 64 ; Set our scan arc to 64 degrees !start opo 11, 100 ; Throttle to 90% opo 17, dx ; Set arc to DX ipo 7, fx ; Scan for enemy cmp fx 2000 ja !decide ; No one found? Decide what to do !track ; Someone was found opo 11, 100 ; Throttle to 100% mov bx, dx ; BX = DX (dx is the scan width) mpy bx, @3 ; bx = scanwidth*accuracy sar bx, 1 ; bx = scanwidth*accuracy/2 opo 12, bx ; turn turret by that amount. cmp dx, 2 ; check scanwidth jbe !fire ; width<=2? then fire, otherwise tighten shr dx, 1 ; tighten scanwidth !fire opo 15, @3 ; Fire! ; Set course towards target mov bx, @1 ; get current desired heading ; (not actual heading) ipo 3, ax ; Get actual heading add ax, @2 ; And add to it our turret offset ; AX is now our new desired heading. cmp fx 120 ; Check our distance jae !turn ; Too close? If not, then steer straight add ax, 64 ; if so, veer off !turn and ax, 255 ; Fix ax into 0-255. sub ax, bx ; get number of degrees to turn. opo 14, ax ; turn! jmp !start ; start over ;Decides what to do if no one found !decide cmp dx 64 ; Compare scanwidth to 64 jae !flip ; If above, then flip shl dx 1 ; otherwise, widen arc jmp !start ; start over !flip opo 12 128 ; rotate turret 128 degrees (180). opo 14 8 ; Turn slightly ; jmp !start ; start over ;program starts over automatically when it runs past the end.