Advertisement
serpent03

kasm

Feb 4th, 2022
1,034
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .global _start
  2.  
  3. .macro PRINT
  4.     call #, "print()"
  5.     push @
  6. .endmacro
  7.  
  8. .macro G_UPD
  9.     push "$body"
  10.     gmb "mu"
  11.     sto "$BODMU"
  12.     push "$body"
  13.     gmb "radius"
  14.     push 2
  15.     pow
  16.     sto "$RADSQR"
  17.  
  18.     push "$BODMU"
  19.     push "$RADSQR"
  20.     div
  21.     sto "$g0"    
  22. .endmacro
  23.  
  24. .macro RAD_UPD
  25.     push "$ship"
  26.     gmb "bounds"
  27.     gmb "bottomaltradar"
  28.  
  29.     sto "$RADALT"
  30. .endmacro
  31.  
  32. .macro DECEL_UPD
  33.     push "$availableThrust"
  34.     push "$mass"
  35.     div
  36.     push "$g0"
  37.     sub
  38.  
  39.     sto "$DECEL"
  40. .endmacro
  41.  
  42. .macro STOP_DIST
  43.     push 2
  44.     push "$DECEL"
  45.     push "$verticalSpeed"
  46.     push 2
  47.     pow
  48.     swap
  49.     div
  50.     sto "$STOPD"
  51. .endmacro
  52.  
  53. .macro IDEAL_THROT
  54.     push "$STOPD"
  55.     push "$RADALT"
  56.     div
  57.     sto "$THROT"
  58. .endmacro
  59.  
  60. .macro STEERING
  61.     push "$THROT"
  62.     push 0.3
  63.     cgt  ; THROT |[--SIGN--]| 0.6
  64.     btr .CHANGE_STEER
  65.     push @
  66.     jmp .CHECK_END
  67.  
  68.     .CHANGE_STEER:
  69.         push @
  70.         push "$ship"
  71.         gmb "velocity"
  72.         gmb "surface"
  73.         PRINT
  74.         ; sto "$steering"
  75.    
  76.     .CHECK_END:
  77.         ; unlock steering..
  78.         push @
  79.  
  80. .endmacro
  81.  
  82. .macro THROTTLE
  83.     push 0.6
  84.     push "$verticalSpeed"
  85.     cgt
  86.     btr .CHANGE_THROT
  87.     ; jmp .THROT_LOGIC_FLOW
  88.     .CHANGE_THROT:
  89.         push "$THROT"
  90.         sto "$throttle"
  91.     .THROT_LOGIC_FLOW:
  92.         eop
  93. .endmacro
  94.  
  95. .macro IMU_UPD
  96.     push @
  97.     G_UPD
  98.     RAD_UPD
  99.     DECEL_UPD
  100.     STOP_DIST
  101.     IDEAL_THROT
  102.     STEERING
  103.     ; THROTTLE
  104. .endmacro
  105.  
  106. .func
  107. _start:
  108.  
  109.     call #, "clearscreen()"
  110.     ; SECTION BEGINS
  111.     .LOOP_START:
  112.     IMU_UPD
  113.     push @
  114.  
  115.     push "$THROT"
  116.     PRINT
  117.     push "$maxThrust"
  118.     PRINT
  119.  
  120.     push 0.25
  121.     wait
  122.     push @
  123.     call #, "clearscreen()"
  124.  
  125.     jmp .LOOP_START
  126.  
  127. eop ; end of program
  128.  
  129.  
  130. .section .data
  131.  
  132. ; trueRad .f64
  133.  
  134.  
Advertisement
RAW Paste Data Copied
Advertisement