What would be the tape in normal Brainfuck is a three-dimensional 320x240 array of pixels matching the size of a graphical display, each pixel containing 3 cells for each of the three RGB color components. The programs start at (0,0,R), the commands are mostly the same as in Brainfuck, with the
< commands moving the pointer along the cells on the X-axis, the R cell of the next pixel going after the B cell and vice-versa, wrapping back to the beginning or the end of the line in a circular fashion.
- similarly wraps around when 0 or 255 are reached.
To move between the lines, GBF introduces an additional command,
@, which flips between horizontal and vertical modes. In vertical mode,
< moves up along the Y-axis instead of left, likewise for
> which moves to the pixel below's R cell instead of the right pixel's when the pointer is on a B cell.
GBF does not change the color of the display by itself, instead the
. command is used to send each of the three RGB cells of the current pixel at the current pointer position on the screen. In the reference implementation,
! is used to wait for a key, but the value isn't written to the cell like
The language can be adapted to run with screen of any size than 320x240 and cells going up to other values than 255 to accomodate for other color spaces such as RGB565 (R and B goes up to 31, G goes up to 63), CMYK (which would require 4 cells/pixel instead of 3 going from 0 to 100) and HSL (H goes from 0 to 359 and S and L goes from 0 to 100), or even monochrome (probably more akin normal brainfuck at this point with a single bit/pixel and
+ ends up doing the same thing as
- as bit flippers,
@ may still be useful). If the screen is unbounded, the language should be Turing-complete.
||Move the pointer to the cell to the right in horizontal mode or down in vertical mode|
||Move the pointer to the cell to the left in horizontal mode or up in vertical mode|
||Increment the memory cell under the pointer|
||Decrement the memory cell under the pointer|
||Output the pixel the cell at the pointer is part of at the current pointer position on the screen|
||Waits for key input and store the character in the cell at the pointer, mod the maximum capacity of that cell|
||Jump past the matching |
||Jump back to the matching |
||Flips between horizontal and vertical modes|
||Waits for key input, but discards it (optional)|
Paints screen white