public static uint ComputeCueCrc(CueSheet cue)
        {
            if (!cue.HasDataTrack())
            {
                throw new Exception("Audio only CDs are not supported for hashing");
            }
            CueSheet.Track track    = cue.FindFirstDataTrack();
            uint           crcAccum = 0xFFFFFFFF;

            using (FileStream fs = new FileStream(track.FileName, FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader reader = new BinaryReader(fs))
                {
                    fs.Seek(track.FileOffset, SeekOrigin.Begin);

                    int numsects = 1;

                    for (int i = 0; i < numsects; ++i)
                    {
                        byte[] data;
                        if (track.SectorSize == CueSheet.SectorSize._2352)
                        {
                            reader.ReadBytes(16);
                            data = reader.ReadBytes(2048);
                            reader.ReadBytes(288);
                        }
                        else
                        {
                            data = reader.ReadBytes(2048);
                        }

                        if (i == 0)                         //check signature
                        {
                            if (data[0x100] != 'S' || data[0x101] != 'E' || data[0x102] != 'G' || data[0x103] != 'A')
                            {
                                //Debug.Assert(false);
                                Console.WriteLine("Err\n");
                            }
                        }

                        crcAccum = Crc32.ComputeStep(crcAccum, data);
                    }

                    crcAccum = Crc32.Finalize(crcAccum);
                }
            }

            return(crcAccum);
        }
        void TestCueSheet()
        {
            CueSheet cue = new CueSheet(@"K:\mame\roms\Akumajou_Dracula_X_-_Chi_no_Rinne_(NTSC-J)_[KMCD3005]\Akumajou_Dracula_X_-_Chi_no_Rinne_(NTSC-J)_[KMCD3005].cue");

            CueSheet.Track track = cue.FindFirstDataTrack();

            using (FileStream fs = new FileStream(track.FileName, FileMode.Open))
            {
                using (BinaryReader reader = new BinaryReader(fs))
                {
                    fs.Seek(track.FileOffset, SeekOrigin.Begin);

                    int  numsects = 10;
                    uint crcAccum = 0xFFFFFFFF;

                    for (int i = 0; i < numsects; ++i)
                    {
                        byte[] data;
                        if (track.SectorSize == CueSheet.SectorSize._2352)
                        {
                            reader.ReadBytes(16);
                            data = reader.ReadBytes(2048);
                            reader.ReadBytes(288);
                        }
                        else
                        {
                            data = reader.ReadBytes(2048);
                        }

                        if (i == 0)                          //check signature
                        {
                            if (data[0] != 0x82 || data[1] != 0xB1 || data[2] != 0x82 || data[3] != 0xCC || data[4] != 0x83 || data[5] != 0x76 || data[6] != 0x83 || data[7] != 0x8D)
                            {
                                Debug.Assert(false);
                            }
                        }

                        crcAccum = Crc32.ComputeStep(crcAccum, data);
                    }

                    crcAccum = Crc32.Finalize(crcAccum);
                }
            }
        }