Posted: Sun Jul 02, 2006 1:41 pm Post subject:
New about SHP format (TS/RA2/YR)
Yesterday I have found out an interesting thing
After 6 hours disassembling GAMEMD.EXE
Frame info header new declaration:
typdef struct tagSHPFRAMEINFO
{
WORD wX
WORD wY;
WORD wDX;
WORD wDY;
BYTE byFlags;
BYTE byAlign[3];
COLORREF clrTransparent;
DWORD dwRes;
DWORD dwOffset;
} SHPFRAMEINFO;
byFlags only ONE byte (Not four)
it can be: 0, 1, 2, 3
File with byFlags == 2 for example RADARY.SHP (ra2md.mix->sidec02md.mix)
SHP Builder 3.35 don't show it correct
When byFlags == 2 in each line first two bytes are width of line
Another interesting thing - clrTransparent
maybe it is transparent color
dwRes looks really reserved QUICK_EDIT
Also Known As: banshee_revora (Steam) Joined: 15 Aug 2002 Location: Brazil
Posted: Sun Jul 02, 2006 3:50 pm Post subject:
@Yuri06: The guy really has some cool info. And it can be used on any SHP related tool. So, he did post it in the correct place.
@C&CK: Very interesting stuff. I've tested the radar file that you mentioned, and you are right. XCC displays it in a better way than OS SHP Builder does.
byFlags: That's the compression type of the frame. I was aware of the compression 1 and 3. The 0 works like 1. But I never saw the two before. So, as you are saying, the 2 works similarly to the compression 3. But are you sure that the first two bytes are really the width of the line? I'm asking that, because, with compression 3, the first 2 bytes are the width of the line. So, it's like... the line data starts on byte 3.
byAlign: I'd like to know how this stuff works out. I know that some 'TS' files from RA2.mix uses different values for it. OS SHP Builder even has a special treatment for them, treating them as compression 3.
Code:
if (SHP.Data[x].header_image.compression = 3) or
(SHP.Data[x].header_image.compression = -859045885) then
I'll take a new look at these files.
clrTransparent: That's definittelly the transparent colour on RGBA format.
DwRes: Yes, it is reserved. Westwood always has these trashes in their files. W3D is also full of them.
Thanks a lot for the info and I'll look into this align stuff. QUICK_EDIT
Also Known As: banshee_revora (Steam) Joined: 15 Aug 2002 Location: Brazil
Posted: Sun Jul 02, 2006 4:31 pm Post subject:
Update: Compression 2 is the compression 3 without the treatment for 0. Here's the source from OS SHP Builder 3.36 Beta 05:
Code:
procedure reinterpretwordfrombytes(Byte1, Byte2: byte; var FullValue: word); overload;
begin
FullValue := (Byte2 * 256) + Byte1;
end;
// 3.36: Decode Compression 2.
procedure Decode2(const Source: Tdatabuffer; var Dest: Tdatabuffer;
const cx, cy: integer; var max: integer);
var
SP, DP, y, maxdp: integer;
Count : word;
begin
maxdp := cx * cy;
SP := 0;
DP := 0;
for y := 1 to cy do
begin
reinterpretwordfrombytes(Source[SP], Source[SP + 1], Count);
Count := Count - 2;
inc(SP,2);
while Count > 0 do
begin
Dec(Count);
if (SP > max) or (DP > maxdp) then
exit; // SP has reached max value, exit
Dest[DP] := Source[SP];
Inc(SP);
Inc(DP);
end;
if (SP >= max) or (DP >= maxdp) then
exit; // SP has reached max value, exit
end;
end;
BYTE byFlags; ONLY ONE byte
Maybe byFlags contains a bit mask, not number
0 - 00
1 - 10
2 - 10
3 - 11
In code I found that engine test only bit 2 in byFlags
and don't use byAlign[3]?!?!
I will continue work and I will try to find out the correct order of loading of a SHP file
"some 'TS' files from RA2.mix uses different values for byFlags"
Can you tell me some examples? QUICK_EDIT
Also Known As: banshee_revora (Steam) Joined: 15 Aug 2002 Location: Brazil
Posted: Sun Jul 02, 2006 9:32 pm Post subject:
Regarding the examples, honestly, at ra2.mix I don't remember anymore... but at language.mix, you'll find a lot of TS cameos inside it. Test them and you'll see that they use the Align stuff. QUICK_EDIT
I have found interesting thing - file limitation
C&C Yuri's Revenge read ONLY (3 * 1024 * 1024) from file (never more 3Mb)
So any SHP file with FileSize > 3Mb not correct
I am not testing it, yet
TS = dirtexpl.shp fsair.shp fsgrnd.shp fsidle.shp inviso.shp lobrdg01.shp null.shp
RA2 = ngmisl.shp ngiron_e.shp nghand_b.shp natbnk.shp inviso.shp ggpile_c.shp ggpile_b.shp gclock2.shp c_shadow.shp null.shp pwrlvl.shp tstlexp.shp yagntcmk.shp
and it not the full list...
It is files list with byFlags not equal 0, 1, 2, 3
Interesting is byFlag == 4 it is "NULL" frame QUICK_EDIT
dirtexpl.shp has a frame with compression 77 !? But, yea, it's a blank frame.
Number not is important
Important ONLYSECOND bit
0 - 00000000b
1 - 00000001b
2 - 00000010b
3 - 00000011b
4 - 00000100b
5 - 00000101b
6 - 00000110b
77 - 01001101b
Replace in file 3 -> 6 and it work[/b] QUICK_EDIT
Can I confirm, is compression type 2 exactly the same as no compression, but with 2 bytes at the start of each line to indicate how many bytes are in the line? QUICK_EDIT
Exist only TWO types of SHP 2 files:
1)without compression - second bit in flags is clear.
2)with RLE compression - second bit in flags is set.
You still not believe me?
Check it by hands.
Open a glslmd.shp file in HEX editor, find frame flags byte
(there only one frame), (file offset is 10h bytes)
and replace it by 3, AAh, or by any number with second bit = 1.
Run the game!
You still see correct load screen
however glslmd.shp have pixels with color = 0 at all. _________________ ARM forever - x86 sucks QUICK_EDIT
I'm just trying to understand - it's not a matter of not believing you. Please don't be offended.
It seems there are two conflicting view. Banshee says there is a difference, but VK says otherwise. Do files that have 0x02 for the flag have different compression or the same? I've never seen one of these files, and it's a little hard for me to check, I'm trying to write a complete decoder, but I only have one SHP file to work with (which is 0x03) QUICK_EDIT
Also Known As: banshee_revora (Steam) Joined: 15 Aug 2002 Location: Brazil
Posted: Mon Jun 18, 2007 3:07 am Post subject:
Don't be confused on that. CnCVK is right. The second bit 1 determines if it's compressed or not. Compression 0x02 doesn't have compression. 0x03 has compression. QUICK_EDIT
but compression never used because image haven't pixels with zero color at all!
Quote:
It seems there are two conflicting view. Banshee says there is a difference, but VK says otherwise. Do files that have 0x02 for the flag have different compression or the same? I've never seen one of these files, and it's a little hard for me to check, I'm trying to write a complete decoder, but I only have one SHP file to work with (which is 0x03)
use code like this:
Code:
if (info->flags & 0x02)
{
// the second bit is set - use code for RLE compression
}
else
{
// the second bit is clear - use code for uncompressed data
}
_________________ ARM forever - x86 sucks QUICK_EDIT
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum