You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
4.2 KiB

  1. struct MindustryObject {};
  2. // builtin instructions
  3. void print(char* s) {
  4. asm("print {s}");
  5. }
  6. void printd(double s) {
  7. asm("print {s}");
  8. }
  9. void printflush(struct MindustryObject message) {
  10. asm("printflush {message}");
  11. }
  12. struct MindustryObject radar(struct MindustryObject obj, char* target1, char* target2,
  13. char* target3, char* sort, double index) {
  14. asm("radar {target1} {target2} {target3} {sort} {obj} {index} {dest}");
  15. }
  16. double sensor(struct MindustryObject obj, char* prop) {
  17. asm("sensor {dest} {obj} @{prop}");
  18. }
  19. void enable(struct MindustryObject obj, double enabled) {
  20. asm("control enabled {obj} {enabled} 0 0 0");
  21. }
  22. void configure(struct MindustryObject obj, char* configure) {
  23. asm("control configure {obj} {configure} 0 0 0");
  24. }
  25. void setcolor(struct MindustryObject obj, double r, double g, double b) {
  26. asm("control color {obj} {r} {g} {b} 0");
  27. }
  28. void shoot(struct MindustryObject obj, double x, double y, double shoot) {
  29. asm("control shoot {obj} {x} {y} {shoot} 0");
  30. }
  31. void shootp(struct MindustryObject obj, double unit, double shoot) {
  32. asm("control shootp {obj} {unit} {shoot} 0 0");
  33. }
  34. struct MindustryObject get_link(double index) {
  35. asm("getlink {dest} {index}");
  36. }
  37. double read(struct MindustryObject cell, double index) {
  38. asm("read {dest} {cell} {index}");
  39. }
  40. void write(double val, struct MindustryObject cell, double index) {
  41. asm("write {val} {cell} {index}");
  42. }
  43. void drawclear(double r, double g, double b) {
  44. asm("draw clear {r} {g} {b}");
  45. }
  46. void drawcolor(double r, double g, double b, double a) {
  47. asm("draw color {r} {g} {b} {a}");
  48. }
  49. void drawstroke(double width) {
  50. asm("draw stroke {width}");
  51. }
  52. void drawline(double x1, double y1, double x2, double y2) {
  53. asm("draw line {x1} {y1} {x2} {y2}");
  54. }
  55. void drawrect(double x, double y, double w, double h) {
  56. asm("draw rect {x} {y} {w} {h}");
  57. }
  58. void drawlinerect(double x, double y, double w, double h) {
  59. asm("draw lineRect {x} {y} {w} {h}");
  60. }
  61. void drawpoly(double x, double y, double sides, double radius, double rotation) {
  62. asm("draw poly {x} {y} {sides} {radius} {rotation}");
  63. }
  64. void drawlinepoly(double x, double y, double sides, double radius, double rotation) {
  65. asm("draw linePoly {x} {y} {sides} {radius} {rotation}");
  66. }
  67. void drawtriangle(double x1, double y1, double x2, double y2, double x3, double y3) {
  68. asm("draw triangle {x1} {y1} {x2} {y2} {x3} {y3}");
  69. }
  70. void drawimage(double x, double y, char* image, double size, double rotation) {
  71. asm("draw image {x} {y} {image} {size} {rotation} 0");
  72. }
  73. void drawflush(struct MindustryObject display) {
  74. asm("drawflush {display}");
  75. }
  76. void end() {
  77. asm("end");
  78. }
  79. // unit commands (not complete; don't know how to return multiple values)
  80. void ubind(char* type) {
  81. asm("ubind @{type}");
  82. }
  83. void unit_move(double x, double y) {
  84. asm("ucontrol move {x} {y} 0 0 0");
  85. }
  86. void unit_idle() {
  87. asm("ucontrol idle 0 0 0 0 0");
  88. }
  89. void unit_stop() {
  90. asm("ucontrol stop 0 0 0 0 0");
  91. }
  92. void unit_approach(double x, double y, double radius) {
  93. asm("ucontrol approach {x} {y} {radius} 0 0");
  94. }
  95. void unit_boost(double enable) {
  96. asm("ucontrol boost {enable} 0 0 0 0");
  97. }
  98. void unit_pathfind() {
  99. asm("ucontrol pathfind 0 0 0 0 0");
  100. }
  101. void unit_target(double x, double y, double shoot) {
  102. asm("ucontrol target {x} {y} {shoot} 0 0");
  103. }
  104. void unit_targetp(double unit, double shoot) {
  105. asm("ucontrol targetp {unit} {shoot} 0 0 0");
  106. }
  107. void unit_itemDrop(struct MindustryObject obj, double amount) {
  108. asm("ucontrol itemDrop {obj} {amount} 0 0 0");
  109. }
  110. void unit_itemTake(struct MindustryObject obj, char* item, double amount) {
  111. asm("ucontrol itemTake {obj} {item} {amount} 0 0");
  112. }
  113. void unit_payDrop() {
  114. asm("ucontrol payDrop 0 0 0 0 0");
  115. }
  116. void unit_payTake(double takeUnits) {
  117. asm("ucontrol payTake {takeUnits} 0 0 0 0");
  118. }
  119. void unit_mine(double x, double y) {
  120. asm("ucontrol mine {x} {y} 0 0 0");
  121. }
  122. void unit_flag(double value) {
  123. asm("ucontrol flag {value} 0 0 0 0");
  124. }
  125. void unit_build(double x, double y, char* block, double rotation, char* configure) {
  126. asm("ucontrol build {x} {y} {block} {rotation} {configure}");
  127. }
  128. double unit_within(double x, double y, double radius) {
  129. asm("ucontrol within {x} {y} {radius} {dest} 0");
  130. }
  131. MindustryObject unit_radar(char* target1, char* target2, char* target3, char* sort, double order) {
  132. asm("uradar {target1} {target2} {target3} {sort} 0 {order} {dest}");
  133. }