OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
API index — by what you are trying to do

Doxygen lists the SDK by module, which only helps once you know the module's name. This page goes the other way: what you want → what to use → an example that does it.

It exists because that gap has a cost. While writing the RPG template the author re-implemented collideTile() by hand, wrote a sprite-culling helper without noticing oamHide(), hand-rolled scene switching without noticing <snes/scene.h>, and missed the example that already demonstrated the Tiled pipeline (now examples/maps/map_scroll). All four were in the tree. If you are about to write a helper, scan this page first.

Modules are opt-in: add the name to LIB_MODULES in your Makefile and nothing you do not list is linked (SRAM and SNESMOD are switched on with USE_SRAM := 1 and USE_SNESMOD := 1 instead).

Getting something on screen

I want to… Use Module Example
print text textModeInit, textPrintAt text text/print_string
show a background from a PNG bgInitTileSet, bgSetGfxPtr, bgSetMapPtr background backgrounds/mode1
bundle a tileset + its palette as one thing BgAsset, DECLARE_BG_ASSET, bgLoad asset backgrounds/mode1
draw a sprite oamInit, oamSet, oamUpdate sprite sprites/simple_sprite
draw a sprite whose attribute byte (flip, priority, palette) the game keeps composed oamSetAttr, OAM_ATTR sprite sprites/animated_sprite
hide a sprite that left the screen, or a run of them oamHide, oamHideRange sprite demos/rpg
animate a sprite AnimClip, animPlay, animTickOam anim sprites/animated_sprite
draw one character out of many tiles oamDrawMetasprite, MetaspriteItem, MetaspriteStyle sprite sprites/aseprite_pipeline
make a tile while the game runs (procedural art) tileEncode2bpp, tileEncode4bpp, tileEncode8bpp tile sprites/sprite_swarm
compose text at the pixel in a 2bpp layer (a proportional font, a label at any x and y) tileBlitGlyph2bpp tile text/pixel_text

Moving around a world

I want to… Use Module Example
scroll a background bgSetScroll background scrolling/parallax_scroll
scroll a map bigger than VRAM mapLoad, mapUpdate map maps/map_scroll
load a map made in Tiled opensnes-level → .m16/.b16 map maps/map_scroll
ask whether a tile is solid collideTile (collideTileEx for 16- or 32-pixel tiles) collision basics/collision_demo
ask whether two boxes overlap collideRect collision basics/collision_demo
handle slopes objCollidMapWithSlopes + per-tile attributes object demos/platform_objects
place the sprite so collision feels right the straddle convention — collision tutorial

Input

I want to… Use Module Example
read a joypad padHeld, padPressed input input/controller
read two players padHeld(0) / padHeld(1) input input/controller
read a mouse or Super Scope mouse* / scope* input input/mouse

Structuring a game

I want to… Use Module Example
a main loop you do not write gameLoopRun gameloop input/controller
title → play → pause, without a state enum Scene, scenePush, scenePop scene basics/scene_stack
save the player's progress sramSave, sramLoad USE_SRAM := 1 memory/save_game
a dialog box or a status bar panelDraw, panelPut, panelFlush panel demos/rpg

Sound

I want to… Use Module Example
play music from a tracker module snesmod* USE_SNESMOD := 1 audio/snesmod_music
play a sound effect audioPlaySample audio audio/soundboard

Effects

I want to… Use Module Example
fade in or out fadeIn, fadeOut (the program waits), fadeStart + fadeStep (a step per frame, the loop free) console transitions/fading
blend two layers colormath* colormath color/transparency
mask part of the screen windowSet* window windows/window
change a register mid-frame hdmaSetup, hdmaEnableMask hdma windows/window_multi_hdma
rotate or scale a background mode7* mode7 mode7/mode7_racing
pixelate mosaicSetLayers, mosaicFadeIn mosaic transitions/fading

Moving data around

