; 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 scanner=3 ; gives 2 points #config mines=2 ; consumes 2 points #config weapon=1 #config heatsinks=2 #def armour #msg Greetz in 6 ax mov armour ax mov ax, 1 int 3 ; Keepshift on. out 20 350 ; Set shut down level to 350 !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 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 300 ; Too hot? ja !dontfire ; If so, skip shooting. in 18 0 ipo 2, ax cmp ax 150 ja !noburn in 18 20 opo 15, -4 ; Fire! opo 15, 4 ; Fire! opo 15, -3 ; Fire! opo 15, 3 !noburn opo 15, -2 ; Fire! opo 15, 2 ; Fire! opo 15, -1 ; Fire! opo 15, 1 ; Fire! opo 15 in 22 ax cmp ax,0 je !DontDrop opo 22 22 ; Lay mine. !rfdd opo 15, @3 ; Fire! !dontfire in 6 ax add ax 50 cmp ax armour jne !werehit ; 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 ;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 !dontdrop nop jmp !rfdd !werehit mov armour ax in 3 ax in 10 bx add ax bx mod ax 255 out 14 ax opo 11, 100 ; Throttle to 100% jmp !start