예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("DJSLACKERS - DJMainExtract");

            args = Subfolder.Parse(args);

            if (System.Diagnostics.Debugger.IsAttached && args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Debugger attached. Input file name:");
                args = new string[] { Console.ReadLine() };
                if (args[0] == "")
                {
                    args[0] = @"D:\chds\753jaa11.chd";
                }
            }

            for (int i = 0; i < args.Length; i++)
            {
                if (File.Exists(args[i]))
                {
                    string sourceFileName = Path.GetFileNameWithoutExtension(args[i]);
                    string sourcePath     = Path.GetDirectoryName(args[i]);
                    string targetPath     = Path.Combine(sourcePath, sourceFileName);
                    Directory.CreateDirectory(targetPath);

                    Console.WriteLine();
                    Console.WriteLine("Processing " + args[i]);

                    using (FileStream fs = new FileStream(args[i], FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        CHD          chd    = CHD.Load(fs);
                        BinaryReader reader = new BinaryReader(chd);

                        long totalChunks = (int)(chd.Length / 0x1000000L);

                        for (int j = 0; j < totalChunks; j++)
                        {
                            chd.Position = (long)j * 0x1000000;
                            //DJMainChunk chunk = DJMainChunk.Read(chd, new int[] { 0x002000, 0x006000, 0x00A000, 0x00E000, 0x012000, 0x016000 }, new int[] { 0x000000, 0x000200 }, 0x020000);
                            DJMainChunk chunk = DJMainChunk.Read(chd, new int[] { 0x000400 }, new int[] { 0x000000, 0x000200 }, 0x002000);

                            if (chunk.ChartCount > 0)
                            {
                                Console.WriteLine("Exporting set " + j.ToString());
                                string fname = Path.Combine(Path.GetDirectoryName(args[i]), Util.ConvertToDecimalString(j, 3));
                                //ConvertHelper.BemaniToBMS.ConvertChart(chunk.Charts[0], 16, 192, fname, "", 0, chunk.SampleMaps[0]);
                                ConvertHelper.BemaniToBMS.ConvertSounds(chunk.Sounds, fname, 0.6f);
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        static public StreamAdapterInfo Open(string filename)
        {
            filename = filename.ToLowerInvariant().Trim();
            if (!File.Exists(filename))
            {
                return(null);
            }

            if (filename.EndsWith(@".chd"))
            {
                return(new StreamAdapterInfo(CHD.Load(new FileStream(filename, FileMode.Open, FileAccess.Read))));
            }

            if (filename.EndsWith(@".gz"))
            {
                var gz = new Gzip(filename);
                return(new StreamAdapterInfo(gz.GetDeflateStream(), 0x7FFFFFFFFFFFL)); // stupid value to play nice with arithmetic
            }

            if (filename.EndsWith(@".zip"))
            {
                var zip = new Zip(filename);
                if (zip.Files.Count > 0)
                {
                    var  file   = zip.Files[0];
                    long length = file.UncompressedSize;
                    if (length == 0 && file.CompressedSize != 0)
                    {
                        length = file.CompressedSize;
                    }
                    return(new StreamAdapterInfo(zip.StreamFile(file), length));
                }
            }

            return(new StreamAdapterInfo(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read)));
        }