Advertisement
waelwindows92

SPR template test

Jun 2nd, 2017
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.72 KB | None | 0 0
  1.  
  2. //------------------------------------------------
  3. //--- 010 Editor v8.0 Binary Template
  4. //
  5. //      File: *.spr
  6. //   Authors: Waelwindows
  7. //   Version: 0
  8. //   Purpose: Structure the spr format into a understandable class
  9. //------------------------------------------------
  10.  
  11. typedef struct {
  12.     uint    unknown    <name="UNK1", hidden=1>; // Seems to be always 0x0
  13.     int     scale      <name="Scaling">;
  14. } SPR_SCALER;
  15.  
  16. typedef struct {
  17.     uint texIndex <name="Texture Index">;
  18.     float unk1 <hidden=1>;
  19.     float unk2 <hidden=1>; // Various
  20.     float unk3 <hidden=1>; // Various
  21.     float unk4 <hidden=1>; // Various
  22.     float unk5 <hidden=1>; // Various
  23.     float rectX <name="Rectangle X">;
  24.     float rectY <name="Rectangle Y">;
  25.     float rectWidth <name="Rectangle Width">;
  26.     float rectHeight <name="Rectangle Height">;
  27. } SPR_PROPERTY;
  28.  
  29. typedef struct {
  30.     byte type;
  31.     char signature[3];
  32.  
  33.     if ( signature != "PXT" ) {
  34.         Warning("Texture doesn't have PXT identifier");
  35.         return -1;
  36.     }
  37.  
  38.     if (type == 2) {
  39.         uint width <name="Width">;
  40.         uint height <name="Height">;
  41.         uint unknown <hidden=1>;
  42.         uint index <name="Index">;
  43.         uint byteSize <name="Byte Size">;
  44.         byte data[byteSize];
  45.     }
  46.  
  47.     // Texture container
  48.     // 3: Main texture container
  49.     // 4: Child texture container (child of 3)
  50.     else if (type == 3 || type == 4) {
  51.         uint childrenCount;
  52.         byte childrenCount; // Same as above, yes
  53.         byte flags[3]; // Changing them in game does nothing
  54.         uint childrenPositions[childrenCount]; // All of them are relative to where TXP starts
  55.     }
  56.  
  57.     else {
  58.         Warning("Error, unknown texture type");
  59.         return -1;
  60.     }
  61. } TEX;
  62.  
  63.  
  64. // ----------------------------------------------------------
  65.  
  66. typedef struct {
  67.         char    magic[4]        <name="File ID", comment="Always SPRC">;
  68.         uint    eofc            <name="EOFC Offset", format=hex>;
  69.         uint    headerOffset    <name="Header Offset", comment="Seems to be always set to 0x20", format=hex>;
  70.         uint    ver             <name="File Version">;
  71.         DWORD   ebr1            <hidden=1>;
  72.         uint    texCompOffset   <name="Texture Compression Offset", format=hex>;
  73. } OFFSET_TBL;
  74.  
  75. typedef struct {
  76.         uint    id                  <name="ID", comment="Should be always set to 0">;
  77.         uint    texOffset           <name="Texture Offset", comment="Always 8 bytes before last PXT?", format=hex>;
  78.         uint    texCount            <name="Texture Count">;
  79.         uint    sprCount            <name="Sprite Count">;
  80.         uint    sprPropertOffset    <name="Sprite Properties Offset", format=hex>;
  81.         uint    texNameOffset       <name="Texture Name Offset Table", format=hex>;
  82.         uint    sprNameOffset       <name="Sprite Name Offset Table", format=hex>;
  83.         uint    sprScaleOffset      <name="Sprite Scale Offset", format=hex>;
  84. } HEADER;
  85.  
  86. // Define the headers
  87. LittleEndian();
  88. OFFSET_TBL offset_tbl <name="Offset Table", open=true, bgcolor=cGreen>;
  89.  
  90. BigEndian();
  91. FSeek(offset_tbl.headerOffset);
  92. HEADER header <name="Header", open=true, bgcolor=cRed>;
  93.  
  94. FSeek(header.sprScaleOffset);
  95. SPR_SCALER scale[header.sprCount] <name="Sprite Scaling", bgcolor=cBlue>;
  96.  
  97. FSeek(header.sprPropertOffset);
  98. SPR_PROPERTY properties[header.sprCount] <name="Sprite Properties", bgcolor=cYellow>;
  99.  
  100. FSeek(header.sprNameOffset);
  101. uint sprNames[header.sprCount] <name="Sprite Names Offsets", format=hex, bgcolor=cGreen>;
  102.  
  103. FSeek(header.texNameOffset);
  104. uint texNames[header.texCount] <name="Texture Names Offsets", format=hex, bgcolor=cRed>;
  105.  
  106. FSeek(header.texOffset +8);
  107. TEX textures[header.texCount] <name="Textures", bgcolor=cWhite>;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement