MVIDELL.SE

DCPU Game of Life

After his success with Minecraft, Markus 'Notch' Persson announced a new game called 0x10c. It was designed to be a science fiction sandbox that included a virtual computer and virtual hardware peripherals that Notch himself had designed the specifications for.

I thought the concept was interesting and decided to implement Conway's Game of Life written in DCPU, the assembly-like language created for the virtual computer and output the result on the virtual monitor called LEM1802.

The monitor can only print monochrome characters from a program-defined alphabet of 128 characters. A character is 4x8 pixels and each character is defined by setting each pixel to be either foreground or background colour.

One way to implement Game of Life would be to have one Game of Life cell per character for a total of 32x12 = 384 cells, but I wanted to divide each character into 2x4 cells (each cell would be 2x2 pixels) for a total of 64x48 = 3072 cells.

However, 8 cells per character means 28 = 256 different combinations, double the available alphabet. I managed to solve this problem by utilising that each character can be printed in normal or inverted colours, effectively doubling the available alphabet if it is generated correctly. I used the last cell as a sort of sign bit (inspired by Two's complement used to store signed integers) to determine whether the character should be printed in normal or in inverted colours.

The all-in-one.s source file is a concatenation of all source files, to simplify copying and pasting into the online emulator I used when creating this.

Includes two premade patterns, a glider and acorn. To change to acorn edit the line JSR write_glider to JSR write_acorn.

Links