-
Notifications
You must be signed in to change notification settings - Fork 56
Overworld Speedup
Tutorial was written by HashtagMarky using pret/pokeemerald
, but can easily be ported to pret/pokefirered
or RHH/pokeemerald-expansion
.
This creates an option for overworld speedup, which can be toggled through a scripting variable or the options menu. This animates sprites multiple times per frame in order to achieve a similar effect to emulator speedup, with greater control and without music distortion. A branch isolating these change is available here, but following this tutorial is recommended in order to understand how this was made.
Firstly, decide on the increased overworld speeds you wish to have, below I've chosen the base speed and three increased speeds, also defining their _EXTRA_ITERATIONS
. These values are however many extra animations need to be done per frame to achieve the desired speed. In include/constants/.h
file if your choosing, define the following constants:
+ #define OPTIONS_OVERWORLD_SPEED_1X 0
+ #define OPTIONS_OVERWORLD_SPEED_2X 1
+ #define OPTIONS_OVERWORLD_SPEED_4X 2
+ #define OPTIONS_OVERWORLD_SPEED_8X 3
+ #define OPTIONS_OVERWORLD_SPEED_1X_EXTRA_ITERATIONS 0
+ #define OPTIONS_OVERWORLD_SPEED_2X_EXTRA_ITERATIONS 1
+ #define OPTIONS_OVERWORLD_SPEED_4X_EXTRA_ITERATIONS 3
+ #define OPTIONS_OVERWORLD_SPEED_8X_EXTRA_ITERATIONS 7
Make sure that the constant file is included in event_scripts.s
and any .c
files you wish to use them in.
In overworld.c
create a function in order to return the number of iterations required to create the desired speed. The parameters u16 speed
allow the speed to be passed through, as either a variable, value from the SaveBlock or even as a selection value in the options menu. The parameter bool32 overworld
also helps with the latter, allowing it return the speedup value if needed in places other than the overworld. You also have the option of adding flags or conditions to enable/disable speedup.
+ u8 OverworldSpeedup_AdditionalIterations(u16 speed, bool32 overworld)
+ {
+ if (overworld
+ && VAR_OVERWORLD_SPEEDUP != 0
+ && (JOY_HELD(R_BUTTON)
+ || (FlagGet(FLAG_PREVENT_OVERWORLD_SPEEDUP) && FLAG_PREVENT_OVERWORLD_SPEEDUP != 0)
+ // || FlagGet(FLAG_SYS_DEXNAV_SEARCH) Other conditions when no speedup is wanted.
+ ))
+ {
+ return OPTIONS_OVERWORLD_SPEED_1X_EXTRA_ITERATIONS;
+ }
+
+ switch (speed)
+ {
+ case OPTIONS_OVERWORLD_SPEED_8X: return OPTIONS_OVERWORLD_SPEED_8X_EXTRA_ITERATIONS;
+ case OPTIONS_OVERWORLD_SPEED_4X: return OPTIONS_OVERWORLD_SPEED_4X_EXTRA_ITERATIONS;
+ case OPTIONS_OVERWORLD_SPEED_2X: return OPTIONS_OVERWORLD_SPEED_2X_EXTRA_ITERATIONS;
+ case OPTIONS_OVERWORLD_SPEED_1X: return OPTIONS_OVERWORLD_SPEED_1X_EXTRA_ITERATIONS;
+ default: return OPTIONS_OVERWORLD_SPEED_1X_EXTRA_ITERATIONS;
+ }
+ }
Also remember to declare the function in overworld.h
.
Again in overworld.c
, in the function CB2_Overworld
make these changed.
void CB2_Overworld(void)
{
bool32 fading = (gPaletteFade.active != 0);
+ u8 loops;
if (fading)
SetVBlankCallback(NULL);
OverworldBasic();
+ for (loops = 0; loops < OverworldSpeedup_AdditionalIterations(VarGet(VAR_OVERWORLD_SPEEDUP), TRUE); loops++)
+ {
+ AnimateSprites();
+ CameraUpdate();
+ UpdateCameraPanning();
+ }
if (fading)
SetFieldVBlankCallback();
}
In this case VarGet(VAR_OVERWORLD_SPEEDUP)
is used to get the value of speedup, but it can easily be saved elsewhere. If using this code directly, make sure to define VAR_OVERWORLD_SPEEDUP
in constants/vars.h
.
And it's as easy as that! As a caveat, I did not see a massive notable difference between x8 & x16 speeds, and x32 speeds started having visible performance issues.
git clone https://github.com/pret/pokeemerald.git cd pokeemerald git remote rename origin upstream git remote add origin https://github.com/DEN-DALI-KAVKA/Copy-of-the-World.git git push -u origin