PixelCode

From Esolang
Jump to navigation Jump to search

PixelCode is an esoteric programming language that was created by Vladimir Dabić (SealedKiller), inspired by Brainfuck among others.

Overview

PixelCode operates on a 25x19 screen, a 25x19 buffer screen, an array of Brainfuck memory cells, and 2 stacks, as well as a pointer which initially points to the first memory cell and to the top-left corner of the screen at (0, 0). Both stacks are used as arguments for certain instructions based on which one is selected. They are also visually inverted, with items arriving at the bottom then falling upwards, but act the same as expected.

There are two modes: Drawing and Memory. Drawing mode will move the screen pointer up, down, left, and right. Memory mode will move the memory pointer left and right. The initial mode is drawing mode.

There is an additional I/O panel included in the interpreter, with buttons 1, 2, 3, 4, 5, and S, along with a colored bar that initially starts black. The behavior of this panel is not stated in the documentation.

Instructions

Some instructions act differently depending on what mode is used or if - is preceded, as -~. Blank cells are not defined by the documentation. The / and # operators are explained in seperate sections.

Instruction Drawing mode Memory mode - modified
> Move screen pointer right Move memory pointer right
< Move screen pointer left Move screen pointer left
^ Move screen pointer up
_ Move screen pointer down Set cell to 0
. Place pixel (i.e. set pixel to black) Increment cell Place pixel
, Delete pixel (i.e. set pixel to white) Decrement cell Print ASCII
: Push cell to selected stack Toggle selection between stacks 1 and 2 (default is stack 1)
; Pop from the selected stack to cell Pop from other side of selected stack to cell
! Toggle drawing/memory mode (default is drawing)
@ Use top 2 numbers (top as Y, second from top as X) then move pointer to X, Y
~ clear selected stack clear screen
% show buffer
* end program
/ ALU - see below
$ waits for user to click on screen, then pushes X then Y coordinates to selected stack, then moves pointer to clicked coordinates set cell to numerical user input (integers only)
# Comparison - see below clear buffer screen
[...] If cell is greater than 0, execute ...
{...} While cell is greater than 0, execute ...

/

Use top 3 #s F, N1, N2, (don't pop) then set memory cell to output
F = 1 => N1 + N2
F = 2 => N1 - N2
F = 3 => N1 * N2
F = 4 => N1 / N2
F = 5 => random # between N1 to N2, inclusive

#

Pop 3 #s F, N1, N2, then set memory cell to output
F = 1 => N1 == N2   true => 1
F = 2 => N1 != N2   false => 0
F = 3 => N1 > N2
F = 4 => N1 < N2

Example Programs

Draws a smiley face on the screen.
 >_.>>.>__._<.<.<.<^.
A very simple "drawing" program.
You click on the screen and it places a dot.
!.!{$.~}
The same program as above, but clicking the S button in the IO panel clears the screen.
!.{$!.!>S[,-~]<~}
!.! increments memory cell
{ while(1){
$   wait for screen click, pushes X then Y, moves screen pointer to (X, Y)
.   places pixel
!>! moves memory pointer right
S   ???
[   if the cell after S was done > 0 {
-~    clear screen
]   }
!<! moves memory pointer left
~   clear stack
} }
Draws a smiley face using the screen buffer.
>_-.>>-.>__-._<-.<-.<-.<^-.%
Draws 2 dots and, depending on which one you click, it will draw a dot in a specific place.
>_.>>.$-~!-;>-;>.:,<<:>>.:,<>#[~<{,}<{,}::!@~.*]~.:,<<:>>...:,<>#[~<{,}<{,}::!@~>.*]*
A program that uses the inputs and the indicators to draw on the screen!
Press 1 = Move Pointer to X, Y (It asks you for two numbers)
Press 2 = Place Pixel
Press 3 = Clear Screen
Press 4 = End
!.{~>>|<\>|<-;>.::,<:>>#[>~-$:-$:!@!~_<]~<.:.:,,<:>>#[~!.%!~]~<.:..:,,,<:>>#[~!-~-#!~]~<.:...:,,,,<:>>#[~*~]<<<}

Links

PixelCode GitHub