mirror of https://github.com/mgba-emu/mgba.git
Clean up GBAThread variables
This commit is contained in:
parent
e53135a7b9
commit
80c61379a0
|
@ -88,13 +88,13 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
|
||||||
GBAVideoAssociateRenderer(&gba.video, threadContext->renderer);
|
GBAVideoAssociateRenderer(&gba.video, threadContext->renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (threadContext->fd) {
|
if (threadContext->rom) {
|
||||||
GBALoadROM(&gba, threadContext->fd, threadContext->saveFd, threadContext->fname);
|
GBALoadROM(&gba, threadContext->rom, threadContext->save, threadContext->fname);
|
||||||
if (threadContext->biosFd) {
|
if (threadContext->bios) {
|
||||||
GBALoadBIOS(&gba, threadContext->biosFd);
|
GBALoadBIOS(&gba, threadContext->bios);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (threadContext->patchFd && loadPatch(threadContext->patchFd, &patch)) {
|
if (threadContext->patch && loadPatch(threadContext->patch, &patch)) {
|
||||||
GBAApplyPatch(&gba, &patch);
|
GBAApplyPatch(&gba, &patch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,10 +169,10 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAMapOptionsToContext(struct StartupOptions* opts, struct GBAThread* threadContext) {
|
void GBAMapOptionsToContext(struct StartupOptions* opts, struct GBAThread* threadContext) {
|
||||||
threadContext->fd = VFileOpen(opts->fname, O_RDONLY);
|
threadContext->rom = VFileOpen(opts->fname, O_RDONLY);
|
||||||
threadContext->fname = opts->fname;
|
threadContext->fname = opts->fname;
|
||||||
threadContext->biosFd = VFileOpen(opts->bios, O_RDONLY);
|
threadContext->bios = VFileOpen(opts->bios, O_RDONLY);
|
||||||
threadContext->patchFd = VFileOpen(opts->patch, O_RDONLY);
|
threadContext->patch = VFileOpen(opts->patch, O_RDONLY);
|
||||||
threadContext->frameskip = opts->frameskip;
|
threadContext->frameskip = opts->frameskip;
|
||||||
threadContext->logLevel = opts->logLevel;
|
threadContext->logLevel = opts->logLevel;
|
||||||
threadContext->rewindBufferCapacity = opts->rewindBufferCapacity;
|
threadContext->rewindBufferCapacity = opts->rewindBufferCapacity;
|
||||||
|
@ -194,7 +194,7 @@ bool GBAThreadStart(struct GBAThread* threadContext) {
|
||||||
threadContext->rewindBuffer = 0;
|
threadContext->rewindBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (threadContext->fname && !threadContext->saveFd) {
|
if (threadContext->fname && !threadContext->save) {
|
||||||
char* savedata = 0;
|
char* savedata = 0;
|
||||||
char* dotPoint = strrchr(threadContext->fname, '.');
|
char* dotPoint = strrchr(threadContext->fname, '.');
|
||||||
if (dotPoint > strrchr(threadContext->fname, '/') && dotPoint[1] && dotPoint[2] && dotPoint[3]) {
|
if (dotPoint > strrchr(threadContext->fname, '/') && dotPoint[1] && dotPoint[2] && dotPoint[3]) {
|
||||||
|
@ -213,7 +213,7 @@ bool GBAThreadStart(struct GBAThread* threadContext) {
|
||||||
strcpy(savedata, threadContext->fname);
|
strcpy(savedata, threadContext->fname);
|
||||||
strcat(savedata, "sav");
|
strcat(savedata, "sav");
|
||||||
}
|
}
|
||||||
threadContext->saveFd = VFileOpen(savedata, O_RDWR | O_CREAT);
|
threadContext->save = VFileOpen(savedata, O_RDWR | O_CREAT);
|
||||||
free(savedata);
|
free(savedata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,6 +301,26 @@ void GBAThreadJoin(struct GBAThread* threadContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(threadContext->rewindBuffer);
|
free(threadContext->rewindBuffer);
|
||||||
|
|
||||||
|
if (threadContext->rom) {
|
||||||
|
threadContext->rom->close(threadContext->rom);
|
||||||
|
threadContext->rom = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (threadContext->save) {
|
||||||
|
threadContext->save->close(threadContext->save);
|
||||||
|
threadContext->save = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (threadContext->bios) {
|
||||||
|
threadContext->bios->close(threadContext->bios);
|
||||||
|
threadContext->bios = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (threadContext->patch) {
|
||||||
|
threadContext->patch->close(threadContext->patch);
|
||||||
|
threadContext->patch = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAThreadInterrupt(struct GBAThread* threadContext) {
|
void GBAThreadInterrupt(struct GBAThread* threadContext) {
|
||||||
|
|
|
@ -47,10 +47,10 @@ struct GBAThread {
|
||||||
struct GBAVideoRenderer* renderer;
|
struct GBAVideoRenderer* renderer;
|
||||||
struct GBASIODriverSet sioDrivers;
|
struct GBASIODriverSet sioDrivers;
|
||||||
struct ARMDebugger* debugger;
|
struct ARMDebugger* debugger;
|
||||||
struct VFile* fd;
|
struct VFile* rom;
|
||||||
struct VFile* saveFd;
|
struct VFile* save;
|
||||||
struct VFile* biosFd;
|
struct VFile* bios;
|
||||||
struct VFile* patchFd;
|
struct VFile* patch;
|
||||||
const char* fname;
|
const char* fname;
|
||||||
int activeKeys;
|
int activeKeys;
|
||||||
int frameskip;
|
int frameskip;
|
||||||
|
|
Loading…
Reference in New Issue