/// ------------------------------------------------------------------------------------------------- /// <summary> Updates the memory. </summary> /// /// <remarks> 09/09/2018. </remarks> /// ------------------------------------------------------------------------------------------------- public void UpdateMemory() { if (!this.Visible) { return; } if (sending) { return; } sending = true; int v; for (int i = 0; i < regs.Length; i++) { v = MainForm.myNewRegisters.GetRegisterValueint(regs[i]); ByteProvider bp = ByteProviders[i]; bp.offset = v; int bank = NextAddress.GetBankFromAddress(ref MainForm.banks, v); Program.serialport.GetMemory( delegate(byte[] response, int tag) { Invoke((MethodInvoker) delegate { UIUpdate(response, tag); }); } , v, 32, bank, i); } }
/// ------------------------------------------------------------------------------------------------- /// <summary> Updates the memory. </summary> /// /// <remarks> 09/09/2018. </remarks> /// ------------------------------------------------------------------------------------------------- public void UpdateMemory() { if (!this.Visible) { return; } int v = memaddress; ByteProvider bp = byteProvider; bp.offset = v; int bank = bankNum; if (bankNum < 0) { bank = NextAddress.GetBankFromAddress(ref MainForm.banks, v); } Program.serialport.GetMemory( delegate(byte[] response, int tag) { Invoke((MethodInvoker) delegate { UIUpdate(response, tag); }); } , v, 512, bank, 0); }
/// ------------------------------------------------------------------------------------------------- /// <summary> Request update. </summary> /// /// <remarks> 12/09/2018. </remarks> /// /// <param name="address"> The address. </param> /// ------------------------------------------------------------------------------------------------- public void RequestUpdate(int pc) { int addr = Math.Max(0, pc - 64); int bank = NextAddress.GetBankFromAddress(ref MainForm.banks, addr); Program.serialport.GetMemory( delegate(byte[] response, int tag) { Invoke((MethodInvoker) delegate { UIUpdate(tag, response); }); } , addr, 128, bank, addr); }
// ------------------------------------------------------------------------------------------------- // Event handler. Called by stepoverbutton for click events // // \param sender Source of the event. // \param e Event information. // ------------------------------------------------------------------------------------------------- private void stepoverbutton_Click(object sender, EventArgs e) { int breakpointAddress = MainForm.myDisassembly.GetStepOverAddress(); int bank = NextAddress.GetBankFromAddress(ref MainForm.banks, breakpointAddress); Program.serialport.SetBreakpoint( delegate(byte[] response, int tag) { Invoke((MethodInvoker) delegate { ContinueExecution(); }); } , breakpointAddress, bank); }
/// ------------------------------------------------------------------------------------------------- /// <summary> Gets a label. </summary> /// /// <remarks> 07/09/2018. </remarks> /// /// <param name="addr"> The address. </param> /// /// <returns> The label. </returns> /// ------------------------------------------------------------------------------------------------- public static Label GetLabel(ref int[] bankmap, int addr) { int bank = NextAddress.GetBankFromAddress(ref bankmap, addr); int longaddr = NextAddress.MakeLongAddress(bank, addr); foreach (Label l in labels) { if (longaddr == l.nextAddress.GetLongAddress()) { return(l); } } return(null); }
/// ------------------------------------------------------------------------------------------------- /// <summary> Updates the call stack. </summary> /// /// <remarks> 11/09/2018. </remarks> /// ------------------------------------------------------------------------------------------------- public void UpdateCallStack() { if (!this.Visible) { return; } int sp = MainForm.myNewRegisters.GetRegisterValueint(Registers.Z80Register.sp); int bank = NextAddress.GetBankFromAddress(ref MainForm.banks, sp); Program.serialport.GetMemory( delegate(byte[] response, int tag) { Invoke((MethodInvoker) delegate { UIUpdate(response, tag); }); } , sp, 32, bank, sp); }
// ------------------------------------------------------------------------------------------------- // Patch dism memory with breakpoints // // \param [in,out] mem // The memory. // \param addr // The address. // \param length // The length. // ------------------------------------------------------------------------------------------------- private void PatchDismMemoryWithBreakpoints(ref byte[] mem, int addr, int length) { for (int i = 0; i < length; i++) { //looking for breakpoint instruction if (mem[i] == 0xc7) { int a = addr + i; int bank = NextAddress.GetBankFromAddress(ref MainForm.banks, a); int brk = Breakpoint.FindFreeBreakpointAddr(NextAddress.MakeLongAddress(bank, a)); if (brk >= 0) { //found a breakpoint so lets replace the memory bytes with the origional value. mem[i] = Breakpoint.breakpointData[brk].replaceopcode; } } } }
/// ------------------------------------------------------------------------------------------------- /// <summary> Gets function with offset. </summary> /// /// <remarks> 18/09/2018. </remarks> /// /// <param name="addr"> The address. </param> /// <param name="lab"> [out] The lab. </param> /// <param name="offset"> [out] The offset. </param> /// /// <returns> True if it succeeds, false if it fails. </returns> /// ------------------------------------------------------------------------------------------------- public static bool GetFunctionWithOffset(ref int[] bankmap, int addr, out Label lab, out int offset) { int bank = NextAddress.GetBankFromAddress(ref bankmap, addr); int longaddr = NextAddress.MakeLongAddress(bank, addr); lab = null; offset = 0; int best = int.MaxValue; int bestindex = -1; int index = 0; foreach (Label l in labels) { if (longaddr >= l.nextAddress.GetLongAddress() && l.function) { int off = longaddr - l.nextAddress.GetLongAddress(); if (off < best) { best = off; bestindex = index; } } index++; } if (bestindex < 0) { return(false); } lab = labels[bestindex]; offset = best; return(true); }
// ------------------------------------------------------------------------------------------------- // Gets dissasembly source // // \param [in,out] tf // The tf. // \param maxlines // The maxlines. // // \return The dissasembly source. // ------------------------------------------------------------------------------------------------- public string GetDissasemblySource(ref TraceFile tf, int maxlines, int currentline) { string textfile = ""; tf.lines.Clear(); int lineNumber = 0; for (int i = 0; i < maxlines - 1; i++) { textfile = textfile + DissasemblyLines[currentline].line + "\n"; if (DissasemblyLines[currentline].addr >= 0) { LineData ld = new LineData(); ld.lineNumber = lineNumber; ld.nextAddress = new NextAddress(DissasemblyLines[currentline].addr, NextAddress.GetBankFromAddress(ref MainForm.banks, DissasemblyLines[currentline].addr)); ld.tf = tf; tf.lines.Add(ld); } lineNumber++; currentline++; } return(textfile); }