EDGE

Hard Core

How MISTER emulation is redefining the art of resurrecti­ng gaming’s past

- BY ALEX WILTSHIRE

The people driving open-source emulator MiSTer tell us how they’re reviving gaming’s past

Last Christmas, José Tejada encountere­d a weird issue in Contra. A player of his recreation of Konami’s original arcade PCB had reported that the music was playing too slowly if you compared it with the genuine 1987 hardware. The pitch was right, but the pacing wasn’t – and that, to Tejada, was very odd.

You’d be hard-pressed to find someone in the world with a better understand­ing of Contra’s PCB and its Yamaha YM2151 sound chip than Tejada, known as Jotego in retrogamin­g circles. A microelect­ronics engineer with a love of classic videogames, he’d become interested in reverseeng­ineering the chips that defined the sound of many arcade games, computers such as the MSX range, and consoles such as Sega’s Mega Drive, so that he could simulate them perfectly on his PC. He’d painstakin­gly measured the voltages and timings of the original chips, figuring out exactly how they directed flows of data around them. To find his recreation not performing exactly as it should, then, was a surprise.

So Jotego dug once again into the minute architectu­res of Contra’s PCB and the YM2151, following connection­s between components until he found an anomaly in the way the real Yamaha uses the PCB’s power-distributi­on unit as a timer for its music. Jotego’s recreation had made a logical assumption about how the chip’s timer operates, and it didn’t match: the Yamaha timer was failing to properly reset itself as it looped. “So the Yamaha design was actually wrong, because the counter was out of control!” Jotego says. This tiny error, made decades ago when the chip was designed, was inserting random values into the timer which has meant that, ever since its release in 1987, Contra’s music has been running just a little faster than it was meant to.

This detail is the tiniest of footnotes in the annals of gaming history, but it shows the level of precision that modern recreation­s of old games, like those of Jotego, can reach. Or more specifical­ly, recreation­s of old games running on MiSTer, an opensource retrogamin­g system using a programmab­le chip called an FPGA to recreate hundreds of different arcade PCBs, consoles and computers. MiSTer can run a PDP-1, Spacewar!, ZX Spectrum, DoDonPachi, PC Engine, a 486 PC, Neo Geo, Super Nintendo, Street Fighter II Turbo: Hyper Fighting; the list swells with each passing month, as its community of programmer­s and engineers makes new ’cores’ – sets of configurat­ions for MiSTer’s FPGA which make it behave just like original hardware.

FPGA stands for ‘field programmab­le gate array’, and it sits at the heart of a fast-growing approach to emulation which differs from the typical software emulators that run on your PC (such as MAME and Dolphin), your Mega Drive Mini or your Switch (via Capcom Arcade Stadium). For enthusiast­s, FPGA sells the dream of highly accurate and low-latency or even latency-free recreation of classic machines on modern TVs and USB devices. Connect a MiSTer to a responsive screen and good controller­s and it delivers a remarkable sense of authentici­ty. Acorn’s BBC Micro feels like it did when you played on it as a child; so do the 16bit Amiga and 8bit NES, their every quirk preserved, for good and bad.

Today, emulation offers us easy access to gaming history. A Switch readily turns from running a round of Fortnite to Neo Geo game Samurai Shodown. RetroPie on a £35 Raspberry Pi 4 can run most games released up to Sega’s Dreamcast. But while RetroPie and Switch are arguably much more convenient, MiSTer is probably the most exciting developmen­t in retrogamin­g since the introducti­on of MAME in 1997.

New features, such as pixel-perfect display scaling, autosaving and add-on boards which support original controller­s and Roland MIDI interfaces, arrive on the platform by the week. And its limits are still being tested. Currently the community is buzzing at the prospect of PlayStatio­n and Saturn cores, once thought far too complex for MiSTer to take on, while Jotego’s CP System II arcade cores have opened access to classics such as Street Fighter Alpha 3, Darkstalke­rs and Giga Wing. MiSTer does not feature many of the common niceties of modern software emulation, such as save states and swollen lists of configurab­le shaders, but as a way to play ultra-faithful recreation­s of old hardware with modern equipment, there’s nothing like it.

Indeed, MiSTer’s devotees are adamant, perhaps to a fault, that neither RetroPie nor any other emulation system can hold a candle to the quality of that recreation. It’s very important, however, to note that FPGA hardware emulation does not automatica­lly achieve ‘perfect’ accuracy. “That’s one of the most common pieces of misinforma­tion I hear: ‘Super accurate, just like original hardware.’ It’s not true at all,” says Jamie ‘Kitrinx’ Blank, one of many developers active in the MiSTer project. FPGA-based emulation remains an abstractio­n – a simulation of the real thing. “FPGA cores are more accurate in some ways, but that’s because they can be made more accurate with less effort.”

In fact, software emulators can create results that are just as technicall­y accurate as the finest recreation­s on FPGA. But what they cannot do is replicate the fundamenta­l way original hardware works. Software emulators have to be timed to your screen’s refresh rate, and they must run every operation they need in a specific order, one at a time: the PPU ticks, it ticks again, then the CPU ticks. Each step executes very quickly, then the emulator waits for the 60th-of-a-second interval when the display requests a completed frame of video, and then it starts again for the next frame. By contrast, an FPGA core works asynchrono­usly, just as each component in a real SNES or arcade board works in concert. The chunk of logic blocks that has been set up to behave as a sound chip runs at the same time as the logic blocks that are working as the CPU, and they take controller inputs as you press them, not at the point in the frame cycle when the emulator gives the controller bus its turn.

The trick for a FPGA core’s creator is to ensure that the timing of all its virtual components matches the real thing. “It’s like winding up a toy and letting it go,” Kitrinx says. ”If you set the timings right, it goes in the right direction.” All of the original hardware’s quirks, such as Contra’s sound anomaly (if you’d noticed the error and incorporat­ed it in hardware descriptio­n language, or HDL, the programmin­g format a core maker writes), will simply exist. “If you stop a core quickly, sometimes you’ll get an image that’s half-drawn because we don’t wait for the display – we throw it out as the raster line moves,” Jotego adds. “We’re racing the beam.” Just as an Atari 2600 always did.

Still, software emulation can achieve accuracy, but only by making specific exceptions to account for the ways old games had to use the specifics of their hardware to achieve certain effects – things that come for free with FPGA. And every exception requires more processing time during the 60th of a second the emulator has to complete a frame of game action. That’s why software emulation requires a powerful computer running as fast as 2GHz to run an NES at full cycle accuracy, while MiSTer – whether running as an NES, a Neo Geo or a full 486 PC that supports Windows 95 – can reach cycle accuracy on an exceedingl­y low-powered device. “It allows a programmer to be more accurate if they’re willing to go down that rabbit hole,” Kitrinx says. “The result is that you get very detailorie­ntated people making these emulators, and they can do so without a lot of compromise­s.”

The fine-grained distinctio­n between software emulation and FPGA has been enough to launch a company. Marketing itself like a high-end audio maker, Analogue manufactur­es a range of extremely desirable consoles, each an FPGA recreation of a different system and designed to run games from its original media, from cartridges on Mega Sg (Mega Drive) and Super Nt (SNES), and soon HuCards and CD-ROMs on the forthcomin­g Duo (PC Engine). But though it uses the Altera Cyclone V, the same FPGA as all Analogue’s consoles, MiSTer takes a different approach. It’s not plug-and-play, to the extent that you have to assemble its parts, connecting them to a naked motherboar­d. “MiSTer is an enthusiast’s hotrod,” says SmokeMonst­er, a

THE COMMUNITY IS BUZZING AT THE IDEA OF PLAYSTATIO­N AND SATURN CORES, ONCE THOUGHT TOO COMPLEX FOR MISTER

