XeNTaX Forum Index
Forum Home Tools Blog GFFC MultiEx
It is currently Fri Sep 03, 2010 6:18 am

All times are UTC + 1 hour


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Worms2 file format and Hachoir program
PostPosted: Mon Jan 02, 2006 2:12 pm 
Offline
n00b

Joined: Mon Jan 02, 2006 1:42 pm
Posts: 11
Hi,

I'm the author of the software Hachoir. This program aims to split files into chunks like MultiEx does with game files. You may try it, it's a free ("libre") software under GPL licence and written in Python language.

I'm writing to you because I'm trying to read Worms2 game files (.dir files), and I don't understand Sprite pixels encoding. Hachoir is able to read most important informations from Images and Font, but can not read Sprite data. For Sprite (animations), it can read color palette, number of frame, and frame informations : (x,y) and (width, frame).

Ask me if you need help to run the Hachoir, and if you just want file format. And can also send you DIR example file.

Haypo


Top
 Profile  
 
 
 Post subject:
PostPosted: Mon Jan 02, 2006 2:44 pm 
Offline
Site Admin
User avatar

Joined: Wed Jan 15, 2003 6:45 pm
Posts: 7745
Location: Dungeons of Doom
Hi!

Nice program you have there! It's a layout especially suited for programmers! We should talk, because it may be, from the look of the screenshots, that there might be a MultiEx script<->Hachoir conversion routine possible. :)

_________________
Game Request Rules
Game File Format Central
Add your file formats there now! 1000s of formats!


Top
 Profile  
 
 
 Post subject:
PostPosted: Mon Jan 02, 2006 2:47 pm 
Offline
n00b

Joined: Mon Jan 02, 2006 1:42 pm
Posts: 11
Ok, here are the command to test the Hachoir with a Worms2 dir file :
Code:
svn co svn://svn.berlios.de/happyboom/haypo/hachoir/trunk hachoir
cd hachoir
wget http://www.haypocalc.com/tmp/Gfx.dir
./hachoir.py Gfx.dir

Double clic on field "resoures". You will see :
* Sprite from res[0] .. res[589]
* Image from res[590] .. res[712]
* Font from res[713] .. res[739]

Haypo


Top
 Profile  
 
 
 Post subject:
PostPosted: Mon Jan 02, 2006 2:49 pm 
Offline
n00b

Joined: Mon Jan 02, 2006 1:42 pm
Posts: 11
Mr.Mouse wrote:
We should talk

Here my addresses:
http://www.haypocalc.com/wiki/Victor_St ... _contacter

Mr.Mouse wrote:
there might be a MultiEx script<->Hachoir conversion routine possible. :)

Yep, sure, it's always possible.

Haypo


Top
 Profile  
 
 
 Post subject:
PostPosted: Mon Jan 02, 2006 3:08 pm 
Offline
VVIP member
VVIP member
User avatar

Joined: Wed Jun 30, 2004 3:01 pm
Posts: 533
Location: Aussie-Land
Hi mate,

Sure, we would be happy to help :) . I took a look at your program - I like it a lot - it is definately something that is benificial and I wish you the best with it.

I don't know how much assistance I will be able to provide, considering the file you request is image/animation based, but I will definately help out as much as possible. I know Mr Mouse would be similar in this.

If you could provide us with the specifications you have so far, it would definately be a help, and any files you could provide would be excellent - maybe just zip up a few things and send it over - we will do our best to help you out wherever possible.

Thanks, keep up the excellent work with your program!

WATTO
watto@watto.org
http://www.watto.org

_________________
Game Extractor - Program to read and write hundreds of game archives.
REQUEST RULES - Read before posting a game request.


Top
 Profile  
 
 
 Post subject:
PostPosted: Mon Jan 02, 2006 3:34 pm 
Offline
n00b

Joined: Mon Jan 02, 2006 1:42 pm
Posts: 11
Try to read source code of Worms2 plugin:
http://svn.berlios.de/viewcvs/happyboom ... iew=markup

Palette is a color palette with RGB colors:
http://svn.berlios.de/viewcvs/happyboom ... iew=markup

