Esempio n. 1
0
        void Reset(string romFilename)
        {
            // Gameboy itself doesn't support reset so i see no reason to contrive one. Just create a fresh one

            // Wait for previous frame to finish drawing
            while (drawFrame)
            {
            }
            drawFrame = false;

            bool consoleWndVisibile = (consoleWindow != null) ? consoleWindow.Visible : false;
            bool bgWndVisibile      = (bgWnd != null) ? bgWnd.Visible : false;

            string rom = romFilename;

            dmg         = new DmgSystem();
            dmg.OnFrame = () => this.Draw();

            // Bit hacky, maintain breakpoints between reset
            List <Breakpoint> breakpoints = null;

            if (dbgConsole != null)
            {
                breakpoints = dbgConsole.Breakpoints;
            }
            dbgConsole = new DmgDebugConsole(dmg);
            if (breakpoints != null)
            {
                dbgConsole.Breakpoints = breakpoints;
            }

            if (consoleWindow != null)
            {
                consoleWindow.Dispose();
            }
            consoleWindow          = new DmgConsoleWindow(dmg, dbgConsole);
            consoleWindow.Visible  = consoleWndVisibile;
            consoleWindow.Location = new Point(Location.X + Width + 20, Location.Y);

            if (bgWnd != null)
            {
                bgWnd.Dispose();
            }
            bgWnd         = new BgWindow(dmg);
            bgWnd.Visible = bgWndVisibile;

            dmg.PowerOn(rom);

            this.Text = dmg.rom.RomName;
            dbgConsole.PeekSequentialInstructions();
            dbgConsole.DmgMode = DmgDebugConsole.Mode.Running;
        }
Esempio n. 2
0
        private void OnApplicationIdle(object sender, EventArgs e)
        {
            while (IsApplicationIdle())
            {
                if (dmg == null || dmg.PoweredOn == false)
                {
                    Thread.Sleep(10);
                    continue;
                }

                // The call to IsAppication Idle is actually quite exoensive. Let's execute a few instructions between calls to it.
                for (int i = 0; i < 256; i++)
                {
                    if (timer.ElapsedMilliseconds - elapsedMs >= 1000)
                    {
                        elapsedMs = timer.ElapsedMilliseconds;

                        fps         = framesDrawn;
                        framesDrawn = 0;
                    }


                    if (dbgConsole.DmgMode == DmgDebugConsole.Mode.Running)
                    {
                        dmg.Step();

                        if (dbgConsole.CheckForBreakpoints())
                        {
                            consoleWindow.RefreshDmgSnapshot();
                        }
                    }

                    else if (dbgConsole.DmgMode == DmgDebugConsole.Mode.BreakPoint &&
                             dbgConsole.BreakpointStepAvailable)
                    {
                        dbgConsole.OnPreBreakpointStep();
                        dmg.Step();
                        dbgConsole.PeekSequentialInstructions();
                        dbgConsole.OnPostBreakpointStep();
                        consoleWindow.RefreshDmgSnapshot();
                        consoleWindow.RefreshConsoleText();
                    }
                }
            }
        }