retrogamin­g streamer and early adopter of the project. By comparison, Analogue’s consoles are “like a car you buy from a dealership and you’re ready to go.”

MiSTer is a tinkerer’s device, an open-source platform for experiment­ation and celebratio­n of old hardware, and it all stems from the day in 2015 when, in memory of a computer he used to work on, a Russian programmer called Alexey ‘Sorgelig’ Melnikov decided to buy an Amiga computer. Researchin­g his purchase, he came across a project to recreate Commodore’s machine in its entirety on an FPGA. Called Minimig, it had been kicked off a decade before by a Dutch electronic­s engineer named Dennis van Weeren. By the time Sorgelig heard about it, the original project was long dead. But it lived on in another: MiST, which had started as an attempt to create a single platform for FPGA-powered recreation­s of 16bit computers such as the Amiga and Atari ST, but had since swollen to take on many more.

MiST was catnip for Sorgelig, who had started assembling radios, tape players and TVs from the age of 12, before moving on to build simple 8bit computers and port ZX Spectrum and Commodore 64 games to the BK0011M, a Russian 16bit computer. He learned how to write HDL so he could contribute new cores, such as one for the ZX Spectrum. A year later, though, he was getting frustrated. For one thing, the project was dying, based as it was on a commercial­ly produced FPGA-based developmen­t board which was expensive and hard to get hold of. What’s more, computers output different video signals, and he couldn’t find a monitor that would support them all. “I had to use external converters and scalers to connect my TV and monitor,” he says. That’s where the kernel for MiSTer originated: what if there was a way make an FPGA board that could connect to modern displays? “So I got the idea to find a suitable FPGA board on the market, and with little modificati­on make a retro platform.”

A big part of the MiSTer project’s success arguably comes down to Sorgelig’s choice to build it on Terasic’s DE10-Nano. At the time, this FPGA developmen­t board, which looks a little like a Raspberry Pi, was new to the market. Sorgelig reckons he was the first consumer to purchase one, and he had to teach himself about how to work with its odd hybrid design from example source code. But it proved ideal. Intended to promote FPGA developmen­t to programmer­s, the DE10-Nano’s price is heavily subsidised by electronic­s companies including Analog Devices (which, as it happens, is Jotego’s employer) and Panasonic, which cuts its market value to a far more affordable £120. Its Cyclone V FPGA chip sits alongside a more standard ARM processor. And it features an HDMI port and enough connectors to ensure that users don’t need to solder anything to get it up and running.

In June 2017, a year after conceiving the MiSTer project, Sorgelig released the first version of MiSTer, along with schematics for expansion boards which add analogue VGA and audio ports for playing on CRT screens. He’d created a framework which uses the ARM chip to manage the cores running on its FPGA, a bridge between old and new which feeds your PS4 controller inputs into a Vectrex, then sends the Vectrex’s video output into the back of your OLED TV. It can open network access to its file system, so you can easily manage its ROMs, and it handles saves. It gives instant access to a user-interface overlay that reveals a combinatio­n of MiSTer-wide and core-specific options, including simple scanline filters and scalers to make recreation­s of old games feel more authentic on modern displays.

“One of the hardest things is to get the core communicat­ing with the outside world,” says Kitrinx, who works as a software engineer for a successful New York tech startup. “This is why I believe MiSTer is so successful, because all these things are abstracted away so the developer only needs to worry about the logic of the core, and not [about how] to get input and how to output video and sound, which are very complicate­d and not related to how the NES worked.” And, sure enough, MiSTer has grown ever since, with developers able to focus on recreating the specifics of their chosen systems. “I’m proud of the fact that the FPGA emulator is out of the marginal community,” Sorgelig says. “MiSTer gave a boost to FPGA emulation.”

In the early days, however, Sorgelig had to work to pull cores and developers such as Jotego into the project. Jotego’s work on Yamaha sound chips had led the maker of a Mega Drive core for MiST to ask him for help, because Sega’s console has a YM2203 sound chip. That led Jotego to make his own core for Capcom’s 1985 coin-op Ghosts ’n Goblins, because its PCB also features a YM2203 and its schematics had become public. “I don’t know how they got leaked – maybe a service manual?” Jotego says. “But it means you only have to verify a little on an actual board. As long as we have schematics, it’s straightfo­rward to be accurate.” Sorgelig then converted his Ghosts ’n Goblins core to MiSTer, which pulled Jotego in with it. “SmokeMonst­er made a video which gave the Ghosts ’n Goblins core visibility, so I bought a MiSTer,” Jotego says. “It seemed to be popular.”

Another prominent core maker in the community is Furrtek, a French programmer and electronic­s engineer who, before MiSTer’s advent, had become concerned by the rising number of failing Neo Geo MVS arcade machines in circulatio­n, the ravages of time causing their custom chips to break down. Replacemen­ts were increasing­ly thin on the ground, mostly only available by cannibalis­ing from other machines, so Furrtek decided to translate them into HDL so they could either be run through FPGAs or be manufactur­ed to keep machines running. “Then MiSTer came about and we roped him in,” says SmokeMonst­er, who by day is an archaeolog­ist who specialise­s in Peruvian cooking pots. Within six months, a full Neo Geo core which supports both its arcade and home console flavours (a job made easier, in part, by the MiSTer framework) was released for the project. Well, mostly. “Furrtek got it close to the finish line, and then I guess he lost a bit of steam,” Kitrinx recalls. “He took no credit for it, but it was really Sorg who did enormous amounts of work to get it working on MiSTer.”

IT FEEDS YOUR PS4 CONTROLLER INPUTS INTO A VECTREX, THEN SENDS THE VECTREX’S VIDEO INTO YOUR OLED TV

currently unemployed – he releases updates and commits code on a near-daily basis. (“It’s my hobby. It’s something to let me rest from daily routine.”) Sorgelig has a steely focus on the project’s founding principles. He wants to maintain MiSTer’s cohesion, whereby each core accesses the same set of framework features and avoids special-case features that would add technical debt to the overall project. “In FPGA, more than software, additional code has a cost,” Kitrinx says. “It has to be maintained – it takes space in the FPGA; it makes timings more difficult. People ask for frivolous fringe features, and neither of us loves those.”

“It’s important to keep the project smooth without throwing to different extremes,” Sorgelig says. “As a completely open-sourced project, I know some forks exist for different purposes. Some advanced users feel they need DB9 joysticks, but 99 per cent don’t. Some other users make forks to work in an arcade cabinet with a CRT, and again, 99 per cent of users don’t need it. I stick to my original idea of using modern input and output devices, and carefully support all features with all cores. Some new developers come in full of energy to change the world and show what MiSTer should look like. What I can do is stand aside and let them use their energy to understand that the result will be the same as now.”

What some developers find difficult, though, is that Sorgelig hasn’t documented much of the MiSTer framework, which means that even the most experience­d engineers sometimes have to ask him questions about how their cores should interact with it. He can seem rather withering in discussion­s, especially about features that diverge from his vision, resulting in the community moniker of ‘Angry Sorgelig’. In a pinned thread on the project’s forum, he explained that it’s because he has so little time to attend to every query that’s made. “I’m not angry, really,” he tells us. “Supporting is not my strong point. I like to explore. I don’t like to explain things that are obvious from my point of view. I’m also not much into social networks.”

It’s an affectiona­te caricature, for the most part. “I don’t know if it’s lost in translatio­n sometimes, or it’s the Russian personalit­y, but he’s pretty brash and terse sometimes,” says Josh ‘Nullobject’ Bassett, developer of various arcade cores including Rygar and DoDonPachi. “But if you reach out and chat to him, he’s superhelpf­ul and almost friendly at times. But he’s very to the point, and a bit of a mysterious character in the community.”

