Stationeers

Stationeers

评价数不足
ic centrifuge
   
奖励
收藏
已收藏
取消收藏
文件大小
发表于
109.466 KB
10 月 23 日 上午 5:15
1 项改动说明 ( 查看 )

订阅以下载
ic centrifuge

描述
# CodeCentrifugeControllerV1.txt
# - Each device port connected to an optional centrifuge (thus supports 1 to 6 centrifuges).
# - Auto powers down unused centrifuges.
# - Auto eject when MaxReagents is reached. (Increase for larger batches).

# Register used to enumerate 0..5 representing device ports.
alias rDeviceIndex r8

# Current centrifuge state (used to simplify logic checks).
alias rIsPowerOn r9
alias rIsErrorOn r10
alias rIsEmpty r11
alias rIsFull r12
alias rHasInput r13

# Count of device ports supported by an IC Housing.
define DeviceIndexCount 6

# Maximum amount of reagents before auto eject.
define MaxReagents 50

# Initialization.
initialize:
move rDeviceIndex 0

# Loop over each device port and handle the centrifuge(s) found.
mainLoop:
yield

bdseal dr8 processCentrifuge

add rDeviceIndex rDeviceIndex 1
mod rDeviceIndex rDeviceIndex 6

endLoop:
j mainLoop

# Call for each port with a device.
processCentrifuge:

# Compute various centrifuge state to simplify rule checks that follow.
computeCentrifugeState:
l rIsPowerOn dr8 On
l rIsErrorOn dr8 Error
l r0 dr8 Reagents
seqz rIsEmpty r0
seq rIsFull r0 MaxReagents
ls rHasInput dr8 0 Occupied

# If the centrifuge is in error state and empty, then close the handle.
IfErrorOnAndEmptyCheck:
and r0 rIsErrorOn rIsEmpty
beqz r0 IfErrorOn
s dr8 Open 0
j ra

#If the centrifuge is in error state (and not empty), then wait until it stops.
IfErrorOn:
beqz rIsErrorOn IfFullThenOpen
j ra

# If has maximum amount of reagents (i.e., full), then open to empty.
IfFullThenOpen:
beqz rIsFull IfNoInputHasReagents
s dr8 Open 1
j ra

# If no additional input and have reagents, then open to empty.
IfNoInputHasReagents:
or r0 rHasInput rIsEmpty
bnez r0 SwitchPowerBasedOnInput
s dr8 Open 1

# If input to process, then power on; otherwise power off.
SwitchPowerBasedOnInput:
s dr8 On rHasInput

# Return to the caller.
j ra​