[HN Gopher] How Duke Nukem II's parallax scrolling worked
___________________________________________________________________
How Duke Nukem II's parallax scrolling worked
Author : bpierre
Score : 200 points
Date : 2022-07-15 14:23 UTC (8 hours ago)
(HTM) web link (lethalguitar.wordpress.com)
(TXT) w3m dump (lethalguitar.wordpress.com)
| Dwedit wrote:
| I never would have guessed that this game was using an EGA mode.
| Using a non-default palette completely fooled me.
| StillBored wrote:
| Hmm, maybe my memory is failing me, but VLB went from 0 to 100%
| on 486 motherboards pretty much overnight. The ISA bus limits
| (and hence EISA) were well known, and most of the SVGA cards
| being sold in the early 1990's (like those cirrus logic's) were
| "accelerated" to compensate for the lack of ISA bandwidth. AKA,
| they had blit engines, hw cursors, line drawing, etc, and windows
| drivers to utilize that functionality. I'm fairly certain,
| although to lazy to dig up the tech manual for them that the blit
| functionality included alpha channels. Given that 486's
| themselves were considered high end, I frankly never remember
| seeing one with an 8 bit EGA card, even 386's usually in the late
| 80's early 1990's were shipping with 16-bit (S)VGA cards because
| the 3rd party cards were fairly inexpensive. While EGA lived on
| in lots of games because it had some convenient modes, actual EGA
| cards were also fairly short lived in that little window before
| VGA was released so by the late 1980's weren't being sold with
| new machines. It was also fairly common to overclock the 8-MHz
| ISA bus to 10MHz on boards that didn't have VLB. Anyway, my point
| is that in 1992, low end machines were coming with Hercules
| graphics and monochrome monitors. Anyone who could afford a color
| RGB monitor wasn't getting it with VGA/EGA because the monitor
| was 80% of the price (few hundred dollars) and a 512K SVGA card
| was well under a hundred.
|
| 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.
| danachow wrote:
| > included alpha channels
|
| 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.
| tomxor wrote:
| > VLB went from 0 to 100% on 486 motherboards pretty much
| overnight. [...] actual EGA cards were also fairly short lived
| in that little window before VGA was released so by the late
| 1980's weren't being sold with new machines
|
| 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.
| bombcar wrote:
| Also upgrades were very very common back then - and you'd
| often sell back your current card to the store when buying
| the upgrade. So people would be upgrading to EGA cards as
| those came back in.
| syntheweave wrote:
| Also taking place in this time frame was the move towards
| "multimedia PC" standards. At its onset, MPC Level 1 helped
| consolidate the standards around VGA spec and Soundblaster
| audio, when before that, the expectations for PC games were
| that it was primarily an office computer and didn't "do"
| graphics or sound, so you just had to try to support
| everything, especially if you were doing shareware and wanted
| high install rates. So around 1991, when that spec was
| released, you start to see VGA as a requirement, but
| shareware did stay behind the curve to support "granny PCs".
|
| 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.
| luckyorlame wrote:
| Doesn't it still work that way?
| tambourine_man wrote:
| IIRC, Karateka did parallax scrolling in Apple II and C64 days.
|
| I've read the technical explanation but it was beyond me at time.
| vidarh wrote:
| Karateka is a poor example of Parallax on C64, as it apparently
| does (slow) bitmap scrolling in front of a static background.
| Parallax on the C64 tends to rely on the ability to redefine
| the character set and effectively use it as a tile set. You can
| smooth scroll characters using the graphics chip, so you only
| need to move them every 8 pixels.
|
| 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:
|
| https://www.c64-wiki.com/wiki/Parallax_Scrolling
| LocalH wrote:
| Karateka didn't use any of the C64's advanced features
| (hardware scrolling, sprites) as far as I know, being a game
| that originated on the Apple II. It was still very impressive.
| I wonder which C64 game was the first to have smooth parallax
| scrolling (at 50/60Hz).
|
| 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)
| aj7 wrote:
| If the graphic example shows parallax scrolling, I don't see it.
| It looks utterly flat to me.
| scatters wrote:
| The background texture moves relative to the foreground (pipes
| and walkways). That's all!
| chrisseaton wrote:
| Different planes moving at different speeds to simulate them
| being further away - thee we at what they mean and the example
| does show it.
| antiverse wrote:
| Semi-related; a fun bit of juicy drama is always par for HN:
| "Duke Nukem Stole Graphics from Turrican" -
| http://www.nemmelheim.de/turrican/news/duke/
| gRoberts84 wrote:
| Fair usage applies :D
| daenz wrote:
| After watching some gameplay of Turrican[0], which came out in
| 1990, I'm convinced it is heavily inspired by the NES Contra
| (1987).
|
| 0. https://www.youtube.com/watch?v=P7jP0qQgL-c
| alisonatwork wrote:
| That's pretty funny. Although, to be honest, I think a lot of
| the shareware platform games from that era were seen as low
| budget knock-offs of more famous games on the consoles and
| 8/16-bit home computers.
| bm5k wrote:
| A couple of those could be considered "inspired by" if you (a)
| squint and (b) ignore all the examples that are clearly the
| same ;)
|
| 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.
| davedx wrote:
| I remember implementing a side scrolling platformer on my 386 and
| being boggled by how slow everything was compared to on consoles.
| Didn't know what hardware acceleration was then, and this was
| before I got Internet access so I worked it out myself, coded it
| in C, then hand optimized the inner drawing loop in assembly,
| rewriting the pixel writes to use rep/mov instructions for each
| tile. This took a while but I managed to squeeze out acceptable
| performance for my game with Keen-like smooth scrolling.
|
| 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!!
| moosedev wrote:
| Since you mentioned latch writes, check out Michael Abrash's
| Graphics Programming Black Book[0], chapter 23 onwards, if you
| feel like immersing yourself further in well-written VGA lore.
|
| Not recommended for your present-day productivity (unless
| you're making retro games!)
|
| [0] https://www.jagregory.com/abrash-black-book/
| layer8 wrote:
| TLDR: The primary scrolling used 8-pixel steps (based on 8x8
| tiles), while the parallax scrolling was in 4-pixel steps just by
| using two (or 2x2) variations of the tiles. Also, the EGA
| hardware allowed copying tiles within video memory with four
| times the speed of memory accesses from the CPU, by operating EGA
| latch registers for the four bitplanes in parallel. The number of
| tiles on the screen where sprites and tiles and background
| partially overlapped, and therefore required slower drawing
| methods, was minimized.
| rob74 wrote:
| Ha! You call _that_ parallax scrolling? Then take a look at
| _this_ (Amiga, 1993):
| https://www.youtube.com/watch?v=BoiHk_3siYg. In the first level,
| the bands of clouds are moving in (I think) 6 different levels of
| parallax, and also the mountain range and swamp below has
| different levels of parallax. Ok, this was a game that, as one
| reviewer put it, "squeezes all the graphic power out of the
| Amiga". Would you believe that this was a computer which was only
| capable of displaying 32 colors at once? Ok, that was without
| tricks of course, and this game probably uses every trick in the
| book...
| z303 wrote:
| Not to take anything away from the developers but the Amiga
| does have hardware sprites, hardware scrolling, a blitter, the
| copper and dual playfield mode to make things a little easier
| chrisseaton wrote:
| > Ha! You call that parallax scrolling?
|
| 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.
| neilwilson wrote:
| Perhaps a little context would help
|
| https://genius.com/Monty-python-four-yorkshiremen-live-
| lyric...
| dota_fanatic wrote:
| That's a stretch. That sketch is about one-upmanship as to
| who suffered more. (Which is also toxic behavior when taken
| out of comedic contexts. I know people who do this
| unironically and it's not healthy.)
|
| 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.
| dhosek wrote:
| In my day there were no graphics cards. You had to write
| the bits into special parts of memory yourself. And you
| considered yourself lucky to get 140 pixels on a line.
| chrisseaton wrote:
| Seems an entirely unconnected bit?
| christkv wrote:
| I mean the Duke Nukem 2 parallax is impressive because it's
| basically beating a square peg into a round hole.
|
| The Amiga had a lot more helpful hardware. Lionheart really is
| an incredible title for squeezing so much out of the OCS
| chipset.
| ekianjo wrote:
| YOu could also go back to Shadow of the Beast 1, much earlier
| on the Amiga, with a very impressive feat when it comes to
| parallax scrollings.
|
| 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.
| icedchai wrote:
| I still remember when I first played Shadow of the Beast,
| back in 1989 on my Amiga 500. It was incredible.
| ekianjo wrote:
| It was the future! Compared to all 8 bits games of the time
| it was such a HUGE step forward, everyone who saw it was
| absolutely amazed.
| z303 wrote:
| A nice breakdown on how it was done [1]
|
| [1] https://codetapper.com/amiga/sprite-tricks/shadow-of-the-
| bea...
| [deleted]
| layer8 wrote:
| I'll throw in Turrican II level 3-1:
| https://youtu.be/-TSjfMNAXwU
| the_af wrote:
| Cool, and technically impressive!
|
| 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.
| mortenjorck wrote:
| While not nearly as lush, this is another impressive bit of
| Amiga parallax scrolling from six years earlier:
| https://www.youtube.com/watch?v=GwATApeN2Qw
|
| (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.)
| TacticalCoder wrote:
| That vid is a very bad example for the vid itself is not
| running at 50/60 Hz. And that was the whole thing back then:
| most great game on the Amiga (and the Atari ST) were running at
| "full frame rate". Arcade games too (except some still amazing
| ones like Outrun which was 30 fps IIRC).
|
| 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.
| dottrap wrote:
| Many of the comments here imply this article is about how to do
| parallax scrolling in general or think the article is suggesting
| Duke Nukem II was pioneering parallax scrolling. This is not what
| the article is about.
|
| 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.
| [deleted]
| [deleted]
| ghoomketu wrote:
| My god the things programmers had to do back in the day to
| squeeze every single bit out of the machine and here I was
| feeling smug using Weakmap instead of map for my code
| optimisation :P
|
| 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.
| qbasic_forever wrote:
| Track down the Graphics Gems series of books, it's what most of
| the game devs back in that era used to get tricks like fast
| square root, etc.
| https://www.realtimerendering.com/resources/GraphicsGems/
| sumtechguy wrote:
| I always liked this site for some interesting tricks.
|
| https://graphics.stanford.edu/~seander/bithacks.html
| desi_ninja wrote:
| great to see lethal guitar's work getting featured here. Rigel
| Engine is a very cool and ambitious project to revitalize a retro
| game. He is also very welcoming. I had my fun time contributing
| to it few years back.
| gwbas1c wrote:
| > Earlier, I also said that VGA games more frequently featured
| parallax, and that VGA was easier to program than EGA. This is
| primarily because in 256-color VGA mode, each pixel always
| occupies one byte. So all the complexity caused by the need to
| address individual bits disappears. VGA still has a planar memory
| layout, but this applies to bytes instead of bits.
|
| 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.
| tdumitrescu wrote:
| It wasn't just coding, it was also a lot of design/art
| resources. Going from 256->16 colors would look terrible with
| automatic dithering. My recollection is that there were a few
| Sierra titles made for VGA that also supported EGA and that it
| looked like someone had gone through each screen by hand to
| make the low-color ones look acceptable-ish.
| the_af wrote:
| EGA art specifically designed for EGA could look beautiful.
| For example, I love EGA Monkey Island. Most adventures with
| EGA support had different graphics for EGA vs VGA.
|
| But yeah, automatic dithering didn't look nice.
___________________________________________________________________
(page generated 2022-07-15 23:00 UTC)