Ejemplo n.º 1
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            //use dialog obeject to get rom file
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                if (chip8.IsOn())
                {
                    if (chip8.DebugMode)
                    {
                        //swaping in a new game while debugger window is open and processing
                        if (chip8.isCpuRunning())
                        {
                            chip8.connectDisplay(null);
                            chip8.powerOff();
                        }
                        chip8.setDebuggerInterface(null);
                        chip8.clearDisplay();
                        screen.UpdateLayout();

                        chip8 = new Chip8();
                        chip8.connectDisplay(screen);
                        chip8.loadGame(openFileDialog.FileName);
                        debuggerWindow.Chip8 = chip8;
                        debuggerWindow.initRoutine();
                    }
                    else
                    {
                        //swaping in a new game when only the main window is open
                        chip8.swapGame(openFileDialog.FileName);
                    }
                }
                else
                {
                    chip8.loadGame(openFileDialog.FileName);
                    chip8.powerOn();

                    if (chip8.DebugMode)// debugger window is open but no game is being processed by it
                    {
                        debuggerWindow.initRoutine();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void workerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                //cpuHalt flag controls the state of the Chip8 when the Cpu loop thread ends
                //If cpuHalt is true, the thread that is currently carrying out the cpu loop will end without altering
                //the current state of the chip8, thus, if desired, a new Cpu thread can be invoked and start
                //executing from the last state processed by the previous cpu loop thread
                //If false, the chip8 properties are re-initilizing to the state it was in prior to the excution of the rom
                if (!cpuHalt)
                {
                    String path = game.Path;
                    init();
                    if (swapGameFlag)
                    {
                        swapGameFlag = false;
                        loadGame(gameToBeLoaded);
                        worker = null;
                        cpuCycle();
                    }
                    else
                    {
                        loadGame(path);
                    }

                    //exectued if reset() is called to end chip8 simulation
                    if (resetFlag)
                    {
                        resetFlag = false;
                        worker    = null;
                        powerOn();
                        debuggerWindow.initRoutine();
                    }
                }


                //Set by a breakpoint being flagged which can only occur if the chip8 debugMode variable is set to true
                if (breakPointFlag)
                {
                    breakPointFlag = false;
                    debuggerWindow.breakPointPause();
                    debuggerWindow.BreakPointTrigger = true;
                }
            }
        }