Light gun detection, calibration via PPU H/V counters, and fire tracking with a red dot sprite.
| Input | Action |
|---|---|
| Fire (trigger) | Calibrate aim / mark hit position |
| Pause | Return to calibration screen |
| Cursor | Advance to ready state |
Then open superscope.sfc in your emulator (Mesen2 recommended). Enable Super Scope in Mesen2 Input settings, port 2.
OBJSEL() to configure sprite sizes and VRAM base in one readable macroMode 0 gives four 2bpp BG layers. We use BG1 for text and BG2 for the calibration target image.
The built-in 2bpp font is loaded to VRAM $0000. BG1's tilemap sits at $3800 to avoid conflicts with BG2 graphics.
The crosshair target image is a 256x224 background. Tiles at $1000, tilemap at $2000.
The OBJSEL() macro replaces the cryptic 0x62 with a readable size + base address. OBJ_SIZE16_L32 means small=16x16, large=32x32. The sprite sheet has the red dot at tile 0x80 (pixel position 0,64 in the 128-wide sheet).
Writing directly to oamMemory[] avoids the overhead of oamSet() (framesize=158). For a single sprite updated occasionally, this is clean and fast.
The example uses three states:
scopeInit() each frame until scopeIsConnected() returns truescopeCalibrate() to set the aim offsetscopeGetX()/scopeGetY() on fire events and moves the red dotThe fire_armed flag prevents the calibration fire from immediately re-triggering in the next state (debouncing).
quantize()) to control which colors are preserved.row * 32 + col * 2. Use gfx4snes --sprite-map to print the full tile map and find the right tile number.0x62 means "16/32 sizes at VRAM $4000", use OBJSEL(OBJ_SIZE16_L32, 0x4000).| Module | Why it's here |
|---|---|
console | VBlank/NMI handling |
input | Super Scope detection and reading |
sprite | oamInit(), oamClear() |
dma | DMA transfers for tiles, maps, palettes |
text | Font loading and text rendering |
background | bgSetGfxPtr(), bgSetMapPtr(), bgSetScroll() |
| Register | Address | Role in this example |
|---|---|---|
| OBJSEL | $2101 | Sprite size + tile base address |
| CGADD | $2121 | Palette write address |
| CGDATA | $2122 | Palette color data (RGB555 LE) |
| TM | $212C | Main screen layer enable |
| OPHCT | $213C | PPU horizontal counter (Super Scope X) |
| OPVCT | $213D | PPU vertical counter (Super Scope Y) |
| File | What's in it |
|---|---|
main.c | State machine, sprite control, text display |
data.asm | .incbin references for background and sprite graphics |
res/ | Pre-converted graphics (.pic, .pal, .map) and source PNGs |
Makefile | LIB_MODULES := console input sprite dma text background |