Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # GasNeed-Master (1.2.0.4)
- # - 1.2. add pressure target
- # If all ratios are fulfilled, require gas (highest)
- # until max pressure is reached.
- # Writes gas need key to housing based on required
- # ratio settings in cGas1r, cGas2r, ...
- # 1010 : error, missing gas reading device
- alias dHousing db
- alias dMaster d0
- alias dGasRead d1
- # required gas ratios
- define cGasPt 55 # pressure target, ignore if 0
- define cGasPk 1 # gas to fill key, ignore if 0
- define cGas1r 0.40 # RatioOxygen
- define cGas2r 0.06 # RatioCarbonDioxide
- define cGas3r 0.01 # RatioNitrogen
- define cGas4r 0.00 # RatioPollutant
- define cGas5r 0.00 # RatioVolatiles
- define cGas6r 0.00 # RatioWater
- define cGas7r 0.00 # RatioNitrousOxide
- #define cGas8r 0.00 # some new gas
- # registers
- alias rRa r0 # dynamic jump point
- alias rReturn r1
- alias rR r2 # reference
- alias rC r3 # compare
- alias rK r4 # key
- alias rD r5 # defined compare
- alias rP r6 # priority, activate if presse needed
- # loop
- jLoop:
- move rReturn 1010 # error return
- bdns dGasRead jLoopDone
- move rReturn 0 # default return
- # prepare compare
- l rR dGasRead RatioOxygen # first reference
- select rR rR rR 1 # !zero
- select rD cGas1r cGas1r 1 # !zero
- div rR rR rD # calc ratio
- move rK 0 # init key (raised by fx)
- # init gas key
- l rC dGasRead RatioCarbonDioxide # read compare
- move rD cGas2r
- jal jFxFindNeed
- l rC dGasRead RatioNitrogen
- move rD cGas3r
- jal jFxFindNeed
- l rC dGasRead RatioPollutant
- move rD cGas4r
- jal jFxFindNeed
- l rC dGasRead RatioVolatiles
- move rD cGas5r
- jal jFxFindNeed
- l rC dGasRead RatioWater
- move rD cGas6r
- jal jFxFindNeed
- l rC dGasRead RatioNitrousOxide
- move rD cGas7r
- jal jFxFindNeed
- move rD 1 # set final compare to fulfilled
- jal jFxFindNeed
- # l rC dGasRead SomeNewGas9
- # move rD cGas5r
- # jal jFxFindNeed
- # pressure target
- bgtz rReturn jLoopDone # not idle : skip
- beqz cGasPt jLoopDone # not set : skip
- beqz cGasPk jLoopDone # not set : skip
- l rP dGasRead Pressure
- bge rP cGasPt jLoopDone # target reached
- move rReturn cGasPk
- #brlt A b # ...
- jLoopDone:
- s dHousing Setting rReturn
- yield
- j jLoop
- jFxFindNeed:
- add rK rK 1
- select rC rC rC 1 # set fulfilled if zero
- select rD rD rD 1 # set fulfilled if zero
- div rC rC rD
- brge rR 1 3 # reference >= 1 : fulfilled
- brge rR rC 2 # reference >= compare : not priority
- move rReturn rK # set need to gas key
- move rR rC # store compare as new reference
- j ra
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement