View previous topic :: View next topic |
Author |
Message |
Tomaitheous Elder

Joined: 27 Sep 2005 Posts: 306 Location: Tucson
|
Posted: Mon Aug 06, 2007 7:14 am Post subject: Pucrunch for PCE |
|
|
Hello again,
Pucrunch is an LZSS variant compression scheme with Elias Gamma Code for control values ( http://www.cs.tut.fi/~albert/Dev/pucrunch/ ).
I converted the 65C02 standalone decompression source to PCE(CD). I added a few things like automatic bank rollover (source). So far the largest decompressed file is limited to 32k until I can add additional code for destination bank rollover.
On average, pucrunch does a fair bit better on compression than standard LZSS, but decompression is much slower. Also, pucrunch does *very* well with 4bit linear tile format, though you'd have to convert it to 4bpp composite on the fly to the VDC, after decompressing the stream.
I whipped up a working example. Everything needed to compile the cd image is there. Just run the example.bat from command prompt (not double click it).
Example.
Some quick numbers: the 57k tile set file compresses to 16k with LZSS and 10k with pucrunch.
(Note: I had to split the tile set into two files since the decompressed size was larger than 32k.)
-Rich
Edit: Fixed links _________________ www.pcedev.net |
|
Back to top |
|
 |
MooZ Visitor

Joined: 14 May 2002 Posts: 15 Location: France
|
Posted: Mon Sep 03, 2007 10:58 pm Post subject: |
|
|
Congrats!
All you need to do is add it to mkit  |
|
Back to top |
|
 |
nodtveidt Elder

Joined: 27 Dec 2004 Posts: 414 Location: Isla del Encanto
|
Posted: Mon May 19, 2008 4:53 am Post subject: |
|
|
So I finally found a need for this. Converting a digital comic for the PCE and am running very low on available RAM due to the large number of images that have to be present at any given time. These images are 256x160 pixels in size. I suppose I could just use pce_bmp.exe to spit out binary tile files, but that seems like overkill. Also, I can't quite make heads or tails of your assembly code, let alone get it to work with HuC.  _________________ Frozen Utopia
Retro gaming was never this cool. |
|
Back to top |
|
 |
Tomaitheous Elder

Joined: 27 Sep 2005 Posts: 306 Location: Tucson
|
Posted: Fri May 23, 2008 6:22 pm Post subject: |
|
|
Ring buffer is implemented in pucrunch now. You can decompress directly to I/O ports. Almost have it fully integrated with HuC. Anyone know of any C leve layer commands that will grab a #bank of a source label for an include? I rather cut out as much inline asm to keep it looking clean.
Edit: Nevermind on the far data get for C layer.
This works fine:
#pragma fastcall LZ_decmp( farptr _fbank:_fptr ); _________________ www.pcedev.net |
|
Back to top |
|
 |
ccovell Regular

Joined: 19 Dec 2005 Posts: 100 Location: Japan
|
Posted: Tue Jun 10, 2008 3:42 pm Post subject: |
|
|
Just a quick question: does this PuCrunch routine depend on the presence of CD RAM, even for the ring buffer? _________________ http://www.chrismcovell.com |
|
Back to top |
|
 |
Tomaitheous Elder

Joined: 27 Sep 2005 Posts: 306 Location: Tucson
|
Posted: Tue Jun 10, 2008 11:29 pm Post subject: |
|
|
Chris, the current version does use CD RAM but would pretty easy change it to use scratch pad ram. The version for HuC uses a 8k ring buffer, but that can also be changed to 512,1024,2048bytes and so on.
If you're interested, I can write a Mkit hucard version and then let you tailor it.
-Rich
PS: I also added automatic 4bit linear tile to PCE tile conversion in the ring buffer while writing to the VDC. It's slower, but gets you a little more savings. _________________ www.pcedev.net |
|
Back to top |
|
 |
ccovell Regular

Joined: 19 Dec 2005 Posts: 100 Location: Japan
|
Posted: Wed Jun 11, 2008 4:47 pm Post subject: |
|
|
That would be great, since for now, everything in Tongueman's Logic is uncompressed, and the first step towards getting it on CD is to compress the graphics. (Plus of course, I don't use HuC.) _________________ http://www.chrismcovell.com |
|
Back to top |
|
 |
