Closed kuroppoi closed 2 weeks ago
Initial rewrite is complete; I've tested importing/exporting for both games (img and file).
I'll let it marinate a bit before merging, unless someone finds any issues :)
Rewrite makes it much easier to add support for PokéDex Skins, but that requires figuring out the various flags to enable display in-game (see SAV5 for enabling logic).
When importing a
.cgb
or.psk
file, PKHeX will decompose all of the tilemap indices under the assumption that they are obfuscated. In reality, the C-Gear skin tiles are just stored in an odd manner in tile memory.(Tileset image, the top left tile is tile![image](https://github.com/user-attachments/assets/c159682c-eb44-4259-b6dd-fc9e93881208)
0x0
and the bottom right is0x3FF
. The blank areas are typically filled with tiles from recently accessed menus and are unreliable to use.)All of these tiles can be used in C-Gear skin tilemaps. Skin tiles start at index
0xA0
and seems to skip 15 tiles after every strip of 17 tiles. The problem with decomposing the tilemap indices is that it gets rid of indices belonging to tiles not part of the skin itself, which is actually something that most official C-Gear skins make use of.This bar that stretches across the top of the screen is stored in the tilemap data and is constructed using tiles![image](https://github.com/user-attachments/assets/fdbf5d01-10ff-44d4-b32a-a2b7caed38d7)
0xA
and0xB
with color palette 8 (which is dynamic: either blue or reddish depending on the trainer's gender.) Currently, PKHeX will filter these indices out which is why this detail is not present in all skins that have been imported by it.Speaking of palettes -- those are stored in the tilemap data as well. In Black & White, skin colors are stored in palette 10 (
0xA
). Taking example index0xA0A0
(or0b1010000010100000
in binary) the complete data is as follows:I should add that all of this data pertains to Black & White only. In Black 2 & White 2, skin tiles are stored linearly and the game forces all tiles to use the skin palette. There are also no interesting non-skin tiles that can be used. This is probably because the game seems to add
0x200
to all skin tile indices which puts all of the earlier tiles out of reach.