OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
Processing

Functions

void snesmodFlush (void)
 Wait for command queue to empty.
void snesmodProcess (void)
 Process audio commands.

Detailed Description

Function Documentation

◆ snesmodFlush()

void snesmodFlush ( void )

Wait for command queue to empty.

Blocks until all queued commands have been processed. Useful before loading new modules.

◆ snesmodProcess()

void snesmodProcess ( void )

Process audio commands.

Warning
This function MUST be called every frame!

Processes the command queue and handles streaming. Failure to call this regularly will cause:

  • Audio stuttering and dropouts
  • Command buffer overflow
  • Desynchronization with module playback

Call it from the MAIN LOOP, once per frame — not from an nmiSet() callback: it shares its command staging bytes with snesmodPlayEffect(), snesmodPlay(), snesmodFadeVolume() and snesmodSetModuleVolume(), so an NMI landing between one of those staging its parameters and queueing them corrupts the command. (This line offered "or NMI handler" until 2026-09-20.)

Cost: with nothing queued it returns at once. With one message queued it sends it and returns. With more, it sends what the SPC700 accepts for at most five scanlines (about 2 % of a frame), then leaves the rest for the next call; the audio driver takes about two messages per frame.

The queue holds 85 commands. A command sent while it is full is dropped (the newest one; until 2026-10-03 it wrapped onto the oldest and the driver stopped answering). Reaching 85 means snesmodProcess() is not being called, or dozens of commands are sent per frame.

It reads no H/V counter and leaves the counter latch alone (it used to latch $2137 and read OPVCT, which raised the Super Scope latch flag and shifted OPVCT's read pointer for whoever read it next).

while (1) {
// ... game logic
}
void WaitForVBlank(void)
Wait for next VBlank period.
void snesmodProcess(void)
Process audio commands.