Datablocks

Datablocks Example

Datablocks is a powerfull system that allows you to store custom data in any blocks.


How it works

Datablocks is a system that allows you to store 16-bit of data in only one tile. Then this data can be used with magitech using some ROM decoder devices.

The data is stored as following:

  • 4 bits are defined by the type of the first backwall
  • 4 bits are defined by the type of the second backwall (double slope)
  • 4 bits are defined by the color of the backwall
  • 4 bits are defined by the color of the front (or the second backwall)

If you want to store only one value from 0 to 15, you can simply use a data block:

pc_block_data0 .. pc_block_data15


Each of this block simply represents one 4-bit value from 0 to 15.

If you want to store two values from 0 to 15, you will need a data block on back for the first value, and to apply a color on this block to represent the second value.

Datablocks colors
The data is represented by the hue of the palette.


So gray is 0, red 1, yellow 5, etc…

When you want 16-bit values you’ll have to use double blocks, but things work the same.

To summarize, you can store:

  • 4-bit values with a simple datablock (there are 16 types of datablock)
  • 8-bit values with a colored datablock
  • 16-bit values with a colored double datablock


Writing data

Writing data by hand is not straightforward, so the game offers a command system to simplify the process.

You can write data from hexadecimal or decimal numbers:

/db -h f055 1234
/db 0 1 2 3 4 5 6 7


The data will always be written in columns from top to bottom and left to right. You can specify the size of a column with -c (the default value is 8):

/db -c 2 0 1 2 3 4 5 6 7


If needed you can generate ranges of data automatically using -r:

/db -r 0 7


Note: data will be written at the position of the cursor.


Reading data

You can read data using the CLI:

/db get
/db -h get


The content of the selected block when using the command will be displayed in the chatbox.


Reading data with magitech

To read datablocks you will need specific magitech devices.

ROM block

The magitech ROM block allows you to read one byte (8-bit) of data using the backwall behind the object. This object can be used to define constants used by your circuits easily.

Rom block example
Example of ROM blocks used to
display data in a pixel matrix.


CENTeNrtVDtOxDAUHP9j7zVQboC0LRUnWlqaXALRcgDqiA6ugfYGQaKAAoHxmwcsK60gSDQrbeI3eZ5
Mxu8lio8BLFqUFpdrA7wZOacWDy2eWjy3qHUltx5bkr9mPwhf5wpf5gqnb8JaF9tZlewAv8E1cNs+sR
52K2o9A3y7FMlXSu8UtVf+z5Jaz/Vy+EazYAROzQ5+AKbDz/DXV3kHSfqPMfRHm8kejbHXPj7HgOVms
kdj5IZxghiu2m5h0rqhi/eyc4QLwXxjDbKRux01MML7JLknk73oEzUmiEMhn6jJzC3zqIwTLMRAzOQT
lY5u8LJKR8+gtTlx9mSs+lMZySCK3kEYR7dChGO1XMUYcUASJllRZmKgQ2bXHZ/qqE9knNZA50Am8Cm
n1VIZtRftgkpYWSVr3kle6JOotKpn/Y5uVrvg8Q6Q5OLr


8-byte ROM driver

Sometimes you need just a small amount of data, for example to output a value from 0 to 7 periodicaly on a clock, or to store a few characters to display.

The 8-byte ROM driver is specially designed for this. It allows you to read a small square of 2x2 data blocks (left to right, top to bottom) placed behind it.

8-byte Rom driver example
Example of a 8-byte ROM blocks used as an
analog clock that output data from 0 to 7.


CENTeNrtlM0JwkAQhd/8RCTYgGWIBA/2pQfFg1ZhBWnAg2gHVmEFHkU8ZJ2ZGBLwokchS+bjzfB2A49
lCwCZ1cBqtyQgpayilFZARRXd6E6d9kHPpm19Hyq56vE9jsDConepjCbKt2KolTdrmOxalGPQ2vswf0
/+4rlvMZmmDYqZjf/4m/slwhgse0YONYK0ZLtcEpqDrkdExiGckPBoreHkoAbBJxZ7JtxPWelzP5mk1
jFnZ84amq7+l9grcvaT5cCMer0AFvFAuA==


256-byte ROM driver

When you need to access a lot of data you can use the 256-byte ROM driver. This device allows you to read up to 16x8 blocks, and is configurable to read a specified amount of data on a specific channel.

This driver takes 4 facultative datablocks as parameters:

  • Number of bytes to read
  • Number of columns to read (16 by default)
  • Number of lines to read (8 by default)
  • Channel of the ROM driver (used to chain drivers to create bigger ROMs)

With theses parameters you can access from 1 to 256 bytes easily.

The 256-byte ROM driver takes 3 inputs, from top to bottom:

  • Address to read (readonly)
  • Power
  • Select channel (disable any rom driver that uses a different channel)
8-byte Rom driver example
The data is read column by column from left to right and top to bottom.


CENTeNrt0c0RgjAQBeC3QUV+VBgswgYsy4sFqG1YgoVQCA1YAo/NQ4ejevLCZvbLyyWT2RwBNN6Fd9I
aQDa9kSegtxiqp/3pPL3klRjTzCcOwFkfeQOCL/LyDlf8sJF1mKf5LQ+o9jDrgs8wu7smYW5ejzlEV8
qJLORWpjKTuVzIpVzLSpZyJzfjzaoBHUDeew==


Chaining

When we need to read more than 256 bytes, we can chain multiple drivers.

We specify the channel of each driver using datablocks, then we can read data of a specific ROM by addressing the channel using the 3rd input, so only the ROM associated with the given channel will output its content.

In theory you can chain up to 65536 ROMs.

8-byte Rom driver example
Two chained drivers that allows
to read up to 512 bytes of data.


CENTeNrtkdENwjAMRM+XOEVFsABzsFxZgQWyCPuwACMQfIFIfNIP/prIT5eL5UT2GUCJ2EWkqwGt+dM
e1tryB92kN/yEG1D7PAoxuih1+VbEiFXHT0X2PYyt6auGo3WCTZWcmGr00UMjRhb0jHs4NPlJnJP8mU
EDXT6zCGlH6VQFN3SfwQzlOEvP1y0sqvEA1XQvet0hh8r3FOQR/T8mvX//9AWo4ceW


Some orders of magnitude

With a DAC you can store 1 byte using 16 blocks + the 2 connected pipes (power and out).

With a ROM block you can store 1 byte using 1 block + the 2 connected pipes (power and out).

With a 8-byte ROM driver you can store 8 bytes using 4 blocks + the 3 connected pipes (power, in and out).

With a 256-byte ROM driver you can store 256 bytes using 264 blocks + the 3 connected pipes.

Using a full chunk as data storage, you can store approximatively 32kb of data, but you will probably need more space to drive this data using some circuitery.


Some patterns to copy

Datablocks Example
Standard data blocks.

CENTeNrtx8kJgEAABMFuMSWTMgYjMyjv+2AV1o9P/w5MQ2VA+jzJhcraydkQClhc3dwjDk8b24jO3sH
xRoA/n1Py2gUlatN/


Datablocks Example Data blocks 0 to 7 for a 8-byte Rom driver.

CENTeNozZWBgYILiJl9GBoZ3jN8Y//+vY2D4wfgLyPjPwDBKkEfsZWA4DgxVQ2NgaJqaA8WGMAL6BQk
AAJ41SL8=