1
0
mirror of https://github.com/irmen/ksim65.git synced 2024-06-13 06:29:38 +00:00

cpu jump loop detection added

This commit is contained in:
Irmen de Jong 2020-02-16 15:40:51 +01:00
parent 30351b44ba
commit c327c59c8b
2 changed files with 10 additions and 0 deletions

View File

@ -245,6 +245,10 @@ class C64Machine(title: String) : IVirtualMachine {
// this should result in ~1 Mhz cpu speed
val timer = java.util.Timer("cpu-cycle", true)
timer.scheduleAtFixedRate(0, 1000L/VicII.framerate) {
// if(cpu.isLooping) {
// // cpu is jump looping, could do some sleeping here perhaps
// // but should still consider irqs occurring in the meantime...
// }
if (!paused) {
try {
while (vic.vsync) step()

View File

@ -98,6 +98,11 @@ open class Cpu6502 : BusComponent() {
protected set
var instrCycles: Int = 0
protected set
val isLooping: Boolean get() {
// jump loop detection
return (previousOpcodeAddress == currentOpcodeAddress) && !(pendingNMI || pendingIRQ)
}
private var previousOpcodeAddress: Address = 0xffff
lateinit var currentInstruction: Instruction
@ -263,6 +268,7 @@ open class Cpu6502 : BusComponent() {
}
// no interrupt, fetch next instruction from memory
previousOpcodeAddress = currentOpcodeAddress
currentOpcodeAddress = regPC
currentOpcode = read(regPC)
currentInstruction = instructions[currentOpcode]