13 ms·
Commander Keen's adaptive tile refresh
- Dwedit 3y agoI see fabiensanglard.net, I upvote.
- ekorz 3y agoHe is a treasure. His CPS1 book is outstanding. If anyone knows other classic-gaming blogs, where there is technical depth, please do share. https://nicole.express/ https://nicole.express/ and https://sudden-desu.net/ https://sudden-desu.net/ are my other favorites.
- lockhouse 3y agoHis Game Engine Black Book series is excellent as well. One of these days I’ll make a retro DOS game for fun. Just need to find the time.
- smitelli 3y agoI'm the author of https://cosmodoc.org https://cosmodoc.org (Cosmo's Cosmic Adventure) which I genuinely plan to finish someday.
- afavour 3y agoAwesome. > Those poor saps with 2,400 bps modems would spend almost a full half hour doing this. This was me! Still remember it to this day.
- Moru 3y agoI was always envious of the people with 1200 baud modems... I had a 300 without dialer so had to use a phone to dial the number, wait for the answer and flip a switch for the modem to take over :-)
- AndrewStephens 3y agoI remember writing a tile-based game for Window98 using DirectX 5. I originally implemented something similar to what is described in this article. My case was not as complex because the screen didn't scroll but large numbers of tiles could potentially need redrawing. I ended up ripping out all of that code because when I tried to profile the cost of drawing the whole screen with my RIVA TnT card I literally couldn't measure the tiny amount of time it took. I am glad I missed the EGA period of PC development, I never would have gotten anything done.
- icoder 3y agoI was the opposite, I loved programming so low level, optimising using bitshifts instead of multiplications, writing essential code in assembly, writing 16 or 32 bits at a time (as processors developed). Continuously learning from the scarce resources I had (books from the local library and a floppy disk with txt files). I was too young (mid teens) / unexperienced to get anything finished but did manage smooth vertical scrolling and almost got the horizontal stuff working, double buffering a rotating 3D cube (z buffering, math, line by line polygon drawing). Then came DirectX and you lost all touch with the machine, a rotating 3D cube was breeze, I didn't see the fun in that.
- pengaru 3y agoIf you ignore the GPU acceleration APIs and try programming graphics the old fashioned way but on modern multi-core & SIMD machines, you can more or less still have a very similar rewarding experience. Sure it won't compete with the performance of GPUs, but I feel like we should have a category of GPU-less PC graphics for things like the demo scene. Where you strive to deliver interesting results at modern resolutions but hamstrung by CPU-only, incentivizing exploring parallelization techniques, SIMD optimization that strongly resembles assembly coding of yesteryear, and good old fashioned cleverness.
- RetroTechie 3y agoYeah I'd like something like that: * 'Many'-core CPU (say 8..16 relatively simple cores, eg. RISC-V) * A good, but modest amount of RAM (eg. few dozen... few hundred MB) * Integrated graphics, but of a conceptually simple type, eg. a plain framebuffer + _maybe_ some blitter / DMA / scrolling / hw sprite support. Simple enough that a single programmer can wrap their head around it (vs. complex 3D GPU where hardly anyone knows all its details). * Graphics outputting to common consumer display (HDMI, DisplayPort) * Sound & some other common I/O Roughly Commodore Amiga level complexity (at most! simpler = better), just modern fabrication tech & faster. This would be perfect platform for all sorts of homebrew games, hobby / retro style OSes, educational, industrial uses & more. But doesn't exist afaik. Microcontroller usually don't have built-in graphics, too little RAM, or otherwise aren't quite it. A step up (small SBC) and you get loooaads of peripherals, 3D GPU, firmware & associated complexity thrown in 'for free'. Nice for running full blown OS like Linux, not so nice for wrapping one's head around that hardware.
- geon 3y agoI implemented the second method a couple of years ago, but drawing even just the leading edge was very slow. I did it in C though and have never really mastered asm programming. https://github.com/geon/kate/blob/master/src/platform/dos/ega.c https://github.com/geon/kate/blob/master/src/platform/dos/eg...
- sdfghswe 3y agoOh man Commander Keen was such a lovely little game. I gotta find a way to run it again. BTW. Recommendations how to run this? As a "grown up" I haven't used windows in about... 20 years? How do I play this on Debian?
- nick_ 3y agoDosbox is my guess
- elteto 3y agoYou can start playing right now: https://archive.org/details/msdos_Commander_Keen_1_-_Marooned_on_Mars_1990 https://archive.org/details/msdos_Commander_Keen_1_-_Maroone...
- thristian 3y agoThe Internet Archive's browser emulation is an excellent way to scratch a nostalgic itch over a lunch-break. If you'd like something a little more local, Commander Genius¹ is an open-source engine that plays all the Keen games (and apparently Cosmo's Cosmic Adventure, too). ¹: https://clonekeenplus.sourceforge.io/index.php https://clonekeenplus.sourceforge.io/index.php
- lagniappe 3y agoyou can run it in the broswer
- benatkin 3y agoI disagree. It was for kids who for some reason had access to a computer but not a Nintendo (computers cost 10x what a console costs back then, so it was usually due to strong opinions by adults about what kids should be doing). It is lacking soul compared to all the NES and Genesis games. I liked it at the time, but I recently tried it in DosBox and realized that it pales in comparison.
- vunderba 3y agoI think it just depended on your family's circumstances. My father was a mechanical engineer, so we naturally had a computer in the house for his work. As a child, I couldn't convince my family to splurge on a dedicated entertainment device, but it was trivial to get a hold of a copy of the shareware version of commander keen and install it on the computer.
- clintfred 3y agoAnyone here read "Doom Guy"https://amzn.to/43DLW2U https://amzn.to/43DLW2U? I'd love to hear what you think of it. I have really enjoyed Jason Schreier's recent books on game dev.
- bombcar 3y agoThe linked article says Fabien loves it.
- clintfred 3y agoYep! I saw that he mentioned it and was trying to get some more perspectives. Who am I kidding? I should just buy it. :-)
- ant6n 3y agoI always recommend "the Masters of Doom". Probably mostly accurate. Perhaps a bit exaggerated at times. But definitely a great story, and well written.
- fullshark 3y agoYeah I read that and enjoyed it thoroughly. I know Jordan Mechner's journals making Prince of Persia and Karateka are supposed to be great too if people are into this type of thing, I haven't read them though: https://www.amazon.com/gp/product/B005WUE6Q2 https://www.amazon.com/gp/product/B005WUE6Q2
- mortenjorck 3y agoThe fluidity of the scrolling in Commander Keen 4-6 was unmatched on PC for years, even as games moved to 256-color graphics. Between Carmack's incredible technical work and Adrian Carmack's [1] art, Id had perhaps the best-looking PC platformer well into the 1990s. [1] No relation to the more famous Carmack, but IMO the unsung master of the 16-color palette.
- Aeolun 3y agoI think it might be hindsight, but a lot of these ‘revolutional’ developments seem kind of simple compared to a lot current development. “Our memory is slow, so let’s redraw only things that changed” is kind of a given nowadays. Still the optimization in 4-6 is fun. Did the whole thing in 1-3 just because of an assumption that the buffer would not wrap around, and then it did and all that work became obsolete.
- incrudible 3y ago“Our memory is fast, so let us redraw everything” is a given. Our web APIs on the other hand are incredibly slow, so let us carefully track changes in a complicated runtime (or compiler) to avoid redundantly modifying properties in a tree.
- II2II 3y agoIf I recall correctly, the original Macintosh would go as far as telling the software which regions of a window had to be redrawn at any given time so the idea itself wasn't exactly new. The thing is that these optimizations required tradeoffs. Figuring out which tiles had to be updated required storing extra data and doing extra computations. Not only did you have to recognize the value of these techniques, you actually had to write the code in a way that did not slow things down (and design the levels so they would not slow things down).
- magicalhippo 3y agoWindows has had this[1] for as long as I remember as well, at least since Windows 3 days so I assume since the very beginning. [1]: https://learn.microsoft.com/en-us/windows/win32/gdi/clipping https://learn.microsoft.com/en-us/windows/win32/gdi/clipping
- deleted 3y ago[deleted]
- lowbloodsugar 3y agoI mean, we were doing the wrap-around “trick” in 1981 on the BBC Micro - and I didn’t know it was a trick so much as in the manual. The Defender and Scramble clones on the beeb were super smooth.
- tom_ 3y agoThe BBC Micro wraparound is designed in rather than being apparently some kind of unreliable poorly-defined accident. There's a specific bit of hardware that subtracts a specific amount if the address runs off the top of RAM, so the video memory (typically the top 10 KB or 20 KB of RAM) is effectively circular. For single-buffered infinite scrolling, this is exactly what you want, and this is how the BBC Micro's 640 pixel wide bitmap mode scrolls nice and quickly (something you'd never manage otherwise with a 2 MHz CPU), and why there are a fair number of infinite 4-way scrolling games on the platform. It's a shame more platforms didn't have this kind of thing designed in.
- legendofbrando 3y agoJust piping in to say how much I loved this piece. This is what the internet is excellent for.
- zelphirkalt 3y agoI still rememner the time, when I knew almost every secret (or so I believed) in Commander Keen Goodbye Galaxy, and other pupils at school asking me to tell them secrets in levels they played after classes on a school computer.
- nazgulsenpai 3y agoLucky, I was the only nerd in my school that I ever spoke to who had even heard of Commander Keen!
- dextersgenius 3y agoCool, but did you ever hear about and play BioMenace? Everyone always talks about Keen, but literally no one ever mentions BioMenace, which was built on the same engine as Keen. :(
- parlortricks 3y agoBioMenace was a great game too, so many hours playing that game.
- zelphirkalt 3y agoBioMenace was on a computer of the parallel group (pupils were put into groups A, B, C, etc., who would have their classes separately). One of my best friends excelled at that game. I enjoyed watching him play it. In hindsight, we were pretty lucky to have computers at that time at school. Even if old ones. Still have not found all of the games again on DOS game archives, that were on these machines.
- thristian 3y agoI can understand how to scroll vertically by adjusting the frame buffer start by a scanline at a time, but it wasn't clear to me how scrolling horizontally would work without horribly shearing the framebuffer. Now that I've thought about it a little more, I realised it's like painting a picture on the side of a cylinder. No matter where you draw the left-hand edge of the image, there's always a way to rotate the cylinder (set the CRTC_START and PEL registers) so you can see the whole thing clearly. > I took the easy solution of when you finally did run to the edge of the screen I accepted a hitch and just copied the whole screen up. I remember when Keen started up it would usually mention something about "VGA compatibility mode enabled", and I always wondered what that meant.
- wizardforhire 3y agoJust gonna leave this here for the spelunkers… https://www.dopefish.com/fishinfo.html https://www.dopefish.com/fishinfo.html
- dreadlordbone 3y agohugged to death: https://archive.is/eX21w https://archive.is/eX21w
- ndiddy 3y ago@fabiensanglard If you see this can you please tell us what web host you use so I can make sure to never use them?
- fabiensanglard 3y agoI use HostGator and they rarely go down. Over the years, I have found them quite hug resilient. They are actually back up now.
- x0x0 3y agoSince you're reading this, I really enjoyed your book on Doom's engine.
- ndiddy 3y agoThanks, that's a shame they dropped the ball. I'd previously heard good things about Hostgator. The article was stellar as always. If you're interested in other EGA stuff, IBM made a demo called "Fantasy Land" in the mid-80s that has smooth 4-way scrolling and animated backgrounds (but it's character mode, not graphics mode): https://youtu.be/czfGt5iNuSQ?t=65 https://youtu.be/czfGt5iNuSQ?t=65
- timcederman 3y agoMaybe it's explained in Doom Guy, but why does the author use "ATS" as the TLA for "Adaptive Tile Refresh"? I can't find any references other than this article.
- bombcar 3y agoAdaptive Tile Select maybe? Or a typo?
- fabiensanglard 3y agoA typo! Thank you for pointing it out :) !
- bombcar 3y agoA fabien typo is almost as rare and valuable as a Knuth one! Thank you for your writing, it’s been exceptionally enjoyable.
- magnawave 3y agoOh this is awesome. When I was a kid I really really attempted to write a Keen knock off (doctor who themed) on my 386 and it was ok although never really did enough level development to make it super playable. But TO THIS DAY, never knew how the heck they made it scroll so smoothly. I just ended up just jump scrolling. Figured it was some mad assembler skills, never imagined there was a hw register! Did figure out the double buffering stuff on my own though ;) Seems so obvious, learn something new everyday, even if it would have been more useful, say maybe ~30yrs ago ;)
- djmips 3y agoI worked at a different game company in the same time frame and I invented the same technique as the second approach. I don't think it's that amazing - if you were working on it at the same time you probably would have come around to it. Just as we also made our own PWM audio driver to play sampled sounds through the PC speaker - so did everyone else it seems. The PC didn't get enough love before we were all on to the consoles. I get excited when I see demos like 8088 MPH by Hornet.
- mysterydip 3y agoIf the game went to release, would you mind sharing the title for comparison purposes? I agree most would come up with similar solutions, but I'm curious if the result feels the same to play.
- djmips 3y agoThere's no doubt that commander Keen is a better game. We didn't linger on that tech long enough before we moved to console game dev. Here's one game. Note we did not do the smooth scrolling but the coarse scrolling worked by the second method. We had the tech to do smooth scrolling, I don't recall why it didn't make it to final game. Maybe compatibility. https://youtu.be/qlRthjjQreg https://youtu.be/qlRthjjQreg
- djmips 3y agoOn a fixed horizontal scroller idea for avoiding the full screen move / copy at the end is to amortize it while you are moving. So over many frames you build up the screen you need to reset to at the end.
- green_leaves 3y agoI remember playing that game in CGA (and speaker) back in the day. Fond memories :)
- Gareth321 3y agoPeople often don't realise but it's not the invention itself which results in fame. It's the ability to commercialise and market it. There have undoubtedly been countless incredible inventions over the millennia. I myself "invented" LinkedIn a decade before it was a thing, but I never successfully commercialised it. I would estimate that most inventions were never widely known. This is why many startups begin with two people: an expert, and a business person. So you're not wrong: this invention is perhaps nothing particularly special. What made it special was the combination of novelty, utility, and successful commercialisation.
- NovaDudely 3y agoSo the second trick looks like how the background layers work on systems like NES/Master System/SNES/Genesis. Just update tiles outside of the visible range and just have the view window constantly looping around. Or am I missing something? I mean to do that on EGA is very neat (well duh!) considering those consoles all have dedicated VPU's for this task. Just wanted to make sure I am understanding it correctly.
- ensocode 3y agoOne of my favourites together with Lemmings
- beardedmoose 3y agoLemmings is a great game! If you haven't seen it yet, I stumbled upon a somewhat modern version / idea of Lemmings called Humanity. I've been playing it on PS5 but it's also on steam and probably others. https://store.steampowered.com/app/1581480/Humanity/ https://store.steampowered.com/app/1581480/Humanity/ You play a spirit version of a Shiba Inu guiding humans to the exits.
- ensocode 3y agoAwesome. That's a cool version. Thanks
- janvdberg 3y agoIn the excellent Masters of Doom it is explained that Keen was the Mario-like game (i.e. sideways scrolling). They offered the tech to Nintendo as an option to port Mario to the PC. Nintendo declined, thus Keen was born. It was a vast leap for PC gaming and it opened an new era of PC gaming. However, here is what I never quite understood, what was so different about the NES and PC tech that Nintendo had figured out to do sideways scrolling years before the PC?
- enneff 3y agoThey actually did a port of SMB3 and presented that to Nintendo. When Nintendo didn’t bite, they made new assets to make what became Keen. Here’s a video of the port: https://youtu.be/1YWD6Y9FUuw https://youtu.be/1YWD6Y9FUuw
- janvdberg 3y agoWow amazing! I did not know this was available on YouTube. Thank you. It is kind of bonkers considering how well it works for a prototype that all-in-all (based on the comment by Lane Roathe) took just 48 hours to make!
- marmakoide 3y agoI don't think it's 48h from scratch. Making the prototype for scrolling a tile map, a tile editor, etc might have taken more time. 48h sounds more like the time to capture sprites and slap them using already made tools/code.
- zactato 3y agoI recall playing this back in the day. It was super cool. My Dad pulled it from the DEC internal file sharing service and brought it home. I long believed that it was a figment of my imagination until I heard that ID had developed a demo for Nintendo that must have gotten leaked
- MattBearman 3y agoI’m not 100% on this but I believe the NES has a dedicated graphics chip for sprite manipulation, where as it all had to be done in software on the PC
- sentientmachin3 3y agoThe Lex Friedman podcast with J. Carmack goes over all the major innovations in every game, really interesting episode, strongly advised if you have time (roughly 5 hours long)
- fernandotakai 3y agolink for people that want to watch it: https://www.youtube.com/watch?v=I845O57ZSy4 https://www.youtube.com/watch?v=I845O57ZSy4 i would also recommend another two of his interviews: Todd Howard https://www.youtube.com/watch?v=H9AAnV59ddE https://www.youtube.com/watch?v=H9AAnV59ddE Guido van Rossun https://www.youtube.com/watch?v=-DVyjdw4t9I https://www.youtube.com/watch?v=-DVyjdw4t9I
- andai 3y agoMost surprising part of this for me is that IBM used to invent computer hardware! (And it sounds like they were pretty good at it!) Why'd they stop?
- ido 3y agoIBM still “invent computer hardware” (e.g. POWER/PPC CPUs are still being developed) and have been doing it more or less ever since “computer hardware” as a concept was commercialized. You’re probably aware that the PC itself is an IBM development, but once it because a generic platform they couldn’t turn a profit while having to compete with all the cheap clones (I.e. what we today simply call PCs).
- bluedino 3y agoIn the late 80's IBM came out with the PS/2 computer that had proprietary things like the MicroChannel bus that didn't catch on, but things like PS/2 ports that lived on for a long time. When the early 90's were here, IBM was losing billions of dollars a year, companies like Dell and Compaq were selling more and more PC's while IBM continued to sell less and less. There were spinoffs and re-organizations, IBM still made some things like the MWave soundcard/modem, but they couldn't really compete with all the small startups making new peripherals and components. IBM was still manufacturing things in the USA, they were and old and slow and kludgy company...
- I_am_tiberius 3y ago> The second Keen trilogy used a better trick -- just keep panning and redrawing the leading edge, letting the screen wrap around at the 64k aperture edge. Isn't this similar to virtual scrolling?