I want to… Use Module Notes
upload tiles or a tilemap dmaCopyVram dma VBlank fits ~4 KB; more needs setScreenOff()
upload a palette dmaCopyCGram dma the source may live in any bank
set one colour setColor console sprite palettes start at CGRAM 128
cycle a palette (waterfall/fire/lights) setColor, dmaCopyCGram dma color/palette_cycle — animate with zero VRAM traffic
darken or colour-cast a whole scene (night/underwater/sunset) colorMathShadow, colorMathTint colormath color/shadow_tint
draw a HUD / dialog box (9-slice) panelInit, panelDraw, panelPut, panelFlush panel basics/panel_hud
structure a whole game (title/play/over) frame loop + switch(state) — basics/game_skeleton
structure a game in several files (a screen layer, a checksummed save, a test per screen) fadeStart, fadeStep, vramQueuePush, sramLoad, sramSave vramqueue, sram games/shard_dash
scroll each column independently (flag ripple, heat-haze) offset-per-tile, setMode(BG_MODE2) + BG3 offset table background backgrounds/mode2
send several small VRAM uploads in one VBlank (streamed sprite frames, map rows and columns) vramQueuePush, vramQueuePushWithin (the push that checks a budget you give), vramQueuePushSprite, vramQueuePushSpriteWithin (a whole sprite frame within your budget), vramQueueFlush, vramQueueFlushUntil (what ends before a scanline; the rest kept in order), vramQueueCost (what the queue will cost the VBlank) vramqueue DMA: several small uploads
place the sprites of a scrolling game (world coordinates, camera, culling; sorted by depth, two sizes in one order) oamPlaceWorld, OamWorldBatch sprite sprites: a scrolling game's sprites
write the OAM entries of N alike objects (bullets, particles) from arrays, in one call oamSetBatch, OamBatch sprite_batch (opt-in) sprites: a scrolling game's sprites
move many sprites at once oamMemory, oam_update_flag, oamSetFast sprite sprites/sprite_swarm — and its 60fps ceiling
decompress LZ77 tiles (into VRAM under forced blank, or into RAM of any bank with the screen on) lzssDecodeVram, lzssDecodeRam lzss memory/lzss_ram — about 100 master cycles per byte, 160 for tiles
copy, fill or compare memory and strings memcpy, memmove, memset, strlen, strcmp, strcpy, strncpy string FAR RAM: copying

3D math on the DSP-1 coprocessor

I want to… Use Module Notes
rotate + project points in 3D dsp1Attitude, dsp1Objective, dsp1Project (setup: dsp1SetCamera) dsp1 mode7/dsp1_ground — needs USE_DSP1 := 1
true 3D distance / sphere test dsp1Distance, dsp1Range dsp1 hardware sqrt — collision, LOD, homing
sin/cos scaled by a radius dsp1Triangle dsp1 16-bit angles (full turn = 2^16)
check the chip is there dsp1IsPresent dsp1 known-answer probe, never hangs

Going faster

I want to… Use Notes
more CPU SA-1 (USE_SA1=1) same 65816 ISA at 10.74 MHz — tutorial
polygons Super FX (USE_SUPERFX=1) GSU assembly only, no C compiler
fixed-point maths fixed32.h

The rest, by header

Functions the tables above do not name, each with the page that shows it in use. Anything not listed here or above is in the Doxygen reference of its header.

