Browse Source

Merge pull request #102 from myst6re/master

PC and PS export background additions
paulsapps 11 năm trước cách đây
mục cha
commit
eefd49c627

+ 4 - 0
QGearsMain/src/data/QGearsBackgroundFile.cpp

@@ -306,6 +306,10 @@ namespace QGears
                         {
                             colour.a = 0;
                         }
+                        else if (colour.a && (colour.r != 0 || colour.g != 0 || colour.b != 0))
+                        {
+                            colour.a = 0.5;
+                        }
                         else
                         {
                             colour.a = 1;

+ 22 - 3
QGearsMain/src/data/QGearsBackgroundFileSerializer.cpp

@@ -167,11 +167,16 @@ namespace QGears
 
         uint16 size;
         // width and height are sometimes incorrect in the file
-        if ( m_layer_index < 2 ) {
+        if ( m_layer_index < 2 )
+        {
             size = 16;
-        } else if ( m_layer_index < BackgroundFile::LAYER_COUNT) {
+        }
+        else if ( m_layer_index < BackgroundFile::LAYER_COUNT)
+        {
             size = 32;
-        } else {
+        }
+        else
+        {
             OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS
                 ,"m_layer_index not set correctly"
                 ,"BackgroundFileSerializer::readObject" );
@@ -181,6 +186,20 @@ namespace QGears
         readShort( stream, pDest.palette_page );
         readShort( stream, pDest.depth );
 
+        // Force depth values
+        switch ( m_layer_index )
+        {
+          case 0:
+            pDest.depth = 4095;
+            break;
+          case 2:
+            pDest.depth = 4096;
+            break;
+          case 3:
+            pDest.depth = 0;
+            break;
+        }
+
         uint8 animation[2];
         stream->read( animation, sizeof( animation ) );
         pDest.animation_id = animation[0];

+ 1 - 5
utilities/ffvii_field_dat_dumper/src/DatFile.cpp

@@ -3336,7 +3336,7 @@ DatFile::AddTile( const Tile& tile, MimFile& mim, Logger* export_text )
     {
         blending_str = "alpha";
     }
-    else if( tile.blending == 1 )
+    else if( tile.blending == 1 || tile.blending == 3 ) // 3 is source + 0.25 * destination
     {
         blending_str = "add";
     }
@@ -3344,10 +3344,6 @@ DatFile::AddTile( const Tile& tile, MimFile& mim, Logger* export_text )
     {
         blending_str = "subtract";
     }
-    // else if( tile.blending == 3 )
-    // {
-    //     blending_str = "add"; // source + 0.25 * destination
-    // }
     else
     {
         LOGGER->Log( "Tile blending with type \"" + Ogre::StringConverter::toString( tile.blending ) + "\" not supported." );

+ 31 - 0
utilities/ffvii_field_dat_dumper/src/MimFile.cpp

@@ -180,6 +180,37 @@ MimFile::GetSurface( const u16 page_x, const u16 page_y, const u16 clut_x, const
         }
     }
 
+
+
+    else if ( bpp == 2 )
+    {
+        for( int y = 0; y < 256; ++y )
+        {
+            for( int x = 0; x < 256; ++x )
+            {
+                u16 real_x = mImageVramPositionX + page_x * 128 + x * 2;
+                u16 real_y = mImageVramPositionY + page_y * 256 + y;
+
+                u16 col = m_Vram->GetU16(real_x, real_y);
+
+                color.r = ( ( col       ) & 31 ) * 255 / 31;
+                color.g = ( ( col >>  5 ) & 31 ) * 255 / 31;
+                color.b = ( ( col >> 10 ) & 31 ) * 255 / 31;
+
+                if( col == 0x0000 )
+                {
+                    color.a = 0;
+                }
+                else
+                {
+                    color.a = 255;
+                }
+
+                memcpy( ret->pixels.data() + x * 4 + ret->width * 4 * y, &color, sizeof( ClutColor ) );
+            }
+        }
+    }
+
     return ret;
 }
 

+ 1 - 1
utilities/q-gears-launcher/src/ff7DataInstaller.cpp

@@ -295,7 +295,7 @@ static void FF7PcFieldToQGearsField(QGears::FLevelFilePtr& field, const std::str
                     {
                         blending_str = "alpha";
                     }
-                    else if (sprite.blending == 1)
+                    else if (sprite.blending == 1 || sprite.blending == 3) // 3 is source + 0.25 * destination
                     {
                         blending_str = "add";
                     }