OpF0, OpF1, OpF2, Op__, Op__, OpF5, OpF6, OpF7, OpF8, OpF9, OpFA, Op__, Op__, OpFD, OpFE, OpFF
};
+
//
// Internal "memcpy" (so we don't have to link with any external libraries!)
//
//bleh.
//static uint32_t limit = 0;
+// This should be in the regs struct, in case we have multiple CPUs...
+#warning "!!! Move overflow into regs struct !!!"
+static uint64_t overflow = 0;
//
// Function to execute 65C02 for "cycles" cycles
//
if (regs.clock + cycles > 0xFFFFFFFF)
wraparound = true;
*/
- uint64_t endCycles = regs.clock + (uint64_t)cycles;
+ uint64_t endCycles = regs.clock + (uint64_t)cycles - overflow;
while (regs.clock < endCycles)
{
}
}
-//This is a lame way of doing it, but in the end the simplest--however, it destroys any
-//record of elasped CPU time. Not sure that it's important to keep track, but there it is.
-// Now we use a 64-bit integer, so it won't wrap for about 500 millenia. ;-)
-// regs.clock -= cycles;
+ // If we went longer than the passed in cycles, make a note of it so we can
+ // subtract it out from a subsequent run. It's guaranteed to be positive,
+ // because the condition that exits the main loop above is written such
+ // that regs.clock has to be larger than endCycles to exit from it.
+ overflow = regs.clock - endCycles;
myMemcpy(context, ®s, sizeof(V65C02REGS));
}
+
//
// Get the clock of the currently executing CPU
//
{
return regs.clock;
}
+