OldSchool Library
Synchronization

Synchronization routines for your game. More...

Macros

#define oslSetFrameskip(val)
 Sets the current fixed frameskipping value.
 
#define oslSetMaxFrameskip(val)
 Sets the maximum frameskip value.
 
#define oslSetVSync(val)
 Sets the VSync parameter.
 
#define oslSyncFrame()
 Synchronization function to be called at the end of a frame.
 

Functions

void oslEndFrame ()
 Call this function when a frame has ended.
 
int oslSyncFrameEx (int frameskip, int max_frameskip, int vsync)
 Synchronization function with explicit parameters.
 
void oslWaitVSync ()
 Waits for the VSync, synchronizing your game.
 

Variables

int osl_quit
 Indicates whether the application should exit.
 
int osl_standByUnpermitted
 Controls whether standby mode is permitted.
 
int(* osl_powerCallback )(int arg1, int arg2, void *common)
 Pointer to the power callback function.
 
int(* osl_exitCallback )(int arg1, int arg2, void *common)
 Pointer to the exit callback function.
 
int osl_vblInterruptNumber
 The interrupt number for the VBLANK interrupt.
 
int osl_maxFrameskip
 Maximum allowed frameskip value.
 
int osl_vsyncEnabled
 Indicates whether VSync is enabled.
 
int osl_frameskip
 Current frameskip setting.
 
volatile int osl_vblCount
 Count of VBLANK interrupts.
 
volatile int osl_vblCallCount
 Count of VBLANK interrupt calls.
 
volatile int osl_vblankCounterActive
 Indicates if the VBLANK counter is active.
 
volatile int osl_skip
 Indicates whether the current frame should be skipped.
 
volatile int osl_currentFrameRate
 Current framerate setting.
 

Detailed Description

Synchronization routines for your game.

These functions are used to synchronize the game's frame rate and ensure smooth rendering and input handling. They include functions for managing frame skipping and VSync.

Macro Definition Documentation

◆ oslSetFrameskip

#define oslSetFrameskip ( val)
Value:
int osl_frameskip
Current frameskip setting.

Sets the current fixed frameskipping value.

Parameters
val1 enables auto frameskip, 2 or more enables fixed skipping (val-1 frames out of val are skipped).

◆ oslSetMaxFrameskip

#define oslSetMaxFrameskip ( val)
Value:
int osl_maxFrameskip
Maximum allowed frameskip value.

Sets the maximum frameskip value.

Parameters
valMaximum frameskip value.

◆ oslSetVSync

#define oslSetVSync ( val)
Value:
int osl_vsyncEnabled
Indicates whether VSync is enabled.

Sets the VSync parameter.

Parameters
valVSync parameter value.

◆ oslSyncFrame

#define oslSyncFrame ( )
Value:
int oslSyncFrameEx(int frameskip, int max_frameskip, int vsync)
Synchronization function with explicit parameters.

Synchronization function to be called at the end of a frame.

This function synchronizes the frame rate based on the current frameskip and VSync settings.

Returns
A boolean value indicating if the game is running late.

Function Documentation

◆ oslEndFrame()

void oslEndFrame ( )
extern

Call this function when a frame has ended.

This function should be called just before calling oslSyncFrame or oslWaitVSync. It handles audio synchronization and other end-of-frame tasks.

◆ oslSyncFrameEx()

int oslSyncFrameEx ( int frameskip,
int max_frameskip,
int vsync )
extern

Synchronization function with explicit parameters.

This function is similar to oslSyncFrame but allows you to pass all synchronization parameters directly in one call.

Parameters
frameskipFrameskip value.
max_frameskipMaximum frameskip value.
vsyncVSync parameter.
Returns
A boolean value indicating if the game is running late.

◆ oslWaitVSync()

void oslWaitVSync ( )
extern

Waits for the VSync, synchronizing your game.

This function is a simpler and less efficient method than oslSyncFrame.

