Exemple #1
0
        /// <summary>
        /// Get <see cref="GameInformation"/> from the given UMD device.
        /// </summary>
        /// <param name="device">The device containing the game.</param>
        /// <returns>A <see cref="GameInformation"/> instance representing the game, or <c>null</c> if an error occurred.</returns>
        public static GameInformation GetUmdGameInformation(IMediaDevice device)
        {
            IMediaFolder folder  = device.Root;
            IMediaFile   umdData = folder["UMD_DATA.BIN"] as IMediaFile;

            //[4 alpha country code]-[4 digit game id]|16 digit binhex|0001|G
            // Get code from SFO
            string uniqueId;

            using (StreamReader reader = new StreamReader(umdData.OpenRead()))
            {
                string   line = reader.ReadToEnd().Trim();
                string[] ps   = line.Split('|');
                uniqueId = ps[1];
            }

            IMediaFile sfoData = folder.FindFile(@"PSP_GAME\PARAM.SFO");

            GameParameters gameParams;

            using (Stream stream = sfoData.OpenRead())
                gameParams = ReadSfo(stream);

            // Only accept games
            if ((gameParams.Category != GameCategory.MemoryStickGame) &&
                (gameParams.Category != GameCategory.UmdGame))
            {
                return(null);
            }

            Stream     icon       = null;
            Stream     background = null;
            IMediaFile iconData   = folder.FindFile(@"PSP_GAME\ICON0.PNG");

            if (iconData != null)
            {
                icon = iconData.OpenRead();
            }
            IMediaFile bgData = folder.FindFile(@"PSP_GAME\PIC1.PNG");

            if (bgData != null)
            {
                background = bgData.OpenRead();
            }

            return(new GameInformation(GameType.UmdGame, folder, gameParams, icon, background, uniqueId));
        }
Exemple #2
0
        public void SetupGame(GameInformation game, Stream bootStream)
        {
            // Attempt to load symbols from game information
            bool debugInfoLoaded = false;

            if (bootStream != null)
            {
                debugInfoLoaded = this.LoadDebugData(DebugDataType.Symbols, bootStream);
            }

            // If nothing loaded, give the user a choice
            bool       skipLoadInfo = debugInfoLoaded;
            DebugSetup setup        = null;

            if (debugInfoLoaded == false)
            {
                setup = new DebugSetup();
                if (setup.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    skipLoadInfo = true;
                }
            }

            if (skipLoadInfo == false)
            {
                bool result = false;
                if (setup.UseElfDebug == true)
                {
                    IMediaFolder folder = game.Folder;
                    IMediaFile   file   = folder.FindFile("BOOT.BIN");
                    using (Stream stream = file.OpenRead())
                        result = this.LoadDebugData(DebugDataType.Elf, stream);
                }
                else
                {
                    Debug.Assert(false);
                }
                Debug.Assert(result == true);
                if (result == false)
                {
                    throw new InvalidOperationException("Could not load debugging data - cannot continue.");
                }
            }
        }