Homebrew SKN file format specification

Stormwave

Well-Known Member
OP
Member
Joined
Apr 22, 2010
Messages
237
Trophies
0
Website
Visit site
XP
229
Country
I figured I'd share this knowledge, so any other programmers can make SKN extractors/previewers etc. It explains the file format, to the best of my knowledge, for Moonshell2 and Sakura skn files (and probably any ohers that use these aswell).

Feel free to add this to any FAQs or anything.

Code:
SKN format Specification
------------------------

Following is the SKN file format specification for Moonshell2 and Sakura.

Header
------

BytesÂÂÂÂ Description
-----ÂÂÂÂ -----------
1ÂÂÂÂÂÂÂÂ Header String Length (N)
N+1ÂÂÂÂÂÂ Header = Header String Length + 1 null byte
4ÂÂÂÂÂÂÂÂ File Count (FC)
4ÂÂÂÂÂÂÂÂ Header Length

Then follows the file list table, it is a series of small structures. One for each file represented by File Count.

File Data
---------

BytesÂÂÂÂ Description
-----ÂÂÂÂ -----------
4ÂÂÂÂÂÂÂÂ Name Offset (exact offset is Name Offset + 0x34)
4ÂÂÂÂÂÂÂÂ Uncompressed Size
4ÂÂÂÂÂÂÂÂ Compressed Size
4ÂÂÂÂÂÂÂÂ Data Offset

Total File Data table size therefore is (16 * File Count).

After that you can read in the names for all of the files. This will be in the immediate bytes following the File Data table, so you can simply continue reading the file. Alternatively, you can use Name Offset + 0x34 to get to the exact offset.

All file name strings are represented as follows

Strings
-------

BytesÂÂÂÂ Description
-----ÂÂÂÂ -----------
1ÂÂÂÂÂÂÂÂ String Length (N)
NÂÂÂÂÂÂÂÂ String Data
1ÂÂÂÂÂÂÂÂ Null Byte (0)


If you're opening a MoonShell2 type.5 skin, then you will need to read 3 bytes (unsure of their purpose) at this point.


Then follows the data section, using the following layout format

Data
----

BytesÂÂÂÂ Description
-----ÂÂÂÂ -----------
2ÂÂÂÂÂÂÂÂ Unknown
CS(n)*FCÂÂData (where CS is "Compressed Size" for each item, and FC is the file count)

Each data segment is a compressed file. The compression uses the "Deflate" algorithm, which is widely used and can be performed easily using the zlib library.



And that is all!

Notes:

- There are a few bytes at the end of the compressed data that I have no idea what they do. They do not affect decompression at all, but seem necessary to the skin. I'm not sure entirely what these bytes are for, or how to replicate them, hence the reason DS Skin Maker uses MakeSkin.exe still.
- This spec only covers type 3 and type 5 skins. I'm not sure about any other types.
- This works completely with Sakura and Moonshell2 (and potentially any other firmware that uses MoonShell 2 SKN files)
 

env

Well-Known Member
Member
Joined
Aug 20, 2009
Messages
219
Trophies
0
Age
35
XP
90
Country
frown.gif
Felt kinda sad about this, IDK but for some skin makers (like myself), SKN file "extractors" are one of the factors that indisposed us from making more skins, that no matter how we try to attract skin makers to try making MS2 skins, and share it, they just.. ah forget it.
(XD look who's taking anti-pirate now lol ..
mellow.gif
)
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Veho @ Veho: https://www.keepretro.com/products/miyoo-a30