Changes

4,150 bytes added ,  07:17, 16 July 2021
add lag and look down technical details and references
Line 20: Line 20:  
One of the big early discoveries was that of '[[lookdown]]'. More precisely, this was the idea that a higher frame rate increases your forward speed.
 
One of the big early discoveries was that of '[[lookdown]]'. More precisely, this was the idea that a higher frame rate increases your forward speed.
   −
Again this is not terribly well understood, as the code is horrific. Your forward movement seems to be actually driven by the animation of Bond moving side to side, and so perhaps the root cause is in how lag effects this process.  
+
This is not well understood. Your forward movement seems to be actually driven by the animation of Bond moving side to side, and so perhaps the root cause is in how lag effects this process. <ref name="lag and lookdown">{{cite web | url=https://forums.the-elite.net/index.php?topic=18518.msg450020#msg450020|title=the-elite facts topic post on lag and lookdown|access-date=July 16, 2021}}</ref>
    
Certainly exactly when lag spikes land affects the loss of speed: TASers will nudge weapon switches about by a few frames to find a spot that causes the smallest loss of forward speed, and the variation is dramatic.
 
Certainly exactly when lag spikes land affects the loss of speed: TASers will nudge weapon switches about by a few frames to find a spot that causes the smallest loss of forward speed, and the variation is dramatic.
   −
Strafing speed is added to your velocity much later in the process, and is confirmed as being entirely unaffected by lag.
+
In conclusion, the complex nature of Bond's forward movement causes a decrease in speed when lag increases and is the reason why lookdown saves time.
 +
 
 +
Strafing speed is added to your velocity much later in the movement calculation process, and is confirmed as being entirely unaffected by lag.
 +
 
 +
== Technical Details ==
 +
 
 +
=== Lag and lookdown ===
 +
 
 +
First of all, what does lookdown actually do?<ref name="lag and lookdown" /> Well, it makes it so that less things are rendered on screen, thus increasing the framerate. However, if we dig a bit deeper, and look at how this affects in-game values in memory, we'll see that it mainly affects the value that tells the game how many 1/60th ticks (i.e. "frames") that passed since the last update.
 +
 
 +
To figure out how many frames have passed, the game checks the value of the N64 CPU cycle counter. According to the official documentation<ref>{{cite web | url=https://level42.ca/projects/ultra64/Documentation/man/n64man/os/osSetTime.html|title=N64 official documentation osSetTime|access-date=July 16, 2021}}</ref>, the CPU runs at 45.6375 MHz (or perhaps 46.875 MHz<ref>{{cite web | url=https://level42.ca/projects/ultra64/Documentation/man/n64man/os/OS_CYCLES_TO_NSEC.html|title=N64 official documentation OS_CYCLES_TO_NSEC|access-date=July 16, 2021}}</ref>). If we wish to convert this to 1/60ths of a second:
 +
<pre>
 +
                  cpu_cycles          cpu_cycles
 +
    frames = ------------------  = ---------------
 +
                (46875000 / 60)        781250
 +
</pre>
 +
Interestingly, the game doesn't divide by 781250, but rather 775875. I haven't been able to figure out where that number comes from. This number comes from the PAL version <ref>{{cite web | url=http://ultra64.ca/files/documentation/online-manuals/man/n64man/os/osGetTime.html|title=N64 official documentation osGetTime|access-date=July 16, 2021}}</ref>, credit to MW for figuring it out. Anyway, to get the number of frames passed since last update, we just use the number of CPU cycles passed, divided by 775875, and rounded to nearest integer. This number will be added to the mission timer and will be used in gameplay calculations. To understand lookdown, we'll want to look at the way Bond's position is updated. This is straightforward:
 +
 
 +
position += (velocity * time)
 +
 
 +
Time in this case is the value we calculated in the previous step. So if we assume a constant velocity, the distance we move will be proportional to the number of frames passed since the last update. In this scenario, we should be moving just as fast no matter how much the game lags, meaning in-game time should remain unaffected. In reality however, velocity is not constant.
 +
 
 +
The calculation of velocity in Goldeneye is very complicated, and beyond my patience to figure out. What we can say is that in order to lose in-game time, the average speed of Bond must decrease when lag increases. In order to test this, I modified a ROM to force the number of frames passed to a constant value, essentially emulating constant lag. The result can be seen in [https://www.youtube.com/watch?v=HU3TekStVXY this video] (the lower right corner shows the value of the constant).
 +
 
 +
When running forwards, the amount of lag has a huge effect on the amount of time it takes to run down the runway (~1600 frames at 1x, ~13000 frames at 64x). Bond's speed clearly decreases at higher amounts of lag, almost to the point of Bond stopping sporadically at 64x. It looks strange to say the least.
 +
 
 +
Sideways movement is a different story however, as it remains smooth even at very high lag. Indeed, the time taken stays relatively constant at ~2000 frames throughout the test.
 +
 
 +
In conclusion, the complex nature of Bond's forward movement (likely programmed that way to create more interesting gameplay and make the movement feel less artifical) causes a decrease in speed when lag increases and is the reason why lookdown saves time. Normally, the game runs at around 1x-4x, where you can't really see the effect. However, it is there, and over longer distances it will have a big effect on you in-game time.
 +
 
 +
==References==
 +
{{Reflist|2}}