How Duke Nukem II’s parallax scrolling worked
lethalguitar.wordpress.com
lethalguitar.wordpress.com
My dad picked up an old EGA computer from work in the early 90s. I was always frustrated that almost all games required a VGA at the time. Now I understand why... It was too much effort to be backwards compatible with what was increasingly becoming niche hardware.
But yeah, automatic dithering didn't look nice.
Anyway, I guess the benchmarks in there were to show how slow plain VGA was, but really by the time frame of duke nukem, 486SX's and VLB were radically changing the PC's performance characteristics, even on fairly low end machines.
PS: I still have the cirrus technical manuals because back in the 1990's you could call up these companies, tell them you were a software developer and they would send you a 400+ page technical manual that details registers and operational/functional characteristics of the boards.
I know the market moved fast back then, but "sales" != "ownership". Sales may have switched to VGA overnight, but if a game wants to maximise it's audience it needs to target what people already own. So unless people buy computers like they buy milk, that would have included EGA cards.
Doom really changed this. Lots of people ran out and got new systems for the sake of Doom, when before there was an association between high end machines and complicated simulator games. And while there were still casual games that remained focused on the "granny PC" well into the 2000's, the market really redefined itself in a big way around this new wave of enthusiasts playing shooter games.
The CPU/GPU HW vendors could probably boost their sales by buying rights for some of those games and selling them very discounted to drive HW upgrades. Thats basically what happened to me with Witcher 3, I bought it on some super sale for $10-15 discovered it didn't play very well on my older graphics card, and ended up spending $500 (or something) as a result.
For the most part I think people mostly ignored the MPC spec's though. Outside of maybe 7th guest which drove CDROM sales, most people I knew who were interested in gaming already had purchased or scrounged up a soundblaster and a 10base2 nic (for lan parties).
When it comes to GPU manufacturers Afaik AMD started first in 2012 with "Never Settle" Far Cry 3, Hitman: Absolution and Sleeping Dogs. Nivida followed a year later with "Gear Up" garbage promotion of free items for free to play Planetside 2, World of Tanks and Hawken.
When it comes to bang for buck giving out free games is fools game, real money is in paying brib^^^ organizing cross promotion and developer support for game studios. Nvidia started with "The Way It’s Meant To Be Played" program sponsoring Ubisoft
https://techreport.com/news/14707/ubisoft-comments-on-assass...
this bought them power to retract game studios DirectX 10.1 patch which inconveniently gave AMD fps advantage.
Nvidia doubled down with a new program ironically called GameWorks:
https://techreport.com/review/21404/crysis-2-tessellation-to...
https://arstechnica.com/gaming/2015/05/amd-says-nvidias-game...
https://wccftech.com/fight-nvidias-gameworks-continues-amd-c...
"Number one: Nvidia Gameworks typically damages the performance on Nvidia hardware as well, which is a bit tragic really. It certainly feels like it’s about reducing the performance, even on high-end graphics cards, so that people have to buy something new.
"That’s the consequence of it, whether it’s intended or not - and I guess I can’t read anyone’s minds so I can’t tell you what their intention is. But the consequence of it is it brings PCs to their knees when it’s unnecessary. And if you look at Crysis 2 in particular, you see that they’re tessellating water that’s not visible to millions of triangles every frame, and they’re tessellating blocks of concrete – essentially large rectangular objects – and generating millions of triangles per frame which are useless."
Why give out free games when you can influence developers to include your closed source garbage tech (physX, running in FPU mode on SSE capable CPUs to make it a slow path without nvidia GPU), dial useless feature to 11 (tessellation), or incorporate something taking 50% performance hit for marginal visual gain (ray tracing) forcing users into frequent upgrades!
They werent even the first to do it. Intel pioneered this practice in their golden age of anticompetitive bribe binge starting in 1998 by sponsoring Ubisoft to print huge "Designed for Intel MMX" commercial on all POD boxes https://www.mobygames.com/images/covers/l/51358-pod-windows-... despite MMX not influencing game speed at all (used for one sound effect). Amazingly someone working in Intel "developer relations group" at the time is on HN and chimed in https://news.ycombinator.com/item?id=28237085
"I can tell you that Intel gave companies $1 million for "Optimized" games for marketing such."
$1 million for one optional MMX optimized sound effect.
Which is what drove my upgrades, I liked the games in question, and saw how they ran on other peoples hardware enough to want that experience for myself.
(although in the case of the 1080 I also had a monitor setup that didn't work well with the graphics card I was using at the time, so it was that as much as witcher which drove the upgrade).
Instead of bundling, the game companies would be better served by picking some gotta-have-it title and giving the first couple levels away as a trial/etc, and making sure that there was big jump in perf moving to the latest card and then bundling the license with the card. That way people were hooked and willing to pay for the experience. I generally avoid bundled card deals because the games don't interest me.
as in my linked examples Nvidia already does that by paying dev houses to slow down games on older/competitor hardware.
I would be very surprised by this. Raster ops, yes. Alpha channel image compositing operations, no way - that's an entirely whole nother level of complexity.
So I looked it up, the 542x series in this article do support "transparency" blt operations, but it might be fair to call them raster ops rather than full blending. They would be be sufficient for the parallax scrolling Duke Nukem here was implementing, which was sorta my original point.
OTOH, full 32-bit ARGB support shows up in the Cirrus line of adapters with the next revision 543x, mostly for video overlay though, although the way its wired seems to leave a lot of open doors for interesting effects too.
And full blown alpha blending shows up one generation later in the 546x series.
So there is full hardware support by the mid 1990's in fairly low end HW/PCs at that point. I've said before on this board that alpha blending was going on all through the 1990's and there are various ways to "cheat" and speed up what is presented in '84 (https://dl.acm.org/doi/10.1145/964965.808606). Pulling my Copy of CGPnP off the shelf it says under compositing "since it is fairly easy to do". I give you a demo from '92 with real time apparent blended transparency: https://www.youtube.com/watch?v=pLJhtefcoPE see about 4 mins in. I sorta doubt this is the first case, but was one I vaguely remembered, since I was myself hacking these kinds of things with my schoolmates around that time as we tried to emulate what we saw others doing/etc. And none of us went into computer graphics or gaming oriented parts of the technology fields.
BTW: That demo notes it needs a 386+VGA, so we are talking late 1980's PC hardware.
http://www.vgamuseum.info/index.php/cpu/item/130-cirrus-logi... "D3 Selects the memory read data latches to be eight bytes wide, instead of the normal four bytes. This bit can be used in Write Mode 1, in order to rewrite 8 latched pixels (64 bits) back into display memory. This bit should be used in X8 addressing mode only."
= Set/Reset and Compare registers extended to full 8 bits and read/write mode 1 extended to 8 bytes at a time with extra foreground/background masks. If Im calculating correctly this means you can perform internal copies at 12-20MB/s and lines/pattern fills at 24-40MB/s
Things might of looked different with VBE/AF fully defined in early 1992 and subsequent graphic products all providing at least partial support (8/16bit panning and sprites would be enough).
Instead everything was too late. Even VESA LFB never truly got implemented on ISA cards (afaik only ATI Mach64 and maybe experimental support in ET4000?), and only started working on VBE and PCI.
Reading Masters of Doom some 30 years later was pretty eye opening. This article too - to this day I’ve never heard of latch writes.
So much voodoo in graphics programming!!
Not recommended for your present-day productivity (unless you’re making retro games!)
I played the duke nukem 1 & 2 shareware _back in the day_ but I missed out on Turrican thanks for sending me down this rabbit hole.
I also remember carmack's fast square root function. So many amazing tricks. There definitely needs to a site or sub-reddit dedicated to these.
The Amiga had a lot more helpful hardware. Lionheart really is an incredible title for squeezing so much out of the OCS chipset.
https://www.youtube.com/watch?v=y9BltSvKMlQ
Honestly, PC games were a complete joke compared to whatever was on the Amiga, until Wing Commander 1 came out.
[1] https://codetapper.com/amiga/sprite-tricks/shadow-of-the-bea...
Don't get why you need to put down what someone else did because someone else did something better at the same time? Nobody claimed it was the best parallax at the time.
https://genius.com/Monty-python-four-yorkshiremen-live-lyric...
Agree with the parent, it's great to develop a richer context on top of the OP and have everyone benefit as a result, but there's no need to put one down in order to raise another. They're both cool and interesting.
But this kind of game raises my stress levels :D
Yes, I used to play R-Type, Blood Money, etc. Then I realized I didn't enjoy them, I suffered them.
A parallax a 50 Hz was silky smooth. A video of a game running at 50 Hz that is recorded at 30 fps doesn't do the original game justice.
The link to Shadow of The Beast (Amiga 1989) is much better in that you can configure YouTube to play the vid at 50 Hz.
(Also the only video I could find with the original, heroic-sounding music I remember, as everyone else seems to have somehow ended up with a disk image using an oddly-substituted filler track.)
The Commodore 64 had smooth parallax scrolling in 1986 without any hardware acceleration. Instead, they used a trick where they rolled the character set definitions, eg. https://www.youtube.com/watch?v=iHrmjP6D1OU
More advanced examples appeared later. eg "Flimbo's Quest" in 1990 https://www.youtube.com/watch?v=SiCxXMquPKs
This video has an explanation for how it worked https://youtu.be/DQpLAIkNVLE?t=165
I didn't know that Flimbo's Quest trick, that's cool!
BTW, many Amiga games could do 3 layers per horizontal line.
I've read the technical explanation but it was beyond me at time.
The technique of pre-shifting was used very widely, even on consoles with some form of hardware assistance (Sonic 3 uses pre-shifted images to gain an extra parallax layer in some places, like the Launch Base Zone background, in addition to the two hardware tile layers and single sprite layer, which could be combined in interesting ways via priority bits). Many Amiga games would also dedicate two sprites to generating a parallax layer (as the Agnus chip's "copper" could rewrite sprite registers mid-scanline, two sprites would be sufficient to cover the whole width of the screen via updating the image pointers on the fly, which was really the endgame of the idea of "racing the beam", dedicating a piece of compute logic towards updating registers at extremely high speed)
Combine that with multiple character sets and you get a variation of the Duke Nukem II approach for "free" - you scroll the characters for the background with the foreground, but you flip to a partially scrolled definition of the tiles.
Another approach often used when the background is limited in complexity, is sprites.
A third option is banding. E.g. if the background you want to parallax scroll is above the normal play area, you can use the raster interrupt to control the scrolling independently for each band.
A fourth option is a bitmap scroll of the tile data. This is "easy" if your parallax bands are limited patterns. E.g. you might fill one band of the background with 0123012301230123 over and over, and then just scroll that as a 32 bit pattern in the character definition.
In any case, the key to all of these is that few c64 games use the bitmap mode (a few do), and so you get to offset the slow CPU with moving far less data around. Tack on the hardware sprites and raster interrupt and you can do a lot of interesting stuff.
Here's a great page on Parallax in C64 games with some video:
This article is about how Duke Nukem II specifically implemented drawing so that it could actually achieve playable framerates on EGA video cards and slow ISA buses, which were too slow to do a naive implementation.