Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > WVL/Xenon's challenge!
2005-01-15 20:12
WVL

Registered: Mar 2002
Posts: 889
WVL/Xenon's challenge!

A small challenge for all coders out there.

first let me explain how i got here. As most of you will know i'm working on a c64 conversion of Pinball Dreams. And as some will know, i'm rather stumbling on the 64K memory limit. So I'm always puzzling and optimizing to free up some more memory.

This morning i got an idea to optimize the way the clipmap data is stored. (what is the clipmap, you might ask? it's a black/white map that describes where the ball goes behind objects on the table).

Now this clipmap is stored as a 40*64 charscreen (RLE-ed) and a charset (lucky for me, it fitted in $a1 chars).

The idea comes to letting go of putting the chars at n*8 memory position with n integer and using pointers to point to where the data is to be fetched. The pointers will not costs any memory themselves, as for speed i'm already using a 512 table (lo/hi) with numbers times 8.

;---------------------------------------

so here's my challenge to you all!

;---------------------------------------

try to fit all $a1 chars of this charset : http://www.interstyles.nl/Charset.prg into the minimum amount of bytes you possibly can!

the answer has to be in the following form :

-a pointer table, with $a1 pointers to the positions in the chardata
-a chardata bin, as small as possible.

ofcourse all the chars still have to be made from the pointer table and the bin. All the chars have to lie COMPLETELY inside the bin, don't assume the bytes before or after the bin take on certain values.

Winner gets a beer + a hug if winner is a girl ;-)

regards,

WVL/XENON, who's anxious to win the competition himself ;-)
 
... 38 posts hidden. Click here to view all posts....
 
2005-01-18 10:30
WVL

Registered: Mar 2002
Posts: 889
there are all kind of maps :) but the gravity-map is mostly unrelated to the clipmap.

RLE-ing a bitmap directly would not work. f.e. i would need at least 512(pixels high) pointers to all the RLE lines, which eats up 1024 bytes already. And i don't have any data yet in that case..

some more explanation about this :

the way i see it the best thing you can do is try to divide the screen up in blocks, so you have as close to 256 different blocks as possible. It turns out that chosing 8x8 blocks gives you $a1 different 'blocks', so imo dividing the bitmap into a charscreen is the most logical solution.

ofcourse the clipmap is completely optimized to take as best advantage as possible from this representation!
2005-01-18 11:09
Hoogo

Registered: Jun 2002
Posts: 103
If I count it correctly you currently have packed the chars into ~650 Bytes, 2560 Bytes for the charmap (but RLE'd, how much ist it exactly?) + 128 for pointers. Don't know the results for line-wise. 1024 for pointers + x.

Now it depends on how many different lines you have, how good lines can be puzzled, and how good each line can be compressed (how many changes between 0 and 1 there are each line).

And you can maybe use the same system not only for this clipmap, but can add some more bitplanes before compressing it. Depends on your other maps.
2005-01-18 12:12
WVL

Registered: Mar 2002
Posts: 889
some quick numbers..

compressed charset : 678 bytes
pointers to chars : 322 bytes
RLE-ed screendata+pointers : 1115 bytes

makes 2115 bytes total = $843

not bad for describing a 160*512 b/w bitmap (raw data = 10240 bytes). f.e. the same file as .gif is 4867 bytes.
2005-01-18 12:22
Hoogo

Registered: Jun 2002
Posts: 103
Is that gif somewhere to download? And what about the other maps?

Its really interesting :-)
2005-01-18 12:55
WVL

Registered: Mar 2002
Posts: 889
http://www.interstyles.nl/CLIP.gif

it looks a bit insane bcoz of all the RLE optimizations.
2005-01-18 15:04
Hoogo

Registered: Jun 2002
Posts: 103
Hm, a fast hack (I only removed duplicate lines) without puzzling and the simple counting of 0/1 gives 2.450 Bytes. I doubt that optimizations in the graphic, the puzzling and a fast dictionary compression could press that to less than 1.100 bytes... So this might only be of use if it is used for more than one map (2 maps will turn that from 0/1 to 0..3. That compresses poorer, but the 1024 Bytes pointer are only needed once).
2005-01-19 11:33
WVL

Registered: Mar 2002
Posts: 889
erh.. but then you have to do RLE decoding for every byte..
I only have to do RLE-decoding for every char (saves a lot of cycles) and then i can fetch data by a simple loop. Also my data is smaller ;)
2005-01-19 11:50
TDJ

Registered: Dec 2001
Posts: 1879
Quote: erh.. but then you have to do RLE decoding for every byte..
I only have to do RLE-decoding for every char (saves a lot of cycles) and then i can fetch data by a simple loop. Also my data is smaller ;)


Hmm .. normally people just brag about their 'data' being bigger ;)
2005-01-19 12:22
Cruzer

Registered: Dec 2001
Posts: 1048
Btw, how about enabling backwards fetching of char-gfx from the bin? This shouldn't take many more cycles if you make a dedicated routine for it. The highest bit of the address could indicate if it should be fetched backwards, so it wouldn't mean more lut-data.
2005-01-19 12:27
WVL

Registered: Mar 2002
Posts: 889
cruzer : that probably wont work very well in my code, that reads from 3 chars at the same time. It's a good idea, but unfortunately a no-no :)

the loop that uses the clipdata looks like :


clipoffset 
         ldy #0
cliploop
spritea1 lda $1000,x
char1    and $1000,y
point1a  sta spriteimage,x
spriteb1 and $1000,x
point2a  sta spriteimage2,x
spritec1 and $1000,x
point3a  sta spriteimage3,x
	 dex
spritea2 lda $1000,x
char2    and $1000,y
point1b  sta spriteimage,x
spriteb2 and $1000,x
point2b  sta spriteimage2,x
spritec2 and $1000,x
point3b  sta spriteimage3,x
	 dex
spritea3 lda $1000,x
char3    and $1000,y
point1c  sta spriteimage,x
spriteb3 and $1000,x
point2c  sta spriteimage2,x
	 beq point3c
spritec3 and $1000,x
point3c  sta spriteimage3,x
	 dex
         bmi endclip
         dey
         bpl cliploop
         lda #7
         sta clipoffset+1
         bne bigcliploop
endclip

char1/char2/char3 pointing to 3 different chars in the clipmap.

I was thinking of improving the search routine a bit, so it would also search in the bitmap-gfx for finding certain patterns...
Previous - 1 | 2 | 3 | 4 | 5 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Exploding Fi../Techn..
theK/ATL
Guests online: 106
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 Uncensored  (9.6)
7 Wonderland XIV  (9.6)
8 Comaland 100%  (9.6)
9 No Bounds  (9.6)
10 Unboxed  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 It's More Fun to Com..  (9.5)
7 Morph  (9.5)
8 Dawnfall V1.1  (9.5)
9 Onscreen 5k  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Nostalgia  (9.3)
4 Censor Design  (9.3)
5 Performers  (9.3)
Top Graphicians
1 Mirage  (9.7)
2 Archmage  (9.7)
3 Facet  (9.6)
4 Carrion  (9.6)
5 Pal  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.06 sec.