Emulation Techniques
Software becoming hardware
An emulator makes one machine's software run on another by imitating its hardware. The magazines here give the method in Chris Hardy's words, the interpreter-versus-recompiler choice in Simon Goodwin's, MAME's growth from 1997, and the UltraHLE and Connectix cases of 1999.
An emulator is a program that behaves enough like one machine’s hardware that software written for it runs, unchanged, on another. The magazines held here cover the working method (emulate the hardware, not the game), the two ways of executing the old machine’s code, the arrival of MAME in 1997, the UltraHLE and Connectix cases of 1999, and the later push for cycle-exact accuracy.
Fast facts
- The method: “emulates the hardware so that the game thinks it’s running on a real machine” — Chris Hardy, 1997.
- Two engines: an interpreter looks up each instruction as it runs; a dynamic recompiler translates blocks to native code and must notice when the program rewrites itself (Simon Goodwin, 1999).
- MAME: born February 5, 1997; “more than 100” games by July 1997, “over 590” by August 1998, 3469 ROM sets by October 2002.
- The law: Sony sued Connectix on January 27, 1999 and was refused a restraining order; Nintendo said UltraHLE’s authors “had to circumvent our security chip”.
Emulate the hardware, not the game
Chris Hardy, who wrote Windows 95 emulators for the Phoenix and Pleiades boards, gave Edge the working rule in June 1997:
One of the most important thi[ngs] to remember is that it’s not necessary to actually know anything about how the arcade machine works internally. As lo[ng] as the programmer emulates the hardware so that the game thinks it’s running on a real machine, then the game will run exactly like the real thing. You don’t have to worry about what to do with the sprites, what’s important is that the emulator knows. Then it’ll do all the real work for you.
The same feature answered the question of why boards that used under 50K of memory and ran at a few MHz had taken so long to emulate on a 100 MHz PC. A game like Galaxian drives a character display and a sprite display at once, and a PC with a single bitmapped display has to emulate both. It also noted how small the results could be: NESticle, “knocked together for fun in about three weeks” by Bloodlust Software, and a Space Invaders emulator that “takes up a mind-bogglingly tiny 3K”.
Interpreting and compiling
Simon Goodwin’s Amiga Format column of June 1999, on the fMSX2 MSX emulator, is the clearest period account of the two ways to run the old machine’s code. Interpreting emulators “must laboriously look up code for each Z80 instruction” and “have gone about as far as they can on Von Neuman and Harvard architectures and underuse modern pipelined processors”. A compiling emulator translates the code once, but “Programs, unlike books, can change themselves as they go along. A useful compiling emulator must check for this, or else it will carry on running the old code after it’s been replaced.”
fMSX2 did both: “it dynamically compiles as it runs. Translation delays are imperceptible, swamped by the time saved when code doesn’t need to be re-interpreted, Dynamic recompilation tracks code invalidation”. The price was memory, “for dynamically-generated 68020 code, typically more verbose than the Z80 equivalent”.
MAME
Edge first reported Nicola Salmoria’s MAME in July 1997 as “a free emulator that runs more than 100 arcade games from their original code, dumped straight from the coin-op ROM boards”. By August 1998 it supported “over 590 arcade ROMs” across “a number of hardware configurations, from Z80 to 68000 and beyond, although only CISC-based chipsets are supported at present”. The 2002 history put its birth at February 5, 1997, after Salmoria combined single-game emulators for Mr. Do!, Pengo and Lady Bug, and counted 3469 ROM sets.
Emulating the whole board rather than the game had a side effect Edge enjoyed in 1998: the operator’s dip switches came with it. In Tehkan’s Bomb Jack “players can alter the tenacity of the pursuing mechanical bird, the number and speed of more generic assailants, and the appearance and frequency of coveted ‘E’ and ‘S’ coins.”
UltraHLE and Connectix, 1999
Two releases in January 1999 moved emulation from old arcade boards to current consoles. UltraHLE, from the pseudonymous Epsilon and RealityMan, ran Nintendo 64 games including Ocarina of Time and Super Mario 64 on a Pentium II with a 3Dfx card, in a program of “around 220K”. Its authors said they wrote it “to see if it could be done” and declared the project discontinued. Edge called it “an astounding achievement” while finding “the issues and complexities that it introduces are less palatable”; Nintendo’s Beth Llewelyn said the authors “had to circumvent our security chip”.
Connectix’s Virtual Game Station, a $50 PlayStation emulator for the Macintosh shown at Macworld ’99, drew a lawsuit from Sony on January 27. The court refused a temporary restraining order, and Connectix’s chief executive Roy McDonald answered with a sentence that has been quoted ever since: “Reverse engineering is not illegal.”
Accuracy
Speed was the first goal; exactness came later, once host machines had cycles to spare. Richard Bannister, who ported emulators to the Macintosh, told Retro Gamer in 2005 that “Traditional emulators often take shortcuts to run at acceptable speeds on today’s hardware. Although this rarely affects emulated software, it’s nice to see all these hacks removed for true authenticity.” His example was BSNES, “which only attains full speed on the fastest Macs Apple has produced, but the end result is as accurate as you can get.” See cycle accuracy.