Page 2 of 2

Re: Tatsunoko vs Capcom (Wii)

Posted: Tue Jun 09, 2009 3:23 pm
by aluigi
N=10? so basically the data is almost uncompressed :)
other games other than s2?

Re: Tatsunoko vs Capcom (Wii)

Posted: Tue Jun 09, 2009 3:31 pm
by Rheini
Oh I meant the number of bits used for encoding.

Re: Tatsunoko vs Capcom (Wii)

Posted: Tue Jun 09, 2009 3:34 pm
by aluigi
another interesting thing I noticed some months ago about LZSS.
the following is the latest source of Okumura
but even if you change the EI, EJ and P parameter to make them compatible with the classical algorithm it's not compatible at all.

Re: Tatsunoko vs Capcom (Wii)

Posted: Tue Jun 09, 2009 3:40 pm
by Rheini
Oh yeah I forgot that one.
There the bit is saved immediately followed by the data. This is the original LZSS.
Grouping 8 (16) bits together to ease reading and writing is more common though.

Re: Tatsunoko vs Capcom (Wii)

Posted: Tue Jun 09, 2009 3:54 pm
by aluigi
uhmm maybe I'm wrong but I think that the lzss.c version with N, F and THRESHOLD (like is the oldest one, or at least is the most used.

Re: Tatsunoko vs Capcom (Wii)

Posted: Tue Jun 09, 2009 4:01 pm
by Rheini
I was refering to the paper ("Data compression via textual substitution")

Re: Tatsunoko vs Capcom (Wii)

Posted: Wed Jun 10, 2009 2:08 am
by chrrox
There is an ida Pro 5.2 plugin to load the game executable for this game would this make it possible to see the compression used in this game if I upload the main exe and the plugin?

Re: Tatsunoko vs Capcom (Wii)

Posted: Thu Jul 09, 2009 9:26 am
by tpu
The .fpk file use PRS compress method(a little change). This is the fpk tool:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <dirent.h>

typedef unsigned int   u32;
typedef unsigned short u16;
typedef unsigned char  u8;

int endian=1;

u32 BE32(u32 data)
		return ( (data<<24) | ((data<<8)&0x00ff0000) |
				((data>>8)&0x0000ff00) | (data>>24) );
		return data;

int blen;
int fbuf;

/* PRS get bit form lsb to msb, FPK get it form msb to lsb */
int get_bits(int n, char *sbuf, int *sptr)
	int retv;

	retv = 0;
		retv <<= 1;
			fbuf = sbuf[*sptr];
				//{ printf("[%02x] ", fbuf&0xff); fflush(0); }
			blen = 8;

			retv |= 1;

		fbuf <<= 1;
		blen --;
		n --;

	return retv;

