; Pegger - The robot that pegs you. 10/19/2000 ; Copyright 2000 Ed T. Toton III, All Rights Reserved. ; ; This robot uses mostly ZitGun's code for scanning, ; but handles shooting a little differently and doesn't ; move. It tries to kill the target before it moves far, ; and thus only works well in high-cpu-timeslice settings. #msg Take this! #config scanner=4 ; Saves a point #config armor=3 ; Consumes a point #config engine=0 ; Saves 2 points #config heatsinks=3 ; Consumes 2 points mov ax, 1 int 3 ; Keepshift on. !begin mov dx, 64 ; Set our scan arc to 64 degrees !start 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 mov bx, dx ; BX = DX (dx is the scan width) mov ax, @3 ; bx = scanwidth*accuracy add ax 1002 ; This is achieved by calling je ax ; a routine chosen by the accuracy jne ax ; number, rather than actually do :1005 ; a multiplication, which is slow. sar bx, 1 ; bx = scanwidth*accuracy/2 opo 12, bx ; turn turret by that amount. cmp dx, 1 ; check scanwidth jbe !fire ; width<=2? then fire, otherwise tighten shr dx, 1 ; tighten scanwidth je !dontfire jne !dontfire !fire ipo 2, ax ; Check our heat cmp ax 80 ; Too hot? ja !dontfire ; If so, skip shooting. out 15, @3 out 15, @3 ; Fire a whole bunch of times ; out 15, @3 out 15, @3 out 15, @3 !dontfire je !start ; start over jne !start ;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 je !start ; start over jne !start !flip opo 12 128 ; rotate turret 128 degrees (180). opo 14 8 ; Turn slightly je !start ; start over jne !start ; Hardcoded firing solutions :1000 shl bx, 1 mov ax, 0 sub ax, bx mov bx, ax ; BX = 0-(BX*2) jne 1005 je 1005 :1001 mov ax, 0 sub ax, bx mov bx, ax ; BX = 0-BX jne 1005 je 1005 :1002 mov bx, 0 ; BX = 0 jne 1005 je 1005 :1003 ; BX doesn't change jne 1005 je 1005 :1004 shl bx, 1 ; BX = BX*2 jne 1005 je 1005