From a symptom to its cause. The SNES fails quietly, so many symptoms below lead to an entry of Known Limitations, the catalogue of silent failures: this page names the trap, that one explains it.
Build Issues
"OPENSNES not defined" or "No rule to make target 'common.mk'"
Cause: The Makefile can't find the OpenSNES installation.
Fix: Set OPENSNES in your Makefile, or pass it on the command line:
# Option 1: in the Makefile (recommended for project portability)
OPENSNES := /path/to/opensnes
# Option 2: on the command line (make reads variables, not OPENSNES_HOME)
make OPENSNES=/path/to/opensnes
OPENSNES_HOME is read by the opensnes CLI only, not by make.
Empty compiler/ directories or "cc65816 not found"
Cause: Submodules weren't cloned.
Fix:
cd /path/to/opensnes
git submodule update --init --recursive
make compiler
"wla-65816: command not found"
Cause: Compiler toolchain not built.
Fix:
cd /path/to/opensnes
make compiler
"clang: command not found" or "cc: command not found"
Cause: Missing host C compiler.
Fix (by platform):
# macOS
xcode-select --install
# Ubuntu/Debian
sudo apt install clang
# Fedora
sudo dnf install clang
# Windows MSYS2 (UCRT64)
pacman -S mingw-w64-ucrt-x86_64-clang
Build fails with "refusing to emit silently-wrong code"
Cause: The code uses a C feature the 65816 backend does not lower. The message names it: a struct passed or returned by value, a struct copied to or from a FAR object, a variadic function, or inline assembly (asm). Plain struct assignment (a = b;) works.
Fix: pass a pointer to the struct, copy it field by field (or with a loop), give the function a fixed argument list, or move the assembly into a .asm file of the project. 32-bit arithmetic (u32, s32, *, /, %, shifts) is supported and tested — prefer u16 for speed, not for correctness.
Runtime Issues (Black Screen / Crash)
ROM loads but screen is black
This is the most common issue. Causes and fixes:
1. Missing setScreenOn()
void setScreenOn(void)
Enable screen display.
2. No VBlank loop
while (1) {
}
void WaitForVBlank(void)
Wait for next VBlank period.
3. Console not initialized
void consoleInit(void)
Initialize SNES hardware.
4. A DMA under setBrightness(0)
setBrightness(0) darkens the picture but is not forced blank: the PPU still rejects VRAM writes. Upload under setScreenOff().
5. C variables past the 8 KB RAM band
Plain C variables must sit in $0000-$1FFF; a large buffer belongs in far RAM (FAR, see Far RAM). The build checks it after every link and stops when the band overflows; opensnes-rom check game.sfc prints how much of it is left, and opensnes-rom budget game.sfc what uses it.
A big buffer behaves strangely
Same cause as above: a plain C global past $2000 is wrong-banked. Declare bulk buffers FAR (Far RAM Tutorial — FAR objects beyond the 8 KB band; the RAM entry of Known Limitations).
A const array reads garbage
The const was cast away and the data read through a plain pointer. C const data lives in the asset banks and every C read of it is a far read; a plain pointer reads bank $00 instead. Keep the const, or hand the data to a library function that takes a far pointer. The build's bank-blind read check fails the link when the read names its symbol; it does not see a plain pointer that travels (stored, or passed to a function in another file, then read there), whose read is silently wrong. The bank $00 entry of Known Limitations has the details.
ROM runs but crashes after a few seconds
Causes:
- Stack overflow - Too many function calls or large local arrays
- DMA during active display - Only do DMA in VBlank
- Uninitialized pointers - C doesn't zero local variables
Debug:
- Use luna to see where it crashes (run_until_pc / state over MCP — see the debugging tutorial)
- Check the call stack depth
- Look for NULL pointer dereferences
Sprites don't appear
Checklist:
sprite_pal, sprite_pal_end - sprite_pal,
void oamInit(u16 size, u16 name_base)
Initialize the sprite (OAM) system.
#define OAM_DEFAULT_SIZE
Default sprite size mode — small=8×8 / large=16×16.
Definition sprite.h:211
#define OAM_DEFAULT_TILE_BASE
Default sprite tile base — 0 = tiles at VRAM word $0000.
Definition sprite.h:213
void oamSet(u16 id, u16 x, u16 y, u16 tile, u16 palette, u16 priority, u16 flags)
Set sprite properties.
#define OBJ_SIZE8_L16
Sprite size indices (for oamInit, oamInitGfxSet).
Definition sprite.h:52
void oamInitGfxSet(const u8 *tileSource, u16 tileSize, const u8 *tilePalette, u16 paletteSize, u8 paletteEntry, u16 vramAddr, u8 oamSize)
Initialize sprite graphics and palette (PVSnesLib compatible).
A sprite renders as background garbage
oamInit's second argument is a name-base page number (0-7), not a VRAM address. Pass OBJ_NAME_BASE(addr) rather than the address.
A sprite appears where no entity is
Off-camera OAM coordinates wrap around the screen. Hide a sprite that left the view with oamHide(); oamPlaceWorld() culls for you (Sprites & Animation Tutorial).
Sprites have the wrong colours
Sprite palettes start at CGRAM entry 128, not 0: palette 0 of the sprites is entries 128-143. A palette loaded at 0 colours the backgrounds instead.
Controller input not working
Checklist:
unsigned short u16
16-bit unsigned integer (0 to 65535)
Definition types.h:53
Audio not playing
For basic audio:
u8 audioInit(void)
Initialize the audio system.
u8 audioPlaySample(u8 sampleId)
Play a sample with default settings.
u8 audioLoadSample(u8 id, const u8 *brrData, u16 size, u16 loopPoint)
Load a BRR sample into SPC700 RAM.
For SNESMOD:
while (1) {
}
void snesmodSetSoundbank(u8 bank)
Set the soundbank bank number.
void snesmodInit(void)
Initialize SNESMOD audio engine.
void snesmodPlay(u8 startPosition)
Start module playback.
void snesmodLoadModule(u16 moduleId)
Load a module from the soundbank.
void snesmodProcess(void)
Process audio commands.
Graphics Issues
Wrong colours / garbled palette
Cause: BGR555 format mismatch.
SNES uses BGR555 (5 bits blue, 5 green, 5 red), not RGB. Let the converter write the palette from an indexed PNG:
opensnes-sprite sheet res/sprite.png --size 16 --colors 16 # sprites
opensnes-tileset convert res/bg.png --colors 16 # backgrounds
(or the same settings in res/sprite.png.toml, which the build runs for you).
Colours shift when you add a tile
The converter derives the whole palette again from the new art. Author a fixed palette and impose it: palette = "fixed.pal" in the asset's settings file (The opensnes-* tools: conventions).
Tiles appear corrupted, or an upload only partly lands
Causes:
- VRAM written during the picture: the PPU drops it without an error. Upload in VBlank or under setScreenOff()
- Over the ~4 KB of DMA a VBlank holds: split the upload across frames or do it under forced blank
- Wrong tile format (2bpp vs 4bpp vs 8bpp)
- VRAM address overlap
- DMA transfer size mismatch
The first two are the first two entries of Known Limitations.
Check your graphics mode:
void bgInitTileSet
Definition background.h:209
#define BG_MODE1
Definition video.h:39
void setMode(u8 mode, u8 flags)
Set background mode.
Scrolling is jerky or tears
Cause: Writing BGnHOFS / BGnVOFS directly during the frame: the top of the picture uses the old value, the bottom the new one.
Fix: use bgSetScroll(). It only records the position, and the NMI handler writes it during VBlank. Set it before WaitForVBlank(), with the rest of the frame's logic, so it is shown on the next frame:
while (1) {
scrollX += 1;
}
void bgSetScroll(u8 bg, u16 x, u16 y)
Set background scroll position.
See Scrolling for per-line scroll (HDMA parallax).
Everything is one line off vertically
The library already subtracts the 1 that the PPU's missing scanline 0 requires (bgSetScroll, the map module, mode7SetScroll). Pass the row you want; keep your own -1 only in data that reaches the register without the library, such as an HDMA table on BGnVOFS. A PVSnesLib port that passed y - 1 itself ends up one line off. The vertical scroll entry of Known Limitations has the details.
Memory Issues
"ROM too large" or linker errors about size
Cause: Too much data in your ROM.
Check ROM size:
Solutions:
- Compress graphics
- Use smaller audio samples
- Split into multiple banks (advanced)
Variables have wrong values
Check symbol placement:
grep "my_variable" game.sym
- Good (RAM): 00:0234 my_variable
- Bad (ROM): 00:8234 my_variable
If it's in ROM ($8000+), you can't write to it.
Getting More Help
Diagnostic Commands
# The post-link checks: bank $00, the RAM bands, bank-blind reads
# (on game.sym when the build refused the ROM: a refused .sfc is deleted)
opensnes-rom check game.sfc
# What the game uses of ROM, RAM, VRAM and CGRAM
opensnes-rom budget game.sfc
# View symbol map
cat game.sym | grep "variable_name"
# Inspect ROM header
xxd -s 0x7FC0 -l 32 game.sfc
# Check ROM size
ls -la game.sfc
Interactive debugging with luna
See the debugging tutorial for the full workflows (who-writes-this-variable, break-at-function, OAM shadow-vs-hardware, poke and observe). A third-party GUI debugger also works:
Using Mesen Debugger (alternative)
- Load ROM in Mesen
- Tools → Debugger
- Set breakpoint at your code
- Step through and watch registers/memory
Reporting Bugs
Include in your issue:
- OpenSNES version (git rev-parse HEAD)
- OS and compiler version
- Minimal code that reproduces the issue
- Error messages (full output)
- What you expected vs what happened