EarthBound/Map Data/Palettes

From Data Crystal
< EarthBound
Revision as of 21:53, 1 July 2023 by Esorth (talk | contribs) (→‎Unknown: Document Sprite Palette Replacement Index)
Jump to navigation Jump to search

This is a sub-page of EarthBound/Map Data.

Map Palettes
Game EarthBound
Start Address 0x1A7EA7
End Address 0x1AFCA6
# of Entries 168
Entry Length 192 bytes (0xC0)
Total Length 32256 bytes (0x7E00)
Back to the ROM map

Data block of the palette data used for game maps.

Format

Each entry represents palette data for use by EarthBound map graphics for any sector. Each entry is itself comprised of 6 subpalettes (to create 6 different options for palettes to be used by any given map minitile), each comprised of 16 colors.

Because the first color in each palette is generally ignored by the SNES and treated as transparent, EarthBound uses the bytes for that first color to instead stash some control data about the palette.

Terminology Note: What the EarthBound modding community (and this page) generally refers to as a "subpalette" is itself referred to in the SNES development guide as a "palette", and therefore the grouping of 6 of those, which is generally referred to in EarthBound modding (and in this page) as a "palette" (at least in the context of map changes), would in general SNES development be a group of palettes.

Alternate Palette Flag

If non-zero, directs that the palette will be replaced by an alternate (designated by Alternate Palette Pointer), depending on flag values. The alternate palette will then itself have its Alternate Palette Flag checked to determine if it should be replaced by another alternate palette.

Bits 0x7ffff
A flag number to check. Note that this allows up to 32767 flag numbers, but most of these bits will always be zero in unmodified EarthBound where the highest possible flag is 1024. There are however popular mods that greatly increase the number of possible flags
Bit 0x8000
Alternate palette will be used if this bit matches the checked flag's status

For example, given a value 0x01a6, the alternate palette will be used if flag 422 (FLG_ONET_DAYBREAK) is not set (vs it would be looking for the flag to be set if 0x8000 were 1). This is the value used in the main Onett palette to instead use the "nighttime" palette until the flag is set to make the game "daytime".

Subpalette 0

15-color subpalette. Combined with Alternate Palette Flag as the first ignored transparent "color" to create a 16-color subpalette.

Colors are each stored as little endian (2 bytes):

gggrrrrr 0bbbbbgg

The subpalette is formatted as 15 colors in a row.

Alternate Palette Pointer

2-byte pointer to an alternative palette. Combined with the bank used in the first entry of the Palette Pointer Table, which is $DA in unmodified EarthBound where all map palettes are always stored in a single block within that bank.

See Alternate Palette Flag for behavior of when the alternate palette pointer is used.

Subpalette 1

15-color subpalette. Same format as Subpalette 0.

Sprite Palette Replacement Index

If non-zero, contains a subpalette index, counting all EarthBound subpalettes, not just the map subpalettes, from RAM addresses $7E0200-$7E03FF, except subpalette zero at $7E0200 cannot be selected because the index is ignored if zero. The selected subpalette will completely replace sprite subpalette 3 (loaded into RAM at $7E0380-$7E039F.

Used to bring a map subpalette into sprite subpalettes for the occasions where a map element needs to be created using sprites, e.g. to animate Lost Underworld geysers.

Subpalette 2

15-color subpalette. Same format as Subpalette 0.

Palette Animation Index

If non-zero, contains one plus index into Palette Animation Pointer Table.

Subpalette 3

15-color subpalette. Same format as Subpalette 0.

Unknown

Subpalette 4

15-color subpalette. Same format as Subpalette 0.

Unknown

Subpalette 5

15-color subpalette. Same format as Subpalette 0.

Entry Ordering

Palettes are ordered first by tileset number (from the Global Tileset/Palette Table), then within each tileset by the palette number (also from the Global Tileset/Palette Table). Because different tilesets have different numbers of palettes, a lookup to the Palette Pointer Table is used to find a pointer to the first palette for any given tileset. The individual palette address can then be found using the following formula: palette_pointer = first_palette_pointer_from_pointer_table + 0xC0 * palette_number