Skip to content

Building the RSDKv4 Decompilation

The RSDKv4 Decompilation uses CMake, a versatile building system that supports many different compilers and platforms.

Read before proceeding

This guide requires basic knowledge of how to use the appropriate terminal for your OS, such as Command Prompt for Windows. If you aren't familiar with doing basic actions with terminals, such as opening one in specific directories, look up a tutorial online.

In addition, refer to these warnings depending on the platform you are compiling for:

Warning

Make sure to use Command Prompt when typing commands instead of PowerShell, as PowerShell is known to cause issues.

Notice for Steam Deck users

Due to how SteamOS handles packages, building the decompilation on the Steam Deck is highly difficult and not recommended. Instead, consider building it on another Arch Linux device and using that build on the Steam Deck.

TODO

Get the source code

In order to clone the repository, you need to install Git, which you can get here.

Clone the repo recursively, using:

git clone --recursive https://github.com/RSDKModding/RSDKv4-Decompilation

If you've already cloned the repo, run these commands inside of the repository to ensure the clone is up-to-date:

git pull
git submodule update --remote --init --recursive

Getting dependencies

Install CMake. Make sure to enable the feature to add CMake to the system PATH during the installation.

To handle dependencies, you'll need to install Visual Studio Community with the Desktop development with C++ workload. If you already have Visual Studio installed, you can manage your installed workloads by opening Visual Studio Installer from the Start Menu and clicking the Modify button next to your Visual Studio installation.

Warning

An installation of Visual Studio with the Desktop development with C++ workload uses around 8 GB of storage space. Make sure you have the necessary space on your drive before proceeding.

You will also need to set up vcpkg. You only need to follow 1 - Set up vcpkg in the guide.

Tip

It's recommended to clone vcpkg into a short path such as C:/src to avoid potential file path issues.

Run the following command in the vcpkg repository:

vcpkg.exe install glew sdl2 libogg libvorbis --triplet=x64-windows-static
vcpkg.exe install glew sdl2 libogg libvorbis --triplet=x86-windows-static

Then, add vcpkg to your environment variables by running the following commands in the vcpkg repository:

set VCPKG_ROOT="%CD%"
setx VCPKG_ROOT %VCPKG_ROOT%

Run the following command in the terminal:

sudo pacman -S base-devel cmake glew sdl2 libogg libvorbis
sudo apt install build-essential cmake libglew-dev libglfw3-dev libsdl2-dev libogg-dev libvorbis-dev
sudo dnf install make gcc cmake glew-devel glfw-devel sdl2-devel libogg-devel libvorbis-devel zlib-devel
sudo apk add build-base cmake glew-dev glfw-dev sdl2-dev libogg-dev libvorbis-dev
sudo xbps-install make cmake pkg-config glew-devel glfw-devel SDL2-devel libogg-devel libvorbis-devel  zlib-devel

Download and install Android Studio.

Download the ZIP archives for libogg and libvorbis from xiph.org, then extract and place the libogg-X.X.X and libvorbis-X.X.X folders into RSDKv4-Decompilation/dependencies/android. Rename the folders libogg and libvorbis, respectively.

Download the source code for SDL version 2.28.3, then extract and place the SDL2-2.28.3 folder into RSDKv4-Decompilation/dependencies/android. Rename the folder SDL.

Download the binaries for GLEW from glew.sourceforge.net, then extract and place the glew-X.X.X folder into RSDKv4-Decompilation/dependencies/android. Rename the folder glew.

Navigate to RSDKv4-Decompilation/android/app/jni and delete the src file in it, then create the symbolic links in the following table in that directory:

Symlink Name Path
SDL Path to RSDKv4-Decompilation/dependencies/android/SDL
src Path to RSDKv4-Decompilation

How do I make a symbolic link?

You can create a symlink using the appropriate command:

  • Windows: mklink /d "[symlink-name]" "[path]" (or use Link Shell Extension)
  • Linux: ln -s "[path]" "[symlink-name]"

Compiling

Enter the following commands in the RSDKv4 decompilation repository directory:

cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_PREFIX_PATH="%VCPKG_ROOT%/installed/x64-windows-static/"
cmake --build build --config release
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x86-windows-static -DCMAKE_PREFIX_PATH="%VCPKG_ROOT%/installed/x86-windows-static/" -A Win32
cmake --build build --config release

The resulting build will be located somewhere in build/ depending on your system.

You can set build flags by adding -D[flag-name]=[value] to the end of the first command. For example, to build with RETRO_DISABLE_PLUS set to on, add -DRETRO_DISABLE_PLUS=on to the command.

Enter the following commands in the RSDKv4 decompilation repository directory:

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config release

The resulting build will be located somewhere in build/ depending on your system.

You can set build flags by adding -D[flag-name]=[value] to the end of the first command. For example, to build with RETRO_DISABLE_PLUS set to on, add -DRETRO_DISABLE_PLUS=on to the command.

TODO: Be more descriptive

Open RSDKv4-Decompilation/android/ in Android Studio, install the NDK and everything else that it asks for, and build.

Build Flags

Warning

These build flags modify certain aspects of the decomp; only use these if you know what you're doing!

Flag Description Value Type Default Value
RETRO_REVISION The RSDKv4 revision to compile. Datapacks for certain versions of Sonic 1/2 only work on older revisions. Integer (See Revisions) 3
RETRO_DISABLE_PLUS Disables access to content from Sonic Origins's Plus Expansion Pack. Any publicly distributed builds must have this flag enabled. Boolean off
RETRO_FORCE_CASE_INSENSITIVE Forces case insensivity when loading files. Boolean off
RETRO_MOD_LOADER Enables the ability the load mods and certain features related to them. Boolean on
RETRO_NETWORKING Enables networking features used for Sonic 2's 2P VS mode. Boolean on
RETRO_USE_HW_RENDER Enables the Hardware Renderer used for native menus and objects. The main menu, pause menu, and touch controls will not be visible if this is disabled. Boolean on
RETRO_SDL_VERSION Switches between using SDL 1.2 or SDL 2. Integer (1 or 2) 2

Revisions

Flag Value Revision
0 REV00 (Initial Sonic 1 Release)
1 REV01 (Initial Sonic 2 Release)
2 REV02 (Sega Forever)
3 REV03 (RSDKv5U Legacy v4 Mode)