libmame
Public Attributes
LibMame_RunGameCallbacks Struct Reference

#include <libmame.h>

List of all members.

Public Attributes

void(* StatusText )(const char *format, va_list args, void *callback_data)
void(* StartingUp )(LibMame_StartupPhase phase, int pct_complete, LibMame_RunningGame *running_game, void *callback_data)
void(* PollAllControlsState )(LibMame_AllControlsState *all_states, void *callback_data)
void(* UpdateVideo )(const LibMame_RenderPrimitive *render_primitive_list, void *callback_data)
void(* UpdateAudio )(int sample_rate, int samples_this_frame, const int16_t *buffer, void *callback_data)
void(* SetMasterVolume )(int attenuation, void *callback_data)
void(* MakeRunningGameCalls )(void *callback_data)
void(* Paused )(void *callback_data)

Detailed Description

This is the set of callbacks that the caller of LibMame_RunGame passes in. These provide the interface to allow MAME to supply the frames of video and audio that constitute a running game, as well as allowing MAME to gather input from players of the game, and to provide a mechanism for altering the game state as it is running


Member Data Documentation

void(* LibMame_RunGameCallbacks::MakeRunningGameCalls)(void *callback_data)

This callback is made by libmame periodically to give the thread which called LibMame_RunGame an opportunity to call any one or more of the LibMame_RunningGame_XXX function calls, which are only permitted to be called from this callback.

Parameters:
callback_datathe data pointer that was passed to LibMame_RunGame
void(* LibMame_RunGameCallbacks::Paused)(void *callback_data)

This callback is made when MAME has completed a pause operation in response to a LibMame_RunningGame_Pause() call. The caller may take an indefinite period of time to return from this callback without affecting the paused game. When the caller returns from this function, the game will resume. This is the only callback that is not performance sensitive; taking too long in any of the other callbacks could degrade the performance of a running game.

Parameters:
callback_datathe data pointer that was passed to LibMame_RunGame

Called by libmame periodically to poll the current state of all controls. The supplied callback should expect the all_states structure to be completely zeroed out when this function is called, and should set all relevent states within the structure. Relevent states are those used by the game being played (which can be determined by calling LibMame_Get_Game_AllControllers()), for each player which could be playing the game (which can be determined by calling LibMame_Get_Game_MaxSimultaneousPlayers()), plus all states from the shared states structure.

Parameters:
all_statesis all possible control states; the callback should set the current state of relevent controls
callback_datathe data pointer that was passed to LibMame_RunGame
void(* LibMame_RunGameCallbacks::SetMasterVolume)(int attenuation, void *callback_data)

Called by libmame to alter the current volume of audio output.

Attenuation is the attenuation in dB (a negative number). To convert from dB to a linear volume scale do the following:

volume = MAX_VOLUME; while (attenuation++ < 0) volume /= 1.122018454; // = (10 ^ (1/20)) = 1dB

Parameters:
attenuationis the attenuation in dB (a negative number).
callback_datathe data pointer that was passed to LibMame_RunGame
void(* LibMame_RunGameCallbacks::StartingUp)(LibMame_StartupPhase phase, int pct_complete, LibMame_RunningGame *running_game, void *callback_data)

Called by libmame as LibMame_RunGame initializes the game and prepares it for being run. This includes the loading of ROMs and initializing of internal machine state. Additionally lets the callbacks know the handle of the running game, so that it may be used for the LibMame_RunningGame_XXX calls for this game.

Parameters:
phaseis either LibMame_StartupPhase_LoadingRoms, or LibMame_StartupPhase_InitializingMachine
pct_completeis the percentage completion of this phase
running_gameis an opaque pointer which identifies the game being run, and that is used in subsequent calls to LibMame_RunningGame_XXX functions. The application should, if it intends to run more than one game simultaneously (currently not possible due to internal MAME limitations), save this value in a way that associates it with the callback data.
callback_datathe data pointer that was passed to LibMame_RunGame
void(* LibMame_RunGameCallbacks::StatusText)(const char *format, va_list args, void *callback_data)

Called by libmame whenever there is textual status reported by a running game. In general, this text may be ignored, but some applications may prefer to show this text to the user.

Parameters:
formatis the format text, as in vsprintf
argsare the args, as in vsprintf
callback_datathe data pointer that was passed to LibMame_RunGame
void(* LibMame_RunGameCallbacks::UpdateAudio)(int sample_rate, int samples_this_frame, const int16_t *buffer, void *callback_data)

Called by libmame to periodically (and regularly, at the original frame rate of the game) provide the audio that need to be output for the current frame of the game.

Parameters:
sample_rateis the sample rate of the game which is delivering this audio
samples_this_frameis the number of samples contained in the buffer (?? more docs needed)
bufferis a pointer to the raw sound data (more documentation needed about the format of this)
callback_datathe data pointer that was passed to LibMame_RunGame
void(* LibMame_RunGameCallbacks::UpdateVideo)(const LibMame_RenderPrimitive *render_primitive_list, void *callback_data)

Called by libmame to periodically (and regularly, at the original frame rate of the game) provide the primitives that need to be rendered to display the current frame of the game.

Parameters:
render_primitive_listis a list of primitives that are to be rendered
callback_datathe data pointer that was passed to LibMame_RunGame

The documentation for this struct was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines