public void UpdateForm() { ushort adr = GameBoy.Cpu.PC; bool bIsCB = false; ushort opcode = GameBoy.Ram.ReadByteAt(adr); if (opcode == 0xCB) { bIsCB = true; adr += 0x01; opcode = GameBoy.Ram.ReadByteAt(adr); } Z80Instruction inst = GameBoy.Cpu.decoder.GetInstructionAt(adr, bIsCB); if (inst != null) { this.text_name.Text = inst.name; String opcodeStr = String.Format("{0:x2}", opcode); this.text_name.Text = inst.ToString(adr); this.text_opcode.Text = opcodeStr; //this.text_lenght.Text = m_curInst.GetLenght().ToString(); this.text_cycles.Text = inst.nbCycles.ToString() + "/" + inst.nbCyclesMax.ToString(); //String data = m_ram.GetDataToString(m_cpu.PC+1, m_curInst.lenght-1); //this.text_data.Text = m_curInst.toString(); ; } }
public void UpdateForm() { if (checkBox_autoFollow.Checked) { if (radio_PC.Checked) { if (GameBoy.Cpu.PC != m_lastPC_Position) { m_lastPC_Position = GameBoy.Cpu.PC; hexRam.Select(m_lastPC_Position, 1); } } else if (radio_SP.Checked) { m_lastSP_Position = GameBoy.Cpu.SP; hexRam.Select(m_lastSP_Position, 1); } else { m_lastPC_Position = GameBoy.Cpu.PC; Z80Instruction inst = GameBoy.Cpu.currentInstruction; long l = 1; if (inst != null) { l = inst.GetLenght(m_lastPC_Position); } hexRam.Select(m_lastPC_Position, l); } } }
public InstructionItem(GameBoy.GameBoy gameBoy, Z80Instruction instruction) { if (gameBoy == null) { throw new ArgumentNullException(nameof(gameBoy)); } if (instruction == null) { throw new ArgumentNullException(nameof(instruction)); } _gameBoy = gameBoy; _instruction = instruction; }
public void RefreshView() { RegistersTextBox.Text = _currentDevice.Cpu.Registers + "\r\nTick: " + _currentDevice.Cpu.TickCount + "\r\n\r\n" + "LCDC: " + ((byte)_currentDevice.Gpu.Lcdc).ToString("X2") + "\r\n" + "STAT: " + ((byte)_currentDevice.Gpu.Stat).ToString("X2") + "\r\n" + "LY: " + _currentDevice.Gpu.LY.ToString("X2") + "\r\n" + "ScY: " + _currentDevice.Gpu.ScY.ToString("X2") + "\r\n" + "ScX: " + _currentDevice.Gpu.ScX.ToString("X2") + "\r\n" + "\r\n" + "TIMA: " + _currentDevice.Timer.Tima.ToString("X2") + "\r\n" + "TMA: " + _currentDevice.Timer.Tma.ToString("X2") + "\r\n" + "TAC: " + ((byte)_currentDevice.Timer.Tac).ToString("X2") + "\r\n"; ; DisassemblyView.Items.Clear(); var disassembler = new Z80Disassembler(_currentDevice.Memory); var position = _currentDevice.Cpu.Registers.PC; for (int i = 0; i < 30 && position < 0xFFFF; i++) { var instruction = new Z80Instruction(0, Z80OpCodes.SingleByteOpCodes[0], new byte[0]); disassembler.ReadInstruction(ref position, instruction); DisassemblyView.Items.Add(new InstructionItem(_currentDevice, instruction)); } }
private void UpdateContentArray() { for (int i = 0; i < m_callstackSize; i++) { if (!m_contentArray[i]._written) { if (m_contentArray[i]._isInt) { String intStr = ""; switch (m_contentArray[i]._opcode) { case 0: { intStr = "vblank"; break; } case 1: { intStr = "lcdstat"; break; } case 2: { intStr = "timer"; break; } case 3: { intStr = "serial"; break; } case 4: { intStr = "joypad"; break; } default: { intStr = "error"; break; } } String opcodeStr = String.Format("{0:x2}", m_contentArray[i]._opcode); String pc = String.Format("{0:x4}", m_contentArray[i]._pc); int frame = GameBoy.Video.getRefreshLine(); m_contentArray[i]._str = String.Format(myFormatInt, intStr, pc, m_contentArray[i]._bank); } else { Z80Instruction inst = GameBoy.Cpu.decoder.GetInstructionAt(m_contentArray[i]._adr, m_contentArray[i]._isCB); String opcodeStr = String.Format("{0:x2}", m_contentArray[i]._opcode); String name = "????"; if (inst != null) { name = opcodeStr + " - " + inst.ToString(m_contentArray[i]._adr); } String af = String.Format("{0:x4}", m_contentArray[i]._raf); String de = String.Format("{0:x4}", m_contentArray[i]._rde); String bc = String.Format("{0:x4}", m_contentArray[i]._rbc); String hl = String.Format("{0:x4}", m_contentArray[i]._rhl); String pc = String.Format("{0:x4}", m_contentArray[i]._pc); String sp = String.Format("{0:x4}", m_contentArray[i]._sp); String fl = ""; if (GameBoy.Cpu.ZValue) { fl += "Z"; } else { fl += "-"; } if (GameBoy.Cpu.NValue) { fl += "N"; } else { fl += "-"; } if (GameBoy.Cpu.HValue) { fl += "H"; } else { fl += "-"; } if (GameBoy.Cpu.CValue) { fl += "C"; } else { fl += "-"; } int bank = m_contentArray[i]._bank; m_contentArray[i]._str = String.Format(myFormatInst, m_contentArray[i]._cnt, pc, name, af, bc, de, hl, sp, fl, bank); } if (m_bSaveCallStack) { if (m_saveFile == null) { m_saveFile = File.Open(m_fileSavePath, FileMode.OpenOrCreate, FileAccess.Write); m_writer = new StreamWriter(m_saveFile); m_writer.AutoFlush = true; } m_writer.WriteLine(m_contentArray[i]._str); } m_contentArray[i]._written = true; } } }