MAME Work In Progress - Polygonet Commanders (Part 7, Ordering - 7:23AM 25 June 2022)
This video represents the present state of Polygonet Commanders in my MAME source tree, and is (at a minimum) how the game will look in the upcoming release of MAME 0.245, assuming my pull request is approved.
One of the consistently irritating issues that I kept circling back to was the apparently "missing" portions of the player's tank during the very beginning of attract mode, as well as the base portions appearing in front of the doors as they open.
The hardware is both old enough and simple enough to obviously not support depth buffering: Although it was a concept which was known in the computer graphics field for at least a decade prior, the necessary bandwidth and RAM was still out of throwing range for even the custom sort of hardware that could be found in arcades during their heyday. Moreover, based on getting the on-screen 3D to draw at all, it was clear that Konami's custom chips are little more than accelerated span fillers: Which is to say, the DSP56156 manages transforming the 3D vertices to "screen-space" vertices, i.e., 2D coordinates. It then simply emits a set of start/end coordinates for horizontal lines that, when filled, will form a flat-shaded polygon. By the time the hardware even knows about the polygons, there's no such thing as depth.
Finally, out of desperation, I tried treating the framebuffers themselves as a very limited depth buffer: If a pixel has already been filled, don't allow any spans later in the list to overwrite it until an entirely new batch is being drawn.
It turns out that this was the key, and makes sense in retrospect. While it would be awkward in actual silicon to iterate to the end of the span list and then work backwards, it would be fairly trivial to have framebuffer writes use a read-modify-write cycle that aborts the "modify" and "write" portions if the framebuffer contains a non-zero value at that point.
While I was in there, I also worked to square up the size and position of the framebuffer relative to footage from real hardware, kindly provided by MAME developer Phil Bennett.
As far as I can ascertain, the only significant graphical issue is that some geometry continues to drop out, but I believe this is still due to lurking DSP56156 issues. After inserting a significant amount of debug-drawing code, it would appear that when the player's own tank body disappears, it simply is just not there in any of the span lists.