![]() |
![]() |
![]() |
#1 |
Registered User
![]() Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,515
|
In-Place Packers/Unpackers
Hi All,
For my project I'm currently using the Rob Northen packer/depacker because mainly it was the first one I found and it did a job. The problem with it is that it doesn't support inplace depack and some of the file I pack take a while to pack using WinUAE even with warp mode. Could anyone suggest a better packer to use that is pretty straight forward to use for packing data files only? It needs to support in place depack as I can get back 160Kb of ram if I do. I'll need the assembler unpack routine as well to swap out. Cheers, Geezer |
![]() |
![]() |
#2 | |
Going nowhere
![]() Join Date: Oct 2001
Location: United Kingdom
Age: 46
Posts: 7,327
|
Quote:
It uses quite a large ish stack space though, $180+ bytes to achieve it. There are 2 types of Propack, look at the header, it will say RNC and then after that a value of $01 or $02. |
|
![]() |
![]() |
#3 | |
Registered User
![]() Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,515
|
Quote:
Code:
*------------------------------------------------------------------------------ * PRO-PACK Unpack Routine (Compact Version) - MC68000, Method 1 * * on entry, * a0.l = start address of packed file * a1.l = start address to unpack file * (note: a1 cannot be equal to a0) * stack space required: $1DC bytes * * all other registers are preserved *------------------------------------------------------------------------------ |
|
![]() |
![]() |
#4 |
Registered User
![]() Join Date: Nov 2017
Location: Los Angeles
Posts: 27
|
It is quite common for packers which can decompress in-place to require the source to be aligned to the end of the buffer rather than the start.
i.e. if input size = $400 and output size = $1000 then the input data should start at $600 bytes in the buffer. Is that possibly a requirement of propacker? |
![]() |
![]() |
#5 |
Registered User
![]() Join Date: Mar 2016
Location: Australia
Posts: 730
|
As Galahad said, use method 2 and then you can de-pack in place.
As for packing speed, if you're cross building you can use this on your host machine: https://github.com/lab313ru/rnc_propack_source Creates 100% identical files to the RNC version run on the Amiga. |
![]() |
![]() |
#6 |
Going nowhere
![]() Join Date: Oct 2001
Location: United Kingdom
Age: 46
Posts: 7,327
|
I've figured it out, you're using the COMPACT version of RNC 1 to unpack.
You can use RNC 2 or RNC 1 so long as its the non COMPACT version, check out the zone, i've put what I use there ![]() |
![]() |
![]() |
#7 |
Natteravn
![]() Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,485
|
Another option besides unpacking in place would be to do it while loading. So you only need a small additional buffer, let's say 512 bytes, for the next block.
There are some disadvantages though: It is not as fast, because you have to fill the buffer from time to time, and it only works with packers which use a single data stream. Don't know if Propack falls into this category, but the LZ-packer, which I used for my last games, did not. Simple packers, like Bytekiller, are usually fine for this method. |
![]() |
![]() |
#8 |
Registered User
![]() Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,515
|
|
![]() |
![]() |
#9 | |
Registered User
![]() Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,515
|
Quote:
|
|
![]() |
![]() |
#10 |
Per aspera ad astra
![]() Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 2,241
|
Damn! I would have so much to say on the subject that I can't find the time to do it...
![]() |
![]() |
![]() |
#11 |
Registered User
![]() Join Date: Feb 2018
Location: London / UK
Posts: 73
|
For very fast on the fly data decompression I've used lz77 a lot.
There are sources here for decompression on 68k and also a C program for compression and decompression which works on any platform: http://privat.bahnhof.se/wb800787/da...h/lz77_v13.zip Recently I've started using lz48 though which is pretty much as fast and still simple but slightly better: http://www.cpcwiki.eu/forum/programm...herdecruncher/ |
![]() |
![]() |
#12 | |
Registered User
![]() Join Date: Sep 2004
Location: Brasil
Age: 45
Posts: 158
|
Quote:
![]() Those days i use ZX7, although the compressor is slower for big files and doesn't crunch so well than aplib (but never more that a few dozens of bytes); the zx7 decruncher is faster and smaller than aplib; support forward and backward decrunch, of course; and everything is open source, while we will never get the aplib cruncher sources. Another great feature is that the delta (extra bytes for decrunching in place) is guaranteed that is never bigger than 4 bytes; because that for decrunching in place, you only need to reserve in memory the decrunched file size + an extra long, load the crunched file at the end of this zone and decrunch ![]() And this extra long can be used as a flag for signaling that data was loaded or another thing that you like. ... and i forget, a nice feature is that it is super easy to modify the decruncher for adding a function that changes the calculation of the destination address. That is useful for making funny FX effects while you are decrunching data directly on the screen or if you want to sort your data in other way for getting a better compression rate (for example, storing screen as tiles or interleaved screens as independent planes, ...) Last edited by SyX; 11 April 2019 at 16:30. Reason: Last note about customizing the decruncher... |
|
![]() |
![]() |
#13 |
old bearded fool
![]() Join Date: Jan 2010
Location: Bangkok
Age: 52
Posts: 525
|
I'm assuming this is available in some shape or form on Amiga?
https://en.wikipedia.org/wiki/LZ77_and_LZ78 A personal favourite is the V.42bis variant of this compression modems used back in the day, where data which was already compressed passed through without performance loss, also relatively easy to implement in hardware. EDIT: Great, found it two posts above mine. ![]() ![]() ![]() Last edited by modrobert; 14 April 2019 at 04:05. |
![]() |
![]() |
#14 |
Moderator
![]() Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 4,781
|
Galahad and phx have given help, so all that is left is a timid logical reaction: In-place decompression so completely goes against the grain of what data compression is.
![]() Load-to-top-of-dest or even just a few bytes to spare for a load offset (instead of having to copying to/from the stack to slow things down, spending more bytes) allows maximum decompression speed, making your program appear 'zippier' ![]() |
![]() |
![]() |
#15 | |
Registered User
![]() Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,515
|
Quote:
|
|
![]() |
![]() |
#16 |
Per aspera ad astra
![]() Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 2,241
|
It's all about costs/benefits.
The simplest thing would be that the compressed data were at the beginning of the buffer containing the final destination. In this way the user should not worry about anything except to allocate the buffer, load the compressed data at start address and call the unpacker. But in this case, even neglecting a securyty zone and doing a pure LZ compression, it's a necessity to arrange the bitcoding for backward references access, which is certainly slightly slower than a forward access. For the forward case you can think of copying the data to the end of buffer (loss of speed in the unpacker) or load compressed data directly at the top (slightly complicating the logic of the loader). I have to quantify the loss of speed for a backward fetch bitcoding. |
![]() |
![]() |
#17 | |
Per aspera ad astra
![]() Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 2,241
|
Quote:
So if you use the 'bitchoice' token as a longword you can make a real in place decompressor (with backward fetch). The problem is that it would be rather slow in a bare 68k (no problem for 020+). But I can't think of any possibility to guarantee a safety margin of 4 bytes except by cutting off the compression at some point for pathological cases. In any case, for normal graphics and code data, it is rare to find yourself in such negative situations, especially if your compressor uses 'literal sequences' and therefore pure encoding cannot expand the stream much. |
|
![]() |
![]() |
#18 | |
Registered User
![]() Join Date: Sep 2004
Location: Brasil
Age: 45
Posts: 158
|
Quote:
Usually we try to consider every possibility, but sometimes the probability of happening every one of those are very low... not impossible, but well, we have tests for that reason. |
|
![]() |
![]() |
#19 | |
Moderator
![]() Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 4,781
|
Quote:
![]() ![]() There's absolutely zero complexity from adding an offset. Rather, someone who made the cruncher for you to use, would facepalm and ask, "What the hell were you thinking, decompressing to the same place?? Don't you even understand the basics of coding? Like, source/destination overwrite, ring a bell?" Anyway. Understand the tools you use. Load to an appropriate address. Decompress to destination. Simple & lets you select the best compression tool from all the compression tools there are, for your needs. Aahh..! Now I can go back to my timid self again. ![]() Last edited by Photon; 14 April 2019 at 00:53. |
|
![]() |
![]() |
#20 | |
Registered User
![]() Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,515
|
Quote:
Do I understand the basics of coding? yes I fucking well do! You should try going upward of 20,000 lines of assembler into a game under a time limit and things tend to get a bit complex. All I asked for was a bit of help with de-packing in place, the speed of which isn't important at this time, the reason was to save on memory (which I have thanks to Galahad). I have used the in place de-pack routine he put into the zone because as it stands I allocate ram, load the file to the start of that allocation and then de-pack using the same address, fair enough I could have loaded the file to an extra offset - but that adds some complexity. Go back to being your normal self for all I care, but keep things respectful and we'll get along just peachy. Last edited by mcgeezer; 14 April 2019 at 16:29. Reason: Typos and clarification. |
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Data Packers | bjadams | Coders. Blitz Basic | 3 | 21 September 2018 00:41 |
What are MOD Packers ? | chip | New to Emulation or Amiga scene | 9 | 20 August 2018 17:01 |
Runtime data unpackers similar to PPDATA/RTDD? | BarryB | support.Apps | 4 | 21 December 2012 19:25 |
A better place to be! | fatboy | Amiga scene | 10 | 29 September 2011 18:54 |
|
|