Hacking TvC FPK tool

RupertAvery

Member
OP
Newcomer
Joined
Feb 1, 2010
Messages
16
Trophies
1
XP
160
Country
I've written an FPK packer for Tatsunoko vs Capcom. It will scan a folder recursively and compress the files into a fpk.

The fpk files generated by the packer can be unpacked with unFPK, but I haven't been able to test by replacing files on the ISO. The files are generally larger by around 1k or 2k than the original fpk files.

The entire file format is accounted for except for the first 4 bytes, which changes from file to file. I think it's a checksum, but I haven't yet been able to figure out how it's computed.

Hopefully TvC will accept FPKs with the first 4 bytes set to zero.

You can download the tool (and VS2005 source code) here.

CODETo create an FPK:

fpktool -p

To unpack an FPK:

fpktool -u

Would anyone like to help with testing?
 
  • Like
Reactions: TanookiMario

WiiShizzza

Graphics juggler
Member
Joined
Oct 10, 2008
Messages
1,201
Trophies
1
Website
Visit site
XP
241
Country
Gambia, The
Nice!! Thank you!

unpacking/packing seems to work. packing is a bit slow. Later on today I'm going to test if the created fpk files work with TvC UAS partition.
 

RupertAvery

Member
OP
Newcomer
Joined
Feb 1, 2010
Messages
16
Trophies
1
XP
160
Country
@ganons:

FPK is more or less an archive file, used to store related sets of data.

The TvC FPKs seem to store data related to the characters, as they are stored in folders such as "fpk/ryu" and "fpk/sak". When unpacked, you get a bunch of folders and files, with various extensions like *.MOT, *.BRRES, *.SEQ. I suppose in TvC these files are used for the character models, as some of them likely contain textures.

I'm not too well versed with GC/Wii/Ninty file formats as I'm new to the scene (just bought my Wii a month ago). I was just bored at work/home and wanted to get back into programming-for-fun.

@WiiShizzza:

Yeah, it is a bit slow. The compression algorithm currently does a brute-force search for matching sequences, so there's still room for improvement. However if TvC actually does require the checksum and refuses to load the fpk, speed will be the last of our problems
laugh.gif
 

ganons

Well-Known Member
Member
Joined
Jun 12, 2005
Messages
3,290
Trophies
1
XP
3,101
Country
RupertAvery said:
@ganons:

FPK is more or less an archive file, used to store related sets of data.

The TvC FPKs seem to store data related to the characters, as they are stored in folders such as "fpk/ryu" and "fpk/sak". When unpacked, you get a bunch of folders and files, with various extensions like *.MOT, *.BRRES, *.SEQ. I suppose in TvC these files are used for the character models, as some of them likely contain textures.

I'm not too well versed with GC/Wii/Ninty file formats as I'm new to the scene (just bought my Wii a month ago). I was just bored at work/home and wanted to get back into programming-for-fun.

@WiiShizzza:

Yeah, it is a bit slow. The compression algorithm currently does a brute-force search for matching sequences, so there's still room for improvement. However if TvC actually does require the checksum and refuses to load the fpk, speed will be the last of our problems
laugh.gif

thanks for answer and welcome to the wii scene, looking forward to some of your work
 

RupertAvery

Member
OP
Newcomer
Joined
Feb 1, 2010
Messages
16
Trophies
1
XP
160
Country
I was thinking about how to reverse those formats when it occurred to me that we have the code for reading the formats. It's a long shot, but shouldn't the game contain the code for reading those files?

The main.dol of TvC contains the folder names for the ssds, fpks and other resources.

If they are aligned sequentially and of the same size, then I would assume that some code references them via an index, and a pointer to the first item. If the binary contains a "%s.fpk" string, some code pointing to that would likely call a sprintf routine of some sort to build the path prior to loading it. Of course I have no idea as of yet how memory is loaded into the wii and how it is referenced in code.

If two games both use a certain file format, the dols might contain the same code, making identifying the code a matter of diff-comparing the two dols. Anyway, all this is just to help make identifying which portion of the code to disassemble much easier.

I was also thinking that maybe the dolphin emulator could be modified to break when it tries to "load" a certain file in the ISO, or access a certain part of memory. I know Dolphin has a debug mode, but it doesn't seem to have the ability to trigger a break on memory access, nor can I actively scan memory for some strings.

