I've tried to follow the example but cannot get anything to output. Is there an actual working example or can someone post a working makefile?Special: batch bitmap->tilemap conversions. This is an example
makefile rule for mapping and converting many bitmaps into a
file with tilemaps and a shared tileset.
The following converts files a1.bmp a2.bmp and a3.bmp to regular 8bpp
tilemaps. The maps are stored into tilemap.s, WITHOUT the palette or
tiles. The -fx option gathers the tileset into tiles.bmp, which is
converted into a palette and tileset by the second command in the
rule.
Code: Select all
GIT := grit.exe BMPS := a1.bmp a2.bmp a3.bmp TILESET := tiles.bmp tilemap.s : $(BMPS) $(GIT) $^ -o $@ -fa -fx $(TILESET) -p! -g! -mR8 $(GIT) $(TILESET) -o tileset.s
Shared tiles and palettes
Shared tiles and palettes
I cannot seems to get this feature to work in a makefile. The only information I can find is in the readme
Re: Shared tiles and palettes
In my experience, shared gfx will only work if the first image processed has all the colors of the remaining images in its palette. This can be fairly easily achieved by using usenti to build up your palette.
Re: Shared tiles and palettes
Actually, I have some more notes. It's not enough to simply put all the other file's colors into the first image's palette. Those colors have to actually appear in the first image. What I've found useful is to just combine all the images into one master image, and then use usenti's built-in "Reduce Tiles" to get an image that is in the format grit expects for an existing master tileset. So in your example, I'd combine a1.bmp a2.bmp a3.bmp a4.bmp into a single image file, "Reduce Tiles", save it as tiles.bmp, and then change the makefile to something like this:
Code: Select all
GIT := grit.exe
BMPS := a1.bmp a2.bmp a3.bmp
TILESET := tiles.bmp
tilemap.s : $(BMPS)
$(GIT) $^ -o $@ -fa -fx $(TILESET) -p! -g! -mR8
$(GIT) $(TILESET) -o tileset.s
Re: Shared tiles and palettes
Palettes are not the issue I'm having. All the graphics I need to convert share the same palette already. I can run grit from the command line and generate the tiles.png. I just can't seem to get it to work in a makefile. So I'm really just looking for a working example that will take a directory of png's and generate a single palette along with a tiles.png and header file which will have all the shared tiles and a map file for each individual image. Any help with this would be appreciated.
Re: Shared tiles and palettes
Okay forget the makefile for a moment, I can't even get grit to do what I want from command line. Here is my batch file
This creates a tileset.png along with tileset.s and tileset.h but I can't seem to get the map files for each shared png. When I change "-o *.o" to "-o *.s" it crashes grit.
Code: Select all
@ECHO OFF
SET PATH=C:\devkitPro\devkitARM\bin
grit.exe graphics\*.png -o *.o -fa -fx tileset.png -gt -mRtf -m -gB8 -mLs -gS -pS
grit.exe tileset.png -o tileset.s
Re: Shared tiles and palettes
Here is a major problem:
grit.exe graphics\*.png -o *.o -fa -fx tileset.png -gt -mRtf -m -gB8 -mLs -gS -pS
Maybe you don't realize this will expand to become:
grit.exe graphics\*.png -o a1.o a2.o a3.o a4.o -fa -fx tileset.png -gt -mRtf -m -gB8 -mLs -gS -pS
Basically this is going to cause grit to try to use a2.o a3.o and a4.o as input image files (or a2.s a3.s a4.s). Maybe grit does something special with '.s' files and that's why it ends up crashing. It could be a number of things.
I've got shared graphics working before; I still need to go back and look at how I did it. When I do, I'll get back to you.
grit.exe graphics\*.png -o *.o -fa -fx tileset.png -gt -mRtf -m -gB8 -mLs -gS -pS
Maybe you don't realize this will expand to become:
grit.exe graphics\*.png -o a1.o a2.o a3.o a4.o -fa -fx tileset.png -gt -mRtf -m -gB8 -mLs -gS -pS
Basically this is going to cause grit to try to use a2.o a3.o and a4.o as input image files (or a2.s a3.s a4.s). Maybe grit does something special with '.s' files and that's why it ends up crashing. It could be a number of things.
I've got shared graphics working before; I still need to go back and look at how I did it. When I do, I'll get back to you.
Re: Shared tiles and palettes
Okay I have played around a bit and the resultant "shared image" is always garbage. However, that doesn't mean the exported .h and .s files are garbage! Here is my Makefile:
This is tiles.grit:
Of course, you can put all those rules inline in the Makefile, but I prefer to have separate grit rule files (makes for easy editing). Now you will end up with tilemap.s and tilemap.h. You just need to include tilemap.h and then you will have several things available:
I hope this helps.
Code: Select all
PATH:=$(DEVKITARM)/bin:$(PATH)
all: tilemap.s
BMPS := a1.bmp a2.bmp a3.bmp a4.bmp
tilemap.s : $(BMPS)
grit $^ -o $@ -ff tiles.grit
Code: Select all
# include graphics, tiled, 8bpp, shared, array is u8[], transparent color magenta
-g -gt -gB8 -gS -gu8 -gT FF00FF
# include palette, shared, array is u16[]
-p -pS -pu16
# include map, tile and flip reduction, organized in screen blocks
-m -mR8 -mLs
# shared name is tileset, append data (build up shared set)
-S tileset
-fa
- a1Map (and a1MapLen #define)
- a2Map (and a2MapLen #define)
- a3Map (and a3MapLen #define)
- a4Map (and a4MapLen #define)
- tilesetTiles (and tilesetTilesLen #define)
- tilesetPal (and tilesetPalLen)
I hope this helps.
Re: Shared tiles and palettes
Oh yeah, I forgot to mention, this method won't require that all the colors appear in the first image.
Re: Shared tiles and palettes
Thanks. This is just about right for my needs. What I need is to change $(BMPS) so it's a directory of png's. I can't seem to get it to work without listing each file manually. I think this is the problem I've been having all along. As soon as I try and change it to be a directory it will include the maps and exclude the tile data or include the tile data and exclude the maps.
Re: Shared tiles and palettes
Okay here is the only solution I've found thus far. If anyone knows of a way to do this without the shell call I'm all ears. Anyway it works and I'm happy!
Code: Select all
PATH := $(DEVKITARM)/bin:$(PATH)
GRAPHICS := graphics
PNGS := $(shell find $(GRAPHICS) -name "*.png" | tr "\n" " ")
all: tilemap.s
tilemap.s : $(PNGS)
grit $^ -o $@ -ff $(GRAPHICS)/tiles.grit
Who is online
Users browsing this forum: No registered users and 2 guests