Esempio n. 1
0
        public static void CloseWindows(CoprocessorType coprocessorType)
        {
            if (coprocessorType != CoprocessorType.CX4)
            {
                CloseWindows(CpuType.Cx4);
            }
            if (coprocessorType != CoprocessorType.GSU)
            {
                CloseWindows(CpuType.Gsu);
            }
            if (coprocessorType != CoprocessorType.SA1)
            {
                CloseWindows(CpuType.Sa1);
            }
            if (coprocessorType < CoprocessorType.DSP1 && coprocessorType > CoprocessorType.DSP4 && coprocessorType != CoprocessorType.ST010 && coprocessorType != CoprocessorType.ST011)
            {
                CloseWindows(CpuType.NecDsp);
            }

            if (coprocessorType == CoprocessorType.Gameboy)
            {
                CloseWindows(CpuType.Cpu);
                CloseWindows(CpuType.Spc);
            }

            if (coprocessorType != CoprocessorType.Gameboy && coprocessorType != CoprocessorType.SGB)
            {
                CloseWindows(CpuType.Gameboy);
            }
        }
Esempio n. 2
0
        private void UpdateTabs()
        {
            tabMain.SelectedIndexChanged -= tabMain_SelectedIndexChanged;
            _coprocessorType              = EmuApi.GetRomInfo().CoprocessorType;

            tabMain.TabPages.Clear();
            if (_coprocessorType != CoprocessorType.Gameboy)
            {
                tabMain.TabPages.AddRange(new TabPage[] { tpgCpu, tpgDma, tpgPpu, tpgSpc, tpgDsp });
                tabMain.SelectedTab = tpgCpu;
            }

            if (_coprocessorType == CoprocessorType.SA1 || _coprocessorType == CoprocessorType.Gameboy || _coprocessorType == CoprocessorType.SGB)
            {
                tpgCoprocessor       = new TabPage();
                tpgCoprocessor.Text  = _coprocessorType == CoprocessorType.SA1 ? "SA-1" : "Gameboy";
                ctrlCoprocessor      = new ctrlPropertyList();
                ctrlCoprocessor.Dock = DockStyle.Fill;
                tpgCoprocessor.Controls.Add(ctrlCoprocessor);
                tabMain.TabPages.Add(tpgCoprocessor);

                if (_coprocessorType == CoprocessorType.Gameboy)
                {
                    tabMain.SelectedTab = tpgCoprocessor;
                }
            }

            ctrlScanlineCycleSelect.Initialize(ctrlScanlineCycleSelect.Scanline, ctrlScanlineCycleSelect.Cycle, EmuApi.GetRomInfo().CoprocessorType == CoprocessorType.Gameboy ? CpuType.Gameboy : CpuType.Cpu);

            tabMain.SelectedIndexChanged += tabMain_SelectedIndexChanged;
        }
Esempio n. 3
0
        public static CpuType?ToCpuType(this CoprocessorType type)
        {
            switch (type)
            {
            case CoprocessorType.CX4:
                return(CpuType.Cx4);

            case CoprocessorType.DSP1:
            case CoprocessorType.DSP1B:
            case CoprocessorType.DSP2:
            case CoprocessorType.DSP3:
            case CoprocessorType.DSP4:
                return(CpuType.NecDsp);

            case CoprocessorType.SA1:
                return(CpuType.Sa1);

            case CoprocessorType.GSU:
                return(CpuType.Gsu);

            case CoprocessorType.Gameboy:
            case CoprocessorType.SGB:
                return(CpuType.Gameboy);

            default:
                return(null);
            }
        }
Esempio n. 4
0
        private InteropTraceLoggerOptions GetInteropOptions(bool disableLogging = false)
        {
            _entityBinder.UpdateObject();
            TraceLoggerOptions options = (TraceLoggerOptions)_entityBinder.Entity;

            CoprocessorType coproc = EmuApi.GetRomInfo().CoprocessorType;

            InteropTraceLoggerOptions interopOptions = new InteropTraceLoggerOptions();

            interopOptions.LogCpu         = !disableLogging && options.LogCpu && coproc != CoprocessorType.Gameboy;
            interopOptions.LogSpc         = !disableLogging && options.LogSpc && coproc != CoprocessorType.Gameboy;
            interopOptions.LogNecDsp      = !disableLogging && options.LogNecDsp;
            interopOptions.LogSa1         = !disableLogging && options.LogSa1;
            interopOptions.LogGsu         = !disableLogging && options.LogGsu;
            interopOptions.LogCx4         = !disableLogging && options.LogCx4;
            interopOptions.LogGameboy     = !disableLogging && options.LogGameboy;
            interopOptions.IndentCode     = options.IndentCode;
            interopOptions.ShowExtraInfo  = options.ShowExtraInfo;
            interopOptions.UseLabels      = options.UseLabels;
            interopOptions.UseWindowsEol  = options.UseWindowsEol;
            interopOptions.ExtendZeroPage = options.ExtendZeroPage;

            interopOptions.Condition = Encoding.UTF8.GetBytes(txtCondition.Text);
            Array.Resize(ref interopOptions.Condition, 1000);

            interopOptions.Format = Encoding.UTF8.GetBytes(txtFormat.Text.Replace("\t", "\\t"));
            Array.Resize(ref interopOptions.Format, 1000);

            return(interopOptions);
        }
Esempio n. 5
0
        private void UpdateDebuggerMenu()
        {
            bool running = EmuRunner.IsRunning();

            mnuDebugger.Enabled    = running;
            mnuSpcDebugger.Enabled = running;

            CoprocessorType coprocessor = EmuApi.GetRomInfo().CoprocessorType;

            mnuSa1Debugger.Enabled = coprocessor == CoprocessorType.SA1;
            mnuSa1Debugger.Visible = coprocessor == CoprocessorType.SA1;

            mnuGsuDebugger.Enabled = coprocessor == CoprocessorType.GSU;
            mnuGsuDebugger.Visible = coprocessor == CoprocessorType.GSU;

            mnuTraceLogger.Enabled    = running;
            mnuScriptWindow.Enabled   = running;
            mnuMemoryTools.Enabled    = running;
            mnuTilemapViewer.Enabled  = running;
            mnuTileViewer.Enabled     = running;
            mnuSpriteViewer.Enabled   = running;
            mnuPaletteViewer.Enabled  = running;
            mnuEventViewer.Enabled    = running;
            mnuRegisterViewer.Enabled = running;
        }
Esempio n. 6
0
 public RomInfo(InteropRomInfo romInfo)
 {
     RomPath         = (ResourcePath)Utf8Marshaler.GetStringFromIntPtr(romInfo.RomPath);
     PatchPath       = (ResourcePath)Utf8Marshaler.GetStringFromIntPtr(romInfo.PatchPath);
     Header          = romInfo.Header;
     CoprocessorType = romInfo.CoprocessorType;
 }
