Closed Rangi42 closed 3 years ago
A simple solution would be to just pick a starting index, same as how tiles work:
(This should say "Start at Palette" for most tilemap formats, e.g. for GBC you'd pick a palette index from 0 to 7. For Plain and GBA 8bpp tilemaps, which only have a single 256-color palette, it would change to "Start at Index" and pick an index within the palette from $00 to $FF.)
(If a "Color 0" is chosen it would always use index 0, or whichever index is zero/transparent for the current palette for multi-palette formats.)
Note, ExpoSeed found that this nonzero origin comes from LoadPalette(sRegionMapBg_Pal, 0x70, 0x60);
in src/region_map.c. The 0x70 is the starting index; the 0x60 is the size in byte (loads 48 colors 2 bytes per color). Technically it only needs to copy 32 colors (0x40).
pokeemerald's main Town Map files are graphics/pokenav/region_map_map.bin (a Plain tilemap) and graphics/pokenav/region_map.png. (There's also a slightly different 4bpp graphics/interface/region_map.{bin,png,pal}, used for the Pokédex area map in src/pokedex_area_region_map.c.)
The problem is that region_map.png's palette starts at index 112 (hex $70), i.e. the first seven 16-color palettes are skipped:
If you mock up a new Town Map and run Image to Tiles on it, the generated PLTE will start at index 0.
A workaround for this is to open the PNG in Aseprite; switch to Sprite→Color Mode→RGB Color; click-and-drag to select the color swatches starting at 0 and Ctrl+C to copy them; click on index 112 and Ctrl+V to paste them there instead; similarly copy-and-paste some of the unused black swatches onto the ones starting at 0; then switch back to Indexed color mode and File→Save. This will remap the used indexes from 0 to 112.
(Note, one thing that makes this difficult to work around is that it's a plain tilemap. For a GBA 4bpp tilemap, you could just generate a JASC palette like pokeemerald's various .pal files; edit it in a text editor to shift the colors down; edit the tilemap in Tilemap Studio's Palettes tab to shift the palette indexes from 0 to 7; and edit the project to include a palette from the .pal file instead of from the PNG's indexed PLTE.)
There should be a better way to do this, ideally flexible enough to accommodate other weird palette requirements.