Fixing savestate and adding load keys.
This commit is contained in:
parent
05fff066ef
commit
72677feab5
@ -10,10 +10,11 @@
|
|||||||
struct msMultiplayerController;
|
struct msMultiplayerController;
|
||||||
|
|
||||||
struct msCoreController {
|
struct msCoreController {
|
||||||
struct msMultiplayerController *multiplayer;
|
struct msMultiplayerController *multiplayer;
|
||||||
struct mCoreThread threadContext;
|
struct mCoreThread threadContext;
|
||||||
color_t *outputBuffer;
|
color_t *outputBuffer;
|
||||||
unsigned int stride;
|
unsigned int stride;
|
||||||
|
struct VFile *saveState;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct msCoreController *
|
struct msCoreController *
|
||||||
|
@ -6,3 +6,13 @@
|
|||||||
|
|
||||||
extern char *ms_last_error;
|
extern char *ms_last_error;
|
||||||
#endif
|
#endif
|
||||||
|
#define MSGBA_KEY_A 0
|
||||||
|
#define MSGBA_KEY_B 1
|
||||||
|
#define MSGBA_KEY_L 2
|
||||||
|
#define MSGBA_KEY_R 3
|
||||||
|
#define MSGBA_KEY_START 4
|
||||||
|
#define MSGBA_KEY_SELECT 5
|
||||||
|
#define MSGBA_KEY_UP 6
|
||||||
|
#define MSGBA_KEY_DOWN 7
|
||||||
|
#define MSGBA_KEY_LEFT 8
|
||||||
|
#define MSGBA_KEY_RIGHT 9
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include <msgba/global.h>
|
#include <msgba/global.h>
|
||||||
#include <msgba/core_controller.h>
|
#include <msgba/core_controller.h>
|
||||||
|
#include <mgba/core/input.h>
|
||||||
|
#include <mgba/internal/gba/input.h>
|
||||||
|
|
||||||
|
|
||||||
struct msCoreController *
|
struct msCoreController *
|
||||||
@ -35,6 +37,17 @@ msCoreControllerLoadGame (const unsigned char *rom, size_t rom_len,
|
|||||||
goto loadGameReturn;
|
goto loadGameReturn;
|
||||||
}
|
}
|
||||||
core->init(core);
|
core->init(core);
|
||||||
|
mInputBindKey(&core->inputMap, 0, MSGBA_KEY_A, GBA_KEY_A);
|
||||||
|
mInputBindKey(&core->inputMap, 0, MSGBA_KEY_B, GBA_KEY_B);
|
||||||
|
mInputBindKey(&core->inputMap, 0, MSGBA_KEY_L, GBA_KEY_L);
|
||||||
|
mInputBindKey(&core->inputMap, 0, MSGBA_KEY_R, GBA_KEY_R);
|
||||||
|
mInputBindKey(&core->inputMap, 0, MSGBA_KEY_START, GBA_KEY_START);
|
||||||
|
mInputBindKey(&core->inputMap, 0, MSGBA_KEY_SELECT, GBA_KEY_SELECT);
|
||||||
|
mInputBindKey(&core->inputMap, 0, MSGBA_KEY_UP, GBA_KEY_UP);
|
||||||
|
mInputBindKey(&core->inputMap, 0, MSGBA_KEY_DOWN, GBA_KEY_DOWN);
|
||||||
|
mInputBindKey(&core->inputMap, 0, MSGBA_KEY_LEFT, GBA_KEY_LEFT);
|
||||||
|
mInputBindKey(&core->inputMap, 0, MSGBA_KEY_RIGHT, GBA_KEY_RIGHT);
|
||||||
|
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
mCoreInitConfig(core, NULL);
|
mCoreInitConfig(core, NULL);
|
||||||
@ -47,11 +60,11 @@ msCoreControllerLoadGame (const unsigned char *rom, size_t rom_len,
|
|||||||
printf("controller->outputBuffer width: %u\n", width);
|
printf("controller->outputBuffer width: %u\n", width);
|
||||||
core->setVideoBuffer(core, outputBuffer, width);
|
core->setVideoBuffer(core, outputBuffer, width);
|
||||||
core->loadROM (core, file_rom);
|
core->loadROM (core, file_rom);
|
||||||
mCoreLoadStateNamed (core, file_state, SAVESTATE_SAVEDATA & SAVESTATE_RTC);
|
|
||||||
|
|
||||||
controller = msCoreControllerNew (core, data);
|
controller = msCoreControllerNew (core, data);
|
||||||
controller->outputBuffer = outputBuffer;
|
controller->outputBuffer = outputBuffer;
|
||||||
controller->stride = width;
|
controller->stride = width;
|
||||||
|
controller->saveState = file_state;
|
||||||
loadGameReturn:
|
loadGameReturn:
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
@ -65,10 +78,21 @@ msCoreControllerSetStartCallback(struct msCoreController *const self, void(*call
|
|||||||
self->threadContext.startCallback = callback;
|
self->threadContext.startCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mCoreThreadAfterStart(struct mCoreThread *threadContext) {
|
||||||
|
struct msClientConnectionData *data = (struct msClientConnectionData *)threadContext->userData;
|
||||||
|
struct msCoreController *coreController = data->coreController;
|
||||||
|
struct mCore *core = coreController->threadContext.core;
|
||||||
|
if (!mCoreLoadStateNamed (core, coreController->saveState, 0)) { // SAVESTATE_SAVEDATA & SAVESTATE_RTC)) {
|
||||||
|
fprintf(stderr, "Unable to load save state\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
msCoreControllerThreadStart (struct msCoreController *const core_controller) {
|
msCoreControllerThreadStart (struct msCoreController *const core_controller) {
|
||||||
struct mCoreThread *thread = &core_controller->threadContext;
|
struct mCoreThread *thread = &core_controller->threadContext;
|
||||||
mCoreThreadStart(thread);
|
mCoreThreadStart(thread);
|
||||||
|
mCoreThreadRunFunction(thread, &mCoreThreadAfterStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <sys/signal.h>
|
#include <sys/signal.h>
|
||||||
|
|
||||||
|
#include <mgba/core/serialize.h>
|
||||||
|
|
||||||
#include <msgba/packet/send_frame.h>
|
#include <msgba/packet/send_frame.h>
|
||||||
#include <msgba/packet.h>
|
#include <msgba/packet.h>
|
||||||
#include <msgba/packet/hello.h>
|
#include <msgba/packet/hello.h>
|
||||||
@ -28,6 +30,12 @@ msThreadCallbackStart(struct mCoreThread *threadContext) {
|
|||||||
sigemptyset(&set);
|
sigemptyset(&set);
|
||||||
sigaddset(&set, SIGPIPE);
|
sigaddset(&set, SIGPIPE);
|
||||||
pthread_sigmask(SIG_BLOCK, &set, NULL);
|
pthread_sigmask(SIG_BLOCK, &set, NULL);
|
||||||
|
struct msClientConnectionData *data = (struct msClientConnectionData *)threadContext->userData;
|
||||||
|
struct msCoreController *coreController = data->coreController;
|
||||||
|
struct mCore *core = coreController->threadContext.core;
|
||||||
|
if (!mCoreLoadStateNamed (core, coreController->saveState, 0)) { // SAVESTATE_SAVEDATA & SAVESTATE_RTC)) {
|
||||||
|
fprintf(stderr, "Unable to load save state\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
msThreadCallbackSetFrame(struct mCoreThread *threadContext) {
|
msThreadCallbackSetFrame(struct mCoreThread *threadContext) {
|
||||||
|
Loading…
Reference in New Issue
Block a user