Perfect Dark: Recompiled

There’s an interesting renaissance of Nintendo 64 gaming, powered by the ability to decompile N64 ROMs back into C code using Ghidra. There are projects around multiple classic games, taking the Ghidra output and renaming the generic function and variable names. There are two approaches to these projects, sometimes happening in parallel. The first is to perfectly recreate the original work, and get a bit-perfect binary that matches the original ROM. The other approach is to fix bugs, optimize the code, and add new features, often porting to new platforms in the process. Right now, we’re seeing the latter happen with 2000’s Perfect Dark.

There is a project by [Ryan Dwyer] to produce a matching C codebase, and that project is functionally complete with an over 99% bit-perfect output. But as impressive as that is, we’re interested in making code even better, and that’s what [fgsfdsfgs] has accomplished with the Perfect Dark port.

The game now runs on Windows or Linux, has mouse support, and runs at a solid 60 frames per second (FPS) at multiple screen resolutions. Want an ultra-widescreen Perfect Dark experience? The upgraded rendering engine handles it wonderfully. Mods? No problem. In the future, the developer is also looking to support high-definition textures.

To play, you do have to provide your own legally sourced copy of the original Perfect Dark game. That is the only way this project is remotely legal, and we suspect that even then it’s in a somewhat grey zone, as a derivative work of a copyrighted game. Big N hasn’t shut the project down, but the Mario 64 port was killed for attempting the same thing. We’ll hope for the best, and enjoy the nostalgia trip in the meanwhile!