For Worms2, they are a few classes:
- Worms2_Dir_File: Just call Resource (1st level)
- Resource: One resource (size + data) (2nd level)
- Sprite, Font, Image: differents resource type (3rd level)
- ImageData, MysteriousHeader, SpriteFrame: informations (4th level)

Just read __init__ methods, and especially "read()" functions which have prototype:
Code:
def read(identifier, description, (type, arg1, arg2, ...))


Haypo


Top
 Profile  
 
 
 Post subject:
PostPosted: Mon Jan 02, 2006 5:06 pm 
Offline
Site Admin
User avatar

Joined: Wed Jan 15, 2003 6:45 pm
Posts: 7745
Location: Dungeons of Doom
haypo wrote:
Mr.Mouse wrote:
We should talk

Here my addresses:
http://www.haypocalc.com/wiki/Victor_St ... _contacter

Mr.Mouse wrote:
there might be a MultiEx script<->Hachoir conversion routine possible. :)

Yep, sure, it's always possible.

Haypo


I'll be in touch. :D

_________________
Game Request Rules
Game File Format Central
Add your file formats there now! 1000s of formats!


Top
 Profile  
 
 
 Post subject:
PostPosted: Mon Jan 02, 2006 11:41 pm 
Offline
VVIP member
VVIP member
User avatar

Joined: Wed Jun 30, 2004 3:01 pm
Posts: 533
Location: Aussie-Land
I think i understand some of this - it was a bit confusing at first because the source on the webpage you gave above is not the same as the source of your program, and in fact the website one looks like it is missing a few lines.

Anyway, at the moment I see it as something like this...

Code:
+---------------+
| Worms 2 *.spr |
+---------------+

4 - Header (SPR + (byte)26)
4 - File Size
X - Filename (null)
4 - Unknown Constant (5292040)

// for (81)
  1 - Red
  1 - Green
  1 - Blue
 
1 - Unknown (174)
2 - Number Of Flags (1/2)
8 - null

// for each flag
  4 - Flag

4 - null
4 - Unknown Constant (7428)
2 - null

2 - X Position ? (0)
1 - null
2 - Y Position ? (1)
2 - Image Width
2 - Image Height
2 - Number Of Frames
1 - null

// for each frame
  2 - Size Of Control Characters?
  1 - Unknown
  2 - Unknown
  2 - Unknown
  2 - Unknown
  2 - Unknown
  1 - Size Of Changed Data?
 
2 - Extra Size To Make The Complete File
 
// for each Changed Block
  X - Data For The Change
  1 - null


It is a bit of a mix of things, so let me hopefully explain some of it here. And I know its alittle rough and whatever - I havn't really been strict in documenting it correctly at this point in time.

I see several possibilities. ..

1. There are several frames, and the lower part of the file it like a script that tells the pixels that are to be changed with each frame. Each "script" block is terminated with a null byte, so if there are 36 nulls (as in the file I was looking at - arrowdnb.spr), there are 36 frames.
2. The sprite is just a single image, because the lower part of the file has the same number of bytes as (width-X * height-Y) - but this could be just coincidental
3 - If you add up the values in the loop labled "Size Of Control Characters" and "Size Of Changed Data" for each of the "frames", you get the size of the data following the "frames" directory, so maybe these 2 fields both somehow reflect things that I used for the description names
4. The other 2-byte field in the "frames" directory are probably just as before - X,Y,W,H

I see the whole thing being a little like a GIF animation image - you would start off with 1 single frame, and then for each frame following you only store the changed pixels rather than each frame in its completeness.

Hopefully some of this helps - you might be able to make some suggestions or something based on whatever you know about the format or the game.

Like I said - hope it helps!

WATTO
watto@watto.org
http://www.watto.org

_________________
Game Extractor - Program to read and write hundreds of game archives.
REQUEST RULES - Read before posting a game request.


Top
 Profile  
 
 
 Post subject:
PostPosted: Tue Jan 03, 2006 1:34 am 
Offline
n00b

Joined: Mon Jan 02, 2006 1:42 pm
Posts: 11
friendsofwatto wrote:
I think i understand some of this - it was a bit confusing at first because the source on the webpage you gave above is not the same as the source of your program, and in fact the website one looks like it is missing a few lines.

