Esempio n. 1
0
        private bool LoadDisc(string path, CoreComm nextComm, HawkFile file, string ext, string forcedCoreName, 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);
            }

            game = MakeGameFromDisc(disc, ext, Path.GetFileNameWithoutExtension(file.Name));

            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, forcedCoreName);
            return(true);
        }
Esempio n. 2
0
        private void LoadM3U(string path, CoreComm nextComm, HawkFile file, string forcedCoreName, out IEmulator nextEmulator, out GameInfo game)
        {
            M3U_File m3u;

            using (var sr = new StreamReader(path))
                m3u = M3U_File.Read(sr);
            if (m3u.Entries.Count == 0)
            {
                throw new InvalidOperationException("Can't load an empty M3U");
            }
            m3u.Rebase(Path.GetDirectoryName(path));

            var discs = m3u.Entries
                        .Select(e => e.Path)
                        .Where(p => Disc.IsValidExtension(Path.GetExtension(p)))
                        .Select(path => new
            {
                d = DiscExtensions.CreateAnyType(path, str => DoLoadErrorCallback(str, "???", LoadErrorType.DiscError)),
                p = path,
            })
                        .Where(a => a.d != null)
                        .Select(a => (IDiscAsset) new DiscAsset
            {
                DiscData = a.d,
                DiscType = new DiscIdentifier(a.d).DetectDiscType(),
                DiscName = Path.GetFileNameWithoutExtension(a.p)
            })
                        .ToList();

            if (m3u.Entries.Count == 0)
            {
                throw new InvalidOperationException("Couldn't load any contents of the M3U as discs");
            }

            game = MakeGameFromDisc(discs[0].DiscData, Path.GetExtension(m3u.Entries[0].Path), discs[0].DiscName);
            var cip = new CoreInventoryParameters(this)
            {
                Comm  = nextComm,
                Game  = game,
                Discs = discs
            };

            nextEmulator = MakeCoreFromCoreInventory(cip, forcedCoreName);
        }
Esempio 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);
        }