Skip to content

Palette Overrides

grunt-lucas edited this page Mar 9, 2025 · 32 revisions

Table Of Contents

Motivation

You may have noticed that palette primers do not give you control over the ordering of the output palettes, nor the ordering of colors within each palette. For direct control over palette and color orderings, palette overrides are the right choice. This feature may be especially useful for:

  1. DNS systems which expect window lights to be in specific, fixed palette slots
  2. Forcing tile sharing, i.e. saving tile space by storing one tile that can index into multiple palettes, e.g. the vanilla Pokémart and Pokécenter roof tile
  3. Cases where you want to manually construct palettes, or re-use palettes you already created manually
  4. Fixing the palette slots for your door anim colors, so they don't keep breaking as you update your tileset

Palette overrides and palette primers are complementary features. Both will work together, and (in most cases) play nicely with Porytiles's automatic palette assigment algorithm.

How To Use The Feature

First step: create a palette-overrides directory in your source folder, right along side your layer PNGs and attributes CSV. Within the palette-overrides directory, you can place a JASC .pal file for each output palette you want to override. E.g. if you want to override some slots in output palette one, then place a JASC .pal file called 01.pal in your palette-overrides directory.

A palette override JASC .pal file is like any other JASC .pal file, except it allows for a special wildcard - symbol which denotes any color. You can use this symbol to tell Porytiles that you don't care what it puts at this particular slot. That slot is "open" for Porytiles's automatic palette assignment algorithm to freely use.

A palette override JASC .pal file must have a declared size of 16, and must use the wildcard - symbol in the 0th pal slot. This is because pal slot 0 is always transparent. So we need to leave that slot open so Porytiles can place the transparent color there. You'll get an error if either your declared pal size isn't 16 or if your 0th pal slot isn't set to -. You'll also get an error if your actual pal size does not match the declared size.

Note

Porytiles accepts JASC .pal files with either CRLF or LF line-ending format. No need to worry about platform-specific line endings.

Here's a simple example. Suppose you want output pal 1 in your primary tileset to contain a particular red tone in pal slot 2, and a particular green tone in pal slot 3. You don't care about the contents of any other palette slots. Create a 01.pal file with the following contents, and place it in your palette-overrides folder:

JASC-PAL
0100
16
-
-
240 20 40
50 200 40
-
-
-
-
-
-
-
-
-
-
-
-

After compilation, you should see that your 01.pal in the output palettes directory contains the colors you specified at the appropriate slots!

Case Study: Tile Sharing

Let's now look at a more complex example which showcases how you can use palette overrides to pull off a tile sharing optimization.

Compiling Without Overrides

In the Resources directory, you can find a small primary set example that demonstrates how palette overrides alter the tileset compilation process. The example is a bit contrived, but it should serve to illustrate how the feature works.

Let's walk through compilation and see what happens. The tileset bottom, middle, and top layers look like this:

First, we'll compile without the overrides. Note that we have explicitly overriden the primary palette count to 3. This is crucial for understanding the example.

porytiles compile-primary -Wall -tiles-output-pal=true-color -pals-primary-override=3 -o without-compiled ./Resources/Examples/palette-overrides-tutorial/primary-without ./Resources/Examples/metatile_behaviors.h

The

Manual Palette Allocation With Overrides

Palette overrides provide a way to force Porytiles to use a manual palette allocation. For example, let's assume you want to manually allocate the palettes for a pokeemerald primary tileset. First, create your palette-overrides directory within the Porytiles-format tileset directory. Then, copy your 00.pal through 05.pal into the palette-overrides folder. Finally, open each palette and adjust the declared size to 15 and remove the transparency color in slot 0. If your tiles are not allocatable with the palettes you've provided, you'll receive the usual error message.

This functionality is very useful in the following scenarios:

  1. You want Porytiles to handle tile flip/dupe optimization and metatile construction, but you'd like to set up palettes manually.
  2. Porytiles is struggling to allocate palettes for your tileset, but you know it's possible and can see where the allocation algorithm is going wrong.
  3. You have an old manually-constructed Porymap-format tileset that you've imported to Porytiles-format via the decompiler, but you want to keep your original, manually-constructed palettes.
Clone this wiki locally