Skip to content

Stationeers-ic/Ic10-and-Icx-Sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ic10 and Icx Sample

issues open-issues watchers stars release last-commit open-prs

npm-ic10 npm

npm npm npm

Sponsor this project

discord

Debugger launch

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "ic10",
            "request": "launch",
            "name": "Debug ic10",
            "program": "${fileWorkspaceFolder}${pathSeparator}${fileBasenameNoExtension}.ic10",
            "stopOnEntry": true,
            "trace": false
        }

    ]
}
  • highlights syntax for ic10
  • tooltips for function
  • snippets
  • Debugger

News

  • add icX Formatter
  • Rework Stack
  • new snippets
  • new description for variable
  • Write value in debugger
  • translate to english
  • Debugger
  • Formatter
  • Semantic code analize
  • counter left lines

counter left lines counter

new snippets snippets

demo4

img4

demo3

img3

demo2

img2

demo1

img1

img1

icX

icX is a programming language translated to ic10 used to simplify the programming of ic10 microprocessors in the Stationeers game.

Quick start

  1. Install plugin for VSC
  2. Create a file with .icX type
  3. Write a program. For example:
    use loop
    var on = d1.Open
    d0.On = on
    
  4. Save the file (Ctrl+S)
  5. Copy a code from a new generated file with the same name and type .ic10
  6. Paste code into microprocessor Ic10 in the game

Instructions

Comments

# Text after a # will be ignored to the end of the line

Vars

icX will automatically replace variable names with register names

---icX
   var a = 10
---ic10
   move r0 10

Using alias

---icX
   use aliases
   var a = 10
---ic10
   alias a r0
   move a 10

Using define

---icX
   use constants
   const PI = 3.14
---ic10
   define PI 3.14

Math

Unary operations (++, --)

inc

---icX
   var a = 0
   a++
---ic10
   move r0 0
   add r0 r0 1

dec

---icX
   var a = 0
   a--
---ic10
   move r0 0
   sub r0 r0 1

Binary operations (+, -, *, /, %)

Constants will be calculated automatically

---icX
   var x =  5 + 5 * 2 
---ic10
   move r0 15
---icX
   const x = 2 + 2
   const y = x + 2
   var z = y + 2
---ic10
   move r0 8

Binary operations with variables

---icX
   var k = 2
   var y = 5
   var x =  y + y * k
---ic10
   move r0 2
   move r1 5
   mul r15 r1 r0
   add r2 r1 r15
   add r2 r2 5

IF - ELSE

Binary logical operations used (<, >, ==, !=, <=, >=, &, |, ~=)

---icX
   var a = 0
   var b = 0
   if a >= 0
     b = 1
   else
     b = 0
   end
---ic10
   move r0 0
   move r1 0
   sgez r15 r0
   beqz r15 if0else
   beq r15 1 if0
   if0:
      move r1 1
      j if0exit
   if0else:
      move r1 0
   if0exit:

While

---icX
 var a = 0
 while a >= 10
    a++
 end
---ic10
 move r0 0
 while0:
    sge r15 r0 10
    beqz r15 while0exit
    add r0 r0 1
    j while0
 while0exit:

Devices

---icX
 d0.Setting = 1                  # Set device param
 var a = d0.Setting              # Load device param into a register 
 var b = d0.slot(a).PrefabHash   # Using a slot of the device
 a = d(5438547545).Setting(Sum)  # Batch load, where 5438547545 is hash of the device
 d(5438547545).Setting = b       # Batch configuration 
---ic10
 s d0 Setting 1
 l r0 d0 Setting
 ls r1 d0 r0 PrefabHash
 lb r0 5438547545 Setting Sum
 sb 5438547545 Setting r1

Function

To write a function, use the function keyword

{function name}()

function {function name}
   {code}
end
---icX
 use loop
 var a = 0 
 example()
 var on = d1.Open
 d0.On = on
 
 function example
     move a 1
 end
---ic10
 move r0 0
 jal example
 l r1 d1 Open
 s d0 On r1
 j 0
 example:
 move r0 1
 j ra

Stack

To easily write in stack, use the stack keyword

---icX
   stack 342423 432423 54534 6567
---ic10
   push 342423
   push 432423
   push 54534
   push 6567

For each stack

---icX
   var YourVariabele = 0
   foreach YourVariabele
    if a == 6567
       var b = 5
    end
   end
---ic10
   move sp 0 # reset counter
   while0:
      peek r0 # get value to YourVariabele
      #------- block code ---------
      seq r15 r0 6567
      beqz r15 if0exit
      move r1 5
      if0exit:
      #------- block code ---------
      breqz r0 2 # end of cycle
      add sp sp 1 # increment counter
   j while0

Use

In addition to use aliases and use constant, the following constructs are supported:

To loop the application, use use loop

---icX
 move r0 0
 jal example
 l r1 d1 Open
 s d0 On r1
 j 0
 example:
 move r0 1
 j ra
---ic10
 move r0 0
 jal example
 l r1 d1 Open
 s d0 On r1
 j 0
 example:
 move r0 1
 j ra

Use use comments to transfer your comments to ic10 code

---icX
 use comments
 # Example
 var a = 0
 var on = d1.Open
 # Example
 d0.On = on
 test()
 function test
  var c = 1
 end
---ic10
 # ---icX User code start---
 # Example
 move r0 0
 l r1 d1 Open
 # Example
 s d0 On r1
 jal test
 # ---icX User code end---
 jr 4
 test:
 move r2 1
 j ra

Additional examples of icX code

alias SolarSensor d0
alias SolarPanel d1
alias LedVertical d2
alias LedHorizontal d3
var SOLAR_HASH = d1.PrefabHash

var verical = 180
var horizontal = 180

main:
    updateLED()
    setSolarPanels()
    yield
j main

function setSolarPanels
    d(SOLAR_HASH).Vertical = verical
    d(SOLAR_HASH).Horizontal = horizontal
end

function updateLED
    d2.Setting = verical
    d3.Setting = horizontal
end

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published