Community
SCI Programming => SCI Development Tools => Topic started by: MusicallyInspired 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.
-
As I posted on VOGONS, try Enrico Rolfi's FotoSCIhop.
-
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.
-
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.
-
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.
-
MI, check the development forum on SHP.
-
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...
-
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.
-
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.
-
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.
-
Nice!! Gotta get a hold of those.
-
Same place as the other.
-
Enrico replied in the development forum, offering to provide information.
-
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
-
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.
-
oh really?
wow, i didn't expect sq2 to be AGI since it's text input and from the 80's
are you sure you're not talking about the remake?
I mean the original
if it was AGI i'm super surprised :P
-
AGI is the older engine that SCI replaced. It was Sierra's main development engine from the original King's Quest to the Manhunter games. As primitive as it seems now, it was ground breaking at the time. IBM commissioned the game from Sierra to showcase the expanded capabilities of their new PCjr. It had a parser interface and with a PCjr or Tandy it had a three voice with noise channel sound capabilities. From the very start AGI was designed to be portable and many AGI games were made available for other platforms. Sierra took advantage of any capabilities that those other platforms had, so Apple games had better music.
King's Quest 4 was the first SCI game and Sierra co-developed the game in both AGI and SCI. SCI was much more advanced than AGI with EGA graphics and full soundcard support.
For a more complete discussion on the differences between AGI and SCI see this thread: http://sierrahelp.com/forums/viewtopic.php?f=2&t=3965
You can see a list of the Si8erra AGI games here: http://agiwiki.sierrahelp.com/index.php?title=Sierra_Game_List
You can see a list of the Sierra SCI games here: http://sciwiki.sierrahelp.com/index.php?title=Sierra_Game_List
-
ohhh... lol
nm I'm just being a ditz
I was thinking about AGS when you said AGI lol :P
-
So I just realized that the SCI Studio VGA's SCI1 Pic editor has greyed out buttons for importing bitmaps and setting custom priority line positions (as well as rectangle and ellipse tools). I don't know how I missed this. None of them really work, though. I tried making a test build after enabling the buttons but the import function is seriously messed up. It puts a bunch of garbage on the picture instead of the actual image. I don't know if it's actually trying to draw it (SCI Companion style) or put the actual bitmap into the picture SCI1 style. I'm investigating what pushing this Import Bitmap window actually does and why it's screwing up....
I just wish I knew more about this. I notice that a few of the functions in Studio VGA fall back to SCI0 defaults even though there are SCI1 functions present. This could just be a matter of pointing events to the right function or adding a conditional statement somewhere in the source. Or it could be as easy as adding a simple flag or something somewhere. BC++ has a function to display "forms" of windows using its libraries that generate Windows(TM)-style...er...windows. Along with menus, tooltips, buttons, etc. You can look at all the buttons, edit their sizes, what they display, etc it's all very intuitive and point & click and you can go to the source for the function call that happens when a certain event takes place (like clicking on a button). This is all very interesting, I just wish I knew more about BC++.
-
Ok, I sort of got it working. I successfully imported a bitmap with the picture editor, but it created a series of strange drawing commands instead of the EXT: Draw Bitmap command that you see when you open a previously created SCI1 pic resource. However, the palette was all wrong. There doesn't seem to be a way to edit the palette of a SCI1 picture resource (the palette tools just use the default SCI0 palette system, more that Brian's meant to complete somehow obviously). Also, the program crashed when I tried to look at the list of draw commands. I haven't tried saving yet.
Step by step...
-
My attempts to save a customized Pic resource have failed (unsurprisingly). According to SCI Studio, I can successfully "save" a Picture resource (though the colours are all messed up), but each time I try to open it again the colours get a different mixture of "messed up". One of two possibilities, actually. So the only real thing stopping this up is proper palette support.
Then again, I tried to use my custom Pic resource in a game and the game would simply freeze (music, cursor, everything) once it got to that resource. SCI Viewer doesn't even recognize the format. It seems to understand that it's a Pic resource (probably from the extension? Or maybe the header) but it doesn't display an image. I'm combing through my new customized Pic resource now with a hex editor noting differences with official resources to see what I can see.
-
Perhaps some of the vector stuff was intended to have it be able to work with both SCI0 and SCI1 games, though most likely leftover from the previous version of Studio. Have you determined the status of the compiler?
-
I was wondering that myself. Yet it doesn't work in EGA either. Probably just straight up unfinished all around.
You mean the Script compiler? Haven't looked at it yet, no.
-
I am actually working on this, https://code.google.com/p/sci-palette-convertor/ (https://code.google.com/p/sci-palette-convertor/) the first step is to get the palette's down, pretty sure i am close, this should convert any palette FotoSCIhop extracts, and sv.exe extracts, if anyone has a palette file this will not load, please send it to me.
Erp, this program converts the *.pal files FotoSCIhop extracts from *.p56 and *.v56 into a Microsoft RIFF palette that you can use in corel to alter the *.v56 and *p56 files with FotoSCIhop.
-
I'm confused. Where's the download?
-
It is just the code. You either need to download each file or use SVN to create a local copy. If you don't have VS installed let me know and I can give you a binary. Keep in mind that at this point it is only the beginning of an SCI library.