View previous topic :: View next topic |
Author |
Message |
duskwolf Trick Member
Joined: 04 Oct 2006
|
0. Posted: Thu Oct 05, 2006 1:57 am Post subject: Extracting data from ITGPC2 (and probably ITGPC as well) |
|
|
If you folks haven't noticed already, Roxor's made the ITGPC to ITGPC2 upgrade available for free. (There's a link to it from stepmania.com.) I haven't looked at the Windows package, but the Mac package - which can be viewed under Windows; don't worry - contains several interesting-looking .PCK files. I've reverse-engineered the format and written an unpacker (in Python), which I've attached.
I wasn't forced to agree to any licensing terms in order to download the patch, so the legal situation on the files that you can extract using this tool is distinctly unclear. It's probably legal to possess them, but not to distribute them. The tool itself, though, is free and clear - I wrote it without looking at the ITG binary at all, so it's considered a "clean-room" reimplementation of the format.
The two files that really matter in the package are:
- Contents/Resources/Patch/Contents/Resources/pcks/packa/D1513758.PCK - background movies
- Contents/Resources/Patch/Contents/Resources/pcks/packa/DC37F75E.PCK - songfiles and music
There are a couple of other interesting PCK files in the patch; you can probably find them for yourself. The tool will probably work on the ITG1 .PCK files as well. I don't have a copy of the game, though, so I can't test that.
Please note that this tool requires Python, and operates from the command line. I do not plan to write a GUI, as it would be overkill - you really only need to use it a few times.
Code: | #!/usr/bin/python
import sys, os, struct, zlib
def mkpath(p):
if os.path.exists(p): return
b,d = os.path.split(p)
if b:
mkpath(b)
os.mkdir(p)
def mkpathto(p):
d,f = os.path.split(p)
mkpath(d)
def do_header(f):
hdr = f.read(0x88)
ident, packname, filecount = struct.unpack("< 4s 128s L", hdr)
packname = packname.strip("\0")
if ident != "PCKF":
print "That doesn't look like a ITG PCK file..."
sys.exit(1)
print "Package %s contains %d files." % (repr(packname), filecount)
print
return filecount
def get_files(f, filecount):
files = []
for i in range(filecount):
hdr = f.read(20)
dsize, fsize, offset, fnlen, compress = struct.unpack("<LLLLL", hdr)
fn = f.read(fnlen)
files.append((i, fn, dsize, fsize, compress))
return files
def do_file(f, finfo):
i, fn, dsize, fsize, compress = finfo
if compress:
print "%-4d: %10d from %-10d | %s" % (i, dsize, fsize, fn)
elif dsize != fsize:
print "%-4d: %10d !!!! %-10d | %s" % (i, dsize, fsize, fn)
print "!!! Decompressed size != compressed size for uncompressed file. Corrupt?"
sys.exit(1)
else:
print "%-4d: %10d %-10s | %s" % (i, dsize, "", fn)
dat = f.read(dsize)
fname = os.path.join(outdir, fn)
mkpathto(fname)
if compress:
dat = zlib.decompress(dat, -15)
if len(dat) != fsize:
print "!!! Length of decompressed data doesn't match up! (Was %d, should be %d)" % (len(dat), fsize)
sys.exit(1)
of = file(fname, "w")
of.write(dat)
of.flush()
of.close()
def main(args):
global outdir
if len(args) != 3:
print "Usage: [python] itgunpack.py itg-file.pck output-directory"
f = file(args[1], "r")
outdir = args[2]
filecount = do_header(f)
files = get_files(f, filecount)
for finfo in files:
do_file(f, finfo)
print
print "Done!"
sys.exit(0)
main(sys.argv) |
|
|
Back to top |
|
|
Travelsonic Trick Member
Joined: 08 Oct 2005
|
1. Posted: Thu Oct 05, 2006 10:02 am Post subject: |
|
|
If this code works with ITG1 pcks, that'd be cool. _________________
I'll believe that when me **** turns purple, and smells like rainbow sherbet. |
|
Back to top |
|
|
Kalek Trick Member
Joined: 06 Nov 2004 Location: Pickerington, OH |
2. Posted: Thu Oct 05, 2006 10:29 am Post subject: |
|
|
We already have a PCK V2 extracting tool.
But, thanks for the thought...
Its in the "How To Unpack ITG PS2" thread somewhere. |
|
Back to top |
|
|
duskwolf Trick Member
Joined: 04 Oct 2006
|
3. Posted: Thu Oct 05, 2006 11:44 am Post subject: |
|
|
D'oh. I could've sworn I'd seen something about that version not working with ITGPC files, but I guess I just didn't read enough of the thread.
Any case, this one's not Windows-only, in case anyone cares about that. It's also a script, so if anyone's wondering how the format works, now they can figure it out. Sort of. |
|
Back to top |
|
|
Kalek Trick Member
Joined: 06 Nov 2004 Location: Pickerington, OH |
4. Posted: Thu Oct 05, 2006 12:03 pm Post subject: |
|
|
duskwolf wrote: | D'oh. I could've sworn I'd seen something about that version not working with ITGPC files, but I guess I just didn't read enough of the thread.
Any case, this one's not Windows-only, in case anyone cares about that. It's also a script, so if anyone's wondering how the format works, now they can figure it out. Sort of. | Well, since its not just windows only, I guess this is still very helpful
You probably read the whole thing about it not working on PCKSuite, not the PCK V2 extractor mentioned somewhere in the thread.
BTW, do you know how to get Python scripts running on an Intel Mac? |
|
Back to top |
|
|
duskwolf Trick Member
Joined: 04 Oct 2006
|
5. Posted: Thu Oct 05, 2006 2:24 pm Post subject: |
|
|
Just launch it from the terminal - you get a copy of Python installed by default (in /usr/bin). There isn't anything specific you need to do to get it working. |
|
Back to top |
|
|
Cutriss Staff Member
Joined: 24 Jan 2002
|
6. Posted: Fri Oct 06, 2006 5:31 am Post subject: |
|
|
I like the idea of having it in a Python script. It creates a barrier-to-entry that I think should be enforced in topics like this. You'll always have people like videoCWK whose interests say "Programming" but they can't figure out how to use CLI tools and don't know common file formats...
Of course, someone will likely come along and write a wrapper for it anyway and ruin the fun... _________________
Sentient Mode is capable... |
|
Back to top |
|
|
duskwolf Trick Member
Joined: 04 Oct 2006
|
7. Posted: Fri Oct 06, 2006 12:37 pm Post subject: |
|
|
A friend with a copy of ITGPC confirms that it will successfully extract those files too. However, the theme files do not work with Stepmania (current CVS) "out of the box". |
|
Back to top |
|
|
Eric S!! Trick Member
Joined: 16 Apr 2002
|
8. Posted: Thu Oct 12, 2006 9:05 pm Post subject: |
|
|
I just got a copy if ITGPC and I downloaded python and everything, but I have no clue what to do. Is there anyone out here that can provide detailed instructions on how to extract these files? |
|
Back to top |
|
|
duskwolf Trick Member
Joined: 04 Oct 2006
|
9. Posted: Thu Oct 12, 2006 9:16 pm Post subject: |
|
|
Run the script. It'll tell you how to use it, more or less. |
|
Back to top |
|
|
Eric S!! Trick Member
Joined: 16 Apr 2002
|
10. Posted: Sun Oct 15, 2006 9:51 am Post subject: |
|
|
I typed in the script exactly and nothing happpened, I believe I got 1 or 2 error messages. NOTE: I am trying to run this under Windows, do I need to do anything different compared to the mac version? |
|
Back to top |
|
|
duskwolf Trick Member
Joined: 04 Oct 2006
|
11. Posted: Sun Oct 15, 2006 12:04 pm Post subject: |
|
|
You're supposed to save it to a file and run it as a script... |
|
Back to top |
|
|
Eric S!! Trick Member
Joined: 16 Apr 2002
|
12. Posted: Wed Oct 25, 2006 10:42 am Post subject: |
|
|
Well for us computer illeterate people (I dont know programming), can you provide detailed steps on how to extract the files, from saving it as a script and to running it? |
|
Back to top |
|
|
duskwolf Trick Member
Joined: 04 Oct 2006
|
13. Posted: Wed Oct 25, 2006 10:50 am Post subject: |
|
|
Save as .py file. Run. See "usage" message. Use accordingly. |
|
Back to top |
|
|
Scarenormous! Trick Member
Joined: 30 Jul 2003 Location: here |
14. Posted: Tue Oct 31, 2006 6:51 pm Post subject: |
|
|
Cutriss wrote: | I like the idea of having it in a Python script. It creates a barrier-to-entry that I think should be enforced in topics like this. You'll always have people like videoCWK whose interests say "Programming" but they can't figure out how to use CLI tools and don't know common file formats...
|
Quote: | Well for us computer illeterate people (I dont know programming), can you provide detailed steps on how to extract the files, from saving it as a script and to running it? |
Ah the torrent is so bad, why does no one seed? Has anywhere hosted this file or am I going to have to stick out the 17 kb/s? _________________
|
|
Back to top |
|
|
duskwolf Trick Member
Joined: 04 Oct 2006
|
15. Posted: Tue Oct 31, 2006 8:00 pm Post subject: |
|
|
Torrents? I see no torrent here. The only file involved is inline at the top of the thread. |
|
Back to top |
|
|
Scarenormous! Trick Member
Joined: 30 Jul 2003 Location: here |
16. Posted: Wed Nov 01, 2006 7:07 pm Post subject: |
|
|
The download for R2 is a torrent. _________________
|
|
Back to top |
|
|
duskwolf Trick Member
Joined: 04 Oct 2006
|
|
Back to top |
|
|
Scarenormous! Trick Member
Joined: 30 Jul 2003 Location: here |
18. Posted: Thu Nov 02, 2006 12:53 pm Post subject: |
|
|
Thanks that was helpful _________________
|
|
Back to top |
|
|
eaglefan101 Trick Member
Joined: 15 Jun 2005 Location: Somewheres |
|
Back to top |
|
|
|