Gconvert: Tileset generator tool

Topics on software tools like TileStudio, comments on documentation and tutorials (or the lack of) should go here.
User avatar
uze6666
Site Admin
Posts: 4448
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Gconvert: Tileset generator tool

Post by uze6666 » Sat Feb 27, 2010 8:10 am

Hi guys,

I *finally* converted my Java tileset tool to a pure C/C++ command line tool. It was made to be more flexible, user friendly and to integrate nicely with makefiles. Check the Megatris demo project (and it's makefile) for an example of use.

Features (v1.0):
  • 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
I've created a wiki page for the tool. Feel free to enhance if required: http://uzebox.org/wiki/index.php?title=Gconvert. Btw, I also installed a code Syntax Highlight extension for the wiki. Now code,xml , etc. will display nicely...yay! :D Check this page for the language supported.

Hope it'll make your life easier!

-Uze

User avatar
nebososo
Posts: 188
Joined: Sun Oct 04, 2009 10:33 pm
Location: Curitiba, Paraná, Brazil
Contact:

Re: Gconvert: Tileset generator tool

Post by nebososo » Sat Feb 27, 2010 8:30 am

Yey :D . Thanks, Uze. Now it's only the midi conversion that is still a pain :lol: .
I'm gonna finish that tutorial (now for this tool) and add it to the wiki soon.

User avatar
paul
Posts: 457
Joined: Sat May 02, 2009 8:41 am
Location: Brisbane, Australia

Re: Gconvert: Tileset generator tool

Post by paul » Sat Feb 27, 2010 11:57 am

Awesome, I'll use it for my next game and give some feedback. It'll be nice to be rid of Tile Studio.

User avatar
nebososo
Posts: 188
Joined: Sun Oct 04, 2009 10:33 pm
Location: Curitiba, Paraná, Brazil
Contact:

Re: Gconvert: Tileset generator tool

Post by nebososo » Sat Feb 27, 2010 6:45 pm

I'm finishing writing the last section of the tutorial: testing the tiles and maps. I did notice before that gconvert makes int arrays, instead of char arrays like the java tool, and I thought "Oh, different :? ". But when I actually tried using DrawMap2 to print the maps on the screen, the compiler would complain about the type of the array. I changed all the arrays to chars and it's now working.

Also, I haven't tried converting pngs, but I was following uze's wiki example to convert raws and gconvert would complain about not declaring the width and the height of the image on the xml. I would update the wiki, but I don't really know if it's only needed for raws, as uze's example with pngs does not declare the width and height.
I was way to tired yesterday night when I finished this stuff. I wanted to publish the XML schema into which you would have seen all the possible elements and options that where not part of my examples. So in the mean time, here's a few more details:

-Mode 1 & Megatris uses 16 bits map indexes, hence the map are ints (pointers-size="16"). For all other modes, like mode 3, map indexes are chars, so use pointers-size="8" in your <map> element, i.e:

Code: Select all

<maps pointers-size="8">
 ...
</maps>
This will also result in having the tool throw an error if, while scanning for unique tiles, the count goes beyond 256.

-PNGs have the image size embedded in its header so it's redundant to specify the size/height in the transformation file. RAW does not, hence the need to specify these attributes. Here's the required element for the two image types:

RAW

Code: Select all

<input file="c:/uze/tetris-tiles.raw" type="raw" width="240" height="368" tile-width="6" tile-height="8" />
PNG (notice no width/height attributes)

Code: Select all

<input file="..\data\graphics.png" type="png" tile-width="6" tile-height="8" />
Hope that helps

-Uze

User avatar
nebososo
Posts: 188
Joined: Sun Oct 04, 2009 10:33 pm
Location: Curitiba, Paraná, Brazil
Contact:

Re: Gconvert: Tileset generator tool

Post by nebososo » Sat Feb 27, 2010 7:28 pm

@Uze
Weird how you edited my post and quoted it at the same time :lol: .
uze6666 wrote: I was way to tired yesterday night when I finished this stuff. I wanted to publish the XML schema into which you would have seen all the possible elements and options that where not part of my examples. So in the mean time, here's a few more details:

-Mode 1 & Megatris uses 16 bits map indexes, hence the map are ints (pointers-size="16"). For all other modes, like mode 3, map indexes are chars, so use pointers-size="8" in your <map> element, i.e:

Code: Select all

<maps pointers-size="8">
 ...
</maps>
This will also result in having the tool throw an error if, while scanning for unique tiles, the count goes beyond 256.
Great, much clearer now, I was gonna ask about this variable, but I forgot.
-PNGs have the image size embedded in its header so it's redundant to specify the size/height in the transformation file. RAW does not, hence the need to specify these attributes. Here's the required element for the two image types:

RAW

Code: Select all

<input file="c:/uze/tetris-tiles.raw" type="raw" width="240" height="368" tile-width="6" tile-height="8" />
PNG (notice no width/height attributes)

Code: Select all

<input file="..\data\graphics.png" type="png" tile-width="6" tile-height="8" />
Hope that helps

-Uze
That's what I figured, but didn't actually try to confirm ;) .

I just finished my guide: http://uzebox.org/wiki/index.php?title= ... h_gconvert. I added some of the information you just provided, but I'm also adding it to the gconvert wiki page.

User avatar
paul
Posts: 457
Joined: Sat May 02, 2009 8:41 am
Location: Brisbane, Australia

Re: Gconvert: Tileset generator tool

Post by paul » Sat Feb 27, 2010 8:09 pm

Uh oh, Uze is eating posts again :? I think he's just keeping us on our toes.

Thanks, Nebososo. I have linked to your guide from the Space Invaders tutorial, rather than to the Python script.

User avatar
uze6666
Site Admin
Posts: 4448
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Gconvert: Tileset generator tool

Post by uze6666 » Sat Feb 27, 2010 8:42 pm

Weird how you edited my post and quoted it at the same time :lol: .
:shock: Wow I'm confused! What the heck is going on, is there a bug on the forums on what!?! Sorry about that! I'll triple check next time.

Great tutorial btw! I've added a section that describes how to invoke the tool from the Makefile.

Also, I was wondering about a features that could be useful: Automatically relocating the black tile at the beginning, creating one if no one was found in the tileset or removing it entirely if it is known that a font will follow. Another thing I though was to have ClearVram() either accept a (vararg) tile# parameter or use a "black tile" #define provided by the graphics ressource file. That could save a duplicate black tile when having a font following the tile data. Alternatively, the tool could also accept more that one graphics file, to handle fonts for example, and generate a single files of all graphics resources. Let me know what you think.

-Uze

User avatar
nebososo
Posts: 188
Joined: Sun Oct 04, 2009 10:33 pm
Location: Curitiba, Paraná, Brazil
Contact:

Re: Gconvert: Tileset generator tool

Post by nebososo » Sun Feb 28, 2010 12:53 am

paul wrote:I have linked to your guide from the Space Invaders tutorial, rather than to the Python script.
:D
uze6666 wrote: Great tutorial btw! I've added a section that describes how to invoke the tool from the Makefile.
Thanks and that was a great addition.
Also, I was wondering about a features that could be useful: Automatically relocating the black tile at the beginning, creating one if no one was found in the tileset or removing it entirely if it is known that a font will follow. Another thing I though was to have ClearVram() either accept a (vararg) tile# parameter or use a "black tile" #define provided by the graphics ressource file. That could save a duplicate black tile when having a font following the tile data. Alternatively, the tool could also accept more that one graphics file, to handle fonts for example, and generate a single files of all graphics resources. Let me know what you think.

-Uze
I don't think relocation would be could, because someone might want a different tile, like a white one. Creating one automatically would cause the same problem. But I believe that using a black tile define would be great, maybe you could give gconvert the blank tile coordinates and it would find it's number, so we wouldn't have to count and considered duplicated ones manually, and just default the define to zero in case people don't wanna use it. Accepting more one graphics file would be pretty neat too, we could just tell gconvert the blank tiles coordinates and file number, like: Second file 10,10. It would be pretty easy to point to a blank tile in a font and, consequently, save us a few bytes.

User avatar
paul
Posts: 457
Joined: Sat May 02, 2009 8:41 am
Location: Brisbane, Australia

Re: Gconvert: Tileset generator tool

Post by paul » Thu Mar 04, 2010 2:19 am

Another thing I though was to have ClearVram() either accept a (vararg) tile# parameter or use a "black tile" #define provided by the graphics ressource file. That could save a duplicate black tile when having a font following the tile data.
I think the vararg idea is the best and shouldn't break old code. Maybe get rid of ClearVram and just define it like this:

Code: Select all

#define ClearVram(args...) Fill(0, 0, VRAM_TILES_H, VRAM_TILES_V, *#args)

User avatar
uze6666
Site Admin
Posts: 4448
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Gconvert: Tileset generator tool

Post by uze6666 » Thu Mar 04, 2010 7:50 am

I think the vararg idea is the best and shouldn't break old code. Maybe get rid of ClearVram and just define it like this:
#define ClearVram(args...) Fill(0, 0, VRAM_TILES_H, VRAM_TILES_V, *#args)
Yeah, good idea, I've added it to the wiki's todo list.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests