4 ms·
"Unefined" refers to the spec, not the hardware. https://en.wikipedia.org/wiki/Undefined_behavior https://en.wikipedia.org/wiki/Undefined_behavior This case a
by papln 7y ago
"Unefined" refers to the spec, not the hardware.
https://en.wikipedia.org/wiki/Undefined_behavior https://en.wikipedia.org/wiki/Undefined_behavior
This case appears to be "undocumented scenario" or "unsupported use-case", though.
- kazinator 7y agoDo we know that the developers didn't confirm this hack with the hardware people? It could be "defined by e-mail".
- jupiter90000 7y agoFunny to think Zelda was made before email was probably used at these companies :)
- philipov 7y agoYou are playing semantics to try to justify it. If it's not in the official spec, it's undefined behavior.
- kazinator 7y agoI don't agree with the suggestion that there is no difference (other than word semantics) between relying on empirical observations and relying on a privately communicated piece of spec. The one playing semantics is you, since your apparent concern is the definition of the term "undefined behavior" and whether something falls under that definition. My point is about how well an engineering decision is justified, not what term applies to it according to some document.
- ohazi 7y agoDoes anyone actually care? This was embedded software designed to run on exactly one system, not some libc designed to run on 20 architectures ranging from 8-bit microcontrollers to VLIW supercomputers.
- stuart78 7y agoWhat I find interesting is looking for creative ways to prioritize the game experience even when the 'official spec' didn't support it. They could have given up by accepting that the spec represented the limit of what could be done, but instead pushed to find a better way. I hadn't put thought into how important that scroll effect is to the game, but if there was a clean wipe between scenes it would have been tremendously distracting. This technique really is essential to the feeling of immersion.
- derefr 7y agoThe best definition of "undefined behavior" is: "if some other company created a clone of this console by following the spec to the letter, but otherwise making all their own decisions... would this game run?" Of course, if you don't have cloners immediately nipping at your heels, you might end up releasing a smash hit that takes advantage of UB in a way that forces you to define the behavior as "it works however it needs to work to keep that game working", because eventually you yourself (the original console manufacturer) will tape out later revisions of the CPU, and you'll want to make sure they can run that game, given that it's "officially licensed" by you. If you had the right static analysis tools in play, though, you might have wanted to run them over the game, notice the use of UB, and thus fail the game at the QA stage, before things need to escalate to that point.
- kazinator 7y agoIt's not "best" enough to actually appear in a Nintendo spec somewhere, unfortunately.
- derefr 7y agoI meant "best" as in "most practical for a third-party dev when deciding what behaviors to take advantage of." Defined behaviors are guaranteed to work in both 1. clone consoles that conform to the spec, and 2. future revisions of the official hardware. Undefined behaviors aren't.
- kazinator 7y agoFuture revisions of the hardware can throw everything out the window regardless of what is documented for the current hardware. What NES cartridge from 1986 can you plug into current Nintendo boxes?
- ohithereyou 7y agoThe argument that GP seems to be making is that only relying on defined behavior ensures that your game will work on all NES systems made by Nintendo as well as any clone systems that follow the specifications that Nintendo issued for programmers on the NES.
- lgg 7y agoWe have no idea if it was even undefined in the first place, since the PPU documentation is not public. You are correct thought, often guarantees about behavior can be made after the fact. Generally what happens these days is someone determines they need or want to use a certain undefined behavior. The hardware people then go, look at the RTL for the chip and confirm it behaves in a certain way, and then they UPDATE the documentation to explicitly document the newly guaranteed behavior. Conversely, often something that is documented to work just doesn't. Especially in the case of console developers who tend to be using early steppings of custom silicon. In that case sometimes when you go to the HW team they fix it in the next stepping, sometimes they document it as errata and move on.
- klodolph 7y agoThis definitely does not appear to be an “unsupported use-case”. This technique is used in many first-party launch titles. As far as I can tell, this is the reason that sprite zero tests exist in the first place. If you want an example of something that’s really an unsupported use case, consider mid-frame palette changes—in order to do this, you actually have to disable and re-enable rasterization during the horizontal blanking interval. It works, but it is difficult to get right and the PPU is clearly not designed with this in mind. Short of having an actual spec in hand, it would appear that mid-frame scroll register updates were entirely normal and an intended way to use the device, based on the evidence (no other reason for sprite zero check, lots of first-party titles using this feature, other mid-frame updates are much more difficult).
- makomk 7y agoThe sprite zero check is useful for changing the horizontal scroll position mid-frame, which is something the hardware seems to be designed to support - it helpfully copies the value written to the scroll register to the internal horizontal scroll position at the end of each scanline. It does not seem to be designed to make the same thing possible for vertical scrolling. The programmed register value for vertical scroll is read once at the start of each frame.