The purpose of this thread is to over-explain my latest save "Poorly Organized FILT Computer" [2601751].
The Basics
My "computing machine" works on the idea of "buffers". The buffers are like RAM on a budget, as the computer's functions interact with them in different ways; for example, writing a value or changing the mode of something. There are 2 buffers in the computer, designated "A" and "B", to allow for juggling multiple values at once while not over-complicating too much. All the functions/commands and their usage are listed below.
Programs are long lines of FILT with specific ctype values, which correspond to different commands. They are colour-coded to make it easier to read, but require a programmer to either copy-and-paste FILT pixels from the reference, or use my LUA code compiler. Code must be pasted in line with the ARAY reader head, where the red FILT begins on the left, and pressing the start button on the left will begin running the code.
Numbers, to this computer, must be in a specific format; they all have bits 2^28 & 2^29 set to 1, as a BRAY with ctype 0 cannot exist and would halt the computer, while 2^27 is the sign of the number and copies itself when rightshifted.
Commands
Storage Pos Set
Compiler command: `spos`
Sets the storage head position to the buffer A. In other words, prepares writing and reading for a specific point in the chunk of FILT. The "selected" FILT pixel will not change until the command is called again.
Example:
set 79
spos
Storage Write
Compiler command: `swrite`
Writes the buffer A value to the selected storage FILT pixel, to be read later.
Example:
set 88
spos
input
swrite
Storage Get
Compiler command: `sget`
Gets the value of the selected storage FILT pixel to buffer A, to work with.
Example:
set 42
spos
sget
Bit-Op Mode
Compiler command: `bopmode`
Sets bit operator mode to the buffer A value. In other words, prepares the bit operator for a specific operation. Available modes are numbered 0-9 and have keyword aliases for use in the compiler:
0 `val2` The secondary value for the operations XOR, subtract, OR, & AND. Sets the value of FILT that BRAY will pass through.
1 `not` Inverts the passed value, setting all 1 bits to 0 and vice-versa.
2 `xor` For each bit, returns 1 if it is different from the secondary value and 0 if they are the same.
3 `sub` Returns the passed value, except for the 1 bits in the secondary value.
4 `or` Returns the passed value, including the bits in the secondary value.
5 `and` For each bit, returns 1 if both it and the secondary value are 1 and 0 if either is 0.
6 `left` Leftshifts all bits by 1 spot, effectively multiplying by 2.
7 `right` Rightshifts all bits by 1 spot, effectively dividing by 2.
8 `add1` The first value to be added to another. Doesn't return anything, but is changed when a second value is called so cannot be reused.
9 `add2` The second value to be added to another. Returns the sum of it plus the first value.
Bit-Op Write
Compiler command: `bopwrite`
Passes the buffer A value through bit operator of current mode, usually overwriting buffer A. For example if the operator mode is 5, will set buffer A to its inverse.
Example:
set 21
spos
set or
bopmode
sget
bopwrite
Update Buffers
Compiler command: `update`
Copies buffer A to buffer B. Useful if you need to modify one instance of a value without having to store it permanently.
Swap Buffers
Compiler command: `swap`
Swaps buffers A & buffer B. Allows a program to juggle 2 numbers, without which it'll be practically unusable.
Example:
input
update
set not
bopmode
swap
bopwrite
Goto in ROM
Compiler command: `goto`
Goes a specific index in the program, the index being the buffer A value.
Example:
set 55
goto
If B = 0...
Compiler command: `if0`
Unless buffer B is 0, skips the next instruction/FILT pixel. Note it is buffer B being tested; this is done so the tested value doesn't have to be the used value for commands such as `goto`.
Example:
input
update
set 55
if0
goto
Input Number
Compiler command: `input`
"Prompts" a user to input a value. A small block of FILT on the right, below the text output, will glow - a user can CTRL-Shift the FILT's ctype and SPRK its edge to write a value to buffer A.
Output Character
Compiler command: `output`
Output the buffer A value as raw pixel data. This allows for custom characters to be printed, but it's tedious to display readable text/numbers.
One needs to add 4032 (keyword `alphabet`) to the character ID they'd like to display as seen on the left of the save, use character aliases in the format 'A', or set & output the value from the character designer.
Example:
set 'H'
output
set 'I'
output
End Program
Compiler command: `end`
Usually not necessary to put in a script, as the default ROM is filled with this so a program will stop when it reaches the end, but can allow for ending in the middle of a program without needing a `goto`.
Example:
input
update
if0
end
Set Value
Compiler command: `set <VALUE>`
The only "command" that directly influences the buffer, and has a parameter in the compiler. Sets buffer A to a number after `set`, predefined alias such as `not`, `alphabet`, or valid character in apostrophes ('A').
You can refer to the table in the LUA script for specific details, but characters A-Z, 0-9, and some basic grammar is included.
Any value in the ROM with bits 2^28 & 2^29 set to 1 will register as a number to set buffer A to, if neither bit is set it will assume it is a command to execute. If you are coding manually, pass numbers through the small tool to the right of the start button.
LUA Compiler
Due to the awkwardness of programming directly, by copying FILT pixels and setting ctypes, one may download a compiler I wrote at https://pastebin.com/A59vbdP6. By running `dofile("PATH-TO-THIS-SCRIPT")` in the console, then entering the directory of a text file of your script, you'll be able to click and create a line of FILT converted from your code. Additionally, a custom language highlighing definition is available at https://pastebin.com/ayjhnANS for Notepad++.
The compiler has an extra feature, being "goto tags". After writing a line and adding `(TAG)`, where "TAG" can be practically anything, all instances of `[TAG]` will be replaced with the line number of the tag with round brackets. Keep in mind that the actual tag needs to be after a fully completed command, so that it doesn't actually get parsed. For example:
Lines not beginning with any command will be completely ignored. This means you can add comments, preferrably starting with a "#", and chunk code with "{" and "}"