Write NES games in C# with .NES and run them in an emulator
GitHub RepoImpressions54
View on GitHub
@githubprojectsPost Author

Write NES Games in C#? Yes, With .NES

You’ve probably seen a thousand “write X in Y” projects, but this one hits different. What if you could build a real NES game using modern C# and then run it in an actual emulator? No weird DSLs, no custom bytecode—just C# compiled down to 6502 assembly. That’s exactly what .NES does, and it’s surprisingly practical.

What It Does

.NES is a source-to-source compiler that takes C# written with a specific set of constraints and outputs a valid NES ROM file. You write game logic in C# using a custom NES namespace, compile it with the dotnes tool, and get a .nes file you can load into any NES emulator.

Under the hood, it translates your C# into 6502 assembly, the native CPU of the NES. It handles memory mapping, PPU registers, and all the weird NES hardware quirks so you don’t have to. Think of it as a high-level framework for a 40-year-old console.

Why It’s Cool

First, it’s not a toy. The compiler is serious about mapping C# constructs to 6502. You get loops, conditionals, and even simple object allocations. It’s not C# in the full .NET sense—no garbage collection, no LINQ—but the core logic feels familiar.

Second, debugging is actually possible. You can write unit tests in C# for your game logic, which is a huge win over raw assembly. The project also includes a debug build that outputs a .lst file with the generated assembly, so you can see exactly what your code becomes.

Third, the retro dev experience is pure gold. You’re working with palettes, sprites, scanlines, and the NES’s bizarre tile-based graphics. But you’re doing it in Visual Studio with intellisense. It’s a wild mix of modern DX and vintage constraints.

How to Try It

You need the .NET 8 SDK or later. Then install the tool:

dotnet tool install --global dotnes

Create a new project (or clone the repo’s examples):

mkdir MyGame
cd MyGame
dotnet new console

Replace Program.cs with something like:

using NES;

class Program : NESApplication
{
    static void Main()
    {
        var nes = new NESConsole();
        nes.SetBackgroundColor(0x21); // light blue
        while (true)
        {
            // Game loop
        }
    }
}

Compile and generate the ROM:

dotnes build -o MyGame.nes

Open MyGame.nes in any NES emulator (like FCEUX or Mesen) and you’re playing on actual NES hardware (emulated).

For a full working example, check the samples folder on GitHub.

Final Thoughts

.NES isn’t something you’d ship a commercial game with—the NES doesn’t have a GC, and the C# abstraction will always have overhead. But for learning how old consoles work, for game jams, or just for the sheer fun of seeing your C# run on a 1985 machine, it’s fantastic.

If you’re into retro dev or just like playing with constraints, give it a spin. You’ll either build something cool or at least appreciate how much easier modern tooling is.


Found this interesting? Follow us at @githubprojects for more dev tools and open source discoveries.

Back to Projects
Last updated: June 17, 2026 at 02:21 PM