A small command line utility to convert PNG images
to GDBK compliant Game Boy
tiles. Tiles are generated as C unsigned char
arrays.
Takes input like:
That you can use in your Game Boy programs like:
Install cargo, and rust
Then:
$ git clone git@github.com:blakesmith/gbtile.git
$ cd gbtile/
$ cargo install --path .
The gbtile
executable will be installed in $HOME/.cargo/bin/
by default.
Find an image that matches the image criteria below, or make your own in your favorite photo editor, then convert it like so:
$ gbtile -i ascii.png -o ascii.tile.h
2020-05-19 21:07:02,154 INFO [gbtile] File: ascii.png, Tile rows: 14,
columns: 16, unique colors: 2
Make sure the tile count and unique colors match your expectations. The output will be a valid C array like so:
c
unsigned char ascii[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x40,0x40,0x00,0x00,
...
0x10,0x10,0x38,0x38,0x54,0x54,0x50,0x50,0x38,0x38,0x14,0x14,0x54,0x54,0x38,0x38,
};
The variable name should match the input file name.
You can now include the tile array in your GBDK Game Boy projects, and
load it using the set_bkg_data
or set_sprite_data
C functions.
For my workflow, I'm using the following image setup:
MIT Licensed.