English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 04 November 2020, 17:58   #1
JoeJoe
Registered User
 
Join Date: Feb 2020
Location: Germany
Posts: 178
Question decruncing on the fly...

Hello everybody,

there is a tutorial or a piece of source code that briefly shows how to unpack onethefly data. With the packer "Shrinkler" or "Cranker" I can pack the raw data. Now I want to read this file piece by piece and unpack it immediately. The unpacking as a whole is no problem.

Thanks and greetings
JoeJoe
JoeJoe is offline  
Old 04 November 2020, 22:48   #2
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by JoeJoe View Post
there is a tutorial or a piece of source code that briefly shows how to unpack onethefly data.
Where?

Quote:
With the packer "Shrinkler" or "Cranker" I can pack the raw data. Now I want to read this file piece by piece and unpack it immediately.
You mean you have a limited buffer and want to read one chunk of the compressed stream after another while decompressing it?

You need a compression format which is represented as a single continuous stream. This works fine for simple compressors like Bytekiller, but it doesn't for LZ compressors, for example, which need a second stream for the literal buffer.

Some of my games use Bytekiller compression and I'm just reading one 512 bytes block after another into a buffer to decompress it on the fly. I have no experience with Shrinkler or Cranker, though.
phx is offline  
Old 05 November 2020, 06:53   #3
JoeJoe
Registered User
 
Join Date: Feb 2020
Location: Germany
Posts: 178
Sorry, I am looking for a tutorial. Here I have found a good code fragment. https://github.com/keirf/Amiga-Stuff/tree/master/inflate
JoeJoe is offline  
Old 06 November 2020, 11:26   #4
Keir
Registered User
 
Join Date: May 2011
Location: Cambridge
Posts: 682
Quote:
Originally Posted by JoeJoe View Post
Sorry, I am looking for a tutorial. Here I have found a good code fragment. https://github.com/keirf/Amiga-Stuff/tree/master/inflate
Is your aim to unpack in a small RAM buffer? That doesn't work for inflate as the output stream is your dictionary.

Or is it to hide the unpack time behind disk latency? This is tricky: You would need a pair of coroutines, one for disk, which yields after issuing a disk-read DMA, and one for the compressor, which would yield on a newly-implemented "yield symbol". I'm interested in doing this but had no time (or real purpose for it) so far. It's obviously non-trivial.
Keir is offline  
Old 06 November 2020, 21:38   #5
Bartman
Registered User
 
Join Date: Feb 2019
Location: Munich, Germany
Posts: 63
„Titanics Cruncher decrunches while loading...“
Bartman is offline  
Old 07 November 2020, 12:34   #6
WayneK
Registered User
 
Join Date: May 2004
Location: Somewhere secret
Age: 50
Posts: 364
It's quite tricky/unusual on Amiga, I know Mr.Spiv implemented a combined disk-loader/decrunch (almost certainly based on STC?) for the game "Elfmania" but 99.9% of games/demos simply load entire file then decrunch...
WayneK is offline  
Old 08 November 2020, 07:51   #7
Hannibal
Registered User
 
Join Date: May 2015
Location: Kirkland, Washington, USA
Posts: 56
We used a trackloader+decruncher in 3d demo II intro (which was dumb because it was practically a single-file intro). The design is straightforward: double-buffer the memory that track is loaded into, and while waiting for track N to load into buffer A, decode track N-1 from buffer B into the destination buffer, and the decompressor (which uses an algorithm that allows in-place decompression, and can store its' state and resume) runs through the newly loaded bytes.

In pseudo-code:
Code:
start DMA read of track 0 into track buffer 0
while(there are more tracks to read)
{
Wait for DMA track read finish
start DMA read of track N into track buffer (N&1)
Decode buffer track N-1 from track buffer ((N-1)&1) 
Decompress the decoded track N-1
N++
}
Wait for DMA track read finish
Decode buffer track N-1 from track buffer ((N-1)&1) 
Decompress the decoded track N-1
And for the in-place decompression, if you use something like LZ4, you can this by allocating a few bytes extra, and loading the compressed file at the end of the buffer. For example:
if you have a file that's 100000 bytes long when uncompressed, but 30000 bytes when compressed, I'd allocate, say 100008 bytes, and load the compressed file starting 70008 bytes into the buffer.
Hannibal is offline  
Old 08 November 2020, 09:50   #8
JoeJoe
Registered User
 
Join Date: Feb 2020
Location: Germany
Posts: 178
Thanks guys, very interesting contributions just the example with the trackloader and unpack. If you now adapt the trackloader to read a "DOS" file, it should be possible to load and unpack it.
JoeJoe is offline  
Old 13 November 2020, 18:10   #9
mr.spiv
Registered User
 
mr.spiv's Avatar
 
Join Date: Aug 2006
Location: Finland
Age: 51
Posts: 241
The original "Smarty and Nasty Gluttons" used track loader that decrunched a track while DMA was loading the next one.. Similar what Hannibal was describing. And if my memory is serving me right Elf-Mania had a similar loader (at least I got paid for providing the (de)compression program for that purpose )

The "new" Smarty and Nasty Gluttons has a hw banding FFS file loader that decrunches files per sector basic. Alas it has no DMA interleaving, which makes the loader slightly slow..
mr.spiv 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
What settings can be changed on-the-fly? Foebane support.WinUAE 8 31 January 2017 22:33
Bitplane removal on the fly gifgit request.UAE Wishlist 6 11 October 2015 20:31
Venus - The Fly Trap benas request.Old Rare Games 3 01 March 2015 18:36
Fly Harder CD32 killergorilla request.Old Rare Games 8 19 November 2010 20:56
Remove BlazeWCP on the fly? pintcat support.Apps 19 25 June 2010 21:10

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 23:00.

Top

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