当前位置: 首页>>代码示例>>C#>>正文


C# Time.ToBCD方法代码示例

本文整理汇总了C#中Time.ToBCD方法的典型用法代码示例。如果您正苦于以下问题:C# Time.ToBCD方法的具体用法?C# Time.ToBCD怎么用?C# Time.ToBCD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Time的用法示例。


在下文中一共展示了Time.ToBCD方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExpandPsxIso

        public static void ExpandPsxIso( Stream iso )
        {
            byte[] expandedBytes = expandedSectorCount.ToBytes();
            byte[] reverseBytes = new byte[4] { expandedBytes[3], expandedBytes[2], expandedBytes[1], expandedBytes[0] };
            PatcherLib.Iso.PsxIso.PatchPsxIso( iso, PatcherLib.Iso.PsxIso.NumberOfSectorsLittleEndian.GetPatchedByteArray( expandedBytes ) );
            PatcherLib.Iso.PsxIso.PatchPsxIso( iso, PatcherLib.Iso.PsxIso.NumberOfSectorsBigEndian.GetPatchedByteArray( reverseBytes ) );
            //PatcherLib.Iso.PsxIso.PatchPsxIso( iso,
            //    new PatchedByteArray(
            //        (PatcherLib.Iso.PsxIso.Sectors)22,
            //        0xDC,
            //        new byte[] { 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00 } ) );

            // Build directory entry for /DUMMY
            //iso.Seek(0x203E6500, SeekOrigin.Begin);
            //iso.Write(Properties.Resources.PatchedDummyFolder, 0, Properties.Resources.PatchedDummyFolder.Length);

            // Read old sprites
            var locs = SpriteFileLocations.FromPsxIso( iso );
            byte[][] oldSprites = new byte[NumPsxSprites][];
            for (int i = 0; i < NumPsxSprites; i++)
            {
                var loc = locs[i];
                oldSprites[i] = PatcherLib.Iso.PsxIso.ReadFile( iso, (PatcherLib.Iso.PsxIso.Sectors)loc.Sector, 0, (int)loc.Size );
            }

            Set<string> allowedEntries = new Set<string>( new string[] {
                "\0", "\x01",
                "ARUTE.SEQ;1",                "ARUTE.SHP;1",
                "CYOKO.SEQ;1",                "CYOKO.SHP;1",
                "EFC_FNT.TIM;1",                "EFF1.SEQ;1",                "EFF1.SHP;1",                "EFF2.SEQ;1",
                "EFF2.SHP;1",                "ENTD1.ENT;1",                "ENTD2.ENT;1",                "ENTD3.ENT;1",
                "ENTD4.ENT;1",

                "KANZEN.SEQ;1",                "KANZEN.SHP;1",
                "MON.SEQ;1",                "MON.SHP;1",
                "OTHER.SEQ;1",                "OTHER.SHP;1",                "OTHER.SPR;1",                "RUKA.SEQ;1",
                "TYPE1.SEQ;1",                "TYPE1.SHP;1",                "TYPE2.SEQ;1",                "TYPE2.SHP;1",
                "TYPE3.SEQ;1",                "TYPE4.SEQ;1",                "WEP.SPR;1",                "WEP1.SEQ;1",
                "WEP1.SHP;1",                "WEP2.SEQ;1",                "WEP2.SHP;1",                "ZODIAC.BIN;1"} );

            List<PatcherLib.Iso.DirectoryEntry> battleDir = new List<PatcherLib.Iso.DirectoryEntry>( PatcherLib.Iso.DirectoryEntry.GetPsxBattleEntries( iso ) );
            byte[] extBytes = battleDir[2].ExtendedBytes;
            System.Diagnostics.Debug.Assert( battleDir.Sub( 2 ).TrueForAll( ent => PatcherLib.Utilities.Utilities.CompareArrays( extBytes, ent.ExtendedBytes ) ) );
            byte[] midBytes = battleDir[2].MiddleBytes;
            System.Diagnostics.Debug.Assert( battleDir.Sub( 2 ).TrueForAll( ent => PatcherLib.Utilities.Utilities.CompareArrays( midBytes, ent.MiddleBytes ) ) );
            battleDir.RemoveAll( dirent => !allowedEntries.Contains( dirent.Filename ) );

            // Expand length of ISO
            byte[] anchorBytes = new byte[] {
                    0x00, 0xFF, 0xFF, 0xFF,
                    0xFF, 0xFF, 0xFF, 0xFF,
                    0xFF, 0xFF, 0xFF, 0x00 };
            byte[] sectorBytes = new byte[] {
                0x00, 0x00, 0x08, 0x00,
                0x00, 0x00, 0x08, 0x00 };
            byte[] endOfFileBytes = new byte[] {
                0x00, 0x00, 0x89, 0x00,
                0x00, 0x00, 0x89, 0x00 };
            //byte[] sectorBytes = new byte[8];
            //byte[] endOfFileBytes = new byte[8];
            byte[] emptySector = new byte[2328];
            Time t = new Time( 51, 9, 39 );
            for (long l = 0x2040B100; l < 0x20F18D00; l += 2352)
            {
                // write 0x00FFFFFF FFFFFFFF FFFFFF00 MM SS FF 02
                // write 0x00000800 00000800 for sector of file
                // write 0x00008900 00008900 for last sector of file
                iso.Seek( l, SeekOrigin.Begin );
                iso.Write( anchorBytes, 0, anchorBytes.Length );
                iso.Write( t.ToBCD(), 0, 3 );
                t = t.AddFrame();
                iso.WriteByte( 0x02 );
                if ((l - 0x2040B100 + 2352) % 0x12600 != 0)
                {
                    iso.Write( sectorBytes, 0, 8 );
                }
                else
                {
                    iso.Write( endOfFileBytes, 0, 8 );
                }
                iso.Write( emptySector, 0, 2328 );
            }

            // Copy old sprites to new locations
            List<byte> posBytes = new List<byte>( NumPsxSprites * 8 );
            const long startSector = 0x2040B100 / 2352;
            for (int i = 0; i < NumPsxSprites; i++)
            {
                uint sector = (uint)(startSector + i * 65536 / 2048);
                byte[] bytes = oldSprites[i];
                byte[] realBytes = new byte[65536];
                bytes.CopyTo( realBytes, 0 );
                PatcherLib.Iso.PsxIso.PatchPsxIso( iso, new PatchedByteArray( (int)sector, 0, realBytes ) );
                posBytes.AddRange( sector.ToBytes() );
                posBytes.AddRange( ((uint)realBytes.Length).ToBytes() );

                battleDir.Add( new PatcherLib.Iso.DirectoryEntry( sector, 65536, DateTime.Now, battleDir[2].GMTOffset, battleDir[2].MiddleBytes,
                    string.Format( "{0:X2}.SPR;1", i + 1 ), battleDir[2].ExtendedBytes ) );
            }

//.........这里部分代码省略.........
开发者ID:Glain,项目名称:FFTPatcher,代码行数:101,代码来源:AllSprites.cs


注:本文中的Time.ToBCD方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。