Esempio n. 7
0
        private static List <string> GetExpectedHashes(CoprocessorType type)
        {
            switch (type)
            {
            case CoprocessorType.CX4: return(new List <string>()
                {
                    "AE8D4D1961B93421FF00B3CAA1D0F0CE7783E749772A3369C36B3DBF0D37EF18"
                });

            case CoprocessorType.DSP1: return(new List <string>()
                {
                    "91E87D11E1C30D172556BED2211CCE2EFA94BA595F58C5D264809EF4D363A97B"
                });

            case CoprocessorType.DSP1B: return(new List <string>()
                {
                    "D789CB3C36B05C0B23B6C6F23BE7AA37C6E78B6EE9CEAC8D2D2AA9D8C4D35FA9"
                });

            case CoprocessorType.DSP2: return(new List <string>()
                {
                    "03EF4EF26C9F701346708CB5D07847B5203CF1B0818BF2930ACD34510FFDD717"
                });

            case CoprocessorType.DSP3: return(new List <string>()
                {
                    "0971B08F396C32E61989D1067DDDF8E4B14649D548B2188F7C541B03D7C69E4E"
                });

            case CoprocessorType.DSP4: return(new List <string>()
                {
                    "752D03B2D74441E430B7F713001FA241F8BBCFC1A0D890ED4143F174DBE031DA"
                });

            case CoprocessorType.ST010: return(new List <string>()
                {
                    "FA9BCED838FEDEA11C6F6ACE33D1878024BDD0D02CC9485899D0BDD4015EC24C"
                });

            case CoprocessorType.ST011: return(new List <string>()
                {
                    "8B2B3F3F3E6E29F4D21D8BC736B400BC988B7D2214EBEE15643F01C1FEE2F364"
                });

            case CoprocessorType.ST018: return(new List <string>()
                {
                    "6DF209AB5D2524D1839C038BE400AE5EB20DAFC14A3771A3239CD9E8ACD53806"
                });

            case CoprocessorType.Satellaview: return(new List <string>()
                {
                    "27CFDB99F7E4252BF3740D420147B63C4C88616883BC5E7FE43F2F30BF8C8CBB",                     //Japan, no DRM
                    "A49827B45FF9AC9CF5B4658190E1428E59251BC82D8A63D8E9E0F71E439F008F",                     //English, no DRM
                    "3CE321496EDC5D77038DE2034EB3FB354D7724AFD0BC7FD0319F3EB5D57B984D",                     //Japan, original
                    "77D94D64D745014BF8B51280A4204056CDEB9D41EA30EAE80DBC006675BEBEF8",                     //English, DRM
                });
            }
            throw new Exception("Unexpected coprocessor type");
        }
Esempio n. 8
0
        private void UpdateDebuggerMenu()
        {
            bool running = EmuRunner.IsRunning();

            mnuDebugger.Enabled    = running;
            mnuSpcDebugger.Enabled = running;

            CoprocessorType coprocessor = EmuApi.GetRomInfo().CoprocessorType;

            mnuSa1Debugger.Enabled = coprocessor == CoprocessorType.SA1;
            mnuSa1Debugger.Visible = coprocessor == CoprocessorType.SA1;

            mnuGsuDebugger.Enabled = coprocessor == CoprocessorType.GSU;
            mnuGsuDebugger.Visible = coprocessor == CoprocessorType.GSU;

            bool isNecDsp = (
                coprocessor == CoprocessorType.DSP1 ||
                coprocessor == CoprocessorType.DSP1B ||
                coprocessor == CoprocessorType.DSP2 ||
                coprocessor == CoprocessorType.DSP3 ||
                coprocessor == CoprocessorType.DSP4 ||
                coprocessor == CoprocessorType.ST010 ||
                coprocessor == CoprocessorType.ST011
                );

            mnuNecDspDebugger.Enabled = isNecDsp;
            mnuNecDspDebugger.Visible = isNecDsp;

            mnuCx4Debugger.Enabled = coprocessor == CoprocessorType.CX4;
            mnuCx4Debugger.Visible = coprocessor == CoprocessorType.CX4;

            mnuTraceLogger.Enabled    = running;
            mnuScriptWindow.Enabled   = running;
            mnuMemoryTools.Enabled    = running;
            mnuTilemapViewer.Enabled  = running;
            mnuTileViewer.Enabled     = running;
            mnuSpriteViewer.Enabled   = running;
            mnuPaletteViewer.Enabled  = running;
            mnuEventViewer.Enabled    = running;
            mnuRegisterViewer.Enabled = running;
            mnuProfiler.Enabled       = running;
            mnuAssembler.Enabled      = running;

            bool isGameboyMode = coprocessor == CoprocessorType.Gameboy;

            mnuGbDebugger.Enabled      = isGameboyMode;
            mnuGbDebugger.Visible      = isGameboyMode;
            sepGameboyDebugger.Visible = isGameboyMode;

            //Remove/disable all tools that aren't useful when running a plain GB game
            mnuGbDebugger.Text      = isGameboyMode ? "Debugger" : "Game Boy Debugger";
            mnuDebugger.Enabled     = running && !isGameboyMode;
            mnuDebugger.Visible     = !isGameboyMode;
            mnuSpcDebugger.Enabled  = running && !isGameboyMode;
            mnuSpcDebugger.Visible  = !isGameboyMode;
            sepCoprocessors.Visible = !isGameboyMode;
        }
