예제 #1
0
        void OnGUI()
        {
            if (debugger == null)
            {
                debugger = GameObject.FindObjectOfType <EmulatorDebugger>();
            }

            if (debugger == null)
            {
                GUILayout.Label("No emulator debugger found");
                return;
            }

            GUILayoutOption[] options = null;

            GUILayout.Space(10);
            debugger.enableBreakPoints = GUILayout.Toggle(debugger.enableBreakPoints, "Enable breakpoints", options);
            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            string[] texts =
            {
                "Breakpoints", "Memory breakpoints"
            };
            selectedView = GUILayout.Toolbar(selectedView, texts, options);
            GUILayout.EndHorizontal();

            if (selectedView == 0)
            {
                DrawBreakpointsView(debugger.breakPoints);
            }
            else if (selectedView == 1)
            {
                DrawBreakpointsView(debugger.memoryBreakPoints);
            }
        }
예제 #2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (!EditorApplication.isPlaying)
            {
                return;
            }

            Color            defaultColor = GUI.color;
            EmulatorDebugger debugTools   = (target as EmulatorDebugger);
            Emulator         emu          = debugTools.emu;

            if (!emu.isOn)
            {
                GUI.color = Color.green;
                if (GUILayout.Button("Turn on"))
                {
                    emu.TurnOn();
                }
                GUI.color = defaultColor;
            }
            else
            {
                GUI.color = Color.red;
                if (GUILayout.Button("Turn off"))
                {
                    emu.TurnOff();
                }
                GUI.color = defaultColor;

                GUI.color = Color.yellow;
                if (GUILayout.Button("Reset"))
                {
                    emu.Reset();
                }
                GUI.color = defaultColor;
            }


            GUILayout.Label("Hotkeys:");
            GUILayout.Label("R: run (continue)");
            GUILayout.Label("P: pause");
            GUILayout.Label("S: next step");


            if (emu.isOn && emu.paused)
            {
                GUILayout.Space(30);



                if (GUILayout.Button("Next step"))
                {
                    emu.EmulatorStep();
                }
                if (GUILayout.Button("Resume"))
                {
                    emu.paused = false;
                }

                GUILayout.Space(30);
                GUILayout.BeginHorizontal();
                addrToCheck = GUILayout.TextField(addrToCheck);
                if (GUILayout.Button("Check Address"))
                {
                    if (addrToCheck != string.Empty)
                    {
                        ushort dir = (ushort)(System.Convert.ToInt16(addrToCheck, 16));
                        resultAddr = string.Format("Value: 0x{0:X2}", emu.mmu.Read(dir));
                    }
                }
                GUILayout.EndHorizontal();

                if (resultAddr != string.Empty)
                {
                    GUILayout.Label(resultAddr);
                }
            }
        }
예제 #3
0
        void OnGUI()
        {
            if (debugger == null)
            {
                debugger = GameObject.FindObjectOfType <EmulatorDebugger>();
            }

            if (debugger == null)
            {
                GUILayout.Label("No debugger found");
                return;
            }

            List <int> addressesToRemove = new List <int>();

            if (addresses == null)
            {
                addresses = new List <string>();
            }

            GUILayoutOption[] emptyOptions = null;

            GUILayoutOption[] addressOptions =
            {
                GUILayout.Width(80)
            };

            GUILayoutOption[] deleteButtonOptions =
            {
                GUILayout.Width(30)
            };

            GUILayout.Space(10);
            GUILayout.BeginScrollView(addressesScrollOffset, GUI.skin.scrollView);
            for (int i = 0; i < addresses.Count; i++)
            {
                GUILayout.BeginHorizontal();
                addresses[i] = GUILayout.TextField(addresses[i], addressOptions);

                var value = "0x00";
                if (debugger != null && debugger.emu != null && debugger.emu.isOn)
                {
                    value = string.Format("0x{0:X2}", debugger.emu.mmu.Read((ushort)System.Convert.ToUInt16(addresses[i], 16)));
                }
                GUILayout.Label(value, addressOptions);
                GUILayout.FlexibleSpace();
                var color = GUI.backgroundColor;
                GUI.backgroundColor = Color.red;
                if (GUILayout.Button("X", deleteButtonOptions))
                {
                    addressesToRemove.Add(i);
                }
                GUI.backgroundColor = color;
                GUILayout.EndHorizontal();
            }
            if (GUILayout.Button("Add", emptyOptions))
            {
                addresses.Add("0");
            }
            GUILayout.EndScrollView();

            for (int i = 0; i < addressesToRemove.Count; i++)
            {
                var idx = addressesToRemove[addressesToRemove.Count - i - 1];
                addresses.RemoveAt(idx);
            }
        }