示例#1
0
        public static void ActiveGameGenie()
        {
            if (!NesEmu.EmulationON)
            {
                Program.VIDEO.WriteNotification("Game Genie can't be enabled while emulation is OFF.", 200, System.Drawing.Color.Red);
                return;
            }
            string filePath = Path.Combine(Settings.Folder_GameGenieCodes,
                                           Path.GetFileNameWithoutExtension(Program.CurrentGameFile) + ".ggc");

            if (File.Exists(filePath))
            {
                string[] lines = File.ReadAllLines(filePath);
                // Clear all
                if (lines.Length > 0)
                {
                    GameGenie            gameGenie = new GameGenie();
                    List <GameGenieCode> codes     = new List <GameGenieCode>();
                    // Add code by code
                    for (int i = 0; i < lines.Length; i++)
                    {
                        GameGenieCode newcode = new GameGenieCode();
                        newcode.Enabled = true;
                        newcode.Name    = lines[i];

                        if (lines[i].Length == 6)
                        {
                            newcode.Address   = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(lines[i]), 6) | 0x8000;
                            newcode.Value     = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(lines[i]), 6);
                            newcode.IsCompare = false;
                        }
                        else
                        {
                            newcode.Address   = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(lines[i]), 8) | 0x8000;
                            newcode.Value     = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(lines[i]), 8);
                            newcode.Compare   = gameGenie.GetGGCompareValue(gameGenie.GetCodeAsHEX(lines[i]));
                            newcode.IsCompare = true;
                        }
                        codes.Add(newcode);
                    }
                    if (codes.Count > 0)
                    {
                        NesEmu.SetupGameGenie(true, codes.ToArray());
                        Program.VIDEO.WriteNotification("Game Genie File Loaded; Game Genie enabled.", 200, System.Drawing.Color.Lime);
                    }
                    else
                    {
                        Program.VIDEO.WriteNotification("There is no Game Genie code to load.", 200, System.Drawing.Color.Red);
                    }
                }
                else
                {
                    Program.VIDEO.WriteNotification("Game Genie file is empty.", 200, System.Drawing.Color.Red);
                }
            }
            else
            {
                Program.VIDEO.WriteNotification("Game Genie file is not found.", 200, System.Drawing.Color.Red);
            }
        }
示例#2
0
 public override void Execute()
 {
     if (NesEmu.EmulationON)
     {
         NesEmu.EMUHardReset();
     }
     else
     {
         if (Program.CurrentGameFile != "")
         {
             if (File.Exists(Program.CurrentGameFile))
             {
                 Program.LoadRom(Program.CurrentGameFile);
                 Program.VIDEO.WriteNotification("HARD RESET", 120, System.Drawing.Color.Red);
                 NesEmu.EmulationPaused = false;
                 Program.PausedShowMenu = false;
             }
             else
             {
                 Program.VIDEO.WriteNotification("NO GAME LOADED !!", 120, System.Drawing.Color.Red);
             }
         }
         else
         {
             Program.VIDEO.WriteNotification("NO GAME LOADED !!", 120, System.Drawing.Color.Red);
         }
     }
 }
示例#3
0
            public override void Execute()
            {
                Settings.Audio_PlaybackEnabled      = audioPage.Items[0].SelectedOptionIndex == 1;
                Settings.Audio_PlaybackVolume       = audioPage.Items[1].SelectedOptionIndex;
                Settings.Audio_PlaybackFrequency    = audioPage.Items[2].SelectedOptionIndex == 0 ? 44100 : 48000;
                Settings.Audio_playback_sq1_enabled = audioPage.Items[3].SelectedOptionIndex == 1;
                Settings.Audio_playback_sq2_enabled = audioPage.Items[4].SelectedOptionIndex == 1;
                Settings.Audio_playback_dmc_enabled = audioPage.Items[5].SelectedOptionIndex == 1;
                Settings.Audio_playback_trl_enabled = audioPage.Items[6].SelectedOptionIndex == 1;
                Settings.Audio_playback_noz_enabled = audioPage.Items[7].SelectedOptionIndex == 1;

                // Apply on provider !!
                Program.AUDIO.Enabled = Settings.Audio_PlaybackEnabled;
                Program.AUDIO.Volume  = Settings.Audio_PlaybackVolume;

                NesEmu.SetupSoundPlayback(Program.AUDIO,
                                          Settings.Audio_PlaybackEnabled,
                                          Settings.Audio_PlaybackFrequency);
                NesEmu.audio_playback_dmc_enabled = Settings.Audio_playback_dmc_enabled;
                NesEmu.audio_playback_noz_enabled = Settings.Audio_playback_noz_enabled;
                NesEmu.audio_playback_sq1_enabled = Settings.Audio_playback_sq1_enabled;
                NesEmu.audio_playback_sq2_enabled = Settings.Audio_playback_sq2_enabled;
                NesEmu.audio_playback_trl_enabled = Settings.Audio_playback_trl_enabled;

                Settings.SaveSettings();
                Program.SelectRoom("settings");
            }
