git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-support/png2asset/readme.md

      1 # png2asset
      2 A tool that converts png to maps or meta sprites in C for gbdk 2020
      3 
      4 ### Working with png2asset
      5   - The origin (pivot) for the metasprite is not required to be in the upper left-hand corner as with regular hardware sprites. See `-px` and `-py`.
      6 
      7   - The conversion process supports using both SPRITES_8x8 (`-spr8x8`) and SPRITES_8x16 mode (`-spr8x16`). If 8x16 mode is used then the height of the metasprite must be a multiple of 16.
      8 
      9 #### Terminology
     10 The following abbreviations are used in this section:
     11 * Original Game Boy and Game Boy Pocket style hardware: `DMG`
     12 * Game Boy Color: `CGB`
     13 
     14 #### Conversion Process
     15 png2asset accepts any png as input, although that does not mean any image will be valid. The program will follow the next steps:
     16   - The image will be subdivided into tiles of 8x8 or 8x16
     17   - For each tile a palette will be generated
     18   - If there are more than 4 colors in the palette it will throw an error
     19   - The palette will be sorted from darkest to lightest. If there is a transparent color that will be the first one (this will create a palette that will also work with `DMG` devices)
     20   - If there are more than 8 palettes the program will throw an error
     21 
     22 With all this, the program will generate a new indexed image (with palette), where each 4 colors define a palette and all colors within a tile can only have colors from one of these palettes
     23 
     24 It is also posible to pass an indexed 8-bit png with the palette properly sorted out, using `-keep_palette_order`
     25   - Palettes will be extracted from the image palette in groups of 4 colors.
     26   - Each tile can only have colors from one of these palettes per tile
     27   - The maximum number of colors is 32
     28 
     29 Using this image a tileset will be created
     30   - Duplicated tiles will be removed
     31   - Tiles will be matched without mirror, using vertical mirror, horizontal mirror or both (use `-noflip` to turn off matching mirrored tiles)
     32   - The palette won't be taken into account for matching, only the pixel color order, meaning there will be a match between tiles using different palettes but looking identical on grayscale
     33 
     34 #### Maps
     35 Passing `-map` the png can be converted to a map that can be used in both the background and the window. In this case, png2asset will generate:
     36   - The palettes
     37   - The tileset
     38   - The map
     39   - The color info
     40     - By default, an array of palette index for each tile. This is not the way the hardware works but it takes less space and will create maps compatibles with both `DMG` and `CGB` devices.
     41     - Passing `-use_map_attributes` will create an array of map attributes. It will also add mirroring info for each tile and because of that maps created with this won't be compatible with.
     42       - Use `-noflip` to make background maps which are compatible with `DMG` devices.
     43 
     44 #### Meta sprites
     45 By default the png will be converted to metasprites. The image will be subdivided into meta sprites of `-sw` x `-sh`. In this case png2asset will generate:
     46   - The metasprites, containing an array of:
     47     - tile index
     48     - y offset
     49     - x offset
     50     - flags, containing the mirror info, the palettes for both DMG and GBC and the sprite priority
     51   - The metasprites array
     52 
     53 

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.