
8088 MPH: We Break All Your Emulators (2015) - quietcuriosity
https://trixter.oldskool.org/2015/04/07/8088-mph-we-break-all-your-emulators/
======
ajenner
I'm one of the creators of this demo. For the past several months I've been
working on a cycle-exact 8088 emulator (that will eventually be able to run
8088 MPH properly). I don't have it hooked up to any audio or video output
yet, but for the first time last night it ran automatically-generated
testcases all night without finding any differences from the real hardware.

~~~
tombert
I remember reading a writeup a few years ago from the guy who made BSNES, and
him mentioning to get cycle exactness requires a crazy amount more CPU power
than getting "cycle-good-enough-for-99%-of-things", and that he had to do some
elaborate cooperative threading to get decent performance.

Has this been the case for you?

Also, 8088mph is super cool; great job on it!

~~~
sp332
I remember that one, it's 3GHz for perfect emulation of a SNES which had a <25
MHz CPU. [https://arstechnica.com/gaming/2011/08/accuracy-takes-
power-...](https://arstechnica.com/gaming/2011/08/accuracy-takes-power-one-
mans-3ghz-quest-to-build-a-perfect-snes-emulator/)

~~~
pvg
25 MHz is mentioned in the article as a basic requirement of the earliest SNES
emulators. The SNES CPU itself clocks in at less than 4.

~~~
sp332
So it's not the clock speed, but an oscillator at 21.47MHz that I was
accidentally citing.

~~~
pvg
Ah that makes sense - 6x the CPU clock of 3.58something.

------
caf
My favourite part:

 _It’s a cycle-counting effect, as there is simply no time to monitor for
horizontal retrace. To ensure the cycle counting was consistent, several
things were done including changing the system default DRAM refresh from it’s
default interval of 18 to 19, to get the DRAM refresh periods to line up with
CRTC accesses._

(previous HN discussion:
[https://news.ycombinator.com/item?id=9338944](https://news.ycombinator.com/item?id=9338944))

------
drivers99
When I ran across this a couple years ago, I transferred this to the IBM PC
(which was my first computer) over a serial cable (I still have Telix
installed) from a Windows XP desktop since it also had a serial port, and use
Hyperterminal to transmit the file. And in order to get it to that computer I
had to put it on a USB drive.

It was pretty cool seeing it run. That PC was what I used from 1987-1993 and
it was mostly obsolete during that time but I tried to get everything I could
out of it. There was nothing that approached what this demo was able to do
graphically. (There were a lot of cool music programs even for the PC speaker
back then though.) Although, I get a memory parity error partway through the
demo because I don't have the full 640k due to some bad memory chips on the
memory expansion card.

It helps that they designed it for composite output, since I no longer have a
CGA monitor, but you can still hook it up to TVs.

~~~
iforgotpassword
I had to transfer it to a win2k machine via network, then wrote a serial
transfer program in gwbasic and visual basic 6.

I don't have a CGA but some ati clone (forgot name, it can emulate a bunch of
modes including hercules), so I couldn't get colors to work in their new 1k
mode. The color burst was either not recognized at all or the picture wasn't
stable. But that might have been an issue with the modern TV, or both.

Most effects worked really well with that card surprisingly. Kefrens bars
started halfway through the screen for some reason but otherwise were fine
too.

------
foota
Apparently 640K is enough for anyone.

------
partycoder
If these guys went back to the 80s with this knowledge they would be rich.

~~~
nielsbot
They mention that a company called Macrocom had figured out part of this trick
in the mid-80s... From this linked explanation:
[http://8088mph.blogspot.com/2015/04/cga-in-1024-colors-
new-m...](http://8088mph.blogspot.com/2015/04/cga-in-1024-colors-new-mode-
illustrated.html#the_macrocom_method)

~~~
gknoy
This link is amazing. The explanation of which characters are used, and the
process they used to get to the 1024 colors, is fantastic. Thank you for
sharing this!

------
em3rgent0rdr
The outro credits manage to play a MOD file just via PC speakers (which
normally can just make bleeps)...quite an accomplishment! [1]

[1] [http://www.reenigne.org/blog/8088-pc-speaker-mod-player-
how-...](http://www.reenigne.org/blog/8088-pc-speaker-mod-player-how-its-
done/)

------
Aardwolf
The graphics are amazing!

About the sound, I remember playing an mp3 through PC speaker on a 386
computer, as well as having a special config for wolf3D that made it play its
soundblaster sound effects through the PC speaker, so its single voice square
wave can produce arbitrary sound.

Good ending music nonetheless!

------
overcast
Whoa Doc, do you mean to tell me this sucker is nuclear?!

------
unixhero
Congrats with the win! It was an enjoyable demo!

------
dingo_bat
Does anybody know and has time to explain why emulators cannot play this demo?
I always assumed emulators recreated the hardware in software, so why won't
they be able to do something the hardware could?

~~~
Scali
In theory emulators recreate the hardware in software. In practice, emulators
_approximate_ the hardware in software. In the case of PCs, there is so much
hardware variation, that it was never a requirement to be very accurate in
terms of speed, unlike machines such as the C64, Amiga, Atari ST, NES and
various other machines, where many tricks found in games and demos depend on
manipulating specific hardware registers in very specific timeframes.

This demo has various effects that depend on the _exact_ speed of the CPU and
hardware. No PC emulator is anywhere near that accurate, leading to effects
not working correctly, or just hanging altogether (eg the end-tune depends on
instructions being in the prefetch-buffer at a specific time).

Another issue was the 1k colour effect, which exploits the way the NTSC signal
is generated. Most emulators didn't emulate NTSC composite very accurately
(just treating it as a 16-colour mode).

The timing in this demo is so critical, that even most clones with an 8088 at
4.77 MHz and a CGA-compatible clone card do not play the demo correctly.

~~~
zellyn
OpenEmulator, a little-known emulator for the Apple II, has an absolutely
fantastic NTSC emulation, done with GPU shaders. I'm in the process of porting
it to WebGL, so that (a) I and others can actually understand it, and (b) so
that others can use it.

------
gaius
trixter.oldskool.org may be the greatest personal URL of all time

