It is currently Mon Oct 20, 2014 5:46 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Crunching
PostPosted: Tue Jul 28, 2009 8:30 pm 
Offline
User avatar
 WWW  Profile

Joined: Thu Apr 03, 2008 2:49 pm
Posts: 277
Location: Antarctica
Hello

After some discussion with Colin and TMR at the Geekend, I thought I'd give pucrunch a try for packing some of my game data. I'm happy to report that it works fine on the trusty BBC, and has been very useful!

Code assembled with relatively few changes. If anyone is interested, I can let them have the source and instructions!


Top
 
 Post subject: Re: Crunching
PostPosted: Tue Jul 28, 2009 8:46 pm 
Offline
User avatar
 Profile

Joined: Wed Jan 09, 2008 7:30 am
Posts: 406
Aye aye, I was going to implement simple RLE for none active levels, but this sounds like it might give me more compression. Wht sort of ratios did you get with yout level data ?


Top
 
 Post subject: Re: Crunching
PostPosted: Tue Jul 28, 2009 10:12 pm 
Offline
User avatar
 WWW  Profile

Joined: Thu Apr 03, 2008 2:49 pm
Posts: 277
Location: Antarctica
I've only tried it on my tile graphics data, but from memory, went from 2048 bytes to 816 bytes. Not too shoddy.

I'll also crunch the level data itself but I'd imagine the ratio to be less since there is already a rather crude method of packing the level data.


Top
 
 Post subject: Re: Crunching
PostPosted: Tue Jul 28, 2009 11:43 pm 
Offline
User avatar
 Profile

Joined: Mon Jan 07, 2008 6:46 pm
Posts: 380
Location: Málaga, Spain
Interesting stuff Dave - I've been thinking myself about how I might compress a lot of graphics / maps, and had totally ruled out the likes of LZW on the Beeb.

I always planned on having a compressed sprite bank, and then, on each level, decompressing the whole lot to blanked screen memory, and extracting the sprites I need for that particular level... it seemed to be a reasonably good way to go, and the more data you have in your compressed block, the more benefit you get from the compression. Likewise, the maps would work in much the same way.

Well, if you have any examples to shove on the wiki, that'd be much appreciated :)


Top
 
 Post subject: Re: Crunching
PostPosted: Wed Jul 29, 2009 9:57 am 
Offline
User avatar
 WWW  Profile

Joined: Thu Apr 03, 2008 2:49 pm
Posts: 277
Location: Antarctica
RichTW wrote:
Well, if you have any examples to shove on the wiki, that'd be much appreciated :)


Sure, if I can figure out how to create a new wiki page - how do you do it?


Top
 
 Post subject: Re: Crunching
PostPosted: Wed Jul 29, 2009 10:51 am 
Offline
User avatar
 Profile

Joined: Wed Jan 09, 2008 7:30 am
Posts: 406
DaveF wrote:
RichTW wrote:
Well, if you have any examples to shove on the wiki, that'd be much appreciated :)


Sure, if I can figure out how to create a new wiki page - how do you do it?


Just add the name of your page to the main url

http://www.retrosoftware.co.uk/wiki/ind ... MyWikiPage

and it'll say the page isn't there yet and give you the option to edit it as a new page


Top
 
 Post subject: Re: Crunching
PostPosted: Wed Jul 29, 2009 12:38 pm 
Offline
User avatar
 WWW  Profile

Joined: Thu Apr 03, 2008 2:49 pm
Posts: 277
Location: Antarctica
Here ya go:

http://www.retrosoftware.co.uk/wiki/ind ... _Pu_Crunch

Sorry it's a bit rushed, me and Wikis don't seem to get on, but it should get the point across and prove how simple it is to get packing!


Top
 
 Post subject: Re: Crunching
PostPosted: Wed Jul 29, 2009 12:51 pm 
Offline
User avatar
 WWW  Profile

Joined: Wed Jan 09, 2008 10:23 am
Posts: 359
Location: Glasgow, Scotland
Interesting. I'll need to have a look and see how pucrunch compares with my own graphics specific compressor.

Kind regards,

Francis


Top
 
 Post subject: Re: Crunching
PostPosted: Thu Jul 30, 2009 10:39 am 
Offline
User avatar
 Profile

Joined: Sun Jun 28, 2009 11:37 pm
Posts: 55
I had a go with this using the screen data for Treasure Island and got some promising results.

The combined data for sprites, tiles and screens takes up just over 15K. After compression this was reduced to under 7K. Not bad at all.

Then, out of curiosity I tried to compress a mock-up of the title screen. It went from 20K to, get this, 2.5K :o

This got me thinking that the cruncher could be used to load in and display title screens quicker, especially on real hardware. I'd be prepared to knock up a quick demo if anyone's interested.


Top
 
 Post subject: Re: Crunching
PostPosted: Thu Jul 30, 2009 12:38 pm 
Offline
User avatar
 WWW  Profile

Joined: Wed Jan 09, 2008 10:23 am
Posts: 359
Location: Glasgow, Scotland
I've just tried the pucrunch against my own screen compressor, and it beats mine hands down!

The Mode 2 test screen that I used compressed from 20k to 9.5k using my compressor and down to 4.4k using pucrunch.

Kind regards,

Francis.


Top
 
 Post subject: Re: Crunching
PostPosted: Thu Jul 30, 2009 2:22 pm 
Offline
User avatar
 WWW  Profile

Joined: Thu Jan 10, 2008 7:45 pm
Posts: 472
Location: Treddle's Wharf, Chigley
Out of interest, how big is the actual decompressor?

This sounds potentially very handy for Retro Software loading screens.


Top
 
 Post subject: Re: Crunching
PostPosted: Fri Jul 31, 2009 6:42 pm 
Offline
User avatar
 Profile

Joined: Mon Jan 07, 2008 6:46 pm
Posts: 380
Location: Málaga, Spain
Maybe any compression algorithm experts can help me here, but one thing I don't understand about pucrunch is that it appears to implement two different methods of compression: run-length encoding and LZ77. But I was under the impression that RLE could be implemented by LZ77 anyway, so this seems wasteful.

As I understand it, the basis of LZ77 is that it's possible to insert a token at any point in the bitstream which contains two elements: a number of characters back in the bitstream, and a length. So if you have the string:
Code:
Mellow yellow

...this could be represented in LZ77 like this:
Code:
Mellow y{-7,5}


But if you only step back one character, and put a longer length, this effectively does RLE for free:
Code:
I'm freeeee!

becomes
Code:
I'm fre{-1,4}!


So have I missed something here? Is the RLE compression of pucrunch doing something different, or is it wasting code and compression ratio? It seems to me that you could probably write a better compression/decompression routine if you weren't wasting bits to specify whether a token was RLE or LZ77, not to mention having to implement different code to decompress each type.


Top
 
 Post subject: Re: Crunching
PostPosted: Fri Jul 31, 2009 7:05 pm 
Offline
User avatar
 Profile

Joined: Mon Jan 07, 2008 6:46 pm
Posts: 380
Location: Málaga, Spain
...and further more, LZ77 can even implement a more flexible type of RLE, with multibyte repeated sequences e.g.
Code:
Hahahahahaha!

becomes
Code:
Haha{-2,8}!

Perhaps the author wasn't aware of how to create this kind of data in his compression tool, or perhaps I've misunderstood his explanation?


Top
 
 Post subject: Re: Crunching
PostPosted: Fri Jul 31, 2009 7:14 pm 
Offline
User avatar
 WWW  Profile

Joined: Wed Jan 09, 2008 10:23 am
Posts: 359
Location: Glasgow, Scotland
Maybe his implementation of a separate RLE decoder is faster than the LZ77 one, but I'm just guessing.

Kind regards,

Francis


Top
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron