mirror of https://github.com/stella-emu/stella.git
'_cycles' pseudo register added (returns cycles of last instruction)
This commit is contained in:
parent
7d40d5b1f8
commit
9f7270a70d
|
@ -802,6 +802,7 @@ Debugger::BuiltinFunction Debugger::ourBuiltinFunctions[NUM_BUILTIN_FUNCS] = {
|
||||||
Debugger::PseudoRegister Debugger::ourPseudoRegisters[NUM_PSEUDO_REGS] = {
|
Debugger::PseudoRegister Debugger::ourPseudoRegisters[NUM_PSEUDO_REGS] = {
|
||||||
{ "_bank", "Currently selected bank" },
|
{ "_bank", "Currently selected bank" },
|
||||||
{ "_cclocks", "Color clocks on current scanline" },
|
{ "_cclocks", "Color clocks on current scanline" },
|
||||||
|
{ "_cycles", "Number of cycles of last instruction" },
|
||||||
{ "_cycleshi", "Higher 32 bits of number of cycles since emulation started" },
|
{ "_cycleshi", "Higher 32 bits of number of cycles since emulation started" },
|
||||||
{ "_cycleslo", "Lower 32 bits of number of cycles since emulation started" },
|
{ "_cycleslo", "Lower 32 bits of number of cycles since emulation started" },
|
||||||
{ "_fcount", "Number of frames since emulation started" },
|
{ "_fcount", "Number of frames since emulation started" },
|
||||||
|
|
|
@ -315,7 +315,7 @@ class Debugger : public DialogContainer
|
||||||
string name, help;
|
string name, help;
|
||||||
};
|
};
|
||||||
static const uInt32 NUM_BUILTIN_FUNCS = 18;
|
static const uInt32 NUM_BUILTIN_FUNCS = 18;
|
||||||
static const uInt32 NUM_PSEUDO_REGS = 11;
|
static const uInt32 NUM_PSEUDO_REGS = 12;
|
||||||
static BuiltinFunction ourBuiltinFunctions[NUM_BUILTIN_FUNCS];
|
static BuiltinFunction ourBuiltinFunctions[NUM_BUILTIN_FUNCS];
|
||||||
static PseudoRegister ourPseudoRegisters[NUM_PSEUDO_REGS];
|
static PseudoRegister ourPseudoRegisters[NUM_PSEUDO_REGS];
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ M6502::M6502(const Settings& settings)
|
||||||
mySettings(settings),
|
mySettings(settings),
|
||||||
A(0), X(0), Y(0), SP(0), IR(0), PC(0),
|
A(0), X(0), Y(0), SP(0), IR(0), PC(0),
|
||||||
N(false), V(false), B(false), D(false), I(false), notZ(false), C(false),
|
N(false), V(false), B(false), D(false), I(false), notZ(false), C(false),
|
||||||
|
cycles(0),
|
||||||
myNumberOfDistinctAccesses(0),
|
myNumberOfDistinctAccesses(0),
|
||||||
myLastAddress(0),
|
myLastAddress(0),
|
||||||
myLastPeekAddress(0),
|
myLastPeekAddress(0),
|
||||||
|
@ -99,6 +100,8 @@ void M6502::reset()
|
||||||
PS(BSPF::containsIgnoreCase(cpurandom, "P") ?
|
PS(BSPF::containsIgnoreCase(cpurandom, "P") ?
|
||||||
mySystem->randGenerator().next() : 0x20);
|
mySystem->randGenerator().next() : 0x20);
|
||||||
|
|
||||||
|
cycles = 0;
|
||||||
|
|
||||||
// Load PC from the reset vector
|
// Load PC from the reset vector
|
||||||
PC = uInt16(mySystem->peek(0xfffc)) | (uInt16(mySystem->peek(0xfffd)) << 8);
|
PC = uInt16(mySystem->peek(0xfffc)) | (uInt16(mySystem->peek(0xfffd)) << 8);
|
||||||
|
|
||||||
|
@ -124,6 +127,7 @@ inline uInt8 M6502::peek(uInt16 address, uInt8 flags)
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
mySystem->incrementCycles(SYSTEM_CYCLES_PER_CPU);
|
mySystem->incrementCycles(SYSTEM_CYCLES_PER_CPU);
|
||||||
|
cycles += SYSTEM_CYCLES_PER_CPU;
|
||||||
uInt8 result = mySystem->peek(address, flags);
|
uInt8 result = mySystem->peek(address, flags);
|
||||||
myLastPeekAddress = address;
|
myLastPeekAddress = address;
|
||||||
|
|
||||||
|
@ -157,6 +161,7 @@ inline void M6502::poke(uInt16 address, uInt8 value, uInt8 flags)
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
mySystem->incrementCycles(SYSTEM_CYCLES_PER_CPU);
|
mySystem->incrementCycles(SYSTEM_CYCLES_PER_CPU);
|
||||||
|
cycles += SYSTEM_CYCLES_PER_CPU;
|
||||||
mySystem->poke(address, value, flags);
|
mySystem->poke(address, value, flags);
|
||||||
myLastPokeAddress = address;
|
myLastPokeAddress = address;
|
||||||
|
|
||||||
|
@ -238,6 +243,7 @@ bool M6502::execute(uInt32 number)
|
||||||
// Reset the peek/poke address pointers
|
// Reset the peek/poke address pointers
|
||||||
myLastPeekAddress = myLastPokeAddress = myDataAddressForPoke = 0;
|
myLastPeekAddress = myLastPokeAddress = myDataAddressForPoke = 0;
|
||||||
|
|
||||||
|
cycles = 0;
|
||||||
// Fetch instruction at the program counter
|
// Fetch instruction at the program counter
|
||||||
IR = peek(PC++, DISASM_CODE); // This address represents a code section
|
IR = peek(PC++, DISASM_CODE); // This address represents a code section
|
||||||
|
|
||||||
|
@ -251,6 +257,7 @@ bool M6502::execute(uInt32 number)
|
||||||
// Oops, illegal instruction executed so set fatal error flag
|
// Oops, illegal instruction executed so set fatal error flag
|
||||||
myExecutionStatus |= FatalErrorBit;
|
myExecutionStatus |= FatalErrorBit;
|
||||||
}
|
}
|
||||||
|
//cycles = mySystem->cycles() - c0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we need to handle an interrupt
|
// See if we need to handle an interrupt
|
||||||
|
|
|
@ -348,6 +348,8 @@ class M6502 : public Serializable
|
||||||
bool notZ; // Z flag complement for processor status register
|
bool notZ; // Z flag complement for processor status register
|
||||||
bool C; // C flag for processor status register
|
bool C; // C flag for processor status register
|
||||||
|
|
||||||
|
uInt8 cycles; // cycles of last instruction
|
||||||
|
|
||||||
/// Indicates the numer of distinct memory accesses
|
/// Indicates the numer of distinct memory accesses
|
||||||
uInt32 myNumberOfDistinctAccesses;
|
uInt32 myNumberOfDistinctAccesses;
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,8 @@ CpuMethod getCpuSpecial(char* ch)
|
||||||
return &CpuDebug::i;
|
return &CpuDebug::i;
|
||||||
else if(BSPF::equalsIgnoreCase(ch, "b"))
|
else if(BSPF::equalsIgnoreCase(ch, "b"))
|
||||||
return &CpuDebug::b;
|
return &CpuDebug::b;
|
||||||
|
else if(BSPF::equalsIgnoreCase(ch, "_cycles"))
|
||||||
|
return &CpuDebug::cycles;
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue