-
-
Save barncastle/f931764404b4f5d1d2d93cbd04ac94d8 to your computer and use it in GitHub Desktop.
using System.IO; | |
using System.Runtime.InteropServices; | |
namespace ConsoleApp2 | |
{ | |
static class DinoKingSSZL | |
{ | |
public static void Extract(string directory, string filename) | |
{ | |
Directory.CreateDirectory("Dump"); | |
using var fsFil = File.OpenRead(Path.Combine(directory, filename) + ".fil"); | |
using var fsBin = File.OpenRead(Path.Combine(directory, filename) + ".bin"); | |
while (fsFil.Position != fsFil.Length) | |
{ | |
var entry = fsFil.Read<FileInfo>(); | |
fsBin.Position = entry.Offset; | |
byte[] buffer; | |
if (entry.Flags == 1) | |
{ | |
var header = fsBin.Read<SSZL_Header>(); | |
buffer = fsBin.ReadBytes(entry.Size - 16); | |
buffer = Decompress(header, buffer); | |
} | |
else | |
{ | |
buffer = fsBin.ReadBytes(entry.Size); | |
} | |
File.WriteAllBytes("Dump\\" + entry.Filename, buffer); | |
} | |
} | |
public static byte[] Decompress(SSZL_Header header, byte[] input) | |
{ | |
var output = new byte[header.DecompressedSize]; | |
// i = input position, o = output position | |
for (int i = 0, o = 0; o < header.DecompressedSize;) | |
{ | |
byte value = input[i++]; | |
if (value != header.Control) | |
{ | |
// store literal | |
output[o++] = value; | |
} | |
else | |
{ | |
byte index = input[i++]; | |
if (index == header.Control) | |
{ | |
// store control byte | |
output[o++] = (byte)header.Control; | |
} | |
else | |
{ | |
byte count = input[i++]; | |
// fix index value | |
if (index > header.Control) | |
index--; | |
// back reference | |
for (int j = 0; j < count; j++, o++) | |
output[o] = output[o - index]; | |
} | |
} | |
} | |
return output; | |
} | |
[StructLayout(LayoutKind.Sequential)] | |
struct FileInfo | |
{ | |
public int Offset; | |
public int Size; | |
public int Flags; | |
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] | |
public string Filename; | |
} | |
[StructLayout(LayoutKind.Sequential)] | |
struct SSZL_Header | |
{ | |
public uint Magic; | |
public int DecompressedSize; | |
public int Size; | |
public int Control; | |
} | |
} | |
} |
This is more of an initial concept on how to decompress these files and a starting point for someone to properly investigate this format. With that being said it does work for most files.
If you want I can package it up into an app for you?
Yes please I would really like to decompressed the files of this game.
Just out of curiosity where did you get the compressed files?
If you download dinokingextractor.zip and extract it to the game's data directory and run, it'll created a folder called Dump
containing the decompressed assets. Just to note, the data folder is the one that contains complimentary *.bin
and *.fil
files that share the same name e.g. CF_pack.bin
+ CF_pack.fil
.
Just out of curiosity where did you get the compressed files?
All my research was done on the sample files provided here. These would've been extracted from the roms however that's not something I'm knowledgeable on.
Man, thanks a lot it works, however there are some models and textures that are transparent.
As I said, this is concept code and is no way verified as being 100% correct. It could also be that certain models/textures have custom handling by the game.
Unfortunately you'll need someone with more knowledge to reverse engineer this game to get this working.
Hello, I would like to extract the contents of this file containing the source code of the first Dinosaur King arcade game but unlike the next Dinosaur King arcade games, the first game does not have dir and fil files as stipulated in your script. Could someone create a new script for extracted data from the first Dinosaur King game without needing fil and dir files?
https://mega.nz/file/am4XRDjb#sRJOR3wcYnmcQRPX0ZRp7sVTOyOFNA_F4fgmbmDMMJA
Sorry to disturb you. I noticed that you made an extractor for a NAOMI card game which is interesting. I was wondering if this could also be applied to another naomi card game like Love and Berry or MushiKing (the former is I'm more interested in.). Unfortunately, I'm not a coder so I don't know anything.
Love and Berry 1st-2nd Collection is stored in an IC file while Love and Berry 3rd-5th Collection is stored in an mda file. There's nothing much I can do with an IC file but it's possible to convert mda to an image disk file. When I converted it to an image disk, there is an encrypted bin file (containing other models, graphics, etc.), ADX song files that can be played with a sound software, and model and texture files that are in FC format.
I'm fine with if it's just the bin file extracted as I'm most curious of what's inside.
If you download dinokingextractor.zip and extract it to the game's data directory and run, it'll created a folder called
Dump
containing the decompressed assets. Just to note, the data folder is the one that contains complimentary*.bin
and*.fil
files that share the same name e.g.CF_pack.bin
+CF_pack.fil
.Just out of curiosity where did you get the compressed files?
All my research was done on the sample files provided here. These would've been extracted from the roms however that's not something I'm knowledgeable on.
Does somebody still have the sample files? The link is not working anymore, other files I found did not work as well. Would be so much appreciated ...
Thanks in advance!
If you download dinokingextractor.zip and extract it to the game's data directory and run, it'll created a folder called
Dump
containing the decompressed assets. Just to note, the data folder is the one that contains complimentary*.bin
and*.fil
files that share the same name e.g.CF_pack.bin
+CF_pack.fil
.Just out of curiosity where did you get the compressed files?
All my research was done on the sample files provided here. These would've been extracted from the roms however that's not something I'm knowledgeable on.
Does somebody still have the sample files? The link is not working anymore, other files I found did not work as well. Would be so much appreciated ... Thanks in advance!
Hello, do you want the sample files to test and improve the dinokingextractor script?
If you download dinokingextractor.zip and extract it to the game's data directory and run, it'll created a folder called
Dump
containing the decompressed assets. Just to note, the data folder is the one that contains complimentary*.bin
and*.fil
files that share the same name e.g.CF_pack.bin
+CF_pack.fil
.Just out of curiosity where did you get the compressed files?
All my research was done on the sample files provided here. These would've been extracted from the roms however that's not something I'm knowledgeable on.
Does somebody still have the sample files? The link is not working anymore, other files I found did not work as well. Would be so much appreciated ... Thanks in advance!
Hello, do you want the sample files to test and improve the dinokingextractor script?
Hey!
Well testing at first would be helpful of course. I am not sure if I can improve it, but I think we have same goals here. What is different in the first arcade game that you want extract? If you still have the sample files would be awesome if you could share them with me.
Let me know what you think!
If you download dinokingextractor.zip and extract it to the game's data directory and run, it'll created a folder called
Dump
containing the decompressed assets. Just to note, the data folder is the one that contains complimentary*.bin
and*.fil
files that share the same name e.g.CF_pack.bin
+CF_pack.fil
.Just out of curiosity where did you get the compressed files?
All my research was done on the sample files provided here. These would've been extracted from the roms however that's not something I'm knowledgeable on.
Does somebody still have the sample files? The link is not working anymore, other files I found did not work as well. Would be so much appreciated ... Thanks in advance!
Hello, do you want the sample files to test and improve the dinokingextractor script?
How is it going? Would you mind sending me the old files togehter with the new ones you want to extract? I can't promise anything, but I will do my best to check it out.
Hello, does this script work and how to use it?