Slashdot Mirror


Hacker Gets Super NES Games Running On Unmodified NES (arstechnica.com)

The latest project from Tom "Tom7" Murphy is an unmodified NES running Super NES games. "Murphy breaks down this wizardry in a pair of detailed videos laying out his tinkering process," reports Ars Technica. "Though the NES hardware itself is untouched, the cartridge running this reverse emulation is a heavily customized circuit board (ordered from China for about $10), with a compact, multi-core Raspberry Pi 3 attached to handle the actual Super NES emulation." From the report: The Pi essentially replaces the PPU portion of the cartridge, connecting to the NES via a custom-coded EEPROM chip that tells the system how to process and display what would normally be an overwhelming stream of graphical data coming from the miniature computer. Only the CIC "copyright" chip from the original cartridge remains unmodified to get around the hardware's lockout chip. Murphy -- you may remember him from previous efforts to teach an AI how to play NES games -- says that the Raspberry Pi actually has too much latency to effectively "stream" tile-by-tile graphical instructions to the NES' cartridge CPU. By the time the Pi manages to "discharge" a set of instruction bits (only 180ns after they were generated), the NES itself has already moved on to the next part of its read-write cycle.

Murphy used a one-cycle delay to compensate for this latency, essentially guessing where the fairly predictable PPU would be writing to next and just sending data to that location ahead of time. That process works pretty well but results in the persistent flickering and graphical noise you see throughout his video demonstrations.

43 comments

  1. Near-perfect emulation? Not really.. by willy_me · · Score: 4, Insightful

    First off, a very cool project. However, this is an example of how when you have a hammer, everything looks like a nail. The jitter in the resulting screen is horrible - probably the result of the CPU not having consistent timing.

    The BeagleBone board has a main CPU along with some dedicated, single cycle, accurate timing, real-time processors. It would have been interesting to see such a board being used where the main CPU does the emulation and the real-time processors handle the actual final output. Alternatively, an iCE40 or similar FPGA could have been used. The Pi is just not the right tool for the job. Although, it would be interesting to see it paired with a small FPGA.

    So it is great that Tom "Tom7" Murphy got this to work. An excellent first step. But if the jitter problem were to be solved it would be even better.. Oh who am I kidding, it is damn impressive even with the jitter.

  2. Really tough hack by Anonymous Coward · · Score: 0

    Turning pattern ROM into a framebuffer for a co-processor to access. I mean Starfox did it, but that doesn't count.

    I'd be more impressed if there was an ASTC TV tuner SDR writing to the buffer letting me watch HD TV on the NES palette and resolution.

  3. More like... by Anonymous Coward · · Score: 4, Insightful

    Hacker gets video output (with significant glitches due to timing) of a SNES game executing instructions (and receiving controller input) via an Emulator running on a Raspberry Pi displayed on an unmodified NES. Still, good work m8.

    1. Re:More like... by rhazz · · Score: 0

      I could do this even better by routing the output of a SNES directly through the NES console. I'd drill a 1-inch hole all the way through an original unmodified NES, and then run the A/V cables of an unmodified SNES (or even a SNES classic if I had the patience) through the hole and into my TV. There'd be no jitter and you'd get 100% perfect SNES output on the TV. Since it can be done far more quickly this way we'd have far more time to actually play the games, and would be exactly as useful as the article's experiment.

    2. Re:More like... by Anonymous Coward · · Score: 0

      " I'd drill a 1-inch hole all the way through an original unmodified NES"

      And then it would no longer be unmodified.

      The point is that this cartridge can be inserted into any NES.

    3. Re:More like... by AlanBDee · · Score: 1

      He beat the game he was playing but that game was to get a NES to play SNES games. I recommend watching the video. In reading the summary my first thought was similar to yours but after watching the video I understand why he did it. It's very fascinating.

    4. Re:More like... by Anonymous Coward · · Score: 0

      The point is that this cartridge can be inserted into any NES.

      THAT'S AMAZING!

  4. Re:Near-perfect emulation? Not really.. by Junta · · Score: 2

    Well, as mentioned in the video, the glitchiness is because he's having to guess what the address will be before it actually gets read from, modifying his guess when predicted wrong for the next pass. Yes, he mentioned some facets of the experience due to the non-RT nature of the platform, but largely it's because of the having to guess addresses to respond to in advance.

    In essence, the NES is a particularly convoluted video output converter here. A very impressive and difficult way to do something relatively simple, largely to make a point about imagining technology augmented brain.

    --
    XML is like violence. If it doesn't solve the problem, use more.
  5. Re:Near-perfect emulation? Not really.. by Shikaku · · Score: 2

    Also this is how Super Mario Bros. 3 works: there is an ASIC instead of the PPU ROM, which is why it is not only quite large but supports both horizontal and vertical scrolling at the same time, with more palettes than normal. Except he put a Raspberri Pi in it instead of an ASIC. So he just decided to emulate SNES games for fun after figuring out the PPU.

  6. Re:Near-perfect emulation? Not really.. by Anonymous Coward · · Score: 0

    tl'dr the jitter is because the 'guess' is wrong sometimes.

  7. Like getting a .22 to fire nukes by transportation by Anonymous Coward · · Score: 0

    All this project is saying is that it can get a raspberry pi to run SNES games and offload the graphical results to an NES. NES isn't running shit anymore than a .22 can fire Nukes if somebody magically Star Trek transports the warhead just ahead of the barrel.

  8. Video by darkain · · Score: 3, Insightful

    More like "Hacker turns NES into a glictchy as fuck Pi video card, and then emulates SNES on Pi, on an 'unmodified' NES with a heavily modified NES game PCB"

    1. Re:Video by bug_hunter · · Score: 2

      More accurate to say "Hacker turns cartridge into cartridge that can send bizarre output into a NES using all kinds of crazy tricks" and is able to get higher resolution output on a machine never meant to be capable of it.

      I mean, it is technically one of those wastes of time as emulating a full SNES with video out would have been much easier - but it's a really cool the way he's done it.
      No need to always jump to the most cynical interpretation.

      --
      It's turtles all the way down.
    2. Re:Video by YukariHirai · · Score: 1

      Yeah, the snark about the headline accuracy is really unnecessary; it's an impressive feat to do this with an unmodified NES, however it's achieved. And sure, there's probably ways to do it better. And sure, there's not much practical use for this specific thing. But it's a cool and interesting proof of concept; taking the knowledge gained from this, one could develop a NES cartridge that could make an unmodified NES do all sorts of things no-one would dream it's capable of.

      The fact the cartridge would necessarily be itself a more powerful computer than the NES is neither here nor there, as is the fact that in most cases there'd be no practical point to including the NES in the equation versus just using the other hardware on its own or with less troublesome video output. It need not even be a NES that further work in this direction is done with; the basic theory would be applicable to other systems, even if implementation would be very different.

    3. Re:Video by squiggleslash · · Score: 1

      I really feel like nobody here, from the submitter to the comments patting this guy on the back, have any idea what the term "unmodified" means.

      It's an impressive achievement, but if it involves additional hardware being attached to the NES - even if via the NES's cartridge port - it's not "unmodified" in any meaningful sense of the word.

      --
      You are not alone. This is not normal. None of this is normal.
    4. Re:Video by willaien · · Score: 2

      It's a bit philosophical. Do you consider an NES to be modded if you put a SMB3 cart into it? (SMB3 cart had an extra MMU on it) What about a famicom with Castlevania 3? (That had a sound chip on it that could output directly through the NES audio)

      The NES itself hasn't been modded. I don't consider plugging in a cartridge to be "modding", at least not any more than was already done with the NES.

    5. Re:Video by YukariHirai · · Score: 1

      Maybe everyone is wrong but you. But maybe, just maybe, you're the one with a strange idea about what "modified" means.

      If I plug a USB webcam into my desktop PC, my PC hasn't been modified, it's had a peripheral plugged into it to provide functionality it otherwise lacked. On unplugging said peripheral, my PC is back to being the same as it previously was. This cartridge of his can be plugged into any old NES, using the exact same interface as any other cartridge, and provide it additional functionality. On this cartridge being unplugged, the NES is back to being the same as it ever was. No actual modification has taken place; no chips added to the motherboard, no wires soldered to existing chips.

      As another poster points out, a number of published NES games included additional hardware on the cartridge, and no-one's described a NES that's running one of those games as being modified because of it.

  9. Awww yeah! by RyanFenton · · Score: 1

    First up: Watch the whole video. It's worth the time!

    I've been wondering about the counter-side to this for years: Ubiquitous emulation.

    As technology advances, emulators get more sophisticated. Eventually, emulators are going to be showing up earlier and earlier, and be better and better.

    Functionally, you're only going to need any unique hardware plugged into a friendly interface, and a any system can act like a less efficient version of any other, perhaps one generation worth of speed lost for the conversion.

    The Wii was especially great along these lines, because you just needed a wiimote and IR lights, and emulation was amazing.

    Anyway - once you have established a working matrix of ubiquitous emulation, the whole framework of games becomes basically more accessible anywhere, as long as you could create a central licensing body - you could basically make the Everything version of Steam.

    Sure - companies would be resistant to the idea at first - walled gardens and all that - but it's the same logic that leads to better results for legalizing some forms of drugs - licensing it is a LOT more income than letting the black market exist.

    And if 99% of your income comes when your hardware is still uniquely capable and beyond cross-console emulation, then it doesn't hurt most of your walled garden.

    Or, you know, it can happen completely in the face of the various markets control systems, like it already has been - where each manufacturer uses their own emulators to slowly trickle old games out. But like voting patterns and television markets, I think the younger audiences are increasingly picking up on the idea that there's a better way to play the whole "gaming" game.

    Ryan Fenton

    1. Re:Awww yeah! by Anonymous Coward · · Score: 0

      As someone who started console gaming on emulators, it seems like it's actually going the other direction. Newer consoles are much harder to emulate and emulators for them lag further behind the console releases. I remember playing SNES games just fine (erm, without transparency effects...) on an SNES emulator before the N64 even came out. I've never looked into Wii emulation, but I suspect it may be an exception because it was intentionally built with underpowered hardware for its time to save money because Nintendo decided competing on interface would be more profitable than competing on graphics. On the other hand, console exclusives seem to be rarer these days, so emulation seems less important. Or maybe I've just drifted away from console gaming (buying a Linux game every once in a while is a lot less commitment than buying a console which I won't use a lot), so I'm less aware of the issues.

  10. "you may remember him from" by talldean · · Score: 1

    Okay, I <3 Tom, but it's worth picking out this bit:

    "you may remember him from previous efforts to teach an AI how to play NES games"

    And point out that that *may* have been a joke. Where he explained part of it in a Youtube video wearing a colander on his head. If he later actually made the joke work, that's terrific, but holy shit, submissions to SIGBovik aren't, uh, real?

    1. Re:"you may remember him from" by plloi · · Score: 1

      Ironically, this time the joke was that it worked.

    2. Re:"you may remember him from" by talldean · · Score: 1

      Okay, that honestly makes my damn day.

  11. Not "running on" by Bert64 · · Score: 3, Informative

    It's not running on the NES any more than it's running on the tv set used to display the output...
    The NES is merely being used as an intermediate output device, the actual game is running on the raspberry pi.

    --
    http://spamdecoy.net - free throwaway anonymous email - avoid spam!
    1. Re:Not "running on" by nine-times · · Score: 1

      Well it's also handling the input from the controller, I think.

      Yes, it's true that the game isn't actually running on the Nintendo hardware, but it's also not as though he's just bypassing the internal hardware to output to the display capabilities. From what I can understand, the Nintendo thinks it's playing a game, but he's screwing with the output from the game cartridge to make it display things that a Nintendo shouldn't be capable of.

      It's sort of like a good magic trick. Yes, it's a trick, but the way he's pulling the trick off is interesting and impressive in its own right.

    2. Re:Not "running on" by mrfaithful · · Score: 1

      I can't watch the video right now so apologies if this is all explained, but I don't see why the summary makes it sound so complicated. The NES PPU gets its tile data from ROM on the cart. Most of the NES library uses a mapper that supports replacing this ROM with an electrically compatible RAM setup. More complicated mappers write data to this RAM on behalf of the game code to provide support for features the NES can't do.

      He could obviously just take this approach to its logical conclusion and dump the emulated buffer from the Pi in NES tile format in a RAM buffer the way NES mappers already do.

      The only reason I can see to do what he's doing is to subvert the limitations on colours per tile to get the output closer to the SNES. But given the absurd amount of noise a stable lower colour display using the simple, obvious way would be better than having to explain to people that if they squint really hard they can see more colours behind the noise than the NES could really display at once.

      And "the noise is caused by guessing" doesn't entirely fly. Nintendo would fail any game submission that wrote to the PPU registers outside of vblank because the NES PPU was highly unstable and very easy to throw off. To me it looks more like what happens when hot shit coders tried to micromanage the PPU to get fancy graphical effects, then spent hours trying to stop the output from looking like something was failing very badly before giving up and having to be satisfied with their smooth 8-way scroller without mid-scanline effects.

    3. Re:Not "running on" by Purity+Of+Essence · · Score: 1

      The main difficulty is latency. He has only a few nanoseconds to put the requested data on the PPU bus but the Pi and emulator are nowhere near fast enough. That's the purpose of the imperfect prediction scheme.

      --
      +0 Meh
  12. Quake on an xterm by eggstasy · · Score: 1

    Yeah someone made Quake "run" inside xterm by making an adaptation layer converting the graphics to ASCII art. You can turn any computer into a dumb terminal with external processing. But that's not "running" a program on the actual machine, it's more like "streaming" :P

  13. Hmm by DrXym · · Score: 1

    The NES isn't "running" SNES games, the RPi is. The NES is basically acting as a dumb terminal with shims to the sound, display and inputs. Why even stop at SNES? Whack a few other emulators on there.

    1. Re:Hmm by EkriirkE · · Score: 1

      +1 Next headline "NES runs Windows 10 unmodified!"

      --
      from 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
      to 45 2F 6E 40 3C DF 10 71 4E 41 DF AA 25 7D 31 3F
  14. typical by sad_ · · Score: 1

    on old home computers of the 8 and 16 bit era you can find similar projects.
    most of the time these had a bus that could replace the main cpu, so some people replace them with fpga's or arms or whatever really.
    you can then build some supercomputer with it, most of the time producing impressive results.

    --
    On a long enough timeline, the survival rate for everyone drops to zero.
  15. We hope the police will investigate by Anonymous Coward · · Score: 0

    Hackers are criminals. Anything this criminal has done is not only illegal but probably very dangerous. We can only hope authorities will get to the bottom of this and make high profile arrests.

  16. Re:Near-perfect emulation? Not really.. by Anonymous Coward · · Score: 0

    If he actually understood how the NES PPU works, "guessing" the address would've been a total non-issue - if you know the initial scrolling offsets, the PPU's memory fetch pattern is 100% predictable, so you could just build a table of values and output the "next" one each time the PPU asks for a byte of anything. Of course, that would also require his CPU to be running in real time with no interrupts, which wouldn't have worked with the RPI 3.

  17. Re:Near-perfect emulation? Not really.. by tepples · · Score: 2

    Also this is how Super Mario Bros. 3 works: there is an ASIC instead of the PPU ROM, which is why it is not only quite large

    The Memory Management Controller (MMC3) helps make Super Mario Bros. 3 large, but it doesn't quite replace the CHR ROM. It just controls the high address lines (A16-A10) of CHR ROM and the high address lines (A17-A12) of PRG ROM. It's not conceptually different from the MMU used by a modern CPU to translate virtual memory addresses into physical memory addresses. MMC3 also contains a programmable interval timer that generates an IRQ by counting how often the PPU switches between reading sprite tile memory and reading background memory (which happens once per scanline). This timer is mostly used to switch between a game's playfield and its status bar.

    but supports both horizontal and vertical scrolling at the same time

    And a bunch of games that don't use MMC3 can do 8-way scrolling, such as Solar Jetman and Blaster Master. That's mostly a matter of the design of the game engine and, in some cases, of whether the cartridge has 8 KiB of supplemental work RAM on the CPU side (in addition to the 2 KiB in the NES) to cache a decompressed level map.

    with more palettes than normal.

    MMC3 does not extend the four background palettes and four sprite palettes, which are internal to the CPU. The closest a mapper can do is shrink the area affected by each palette from the normal 16x16 pixels. MMC5 has an "ExGrafix" mode that shrinks color areas to 8x8, and it was largely used for Koei's war sims but also saw use in Castlevania III and a handful of other games. But by the time developers started to figure out the MMC5's true capability, the TurboGrafx-16, Genesis, and Super NES were out, and game studios had mostly lost interest in the NES.

    Sources: MMC3 reverse engineered docs; MMC5 reverse engineered docs; NesCartDB entries for SMB3 and other games

  18. Re:Near-perfect emulation? Not really.. by Junta · · Score: 1

    Perhaps so, but I'll give him the benefit of the doubt that perhaps there's some complication since he did do a pretty impressive job. Of course he also says he could have done better on PPU fetch pattern prediction, which may be what you refer to.

    Since it's just a fun stunt to pull, not like it has to be perfect anyway.

    --
    XML is like violence. If it doesn't solve the problem, use more.
  19. Not the first, but the weirdest by DrYak · · Score: 1

    It's not the first time even.
    Some of the special ASICs used in official NES cartridges by Nintendo did feed programmable RAM instead of ROM to the PPU.
    Wikipedia mentions Zelda and Castlevania that use the MMC1 to map RAM so they can animate backgrounds by modifying tiles.
    Other posts here mention Mario 3 using ASIC for multidirectional scrolling, etc.
    (And that for the NES only. Then the SNES came with its co-processors embed in cartridges, be it SuperFX accelerator, or the Super Gameboy cartridge)

    So if you feel that Tom7's trick is cheating, Nintendo has been doing it for much longer.

    But the novelties are :
      - instead of using a special ASIC like most of the examples from Nintendo (save for the SGB), Tom7 is using a general purpose CPU (like the Z80 in the SGB).
      - instead of using some special access to the PPU (like any example from Nintendo) Tom7's attempts try to drive the PPU straight from the Pi's GPIO pins.
      - thus the latency problems that classic Nintendo problems avoid (using ASIC and RAM with a reasonable latency), requiring Tom7 to be creative (predict what the PPU will attempt to read, so by the time the PPU is reading it, the Pi has the answer ready on its simulated ROM bus)

    That's worth tons of LULZ points.

    --
    "Sufficiently advanced satire is indistinguishable from reality." - [Tips: 1DrYakQDKCQ6y52z6QbnkxHXAocMZJE61o ]
  20. SGB return, with a twist. by DrYak · · Score: 1

    So basically similar to the Super Gameboy, but with a NES instead of SNES as the host and an (emulated) SNES instead of a GB as the guest.

    and with a PiZero (powerpoint presentation) or a Pi3 (SNES game) driving DIRECTLY THE ROM BUS - and that's the freaking awesome part.

    He's not writing to a dual-ported RAM that then the PPU reads instead of ROM (like tons of official games from Nintendo do), he's feeding the PPU input straight from the Raspberry Pis. He's basically emulating what the ROM chips would be answering to the PPU, *entirely in software* (no ASICs involved unlike classical Nintendo examples).

    In other ways :
    - the SNES emulation is just a party trick for fun.
    - the "REVERSE EMULATION" part, is that he's emulating what a PPU ROM in a real cartridge would be doing, entirely in software, using Pi GPIO PINs.

    --
    "Sufficiently advanced satire is indistinguishable from reality." - [Tips: 1DrYakQDKCQ6y52z6QbnkxHXAocMZJE61o ]
  21. Crysis by Anonymous Coward · · Score: 0

    But... Can. It. Run! Crysis??/

  22. Re:Near-perfect emulation? Not really.. by Anonymous Coward · · Score: 0

    "The jitter in the resulting screen is horrible - probably the result of the CPU not having consistent timing."

    "Probably"?

    It's in the fucking SUMMARY, and explained in the video!

  23. Re:Near-perfect emulation? Not really.. by Shikaku · · Score: 1

    I learn something new everyday. I was not quite right it seems. But it's interesting what they did to enhance the power of the NES near the end of its lifetime.

  24. Like... by Anonymous Coward · · Score: 0

    ....Running Windows 10 on an unmodified Pentium MMX? Useful, huh?