I found these functions buried in the SCI Studio VGA source this evening:
void DecodeSCI1Bits(U8 *inBits, U8 *outBits, int width, int height, U8 transCol, BOOL mirLp)
{
int i=0,x,y;
long endrow = 0,px=0;
U8 *p,*copyBuf;
px=0;
memset(outBits,transCol,width*height);
for(y=height; y!=0; y--) { /* loop by height */
endrow += width;
while (i < endrow) {
if(*inBits&0x80) {
if(*inBits&0x40) {
for(x=*(inBits++)&0x3f; x>0; x--)
i++;
} else {
for(x=*(inBits++)&0x3f; x>0; x--)
outBits[i++] = *inBits;
inBits++;
}
} else
for(x=*(inBits++); x>0; x--)
outBits[i++] = *(inBits++);
}
}
if(mirLp) {
copyBuf = (U8*)ssAlloc(width);
p = outBits;
for(int y=0;y<height;y++) {
memcpy(copyBuf,p,width);
int q=width-1;
for(int x=0;x<width;x++)
p[x] = copyBuf[q--];
}
ssFree(copyBuf);
}
}
and
U16 EncodeSCI1Bits(U8 *inBits, U8 *outBits, int xwidth, int xheight, U8 transCol, BOOL mirLp)
{
U16 width=xwidth,height=xheight;
U16 t=width*height;
U8 *outBitsX,*outStart=outBits;
U8 c, RunLength;
U16 o;
U16 X=0,Y=0;
while(Y<height) {
RunLength=0;
if(*inBits==transCol) {
do {
RunLength++;
inBits++;
X++;
} while(X<width&&transCol==*inBits&&RunLength<0x1F);
*outBits++ = 0xC0|RunLength;
} else if(inBits[0]==inBits[1]) {
c=*inBits;
do {
RunLength++;
inBits++;
X++;
} while(X<width&&c==*inBits&&RunLength<0x1F);
*outBits++ = 0x80|RunLength;
*outBits++ = c;
} else {
outBitsX = outBits++;
do {
RunLength++;
*outBits++ = *inBits++;
X++;
} while(X<width&&*inBits!=inBits[1]&&RunLength<0x1F);
*outBitsX = RunLength;
}
if(X>=width) {
X=0;
Y++;
}
}
return (U16)((int)outBits-(int)outStart);
}
DecodeSCI1Bits is used in the picrender class presumably for viewing picture resources, but EncodeSCI1Bits is only used in a class called impbitmap (Import Bitmap) for which there is no perceivable accessibility from the compiled binary. So the code to import and generate SCI1 backgrounds seems to be all there...but I'm not sure how to enable it (and even if you could good luck compiling it!) or how to take advantage of and learn from it to write a custom one yet...at the very least I hope I can learn something about the SCI1 picture resource format and structure in the hex.