示例#4
0
        public override void Update()
        {
            if (mouse.Acquire().IsSuccess)
            {
                mousestate = mouse.GetCurrentState();

                oldTrigger = Trigger;
                Trigger    = mousestate.IsPressed((int)MouseObject.Button1);

                if (timer > 0)
                {
                    timer--;
                    pixelX = ((Cursor.Position.X - winPosX) * 256) / videoW;
                    if (pixelX < 0 || pixelX >= 256)
                    {
                        State = false;
                        return;
                    }
                    pixelY = ((Cursor.Position.Y - winPosY) * scanlinesCount) / videoH;
                    if (pixelY < 0 || pixelY >= scanlinesCount)
                    {
                        State = false;
                        return;
                    }
                    //System.Console.WriteLine(pixelX + ", " + pixelY);
                    for (int x = -15; x < 15; x++)
                    {
                        for (int y = -15; y < 15; y++)
                        {
                            if (pixelX + x < 256 && pixelX + x >= 0 && pixelY + y < scanlinesCount && pixelY + y >= 0)
                            {
                                c     = NesEmu.GetPixel(pixelX + x, pixelY + y);
                                r     = (byte)(c >> 0x10);            // R
                                g     = (byte)(c >> 0x08);            // G
                                b     = (byte)(c >> 0x00);            // B
                                State = (r > 85 && g > 85 && b > 85); //bright color ?
                            }
                            if (State)
                            {
                                break;
                            }
                        }
                        if (State)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    State = false;
                }
                if (!Trigger && oldTrigger)
                {
                    timer = 6;
                }
            }
        }
示例#5
0
 public override void Update()
 {
     oldTrigger = Trigger;
     Trigger    = Mouse.IsButtonPressed(MouseButton.PrimaryButton);
     if (timer > 0)
     {
         timer--;
         pixelX = ((Mouse.MousePosition.X - winPosX) * 256) / Program.VIDEO.ScreenWidth;
         if (pixelX < 0 || pixelX >= 256)
         {
             State = false;
             return;
         }
         pixelY = ((Mouse.MousePosition.Y - winPosY) * Program.VIDEO.scanlines) / Program.VIDEO.ScreenHeight;
         if (pixelY < 0 || pixelY >= Program.VIDEO.scanlines)
         {
             State = false;
             return;
         }
         //System.Console.WriteLine(pixelX + ", " + pixelY);
         for (int x = -15; x < 15; x++)
         {
             for (int y = -15; y < 15; y++)
             {
                 if (pixelX + x < 256 && pixelX + x >= 0 && pixelY + y < Program.VIDEO.scanlines && pixelY + y >= 0)
                 {
                     c = NesEmu.GetPixel(pixelX + x, pixelY + y);
                     r = (byte)(c >> 0x10);
                     // R
                     g = (byte)(c >> 0x08);
                     // G
                     b = (byte)(c >> 0x00);
                     // B
                     State = (r > 85 && g > 85 && b > 85);
                     //bright color ?
                 }
                 if (State)
                 {
                     break;
                 }
             }
             if (State)
             {
                 break;
             }
         }
     }
     else
     {
         State = false;
     }
     if (!Trigger && oldTrigger)
     {
         timer = 6;
     }
 }
示例#6
0
        private static void InitializeAudio()
        {
            AUDIO = new SDLAudio();
            NesEmu.SetupSoundPlayback(AUDIO, Settings.Audio_PlaybackEnabled, Settings.Audio_PlaybackFrequency);

            NesEmu.audio_playback_dmc_enabled = Settings.Audio_playback_dmc_enabled;
            NesEmu.audio_playback_noz_enabled = Settings.Audio_playback_noz_enabled;
            NesEmu.audio_playback_sq1_enabled = Settings.Audio_playback_sq1_enabled;
            NesEmu.audio_playback_sq2_enabled = Settings.Audio_playback_sq2_enabled;
            NesEmu.audio_playback_trl_enabled = Settings.Audio_playback_trl_enabled;
        }
示例#7
0
 public override void Execute()
 {
     if (NesEmu.EmulationON)
     {
         NesEmu.LoadState();
         Program.PausedShowMenu = false;
         NesEmu.EmulationPaused = false;
     }
     else
     {
         Program.VIDEO.WriteNotification("EMULATION IS OFF !!", 120, System.Drawing.Color.Red);
     }
 }
示例#8
0
        protected override void OnMenuOptionChanged()
        {
            switch (SelectedMenuIndex)
            {
            case 0:    // Region
            {
                switch (Items[0].SelectedOptionIndex)
                {
                case 0:
                    Settings.TvSystemSetting = "auto";
                    break;

                case 1:
                    Settings.TvSystemSetting = "ntsc";
                    break;

                case 2:
                    Settings.TvSystemSetting = "palb";
                    break;

                case 3:
                    Settings.TvSystemSetting = "dendy";
                    break;
                }
                break;
            }

            case 1:    // Connect 4 players
            {
                Settings.Key_Connect4Players = Items[1].SelectedOptionIndex == 1;
                NesEmu.IsFourPlayers         = Settings.Key_Connect4Players;
                break;
            }

            case 2:    // Connect Zapper
            {
                Settings.Key_ConnectZapper = Items[2].SelectedOptionIndex == 1;
                NesEmu.IsZapperConnected   = Settings.Key_ConnectZapper;
                if (NesEmu.IsZapperConnected)
                {
                    NesEmu.SetupZapper(new SDLZapper());
                    SdlDotNet.Input.Mouse.ShowCursor = true;
                }
                break;
            }
            }
        }
示例#9
0
        public static void InitializePalette()
        {
            NTSCPaletteGenerator.brightness = Settings.Palette_NTSC_brightness;
            NTSCPaletteGenerator.contrast   = Settings.Palette_NTSC_contrast;
            NTSCPaletteGenerator.gamma      = Settings.Palette_NTSC_gamma;
            NTSCPaletteGenerator.hue_tweak  = Settings.Palette_NTSC_hue_tweak;
            NTSCPaletteGenerator.saturation = Settings.Palette_NTSC_saturation;

            PALBPaletteGenerator.brightness = Settings.Palette_PALB_brightness;
            PALBPaletteGenerator.contrast   = Settings.Palette_PALB_contrast;
            PALBPaletteGenerator.gamma      = Settings.Palette_PALB_gamma;
            PALBPaletteGenerator.hue_tweak  = Settings.Palette_PALB_hue_tweak;
            PALBPaletteGenerator.saturation = Settings.Palette_PALB_saturation;

            if (Settings.Palette_AutoSelect)
            {
                switch (NesEmu.TVFormat)
                {
                case TVSystem.NTSC:
                    NesEmu.SetPalette(NTSCPaletteGenerator.GeneratePalette());
                    break;

                case TVSystem.DENDY:
                case TVSystem.PALB:
                    NesEmu.SetPalette(PALBPaletteGenerator.GeneratePalette());
                    break;
                }
            }
            else
            {
                if (Settings.Palette_UseNTSCPalette)
                {
                    NesEmu.SetPalette(NTSCPaletteGenerator.GeneratePalette());
                }
                else
                {
                    NesEmu.SetPalette(PALBPaletteGenerator.GeneratePalette());
                }
            }
        }
示例#10
0
            public override void Execute()
            {
                // Apply all codes !
                page._gameGenieCodes = new List <GameGenieCode>();
                bool enabled = page.Items[0].SelectedOptionIndex == 1;

                if (page.Items[3].Options[0] != "N/A")
                {
                    for (int i = 0; i < page.Items[3].Options.Count; i++)
                    {
                        if (page.Items[4].Options[0] != "" &&
                            page.Items[5].Options[0] != "ERROR")
                        {
                            GameGenieCode newcode = new GameGenieCode();
                            newcode.Enabled = true;
                            string code = page.Items[4].Options[0];
                            newcode.Name = code;
                            if (code.Length == 6)
                            {
                                newcode.Address   = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(code), 6) | 0x8000;
                                newcode.Value     = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(code), 6);
                                newcode.IsCompare = false;
                            }
                            else
                            {
                                newcode.Address   = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(code), 8) | 0x8000;
                                newcode.Value     = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(code), 8);
                                newcode.Compare   = gameGenie.GetGGCompareValue(gameGenie.GetCodeAsHEX(code));
                                newcode.IsCompare = true;
                            }
                            page._gameGenieCodes.Add(newcode);
                        }
                    }
                }

                NesEmu.SetupGameGenie(enabled, page._gameGenieCodes.ToArray());

                Program.SelectRoom("main menu");
            }
