.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > The Camo Workshop > WinSPMBT
Notices


Reply
 
Thread Tools Display Modes
  #1  
Old April 10th, 2021, 03:41 PM
MarkSheppard's Avatar

MarkSheppard MarkSheppard is offline
Lieutenant Colonel
 
Join Date: Jun 2005
Posts: 1,376
Thanks: 101
Thanked 618 Times in 409 Posts
MarkSheppard is on a distinguished road
Disk Re-Implementing SHPEd

I've been reimplementing SHP Ed functions in HTML5/Javascript as a way to modernize it and teach myself more programming skills.

However, I'm hitting a blank wall when it comes to the SHP decompression code.

I've got access to Fred's old SHPEd source code (see attached); and I think I've identified the decryption routine in SPF.cpp:

Quote:
//---------------------------------------------------------------------------
// read the shp data (for icon n) into the pseudo image
// this does not use the header info for lines, but reads
// until it finds KEY BYTE 88 Next byte 0.
void __fastcall read_SPicon_shp(FILE *inf, int n)
{
int ch,b,r,i,l=0;
long fpos;

fseek(inf,icon_add[n]+HEADER_SIZE,0);
pix_pos=0;
far_right=0;
far_bottom=0;
do
{
// read data and decode
ch=fgetc(inf);

//==== this section checks for end =====
if (ch==-1) break;// for last image this is end of shp
fgetpos(inf,&fpos);
if ((n<(icons-1)) && fpos>icon_add[n+1]) break;
// ==== end of end check ===========
r=ch%2;
b=ch/2;
if (b==0 && r==1) // a skip over
{
ch=fgetc(inf);
for (i=0; i put_pix(l,BACK_COLOR);
if (pix_pos>far_right) far_right=pix_pos;
}
else if (b==0) // end of line
{
++l;
pix_pos=0;
}
else if (r==0) // a run of bytes
{
ch=fgetc(inf); // the color #
for (i=0; i put_pix(l,ch);
if (pix_pos>far_right) far_right=pix_pos;
}
else // b!0 and r==1 ... read the next b bytes as color #'s
{
for (i=0; i {
ch=fgetc(inf);
put_pix(l,ch);
}
if (pix_pos>far_right) far_right=pix_pos;
}
} while (true); //exit this loop with break
far_bottom=l;
}
I'm thinking that it decodes as:

Read Character

R = Character % 2
B = Character / 2

###########

EOF Test:
If Character EQUAL TO -1 break, this is End of SHP.

##########

TEST ONE:

IF B equals 0 AND R equals 1
(I think Char = 1, which returns B = 0.5 and R = 1)

We have a huge string of blank pixels coming up.

Read the next character in the file. That character is the number of pixels that we paint as the transparent background color.

############

TEST TWO:

If B equals 0

End of SHP Line -- I think this used to mark the end of each row in the SHP file, i.e. incremeting from y = 0 to y =1 and so on.

###########

TEST THREE:

IF R equals 0

Read the next character in the file; that character is the color index number from the palette.

We then paint a number of pixels equal to "B" with that color we just grabbed.

##############

TEST FOUR:

IF B NOT ZERO and R EQUAL ONE

Read the next [b] bytes as color numbers?

Basically this says that the next B characters are direct image colors; probably used to save space when you have a lot of different characters, to avoid the use of space wasting couplets.
Attached Files
File Type: zip shpedsrc.zip (91.8 KB, 282 views)
Reply With Quote
  #2  
Old April 10th, 2021, 04:38 PM
Mobhack's Avatar

Mobhack Mobhack is offline
National Security Advisor
 
Join Date: Mar 2005
Location: Dundee
Posts: 5,955
Thanks: 464
Thanked 1,896 Times in 1,234 Posts
Mobhack is on a distinguished road
Default Re: Re-Implementing SHPHack

see the attatched document extracted from the VFX library documentation

cheers
Andy
Attached Files
File Type: zip SHPFILE.zip (9.1 KB, 285 views)
Reply With Quote
  #3  
Old April 10th, 2021, 09:40 PM

Karagin Karagin is offline
BANNED USER
 
Join Date: Apr 2020
Location: Killeen, TX
Posts: 473
Thanks: 432
Thanked 139 Times in 93 Posts
Karagin is on a distinguished road
Default Re: Re-Implementing SHPHack

Interesting...this sounds like fun and headaches but fun at the same time.
Reply With Quote
  #4  
Old April 11th, 2021, 09:53 AM
MarkSheppard's Avatar

MarkSheppard MarkSheppard is offline
Lieutenant Colonel
 
Join Date: Jun 2005
Posts: 1,376
Thanks: 101
Thanked 618 Times in 409 Posts
MarkSheppard is on a distinguished road
Default Re: Re-Implementing SHPHack

Quote:
Originally Posted by Mobhack View Post
see the attatched document extracted from the VFX library documentation

cheers
Andy
It took me a few moments to figure out what that was.

All this time, I thought SSI basically developed the SHP standard "in house".

I guess by the early 1990s, things had become complicated enough that for graphics libraries, it was simpler to buy the middleware graphics package from Miles Design?

...that makes sense the more I think about it, given that:

A.) SP1 and SP2 had silly video sequences to show off CDROM capability, and those must have been early Smacker/RAD video codecs.

B.) The 3 million and one different video cards and sound cards at the time, all with their own competing standards.
Reply With Quote
The Following User Says Thank You to MarkSheppard For This Useful Post:
  #5  
Old April 11th, 2021, 10:04 AM
DRG's Avatar

DRG DRG is offline
Shrapnel Fanatic
 
Join Date: Mar 2005
Location: GWN
Posts: 12,487
Thanks: 3,957
Thanked 5,690 Times in 2,810 Posts
DRG will become famous soon enough
Default Re: Re-Implementing SHPHack

The main point is Fred figured this all out just before we started converting SP2 into SP2WW2 and the work I did and feedback allowed him to iron out the final little issues and this is AFAIK the only game still actively using SHP and LBM and what we have now works and it "ain't broke" and there is little need for improving it although I have slightly tweaked it for this next release.....but only a tweak
__________________


"You are never to old to rock and roll if you are too young to die".--- What do you expect to be doing when you are 80?


https://www.youtube.com/watch?v=8kWt8ELuDOc
Reply With Quote
The Following User Says Thank You to DRG For This Useful Post:
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 11:34 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.