If anyone can point me to good information about dols, how they are loaded, disassemblers and PPC assembly, it would help a lot.

I've done some NES and SNES assembly in the past. I tried to convert Willow to a SRAM- instead of password-based save for the NES, and for SNES I started a ROM translation project for Akazukin Cha Cha RPG, adding roman font and variable font width routines.
 

vashgs

Well-Known Member
Member
Joined
Feb 1, 2008
Messages
236
Trophies
0
XP
234
Country
United States
If it requires the checksum, we have a checksum library used by the game save. I doubt it'd be the same routine (as FPK file format is used in other games as well), but it's worth a shot. Drop me a PM if interested.
 

RupertAvery

Member
OP
Newcomer
Joined
Feb 1, 2010
Messages
16
Trophies
1
XP
160
Country
I don't know if I did this correctly, but I replaced ryu's 0000.fpk file with a recompiled one using WiiScrubber's replace function.

Unfortunately, TvC now freezes whenever I select Ryu.
cry.gif
So it's either my compression is wrong in some places, or the checksum thing...

Things to try with a clean ISO:

1. Extract a file and replace without changes, to show that replacing works without issues.
2. Extract a file, modify the "checksum" bytes, replace, to confirm that TvC actually does something with those bytes.

I doesn't make sense to put a checksum in there though, the game usually expects all the data to be good. I mean, it won't throw a checksum error because there would be no way to recover from it anyway.

Oh well, back to the drawing board...
 

TempusC

Well-Known Member
Member
Joined
Nov 22, 2006
Messages
229
Trophies
0
Website
www.FatalFrame4.net
XP
91
Country
Canada
QUOTE said:
I was thinking about how to reverse those formats when it occurred to me that we have the code for reading the formats. It's a long shot, but shouldn't the game contain the code for reading those files?

The Wii uses PPC assembly. You can get a plugin to load the dol’s into IDA over here. There’s plenty of good information on Wiibrew.org about the Wii’s internals. You’ll want to look at the Memory Map specifically. The dol loads into the beginning of Mem1, and the resources (your fpks) usually load into Mem2. Only the cached part is useful to you.



QUOTE said:
I was also thinking that maybe the dolphin emulator could be modified to break when it tries to "load" a certain file in the ISO, or access a certain part of memory. I know Dolphin has a debug mode, but it doesn't seem to have the ability to trigger a break on memory access, nor can I actively scan memory for some strings.

Dolphins debug is reasonably bad. It does have a breakpoint though, in the debug mode. Under View -> Breakpoint. You’ll need JIT enabled, and switch to the interpreter core. Thanks to Treeki for the info (I can’t run Dolphin on my system).

USB gecko is superior, but of course requires the hardware.



QUOTE
I doesn't make sense to put a checksum in there though, the game usually expects all the data to be good. I mean, it won't throw a checksum error because there would be no way to recover from it anyway.

Well, while true, it could be some data which is equivalent to a checksum, such as a hash, a count of the number of entries of something or other, or even a simple file length. If you do indeed find it to be a checksum, you may want to contact megazig - he has gone checksum discovering crazy lately and is the creator of the library vashgs was speaking of.



There are several places to gain further support into Wii hacking - the Wiibrew forums (which is good), #wiidev on irc.efnet.net (which is kind to newbies), #HACKERCHANNEL on irc.freenode.net (which will probably kick you if you can’t operate your computer entirely via command line), or here (though developments questions can get bogged down fast here - this is truly more of an end-user forum). Lastly, you could ask the original dev - devs are often willing to put in some more effort when someone else with skill shows a little interest.
 

Doux91

Well-Known Member
Member
Joined
Feb 23, 2014
Messages
306
Trophies
0
Age
33
XP
961
Country
Honduras
How can i use it i want to extract a 0000.fpk file but i dont know how to make it work can you help me, give me an example at least please i know to open it but how to use it
fpktool -u <input file> <ouput folder> if i use the < i get an error, if i dont use it doesnt do anything, please help me, or make a GUI for make simple the extraction please
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: https://youtube.com/shorts/WOppJ92RgGU?si=KE79L6A_3jESsGQM