Qhimm.com Forums

Miscellaneous Forums => Scripting and Reverse Engineering => Topic started by: bspbsp on 2003-08-04 23:39:28

Title: How the LZS compression works?
Post by: bspbsp on 2003-08-04 23:39:28
As it mentioned in the readme,Ficedula's ficelzs uses Haruhiko compression as its default compression method.i want to know how it works on compression,but i am not able to read the delphi code of Cosmo.who can give me a copy of Haruhiko compression algorithm or a discription of it?Thanks. :)
Title: How the LZS compression works?
Post by: Srethron Askvelhtnod on 2003-08-05 02:16:20
Ficedula's LZS Compression Description (http://www.warwickcompsoc.co.uk/~ficedula/f2k3/docs/lzs.txt)

FiceLZS (http://www.warwickcompsoc.co.uk/~ficedula/f2k3/programs/ficelzs/ficelzs120.zip) (Ficedula's command-line app that compresses/decompresses LZS)
-Srethron
Title: How the LZS compression works?
Post by: bspbsp on 2003-08-05 07:38:36
many thanks!
but i have already read that document and it's about how to decompression,what i'm looking for is Haruhiko compression.Qhimm also have his own version in eight and garden,but it seems not effect as the Haruhiko compression.
Title: How the LZS compression works?
Post by: mirex on 2003-08-05 11:32:24
I think there was a thread about LZS compressions, and how to make them better ... wait a sec, i'll search . . . . here: FF7 Translation (http://forums.qhimm.com/viewtopic.php?t=1751&postdays=0&postorder=asc&start=0). Im not sure if it helps, but word "Haruhiko" is used at least 13 times there :D
Title: How the LZS compression works?
Post by: Srethron Askvelhtnod on 2003-08-05 22:35:10
bspbsp: Well, the idea was that you (theoretically) could reverse the decompression info given back into the Haruhiko compression scheme. As far as I can tell, enough info for that is in Ficedula's doc. You just have to reverse engineer something that was already reverse engineered. =P

I don't know what else to tell you. As a last resort you can try this (http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=haruhiko+compression).
-Srethron
Title: How the LZS compression works?
Post by: bspbsp on 2003-08-07 14:33:06
now i understand the Haruhiko compression that ficedula mentioned  is the original LZSS compression,thanks to mirex!
and to Srethron Askvelhtnod:also thanks to your google site! i have found some source codes there.may raise new questions if i have any
Title: How the LZS compression works?
Post by: mav on 2003-09-12 07:54:59
Yeah, but there's a diffrence between Haruhiko LZSS and FF7 LZSS alghoritm. I'm looking for Delphi source to compress files using FF7 LZSS alghoritm. Does anyone have some ? .

Edit: I've developed a tool that can compress and decompress them (finally ;)), and it works pretty well. Win32 app. Link:
http://mav.pix.pl/personal/Lzss.zip
Title: How the LZS compression works?
Post by: bspbsp on 2003-09-14 13:40:15
good news!!
i've found the differences between Haruhiko LZSS and the method SQUARESOFT used to compress their files.
this is a c source code about standard LZSS compression:
http://sprite.phys.ncku.edu.tw/NCKUtech/DCM/pub/DCM_CODE_ASM/lzss.c
then make some changes:
1.initialize the ring buffer with NUL chars instead of space(standard LZSS),both in encode() and decode().
2.add a dword at the head of the file indicating the length of the whole block,encoded or decoded,not so difficult,i think. :wink:
complete,now it works as a compressing method which SQUARESOFT uses
Title: How the LZS compression works?
Post by: Haruhiko on 2003-10-12 12:16:11
@bspbsp

What do you exactly mean with "2.". I don't understand, sorry.

When I get 32 bits from infile before decoding it, the decompressed file has the same size as the decompressed file produced by ficedulas lzs.exe.

When I put 32 bits to outfile before encoding the infile into it, it ends up with a different size as the original LZS file.
Title: How the LZS compression works?
Post by: mav on 2003-10-12 13:57:37
Bspbsp: Yes, i know this diffrences and they're applied to my program. If you want, you can use it, and I can send you a Delphi source eventually ;).
Title: How the LZS compression works?
Post by: bspbsp on 2003-10-14 14:25:11
to Haruhiko:
what i mean is add a length dword at the beginning of the file,you can add it during the runtime

to M4v3R:
i'm totally new to Delphi :lol:
if you can give me a C++ copy ,i'd very appreciate. :D
Title: How the LZS compression works?
Post by: mav on 2003-10-14 15:30:48
Here: Link (http://mav.pix.pl/personal/ff7_lzss.c). Hope this'll help ;).
Title: How the LZS compression works?
Post by: Haruhiko on 2003-10-14 17:49:49
Hm, I had modified lzss.c exactly this way by my own. But Encode() produces "garbage":

ENEMY000.LZS (512 Bytes) => Decode() => Encode() => ENEMY000.LZS (511 Bytes).
Title: How the LZS compression works?
Post by: mav on 2003-10-14 19:03:53
Hm... it worked well for me... Weird :P.
Title: How the LZS compression works?
Post by: Haruhiko on 2003-10-15 07:32:12
Can someone post the first four DWORDs (32 bits each) of the decompressed ENEMY000.LZS (hex-values) please? It's little-endian right? (MSVS .NET 2003 shows me some confusing values...  :isee:
Title: How the LZS compression works?
Post by: mav on 2003-10-15 09:22:37
And where can I find this enemy000.lzs ? :P.
Title: How the LZS compression works?
Post by: bspbsp on 2003-10-15 10:07:41
to Haruhiko:
if you have been using the lzss compression,you can try to delete the first DWORD of the ENEMY000.LZS,then decode/encode it,then add a new DWORD at the beginning of the new file(simply a length)
to M4v3R:
of course!! it's of great help! :D
Title: How the LZS compression works?
Post by: Haruhiko on 2003-10-15 18:50:02
Now I understand the way how MSVS displays binary files.

e.g.:

10 00 00 00 = 16 dec
00 10 00 00 = 10 00 = 4096 dec

:evil:
Title: How the LZS compression works?
Post by: mav on 2003-10-15 18:55:49
Indeed, and not only MSVS but this is a standard in saving integers to file. You have allways read them from right ;). But when you write programs to read this integers, program reads it in good way, so it's no problem :).
Title: How the LZS compression works?
Post by: Haruhiko on 2003-10-15 20:25:30
But I don't like it.  :P  :wink: