changing mgba game speed

Post Reply
petrb
Posts: 8
Joined: Fri Jan 13, 2023 11:19 pm
languages_spoken: english
ODROIDs: odroid go super
Has thanked: 1 time
Been thanked: 0
Contact:

changing mgba game speed

Post by petrb »

Hello,

I am using the default ubuntu image with emulationstation and precompiled emulator images. I am trying to figure out how to make the game go faster (some turbo mode).

Regular mGBA supports this just fine, but problem is that mgba shipped with default image is some custom version? IDK. All the mGBA options are ignored, even --help doesn't do anything. The config file in .config/mgba/config.ini is also clearly ignored.

Is there any easy way to do this, other than replacing it with actual mGBA? (needs ~900MB of extra packages)

crashoverride
Posts: 5774
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 599 times
Contact:

Re: changing mgba game speed

Post by crashoverride »

petrb wrote:
Fri Jan 13, 2023 11:23 pm
Regular mGBA supports this just fine, but problem is that mgba shipped with default image is some custom version?
The source code of mGBA in the reference image is located here:
https://github.com/OtherCrashOverride/mgba-libretro-go2

petrb
Posts: 8
Joined: Fri Jan 13, 2023 11:19 pm
languages_spoken: english
ODROIDs: odroid go super
Has thanked: 1 time
Been thanked: 0
Contact:

Re: changing mgba game speed

Post by petrb »

that's very helpful!

It's interesting, there seems to be some custom main.cpp that doesn't even parse the options, but otherwise it's working with libmgba. I am going to implement my own version with this missing option.

Funny part is that reading the source code I noticed that speedup feature in UI (fpsTarget) seems to be really only implemented in Qt version. It's not used anywhere in core of the emulator, besides its config loader and arg parser. I will see what I can do.

petrb
Posts: 8
Joined: Fri Jan 13, 2023 11:19 pm
languages_spoken: english
ODROIDs: odroid go super
Has thanked: 1 time
Been thanked: 0
Contact:

Re: changing mgba game speed

Post by petrb »

btw is there any instructions how to compile this odroid version? it seems like it's a clone of mgba with extra folder "odroid" which contains custom main and some premake lua script, after using premake tool for it, I managed to start compiling, but then it fails with:

Code: Select all

build@goadvance:~/Documents/mgba-libretro-go2/odroid$ make
==== Building mgba (debug) ====
Linking mgba
/usr/bin/ld: ./../../../build/libmgba.a(gl.c.o): undefined reference to symbol 'glGetProgramInfoLog'
//usr/local/lib/aarch64-linux-gnu/libEGL.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:76: recipe for target 'bin/Debug/mgba' failed
make[1]: *** [bin/Debug/mgba] Error 1
Makefile:29: recipe for target 'mgba' failed
make: *** [mgba] Error 2
it seems that it's trying to link against some custom libEGL.so (no idea why? maybe it's in ldconfig cache?) this one in /usr/local points to "libmali-bifrost-g31-rxp0-gbm.so" no idea what is that, but it's clearly missing some symbols of actual libEGL?

what is the procedure to actually compile it?

petrb
Posts: 8
Joined: Fri Jan 13, 2023 11:19 pm
languages_spoken: english
ODROIDs: odroid go super
Has thanked: 1 time
Been thanked: 0
Contact:

Re: changing mgba game speed

Post by petrb »

ok after lots of hacking I managed to accomplish this - but it completely ruins the music (as expected).

For linker errors - I just switched from static to dynamic linking, it works without problems.

The hack I did - to be honest I don't even know what I did, but it seems to work xD

I was messing up with flags audioSync and videoSync, apparently the only thing that is syncing the game speed with GB speed is sound in this version of mgba, there is no other speed synchronization, so if you disable audio and video syncing and cripple the music subsystem, the game will go as fast as possible, which is acceptable given the max speed of odroid CPU it's still pretty playable.

So what I did:

I changed these lines

Code: Select all

@@ -54,7 +54,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
// This cripples music thread, if you don't do it, even disabling sync will have no effect on game speed
-#define SAMPLES (1024)
+#define SAMPLES (600)

@@ -425,9 +425,9 @@ int main(int argc, char** argv)
                .useBios = true,
                .rewindEnable = false,
                .rewindBufferCapacity = 600,
-               .audioBuffers = 1024,
+               .audioBuffers = 600,
                .videoSync = true,
-               .audioSync = true,
+               .audioSync = false,
                .volume = 0x100,
                
// then I added this piece of code in main loop

@@ -623,6 +623,12 @@ int main(int argc, char** argv)
             mCoreThreadEnd(&thread);
             break;
         }
+
+       if (!prevGamepad.buttons.f2 && gamepad.buttons.f2)
+        {
+           thread.impl->sync.videoFrameWait = !core->opts.videoSync;
+            core->opts.videoSync = !core->opts.videoSync;
+       }
that last piece of code makes f2 button toggle super fast vs synced, so it effectively turned this into a turbo button.

crashoverride
Posts: 5774
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 599 times
Contact:

Re: changing mgba game speed

Post by crashoverride »

petrb wrote:
Sat Jan 14, 2023 6:27 am
btw is there any instructions how to compile this odroid version?
After cloning, change into the directory that the code was cloned into ...

Code: Select all

export CFLAGS="-Ofast -flto=$(nproc) -fuse-linker-plugin -march=armv8-a+crc+simd+crypto -mtune=cortex-a35"
mkdir build
cd build
cmake -DLIBMGBA_ONLY=ON -DBUILD_STATIC=ON  ..
make -j$(nproc)
cd ../odroid
premake4 gmake
make config=release -j$(nproc)

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 3 guests