; AT-Robots AI, written by Jude Hungerford. Started on 9/11/1999. ; Last modification: 13/11/1999, version 0.09. ; modification: Another idea for the scanner because the others don't work. ;*== ;Variable declarations. ;*== #def heading #def thrust #def accuracy #def turn #def generic #def scanarc #def scandist #def heat ;*== ;Standard initialisation ;*== :100 ;#config scanner=3 ;#config weapon=3 ;#config heatsinks=2 mov thrust, 100 mov turn, 3 mov scanarc, 2 opo 17, scanarc ;very narrow scanning arc: 2/5 per segment mov AX, 0 int 3, AX ;set keepshift=on opo 11, thrust ;set speed ;*== ;*Main program segment A ;*== :200 opo 11, thrust ;Make sure thrusters are going. call !steer ;See if we want to steer. call !scan ;scan opo 14, turn :299 jmp 200 ;loop main section ;*==labels 300-399 ;*Firing routine A ;*== !fire :300 ipo 8, accuracy opo 12, accuracy ;turn turret to face enemy ipo 17, scanarc cmp scanarc, 2 jgr !narrowarc ipo 2, heat ;are we burning up? cmp heat, 200 jge 399 ;if yes, continue with scans cmp heat, 10 ;are we completely safe? jgr 350 ;if yes, consider overburning. ipo 7, scandist ;are we close to the target? cmp scandist, 300 jgr 350 opo 18, 1 ;if we are, Overburn. :350 opo 15, 0 ;fire straight ahead. opo 15, -1 ;fire a little to the left. opo 15, 1 ;fire a little to the right. opo 18, 0 ;make sure overburn is now off. ipo 7, scandist ;can we still see them? cmp scandist, 1500 jls 300 ;if so, fire again. :399 ret ;return !narrowarc shr scanarc, 2 jmp 399 ;*==labels 400 - 499 ;*Steering handling ;*== !steer :400 int 2 ;What are our coordinates? } call !leftwall ; } :410 ; } call !rightwall ; } anti-wall-collision :420 ; } call !topwall ; } :430 ; } call !bottomwall ; } :440 ; cmp turn, 0 jgr 450 mov turn, -6 opo 13, 160 jmp 490 :450 opo 13, 64 mov turn, 6 :499 ret ;continue with main section (return). ;*****-- Start of steering subroutines !leftwall cmp EX, 90 ;are we close to the left wall? jgr 410 ;We are: [ret] ipo 3, heading ;What is our heading? cmp heading, 256 ; jls 402 ;Might we need to turn? ret ;if not, continue :402 cmp heading, 128 ;Do we need to turn? jge 404 ; ret ;if not, continue :404 cmp heading, 192 ;Which way should we turn? jgr 406 ;turn right jle 408 ;turn left jmp 440 ;continue (placed in case of errors) :406 mov turn, 5 ;use turn variable to calculate turn angle. sub turn, heading ;How far should we turn right? opo 14, turn ;turn. ret ;continue :408 mov turn, 133 ; sub turn, heading ;How far should we turn left? opo 14, turn ;turn. jmp 410 ;continue !rightwall cmp EX, 910 ;are we close to the right wall? jls 420 ;We are: ipo 3, heading ;What is our heading? cmp heading, 128 ; jls 412 ;Might we need to turn? ret ;if not, continue :412 cmp heading, 0 ;Do we need to turn? jgr 414 ; ret ;if not, continue :414 cmp heading, 64 ;Which way should we turn? jgr 418 ;turn left jle 416 ;turn right jmp 440 ;continue (placed in case of errors) :416 mov turn, 251 ;use turn variable to calculate turn angle. sub turn, heading ;How far should we turn right? opo 14, turn ;turn. jmp 440 ;continue with main :418 mov turn, 133 ; sub turn, heading ;How far should we turn left? opo 14, turn ;turn. jmp 440 ;continue with main !topwall cmp FX, 90 ;are we close to top wall? jgr 430 ;We are: ipo 3, heading ;What is our heading? add heading, 128 ;shift around for calculations cmp heading, 64 ; jgr 422 ;Might we need to turn? ret ;if not, continue :422 cmp heading, 256 ;more shifting of values jls 423 ;to make circle continuous: sub heading, 256 ;shift :423 cmp heading, 192 ;Do we need to turn? jls 424 ;if not, ret ;continue :424 cmp heading, 128 ;Which way should we turn? jge 426 ;turn right jls 428 ;turn left jmp 440 ;continue (placed in case of errors) :426 ;leftturn ipo 3, heading ;reset heading variable to correct value mov turn, 69 ;use turn variable to calculate turn angle. sub turn, heading ;How far should we turn right? opo 14, turn ;turn. jmp 440 ;continue with main :428 ;rightturn ipo 3, heading ;reset heading variable to correct value. mov turn, 187 ; sub turn, heading ;How far should we turn left? opo 14, turn ;turn. jmp 440 ;continue with main !bottomwall cmp FX, 910 ;are we close to bottom wall? jls 440 ;we are: ipo 3, heading ;What is our heading? cmp heading, 64 ; jgr 432 ;Might we need to turn? ret ;if not, continue :432 cmp heading, 192 ;Do we need to turn? jls 434 ; ret ; :434 cmp heading, 128 ;Which way should we turn? jgr 436 ;turn right jle 438 ;turn left jmp 220 ;continue (placed in case of errors) :436 mov turn, 197 ;use turn variable to calculate turn angle. sub turn, heading ;How far should we turn right? opo 14, turn ;turn. jmp 440 ;continue with main :438 mov turn, 59 ; sub turn, heading ;How far should we turn left? opo 14, turn ;turn. jmp 440 ;continue with main ;***** end of steering subroutines ;*==labels 500-599 ;*Scanner control ;*== !scan :500 ipo 7, scandist ;robot in sight? cmp scandist, 1500 jls !found :599 ret jmp 299 !found call !fire jmp 599