Variable Documentation

◆ osl_quit

int osl_quit
extern

Indicates whether the application should exit.

This variable is set to 1 when the user chooses "Exit" from the HOME menu, signaling that the application should clean up resources and quit. Game loops should monitor this variable and exit gracefully when it is set to 1.

◆ osl_standByUnpermitted

int osl_standByUnpermitted
extern

Controls whether standby mode is permitted.

This variable can be set to 1 to prevent the PSP from entering standby mode. If set to 0, standby mode is allowed.

◆ osl_powerCallback

int(* osl_powerCallback) (int arg1, int arg2, void *common) ( int arg1,
int arg2,
void * common )
extern

Pointer to the power callback function.

This function is called when a power event occurs, such as low battery, power switch action, or other power-related events. The callback receives three parameters: two integers and a void pointer for user-defined data.

Parameters
arg1First argument, typically indicating the type of power event.
arg2Second argument, providing additional context or flags related to the event.
commonA pointer to user-defined data, typically passed when setting up the callback.
Returns
Typically returns 0, but the return value may be used to influence power event handling.

◆ osl_exitCallback

int(* osl_exitCallback) (int arg1, int arg2, void *common) ( int arg1,
int arg2,
void * common )
extern

Pointer to the exit callback function.

This function is executed when the user chooses "Exit" from the HOME menu. By default, it sets osl_quit to 1. You can override this function to handle exit events in a custom way.

Parameters
arg1First argument, usually indicating the reason for the exit request.
arg2Second argument, providing additional context or flags related to the exit request.
commonA pointer to user-defined data, typically passed when setting up the callback.
Returns
Typically returns 0, but the return value may be used to influence exit event handling.

◆ osl_vblInterruptNumber

int osl_vblInterruptNumber
extern

The interrupt number for the VBLANK interrupt.

This variable stores the number of the VBLANK interrupt used by OSLib. It is generally set during initialization and used to manage frame synchronization.

◆ osl_maxFrameskip

int osl_maxFrameskip
extern

Maximum allowed frameskip value.

This variable determines the maximum number of frames that can be skipped to maintain a stable frame rate. A higher value may result in a less smooth visual experience but can help the game maintain its target frame rate.

◆ osl_vsyncEnabled

int osl_vsyncEnabled
extern

Indicates whether VSync is enabled.

This variable controls the VSync setting for the application. When VSync is enabled, the rendering process is synchronized with the screen refresh rate to prevent screen tearing.

◆ osl_frameskip

int osl_frameskip
extern

Current frameskip setting.

This variable determines how many frames should be skipped between rendering frames. A value of 1 disables frameskipping, while higher values increase the number of frames skipped, potentially improving performance at the cost of smoothness.

◆ osl_vblCount

volatile int osl_vblCount
extern

Count of VBLANK interrupts.

This volatile variable tracks the number of VBLANK interrupts that have occurred. It is used internally to synchronize rendering with the display's refresh rate.

◆ osl_vblCallCount

volatile int osl_vblCallCount
extern

Count of VBLANK interrupt calls.

This volatile variable tracks the number of times the VBLANK interrupt has been handled. It is used to ensure that the application correctly responds to each interrupt.

◆ osl_vblankCounterActive

volatile int osl_vblankCounterActive
extern

Indicates if the VBLANK counter is active.

This volatile variable is set to 1 when the VBLANK counter is actively tracking VBLANK interrupts. It is used internally by OSLib for frame synchronization.

◆ osl_skip

volatile int osl_skip
extern

Indicates whether the current frame should be skipped.

This volatile variable is used internally to determine if rendering for the current frame should be skipped based on the frameskip settings and current performance.

◆ osl_currentFrameRate

volatile int osl_currentFrameRate
extern

Current framerate setting.

This volatile variable stores the current target framerate, typically set to 60 for a standard PSP display. It can be modified to simulate different framerates, such as 50 for PAL games.