Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Last active November 30, 2022 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleverca22/465314761110b26e65383289f2dc10f5 to your computer and use it in GitHub Desktop.
Save cleverca22/465314761110b26e65383289f2dc10f5 to your computer and use it in GitHub Desktop.
start:
alias FlushSwitch d0
alias FlushRegulator d1
alias Furnace d2
alias FillSwitch d3
alias FillRegulator d4
loop:
l r0 FillSwitch Open
s FillRegulator On r0
l r0 FlushSwitch Open
s FlushRegulator On r0
# check for valid recipe and auto-eject
ls r0 Furnace 0 Occupied
beq r0 1 done
l r0 Furnace RecipeHash
beq r0 0 invalid
s Furnace Open 1
j done
invalid:
s Furnace Open 0
done:
yield
j loop
alias Plant d0
loop:
l r0 d0 Activate #Check ready for next command
bnez r0 done
ls r0 Plant 0 Mature
beq r0 0 done
beq r0 1 needHarvest
beq r0 -1 needPlant
j done
needHarvest:
s Plant Harvest 1
j done
needPlant:
s Plant Plant 1
j done
done:
sleep 2
j loop
alias Panel d0
define panels -2045627372
alias TargetH r0
alias TargetV r1
alias CurRatio r2
alias RatioDelta r3
alias Temp r4
alias HSpeed r5
alias VSpeed r6
init:
move HSpeed 1
move VSpeed 1
move TargetV 30
jal readRatio
start:
jal readRatio
bltz RatioDelta worseH
j doneH
worseH:
mul HSpeed HSpeed -1
doneH:
add TargetH TargetH HSpeed
max Temp TargetH 0
beq Temp 0 good1
move TargetH 0
mul HSpeed HSpeed -1
good1:
min Temp TargetH -180
beq Temp -180 good2
move TargetH -180
mul HSpeed HSpeed -1
good2:
round TargetH TargetH
jal updatePanel
yield
justV:
jal readRatio
bltz RatioDelta worseV
j doneV
worseV:
mul VSpeed VSpeed -1
doneV:
add TargetV TargetV VSpeed
max Temp TargetV 0
bne Temp 0 good3
move TargetV 0
mul VSpeed VSpeed -1
good3:
min Temp TargetV 0
beq Temp 0 good4
move TargetV 0
mul VSpeed VSpeed -1
good4:
round TargetV TargetV
jal updatePanel
yield
j justV
updatePanel:
sb panels Horizontal TargetH
sb panels Vertical TargetV
s db Setting TargetV
j ra
readRatio:
move Temp CurRatio
l CurRatio Panel Ratio
mul CurRatio CurRatio 100
round CurRatio CurRatio
sub RatioDelta CurRatio Temp
j ra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment