; Zit Gun2, and CrossBreed of ZitGun and Experiment. Alexander Cole Wise I ; ; This Robot is a hybrid of ZitGun and Experiment, Swarming the enemy with bullets. ; #config weapon=1 ; gives 1 point #config scanner=3 ; gives 2 points #config engine=4 ; consumes 2 points #config heatsinks=2 ; consumes a point #def Angle_Counter #msg Watch your five! :) mov ax, 1 ;Sets V = N int 3 ; Keepshift on. !begin mov dx, 64 ; Set our scan arc to 64 degrees !start opo 11, 100 ; Throttle to 100% opo 17, dx ; Set arc to DX ipo 7, fx ; Scan for enemy cmp fx 2000 ;Compares 2 numbers, results in flags reg. 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, 2 ; check scanwidth jbe !fire ; width<=2? then fire, otherwise tighten shr dx, 1 ; tighten scanwidth !fire ipo 2, ax ; Check our heat cmp ax 80 ; Too hot? ja !dontfire ; If so, skip shooting. jmp !swarm ipo 2, ax ; Check our heat cmp ax 50 ; Too hot? ja !dontfire ; If so, skip shooting. jmp !swarm !dontfire ; 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 150 ; Check our distance jae !turn ; Too close? If not, then steer straight add ax, 40 ; if so, veer off !turn add ax 16 ; 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 ;Jumps to label #N if last compare was <> ;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 ;Jumps to label #N if last compare was <> !flip opo 12 128 ; rotate turret 128 degrees (180). opo 14 8 ; Turn slightly je !start ; start over jne !start ;Jumps to label #N if last compare was <> !swarm :100 do 9 mov angle_counter, -4 ;Set angle_counter to -4 :101 opo 15, angle_counter ;Fire weapon at offset of angle_counter (-4) add angle_counter, 1 ;Add 1 to angle_counter loop 101 jmp !fire ; Hardcoded firing solutions :1000 shl bx, 1 ;Bit-Shifts V left N bit Positions mov ax, 0 ;Sets V = N sub ax, bx ;Subtracts V-N, Result Stored in V mov bx, ax ; BX = 0-(BX*2) jne 1005 ;Jumps to label #N if last compare was <> je 1005 ;Jumps to label N if last compare was = :1001 mov ax, 0 ;Sets V = N sub ax, bx ;Subtracts V-N, Result Stored in V mov bx, ax ; BX = 0-BX jne 1005 ;Jumps to label #N if last compare was <> je 1005 ;Jumps to label N if last compare was = :1002 mov bx, 0 ; BX = 0 jne 1005 ;Jumps to label #N if last compare was <> je 1005 ;Jumps to label N if last compare was = :1003 ; BX doesn't change jne 1005 ;Jumps to label #N if last compare was <> je 1005 ;Jumps to label N if last compare was = :1004 shl bx, 1 ; BX = BX*2 jne 1005 ;Jumps to label #N if last compare was <> je 1005 ;Jumps to label N if last compare was =