msgba/include/msgba/core_controller.h

81 lines
2.3 KiB
C
Raw Normal View History

2023-03-10 23:37:11 +01:00
#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;
2023-03-26 18:41:29 +02:00
/**
* The struct representing the controller for a single mgba instance.
*/
2023-03-10 23:37:11 +01:00
struct msCoreController {
2023-03-26 18:41:29 +02:00
//! The multiplayer instance. (Unused currently.)
2023-03-24 22:28:30 +01:00
struct msMultiplayerController *multiplayer;
2023-03-26 18:41:29 +02:00
//! The mCoreThread containing the current game.
2023-03-24 22:28:30 +01:00
struct mCoreThread threadContext;
2023-03-26 18:41:29 +02:00
//! The output image buffer.
2023-03-10 23:37:11 +01:00
color_t *outputBuffer;
2023-03-26 18:41:29 +02:00
//! The width of the buffer.
2023-03-10 23:37:11 +01:00
unsigned int stride;
2023-03-26 18:41:29 +02:00
//! The savestate to load on boot.
2023-03-24 22:28:30 +01:00
struct VFile *saveState;
2023-03-10 23:37:11 +01:00
};
2023-03-26 18:41:29 +02:00
/**
* 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.
*/
2023-03-10 23:37:11 +01:00
struct msCoreController *
msCoreControllerLoadGame (const unsigned char *rom, size_t rom_len,
const unsigned char *state, size_t state_len,
struct msClientConnectionData *const data);
2023-03-26 18:41:29 +02:00
/**
* Ends the life of msCoreController.
* @param controllerPtr The pointer to the pointer to msCoreController.
*/
2023-03-10 23:37:11 +01:00
void
2023-03-26 18:41:29 +02:00
msCoreControllerDestroy(struct msCoreController **controllerPtr);
2023-03-10 23:37:11 +01:00
2023-03-26 18:41:29 +02:00
/**
* Creates a new msCoreController.
* @param core The mCore to load in the threadContext.
* @param data The current session.
* @return The created controller.
*/
2023-03-10 23:37:11 +01:00
struct msCoreController *
msCoreControllerNew (struct mCore *core, struct msClientConnectionData *const data);
2023-03-26 18:41:29 +02:00
/**
* Starts the thread for this coreController
* @param coreController This object.
*/
2023-03-10 23:37:11 +01:00
void
2023-03-26 18:41:29 +02:00
msCoreControllerThreadStart (struct msCoreController *const coreController);
/**
* Sets a callback to be executed on every frame.
* @param self This object.
* @param callback The subroutine to execute.
*/
2023-03-11 08:17:25 +01:00
void
msCoreControllerSetFrameCallback(struct msCoreController *const self, void(*callback)(struct mCoreThread *));
2023-03-26 18:41:29 +02:00
/**
* Sets a subroutine to be executed on the start of the threadContext.
* @param self This object.
* @param callback The subroutine to be executed.
*/
2023-03-13 00:06:19 +01:00
void
msCoreControllerSetStartCallback(struct msCoreController *const self, void(*callback)(struct mCoreThread *));
2023-03-10 23:37:11 +01:00
#endif