示例#11
0
 // IRQ
 public override void OnPPUScanlineTick()
 {
     // In frame signal
     irq_current_inframe = (NesEmu.IsInRender() && NesEmu.IsRenderingOn()) ? 0x40 : 0x00;
     if (irq_current_inframe == 0)
     {
         irq_current_inframe = 0x40;
         irq_current_counter = 0;
         irq_pending         = 0;
         NesEmu.IRQFlags    &= ~NesEmu.IRQ_BOARD;
     }
     else
     {
         irq_current_counter++;
         if (irq_current_counter == irq_line)
         {
             irq_pending = 0x80;     // IRQ pending flag is raised *regardless* of whether or not IRQs are enabled.
             if (irq_enable == 0x80) // Trigger an IRQ on the 6502 if both this flag *and* the IRQ enable flag is set.
             {
                 NesEmu.IRQFlags |= NesEmu.IRQ_BOARD;
             }
         }
     }
 }
示例#12
0
        //ok
        private void button1_Click(object sender, EventArgs e)
        {
            if (listView1.Items.Count == 0)
            {
                MessageBox.Show(Program.ResourceManager.GetString("Message_ThereIsNoCodeInTheList"));
                return;
            }
            //Nes.Board.IsGameGenieActive = checkBox1.Checked;
            List <GameGenieCode> codes = new List <GameGenieCode>();

            gameGenie = new GameGenie();
            foreach (ListViewItem item in listView1.Items)
            {
                GameGenieCode code = new GameGenieCode();
                code.Enabled     = item.Checked;
                code.Name        = item.Text;
                code.Descreption = item.SubItems[1].Text;
                if (item.Text.Length == 6)
                {
                    code.Address   = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(item.Text), 6) | 0x8000;
                    code.Value     = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(item.Text), 6);
                    code.IsCompare = false;
                }
                else
                {
                    code.Address   = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(item.Text), 8) | 0x8000;
                    code.Value     = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(item.Text), 8);
                    code.Compare   = gameGenie.GetGGCompareValue(gameGenie.GetCodeAsHEX(item.Text));
                    code.IsCompare = true;
                }
                //add to active list
                codes.Add(code);
            }
            NesEmu.SetupGameGenie(checkBox1.Checked, codes.ToArray());
            this.Close();
        }
示例#13
0
        public static void InitializeInput()
        {
            LoadShortcuts();
            NesEmu.IsFourPlayers     = Settings.Key_Connect4Players;
            NesEmu.IsZapperConnected = Settings.Key_ConnectZapper;
            IJoypadConnecter         joy1  = null;
            IJoypadConnecter         joy2  = null;
            IJoypadConnecter         joy3  = null;
            IJoypadConnecter         joy4  = null;
            IVSUnisystemDIPConnecter vsUni = null;

            Console.WriteLine(">Initializing input settings...");
            if (Settings.Key_P1_UseJoystick ||
                Settings.Key_P2_UseJoystick ||
                Settings.Key_P3_UseJoystick ||
                Settings.Key_P4_UseJoystick ||
                Settings.Key_VS_UseJoystick)
            {
                Console.WriteLine(">Initializing joysticks...");
                Joysticks.Initialize();
                Console.WriteLine("->Joysticks number = " + Joysticks.NumberOfJoysticks);
            }
            Console.WriteLine(">Applying key mappings...");
            #region Player 1
            if (!Settings.Key_P1_UseJoystick)
            {
                joy1 = new SDL_Keyboard_Joyad(0);
                Console.WriteLine("->Using keyboard for player 1.");
            }
            else
            {
                if (Joysticks.IsValidJoystickNumber(Settings.Key_P1_JoystickIndex))
                {
                    joy1 = new SDL_Joystick_Joypad(Settings.Key_P1_JoystickIndex, 0);
                    Console.WriteLine("->Using joystick for player 1.");
                }
                else
                {
                    // USE keyboard ?
                    joy1 = new SDL_Keyboard_Joyad(0);
                    Console.WriteLine("->Joystick is not connected; using keyboard for player 1.");
                }
            }
            #endregion
            #region Player 2
            if (!Settings.Key_P2_UseJoystick)
            {
                joy2 = new SDL_Keyboard_Joyad(1);
                Console.WriteLine("->Using keyboard for player 2.");
            }
            else
            {
                if (Joysticks.IsValidJoystickNumber(Settings.Key_P2_JoystickIndex))
                {
                    joy2 = new SDL_Joystick_Joypad(Settings.Key_P2_JoystickIndex, 1);
                    Console.WriteLine("->Using joystick for player 2.");
                }
                else
                {
                    // USE keyboard ?
                    joy2 = new SDL_Keyboard_Joyad(1);
                    Console.WriteLine("->Joystick is not connected; using keyboard for player 2.");
                }
            }
            #endregion
            #region Player 3
            if (!Settings.Key_P3_UseJoystick)
            {
                joy3 = new SDL_Keyboard_Joyad(2);
                Console.WriteLine("->Using keyboard for player 3.");
            }
            else
            {
                if (Joysticks.IsValidJoystickNumber(Settings.Key_P3_JoystickIndex))
                {
                    joy3 = new SDL_Joystick_Joypad(Settings.Key_P3_JoystickIndex, 2);
                    Console.WriteLine("->Using joystick for player 3.");
                }
                else
                {
                    // USE keyboard ?
                    joy3 = new SDL_Keyboard_Joyad(2);
                    Console.WriteLine("->Joystick is not connected; using keyboard for player 3.");
                }
            }
            #endregion
            #region Player 4
            if (!Settings.Key_P4_UseJoystick)
            {
                joy4 = new SDL_Keyboard_Joyad(3);
                Console.WriteLine("->Using keyboard for player 4.");
            }
            else
            {
                if (Joysticks.IsValidJoystickNumber(Settings.Key_P4_JoystickIndex))
                {
                    joy4 = new SDL_Joystick_Joypad(Settings.Key_P4_JoystickIndex, 3);
                    Console.WriteLine("->Using joystick for player 4.");
                }
                else
                {
                    // USE keyboard ?
                    joy4 = new SDL_Keyboard_Joyad(3);
                    Console.WriteLine("->Joystick is not connected; using keyboard for player 4.");
                }
            }
            #endregion
            #region VS Unisystem
            if (!Settings.Key_VS_UseJoystick)
            {
                vsUni = new SDL_Keyboard_VSUnisystem();
                Console.WriteLine("->Using keyboard for VS Unisystem PID.");
            }
            else
            {
                if (Joysticks.IsValidJoystickNumber(Settings.Key_VS_JoystickIndex))
                {
                    vsUni = new SDL_Joystick_VSUnisystem(Settings.Key_VS_JoystickIndex);
                    Console.WriteLine("->Using joystick for VS Unisystem PID.");
                }
                else
                {
                    // USE keyboard ?
                    vsUni = new SDL_Keyboard_VSUnisystem();
                    Console.WriteLine("->Joystick is not connected; using keyboard for VS Unisystem PID.");
                }
            }
            #endregion
            NesEmu.SetupJoypads(joy1, joy2, joy3, joy4);
            NesEmu.SetupVSUnisystemDIP(vsUni);
            NesEmu.IsZapperConnected = Settings.Key_ConnectZapper;
            NesEmu.IsFourPlayers     = Settings.Key_Connect4Players;
            if (NesEmu.IsZapperConnected)
            {
                Console.WriteLine("->ZAPPER IS CONNECTED !!");
                NesEmu.SetupZapper(new SDLZapper());
                SdlDotNet.Input.Mouse.ShowCursor = true;
            }
            if (NesEmu.IsFourPlayers)
            {
                Console.WriteLine("->4 PLAYERS IS CONNECTED !!");
            }
            Console.WriteLine(">Input settings initialized successfully.");
        }
示例#14
0
        private static void DoCommandLines(string[] args)
        {
            if (args == null)
            {
                return;
            }
            if (args.Length == 0)
            {
                return;
            }

            // Loop through commands and execute them one by one
            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i].ToLower())
                {
                case "/audio_on": Program.Settings.Audio_SoundEnabled = true; FormMain.InitializeSoundRenderer(); break;

                case "/audio_off": Program.Settings.Audio_SoundEnabled = false; FormMain.InitializeSoundRenderer(); break;

                case "/f_skip_off": Program.Settings.FrameSkip_Enabled = false; break;

                case "/f_skip_1": Program.Settings.FrameSkip_Enabled = true; Program.Settings.FrameSkip_Reload = 1; break;

                case "/f_skip_2": Program.Settings.FrameSkip_Enabled = true; Program.Settings.FrameSkip_Reload = 2; break;

                case "/f_skip_3": Program.Settings.FrameSkip_Enabled = true; Program.Settings.FrameSkip_Reload = 3; break;

                case "/f_skip_4": Program.Settings.FrameSkip_Enabled = true; Program.Settings.FrameSkip_Reload = 4; break;

                case "/f_skip_5": Program.Settings.FrameSkip_Enabled = true; Program.Settings.FrameSkip_Reload = 5; break;

                case "/f_skip_6": Program.Settings.FrameSkip_Enabled = true; Program.Settings.FrameSkip_Reload = 6; break;

                case "/f_skip_7": Program.Settings.FrameSkip_Enabled = true; Program.Settings.FrameSkip_Reload = 7; break;

                case "/f_skip_8": Program.Settings.FrameSkip_Enabled = true; Program.Settings.FrameSkip_Reload = 8; break;

                case "/f_skip_9": Program.Settings.FrameSkip_Enabled = true; Program.Settings.FrameSkip_Reload = 9; break;

                case "/pal_use_gen": Program.Settings.Palette_UseGenerators = true; break;

                case "/pal_dontuse_gen": Program.Settings.Palette_UseGenerators = false; break;

                case "/pal_gen_auto": Program.Settings.Palette_GeneratorUsageMode = PaletteGeneratorUsage.AUTO; break;

                case "/pal_gen_ntsc": Program.Settings.Palette_GeneratorUsageMode = PaletteGeneratorUsage.NTSC; break;

                case "/pal_gen_pal": Program.Settings.Palette_GeneratorUsageMode = PaletteGeneratorUsage.PAL; break;

                case "/sram_save_on": Program.Settings.SaveSramOnShutdown = true; break;

                case "/sram_save_off": Program.Settings.SaveSramOnShutdown = false; break;

                case "/show_issues_on": Program.Settings.ShowRomIssuesIfHave = true; break;

                case "/show_issues_off": Program.Settings.ShowRomIssuesIfHave = true; break;

                case "/tv_auto": Program.Settings.TVSystemSetting = Core.TVSystemSetting.AUTO; break;

                case "/tv_ntsc": Program.Settings.TVSystemSetting = Core.TVSystemSetting.NTSC; break;

                case "/tv_pal": Program.Settings.TVSystemSetting = Core.TVSystemSetting.PALB; break;

                case "/tv_dendy": Program.Settings.TVSystemSetting = Core.TVSystemSetting.DENDY; break;

                case "/vid_hide_lines_on": Program.Settings.Video_CutLines = true; break;

                case "/vid_hide_lines_off": Program.Settings.Video_CutLines = false; break;

                case "/vid_filter_point": Program.Settings.Video_Filter = SlimDX.Direct3D9.TextureFilter.Point; break;

                case "/vid_filter_none": Program.Settings.Video_Filter = SlimDX.Direct3D9.TextureFilter.None; break;

                case "/vid_filter_linear": Program.Settings.Video_Filter = SlimDX.Direct3D9.TextureFilter.Linear; break;

                case "/vid_vertex_hardware": Program.Settings.Video_HardwareVertexProcessing = true; break;

                case "/vid_vertex_software": Program.Settings.Video_HardwareVertexProcessing = false; break;

                case "/vid_keep_apsect_on": Program.Settings.Video_KeepAspectRatio = true; break;

                case "/vid_keep_apsect_off": Program.Settings.Video_KeepAspectRatio = false; break;

                case "/vid_fps_on": Program.Settings.Video_ShowFPS = true; break;

                case "/vid_fps_off": Program.Settings.Video_ShowFPS = false; break;

                case "/vid_noti_on": Program.Settings.Video_ShowNotifications = true; break;

                case "/vid_noti_off": Program.Settings.Video_ShowNotifications = false; break;

                case "/vid_fullscreen": Program.Settings.Video_StartFullscreen = true; break;

                case "/vid_wind": Program.Settings.Video_StartFullscreen = false; break;

                case "/vid_stretch_wind_on": Program.Settings.Video_StretchToMulti = true; break;

                case "/vid_stretch_wind_off": Program.Settings.Video_StretchToMulti = false; break;

                case "/state_slot_0": NesEmu.STATESlot = 0; break;

                case "/state_slot_1": NesEmu.STATESlot = 1; break;

                case "/state_slot_2": NesEmu.STATESlot = 2; break;

                case "/state_slot_3": NesEmu.STATESlot = 3; break;

                case "/state_slot_4": NesEmu.STATESlot = 4; break;

                case "/state_slot_5": NesEmu.STATESlot = 5; break;

                case "/state_slot_6": NesEmu.STATESlot = 6; break;

                case "/state_slot_7": NesEmu.STATESlot = 7; break;

                case "/state_slot_8": NesEmu.STATESlot = 8; break;

                case "/state_slot_9": NesEmu.STATESlot = 9; break;

                case "/state_load": NesEmu.LoadState(); break;    // Request a state load on the first rendered frame !
                }
            }

            // First command must be file path, run it here to apply commands first.
            if (File.Exists(args[0]))
            {
                FormMain.OpenRom(args[0]);
            }
        }
