Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Digital Archaeology » Computer Arcana » Commodore » Commodore 8-bit » cc65 compression technique optimizations?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
cc65 compression technique optimizations? [message #387732] Wed, 09 October 2019 10:58 Go to next message
Harry Potter is currently offline  Harry Potter
Messages: 1301
Registered: March 2012
Karma: 0
Senior Member
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. :(
Re: cc65 compression technique optimizations? [message #387740 is a reply to message #387732] Wed, 09 October 2019 14:55 Go to previous messageGo to next message
Andreas Kohlbach is currently offline  Andreas Kohlbach
Messages: 1416
Registered: December 2011
Karma: 0
Senior Member
On Wed, 9 Oct 2019 07:58:38 -0700 (PDT), Harry Potter wrote:
>
> 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/
Re: cc65 compression technique optimizations? [message #387741 is a reply to message #387740] Wed, 09 October 2019 15:03 Go to previous messageGo to next message
Harry Potter is currently offline  Harry Potter
Messages: 1301
Registered: March 2012
Karma: 0
Senior Member
On Wednesday, October 9, 2019 at 2:55:44 PM UTC-4, Andreas Kohlbach wrote:
> 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\t@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;
}
}
------------------------------
Re: cc65 compression technique optimizations? [message #387753 is a reply to message #387741] Thu, 10 October 2019 15:50 Go to previous message
Andreas Kohlbach is currently offline  Andreas Kohlbach
Messages: 1416
Registered: December 2011
Karma: 0
Senior Member
On Wed, 9 Oct 2019 12:03:12 -0700 (PDT), Harry Potter wrote:
>
> On Wednesday, October 9, 2019 at 2:55:44 PM UTC-4, Andreas Kohlbach wrote:
>> 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:

[...]

Thanks. My C knowledge is even rustier than that of assembly. I hope
somebody can help you. Keep us posted.
--
Andreas
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Official FAQ comp.binaries.cbm (semimonthly posting)
Next Topic: FCUG "picnic" lunch - Sunday, Oct. 20
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Mon Jan 24 20:36:15 EST 2022

Total time taken to generate the page: 0.00688 seconds