This is the specification for the program metadata format used by the Bedrock computer system.
Overview
Program metadata is used to identify Bedrock program files from other files, and to embed structured information into program files. This information can be used to track down further information for an otherwise unlabelled program file.
Metadata
The metadata format is a 24 byte header at the start of an assembled program, as per the following table. The header contains the address of each piece of data, with the actual values being stored elsewhere in the program. An address of zero indicates that the value was not provided.
Address | Bytes | Name | Description |
---|---|---|---|
0x0000 |
10 | Identifier | Metadata identifier. |
0x000A |
2 | Name | Pointer to program name and version |
0x000C |
2 | Authors | Pointer to list of author names. |
0x000E |
2 | Description | Pointer to program description. |
0x0010 |
2 | Background colour | Pointer to background colour for icons. |
0x0012 |
2 | Foreground colour | Pointer to foreground colour for icons. |
0x0014 |
2 | Small icon | Pointer to 24x24 pixel monochrome icon. |
0x0016 |
2 | Large icon | Pointer to 64x64 pixel monochrome icon. |
Identifier
The identifier is the 10 byte sequence E8 00 18 42 45 44 52 4F 43 4B
. The identifier indicates that the file is a Bedrock program, and that the following 14 bytes should be read as pointers to metadata values.
The first three bytes of the identifier encode the immediate-mode jump instruction JMPr*:
that prevents the metadata from being interpreted as code when the program is run. The instruction byte is 0xE8
, which when combined with the following byte will form an invalid UTF-8 byte sequence, indicating that this isn’t a text file. This is reinforced by the bytes 0x00
and 0x18
, which would be interpreted as a pair of unprintable control characters.
The remaining seven bytes of the identifier encode the string BEDROCK
. This provides a human-readable hint that the file is a Bedrock program, which can be used as part of a search query to find out how to run the program.
Name
The name value is a UTF-8 encoded string containing the name and version of the program, followed by a zero byte. The string format is the program name, followed by the forward-slash character 0x2F
, followed by the program version.
The name is referenced by a pointer at address 0x000A
. A pointer value of zero indicates that no name has been provided.
Authors
The author list is a UTF-8 encoded string containing a list of the authors of the program, followed by a zero byte. The string format is a concatenated list of author names, with every name but the last followed by the newline character 0x0A
.
The author list is referenced by a pointer at address 0x000C
. A pointer value of zero indicates that no list of authors has been provided.
Description
The description is a UTF-8 encoded string containing a short description of the program, followed by a zero byte. The description should be a short sentence that describes the category or purpose of the program, no more than a few words in length, and should not have a full stop.
The description is referenced by a pointer at address 0x000E
. A pointer value of zero indicates that no description has been provided.
Background colour
The background colour is a double-width value representing the colour that should be used when drawing the background of the large and small icons.
The background colour is referenced by a pointer at address 0x0010
. A pointer value of zero indicates that no background colour has been provided.
Foreground colour
The foreground colour is a double-width value representing the colour that should be used when drawing the foreground of the large and small icons.
The foreground colour is referenced by a pointer at address 0x0012
. A pointer value of zero indicates that no foreground colour has been provided.
Small icon
The small icon is a 24x24 pixel monochrome icon representing the program. The icon is encoded as a sequence of nine 1-bit sprites, ordered left-to-right and then top-to-bottom.
The small icon is referenced by a pointer at address 0x0014
. A pointer value of zero indicates that no small icon has been provided.
Large icon
The large icon is a 64x64 pixel monochrome icon representing the program. The icon is encoded as a sequence of sixty-four 1-bit sprites, ordered left-to-right and then top-to-bottom.
The large icon is referenced by a pointer at address 0x0016
. A pointer value of zero indicates that no large icon has been provided.
Data structures
1-bit sprite
A 1-bit sprite is a sequence of 8 bytes that represents a two-colour 8x8 pixel image.
Each byte represents a row of the sprite, ordered top to bottom. Each bit of a byte represents a pixel in the row, ordered left to right, from highest bit to lowest. If a bit is set, that pixel will be drawn as the foreground colour, otherwise it will be drawn as the background colour.
Colour
A colour is a double-width value that represents a 12-bit RGB value. The highest four bits are ignored, the next four bits hold the red value, the next four bits hold the green value, and the lowest four bits hold the blue value.
Bits | Description |
---|---|
0xF000 |
ignored |
0x0F00 |
Red channel |
0x00F0 |
Green channel |
0x000F |
Blue channel |
Implementation notes
Window information
A Bedrock system that runs inside a decorated window should use the name string as the window title, and either the large icon or the small icon as the window icon.
Appendix A: Metadata example
The data pointed to by the metadata table can be elsewhere in the program and shared with other code.
JMPr*:{ 'BEDROCK' metadata/name metadata/author metadata/description metadata/bg-colour metadata/fg-colour metadata/small-icon metadata/large-icon } ( ...program content... ) @metadata &name "Example program" &author "Ben Bridle" &description "A small example program." &bg-colour 0223 &fg-colour 0E65 &small-icon 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 &large-icon 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000