I am writing a MOS 6502 processor emulator as part of a larger project that I undertook in my free time. The emulator is written in Java, and before you say it, I know that it will not be as efficient and optimized as if it were written in c or assembly, but the goal is to run it on different platforms and pull it out 2.5MHZ on a 1GHZ processor, which is pretty good for an interpreted emulator. My problem is quite the opposite, I need to limit the number of cycles to 1 MHz. Ive looked around, but did not see many strategies for this. Ive tried a few things, including checking the time after several cycles and sleeping for the difference between the expected time and the actual time elapsed, but checking the time slows down the emulation by 8 times, so someone has some better suggestions or maybeways to optimize time polling in java to reduce slowdown?
source
share