示例#15
0
        private void Resize(bool fullScreen, bool resizable, int w, int h)
        {
            if (Settings.Video_AutoResizeToFitEmu && NesEmu.EmulationON)
            {
                w = 256 * stretchMultiply;
                h = scanlines * stretchMultiply;
            }
            switch (NesEmu.TVFormat)
            {
            case TVSystem.NTSC:
            {
                Events.TargetFps = 60;
                scanlines        = 224;
                firstToCut       = 8;
                break;
            }

            case TVSystem.PALB:
            case TVSystem.DENDY:
            {
                Events.TargetFps = 50;
                scanlines        = 238;
                firstToCut       = 1;
                break;
            }
            }
            if (!cutLines)
            {
                scanlines  = 240;
                firstToCut = 0;
            }
            screenBufferSize = 256 * scanlines;
            originalRect     = new Rectangle(0, 0, 256, scanlines);
            screen_back      = new Surface(256, scanlines, 32);

            windowH = scanlines * stretchMultiply;

            pointer        = screen_back.Pixels;
            screen_pointer = (int *)screen_back.Pixels;
            NesEmu.SetupVideoRenderer(this, true, screen_back.Pixels, firstToCut * 256, 256 * (240 - firstToCut));
            // setup rectangles
            if (FullScreen)
            {
                if (!keepAspectRatio)
                {
                    destinationRect = new Rectangle(0, 0, fullscreenModes[FullScreenModeIndex].Width, fullscreenModes[FullScreenModeIndex].Height);
                }
                else
                {
                    destinationRect = GetRatioStretchRectangle(fullscreenModes[FullScreenModeIndex].Width, fullscreenModes[FullScreenModeIndex].Height);
                }
                if (!NesEmu.IsZapperConnected)
                {
                    SdlDotNet.Input.Mouse.ShowCursor = false;
                }
            }
            else
            {
                if (!keepAspectRatio)
                {
                    destinationRect = new Rectangle(0, 0, w, h);
                }
                else
                {
                    destinationRect = GetRatioStretchRectangle(w, h);
                }
                SdlDotNet.Input.Mouse.ShowCursor = true;
                Settings.Video_ScreenWidth       = w;
                Settings.Video_ScreenHeight      = h;
            }

            fpsTextSprite.X     = destinationRect.X + 2;
            fpsTextSprite.Y     = 2;
            fpsTextSprite.Color = Color.White;
            fpsTextSprite.Text  = "0/0";

            notTextSprite.X     = destinationRect.X + 2;
            notTextSprite.Y     = destinationRect.Height - 40;
            notTextSprite.Color = Color.White;
            notTextSprite.Text  = " ";

            soundRecordTextSprite.X     = destinationRect.X + 2;
            soundRecordTextSprite.Y     = 22;
            soundRecordTextSprite.Color = Color.White;
            soundRecordTextSprite.Text  = " ";

            statusTextSprite.X     = destinationRect.X + 2;
            statusTextSprite.Y     = 2;
            statusTextSprite.Color = Color.White;
            statusTextSprite.Text  = "0/0";
            // set video mode.
            if (fullScreen)
            {
                screen = Video.SetVideoMode(fullscreenModes[FullScreenModeIndex].Width, fullscreenModes[FullScreenModeIndex].Height, 32, resizable, openGL, true);
            }
            else
            {
                screen = Video.SetVideoMode(w, h, 32, resizable, openGL, false);
            }
        }
示例#16
0
 private void TestPALBPalette()
 {
     NesEmu.SetPalette(PALBPaletteGenerator.GeneratePalette());
 }
示例#17
0
        public SDLVideo(TVSystem system)
        {
            LoadSettings();
            initialized = false;
            canRender   = false;
            Console.WriteLine("->Initializing video ...");
            fontPath = System.IO.Path.Combine(Program.ApplicationFolder, "FreeSans.ttf");
            // Initialize the video
            Video.Initialize();
            Video.WindowIcon();
            Video.WindowCaption         = "My Nes SDL";
            fullscreenModes             = Video.ListModes();
            Video.GLDoubleBufferEnabled = !ImmediateMode;
            windowW = 256 * stretchMultiply;
            switch (system)
            {
            case TVSystem.NTSC:
            {
                Events.TargetFps = 60;
                break;
            }

            case TVSystem.PALB:
            case TVSystem.DENDY:
            {
                Events.TargetFps = 50;
                break;
            }
            }
            if (cutLines)
            {
                if (system == TVSystem.NTSC)
                {
                    scanlines  = 224;
                    firstToCut = 8;
                }
                else
                {
                    scanlines  = 238;
                    firstToCut = 1;
                }
            }
            else
            {
                scanlines  = 240;
                firstToCut = 0;
            }
            screenBufferSize = 256 * scanlines;
            originalRect     = new Rectangle(0, 0, 256, scanlines);
            screen_back      = new Surface(256, scanlines, 32);

            windowH = scanlines * stretchMultiply;

            pointer        = screen_back.Pixels;
            screen_pointer = (int *)screen_back.Pixels;
            NesEmu.SetupVideoRenderer(this, true, screen_back.Pixels, firstToCut * 256, 256 * (240 - firstToCut));
            // Create texts
            Console.WriteLine("-->Loading fonts ...");
            fpsTextSprite                         = new TextSprite(new SdlDotNet.Graphics.Font(fontPath, 15));
            fpsTextSprite.Color                   = Color.White;
            fpsTextSprite.BackgroundColor         = Color.Black;
            notTextSprite                         = new TextSprite(new SdlDotNet.Graphics.Font(fontPath, 15));
            notTextSprite.BackgroundColor         = Color.Black;
            soundRecordTextSprite                 = new TextSprite(new SdlDotNet.Graphics.Font(fontPath, 15));
            soundRecordTextSprite.BackgroundColor = Color.Black;
            statusTextSprite                      = new TextSprite(new SdlDotNet.Graphics.Font(fontPath, 15));
            statusTextSprite.BackgroundColor      = Color.Black;
            // set video mode.
            Resize(FullScreen, true, windowW, windowH);
            Events.VideoResize     += VideoResize;
            Events.MouseButtonDown += Events_MouseButtonDown;
            Events.MouseButtonUp   += Events_MouseButtonUp;
            Events.Tick            += OnTick;
            canRender   = true;
            initialized = true;
            Console.WriteLine("->Video initialized successfully");
        }
示例#18
0
        private static void CheckJoyShortcuts()
        {
            if (IsJoyButtonPressed(Settings.JoyKey_SwitchFullscreen))
            {
                VIDEO.SwitchFullscreen();
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_HardReset))
            {
                if (NesEmu.EmulationON)
                {
                    NesEmu.EMUHardReset();
                }
                else
                {
                    if (CurrentGameFile != "")
                    {
                        if (File.Exists(CurrentGameFile))
                        {
                            LoadRom(CurrentGameFile);
                        }
                    }
                }
                VIDEO.WriteNotification("HARD RESET", 120, System.Drawing.Color.Red);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_SoftReset))
            {
                NesEmu.EMUSoftReset();
                VIDEO.WriteNotification("SOFT RESET", 120, System.Drawing.Color.LightYellow);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_TakeSnap))
            {
                NesEmu.TakeSnapshot();
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_LoadState))
            {
                NesEmu.LoadState();
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_SaveState))
            {
                NesEmu.SaveState();
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_ShutdownEmu))
            {
                NesEmu.EmulationON = false;
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_StateSlot0))
            {
                NesEmu.UpdateStateSlot(0);
                VIDEO.WriteNotification("STATE SLOT SET TO 0", 120, System.Drawing.Color.Lime);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_StateSlot1))
            {
                NesEmu.UpdateStateSlot(1);
                VIDEO.WriteNotification("STATE SLOT SET TO 1", 120, System.Drawing.Color.Lime);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_StateSlot2))
            {
                NesEmu.UpdateStateSlot(2);
                VIDEO.WriteNotification("STATE SLOT SET TO 2", 120, System.Drawing.Color.Lime);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_StateSlot3))
            {
                NesEmu.UpdateStateSlot(3);
                VIDEO.WriteNotification("STATE SLOT SET TO 3", 120, System.Drawing.Color.Lime);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_StateSlot4))
            {
                NesEmu.UpdateStateSlot(4);
                VIDEO.WriteNotification("STATE SLOT SET TO 4", 120, System.Drawing.Color.Lime);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_StateSlot5))
            {
                NesEmu.UpdateStateSlot(5);
                VIDEO.WriteNotification("STATE SLOT SET TO 5", 120, System.Drawing.Color.Lime);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_StateSlot6))
            {
                NesEmu.UpdateStateSlot(6);
                VIDEO.WriteNotification("STATE SLOT SET TO 6", 120, System.Drawing.Color.Lime);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_StateSlot7))
            {
                NesEmu.UpdateStateSlot(7);
                VIDEO.WriteNotification("STATE SLOT SET TO 7", 120, System.Drawing.Color.Lime);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_StateSlot8))
            {
                NesEmu.UpdateStateSlot(8);
                VIDEO.WriteNotification("STATE SLOT SET TO 8", 120, System.Drawing.Color.Lime);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_StateSlot9))
            {
                NesEmu.UpdateStateSlot(9);
                VIDEO.WriteNotification("STATE SLOT SET TO 9", 120, System.Drawing.Color.Lime);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_TogglePause))
            {
                NesEmu.EmulationPaused = !NesEmu.EmulationPaused;
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_ToggleTurbo))
            {
                NesEmu.SpeedLimitterON = !NesEmu.SpeedLimitterON;
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_RecordSound))
            {
                if (AUDIO.IsRecording)
                {
                    AUDIO.StopRecord();
                }
                else
                {
                    AUDIO.Record();
                }
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_ToggleFrameSkip))
            {
                Settings.FrameSkipEnabled = !Settings.FrameSkipEnabled;
                NesEmu.SetupFrameSkip(Settings.FrameSkipEnabled, (byte)Settings.FrameSkipCount);

                VIDEO.WriteNotification(Settings.FrameSkipEnabled ? "Frame skip enabled." : "Frame skip disabled.", 120, System.Drawing.Color.White);
            }
            else if (IsJoyButtonPressed(Settings.JoyKey_ShowGameStatus))
            {
                VIDEO.ShowGameStatus();
            }
        }
