9 ms·
How Duke Nukem II’s parallax scrolling worked
- tambourine_man 4y agoIIRC, Karateka did parallax scrolling in Apple II and C64 days. I've read the technical explanation but it was beyond me at time.
- LocalH 4y agoKarateka 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)
- vidarh 4y agoKarateka 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 https://www.c64-wiki.com/wiki/Parallax_Scrolling
- antiverse 4y agoSemi-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/ http://www.nemmelheim.de/turrican/news/duke/
- bm5k 4y agoA 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.
- gRoberts84 4y agoFair usage applies :D
- daenz 4y agoAfter 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 https://www.youtube.com/watch?v=P7jP0qQgL-c
- toast0 4y agoTurrican being a robot, and the developer being from Germany leads me to believe it may have been inspired by NES Probotector[1] rather than Contra. PS, watching that now I know the struggle of 50hz gamers playing slow games was real... yikes. [1] https://www.youtube.com/watch?v=WcAjDFvVvaY https://www.youtube.com/watch?v=WcAjDFvVvaY
- alisonatwork 4y agoThat'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.
- aj7 4y agoIf the graphic example shows parallax scrolling, I don’t see it. It looks utterly flat to me.
- scatters 4y agoThe background texture moves relative to the foreground (pipes and walkways). That's all!
- chrisseaton 4y agoDifferent planes moving at different speeds to simulate them being further away - thee we at what they mean and the example does show it.
- rob74 4y agoHa! You call that parallax scrolling? Then take a look at this (Amiga, 1993): https://www.youtube.com/watch?v=BoiHk_3siYg 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...
- christkv 4y agoI 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 4y agoYOu 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 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 4y agoI still remember when I first played Shadow of the Beast, back in 1989 on my Amiga 500. It was incredible.
- ekianjo 4y agoIt 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 4y agoA nice breakdown on how it was done [1] [1] https://codetapper.com/amiga/sprite-tricks/shadow-of-the-beast/ https://codetapper.com/amiga/sprite-tricks/shadow-of-the-bea...
- StillBored 4y agoHmm, 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.
- tomxor 4y ago> 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.
- 4y ago
- luckyorlame 4y agoDoesn’t it still work that way?
- desi_ninja 4y agogreat 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.
- layer8 4y agoTLDR: 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.
- dottrap 4y agoMany 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 4y ago[deleted]
- deleted 4y ago[deleted]
- ghoomketu 4y agoMy 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 4y agoTrack 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/ https://www.realtimerendering.com/resources/GraphicsGems/
- sumtechguy 4y agoI always liked this site for some interesting tricks. https://graphics.stanford.edu/~seander/bithacks.html https://graphics.stanford.edu/~seander/bithacks.html
- gwbas1c 4y ago> 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 4y agoIt 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 4y agoEGA 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.
- Andrew_nenakhov 4y agoInterestingly, original "Loom" by Lucasfilm looks much better in EGA [1] than its later VGA edition does. [1]: http://www.superrune.com/tutorials/loom_ega.php http://www.superrune.com/tutorials/loom_ega.php
- davedx 4y agoI 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 4y agoSince 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/ https://www.jagregory.com/abrash-black-book/
- dylan604 4y agoMaybe that's where the 3dfx voodoo name originates?
- Dwedit 4y agoI never would have guessed that this game was using an EGA mode. Using a non-default palette completely fooled me.