Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
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;
                }
            }
        }