If a computer is powerful enough, how does it know not to play videos or perform logic for games at a faster speed?

905 views

I don’t know if I’m explaining this right…
A computer can run logic at some speed based on how powerful the components of it are, so if it can perform the logic of something, for example, movement in a game, how does it know how much should be done based on its power, instead of essentially running in “fast-forward” or conversely in slow motion?

In: 1307

40 Answers

Anonymous 0 Comments

Imagine starting math class on the first day of school and the teacher hands everyone a thick pile of printouts containing every day’s homework assignments for the whole year of class. If you’re super good and super fast at math you might get to work and finish super-early – maybe even weeks or months early.

Now imagine starting a math class and on the first say of school the teacher hands everyone a single homework assignment. On the second day they hand out a second assignment, on the third day they hand out the third assignment, etc. There is no way for you to finish early (no matter how good or fast at math you are) if this is how the teacher hands out the homework assignments. You might finish each assignment in 5-seconds instead of 5-minutes… but there’s no way you’ll get out of sync with the rest of the class.

————————————————————————–

Videogames and audio/video playback don’t have “fast forward” problems because they are programed to “hand out assignments” at predetermined well-scheduled intervals like the second example.

—————————————————————————————————————-

However, if you emulate some very old videogames on modern hardware you can sometimes run into the exact kind of “fast-forward” problem you describe.

Usually it happens because the game was only ever meant to be played on one very specific piece of console hardware… and so no assignment-schedule programming was done because “handing out the whole pile of homework” was slightly easier to program and was assumed to run the same way on the same piece of hardware every single time.

Anonymous 0 Comments

Because the computer has a clock that runs at a set speed independent of the processor.

This wasn’t always the case, some older software and video games did time their actions based on the processing speed, so if the software was ran on a faster computer then the game would also appear sped up.

Anonymous 0 Comments

Great Question! Modern computers have very accurate clocks built into them. When you write a computer program, you can write a command like “do nothing for .002 seconds”. Video programs and games will use pauses to make sure they update the screen and look for user input at the correct times.

Many older computers did not have this ability, and if you played a game on a computer that was too fast, it might be impossible to play because everything would move too fast.

Anonymous 0 Comments

There are internal clocks you can call to ensure you do things at the right rate.

But in the past certain games were linked to processor speed, so having a faster processor can make certain things happen faster.

Then to make it all more complicated there is also your internet connection speed.

So there were lots of examples of issues, since trying to to take into account time, processor speed and network connection is hard, so often you have weird artefacts depending on these.

Anonymous 0 Comments

Computers usually know exactly how fast they are and can time things accordingly. Time-sensitive software is programmed in such a way that the actual logic code will run, figure out how long to wait for until it needs to run again, then wait that amount of time.

Anonymous 0 Comments

Clocks. This brings to mind the old 386 days when a faster computer would play the game faster. Until computers became so fast it was impossible to play the old games. Try playing the original Wolfenstein on an 8 core i7…

Anonymous 0 Comments

Fun fact, during an interview process for an airline, we had to play a mini game (to test basic hand eye coordination and reflexes I guess).
I figured out the game was computer speed dependant and quickly ditched my gaming laptop for the old pentium + crt screen in the basement.
Got through to the next part easily 🙂

Anonymous 0 Comments

It’s like your computer knows how much power it has and adjusts the speed of the game accordingly, just like how you can control the speed of a toy car

So it won’t go too fast or too slow.

Anonymous 0 Comments

Games are programmed to update frames using delta time. However, if they aren’t then what you said will occur.

Anonymous 0 Comments

So there’s two ways to handle this.

The first is by padding out NOP instructions, which basically tells the CPU to “do nothing”. This is what early console games did, since every console had the same hardware and ran at the same speed, they could just write the main loop to do everything it needed to do, then put in enough NOPs to make it run at whatever speed they wanted. This actually does result in a “fast forward” effect if you try to run them on faster hardware.

With newer games you first read the clock into a variable we’ll call T, do all the stuff you need to do, then just sit there and keep reading the clock until it reads T+10ms before you run the loop again. That means the loop will run once every 10ms.

In both cases, the stuff you do in the loop is: check inputs to see if a button is pressed, react accordingly, update the character’s position, then render the results on the screen.

Edit: since you’re reading from a realtime clock, all that matters is that the CPU can complete all tasks within the disired timeframe. It will run at the same speed on all hardware that is at least fast enough to beat the clock.