Header Functions Where it is explained
anim.h animRestart animation
audio.h audioPlaySampleOn, audioStopVoice, audioStopVoices, audioStopAll audio: choosing the voice
audio.h audioSetVolume, audioGetVolume, audioSetVoiceVolume, audioSetVoicePitch, audioSetVoiceVolumePitch, audioSetVoicePan audio: volume and pitch
audio.h audioSetADSR, audioSetGain audio: ADSR or GAIN
audio.h audioSetEcho, audioSetEchoFilter, audioEnableEcho, audioDisableEcho, audioReleaseEcho audio: echo
audio.h audioIsReady, audioCommandDone, audioGetFreeMemory, audioGetVoiceState audio: asking the engine
audio.h audioLoadSampleAt, audioLoadSampleBeginAt audio: a swap area
background.h bgInitTileSetData, bgInit graphics
collision.h rectSetPos, rectGetCenter collision
colormath.h colorMathSetChannel, colorMathSetBrightness, colorMathTransparency50, colorMathSetDirectColor colour math
console.h rngNext, rngSeed math: random numbers
console.h resetFrameCount animation
console.h isInVBlank DMA
console.h ppuReset game states: registers the previous screen left
debug.h consoleMesenBreakpoint, consoleNocashMessage (behind SNES_BREAK, SNES_NOCASH) debugging
hdma.h hdmaColorGradient, hdmaColorGradientStop, hdmaBrightnessGradientStop, hdmaIrisWipe, hdmaIrisWipeStop, hdmaWaterRipple, hdmaWaveInit, hdmaWaveStop, hdmaWindowShape, hdmaGetEnabled, hdmaDisableAll HDMA: ready-made effects
input.h padIsConnected input: is a pad plugged in?
input.h mouseInit, mouseIsConnected, mouseGetX, mouseGetY, mouseButtonsHeld, mouseButtonsPressed, mouseSetSensitivity, mouseGetSensitivity input: the mouse
input.h scopeInit, scopeIsConnected, scopeGetX, scopeGetY, scopeGetRawX, scopeGetRawY, scopeButtonsHeld, scopeButtonsPressed, scopeButtonsRepeat, scopeSetHoldDelay, scopeSetRepeatDelay, scopeSinceShot input: the Super Scope
interrupt.h nmiSet, nmiClear, nmiSetLag, irqSet, irqClear, irqSetHTimer, irqSetVTimer, irqEnable, irqDisable interrupts
math.h easeInQuad, easeOutQuad (module math_ease) math: easing curves
profile.h profileGetScanline profiling
snesmod.h snesmodGetPosition, snesmodFlush audio: following the music
sprite.h oamSetX sprites
superfx.h gsuIsPresent, gsuSetupBitmapTilemap, gsuDmaFullFrame, gsuSetupHdmaBlanking, gsuCacheLoad, gsuStartCached, gsuBusy, gsuWait Super FX, the code cache

When something silently does nothing

The SNES fails quietly. Troubleshooting OpenSNES goes from the symptom to the cause, and Known Limitations is the catalogue of the traps behind them.

Header → tutorial map

Which public header each tutorial covers, and where the documentation is thin. Written by hand; make lint-docs checks that every header of lib/include/snes/ has a row and that every header and tutorial a row names exists. "Partial" means the tutorial teaches the topic without naming most of the API.

Header Covered by State
anim.h Animation ✅
apu.h Samples and the raw APU ✅
audio.h Samples and the raw APU ✅
background.h Scrolling, Graphics ✅
collision.h Collision ✅
colormath.h Colour math ✅
console.h scattered across tutorials 🟡 partial — no page owns init, brightness, fades, region
dma.h DMA ✅
dsp1.h DSP-1 ✅
hdma.h HDMA ✅
input.h Input ✅ pads, mouse, Super Scope (the multitap cannot be switched on: Known limitations)
interrupt.h Interrupts ✅
tile.h Graphics ✅
map.h Maps ✅
math.h Fixed-Point Math ✅
mode7.h Mode 7 ✅
mosaic.h Mosaic ✅
panel.h Panels ✅
profile.h Profiling ✅
sa1.h SA-1 ✅
scene.h Game States ✅
snesmod.h Music with SNESMOD ✅
sprite.h Sprites, Animation ✅
sram.h SRAM ✅
superfx.h Super FX: a first job, running a game around the GSU ✅
video.h Graphics ✅
window.h Window ✅
asset.h The Opt-In Framework ✅
debug.h Debugging — recipe 7 ✅
fixed32.h Math — the 16.16 section ✅
gameloop.h The Opt-In Framework ✅
lzss.h Graphics — compressed tiles ✅
string.h FAR RAM — copying between ROM, RAM and FAR RAM ✅
vramqueue.h DMA — several small uploads in one VBlank ✅
object.h The Object Engine, how it works ✅
text.h Text & Fonts ✅
tilering.h Scrolling — maps with more characters than VRAM ✅
registers.h, system.h, types.h — reference headers: macros and types, no prose needed

Every public header is covered: 16.16 maths in the Math tutorial, LZ77 decompression in Graphics, and the in-ROM debug channel in Debugging (recipe 7).

Keeping this page honest

Example paths here, and the header map above, are checked by devtools/check_doc_drift.py, so a renamed or deleted example, a header without a row, a dead tutorial link or a function no header declares fails make lint-docs.