Author Topic: How the LZS compression works?  (Read 13103 times)

bspbsp

  • *
  • Posts: 24
    • View Profile
How the LZS compression works?
« 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. :)

How the LZS compression works?
« Reply #1 on: 2003-08-05 02:16:20 »
Ficedula's LZS Compression Description

FiceLZS (Ficedula's command-line app that compresses/decompresses LZS)
-Srethron

bspbsp

  • *
  • Posts: 24
    • View Profile
How the LZS compression works?
« Reply #2 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.

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
How the LZS compression works?
« Reply #3 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. Im not sure if it helps, but word "Haruhiko" is used at least 13 times there :D

How the LZS compression works?
« Reply #4 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.
-Srethron

bspbsp

  • *
  • Posts: 24
    • View Profile
How the LZS compression works?
« Reply #5 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

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
How the LZS compression works?
« Reply #6 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

bspbsp

  • *
  • Posts: 24
    • View Profile
How the LZS compression works?
« Reply #7 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

Haruhiko

  • *
  • Posts: 24
    • View Profile
How the LZS compression works?
« Reply #8 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.

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
How the LZS compression works?
« Reply #9 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 ;).

bspbsp

  • *
  • Posts: 24
    • View Profile
How the LZS compression works?
« Reply #10 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

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
How the LZS compression works?
« Reply #11 on: 2003-10-14 15:30:48 »
Here: Link. Hope this'll help ;).

Haruhiko

  • *
  • Posts: 24
    • View Profile
How the LZS compression works?
« Reply #12 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).

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
How the LZS compression works?
« Reply #13 on: 2003-10-14 19:03:53 »
Hm... it worked well for me... Weird :P.

Haruhiko

  • *
  • Posts: 24
    • View Profile
How the LZS compression works?
« Reply #14 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:

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
How the LZS compression works?
« Reply #15 on: 2003-10-15 09:22:37 »
And where can I find this enemy000.lzs ? :P.

bspbsp

  • *
  • Posts: 24
    • View Profile
How the LZS compression works?
« Reply #16 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

Haruhiko

  • *
  • Posts: 24
    • View Profile
How the LZS compression works?
« Reply #17 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:

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
How the LZS compression works?
« Reply #18 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 :).

Haruhiko

  • *
  • Posts: 24
    • View Profile
How the LZS compression works?
« Reply #19 on: 2003-10-15 20:25:30 »
But I don't like it.  :P  :wink: