コード例 #1
0
ファイル: StoredInstruction.cs プロジェクト: gb-archive/DMG
 public static StoredInstruction DeepCopy(StoredInstruction instruction)
 {
     return(new StoredInstruction(instruction.Name, instruction.OpCode, instruction.OperandLength, null)
     {
         Operand = instruction.Operand,
         PC = instruction.PC,
         extendedInstruction = instruction.extendedInstruction
     });
 }
コード例 #2
0
ファイル: DmgDebugConsole.cs プロジェクト: gb-archive/DMG
        // We are about to step
        public void OnPreBreakpointStep()
        {
            // Pop the current instruction and store it in our history
            executionHistory.Enqueue(StoredInstruction.DeepCopy(NextInstructions[0]));
            NextInstructions.RemoveAt(0);

            // Only show last x instructions
            if (executionHistory.Count == Instruction_Depth)
            {
                executionHistory.Dequeue();
            }
        }
コード例 #3
0
ファイル: DmgDebugConsole.cs プロジェクト: gb-archive/DMG
        public void PeekSequentialInstructions()
        {
            if (dmg.PoweredOn == false)
            {
                return;
            }

            NextInstructions.Clear();

            int lookAheadBytes = 0;

            for (int i = 0; i < Instruction_Depth; i++)
            {
                ushort pc     = (ushort)(dmg.cpu.PC + lookAheadBytes);
                byte   opCode = dmg.memory.ReadByte(pc);
                lookAheadBytes++;

                var newInstruction = StoredInstruction.DeepCopy(dmg.cpu.GetInstruction(opCode));
                NextInstructions.Add(newInstruction);

                ushort operandValue = 0;
                if (newInstruction.OperandLength == 1)
                {
                    operandValue = dmg.memory.ReadByte((ushort)(dmg.cpu.PC + lookAheadBytes));
                    lookAheadBytes++;
                }
                else if (newInstruction.OperandLength == 2)
                {
                    operandValue    = dmg.memory.ReadShort((ushort)(dmg.cpu.PC + lookAheadBytes));
                    lookAheadBytes += 2;
                }

                newInstruction.Operand = operandValue;
                newInstruction.PC      = pc;

                if (opCode == 0xCB && dmg.cpu.GetExtendedInstruction((byte)operandValue) != null)
                {
                    newInstruction.extendedInstruction = dmg.cpu.GetExtendedInstruction((byte)operandValue).DeepCopy();
                }
            }
        }