Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.
I am confused by how QueryPerformanceCounter works. I have used QueryPerformanceFrequency to get my CPU ticks, and I know that works because it returns the speed of my CPU in Hz correctly. Now I have searched Google and have come up with this kind of thing;
It's like 10000000 different when it should only be a couple of thousand. So what does QueryPerformanceCounter actually return? It always seems to wrap at around the 32-bit 4 billion mark.
And if you've got a MessageBox call in between the two calls you could get a high value because MessageBox doesn't return until you press OK/Cancel/whatever.
Though using Sleep(1) will hog the CPU quite a bit, so you should probably do it in two stages. First with longer sleeps, and then with Sleep(1) as you get closer to the limit.
And that's the problem for me. I know that I can use methods that will work, but will use the CPU 100% of the time, so I need the kind of method that other emulator authors use.
Here's another tip for you if you're using QueryPerformacene*
I discovered this one after trying our code at the office on another computer.. it seems like computers with more then one core can have a problem with those functions making it very unstable. To solve this you call SetThreadAffinityMask() before and after the QueryPerformance call.
edit:
Worth to note though, is that I've heard mixed response to this solution with some saying that this still won't guarantee anything. But it seems to work good so far ;)