; Sniper 2. 4/21/99. Copyright 1999 Ed T. Toton III, All Rights Reserved. ; ; This is a new version of sniper, written from scratch. It's a little ; smarter, but is still intended to be only an example and not a high- ; powered contestant for the tournaments. ; ; Notice there are few or no hard JMP commands. Whenever you see a ; je/jne to the same label together, it acts like a hard jmp but requires ; zero cpu cycles to execute. #msg You can't hide! #config scanner=3 #config armor=3 #config engine=0 #config heatsinks=5 #config weapon=1 #def turret_home #def arc #def armor #def firecode opo 20 200 !scan mov arc 64 ; Set our inital scan arc opo 12 128 ; Turn turret 180 degrees ; Begin the actual scan :2000 opo 17 arc ; Set scan-arc ipo 7 ax ; Scan for enemy cmp ax 700 ja !decide ; If no one there, decide what to do. mov ax @3 ; Get accuracy add ax 2012 ; move it to 2010-2014 range je ax jne ax :2010 xor ax ax ; ax = 0 sub ax arc ; ax = 0-arc opo 12 ax ; turn turret left mov firecode -2 opo 15 firecode je 2015 jne 2015 :2011 xor ax ax ; ax = 0 sub ax arc ; ax = 0-arc sar ax 1 ; ax = (0-arc)/2 opo 12 ax ; turn turret left mov firecode -1 opo 15 firecode je 2015 jne 2015 :2012 ipo 2 ax ; Check heat cmp ax 150 ; Campare to 150 ja 2015 ; If too hot, skip shooting mov firecode 0 opo 15 firecode je 2015 jne 2015 :2013 mov ax arc ; ax = arc shr ax 1 ; ax = arc/2 opo 12 ax ; turn turret right mov firecode 1 opo 15 firecode je 2015 jne 2015 :2014 mov ax arc ; ax = arc opo 12 ax ; turn turret right mov firecode 2 je 2015 jne 2015 :2015 cmp arc 2 ; compare arc to 2 jle 2000 ; If arc <= 2, then skip shrinking it. shr arc 2 ; cut our arc to 1/4 size je 2000 ; Scan again. jne 2000 !decide cmp arc 64 ; What is our arc setting? jae !scan ; If too wide, move to another wall. shl arc 2 ; Otherwise widen the arc, repeat scan. je 2000 jne 2000 ;------------------------------------------------------------------------- ;Set course to heading in AX. !set-course mov bx, @1 ; get current desired heading ; (not actual heading) and ax, 255 ; Fix ax into 0-255. sub ax, bx ; get number of degrees to turn. opo 14, ax ; turn! ret ; All done!