コード例 #1
0
ファイル: Console.cs プロジェクト: UncleJey/unity-nes-blob
        /// <summary>
        /// Loads a cartridge into the console.
        /// </summary>
        /// <remarks>
        /// Logs information about the cartridge to stdout while loading including
        /// any errors that would cause the method to return <c>false</c>.
        /// </remarks>
        /// <returns><c>true</c>, if cartridge was loaded successfully, <c>false</c> otherwise.</returns>
        /// <param name="path">Path to the iNES cartridge file to load</param>
        public bool LoadCartridge(string path)
        {
                #if UNITY_EDITOR
            UnityEngine.Debug.Log("Loading ROM " + path);
                #endif

            Cartridge = new Cartridge(path);
            if (Cartridge.Invalid)
            {
                return(false);
            }

            // Set mapper
            System.Console.Write("iNES Mapper Number: " + Cartridge.MapperNumber.ToString());
            switch (Cartridge.MapperNumber)
            {
            case 0:
                                #if UNITY_EDITOR
                UnityEngine.Debug.Log(" (NROM) Supported!");
                                #endif
                Mapper = new NromMapper(this);
                break;

            case 1:
                                #if UNITY_EDITOR
                UnityEngine.Debug.Log(" (MMC1) Supported!");
                                #endif
                Mapper = new Mmc1Mapper(this);
                break;

            case 2:
                                        #if UNITY_EDITOR
                UnityEngine.Debug.Log(" (UxROM) Supported!");
                                #endif
                Mapper = new UxRomMapper(this);
                break;

            case 4:
                                #if UNITY_EDITOR
                UnityEngine.Debug.Log(" (MMC3) Supported!");
                                #endif
                Mapper = new Mmc3Mapper(this);
                break;

            default:
                                #if UNITY_EDITOR
                UnityEngine.Debug.Log(" mapper is not supported");
                                #endif
                return(false);
            }

            Cpu.Reset();
            Ppu.Reset();

            CpuMemory.Reset();
            PpuMemory.Reset();

            _frameEvenOdd = false;
            return(true);
        }
コード例 #2
0
ファイル: Console.cs プロジェクト: mrbiggbrain/nescafe
        /// <summary>
        /// Loads a cartridge into the console.
        /// </summary>
        /// <remarks>
        /// Logs information about the cartridge to stdout while loading including
        /// any errors that would cause the method to return <c>false</c>.
        /// </remarks>
        /// <returns><c>true</c>, if cartridge was loaded successfully, <c>false</c> otherwise.</returns>
        /// <param name="path">Path to the iNES cartridge file to load</param>
        public bool LoadCartridge(string path)
        {
            System.Console.WriteLine("Loading ROM " + path);

            Cartridge = new Cartridge(path);
            if (Cartridge.Invalid) return false;

            // Set mapper
            System.Console.Write("iNES Mapper Number: " + Cartridge.MapperNumber.ToString());
            switch (Cartridge.MapperNumber)
            {
                case 0:
                    System.Console.WriteLine(" (NROM) Supported!");
                    Mapper = new NromMapper(this);
                    break;
                case 1:
                    System.Console.WriteLine(" (MMC1) Supported!");
                    Mapper = new Mmc1Mapper(this);
                    break;
                case 2:
                    System.Console.WriteLine(" (UxROM) Supported!");
                    Mapper = new UxRomMapper(this);
                    break;
                case 4:
                    System.Console.WriteLine(" (MMC3) Supported!");
                    Mapper = new Mmc3Mapper(this);
                    break;
                default:
                    System.Console.WriteLine(" mapper is not supported");
                    return false;
            }

            Cpu.Reset();
            Ppu.Reset();

            CpuMemory.Reset();
            PpuMemory.Reset();

            _frameEvenOdd = false;
            return true;
        }