示例#1
0
 private void menu_menuReturn(object sender, EventArgs e)
 {
     menu.Active = false;
     renderer.ResetDrawState();
     renderer.ResetBuffer();
     renderer.Draw();
     if (!network.IsClient)
     {
         C64.Unpause();
     }
 }
示例#2
0
        public void Start()
        {
            network = new Network();
            network.screenReceived      += new ScreenReceived(network_screenReceived);
            network.keyEventReceived    += new KeyEventReceived(network_keyEventReceived);
            network.joyEventReceived    += new JoyEventReceived(network_joyEventReceived);
            network.clientConnected     += new ClientConnected(network_clientConnected);
            network.clientConnectFailed += new ClientConnectFailed(network_clientConnectFailed);
            network.clientDisconnected  += new ClientDisconnected(network_clientDisconnected);
            network.incomingClient      += new IncomingClient(network_incomingClient);
            network.partedClient        += new PartedClient(network_partedClient);

            Video.WindowIcon(Resources.c64icon);
            Video.WindowCaption = "Pipkinsoft C64 Emulator";

            renderer = new RendererSDL();

            menu             = new Menu(renderer, network);
            menu.menuReturn += new MenuReturn(menu_menuReturn);
            menu.menuQuit   += new MenuQuit(menu_menuQuit);

            try
            {
                C64.Start(renderer, network);
            }
            catch (Exception ex)
            {
                renderer.DrawError(ex.Message);
                Events.Quit += new EventHandler <QuitEventArgs>(Quit);
                Events.Run();
                return;
            }

            Joysticks.Initialize();

            if (Joysticks.NumberOfJoysticks > 0)
            {
                joy1 = Joysticks.OpenJoystick(0);
            }
            if (Joysticks.NumberOfJoysticks > 1)
            {
                joy2 = Joysticks.OpenJoystick(1);
            }

            Events.Quit               += new EventHandler <QuitEventArgs>(Quit);
            Events.KeyboardDown       += new EventHandler <KeyboardEventArgs>(KeyboardEvent);
            Events.KeyboardUp         += new EventHandler <KeyboardEventArgs>(KeyboardEvent);
            Events.JoystickAxisMotion += new EventHandler <JoystickAxisEventArgs>(JoystickAxisMotion);
            Events.JoystickButtonDown += new EventHandler <JoystickButtonEventArgs>(JoystickButtonEvent);
            Events.JoystickButtonUp   += new EventHandler <JoystickButtonEventArgs>(JoystickButtonEvent);

            Events.Run();
        }
示例#3
0
 private void processKey(KeyboardEventArgs k)
 {
     if (k.Key == Key.F9)
     {
         if (k.Down)
         {
             C64.FastForward();
         }
         else
         {
             C64.RegularSpeed();
         }
     }
     else if (k.Key == Key.F10)
     {
     }
     else if (k.Key == Key.F11)
     {
         if (!k.Down)
         {
             C64.cia1.SwitchJoysticks();
             renderer.DisplayStatus("Joysticks Switched");
         }
     }
     else if (k.Key == Key.F12)
     {
         if (!k.Down)
         {
             if (menu.Active)
             {
                 menu_menuReturn(null, null);
             }
             else
             {
                 if (!network.IsClient)
                 {
                     C64.Pause();
                 }
                 renderer.ResetDrawState();
                 menu.Active = true;
             }
         }
     }
     else if (menu.Active)
     {
         menu.KeyEvent(k);
     }
     else
     {
         C64.cia1.KeyEvent(k, false);
     }
 }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="disposing"></param>
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                C64.Dispose();
                if (network.IsHosting)
                {
                    network.HostEnd();
                }
                if (network.IsClient)
                {
                    network.ClientDisconnect();
                }
                renderer.Kill();

                this.disposed = true;
            }
        }
