Ejemplo n.º 1
0
 static string HashDiscImage(string file)
 {
     try
     {
         string ext = new FileInfo(file).Extension.ToLowerInvariant();
         using (var disc = Disc.LoadAutomagic(file))
         {
             var hasher = new DiscHasher(disc);
             return(hasher.OldHash());
         }
     }
     catch
     {
         return("Error Hashing Disc");
     }
 }
Ejemplo n.º 2
0
        private GameInfo MakeGameFromDisc(Disc disc, string ext, string name)
        {
            // TODO - use more sophisticated IDer
            var discType   = new DiscIdentifier(disc).DetectDiscType();
            var discHasher = new DiscHasher(disc);
            var discHash   = discType == DiscType.SonyPSX
                                ? discHasher.Calculate_PSX_BizIDHash().ToString("X8")
                                : discHasher.OldHash();

            var game = Database.CheckDatabase(discHash);

            if (game == null)
            {
                // try to use our wizard methods
                game = new GameInfo {
                    Name = name, Hash = discHash
                };

                switch (discType)
                {
                case DiscType.SegaSaturn:
                    game.System = "SAT";
                    break;

                case DiscType.SonyPSP:
                    game.System = "PSP";
                    break;

                case DiscType.SonyPS2:
                    game.System = "PS2";
                    break;

                case DiscType.MegaCD:
                    game.System = "GEN";
                    break;

                case DiscType.PCFX:
                    game.System = "PCFX";
                    break;

                case DiscType.TurboGECD:
                case DiscType.TurboCD:
                    game.System = "PCE";
                    break;

                case DiscType.Amiga:
                case DiscType.CDi:
                case DiscType.Dreamcast:
                case DiscType.GameCube:
                case DiscType.NeoGeoCD:
                case DiscType.Panasonic3DO:
                case DiscType.Playdia:
                case DiscType.Wii:
                    // no supported emulator core for these (yet)
                    game.System = discType.ToString();
                    throw new NoAvailableCoreException(discType.ToString());

                case DiscType.AudioDisc:
                case DiscType.UnknownCDFS:
                case DiscType.UnknownFormat:
                    game.System = PreferredPlatformIsDefined(ext)
                                                        ? _config.PreferredPlatformsForExtensions[ext]
                                                        : "NULL";
                    break;

                default:                         //"for an unknown disc, default to psx instead of pce-cd, since that is far more likely to be what they are attempting to open" [5e07ab3ec3b8b8de9eae71b489b55d23a3909f55, year 2015]
                case DiscType.SonyPSX:
                    game.System = "PSX";
                    break;
                }
            }
            return(game);
        }
Ejemplo n.º 3
0
        private bool LoadDisc(string path, CoreComm nextComm, HawkFile file, string ext, out IEmulator nextEmulator, out GameInfo game)
        {
            var disc = DiscExtensions.CreateAnyType(path, str => DoLoadErrorCallback(str, "???", LoadErrorType.DiscError));

            if (disc == null)
            {
                game         = null;
                nextEmulator = null;
                return(false);
            }

            // TODO - use more sophisticated IDer
            var discType   = new DiscIdentifier(disc).DetectDiscType();
            var discHasher = new DiscHasher(disc);
            var discHash   = discType == DiscType.SonyPSX
                                ? discHasher.Calculate_PSX_BizIDHash().ToString("X8")
                                : discHasher.OldHash();

            game = Database.CheckDatabase(discHash);
            if (game == null)
            {
                // try to use our wizard methods
                game = new GameInfo {
                    Name = Path.GetFileNameWithoutExtension(file.Name), Hash = discHash
                };

                switch (discType)
                {
                case DiscType.SegaSaturn:
                    game.System = "SAT";
                    break;

                case DiscType.SonyPSP:
                    game.System = "PSP";
                    break;

                case DiscType.MegaCD:
                    game.System = "GEN";
                    break;

                case DiscType.PCFX:
                    game.System = "PCFX";
                    break;

                case DiscType.TurboGECD:
                case DiscType.TurboCD:
                    game.System = "PCECD";
                    break;

                case DiscType.Amiga:
                case DiscType.CDi:
                case DiscType.Dreamcast:
                case DiscType.GameCube:
                case DiscType.NeoGeoCD:
                case DiscType.Panasonic3DO:
                case DiscType.Playdia:
                case DiscType.Wii:
                    // no supported emulator core for these (yet)
                    game.System = discType.ToString();
                    throw new NoAvailableCoreException(discType.ToString());

                case DiscType.AudioDisc:
                case DiscType.UnknownCDFS:
                case DiscType.UnknownFormat:
                    game.System = PreferredPlatformIsDefined(ext)
                                                        ? _config.PreferredPlatformsForExtensions[ext]
                                                        : "NULL";
                    break;

                default:                         //"for an unknown disc, default to psx instead of pce-cd, since that is far more likely to be what they are attempting to open" [5e07ab3ec3b8b8de9eae71b489b55d23a3909f55, year 2015]
                case DiscType.SonyPSX:
                    game.System = "PSX";
                    break;
                }
            }

            var cip = new CoreInventoryParameters(this)
            {
                Comm  = nextComm,
                Game  = game,
                Discs =
                {
                    new DiscAsset
                    {
                        DiscData = disc,
                        DiscType = new DiscIdentifier(disc).DetectDiscType(),
                        DiscName = Path.GetFileNameWithoutExtension(path)
                    }
                },
            };

            nextEmulator = MakeCoreFromCoreInventory(cip);
            return(true);
        }