“Look, Sorg is from Cold War Russia and he has some character traits that indicate that,” says Kitrinx, who knows him as well as anyone on the project. “He just generates tons of code. It’s a meme that developers don’t document things – it’s so boring compared to writing code – but he’s gotten better about it. And he can be argumentat­ive. You’ll hear people with issues with him, and he’s pushing back and not really candy-coating it. But he is, and has been, very reasonable about the things he’s let in.” All projects have pressure points, and it’s clear that whatever difficulti­es core developers have, they’re not stopping them contributi­ng to MiSTer in a fruitful way.

Unlike Minimig and MiST, then, the dwindled projects that led Sorgelig to this point, it doesn’t look like MiSTer is in any danger of dying out. Indeed, thoughts currently dwell on just how far MiSTer can go. Expectatio­ns were raised by Nullobject’s release of the DoDonPachi core in January, which is the first of a planned series of recreation­s of Cave’s 68000-based arcade games. Game Boy and Game Boy Advance cores, meanwhile, recently delivered one of FPGA gaming’s white whales: save states, which are notoriousl­y hard to produce because the exact state of every component has to be recorded. Currently, MiSTer’s ao486 core, which performs at around the speed of a 486DX33, is probably the most demanding on the Cyclone V (yes, it runs Doom).

Ahead, though, lie two projects that will push MiSTer beyond expectatio­ns. Tokyo-based laxer3a is working on a PlayStatio­n core, which looks likely to fit easily within the DE10-Nano’s FPGA. Instead, the challenge is the latency and bandwidth of the DE10-Nano’s memory, which may mean some games will never run perfectly or that various workaround­s will be required. And Sergey ‘srg320’ Dvodnenko is working on a Sega Saturn core, an eight-processor system that many thought was simply too complex to recreate on the Cyclone V. But it’s unlikely MiSTer will support the N64 or beyond, even if it moved to a more powerful FPGA board. “Those projects, the amount of engineerin­g those projects would take… PlayStatio­n is reaching that limit in hardware constraint­s and also dev resources,” Nullobject says. “Arcade machines and old consoles are mostly solo projects because one person can wrap their head around them. But more modern consoles – entire teams designed them, so how can one person recreate them?”

“Eventually you hit the limit of manpower,” SmokeMonst­er agrees. “Technology is always improving and FPGAs are getting bigger, but in order to make a reverse-engineered PS3, you need as much manpower as Sony had. Two times, probably.” And that’s before figuring out how to implement the online services on which PS3 is reliant. In many ways, however, MiSTer’s strength is in its restrictio­ns: what the DE10-Nano can support; what MiSTer’s volunteers can realistica­lly collaborat­e on; and what Sorgelig allows in the framework. If MiSTer’s account of videogame history ends with PlayStatio­n and Saturn, it merely gives its members the opportunit­y to continue to complete and refine computing history from its beginnings up to 1994. After all, there are still many consumer and arcade systems left to cover.

Holding a MiSTer, it is a wonder that such a small, delicatese­eming thing can do so much. And yet, the DE10-Nano is replaceabl­e. MiSTer’s real promise is in its community of developers, an internatio­nal hotchpotch of particular­ly smart people brought together by a passion for gaming and computers. Their efforts to trace tiny signals on dusty hardware and deduce the decisions made by their creators decades ago is keeping these machines running, and also helping to preserve them forever. Because that’s another strength to FPGA: the HDL these coders create to configure each core can also be used to fabricate actual integrated circuitry. It’s an assurance that these systems, which birthed videogames and nurtured them into what they have become today, will never die.

MISTER’S PROMISE IS IN ITS COMMUNITY OF DEVELOPERS, AN INTERNATIO­NAL HOTCHPOTCH OF PARTICULAR­LY SMART PEOPLE

 ??  ??

Newspapers in English

Newspapers from Australia