示例#5
0
        private void processCommand(string command, string[] args)
        {
            switch (command)
            {
            case "display":
                loadDisplayMenu();
                break;

            case "input":
                loadInputMenu();
                break;

            case "network":
                loadNetworkMenu();
                break;

            case "load":
                string appDir =
                    Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
                loadFileMenu(appDir);
                break;

            case "softreset":
                menuReturn(this, null);
                C64.SoftReset();
                break;

            case "hardreset":
                menuReturn(this, null);
                C64.HardReset();
                break;

            case "return":
                menuReturn(this, null);
                break;

            case "quit":
                menuQuit(this, null);
                break;

            case "main":
                loadMainMenu();
                break;

            case "fps.left":
            case "fps.right":
                renderer.DisplayFPS = !renderer.DisplayFPS;
                menuList[1].Text    = "Display FPS: " + (renderer.DisplayFPS ? "Yes" : "No");
                break;

            case "resolution":
                renderer.Reset(
                    args[0] == "fullscreen",
                    int.Parse(args[1]),
                    int.Parse(args[2])
                    );
                break;

            case "starthost":
                menuReturn(this, null);
                if (network.IsClient)
                {
                    network.ClientDisconnect();
                }
                network.HostBegin(Network.NETWORK_PORT);
                renderer.DisplayStatus("Started hosting");
                break;

            case "stophost":
                menuReturn(this, null);
                network.HostEnd();
                renderer.DisplayStatus("Stopped hosting");
                break;

            case "connect":
                menuReturn(this, null);
                Settings.Default.LastHost = args[0];
                if (network.IsHosting)
                {
                    network.HostEnd();
                }
                network.ClientConnect(args[0], Network.NETWORK_PORT);
                renderer.DisplayStatus("Trying to connect to host...");
                break;

            case "disconnect":
                menuReturn(this, null);
                network.ClientDisconnect();
                break;

            case "directory":
                loadFileMenu(args[0]);
                break;

            case "file":
                if (args[0] == "prg")
                {
                    C64.LoadProgram(args[1]);
                    menuReturn(this, null);
                    renderer.DisplayStatus("Program loaded into memory");
                }
                break;

            case "joy1map.left":
                int newMap = (int)C64.cia1.Joy1Map - 1;
                if (newMap == -1)
                {
                    newMap = 4;
                }
                C64.cia1.Joy1Map = (MapType)newMap;
                menuList[1].Text = "Joystick 1 Map: " + C64.cia1.Joy1Map.ToString();
                break;

            case "joy1map.right":
                newMap = (int)C64.cia1.Joy1Map + 1;
                if (newMap == 5)
                {
                    newMap = 0;
                }
                C64.cia1.Joy1Map = (MapType)newMap;
                menuList[1].Text = "Joystick 1 Map: " + C64.cia1.Joy1Map.ToString();
                break;

            case "joy2map.left":
                newMap = (int)C64.cia1.Joy2Map - 1;
                if (newMap == -1)
                {
                    newMap = 4;
                }
                C64.cia1.Joy2Map = (MapType)newMap;
                menuList[2].Text = "Joystick 2 Map: " + C64.cia1.Joy2Map.ToString();
                break;

            case "joy2map.right":
                newMap = (int)C64.cia1.Joy2Map + 1;
                if (newMap == 5)
                {
                    newMap = 0;
                }
                C64.cia1.Joy2Map = (MapType)newMap;
                menuList[2].Text = "Joystick 2 Map: " + C64.cia1.Joy2Map.ToString();
                break;

            case "editkey1":
                loadKeySetMenu(1);
                break;

            case "editkey2":
                loadKeySetMenu(2);
                break;
            }
        }
示例#6
0
 private void network_clientConnected(object sender, EventArgs e)
 {
     C64.Stop();
     renderer.ResetBuffer();
     renderer.DisplayStatus("Connected to host");
 }
示例#7
0
 private void network_clientDisconnected(object sender, EventArgs e)
 {
     C64.HardReset();
     renderer.DisplayStatus("Disconnected");
 }