OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
Super Scope Input

SNES Super Scope support (port 2 only). More...

Macros

#define SSC_CURSOR   0x4000
#define SSC_FIRE   0x8000
#define SSC_NOISE   0x0100
#define SSC_OFFSCREEN   0x0200
#define SSC_PAUSE   0x1000
#define SSC_TURBO   0x2000

Functions

u16 scopeButtonsDown (void)
 Get currently held buttons.
u16 scopeButtonsHeld (void)
 Get buttons held past the hold delay threshold.
u16 scopeButtonsPressed (void)
 Get newly pressed buttons this frame.
void scopeCalibrate (void)
u16 scopeGetRawX (void)
 Get raw (uncalibrated) H position from PPU.
u16 scopeGetRawY (void)
 Get raw (uncalibrated) V position from PPU.
u16 scopeGetX (void)
 Get calibration-adjusted H position.
u16 scopeGetY (void)
 Get calibration-adjusted V position.
u8 scopeInit (void)
 Detect Super Scope on port 2.
u8 scopeIsConnected (void)
 Check if Super Scope is connected.
void scopeSetHoldDelay (u16 frames)
void scopeSetRepeatDelay (u16 frames)
 Set repeat delay (frames between repeat fires after hold).
u16 scopeSinceShot (void)
 Get frames since last detected shot.

Variables

u16 scope_centerh
u16 scope_centerv
u16 scope_holddelay
 Set hold delay (frames before hold triggers).
u16 scope_shothraw
 Calibrate aim from a center-screen shot.
u16 scope_shotvraw

Detailed Description

SNES Super Scope support (port 2 only).

The Super Scope is a light gun that uses the PPU H/V counter latch to determine aim position. It provides 4 buttons and 2 status flags.

Usage

// Detect and initialize Super Scope
if (scopeInit()) {
// Super Scope found on port 2!
}
// Calibration: ask user to fire at screen center
// Wait for fire...
// Main loop
while (1) {
u16 x = scopeGetX();
u16 y = scopeGetY();
// Shot fired!
}
}
void WaitForVBlank(void)
Wait for next VBlank period.
#define SSC_FIRE
Definition input.h:311
void scopeCalibrate(void)
Definition input.h:400
u16 scopeButtonsPressed(void)
Get newly pressed buttons this frame.
u16 scopeGetX(void)
Get calibration-adjusted H position.
u8 scopeInit(void)
Detect Super Scope on port 2.
u16 scopeGetY(void)
Get calibration-adjusted V position.
unsigned short u16
16-bit unsigned integer (0 to 65535)
Definition types.h:53

Macro Definition Documentation

◆ SSC_CURSOR

#define SSC_CURSOR   0x4000

Cursor button

◆ SSC_FIRE

#define SSC_FIRE   0x8000

Fire button (trigger)

◆ SSC_NOISE

#define SSC_NOISE   0x0100

Noise flag (no signal)

◆ SSC_OFFSCREEN

#define SSC_OFFSCREEN   0x0200

Off-screen flag

◆ SSC_PAUSE

#define SSC_PAUSE   0x1000

Pause button

◆ SSC_TURBO

#define SSC_TURBO   0x2000

Turbo switch

Function Documentation

◆ scopeButtonsDown()

u16 scopeButtonsDown ( void )

Get currently held buttons.

Returns
Button mask (SSC_FIRE, SSC_CURSOR, SSC_TURBO, SSC_PAUSE, SSC_OFFSCREEN, SSC_NOISE)

◆ scopeButtonsHeld()

u16 scopeButtonsHeld ( void )

Get buttons held past the hold delay threshold.

After holding a button for holddelay frames, it triggers as "held". Then it re-triggers every repdelay frames.

Returns
Button mask of held buttons

◆ scopeButtonsPressed()

u16 scopeButtonsPressed ( void )

Get newly pressed buttons this frame.

Returns
Button mask of buttons pressed this frame (edge detection)

◆ scopeCalibrate()

void scopeCalibrate ( void )
inline

◆ scopeGetRawX()

u16 scopeGetRawX ( void )

Get raw (uncalibrated) H position from PPU.

Returns
Raw X coordinate from PPU H counter

◆ scopeGetRawY()

u16 scopeGetRawY ( void )

Get raw (uncalibrated) V position from PPU.

Returns
Raw Y coordinate from PPU V counter

◆ scopeGetX()

u16 scopeGetX ( void )

Get calibration-adjusted H position.

Returns
Adjusted X coordinate (0-255 visible range)

◆ scopeGetY()

u16 scopeGetY ( void )

Get calibration-adjusted V position.

Returns
Adjusted Y coordinate (0-223 visible range)

◆ scopeInit()

u8 scopeInit ( void )

Detect Super Scope on port 2.

Checks the auto-joypad device signature on port 2. If a Super Scope is found, enables reading in the NMI handler and sets default hold/repeat delays (60/20 frames).

Returns
1 if Super Scope detected, 0 if not

◆ scopeIsConnected()

u8 scopeIsConnected ( void )

Check if Super Scope is connected.

Returns
1 if connected, 0 if not

◆ scopeSetHoldDelay()

void scopeSetHoldDelay ( u16 frames)
inline

◆ scopeSetRepeatDelay()

void scopeSetRepeatDelay ( u16 frames)

Set repeat delay (frames between repeat fires after hold).

Parameters
framesNumber of frames (default: 20)

◆ scopeSinceShot()

u16 scopeSinceShot ( void )

Get frames since last detected shot.

Returns
Number of frames since last PPU latch (shot detection)

Variable Documentation

◆ scope_centerh

u16 scope_centerh
extern

◆ scope_centerv

u16 scope_centerv

◆ scope_holddelay

u16 scope_holddelay
extern

Set hold delay (frames before hold triggers).

Parameters
framesNumber of frames (default: 60 = 1 second at 60Hz) Inlined for zero-call-overhead access.

◆ scope_shothraw

u16 scope_shothraw
extern

Calibrate aim from a center-screen shot.

Call this after the user fires at the center of the screen (128, 112). Computes calibration offsets: centerh = 128 - rawX, centerv = 112 - rawY. The NMI handler applies these offsets to all subsequent readings.

Inlined for zero-call-overhead access.

◆ scope_shotvraw

u16 scope_shotvraw