Exemplo n.º 1
0
                private static void BuildCharMapFromIso(Stream iso, out GenericCharMap outCharmap, out IList <Glyph> customGlyphs)
                {
                    var rootDirEnt   = DirectoryEntry.GetPsxDirectoryEntries(iso, FFTText.PsxRootDirEntSector, 1);
                    var charMapEntry = rootDirEnt.Find(d => d.Filename == FFTText.PsxCharmapFileName);

                    System.Diagnostics.Debug.Assert(charMapEntry.Sector == FFTText.PsxCharmapSector);
                    var charmapBytes = PsxIso.GetBlock(iso, new PsxIso.KnownPosition((PsxIso.Sectors)FFTText.PsxCharmapSector, 0,
                                                                                     (int)charMapEntry.Size));
                    Dictionary <int, string> myCharmap = new Dictionary <int, string>();

                    using (MemoryStream memStream = new MemoryStream(charmapBytes))
                        using (TextReader reader = new StreamReader(memStream, Encoding.UTF8))
                        {
                            // Get header line
                            reader.ReadLine();
                            string currentLine = string.Empty;
                            while ((currentLine = reader.ReadLine()) != null)
                            {
                                string[] cols  = currentLine.Split('\t');
                                int      index = int.Parse(cols[0], System.Globalization.NumberStyles.HexNumber);
                                myCharmap[index] = cols[1];
                            }
                        }

                    outCharmap   = new NonDefaultCharMap(myCharmap);
                    customGlyphs = null;
                }
Exemplo n.º 2
0
        public static IList <DirectoryEntry> GetPsxDirectoryEntries(Stream iso, int sectorOfParentEntry, int numSectors)
        {
            int sector = sectorOfParentEntry;
            int length = numSectors;

            byte[] bytes = PsxIso.GetBlock(iso, new PsxIso.KnownPosition((PatcherLib.Iso.PsxIso.Sectors)sector, 0, length * 2048));
            return(BuildDirectoryEntriesFromBytes(bytes));
        }
Exemplo n.º 3
0
        public static bool DoesPsxIsoHaveDtePatches(System.IO.Stream iso)
        {
            foreach (var pba in psxDtePatches)
            {
                byte[] patchBytes  = pba.GetBytes();
                byte[] streambytes =
                    PsxIso.GetBlock(iso, new PsxIso.KnownPosition((PsxIso.Sectors)pba.Sector, (int)pba.Offset, patchBytes.Length));
                if (!Utilities.CompareArrays(patchBytes, streambytes))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 4
0
                public static void GetCharMap(Stream iso, out GenericCharMap outCharmap, out IList <Glyph> customGlyphs)
                {
                    var matchBytes = Encoding.UTF8.GetBytes(FFTText.CharmapHeader);
                    var isoBytes   = PsxIso.GetBlock(iso, new PsxIso.KnownPosition((PsxIso.Sectors)FFTText.PsxCharmapSector, 0,
                                                                                   matchBytes.Length));

                    if (Utilities.CompareArrays(matchBytes, isoBytes))
                    {
                        BuildCharMapFromIso(iso, out outCharmap, out customGlyphs);
                    }
                    else
                    {
                        IList <byte> dteBytes = PsxIso.ReadFile(iso, DTE.PsxDteTable);
                        outCharmap   = GetCharMap(dteBytes);
                        customGlyphs = null;
                    }
                }
Exemplo n.º 5
0
        public static bool DoesPsxIsoHaveDtePatches(System.IO.Stream iso)
        {
            var matchBytes = Encoding.UTF8.GetBytes(FFTText.CharmapHeader);
            var isoBytes   = PsxIso.GetBlock(iso, new PsxIso.KnownPosition((PsxIso.Sectors)FFTText.PsxCharmapSector, 0,
                                                                           matchBytes.Length));

            if (Utilities.CompareArrays(matchBytes, isoBytes))
            {
                return(true);
            }

            foreach (var pba in psxDtePatches)
            {
                byte[] patchBytes  = pba.GetBytes();
                byte[] streambytes =
                    PsxIso.GetBlock(iso, new PsxIso.KnownPosition((PsxIso.Sectors)pba.Sector, (int)pba.Offset, patchBytes.Length));
                if (!Utilities.CompareArrays(patchBytes, streambytes))
                {
                    return(false);
                }
            }

            return(true);
        }