CGA = 4 colors, amirite?
April 10, 2015 4:10 PM   Subscribe

When displaying graphics on an original IBM Color Graphics Adapter (CGA), normally only 4 colours (from a palette of 16) are possible at once. So this ("Oldskool Demo" first place at the Revision 2015 demoparty) is not so normal. posted by juv3nal (58 comments total) 58 users marked this as a favorite
 
This thing defaults to 480P on mine when it absolutely must be watched in 720p60 so heads up.

And, oh, man, this is one of those things where I know just enough to understand why this is holy-shit-impressive but not enough to understand the explanation of how it works, so that basically makes it magic.
posted by griphus at 4:17 PM on April 10, 2015 [9 favorites]


Ho-lee shit. That "How it was done" link is something to behold.
posted by Joakim Ziegler at 4:17 PM on April 10, 2015 [3 favorites]


There were a few games made with non-BIOS CGA modes too, like 160x100x16. I don't think I'd ever seen any of these before.
posted by RobotVoodooPower at 4:21 PM on April 10, 2015 [1 favorite]


so cool. i never understood how to get into or understand the demo scene in the 1990's, and still dont. i like the mystery...
posted by brainimplant at 4:26 PM on April 10, 2015 [1 favorite]


That music is sort of like Boulez piano sonatas or something, where performing it is a great technical feat, but it's still a toss-up whether I'd rather listen to it for three minutes or be stung by wasps forever.
posted by Wolfdog at 4:30 PM on April 10, 2015 [8 favorites]


But the SID chip still rules, right? Right?
posted by Splunge at 4:31 PM on April 10, 2015 [4 favorites]


Inspiring. I've still got to get my Osborne 1 up and running...
posted by phooky at 4:34 PM on April 10, 2015


Holy balls.
posted by cortex at 4:36 PM on April 10, 2015 [3 favorites]


Oops, missed this earlier regarding the music.
posted by juv3nal at 4:43 PM on April 10, 2015 [4 favorites]


I'm TRULY HAPPY people are still hacking away at this shit. With all the Fucking Bullshit going on in the world, it gives me a bit of hope for the future.
posted by mikelieman at 4:43 PM on April 10, 2015 [6 favorites]


Yeah, I'm with griphus. I appreciate how impressive it is, but that "How it's done" link might as well read "A wizard did it."
posted by Rock Steady at 4:43 PM on April 10, 2015 [10 favorites]




Idk why but this makes me want to play Tyrian 2000 really badly.
posted by gucci mane at 4:52 PM on April 10, 2015 [3 favorites]


I understood that how it's done link pretty well, and yeah, a wizard did it. That is some hardcore retroengineering to get 35 year old hardware to do what its cheaper contemporary competitor could easily do when it was new.
posted by localroger at 4:53 PM on April 10, 2015


Wow. Imagine what they could have done with my AT!
posted by selfnoise at 4:54 PM on April 10, 2015 [1 favorite]


A wizard also did the audio.
posted by localroger at 5:02 PM on April 10, 2015 [1 favorite]


Just think what they could do with an OC'd Pentium!

This is pretty impressive, thanks for sharing the demo video and the documentation.
posted by filthy light thief at 5:03 PM on April 10, 2015


I can't put my finger on it, but there's something odd about the way the 3D figures rotate. Anyone else notice that?
posted by griphus at 5:07 PM on April 10, 2015 [1 favorite]


They don't rotate smoothly, they go through a partial rotation and then stop and reverse what they just did.
posted by GuyZero at 5:12 PM on April 10, 2015 [1 favorite]


GuyZero: "They don't rotate smoothly, they go through a partial rotation and then stop and reverse what they just did."

So it's a hoedown?
posted by Splunge at 5:15 PM on April 10, 2015 [8 favorites]


where it fell apart for me was the music - next to a SID chip, no, that's just not that good

it's an impressive coding and technical achievement - but alas, they've proven that an IBM 8088 just isn't a C64
posted by pyramid termite at 5:22 PM on April 10, 2015 [1 favorite]


Yes, it's a 3D CGA hoedown.
posted by GuyZero at 5:23 PM on April 10, 2015 [5 favorites]


Oh man.

