diff --git a/CHANGES b/CHANGES index 042e6449f..086f03924 100644 --- a/CHANGES +++ b/CHANGES @@ -97,6 +97,7 @@ Misc: - FFmpeg: Add looping option for GIF/APNG - mGUI: Show battery percentage - mGUI: Skip second scan loop when possible + - mGUI: Improve loading speed (fixes mgba.io/i/1957) - Qt: Renderer can be changed while a game is running - Qt: Add hex index to palette view - Qt: Add transformation matrix info to sprite view diff --git a/src/core/core.c b/src/core/core.c index 5afdc8667..04c5dca8c 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -153,12 +153,23 @@ bool mCorePreloadVFCB(struct mCore* core, struct VFile* vf, void (cb)(size_t, si vfm = VFileMemChunk(NULL, size); #endif - uint8_t buffer[2048]; + size_t chunkSize; +#ifdef FIXED_ROM_BUFFER + uint8_t* buffer = (uint8_t*) romBuffer; + chunkSize = 0x10000; +#else + uint8_t buffer[0x4000]; + chunkSize = sizeof(buffer); +#endif ssize_t read; size_t total = 0; vf->seek(vf, 0, SEEK_SET); - while ((read = vf->read(vf, buffer, sizeof(buffer))) > 0) { + while ((read = vf->read(vf, buffer, chunkSize)) > 0) { +#ifdef FIXED_ROM_BUFFER + buffer += read; +#else vfm->write(vfm, buffer, read); +#endif total += read; if (cb) { cb(total, size, context); diff --git a/src/feature/gui/gui-runner.c b/src/feature/gui/gui-runner.c index fe3999ad6..c2e860edb 100644 --- a/src/feature/gui/gui-runner.c +++ b/src/feature/gui/gui-runner.c @@ -296,10 +296,6 @@ static void _log(struct mLogger* logger, int category, enum mLogLevel level, con static void _updateLoading(size_t read, size_t size, void* context) { struct mGUIRunner* runner = context; - if (read & 0x3FFFF) { - return; - } - runner->params.drawStart(); if (runner->params.guiPrepare) { runner->params.guiPrepare(); @@ -388,7 +384,13 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) { mInputMapInit(&runner->core->inputMap, &GBAInputInfo); struct VFile* rom = mDirectorySetOpenPath(&runner->core->dirs, path, runner->core->isROM); + if (runner->setFrameLimiter) { + runner->setFrameLimiter(runner, false); + } found = mCorePreloadVFCB(runner->core, rom, _updateLoading, runner); + if (runner->setFrameLimiter) { + runner->setFrameLimiter(runner, true); + } #ifdef FIXED_ROM_BUFFER extern size_t romBufferSize;