GithubHelp home page GithubHelp logo

pixelfuck's Introduction

pixelfuck

⚠️ This is in early stages of development ⚠️
Write programs for a pixel display ❤️.

Specifications

The programs can be written in a stack-based variant of brainfuck 🤬 that I named pixelfuck. The operations are performed on a stack while the output can be displayed in a $16 \times 16$ grid of virtual pixels 🚨.

Colours

The LEDs can range from 0 to F in hexadecimal, mapped to the castpixel-16 color palette from top to bottom, left to right.

Since the memory cells are 8-bits wide, the highest 4 bits will be used for colour transparency. The lowest 4 bits will be used for the colour index. For example, 0x0F is the color F with no transparency (which means is 100% visible), while 0x8E is the color E with 8 / 16 transparency (which means is only 50% visible). If you want to use a solid colour just after the grid has been prepared / reset, you won't need to set a full byte, you can just set the lowest 4 bits like this: E.

The display will be updated on every output operation (.). Display memory wraps around. Any program running for more than 5 seconds will be stopped.

To allow for faster and cooler programs, there are a few extra features allowed as a language extension:

C Meaning
` Duplicate stack top.
° Push stack top colour into current cell.
, Push 0 onto the stack.
. Sets the current cell to the specified value.
: Push value onto the stack.
; Output a frame on the display.
? Pushes current cell colour onto the stack.
" Increment stack top.
' Decrement stack top.
+ Pops twice and pushes the addition result.
- Pops twice and pushes the subtraction result.
* Pops twice and pushes the multiplication result.
/ Pops twice and pushes the division result.
% Pops twice and pushes the modulus result.
& Pops twice and pushes the and result.
| Pops twice and pushes the or result.
! Flip the current stack top value.
@ Set delay for the next frames to stack top.
$ Pops and discards the top stack value.
# Pops and sets the current cell pointer.
= Pops and sets the current cell data.
< Move display tape head left ($x - 1$).
> Move display tape head right ($x + 1$).
^ Move display tape head up ($y - 1$).
_ Move display tape head down ($y + 1$).
[ Jump past matching ] if stack top holds 0.
] Jump back to matching [ if stack top is not 0.
\ Resets the whole grid to the values F0.
§ Halt the program early.

For practical reasons, you can loop with (), [] and {}.

Data and Pointer Manipulation

You can set a cell to a specific value by using . which will pop the value off the stack and set it in the current cell. For example, 0F. will set the current cell to 15. This is done through subsequent 4 bit shifts and or operations.

You can manipulate the current cell pointer by subfixing the hexadecimal pointer with #. For example, A0:# will set the current cell pointer to [ 10, 0 ] where the first value is the x coordinate and the second value is the y coordinate. The display position [ 0, 0 ] is the top left corner.

Delay and Output

The delay operator @ can be used to set the delay between frames. The delay is a hexadecimal value from 0 to F and it will be multiplied by 200ms. For example, F:@ will set the delay to 3.2s.

pixelfuck's People

Contributors

cristian-5 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.