msgba/include/msgba/core_controller.h

81 lines
2.3 KiB
C

#ifndef MS_CORE_CONTROLLER
#define MS_CORE_CONTROLLER
#include <unistd.h>
#include <mgba/core/core.h>
#include <mgba/core/thread.h>
#include <msgba/client_connection_data.h>
struct msMultiplayerController;
/**
* The struct representing the controller for a single mgba instance.
*/
struct msCoreController {
//! The multiplayer instance. (Unused currently.)
struct msMultiplayerController *multiplayer;
//! The mCoreThread containing the current game.
struct mCoreThread threadContext;
//! The output image buffer.
color_t *outputBuffer;
//! The width of the buffer.
unsigned int stride;
//! The savestate to load on boot.
struct VFile *saveState;
};
/**
* Loads a game and returns a msCoreController
* @param rom The byte array of the rom.
* @param rom_len The size of the previous parameter.
* @param state The savestate byte array.
* @param state_len The size of the savestate.
* @param data The session object.
* @return The created controller.
*/
struct msCoreController *
msCoreControllerLoadGame (const unsigned char *rom, size_t rom_len,
const unsigned char *state, size_t state_len,
struct msClientConnectionData *const data);
/**
* Ends the life of msCoreController.
* @param controllerPtr The pointer to the pointer to msCoreController.
*/
void
msCoreControllerDestroy(struct msCoreController **controllerPtr);
/**
* Creates a new msCoreController.
* @param core The mCore to load in the threadContext.
* @param data The current session.
* @return The created controller.
*/
struct msCoreController *
msCoreControllerNew (struct mCore *core, struct msClientConnectionData *const data);
/**
* Starts the thread for this coreController
* @param coreController This object.
*/
void
msCoreControllerThreadStart (struct msCoreController *const coreController);
/**
* Sets a callback to be executed on every frame.
* @param self This object.
* @param callback The subroutine to execute.
*/
void
msCoreControllerSetFrameCallback(struct msCoreController *const self, void(*callback)(struct mCoreThread *));
/**
* Sets a subroutine to be executed on the start of the threadContext.
* @param self This object.
* @param callback The subroutine to be executed.
*/
void
msCoreControllerSetStartCallback(struct msCoreController *const self, void(*callback)(struct mCoreThread *));
#endif