OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
profile.h File Reference

Performance profiling tools for SNES development. More...

#include <snes/types.h>

Go to the source code of this file.

Macros

#define PROFILE_BLUE   2
#define PROFILE_CYAN   4
#define PROFILE_GREEN   1
#define PROFILE_MAGENTA   5
#define PROFILE_RED   0
#define PROFILE_WHITE   6
#define PROFILE_YELLOW   3

Functions

void profileColorEnd (void)
 End a color-bar profiling section.
void profileColorStart (u16 color)
 Start a color-bar profiling section.
u16 profileGetLagFrames (void)
 Get lag frame count since boot.
u16 profileGetScanline (void)
 Get the current scanline number (0-261 NTSC, 0-311 PAL).
void profileInit (void)
 Initialize the profiler.
u16 profileScanlineEnd (void)
 End a scanline-based timing measurement.
void profileScanlineStart (void)
 Start a scanline-based timing measurement.

Detailed Description

Performance profiling tools for SNES development.

Provides scanline-based timing, visual color-bar profiling, and frame/lag counters.

Quick Start

#include <snes.h>
#include <snes/profile.h>
int main(void) {
profileInit(); // enable color math for visual bars
// ... setup ...
while (1) {
// ... game logic ...
}
}
int main(void)
Definition main.c:66
void consoleInit(void)
Initialize SNES hardware.
void WaitForVBlank(void)
Wait for next VBlank period.
void setScreenOn(void)
Enable screen display.
Performance profiling tools for SNES development.
void profileColorStart(u16 color)
Start a color-bar profiling section.
#define PROFILE_RED
Definition profile.h:55
void profileInit(void)
Initialize the profiler.
void profileColorEnd(void)
End a color-bar profiling section.
OpenSNES common-case master header.

Build

Add profile to LIB_MODULES:

LIB_MODULES := console sprite dma profile
Author
OpenSNES Team

Macro Definition Documentation

◆ PROFILE_BLUE

#define PROFILE_BLUE   2

◆ PROFILE_CYAN

#define PROFILE_CYAN   4

◆ PROFILE_GREEN

#define PROFILE_GREEN   1

◆ PROFILE_MAGENTA

#define PROFILE_MAGENTA   5

◆ PROFILE_RED

#define PROFILE_RED   0

◆ PROFILE_WHITE

#define PROFILE_WHITE   6

◆ PROFILE_YELLOW

#define PROFILE_YELLOW   3

Function Documentation

◆ profileColorEnd()

void profileColorEnd ( void )

End a color-bar profiling section.

Clears the fixed color back to black.

◆ profileColorStart()

void profileColorStart ( u16 color)

Start a color-bar profiling section.

Parameters
colorOne of the PROFILE_* color constants (0-6)

◆ profileGetLagFrames()

u16 profileGetLagFrames ( void )

Get lag frame count since boot.

A lag frame occurs when main code doesn't finish before the next NMI.

◆ profileGetScanline()

u16 profileGetScanline ( void )

Get the current scanline number (0-261 NTSC, 0-311 PAL).

◆ profileInit()

void profileInit ( void )

Initialize the profiler.

Enables color math so that profileColorStart/End produce visible color bars on the backdrop. Call once after consoleInit(), before setScreenOn().

Sets CGADSUB ($2131) to add fixed color to backdrop.

◆ profileScanlineEnd()

u16 profileScanlineEnd ( void )

End a scanline-based timing measurement.

Returns
Number of scanlines elapsed since profileScanlineStart(). Multiply by 1364 for approximate master cycles (NTSC).

◆ profileScanlineStart()

void profileScanlineStart ( void )

Start a scanline-based timing measurement.

Note
Reads SLHV ($2137) to latch the H/V counters, which also sets STAT78 bit 6 — the flag the Super Scope module reads as "the gun fired this frame". Do not profile scanlines in a frame whose scope input matters.