From 6b257d52f20a310e8b761248521b39ac70f028c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ed=C3=AAnis=20Freindorfer=20Azevedo?= Date: Thu, 21 May 2020 22:55:51 -0300 Subject: [PATCH] Avoid override of variable `throttle` for turbo. It is not needed to set `throttle` on neither case. There is actually a bug when using turbo/speedup and closing the emulator. The test case is the following: https://github.com/visualboyadvance-m/visualboyadvance-m/issues/627 On Windows: 1. use opengl; 2. load GBA game; 3. set throttle to `100%`; 4. set turbo throttle to `200%`; 5. enable turbo on menu; 6. save game; 7. close emulator && open emulator; 8. load GBA game; ==> throttle is `200%`. This is definitely not expected. --- src/gb/GB.cpp | 4 ++-- src/gba/GBA.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gb/GB.cpp b/src/gb/GB.cpp index 7173ae50d..ca265db05 100644 --- a/src/gb/GB.cpp +++ b/src/gb/GB.cpp @@ -4953,7 +4953,7 @@ void gbEmulate(int ticksToStop) if (turbo_button_pressed) { if (!speedup_throttle_set && throttle != speedup_throttle) { last_throttle = throttle; - throttle = speedup_throttle; + //throttle = speedup_throttle; soundSetThrottle(speedup_throttle); speedup_throttle_set = true; } @@ -4970,7 +4970,7 @@ void gbEmulate(int ticksToStop) framesToSkip = speedup_frame_skip; } else if (speedup_throttle_set) { - throttle = last_throttle; + //throttle = last_throttle; soundSetThrottle(last_throttle); speedup_throttle_set = false; diff --git a/src/gba/GBA.cpp b/src/gba/GBA.cpp index a385533cf..996d42b44 100644 --- a/src/gba/GBA.cpp +++ b/src/gba/GBA.cpp @@ -3799,7 +3799,7 @@ void CPULoop(int ticks) if (turbo_button_pressed) { if (!speedup_throttle_set && throttle != speedup_throttle) { last_throttle = throttle; - throttle = speedup_throttle; + //throttle = speedup_throttle; soundSetThrottle(speedup_throttle); speedup_throttle_set = true; } @@ -3816,7 +3816,7 @@ void CPULoop(int ticks) framesToSkip = speedup_frame_skip; } else if (speedup_throttle_set) { - throttle = last_throttle; + //throttle = last_throttle; soundSetThrottle(last_throttle); speedup_throttle_set = false;