示例#19
0
 private void TestNTSCPalette()
 {
     NesEmu.SetPalette(NTSCPaletteGenerator.GeneratePalette());
 }
示例#20
0
        private static void OnKeyDown(object sender, SdlDotNet.Input.KeyboardEventArgs e)
        {
            if (PausedShowMenu)
            {
                Rooms[RoomIndex].DoKeyDown(e);
                if (e.Key == Key.Tab)
                {
                    NesEmu.EmulationPaused = false;
                    PausedShowMenu         = false;
                    Rooms[RoomIndex].OnTabResume();
                }
                return;
            }

            if (e.Key == Key.Escape)
            {
                Quit();
            }
            else if (e.Key == Key.Tab)
            {
                if (!PausedShowMenu)
                {
                    NesEmu.EmulationPaused = true;
                    SelectRoom("main menu");
                    PausedShowMenu = true;
                }
                else
                {
                    NesEmu.EmulationPaused = false;
                    PausedShowMenu         = false;
                }
            }
            else if (e.Key == Key_SwitchFullscreen)
            {
                VIDEO.SwitchFullscreen();
            }
            else if (e.Key == Key_HardReset)
            {
                if (NesEmu.EmulationON)
                {
                    NesEmu.EMUHardReset();
                }
                else
                {
                    if (CurrentGameFile != "")
                    {
                        if (File.Exists(CurrentGameFile))
                        {
                            LoadRom(CurrentGameFile);
                        }
                    }
                }
                VIDEO.WriteNotification("HARD RESET", 120, System.Drawing.Color.Red);
            }
            else if (e.Key == Key_SoftReset)
            {
                NesEmu.EMUSoftReset();
                VIDEO.WriteNotification("SOFT RESET", 120, System.Drawing.Color.LightYellow);
            }
            else if (e.Key == Key_TakeSnap)
            {
                NesEmu.TakeSnapshot();
            }
            else if (e.Key == Key_LoadState)
            {
                NesEmu.LoadState();
            }
            else if (e.Key == Key_SaveState)
            {
                NesEmu.SaveState();
            }
            else if (e.Key == Key_ShutdownEmu)
            {
                NesEmu.EmulationON = false;
            }
            else if (e.Key == Key_StateSlot0)
            {
                NesEmu.UpdateStateSlot(0);
                VIDEO.WriteNotification("STATE SLOT SET TO 0", 120, System.Drawing.Color.Lime);
            }
            else if (e.Key == Key_StateSlot1)
            {
                NesEmu.UpdateStateSlot(1);
                VIDEO.WriteNotification("STATE SLOT SET TO 1", 120, System.Drawing.Color.Lime);
            }
            else if (e.Key == Key_StateSlot2)
            {
                NesEmu.UpdateStateSlot(2);
                VIDEO.WriteNotification("STATE SLOT SET TO 2", 120, System.Drawing.Color.Lime);
            }
            else if (e.Key == Key_StateSlot3)
            {
                NesEmu.UpdateStateSlot(3);
                VIDEO.WriteNotification("STATE SLOT SET TO 3", 120, System.Drawing.Color.Lime);
            }
            else if (e.Key == Key_StateSlot4)
            {
                NesEmu.UpdateStateSlot(4);
                VIDEO.WriteNotification("STATE SLOT SET TO 4", 120, System.Drawing.Color.Lime);
            }
            else if (e.Key == Key_StateSlot5)
            {
                NesEmu.UpdateStateSlot(5);
                VIDEO.WriteNotification("STATE SLOT SET TO 5", 120, System.Drawing.Color.Lime);
            }
            else if (e.Key == Key_StateSlot6)
            {
                NesEmu.UpdateStateSlot(6);
                VIDEO.WriteNotification("STATE SLOT SET TO 6", 120, System.Drawing.Color.Lime);
            }
            else if (e.Key == Key_StateSlot7)
            {
                NesEmu.UpdateStateSlot(7);
                VIDEO.WriteNotification("STATE SLOT SET TO 7", 120, System.Drawing.Color.Lime);
            }
            else if (e.Key == Key_StateSlot8)
            {
                NesEmu.UpdateStateSlot(8);
                VIDEO.WriteNotification("STATE SLOT SET TO 8", 120, System.Drawing.Color.Lime);
            }
            else if (e.Key == Key_StateSlot9)
            {
                NesEmu.UpdateStateSlot(9);
                VIDEO.WriteNotification("STATE SLOT SET TO 9", 120, System.Drawing.Color.Lime);
            }
            else if (e.Key == Key_TogglePause)
            {
                NesEmu.EmulationPaused = !NesEmu.EmulationPaused;
            }
            else if (e.Key == Key_ToggleTurbo)
            {
                NesEmu.SpeedLimitterON = !NesEmu.SpeedLimitterON;
            }
            else if (e.Key == Key_RecordSound)
            {
                if (AUDIO.IsRecording)
                {
                    AUDIO.StopRecord();
                }
                else
                {
                    AUDIO.Record();
                }
            }
            else if (e.Key == Key_ToggleFrameSkip)
            {
                Settings.FrameSkipEnabled = !Settings.FrameSkipEnabled;
                NesEmu.SetupFrameSkip(Settings.FrameSkipEnabled, (byte)Settings.FrameSkipCount);

                VIDEO.WriteNotification(Settings.FrameSkipEnabled ? "Frame skip enabled." : "Frame skip disabled.", 120, System.Drawing.Color.White);
            }
            else if (e.Key == Key.KeypadPlus || e.Key == Key.Plus)
            {
                if (AUDIO.Volume + 10 < 100)
                {
                    AUDIO.Volume += 10;
                }
                else
                {
                    AUDIO.Volume = 100;
                }
                VIDEO.WriteNotification("VOLUME " + AUDIO.Volume + " %", 120, System.Drawing.Color.Lime);
            }
            else if (e.Key == Key.Minus || e.Key == Key.KeypadMinus)
            {
                if (AUDIO.Volume - 10 > 0)
                {
                    AUDIO.Volume -= 10;
                }
                else
                {
                    AUDIO.Volume = 0;
                }
                VIDEO.WriteNotification("VOLUME " + AUDIO.Volume + " %", 120, System.Drawing.Color.Lime);
            }
            else if (e.Key == Key_ShowGameStatus)
            {
                VIDEO.ShowGameStatus();
            }
        }
