Atari 2600 Emulation & Debugging with Stella
In this article
This guide shows you how to use Stella, the most mature Atari 2600 emulator, to run classic games and, more importantly, debug your own homebrew or hacked ROMs. Stella includes a built-in debugger that lets you step through 6502 assembly code, inspect memory and registers, and watch the TIA (Television Interface Adaptor) chip's graphics state in real time. You'll need a ROM file (.bin or .a26) to get started—either a commercial game dump or your own compiled source code.
What You'll Need
- A computer running Windows, macOS, or Linux.
- The latest Stella release (download from the official Stella GitHub page).
- A ROM file to load. For debugging, a ROM with symbols (a .sym file) or debug info is helpful.
- Basic familiarity with 6502 assembly language (for debugging).
Step-by-Step
-
Install Stella.
- Windows: Run the installer .exe and follow the prompts.
- macOS: Open the .dmg and drag Stella to Applications.
- Linux: Use your package manager (e.g.,
sudo apt install stellaon Debian/Ubuntu) or build from source.
-
Launch Stella and load a ROM.
- Open Stella. You'll see a file browser dialog.
- Navigate to your ROM file and double-click it, or select it and press Enter.
- The game should start running immediately.
-
Access the debugger.
- While the game is running, press the backtick key (
`) or theTabkey (depending on your keyboard layout) to enter the debugger. - You'll see a prompt at the bottom of the screen. This is the debugger console.
- Type
helpand press Enter to see a list of available commands.
- While the game is running, press the backtick key (
-
Set breakpoints.
- Breakpoints pause the emulator when a specific address is executed or accessed.
- To break on execution of address
$F000, typebreak $F000. - To break on read or write to a memory location, use
breakread $80orbreakwrite $80. - You can list active breakpoints with
breaklistand clear them withclearbreaks.
-
Step through code.
- When the emulator pauses (at a breakpoint or via
pause), you can step one instruction at a time. - Use
step(or just presss) to execute one instruction. - Use
trace(ort) to step into subroutines. - Use
run(orr) to continue running until the next breakpoint.
- When the emulator pauses (at a breakpoint or via
-
Inspect CPU and memory.
- Type
cputo see the current register values (A, X, Y, PC, SP, flags). - To view memory, type
memoryfollowed by an address range, e.g.,memory $80 $9F. - To set a memory value, use
poke $80 #$1A(writes hex value 1A to address 80). - To read a specific address, type
peek $80.
- Type
-
Watch TIA state.
- The debugger shows a graphical view of the TIA registers on the right side.
- You can also type
tiato get a text dump of all TIA registers. - Use
scanlineto see the current scanline and cycle count.
-
Use the built-in cheat system (optional).
- Type
cheatto open the cheat code manager. - You can add RAM or ROM cheats to test game behavior.
- Type
Common Mistakes
- Using the wrong breakpoint type: A common error is using
breakwhen you want to break on a memory access.breakonly stops on instruction execution at that address. - Forgetting to load symbols: If you have a .sym file, load it with
loadsym file.symbefore debugging. Otherwise, you'll see raw addresses instead of labels, making code much harder to follow. - Not pausing before stepping: You can't step while the game is running. Always pause first (with the backtick or
pausecommand). - Misreading hex values: Stella uses hex by default. If you type a decimal number without a prefix, it's interpreted as hex. Use
#for decimal (e.g.,poke $80 #100).
Tips
- Use the built-in disassembler: Type
disasm $F000 $F010to see disassembled instructions in that address range. - Save and restore debugger states: Use
savestateandloadstateto save a snapshot of your debugging session. - Use the watch window: Type
watch $80to add an address to the watch list. It will be displayed and updated in the debugger's right panel. - Learn the keyboard shortcuts: In the debugger,
F5runs,F6steps,F7steps over, andF8steps out. These save time compared to typing commands. - Use the scanline indicator: The bottom bar shows the current scanline (e.g., 50). This is crucial for debugging timing-sensitive code like kernel routines.
Troubleshooting
- Game won't load: Ensure the ROM file is not corrupted and is a valid Atari 2600 ROM. Try loading it in another emulator to verify. If it's a homebrew, check that it's compiled for the correct bank-switching method.
- Debugger doesn't open: The backtick key might be remapped. Check the input settings in the Options menu. You can also type
debuggerat the main Stella prompt (if you have the command-line version). - Breakpoints not hitting: Make sure the address is correct. If you're using symbols, verify the symbol file loaded correctly with
listsym. Also, check if the code is running in a different bank—you may need to set a breakpoint on the bank-switch address. - Registers show unexpected values: This often happens when the game uses undocumented opcodes or illegal memory accesses. Use the
undefcommand to check for undefined opcodes in your code. - Stella crashes on startup: Try deleting the Stella configuration file (usually in
~/.stellaon Linux/macOS or%APPDATA%\Stellaon Windows) and restarting.
Frequently Asked Questions
- Can I use Stella to debug commercial games? Yes, but you'll only see raw assembly without symbols. You can still set breakpoints and inspect memory, but it's more challenging.
- How do I load a symbol file? In the debugger, type
loadsym /path/to/file.sym. Stella also auto-loads .sym files if they have the same name as the ROM and are in the same directory. - What is the difference between 'step' and 'trace'?
stepexecutes one instruction and stops. If that instruction is a JSR (jump to subroutine),tracewill step into the subroutine, whilestepwill step over it (treating it as a single instruction). - How can I see the current frame's graphics? The debugger's TIA tab shows a visual representation of the playfield, sprites, and missiles. You can also use the
screenshotcommand to save an image. - Can I set a breakpoint on a specific scanline? Yes, type
breakscanline 100to break when the scanline counter reaches 100. This is very useful for debugging kernel timing. - Is there a way to step backwards? No, the debugger is forward-only. However, you can use
savestatebefore a critical section andloadstateto go back to that point.