Discussion:
cc65 compression technique optimizations?
(too old to reply)
Harry Potter
2019-10-09 14:58:38 UTC
Permalink
Hi! I am working on a compression technique for the C64 using cc65 and looking for some optimizations to speed up the code. Does anybody here have any optimizations that might work? I am willing to post some code snippets here upon asking, but the code is sloppy and poorly-commented. :(
Andreas Kohlbach
2019-10-09 18:55:43 UTC
Permalink
Post by Harry Potter
Hi! I am working on a compression technique for the C64 using cc65
and looking for some optimizations to speed up the code. Does anybody
here have any optimizations that might work? I am willing to post
some code snippets here upon asking, but the code is sloppy and
poorly-commented. :(
Yes, post some snippets please. I won't be able to help because I am a
lousy 6502 assembly coder but generally interested what you have done so
far.
--
Andreas

My random thoughts and comments
https://news-commentaries.blogspot.com/
Harry Potter
2019-10-09 19:03:12 UTC
Permalink
Post by Andreas Kohlbach
Yes, post some snippets please. I won't be able to help because I am a
lousy 6502 assembly coder but generally interested what you have done so
far.
--
Andreas
It is written in C using cc65. Here are two code snippets:
-------------------------
static unsigned sslz_getcomp (int pos, register unsigned char len)
{
register unsigned i2, j2; //register unsigned char k;
static unsigned char k, n, o;//=0;
static unsigned char comp, compa, bestcomp;
bestcomp=(len<<3)+2;
tmpcptr=&InBuffer[pos];
i=5;
if (len<=3) i=7;
if (len<=2) i=7;
j2=(len<=2?60:len<=3?600:7*1024);
if (pos<j2) j2=pos;
o=0;
for (i2=1; i2<=j2; ++i2) {
--tmpcptr;
if (len>=4) {
if (i2==1) {i+=3; k+=3;}
if (i2==250) {i+=4; k+=3;}
if (i2==1800) {i+=3; k+=3;}
}
j=i; n=0;
for (e=0; e<len; ++e) {
if (cin[e]==((unsigned char*)tmpcptr)[e]) {
sslz_tocomp[e]=1;
++n;
++j;
} else {
sslz_tocomp[e]=0;
j+=9;
}
}
if (j<bestcomp && n>=2) {
if (n>=2) o=1;
bestcomp=j;
//m=1;
sslz_offs=i2-1;
//memcpy (&sslz_best, &sslz_tocomp, sizeof(sslz_tocomp));
__asm__ (
"\tldx\t_buflen\n"
"\tdex\n"
"@aaa:\r\n"
"\tlda\t_sslz_tocomp,x\n"
"\tsta\t_sslz_best,x\n"
"\tdex\n"
"\tbpl\***@aaa\n"
);
}
}
sslz_comp=bestcomp;
return o;
}
-------------------------
j=0; y=&InBuffer[in+i];
for (k=0; k<108 && j<108; /*++k*/) {
if ((len!=2 && len!=3 && len<7) && j>=12) {j=108; break;}
m=0;
--y;
if ((unsigned)y<(unsigned)&InBuffer) {k= 108; break;}
if (cin[i]==*y) break;
if (j>=0) {
for (l=1;l<=j; ++l) {
//if (InBuffer[in+i-l-1]==InBuffer[in+i-j-1]) {
if (*y==y[l]) {
m=1; break;
}
}
}
if (m) {++j; continue;}
++j;
++k;
}
xcomp:
l2=in+i;
if (k<108 && j<108) {
po_offs[i]=k; //comp+=/*5-(k<4)*/(k<6?1:getnumbits(po_getnumlits(vz.InPos-buflen+i+1)));
if (len!=2 && len!=3 && len<7) comp+=EstimDist(k, po_getnumlits(in+i));
else comp+=EstimDist (k, po_getnumlits2(l2)); }
else {
po_offs[i]=-1;
if ((len!=2 && len!=3 && len<7)) x=po_writelit (l2, InBuffer[l2], &l);
else x=po_writelit1a (in+i, InBuffer[in+i], &l);
po_nl1[i]=x; po_nl2[i]=l;
comp+=EstimDist (x, l)+1;
}
}
------------------------------
Andreas Kohlbach
2019-10-10 19:50:35 UTC
Permalink
Post by Andreas Kohlbach
Yes, post some snippets please. I won't be able to help because I am a
lousy 6502 assembly coder but generally interested what you have done so
far.
--
Andreas
[...]

Thanks. My C knowledge is even rustier than that of assembly. I hope
somebody can help you. Keep us posted.
--
Andreas
Loading...