示例#21
0
        public static void ApplyEmuSettings()
        {
            NesEmu.ApplySettings(Settings.SaveSRAMOnShutdown, Settings.Folder_SRAM, Settings.Folder_STATE, Settings.Folder_SNAPS, Settings.SnapsFormat, Settings.SnapReplace);

            NesEmu.SetupFrameSkip(Settings.FrameSkipEnabled, (byte)Settings.FrameSkipCount);
        }
示例#22
0
        public static void LoadRom(string fileName)
        {
            CurrentGameFile = fileName;

            NesEmu.EmulationPaused = true;
            // Make sure it's still paused !
            bool   is_supported_mapper = false;
            bool   has_issues          = false;
            string issues = "";

            if (NesEmu.CheckRom(fileName, out is_supported_mapper, out has_issues, out issues))
            {
                if (!is_supported_mapper)
                {
                    Console.WriteLine("** MAPPER IS NOT SUPPORTED !!");
                    Console.WriteLine("** RUNNING WITH DEFAULT MAPPER CONFIGURATION");
                }
                if (has_issues)
                {
                    Console.WriteLine("** " + issues);
                }
                NesEmu.EmulationON     = false;
                NesEmu.EmulationPaused = true;
                // Kill the original thread
                if (NesEmu.EmulationThread != null)
                {
                    if (NesEmu.EmulationThread.IsAlive)
                    {
                        NesEmu.EmulationThread.Abort();
                    }
                }

                // Create new
                TVSystemSetting sett = TVSystemSetting.AUTO;
                switch (Settings.TvSystemSetting.ToLower())
                {
                case "auto":
                    sett = TVSystemSetting.AUTO;
                    break;

                case "ntsc":
                    sett = TVSystemSetting.NTSC;
                    break;

                case "palb":
                    sett = TVSystemSetting.PALB;
                    break;

                case "dendy":
                    sett = TVSystemSetting.DENDY;
                    break;
                }
                NesEmu.CreateNew(fileName, sett, true);

                VIDEO.SetWindowTitle();
                InitializePalette();// Confirm palette selection !
                NesEmu.EmulationPaused = true;
            }
            else
            {
                Console.WriteLine(@"** MY NES CAN'T RUN THIS GAME !!");
                if (!is_supported_mapper)
                {
                    Console.WriteLine("** MAPPER IS NOT SUPPORTED !!");
                    Console.WriteLine("** RUNNING WITH DEFAULT MAPPER CONFIGURATION");
                }
                if (has_issues)
                {
                    Console.WriteLine("** " + issues);
                }
                if (NesEmu.EmulationON)
                {
                    NesEmu.EmulationPaused = false;
                }
            }
        }
示例#23
0
        private static void ExecuteCommands(string[] commands)
        {
            if (commands == null)
            {
                return;
            }
            if (commands.Length == 0)
            {
                return;
            }
            // Commands that can be ued for emu
            foreach (string command in commands)
            {
                switch (command.ToLower())
                {
                case "record_sound":
                    AUDIO.Record();
                    break;

                case "gamegenie_enable":
                    ActiveGameGenie();
                    break;

                case "state_slot_0":
                    NesEmu.UpdateStateSlot(0);
                    break;

                case "state_slot_1":
                    NesEmu.UpdateStateSlot(1);
                    break;

                case "state_slot_2":
                    NesEmu.UpdateStateSlot(2);
                    break;

                case "state_slot_3":
                    NesEmu.UpdateStateSlot(3);
                    break;

                case "state_slot_4":
                    NesEmu.UpdateStateSlot(4);
                    break;

                case "state_slot_5":
                    NesEmu.UpdateStateSlot(5);
                    break;

                case "state_slot_6":
                    NesEmu.UpdateStateSlot(6);
                    break;

                case "state_slot_7":
                    NesEmu.UpdateStateSlot(7);
                    break;

                case "state_slot_8":
                    NesEmu.UpdateStateSlot(8);
                    break;

                case "state_slot_9":
                    NesEmu.UpdateStateSlot(9);
                    break;

                case "state_load":    // Request a state load on the first rendered frame !
                    NesEmu.LoadState();
                    break;
                }
            }
        }
示例#24
0
        static void Main(string[] args)
        {
            // Working directory
            WorkingFolder     = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            WorkingFolder     = Path.Combine(WorkingFolder, "MyNes");
            ApplicationFolder = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]);
            Directory.CreateDirectory(WorkingFolder);
            // NES
            NesEmu.WarmUp();
            // Database
            NesCartDatabase.LoadDatabase(Path.Combine(ApplicationFolder, "database.xml"));
            // Load settings !
            Settings.LoadSettings();
            // Execute commands
            Settings.ExecuteCommands(args);

            // Apply settings.
            ApplyEmuSettings();

            // Initialize providers
            InitializeVideo();
            InitializeAudio();
            InitializeInput();
            InitializePalette();
            // Initialize rooms (menus)
            InitializeMenus();
            // Load the rom !
            if (args != null)
            {
                if (args.Length > 0)
                {
                    // First arg must be rom path !
                    if (File.Exists(args[0]))
                    {
                        LoadRom(args[0]);
                    }
                    else
                    {
                        Console.WriteLine("File is not exist at: " + args[0]);
                    }
                }
            }
            // Execute commands of the emulation
            if (NesEmu.EmulationON)
            {
                ExecuteCommands(args);
            }

            // Run SDL
            Events.KeyboardDown       += OnKeyDown;
            Events.JoystickButtonDown += OnJoystickButtonDown;
            Events.JoystickAxisMotion += OnJoystickAxisMove;
            Events.Quit += OnQuit;

            NesEmu.EmulationPaused = false;

            Events.Run();

            // Reached here means everything is done.
            Settings.SaveSettings();
        }