PixelCode

From Esolang
Jump to: navigation, search

PixelCode is a esoteric programming language that was created by Vladimir Dabić (SealedKiller). It was inspired by Brainfuck and other esoteric programming languages.

Language Overview

PixelCode operates on an array of memory cells and a screen to draw on. There is a pointer, initially pointing to the first memory cell and to the top left corner of the screen.

There are two modes: Drawing and Memory

If you're on drawing mode you will move the screen pointer around using the move commands. If you're on memory mode you will move the memory pointer which can be only moved left and right.

Basic Instructions

> - Move Pointer Right
< - Move Pointer Left
^ - Move Pointer Up (Only in Drawing Mode)
_ - Move Pointer Down (Reset Cell - Memory Mode)
. - Place Pixel (Add One - Memory Mode)
, - Delete Pixel (Substract One - Memory Mode)
: - Push current memory cell onto Stack
; - Pop from the Stack to the current memory cell
! - Toggle Mode (Draw, Memory)

There are two stacks in this language, the first stack is often used for arguments of some instructions. The second stack is never used by any instruction so you can push stuff to it.

Your first program

Okay, so lets draw a smiley face!

So we can't really do a Hello World program because you can't print text.

Smiley face program
>_.
>>.
>__.
_<.
<.
<.
<^.

This is a set of instructions to draw a smiley face on the screen.

It basically moves the pointer around and places pixel to draw it.

The same program in minimised form:

>_.>>.>__._<.<.<.<^.

Special Functions

If you put a dash in front of a letter it will run a completely different instruction

This is to increase the number of functions that the interpreter can run.

Here's a list of letters that have a special function

Put a dash ( - ) in front of these characters and you'll run a different instruction. 
ex. -$

;  Pop from top of the currently selected stack.
~  Clear the drawing screen
#  Clear the buffer
$  Input a number into the current memory cell
.  Draw to the buffer
:  Toggle between Stack 1 and Stack 2

Full list of instructions

> - Move Pointer Right
< - Move Pointer Left
^ - Move Pointer Up (Drawing Mode)
_ - Move Pointer Down (Reset Cell - Memory Mode)
. - Place Pixel (Add One - Memory Mode)
, - Delete Pixel (Substract One - Memory Mode)
: - Push current memory cell onto Stack
; - Pop from the Stack to the current memory cell
! - Toggle Mode (Draw, Memory)
@ - Move Pointer to a location X,Y (Push onto stack X then Y and then use this)
~ - Clear Stack
% - Display Buffer
* - End Program
/ - ALU (Devide, Substact, Add, Mulitply - MORE EFFICIENT than the Brainfuck way | Push onto stack: Function, N1, N2 | Output will be saved to the current memory cell)

ALU Functions:
1 - Add
2 - Substract
3 - Multiply
4 - Devide
5 - RNG (Random Number Generator)

\ - Ask for User Input (IO Panel, Saves into Stack a number from 1to 4)
| - Toggle Indicator (IO Panel, Set a number in the current memory cell from 0 to 9 then use this)
- (Dash is used to call a special function of a letter, supported letters:  ; POP FROM BOTTOM OF STACK | ~ CLEAR DRAWING SCREEN | $ INPUT NUMBER TO CURRENT MEMORY CELL | . DRAW TO BUFFER | , PRINT ASCII | # CLEAR BUFFER | : TOGGLE BETWEEN STACK #1 AND #2)

$ - Waits for the user to click on the screen. (Pushes the X, Y coordinates onto the stack 1 for use and moves the pointer to the location you clicked.)
# - Compare (Push onto stack: Comparation Mode, N1, N2 | Output will be saved to the current memory cell, 1 = True, 0 = False)

Comparation Modes:
1 - Equals
2 - Not Equals
3 - Greater
4 - Lower


[ (code) ] - Runs code inside only if the current memory cell is greater than 0! (Inspired by Brainfuck)
{ (code) } - Loops the code inside while the current memory cell is greater than 0! (Inspired by Brainfuck too)


Example Programs

>_-.>>-.>__-._<-.<-.<-.<^-.%

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 very simple "drawing" program.
You click on the screen and it places a dot.
!.!{$.!>!S[!>.-~,<!]!<!~}

This is the same program as above but when you click the "S" button it clears the screen.
!.{~>>|<\>|<-;>.::,<:>>#[>~-$:-$:!@!~_<]~<.:.:,,<:>>#[~!.%!~]~<.:..:,,,<:>>#[~!-~-#!~]~<.:...:,,,,<:>>#[~*~]<<<}

A program that uses the inputs and the indicators to draw on the screen!
Input #1: Move Pointer to X, Y (It asks you for two numbers)
Input #2: Place Pixel
Input #3: Clear Screen
Input #4: End


Links

SealedKiller's Youtube Channel

PixelCode Interpreter