Hello,
This is another boring (really boring, seriously
) tech-related-topic by dziugo. If you aren't interested in this kind of stuff, stop reading now, no need to waste your time here
.
For those who haven't yet closed their InternetExplorer window...
Prologue - Info about rdtscWhat is rdtsc? It's an instruction of modern (286+ i think...
) CPUs that fills the EAX and EDX registers (yep you're right, 64-bit value) with the amount of clock cycles since the start of system. This value is kept by the CPU and is increased every [1/CPU speed] second. I have an Athlon XP 2000+ on-board, so this value is increased every 0.000000000602 seconds in my CPU. Why am I talking about that? You'll see (or you won't? anyone got to this part?
).
Part1 - FF7 benchmarking your CPUWhen FF7 is launched it (kind of) benchamrks your CPU. It checks how many clock cycles are done in 1000ms (it's 1663653990 on my computer). Basically it's just a speed of your CPU in Hertz. After that, this value is stored (address: 0x014F2B80) and used whenever it's necessary.
Part2 - FF7 using simple frame limiterAs we all know (well, I didn't, but you've probably knew
), FF7 uses a frame limiter to make it run at similar speed on different computers. How it's done? Let's take a SubmarineMiniGame
When initialising the MiniGame, the value found under 0x014F2B80 is divided by 30.0 (meaning - FPS-limit is 30.0). FF7 also subtract 10000.0 from the result (it's some kind of speeding-it-up, but why it's done?). FF7 calls rdtsc before every frame, and stores that value. Then it does all the dirty job (scene creating). When it's done, it calls rdtsc one more time and calculates the difference between the new value and old value. After that, it pauses if necessary (well.. it's just a loop which is ended when the actual value is greater than the one it calculated at initialising the MiniGame). Simple isn't it? It keeps the frame rate under the 30.0FPS (about...). But... what happens, when the CPU isn't fast enough to keep processing the frames? Theoretically, it won't do any frame-skipping, since it's coded to run at 30.0FPS.
Part3 - Other frame limits in FF7Here are the FPS limits for each FF7-internal system (could contain errors):
Battle - 15.0FPS
Field - 30.0FPS (subtracts 10000.0 from the result)
Menu - 60.0FPS
Submarine - 30.0FPS (subtracts 10000.0 from the result)
Part4 - Misc stuff and endingFirst, the misc stuff:
- timeGetTime is called in SubmarineMiniGame to calculate the FPS rate for debugging, nothing more (AFAIK)
- I don't know, how much the FF7 speed is affected by using the multi-threading OS (well, at least it looks good...)
- In HighwayMiniGame, the rdtsc-calculating are done, but not used
I'll try to implement the frame-limiting in the HighwayMiniGame, but i don't know how long will it take (if ever). Also, I'm looking forward to check what Smithie has done already with his dT. For those, who've read the whole topic - congrats
. Yep it's the end.
dziugo