Beispiel #1
0
        static PSXWorldMap()
        {
            int[][,] posLengths = new int[][, ] {
                topLeftPosLengths, topRightPosLengths, bottomLeftPosLengths, bottomRightPosLengths
            };

            IList <PatcherLib.Iso.PsxIso.KnownPosition>[] positions = new IList <PatcherLib.Iso.PsxIso.KnownPosition> [4];
            for (int i = 0; i < 4; i++)
            {
                int length = posLengths[i].GetLength(0);
                PatcherLib.Iso.PsxIso.KnownPosition[] thisPositions = new PatcherLib.Iso.PsxIso.KnownPosition[length];
                for (int j = 0; j < length; j++)
                {
                    int pos = posLengths[i][j, 0];
                    int len = posLengths[i][j, 1];
                    thisPositions[j] = new PatcherLib.Iso.PsxIso.KnownPosition(PatcherLib.Iso.PsxIso.Sectors.WORLD_WLDTEX_TM2, pos, len);
                }
                positions[i] = thisPositions;
            }

            topLeft     = positions[0];
            topRight    = positions[1];
            bottomLeft  = positions[2];
            bottomRight = positions[3];

            isoPositions = new IList <PatcherLib.Iso.PsxIso.KnownPosition>[] {
                topLeft,
                topRight,
                bottomLeft,
                bottomRight
            };
        }
Beispiel #2
0
 public string GetSaveFileName()
 {
     if (Position is PatcherLib.Iso.PsxIso.KnownPosition)
     {
         PatcherLib.Iso.PsxIso.KnownPosition pos = Position as PatcherLib.Iso.PsxIso.KnownPosition;
         return(string.Format("{0}_{1}_{2}.bmp", pos.Sector, pos.StartLocation, pos.Length));
     }
     else if (Position is PatcherLib.Iso.PspIso.KnownPosition)
     {
         PatcherLib.Iso.PspIso.KnownPosition pos = Position as PatcherLib.Iso.PspIso.KnownPosition;
         return(string.Format("{0}_{1}_{2}.bmp", pos.SectorEnum, pos.StartLocation, pos.Length));
     }
     else
     {
         return(name);
     }
 }
Beispiel #3
0
        public static bool IsoHasBuggyLevelBonuses(System.IO.Stream iso, Context context)
        {
            if (context == Context.US_PSP)
            {
                return(false);
                //return true;
            }
            else
            {
                bool allBad = true;
                foreach (var badInstruction in badPsxInstructions)
                {
                    var kp    = new PatcherLib.Iso.PsxIso.KnownPosition(PatcherLib.Iso.PsxIso.Sectors.WORLD_WLDCORE_BIN, badInstruction.Item1, 4);
                    var bytes = kp.ReadIso(iso);
                    allBad &= Utilities.CompareArrays(bytes, badInstruction.Item2);
                }

                if (allBad)
                {
                    return(true);
                }

                bool allGood = true;
                foreach (var goodInstruction in goodPsxInstructions)
                {
                    var kp    = new PatcherLib.Iso.PsxIso.KnownPosition(PatcherLib.Iso.PsxIso.Sectors.WORLD_WLDCORE_BIN, goodInstruction.Item1, 4);
                    var bytes = kp.ReadIso(iso);
                    allGood &= Utilities.CompareArrays(bytes, goodInstruction.Item2);
                }

                if (allGood)
                {
                    return(false);
                }

                return(true);
            }
        }
Beispiel #4
0
        static PSXWorldMap()
        {
            int[][,] posLengths = new int[][,] { topLeftPosLengths, topRightPosLengths, bottomLeftPosLengths, bottomRightPosLengths };

            IList<PatcherLib.Iso.PsxIso.KnownPosition>[] positions = new IList<PatcherLib.Iso.PsxIso.KnownPosition>[4];
            for(int i =0; i < 4; i++)
            {
                int length = posLengths[i].GetLength( 0 );
                PatcherLib.Iso.PsxIso.KnownPosition[] thisPositions = new PatcherLib.Iso.PsxIso.KnownPosition[length];
                for (int j = 0; j < length; j++)
                {
                    int pos = posLengths[i][j,0];
                    int len = posLengths[i][j,1];
                    thisPositions[j] = new PatcherLib.Iso.PsxIso.KnownPosition( PatcherLib.Iso.PsxIso.Sectors.WORLD_WLDTEX_TM2, pos, len );
                }
                positions[i] = thisPositions;
            }

            topLeft = positions[0];
            topRight = positions[1];
            bottomLeft = positions[2];
            bottomRight = positions[3];

            isoPositions = new IList<PatcherLib.Iso.PsxIso.KnownPosition>[] {
                topLeft,
                topRight,
                bottomLeft,
                bottomRight
            };
        }
Beispiel #5
0
        public static bool IsoHasBuggyLevelBonuses( System.IO.Stream iso, Context context )
        {
            if (context == Context.US_PSP)
            {
                return false;
                //return true;
            }
            else
            {
                bool allBad = true;
                foreach (var badInstruction in badPsxInstructions)
                {
                    var kp = new PatcherLib.Iso.PsxIso.KnownPosition( PatcherLib.Iso.PsxIso.Sectors.WORLD_WLDCORE_BIN, badInstruction.Item1, 4 );
                    var bytes = kp.ReadIso( iso );
                    allBad &= Utilities.CompareArrays( bytes, badInstruction.Item2 );
                }

                if (allBad)
                    return true;

                bool allGood = true;
                foreach (var goodInstruction in goodPsxInstructions)
                {
                    var kp = new PatcherLib.Iso.PsxIso.KnownPosition( PatcherLib.Iso.PsxIso.Sectors.WORLD_WLDCORE_BIN, goodInstruction.Item1, 4 );
                    var bytes = kp.ReadIso( iso );
                    allGood &= Utilities.CompareArrays( bytes, goodInstruction.Item2 );
                }

                if (allGood)
                    return false;

                return true;
            }
        }
        public static AbstractImage GetPSXEffectImage(Stream iso, int effectIndex, string effectName, int headerOffset)
        {
            string strEffectNumber = effectIndex.ToString("000");
            string sectorName      = string.Format("EFFECT_E{0}_BIN", strEffectNumber);

            PatcherLib.Iso.PsxIso.Sectors sector = (PatcherLib.Iso.PsxIso.Sectors) 0;

            try
            {
                sector = (PatcherLib.Iso.PsxIso.Sectors)Enum.Parse(typeof(PatcherLib.Iso.PsxIso.Sectors), sectorName);
            }
            catch (Exception) { }

            if (sector == 0)
            {
                return(null);
            }

            /*
             * int effectByteCount = effectFileBytes.SubLength((effectIndex * 8) + 4, 4).ToIntLE();
             * if (effectByteCount == 0)
             *  return null;
             *
             * uint headerLocation = headerLocationBytes.SubLength((effectIndex * 4), 4).ToUInt32();
             * int headerOffset = (int)(headerLocation - 0x801C2500U);
             */

            int frameDataOffset             = PatcherLib.Iso.PsxIso.ReadFile(iso, sector, headerOffset, 4).ToIntLE() + headerOffset;
            int frameDataSectionCount       = PatcherLib.Iso.PsxIso.ReadFile(iso, sector, frameDataOffset, 2).ToIntLE();
            int firstFrameDataPointerOffset = PatcherLib.Iso.PsxIso.ReadFile(iso, sector, frameDataOffset + 4 + (2 * frameDataSectionCount), 2).ToIntLE() + frameDataOffset + 4;
            int firstFrameTexturePageHeader = PatcherLib.Iso.PsxIso.ReadFile(iso, sector, firstFrameDataPointerOffset, 2).ToIntLE();

            int colorDepthCode = (firstFrameTexturePageHeader & 0x0180) >> 7;

            if (colorDepthCode > 1)     // Invalid code
            {
                return(null);
            }

            bool is4bpp        = (colorDepthCode == 0);
            int  paletteOffset = PatcherLib.Iso.PsxIso.ReadFile(iso, sector, headerOffset + 0x24, 4).ToIntLE() + headerOffset;

            int secondSetPaletteOffset = paletteOffset + 0x200;
            int imageSizeDataOffset    = paletteOffset + 0x400;
            int graphicsOffset         = paletteOffset + 0x404;

            byte[] imageSizeData          = PatcherLib.Iso.PsxIso.ReadFile(iso, sector, imageSizeDataOffset, 4);
            int    imageSizeCombinedValue = imageSizeData.Sub(0, 2).ToIntLE();
            int    rowBytes  = (imageSizeData[3] != 0) ? 256 : 128;
            int    height    = imageSizeCombinedValue >> ((imageSizeData[3] != 0) ? 8 : 7);
            int    width     = is4bpp ? (rowBytes * 2) : rowBytes;
            int    imageSize = rowBytes * height;
            int    fileSize  = graphicsOffset + imageSize;
            string name      = String.Format("{0} {1}", effectIndex.ToString("X3"), effectName);
            string fileName  = String.Format("E{0}.BIN", strEffectNumber);

            PatcherLib.Iso.PsxIso.KnownPosition graphicsPosition = new PatcherLib.Iso.PsxIso.KnownPosition(sector, graphicsOffset, imageSize);
            PatcherLib.Iso.PsxIso.KnownPosition palettePosition  = new PatcherLib.Iso.PsxIso.KnownPosition(sector, (is4bpp ? secondSetPaletteOffset : paletteOffset), (is4bpp ? 32 : 512));

            return(GetPalettedImage(is4bpp, name, width, height, fileName, fileSize, sector, graphicsPosition, palettePosition, true, effectIndex));
        }