ccovell Regular

Joined: 19 Dec 2005 Posts: 100 Location: Japan
|
Posted: Fri Sep 19, 2008 1:42 am Post subject: |
|
|
A quick question... I finally took a look at your PuCrunch example, and I don't see any ring buffer or port-writing code or functionality. Did you ever update the zip file that you have in your first post up there?
I checked out the code, and most of it can run from ROM with very little RAM use needed at all, right? I could get it working with ROM-only games, but I want to make sure I have the most updated version of your code first. _________________ http://www.chrismcovell.com |
|
Back to top |
|
 |
Tomaitheous Elder

Joined: 27 Sep 2005 Posts: 306 Location: Tucson
|
Posted: Fri Sep 19, 2008 3:32 pm Post subject: |
|
|
Here's the source: version 1.1 and version 1.2.
If you compare that against the original file I released, you should see the areas where I modified for a ring buffer. In ver 1.1 I made use of the fact that the logic address for the ring buffer is evenly aligned within $0000. You can reuse the same code if you align the buffer to $XX00, otherwise you'll have to write more complex code to do the wrapping of the buffer. Using a 512 byte LZ/ring buffer actually doesn't effect compression size much - the difference is usually pretty small. Even a 256 byte buffer gets decent results.
Version 1.2 has the option of linear format (packed pixel/chunky mode, whatever) to PCE's planar decode on the fly of the ring buffer. It just keeps track of the buffers size and when it's aligned to a tile or sprite, then it decodes and sends the data to vram. Linear pixels almost always compress better than PCE's planar format, but slows down the process some.
I was working on a Hucard version after you and Charles mentioned interest in it, but the point I was at is that you still need the decompression 'code' to sit in ram. Changing it to run completely in rom is a bit of a chore. _________________ www.pcedev.net |
|
Back to top |
|
 |
ccovell Regular

Joined: 19 Dec 2005 Posts: 100 Location: Japan
|
Posted: Mon Sep 22, 2008 1:04 pm Post subject: |
|
|
Thanks for the code examples, and after a few hours' work, I got version 1.1 to work... sort of. Version 1.2 is missing code (the subroutine "pixel_cnvrt", for one) so I'll stay away from that for now.
With v 1.1, I get it to decompress the gfx to VRAM, but after the first cycle of the ring buffer, the rest of the data has multiple errors. These errors are present whether I set the ring buffer to 8k or 512 bytes. For a ring buffer, does the input data have to be compressed differently?
How about including the whole directory that you were working from rather than just the decompression ASM? It would help in getting a better idea of how you call and use these new versions, as they are not forwards-and-backwards compatible. (Nor MagicKit-only compatible.) _________________ http://www.chrismcovell.com |
|
Back to top |
|
 |
Tomaitheous Elder

Joined: 27 Sep 2005 Posts: 306 Location: Tucson
|
Posted: Tue Sep 23, 2008 1:18 am Post subject: |
|
|
Chris,
Use -r XXXX to set the ring buffer size of the compressed file when using pucrunch.exe
So for a 512 byte ring buffer, use pucrunch -c0 -d -r512 file.in file.lzss
If you can post or PM me your test example, that would be better to work with than my current folder (I have a lot of embedded stuff for HuC, for Magickit ASM library interfacing). _________________ www.pcedev.net |
|
Back to top |
|
 |
Tomaitheous Elder

Joined: 27 Sep 2005 Posts: 306 Location: Tucson
|
Posted: Wed Sep 24, 2008 6:48 pm Post subject: |
|
|
Here's the planar to linear tile converter - http://pcedev.net//pce_pucrunch/plnr2lnr.rar
You can drag and drop the source file onto exe. The original file will be overwritten.
It only handles tiles. I can add support for sprites if needed. _________________ www.pcedev.net |
|
Back to top |
|
 |
|