Gconvert: Difference between revisions

From Uzebox Wiki
Jump to navigation Jump to search
m (→‎Tutorial: wikify external link to internal)
Line 83: Line 83:


===Tutorial===
===Tutorial===
[http://uzebox.org/wiki/index.php?title=Generating_Tiles_and_Maps_with_gconvert Generating Tiles and Maps with gconvert]
[[Generating Tiles and Maps with gconvert]]


===Downloads===
===Downloads===

Revision as of 20:57, 6 June 2014

Gconvert is a command line tool that converts an image into a tileset and one or more maps. It's a C/C++ port from an earlier Java tool and was made to integrate more nicely with the makefiles. Check the Lode Runner makefile for an example of use.

Features (v1.1)

  • Accepts raw (8bpp, no headers) and PNG-8 images
  • Uses an XML definition file to describe the input/output files and maps to be generated
  • Removes duplicate tiles
  • Tileset and maps are generated in a single C include file
  • Distinct variable names can be specified for the tileset and maps
  • Two ouput types: 8bpp (8 bits per pixel) or "code tiles" for use with the high resolution video mode 9

Usage

C:\>gconvert mydef.xml

Definition file example

<?xml version="1.0" ?>
<gfx-xform version="1">
    <input file="..\data\graphics.png" type="png" tile-width="6" tile-height="8" />
    <output file="..\data\graphics.inc">
        <tiles var-name="tetrisTiles"/>
        <maps pointers-size="16">
	    <map var-name="map_main" left="0" top="9" width="40" height="28"/>
	    <map var-name="map_title" left="0" top="37" width="33" height="9"/>			
	</maps>	
    </output>
</gfx-xform>

Useful information about the definition file

  • If your input file is a raw image file (8bpp, no header), you have to define its width and height in pixels. Example:
<input file="example.raw" type="raw" tile-width="8" tile-height="8" width="96" height="80" />
  • If your input file is a PNG image file, you don't have to define its width and height in pixels. Only 256 colors, palette-based PNG files are supported (PNG-8). Example:
<input file="example.png" type="png" tile-width="8" tile-height="8" />
  • The pointer-size attribute in the <maps> element depends on the video mode you will be using. For mode 1, it should be 16. For all other tile-based modes, use 8. Check Video Modes for video modes information.
  • Use the type="code" attribute of the output element to define the code tiles output type as required by video mode 9. This will generate a valid C include file. Currently, only 6x8 tile sizes are supported. Defaults to "8bpp".
 <output file="..\data\graphics.inc" type="code"> ... </output>

Output Example

/*
 * Transformation file: ../data/gconvert.xml
 * Source image: ..\data\graphics.png
 * Tile width: 6px
 * Tile height: 8px
 */

#define MAP_ANIM_SPARK4_WIDTH 7
#define MAP_ANIM_SPARK4_HEIGHT 4
const int map_anim_spark4[] PROGMEM ={
7,4
,0x15,0x25,0x26,0x27,0x28,0x29,0x15,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x51,0x52,0x53,0x54,0x55,0x56
,0x57,0x15,0x63,0x64,0x65,0x66,0x67,0x15};

#define MAP_ANIM_SPARK3_WIDTH 7
#define MAP_ANIM_SPARK3_HEIGHT 4
const int map_anim_spark3[] PROGMEM ={
7,4
,0x15,0x15,0x15,0x2a,0x15,0x15,0x15,0x15,0x3c,0x3d,0x3e,0x3f,0x40,0x15,0x15,0x58,0x59,0x5a,0x5b,0x5c
,0x15,0x15,0x68,0x69,0x6a,0x6b,0x6c,0x15};

...

#define TETRISTILES_SIZE 450
const char tetrisTiles[] PROGMEM={
 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0		 //tile:0

...

};

Tutorial

Generating Tiles and Maps with gconvert

Downloads

Definition file XML Schema: http://belogic.com/uzebox/schemas/gconvert_1_2.xsd

Sources are available here: http://code.google.com/p/uzebox/source/browse/#svn/trunk/tools/gconvert

Download the latest binaries here: http://code.google.com/p/uzebox/downloads/list