all repos — mgba @ 484a7f299a966cb8fbd90c9e06b332235073bae8

mGBA Game Boy Advance Emulator

Add rerecord count
Jeffrey Pfau jeffrey@endrift.com
Thu, 07 Aug 2014 01:13:50 -0700
commit

484a7f299a966cb8fbd90c9e06b332235073bae8

parent

e732448aa4d7edb24095dd4c4ae2ad434c9effa2

3 files changed, 23 insertions(+), 1 deletions(-)

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

@@ -150,6 +150,11 @@ rr->maxStreamId = 0;

_emitTag(rr, rr->metadataFile, TAG_MAX_STREAM); rr->maxStreamIdOffset = rr->metadataFile->seek(rr->metadataFile, 0, SEEK_CUR); rr->metadataFile->write(rr->metadataFile, &rr->maxStreamId, sizeof(rr->maxStreamId)); + + rr->rrCount = 0; + _emitTag(rr, rr->metadataFile, TAG_RR_COUNT); + rr->rrCountOffset = rr->metadataFile->seek(rr->metadataFile, 0, SEEK_CUR); + rr->metadataFile->write(rr->metadataFile, &rr->rrCount, sizeof(rr->rrCount)); return true; }

@@ -357,6 +362,13 @@ }

return true; } +bool GBARRMarkRerecord(struct GBARRContext* rr) { + ++rr->rrCount; + rr->metadataFile->seek(rr->metadataFile, rr->rrCountOffset, SEEK_SET); + rr->metadataFile->write(rr->metadataFile, &rr->rrCount, sizeof(rr->rrCount)); + return true; +} + bool _emitMagic(struct GBARRContext* rr, struct VFile* vf) { UNUSED(rr); return vf->write(vf, BINARY_MAGIC, 4) == 4;

@@ -399,6 +411,9 @@ break;

case TAG_LAG_COUNT: vf->read(vf, &rr->lagFrames, sizeof(rr->lagFrames)); break; + case TAG_RR_COUNT: + vf->read(vf, &rr->rrCount, sizeof(rr->rrCount)); + break; case TAG_INIT_EX_NIHILO: rr->initFrom = INIT_EX_NIHILO;

@@ -413,7 +428,6 @@ rr->initFrom = INIT_FROM_BOTH;

break; // To be spec'd - case TAG_RR_COUNT: case TAG_AUTHOR: case TAG_COMMENT: break;

@@ -470,6 +484,9 @@ case TAG_INIT_FROM_SAVEGAME:

case TAG_INIT_FROM_SAVESTATE: case TAG_INIT_FROM_BOTH: rr->initFromOffset = vf->seek(vf, 0, SEEK_CUR); + break; + case TAG_RR_COUNT: + rr->rrCountOffset = vf->seek(vf, 0, SEEK_CUR); break; default: break;
M src/gba/gba-rr.hsrc/gba/gba-rr.h

@@ -65,6 +65,9 @@

enum GBARRInitFrom initFrom; off_t initFromOffset; + uint32_t rrCount; + off_t rrCountOffset; + struct VFile* savedata; // Streaming state

@@ -88,6 +91,7 @@ bool GBARRLoadStream(struct GBARRContext*, uint32_t streamId);

bool GBARRIncrementStream(struct GBARRContext*, bool recursive); bool GBARRFinishSegment(struct GBARRContext*); bool GBARRSkipSegment(struct GBARRContext*); +bool GBARRMarkRerecord(struct GBARRContext*); bool GBARRStartPlaying(struct GBARRContext*, bool autorecord); void GBARRStopPlaying(struct GBARRContext*);
M src/gba/gba-serialize.csrc/gba/gba-serialize.c

@@ -86,6 +86,7 @@ GBARRIncrementStream(gba->rr, true);

} else { GBARRFinishSegment(gba->rr); } + GBARRMarkRerecord(gba->rr); } else if (GBARRIsPlaying(gba->rr)) { GBARRLoadStream(gba->rr, state->associatedStreamId); GBARRSkipSegment(gba->rr);