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

This Month's Specials

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

   







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


 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old March 25th, 2019, 08:22 PM
MarkSheppard's Avatar

MarkSheppard MarkSheppard is offline
Lieutenant Colonel
 
Join Date: Jun 2005
Posts: 1,409
Thanks: 103
Thanked 645 Times in 429 Posts
MarkSheppard is on a distinguished road
Default Re: Deciphering the SHP format...

I think the decompression code works out as this:

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.

Code:
//---------------------------------------------------------------------------
// 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; ifar_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; ifar_right) far_right=pix_pos;
     }
     else // b!0 and r==1 ... read the next b bytes as color #'s
     {
       for (i=0; ifar_right) far_right=pix_pos;
     }
   } while (true); //exit this loop with break
   far_bottom=l;
}
Reply With Quote
The Following 2 Users Say Thank You to MarkSheppard For This Useful Post:
 

Bookmarks


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 04:16 PM.


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