Esempio n. 9
0
        private void UpdateAvailableOptions()
        {
            CoprocessorType coproc = EmuApi.GetRomInfo().CoprocessorType;

            chkLogCpu.Visible     = coproc != CoprocessorType.Gameboy;
            chkLogSpc.Visible     = coproc != CoprocessorType.Gameboy;
            chkLogNecDsp.Visible  = (coproc >= CoprocessorType.DSP1 && coproc <= CoprocessorType.DSP4) || (coproc >= CoprocessorType.ST010 && coproc <= CoprocessorType.ST011);
            chkLogSa1.Visible     = coproc == CoprocessorType.SA1;
            chkLogGsu.Visible     = coproc == CoprocessorType.GSU;
            chkLogCx4.Visible     = coproc == CoprocessorType.CX4;
            chkLogGameboy.Visible = (coproc == CoprocessorType.Gameboy || coproc == CoprocessorType.SGB);
        }
Esempio n. 10
0
        public static void SetDefaultLabels()
        {
            CoprocessorType coproc = EmuApi.GetRomInfo().CoprocessorType;

            if (coproc == CoprocessorType.Gameboy || coproc == CoprocessorType.SGB)
            {
                SetGameboyDefaultLabels();
            }

            if (coproc != CoprocessorType.Gameboy)
            {
                SetSnesDefaultLabels();
            }
        }
Esempio n. 11
0
        private static string GetExpectedHash(CoprocessorType type)
        {
            switch (type)
            {
            case CoprocessorType.CX4: return("AE8D4D1961B93421FF00B3CAA1D0F0CE7783E749772A3369C36B3DBF0D37EF18");

            case CoprocessorType.DSP1: return("91E87D11E1C30D172556BED2211CCE2EFA94BA595F58C5D264809EF4D363A97B");

            case CoprocessorType.DSP1B: return("D789CB3C36B05C0B23B6C6F23BE7AA37C6E78B6EE9CEAC8D2D2AA9D8C4D35FA9");

            case CoprocessorType.DSP2: return("03EF4EF26C9F701346708CB5D07847B5203CF1B0818BF2930ACD34510FFDD717");

            case CoprocessorType.DSP3: return("0971B08F396C32E61989D1067DDDF8E4B14649D548B2188F7C541B03D7C69E4E");

            case CoprocessorType.DSP4: return("752D03B2D74441E430B7F713001FA241F8BBCFC1A0D890ED4143F174DBE031DA");

            case CoprocessorType.ST010: return("FA9BCED838FEDEA11C6F6ACE33D1878024BDD0D02CC9485899D0BDD4015EC24C");

            case CoprocessorType.ST011: return("8B2B3F3F3E6E29F4D21D8BC736B400BC988B7D2214EBEE15643F01C1FEE2F364");

            case CoprocessorType.ST018: return("6DF209AB5D2524D1839C038BE400AE5EB20DAFC14A3771A3239CD9E8ACD53806");
            }
            throw new Exception("Unexpected coprocessor type");
        }
