4BOD

From Esolang
Jump to navigation Jump to search

4BOD, or alternatively 4 Bits of Doom is an esoteric fantasy console and machine language made by puarsliburf games for the FC Dev Game Jam in 2017. It parodies the style of other 8-bit style Fantasy Consoles such as Pico-8 and Tic-80 by having extremely low "specs".

Specifications

4BOD is said to have 0.384 kilobytes of program memory, 0.008 kilobytes of RAM and 0.032 kilobytes of VRAM. Programs are created by drawing a black and white image in the built in editor representing 1s and 0s of machine language. It uses 4 bits for the 16 opcodes each with 0-2 4 bit operands.

The Screen is an 16x16 1bpp pixel grid each controlled by 1 bit in the 256 bits (32 bytes or 64 nybbles) of VRAM. The Program is represented as 16 12x16 pixel 1bpp images. 4BOD can address 16 unique memory addresses each with 4 bits of data (Storing a number from 0-15) in addition to a single 4-bit accumulator.

The original implementation seems to be bugged to the point of (more than intended) unusability. The original developer said they lost the source code so it will likely remain unfixed. So use an open-source reimplementation if you want code where bugs can be fixed.

Instructions

   0000 -           Do nothing.
   0001 arg1 -      Sets the accumulator to the value stored at the address arg1. 
   0010 arg1 -      Writes the accumulator to the address arg1. 
   0011 arg1 -      Sets the accumulator to arg1. 
   0100 -           Sets the accumulator to the states of the arrow keys in the order D|U|R|L.
   0101 -           Increments the accumulator, overflowing if it goes above 15. 
   0110 -           Clears the screen. (setting all VRAM to 0)
   0111 -           Shifts the accumulator left.
   1000 -           Shifts the accumulator right.  
   1001 arg1 arg2 - Sets the accumulator to the state of the pixel at the X and Y coordinates of the values at addresses arg1 and arg2,
                    respectively.  
   1010 arg1 arg2 - Flips the state of the pixel at the X and Y coordinates of the values at addresses arg1 and arg2, respectively.   
   1011 arg1 -      Creates a flag named arg1. 
   1100 arg1 -      Jumps to the flag named after the value stored at the address arg1. (If 2 flags have the same ID the one later in the code
                    is the one jumped to)
   1101 arg1 -      Only perform next instruction if the value at address arg1 is equal to the accumulator.
   1110 arg1 -      Only perform next instruction if the value at address arg1 is greater than the accumulator.
   1111 arg1 -      Only perform next instruction if the value at address arg1 is less than the accumulator.

All arguments are 4 bits and can have a value of 0 to 15. The program is called every frame and endless loops within the code freeze 4BOD.

Examples

Display a 2x2 Square in the center of the screen.

In binary form:

   0110
   0011 1000
   0010 1000
   0011 0111
   0010 0111
   1010 1000 0111
   1010 1000 1000
   1010 0111 0111
   1010 0111 1000

In image form:

4bod example.png

Truth Machine

Enlarged view

Truth machine in 4BOD

Actual size

Truth machine in 4BOD

External Links

Original itch.io page

A re-implementation in Python3