示例#1
0
        private IList <PatchedByteArray> GetPsxCharMapPatches(Stream iso, GenericCharMap baseCharmap, IDictionary <byte, string> dteInfo)
        {
            var dirEnt = DirectoryEntry.GetPsxDirectoryEntries(iso, PsxRootDirEntSector, 1);

            var myDict = new Dictionary <int, string>(baseCharmap);

            dteInfo.ForEach(kvp => myDict[kvp.Key] = kvp.Value);

            System.Text.StringBuilder myString = new System.Text.StringBuilder();
            myString.AppendLine(CharmapHeader);
            myDict.ForEach(kvp => myString.AppendFormat("{0:X4}\t{1}" + Environment.NewLine, kvp.Key, kvp.Value));
            var bytes = System.Text.Encoding.UTF8.GetBytes(myString.ToString());

            var baseDirEntry    = dirEnt.Find(d => d.Filename == "SCEAP.DAT;1");
            var charmapDirEntry = new PatcherLib.Iso.DirectoryEntry(
                PsxCharmapSector, (uint)bytes.Length, DateTime.Now, baseDirEntry.GMTOffset,
                baseDirEntry.MiddleBytes, PsxCharmapFileName, baseDirEntry.ExtendedBytes);

            AddOrReplaceCharMapDirectoryEntry(dirEnt, charmapDirEntry);

            var dirEntPatches = PatcherLib.Iso.DirectoryEntry.GetPsxDirectoryEntryPatches(
                PsxRootDirEntSector, 1, dirEnt);

            dirEntPatches.Add(new PatchedByteArray(PsxCharmapSector, 0, bytes));
            return(dirEntPatches);
        }
示例#2
0
        private void AddOrReplaceCharMapDirectoryEntry(IList <PatcherLib.Iso.DirectoryEntry> dir, PatcherLib.Iso.DirectoryEntry newDirEnt)
        {
            var currentCharmapIndex = dir.IndexOf(dir.Find(d => d.Filename == newDirEnt.Filename));

            if (currentCharmapIndex != -1)
            {
                dir[currentCharmapIndex] = newDirEnt;
            }
            else
            {
                dir.Add(newDirEnt);
                dir.Sort((a, b) => a.Filename.CompareTo(b.Filename));
            }
        }
示例#3
0
        private IList <PatchedByteArray> GetPspCharMapPatches(Stream iso, GenericCharMap baseCharmap, IDictionary <byte, string> dteInfo)
        {
            var pspIsoInfo = PspIso.PspIsoInfo.GetPspIsoInfo(iso);
            var dirEnt     = DirectoryEntry.GetPspDirectoryEntries(iso, pspIsoInfo, PspIso.Sectors.PSP_GAME_USRDIR, 1);

            var currentEntry = dirEnt.Find(de => de.Filename == PspCharmapFileName);

            if (currentEntry != null)
            {
                dirEnt.Remove(currentEntry);
            }
            pspIsoInfo.RemoveFile(PspIso.Sectors.PSP_GAME_USRDIR_CHARMAP);

            var myDict = new Dictionary <int, string>(baseCharmap);

            dteInfo.ForEach(kvp => myDict[kvp.Key] = kvp.Value);

            System.Text.StringBuilder myString = new System.Text.StringBuilder();
            myString.AppendLine(CharmapHeader);
            myDict.ForEach(kvp => myString.AppendFormat("{0:X4}\t{1}" + Environment.NewLine, kvp.Key, kvp.Value));
            var bytes = System.Text.Encoding.UTF8.GetBytes(myString.ToString());

            int insertSector = FindSectorToInsertPspCharmap(pspIsoInfo, bytes.Length);

            if (insertSector == -1)
            {
                throw new InvalidOperationException();
            }

            pspIsoInfo.AddFile(PspIso.Sectors.PSP_GAME_USRDIR_CHARMAP, insertSector, bytes.Length);

            var baseDirEntry    = dirEnt.Find(d => d.Filename == "fftpack.bin");
            var charmapDirEntry = new PatcherLib.Iso.DirectoryEntry(
                (uint)insertSector, (uint)bytes.Length, DateTime.Now, baseDirEntry.GMTOffset,
                baseDirEntry.MiddleBytes, PspCharmapFileName, baseDirEntry.ExtendedBytes);

            AddOrReplaceCharMapDirectoryEntry(dirEnt, charmapDirEntry);

            var dirEntPatches = PatcherLib.Iso.DirectoryEntry.GetPspDirectoryEntryPatches(
                (int)PspIso.Sectors.PSP_GAME_USRDIR, 1, dirEnt);

            dirEntPatches.Add(new PatchedByteArray(PspIso.Sectors.PSP_GAME_USRDIR_CHARMAP, 0, bytes));

            return(dirEntPatches);
        }
