Jump to content

C-Gear Skin Editing


Kaphotics

Recommended Posts

Intro

Since there isn't any information posted about how the C-Gear is planted within the save file, I might as well just explain how one would edit it. PokeStock is capable of editing the skin, but it's a pretty weird standalone program -- people may want to have their own program (in english) that can edit it. Plus it's good to know how it works!

Background Information

The C-Gear Skin is stored inside the save file as a .psk file ("poké-skin") after it is downloaded or edited. It's a pretty big portion of the save file, coming in at 9.50 KB of data -- that's around 2% of the entire save file's size. Visualizing it as an actual image is different, the .psk file format is not a .bmp or .jpg, and this is beyond me... PokeStock is able to visualize it and save it as a view-able image, however.

Documentation of Save Structure for C-Gear Skins:

0x52000-0x545FF 
Contains the .psk data. 
Calculate Checksum of this region, call it checksum(1).

0x54603-0x54604
Contains the checksum of the .psk data.
Overwrite the current value with checksum(1).

0x1C024-0x1C025 
This is a Checksum Reference to the .psk checksum. 
Overwrite the current value with checksum(1).

0x1C02E-0x1C02F
This is a Region Checksum of the reference checksums, which must be recalculated. 
Calculate the checksum of the region 0x1C000-0x1C02B, call it checksum(2).
Overwrite the current value with checksum(2).

0x23F40-0x23F41
This is a Checksum Reference to the previous reference checksum checksum.
Overwrite the current value with checksum(2).

0x23F9A-0x23F9B
This is a Region Checksum of the nearby reference checksums.
Calculate the checksum of the region 0x23F00-0x23F8B, call it checksum(3).
Overwrite the current value with checksum(3).

0x54700-0x54702
This is a Checksum Reference to the previous reference checksum checksum.
Overwrite the current value with checksum(3).

0x54712-0x54713
This is a Region Checksum of a dword which comprises of checksum(3) and zeroes.
Calculate the checksum of the region 0x54700-0x54703, call it checksum(4).
Overwrite the current value with checksum(4).

Link to comment
Share on other sites

.psk Structure:

Tile Building Region: 0x0-0x1FDFF

0x20 per tile, referencing a 16 bit color for each pixel. 
Each tile makes up a 8x8 block of pixels (64 total). 0xFF (255) tiles total.

0x000 - First Tile
0x020 - Second Tile
...
0x1FB0 - 256th tile

0-F to reference 0-F'th color in the color table, 
build the 8x8 tile  (color pixel by color pixel) left to right, top to bottom.

Set up the tiles in a 16x16 array, left to right, top down.

Color Table: 0x1FE0-0x1FFF

Only 16 different colors allowed, 16 bits (1 word) per color.

Tile Arrangement: 0x2000-0x25FF

Choose tile for 8x8 pixel arrangement.
Move Left to Right, at the end of each line go to the next.

16 bits to choose a tile from the array via (x,y) coordinates, when reading as bytes you would read as big endian (y x) sets.

still not completely sure on the coordinate thing... viewing as 64 bits per line is the way to see it visually under a hex viewer

Edited by Kaphotics
Link to comment
Share on other sites

other crap not particularly related to savs/structure:

For the C-Gear skin appearing in the memory, at delay 0x94 when booting the ROM the C-Gear skin's .psk is loaded at location 0x0224A444 in my English White version; but only has the tile building region.

The final tile of the .psk appears at 0x02150760 as well. That's all of the psk I can find on that delay. It's probably then encrypted away as it's already loaded by the game.

so, possible to AR a skin in? possible, but not probable. The sheer amount of lines needed to overwrite 9.5KB.. lol

edit: looks like it processes each tile and then stores it away

Link to comment
Share on other sites

  • 5 years later...

@SciresM

I haven't looked into that yet because I don't have a hacked Ds.

But you are saying that it's possible then to inject custom skins,no?

Or is that not what you implied?

Also, I meant that perhaps we could rewrite some code and then compile it using a compiler to create a method of injecting custom skins for everyone.

Link to comment
Share on other sites

10 hours ago, Got_Eevees said:

@SciresM

I haven't looked into that yet because I don't have a hacked Ds.

But you are saying that it's possible then to inject custom skins,no?

Or is that not what you implied?

Also, I meant that perhaps we could rewrite some code and then compile it using a compiler to create a method of injecting custom skins for everyone.

 

I am pretty sure it's possible.

 

Also..."compile it using a compiler" -- this is....pretty irrelevant to the process of making a tool. The compiler is literally an afterthought, as is the IDE used to write it. The code itself is all that you should really consider.

 

(And PKHeX already has C-Gear code, I think, as I said.)

Link to comment
Share on other sites

55 minutes ago, SciresM said:

(And PKHeX already has C-Gear code, I think, as I said.)

Well it has, but it's not finished and still has a few issues.

 

@Got_Eevees if PKHeX doesn't work yet you can try PokeGen or PokeCGear until the feature is finished. If you have an image in BMP file format (currently not sure about JPG/PNG) you can inject it, however there are some restrictions set by the game for how many different tiles and colors an image is allowed to have, iirc.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...