コード例 #1
0
 private string getPageNum(string address)
 {
     int addressLoc = int.Parse(address, NumberStyles.HexNumber);
     string page = "00";
     Wabbitemu.MEMSTATE memstate = this.debugger.getMemState();
     if (addressLoc < 0x4000) // && memstate.ram0 == 0)
     {
         page = memstate.page0.ToString("X2");
     }
     if (addressLoc >= 0x4000 && addressLoc < 0x8000) // && memstate.ram1 == 0)
     {
         page = ((int)this.apppage - memstate.page1).ToString("X2");
     }
     if (addressLoc >= 0x8000 && addressLoc < 0xC000) // && memstate.ram2 == 0)
     {
         page = memstate.page2.ToString("X2");
     }
     if (addressLoc >= 0xC000 && addressLoc < 0x10000) // && memstate.ram3 == 0)
     {
         page = memstate.page3.ToString("X2");
     }
     if (!this.debugger.isWabbitOpen)
     {
         wabbitClosed();
     }
     return page;
 }
コード例 #2
0
 private int getRamState(string address)
 {
     int addressLoc = int.Parse(address, NumberStyles.HexNumber);
     int isRam = 0;
     Wabbitemu.MEMSTATE memstate = this.debugger.getMemState();
     if (addressLoc < 0x4000) // && memstate.ram0 == 0)
     {
         isRam = memstate.ram0;
     }
     if (addressLoc >= 0x4000 && addressLoc < 0x8000) // && memstate.ram1 == 0)
     {
         isRam = memstate.ram1;
     }
     if (addressLoc >= 0x8000 && addressLoc < 0xC000) // && memstate.ram2 == 0)
     {
         isRam = memstate.ram2;
     }
     if (addressLoc >= 0xC000 && addressLoc < 0x10000) // && memstate.ram3 == 0)
     {
         isRam = memstate.ram3;
     }
     if (!this.debugger.isWabbitOpen)
     {
         wabbitClosed();
     }
     return isRam;
 }
コード例 #3
0
        public void SetPCToSelect(string fileName, int lineNumber)
        {
            string newPC = this.debugTableReverse[fileName + ":" + (lineNumber + 1)].ToString();
            Wabbitemu.Z80_State state = this.debugger.getState();
            Wabbitemu.MEMSTATE memState = this.debugger.getMemState();
            state.PC = UInt16.Parse(newPC.Substring(3, 4), NumberStyles.HexNumber);
            byte page = byte.Parse(newPC.Substring(0, 2), NumberStyles.HexNumber);
            if (this.isAnApp)
            {
                page = (byte)(this.apppage - page);
                memState.page1 = page;
                memState.ram1 = 0;
            }
            else
            {
                memState.page2 = 1;
                memState.ram2 = 1;
            }

            this.removeHighlight();
            this.highlightLine(lineNumber + 1);
            this.debugger.setMemState(memState);
            this.debugger.setState(state);
            debugPanel.updateRegisters();
        }