At one point in an earlier life, I had to hack CGA/EGA/Hercules video modes, not for anything nearly as cool as this but because I had to make a TSR (Terminate and Stay Resident) routine wake up, take over video to do stuff, and then restore the original mode. There was a ton of low-level register mucking about with the 6845 CRTC chip to make that work reliably - although the PC spec claimed that all the mode info was readable from various registers/system variables, it lied - and it was considerably satisfying to dig down enough into the hardware to actually make things fly.

At the time, I thought I was pretty good. Thirty years later, I learn I knew nothing. (Although I did know, from yet another life, that DRAM refresh is not what the spec sheets claim and you can take considerable liberties with the rules if you're careful about what looks at what when. I can walk that walk. But the CGA hacking? My titfer is doffed.)
posted by Devonian at 5:27 PM on April 10, 2015 [7 favorites]


> I can't put my finger on it, but there's something odd about the way the 3D figures rotate. Anyone else notice that?

They all pivot on the same figure 8 pattern. It's sufficient to convey the 3-Dness of it and ensures a seamless loop of motion, but it's not a full rotation on any axis.
posted by ardgedee at 5:36 PM on April 10, 2015 [3 favorites]


next to a SID chip, no, that's just not that good

It was done through the PC 1-bit on/off speaker specifically without using a Sound Blaster. For that hardware it should have been impossible. But then, the the video too.
posted by localroger at 5:37 PM on April 10, 2015 [5 favorites]


In case anyone else is interested about the other competitors, here's a list of entries that of course looks like a .nfo

(I've just been plunking the names into YouTube; not sure if there's an existing link set somewhere.)
posted by griphus at 5:47 PM on April 10, 2015 [1 favorite]


where it fell apart for me was the music - next to a SID chip, no, that's just not that good

But the deal here is that there *is* no audio chip here generating the audio waveform like the SID does: just a speaker connected to a wire that the CPU can toggle on or off. The last minute or so there is them demonstrating just how far they can stretch that when they can get fine-grained control over the timing of that toggling. As the second article describes, they're doing by that by careful cycle counting plus some very clever tricks to mix a little extra useful work into the few cycles per audio frame that they have left over.

(By contrast, the audio in the first 7 minutes is ratty because they're burning most of their cycles on the video effects and squeezing some quick-and-dirty audio into what they have left over.)

Those how-its-done articles are terrific: the first in how deep it digs into the video hardware, the second in how deep it digs into cycle-counted self-modifying code.
posted by We had a deal, Kyle at 5:49 PM on April 10, 2015 [11 favorites]


it's an impressive coding and technical achievement - but alas, they've proven that an IBM 8088 just isn't a C64

The point isn't "look how good the IBM PC was". The point is "look what we can do anyway"
posted by aubilenon at 5:50 PM on April 10, 2015 [19 favorites]


Yeah, the black-magic PWM music starts at 6:40. The stuff before is standard PC blips and bleeps.
posted by RobotVoodooPower at 5:51 PM on April 10, 2015 [1 favorite]


This is jaw droppingly amazing, but somehow a lot more entertaining shown running on real hardware in their verification video.
posted by emptythought at 6:21 PM on April 10, 2015 [1 favorite]


In case anyone else is interested about the other competitors, here's a list of entries that of course looks like a .nfo

(I've just been plunking the names into YouTube; not sure if there's an existing link set somewhere.)


This includes other categories, but the site usually (always?) has downloads for people to run the demos themselves (though presumably some won't work in emulation).
posted by juv3nal at 6:26 PM on April 10, 2015


I worked in a lab back in the early 80s that had some monitors could display ... 64 simultaneous colors. They used to bring people in on tours to look at them.
posted by lagomorphius at 7:30 PM on April 10, 2015 [2 favorites]


Man, I love that stuff. Demos always give me the impression that I'm learning something, when I'm actually just going "oooh, ahhhh".
posted by sneebler at 7:43 PM on April 10, 2015 [1 favorite]


I worked in a lab back in the early 80s that had some monitors could display ... 64 simultaneous colors.

When I was a kid I dreamed of having an EGA card and compatible monitor. Think of the possibilities!
posted by Jpfed at 7:45 PM on April 10, 2015 [2 favorites]


"My titfer is doffed."

A transcript of my thoughts: “What's a titfer? Feeding babies, ba-dum tish. No but really? … Oh.
posted by traveler_ at 8:01 PM on April 10, 2015


IBM PCjr RULEZ!!!11!!ll!"!!

No seriously, some of this stuff is PCjr hacks, that's how they got such a cheap machine to do VGA.

That audio MOD player hack is even more amazing than the video. I have not heard of such outlandish programming since I heard tales of mainframe programmers synchronizing their code loops to the speed the data would appear under the drum memory read head.. and then the drum data was interleaved to match the code loops.

And writing your own assembler, with self-modifying code to translate the start address.. now that is real old skool 8080A programming.
posted by charlie don't surf at 8:01 PM on April 10, 2015 [1 favorite]


CATS: How are you gentlemen !!
CATS: All your base are belong to us.
posted by SPrintF at 8:37 PM on April 10, 2015 [3 favorites]


Just remember this the next time you scoff at a movie where advanced aliens take over our computers and make them do something that seems utterly ridiculously impossible.

This here is some Pham Nuwen godshatter shit.
posted by straight at 8:41 PM on April 10, 2015 [5 favorites]


The audience reaction video is well deserved - I too am astounded by the audio at the end of the demo. You cannot do that by waggling a bit on the end of a 4.77 MHz 8088 IO port.

You cannot. It is impossible. I can follow the CGA magic whereby you create the colour frequencies by black sorcery character map wrangling and getting the gate delays just right - it's wrong and evil and calls down the souls of the dark lords of TTL gate mangling in ways that no mortal could contemplate, but yeah, OK, you got me there. Don Lancaster is still alive.

Yet the audio?

Damn.
posted by Devonian at 9:43 PM on April 10, 2015 [6 favorites]


The audience reaction video from the demoparty this competed in is also fun to watch. (jinx, devonian)
posted by zsazsa at 9:43 PM on April 10, 2015 [2 favorites]


> I have not heard of such outlandish programming since I heard tales of mainframe programmers synchronizing their code loops to the speed the data would appear under the drum memory read head.. and then the drum data was interleaved to match the code loops.

You're thinking of Mel and the RPC4000.
posted by ardgedee at 3:48 AM on April 11, 2015 [3 favorites]


The last 100 seconds of 8088 MPH sound very different to the rest of the demo. The end tune is actually a 4-channel Amiga MOD file (which you can download here) composed by coda. Playing back a MOD through PC speaker on such a slow machine has never been done before. Here is how we did it.

Bullshit, the answer was assembly language and it was done back then just fine. I had a 286/12 as my first intro to the PC world and used things like MODPLAY all of the time, and remember specifically that the "README" file or whatever the documentation was called mentioned the 8088, which wasn't all that far removed from my 286. A ~4MHz 8088 is specifically recommended as a bare-minimum for playing MOD files here:

TextFiles to the Rescue
	Mod playing checklist:
	----------------------
 o IBM PC compatible computer.  Sure you could use a 8088/4.77MHz... they 
   go pretty cheap these days (check your doorstop, it might have an 8088 
   in it!).  But I would recommend at least a 486dx2/50 or dx2/66 for 
   optimimum viewing and listening pleasure.  Note: there are other computer
   systems that apply but who cares!  Buy a pc!  Join the millions of 
   satisfied dos users!
posted by aydeejones at 5:18 AM on April 11, 2015 [1 favorite]


I do have a beard that traverses my neck-al region but it's not a neckbeard per se. I enjoyed the post, that just could not stand.

I watched the video with my wife, trying hard not to mansplain the reason why it was special, and then we watched Second Reality (which has a similar "true color" effect during the demo with procedural plasma, simulating a 24-bit [or was it 16-bit] color palette with an 8-bit graphics card, and then we watched the C-64 remake made 4 years later in 1997, for a computer originally produced in 1982.
posted by aydeejones at 5:24 AM on April 11, 2015 [1 favorite]


And to "well actually" myself, the answer wasn't "just" assembly language, but to pick a sampling rate that the 8088 processor could handle, and to use a Sound Blaster sound card with direct memory access (DMA), though I could've swore it was possible to use a cheap DAC made from a handful of resistors and hooked up to your printer port (definitely on a 286, not sure about the 8088). Another random ephemeral thing on the internet:
It takes at least a 386 to provide that kind of sampling rate on a MOD player, but even a "turbo XT" should be able to play MOD files if you choose a lower sampling rate.

Not on the PC Speaker, no. On a Sound Blaster, sure, because you can use DMA to transfer data as the next block is being calculated. I myself wrote an 8088/4.77MHz modplayer that plays at 8KHz on a Sound Blaster.

For MOD playback on the PC speaker, you need at least a 286 at around 10MHz or higher.
posted by aydeejones at 5:27 AM on April 11, 2015


Bullshit, the answer was assembly language and it was done back then just fine.
...
For MOD playback on the PC speaker, you need at least a 286 at around 10MHz or higher.


From the video description: "This is the real composite output of a true IBM CGA card and 4.77MHz 8088 PC."

The first text file you linked mentions later in its checklist "headphones/speakers", implying a sound card being involved rather than the PC speaker. I don't think any of the things you posted specifically contradict their claim so far.
posted by NMcCoy at 6:11 AM on April 11, 2015 [2 favorites]


I can't tell if it's already been linked, but this page has a lot more information.
posted by Rhomboid at 7:01 AM on April 11, 2015 [1 favorite]


This is like making a seven-course dinner with only a toaster and a cheese grater.
posted by double block and bleed at 7:21 AM on April 11, 2015 [9 favorites]


aydeejones: they mention that it's possible to play mods over a SoundBlaster, but those weren't available until like 1989 so they didn't want to "cheat" and use one. They say they're the first to both mix a mod in realtime and play it back over the PC speaker, on such slow hardware. Any two of those three things had been done together previously.
posted by aubilenon at 10:34 AM on April 11, 2015 [1 favorite]


> I could've swore it was possible to use a cheap DAC made from a handful of resistors and hooked up to your printer port

It was! The instructions were included with "modplay" - the DOS way of playing MODs at the time. I can't remember if I did this on my 8086 with "turbo" or if I did it on the 386 SX, but I absolutely made one of these things with pretty much zero electrical knowledge other than how to read a schematic and a rudimentary idea of how to use a soldering iron. One trip to radio shack later, and I had a couple of packs of resistors, a printer port, and an audio jack. And no wires. And no circuit board.

What I ended up with can only be described as an electrical abomination and a RF hazard -- It was a spider web mesh of resistors directly soldered to printer port contacts, with an audio jack loosely dangling from it, that I hooked up to a shitty 15 watt practice amp. And it WORKED! It was a bit touchy about the gain, but it worked well once you played with the amp enough.

Along the same lines, Star Control 2 seemed like complete magic to me when it came out (and I KNOW that was on the 386) because it was capable of playing its mod-based soundtrack over the PC speaker with no special audio hardware required. I'm not going to say it sounded great, but given the limitations of the platform, and the utter shit audio I was used to, it sounded amazing. It happened to be a stellar game on top of the technical accomplishments as well.
posted by MysticMCJ at 12:33 PM on April 11, 2015


The schematics still exist!

https://www.awe.com/mark/dev/modplay.html

Grab modplay 2.19 from there. Note that it will not decompress via built-in tools on OS X, I cannot speak to Windows - You can run "unzip" from the command line to uncompress it. There is a file named "HARDWARE.DOC" that contains the instructions and schematics for the abomination. I do not know what the native format is, but I could get the "gist" of it treating it just as a text file. It may just be a character set thing that doesn't translate well into unicode.

See option 3 for "how to make an even cheaper D/A" for the route I took:

You need one plug for your amp, one for your parallel port and 9 20k and 9 10K resistors

That's absolutely what I made. It absolutely worked.
posted by MysticMCJ at 12:51 PM on April 11, 2015


I assume it uses techniques similar to old C64 games like Mayhem In Monsterland to get more colours. On the PC the raw grunt that the 16-bit CPU has above the slow 8-bit C64 evens out the advantage the latter has in hardware sprites and dedicated sound chip.
posted by GallonOfAlan at 12:55 PM on April 11, 2015




As mentioned in the article, once you factor the difference in architecture, instruction set and other characteristics the 8088 doesn't really have a huge performance advantage over the C64. Most of what it's got is memory space (although it has a lot of that, relatively speaking).
posted by JHarris at 2:20 PM on April 11, 2015


How the 8088 ended up in the IBM PC is a bit of a story too. After Intel set the world on fire with the 8080A, Zilog locked up the "better than 8080" world with the object code compatible and much more powerful Z80. Intel's next step in 8080-land, the 8085, only added a few instructions and a UART and streamlined the bus interfacing. A lot of them ended up in embedded controllers, as did the Harvard architecture 8048 and 8051, but Zilog had knocked Intel out of the consumer PC CPU market.

One thing IBM wanted to avoid when it contemplated a late entry into the consumer PC market was having the same CPU as [other guy]. Unfortunately, among the big players Zilog was the CPU of the Radio Shack TRS-80 line, Motorola 6800 the Radio Shack Color Computer, 6502 both the Apple ][ and Commodore line. The 68000 was new and expensive and there wasn't a lot of software written for it.

This left Intel's pie in the sky future project which was far from ready for prime time, but was not in use by anybody else. There were actually two chips, the 8088 and 8086. The line was innovative in decoupling the CPU from the memory access unit, so the 88 and 86 were compatible but the '86 had a 16-bit path to memory, making it about twice as fast for the same clock. But this decoupling and other visionary design choices came with a cost that made both chips much slower than other contemporary chips at the same clock rate. They were only competitive at all because Intel was pushing the envelope on raw clock speed.

At the time nobody liked the x86 and IBM was widely ridiculed for using such a dog of a CPU, but it was still true in that day that in business nobody got fired for buying IBM. The 8088 was slow and sloppy, with messy segment registers and a prefetch queue that messed up the cycle-counting tricks beloved of bare metal assembly developers. But it did natively support a megabyte of RAM without paging tricks and it was "source code compatible" with the 8080, which meant that while it wouldn't run an 8080 binary if you were a developer you could generally get an 8080 assembly program to compile for the x86 with only minor tweaks. This is in fact where much of the early PC software came from.

It wasn't really until the 386 came out that the genius of Intel's early vision started to become apparent, as we noticed that quite a bit of software written in 1981 would still run on these blazingly fast new machines without being rewritten. Object code compatibility had never been preserved in the computer industry across such a huge generational gap and performance boost.

This code universality was of course what made the PC architecture the winner as clones by other manufacturers were also able to run object code natively. Ironically it was this advantage which killed IBM's position as they were unable to compete with competitors using their own architecture. They tried to sew it up by making the peripheral cards for the PS/2 proprietary, but by this time ISA was well established and everyone laughed at them for freezing themselves out of their own market.
posted by localroger at 2:26 PM on April 11, 2015 [6 favorites]


Motorola 6800 the Radio Shack Color Computer

Nit: 6809.
posted by ROU_Xenophobe at 5:26 PM on April 11, 2015 [1 favorite]


Yeah ROU that was a typo.
posted by localroger at 7:13 PM on April 11, 2015


aydeejones: BTW, that "random ephemeral thing" was written by one of the coders of this demo (Trixter), albeit not the one that wrote its MOD player (Reenigne). So Trixter's player mentioned in that post could play at 8-9KHz on an 8088, and Galaxy could play at 11KHz, both with a Sound Blaster. The MOD player in this demo can play at 16.6KHz on a CPU-sucking PC speaker. It's not a truly general purpose MOD player (256 byte samples only) but it's still an incredible feat.
posted by zsazsa at 9:23 PM on April 11, 2015


Another reason the 8088 got the IBM win was that Motorola hadn't got the 68k peripheral chips sorted out, and showed no signs of doing so - in fact, I believe that it had disbanded the design team which should have been working on them. The x86 architecture had a large set of established peripheral chips which, while not particularly advanced, were out and tested (and IBM had some experience of them already).

IBM had decided to go with 16 bits at a very early stage of the PC specification process, purely for memory reasons, so that ruled out all of the CPUs in use in the first wave of 8-bit micros. Once it pressed the button, it got a working prototype up and running in a couple of months - if you look at the circuit, it's basically Intel data sheets stapled together. So even when it was new, the IBM PC was getting on a bit...
posted by Devonian at 11:29 AM on April 13, 2015 [2 favorites]


« Older Laura Kicey's architectural collages   |   “Is evil something you are? Or is it something you... Newer »


This thread has been archived and is closed to new comments