You speak about Hachoir's source code? There are a lot of versions. Last stable release is 2005-12-28. But most interesting version is the last one : you have to use SubVersion (works like CVS, do you know it?).

I worked a lot with lodesi (a friend) on Worms2 file format. Here is my informations about the format.
Code:
+---------------+
| Worms 2 *.spr |
+---------------+

4 - Header (SPR + (byte)26)
4 - File Size
X - Filename (null)
1 - Bits / pixel (bpp=8)
1 - Unknow constant (192 for sprite or 128 for others resources)
2 - Number of colors (nb_colors)

// for (nb_colors)
  1 - Red
  1 - Green
  1 - Blue
 
2 - Number of mysterious headers
2 - null ?
// for (nb_colors)
  2 - a ??? (a=0 ?)
  2 - b ??? (b=0 ?)
  2 - c ??? (c=0 ?)
  2 - d ???
  2 - e ??? (e=0 ?)
  2 - f ???

2 - X
2 - Y
2 - Image Width
2 - Image Height
2 - Number Of Frames

// for each frame
  1 - a ???
  1 - b ???
  1 - c ???
  2 - X
  2 - Y
  2 - Width
  2 - Height
 
X - ***DATA***
1 - Separator (sep=26)


Here is the data of a picture: 640x480 pixels, 80 color, only one frame. Can you help me to understand which compression method was used?
Code:
   0: 13 80 01 C5 00 80 01 BD 81 A8 C7 82 6A FF 82 96
  16: FF 84 27 4D 84 D8 FF 85 28 FF 86 A6 4D 87 49 FF
  32: 87 B7 FF 86 BB 4D 87 52 FF 87 AE FF 86 CC 4D 87
  48: 57 FF 87 A9 FF 86 DA 4D 87 5C FF 87 A4 FF 86 E6
  64: 4D 87 5F FF 87 A1 FF 86 F2 4D 87 64 FF 87 9C FF
  80: 86 FB 4D 87 65 FF 87 9B FF 87 04 4D 87 68 FF 87
  96: 98 FF 87 0B 4D 87 6A FF 87 97 FF 87 13 4D 87 6C
112: FF 87 FF FF 82 26 4D 87 6E FF 87 FF FF 82 2A 4D
128: 87 6F FF 87 FF FF 87 91 30 87 E3 3A 87 70 FF 87
144: 90 FF 87 28 1E 87 71 FF 87 FF FF 82 36 4D 87 72
160: FF 87 FF FF 82 39 4D 87 74 FF 87 FF FF 82 3C 4D
176: 87 75 FF 87 FF FF 82 3E 4D 87 76 FF 87 FF FF 82
192: 40 4D 87 77 FF 87 FF FF 82 42 4D 87 77 FF 87 FF
208: FF 82 44 4D 87 78 FF 87 FF FF 82 45 4D 87 79 FF
224: 87 FF FF 82 46 4D 87 7A FF 87 FF FF 82 47 4D 87
240: 7B FF 87 FF FF 82 47 4D 87 7B FF 87 FF FF 82 48
256: 31 80 00

Ideas about "changed pixels" is interresting. I will check it after understanding basic picture encoding :-)

Haypo


Top
 Profile  
 
 
 Post subject:
PostPosted: Tue Jan 03, 2006 2:47 am 
Offline
VVIP member
VVIP member
User avatar

Joined: Wed Jun 30, 2004 3:01 pm
Posts: 533
Location: Aussie-Land
Yeah, I was referring to the source for that program. I kinda know what CVS etc is and how it works, but i've never really used it. Never mind, thanks for completing the specs for me :)

I will take a look at the sample image you draw above - see if I can pick something out of it. It would have to be very good compression if thats a full 640x480 image!