コード例 #4
0
        private void startDebug(object sender, EventArgs e)
        {
            if (this.debugging)
            {
                run();
            }
            else
            {
                this.debugging = true;
                string listName;
                string symName;
                string fileName = "";
                string startAddress;
                string createdName = "";
                bool error = true;
                if (this.projectOpen)
                {
                    listName = Path.Combine(projectLoc, projectName + ".lst");
                    symName = Path.Combine(projectLoc, projectName + ".lab");
                    fileName = Path.Combine(projectLoc, projectName + ".asm");
                    NewProject project = new NewProject(this.wcodeProjectFile);
                    int outputType = project.getOutputType();
                    startAddress = outputType == 5 ? "4080" : "9D95";
                    XmlNodeList buildConfigs;
                    XmlDocument doc = new XmlDocument();
                    doc.Load(this.wcodeProjectFile);
                    buildConfigs = doc.ChildNodes[1].ChildNodes[1].ChildNodes;
                    int counter = 0;
                    foreach (XmlNode config in buildConfigs)
                    {
                        if (config.Name.ToLower() == "debug")
                        {
                            Settings.Default.buildConfig = counter;
                            counter = -1;
                            break;
                        }

                        counter++;
                    }

                    if (counter == -1)
                    {
                        createdName = assembleProject();
                    }
                    else
                    {
                        MessageBox.Show("No build config named Debug was found!");
                        this.debugging = false;
                        return;
                    }
                }
                else
                {
                    if (ActiveMdiChild != null)
                    {
                        fileName = ((newEditor)ActiveMdiChild).editorBox.FileName;
                    }
                    error &= createListing(fileName, Path.ChangeExtension(fileName, "lst"));

                    // if (error)
                    //    MessageBox.Show("Problem creating list file");
                    error &= createSymTable(fileName, Path.ChangeExtension(fileName, "lab"));

                    // if (error)
                    //    MessageBox.Show("Problem creating symtable");
                    error &= assembleCode(fileName, false, Path.ChangeExtension(fileName, getExtension(Settings.Default.outputFile)));

                    // if (error)
                    //    MessageBox.Show("Problem creating 8xp file");
                    listName = Path.ChangeExtension(fileName, ".lst");
                    symName = Path.ChangeExtension(fileName, ".lab");
                    switch (Settings.Default.outputFile)
                    {
                    case 4:
                        startAddress = "9D95";
                        createdName = Path.ChangeExtension(fileName, "8xp");
                        break;
                    case 5:
                        startAddress = "4080";
                        createdName = Path.ChangeExtension(fileName, "8xk");
                        break;
                    default:
                        MessageBox.Show("You cannont debug a non 83/84 Plus file!");
                        goto NoMoreDebug;
                    }
                }

                if (!this.debugging || !error)
                {
                    if (MessageBox.Show("There were errors compiling!!! Would you like to continue and try to debug?", "Continue", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No)
                    {
                        cancelDebug_Click(null, null);
                        return;
                    }
                }

                // if (!File.Exists(listName))
                //    createListing(fileName, Path.ChangeExtension(fileName, "lst"));
                this.debugger = new Wabbitemu(createdName);

                this.showToolbar = Settings.Default.debugToolbar;
                Settings.Default.debugToolbar = true;
                debugToolStrip.Show();
                updateChecks();
                debugPanel = new DebugPanel(this.debugger);
                debugPanel.Show(dockPanel, Settings.Default.debugPanelLoc);
                trackWindow.Show(dockPanel);

                StreamReader reader = new StreamReader(listName);

                // StreamReader breakReader = new StreamReader(fileName.Remove(fileName.Length - 3) + "brk");
                string listFileText = reader.ReadToEnd();

                // string[] listFileLines = listFileText.Split('\n');
                reader = new StreamReader(symName);
                string symFileText = reader.ReadToEnd();
                this.debugTable = new Hashtable();
                this.debugTableReverse = new Hashtable();
                TextEditorControl editorBox;

                // int CurrentListLine = 0;
                // while (!listFileLines[currentListLine].Contains("9D95"))
                //    currentListLine++;
                this.parseListFile(listFileText, fileName, Path.GetDirectoryName(fileName), ref this.debugTable, ref this.debugTableReverse);
                this.parseSymFile(symFileText);

                // string[] breakpoints = breakReader.ReadToEnd().Split('\n');
                // calcScreen.BackColor = Color.FromArgb(158, 171, 136);

                this.staticLabelMarkers = new List<TextMarker>();
                this.breakpoints = new List<Wabbitemu.breakpoint>();
                foreach (newEditor child in MdiChildren)
                {
                    editorBox = child.editorBox;
                    string breakLocInfo;
                    ReadOnlyCollection<Breakpoint> marks = editorBox.Document.BreakpointManager.Marks;
                    foreach (Breakpoint breakpoint in marks)
                    {
                        var newBreakpoint = new Wabbitemu.breakpoint();
                        if (this.debugTable.ContainsValue(editorBox.FileName + ":" + (breakpoint.LineNumber + 1)))
                        {
                            breakLocInfo =
                                this.debugTableReverse[editorBox.FileName + ":" + (breakpoint.LineNumber + 1)].ToString();
                            newBreakpoint.Address = UInt16.Parse(breakLocInfo.Substring(3, 4), NumberStyles.HexNumber);
                            if (this.isAnApp)
                            {
                                newBreakpoint.Page = (byte)(this.apppage - byte.Parse(breakLocInfo.Substring(0, 2), NumberStyles.HexNumber));
                            }
                            else
                            {
                                newBreakpoint.Page = byte.Parse(breakLocInfo.Substring(0, 2), NumberStyles.HexNumber);
                            }
                            newBreakpoint.IsRam = newBreakpoint.Address < 0x8000 ? 0 : 1;
                            this.breakpoints.Add(newBreakpoint);
                            this.debugger.setBreakpoint(Handle, newBreakpoint);
                        }
                        else
                        {
                            editorBox.Document.BreakpointManager.RemoveMark(breakpoint);
                        }
                    }

                    child.setNextStateMenuItem.Visible = true;
                    this.addStaticLabels(editorBox);
                }

                // debugger.setBreakpoint(Handle, true, 1, 0x9D95);
                Wabbitemu.MEMSTATE test = this.debugger.getMemState();
                if (!this.debugger.isWabbitOpen)
                {
                    wabbitClosed();
                }
                if (startAddress == "4080")
                {
                    this.isAnApp = true;
                    Wabbitemu.AppEntry[] appList = new Wabbitemu.AppEntry[20];
                    foreach (Wabbitemu.AppEntry app in appList)
                    {
                    }

                    while (appList[0].page_count == 0)
                    {
                        appList = this.debugger.getAppList();
                        this.apppage = (byte)appList[0].page;
                        Thread.Sleep(500);
                    }
                }
                #region OldDebug
                // Kept for sentimental reasons
                // ((Wabbitcode.newEditor)(ActiveMdiChild)).editorBox.ActiveTextAreaControl.Enabled = false;

                // old stuff?
                // string locInfo = debugTable[page + ":" + startAddress].ToString();
                // string file = locInfo.Substring(0, locInfo.LastIndexOf(':'));
                // string line = locInfo.Substring(locInfo.LastIndexOf(':') + 1, locInfo.Length - locInfo.LastIndexOf(':') - 1);
                /*
                if (Path.GetExtension(createdName) == ".8xk")
                {
                    isAnApp = true;
                    Wabbitemu.AppEntry[] appList = debugger.getAppList();
                    apppage = appList[0].page;
                    debugger.setBreakpoint(false, apppage, 0x4080);
                }
                else
                {
                    debugger.sendKeyPress((int)Keys.F12);
                    debugger.releaseKeyPress((int)Keys.F12);
                    System.Threading.Thread.Sleep(2000);
                    debugger.setBreakpoint(true, 1, 0x9D95);
                }*/
                /*try
                {
                    while (debugging)
                    {
                        Application.DoEvents();
                    }

                        //calcScreen.Image = debugger.DrawScreen();
                        var currentLoc = new Wabbitemu.breakpoint();
                        currentLoc.Address = debugger.getState().PC;
                        currentLoc.Page = byte.Parse(getPageNum(currentLoc.Address.ToString("X")), NumberStyles.HexNumber);
                        currentLoc.IsRam = getRamState(currentLoc.Address.ToString("X"));
                        bool breakpointed = false;
                        foreach (Wabbitemu.breakpoint breakpoint in breakpoints)
                        {
                            if (breakpoint.Page == currentLoc.Page && breakpoint.Address == currentLoc.Address)
                                breakpointed = true;
                        }
                        while (breakpointed)
                        {
                            //updateRegisters();
                            //updateFlags();
                            //updateCPUStatus();
                            //updateInterrupts();
                            if (stepOverClicked)
                                step(debugTable);
                            Application.DoEvents();
                        }
                        debugger.step();
                        //System.Threading.Thread.Sleep(2000);
                        Application.DoEvents();
                    }
                }
                catch (COMException ex)
                {
                    if (ex.ErrorCode != -2147023174)
                        MessageBox.Show(ex.ToString());
                }*/
                #endregion
            }

            NoMoreDebug:
            ;
        }