SNES Console Initialization and Core Functions. More...
Go to the source code of this file.
Functions | |
| void | consoleInit (void) |
| Initialize SNES hardware. | |
| void | consoleInitEx (u16 options) |
| Initialize console with options. | |
| void | fadeIn (u8 speed) |
| Fade the screen from black (0) up to full brightness (15). | |
| void | fadeOut (u8 speed) |
| Fade the screen from full brightness (15) down to black (0). | |
| u8 | getBrightness (void) |
| u16 | getFrameCount (void) |
| Get frame counter. | |
| u8 | getRegion (void) |
| Get system region. | |
| u8 | isInVBlank (void) |
| Check if currently in VBlank. | |
| u8 | isPAL (void) |
| Check if PAL system. | |
| u16 | rand (void) |
| Get random 16-bit number. | |
| void | resetFrameCount (void) |
| Reset frame counter. | |
| void | setBrightness (u8 brightness) |
| Set screen brightness. | |
| void | setScreenOff (void) |
| void | setScreenOn (void) |
| Enable screen display. | |
| void | srand (u16 seed) |
| Seed random number generator. | |
| void | WaitForVBlank (void) |
| Wait for next VBlank period. | |
Variables | |
| u8 | current_brightness |
| Get current brightness. | |
| u8 | force_blanked |
| Disable screen display (blank). | |
SNES Console Initialization and Core Functions.
Provides functions for initializing SNES hardware and core functionality like VBlank synchronization.
Originally from: PVSnesLib (https://github.com/alekmaul/pvsneslib) Author: Alekmaul License: zlib (compatible with MIT) Modifications:
| void consoleInit | ( | void | ) |
Initialize SNES hardware.
Must be called at the start of your program. Performs:
After calling, screen is blanked (black). Call setScreenOn() to enable display after you've set up your graphics.
| void consoleInitEx | ( | u16 | options | ) |
Initialize console with options.
Advanced initialization with configuration options.
| options | Initialization flags (reserved for future use) |
| void fadeIn | ( | u8 | speed | ) |
| void fadeOut | ( | u8 | speed | ) |
Fade the screen from full brightness (15) down to black (0).
Steps INIDISP brightness from 15 → 0, waiting speed VBlank frames between each step. Final state: setBrightness(0) (visually black, screen still rendering). Combine with setScreenOff() afterwards if you want to also enter force-blank for safe VRAM updates.
At 60 fps (NTSC):
| speed | VBlank frames to wait between each brightness step. speed=0 falls through with no inter-step delay (visible flash, ~16 frames if every step still hits VBlank via loop overhead — not typically useful). |
|
inline |
|
inline |
Get frame counter.
Returns the number of VBlanks since initialization. Wraps at 65535.
Inlined for zero-call-overhead access (just a 16-bit load).
| u8 getRegion | ( | void | ) |
Get system region.
| u8 isInVBlank | ( | void | ) |
Check if currently in VBlank.
| u8 isPAL | ( | void | ) |
| u16 rand | ( | void | ) |
Get random 16-bit number.
Returns a pseudo-random number using a linear feedback shift register.
| void resetFrameCount | ( | void | ) |
Reset frame counter.
Sets frame counter to 0. Useful for timing game events.
| void setBrightness | ( | u8 | brightness | ) |
Set screen brightness.
| brightness | Brightness level (0-15, 0=black, 15=full) |
The mistake survives testing: a small transfer written this way lands inside VBlank and is correct every time, while a multi-KB one has its tail dropped during active display. Use setScreenOff() / setScreenOn() around any upload that is not comfortably inside the VBlank budget — see dmaCopyVram().
|
inline |
|
inline |
Enable screen display.
Turns on the display after initialization or a screen blank. Sets full brightness (15).
Inlined for zero-call-overhead access (saves ~28 cycles per call). Shares the same force_blanked and current_brightness shadows as setScreenOff(); both are declared extern below.
| void srand | ( | u16 | seed | ) |
Seed random number generator.
| seed | Initial seed value |
| void WaitForVBlank | ( | void | ) |
Wait for next VBlank period.
Blocks until the PPU enters Vertical Blank. This is essential for:
Call once per frame in your main loop.
|
extern |
Get current brightness.
Inlined for zero-call-overhead access. The standalone definition is still available (force-emitted in console.c) for fn-pointer callers.
|
extern |
Disable screen display (blank).
Turns off the display. Use during major VRAM updates that can't complete during VBlank.
Inlined for zero-call-overhead access (saves ~28 cycles per call). The standalone definition in console.c is still emitted (via the extern inline declaration there) for ABI compatibility — direct call sites collapse to two stores.