English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 30 April 2020, 22:46   #1
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
Need Help: Packing and Unpacking

I need to pack and unpack data into my exe,for incoming game, never done before. What utils should I use? Any suggestion?
sandruzzo is offline  
Old 30 April 2020, 23:05   #2
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,160
RNC cruncher comes to mind. There are others too but that one has packers & unpackers from Windows & Amiga. Amiga unpack is pure asm & can do in-place decrunch.

A lot of games from the 1990 era used it.
jotd is offline  
Old 01 May 2020, 07:46   #3
JoeJoe
Registered User
 
Join Date: Feb 2020
Location: Germany
Posts: 177
I use the LZ4
JoeJoe is offline  
Old 01 May 2020, 08:00   #4
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
@JoeJoe

Any link to get stuffs?
sandruzzo is offline  
Old 01 May 2020, 09:42   #5
DanScott
Lemon. / Core Design
 
DanScott's Avatar
 
Join Date: Mar 2016
Location: Tier 5
Posts: 1,209
http://aminet.net/package/util/pack/RNC_ProPack
DanScott is online now  
Old 01 May 2020, 09:45   #6
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,160
in C: https://github.com/lab313ru/rnc_propack_source
jotd is offline  
Old 01 May 2020, 10:11   #7
JoeJoe
Registered User
 
Join Date: Feb 2020
Location: Germany
Posts: 177
unpack for 68k
JoeJoe is offline  
Old 01 May 2020, 12:38   #8
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
Thanks to all! First time working around pack and unpack on Amiga!
sandruzzo is offline  
Old 01 May 2020, 17:13   #9
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
I'll work around ProPack. First I have to pack my projects' datas.
sandruzzo is offline  
Old 15 May 2020, 09:26   #10
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
I use zlib. Portable and easy to use and can also do inmem de-/packing.
sparhawk is offline  
Old 07 September 2020, 15:59   #11
defor
Registered User
 
Join Date: Jun 2020
Location: Brno
Posts: 90
Quote:
Originally Posted by JoeJoe View Post
I use the LZ4

Hello. Hopefully someone can help me.

I wanted to use LZ4 in my current project. However I'm out of luck to make decompression to work.
I use 68k depack routine by Arnaud Carré (Leonard) (https://github.com/arnaud-carre/lz4-68k) - lz4_normal.asm, and to pack data I use original Win64 CLI (https://lz4.github.io/lz4/).
I figured out that I have to compress data using the legacy format ("-l" parameter), otherwise depack routine crashes. However, even then my data are not correctly depacked. I tried various command-line parameters (block sizes, compression values, ...) - no luck. I also tried LZ4X and smallz4 - same result.
What am I missing? What packer do you use?
defor is offline  
Old 07 September 2020, 17:17   #12
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Did you use --no-frame-crc? A while ago I was experimenting with lz4 and didn't have any problems with decompression.
a/b is offline  
Old 07 September 2020, 18:21   #13
defor
Registered User
 
Join Date: Jun 2020
Location: Brno
Posts: 90
Quote:
Originally Posted by a/b View Post
Did you use --no-frame-crc? A while ago I was experimenting with lz4 and didn't have any problems with decompression.
Yes, I did. Surprisingly the compressed file size is the same with or without crc check. Is it alright? I also tried various block sizes (from "-B4" to "-B7") and "-BI" option. I tried various lz4.exe versions, from 1.9.2 down to 1.7.3. Maybe I should go even lower?
I tried normal and fast LZ4 decrunch routines.
Just to be sure that I don't have bug in a different part of my code I compressed data (4bpl 320x192 image in this case) by RNC packer (Lab313 version) and used ProPack routine from Aminet -- everything is fine. So currently I'm rather inclined to use RNC instead of LZ4. In my case, the compression is slightly better and speed is comparable. Yet, it haunts me what am I doing wrong?
defor is offline  
Old 07 September 2020, 19:20   #14
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Hmm, ok.. Looking at his code now. He assumes there is no header, and a0 points to a packed data block. Now depending on compression flags (like CRC or no CRC) you have to skip a few bytes containing the header. With no CRC and no other flags that would be 11 bytes (4 magic ID, 3 frame descriptor, 4 block length in little-endian format). If you wanted to include the original file length (--content-size flag) it would be additional 8 bytes, for example (if I remember correctly).
Or alternatively, if you want to parse the frame descriptor you can figure out which parts of the header are present and which are not, and based on that skip as many bytes as needed.
a/b is offline  
Old 07 September 2020, 19:27   #15
Antiriad_UK
OCS forever!
 
Antiriad_UK's Avatar
 
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
Check out my github where I wrapped up various routines like LZ4, NRV2S, RNC, cranker, shrinkler, etc.

ConvertAssets.cmd shows the correct command line for the various utils.
IntroLibrary.s shows how to call the depack routines with a source in a0, dest in a1 type api.

https://github.com/jonathanbennett73/amiga-depack
Antiriad_UK is offline  
Old 07 September 2020, 19:43   #16
leonard
Registered User
 
leonard's Avatar
 
Join Date: Apr 2013
Location: paris
Posts: 133
Quote:
Originally Posted by defor View Post
I figured out that I have to compress data using the legacy format ("-l" parameter), otherwise depack routine crashes. However, even then my data are not correctly depacked. I tried various command-line parameters (block sizes, compression values, ...) - no luck. I also tried LZ4X and smallz4 - same result.
What am I missing? What packer do you use?
lz4_small.asm etc are working on raw LZ4 blocks, and not on LZ4 file header. To work with LZ4 file header ( so what lz4.exe produces ), just include https://github.com/arnaud-carre/lz4-.../lz4_frame.asm

As the comment says, it depacks data packed with this exact command line:

; Depack data produced by LZ4.exe command line:
; lz4.exe -9 --no-frame-crc <input_file> <output_file>

https://github.com/arnaud-carre/lz4-68k#lz4-frame

Hope it helps!

Last edited by leonard; 07 September 2020 at 19:51.
leonard is offline  
Old 07 September 2020, 19:59   #17
defor
Registered User
 
Join Date: Jun 2020
Location: Brno
Posts: 90
Quote:
Originally Posted by Antiriad_UK View Post
Check out my github where I wrapped up various routines like LZ4, NRV2S, RNC, cranker, shrinkler, etc.

ConvertAssets.cmd shows the correct command line for the various utils.
IntroLibrary.s shows how to call the depack routines with a source in a0, dest in a1 type api.

https://github.com/jonathanbennett73/amiga-depack

Thanks for your tip!
So obviously I was really just missing something important -- I haven't looked at "lz4_frame.asm" where it's already correctly implemented! Well, shame on me.
Thanks again. Your collection is quite handy.
defor is offline  
Old 07 September 2020, 20:01   #18
defor
Registered User
 
Join Date: Jun 2020
Location: Brno
Posts: 90
Quote:
Originally Posted by leonard View Post
lz4_small.asm etc are working on raw LZ4 blocks, and not on LZ4 file header. To work with LZ4 file header ( so what lz4.exe produces ), just include https://github.com/arnaud-carre/lz4-.../lz4_frame.asm

As the comment says, it depacks data packed with this exact command line:

; Depack data produced by LZ4.exe command line:
; lz4.exe -9 --no-frame-crc <input_file> <output_file>

https://github.com/arnaud-carre/lz4-68k#lz4-frame

Hope it helps!

Yes, at last I noticed my mistake when browsing through Antiriad's code. I was so focused on fastest/normal/smallest source code files that I completely missed importance of lz4_frame.s!
Thank you all for helping me.
defor is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
original packing pics of Rasterbike elcayon request.Other 0 19 January 2018 18:22
ACA500 unpacking error 3? TjLaZer support.Hardware 1 03 October 2015 17:50
Unpacking of Multiple .gz files andyhants support.Apps 4 17 March 2014 03:16
LZX 1.21 packing..... BarrySWE support.Apps 17 31 October 2005 15:00
LZX unpacking??? Medvind support.Apps 25 27 November 2002 12:33

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:58.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.13693 seconds with 15 queries