home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 2001 January / CT_SW0101.ISO / pc / software / spiele / strat / bbots.tgz / battlebots-1.0.2-static.tar / example1.basm < prev    next >
Text File  |  2001-03-18  |  2KB  |  135 lines

  1. RAM: 0
  2.  
  3. DEVICE: 1 2 0
  4. DEVICE: 1 2 0
  5. DEVICE: 2 2 0
  6. DEVICE: 3 2 0
  7. DEVICE: 20 2 0
  8. DEVICE: 5 4 0
  9. DEVICE: 9 4 8
  10. DEVICE: 7 4 0
  11. DEVICE: 6 2 0
  12. DEVICE: 9 0 4
  13. DEVICE: 20 2 0
  14. DEVICE: 9 0 10
  15. DEVICE: 0 0 0
  16. DEVICE: 0 0 0
  17. DEVICE: 0 0 0
  18. DEVICE: 0 0 0
  19. DEVICE: 0 0 0
  20. DEVICE: 0 0 0
  21. DEVICE: 0 0 0
  22. DEVICE: 0 0 0
  23. DEVICE: 0 0 0
  24. DEVICE: 0 0 0
  25. DEVICE: 0 0 0
  26. DEVICE: 0 0 0
  27. DEVICE: 0 0 0
  28. DEVICE: 0 0 0
  29. DEVICE: 0 0 0
  30. DEVICE: 0 0 0
  31. DEVICE: 0 0 0
  32. DEVICE: 0 0 0
  33. DEVICE: 0 0 0
  34. DEVICE: 0 0 0
  35.  
  36. ; Example bot showing use of Multiple CPU:s
  37. ; this bot got 2 CPU:s doing different tasks:
  38. ; CPU 1: navigation
  39. ; CPU2: searches for and shoots at enemy
  40. ;
  41.  
  42. #WantedXpos
  43. dw 0
  44. #WantedYpos
  45. dw 0
  46.  
  47. %CPUboot 0
  48.  
  49. ;This function handles the bots navigation
  50. :navmain
  51.  
  52. ;First, store the wanted positions we should move
  53. ; to (randomized)
  54. rnd
  55. shr ax,1
  56. mov @WantedXpos,ax
  57. rnd
  58. shr ax,1
  59. mov @WantedYpos,ax
  60.  
  61. out Engine0_SetThrust, 105
  62.  
  63. ;Loop until we are close to the point we wanted
  64. ;to go to
  65. :wait
  66.  
  67. mov bx,@WantedXpos
  68. mov dx,@WantedYpos
  69. in cx,Steering0_GetXPos
  70. in ax,Steering0_GetYPos
  71. sub bx,cx
  72. sub dx,ax
  73.  
  74. mov si,bx
  75. mov di,dx
  76. push bx
  77. push dx
  78. atanfunc
  79. out Steering0_SetDir,ax
  80. pop dx
  81. pop bx
  82.  
  83. icmp bx,2000
  84. ja wait
  85. icmp bx,-2000
  86. jb wait
  87. icmp bx,2000
  88. ja wait
  89. icmp bx,-2000
  90. jb wait
  91.  
  92. jmp navmain
  93.  
  94. %CPUstack 0
  95.  
  96. %org +20
  97.  
  98. %CPUboot 1
  99. out Scanner0_SetScanWidth,16
  100. out Turret0_SetOffset,0
  101. out Turret1_SetOffset,1020
  102. out Turret2_SetOffset,4
  103. hwait
  104. :shootmain
  105. :search
  106. out Scanner0_Scan,1
  107. hwait
  108. in ax,Scanner0_GetScanDistance
  109. cmp ax,60000
  110. jb found
  111. out Turret0_AdjustOffset,24
  112. out Turret1_AdjustOffset,24
  113. out Turret2_AdjustOffset,24
  114. hwait
  115. hwait
  116. hwait
  117. jmp search
  118.  
  119. :found
  120. in bx,Scanner0_GetScanAccuracy
  121. sub bx,2
  122. ishl bx,3
  123. out Turret0_AdjustOffset,bx
  124. out Turret1_AdjustOffset,bx
  125. out Turret2_AdjustOffset,bx
  126. out Rocket0_SetDistance, ax
  127. out Rocket1_SetDistance, ax
  128. in cx,Rocket0_GetReadiness
  129. hwait
  130. cmp cx,100
  131. jb shootmain
  132. out Rocket0_FireRocket,1
  133. out Rocket1_FireRocket,1
  134.  
  135. jmp shootmain