示例#4
0
        private IList<PatchedByteArray> GetPsxCharMapPatches( Stream iso, GenericCharMap baseCharmap, IDictionary<byte, string> dteInfo )
        {
            var dirEnt = DirectoryEntry.GetPsxDirectoryEntries( iso, PsxRootDirEntSector, 1 );

            var myDict = new Dictionary<int, string>( baseCharmap );
            dteInfo.ForEach( kvp => myDict[kvp.Key] = kvp.Value );

            System.Text.StringBuilder myString = new System.Text.StringBuilder();
            myString.AppendLine( CharmapHeader );
            myDict.ForEach( kvp => myString.AppendFormat( "{0:X4}\t{1}" + Environment.NewLine, kvp.Key, kvp.Value ) );
            var bytes = System.Text.Encoding.UTF8.GetBytes( myString.ToString() );

            var baseDirEntry = dirEnt.Find( d => d.Filename == "SCEAP.DAT;1" );
            var charmapDirEntry = new PatcherLib.Iso.DirectoryEntry(
                PsxCharmapSector, (uint)bytes.Length, DateTime.Now, baseDirEntry.GMTOffset,
                baseDirEntry.MiddleBytes, PsxCharmapFileName, baseDirEntry.ExtendedBytes );
            AddOrReplaceCharMapDirectoryEntry( dirEnt, charmapDirEntry );

            var dirEntPatches = PatcherLib.Iso.DirectoryEntry.GetPsxDirectoryEntryPatches(
                PsxRootDirEntSector, 1, dirEnt );
            dirEntPatches.Add( new PatchedByteArray( PsxCharmapSector, 0, bytes ) );
            return dirEntPatches;
        }
示例#5
0
        private IList<PatchedByteArray> GetPspCharMapPatches( Stream iso, GenericCharMap baseCharmap, IDictionary<byte, string> dteInfo )
        {
            var pspIsoInfo = PspIso.PspIsoInfo.GetPspIsoInfo( iso );
            var dirEnt = DirectoryEntry.GetPspDirectoryEntries( iso, pspIsoInfo, PspIso.Sectors.PSP_GAME_USRDIR, 1 );

            var currentEntry = dirEnt.Find( de => de.Filename == PspCharmapFileName );
            if (currentEntry != null)
            {
                dirEnt.Remove( currentEntry );
            }
            pspIsoInfo.RemoveFile( PspIso.Sectors.PSP_GAME_USRDIR_CHARMAP );

            var myDict = new Dictionary<int, string>( baseCharmap );
            dteInfo.ForEach( kvp => myDict[kvp.Key] = kvp.Value );

            System.Text.StringBuilder myString = new System.Text.StringBuilder();
            myString.AppendLine( CharmapHeader );
            myDict.ForEach( kvp => myString.AppendFormat( "{0:X4}\t{1}" + Environment.NewLine, kvp.Key, kvp.Value ) );
            var bytes = System.Text.Encoding.UTF8.GetBytes( myString.ToString() );

            int insertSector = FindSectorToInsertPspCharmap( pspIsoInfo, bytes.Length );
            if (insertSector == -1)
            {
                throw new InvalidOperationException();
            }

            pspIsoInfo.AddFile( PspIso.Sectors.PSP_GAME_USRDIR_CHARMAP, insertSector, bytes.Length );

            var baseDirEntry = dirEnt.Find( d => d.Filename == "fftpack.bin" );
            var charmapDirEntry = new PatcherLib.Iso.DirectoryEntry(
                (uint)insertSector, (uint)bytes.Length, DateTime.Now, baseDirEntry.GMTOffset,
                baseDirEntry.MiddleBytes, PspCharmapFileName, baseDirEntry.ExtendedBytes );

            AddOrReplaceCharMapDirectoryEntry( dirEnt, charmapDirEntry );

            var dirEntPatches = PatcherLib.Iso.DirectoryEntry.GetPspDirectoryEntryPatches(
                (int)PspIso.Sectors.PSP_GAME_USRDIR, 1, dirEnt );
            dirEntPatches.Add( new PatchedByteArray( PspIso.Sectors.PSP_GAME_USRDIR_CHARMAP, 0, bytes ) );

            return dirEntPatches;
        }