all repos — mgba @ b4d6d11d19916e7e059f432c02fb6a14c7d865f8

mGBA Game Boy Advance Emulator

Add ability to resume recording as soon as a movie ends
Jeffrey Pfau jeffrey@endrift.com
Sun, 20 Jul 2014 03:14:55 -0700
commit

b4d6d11d19916e7e059f432c02fb6a14c7d865f8

parent

74dae5033ba68c50175316ec2dae8724ddb5a5da

3 files changed, 19 insertions(+), 9 deletions(-)

jump to
M src/gba/gba-rr.csrc/gba/gba-rr.c

@@ -31,18 +31,24 @@ rr->inputsStream = stream->openFile(stream, FILE_INPUTS, O_CREAT | O_RDWR);

return !!rr->inputsStream; } -bool GBARRStartPlaying(struct GBARRContext* rr) { +bool GBARRStartPlaying(struct GBARRContext* rr, bool autorecord) { if (GBARRIsRecording(rr) || GBARRIsPlaying(rr)) { return false; } + rr->autorecord = autorecord; + if (rr->inputsStream->seek(rr->inputsStream, 0, SEEK_SET) < 0) { + return false; + } + if (rr->inputsStream->read(rr->inputsStream, &rr->nextInput, sizeof(rr->nextInput)) != sizeof(rr->nextInput)) { + return false; + } rr->isPlaying = true; - rr->inputId = 0; - return rr->inputsStream->seek(rr->inputsStream, 0, SEEK_SET) == 0; + return true; } void GBARRStopPlaying(struct GBARRContext* rr) { - rr->isPlaying = 0; + rr->isPlaying = false; } bool GBARRStartRecording(struct GBARRContext* rr) {

@@ -93,7 +99,10 @@ if (!GBARRIsPlaying(rr)) {

return 0; } - uint16_t keys; - rr->inputsStream->read(rr->inputsStream, &keys, sizeof(keys)); + uint16_t keys = rr->nextInput; + rr->isPlaying = rr->inputsStream->read(rr->inputsStream, &rr->nextInput, sizeof(rr->nextInput)) == sizeof(rr->nextInput); + if (!rr->isPlaying && rr->autorecord) { + rr->isRecording = true; + } return keys; }
M src/gba/gba-rr.hsrc/gba/gba-rr.h

@@ -10,7 +10,8 @@

struct GBARRContext { // Playback state bool isPlaying; - size_t inputId; + bool autorecord; + uint16_t nextInput; // Recording state bool isRecording;

@@ -30,7 +31,7 @@ void GBARRContextDestroy(struct GBA*);

bool GBARRSetStream(struct GBARRContext*, struct VDir*); -bool GBARRStartPlaying(struct GBARRContext*); +bool GBARRStartPlaying(struct GBARRContext*, bool autorecord); void GBARRStopPlaying(struct GBARRContext*); bool GBARRStartRecording(struct GBARRContext*); void GBARRStopRecording(struct GBARRContext*);
M src/platform/sdl/sdl-events.csrc/platform/sdl/sdl-events.c

@@ -143,7 +143,7 @@ GBAThreadInterrupt(context);

GBARRContextCreate(context->gba); GBARRSetStream(context->gba->rr, context->stateDir); GBARRStopRecording(context->gba->rr); - GBARRStartPlaying(context->gba->rr); + GBARRStartPlaying(context->gba->rr, event->keysym.mod & KMOD_SHIFT); GBAThreadContinue(context); break; default: