M32Tool is a simple multitool for converting common game asset file types into more space-efficient, Macchiato32-native formats.
- Paletted image formats (e.g. PNG) → Macchiato32 Graphics
- Paletted image formats (e.g. PNG) → Macchiato32 Palettes
- Paletted image formats (e.g. PNG) → Macchiato32 Tilesets
- Tiled TMX Tilemaps → Macchiato32 Tilemaps
python m32tool.py graphic -i [INPUT] -o [OUTPUT]
[--left-offset [LOFFSET]]
[--top-offset [LOFFSET]]
[--colorkey KEY]
Graphics are required to be paletted 256 color images. When --colorkey
is given alongside a value between 0 an 255, the output graphic will define the corresponding palette color as it's transparency key.
--left-offset
and --top-offset
will define the graphic's offset point from the top-left. If not given, either value will default to 0.
The output format for Graphic files is made up of the following fields:
Field | Data type | Explanation |
---|---|---|
byteorder |
uint32_t |
Magic number. Unicode byte order mark 0x0000FEFF |
width |
uint16_t |
Graphic width in pixels |
height |
uint16_t |
Graphic height in pixels |
loffset |
int16_t |
Left offset |
toffset |
int16_t |
Top offset |
use_colorkey |
uint8_t |
When != 0 → Colorkey is applied |
colorkey |
uint8_t |
Colorkey index |
data |
n × uint8_t |
Pixel data (palette indices) |
python m32tool.py palette -i [INPUT] -o [OUTPUT]
M32Tool's palette converter allows for converting palettes of existing images into Macchiato32's native palette format. This command requires a paletted image with a palette of 256 colors as an input file and will overwrite the output file as specified below.
Macchiato32's palette file format is very simple: Just a four-byte magic number, consisting of the ASCII characters "A"
, "B"
, "G"
and "R"
which double as a byte order mark. After that follow 256 chunks of four bytes colors, according to the BOM.
By default M32Tool outputs color palettes using the byte order mark "BGRA" as it matches the RISC-V-native little endian uint32_t
encoding of Macchiato32's internal ARGB color format.
Field | Data type | Explanation |
---|---|---|
format |
uint32_t |
Pixel format magic number made up of 8-Bit ASCII characters 'A' , 'B' , 'G' , 'R' . Doubles as byte order mark (BOM) |
colors |
256 × uint32_t |
Tile indices of the map data |
python m32tool.py tileset -i [INPUT] -o [OUTPUT] [--colorkey KEY]
Tilesets are required to be paletted 256 color images of size 16 × 1024px. The tileset converter will create a simple dump of all color indices found in the input image and overwrite it into the output file.
Field | Data type | Explanation |
---|---|---|
byteorder |
uint32_t |
Magic number. Unicode byte order mark 0x0000FEFF |
use_colorkey |
uint8_t |
When != 0 → Colorkey is applied |
colorkey |
uint8_t |
Colorkey index |
padding |
2 × uint8_t |
unused |
pixels |
16 × 1024 × uint8_t |
Tile indices of the map data |
python m32tool.py tilemap -i [INPUT] -o [OUTPUT]
You can use M32Tool to convert TMX tilemaps created with Tiled for your game. Due to Macchiato32's technical limitations, Macchiato32 Tilemaps are far more limited than those you can create with Tiled. The following table compares both Tilemap specifications for your consideration:
Tiled Tilemaps | Macchiato32 Tilemaps |
---|---|
Potentially infinite size | Maximum size up to 256 × 256 tiles |
Supports multiple layers | One layer per tilemap; multiple layers per file |
Multiple Tilesets per tilemap | One tileset per tilemap |
Variable tile size | 16 × 16 px tiles |
Arbitrary amount of tiles per tileset | 64 distinct tiles; 256 accessible |
X/Y mirroring optional | MSBs 7&8 used for X/Y-mirroring |
The tilemap file header looks like this:
Field | Data type | Explanation |
---|---|---|
width |
uint8_t |
Tilemap width in tiles |
height |
uint8_t |
Tilemap height in tiles |
pages |
uint8_t |
Number of layers-1 . |
padding |
uint8_t |
unused |
maps |
n × uint8_t |
Tile indices of the map data |