initial commit
This commit is contained in:
14
.toml
Normal file
14
.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
[db]
|
||||
PressureOutput=55000
|
||||
TemperatureOutput=296
|
||||
PrefabHash="StructureFiltration"
|
||||
|
||||
[d0]
|
||||
On=0
|
||||
Lock=0
|
||||
PrefabHash="StructureDigitalValve"
|
||||
|
||||
[d1]
|
||||
On=0
|
||||
Lock=0
|
||||
PrefabHash="StructureDigitalValve"
|
16
.vscode/launch.json
vendored
Normal file
16
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "ic10",
|
||||
"request": "launch",
|
||||
"name": "Debug ic10",
|
||||
"program": "${file}",
|
||||
"stopOnEntry": true,
|
||||
"trace": false,
|
||||
}
|
||||
]
|
||||
}
|
42
airctl.ic10
Normal file
42
airctl.ic10
Normal file
@@ -0,0 +1,42 @@
|
||||
alias Bypass d0
|
||||
alias Radiator d1
|
||||
define minTemp 293.15
|
||||
define maxTemp 295.15
|
||||
|
||||
s db Open 0
|
||||
s Bypass Lock 1
|
||||
s Radiator Lock 1
|
||||
|
||||
start:
|
||||
yield
|
||||
jal safety
|
||||
pop r0
|
||||
bnez r0 start #safety triggerd. Do not continue
|
||||
l r0 db TemperatureOutput
|
||||
sgt r1 r0 maxTemp
|
||||
bgtzal r1 cooling
|
||||
|
||||
slt r1 r0 minTemp
|
||||
seqz r1 r1
|
||||
beqzal r1 cooling
|
||||
|
||||
j start
|
||||
|
||||
#safety():0|1 -> 0 : ok, 1 : overpressure
|
||||
safety:
|
||||
l r1 db PressureOutput #check the output pressure
|
||||
sgt r0 r1 50000
|
||||
push r0 # r0 == 1 if too high. Use the stack as resturn value
|
||||
s Radiator On r0
|
||||
seqz r0 r0
|
||||
s Bypass On r0
|
||||
slt r0 r1 55000
|
||||
s db Mode r0 #emergency stop
|
||||
j ra #return
|
||||
|
||||
#cooling(r1:0|1)
|
||||
cooling:
|
||||
s Radiator On r1
|
||||
seqz r1 r1
|
||||
s Bypass On r1
|
||||
j ra
|
104
crafter/autoStacker.ic10
Normal file
104
crafter/autoStacker.ic10
Normal file
@@ -0,0 +1,104 @@
|
||||
#IC chip that control flip flops to the machines input
|
||||
define HelperIC HASH("IC Housing (flip flop helper)")
|
||||
define ICHousing HASH("StructureCircuitHousing")
|
||||
#flip flop just behind the stacker to return the reminder to the user
|
||||
define OutputFlipFlop HASH("Chute Digital Flip Flop (Stacker input)")
|
||||
#define FlipFlop HASH("StructureChuteDigitalFlipFlopSplitterRight")
|
||||
define FlipFlop HASH("StructureChuteDigitalFlipFlopSplitterLeft")
|
||||
#stacker
|
||||
alias Stacker d0
|
||||
|
||||
alias stackValue r0
|
||||
alias opVal r1
|
||||
alias qteVal r2
|
||||
alias reagentHash r3
|
||||
alias StackerContent r4
|
||||
alias MachinePort r5
|
||||
alias StackerInputFull r6
|
||||
alias WrongContent r7
|
||||
alias oldQte r8
|
||||
alias oldReagent r9
|
||||
alias eq1 r10
|
||||
alias eq2 r11
|
||||
s Stacker Mode 1
|
||||
|
||||
move MachinePort 1
|
||||
|
||||
start:
|
||||
yield
|
||||
jal readReagent
|
||||
s db Setting reagentHash #used to display on a console with CircuitboardHashDisplay
|
||||
|
||||
#set qte to the parsed value or default to 500
|
||||
select qteVal qteVal qteVal 500
|
||||
s Stacker Setting qteVal
|
||||
|
||||
#goto stacker if there is a requested item
|
||||
bnez reagentHash stacker
|
||||
|
||||
#if not, set the output flipflop to return everything to the user
|
||||
sbn FlipFlop OutputFlipFlop Mode 1
|
||||
sbn FlipFlop OutputFlipFlop Setting 0
|
||||
s Stacker Mode 0 #stacker auto
|
||||
s Stacker Activate 0
|
||||
|
||||
jal findNextPort
|
||||
|
||||
j start
|
||||
|
||||
findNextPort:
|
||||
#iterate over port 1-5 to look for a machine
|
||||
add MachinePort MachinePort 1
|
||||
sgt r6 MachinePort 5
|
||||
breqz r6 2
|
||||
move MachinePort 1
|
||||
bdns dr5 iteratePort
|
||||
j ra
|
||||
|
||||
waitReagentArrive:
|
||||
#check if we need more
|
||||
brlt StackerContent qteVal 2
|
||||
s db Setting 0
|
||||
move oldQte qteVal
|
||||
move oldReagent reagentHash
|
||||
waitReagentArriveLoop:
|
||||
yield
|
||||
push ra
|
||||
jal readReagent
|
||||
pop ra
|
||||
sne eq1 oldQte qteVal
|
||||
sne eq2 oldReagent reagentHash
|
||||
or eq1 eq1 eq2
|
||||
beqz eq1 waitReagentArriveLoop
|
||||
j ra
|
||||
|
||||
readReagent:
|
||||
get stackValue dr5 54
|
||||
and opVal stackValue $ff #op
|
||||
srl qteVal stackValue 8
|
||||
and qteVal qteVal $ff #qte
|
||||
sra reagentHash stackValue 16
|
||||
rmap reagentHash dr5 reagentHash #reagentHash
|
||||
j ra
|
||||
|
||||
stacker:
|
||||
#write the active machine port id to the flipflop helper ic's setting
|
||||
sbn ICHousing HelperIC Setting MachinePort
|
||||
s Stacker Mode 1 #logic
|
||||
ls StackerContent Stacker 2 Occupied #check if the working slot is occupied
|
||||
beqz StackerContent start #if not return
|
||||
ls StackerContent Stacker 2 OccupantHash #check the occupant hash
|
||||
sne WrongContent reagentHash StackerContent
|
||||
#if reagentHash != StackerContent then set the flipflop to output everything
|
||||
sbn FlipFlop OutputFlipFlop Mode WrongContent
|
||||
sbn FlipFlop OutputFlipFlop Setting 1
|
||||
bnez WrongContent emptyStacker
|
||||
ls StackerContent Stacker 2 Quantity
|
||||
s Stacker Output 1
|
||||
yield
|
||||
emptyStacker:
|
||||
s Stacker Activate 1
|
||||
yield
|
||||
s Stacker Activate 0
|
||||
beqzal WrongContent waitReagentArrive
|
||||
j start
|
23
crafter/flipFlopHelper.ic10
Normal file
23
crafter/flipFlopHelper.ic10
Normal file
@@ -0,0 +1,23 @@
|
||||
alias devicePointer r1
|
||||
alias targetDevice r0
|
||||
alias shouldOpen r2
|
||||
|
||||
move devicePointer 0
|
||||
init:
|
||||
brdns dr1 3
|
||||
s dr1 On 1
|
||||
s dr1 Setting 0
|
||||
add devicePointer devicePointer 1
|
||||
ble devicePointer 5 init
|
||||
|
||||
start:
|
||||
yield
|
||||
move devicePointer 0
|
||||
l targetDevice db Setting
|
||||
loop:
|
||||
seq shouldOpen devicePointer targetDevice
|
||||
brdns dr1 2
|
||||
s dr1 Mode shouldOpen
|
||||
add devicePointer devicePointer 1
|
||||
ble devicePointer 5 loop
|
||||
j start
|
44
crafter/recipe.ic10
Normal file
44
crafter/recipe.ic10
Normal file
@@ -0,0 +1,44 @@
|
||||
alias Machine d0
|
||||
alias Qte d1
|
||||
alias Button d2
|
||||
define StructureEmergencyButton HASH("StructureEmergencyButton")
|
||||
alias IsStructureEmergencyButton r10
|
||||
|
||||
s Machine ClearMemory 1
|
||||
clr Machine
|
||||
l IsStructureEmergencyButton Button PrefabHash
|
||||
seq IsStructureEmergencyButton IsStructureEmergencyButton StructureEmergencyButton
|
||||
|
||||
start:
|
||||
yield
|
||||
jal monitorOn
|
||||
put Machine 0 PrinterInstruction.WaitUntilNextValid
|
||||
l r0 Button Setting
|
||||
beqz r0 start
|
||||
breqz IsStructureEmergencyButton 2
|
||||
s Button Open 0
|
||||
s Button Lock 1
|
||||
s Machine ClearMemory 1
|
||||
l r0 Machine RecipeHash
|
||||
sll r1 r0 16
|
||||
l r0 Qte Setting
|
||||
sll r2 r0 8
|
||||
or r0 r1 r2
|
||||
or r0 r0 PrinterInstruction.ExecuteRecipe
|
||||
put Machine 1 r0
|
||||
l r0 Qte Setting
|
||||
yield
|
||||
l r1 Machine ExportCount
|
||||
brlt r1 r0 -2
|
||||
s Button Lock 0
|
||||
j start
|
||||
|
||||
monitorOn:
|
||||
l r0 Machine On
|
||||
breqz IsStructureEmergencyButton 4
|
||||
brnez r0 2
|
||||
s Button Open r0
|
||||
s Button On r0
|
||||
select r0 r0 0 1
|
||||
s Button Lock r0
|
||||
j ra
|
125
filtration/filtration_crafter.ic10
Normal file
125
filtration/filtration_crafter.ic10
Normal file
@@ -0,0 +1,125 @@
|
||||
define STATION -2
|
||||
define TRASHSTATION -7
|
||||
define RESERVE -9
|
||||
define MAXRESERVESOLT 1
|
||||
define DEBUG 0
|
||||
|
||||
alias arg r14
|
||||
alias returnVal r15
|
||||
alias robot d0
|
||||
alias filterHash r13
|
||||
alias printer d1
|
||||
s db Open 0
|
||||
|
||||
start:
|
||||
yield
|
||||
l r0 db PressureOutput
|
||||
slt r0 r0 50000
|
||||
s db Mode r0
|
||||
|
||||
move arg 0
|
||||
jal checkSlotSpent
|
||||
bgtzal returnVal dumpFilter
|
||||
move arg 1
|
||||
jal checkSlotSpent
|
||||
bgtzal returnVal dumpFilter
|
||||
j start
|
||||
|
||||
checkSlotSpent:
|
||||
#arg slotID
|
||||
#returnVal : bool 0|1
|
||||
move returnVal 0
|
||||
ls r0 db arg Occupied
|
||||
beqz r0 ra #if not occupied return 0
|
||||
ls r0 db arg Quantity
|
||||
sle returnVal r0 DEBUG
|
||||
j ra
|
||||
|
||||
dumpFilter:
|
||||
yield
|
||||
#arg slotid
|
||||
l r0 robot Setting
|
||||
bnez r0 dumpFilter
|
||||
push ra
|
||||
push arg
|
||||
move arg STATION
|
||||
jal moveRobot #move to self
|
||||
pop arg
|
||||
jal activateRobot #pick
|
||||
ls filterHash robot 0 OccupantHash
|
||||
jal craft #craft a new filter
|
||||
push arg
|
||||
move arg TRASHSTATION
|
||||
jal moveRobot #move to trash
|
||||
move arg 0
|
||||
jal activateRobot #place in trash
|
||||
move arg RESERVE
|
||||
jal moveRobot #move to reserve
|
||||
jal pickAny #pick in reserve
|
||||
ls r0 robot 0 Occupied
|
||||
beqz r0 returnHome #if empty handed return home
|
||||
move arg STATION
|
||||
jal moveRobot #move to self
|
||||
pop arg
|
||||
jal activateRobot #put the picked filter in
|
||||
push arg #push so it can be poped without stack underflow
|
||||
returnHome:
|
||||
pop arg
|
||||
#return to base
|
||||
s robot Setting 0
|
||||
pop ra
|
||||
j ra
|
||||
|
||||
pickAny:
|
||||
push arg
|
||||
move arg 0
|
||||
searchLoop:
|
||||
s robot TargetSlotIndex arg
|
||||
ls r1 robot 255 Occupied
|
||||
ls r2 robot 255 OccupantHash
|
||||
add arg arg 1
|
||||
beqz r1 searchLoop
|
||||
bne r2 filterHash searchLoop
|
||||
bgt r0 MAXRESERVESOLT ra
|
||||
push ra
|
||||
sub arg arg 1
|
||||
jal activateRobot
|
||||
pop ra
|
||||
pop arg
|
||||
j ra
|
||||
|
||||
waitRobotIdle:
|
||||
yield
|
||||
l r0 robot Idle
|
||||
beqz r0 waitRobotIdle
|
||||
j ra
|
||||
|
||||
activateRobot:
|
||||
#arg TargetSlotId
|
||||
s robot TargetSlotIndex arg
|
||||
s robot Activate 1
|
||||
push ra
|
||||
jal waitRobotIdle
|
||||
pop ra
|
||||
j ra
|
||||
|
||||
moveRobot:
|
||||
#arg target
|
||||
s robot Setting arg
|
||||
push ra
|
||||
jal waitRobotIdle
|
||||
pop ra #move the robotait for it to be idle
|
||||
j ra #return
|
||||
|
||||
craft:
|
||||
clr printer
|
||||
s printer ClearMemory 1
|
||||
sll r1 filterHash 16
|
||||
sll r2 1 8
|
||||
or r0 r1 r2
|
||||
or r0 r0 PrinterInstruction.ExecuteRecipe
|
||||
put printer 0 r0
|
||||
yield
|
||||
l r0 printer ExportCount
|
||||
brlez r0 -2
|
||||
j ra
|
106
filtration/filtration_larre.ic10
Normal file
106
filtration/filtration_larre.ic10
Normal file
@@ -0,0 +1,106 @@
|
||||
define STATION -2
|
||||
define TRASHSTATION -7
|
||||
define RESERVE 2
|
||||
define MAXRESERVESOLT 9
|
||||
|
||||
alias arg r14
|
||||
alias returnVal r15
|
||||
alias robot d0
|
||||
#alias Light d1
|
||||
s db Open 0
|
||||
|
||||
start:
|
||||
yield
|
||||
l r0 db PressureOutput
|
||||
slt r0 r0 50000
|
||||
s db Mode r0
|
||||
|
||||
move arg 0
|
||||
jal checkSlotSpent
|
||||
bgtzal returnVal dumpFilter
|
||||
move arg 1
|
||||
jal checkSlotSpent
|
||||
bgtzal returnVal dumpFilter
|
||||
j start
|
||||
|
||||
checkSlotSpent:
|
||||
#arg slotID
|
||||
#returnVal : bool 0|1
|
||||
move returnVal 0
|
||||
ls r0 db arg Occupied
|
||||
beqz r0 ra #if not occupied return 0
|
||||
ls r0 db arg Quantity
|
||||
seqz returnVal r0#if Quantity is 0 then return 1
|
||||
j ra
|
||||
|
||||
dumpFilter:
|
||||
yield
|
||||
#arg slotid
|
||||
l r0 robot Setting
|
||||
bgtz r0 dumpFilter
|
||||
push ra
|
||||
push arg
|
||||
move arg STATION
|
||||
jal moveRobot #move to self
|
||||
pop arg
|
||||
jal activateRobot #pick
|
||||
push arg
|
||||
move arg TRASHSTATION
|
||||
jal moveRobot #move to trash
|
||||
move arg 0
|
||||
jal activateRobot #place in trash
|
||||
move arg RESERVE
|
||||
jal moveRobot #move to reserve
|
||||
jal pickAny #pick in reserve
|
||||
ls r0 robot 0 Occupied
|
||||
beqz r0 returnHome #if empty handed return home
|
||||
move arg STATION
|
||||
jal moveRobot #move to self
|
||||
pop arg
|
||||
jal activateRobot #put the picked filter in
|
||||
push arg #push so it can be poped without stack underflow
|
||||
returnHome:
|
||||
pop arg
|
||||
#return to base
|
||||
s robot Setting 0
|
||||
pop ra
|
||||
j ra
|
||||
|
||||
pickAny:
|
||||
push arg
|
||||
move arg 0
|
||||
searchLoop:
|
||||
s robot TargetSlotIndex arg
|
||||
ls r1 robot 255 Occupied
|
||||
add arg arg 1
|
||||
beqz r1 searchLoop
|
||||
bgt r0 MAXRESERVESOLT ra
|
||||
push ra
|
||||
sub arg arg 1
|
||||
jal activateRobot
|
||||
pop ra
|
||||
pop arg
|
||||
j ra
|
||||
|
||||
waitRobotIdle:
|
||||
yield
|
||||
l r0 robot Idle
|
||||
beqz r0 waitRobotIdle
|
||||
j ra
|
||||
|
||||
activateRobot:
|
||||
#arg TargetSlotId
|
||||
s robot TargetSlotIndex arg
|
||||
s robot Activate 1
|
||||
push ra
|
||||
jal waitRobotIdle
|
||||
pop ra
|
||||
j ra
|
||||
|
||||
moveRobot:
|
||||
#arg target
|
||||
s robot Setting arg
|
||||
push ra
|
||||
jal waitRobotIdle
|
||||
pop ra #move the robotait for it to be idle
|
||||
j ra #return
|
111
filtration/filtration_larre_singleinput.ic10
Normal file
111
filtration/filtration_larre_singleinput.ic10
Normal file
@@ -0,0 +1,111 @@
|
||||
define STATION -3
|
||||
define TRASHSTATION -7
|
||||
define RESERVE -8
|
||||
define MAXRESERVESOLT 9
|
||||
define DEBUG 0
|
||||
|
||||
alias arg r14
|
||||
alias returnVal r15
|
||||
alias robot d0
|
||||
alias filterHash r13
|
||||
#alias Light d1
|
||||
s db Open 0
|
||||
|
||||
start:
|
||||
yield
|
||||
l r0 db PressureOutput
|
||||
slt r0 r0 50000
|
||||
s db Mode r0
|
||||
|
||||
move arg 0
|
||||
jal checkSlotSpent
|
||||
bgtzal returnVal dumpFilter
|
||||
move arg 1
|
||||
jal checkSlotSpent
|
||||
bgtzal returnVal dumpFilter
|
||||
j start
|
||||
|
||||
checkSlotSpent:
|
||||
#arg slotID
|
||||
#returnVal : bool 0|1
|
||||
move returnVal 0
|
||||
ls r0 db arg Occupied
|
||||
beqz r0 ra #if not occupied return 0
|
||||
ls r0 db arg Quantity
|
||||
sle returnVal r0 DEBUG
|
||||
j ra
|
||||
|
||||
dumpFilter:
|
||||
yield
|
||||
#arg slotid
|
||||
l r0 robot Setting
|
||||
bgtz r0 dumpFilter
|
||||
push ra
|
||||
push arg
|
||||
move arg STATION
|
||||
jal moveRobot #move to self
|
||||
pop arg
|
||||
jal activateRobot #pick
|
||||
ls filterHash robot 0 OccupantHash
|
||||
push arg
|
||||
move arg TRASHSTATION
|
||||
jal moveRobot #move to trash
|
||||
move arg 0
|
||||
jal activateRobot #place in trash
|
||||
move arg RESERVE
|
||||
jal moveRobot #move to reserve
|
||||
jal pickAny #pick in reserve
|
||||
ls r0 robot 0 Occupied
|
||||
beqz r0 returnHome #if empty handed return home
|
||||
move arg STATION
|
||||
jal moveRobot #move to self
|
||||
pop arg
|
||||
jal activateRobot #put the picked filter in
|
||||
push arg #push so it can be poped without stack underflow
|
||||
returnHome:
|
||||
pop arg
|
||||
#return to base
|
||||
s robot Setting 0
|
||||
pop ra
|
||||
j ra
|
||||
|
||||
pickAny:
|
||||
push arg
|
||||
move arg 0
|
||||
searchLoop:
|
||||
s robot TargetSlotIndex arg
|
||||
ls r1 robot 255 Occupied
|
||||
ls r2 robot 255 OccupantHash
|
||||
add arg arg 1
|
||||
beqz r1 searchLoop
|
||||
bne r2 filterHash searchLoop
|
||||
bgt r0 MAXRESERVESOLT ra
|
||||
push ra
|
||||
sub arg arg 1
|
||||
jal activateRobot
|
||||
pop ra
|
||||
pop arg
|
||||
j ra
|
||||
|
||||
waitRobotIdle:
|
||||
yield
|
||||
l r0 robot Idle
|
||||
beqz r0 waitRobotIdle
|
||||
j ra
|
||||
|
||||
activateRobot:
|
||||
#arg TargetSlotId
|
||||
s robot TargetSlotIndex arg
|
||||
s robot Activate 1
|
||||
push ra
|
||||
jal waitRobotIdle
|
||||
pop ra
|
||||
j ra
|
||||
|
||||
moveRobot:
|
||||
#arg target
|
||||
s robot Setting arg
|
||||
push ra
|
||||
jal waitRobotIdle
|
||||
pop ra #move the robotait for it to be idle
|
||||
j ra #return
|
31
filtration/filtration_monitoring.ic10
Normal file
31
filtration/filtration_monitoring.ic10
Normal file
@@ -0,0 +1,31 @@
|
||||
alias Light d0
|
||||
s db Open 0
|
||||
|
||||
init:
|
||||
yield
|
||||
bdns Light init
|
||||
l r0 Light PrefabHash
|
||||
bne r0 -1535893860 init
|
||||
start:
|
||||
yield
|
||||
l r0 db PressureOutput
|
||||
slt r0 r0 50000
|
||||
s db Mode r0
|
||||
|
||||
move r0 0
|
||||
jal checkSlot
|
||||
move r2 r1
|
||||
move r0 1
|
||||
jal checkSlot
|
||||
add r2 r2 r1
|
||||
beq r2 2 start
|
||||
s Light On 1
|
||||
j start
|
||||
checkSlot:
|
||||
#r0 slotID
|
||||
#return : r1 -> bool 0|1
|
||||
ls r1 db r0 Occupied
|
||||
beqz r1 ra
|
||||
ls r1 db r0 Quantity
|
||||
snez r1 r1
|
||||
j ra
|
27
helmet.ic10
Normal file
27
helmet.ic10
Normal file
@@ -0,0 +1,27 @@
|
||||
s db SoundAlert 0
|
||||
|
||||
start:
|
||||
|
||||
l r0 db PressureExternal
|
||||
sgt r0 r0 60
|
||||
bgtz r0 safeAthmo
|
||||
bdns d0 noHelm1
|
||||
s d0 Lock 1
|
||||
s d0 Open 0
|
||||
noHelm1:
|
||||
s db AirRelease 1
|
||||
s db On 1
|
||||
l r0 db RatioCarbonDioxide
|
||||
sgt r0 r0 0.2
|
||||
s db Filtration r0
|
||||
j start
|
||||
|
||||
safeAthmo:
|
||||
bdns d0 noHelm2
|
||||
s d0 Lock 0
|
||||
s d0 Open 1
|
||||
noHelm2:
|
||||
s db Filtration 0
|
||||
s db AirRelease 0
|
||||
s db On 0
|
||||
j start
|
Reference in New Issue
Block a user