int uncomp(char *dbuf, int dlen, char *sbuf, int slen)
	int sptr;
	int dptr;
	int i, flag, len, pos;

	blen = 0;

	sptr = 0;
	dptr = 0;
		flag = get_bits(1, sbuf, &sptr);
				//{ printf("%02x ", (u8)sbuf[sptr]); fflush(0); }
				dbuf[dptr++] = sbuf[sptr++];
			flag = get_bits(1, sbuf, &sptr);
				len = get_bits(2, sbuf, &sptr)+2;
				pos = sbuf[sptr++]|0xffffff00;
				pos = (sbuf[sptr++]<<8)|0xffff0000;
				pos |= sbuf[sptr++]&0xff;
				len = pos&0x07;
				pos >>= 3;
					len = (sbuf[sptr++]&0xff)+1;
					len += 2;
				//{ printf("<%08x(%08x): %08x %d> \n", dptr, dlen, pos, len); fflush(0); }
			pos += dptr;
			for(i=0; i<len; i++){
					dbuf[dptr++] = dbuf[pos++];

	return dptr;

void mkdir_p(char *dname)
	char name[256];
	char *p, *cp;

	strcpy(name, dname);

	cp = name;
		p = strchr(cp, '/');
			p = strchr(cp, '\\');

		*p = 0;
		//mkdir(name, 0777);
		*p = '/';
		cp = p+1;

int process_file(char *infname)
	FILE *fp, *outfp;
	char *fname, *dptr, *buf, *dbuf;
	int i, fcnt, flen, dlen, offset;
	char dname[256], tname[256], *p;

	p = strchr(infname, '.');
		return -1;
	if(strcmp(p+1, "fpk"))
		return -1;

	printf("process file %s ...\n", infname);

	/* Open fpk file */
	fp = fopen(infname, "rb");
		printf("Can't open %s!\n", infname);
		return -1;

	/* Make directory */
	strcpy(dname, infname);
	p = strchr(dname, '.');
		*p = '_';
	//mkdir(dname, 0777);

	fseek(fp, 0, SEEK_END);
	flen = ftell(fp);
	fseek(fp, 0, SEEK_SET);

	buf = (char*)malloc(flen);
	fread(buf, flen, 1, fp);

		endian = 1;
		endian = 0;

	fcnt = BE32(*(int*)(buf+4));
	for(i=0; i<fcnt; i++){
		dptr = buf+0x10+i*0x30;
		fname = dptr;
		flen = BE32(*(int*)(dptr+0x28));
		offset = BE32(*(int*)(dptr+0x24));
		dlen = BE32(*(int*)(dptr+0x2c));
		printf("offset: %08x flen: %08x length: %08x file: %s\n", offset, flen, dlen, fname);

		dbuf = malloc(dlen+256);
		uncomp(dbuf, dlen, buf+offset, flen);

		sprintf(tname, "%s/%s", dname, fname);

		outfp = fopen(tname, "wb");
			printf("Can't open output file %s !\n", tname);
			fwrite(dbuf, dlen, 1, outfp);

	return 0;


int process_dir(char *dname)
	DIR *pdir;
	struct dirent *d;
	struct stat statbuf;
	char fname[256];
	int i, ndir;

	/* process file */
	memset(&statbuf, 0, sizeof(statbuf));
	stat(dname, &statbuf);
	if((statbuf.st_mode&S_IFMT) != S_IFDIR){
		return process_file(dname);

	/* open directory */
	pdir = opendir(dname);
		printf("Can't open directory <%s>\n", dname);
		return -1;

	/* get number of files in dircetory */
	ndir = 0;
	d = malloc(sizeof(struct dirent)*ndir);

	/* read dirent first */
	for(i=0; i<ndir; i++){
		memcpy(&d[i], readdir(pdir), sizeof(struct dirent));

	/* process each files */
	printf("Enter directory <%s> ...\n", dname);
	for(i=0; i<ndir; i++){
		if( d[i].d_name[0]=='.' &&( d[i].d_name[1] =='\0' || (d[i].d_name[1] == '.' && d[i].d_name[2] == '\0') ))

			sprintf(fname, "%s", d[i].d_name);
			sprintf(fname, "%s/%s", dname, d[i].d_name);
	printf("Leave directory <%s> ...\n", dname);

	return 0;

int main(int argc, char *argv[])
		return process_dir(".");
		return process_dir(argv[1]);

Re: Tatsunoko vs Capcom (Wii)

Posted: Thu Jul 09, 2009 11:02 am
by chrrox
here is a compiled exe for everyone.

Re: Tatsunoko vs Capcom (Wii)

Posted: Thu Jul 09, 2009 1:33 pm
by Mr.Mouse
Don't you just love this forum ? :D Another mystery solved. 8) Thanks all!

Re: Tatsunoko vs Capcom (Wii)

Posted: Thu Jul 16, 2009 1:18 am
by chrrox
I found this crashing on some archives for some reason I was wondering if someone could help with this problem. Here are some archives it crashes on.
also is it possible for the program to offer an option to skip a file if it has trouble instead of closing down?
Thanks in advance to anyone who can help :)

Re: Tatsunoko vs Capcom (Wii)

Posted: Fri Sep 11, 2009 6:44 pm
by eycaramba
Same here, also crashes on MHG 0000.fpk :scaredy:

Re: Tatsunoko vs Capcom (Wii)

Posted: Wed Jan 06, 2010 11:58 am
by simple
Sorry for the bump but I am wondering if someone can repost the compressed and uncompressed files of TvC again since the old links expired...


Re: Tatsunoko vs Capcom (Wii)

Posted: Wed Apr 20, 2011 2:52 pm
by fconb2
Late bump. How would I compile the compressor to exe (or, does anyone have the original exe)?