public void PeekSequentialInstructions() { NextInstructions.Clear(); string instructionText; UInt32 rawInstr; StoredInstruction newInstruction; UInt32 instrSize = (UInt32)(gba.Cpu.State == Cpu.CpuState.Arm ? 4 : 2); UInt32 adjust = 0; int instructionPtr = gba.Cpu.NextPipelineInsturction; // Inefficient but we are not running at this point so what the hell rawInstr = gba.Cpu.InstructionPipeline[instructionPtr]; instructionText = gba.Cpu.State == Cpu.CpuState.Arm ? gba.Cpu.PeekArmInstruction(rawInstr) : gba.Cpu.PeekThumbInstruction((ushort)rawInstr); newInstruction = new StoredInstruction(rawInstr, instructionText, gba.Cpu.PC_Adjusted); NextInstructions.Add(newInstruction); instructionPtr++; if (instructionPtr >= Cpu.Pipeline_Size) { instructionPtr = 0; } adjust += instrSize; rawInstr = gba.Cpu.InstructionPipeline[instructionPtr]; instructionText = gba.Cpu.State == Cpu.CpuState.Arm ? gba.Cpu.PeekArmInstruction(rawInstr) : gba.Cpu.PeekThumbInstruction((ushort)rawInstr); newInstruction = new StoredInstruction(rawInstr, instructionText, (UInt32)(gba.Cpu.PC_Adjusted + adjust)); NextInstructions.Add(newInstruction); instructionPtr++; if (instructionPtr >= Cpu.Pipeline_Size) { instructionPtr = 0; } adjust += instrSize; rawInstr = gba.Cpu.InstructionPipeline[instructionPtr]; instructionText = gba.Cpu.State == Cpu.CpuState.Arm ? gba.Cpu.PeekArmInstruction(rawInstr) : gba.Cpu.PeekThumbInstruction((ushort)rawInstr); newInstruction = new StoredInstruction(rawInstr, instructionText, (UInt32)(gba.Cpu.PC_Adjusted + adjust)); NextInstructions.Add(newInstruction); }
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(); } } }
public void PeekSequentialInstructions() { NextInstructions.Clear(); string instructionText; UInt32 rawInstr; StoredInstruction newInstruction; UInt32 instrSize = (UInt32)(gba.Cpu.State == Cpu.CpuState.Arm ? 4 : 2); UInt32 adjust = 0; int instructionPtr = gba.Cpu.NextPipelineInsturction; // Inefficient but we are not running at this point so what the hell rawInstr = gba.Cpu.InstructionPipeline[instructionPtr]; instructionText = gba.Cpu.State == Cpu.CpuState.Arm ? gba.Cpu.PeekArmInstruction(rawInstr) : gba.Cpu.PeekThumbInstruction((ushort)rawInstr); newInstruction = new StoredInstruction(rawInstr, instructionText, gba.Cpu.PC_Adjusted); NextInstructions.Add(newInstruction); instructionPtr++; if (instructionPtr >= Cpu.Pipeline_Size) { instructionPtr = 0; } adjust += instrSize; rawInstr = gba.Cpu.InstructionPipeline[instructionPtr]; instructionText = gba.Cpu.State == Cpu.CpuState.Arm ? gba.Cpu.PeekArmInstruction(rawInstr) : gba.Cpu.PeekThumbInstruction((ushort)rawInstr); newInstruction = new StoredInstruction(rawInstr, instructionText, (UInt32)(gba.Cpu.PC_Adjusted + adjust)); NextInstructions.Add(newInstruction); instructionPtr++; if (instructionPtr >= Cpu.Pipeline_Size) { instructionPtr = 0; } adjust += instrSize; rawInstr = gba.Cpu.InstructionPipeline[instructionPtr]; instructionText = gba.Cpu.State == Cpu.CpuState.Arm ? gba.Cpu.PeekArmInstruction(rawInstr) : gba.Cpu.PeekThumbInstruction((ushort)rawInstr); newInstruction = new StoredInstruction(rawInstr, instructionText, (UInt32)(gba.Cpu.PC_Adjusted + adjust)); NextInstructions.Add(newInstruction); /* * UInt32 lookAheadBytes = 0; * for (int i = 0; i < Cpu.Pipeline_Size; i++) * { * UInt32 pc = (UInt32)(gba.Cpu.PC_Adjusted + lookAheadBytes); * UInt32 rawInstr = gba.Memory.ReadWord(pc); * lookAheadBytes+= 4; * * string instructionText; * try * { * instructionText = gba.Cpu.PeekArmInstruction(rawInstr); * var newInstruction = new StoredInstruction(instructionText, pc); * NextInstructions.Add(newInstruction); * } * catch (ArgumentException) { } * } */ }