File format specifications

Ideas, technology and contributions to Z modifications

Moderator: Brad

Post Reply
rsn10100
Grunt
Grunt
Posts: 1
Joined: 2014-08-03, 08:05
Are you a spam bot?: No

File format specifications

Post by rsn10100 » 2014-08-03, 08:58

Hey, I'm a bit new here so forgive me if this has been posted before...

I've been working a bit on decoding some of the file formats used in the original game and I thought I would post what I know here in case anybody was doing the same. There is still a lot to figure out and a lot to verify but I'm hoping to write some of my own code to work with at least some of the files. If anyone knows how the PAC files are compressed, please let me know.

Here are notes on what I learned so far.

Code: Select all

****************
*.RSC - Sprite resource files

Head {
	uint16 num_sprites;
	uint32 location[num_sprites];	// Byte position in file to find sprite.
	uint8  unknown[num_sprites];	// Single byte ???
	struct RGB {
		uint8 r, g, b;	// Red, green and blue values. TODO: Check order.  Should be correct, but it's not always in this order...
	} palette[256];		// 3 * 256 = 768 (0x300)
};

Sprite {
	uint8 width;			// Width of bitmap.
	uint8 height;			// Height of bitmap.  TODO: Make sure the width and height are not reversed.
	uint8 unknown[width];	// ???
	uint8 bitmap[width * height];
	// uint8 unknown2[2];// May have two extra bytes... ???
};


****************
*.PAC file notes

To read this format you basically need to start at the end (the footer) to get the index.

Head {
	uint32 unknown0;	// Always 0x00000000 ???
};

Files[] {};// Many files compressed and stored within the PAC file.

// The index is located before the footer but after all the file data.
// To find start of the index you seek relative to the end of the 
// file like this...
//
// fseek(fp, -((Footer.num_entries * sizeof(Entry)) - 8), SEEK_END);
//
// or
//
// fseek(fp, file_size - ((Footer.num_entries * sizeof(Entry)) - 8), SEEK_SET);
//
// Note:  All files seem to be individually compressed... 
// TODO: Figure out method of compression.

Index[Footer.num_entries] {
	uint8  name[16];	// Name of entry.
	uint32 location;	// Location in file of compressed data.
	uint32 size;		// Size of uncompressed data.
};

// The footer is located at the end of the file.  It is the last 8 bytes.
Footer {
	uint32 num_entries;	// Number of index entries in file.
	uint8  magic[4];	// Four characters, "JMP2"
};
User avatar
Sam67
Pyro
Pyro
Posts: 22
Joined: 2007-03-03, 14:22
Location: France

Re: File format specifications

Post by Sam67 » 2014-08-27, 09:56

Hi,
I know Z as a gamer not as a coder. Can you tell me why you need to have those files decode ?
Are planning to make a new mod for it are a brad new Z for another platform :?:
Thank you
I wish I knew the tin can who blew up the bridge.
Post Reply