Exemplo n.º 1
0
        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(); ;
            }
        }
Exemplo n.º 2
0
        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;
                }
            }
        }