; Zit Gun, and uprated version of PeaShoot.. Ed T. Toton III 6/16/99 ; ; This robot is just a slightly improved version of PeaShoot, not limited ; to 32 lines of code. #config weapon=2 ; gives 1 point #config scanner=3 ; gives 2 points #config engine=1 ; consumes 2 points #config heatsinks=3 ; consumes a point #config mines=0 #config shield=0 #config armor=3 #msg Watch your five! :) #def lr #def lef #def dir #def vel mov ax, 1 int 3 ; Keepshift on. !begin mov dx, 64 ; Set our scan arc to 64 degrees mov lr 0 !start opo 11, 100 ; Throttle to 100% opo 17, dx ; Set arc to DX ipo 7, fx ; Scan for enemy cmp fx 2000 jle !track ; No one found? Decide what to do cmp lr, 0 ja !right jle !left !track ; Someone was found mov lr @3 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 amout cmp dx, 2 ; check scanwidth jbe !aim ; width<=2? then fire, otherwise tighten shr dx, 1 ; tighten scanwidth !aim mov dir, @6 cmp dir, 32 jbe !zero cmp dir, 96 jbe !aimr cmp dir, 160 jbe !zero je !aiml jne !aiml !aimr mov vel, @7 cmp vel 10 jbe !zero cmp vel 25 jbe !1r cmp vel 40 jbe !2r je !3r jne !3r !1r add bx 1 je !fire jne !fire !2r add bx 2 je !fire jne !fire !3r add bx 4 je !fire jne !fire !aiml mov vel, @7 cmp vel 10 jbe !zero cmp vel 25 jbe !1l cmp vel 40 jbe !2l je !3l jne !3l !1l sub bx 1 je !fire jne !fire !2l sub bx 2 je !fire jne !fire !3l sub bx 4 je !fire jne !fire !zero ; add bx, @3 !fire opo 12, bx ; turn turret by that amout opo 15, bx ; Fire! ; ipo 2, ax ; Check our heat ; cmp ax 50 ; Too hot? ; ja !dontfire ; If so, skip shooting. ; opo 15, cx ; Fire! !dontfire ; Set course towards target mov bx, @1 ; get current desired heading ; (not actual heading) cmp fx, 200 ; Check our distance jle !flee ipo 3, ax ; Get actual heading add ax, @2 ; And add to it our turret offset ; AX is now our new desired heading. add ax, 8 !turn add ax 10 ; 16 degrees right of center and ax, 255 ; Fix ax into 0-255. sub ax, bx ; get number of degrees to turn. opo 14, ax ; turn! je !start ; start over jne !start !flee ipo 3, ax ; Get actual heading sub ax, @2 ; And add to it our turret offset ; AX is now our new desired heading. add ax, 48 ; 16 degrees right of center and ax, 255 ; Fix ax into 0-255. sub ax, bx ; get number of degrees to turn. opo 14, ax ; turn! je !start ; start over jne !start ;Decides what to do if no one found !right cmp dx, 64 ; Compare scanwidth to 64 jae !flip ; If above, then flip add dx, dx ; otherwise, widen arc opo 12, dx je !start ; start over jne !start !left cmp dx, 64 ; Compare scanwidth to 64 jae !flip ; If above, then flip add dx, dx ; otherwise, widen arc mov lef, 0 sub lef, dx opo 12, lef je !start ; start over jne !start !flip opo 12 120 ; 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