Difference between revisions of "Lag"
(→Common sources of lag) |
|||
Line 66: | Line 66: | ||
One address, {{HEX2|0FB4[0x1]}}, is a flag that tells the game to go through all garnish slots and execute them. Garnish can be stuff like a rock or bush being broken into many pieces when you throw it or slash it. The variable is reset on every underworld supertile transition, and when you go from underworld to overworld and vice versa. No known way to "exploit" this to get less lag - the closest in NMG is to not grab the first tree rupees (and also don't dash through any bushes), which would give you less lag for the Lost Woods transition. So not really a feasible strat. | One address, {{HEX2|0FB4[0x1]}}, is a flag that tells the game to go through all garnish slots and execute them. Garnish can be stuff like a rock or bush being broken into many pieces when you throw it or slash it. The variable is reset on every underworld supertile transition, and when you go from underworld to overworld and vice versa. No known way to "exploit" this to get less lag - the closest in NMG is to not grab the first tree rupees (and also don't dash through any bushes), which would give you less lag for the Lost Woods transition. So not really a feasible strat. | ||
− | Another is {{HEX2|7EC300[0x200]}}. This is a palette buffer (2 bytes = 1 palette) that is used during mosaic events in the game. It will contain palette values that might not be used on the current screen - ie. left-overs from previous screens, but the code that calculates what colors to display for each frame during a mosaic event will do extra work for each non-zero value. By for example dying (even if you have fairy), some of these values will be set to zero and give you less lag in mosaic transitions. A save & quit is not sufficient in clearing these palette values, so a full reset | + | Another is {{HEX2|7EC300[0x200]}}. This is a palette buffer (2 bytes = 1 palette) that is used during mosaic events in the game. It will contain palette values that might not be used on the current screen - ie. left-overs from previous screens, but the code that calculates what colors to display for each frame during a mosaic event will do extra work for each non-zero value. By for example dying (even if you have fairy), some of these values will be set to zero and give you less lag in mosaic transitions. A save & quit is not sufficient in clearing these palette values, so a full reset might give you less lag if you're starting a new run. |
== 100% TAS analysis == | == 100% TAS analysis == |
Revision as of 14:19, 21 November 2018
A lag frame happens when the CPU had so much to do in the previous frame, that it didn't finish all of its calculations. Even if the work needed to complete the calculations from the previous frame is minimal, the game still allocates a full frame to finish it off. This frame is essentially a wasted frame in the context of speedrunning since you spent two frames updating the game state only once.
Common sources of lag
Most lag frames in ALttP are unavoidable. It comes from things like decompressing graphics or text and updating huge arrays in the SNES memory when changing screens etc. But there are some things you can do to avoid lag in certain situations, some of which is listed below.
- Rupee lag
The way the game draws the number of rupees on the screen is very inefficient. For each digit except the last one (the "ones"), it will have to do more calculations the higher each digit is.
This means that having 100 rupees is better than having 90 rupees (1 + 0 is less than 0 + 9). While 90 and 99 is the same (since the last digit does not matter).
An analysis of GodTAS showed that it saved 51 frames of lag by having 100 rupees after getting Tempered Sword, versus having 90-99 rupees which is quite common in runs.
To avoid rupee lag in NMG, you want 114 rupees entering Agahnim's Tower. This is mostly not something you can do anything about, since going out of your way to grab more rupees would probably waste more time than it saves.
This same concept applies to bomb and arrow counts too.
- Shield lag
The game spends time figuring out where and how to draw Link's shield. This code is skipped when Link does not have a shield, which can potentially save lag frames.
By analyzing GodTAS, it was shown that not having a shield after completing Ice Palace saved 139 frames of lag throughout the rest of the run.
Another application of this is to grab a wall during boss explosions or similar events. While holding the wall, the shield is not drawn, which has shown to save frames in certain situations (Agahnim 2 opening and ending for example, and possibly during Agahinm 1's lightning attack).
- Heart lag
While there's not much you can do about it, having more HP will cause the game to lag more. Both the containers themselves, and Link's current HP matters.
By analyzing GodTAS, it was shown that grabbing Sanctuary Heart actually adds an additional 65 frames of lag throughout the run.
Another known application of this is the Sanctuary cutscene right after Escape. You can save ~40 frames by having 1 heart or less entering the cutscene.
- Sprite lag
The more sprites (enemies, drops) there are on the screen, the higher the chance is for lag frames to occur. Killing sprites can sometimes save time over not killing them.
The most notable instance of this is in Swamp Palace, where killing more enemies in the room below the second water lever room will save time during the water animation.
Another instance is the firesnake in Thieves' Town, right before opening up the first big key door. After you dash into the stairs, if the firesnake is high up on the screen, you can save time by delaying the dash and instead walk upwards a little bit first, which deactivates the firesnake since it will move out of the screen.
- Movement lag
When Link is moving in any direction, a lot of code is executed to figure out which coordinate to update to, whether Link collided with a wall etc. Walking diagonally executes this code twice.
For the most part, you do want to move in the optimal path for the current room, but there are some instances where avoiding an optimal diagonal path, or delaying the diagonal, can save time.
Mimics are one of the worst enemies for lag, since you get general "sprite lag" but also "movement lag" from them. In general, avoid moving diagonally in screens with Mimics in them.
- Transition lag
Most of the lag from a transition is unavoidable.
But it has been shown that you can avoid some of the lag on overworld transitions that uses the Mosaic effect (entering/leaving Lost Woods or Zora's Domain for example) by canceling your dash right before transitioning, instead of transitioning with a dash.
- Peg switches lag
It has been shown that if the peg switches in a dungeon is set to Blue and not Red, every transition gets an extra 3f of lag.
- Item lag
Using items (hookshot, boom, arrows etc.) can cause lag frames, since the CPU has more to calculate.
One thing you should avoid, which some people do for fun, is using the hookshot when entering Agahnim 2. This has shown to lose up to 40 frames during the first cutscene.
Another thing you could avoid, is doing long hookshots in the Arrghus fight. By being closer to Arrghus when you hookshot, you will save some lag frames.
- G-Tower opening cutscene lag
You can get less lag frames during the G-Tower opening cutscene by 1. not dashing into the cutscene and 2. not being on the top-most coordinate (up against the south wall of G-Tower). Optimally you want to cancel the dash with
, right before the cutscene trigger. This could save ~20-25 frames of lag.- Other lag
There are certain addresses in memory that might add/remove lag depending on what it's set to. It is theoretically possible to manipulate which values these are set to by doing different actions.
One address, $0FB4[0X1]
, is a flag that tells the game to go through all garnish slots and execute them. Garnish can be stuff like a rock or bush being broken into many pieces when you throw it or slash it. The variable is reset on every underworld supertile transition, and when you go from underworld to overworld and vice versa. No known way to "exploit" this to get less lag - the closest in NMG is to not grab the first tree rupees (and also don't dash through any bushes), which would give you less lag for the Lost Woods transition. So not really a feasible strat.
Another is $7EC300[0X200]
. This is a palette buffer (2 bytes = 1 palette) that is used during mosaic events in the game. It will contain palette values that might not be used on the current screen - ie. left-overs from previous screens, but the code that calculates what colors to display for each frame during a mosaic event will do extra work for each non-zero value. By for example dying (even if you have fairy), some of these values will be set to zero and give you less lag in mosaic transitions. A save & quit is not sufficient in clearing these palette values, so a full reset might give you less lag if you're starting a new run.
100% TAS analysis
This table represents an analysis of lag sources throughout the 100% TAS:
Source | Text line | Textbox | UW->OW | OW->UW | OW transition | Supertile | Spiral stairs | Pit/Telepad | Item load | Boss explosion* | UW Mirror | OW mirror | Flute |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | 25 | 100 | 120 | 34 | 19 | 57 | 60 | 4 | 125 | 98 | 76 | 67 | |
3 | 23 | 102 | 122 | 35 | 18 | 61 | 90 | 4 | 46 | 98 | 79 | 69 | |
3 | 24 | 97 | 116 | 33 | 18 | 57 | 47 | 4 | 54 | 101 | 77 | 69 | |
3 | 30 | 122 | 82** | 34 | 18 | 58 | 61 | 4 | 46 | 99 | 82 | 68 | |
5 | 32 | 119 | 128 | 32 | 18 | 57 | 55 | 4 | 50 | 99 | 90 | -- | |
1 | 24 | 121 | 135 | 35 | 18 | 61 | -- | 4 | 39 | -- | 77 | -- | |
4 | 26 | 120 | 117 | 51 | 18 | 67 | -- | 4 | 223 | -- | 78 | -- | |
3 | 21 | 99 | 121 | 30 | 19 | 59 | -- | 4 | 32 | -- | 79 | -- | |
3 | 19 | 99 | 121 | 35 | 21 | -- | -- | 4 | 50 | -- | 83 | -- | |
3 | 36 | 123 | 94 | 35 | 18 | -- | -- | 4 | 148 | -- | 83 | -- | |
Average | 3.1 | 26 | 110.2 | 115.6 | 38.9 | 18.5 | 59.63 | 62.6 | 4 | 81.3 | 99 | 80.4 | 68.25 |
- Notes
* Some include ~8 frames for obtaining heart
** Pit transition to underworld
- Other notes
- Dark room transitions add about 40f of lag
- TT lag room was 24f of lag
- Boss order: Helmasaur, Blind, Moldorm, Mothula, Vitreous, Trinexx heads, Trinexx shell, Trinexx body, Trinexx head, Lanmo (all 3)