Esempio n. 12
0
        private void OnNotificationReceived(NotificationEventArgs e)
        {
            switch (e.NotificationType)
            {
            case ConsoleNotificationType.GameLoaded: {
                if (_cpuType == CpuType.Sa1)
                {
                    CoprocessorType coprocessor = EmuApi.GetRomInfo().CoprocessorType;
                    if (coprocessor != CoprocessorType.SA1)
                    {
                        this.Invoke((MethodInvoker)(() => {
                                this.Close();
                            }));
                        return;
                    }
                }

                if (ConfigManager.Config.Debug.Debugger.BreakOnPowerCycleReset)
                {
                    DebugApi.Step(_cpuType, 1, StepType.PpuStep);
                }

                BreakpointManager.SetBreakpoints();

                DebugState state = DebugApi.GetState();
                this.BeginInvoke((MethodInvoker)(() => {
                        DebugWorkspaceManager.ImportDbgFile();
                        LabelManager.RefreshLabels();
                        DebugApi.RefreshDisassembly(_cpuType);
                        UpdateDebugger(state, null);
                    }));
                break;
            }

            case ConsoleNotificationType.GameReset:
                if (ConfigManager.Config.Debug.Debugger.BreakOnPowerCycleReset)
                {
                    DebugApi.Step(_cpuType, 1, StepType.PpuStep);
                }
                break;

            case ConsoleNotificationType.PpuFrameDone:
                this.BeginInvoke((MethodInvoker)(() => {
                    UpdateContinueAction();
                }));
                break;

            case ConsoleNotificationType.CodeBreak: {
                BreakEvent evt   = (BreakEvent)Marshal.PtrToStructure(e.Parameter, typeof(BreakEvent));
                DebugState state = DebugApi.GetState();
                int        activeAddress;
                switch (_cpuType)
                {
                case CpuType.Cpu: activeAddress = (int)((state.Cpu.K << 16) | state.Cpu.PC); break;

                case CpuType.Spc: activeAddress = (int)state.Spc.PC; break;

                case CpuType.Sa1: activeAddress = (int)((state.Sa1.K << 16) | state.Sa1.PC); break;

                case CpuType.Gsu: activeAddress = (int)((state.Gsu.ProgramBank << 16) | state.Gsu.R[15]); break;

                default: throw new Exception("Unsupported cpu type");
                }

                this.BeginInvoke((MethodInvoker)(() => {
                        ProcessBreakEvent(evt, state, activeAddress);

                        if (_firstBreak && !ConfigManager.Config.Debug.Debugger.BreakOnOpen)
                        {
                            DebugApi.ResumeExecution();
                        }
                        _firstBreak = false;
                    }));
                break;
            }
            }
        }
Esempio n. 13
0
        private void UpdateDebuggerMenu()
        {
            bool running = EmuRunner.IsRunning();

            mnuDebugger.Enabled    = running;
            mnuSpcDebugger.Enabled = running;

            CoprocessorType coprocessor = EmuApi.GetRomInfo().CoprocessorType;

            mnuSa1Debugger.Enabled = coprocessor == CoprocessorType.SA1;
            mnuSa1Debugger.Visible = coprocessor == CoprocessorType.SA1;

            mnuGsuDebugger.Enabled = coprocessor == CoprocessorType.GSU;
            mnuGsuDebugger.Visible = coprocessor == CoprocessorType.GSU;

            bool isNecDsp = (
                coprocessor == CoprocessorType.DSP1 ||
                coprocessor == CoprocessorType.DSP1B ||
                coprocessor == CoprocessorType.DSP2 ||
                coprocessor == CoprocessorType.DSP3 ||
                coprocessor == CoprocessorType.DSP4 ||
                coprocessor == CoprocessorType.ST010 ||
                coprocessor == CoprocessorType.ST011
                );

            mnuNecDspDebugger.Enabled = isNecDsp;
            mnuNecDspDebugger.Visible = isNecDsp;

            mnuCx4Debugger.Enabled = coprocessor == CoprocessorType.CX4;
            mnuCx4Debugger.Visible = coprocessor == CoprocessorType.CX4;

            mnuTraceLogger.Enabled    = running;
            mnuScriptWindow.Enabled   = running;
            mnuMemoryTools.Enabled    = running;
            mnuTilemapViewer.Enabled  = running;
            mnuTileViewer.Enabled     = running;
            mnuSpriteViewer.Enabled   = running;
            mnuPaletteViewer.Enabled  = running;
            mnuEventViewer.Enabled    = running;
            mnuRegisterViewer.Enabled = running;
            mnuProfiler.Enabled       = running;
            mnuAssembler.Enabled      = running;
            mnuDebugLog.Enabled       = running;
            mnuWatchWindow.Enabled    = running;

            bool isGameboyMode  = coprocessor == CoprocessorType.Gameboy;
            bool isSuperGameboy = coprocessor == CoprocessorType.SGB;

            //Only show in super gameboy mode
            mnuGbDebugger.Enabled      = isSuperGameboy;
            mnuGbDebugger.Visible      = isSuperGameboy;
            mnuGbEventViewer.Enabled   = isSuperGameboy;
            mnuGbEventViewer.Visible   = isSuperGameboy;
            mnuGbPaletteViewer.Enabled = isSuperGameboy;
            mnuGbPaletteViewer.Visible = isSuperGameboy;
            mnuGbSpriteViewer.Enabled  = isSuperGameboy;
            mnuGbSpriteViewer.Visible  = isSuperGameboy;
            mnuGbTilemapViewer.Enabled = isSuperGameboy;
            mnuGbTilemapViewer.Visible = isSuperGameboy;
            mnuGbTileViewer.Enabled    = isSuperGameboy;
            mnuGbTileViewer.Visible    = isSuperGameboy;
            sepGameboyDebugger.Visible = isSuperGameboy;

            //Hide in gameboy-only mode
            mnuSpcDebugger.Enabled  = running && !isGameboyMode;
            mnuSpcDebugger.Visible  = !isGameboyMode;
            sepCoprocessors.Visible = !isGameboyMode;
        }
Esempio n. 14
0
        private void OnNotificationReceived(NotificationEventArgs e)
        {
            switch (e.NotificationType)
            {
            case ConsoleNotificationType.GameLoaded: {
                if (_cpuType == CpuType.Sa1)
                {
                    CoprocessorType coprocessor = EmuApi.GetRomInfo().CoprocessorType;
                    if (coprocessor != CoprocessorType.SA1)
                    {
                        this.Invoke((MethodInvoker)(() => {
                                this.Close();
                            }));
                        return;
                    }
                }

                if (ConfigManager.Config.Debug.Debugger.BreakOnPowerCycleReset)
                {
                    DebugApi.Step(_cpuType, 1, StepType.PpuStep);
                }

                BreakpointManager.SetBreakpoints();

                DebugState state = DebugApi.GetState();
                this.BeginInvoke((MethodInvoker)(() => {
                        //Refresh workspace here as well as frmMain to ensure workspace
                        //is up-to-date no matter which form is notified first.
                        DebugWorkspaceManager.GetWorkspace();

                        bool isPowerCycle = e.Parameter.ToInt32() != 0;
                        if (!isPowerCycle)
                        {
                            DebugWorkspaceManager.AutoImportSymbols();
                        }
                        LabelManager.RefreshLabels();
                        DebugApi.RefreshDisassembly(_cpuType);
                        UpdateDebugger(state, null);
                    }));
                break;
            }

            case ConsoleNotificationType.GameReset:
                if (ConfigManager.Config.Debug.Debugger.BreakOnPowerCycleReset)
                {
                    DebugApi.Step(_cpuType, 1, StepType.PpuStep);
                }
                break;

            case ConsoleNotificationType.PpuFrameDone:
                this.BeginInvoke((MethodInvoker)(() => {
                    UpdateContinueAction();
                }));
                break;

            case ConsoleNotificationType.CodeBreak: {
                BreakEvent evt = (BreakEvent)Marshal.PtrToStructure(e.Parameter, typeof(BreakEvent));
                RefreshDebugger(evt);
                break;
            }
            }
        }