IGB Compiler L1 compiles IGB L1 code into IGB Binary.
You may call it an assembly language.
The IGB CL2 compiles high-level code into this low-level code.
The instruction set file can be seen here.
*string*|*number*
If the current argument equals string, number is returned.i
The input value is returned as it is.d
The input value gets multiplied by 1000 (learn why here)@
accepts two arguments:n
that returns 0c
that returns 1
If it's next argument is 'd' and the current argument equals 'c', the next argument isn't multiplied by 1000.
P
If the argument is a string, returns the cell of a pointer. If the argument is an integer, returns it.
Hint: |12| means cell 12
input: Math % 10 c 11 12
syntax match: Math|7 %|3 i @ d i
output: 7 1 10 1 11 12
That instruction can be translated into |12| = |10| % |12|
input: Math % 10 n 11 12
syntax match: Math|7 %|3 i @ d i
output: 7 1 10 0 11000 12
That instruction can be translated into |12| = |10| % 12
There are cells allocated for the IGB VM.
You are safe to use cells 70 or above.
Here are some more important cells:
0 - Function return
1 - Screen width
2 - Screen height
3 - Screen type (0=16c
, 1=rgb
)
4 - Keyboard input char
56 - charLib char code
57 - charLib char x
58 - charLib char y
The full list can be seen here.
Syntax: If *operation* i @ d P
If cell arg2
operation arg4 / |arg4|
is false then jump to arg5
(pointer or integer)
Example: If > 70 n 5 :myfunction
Which means: If cell 70 is NOT higher than the number 5000 jump to :mypointer
Syntax: Init d i
Writes arg1
to cell arg2
Example: Init 5.3 70
Which means: Write 5300 to cell 70
Syntax: Copy i i
Copies cell arg1
to cell arg2
Example: Copy 70 71
Which means: Read cell 70 and write it to cell 71
Syntax: Add i @ d i
Adds cell arg1
to arg3 / |arg3|
and store the result in cell arg4
Why a seperate instruction for adding numbers? It's faster that way.
Example: Add 70 c 71 72
Which means: Add cell 70 and cell 71 and store the result in cell 72
Jump Syntax: Cell Jump P
Sets the current cell to arg2
Call Syntax: Cell Call P
Stores the current cell on a stack and sets the current cell to arg2
Return Syntax: Cell Return
Pops the stack and sets the current cell to it
The screen type (cell 3
) determinates which syntax will do what at runtime.
I recommend that you read about more about pixel cache here.
-
Pixel @ i @ i
Sets the pixel at x=arg2 / |arg2|
, y=arg4 / |arg4|
with the color stored in the pixel cache. -
Pixel Cache Raw i
Sets the pixel cache toarg3
RGB exclusive synax:
-
Pixel Cache @ i @ i @ i
Calculated at runtime the pixel cache from the arguments. (arg3
is r,arg5
is g,arg7
is b)
If all arguments ared
, the cache is computed at compile-time and the instruction is swapped withPixel Cache Raw
. -
Pixel @ i @ i i
Gets the rgb color from pixel at x=arg2 / |arg2|
, y=arg4 / |arg4|
and- r is writen to cell
arg5
- g is written to cell
arg5
+1 - b is written to cell
arg5
+2
- r is writen to cell
16c exclusive synax:
-
Pixel Cache i
Sets pixel cache to cellarg2
-
Pixel @ i @ i i
Gets the 16c color from pixel at x=arg2 / |arg2|
, y=arg4 / |arg4|
and writes it toarg5
-
Device CoreWait i
Waitsarg2
ticks (a tick is 1/20 of a second) -
Device ScreenUpdate
Resizes the screen based on the cells in memory and filles it with #FFFFFF -
Device Log @ d
Printsarg3 / |arg3|
to the terminal/chat.
-
Syntax for
-
*
/
%
operations:Math *operation* i @ d i
It does what you think. -
Syntax for random:
Math R i i i
Writes a random number fromarg2
toarg3
to cellarg4
- Syntax for
CC
:Math CC i i
It reads the value from cellarg2
, then reads the value at cell it just read, then writes in to cellarg3
If you assume ram is an array, then that's how it works:
ram[ arg3 ] = ram[ ram[ arg2 ] ]
Used for reading from arrays.
-
Syntax for
CW
:Math CW i i
Writes value from cellarg2
to cell read from cellarg3
If you assume ram is an array, then that's how it works:
ram[ ram[ arg3 ] ] = ram[ arg2 ]
Used for writing to arrays. -
Synax for sqrt:
Math sqrt i i
Writes the square root of cellarg2
to cellarg3
Licensed under GNU GPLv3 or later