Faxanadu tracks three types of palettes: 1. **Tile palettes**, used for the decoration of the string 2. **Sprite palettes**, used for enemies, items, NPCs, etc. 3. **UI palettes**, used for the background of the HUD and textboxes. There are 28 tile palettes, 3 sprite palettes, and 3 UI palettes, all listed below. The palette types are loaded independently (see [[#Palette Loading Functions]]), combing to form palette data [[#RAM|stored in RAM]]. This is scheduled for write and then written to the PPU using [[#Palette Drawing Functions]]). # Tile Palettes Tile palettes are in Bank 11, taking 16 bytes each, and starting at $8000. | iD | Bank | Address | Description | | --- | ---- | ------- | ------------------ | | 0 | 11 | $8000 | Eolis | | 1 | 11 | $8010 | ? | | 2 | 11 | $8020 | ? | | 3 | 11 | $8030 | ? | | 4 | 11 | $8040 | ? | | 5 | 11 | $8050 | ? | | 6 | 11 | $8060 | Outside | | 7 | 11 | $8070 | Tower | | 8 | 11 | $8080 | Branch | | 9 | 11 | $8090 | Left Side of Trunk | | 10 | 11 | $80A0 | Mist | | 11 | 11 | $80B0 | Suffer | | 12 | 11 | $80C0 | Dartmoor | | 13 | 11 | $80D0 | Fraternal | | 14 | 11 | $80E0 | King Grieve's Room | | 15 | 11 | $80F0 | Evil Fortress | | 16 | 11 | $8100 | Start Screen | | 17 | 11 | $8110 | King's Room | | 18 | 11 | $8120 | Temple | | 19 | 11 | $8130 | Hospital | | 20 | 11 | $8140 | Tavern | | 21 | 11 | $8150 | Tool Shop | | 22 | 11 | $8160 | Key Shop | | 23 | 11 | $8170 | House | | 24 | 11 | $8180 | Meat Shop | | 25 | 11 | $8190 | Martial Arts | | 26 | 11 | $81A0 | Magic Shop | | 27 | 11 | $81B0 | Town | # Sprite Palettes Sprite palettes are in Bank 11, taking 16 bytes each, and starting at $81C0. | ID | Bank | Address | Description | | --- | ---- | ------- | ----------------- | | 0 | 11 | $81C0 | Outside | | 1 | 11 | $81D0 | Inside | | 2 | 11 | $81E0 | IScript Portraits | # UI Palettes | ID | Bank | Address | Description | | --- | ---- | ------- | ----------- | | 0 | | | | | 1 | | | | | 2 | | | | | 3 | | | | The following lookup tables are used: | Bank | Address Range | Description | | ---- | ------------------------------------------------------------- | ----------- | | 11 | [$81F0 - $820F](https://chipx86.com/faxanadu/PRG11.html#81f0) | Mapping | # Functions ## Palette Loading Functions These functions are responsible for setting a palette and loading it into memory (prior to PPU). | Bank | Address | Name | Description | | ---- | ------------------------------------------------------------ | ------------------------------------ | --------------------------------------------------------------------------------------------- | | 15 | | `Screen_LoadTilePalette` | Loads tile palettes | | 15 | [$D03B](https://chipx86.com/faxanadu/PRG15_MIRROR.html#d03b) | `Screen_LoadUIPalette` | Loads HUD/textbox palettes | | 15 | $D062 | `Screen_LoadSpritePalette` | Load sprite palettes | | 15 | [$D074](https://chipx86.com/faxanadu/PRG15_MIRROR.html#d074) | `Screen_SetPaletteData` | Common functionality for setting palette data at a given index (0 for tiles, 16 for sprites). | ## Palette Drawing Functions These functions schedule and then inject a palette into the PPU. | Bank | Address | Name | Description | | ---- | ------------------------------------------------------------ | ------------------------------------ | ---------------------------------------------------------------------- | | 15 | [$D016](https://chipx86.com/faxanadu/PRG15_MIRROR.html#d016) | `PPUBuffer_DrawCommand_WritePalette` | PPU Buffer draw command for writing a scheduled palette to the PPU | | 15 | $D090 | `PPUBuffer_WritePalette` | Schedule writing the loaded palette to the PPU (for the draw command). | # RAM | Address | Name | Description | | ------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------- | | $038D | `UI_AttributeDataIndex` | The palette for the UI HUD/textboxes | | $0293 | `Screen_PaletteData` | The 32 bytes of palette data to write to the screen.<br><br>First 16 bytes is tile palette, and second is sprite. |