Author Topic: The quest for custom SCI1 picture resources  (Read 14733 times)

0 Members and 1 Guest are viewing this topic.

Offline MusicallyInspired

The quest for custom SCI1 picture resources
« on: October 30, 2014, 08:57:42 PM »
So, I can't find any information on SCI1 (specifically SC1.0) picture resource files (*.p56, ie- SQ1VGA, KQ5Disk, PQ3, etc). I've been after something to create custom SCI1 backgrounds for a long time, but I've never found anything. So I decided to try and do something myself with what limited knowledge I have. I recall trying to look through the SCI Studio VGA source code for clues on the format and even comparing BMPs to P56s in a hex editor. Back then I had no luck because I had no idea what I was doing.

I still don't know what I'm doing. However, I'm just looking through comparisons of a P56 and its BMP equivalent and I've nailed down where the palette is store in each file. Beyond that I'm lost. Is there anybody here that has experience with reverse engineering file formats like this? Brian obviously knew how to create them as he did so when he created that first SCI Studio VGA demo game before he disappeared from the community. I know that NewRisingSun was a guru in this area (he helped me with some SCI0 sound/patch conversion tools way back), but I'm not sure how to get in touch with him or if he's even interested in this kind of thing anymore. I was thinking of posting on VOGONS to attract someone who might know (including NRS, as I know he's frequented there before, perhaps he still does).

Regardless, I'm still interested in attempting this myself. Any tips from anyone who's done this sort of thing? I've been looking up information on the BMP format to try and wrap my head around the random characters I'm seeing in a hex editor to spot patterns and such. What I really need, though, is some information on the picture resource format. I know there is information for SCI0 resources but not SCI1. Regardless, this information still might be useful as Sierra would have obviously followed some of the same formulas when upgrading their formats and updating the interpreter over time. Can anyone point me in the direction of anything like this? I've been Googling but all I've found are the SCI wikis (ScummVM's and SierraHelp's) and they don't really go into the nitty gritty detail I'm looking for, sadly. For all I know it could be as simple as taking the hex data that pertains to the image itself from a BMP and plopping it into the space between the header information and the priority/control data of a PIC resource (the visual hex data, wherever that is supposed to be in the hex structure of a PIC resource), but I doubt it.

Any help is appreciated. Even general advice in this area.
« Last Edit: October 30, 2014, 09:20:31 PM by MusicallyInspired »


Brass Lantern Prop Competition

Offline Collector

Re: The quest for custom SCI1 picture resources
« Reply #1 on: October 30, 2014, 11:59:48 PM »
As I posted on VOGONS, try Enrico Rolfi's FotoSCIhop.
KQII Remake Pic

Offline MusicallyInspired

Re: The quest for custom SCI1 picture resources
« Reply #2 on: October 31, 2014, 12:20:23 AM »
Looking forward to that source.

This bugs me, though. How is it that half a dozen different people can easily create programs to at least read and display these resources and I can't make heads or tails of it? I mean obviously  it's experience, but it still bothers me lol. Feels like my goal is just out of reach as none of these tools can do exactly what I want. Makes me feel like this is somewhat easy to learn if you have a brain and patience, but I'm missing something to get me started.
Brass Lantern Prop Competition

Offline Collector

Re: The quest for custom SCI1 picture resources
« Reply #3 on: October 31, 2014, 11:44:37 AM »
The biggest obstacle for me advancing my programming abilities is understanding file formats and and how to make heads or tails of their internal structure. Well that and there is something about RegEx that eludes me. I would love to be able to pick apart files and manipulate them. But like most things along these lines for me, I need to find a way to gain that initial foothold. Once I have gained some purchase, it is simply a matter of plugging away at it.
KQII Remake Pic

Offline gumby

Re: The quest for custom SCI1 picture resources
« Reply #4 on: October 31, 2014, 06:07:32 PM »
Hey, did you try Enrico's SCI Decoder VGA modded 1.1?  

http://gkpatches.vogons.zetafleet.com/er/download.php?file=scidecodervga1.1-src.zip

