/project/gbconvert

A Gameboy Tile Converter

GB-Convert is a simple tool to convert png images into a format supported by Gameboy assembly.

The tiles conversion takes an arbitrarily sized image and outputs the assembly equivalent. It splits the image up into 8x8 tiles.

The map conversion takes in a 256x256 image (32x32 tiles), and matches the tiles in the image, with the tiles from your tilesheet, and outputs the assembly equivalent of your map for use on the Gameboy.

The -i flag inverts the color order, useful if you want to change the transparent color for sprite layers, etc

Example usage:
mytiles.png = 88x96
mymap.png   = 256x256

$ ./gb-convert -i -tiles mytiles.png -map mymap.png >> output.txt

Which gives us output.txt, containing 4 tiles, 16 bytes each. Along with the tile index for each tile in the map.

TILE_DATA:
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $ff,$ff,$81,$ff,$bd,$c3,$a5,$c3,$a5,$c3,$bd,$c3,$81,$ff,$ff,$ff
DB $00,$00,$44,$44,$00,$00,$00,$00,$44,$44,$38,$38,$00,$00,$00,$00
DB $00,$00,$22,$22,$00,$00,$00,$00,$1c,$1c,$22,$22,$00,$00,$00,$00

MAP_DATA:
DB $01,$01,$00...

Here’s an example of both a tile set, and a map. On the left you’ll see the tile set, which is a bunch of 8x8 tiles compiled into a single image. On the right you’ll see a map, which is comprised of tiles from the tile map aligned to an 8x8 grid.

TilesMap