55 thoughts on “Perfect Dark: Recompiled

  1. meh. I won’t even support the second hand market of nintendo copyright bs. I bought countless copies of various games over the years, neh, i’m done. There’s zero reason we should be subject to 96 year copyright. it’s dumb, and it is a ‘lawful’ way to destroy stories and art created by humans. I purposely have avoided nintendo for decades because of their particularly egregious treatment of fans. Turning something that is and should be incredibly common into an artificial rarity does zero good for the economy and should be illegal. Things that are easily reproducible should be free or cheap and copyright shouldn’t last 96 years. hot take? neh. common sense.

    1. While I agree that the copyright period is too long, I find your opinion on copyable things to be silly. People want to eat and live; they need to be paid for that. If you don’t pay for thing X, the thing X won’t be produced. It’s that simple. Your money pays the people who made the thing, and it pays the company so it can expand and make other things like X.

        1. Agreed on that. Nintendo is ridiculous with it’s reactive not proactive policies regarding copyright. They only care enough about a game when its copyright is violated but can’t or won’t give us a legal means to obtain it.

      1. > If you don’t pay for thing X, the thing X won’t be produced. It’s that simple.

        Except it’s not true. It’s literally never been true. Humans created art and music and wrote and told stories long before copyright or even patrons existed. Open source software is still created to this day literally for free. The software that you’re using to read these very words in fact (web browsers, TCP/IP, Hackaday web server, OS and possibly even the CMS powering the site). It’s amazing that people can believe a fiction when it’s disproved literally right in front of their eyes.

        1. You are obtaining something that you paid nothing for from someone who invested time and money to produce it, and would normally obtain money in exchange for a copy. In what possible sense is that not theft? And the “well, they don’t sell it anymore” argument is not valid. Access to past works is not anyone’s entitlement, unless specified in some sort of contract the company made with the person.

          If I invest time and money to produce a product, it is my right to later decide I don’t want it to be available anymore – whatever my reasons. No one has the legal or moral right to make a copy and sell or distribute for free something I’ve determined I no longer want to be available.

          Of course, exceptions exist for used products and legal “clean room” reverse engineering efforts (which I support BTW).

          1. This is just nonsense on multiple fronts. These aren’t people who invested time or money any more (often dead and/or retiring), access to past works *is* everyone’s entitlement, especially as a society, and nobody is investing time or money in these things anymore.

            The scope of “I spent time and money” is limited to a brief period, say 20-30 years or so. Yeah some copyright laws extend much longer but that isn’t their right, that’s legal monopolists lobbying govt officials. If it were their right they wouldn’t have to bribe govt officials, these people are dirty criminals nothing more or less.

    2. Easily reproducible for sure, but the first item, the “original” you want to replicate had budgets ranging from 100s of kilodollars to hundreds of millions. And you could argue that “they have recovered their investment”, but they produced it and they can do whatever they want. But you are free to produce some videogames and offer them for free too.

  2. “but the Mario 64 port was killed for attempting the same thing.”

    No, I think the SM64 port *included* the graphical assets, which made it a clear copyright violation. There’s an SM64 decompile on GitHub still, and the ports of Zelda: Ocarina of Time have been around for years now since they also excluded the assets.

    1. Yep, if there’s no security circumventioning and if the port include just reverse engineered code and not a singly asset, I doubt big N can do much… see all the emulator alive…

      1. Eehhhhh. The game binary, even without assets, would be valid to copyright. So a decompilation would likely be a derivative work. Which is different from an emulator. But regardless, Nintendo has enough lawyer muscle to wield the DMCA like a hammer. A community effort like this wouldn’t be able to mount a defense. I suppose GitHub might help, but it’s far from certain.

          1. *None* of the original binary was copied. It can’t be a derivative work. Derivative doesn’t mean “inspired by the original.” It means “taken from the original.” This isn’t Ice Ice Baby literally using a track from Under Pressure. This is a singer creating an original piece that *sounds* like another one. The fact that they end up byte-for-byte identical is a fact of the lossy nature of compilation: it’s the same thing as a song that sounds the same from a distance.

            And as much bad as laws like the DMCA create, the DMCA (in the US at least) *explicitly allows* reverse engineering for the purpose of interoperability, which is *exactly* what’s going on here (the EU has a similar carve-out).

            Part of this is because these are *console* devices and physical games (in the pre-digital game era) – so there is not, and cannot be, a license agreement that anyone agrees to before the binary is run.

          2. Decompilation creates a derivative work, by definition. (https://www.ipglossary.com/glossary/decompiling/). Look into the AFC test that courts use to determine whether software is a derivative. And while it is generally not a copyright violation to decompile, it is a copyright violation to publish the results without permission. Because derivative work.

            Interoperability has a narrow meaning (https://www.law.cornell.edu/definitions/uscode.php?def_id=17-USC-378882880-2041310950&term_occur=999&term_src=title:17:chapter:12:section:1201), and it really doesn’t cover porting to a new OS.

            You are absolutely correct, that there isn’t a license agreement at play. This is strictly copyright law. But let’s think about your musical example. If you listen to a musical performance, and then go play the same song by ear, you are still performing a cover version of that song. It does not matter whether you ever saw the sheet music.

            DMCA only really comes into play because it’s the hammer that is used to shut down projects online. And it’s hard to fight.

        1. If produce a binary by diff from the original you oblige leave to the user to procure it, and can be done legally. You don’t distribute anything of the original source, so you should be covered legally by any trouble if you don’t circumvent any protection.

        2. The game binary probably isn’t subject to copyright as it’s the result of a mechanical process (namely, compilation). The original source code would certainly be subject to copyright, but there are two issues for N with that: the first is that the decompliation process probably doesn’t produce the original source code sufficient to claim copyright, and even if it did, their original copyright claim would likely fail due to attempting to claim copyright over “literal elements” i.e. function and not form.

          https://en.wikipedia.org/wiki/Abstraction-Filtration-Comparison_test

        1. Copyright basically only exists for the benefit of large publishers, the explosion of independent distribution online has proven that anyone who can find an audience can make money from creative work without even charging for the work itself. Digital distribution is effectively free; copying and stealing are not the same and propaganda from organizations like the RIAA is the only reason you would think otherwise.

          You can tell people to “create something original” but that breaks down as soon as you begin the creative work. Books are made of books, as Cormac McCarthy said. Games copy mechanics/styles from each other (if not code, see Carmack’s fast inverse square root), musicians sample each other. If you trust copyright as an instrument to determine what is “original” then you’re giving it far too much credit. ROM hacking is a great exercise for people getting into game development. Widescreen mods and PC source ports are great, period, whether copyright law agrees or not.

          The only reason anyone can really support copyright with a straight face is because publishers often let violations slide–every company COULD do what Nintendo does, taking games out of print and cracking down on anybody who wants to distribute them. They take away the ability for young people to engage with e.g. video game history, which is bad for the future of the art and puts access exclusively in the hands of people who can afford approved platforms plus a bunch of expensive games.

          If you wanted to study, say, Japanese shoot ’em ups from 1985-2000 without violating copyright, you’re looking at hundreds of thousands of dollars in arcade boards, overpriced low-quality ports, and a bunch of games you can’t even buy. Copyright should be violated because it’s an outdated instrument propping up a bunch of legacy companies that overexploit artists and consumers. You can see copyright’s festering remains in cases like the Internet Archive’s recent Controlled Digital Lending suit.

  3. Nintendo went so far to protect copyright that once, in their game Mother (which was supposed to be ported as Earthbound Zero when they almost got it here), they buried a line of code that somehow detected if the game had been copied or pirated that posted an anti-piracy screen and then ceased to function. The rom community went berserk until they got around it (which later proved to be the fault of a dump’s attempt to accommodate a specific emulator but…. still!).

    Trust me. Nintendo is watching this with an extra grumpy face.

    1. Are Nintendo going to be grumpy about this game? Rare (the developer of Perfect Dark) jumped ship to Microsoft consoles not long after this game was released: that’s where all the sequels are.

  4. If you need to guess or speculate about how something is done, please don’t. You may not realise it, but you’re doing an incredible disservice to the people that put in literal YEARS (like Ryan did) to achieve what they have.

    Perfect Dark and most other N64 decompilation projects are decompiled **by hand** using a combination of tools like mips_to_c.py and asm-differ, looking at the raw assembly code and tweaking the output until it compiles to the same assembly as the input. Ghidra was NOT used and is frankly a very poor tool for the job. If you’re part of the N64 decompilation community or have talked to some of the people involved, you would be aware of this.

    Modern Vintage Gamer was notorious for having said a similar thing and causing a huge influx of newbies asking “how do I use Ghidra to decompile (insert random N64 game here)”. This caused massive frustration throughout the community, who had to repeatedly tell them that it was done painstakingly by hand, and not with Ghidra.

      1. So in that comment, he seems to be saying specifically why tools like Ghidra **can’t** be used, most likely because newcomers often ask us if it can be. He’s saying that tools like Ghidra don’t work for our purposes and that being able to read, interpret, and manipulate the assembly yourself is absolutely mandatory. Ryan rears his head occasionally in our decomp group chat and we’re familiar with how he’s gone about the project and what went into it.

    1. Don’t start a comment discouraging hackers not to guess how something works or is done. It’s ingrained in how we approach everything, and we’re always open to facts to update our guesses. Your insights are helpful, but the condescension is not.

      1. No, it’s understandable if someone’s hard work is made to sound like they just used an automated tool, they get upset. Especially with such work, the recognition of the work put in is the only reward there is.

        1. They don’t care that much about their work I don’t see them out on street corners trying to sell copies of it.
          If Nintendo truly cared about copyright then a) they would be reprinting old cartridges and b) supporting the ROM community in some form of legal way.
          All Nintendo has shown us is it has nothing original to offer us and no creativity anymore.

  5. For the people talking about “Big N being GrUmPy” or shutting down the project: Microsoft owns the copyrights for Perfect Dark and they’re somewhat friendly to projects like this if they avoid making money out of it.

    Stop involving Nintendo’s name in this.

  6. Music artists and Programmers have so much in common, both have the misbegotten belief that because they worked a weekend straight through one time, the world should then, for some reason pay them forevermore.

    1. Yup and that’s the thing Nintendo as a company to day isn’t relevant. It’s the same ol game over and over again how many times has N made Mario, 75 times? In one form or the other…
      The old original games were relevant who cares anymore about Super mario Bros 45.
      Nintendo will probably eventually just wither away and die.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.