EDIT:  Interesting, based on reading the source code in SDV.C, it sure sounds like the PIC bitmaps are encoded just like the views in SCI0 (run-length encoded).  That makes a lot of sense, Sierra just reused their storage process for views and extended them to pics.
« Last Edit: October 31, 2014, 06:20:31 PM by gumby »
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Collector

Re: The quest for custom SCI1 picture resources
« Reply #5 on: October 31, 2014, 07:39:37 PM »
MI, check the development forum on SHP.
KQII Remake Pic

Offline MusicallyInspired

Re: The quest for custom SCI1 picture resources
« Reply #6 on: November 05, 2014, 06:14:47 PM »
Digging into the unfinished SCI Companion source I've found some interesting code for reading SCI1 PIC resources. However, most of it is commented out and attempting to open one in the compiled binary just fails. Seems unfinished. Too bad as troflip had said that he had it at least opening up SCI1 PIC resources at one point.

Man I really wish I knew more about programming. It just seems like such a long journey to learn all that I'd need to know to accomplish what I want to accomplish. I'm making rudimentary sense of some of the code I read, but it's all just so over my head and it's hard to decode what it's all actually accomplishing. I guess I really should just start from the beginning again if I want to get anywhere...
Brass Lantern Prop Competition

Offline MusicallyInspired

Re: The quest for custom SCI1 picture resources
« Reply #7 on: November 05, 2014, 08:47:49 PM »
I found these functions buried in the SCI Studio VGA source this evening:

Code: [Select]
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

Code: [Select]
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.
« Last Edit: November 05, 2014, 09:33:50 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline MusicallyInspired

Re: The quest for custom SCI1 picture resources
« Reply #8 on: November 06, 2014, 01:20:37 AM »
I've found the source code for the original DOS SCI Decoder programs among my old files! This should help immensely with figuring out the SCI1 PIC resource format as they are much less complex than those crazy Borland sources from SCI Studio VGA. Exciting!

EDIT: The source was double spaced which was really annoying. I reuploaded the ZIP with the double spaces removed.
« Last Edit: November 06, 2014, 01:01:49 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline Collector

Re: The quest for custom SCI1 picture resources
« Reply #9 on: November 23, 2014, 10:36:08 PM »
Hey, I got the source for TraduSCI 2.3 and I got most of it, including FotoSCIhop it to compile in VS with a little tweaking. According to Enrico Rolfi FotoSCIhop was originally written in VS, but ported to an enchantment version of Dev-Cpp for distribution.

Among other things were SCIDecoder SCI1.1 and his SCIResourceDumper.
« Last Edit: November 23, 2014, 10:51:52 PM by Collector »
KQII Remake Pic

Offline MusicallyInspired

Re: The quest for custom SCI1 picture resources
« Reply #10 on: November 24, 2014, 12:03:15 AM »
Nice!! Gotta get a hold of those.
Brass Lantern Prop Competition

Offline Collector

Re: The quest for custom SCI1 picture resources
« Reply #11 on: November 24, 2014, 01:21:26 AM »
Same place as the other.
KQII Remake Pic

Offline Collector

Re: The quest for custom SCI1 picture resources
« Reply #12 on: November 25, 2014, 05:22:03 PM »
Enrico replied in the development forum, offering to provide information.
KQII Remake Pic

Offline stateofpsychosis

Re: The quest for custom SCI1 picture resources
« Reply #13 on: December 02, 2014, 11:18:29 AM »
i wonder if there's a way to get those slick looking mac grey scale pics going in sci now

I always thought they looked better than colour but that's probably because I grew up on a Mac Classic II playing games like space quest II.

they seemed to use some sort of cross-hatching i think for the shades if I remember correctly

I wonder about how to go about mac compatibility in general for old macs. must have to use an older version of sci or something

Offline Collector

Re: The quest for custom SCI1 picture resources
« Reply #14 on: December 02, 2014, 12:19:17 PM »
SQ2 was an AGI game. ScummVM uses the old Sarien interpreter for their AGI support, which defaulted to the Amiga palette. ScummVM can play Apple versions of the AGI, too. As to SCI, we are pretty much stuck with the EGA palette. If by "cross-hatching" you mean the dithering, the DOS version already has that.
KQII Remake Pic


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.046 seconds with 22 queries.