The setup week. Install Mesen, run a homebrew NES game, understand the difference between emulator and hardware. You start the week curious; you end the week with software you built familiarity with running real ROMs on your laptop.
Theme
An emulator is a program that pretends to be another computer. When you run an NES game on your laptop using Mesen, Mesen is reading the bytes of the game cartridge file (the ROM) and faithfully simulating what an actual Nintendo Entertainment System would do with those bytes: drawing the pixels, playing the sounds, watching for button presses, advancing the game's clock 60 times a second.
This week you install three free emulators (Mesen for NES, SameBoy for Game Boy, bsnes-plus for SNES, you will use the latter two in week 5). You download a homebrew ROM (a game written by a hobbyist and shared freely online) and run it. By the end of the week you can boot a ROM, take a screenshot, and explain in plain English what just happened when you double-clicked the file.
This is the foundation. Every subsequent week assumes you know how to load a ROM into an emulator and observe what happens.
Reading list (~45 minutes)
- NESdev wiki: "Cartridge connector" at
wiki.nesdev.org/w/index.php/Cartridge_connector, a brief tour of what an NES cartridge actually contains and how it talks to the console. - NESdev wiki: "INES file format" at
wiki.nesdev.org/w/index.php/INES, the file format that ROM dumps use. You will hex-view this in week 2; reading the overview first prepares you. - Mesen documentation: "Getting Started" at
mesen.ca/docs, the practitioner overview of the emulator you are installing this week.
Lecture outline (~1.5 hours)
Section 1: What is a video game cartridge, actually?
- A cartridge is a plastic case around a circuit board
- The circuit board carries a ROM chip (read-only memory) and sometimes a few other parts
- The ROM chip stores the bytes of the game: the code that runs, the graphics, the sounds, the level data
- The console reads bytes out of the ROM as the game plays
- A "ROM dump" is a file containing the bytes from a real cartridge's ROM chip, captured by a hardware tool called a cartridge reader
Section 2: What is an emulator, actually?
- An emulator is a program that simulates the console
- Mesen simulates the 6502 CPU that the NES used
- It simulates the Picture Processing Unit (PPU) that drew the graphics
- It simulates the Audio Processing Unit (APU) that played the sounds
- It simulates the cartridge slot, the controllers, even the TV display
- When you load a ROM file into Mesen, the emulator pretends to be a real NES that has that cartridge plugged in
- The emulator runs at the same speed the real hardware did (60 frames per second on NTSC)
The three-stage pipeline this lists (ROM file → simulated chips → pixels on screen) is illustrated as a scrolling explainer in Visual Helper 1 below; if any of the CPU / PPU / APU split feels abstract, scroll through it before moving on.
Section 3: Why does this work?
- Emulation works because computers can simulate other computers
- The simulator does not need to be the same kind of computer as the simulated one
- Your laptop has a CPU that is thousands of times faster than the 6502; this means it can simulate a 6502 (and a PPU, and an APU, and a cartridge slot) with cycles to spare
- The simulation is faithful enough that real NES games run correctly inside Mesen
- This is the same idea that makes virtual machines work for modern computing: one computer pretending to be another
Section 4: What is a ROM hack?
- A ROM hack is a modified version of a ROM file
- A hacker changes some of the bytes of the ROM, then loads the modified ROM into the emulator
- The emulator does not know or care that the ROM is modified; it just runs whatever bytes it is given
- This is how people have modified classic games for decades: change the byte that says "your character's hat is red," to a byte that says "your character's hat is blue"
- In week 4 you make your own ROM hack. This week you learn the foundation: how to run an unmodified ROM faithfully
Section 5: Legal vs illegal ROMs
- It is legal to dump a ROM from a cartridge you own. The legal status of distributing dumps you did not make yourself varies by country and by what game; if you do not own the cartridge, do not download the ROM.
- It is legal to download and modify open-source homebrew ROMs released by their creators under a permissive license. We will use homebrew ROMs throughout this course.
- Examples of legal homebrew ROMs you can download right now: most of the NESdev competition entries on the NESdev wiki; many entries on
itch.iounder "NES homebrew"; the Roth Brothers homebrew compilation. - We do NOT download commercial-game ROMs in this course. The academy's commitment is that everything you do in SPK-101 is unambiguously legal, regardless of where you live.
The in-browser Lan Master demo in Visual Helper 2 below is exactly this kind of permissive-license homebrew: Shiru released it for the 2011 NESdev Coding Competition under terms that let you play, copy, and redistribute it freely, consistent with this course's commitment to unambiguous legality.
Labs (~4 hours)
Two labs this week.
Lab 1.1: Install Mesen and run your first ROM (labs/lab-1-1-install-mesen.md)
- Goal: Mesen is installed, a homebrew ROM is downloaded, and you have it running with sound and graphics
- Time: ~90 minutes including download and any troubleshooting
- Artifact: a screenshot of the homebrew ROM running, plus the file path of the ROM on your laptop
Lab 1.2: Tour the Mesen interface (labs/lab-1-2-mesen-tour.md)
- Goal: You can pause, reset, save state, load state, take a screenshot, change controller mappings, and find the debugger menu (you will use the debugger in week 3)
- Time: ~90 minutes
- Artifact: a short reflection note (~150 words) in your lab journal explaining what each menu does
Independent practice (~2.5 hours)
Free exploration with the emulator. Recommended exploration paths (pick any one or two):
- Play with controller mappings. Try the keyboard-default mapping, then try plugging in a USB game controller (an Xbox or PlayStation controller works on Windows / macOS / Linux). See if the game feels different with a real controller.
- Try save states. Pick a hard moment in your homebrew ROM. Make a save state right before the hard moment. Try the moment over and over loading the save state each time. Notice how this lets you experiment with strategies you would not try without save states.
- Find another homebrew ROM and try it. The NESdev wiki has a "Game development competition" section; many entries are free downloads. Try one or two.
- Read the Mesen menus you have not opened yet. What does "Video options" do? What does "Audio mixer" do? Open them. Change a setting. Change it back.
Reflection prompts (~30 minutes)
Journal these at week's end. There are no wrong answers; the journal is for your own learning, not for grading.
- Before this week, what did you think an emulator was? After this week, has your understanding changed?
- The lecture mentioned that an emulator simulates the CPU, the PPU, the APU, and the cartridge slot. Which of these did you find easiest to understand? Which was hardest?
- You ran a ROM file this week. The ROM is a sequence of bytes. The emulator turns those bytes into pictures and sounds. Roughly, what do you think the emulator is doing during the gap between the bytes-on-disk and the pixels-on-screen?
- The course asks you to use legal ROMs only. Why do you think the academy cares about this?
- What is one question you have after this week that you hope week 2 will answer?
Visual Helpers
This week introduces the idea that a ROM is a sequence of bytes. Bytes, addresses, and the difference between the two become more important starting in Week 2.
If you are working through this course independently and find yourself confused when numbers like "byte offset 0x0010" come up, turn to the cognitive tools supplement. The Mailbox metaphor section there gives you a concrete picture of what an address is and why it is different from a value. You do not need it yet, but it is worth reading before Week 2's labs.
There are two visual helpers this week. Read this short framing first; then scroll through them in order.
Visual Helper 1 is a scrolling explainer of the emulator pipeline. Before you install Mesen, watch the bytes flow: from the .nes file on disk, through the simulated 6502 + PPU + APU inside the emulator, out to the pixels on your laptop screen. The three scenes match the structure of Sections 2 and 3 of the lecture above.
Visual Helper 2 is a small NES emulator running directly in this page, pre-loaded with Lan Master, a public-domain puzzle game by Shiru. You can play a real NES game here without installing anything. The point is not finishing the puzzle; the point is to feel an emulator running before you spend an hour installing one yourself.
Once you have run the in-browser demo and finished the labs, week 4 picks up where this week stops. You will open the same kind of homebrew ROM in a hex editor, change some of its bytes, and watch the change appear in Mesen. The week 4 Visual Helpers section has in-browser versions of those edits, so you can practice the find-byte change-byte verify-change loop without leaving the browser. See Week 4: ROM Hacking Visual Helpers when you reach that week.
Visual Helper 1: Emulator as a pipeline
The lecture says an emulator "reads the bytes of the cartridge and faithfully simulates what an actual NES would do with those bytes." The three scenes below make that pipeline visible. Scroll through them; each one highlights as it comes into view, and the figure on the right side of each scene animates the part of the pipeline that scene describes.
An emulator is a program that pretends to be another computer. The pipeline has three stops: the ROM file on disk, the emulator program running on your laptop, and the pixels on the screen. The emulator reads bytes from the ROM, simulates what the NES would do with those bytes, and writes pixels into a window on your laptop sixty times a second.
Three boxes, two arrows. The ROM never moves. The emulator reads the ROM the way a real NES would read a cartridge. The pixels appear on your laptop the way they would on a CRT television.
Zoom in on the middle box. The emulator is not one program doing one thing; it simulates each of the chips on the NES separately and runs them in lock-step. The 6502 CPU reads opcodes from the ROM and runs them. The Picture Processing Unit draws pixels into a frame buffer. The Audio Processing Unit generates the waveforms you hear. Each one is a few thousand lines of JavaScript (or C, or Rust) modeling what the real silicon would do.
Three threads of work, one for each chip the real NES carried. The emulator runs them in lockstep so the CPU's writes to the PPU memory map land at exactly the same moment they would on hardware. Week 5 opens up the PPU and APU at depth.
Simulation is expensive. Doing the work of a 6502 CPU in JavaScript instead of in dedicated silicon takes more cycles. But your laptop has so many cycles to spare that the emulator finishes its NES-second of work in much less than a real second. The NES clocks its CPU at 1.79 megahertz (1.79 million cycles per second). A modern laptop runs at 3 to 4 gigahertz (3 to 4 billion cycles per second). That ratio is roughly two thousand to one. Even with the simulation overhead, the emulator has plenty of headroom to keep up with the NES at full speed.
Roughly two thousand laptop CPU cycles for every NES CPU cycle. The emulator runs at NES speed (60 frames per second) and has cycles left over for the browser, your editor, and the dozen other tabs you have open.
Visual Helper 2: Try a homebrew ROM right here
You are about to install Mesen and run a ROM. Before you do, here is a small NES emulator running directly in your browser, pre-loaded with Lan Master, a public-domain puzzle ROM written by Shiru for the 2011 NESdev Coding Competition. You can play it without installing anything; the same kind of emulator you will install this week runs in JavaScript on the page below. The keyboard maps to a standard NES gamepad; on a phone, the on-screen buttons stand in for the gamepad.
The goal of Lan Master is to rotate pipe pieces so every computer on the grid is connected before the timer runs out. Use the D-pad to move the cursor and A to rotate. The point is not to finish the puzzle; the point is that a real NES game is running on your laptop right now without you installing anything. The lab this week walks you through installing Mesen so you can do the same thing for any homebrew ROM you find online.
What comes next
Week 2 takes you inside the ROM. You open the same file you ran this week, but in a hex editor instead of an emulator. You look at the bytes directly. You will see the INES header (the first 16 bytes of every NES ROM file), the program code section, and the graphics data. By the end of week 2 you can point to a specific byte and say "that byte is part of the sprite for the main character."
All technical terms used here are in the glossary.