Some common image compressions are based on RLE encoding - basically just replacing duplicates with a control character that says "repeat X times". For example, instead of actually storing the hex FF FF FF... FF 640 times (if the first line was all the same color), it would just write something equivalent to 640 FF - thus using 2 bytes instead of 640 bytes. Chances are the compression would be like this, but I am still amazed at the size of the compressed data. If it only stores the "changed data" like I initially thought, then compression could be quite good because there would be many lines that are just empty with the same value (like all FF's or something), indicating that this data was the same as the previous frame - that would compress heaps, as in my above example. I know they did this kind of thing in The Sims image sprites (SPR_SPR2).

If you want to read up about RLE encoding - the best place to start would be googling about the RLE compression in BMP images - BMP images are really easy to learn, and there are heaps of resources on the net about them. It would probably be a bit advanced to look at the specs for the The Sims sprites, but it you want to you can take a look - the website can be found on SourceForge - its called something like The Sims Technical Resource.

Good luck. I will see whether I can determine anything from the hex you posted.

WATTO
watto@watto.org
http://www.watto.org

_________________
Game Extractor - Program to read and write hundreds of game archives.
REQUEST RULES - Read before posting a game request.


Top
 Profile  
 
 
 Post subject:
PostPosted: Tue Jan 03, 2006 5:17 am 
Offline
n00b

Joined: Mon Jan 02, 2006 1:42 pm
Posts: 11
haypo wrote:
Here is the data of a picture: 640x480 pixels, 80 color, only one frame. Can you help me to understand which compression method was used?

HEY! The picture is 640x28 pixels, not 640x480 ... sorry. I think that it's possible to store 640x28 in 259 bytes ;-)

Haypo


Top
 Profile  
 
 
 Post subject: Hi there.
PostPosted: Tue Jan 03, 2006 6:37 am 
Offline
VVIP member
VVIP member
User avatar

Joined: Mon Oct 24, 2005 8:52 am
Posts: 411
Location: Sweden
Im sorry to interupt this. but i dont think it is possible
to store a 640x28 picture in just 259 bytes. if its not totally black
or just 1 color. not even with a very good compression.

It wouldnt just work, too much information have to be discarded.

anyone agree with me , or am I the party-destroyer here to today? =(


Top
 Profile  
 
 
 Post subject: To explain.
PostPosted: Tue Jan 03, 2006 6:47 am 
Offline
VVIP member
VVIP member
User avatar

Joined: Mon Oct 24, 2005 8:52 am
Posts: 411
Location: Sweden
To explain what i mean, i made a very simple 1 bitplane picture in
640x28 and using GIF (LZW compression , which is far better than RLE encoding), and i dont even think that "changed data" compression
will achive such incredibly low bitrates.

=o


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
 
 Post subject: Cheers again.
PostPosted: Tue Jan 03, 2006 7:01 am 
Offline
VVIP member
VVIP member
User avatar

Joined: Mon Oct 24, 2005 8:52 am
Posts: 411
Location: Sweden
Something interesting, though. when restructuring the data of the above "640x28" picture it looks like this.

138001
C50080
01BD81
A8C782
6AFF82
96FF84
274D84
D8FF85
28FF86
A64D87
49FF87
B7FF86
BB4D87
52FF87
AEFF86
CC4D87
57FF87
A9FF86
DA4D87
5CFF87
A4FF86
E64D87
5FFF87
A1FF86
-------
etc etc
last block
318000


notice how the numbers are made in 3 byte blocks.
the middlebyte are almost always FF or 4D
and the last byte is 80 or over up to 87.

first block 138001
last block 318000

also some strange similarity.

I dont know what this meens, but i thought it could help you
in some odd way =o


Top
 Profile  
 
 
 Post subject:
PostPosted: Tue Jan 03, 2006 1:26 pm 
Offline
VVIP member
VVIP member
User avatar

Joined: Wed Jun 30, 2004 3:01 pm
Posts: 533
Location: Aussie-Land
640x28 - that sounds much nicer :)

In regards to storing this amount of data in the small number of bytes - it could still be possible if the image is mostly a single color, or a transparency (as I suspect is probably the case).

In regards to the arrangement in 3-byte groups - that could obviously map directly to a pixel encoding like RGB or a bit-mapped variation to include an alpha. However, it is probably not the case (i also think you said that there is a palette, which means this would almost definately be wrong). My guess at the moment is that these "middle" values would be the control characters for an RLE-like compression, and the bytes either side could be some grouping of pixel values.

Thanks for putting forward some ideas - i would be interested to see whether the "middle" byte you found actually means something!

WATTO
watto@watto.org
http://www.watto.org

_________________
Game Extractor - Program to read and write hundreds of game archives.
REQUEST RULES - Read before posting a game request.


Top
 Profile  
 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group