8 ms·
8088 MPH: We Break All Your Emulators
- brink2death 11y agoPossibly stupid question: does the demo run inside DOS or is it completely self-contained? (I would assume the latter.)
- pjc50 11y agoNot clear. They mention writing a custom loader, reading EXE files; whether that's calling the INT21h DOS functions or the INT13h BIOS disk loader is unclear. I don't see why they'd bother to write a custom disk filing system when you can just use the DOS one. DOS is more something you run "on" than "in". It's just a filing and utility layer, no task scheduler, no memory protection.
- ajenner 11y agoIt runs on top of DOS, using INT 0x21 to spawn the effect executables. The loader doesn't read the executables directly, it just decides when to start and stop them, plays music and bounces some text up and down while the effects are loading/decompressing/precalculating. Writing a demo that is it's own OS and has total control of the machine is definitely something like I'd like to have a go at in the future, though.
- alxndr 11y ago> "[Step] 5. Effect starts, magic occurs"
- jpatokal 11y agoI found the raw video awesome enough to submit a few days ago, but the super-detailed explanation in this blog raises this to a whole new level of epic. I wonder if youngsters who didn't grow up thinking 1 MHz is a perfectly acceptable CPU speed and that 640 KB is a whole lot of RAM will understand what the fuss is about here...
- Zardoz84 11y agoI would love to see what could be done with a CPU running at 100KHz
- exmadscientist 11y agoYou know you've seen something special when the only thing you can think to say afterwards is "But it isn't supposed to do that...".
- ekianjo 11y ago> I wonder if youngsters who didn't grow up thinking 1 MHz is a perfectly acceptable CPU speed and that 640 KB is a whole lot of RAM will understand what the fuss is about here... They won't, and thus they don't understand the value of demos in the first place. But don't blame them, even back in the days I knew many people who could not appreciate demos either.
- skrebbel 11y agoStop generalizing. Plenty will.
- ekianjo 11y ago> Stop generalizing. Plenty will. Look at modern forum discussions on Smartphones, it's full of youngsters comparing specs of their respective phones without grasping at all what they mean. Or maybe you are referring to a highly educated subset of youngsters, but that's very few of them.
- tripzilch 11y agoYou should meet some of these youngsters :) A few weeks ago, I taught 12 year old kid to write a mandelbrot zoomer in Processing--no, really I taught him the required basics of complex numbers, took about 2.5-3 (very fun) hours[0]. Afterwards we had a big A3 piece of paper with notes, graphs and formulas all over it, which he took home with him. Two weeks later I met him again, of course I wanted to continue teaching him. I thought maybe the Z^4+C variant would be a nice step further. Turns out he already had written the Julia version of the zoomer ... on his Android phone, while waiting at the dentist's ... O_o Now I used to be all about fractals when I was his age, later grew up to be a 4096 byte democoder (around 2000), I was sooo jealous, what I wouldn't have given for a pocket computer that powerful! Lucky kid :) Aaanyway, apart from sharing this cute anecdote, my point is this. There's some extremely clever young bastards out there. Now there's not many, but they're also not extremely rare. I know a handful, although this particular guy is probably the cleverest right now. They come from all sorts of backgrounds, too. But the important part is not that they're highly educated, but that they're highly educatable, and given the opportunity to develop this. Their little hacker brains are hungry enough :) Having written their own graphics code, running against CPU-limits (although we hit float precision before it got really slow), I'm sure he'd appreciate some of the awesomeness of stunts on a limited machine like the 8088. In fact one of the earlier graphics I programmed with him was something very similar to the circle interference pattern described in the article (it was mostly his own idea, playing with interference patterns, I just carefully nudged towards the classic demo effect, because I knew it'd result in a really cool effect). [0] He already knew how to draw stuff with Processing. He already tried to look online for how the Mandelbrot algorithm works, but couldn't quite wrap his head around it. Missing bit of information turned out to be (a+b)(c+d)=ac+ad+bc+bd, hadn't learned that in school yet. If you explain i as rotation by 90 degrees, the rest becomes quite intuitive, visually. We also took a quick skim through that great WebGL-illustrated article about "How to fold a Julia fractal" (google it), while coding, way better than the five stapled pages I had when I was 15 :) :)
- blackhaz 11y agoI can't believe my eyes. 256 colors on CGA?! HOW?!
- ekianjo 11y agoThe Amiga had such tricks as well to display 4096 colors at the same time on screen while it could only display up to 32 specs wise. Not sure how they do it on PC, but there's probably a way to achieve it as well.
- frooxie 11y agoThe 4096 color HAM mode was always part of the spec.
- ekianjo 11y agoyes, it is, but it can only be used in very specific conditions (you cannot have the colors where you want all over the place), it's a pure hack.
- vardump 11y agoYou could either set any pixel color to any of 16 palette entries OR hold red & green from left side pixel, modify blue, hold red & blue, modify green, etc. You could also change those 16 colors for every scanline (horizontal line). Overall there was a lot of control, but software such as Deluxe Paint did not support full possibilities of HAM mode. Oh and, btw, EHB (extra halfbrite) mode has 64 colors. 32 colors palette + second 32 colors with brightness halved. http://en.wikipedia.org/wiki/Amiga_Halfbrite_mode http://en.wikipedia.org/wiki/Amiga_Halfbrite_mode
- chipsy 11y agoCGA's "Composite" mode contains output artifacts, a trait also found in other early microcomputer graphics like those of the Apple II or Atari 800; with careful use of dithering, CGA can be expanded to a larger effective gamut[0] although most games wouldn't be as ambitious as this demo. It's not as well-known or used as the 4-color modes because it wasn't supported by later PC graphics adapters, nor was it in the spec of the standard monitors of the era. You can see this system struggle to reproduce the demo's intended look: [1] [0] Example: https://www.youtube.com/watch?v=TfVe9l77zLU https://www.youtube.com/watch?v=TfVe9l77zLU [1] https://www.youtube.com/watch?v=aibZKrXc8Nk https://www.youtube.com/watch?v=aibZKrXc8Nk
- corysama 11y agoQuick explanation of compiled sprites: Most commonly a sprite is represented as a 2d array of pixels that you for X, for Y over and use math or branching to blend on to the screen. But, that's a lot of reading and writing, and a lot of the math ends up doing nothing because a lot of the pixels are intentionally invisible. So, you could do some sort of visible/invisible RLE to skip over the invisible pixels. That's better, but it's still a complicated loop and still a lot of reading pixels. So, many crazy democoders have decided to write "sprite compilers" that read the 2D color array of a sprite and spits out the assembly for the exact instructions needed to write each visible pixel one at a time as a linear instruction sequence with no branching. The sprites are then assembled and linked into the program code as individual functions. I believe they can even exclusively use immediate values encoded inside the instructions rather than reading the colors from a separate memory address. So, rather than read instruction, read data, write data; it becomes a read instruction, write data in two straight lines in memory.
- ekianjo 11y ago> it becomes a read instruction, write data in two straight lines in memory. So basically this kind of hack could not be used for a game, then, where interaction is needed?
- masswerk 11y agoEven the very first digital video game (Spacewar!) used something very much alike (Dan Edwards' outline compiler). Movable and rotatable – think of advancing by unit vectors –, compiled just in time from directional encodings. Read more at: http://www.masswerk.at/spacewar/inside/insidespacewar-pt4-oc.html http://www.masswerk.at/spacewar/inside/insidespacewar-pt4-oc...
- geocar 11y agoYour game could dynamically modify the instructions.
- ekianjo 11y agoSure, but wouldn't that incur a loss of performance ?
- tdicola 11y agoThis is the coolest thing I've seen all year, way to go to everyone involved!
- bastomi29 11y agohttp://jalurwisata.beep.com/blusukan-jalur-wisata-air-terjun-di-girimulyo-kulonprogo-2015-04-08.htm http://jalurwisata.beep.com/blusukan-jalur-wisata-air-terjun...
- ptype 11y agoWow, amazing. Would be interesting though to know which hacks make the emulators fail
- Maakuth 11y agoI bet their color hacks end up doing something weird or possibly nothing with emulators. No idea about the implementation details of any PC emulator, but it sure would be tempting for an emulator to just display the bitmap copied from the emulated machine's display buffer instead of emulating the actual display adapter. Even emulating the adapter wouldn't be enough, I suppose, as the color tricks rely on some unintenional (from vendors PoV) bleed behavior, probably on the analog side of things. So I guess a proper emulator should also emulate some of the analog details of the display itself.
- ajenner 11y agoThere are emulators (for other targets) which do emulate NTSC decoding properly, but until I did the research for this demo nobody understood how the CGA card generates composite signals well enough to be emulate it properly. I have some code which I hope to be adding to DOSBox (and any other emulators that want it) soon.
- acqq 11y agoDo you know, how was the video uploaded to the YouTube made, if the emulators don't work? Was it really recorded with the plain camera?
- Scali 11y agoWe used a real PC obviously (my machine), and a capture device plugged into the NTSC composite output of the CGA card.
- Zardoz84 11y agoThere is a link to download the music of the ASCII credits at the end ? I really like it. Also, I would like to propose a little challenge. What do you think that could do you archive on this "virtual" computer : - Specs : https://github.com/trillek-team/trillek-computer https://github.com/trillek-team/trillek-computer - Implementation/Emulator : https://github.com/trillek-team/trillek-vcomputer-module https://github.com/trillek-team/trillek-vcomputer-module In a short resume : - 32 bit RISC CPU running at 100KHz (to 1MHz) - CGA like text mode, but can be remaped to any desired RAM address and the font can be changed on the fly. Fixed palette of 16 colours - VSync interrupt + two timers - 128KiB of RAM (to 1MiB) - Floppy drive (max 1.2 MiB) Extra : Displaying it against a Commodore 1084S monitor -> http://imgur.com/GuTVEdj http://imgur.com/GuTVEdj
- 72deluxe 11y agoIncredibly impressive.
- rcthompson 11y agoI'm interested to know why it breaks all the emulators. Certainly I wouldn't expect emulators to reproduce all the graphical glitches that this takes advantage, but what is it doing that actually crashes them?
- userbinator 11y agoThis is just a guess, but one thing that could do it would be cycle-exact self-modifying code using interrupts. Modify the code too early or too late and the CPU will execute the wrong instructions. I see this demo as somewhat of a challenge to the emulator authors.
- ajenner 11y agoThe emulator I was mostly using for development (DOSBox) doesn't actually crash itself, but here's a nice example of how it goes wrong. In the final part of 8088MPH there is an instruction that modifies the instruction after it, but then (on the real hardware) the old version of the instruction is executed (because it's already in the CPU's prefetch queue when the modification is made). DOSBox executes the modified instruction because it doesn't simulate the prefetch queue. I tried moving the to-be-patched instruction above the patching instruction but that made the code take longer to execute and it no longer met the precise timing requirements necessary for the best audio quality.
- userbinator 11y agoModifying code in the prefetch queue was a well-known anti-debugging/emulation trick in the pre-Pentium days but this is probably the first time I've heard it being used as an optimisation - seriously amazing work.
- faragon 11y agoAmazing. 80×100 resolution 1024-color mode doing CRT controller (6545) tricks, on plain IBM CGA adapter. Also fullscreen bitmap rotation and 3D rendering on a 4.77 MHz Intel 8088 CPU. Wow.
- deleted 11y ago[deleted]
- raverbashing 11y agoNow, I wonder what people could be doing 10, 20 years from now on today's hardware Probably a lot less tricks up the sleeve are possible (especially with 3D accelerators and dependency on a lot of proprietary AND very complex software) Or maybe just drop to the framebuffer and push pixels like it has always been done
- tripzilch 11y ago> Probably a lot less tricks up the sleeve are possible (especially with 3D accelerators and dependency on a lot of proprietary AND very complex software) Sorry but doesn't that mean there are a LOT MORE tricks up the sleeve possible? They might be hard to find if you have to reverse a proprietary driver, but why not? :)
- kyberias 11y agoThese days I find it slightly weird that they don't share the source code of the demos or related tools. Demo scene has this wonderful alpha-male thing going.
- tripzilch 11y agoThere's loads of demo source and demotools source been and being released. The main reasons, afaik, for demo sourcecode to not be released are mostly circumstantial. Either the democoder forgets about it, because a lot of the code is one-off stuff and the next demo is going to be fresh and new! The other reason is that their code is a terrible mess of glue, ducttape and kludges, hacked together moments before the compo deadline (see article ;-) ). The democoder intends to clean up the code (see elsewhere in this thread ;-) ) but then forgets about it because after-demoparty-crash. Occasionally, however, they rest up a bit and later on write a great article about the tricks they pulled (while promising to clean up the code and release it "soon") -- saying this with a great big ;-) of course. And when something happens to be not released, I've always found just mailing the coder about it incredibly helpful, they're happy to explain, I've made great friends, and learned amazing stuff.
- Trixter 11y agoBesides, I don't think my interrupt handler and API would be of that much interest (oOoooh, sexy, an API!)
- tripzilch 11y ago... but someone could use it to disrupt the interrupt market. Anyhow, omg Trixter :) You don't know me[0] but thanks for all the work you did on the Hornet archive! [0] just a random 4k coder, ritz, https://www.youtube.com/watch?v=620CmQ9CJoU https://www.youtube.com/watch?v=620CmQ9CJoU / http://www.pouet.net/prod.php?which=343 http://www.pouet.net/prod.php?which=343
- userbinator 11y agoThe demoscene grew out of the cracking/warez scene, so it's somewhat implied you should take a disassembler to it if you really want to figure out what a demo is doing. It's the complete opposite to the OSS culture, where the prevailing assumption is that the source code is most important and nothing can be done without it; in the demoscene, it's more like "we don't need no stinkin' source!" I think these two approaches are both interesting in their own ways.
- mark-r 11y agoSlight technical inaccuracy at the start: the Z80 also required a minimum of 4 clocks for a memory access, it wasn't better than the 8088 in that regard.
- Scali 11y agoNot sure why you are referring to the Z80? We compare against C64, which uses a 6510 (6502-derivative), not a Z80.
- Scali 11y agoOh nevermind, I thought you were referring to the intro screen of the demo... but there is something about Z80 in the article.
- mikepavone 11y agoNope. An opcode fetch cycle takes 4 clocks, but a normal read or write is only 3.That's why an instruction like LD a, (hl) takes 7 cycles. I believe the GBZ80 always takes 4, but it's more of a separate 8080 clone that borrows from the Z80 a bit than an actual Z80.
- mark-r 11y agoThanks for the correction. I can't believe I've had it wrong for so many years.
- bane 11y agoThe party this was released at had some absolutely mind-blowing stuff. The 8k and 64k competitions were amazing. The demoscene continues to be an astonishing force in computing. Some of the stuff would be completely at home as installation art in any top modern art museum. My favorite is https://www.youtube.com/watch?v=XF4SEVbxUdE https://www.youtube.com/watch?v=XF4SEVbxUdE done in 64kb! Here's the results with links to productions (most of them have youtube videos by now) http://www.pouet.net/party.php?which=1550&when=2015 http://www.pouet.net/party.php?which=1550&when=2015
- 13 11y agoI think Chaos Theory still tops 64k. https://www.youtube.com/watch?v=4DjBq2O0XXk https://www.youtube.com/watch?v=4DjBq2O0XXk