------------------------------------------------------- // \\ || GG GGG || || G G GG G || || G GG G || || GGGGGG rrrr i i ttt || || G GG r r i i t t || || G GG r r r ii t t || || G GG r r i i tttt || || i i t || || ii t || || || ||=========================================================|| || GRIT : GBA Raster Image Transmogrifier || || by : Jasper Vijn (cearn) || || v0.7 || || (last update: 2007-04-03) || || (started: 2005-09-15) || \\_______________________________________________________// // -------------------------------------------------------------------- // Introduction // -------------------------------------------------------------------- Grit and Wingrit are a pair of converters from PC-based bitmaps to GBA readable graphic formats. The functionality is (roughly) the same as the exporter found in my bitmap editor Usenti, but these stand-alone versions can handle more file types by using the FreeImage graphics library (freeimage.sourceforge.net/). (Win)grit converts bitmaps into palettes, graphic data (tile or bitmap formats), tilemaps and metamaps. The output is in C arrays, asm arrays, binary files or a GBFS archive (tepples' GameBoy File system, see www.pineight/com). (Win)grit supports the three main BIOS compression formats (LZ77, huffman, RLE), as well as graphics bitpacking to allow graphic data of 1,2,4,8 and 16 bpp. The data arrays can be in byte, halfword or word formats and a header file can be created with the declarations of these. The tilemapping option includes unique tile reduction, different map layouts and even metamapping with variable width and heights. This can also be used for 1D sprite-sheet conversions. NOTE: this is 0.7 beta. I'm not 100% sure the new features are exactly as they should be, and the documentation needs upgrading. If you have problems, please call. NOTE: (Win)grit was born '(Win)git. But because the linux kernel versioning is also called 'git' and g(r)it's supposed to be a multi-platform too, it had to be renamed. Hence, 'grit'. --- Grit --- Grit is the command-line version, the usage and option list is given below. For the basic CLI functionality I am indebted to gauauu (www.tolberts.net), who basically handed me a set of CLI functions, which proved a _lot_ easier to use than what I had initially planned on using. Also great has been Dave Murphy (www.devkitpro.org) for multi-platform - cearn (daytshen@hotmail.com) --- Changes --- * 20070403, v0.7 - Name change to 'grit'. - Changed the way directories work. All relative paths start from the current working directory, whatever that may be. This also fixes a bug when for dir-less -fx options (thanks dovoto). - Default filetype is now assembly. - Added -We, -Ww, -Ws aliases for -W. - Added no converted output option -ft!. - Added batchfile 'grind.bat' for desktop Drag&Drop runs, for when you want a simple&quick conversion. * 20070317, v0.7b - Batchrun: Multiple bitmaps in one go (no wildcards though). - Dwimming for transparency options (i.e., -gT and -pT interaction) - Error/warning/status logging functions (-W). - external tilefile support (-fx). The batchrun and external tilefile support is still experimental. YHBW. * 20070103, v0.6.2 - true -> pal resulted in a zero-entry palette. This is now fixed. Thanks wintermute. * 20061208, v0.6.1 - Fixed -gT use, which was very, very broken. There should be some interaction between -gT and -pT, but not sure which yet. - The append modes for C and asm should work properly now, i.e., if the array already exists the new ones will replace it. * 20060803, v0.6: - Thanks to wintermute, the code should be fully multiplatform now. - Added -pT, -gT, -ff options. See usage. // -------------------------------------------------------------------- // GIT usage // -------------------------------------------------------------------- The basic format for using grit is: grit srcfiles [opts] That is, `program name', source bitmap (single bitmap only) followed by any combination of options. Example for conversion of foo.bmp into a set of 16x16p 4bpp sprites, using only the first 16 palette entries, to 16bit C arrays: grit foo.bmp -Mw 2 -Mh 2 -gB4 -pe 16 -U16 -ftc Git is relatively lenient in terms of what you enter. For one, it searches out _correct_ options, so that incorrect or options are simply ignored, as are later version of option types in the case of multiple instances. Most options consist of a `base' and a `value'; the space between the two is optional. For example, the bitdepth option in the example ('-gB4') would also have been excepted as '-gB 4'. There is also a complex system of defaults to simplify the input. These are given in brackets in the list below. but for easy reference, here 's a list: Palette: full source palette, u16 C array Graphics: full image, original bpp (kinda). Paletted images default to tiles, true-color will be 16bpp bitmaps. u32 C arrays Map: no map. But if you have any map options (`-m*'), it'll default to a flat regular tilemap, reduced for tiles and flips. u16 C array Misc: no compression, create header, symbol name derived from destination filename, which is derived from the source filename. --- Palette options (base: "-p") --- -p | -p! Include or exclude pal data [inc] -pu{8,16,32} Pal data-type: u8, u16 , u32 [u16] -pz{!,l,h,r} Pal compression: none , lz77, huff, RLE [none] -ps{n} Pal range start [0] -pe{n} Pal range end (exclusive) [pal size] -pT{n} FIXED, v0.7: Transparent palette index; swaps with index 0 [0] -pw{n} Pal width [pal size]. Overrides -pe --- Graphics options (base: "-g") --- -g | -g! Include or exclude gfx data [inc] -gu{8,16,32} Gfx data type: u8, u16, u32 [u32] -gz{!,l,h,r} Gfx compression: none, lz77, huff, RLE [none] -ga{n} Gfx pixel offset (non-zero pixels) [0] -gb | -gt Gfx format, bitmap or tile [tile] -gB{n} Gfx bit depth (1, 2, 4, 8, 16) [img bpp] -gT{n} FIXED, v0.7: Transparent color; rrggbb hex or 16bit BGR hex [FF00FF] -al{n} Area left [0] -ar{n} Area right (exclusive) [img width] -aw{n} Area width [img width]. Overrides -ar -at{n} Area top [0] -ab{n} Area bottom (exclusive) [img height] -ah{n} Area height [img height]. Overrides -ab --- Map options (base: "-m") --- -m | -m! Include or exclude map data [exc] -mu{8,16,32} Map data type: u8, u16, u32 [u16] -mz{!,l,h,r} Map compression: none, lz77, huff, RLE [none] -ma{n} Map tile offset n (non-zero entries) [0] -mR{t|p|f} Tile reduction: (t)iles, (p)al, (f)lipped options can be combined [-mRtpf] -mR{4,8,a} Common tile reduction combos: reg 4bpp (-mRtpf), reg 8bpp (-mRtf), affine (-mRt) -mR! No tile reduction (not advised) -mL{f,s,a} Map layout: reg flat, reg sbb, affine [reg flat] --- Meta/Obj options (base: "-M") --- -Mw{n} Metatile width (in tiles!) [1] -Mh{n} Metatile height (in tiles!) [1] -MRp Metatile reduction (pal only) [none] --- File / var options --- -ft{c,s,b,g} File type (C, GNU asm, bin, gbfs) [.c] -fa File append -fh | -fh! Create header or not [create header] -fx {path} NEW, v0.7: External bitmap for shared tiles. Experimental. -ff{path} Additional options read from flag file [dst-name.grit] -o{path} Destination filepath [from source] -s{name} Symbol base name [from dst] --- Misc --- -Z{!,l,h,r} All compression: none, lz77, huff, RLE -U{8,16,32} All data type: u8, u16, u32 -q Quiet mode; no report at the end -W{1,2,3} NEW, v0.7: Warning/Logging level Also new is the ability to convert multiple files in a single run, although this is still experimental. If you explicitly mention a destination file, be sure to add the -fa flag and DO NOT use the -s flag. The external tilefile is experimental too. It seems to work well enough, but just to be sure, always start with an 8bpp bitmap that's already tiled (or non-existent), and use either bmp, gif or png. Pcx support will be added later (FreeImage doesn't do pcx writing. That's why). I'll try to add metatiling to it too at some point. // -------------------------------------------------------------------- // Examples for common conversions // -------------------------------------------------------------------- Mode 0 map (=regular), 4bpp tiles, tile/pal/flip reduced, sbb format -gt -gB4 -mRtpf -mLs or -gB4 -mR4 -mLs Mode 2 map (=affine), tile reduced, map in bytes -gt -gB8 -mRt -mLa -mu8 Mode 3 or 5 bitmap: -gb -gB16 Mode 4 bitmap, forced to screen size -gb -gB8 -aw 240 -ah 160 Sprite, 4bpp, 16x16p (=2x2t) -gt -gB4 -Mw2 -Mh2 Mode 0 metamap, 4x3 metatiles, full tileset reduction -gt -gB4 -mR4 -Mw 4 -Mh 3 NDS 16bpp bitmap, with cyan as transparent color -gb -gB16 -gT 00FFFF 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] GRIT := grit.exe BMPS := a1.bmp a2.bmp a3.bmp TILESET := tiles.bmp tilemap.s : $(BMPS) $(GRIT) $^ -o $@ -fa -fx $(TILESET) -p! -g! -mR8 $(GRIT) $(TILESET) -o tileset.s [/code]