├── android ├── app │ ├── jni │ │ ├── src │ │ ├── Android.mk │ │ ├── Application.mk │ │ └── CMakeLists.txt │ ├── src │ │ └── main │ │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ ├── styles.xml │ │ │ │ └── colors.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_background.png │ │ │ │ ├── ic_launcher_foreground.png │ │ │ │ └── ic_launcher_monochrome.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_background.png │ │ │ │ ├── ic_launcher_foreground.png │ │ │ │ └── ic_launcher_monochrome.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_background.png │ │ │ │ ├── ic_launcher_foreground.png │ │ │ │ └── ic_launcher_monochrome.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_background.png │ │ │ │ ├── ic_launcher_foreground.png │ │ │ │ └── ic_launcher_monochrome.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_background.png │ │ │ │ ├── ic_launcher_foreground.png │ │ │ │ └── ic_launcher_monochrome.png │ │ │ ├── values-v27 │ │ │ │ └── styles.xml │ │ │ └── mipmap-anydpi-v26 │ │ │ │ └── ic_launcher.xml │ │ │ ├── java │ │ │ ├── org │ │ │ │ └── libsdl │ │ │ │ │ └── app │ │ │ │ │ ├── HIDDevice.java │ │ │ │ │ └── SDL.java │ │ │ └── com │ │ │ │ └── decomp │ │ │ │ └── rsdkv3 │ │ │ │ └── RSDKv3.java │ │ │ └── AndroidManifest.xml │ ├── proguard-rules.pro │ └── build.gradle ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── build.gradle ├── gradle.properties ├── gradlew.bat └── gradlew ├── header.png ├── RSDKv3.Wii └── hbc-data │ ├── icon.png │ └── meta.xml ├── dependencies ├── ios │ ├── Default.png │ ├── Assets.xcassets │ │ ├── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── dependencies.txt │ ├── Info.plist │ └── Base.lproj │ │ └── LaunchScreen.storyboard ├── all │ └── theoraplay │ │ ├── .hgignore │ │ ├── .hg_archival.txt │ │ ├── test │ │ ├── maketest.sh │ │ └── testtheoraplay.c │ │ ├── LICENSE.txt │ │ ├── theoraplay.h │ │ └── theoraplay_cvtrgb.h ├── mac │ ├── Assets.xcassets │ │ ├── Contents.json │ │ └── AppIcon.appiconset │ │ │ ├── RSDKv3 Decomp Icon-128.png │ │ │ ├── RSDKv3 Decomp Icon-16.png │ │ │ ├── RSDKv3 Decomp Icon-256.png │ │ │ ├── RSDKv3 Decomp Icon-257.png │ │ │ ├── RSDKv3 Decomp Icon-32.png │ │ │ ├── RSDKv3 Decomp Icon-33.png │ │ │ ├── RSDKv3 Decomp Icon-512.png │ │ │ ├── RSDKv3 Decomp Icon-513.png │ │ │ ├── RSDKv3 Decomp Icon-64.png │ │ │ ├── RSDKv3 Decomp Icon-1024.png │ │ │ └── Contents.json │ ├── cocoaHelpers.hpp │ ├── Dependencies.xcodeproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── Ogg.xcscheme │ │ │ ├── Theora.xcscheme │ │ │ └── Vorbis.xcscheme │ ├── RSDKv3.entitlements │ ├── dependencies.txt │ ├── Info.plist │ ├── cocoaHelpers.mm │ └── README.md ├── android │ ├── config_types.h │ └── README.md ├── win-uwp │ └── dependencies.txt └── windows │ └── dependencies.txt ├── RSDKv3 ├── RSDKv3 Decomp Icon.ico ├── resource.h ├── Sprite.hpp ├── String.cpp ├── Video.hpp ├── Math.hpp ├── String.hpp ├── fcaseopen.h ├── ModAPI.hpp ├── Text.hpp ├── Ini.hpp ├── Player.hpp ├── Debug.hpp ├── Animation.hpp ├── main.cpp ├── Object.hpp ├── Userdata.hpp ├── Scene3D.hpp ├── Player.cpp ├── Script.hpp ├── Math.cpp ├── Input.hpp ├── Palette.cpp ├── RSDKv3.rc ├── fcaseopen.c ├── Collision.hpp ├── Reader.hpp ├── Palette.hpp ├── Object.cpp └── Animation.cpp ├── flatpak ├── run.sh ├── com.sega.SonicCD.desktop ├── README.md ├── com.sega.SonicCDAndroid.json ├── com.sega.SonicCD.appdata.xml └── com.sega.SonicCDSteam.json ├── RSDKv3UWP ├── packages.config ├── PropertySheet.props ├── main.cpp ├── WinRTIncludes.hpp └── Package.appxmanifest ├── RSDKv3.vita ├── build.sh ├── sce_sys │ └── livearea │ │ └── contents │ │ └── template.xml ├── build-internal.sh └── CMakeLists.txt ├── RSDKv3.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── RSDKv3.xcscheme ├── RSDKv3 ios.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── RSDKv3.xcscheme ├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ └── bug_report.yml └── workflows │ └── build.yml ├── .gitmodules ├── platforms ├── Android.cmake ├── Linux.cmake └── Windows.cmake ├── props ├── winactions.props └── winactions_x64.props ├── .clang-format ├── LICENSE.md ├── Makefile.msys2 ├── Makefile ├── RSDKv3.sln ├── Android.mk ├── RSDKv3UWP.sln └── FAQ.md /android/app/jni/src: -------------------------------------------------------------------------------- 1 | ../../.. -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /android/app/jni/Android.mk: -------------------------------------------------------------------------------- 1 | include $(call all-subdir-makefiles) 2 | -------------------------------------------------------------------------------- /header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/header.png -------------------------------------------------------------------------------- /RSDKv3.Wii/hbc-data/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/RSDKv3.Wii/hbc-data/icon.png -------------------------------------------------------------------------------- /dependencies/ios/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/dependencies/ios/Default.png -------------------------------------------------------------------------------- /RSDKv3/RSDKv3 Decomp Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/RSDKv3/RSDKv3 Decomp Icon.ico -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RSDKv3 3 | 4 | -------------------------------------------------------------------------------- /flatpak/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | [ -f /app/share/soniccd/Data.rsdk ] && ln -sf /app/share/soniccd/Data.rsdk . 4 | 5 | RSDKv3 -------------------------------------------------------------------------------- /dependencies/all/theoraplay/.hgignore: -------------------------------------------------------------------------------- 1 | syntax:glob 2 | test/*.dSYM 3 | test/*.exe 4 | test/testtheoraplay 5 | test/sdltheoraplay 6 | -------------------------------------------------------------------------------- /dependencies/ios/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /dependencies/mac/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /flatpak/com.sega.SonicCD.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=Sonic CD 4 | Icon=com.sega.SonicCD 5 | Exec=RSDKv3 6 | Categories=Game; 7 | -------------------------------------------------------------------------------- /dependencies/mac/cocoaHelpers.hpp: -------------------------------------------------------------------------------- 1 | #ifndef COCOA_HELPERS_H 2 | #define COCOA_HELPERS_H 3 | 4 | void getResourcesPath(char* buffer, int bufferSize); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RSDKv3UWP/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher_background.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher_background.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #231F20 4 | -------------------------------------------------------------------------------- /RSDKv3.vita/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sudo docker run \ 3 | --rm \ 4 | -v $PWD/..:/work \ 5 | -w /work/RSDKv3.vita \ 6 | vitasdk/vitasdk \ 7 | /bin/sh -C "./build-internal.sh" 8 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png -------------------------------------------------------------------------------- /dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-128.png -------------------------------------------------------------------------------- /dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-16.png -------------------------------------------------------------------------------- /dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-256.png -------------------------------------------------------------------------------- /dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-257.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-257.png -------------------------------------------------------------------------------- /dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-32.png -------------------------------------------------------------------------------- /dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-33.png -------------------------------------------------------------------------------- /dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-512.png -------------------------------------------------------------------------------- /dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-513.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-513.png -------------------------------------------------------------------------------- /dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-64.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultra0000/RSDKv3-Decompilation/HEAD/dependencies/mac/Assets.xcassets/AppIcon.appiconset/RSDKv3 Decomp Icon-1024.png -------------------------------------------------------------------------------- /RSDKv3.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /dependencies/all/theoraplay/.hg_archival.txt: -------------------------------------------------------------------------------- 1 | repo: 2cd9243072f0470e51d658b7ef978870d4468af3 2 | node: 99e5fc74603e70d99e8b189eb58d02496f9a0457 3 | branch: default 4 | latesttag: null 5 | latesttagdistance: 67 6 | changessincelatesttag: 67 7 | -------------------------------------------------------------------------------- /dependencies/mac/Dependencies.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RSDKv3 ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Retro Engine Modding Server 4 | url: https://dc.railgun.works/retroengine 5 | about: If you have any questions about the decompilation or want help with modding, ask here. 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dependencies/all/tinyxml2"] 2 | path = dependencies/all/tinyxml2 3 | url = https://github.com/leethomason/tinyxml2 4 | [submodule "flatpak/shared-modules"] 5 | path = flatpak/shared-modules 6 | url = https://github.com/flathub/shared-modules.git 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Aug 03 23:47:29 CDT 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /dependencies/mac/RSDKv3.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.cs.disable-library-validation 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/jni/Application.mk: -------------------------------------------------------------------------------- 1 | 2 | # Uncomment this if you're using STL in your project 3 | # You can find more information here: 4 | # https://developer.android.com/ndk/guides/cpp-support 5 | APP_STL := c++_shared 6 | 7 | APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 8 | 9 | # Min runtime API level 10 | APP_PLATFORM=android-23 11 | -------------------------------------------------------------------------------- /RSDKv3.vita/sce_sys/livearea/contents/template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bg.png 6 | 7 | 8 | 9 | startup.png 10 | 11 | 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/values-v27/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dependencies/android/config_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_TYPES_H__ 2 | #define __CONFIG_TYPES_H__ 3 | 4 | #include 5 | typedef int16_t ogg_int16_t; 6 | typedef uint16_t ogg_uint16_t; 7 | typedef int32_t ogg_int32_t; 8 | typedef uint32_t ogg_uint32_t; 9 | typedef int64_t ogg_int64_t; 10 | typedef uint64_t ogg_uint64_t; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /android/app/jni/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | project(RSDKv3) 3 | 4 | set(curdir ${CMAKE_CURRENT_LIST_DIR}) 5 | set(android 1) 6 | 7 | # message(FATAL_ERROR ${curdir}) 8 | file(GLOB children ${curdir}/*) 9 | 10 | foreach(child ${children}) 11 | if(EXISTS ${child}/CMakeLists.txt) 12 | add_subdirectory(${child}) 13 | endif() 14 | endforeach() 15 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /dependencies/win-uwp/dependencies.txt: -------------------------------------------------------------------------------- 1 | Download the latest SDL2 source tarball from https://www.libsdl.org/download-2.0.php, and extract it's contents to a folder called `SDL2`. 2 | 3 | If you wish to build ARM/ARM64 architecture variants, be sure to retarget and build libogg, libtheora and libvorbis for these platforms. 4 | You will need to undefine OC_X86_ASM for libtheora to build correctly, and resulting binaries aren't particularly fast, but do run. -------------------------------------------------------------------------------- /RSDKv3/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by RSDKv3.rc 4 | // 5 | #define IDI_ICON1 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 104 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /RSDKv3.Wii/hbc-data/meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sonic CD 4 | ultra0 5 | Wii CI Build 6 | 7 | Sonic CD (2011) Port 8 | Port of the RSDKv3 decompilation. 9 | 10 | Remember to put your Data.rsdk file on either sd:/SonicCD/ or usb:/SonicCD/, depending on the storage device you're using. 11 | 12 | Decompilation made by Rubberduckycooly. 13 | -------------------------------------------------------------------------------- /RSDKv3/Sprite.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SPRITE_H 2 | #define SPRITE_H 3 | 4 | int AddGraphicsFile(const char *filePath); 5 | void RemoveGraphicsFile(const char *filePath, int sheetID); 6 | 7 | int LoadBMPFile(const char *filePath, byte sheetID); 8 | int LoadGIFFile(const char *filePath, byte sheetID); 9 | int LoadGFXFile(const char *filePath, byte sheetID); 10 | int LoadRSVFile(const char *filePath, byte sheetID); 11 | int LoadPVRFile(const char *filePath, byte sheetID); 12 | 13 | void ReadGifPictureData(int width, int height, bool interlaced, byte *gfxData, int offset); 14 | 15 | #endif // !SPRITE_H 16 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.3' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } 27 | -------------------------------------------------------------------------------- /RSDKv3UWP/PropertySheet.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in [sdk]/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /dependencies/all/theoraplay/test/maketest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -x 4 | set -e 5 | 6 | OSTYPE=`uname -s` 7 | if [ "$OSTYPE" = "Linux" ]; then 8 | LINKFLAGS="-lpthread" 9 | LINKGLFLAGS="-lGL" 10 | fi 11 | if [ "$OSTYPE" = "Darwin" ]; then 12 | LINKGLFLAGS="-framework OpenGL" 13 | fi 14 | 15 | CFLAGS="-O0 -ggdb3 -Wall -I.." 16 | gcc -o ./testtheoraplay $CFLAGS ../theoraplay.c ./testtheoraplay.c -logg -lvorbis -ltheoradec $LINKFLAGS 17 | gcc -o ./simplesdl $CFLAGS ../theoraplay.c ./simplesdl.c `sdl-config --cflags --libs` -logg -lvorbis -ltheoradec $LINKFLAGS 18 | gcc -o ./sdltheoraplay $CFLAGS ../theoraplay.c ./sdltheoraplay.c `sdl-config --cflags --libs` -logg -lvorbis -ltheoradec $LINKFLAGS $LINKGLFLAGS 19 | 20 | -------------------------------------------------------------------------------- /dependencies/mac/dependencies.txt: -------------------------------------------------------------------------------- 1 | SDL2: https://www.libsdl.org/download-2.0.php 2 | just download the appropriate development library for your compiler and place it in "./SDL2/" 3 | 4 | libogg: https://xiph.org/downloads/ (libogg) 5 | download the libogg .zip file and unzip it in "./libogg/", then build the library as a framework, and include it in the xcode proj 6 | 7 | libvorbis: https://xiph.org/downloads/ (libvorbis) 8 | download the libvorbis .zip file and unzip it in "./libvorbis/", then build the library as a framework, and include it in the xcode proj 9 | 10 | libtheora: https://xiph.org/downloads/ (libtheora) 11 | download the libtheora .zip file and unzip it in "./libtheora/", then build the library as a framework, and include it in the xcode proj -------------------------------------------------------------------------------- /android/app/src/main/java/org/libsdl/app/HIDDevice.java: -------------------------------------------------------------------------------- 1 | package org.libsdl.app; 2 | 3 | import android.hardware.usb.UsbDevice; 4 | 5 | interface HIDDevice 6 | { 7 | public int getId(); 8 | public int getVendorId(); 9 | public int getProductId(); 10 | public String getSerialNumber(); 11 | public int getVersion(); 12 | public String getManufacturerName(); 13 | public String getProductName(); 14 | public UsbDevice getDevice(); 15 | public boolean open(); 16 | public int sendFeatureReport(byte[] report); 17 | public int sendOutputReport(byte[] report); 18 | public boolean getFeatureReport(byte[] report); 19 | public void setFrozen(boolean frozen); 20 | public void close(); 21 | public void shutdown(); 22 | } 23 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build RSDKv3 2 | on: 3 | push: 4 | branches: 5 | - wii 6 | 7 | jobs: 8 | v3-wii: 9 | runs-on: ubuntu-latest 10 | container: devkitpro/devkitppc:latest 11 | steps: 12 | - name: Checkout repository 13 | uses: actions/checkout@v4 14 | with: 15 | submodules: recursive 16 | - name: Build RSDKv3 17 | run: | 18 | cd RSDKv3.Wii 19 | make 20 | mkdir bin/ && mkdir bin/apps/ && mkdir bin/apps/RSDKv3/ 21 | cp RSDKv3.Wii.dol bin/apps/RSDKv3/boot.dol 22 | cp hbc-data/* bin/apps/RSDKv3/ 23 | - name: Upload artifact 24 | uses: actions/upload-artifact@v4 25 | with: 26 | name: v3-wii 27 | path: RSDKv3.Wii/bin 28 | -------------------------------------------------------------------------------- /RSDKv3UWP/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "SDL_main.h" 14 | #include 15 | 16 | int SDL_main(int argc, char *argv[]) 17 | { 18 | SDL_SetHint(SDL_HINT_WINRT_HANDLE_BACK_BUTTON, "1"); 19 | Engine.Init(); 20 | Engine.Run(); 21 | 22 | return 0; 23 | } 24 | 25 | 26 | int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int) { return SDL_WinRTRunApp(SDL_main, NULL); } 27 | -------------------------------------------------------------------------------- /RSDKv3/String.cpp: -------------------------------------------------------------------------------- 1 | #include "RetroEngine.hpp" 2 | 3 | int FindStringToken(const char *string, const char *token, sbyte stopID) 4 | { 5 | int tokenCharID = 0; 6 | bool tokenMatch = true; 7 | int stringCharID = 0; 8 | int foundTokenID = 0; 9 | 10 | while (string[stringCharID]) { 11 | tokenCharID = 0; 12 | tokenMatch = true; 13 | while (token[tokenCharID]) { 14 | if (!string[tokenCharID + stringCharID]) 15 | return -1; 16 | 17 | if (string[tokenCharID + stringCharID] != token[tokenCharID]) 18 | tokenMatch = false; 19 | 20 | ++tokenCharID; 21 | } 22 | if (tokenMatch && ++foundTokenID == stopID) 23 | return stringCharID; 24 | 25 | ++stringCharID; 26 | } 27 | return -1; 28 | } -------------------------------------------------------------------------------- /platforms/Android.cmake: -------------------------------------------------------------------------------- 1 | add_library(RetroEngine SHARED ${RETRO_FILES}) 2 | 3 | set(DEP_PATH android) 4 | set(RETRO_SDL_VERSION 2) 5 | set(RETRO_USE_HW_RENDER ON) 6 | set(RETRO_OUTPUT_NAME "RetroEngine") 7 | 8 | set(COMPILE_OGG TRUE) 9 | set(COMPILE_THEORA TRUE) 10 | set(COMPILE_VORBIS TRUE) 11 | set(OGG_FLAGS -ffast-math -fsigned-char -O2 -fPIC -DPIC -DBYTE_ORDER=LITTLE_ENDIAN -D_ARM_ASSEM_ -w) 12 | set(THEORA_FLAGS -ffast-math -fsigned-char -O2 -fPIC -DPIC -DBYTE_ORDER=LITTLE_ENDIAN -D_ARM_ASSEM_ -w) 13 | set(VORBIS_FLAGS -ffast-math -fsigned-char -O2 -fPIC -DPIC -DBYTE_ORDER=LITTLE_ENDIAN -D_ARM_ASSEM_ -w) 14 | 15 | target_link_libraries(RetroEngine 16 | android 17 | EGL 18 | GLESv1_CM 19 | log 20 | z 21 | jnigraphics 22 | OpenSLES 23 | SDL2 24 | ) 25 | 26 | target_link_options(RetroEngine PRIVATE -u GameActivity_onCreate) -------------------------------------------------------------------------------- /props/winactions.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %(PreprocessorDefinitions);RSDK_AUTOBUILD 6 | 7 | 8 | C:/vcpkg/installed/x86-windows-static/lib/;$(SolutionDir)dependencies/windows/SDL2/lib/$(PlatformTargetAsMSBuildArchitecture)/;$(SolutionDir)dependencies/windows/glew/lib/Release/$(Platform)/ 9 | SDL2.lib;SDL2main.lib;ogg.lib;vorbis.lib;vorbisfile.lib;theora.lib;Opengl32.lib;glu32.lib;glew32.lib;Shell32.lib;Advapi32.lib 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | ABIFILTERS=armeabi-v7a;arm64-v8a;x86;x86_64 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | -------------------------------------------------------------------------------- /props/winactions_x64.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %(PreprocessorDefinitions);RSDK_AUTOBUILD 6 | 7 | 8 | C:/vcpkg/installed/x64-windows-static/lib/;$(SolutionDir)dependencies/windows/SDL2/lib/$(PlatformTargetAsMSBuildArchitecture)/;$(SolutionDir)dependencies/windows/glew/lib/Release/$(Platform)/ 9 | SDL2.lib;SDL2main.lib;ogg.lib;vorbis.lib;vorbisfile.lib;theora.lib;Opengl32.lib;glu32.lib;glew32.lib;Shell32.lib;Advapi32.lib 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /RSDKv3UWP/WinRTIncludes.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | inline char *getResourcesPath() 7 | { 8 | static char resourcePath[256] = { 0 }; 9 | 10 | if (strlen(resourcePath) == 0) { 11 | auto folder = winrt::Windows::Storage::ApplicationData::Current().LocalFolder(); 12 | auto path = to_string(folder.Path()); 13 | 14 | std::copy(path.begin(), path.end(), resourcePath); 15 | } 16 | 17 | return resourcePath; 18 | } 19 | 20 | inline uint UAP_GetRetroGamePlatform() 21 | { 22 | auto touchCaps = winrt::Windows::Devices::Input::TouchCapabilities(); 23 | return touchCaps.TouchPresent() ? RETRO_MOBILE : RETRO_STANDARD; 24 | } 25 | 26 | inline uint UAP_GetRetroGamePlatformId() 27 | { 28 | auto touchCaps = winrt::Windows::Devices::Input::TouchCapabilities(); 29 | return touchCaps.TouchPresent() ? RETRO_ANDROID : RETRO_WIN; 30 | } 31 | -------------------------------------------------------------------------------- /RSDKv3/Video.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_H 2 | #define VIDEO_H 3 | 4 | #if RETRO_PLATFORM != RETRO_WII 5 | #include "theoraplay.h" 6 | #endif 7 | 8 | extern int currentVideoFrame; 9 | extern int videoFrameCount; 10 | extern int videoWidth; 11 | extern int videoHeight; 12 | extern float videoAR; 13 | 14 | #if RETRO_PLATFORM != RETRO_WII 15 | extern THEORAPLAY_Decoder *videoDecoder; 16 | extern const THEORAPLAY_VideoFrame *videoVidData; 17 | extern const THEORAPLAY_AudioPacket *videoAudioData; 18 | extern THEORAPLAY_Io callbacks; 19 | #endif 20 | 21 | extern byte videoSurface; 22 | extern int videoFilePos; 23 | extern int videoPlaying; // 0 = not playing, 1 = playing OGV, 2 = playing RSV 24 | extern int vidFrameMS; 25 | extern int vidBaseticks; 26 | extern float videoAR; 27 | 28 | void PlayVideoFile(char *filepath); 29 | void UpdateVideoFrame(); 30 | int ProcessVideo(); 31 | void StopVideoPlayback(); 32 | 33 | void SetupVideoBuffer(int width, int height); 34 | void CloseVideoBuffer(); 35 | 36 | #endif // !VIDEO_H 37 | -------------------------------------------------------------------------------- /dependencies/all/theoraplay/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2011-2019 Ryan C. Gordon. 3 | 4 | This software is provided 'as-is', without any express or implied warranty. 5 | In no event will the authors be held liable for any damages arising from 6 | the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software in a 14 | product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 20 | 3. This notice may not be removed or altered from any source distribution. 21 | 22 | Ryan C. Gordon 23 | 24 | -------------------------------------------------------------------------------- /dependencies/windows/dependencies.txt: -------------------------------------------------------------------------------- 1 | SDL2: https://www.libsdl.org/download-2.0.php 2 | download the appropriate development library for your compiler and unzip it in "./SDL2/" 3 | 4 | SDL1 (optional, use SDL2 if you're unsure): https://libsdl.org/download-1.2.php 5 | download the appropriate development library for your compiler and unzip it in "./SDL1/" 6 | 7 | libogg: https://xiph.org/downloads/ (libogg) 8 | download libogg and unzip it in "./libogg/", then build the static library 9 | 10 | libvorbis: https://xiph.org/downloads/ (libvorbis) 11 | download libvorbis and unzip it in "./libvorbis/", then build the VS2010 static library (win32/VS2010/vorbis_static.sln) 12 | 13 | libtheora: https://xiph.org/downloads/ (libtheora) 14 | download libtheora and unzip it in "./libtheora/", then build the VS2008 static library (win32/VS2008/libtheora_static.sln) 15 | ignore any building errors you may get, you should at least build the library itself which is all you need 16 | 17 | glew: http://glew.sourceforge.net/ download binaries, place the unzipped folder into "./" and rename it to "glew" -------------------------------------------------------------------------------- /dependencies/ios/dependencies.txt: -------------------------------------------------------------------------------- 1 | SDL2: https://www.libsdl.org/download-2.0.php 2 | Download the source for the latest SDL2 version and open the Xcode project in Xcode/, from there you need to build the "Framework-iOS" target to a generic iOS device, then place the built frameworks (hidapi.framework & SDL2.framework) in "./SDL2/" 3 | NOTE: you will need to create a project to build libSDL2Main.a manually, otherwise there will be "undefined references to _main" errors in the main Xcode project 4 | 5 | libogg: https://xiph.org/downloads/ (libogg) 6 | Download the source and create an Xcode project to build the library as a framework, once the framework is built (Ogg.framework), place it in ./ 7 | 8 | libvorbis: https://xiph.org/downloads/ (libvorbis) 9 | Download the source and create an Xcode project to build the library as a framework, once the framework is built (vorbis.framework), place it in ./ 10 | 11 | libtheora: https://xiph.org/downloads/ (libtheora) 12 | Download the source and create an Xcode project to build the library as a framework, once the framework is built (theora.framework), place it in ./ -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | IndentWidth: 4 2 | Language: Cpp 3 | AlignAfterOpenBracket: Align 4 | SortIncludes: false 5 | ColumnLimit: 150 6 | PointerAlignment: Right 7 | AccessModifierOffset: -4 8 | AllowShortFunctionsOnASingleLine: All 9 | AllowShortCaseLabelsOnASingleLine: true 10 | #AllowShortLambdasOnASingleLine: All 11 | AllowShortLoopsOnASingleLine: true 12 | BinPackArguments: true 13 | BinPackParameters: true 14 | SpaceAfterCStyleCast: false 15 | BreakBeforeTernaryOperators: true 16 | BreakBeforeBinaryOperators: NonAssignment 17 | Cpp11BracedListStyle: false 18 | IndentCaseLabels: true 19 | AlignTrailingComments: true 20 | AlignOperands: true 21 | AlignConsecutiveAssignments: true 22 | AlignConsecutiveDeclarations: false 23 | AlignConsecutiveMacros: true 24 | UseTab: Never 25 | BreakBeforeBraces: Custom 26 | BraceWrapping: 27 | AfterClass: true 28 | AfterControlStatement: false 29 | AfterEnum: false 30 | AfterFunction: true 31 | AfterNamespace: true 32 | AfterObjCDeclaration: false 33 | AfterStruct: false 34 | AfterUnion: false 35 | BeforeCatch: false 36 | BeforeElse: true 37 | IndentBraces: false 38 | -------------------------------------------------------------------------------- /RSDKv3.vita/build-internal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | apk add --no-cache make cmake 3 | 4 | function getSdl2() { 5 | wget https://github.com/rsn8887/SDL-Vita/releases/download/2.0.8dev_vita_rsn8887_git_20180523/sdl2_vita_20180523.tar.xz && \ 6 | mkdir -p ../dependencies/vita/sdl2 || true && \ 7 | tar -xf sdl2_vita_20180523.tar.xz -C ../dependencies/vita/sdl2 8 | rm sdl2_vita_20180523.tar.xz 9 | } 10 | 11 | function getLibTheora() { 12 | wget https://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2 && \ 13 | tar -xf libtheora-1.1.1.tar.bz2 -C ../dependencies/vita && \ 14 | (cd ../dependencies/vita/libtheora || \ 15 | (mv ../dependencies/vita/libtheora-1.1.1 ../dependencies/vita/libtheora && cd ../dependencies/vita/libtheora)) && \ 16 | cd ../dependencies/vita/libtheora && \ 17 | (./configure --host=arm-vita-eabi --prefix=${VITASDK}/arm-vita-eabi --disable-shared --enable-static --disable-spec --disable-examples) || 18 | cd - 19 | rm libtheora-1.1.1.tar.bz2 20 | } 21 | 22 | function installLibTheora() { 23 | cd ../dependencies/vita/libtheora && \ 24 | make install && \ 25 | cd - 26 | } 27 | 28 | # Download dependencies 29 | [ ! -d ../dependencies/vita/sdl2 ] && getSdl2 30 | [ ! -d ../dependencies/vita/libtheora ] && getLibTheora 31 | installLibTheora 32 | 33 | cmake . && \ 34 | make 35 | rm RSDKv3 # this is not ignored by .gitignore 36 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/decomp/rsdkv3/RSDKv3.java: -------------------------------------------------------------------------------- 1 | package com.decomp.rsdkv3; 2 | 3 | import android.Manifest; 4 | import android.content.Context; 5 | import android.os.Environment; 6 | 7 | import java.io.File; 8 | 9 | import org.libsdl.app.*; 10 | 11 | 12 | public class RSDKv3 extends SDLActivity { 13 | @Override 14 | protected void onStart() { 15 | super.onStart(); 16 | getBasePath(); 17 | } 18 | 19 | //Idk what the hell "has multi window" is, but I do NOT have multiple windows and therefore DO wanna pause/resume these threads 20 | @Override 21 | protected void onPause() { 22 | super.onPause(); 23 | if (mHasMultiWindow) { 24 | pauseNativeThread(); 25 | } 26 | } 27 | 28 | @Override 29 | protected void onResume() { 30 | super.onResume(); 31 | 32 | if (mHasMultiWindow) { 33 | resumeNativeThread(); 34 | } 35 | } 36 | 37 | public String getBasePath() { 38 | Context c = getApplicationContext(); 39 | requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0); 40 | String p = Environment.getExternalStorageDirectory().getAbsolutePath() + "/RSDK/v3"; 41 | //getExternalStorageDirectory is deprecated. I do not care. 42 | new File(p).mkdirs(); 43 | return p + "/"; 44 | } 45 | } -------------------------------------------------------------------------------- /dependencies/mac/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 19 | CFBundleShortVersionString 20 | $(MARKETING_VERSION) 21 | CFBundleVersion 22 | 1 23 | LSApplicationCategoryType 24 | public.app-category.games 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2021 Rubberduckycooly. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | NSSupportsAutomaticTermination 34 | 35 | NSSupportsSuddenTermination 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /RSDKv3/Math.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MATH_H 2 | #define MATH_H 3 | 4 | #ifndef M_PI 5 | #define M_PI 3.14159265358979323846264338327950288 6 | #endif 7 | 8 | //#define M_PI (3.1415927) 9 | 10 | #define MEM_ZERO(x) memset(&(x), 0, sizeof((x))) 11 | #define MEM_ZEROP(x) memset((x), 0, sizeof(*(x))) 12 | 13 | extern int sinMLookupTable[0x200]; 14 | extern int cosMLookupTable[0x200]; 15 | 16 | extern int sin512LookupTable[0x200]; 17 | extern int cos512LookupTable[0x200]; 18 | 19 | extern int sin256LookupTable[0x100]; 20 | extern int cos256LookupTable[0x100]; 21 | 22 | extern byte arcTan256LookupTable[0x100 * 0x100]; 23 | 24 | // Setup Angles 25 | void CalculateTrigAngles(); 26 | 27 | inline int Sin512(int angle) 28 | { 29 | if (angle < 0) 30 | angle = 0x200 - angle; 31 | angle &= 0x1FF; 32 | return sin512LookupTable[angle]; 33 | } 34 | 35 | inline int Cos512(int angle) 36 | { 37 | if (angle < 0) 38 | angle = 0x200 - angle; 39 | angle &= 0x1FF; 40 | return cos512LookupTable[angle]; 41 | } 42 | 43 | inline int Sin256(int angle) 44 | { 45 | if (angle < 0) 46 | angle = 0x100 - angle; 47 | angle &= 0xFFu; 48 | return sin256LookupTable[angle]; 49 | } 50 | 51 | inline int Cos256(int angle) 52 | { 53 | if (angle < 0) 54 | angle = 0x100 - angle; 55 | angle &= 0xFFu; 56 | return cos256LookupTable[angle]; 57 | } 58 | 59 | // Get Arc Tan value 60 | byte ArcTanLookup(int X, int Y); 61 | 62 | #endif // !MATH_H 63 | -------------------------------------------------------------------------------- /RSDKv3/String.hpp: -------------------------------------------------------------------------------- 1 | #ifndef STRING_H 2 | #define STRING_H 3 | 4 | inline void StrCopy(char *dest, const char *src) 5 | { 6 | int i = 0; 7 | 8 | for (; src[i]; ++i) dest[i] = src[i]; 9 | 10 | dest[i] = 0; 11 | } 12 | 13 | inline void StrAdd(char *dest, const char *src) 14 | { 15 | int destStrPos = 0; 16 | int srcStrPos = 0; 17 | while (dest[destStrPos]) ++destStrPos; 18 | while (true) { 19 | if (!src[srcStrPos]) { 20 | break; 21 | } 22 | dest[destStrPos++] = src[srcStrPos++]; 23 | } 24 | dest[destStrPos] = 0; 25 | } 26 | 27 | inline bool StrComp(const char *stringA, const char *stringB) 28 | { 29 | bool match = true; 30 | bool finished = false; 31 | while (!finished) { 32 | if (*stringA == *stringB || *stringA == *stringB + ' ' || *stringA == *stringB - ' ') { 33 | if (*stringA) { 34 | ++stringA; 35 | ++stringB; 36 | } 37 | else { 38 | finished = true; 39 | } 40 | } 41 | else { 42 | match = false; 43 | finished = true; 44 | } 45 | } 46 | return match; 47 | } 48 | 49 | inline int StrLength(const char *string) 50 | { 51 | int len = 0; 52 | for (len = 0; string[len]; len++) 53 | ; 54 | return len; 55 | } 56 | int FindStringToken(const char *string, const char *token, sbyte stopID); 57 | 58 | #endif // !STRING_H 59 | -------------------------------------------------------------------------------- /RSDKv3/fcaseopen.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009 Keith Bauer 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #ifndef fcaseopen_h 24 | #define fcaseopen_h 25 | 26 | #include 27 | 28 | #if defined(__cplusplus) 29 | extern "C" { 30 | #endif 31 | 32 | extern FILE *fcaseopen(char const *path, char const *mode); 33 | 34 | extern void casechdir(char const *path); 35 | 36 | #if defined(__cplusplus) 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /flatpak/README.md: -------------------------------------------------------------------------------- 1 | # Flatpak 2 | 3 | You will need the FreeDesktop.org 21.08 SDK installed, if you don't have it, 4 | install [Flathub](https://flathub.org/) which provides it. 5 | 6 | # Sonic CD (Original Steam Version) Flatpak 7 | 8 | First, go to your Steam library, right click on Sonic CD and click `Manage` > `Browse local files`. 9 | Copy the `Data.rsdk` file and the `videos` folder into this directory. 10 | 11 | To build and install the flatpak, run: 12 | 13 | **System-wide:** 14 | ``` 15 | $ sudo flatpak-builder --install --force-clean soniccd com.sega.SonicCDSteam.json 16 | ``` 17 | **User:** 18 | ``` 19 | $ flatpak-builder --user --install --force-clean soniccd com.sega.SonicCDSteam.json 20 | ``` 21 | 22 | # Sonic CD (Android Version) Flatpak 23 | 24 | **This method will not install the video files, as the decompilation 25 | only supports video files from the Steam version.** 26 | 27 | First, you need to install the game on an Android device. 28 | To get it, visit https://www.sega.com/games/sonic-cd. 29 | 30 | Once you have the game, use a file manager on your device to navigate 31 | to the directory `Android/obb/com.sega.soniccd.classic` and copy the 32 | `patch.[number].com.sega.soniccd.classic.obb` file into this directory as `Data.rsdk`. 33 | 34 | To build and install the flatpak, run: 35 | 36 | **System-wide:** 37 | ``` 38 | $ sudo flatpak-builder --install --force-clean soniccd com.sega.SonicCDAndroid.json 39 | ``` 40 | **User:** 41 | ``` 42 | $ flatpak-builder --user --install --force-clean soniccd com.sega.SonicCDAndroid.json 43 | ``` 44 | 45 | -------------------------------------------------------------------------------- /dependencies/mac/cocoaHelpers.mm: -------------------------------------------------------------------------------- 1 | #ifdef __APPLE__ 2 | 3 | #import 4 | #import 5 | #include "cocoaHelpers.hpp" 6 | #include 7 | 8 | void getResourcesPath(char* buffer, int bufferSize) 9 | { 10 | @autoreleasepool 11 | { 12 | NSString* appFolder = [NSBundle.mainBundle.bundlePath stringByDeletingLastPathComponent]; 13 | NSString* dataFile = [appFolder stringByAppendingString:@"/Data.rsdk"]; 14 | NSString* dataFolder = [appFolder stringByAppendingString:@"/Data"]; 15 | NSString* settingsFile = [appFolder stringByAppendingString:@"/settings.ini"]; 16 | if([NSFileManager.defaultManager fileExistsAtPath:dataFile] || 17 | [NSFileManager.defaultManager fileExistsAtPath:settingsFile] || 18 | [NSFileManager.defaultManager fileExistsAtPath:dataFolder]){ 19 | [appFolder getCString:buffer maxLength:bufferSize encoding:NSUTF8StringEncoding]; 20 | return; 21 | } 22 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); 23 | NSString *applicationSupportDirectory = [paths firstObject]; 24 | NSString* gameData = [applicationSupportDirectory stringByAppendingString:@"/RSDKv3"]; 25 | if(![NSFileManager.defaultManager fileExistsAtPath:gameData]){ 26 | mkdir([gameData cStringUsingEncoding:NSUTF8StringEncoding], 0777); 27 | } 28 | [gameData getCString:buffer maxLength:bufferSize encoding:NSUTF8StringEncoding]; 29 | return; 30 | } 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /RSDKv3/ModAPI.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MOD_API_H 2 | #define MOD_API_H 3 | 4 | #if RETRO_USE_MOD_LOADER 5 | #include 6 | #include 7 | #include 8 | #if RETRO_PLATFORM == RETRO_WII 9 | #include "tinyxml2.h" 10 | #else 11 | #include 12 | #endif 13 | 14 | #define PLAYERNAME_COUNT (0x10) 15 | 16 | struct ModInfo { 17 | std::string name; 18 | std::string desc; 19 | std::string author; 20 | std::string version; 21 | std::map fileMap; 22 | std::string folder; 23 | bool useScripts; 24 | int disableFocusPause; 25 | bool redirectSave; 26 | bool disableSaveIniOverride; 27 | std::string savePath; 28 | bool active; 29 | }; 30 | 31 | extern std::vector modList; 32 | extern int activeMod; 33 | 34 | extern char modsPath[0x100]; 35 | 36 | extern bool redirectSave; 37 | extern bool disableSaveIniOverride; 38 | 39 | extern char modTypeNames[OBJECT_COUNT][0x40]; 40 | extern char modScriptPaths[OBJECT_COUNT][0x40]; 41 | extern byte modScriptFlags[OBJECT_COUNT]; 42 | extern byte modObjCount; 43 | 44 | extern char playerNames[PLAYERNAME_COUNT][0x20]; 45 | extern byte playerCount; 46 | 47 | inline void SetActiveMod(int id) { activeMod = id; } 48 | 49 | void InitMods(); 50 | bool LoadMod(ModInfo *info, std::string modsPath, std::string folder, bool active); 51 | void ScanModFolder(ModInfo *info); 52 | void SaveMods(); 53 | 54 | int OpenModMenu(); 55 | 56 | void RefreshEngine(); 57 | 58 | #endif 59 | 60 | #if RETRO_USE_MOD_LOADER || !RETRO_USE_ORIGINAL_CODE 61 | extern char savePath[0x100]; 62 | int GetSceneID(byte listID, const char *sceneName); 63 | #endif 64 | 65 | #endif -------------------------------------------------------------------------------- /RSDKv3/Text.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TEXTSYSTEM_H 2 | #define TEXTSYSTEM_H 3 | 4 | #define TEXTDATA_COUNT (0x2800) 5 | #define TEXTENTRY_COUNT (0x200) 6 | #define TEXTMENU_COUNT (0x2) 7 | 8 | #define FONTCHAR_COUNT (0x400) 9 | 10 | enum TextInfoTypes { TEXTINFO_TEXTDATA = 0, TEXTINFO_TEXTSIZE = 1, TEXTINFO_ROWCOUNT = 2 }; 11 | 12 | struct TextMenu { 13 | ushort textData[TEXTDATA_COUNT]; 14 | int entryStart[TEXTENTRY_COUNT]; 15 | int entrySize[TEXTENTRY_COUNT]; 16 | byte entryHighlight[TEXTENTRY_COUNT]; 17 | int textDataPos; 18 | int selection1; 19 | int selection2; 20 | ushort rowCount; 21 | ushort visibleRowCount; 22 | ushort visibleRowOffset; 23 | byte alignment; 24 | byte selectionCount; 25 | sbyte timer; 26 | }; 27 | 28 | struct FontCharacter { 29 | int id; 30 | short srcX; 31 | short srcY; 32 | short width; 33 | short height; 34 | short pivotX; 35 | short pivotY; 36 | short xAdvance; 37 | }; 38 | 39 | extern TextMenu gameMenu[TEXTMENU_COUNT]; 40 | extern int textMenuSurfaceNo; 41 | 42 | extern FontCharacter fontCharacterList[FONTCHAR_COUNT]; 43 | 44 | void LoadFontFile(const char *filePath); 45 | void LoadTextFile(TextMenu *menu, const char *filePath, byte mapCode); 46 | void LoadConfigListText(TextMenu *menu, int listNo); 47 | 48 | void SetupTextMenu(TextMenu *menu, int rowCount); 49 | void AddTextMenuEntry(TextMenu *menu, const char *text); 50 | void AddTextMenuEntryMapped(TextMenu *menu, const char *text); 51 | void SetTextMenuEntry(TextMenu *menu, const char *text, int rowID); 52 | void EditTextMenuEntry(TextMenu *menu, const char *text, int rowID); 53 | 54 | #endif // !TEXTSYSTEM_H 55 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # RSDKv3/v4 DECOMPILATION SOURCE CODE LICENSE v2 2 | 3 | The code in this repository is a decompilation of RSDK (Retro-Engine) version 3 or 4. 4 | There is original code in this repo, but most of the code is to be functionally the same as the version of RSDK this repo specifies. 5 | 6 | This code is provided as-is, that is to say, without liability or warranty. 7 | Original authors of RSDK and authors of the decompilation are not held responsible for any damages or other claims said. 8 | 9 | You may copy, modify, contribute, and distribute, for public or private use, **as long as the following are followed:** 10 | - All pre-built executables provided TO ANYONE *PRIVATE OR OTHERWISE* **must be built with DLC disabled by __default.__** 11 | - A define, `RSDK_AUTOBUILD`, and a CMake flag, `RETRO_DISABLE_PLUS`, are already provided for you to force DLC off. 12 | - Creating a configuration setting *is allowed,* so long as it is set to off by default. 13 | - *No such configuration will be pushed to the master repository.* 14 | - This is to ensure an extra layer of legal protection for Sonic Origins Plus. 15 | - You may not use the decompilation for commercial (any sort of profit) use. 16 | - You must clearly specify that the decompilation and original code are not yours: the developers of both must be credited. 17 | - You may not distribute assets used to run the game not directly provided by the repository (other than unique, modded assets). 18 | - This license must be in all modified copies of source code, and all forks must follow this license. 19 | 20 | Original RSDK author: Christian "Taxman" Whitehead 21 | 22 | Decompilation authors: Rubberduckycooly and st×tic 23 | -------------------------------------------------------------------------------- /RSDKv3/Ini.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INI_H 2 | #define INI_H 3 | 4 | #include 5 | 6 | class IniParser 7 | { 8 | public: 9 | enum ItemType { 10 | INI_ITEM_STRING, 11 | INI_ITEM_INT, 12 | INI_ITEM_FLOAT, 13 | INI_ITEM_BOOL, 14 | INI_ITEM_COMMENT, 15 | }; 16 | 17 | struct ConfigItem { 18 | ConfigItem() 19 | { 20 | sprintf(section, "%s", ""); 21 | sprintf(key, "%s", ""); 22 | sprintf(value, "%s", ""); 23 | hasSection = false; 24 | type = INI_ITEM_STRING; 25 | } 26 | char section[0x20]; 27 | bool hasSection = false; 28 | char key[0x40]; 29 | char value[0x100]; 30 | byte type = INI_ITEM_STRING; 31 | }; 32 | 33 | IniParser() { items.clear(); } 34 | IniParser(const char *filename, bool addPath = true); 35 | 36 | int GetString(const char *section, const char *key, char *dest); 37 | int GetInteger(const char *section, const char *key, int *dest); 38 | int GetFloat(const char *section, const char *key, float *dest); 39 | int GetBool(const char *section, const char *key, bool *dest); 40 | int SetString(const char *section, const char *key, char *value); 41 | int SetInteger(const char *section, const char *key, int value); 42 | int SetFloat(const char *section, const char *key, float value); 43 | int SetBool(const char *section, const char *key, bool value); 44 | int SetComment(const char *section, const char *key, const char *comment); 45 | void Write(const char *filename, bool addPath = true); 46 | 47 | std::vector items; 48 | }; 49 | #endif // !INI_H 50 | -------------------------------------------------------------------------------- /dependencies/ios/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | metal 29 | 30 | UIRequiresFullScreen 31 | 32 | UIStatusBarHidden 33 | 34 | UISupportedInterfaceOrientations 35 | 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /dependencies/android/README.md: -------------------------------------------------------------------------------- 1 | # Android 2 | 3 | ## Install dependencies 4 | * SDL2: [Download the source code of 2.28.3](https://libsdl.org/release/SDL2-2.28.3.zip) and unzip it in `dependencies/android/SDL`. 5 | 6 | * GLEW: [Download the binaries](http://glew.sourceforge.net/) and unzip it in `dependencies/android/glew`. 7 | 8 | * libogg: [Download](https://xiph.org/downloads/) and unzip it in `dependencies/android/libogg`. Then, copy "config_types.h" from here and paste it in "./libogg/include/ogg/". 9 | 10 | * libvorbis: [Download](https://xiph.org/downloads/) and unzip it in `dependencies/android/libvorbis`. 11 | 12 | * libtheora: [Download](https://xiph.org/downloads/) and unzip it in `dependencies/android/libtheora`. 13 | 14 | * Ensure the symbolic links in `[root]/android/app/jni` are correct: 15 | * `SDL` -> Root of the Android SDL dependency 16 | * `src` -> Root of the RSDKv3 repository 17 | 18 | To add symbolic links, do the following: 19 | * Windows: `mklink /d "[name-of-symlink]" "[path]"` 20 | * Linux: `ln -s "[path]" "[name-of-symlink]"` 21 | * Open `[root]/android/` in Android Studio, install the NDK and everything else that it asks for, and build. 22 | 23 | ## Common build issues (Windows) 24 | ### `make: *** INTERNAL: readdir: No such file or directory` 25 | Delete `android/app/build` and try again. This occurs when the path is short enough to build, but too long for a rebuild. 26 | ### `make: Interrupt/exception caught (code = 0xc0000005)` 27 | Your paths are too long. Try renaming the symbolic links to something shorter, or make a symbolic link to RSDKv3 closer to the root of the drive and open the project through there (e.x. C:/RSDKv3/android). *I haven't had either issue since I did this.* 28 | -------------------------------------------------------------------------------- /dependencies/mac/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "RSDKv3 Decomp Icon-16.png", 5 | "idiom" : "mac", 6 | "scale" : "1x", 7 | "size" : "16x16" 8 | }, 9 | { 10 | "filename" : "RSDKv3 Decomp Icon-32.png", 11 | "idiom" : "mac", 12 | "scale" : "2x", 13 | "size" : "16x16" 14 | }, 15 | { 16 | "filename" : "RSDKv3 Decomp Icon-33.png", 17 | "idiom" : "mac", 18 | "scale" : "1x", 19 | "size" : "32x32" 20 | }, 21 | { 22 | "filename" : "RSDKv3 Decomp Icon-64.png", 23 | "idiom" : "mac", 24 | "scale" : "2x", 25 | "size" : "32x32" 26 | }, 27 | { 28 | "filename" : "RSDKv3 Decomp Icon-128.png", 29 | "idiom" : "mac", 30 | "scale" : "1x", 31 | "size" : "128x128" 32 | }, 33 | { 34 | "filename" : "RSDKv3 Decomp Icon-256.png", 35 | "idiom" : "mac", 36 | "scale" : "2x", 37 | "size" : "128x128" 38 | }, 39 | { 40 | "filename" : "RSDKv3 Decomp Icon-257.png", 41 | "idiom" : "mac", 42 | "scale" : "1x", 43 | "size" : "256x256" 44 | }, 45 | { 46 | "filename" : "RSDKv3 Decomp Icon-512.png", 47 | "idiom" : "mac", 48 | "scale" : "2x", 49 | "size" : "256x256" 50 | }, 51 | { 52 | "filename" : "RSDKv3 Decomp Icon-513.png", 53 | "idiom" : "mac", 54 | "scale" : "1x", 55 | "size" : "512x512" 56 | }, 57 | { 58 | "filename" : "RSDKv3 Decomp Icon-1024.png", 59 | "idiom" : "mac", 60 | "scale" : "2x", 61 | "size" : "512x512" 62 | } 63 | ], 64 | "info" : { 65 | "author" : "xcode", 66 | "version" : 1 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /RSDKv3/Player.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PLAYER_H 2 | #define PLAYER_H 3 | 4 | #define PLAYER_COUNT (2) 5 | 6 | enum PlayerControlModes { 7 | CONTROLMODE_NONE = -1, 8 | CONTROLMODE_NORMAL = 0, 9 | CONTROLMODE_SIDEKICK = 1, 10 | }; 11 | 12 | struct Player { 13 | int entityNo; 14 | int XPos; 15 | int YPos; 16 | int XVelocity; 17 | int YVelocity; 18 | int speed; 19 | int screenXPos; 20 | int screenYPos; 21 | int angle; 22 | int timer; 23 | int lookPos; 24 | int values[8]; 25 | byte collisionMode; 26 | byte skidding; 27 | byte pushing; 28 | byte collisionPlane; 29 | sbyte controlMode; 30 | byte controlLock; 31 | int topSpeed; 32 | int acceleration; 33 | int deceleration; 34 | int airAcceleration; 35 | int airDeceleration; 36 | int gravityStrength; 37 | int jumpStrength; 38 | int jumpCap; 39 | int rollingAcceleration; 40 | int rollingDeceleration; 41 | byte visible; 42 | byte tileCollisions; 43 | byte objectInteractions; 44 | byte left; 45 | byte right; 46 | byte up; 47 | byte down; 48 | byte jumpPress; 49 | byte jumpHold; 50 | byte followPlayer1; 51 | byte trackScroll; 52 | byte gravity; 53 | byte water; 54 | byte flailing[3]; 55 | AnimationFile *animationFile; 56 | Entity *boundEntity; 57 | }; 58 | 59 | extern Player playerList[PLAYER_COUNT]; 60 | extern int playerListPos; 61 | extern int activePlayer; 62 | extern int activePlayerCount; 63 | 64 | extern ushort upBuffer; 65 | extern ushort downBuffer; 66 | extern ushort leftBuffer; 67 | extern ushort rightBuffer; 68 | extern ushort jumpPressBuffer; 69 | extern ushort jumpHoldBuffer; 70 | 71 | void ProcessPlayerControl(Player *player); 72 | 73 | #endif // !PLAYER_H 74 | -------------------------------------------------------------------------------- /dependencies/ios/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /RSDKv3/Debug.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DEBUG_H 2 | #define DEBUG_H 3 | 4 | #if RETRO_PLATFORM == RETRO_ANDROID 5 | #include 6 | #endif 7 | 8 | inline void PrintLog(const char *msg, ...) 9 | { 10 | if (engineDebugMode) { 11 | char buffer[0x100]; 12 | 13 | // make the full string 14 | va_list args; 15 | va_start(args, msg); 16 | vsprintf(buffer, msg, args); 17 | printf("%s\n", buffer); 18 | sprintf(buffer, "%s\n", buffer); 19 | 20 | char pathBuffer[0x100]; 21 | #if RETRO_PLATFORM == RETRO_OSX || RETRO_PLATFORM == RETRO_UWP 22 | if (!usingCWD) 23 | #if RETRO_PLATFORM == RETRO_OSX 24 | { 25 | char logBuffer[0x100]; 26 | getResourcesPath(logBuffer, sizeof(logBuffer)); 27 | sprintf(pathBuffer, "%s/log.txt", logBuffer); 28 | } 29 | #else 30 | sprintf(pathBuffer, "%s/log.txt", getResourcesPath()); 31 | #endif 32 | else 33 | sprintf(pathBuffer, "log.txt"); 34 | #elif RETRO_PLATFORM == RETRO_ANDROID 35 | sprintf(pathBuffer, "%s/log.txt", gamePath); 36 | __android_log_print(ANDROID_LOG_INFO, "RSDKv3", "%s", buffer); 37 | #else 38 | sprintf(pathBuffer, BASE_PATH "log.txt"); 39 | #endif 40 | FileIO *file = fOpen(pathBuffer, "a"); 41 | if (file) { 42 | fWrite(&buffer, 1, StrLength(buffer), file); 43 | fClose(file); 44 | } 45 | } 46 | } 47 | 48 | enum DevMenuMenus { 49 | DEVMENU_MAIN, 50 | DEVMENU_PLAYERSEL, 51 | DEVMENU_STAGELISTSEL, 52 | DEVMENU_STAGESEL, 53 | DEVMENU_SCRIPTERROR, 54 | #if RETRO_USE_MOD_LOADER 55 | DEVMENU_MODMENU, 56 | #endif 57 | }; 58 | 59 | void InitDevMenu(); 60 | void InitErrorMessage(); 61 | void ProcessStageSelect(); 62 | 63 | #endif //! DEBUG_H 64 | -------------------------------------------------------------------------------- /RSDKv3/Animation.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_H 2 | #define ANIMATION_H 3 | 4 | #define ANIFILE_COUNT (0x100) 5 | #define ANIMATION_COUNT (0x400) 6 | #define SPRITEFRAME_COUNT (0x1000) 7 | 8 | #define HITBOX_COUNT (0x20) 9 | #define HITBOX_DIR_COUNT (0x8) 10 | 11 | enum AnimrotationFlags { ROTSTYLE_NONE, ROTSTYLE_FULL, ROTSTYLE_45DEG, ROTSTYLE_STATICFRAMES }; 12 | 13 | struct AnimationFile { 14 | char fileName[0x20]; 15 | int animCount; 16 | int aniListOffset; 17 | int hitboxListOffset; 18 | }; 19 | 20 | struct SpriteAnimation { 21 | char name[16]; 22 | byte frameCount; 23 | byte speed; 24 | byte loopPoint; 25 | byte rotationStyle; 26 | int frameListOffset; 27 | }; 28 | 29 | struct SpriteFrame { 30 | int sprX; 31 | int sprY; 32 | int width; 33 | int height; 34 | int pivotX; 35 | int pivotY; 36 | byte sheetID; 37 | byte hitboxID; 38 | }; 39 | 40 | struct Hitbox { 41 | sbyte left[HITBOX_DIR_COUNT]; 42 | sbyte top[HITBOX_DIR_COUNT]; 43 | sbyte right[HITBOX_DIR_COUNT]; 44 | sbyte bottom[HITBOX_DIR_COUNT]; 45 | }; 46 | 47 | extern AnimationFile animationFileList[ANIFILE_COUNT]; 48 | extern int animationFileCount; 49 | 50 | extern SpriteFrame scriptFrames[SPRITEFRAME_COUNT]; 51 | extern int scriptFrameCount; 52 | 53 | extern SpriteFrame animFrames[SPRITEFRAME_COUNT]; 54 | extern int animFrameCount; 55 | extern SpriteAnimation animationList[ANIMATION_COUNT]; 56 | extern int animationCount; 57 | extern Hitbox hitboxList[HITBOX_COUNT]; 58 | extern int hitboxCount; 59 | 60 | void LoadAnimationFile(const char *FilePath); 61 | void ClearAnimationData(); 62 | 63 | AnimationFile *AddAnimationFile(const char *FilePath); 64 | 65 | inline AnimationFile *GetDefaultAnimationRef() { return &animationFileList[0]; } 66 | 67 | void ProcessObjectAnimation(void *objScr, void *ent); 68 | 69 | #endif // !ANIMATION_H 70 | -------------------------------------------------------------------------------- /RSDKv3/main.cpp: -------------------------------------------------------------------------------- 1 | #include "RetroEngine.hpp" 2 | 3 | #if !RETRO_USE_ORIGINAL_CODE 4 | 5 | #if RETRO_PLATFORM == RETRO_WIN && _MSC_VER 6 | #include "Windows.h" 7 | #endif 8 | 9 | void parseArguments(int argc, char *argv[]) 10 | { 11 | for (int a = 0; a < argc; ++a) { 12 | const char *find = ""; 13 | 14 | find = strstr(argv[a], "stage="); 15 | if (find) { 16 | int b = 0; 17 | int c = 6; 18 | while (find[c] && find[c] != ';') Engine.startSceneFolder[b++] = find[c++]; 19 | Engine.startSceneFolder[b] = 0; 20 | } 21 | 22 | find = strstr(argv[a], "scene="); 23 | if (find) { 24 | int b = 0; 25 | int c = 6; 26 | while (find[c] && find[c] != ';') Engine.startSceneID[b++] = find[c++]; 27 | Engine.startSceneID[b] = 0; 28 | } 29 | 30 | find = strstr(argv[a], "console=true"); 31 | if (find) { 32 | engineDebugMode = true; 33 | Engine.devMenu = true; 34 | Engine.consoleEnabled = true; 35 | #if RETRO_PLATFORM == RETRO_WIN && _MSC_VER 36 | AllocConsole(); 37 | freopen_s((FILE **)stdin, "CONIN$", "w", stdin); 38 | freopen_s((FILE **)stdout, "CONOUT$", "w", stdout); 39 | freopen_s((FILE **)stderr, "CONOUT$", "w", stderr); 40 | #endif 41 | } 42 | 43 | find = strstr(argv[a], "usingCWD=true"); 44 | if (find) { 45 | usingCWD = true; 46 | } 47 | } 48 | } 49 | #endif 50 | 51 | int main(int argc, char *argv[]) 52 | { 53 | #if !RETRO_USE_ORIGINAL_CODE 54 | parseArguments(argc, argv); 55 | #endif 56 | 57 | Engine.Init(); 58 | Engine.Run(); 59 | 60 | #if !RETRO_USE_ORIGINAL_CODE 61 | if (Engine.consoleEnabled) { 62 | #if RETRO_PLATFORM == RETRO_WIN && _MSC_VER 63 | FreeConsole(); 64 | #endif 65 | } 66 | #endif 67 | 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /RSDKv3UWP/Package.appxmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | Sonic CD 10 | SEGA 11 | Assets\StoreLogo.png 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Makefile.msys2: -------------------------------------------------------------------------------- 1 | ifeq ($(STATIC),1) 2 | PKG_CONFIG_STATIC_FLAG = --static 3 | CXXFLAGS_ALL += -static 4 | endif 5 | 6 | CXXFLAGS_ALL += -MMD -MP -MF objects/$*.d $(shell pkg-config --cflags $(PKG_CONFIG_STATIC_FLAG) vorbisfile vorbis theoradec sdl2 glew) $(CXXFLAGS) \ 7 | -DGLEW_STATIC \ 8 | -Idependencies/all/filesystem/include \ 9 | -Idependencies/all/theoraplay \ 10 | -Idependencies/all/tinyxml2/ 11 | LDFLAGS_ALL += $(LDFLAGS) 12 | LIBS_ALL += $(shell pkg-config --libs $(PKG_CONFIG_STATIC_FLAG) vorbisfile vorbis theoradec sdl2 glew) -lopengl32 -lws2_32 -pthread $(LIBS) 13 | 14 | SOURCES = \ 15 | dependencies/all/tinyxml2/tinyxml2.cpp \ 16 | dependencies/all/theoraplay/theoraplay.c \ 17 | RSDKv3/Animation.cpp \ 18 | RSDKv3/Audio.cpp \ 19 | RSDKv3/Collision.cpp \ 20 | RSDKv3/Debug.cpp \ 21 | RSDKv3/Drawing.cpp \ 22 | RSDKv3/Ini.cpp \ 23 | RSDKv3/Input.cpp \ 24 | RSDKv3/main.cpp \ 25 | RSDKv3/ModAPI.cpp \ 26 | RSDKv3/Math.cpp \ 27 | RSDKv3/Object.cpp \ 28 | RSDKv3/Palette.cpp \ 29 | RSDKv3/Player.cpp \ 30 | RSDKv3/Reader.cpp \ 31 | RSDKv3/RetroEngine.cpp \ 32 | RSDKv3/Scene.cpp \ 33 | RSDKv3/Scene3D.cpp \ 34 | RSDKv3/Script.cpp \ 35 | RSDKv3/Sprite.cpp \ 36 | RSDKv3/String.cpp \ 37 | RSDKv3/Text.cpp \ 38 | RSDKv3/Userdata.cpp \ 39 | RSDKv3/Video.cpp 40 | 41 | 42 | ifeq ($(FORCE_CASE_INSENSITIVE),1) 43 | CXXFLAGS_ALL += -DFORCE_CASE_INSENSITIVE 44 | SOURCES += RSDKv3/fcaseopen.c 45 | endif 46 | 47 | OBJECTS = $(SOURCES:%=objects/%.o) 48 | DEPENDENCIES = $(SOURCES:%=objects/%.d) 49 | 50 | all: bin/RSDKv3 51 | 52 | include $(wildcard $(DEPENDENCIES)) 53 | 54 | objects/%.o: % 55 | mkdir -p $(@D) 56 | $(CXX) $(CXXFLAGS_ALL) -std=c++17 $< -o $@ -c 57 | 58 | bin/RSDKv3: $(OBJECTS) 59 | mkdir -p $(@D) 60 | $(CXX) $(CXXFLAGS_ALL) $(LDFLAGS_ALL) $^ -o $@ $(LIBS_ALL) 61 | 62 | install: bin/RSDKv3 63 | install -Dp -m755 bin/RSDKv3 $(prefix)/bin/RSDKv3 64 | chmod -x $(prefix)/bin/RSDKv3 65 | 66 | clean: 67 | rm -r -f bin && rm -r -f objects 68 | -------------------------------------------------------------------------------- /RSDKv3/Object.hpp: -------------------------------------------------------------------------------- 1 | #ifndef OBJECT_H 2 | #define OBJECT_H 3 | 4 | #define ENTITY_COUNT (0x4A0) 5 | #define TEMPENTITY_START (ENTITY_COUNT - 0x80) 6 | #define OBJECT_COUNT (0x100) 7 | 8 | struct Entity { 9 | int XPos; 10 | int YPos; 11 | int values[8]; 12 | int scale; 13 | int rotation; 14 | int animationTimer; 15 | int animationSpeed; 16 | byte type; 17 | byte propertyValue; 18 | byte state; 19 | byte priority; 20 | byte drawOrder; 21 | byte direction; 22 | byte inkEffect; 23 | byte alpha; 24 | byte animation; 25 | byte prevAnimation; 26 | byte frame; 27 | }; 28 | 29 | enum ObjectTypes { 30 | OBJ_TYPE_BLANKOBJECT = 0 // 0 is always blank obj 31 | }; 32 | 33 | enum ObjectPriority { 34 | // The entity is active if the entity is on screen or within 128 pixels of the screen borders on any axis 35 | PRIORITY_BOUNDS, 36 | // The entity is always active, unless the stage state is PAUSED or FROZEN 37 | PRIORITY_ACTIVE, 38 | // Same as PRIORITY_ACTIVE, the entity even runs when the stage state is PAUSED or FROZEN 39 | PRIORITY_ALWAYS, 40 | // Same as PRIORITY_BOUNDS, however it only does checks on the x-axis, so when in bounds on the x-axis, the y position doesn't matter 41 | PRIORITY_XBOUNDS, 42 | // Same as PRIORITY_BOUNDS, however the entity's type will be set to BLANK OBJECT when it becomes inactive 43 | PRIORITY_BOUNDS_DESTROY, 44 | // Never Active. 45 | PRIORITY_INACTIVE, 46 | }; 47 | 48 | extern int objectLoop; 49 | extern int curObjectType; 50 | extern Entity objectEntityList[ENTITY_COUNT]; 51 | 52 | extern char typeNames[OBJECT_COUNT][0x40]; 53 | 54 | extern int OBJECT_BORDER_X1; 55 | extern int OBJECT_BORDER_X2; 56 | extern const int OBJECT_BORDER_Y1; 57 | extern const int OBJECT_BORDER_Y2; 58 | 59 | void ProcessStartupObjects(); 60 | void ProcessObjects(); 61 | void ProcessPausedObjects(); 62 | 63 | void SetObjectTypeName(const char *objectName, int objectID); 64 | 65 | #endif // !OBJECT_H 66 | -------------------------------------------------------------------------------- /dependencies/ios/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY') 2 | def buildAsApplication = !buildAsLibrary 3 | if (buildAsApplication) { 4 | apply plugin: 'com.android.application' 5 | } 6 | else { 7 | apply plugin: 'com.android.library' 8 | } 9 | 10 | def autobuildFlag = false 11 | 12 | android { 13 | ndkVersion "22.1.7171670" 14 | compileSdkVersion 29 15 | defaultConfig { 16 | if (buildAsApplication) { 17 | applicationId "com.decomp.rsdkv3" 18 | } 19 | minSdkVersion 23 20 | targetSdkVersion 29 21 | versionCode 1 22 | versionName "1.3.2" 23 | if(project.hasProperty("RETRO_DISABLE_PLUS")) 24 | autobuildFlag = true 25 | externalNativeBuild { 26 | cmake { 27 | arguments "-DAPP_PLATFORM=android-16", "-DANDROID_STL=c++_static", "-DPLATFORM=Android", "-DRETRO_DISABLE_PLUS=$autobuildFlag" 28 | abiFilters 'armeabi-v7a', 'arm64-v8a' 29 | } 30 | } 31 | } 32 | buildTypes { 33 | release { 34 | minifyEnabled false 35 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 36 | } 37 | } 38 | if (!project.hasProperty('EXCLUDE_NATIVE_LIBS')) { 39 | sourceSets.main { 40 | jniLibs.srcDir 'libs' 41 | } 42 | externalNativeBuild { 43 | cmake { 44 | path 'jni/CMakeLists.txt' 45 | } 46 | } 47 | 48 | } 49 | lintOptions { 50 | abortOnError false 51 | } 52 | 53 | if (buildAsLibrary) { 54 | libraryVariants.all { variant -> 55 | variant.outputs.each { output -> 56 | def outputFile = output.outputFile 57 | if (outputFile != null && outputFile.name.endsWith(".aar")) { 58 | def fileName = "com.decomp.rsdkv3.aar" 59 | output.outputFile = new File(outputFile.parent, fileName) 60 | } 61 | } 62 | } 63 | } 64 | } 65 | 66 | dependencies { 67 | implementation fileTree(include: ['*.jar'], dir: 'libs') 68 | } 69 | -------------------------------------------------------------------------------- /RSDKv3/Userdata.hpp: -------------------------------------------------------------------------------- 1 | #ifndef USERDATA_H 2 | #define USERDATA_H 3 | 4 | #define GLOBALVAR_COUNT (0x100) 5 | 6 | #define ACHIEVEMENT_COUNT (0x40) 7 | #define LEADERBOARD_COUNT (0x80) 8 | 9 | #define MOD_COUNT (0x100) 10 | 11 | #define SAVEDATA_SIZE (0x2000) 12 | 13 | enum OnlineMenuTypes { 14 | ONLINEMENU_ACHIEVEMENTS = 0, 15 | ONLINEMENU_LEADERBOARDS = 1, 16 | }; 17 | 18 | struct Achievement { 19 | char name[0x40]; 20 | int status; 21 | }; 22 | 23 | struct LeaderboardEntry { 24 | int score; 25 | }; 26 | 27 | extern int globalVariablesCount; 28 | extern int globalVariables[GLOBALVAR_COUNT]; 29 | extern char globalVariableNames[GLOBALVAR_COUNT][0x20]; 30 | 31 | extern char gamePath[0x100]; 32 | extern int saveRAM[SAVEDATA_SIZE]; 33 | extern Achievement achievements[ACHIEVEMENT_COUNT]; 34 | extern LeaderboardEntry leaderboards[LEADERBOARD_COUNT]; 35 | 36 | extern int controlMode; 37 | extern bool disableTouchControls; 38 | extern int disableFocusPause; 39 | extern int disableFocusPause_Config; 40 | 41 | #if RETRO_USE_MOD_LOADER || !RETRO_USE_ORIGINAL_CODE 42 | extern bool forceUseScripts; 43 | extern bool forceUseScripts_Config; 44 | #endif 45 | 46 | inline int GetGlobalVariableByName(const char *name) 47 | { 48 | for (int v = 0; v < globalVariablesCount; ++v) { 49 | if (StrComp(name, globalVariableNames[v])) 50 | return globalVariables[v]; 51 | } 52 | return 0; 53 | } 54 | 55 | inline void SetGlobalVariableByName(const char *name, int value) 56 | { 57 | for (int v = 0; v < globalVariablesCount; ++v) { 58 | if (StrComp(name, globalVariableNames[v])) { 59 | globalVariables[v] = value; 60 | break; 61 | } 62 | } 63 | } 64 | 65 | extern bool useSGame; 66 | bool ReadSaveRAMData(); 67 | bool WriteSaveRAMData(); 68 | 69 | void InitUserdata(); 70 | void WriteSettings(); 71 | void ReadUserdata(); 72 | void WriteUserdata(); 73 | 74 | void AwardAchievement(int id, int status); 75 | void SetAchievement(int achievementID, int achievementDone); 76 | void SetLeaderboard(int leaderboardID, int result); 77 | inline void LoadAchievementsMenu() { ReadUserdata(); } 78 | inline void LoadLeaderboardsMenu() { ReadUserdata(); } 79 | 80 | #endif //! USERDATA_H 81 | -------------------------------------------------------------------------------- /dependencies/all/theoraplay/test/testtheoraplay.c: -------------------------------------------------------------------------------- 1 | /** 2 | * TheoraPlay; multithreaded Ogg Theora/Ogg Vorbis decoding. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include "theoraplay.h" 13 | 14 | static void dofile(const char *fname, const THEORAPLAY_VideoFormat vidfmt) 15 | { 16 | THEORAPLAY_Decoder *decoder = NULL; 17 | const THEORAPLAY_VideoFrame *video = NULL; 18 | const THEORAPLAY_AudioPacket *audio = NULL; 19 | 20 | printf("Trying file '%s' ...\n", fname); 21 | decoder = THEORAPLAY_startDecodeFile(fname, 20, vidfmt); 22 | while (THEORAPLAY_isDecoding(decoder)) 23 | { 24 | video = THEORAPLAY_getVideo(decoder); 25 | if (video) 26 | { 27 | printf("Got video frame (%u ms)!\n", video->playms); 28 | THEORAPLAY_freeVideo(video); 29 | } // if 30 | 31 | audio = THEORAPLAY_getAudio(decoder); 32 | if (audio) 33 | { 34 | printf("Got %d frames of audio (%u ms)!\n", audio->frames, audio->playms); 35 | THEORAPLAY_freeAudio(audio); 36 | } // if 37 | 38 | if (!video && !audio) 39 | usleep(10000); 40 | } // while 41 | 42 | if (THEORAPLAY_decodingError(decoder)) 43 | printf("There was an error decoding this file!\n"); 44 | else 45 | printf("done with this file!\n"); 46 | 47 | THEORAPLAY_stopDecode(decoder); 48 | } // dofile 49 | 50 | int main(int argc, char **argv) 51 | { 52 | THEORAPLAY_VideoFormat vidfmt = THEORAPLAY_VIDFMT_YV12; 53 | int i; 54 | 55 | for (i = 1; i < argc; i++) 56 | { 57 | if (strcmp(argv[i], "--rgb") == 0) 58 | vidfmt = THEORAPLAY_VIDFMT_RGB; 59 | else if (strcmp(argv[i], "--rgba") == 0) 60 | vidfmt = THEORAPLAY_VIDFMT_RGBA; 61 | else if (strcmp(argv[i], "--yv12") == 0) 62 | vidfmt = THEORAPLAY_VIDFMT_YV12; 63 | else 64 | dofile(argv[i], vidfmt); 65 | } // for 66 | 67 | printf("done all files!\n"); 68 | return 0; 69 | } // main 70 | 71 | // end of testtheoraplay.c ... 72 | 73 | -------------------------------------------------------------------------------- /flatpak/com.sega.SonicCDAndroid.json: -------------------------------------------------------------------------------- 1 | { 2 | "app-id": "com.sega.SonicCD", 3 | "runtime": "org.freedesktop.Platform", 4 | "runtime-version": "21.08", 5 | "sdk": "org.freedesktop.Sdk", 6 | "command": "run.sh", 7 | "finish-args": [ 8 | "--share=ipc", 9 | "--socket=x11", 10 | "--socket=wayland", 11 | "--socket=pulseaudio", 12 | "--persist=.", 13 | "--device=all" 14 | ], 15 | "modules": [ 16 | "shared-modules/glew/glew.json", 17 | "shared-modules/glu/glu-9.json", 18 | { 19 | "name": "soniccd", 20 | "no-autogen": true, 21 | "make-args": [ 22 | "prefix=/app" 23 | ], 24 | "make-install-args": [ 25 | "prefix=/app" 26 | ], 27 | "post-install": [ 28 | "install -Dp -m 644 Data.rsdk /app/share/soniccd/Data.rsdk", 29 | "install -Dp -m 744 run.sh /app/bin/run.sh", 30 | "install -Dp -m 644 com.sega.SonicCD.desktop /app/share/applications/com.sega.SonicCD.desktop", 31 | "install -Dp -m 644 com.sega.SonicCD.svg /app/share/icons/hicolor/256x256/apps/com.sega.SonicCD.svg", 32 | "install -Dp -m 644 com.sega.SonicCD.appdata.xml /app/share/appdata/com.sega.SonicCD.appdata.xml" 33 | ], 34 | "sources": [ 35 | { 36 | "type": "git", 37 | "url": "https://github.com/RSDKModding/RSDKv3-Decompilation.git", 38 | "branch": "master" 39 | }, 40 | { 41 | "type": "file", 42 | "path": "Data.rsdk" 43 | }, 44 | { 45 | "type": "file", 46 | "path": "run.sh" 47 | }, 48 | { 49 | "type": "file", 50 | "path": "com.sega.SonicCD.desktop" 51 | }, 52 | { 53 | "type": "file", 54 | "path": "com.sega.SonicCD.svg" 55 | }, 56 | { 57 | "type": "file", 58 | "path": "com.sega.SonicCD.appdata.xml" 59 | } 60 | ] 61 | } 62 | ] 63 | } 64 | -------------------------------------------------------------------------------- /RSDKv3/Scene3D.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DRAWING3D_H 2 | #define DRAWING3D_H 3 | 4 | #define VERTEXBUFFER_SIZE (0x1000) 5 | #define FACEBUFFER_SIZE (0x400) 6 | 7 | enum FaceFlags { 8 | FACE_FLAG_TEXTURED_3D = 0, 9 | FACE_FLAG_TEXTURED_2D = 1, 10 | FACE_FLAG_COLOURED_3D = 2, 11 | FACE_FLAG_COLOURED_2D = 3, 12 | }; 13 | 14 | enum MatrixTypes { 15 | MAT_WORLD = 0, 16 | MAT_VIEW = 1, 17 | MAT_TEMP = 2, 18 | }; 19 | 20 | struct Matrix { 21 | int values[4][4]; 22 | }; 23 | 24 | struct Vertex { 25 | int x; 26 | int y; 27 | int z; 28 | int u; 29 | int v; 30 | }; 31 | 32 | struct Face { 33 | int a; 34 | int b; 35 | int c; 36 | int d; 37 | int colour; 38 | int flags; 39 | }; 40 | 41 | struct DrawListEntry3D { 42 | int faceID; 43 | int depth; 44 | }; 45 | 46 | extern int vertexCount; 47 | extern int faceCount; 48 | 49 | extern Matrix matFinal; 50 | extern Matrix matWorld; 51 | extern Matrix matView; 52 | extern Matrix matTemp; 53 | 54 | extern Face faceBuffer[FACEBUFFER_SIZE]; 55 | extern Vertex vertexBuffer[VERTEXBUFFER_SIZE]; 56 | extern Vertex vertexBufferT[VERTEXBUFFER_SIZE]; 57 | 58 | extern DrawListEntry3D drawList3D[FACEBUFFER_SIZE]; 59 | 60 | extern int projectionX; 61 | extern int projectionY; 62 | 63 | extern int faceLineStart[SCREEN_YSIZE]; 64 | extern int faceLineEnd[SCREEN_YSIZE]; 65 | extern int faceLineStartU[SCREEN_YSIZE]; 66 | extern int faceLineEndU[SCREEN_YSIZE]; 67 | extern int faceLineStartV[SCREEN_YSIZE]; 68 | extern int faceLineEndV[SCREEN_YSIZE]; 69 | 70 | void SetIdentityMatrix(Matrix *matrix); 71 | void MatrixMultiply(Matrix *matrixA, Matrix *matrixB); 72 | void MatrixTranslateXYZ(Matrix *Matrix, int x, int y, int z); 73 | void MatrixScaleXYZ(Matrix *matrix, int scaleX, int scaleY, int scaleZ); 74 | void MatrixRotateX(Matrix *matrix, int rotationX); 75 | void MatrixRotateY(Matrix *matrix, int rotationY); 76 | void MatrixRotateZ(Matrix *matrix, int rotationZ); 77 | void MatrixRotateXYZ(Matrix *matrix, int rotationX, int rotationY, int rotationZ); 78 | void TransformVertexBuffer(); 79 | void TransformVerticies(Matrix *matrix, int startIndex, int endIndex); 80 | void Sort3DDrawList(); 81 | void Draw3DScene(int spriteSheetID); 82 | 83 | void ProcessScanEdge(Vertex *vertA, Vertex *vertB); 84 | void ProcessScanEdgeUV(Vertex *vertA, Vertex *vertB); 85 | 86 | #endif // !DRAWING3D_H 87 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | RETRO_FORCE_CASE_INSENSITIVE ?= 1 2 | RETRO_DISABLE_PLUS ?= 0 3 | RETRO_USE_HW_RENDER ?= 1 4 | 5 | ifeq ($(STATIC),1) 6 | PKG_CONFIG_STATIC_FLAG = --static 7 | CXXFLAGS_ALL += -static 8 | endif 9 | 10 | CXXFLAGS_ALL += -MMD -MP -MF objects/$*.d $(shell pkg-config --cflags $(PKG_CONFIG_STATIC_FLAG) vorbisfile vorbis theoradec sdl2 glew) $(CXXFLAGS) \ 11 | -DBASE_PATH='"$(BASE_PATH)"' \ 12 | -Idependencies/all/filesystem/include \ 13 | -Idependencies/all/theoraplay \ 14 | -Idependencies/all/tinyxml2/ 15 | 16 | LDFLAGS_ALL += $(LDFLAGS) 17 | LIBS_ALL += $(shell pkg-config --libs $(PKG_CONFIG_STATIC_FLAG) vorbisfile vorbis theoradec sdl2 glew) -pthread $(LIBS) 18 | 19 | SOURCES = \ 20 | dependencies/all/tinyxml2/tinyxml2.cpp \ 21 | dependencies/all/theoraplay/theoraplay.c \ 22 | RSDKv3/Animation.cpp \ 23 | RSDKv3/Audio.cpp \ 24 | RSDKv3/Collision.cpp \ 25 | RSDKv3/Debug.cpp \ 26 | RSDKv3/Drawing.cpp \ 27 | RSDKv3/Ini.cpp \ 28 | RSDKv3/Input.cpp \ 29 | RSDKv3/main.cpp \ 30 | RSDKv3/ModAPI.cpp \ 31 | RSDKv3/Math.cpp \ 32 | RSDKv3/Object.cpp \ 33 | RSDKv3/Palette.cpp \ 34 | RSDKv3/Player.cpp \ 35 | RSDKv3/Reader.cpp \ 36 | RSDKv3/RetroEngine.cpp \ 37 | RSDKv3/Scene.cpp \ 38 | RSDKv3/Scene3D.cpp \ 39 | RSDKv3/Script.cpp \ 40 | RSDKv3/Sprite.cpp \ 41 | RSDKv3/String.cpp \ 42 | RSDKv3/Text.cpp \ 43 | RSDKv3/Userdata.cpp \ 44 | RSDKv3/Video.cpp 45 | 46 | ifeq ($(RETRO_FORCE_CASE_INSENSITIVE),1) 47 | CXXFLAGS_ALL += -DFORCE_CASE_INSENSITIVE 48 | SOURCES += RSDKv3/fcaseopen.c 49 | endif 50 | 51 | ifeq ($(RETRO_USE_HW_RENDER), 0) 52 | CXXFLAGS_ALL += -RETRO_USING_OPENGL=$(RETRO_USE_HW_RENDER) 53 | endif 54 | 55 | ifeq ($(RETRO_DISABLE_PLUS), 1) 56 | CXXFLAGS_ALL += -DRSDK_AUTOBUILD 57 | endif 58 | 59 | OBJECTS = $(SOURCES:%=objects/%.o) 60 | DEPENDENCIES = $(SOURCES:%=objects/%.d) 61 | 62 | all: bin/RSDKv3 63 | 64 | include $(wildcard $(DEPENDENCIES)) 65 | 66 | objects/%.o: % 67 | mkdir -p $(@D) 68 | $(CXX) $(CXXFLAGS_ALL) -std=c++17 $< -o $@ -c 69 | 70 | bin/RSDKv3: $(OBJECTS) 71 | mkdir -p $(@D) 72 | $(CXX) $(CXXFLAGS_ALL) $(LDFLAGS_ALL) $^ -o $@ $(LIBS_ALL) 73 | 74 | install: bin/RSDKv3 75 | install -Dp -m755 bin/RSDKv3 $(prefix)/bin/RSDKv3 76 | 77 | clean: 78 | rm -r -f bin && rm -r -f objects 79 | 80 | -------------------------------------------------------------------------------- /RSDKv3/Player.cpp: -------------------------------------------------------------------------------- 1 | #include "RetroEngine.hpp" 2 | 3 | Player playerList[PLAYER_COUNT]; 4 | int playerListPos = 0; 5 | int activePlayer = 0; 6 | int activePlayerCount = 1; 7 | 8 | ushort upBuffer = 0; 9 | ushort downBuffer = 0; 10 | ushort leftBuffer = 0; 11 | ushort rightBuffer = 0; 12 | ushort jumpPressBuffer = 0; 13 | ushort jumpHoldBuffer = 0; 14 | 15 | void ProcessPlayerControl(Player *player) 16 | { 17 | switch (player->controlMode) { 18 | default: 19 | case CONTROLMODE_NORMAL: 20 | player->up = keyDown.up; 21 | player->down = keyDown.down; 22 | if (!keyDown.left || !keyDown.right) { 23 | player->left = keyDown.left; 24 | player->right = keyDown.right; 25 | } 26 | else { 27 | player->left = false; 28 | player->right = false; 29 | } 30 | player->jumpHold = keyDown.C | keyDown.B | keyDown.A; 31 | player->jumpPress = keyPress.C | keyPress.B | keyPress.A; 32 | upBuffer <<= 1; 33 | upBuffer |= (byte)player->up; 34 | downBuffer <<= 1; 35 | downBuffer |= (byte)player->down; 36 | leftBuffer <<= 1; 37 | leftBuffer |= (byte)player->left; 38 | rightBuffer <<= 1; 39 | rightBuffer |= (byte)player->right; 40 | jumpPressBuffer <<= 1; 41 | jumpPressBuffer |= (byte)player->jumpPress; 42 | jumpHoldBuffer <<= 1; 43 | jumpHoldBuffer |= (byte)player->jumpHold; 44 | break; 45 | 46 | case CONTROLMODE_NONE: 47 | upBuffer <<= 1; 48 | upBuffer |= (byte)player->up; 49 | downBuffer <<= 1; 50 | downBuffer |= (byte)player->down; 51 | leftBuffer <<= 1; 52 | leftBuffer |= (byte)player->left; 53 | rightBuffer <<= 1; 54 | rightBuffer |= (byte)player->right; 55 | jumpPressBuffer <<= 1; 56 | jumpPressBuffer |= (byte)player->jumpPress; 57 | jumpHoldBuffer <<= 1; 58 | jumpHoldBuffer |= (byte)player->jumpHold; 59 | break; 60 | 61 | case CONTROLMODE_SIDEKICK: 62 | player->up = upBuffer >> 15; 63 | player->down = downBuffer >> 15; 64 | player->left = leftBuffer >> 15; 65 | player->right = rightBuffer >> 15; 66 | player->jumpPress = jumpPressBuffer >> 15; 67 | player->jumpHold = jumpHoldBuffer >> 15; 68 | break; 69 | } 70 | } -------------------------------------------------------------------------------- /RSDKv3/Script.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SCRIPT_H 2 | #define SCRIPT_H 3 | 4 | #define SCRIPTDATA_COUNT (0x40000) 5 | #define JUMPTABLE_COUNT (0x4000) 6 | #define FUNCTION_COUNT (0x200) 7 | 8 | #define JUMPSTACK_COUNT (0x400) 9 | #define FUNCSTACK_COUNT (0x400) 10 | 11 | #define RETRO_USE_COMPILER (1) 12 | 13 | struct ScriptPtr { 14 | int scriptCodePtr; 15 | int jumpTablePtr; 16 | }; 17 | 18 | struct ScriptFunction { 19 | #if RETRO_USE_COMPILER 20 | char name[0x20]; 21 | #endif 22 | ScriptPtr ptr; 23 | }; 24 | 25 | struct ObjectScript { 26 | int frameCount; 27 | int spriteSheetID; 28 | ScriptPtr subMain; 29 | ScriptPtr subPlayerInteraction; 30 | ScriptPtr subDraw; 31 | ScriptPtr subStartup; 32 | int frameListOffset; 33 | AnimationFile *animFile; 34 | #if !RETRO_USE_ORIGINAL_CODE 35 | bool mobile; // flag for detecting mobile/updated bytecode 36 | #endif 37 | }; 38 | 39 | struct ScriptEngine { 40 | int operands[10]; 41 | int tempValue[8]; 42 | int arrayPosition[3]; 43 | int checkResult; 44 | }; 45 | 46 | enum ScriptSubs { SUB_MAIN = 0, SUB_PLAYERINTERACTION = 1, SUB_DRAW = 2, SUB_SETUP = 3 }; 47 | 48 | extern ObjectScript objectScriptList[OBJECT_COUNT]; 49 | 50 | extern ScriptFunction scriptFunctionList[FUNCTION_COUNT]; 51 | extern int scriptFunctionCount; 52 | 53 | extern int scriptCode[SCRIPTDATA_COUNT]; 54 | extern int jumpTableData[JUMPTABLE_COUNT]; 55 | 56 | extern int jumpTableStack[JUMPSTACK_COUNT]; 57 | extern int functionStack[FUNCSTACK_COUNT]; 58 | 59 | extern int scriptCodePos; 60 | extern int scriptCodeOffset; 61 | extern int jumpTablePos; 62 | extern int jumpTableOffset; 63 | 64 | extern int jumpTableStackPos; 65 | extern int functionStackPos; 66 | 67 | extern ScriptEngine scriptEng; 68 | extern char scriptText[0x100]; 69 | 70 | 71 | extern int aliasCount; 72 | extern int lineID; 73 | 74 | bool ConvertStringToInteger(char *text, int *value); 75 | 76 | #if RETRO_USE_COMPILER 77 | 78 | void CheckAliasText(char *text); 79 | void ConvertArithmaticSyntax(char *text); 80 | void ConvertIfWhileStatement(char *text); 81 | bool ConvertSwitchStatement(char *text); 82 | void ConvertFunctionText(char *text); 83 | void CheckCaseNumber(char *text); 84 | bool ReadSwitchCase(char *text); 85 | void AppendIntegerToString(char *text, int value); 86 | void CopyAliasStr(char *dest, char *text, bool arrayIndex); 87 | bool CheckOpcodeType(char *text); // Never actually used 88 | 89 | void ParseScriptFile(char *scriptName, int scriptID); 90 | #endif 91 | void LoadBytecode(int stageListID, int scriptID); 92 | 93 | void ProcessScript(int scriptCodeStart, int jumpTableStart, byte scriptSub); 94 | 95 | void ClearScriptData(); 96 | 97 | #endif // !SCRIPT_H 98 | -------------------------------------------------------------------------------- /dependencies/mac/Dependencies.xcodeproj/xcshareddata/xcschemes/Ogg.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | 10 | 16 | 22 | 23 | 24 | 25 | 26 | 32 | 33 | 43 | 44 | 50 | 51 | 57 | 58 | 59 | 60 | 62 | 63 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /dependencies/mac/Dependencies.xcodeproj/xcshareddata/xcschemes/Theora.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | 10 | 16 | 22 | 23 | 24 | 25 | 26 | 32 | 33 | 43 | 44 | 50 | 51 | 57 | 58 | 59 | 60 | 62 | 63 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /dependencies/mac/Dependencies.xcodeproj/xcshareddata/xcschemes/Vorbis.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | 10 | 16 | 22 | 23 | 24 | 25 | 26 | 32 | 33 | 43 | 44 | 50 | 51 | 57 | 58 | 59 | 60 | 62 | 63 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /flatpak/com.sega.SonicCD.appdata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.sega.SonicCD 4 | Sonic CD 5 | CC0-1.0 6 | It’s time to usher the past into the future in this enhanced recreation of Sonic CD! 7 | 8 |

The fate of the world is determined by the choices you make throughout your adventure! Fight through the past, recover the Time Stones, and defeat the evil Metal Sonic in order to save the future from Dr. Eggman's nefarious schemes!

9 |
10 | https://www.sega.com/games/sonic-cd 11 | 12 | https://cdn.sega.com/img_0329.jpg 13 | https://cdn.sega.com/img_0334.jpg 14 | https://cdn.sega.com/img_0340.jpg 15 | https://cdn.sega.com/img_0350.jpg 16 | https://cdn.sega.com/img_0368.jpg 17 | 18 | com.sega.SonicCD.desktop 19 | LicenseRef-proprietary 20 | SEGA 21 | 22 | moderate 23 | none 24 | none 25 | none 26 | none 27 | none 28 | none 29 | none 30 | none 31 | none 32 | none 33 | none 34 | none 35 | intense 36 | none 37 | none 38 | none 39 | none 40 | none 41 | none 42 | 43 |
44 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /flatpak/com.sega.SonicCDSteam.json: -------------------------------------------------------------------------------- 1 | { 2 | "app-id": "com.sega.SonicCD", 3 | "runtime": "org.freedesktop.Platform", 4 | "runtime-version": "21.08", 5 | "sdk": "org.freedesktop.Sdk", 6 | "command": "run.sh", 7 | "finish-args": [ 8 | "--share=ipc", 9 | "--socket=x11", 10 | "--socket=wayland", 11 | "--socket=pulseaudio", 12 | "--persist=.", 13 | "--device=all" 14 | ], 15 | "modules": [ 16 | "shared-modules/glew/glew.json", 17 | "shared-modules/glu/glu-9.json", 18 | { 19 | "name": "soniccd", 20 | "no-autogen": true, 21 | "make-args": [ 22 | "prefix=/app" 23 | ], 24 | "make-install-args": [ 25 | "prefix=/app" 26 | ], 27 | "post-install": [ 28 | "install -Dp -m 644 Data.rsdk /app/share/soniccd/Data.rsdk", 29 | "install -Dp -m 744 run.sh /app/bin/run.sh", 30 | "install -Dp -m 644 Bad_Ending.ogv /app/share/soniccd/videos/Bad_Ending.ogv", 31 | "install -Dp -m 644 Good_Ending.ogv /app/share/soniccd/videos/Good_Ending.ogv", 32 | "install -Dp -m 644 Opening.ogv /app/share/soniccd/videos/Opening.ogv", 33 | "install -Dp -m 644 Pencil_Test.ogv /app/share/soniccd/videos/Pencil_Test.ogv", 34 | "install -Dp -m 644 com.sega.SonicCD.desktop /app/share/applications/com.sega.SonicCD.desktop", 35 | "install -Dp -m 644 com.sega.SonicCD.svg /app/share/icons/hicolor/256x256/apps/com.sega.SonicCD.svg", 36 | "install -Dp -m 644 com.sega.SonicCD.appdata.xml /app/share/appdata/com.sega.SonicCD.appdata.xml" 37 | ], 38 | "sources": [ 39 | { 40 | "type": "git", 41 | "url": "https://github.com/RSDKModding/RSDKv3-Decompilation.git", 42 | "branch": "master" 43 | }, 44 | { 45 | "type": "file", 46 | "path": "Data.rsdk" 47 | }, 48 | { 49 | "type": "file", 50 | "path": "run.sh" 51 | }, 52 | { 53 | "type": "dir", 54 | "path": "videos" 55 | }, 56 | { 57 | "type": "file", 58 | "path": "com.sega.SonicCD.desktop" 59 | }, 60 | { 61 | "type": "file", 62 | "path": "com.sega.SonicCD.svg" 63 | }, 64 | { 65 | "type": "file", 66 | "path": "com.sega.SonicCD.appdata.xml" 67 | } 68 | ] 69 | } 70 | ] 71 | } 72 | -------------------------------------------------------------------------------- /platforms/Linux.cmake: -------------------------------------------------------------------------------- 1 | # PKG-CONFIG IS USED AS THE MAIN DRIVER 2 | # bc cmake is inconsistent as fuuuckkk 3 | 4 | find_package(PkgConfig REQUIRED) 5 | 6 | add_executable(RetroEngine ${RETRO_FILES}) 7 | 8 | pkg_check_modules(OGG ogg) 9 | 10 | if(NOT OGG_FOUND) 11 | set(COMPILE_OGG TRUE) 12 | message(NOTICE "libogg not found, attempting to build from source") 13 | else() 14 | message("found libogg") 15 | target_link_libraries(RetroEngine ${OGG_STATIC_LIBRARIES}) 16 | target_link_options(RetroEngine PRIVATE ${OGG_STATIC_LDLIBS_OTHER}) 17 | target_compile_options(RetroEngine PRIVATE ${OGG_STATIC_CFLAGS}) 18 | endif() 19 | 20 | pkg_check_modules(THEORA theora theoradec) 21 | 22 | if(NOT THEORA_FOUND) 23 | message("could not find libtheora, attempting to build manually") 24 | set(COMPILE_THEORA TRUE) 25 | else() 26 | message("found libtheora") 27 | target_link_libraries(RetroEngine ${THEORA_STATIC_LIBRARIES}) 28 | target_link_options(RetroEngine PRIVATE ${THEORA_STATIC_LDLIBS_OTHER}) 29 | target_compile_options(RetroEngine PRIVATE ${THEORA_STATIC_CFLAGS}) 30 | endif() 31 | 32 | pkg_check_modules(VORBIS vorbis vorbisfile) #idk what the names are 33 | 34 | if(NOT VORBIS_FOUND) 35 | set(COMPILE_VORBIS TRUE) 36 | message(NOTICE "libvorbis not found, attempting to build from source") 37 | else() 38 | message("found libvorbis") 39 | target_link_libraries(RetroEngine ${VORBIS_STATIC_LIBRARIES}) 40 | target_link_options(RetroEngine PRIVATE ${VORBIS_STATIC_LDLIBS_OTHER}) 41 | target_compile_options(RetroEngine PRIVATE ${VORBIS_STATIC_CFLAGS}) 42 | endif() 43 | 44 | if(RETRO_USE_HW_RENDER) 45 | pkg_check_modules(GLEW glew) 46 | 47 | if(NOT GLEW_FOUND) 48 | message(NOTICE "could not find glew, attempting to build from source") 49 | 50 | else() 51 | message("found GLEW") 52 | target_link_libraries(RetroEngine ${GLEW_STATIC_LIBRARIES}) 53 | target_link_options(RetroEngine PRIVATE ${GLEW_STATIC_LDLIBS_OTHER}) 54 | target_compile_options(RetroEngine PRIVATE ${GLEW_STATIC_CFLAGS}) 55 | endif() 56 | endif() 57 | 58 | if(RETRO_SDL_VERSION STREQUAL "2") 59 | pkg_check_modules(SDL2 sdl2 REQUIRED) 60 | target_link_libraries(RetroEngine ${SDL2_STATIC_LIBRARIES}) 61 | target_link_options(RetroEngine PRIVATE ${SDL2_STATIC_LDLIBS_OTHER}) 62 | target_compile_options(RetroEngine PRIVATE ${SDL2_STATIC_CFLAGS}) 63 | elseif(RETRO_SDL_VERSION STREQUAL "1") 64 | pkg_check_modules(SDL1 sdl1 REQUIRED) 65 | target_link_libraries(RetroEngine ${SDL1_STATIC_LIBRARIES}) 66 | target_link_options(RetroEngine PRIVATE ${SDL1_STATIC_LDLIBS_OTHER}) 67 | target_compile_options(RetroEngine PRIVATE ${SDL1_STATIC_CFLAGS}) 68 | endif() 69 | 70 | if(RETRO_MOD_LOADER) 71 | set_target_properties(RetroEngine PROPERTIES 72 | CXX_STANDARD 17 73 | CXX_STANDARD_REQUIRED ON 74 | ) 75 | endif() -------------------------------------------------------------------------------- /RSDKv3/Math.cpp: -------------------------------------------------------------------------------- 1 | #include "RetroEngine.hpp" 2 | #include 3 | #include 4 | 5 | #ifndef M_PI 6 | #define M_PI 3.14159265358979323846264338327950288 7 | #endif 8 | 9 | int sinMLookupTable[512]; 10 | int cosMLookupTable[512]; 11 | 12 | int sin512LookupTable[512]; 13 | int cos512LookupTable[512]; 14 | 15 | int sin256LookupTable[256]; 16 | int cos256LookupTable[256]; 17 | 18 | byte arcTan256LookupTable[0x100 * 0x100]; 19 | 20 | void CalculateTrigAngles() 21 | { 22 | srand((unsigned)time(NULL)); 23 | 24 | for (int i = 0; i < 0x200; ++i) { 25 | sinMLookupTable[i] = (sin((i / 256.0) * M_PI) * 4096.0); 26 | cosMLookupTable[i] = (cos((i / 256.0) * M_PI) * 4096.0); 27 | } 28 | 29 | cosMLookupTable[0x00] = 0x1000; 30 | cosMLookupTable[0x80] = 0; 31 | cosMLookupTable[0x100] = -0x1000; 32 | cosMLookupTable[0x180] = 0; 33 | 34 | sinMLookupTable[0x00] = 0; 35 | sinMLookupTable[0x80] = 0x1000; 36 | sinMLookupTable[0x100] = 0; 37 | sinMLookupTable[0x180] = -0x1000; 38 | 39 | for (int i = 0; i < 0x200; ++i) { 40 | sin512LookupTable[i] = (sinf((i / 256.0) * M_PI) * 512.0); 41 | cos512LookupTable[i] = (cosf((i / 256.0) * M_PI) * 512.0); 42 | } 43 | 44 | cos512LookupTable[0x00] = 0x200; 45 | cos512LookupTable[0x80] = 0; 46 | cos512LookupTable[0x100] = -0x200; 47 | cos512LookupTable[0x180] = 0; 48 | 49 | sin512LookupTable[0x00] = 0; 50 | sin512LookupTable[0x80] = 0x200; 51 | sin512LookupTable[0x100] = 0; 52 | sin512LookupTable[0x180] = -0x200; 53 | 54 | for (int i = 0; i < 0x100; i++) { 55 | sin256LookupTable[i] = (sin512LookupTable[i * 2] >> 1); 56 | cos256LookupTable[i] = (cos512LookupTable[i * 2] >> 1); 57 | } 58 | 59 | for (int Y = 0; Y < 0x100; ++Y) { 60 | byte *atan = (byte *)&arcTan256LookupTable[Y]; 61 | for (int X = 0; X < 0x100; ++X) { 62 | float angle = atan2f(Y, X); 63 | *atan = (angle * 40.743664f); 64 | atan += 0x100; 65 | } 66 | } 67 | } 68 | 69 | byte ArcTanLookup(int X, int Y) 70 | { 71 | int x = 0; 72 | int y = 0; 73 | 74 | x = abs(X); 75 | y = abs(Y); 76 | 77 | if (x <= y) { 78 | while (y > 0xFF) { 79 | x >>= 4; 80 | y >>= 4; 81 | } 82 | } 83 | else { 84 | while (x > 0xFF) { 85 | x >>= 4; 86 | y >>= 4; 87 | } 88 | } 89 | if (X <= 0) { 90 | if (Y <= 0) 91 | return arcTan256LookupTable[(x << 8) + y] + -0x80; 92 | else 93 | return -0x80 - arcTan256LookupTable[(x << 8) + y]; 94 | } 95 | else if (Y <= 0) 96 | return -arcTan256LookupTable[(x << 8) + y]; 97 | else 98 | return arcTan256LookupTable[(x << 8) + y]; 99 | } 100 | -------------------------------------------------------------------------------- /RSDKv3/Input.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INPUT_H 2 | #define INPUT_H 3 | 4 | enum InputButtons { 5 | INPUT_UP, 6 | INPUT_DOWN, 7 | INPUT_LEFT, 8 | INPUT_RIGHT, 9 | INPUT_BUTTONA, 10 | INPUT_BUTTONB, 11 | INPUT_BUTTONC, 12 | INPUT_START, 13 | INPUT_ANY, 14 | INPUT_BUTTONCOUNT, 15 | }; 16 | 17 | struct InputData { 18 | bool up; 19 | bool down; 20 | bool left; 21 | bool right; 22 | bool A; 23 | bool B; 24 | bool C; 25 | bool start; 26 | }; 27 | 28 | struct InputButton { 29 | bool press, hold; 30 | int keyMappings, contMappings; 31 | 32 | inline void setHeld() 33 | { 34 | press = !hold; 35 | hold = true; 36 | } 37 | inline void setReleased() 38 | { 39 | press = false; 40 | hold = false; 41 | } 42 | 43 | inline bool down() { return (press || hold); } 44 | }; 45 | 46 | enum DefaultHapticIDs { 47 | HAPTIC_NONE = -2, 48 | HAPTIC_STOP = -1, 49 | }; 50 | 51 | extern InputData keyPress; 52 | extern InputData keyDown; 53 | 54 | extern bool anyPress; 55 | 56 | extern int touchDown[8]; 57 | extern int touchX[8]; 58 | extern int touchY[8]; 59 | extern int touchID[8]; 60 | extern int touches; 61 | 62 | extern int hapticEffectNum; 63 | 64 | #if !RETRO_USE_ORIGINAL_CODE 65 | extern InputButton inputDevice[INPUT_BUTTONCOUNT]; 66 | extern int inputType; 67 | 68 | extern float LSTICK_DEADZONE; 69 | extern float RSTICK_DEADZONE; 70 | extern float LTRIGGER_DEADZONE; 71 | extern float RTRIGGER_DEADZONE; 72 | 73 | extern int mouseHideTimer; 74 | #endif 75 | 76 | #if !RETRO_USE_ORIGINAL_CODE 77 | #if RETRO_USING_SDL2 78 | // Easier this way 79 | enum ExtraSDLButtons { 80 | SDL_CONTROLLER_BUTTON_ZL = SDL_CONTROLLER_BUTTON_MAX + 1, 81 | SDL_CONTROLLER_BUTTON_ZR, 82 | SDL_CONTROLLER_BUTTON_LSTICK_UP, 83 | SDL_CONTROLLER_BUTTON_LSTICK_DOWN, 84 | SDL_CONTROLLER_BUTTON_LSTICK_LEFT, 85 | SDL_CONTROLLER_BUTTON_LSTICK_RIGHT, 86 | SDL_CONTROLLER_BUTTON_RSTICK_UP, 87 | SDL_CONTROLLER_BUTTON_RSTICK_DOWN, 88 | SDL_CONTROLLER_BUTTON_RSTICK_LEFT, 89 | SDL_CONTROLLER_BUTTON_RSTICK_RIGHT, 90 | SDL_CONTROLLER_BUTTON_MAX_EXTRA, 91 | }; 92 | 93 | void ControllerInit(byte controllerID); 94 | void ControllerClose(byte controllerID); 95 | #endif 96 | 97 | #if RETRO_USING_SDL1 98 | extern byte keyState[SDLK_LAST]; 99 | 100 | extern SDL_Joystick *controller; 101 | #endif 102 | 103 | void ProcessInput(); 104 | #endif 105 | 106 | void CheckKeyPress(InputData *input, byte Flags); 107 | void CheckKeyDown(InputData *input, byte Flags); 108 | 109 | #if RETRO_USE_HAPTICS 110 | inline int GetHapticEffectNum() 111 | { 112 | int num = hapticEffectNum; 113 | hapticEffectNum = HAPTIC_NONE; 114 | return num; 115 | } 116 | void QueueHapticEffect(int hapticID); 117 | void PlayHaptics(int left, int right, int power); 118 | void PlayHapticsID(int hapticID); 119 | void StopHaptics(int hapticID); 120 | #endif 121 | 122 | #endif // !INPUT_H 123 | -------------------------------------------------------------------------------- /RSDKv3.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29806.167 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RSDKv3-ogl", "RSDKv3\RSDKv3.vcxproj", "{BD4A4266-8ED9-491E-B4CC-3F63F0D39C1B}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RSDKv3-sdl2", "RSDKv3\RSDKv3-sdl2.vcxproj", "{392DA72B-17D6-4446-9C3B-B8ADB592F096}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RSDKv3-sdl1", "RSDKv3\RSDKv3-sdl1.vcxproj", "{CCDCAD1A-7DAA-4895-AA32-BB672DEE5083}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|x64 = Debug|x64 15 | Debug|x86 = Debug|x86 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {BD4A4266-8ED9-491E-B4CC-3F63F0D39C1B}.Debug|x64.ActiveCfg = Debug|x64 21 | {BD4A4266-8ED9-491E-B4CC-3F63F0D39C1B}.Debug|x64.Build.0 = Debug|x64 22 | {BD4A4266-8ED9-491E-B4CC-3F63F0D39C1B}.Debug|x86.ActiveCfg = Debug|Win32 23 | {BD4A4266-8ED9-491E-B4CC-3F63F0D39C1B}.Debug|x86.Build.0 = Debug|Win32 24 | {BD4A4266-8ED9-491E-B4CC-3F63F0D39C1B}.Release|x64.ActiveCfg = Release|x64 25 | {BD4A4266-8ED9-491E-B4CC-3F63F0D39C1B}.Release|x64.Build.0 = Release|x64 26 | {BD4A4266-8ED9-491E-B4CC-3F63F0D39C1B}.Release|x86.ActiveCfg = Release|Win32 27 | {BD4A4266-8ED9-491E-B4CC-3F63F0D39C1B}.Release|x86.Build.0 = Release|Win32 28 | {392DA72B-17D6-4446-9C3B-B8ADB592F096}.Debug|x64.ActiveCfg = Debug|x64 29 | {392DA72B-17D6-4446-9C3B-B8ADB592F096}.Debug|x64.Build.0 = Debug|x64 30 | {392DA72B-17D6-4446-9C3B-B8ADB592F096}.Debug|x86.ActiveCfg = Debug|Win32 31 | {392DA72B-17D6-4446-9C3B-B8ADB592F096}.Debug|x86.Build.0 = Debug|Win32 32 | {392DA72B-17D6-4446-9C3B-B8ADB592F096}.Release|x64.ActiveCfg = Release|x64 33 | {392DA72B-17D6-4446-9C3B-B8ADB592F096}.Release|x64.Build.0 = Release|x64 34 | {392DA72B-17D6-4446-9C3B-B8ADB592F096}.Release|x86.ActiveCfg = Release|Win32 35 | {392DA72B-17D6-4446-9C3B-B8ADB592F096}.Release|x86.Build.0 = Release|Win32 36 | {CCDCAD1A-7DAA-4895-AA32-BB672DEE5083}.Debug|x64.ActiveCfg = Debug|x64 37 | {CCDCAD1A-7DAA-4895-AA32-BB672DEE5083}.Debug|x64.Build.0 = Debug|x64 38 | {CCDCAD1A-7DAA-4895-AA32-BB672DEE5083}.Debug|x86.ActiveCfg = Debug|Win32 39 | {CCDCAD1A-7DAA-4895-AA32-BB672DEE5083}.Debug|x86.Build.0 = Debug|Win32 40 | {CCDCAD1A-7DAA-4895-AA32-BB672DEE5083}.Release|x64.ActiveCfg = Release|x64 41 | {CCDCAD1A-7DAA-4895-AA32-BB672DEE5083}.Release|x64.Build.0 = Release|x64 42 | {CCDCAD1A-7DAA-4895-AA32-BB672DEE5083}.Release|x86.ActiveCfg = Release|Win32 43 | {CCDCAD1A-7DAA-4895-AA32-BB672DEE5083}.Release|x86.Build.0 = Release|Win32 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | GlobalSection(ExtensibilityGlobals) = postSolution 49 | SolutionGuid = {CEEC6B21-D41E-4C5C-8B97-9FAAD7974615} 50 | EndGlobalSection 51 | EndGlobal 52 | -------------------------------------------------------------------------------- /RSDKv3/Palette.cpp: -------------------------------------------------------------------------------- 1 | #include "RetroEngine.hpp" 2 | 3 | // Palettes (as RGB888 Colours) 4 | PaletteEntry fullPalette32[PALETTE_COUNT][PALETTE_SIZE]; 5 | PaletteEntry *activePalette32 = fullPalette32[0]; 6 | 7 | // Palettes (as RGB565 Colours) 8 | ushort fullPalette[PALETTE_COUNT][PALETTE_SIZE]; 9 | ushort *activePalette = fullPalette[0]; // Ptr to the 256 colour set thats active 10 | 11 | byte gfxLineBuffer[SCREEN_YSIZE]; // Pointers to active palette 12 | int GFX_LINESIZE; 13 | int GFX_LINESIZE_MINUSONE; 14 | int GFX_LINESIZE_DOUBLE; 15 | int GFX_FRAMEBUFFERSIZE; 16 | int GFX_FBUFFERMINUSONE; 17 | 18 | int fadeMode = 0; 19 | byte fadeA = 0; 20 | byte fadeR = 0; 21 | byte fadeG = 0; 22 | byte fadeB = 0; 23 | 24 | int paletteMode = 0; 25 | 26 | int texPaletteNum = 0; 27 | 28 | uint gfxPalette16to32[0x10000]; 29 | 30 | void LoadPalette(const char *filePath, int paletteID, int startPaletteIndex, int startIndex, int endIndex) 31 | { 32 | FileInfo info; 33 | char fullPath[0x80]; 34 | 35 | StrCopy(fullPath, "Data/Palettes/"); 36 | StrAdd(fullPath, filePath); 37 | 38 | if (LoadFile(fullPath, &info)) { 39 | SetFilePosition(3 * startIndex); 40 | if (paletteID >= PALETTE_COUNT || paletteID < 0) 41 | paletteID = 0; 42 | 43 | byte colour[3]; 44 | if (paletteID) { 45 | for (int i = startIndex; i < endIndex; ++i) { 46 | FileRead(&colour, 3); 47 | SetPaletteEntry(paletteID, startPaletteIndex++, colour[0], colour[1], colour[2]); 48 | } 49 | } 50 | else { 51 | for (int i = startIndex; i < endIndex; ++i) { 52 | FileRead(&colour, 3); 53 | SetPaletteEntry(-1, startPaletteIndex++, colour[0], colour[1], colour[2]); 54 | } 55 | } 56 | CloseFile(); 57 | } 58 | } 59 | 60 | void SetLimitedFade(byte paletteID, byte R, byte G, byte B, ushort alpha, int startIndex, int endIndex) 61 | { 62 | if (paletteID >= PALETTE_COUNT) 63 | return; 64 | paletteMode = 1; 65 | activePalette = fullPalette[paletteID]; 66 | activePalette32 = fullPalette32[paletteID]; 67 | 68 | if (alpha >= 0x100) 69 | alpha = 0xFF; 70 | 71 | if (startIndex >= endIndex) 72 | return; 73 | 74 | uint alpha2 = 0xFF - alpha; 75 | for (int i = startIndex; i < endIndex; ++i) { 76 | PACK_RGB888(activePalette[i], (byte)((ushort)(R * alpha + alpha2 * activePalette32[i].r) >> 8), 77 | (byte)((ushort)(G * alpha + alpha2 * activePalette32[i].g) >> 8), 78 | (byte)((ushort)(B * alpha + alpha2 * activePalette32[i].b) >> 8)); 79 | if (renderType == RENDER_HW) { // not like this works on HW.... 80 | activePalette32[i].r = (byte)((ushort)(R * alpha + alpha2 * activePalette32[i].r) >> 8); 81 | activePalette32[i].g = (byte)((ushort)(G * alpha + alpha2 * activePalette32[i].g) >> 8); 82 | activePalette32[i].b = (byte)((ushort)(B * alpha + alpha2 * activePalette32[i].b) >> 8); 83 | activePalette[i] |= 1; 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /RSDKv3.xcodeproj/xcshareddata/xcschemes/RSDKv3.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /RSDKv3 ios.xcodeproj/xcshareddata/xcschemes/RSDKv3.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /dependencies/all/theoraplay/theoraplay.h: -------------------------------------------------------------------------------- 1 | /** 2 | * TheoraPlay; multithreaded Ogg Theora/Ogg Vorbis decoding. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | #ifndef _INCL_THEORAPLAY_H_ 10 | #define _INCL_THEORAPLAY_H_ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | typedef struct THEORAPLAY_Io THEORAPLAY_Io; 17 | struct THEORAPLAY_Io 18 | { 19 | long (*read)(THEORAPLAY_Io *io, void *buf, long buflen); 20 | void (*close)(THEORAPLAY_Io *io); 21 | void *userdata; 22 | }; 23 | 24 | typedef struct THEORAPLAY_Decoder THEORAPLAY_Decoder; 25 | 26 | /* YV12 is YCrCb, not YCbCr; that's what SDL uses for YV12 overlays. */ 27 | typedef enum THEORAPLAY_VideoFormat 28 | { 29 | THEORAPLAY_VIDFMT_YV12, /* NTSC colorspace, planar YCrCb 4:2:0 */ 30 | THEORAPLAY_VIDFMT_IYUV, /* NTSC colorspace, planar YCbCr 4:2:0 */ 31 | THEORAPLAY_VIDFMT_RGB, /* 24 bits packed pixel RGB */ 32 | THEORAPLAY_VIDFMT_RGBA /* 32 bits packed pixel RGBA (full alpha). */ 33 | } THEORAPLAY_VideoFormat; 34 | 35 | typedef struct THEORAPLAY_VideoFrame 36 | { 37 | unsigned int playms; 38 | double fps; 39 | unsigned int width; 40 | unsigned int height; 41 | THEORAPLAY_VideoFormat format; 42 | unsigned char *pixels; 43 | struct THEORAPLAY_VideoFrame *next; 44 | } THEORAPLAY_VideoFrame; 45 | 46 | typedef struct THEORAPLAY_AudioPacket 47 | { 48 | unsigned int playms; /* playback start time in milliseconds. */ 49 | int channels; 50 | int freq; 51 | int frames; 52 | float *samples; /* frames * channels float32 samples. */ 53 | struct THEORAPLAY_AudioPacket *next; 54 | } THEORAPLAY_AudioPacket; 55 | 56 | THEORAPLAY_Decoder *THEORAPLAY_startDecodeFile(const char *fname, 57 | const unsigned int maxframes, 58 | THEORAPLAY_VideoFormat vidfmt, 59 | unsigned int audio_bitstream); 60 | THEORAPLAY_Decoder *THEORAPLAY_startDecode(THEORAPLAY_Io *io, 61 | const unsigned int maxframes, 62 | THEORAPLAY_VideoFormat vidfmt, 63 | unsigned int audio_bitstream); 64 | void THEORAPLAY_stopDecode(THEORAPLAY_Decoder *decoder); 65 | 66 | int THEORAPLAY_isDecoding(THEORAPLAY_Decoder *decoder); 67 | int THEORAPLAY_decodingError(THEORAPLAY_Decoder *decoder); 68 | int THEORAPLAY_isInitialized(THEORAPLAY_Decoder *decoder); 69 | int THEORAPLAY_hasVideoStream(THEORAPLAY_Decoder *decoder); 70 | int THEORAPLAY_hasAudioStream(THEORAPLAY_Decoder *decoder); 71 | unsigned int THEORAPLAY_availableVideo(THEORAPLAY_Decoder *decoder); 72 | unsigned int THEORAPLAY_availableAudio(THEORAPLAY_Decoder *decoder); 73 | 74 | const THEORAPLAY_AudioPacket *THEORAPLAY_getAudio(THEORAPLAY_Decoder *decoder); 75 | void THEORAPLAY_freeAudio(const THEORAPLAY_AudioPacket *item); 76 | 77 | const THEORAPLAY_VideoFrame *THEORAPLAY_getVideo(THEORAPLAY_Decoder *decoder); 78 | void THEORAPLAY_freeVideo(const THEORAPLAY_VideoFrame *item); 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif /* include-once blocker. */ 85 | 86 | /* end of theoraplay.h ... */ 87 | 88 | -------------------------------------------------------------------------------- /platforms/Windows.cmake: -------------------------------------------------------------------------------- 1 | project(RetroEngine) 2 | 3 | add_executable(RetroEngine ${RETRO_FILES}) 4 | 5 | set(DEP_PATH windows) 6 | 7 | find_package(Ogg CONFIG) 8 | 9 | if(NOT ${Ogg_FOUND}) 10 | set(COMPILE_OGG TRUE) 11 | message(NOTICE "libogg not found, attempting to build from source") 12 | else() 13 | message("found libogg") 14 | add_library(libogg ALIAS Ogg::ogg) 15 | target_link_libraries(RetroEngine libogg) 16 | endif() 17 | 18 | # i don't like this but it's what's on vcpkg so 19 | find_package(unofficial-theora CONFIG) 20 | 21 | if(NOT unofficial-theora_FOUND) 22 | message(NOTICE "could not find libtheora from unofficial-theora, attempting to find through Theora") 23 | find_package(Theora CONFIG) 24 | 25 | if(NOT Theora_FOUND) 26 | message("could not find libtheora, attempting to build manually") 27 | set(COMPILE_THEORA TRUE) 28 | else() 29 | message("found libtheora") 30 | add_library(libtheora ALIAS Theora::theora) # my best guess 31 | target_link_libraries(RetroEngine libtheora) 32 | endif() 33 | else() 34 | message("found libtheora") 35 | add_library(libtheora ALIAS unofficial::theora::theora) 36 | target_link_libraries(RetroEngine libtheora) 37 | endif() 38 | 39 | find_package(Vorbis CONFIG) 40 | 41 | if(NOT ${Vorbis_FOUND}) 42 | set(COMPILE_VORBIS TRUE) 43 | message(NOTICE "libvorbis not found, attempting to build from source") 44 | else() 45 | message("found libvorbis") 46 | add_library(libvorbis ALIAS Vorbis::vorbisfile) 47 | target_link_libraries(RetroEngine libvorbis) 48 | endif() 49 | 50 | if(RETRO_USE_HW_RENDER) 51 | find_package(GLEW CONFIG) 52 | 53 | if(NOT GLEW_FOUND) 54 | message(NOTICE "could not find glew, attempting to build from source") 55 | 56 | else() 57 | message("found GLEW") 58 | add_library(glew ALIAS GLEW::GLEW) 59 | endif() 60 | 61 | target_link_libraries(RetroEngine 62 | glew 63 | ) 64 | endif() 65 | 66 | if(RETRO_SDL_VERSION STREQUAL "2") 67 | find_package(SDL2 CONFIG REQUIRED) 68 | target_link_libraries(RetroEngine 69 | $ 70 | $,SDL2::SDL2,SDL2::SDL2-static> 71 | ) 72 | elseif(RETRO_SDL_VERSION STREQUAL "1") 73 | find_package(SDL1 CONFIG REQUIRED) 74 | target_link_libraries(RetroEngine 75 | $ 76 | $,SDL1::SDL1,SDL1::SDL1-static> 77 | ) 78 | else() 79 | message(FATAL_ERROR "RETRO_SDL_VERSION must be 1 or 2") 80 | endif() 81 | 82 | target_compile_definitions(RetroEngine PRIVATE _CRT_SECURE_NO_WARNINGS) 83 | target_link_libraries(RetroEngine 84 | winmm 85 | comctl32 86 | ) 87 | 88 | if(RETRO_MOD_LOADER) 89 | set_target_properties(RetroEngine PROPERTIES 90 | CXX_STANDARD 17 91 | CXX_STANDARD_REQUIRED ON 92 | ) 93 | endif() 94 | 95 | if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 96 | target_compile_options(RetroEngine PRIVATE -Wno-microsoft-cast -Wno-microsoft-exception-spec) 97 | endif() 98 | 99 | target_sources(RetroEngine PRIVATE ${RETRO_NAME}/${RETRO_NAME}.rc) 100 | target_link_options(RetroEngine PRIVATE /subsystem:windows) -------------------------------------------------------------------------------- /RSDKv3/RSDKv3.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "winres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (United Kingdom) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK 20 | #pragma code_page(1252) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | #endif // English (United Kingdom) resources 48 | ///////////////////////////////////////////////////////////////////////////// 49 | 50 | 51 | ///////////////////////////////////////////////////////////////////////////// 52 | // English (Australia) resources 53 | 54 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) 55 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS 56 | #pragma code_page(1252) 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | VS_VERSION_INFO VERSIONINFO 64 | FILEVERSION 1,0,0,0 65 | PRODUCTVERSION 1,0,0,0 66 | FILEFLAGSMASK 0x3fL 67 | #ifdef _DEBUG 68 | FILEFLAGS 0x1L 69 | #else 70 | FILEFLAGS 0x0L 71 | #endif 72 | FILEOS 0x40004L 73 | FILETYPE 0x1L 74 | FILESUBTYPE 0x0L 75 | BEGIN 76 | BLOCK "StringFileInfo" 77 | BEGIN 78 | BLOCK "0c0904b0" 79 | BEGIN 80 | VALUE "CompanyName", "RSDKv3/Sonic CD (2011) By Christian 'The Taxman' Whitehead, Decompilation by Rubberduckycooly" 81 | VALUE "FileDescription", "RSDKv3" 82 | VALUE "FileVersion", "1.0.0" 83 | VALUE "InternalName", "RSDKv3.exe" 84 | VALUE "OriginalFilename", "RSDKv3.exe" 85 | VALUE "ProductName", "RSDKv3" 86 | VALUE "ProductVersion", "1.0.0" 87 | END 88 | END 89 | BLOCK "VarFileInfo" 90 | BEGIN 91 | VALUE "Translation", 0xc09, 1200 92 | END 93 | END 94 | 95 | 96 | ///////////////////////////////////////////////////////////////////////////// 97 | // 98 | // Icon 99 | // 100 | 101 | // Icon with lowest ID value placed first to ensure application icon 102 | // remains consistent on all systems. 103 | IDI_ICON1 ICON "RSDKv3 Decomp Icon.ico" 104 | 105 | #endif // English (Australia) resources 106 | ///////////////////////////////////////////////////////////////////////////// 107 | 108 | 109 | 110 | #ifndef APSTUDIO_INVOKED 111 | ///////////////////////////////////////////////////////////////////////////// 112 | // 113 | // Generated from the TEXTINCLUDE 3 resource. 114 | // 115 | 116 | 117 | ///////////////////////////////////////////////////////////////////////////// 118 | #endif // not APSTUDIO_INVOKED 119 | 120 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | OGG_DIR := dependencies/android/libogg 4 | VORBIS_DIR := dependencies/android/libvorbis 5 | THEORA_DIR := dependencies/android/libtheora 6 | 7 | OGG_INCLUDES := $(LOCAL_PATH)/$(OGG_DIR)/include 8 | VORBIS_INCLUDES := $(LOCAL_PATH)/$(VORBIS_DIR)/include \ 9 | $(LOCAL_PATH)/$(VORBIS_DIR)/lib 10 | THEORA_INCLUDES := $(LOCAL_PATH)/$(THEORA_DIR)/include \ 11 | $(LOCAL_PATH)/$(THEORA_DIR)/lib 12 | 13 | ###################################################################### 14 | # OGG 15 | include $(CLEAR_VARS) 16 | 17 | LOCAL_ARM_MODE := arm 18 | LOCAL_MODULE := libogg 19 | LOCAL_CFLAGS := -ffast-math -fsigned-char -O2 -fPIC -DPIC \ 20 | -DBYTE_ORDER=LITTLE_ENDIAN -D_ARM_ASSEM_ 21 | 22 | LOCAL_C_INCLUDES := $(OGG_INCLUDES) 23 | 24 | WILDCARD_SETUP := \ 25 | $(wildcard $(LOCAL_PATH)/$(OGG_DIR)/src/*.c) 26 | 27 | 28 | LOCAL_SRC_FILES := \ 29 | $(subst jni/src/, , $(WILDCARD_SETUP)) 30 | 31 | include $(BUILD_STATIC_LIBRARY) 32 | 33 | ###################################################################### 34 | # VORBIS 35 | include $(CLEAR_VARS) 36 | 37 | LOCAL_ARM_MODE := arm 38 | LOCAL_MODULE := libvorbis 39 | LOCAL_CFLAGS := -ffast-math -fsigned-char -O2 -fPIC -DPIC \ 40 | -DBYTE_ORDER=LITTLE_ENDIAN -D_ARM_ASSEM_ 41 | 42 | LOCAL_C_INCLUDES := $(OGG_INCLUDES) $(VORBIS_INCLUDES) 43 | 44 | WILDCARD_SETUP := \ 45 | $(wildcard $(LOCAL_PATH)/$(VORBIS_DIR)/lib/*.c) 46 | FILTERED := $(filter-out $(LOCAL_PATH)/$(VORBIS_DIR)/lib/psytune.c, $(WILDCARD_SETUP)) 47 | 48 | LOCAL_SRC_FILES := \ 49 | $(subst jni/src/, , $(FILTERED)) 50 | 51 | include $(BUILD_STATIC_LIBRARY) 52 | 53 | ###################################################################### 54 | # THEORA 55 | include $(CLEAR_VARS) 56 | 57 | LOCAL_ARM_MODE := arm 58 | LOCAL_MODULE := libtheora 59 | LOCAL_CFLAGS := -ffast-math -fsigned-char -O2 -fPIC -DPIC \ 60 | -DBYTE_ORDER=LITTLE_ENDIAN -D_ARM_ASSEM_ 61 | 62 | LOCAL_C_INCLUDES := $(OGG_INCLUDES) $(THEORA_INCLUDES) 63 | 64 | WILDCARD_SETUP := \ 65 | $(wildcard $(LOCAL_PATH)/$(THEORA_DIR)/lib/*.c) 66 | 67 | LOCAL_SRC_FILES := \ 68 | $(subst jni/src/, , $(WILDCARD_SETUP)) 69 | 70 | include $(BUILD_STATIC_LIBRARY) 71 | 72 | ###################################################################### 73 | 74 | include $(CLEAR_VARS) 75 | 76 | LOCAL_MODULE := main 77 | 78 | SDL_PATH := ../SDL 79 | 80 | LOCAL_CFLAGS := -fexceptions 81 | LOCAL_CPPFLAGS := -std=c++17 82 | APP_CPPFLAGS := -std=c++17 83 | 84 | LOCAL_C_INCLUDES := \ 85 | $(LOCAL_PATH)/$(SDL_PATH)/include \ 86 | $(LOCAL_PATH)/dependencies/all \ 87 | $(LOCAL_PATH)/$(VORBIS_DIR)/include \ 88 | $(LOCAL_PATH)/$(OGG_DIR)/include \ 89 | $(LOCAL_PATH)/$(THEORA_DIR)/include \ 90 | $(LOCAL_PATH)/dependencies/all/theoraplay \ 91 | $(LOCAL_PATH)/dependencies/all/tinyxml2 \ 92 | 93 | 94 | WILDCARD_SETUP := \ 95 | $(wildcard $(LOCAL_PATH)/dependencies/all/theoraplay/*.c) \ 96 | $(wildcard $(LOCAL_PATH)/dependencies/all/tinyxml2/*.cpp) \ 97 | $(wildcard $(LOCAL_PATH)/RSDKv3/*.cpp) 98 | 99 | LOCAL_SRC_FILES := $(subst jni/src/, , $(WILDCARD_SETUP)) 100 | 101 | LOCAL_LDLIBS := -lGLESv1_CM -llog 102 | 103 | LOCAL_SHARED_LIBRARIES := SDL2 libogg libvorbis libtheora 104 | 105 | include $(BUILD_SHARED_LIBRARY) 106 | -------------------------------------------------------------------------------- /RSDKv3/fcaseopen.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009 Keith Bauer 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #include "fcaseopen.h" 24 | 25 | #if !defined(_WIN32) 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | // r must have strlen(path) + 3 bytes 34 | static int casepath(char const *path, char *r) 35 | { 36 | size_t l = strlen(path); 37 | char *p = (char *)alloca(l + 1); 38 | strcpy(p, path); 39 | size_t rl = 0; 40 | 41 | DIR *d; 42 | if (p[0] == '/') { 43 | d = opendir("/"); 44 | p = p + 1; 45 | } 46 | else { 47 | d = opendir("."); 48 | r[0] = '.'; 49 | r[1] = 0; 50 | rl = 1; 51 | } 52 | 53 | int last = 0; 54 | char *c = strsep(&p, "/"); 55 | while (c) { 56 | if (!d) { 57 | return 0; 58 | } 59 | 60 | if (last) { 61 | closedir(d); 62 | return 0; 63 | } 64 | 65 | r[rl] = '/'; 66 | rl += 1; 67 | r[rl] = 0; 68 | 69 | struct dirent *e = readdir(d); 70 | while (e) { 71 | if (strcasecmp(c, e->d_name) == 0) { 72 | strcpy(r + rl, e->d_name); 73 | rl += strlen(e->d_name); 74 | 75 | closedir(d); 76 | d = opendir(r); 77 | 78 | break; 79 | } 80 | 81 | e = readdir(d); 82 | } 83 | 84 | if (!e) { 85 | strcpy(r + rl, c); 86 | rl += strlen(c); 87 | last = 1; 88 | } 89 | 90 | c = strsep(&p, "/"); 91 | } 92 | 93 | if (d) 94 | closedir(d); 95 | return 1; 96 | } 97 | #endif 98 | 99 | FILE *fcaseopen(char const *path, char const *mode) 100 | { 101 | FILE *f = fopen(path, mode); 102 | #if !defined(_WIN32) 103 | if (!f) { 104 | char *r = (char *)alloca(strlen(path) + 3); 105 | if (casepath(path, r)) { 106 | f = fopen(r, mode); 107 | } 108 | } 109 | #endif 110 | return f; 111 | } 112 | 113 | void casechdir(char const *path) 114 | { 115 | #if !defined(_WIN32) 116 | char *r = (char *)alloca(strlen(path) + 3); 117 | if (casepath(path, r)) { 118 | chdir(r); 119 | } 120 | else { 121 | errno = ENOENT; 122 | } 123 | #else 124 | chdir(path); 125 | #endif 126 | } 127 | -------------------------------------------------------------------------------- /android/app/src/main/java/org/libsdl/app/SDL.java: -------------------------------------------------------------------------------- 1 | package org.libsdl.app; 2 | 3 | import android.content.Context; 4 | 5 | import java.lang.Class; 6 | import java.lang.reflect.Method; 7 | 8 | /** 9 | SDL library initialization 10 | */ 11 | public class SDL { 12 | 13 | // This function should be called first and sets up the native code 14 | // so it can call into the Java classes 15 | public static void setupJNI() { 16 | SDLActivity.nativeSetupJNI(); 17 | SDLAudioManager.nativeSetupJNI(); 18 | SDLControllerManager.nativeSetupJNI(); 19 | } 20 | 21 | // This function should be called each time the activity is started 22 | public static void initialize() { 23 | setContext(null); 24 | 25 | SDLActivity.initialize(); 26 | SDLAudioManager.initialize(); 27 | SDLControllerManager.initialize(); 28 | } 29 | 30 | // This function stores the current activity (SDL or not) 31 | public static void setContext(Context context) { 32 | SDLAudioManager.setContext(context); 33 | mContext = context; 34 | } 35 | 36 | public static Context getContext() { 37 | return mContext; 38 | } 39 | 40 | public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException { 41 | 42 | if (libraryName == null) { 43 | throw new NullPointerException("No library name provided."); 44 | } 45 | 46 | try { 47 | // Let's see if we have ReLinker available in the project. This is necessary for 48 | // some projects that have huge numbers of local libraries bundled, and thus may 49 | // trip a bug in Android's native library loader which ReLinker works around. (If 50 | // loadLibrary works properly, ReLinker will simply use the normal Android method 51 | // internally.) 52 | // 53 | // To use ReLinker, just add it as a dependency. For more information, see 54 | // https://github.com/KeepSafe/ReLinker for ReLinker's repository. 55 | // 56 | Class relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker"); 57 | Class relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener"); 58 | Class contextClass = mContext.getClassLoader().loadClass("android.content.Context"); 59 | Class stringClass = mContext.getClassLoader().loadClass("java.lang.String"); 60 | 61 | // Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if 62 | // they've changed during updates. 63 | Method forceMethod = relinkClass.getDeclaredMethod("force"); 64 | Object relinkInstance = forceMethod.invoke(null); 65 | Class relinkInstanceClass = relinkInstance.getClass(); 66 | 67 | // Actually load the library! 68 | Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass); 69 | loadMethod.invoke(relinkInstance, mContext, libraryName, null, null); 70 | } 71 | catch (final Throwable e) { 72 | // Fall back 73 | try { 74 | System.loadLibrary(libraryName); 75 | } 76 | catch (final UnsatisfiedLinkError ule) { 77 | throw ule; 78 | } 79 | catch (final SecurityException se) { 80 | throw se; 81 | } 82 | } 83 | } 84 | 85 | protected static Context mContext; 86 | } 87 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 8 | 9 | 10 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /RSDKv3/Collision.hpp: -------------------------------------------------------------------------------- 1 | #ifndef COLLISION_H 2 | #define COLLISION_H 3 | 4 | #define COLSTORE_COUNT (2) 5 | 6 | enum CollisionSides { 7 | CSIDE_FLOOR = 0, 8 | CSIDE_LWALL = 1, 9 | CSIDE_RWALL = 2, 10 | CSIDE_ROOF = 3, 11 | CSIDE_ENTITY = 4, 12 | }; 13 | 14 | enum CollisionModes { 15 | CMODE_FLOOR = 0, 16 | CMODE_LWALL = 1, 17 | CMODE_ROOF = 2, 18 | CMODE_RWALL = 3, 19 | }; 20 | 21 | enum CollisionSolidity { 22 | SOLID_ALL = 0, 23 | SOLID_TOP = 1, 24 | SOLID_LRB = 2, 25 | SOLID_NONE = 3, 26 | }; 27 | 28 | enum ObjectCollisionTypes { 29 | C_TOUCH = 0, 30 | C_BOX = 1, 31 | C_BOX2 = 2, 32 | C_PLATFORM = 3, 33 | C_BOX3 = 4, // Introduced in Origins Plus 34 | C_ENEMY = 5, // Introduced in Origins Plus 35 | }; 36 | 37 | struct CollisionSensor { 38 | int XPos; 39 | int YPos; 40 | int angle; 41 | bool collided; 42 | }; 43 | 44 | // Introduced in Origins Plus 45 | struct CollisionStore { 46 | int entityNo; 47 | sbyte type; 48 | int left; 49 | int right; 50 | int top; 51 | int bottom; 52 | }; 53 | extern CollisionStore collisionStorage[2]; 54 | 55 | enum EntityCollisionEffects { 56 | ECEFFECT_NONE = 0, 57 | ECEFFECT_RESETSTORAGE = 1, 58 | ECEFFECT_BOXCOL3 = 2, 59 | }; 60 | 61 | #if !RETRO_USE_ORIGINAL_CODE 62 | #define DEBUG_HITBOX_COUNT (0x400) 63 | 64 | struct DebugHitboxInfo { 65 | byte type; 66 | byte collision; 67 | short left; 68 | short top; 69 | short right; 70 | short bottom; 71 | int XPos; 72 | int YPos; 73 | Entity *entity; 74 | }; 75 | 76 | 77 | enum DebugHitboxTypes { H_TYPE_TOUCH, H_TYPE_BOX, H_TYPE_PLAT, H_TYPE_FINGER, H_TYPE_HAMMER}; 78 | 79 | extern byte showHitboxes; 80 | extern int debugHitboxCount; 81 | extern DebugHitboxInfo debugHitboxList[DEBUG_HITBOX_COUNT]; 82 | 83 | int AddDebugHitbox(byte type, Entity *entity, int left, int top, int right, int bottom); 84 | #endif 85 | 86 | extern int collisionLeft; 87 | extern int collisionTop; 88 | extern int collisionRight; 89 | extern int collisionBottom; 90 | 91 | extern CollisionSensor sensors[6]; 92 | 93 | void FindFloorPosition(Player *player, CollisionSensor *sensor, int startYPos); 94 | void FindLWallPosition(Player *player, CollisionSensor *sensor, int startXPos); 95 | void FindRoofPosition(Player *player, CollisionSensor *sensor, int startYPos); 96 | void FindRWallPosition(Player *player, CollisionSensor *sensor, int startXPos); 97 | void FloorCollision(Player *player, CollisionSensor *sensor); 98 | void LWallCollision(Player *player, CollisionSensor *sensor); 99 | void RoofCollision(Player *player, CollisionSensor *sensor); 100 | void RWallCollision(Player *player, CollisionSensor *sensor); 101 | void SetPathGripSensors(Player *player); 102 | 103 | void ProcessPathGrip(Player *player); 104 | void ProcessAirCollision(Player *player); 105 | 106 | void ProcessPlayerTileCollisions(Player *player); 107 | 108 | void TouchCollision(int left, int top, int right, int bottom); 109 | void BoxCollision(int left, int top, int right, int bottom); // Standard 110 | void BoxCollision2(int left, int top, int right, int bottom); // Updated (?) 111 | void PlatformCollision(int left, int top, int right, int bottom); 112 | void BoxCollision3(int left, int top, int right, int bottom); // Added in Origins Plus 113 | void EnemyCollision(int left, int top, int right, int bottom); // Added in Origins Plus 114 | 115 | void ObjectFloorCollision(int xOffset, int yOffset, int cPath); 116 | void ObjectLWallCollision(int xOffset, int yOffset, int cPath); 117 | void ObjectRoofCollision(int xOffset, int yOffset, int cPath); 118 | void ObjectRWallCollision(int xOffset, int yOffset, int cPath); 119 | 120 | void ObjectFloorGrip(int xOffset, int yOffset, int cPath); 121 | void ObjectLWallGrip(int xOffset, int yOffset, int cPath); 122 | void ObjectRoofGrip(int xOffset, int yOffset, int cPath); 123 | void ObjectRWallGrip(int xOffset, int yOffset, int cPath); 124 | void ObjectEntityGrip(int direction, int extendBottomCol, int effect); // Added in Origins Plus 125 | 126 | #endif // !COLLISION_H 127 | -------------------------------------------------------------------------------- /RSDKv3UWP.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RSDKv3UWP", "RSDKv3UWP\RSDKv3UWP.vcxproj", "{7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2-UWP", "dependencies\win-uwp\SDL2\VisualC-WinRT\UWP_VS2015\SDL-UWP.vcxproj", "{89E9B32E-A86A-47C3-A948-D2B1622925CE}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|ARM = Debug|ARM 13 | Debug|ARM64 = Debug|ARM64 14 | Debug|x64 = Debug|x64 15 | Debug|x86 = Debug|x86 16 | Release|ARM = Release|ARM 17 | Release|ARM64 = Release|ARM64 18 | Release|x64 = Release|x64 19 | Release|x86 = Release|x86 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Debug|ARM.ActiveCfg = Debug|ARM 23 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Debug|ARM.Build.0 = Debug|ARM 24 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Debug|ARM.Deploy.0 = Debug|ARM 25 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Debug|ARM64.ActiveCfg = Debug|ARM64 26 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Debug|ARM64.Build.0 = Debug|ARM64 27 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Debug|ARM64.Deploy.0 = Debug|ARM64 28 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Debug|x64.ActiveCfg = Debug|x64 29 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Debug|x64.Build.0 = Debug|x64 30 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Debug|x64.Deploy.0 = Debug|x64 31 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Debug|x86.ActiveCfg = Debug|Win32 32 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Debug|x86.Build.0 = Debug|Win32 33 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Debug|x86.Deploy.0 = Debug|Win32 34 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Release|ARM.ActiveCfg = Release|ARM 35 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Release|ARM.Build.0 = Release|ARM 36 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Release|ARM.Deploy.0 = Release|ARM 37 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Release|ARM64.ActiveCfg = Release|ARM64 38 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Release|ARM64.Build.0 = Release|ARM64 39 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Release|ARM64.Deploy.0 = Release|ARM64 40 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Release|x64.ActiveCfg = Release|x64 41 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Release|x64.Build.0 = Release|x64 42 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Release|x64.Deploy.0 = Release|x64 43 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Release|x86.ActiveCfg = Release|Win32 44 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Release|x86.Build.0 = Release|Win32 45 | {7376A5B2-E65D-4CC8-A0CF-5AE96BBA84A5}.Release|x86.Deploy.0 = Release|Win32 46 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM.ActiveCfg = Debug|ARM 47 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM.Build.0 = Debug|ARM 48 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM64.ActiveCfg = Debug|Win32 49 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x64.ActiveCfg = Debug|x64 50 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x64.Build.0 = Debug|x64 51 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x86.ActiveCfg = Debug|Win32 52 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x86.Build.0 = Debug|Win32 53 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM.ActiveCfg = Release|ARM 54 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM.Build.0 = Release|ARM 55 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM64.ActiveCfg = Release|Win32 56 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x64.ActiveCfg = Release|x64 57 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x64.Build.0 = Release|x64 58 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x86.ActiveCfg = Release|Win32 59 | {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x86.Build.0 = Release|Win32 60 | EndGlobalSection 61 | GlobalSection(SolutionProperties) = preSolution 62 | HideSolutionNode = FALSE 63 | EndGlobalSection 64 | GlobalSection(ExtensibilityGlobals) = postSolution 65 | SolutionGuid = {536DEE70-A1FC-47D8-9763-410FBD1A2958} 66 | EndGlobalSection 67 | EndGlobal 68 | -------------------------------------------------------------------------------- /dependencies/all/theoraplay/theoraplay_cvtrgb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * TheoraPlay; multithreaded Ogg Theora/Ogg Vorbis decoding. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | #if !THEORAPLAY_INTERNAL 10 | #error Do not include this in your app. It is used internally by TheoraPlay. 11 | #endif 12 | 13 | static unsigned char *THEORAPLAY_CVT_FNNAME_420(const th_info *tinfo, 14 | const th_ycbcr_buffer ycbcr) 15 | { 16 | const int w = tinfo->pic_width; 17 | const int h = tinfo->pic_height; 18 | const int halfw = w / 2; 19 | unsigned char *pixels = (unsigned char *) malloc(w * h * 4); 20 | 21 | // http://www.theora.org/doc/Theora.pdf, 1.1 spec, 22 | // chapter 4.2 (Y'CbCr -> Y'PbPr -> R'G'B') 23 | // These constants apparently work for NTSC _and_ PAL/SECAM. 24 | const float yoffset = 16.0f; 25 | const float yexcursion = 219.0f; 26 | const float cboffset = 128.0f; 27 | const float cbexcursion = 224.0f; 28 | const float croffset = 128.0f; 29 | const float crexcursion = 224.0f; 30 | const float kr = 0.299f; 31 | const float kb = 0.114f; 32 | 33 | if (pixels) 34 | { 35 | unsigned char *dst = pixels; 36 | const int ystride = ycbcr[0].stride; 37 | const int cbstride = ycbcr[1].stride; 38 | const int crstride = ycbcr[2].stride; 39 | const int yoff = (tinfo->pic_x & ~1) + ystride * (tinfo->pic_y & ~1); 40 | const int cboff = (tinfo->pic_x / 2) + (cbstride) * (tinfo->pic_y / 2); 41 | const unsigned char *py = ycbcr[0].data + yoff; 42 | const unsigned char *pcb = ycbcr[1].data + cboff; 43 | const unsigned char *pcr = ycbcr[2].data + cboff; 44 | int posy; 45 | 46 | for (posy = 0; posy < h; posy++) 47 | { 48 | int posx, poshalfx; 49 | 50 | posx = 0; 51 | for (poshalfx = 0; poshalfx < halfw; poshalfx++, posx += 2) 52 | { 53 | const float y1 = (((float) py[posx]) - yoffset) / yexcursion; 54 | const float y2 = (((float) py[posx+1]) - yoffset) / yexcursion; 55 | const float pb = (((float) pcb[poshalfx]) - cboffset) / cbexcursion; 56 | const float pr = (((float) pcr[poshalfx]) - croffset) / crexcursion; 57 | const float r1 = (y1 + (2.0f * (1.0f - kr) * pr)) * 255.0f; 58 | const float g1 = (y1 - ((2.0f * (((1.0f - kb) * kb) / ((1.0f - kb) - kr))) * pb) - ((2.0f * (((1.0f - kr) * kr) / ((1.0f - kb) - kr))) * pr)) * 255.0f; 59 | const float b1 = (y1 + (2.0f * (1.0f - kb) * pb)) * 255.0f; 60 | const float r2 = (y2 + (2.0f * (1.0f - kr) * pr)) * 255.0f; 61 | const float g2 = (y2 - ((2.0f * (((1.0f - kb) * kb) / ((1.0f - kb) - kr))) * pb) - ((2.0f * (((1.0f - kr) * kr) / ((1.0f - kb) - kr))) * pr)) * 255.0f; 62 | const float b2 = (y2 + (2.0f * (1.0f - kb) * pb)) * 255.0f; 63 | 64 | *(dst++) = (unsigned char) ((r1 < 0.0f) ? 0.0f : (r1 > 255.0f) ? 255.0f : r1); 65 | *(dst++) = (unsigned char) ((g1 < 0.0f) ? 0.0f : (g1 > 255.0f) ? 255.0f : g1); 66 | *(dst++) = (unsigned char) ((b1 < 0.0f) ? 0.0f : (b1 > 255.0f) ? 255.0f : b1); 67 | #if THEORAPLAY_CVT_RGB_ALPHA 68 | *(dst++) = 0xFF; 69 | #endif 70 | 71 | *(dst++) = (unsigned char) ((r2 < 0.0f) ? 0.0f : (r2 > 255.0f) ? 255.0f : r2); 72 | *(dst++) = (unsigned char) ((g2 < 0.0f) ? 0.0f : (g2 > 255.0f) ? 255.0f : g2); 73 | *(dst++) = (unsigned char) ((b2 < 0.0f) ? 0.0f : (b2 > 255.0f) ? 255.0f : b2); 74 | #if THEORAPLAY_CVT_RGB_ALPHA 75 | *(dst++) = 0xFF; 76 | #endif 77 | } // for 78 | 79 | // adjust to the start of the next line. 80 | py += ystride; 81 | pcb += cbstride * (posy % 2); 82 | pcr += crstride * (posy % 2); 83 | } // for 84 | } // if 85 | 86 | return pixels; 87 | } // THEORAPLAY_CVT_FNNAME_420 88 | 89 | // end of theoraplay_cvtrgb.h ... 90 | 91 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: Something isn't working 3 | labels: [bug] 4 | body: 5 | - id: validation 6 | type: checkboxes 7 | attributes: 8 | label: Before opening this issue, I ensure that... 9 | options: 10 | - label: I have read the [FAQ](https://github.com/RSDKModding/RSDKv3-Decompilation/blob/main/FAQ.md) and confirmed my issue is not mentioned in it. 11 | required: true 12 | - label: I have checked **both open and closed** issues and confirmed this bug has not already been reported. 13 | required: true 14 | - label: I am not asking for tech support (e.g. game closing on startup, error when trying to build, etc). 15 | required: true 16 | - label: I am not asking for modding support or reporting a bug in a specific mod; this bug either occurs without mods enabled or is directly related to the mod loader. 17 | required: true 18 | - label: This bug is not related to any unofficial fork/port of the decompilation, and any issues with those should be kept in the appropriate repository. 19 | required: true 20 | - id: expected-behavior 21 | type: input 22 | validations: 23 | required: true 24 | attributes: 25 | label: Expected Behavior 26 | description: What behavior is supposed to occur? 27 | - id: actual-behavior 28 | type: input 29 | validations: 30 | required: true 31 | attributes: 32 | label: Actual Behavior 33 | description: What actually happens? 34 | - id: repro-steps 35 | type: textarea 36 | validations: 37 | required: true 38 | attributes: 39 | label: Steps to Reproduce 40 | description: How can you reproduce the bug? Please give clear instructions. 41 | placeholder: | 42 | 1. Do this 43 | 2. Do that 44 | 3. This happens 45 | - id: screenshots 46 | type: textarea 47 | validations: 48 | required: false 49 | attributes: 50 | label: Screenshots 51 | description: Provide screenshots if applicable. 52 | - id: log-file 53 | type: textarea 54 | validations: 55 | required: false 56 | attributes: 57 | label: Log File 58 | description: If EngineDebugMode is enabled in settings.ini, the decompilation will write to a log file named log.txt. You can provide it here if you believe it will be helpful. 59 | - id: decomp-version 60 | type: input 61 | validations: 62 | required: true 63 | attributes: 64 | label: Decompilation Version 65 | description: The decompilation version. If you built it manually or are using an autobuild, please specify the commit if possible. 66 | - id: gameversion 67 | type: dropdown 68 | validations: 69 | required: true 70 | attributes: 71 | label: "Game Version" 72 | description: What version of Sonic CD is being played? 73 | multiple: false 74 | options: 75 | - Blit Release (Steam/XBOX 360/PS3) 76 | - Mobile (Sega Forever) 77 | - Mobile (Pre-Sega Forever) 78 | - Sonic Origins 79 | - id: gamerevision 80 | type: input 81 | validations: 82 | required: false 83 | attributes: 84 | label: Game Revision 85 | description: If you know the specific version number of the game, provide it here. 86 | - id: renderer 87 | type: dropdown 88 | validations: 89 | required: true 90 | attributes: 91 | label: "Renderer Type" 92 | description: Are you using the Software Renderer or the Hardware Renderer? (If unsure, check the HardwareRenderer setting in settings.ini.) 93 | multiple: false 94 | options: 95 | - Software Renderer 96 | - Hardware Renderer 97 | - id: platform 98 | type: input 99 | validations: 100 | required: true 101 | attributes: 102 | label: Platform 103 | description: The platform/OS you're running the decompilation on. 104 | - id: comments 105 | type: textarea 106 | validations: 107 | required: false 108 | attributes: 109 | label: Additional Comments 110 | description: Provide any additional information if needed. 111 | -------------------------------------------------------------------------------- /dependencies/mac/README.md: -------------------------------------------------------------------------------- 1 | # Mac 2 | 3 | Before anything, you'll need to install XCode from either the App Store or the [Apple developer website](https://developer.apple.com/download/). After which to use Command Line Tools, you'll need to run `xcode-select --install` to begin the setup. 4 | 5 | Most of the Xcode project work has been done for you. Once you've set up the following sources in the dependencies folder, you can build RSDKv3 and the frameworks will compile along with it. 6 | 7 | ## Install dependencies 8 | 9 | * SDL2: [Download](https://github.com/libsdl-org/SDL/releases) as a DMG, open the file and replace the SDL2.framework in `dependencies/mac` with the newer version located inside. 10 | 11 | * libogg: [Download](https://xiph.org/downloads/) and unzip it as `./libogg/`. After which, set the current directory to said folder and run `./configure`, or run it externally as the full or partial path. 12 | 13 | * libvorbis: [Download](https://xiph.org/downloads/) and unzip it as `./libvorbis/`. 14 | 15 | * libtheora: [Download](https://xiph.org/downloads/) and unzip it as `./libtheora/`. 16 | 17 | ## Customization 18 | 19 | If you're debugging the engine, best to just open the XCode project directly and run it through the debugging process.However, if you have the Command Line Tools and want to play games using it, run `xcodebuild -project RSDKv3.xcodeproj -scheme RSDKv3 DSTROOT="./build" -configuration Release DEPLOYMENT_LOCATION=YES` to create the app. 20 | 21 | * You can still apply flags for compiling by appending the line `OTHER_CFLAGS=` and then the list of flags. All of the flags except for the last two represent bools where `0` is false and `1` is true. The last two flags take string arguments. 22 | 23 | * `RETRO_USE_MOD_LOADER` is used for `RETRO_MOD_LOADER`. Default is `-DRETRO_USE_MOD_LOADER=1`. 24 | 25 | * `RETRO_USING_OPENGL` is used for `RETRO_USE_HW_RENDER`. Default is `-DRETRO_USING_OPENGL=1`. 26 | 27 | * `RETRO_USE_SDL1` and `RETRO_USE_SDL2` are used for `RETRO_SDL_VERSION`. You should only have one on at a time or neither on. By default, `RETRO_USE_SDL2` is on. You don't really need this unless you want to switch out SDL2 with SDL1. Default is `-DRETRO_USE_SDL1=0 -DRETRO_USE_SDL2=1`. 28 | 29 | * `FORCE_CASE_INSENSITIVE` is used for `RETRO_FORCE_CASE_INSENSITIVE`. Default is `-DFORCE_CASE_INSENSITIVE=1`. 30 | 31 | * `RETRO_USE_ORIGINAL_CODE` is used for `RETRO_ORIGINAL_CODE`. Default is `-RETRO_USE_ORIGINAL_CODE=0`. 32 | 33 | * `RSDK_AUTOBUILD` is used for `RETRO_DISABLE_PLUS`. Default is `-DRSDK_AUTOBUILD=0`. 34 | * You **MUST** have this set to `1` if you plan on distributing RSDKv3 builds. And for MacOS builds specifically, you should inform users to use the command `xattr -cr /path/to/RSDKv3.app` in order to be able to open the app, or `xattr -cr /path/to/RSDKv3.zip` if said zip contains the app. This also applies to the autobuilds. 35 | 36 | * `RETRO_DEV_EXTRA` is an argument used in autobuilds to state the `CMAKE_SYSTEM_NAME` and the `CMAKE_CXX_COMPILER_ID` in the Dev Menu, such as `Darwin - AppleClang`. 37 | * You need to have a backslash escape for every special character since this is a string. 38 | * It may be better to edit [Other C++ Flags](https://developer.apple.com/documentation/xcode/build-settings-reference#Other-C++-Flags) using the XCode app so you can have a better sense of what goes wrong. 39 | 40 | * `DECOMP_VERSION` is an argument used in autobuilds to display the decomp's version number in the Dev Menu. In this case, it would be `1.3.2` already, and may not need changing. 41 | * You need to have a backslash escape for every special character since this is a string. 42 | * It may be better to edit [Other C++ Flags](https://developer.apple.com/documentation/xcode/build-settings-reference#Other-C++-Flags) using the XCode app so you can have a better sense of what goes wrong. 43 | 44 | * The default for `OTHER_CPLUSPLUSFLAGS` contains the same flags in `OTHER_CFLAGS`. You could use `OTHER_CPLUSPLUSFLAGS` to be more specific, especially if you have a major difference between the two. 45 | 46 | * The resulting command could look something like `xcodebuild -project RSDKv3.xcodeproj -scheme RSDKv3 DSTROOT="./build" -configuration Release DEPLOYMENT_LOCATION=YES OTHER_CFLAGS="-DRSDK_AUTOBUILD=1 -DRETRO_DEV_EXTRA=\\\"Darwin\\ -\\ AppleClang\\\""` 47 | -------------------------------------------------------------------------------- /RSDKv3.vita/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ## This file is a quick tutorial on writing CMakeLists for targeting the Vita 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | ## This includes the Vita toolchain, must go before project definition 5 | # It is a convenience so you do not have to type 6 | # -DCMAKE_TOOLCHAIN_FILE=$VITASDK/share/vita.toolchain.cmake for cmake. It is 7 | # highly recommended that you include this block for all projects. 8 | if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) 9 | if(DEFINED ENV{VITASDK}) 10 | set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file") 11 | else() 12 | message(FATAL_ERROR "Please define VITASDK to point to your SDK path!") 13 | endif() 14 | endif() 15 | 16 | ## Define project parameters here 17 | # Name of the project 18 | project(RSDKv3) 19 | # This line adds Vita helper macros, must go after project definition in order 20 | # to build Vita specific artifacts (self/vpk). 21 | include("${VITASDK}/share/vita.cmake" REQUIRED) 22 | 23 | ## Configuration options for this app 24 | # Display name (under bubble in LiveArea) 25 | set(VITA_APP_NAME "Sonic CD") 26 | # Unique ID must be exactly 9 characters. Recommended: XXXXYYYYY where X = 27 | # unique string of developer and Y = a unique number for this app 28 | set(VITA_TITLEID "RSDK00001") 29 | # Optional version string to show in LiveArea's more info screen 30 | set(VITA_VERSION "1.3.2") 31 | 32 | ## Flags and includes for building 33 | # Note that we make sure not to overwrite previous flags 34 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -fsigned-char -fno-lto") 35 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -fsigned-char -fno-lto -fno-rtti -fno-exceptions") 36 | # Optional. You can specify more param.sfo flags this way. 37 | set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1") 38 | 39 | # Add any additional include paths here 40 | include_directories( 41 | ../dependencies/all/theoraplay 42 | ../dependencies/all/tinyxml2 43 | /home/user/vitasdk/arm-vita-eabi/include 44 | ) 45 | 46 | # Add any additional library paths here 47 | # ${CMAKE_CURRENT_BINARY_DIR} lets you use any library currently being built 48 | link_directories( 49 | ${CMAKE_CURRENT_BINARY_DIR} 50 | ) 51 | 52 | ## Build and link 53 | # Add all the files needed to compile here 54 | add_executable(${PROJECT_NAME} 55 | ../dependencies/all/theoraplay/theoraplay.c 56 | ../RSDKv3/Animation.cpp 57 | ../RSDKv3/Audio.cpp 58 | ../RSDKv3/Collision.cpp 59 | ../RSDKv3/Debug.cpp 60 | ../RSDKv3/Drawing.cpp 61 | ../RSDKv3/Ini.cpp 62 | ../RSDKv3/Input.cpp 63 | ../RSDKv3/Math.cpp 64 | ../RSDKv3/ModAPI.cpp 65 | ../RSDKv3/Object.cpp 66 | ../RSDKv3/Palette.cpp 67 | ../RSDKv3/Player.cpp 68 | ../RSDKv3/Reader.cpp 69 | ../RSDKv3/RetroEngine.cpp 70 | ../RSDKv3/Scene.cpp 71 | ../RSDKv3/Scene3D.cpp 72 | ../RSDKv3/Script.cpp 73 | ../RSDKv3/Sprite.cpp 74 | ../RSDKv3/String.cpp 75 | ../RSDKv3/Text.cpp 76 | ../RSDKv3/Userdata.cpp 77 | ../RSDKv3/Video.cpp 78 | ../RSDKv3/main.cpp 79 | ) 80 | 81 | # Library to link to (drop the -l prefix). This will mostly be stubs. 82 | target_link_libraries(${PROJECT_NAME} 83 | SDL2 84 | vita2d 85 | vorbisfile 86 | vorbis 87 | ogg 88 | theora 89 | glew 90 | tinyxml2 91 | pthread 92 | SceDisplay_stub 93 | SceAudio_stub 94 | SceCtrl_stub 95 | SceSysmodule_stub 96 | SceGxm_stub 97 | SceCommonDialog_stub 98 | SceAppMgr_stub 99 | SceTouch_stub 100 | SceHid_stub 101 | SceAudio_stub 102 | SceMotion_stub 103 | m 104 | ) 105 | 106 | ## Create Vita files 107 | vita_create_self(${PROJECT_NAME}.self ${PROJECT_NAME}) 108 | # The FILE directive lets you add additional files to the VPK, the syntax is 109 | # FILE src_path dst_path_in_vpk. In this case, we add the LiveArea paths. 110 | vita_create_vpk(${PROJECT_NAME}.vpk ${VITA_TITLEID} ${PROJECT_NAME}.self 111 | VERSION ${VITA_VERSION} 112 | NAME ${VITA_APP_NAME} 113 | # FILE sce_sys/icon0.png sce_sys/icon0.png 114 | # FILE sce_sys/livearea/contents/bg.png sce_sys/livearea/contents/bg.png 115 | # FILE sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png 116 | FILE sce_sys/livearea/contents/template.xml sce_sys/livearea/contents/template.xml 117 | ) 118 | -------------------------------------------------------------------------------- /RSDKv3/Reader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef READER_H 2 | #define READER_H 3 | 4 | #ifdef FORCE_CASE_INSENSITIVE 5 | 6 | #include "fcaseopen.h" 7 | #define FileIO FILE 8 | #define fOpen(path, mode) fcaseopen(path, mode) 9 | #define fRead(buffer, elementSize, elementCount, file) fread(buffer, elementSize, elementCount, file) 10 | #define fSeek(file, offset, whence) fseek(file, offset, whence) 11 | #define fTell(file) ftell(file) 12 | #define fClose(file) fclose(file) 13 | #define fWrite(buffer, elementSize, elementCount, file) fwrite(buffer, elementSize, elementCount, file) 14 | 15 | #else 16 | 17 | #if RETRO_USING_SDL2 18 | #define FileIO SDL_RWops 19 | #define fOpen(path, mode) SDL_RWFromFile(path, mode) 20 | #define fRead(buffer, elementSize, elementCount, file) SDL_RWread(file, buffer, elementSize, elementCount) 21 | #define fSeek(file, offset, whence) SDL_RWseek(file, offset, whence) 22 | #define fTell(file) SDL_RWtell(file) 23 | #define fClose(file) SDL_RWclose(file) 24 | #define fWrite(buffer, elementSize, elementCount, file) SDL_RWwrite(file, buffer, elementSize, elementCount) 25 | #else 26 | #define FileIO FILE 27 | #define fOpen(path, mode) fopen(path, mode) 28 | #define fRead(buffer, elementSize, elementCount, file) fread(buffer, elementSize, elementCount, file) 29 | #define fSeek(file, offset, whence) fseek(file, offset, whence) 30 | #define fTell(file) ftell(file) 31 | #define fClose(file) fclose(file) 32 | #define fWrite(buffer, elementSize, elementCount, file) fwrite(buffer, elementSize, elementCount, file) 33 | #endif 34 | 35 | #endif 36 | 37 | struct FileInfo { 38 | char fileName[0x100]; 39 | int fileSize; 40 | int vFileSize; 41 | int readPos; 42 | int bufferPosition; 43 | int virtualFileOffset; 44 | byte eStringPosA; 45 | byte eStringPosB; 46 | byte eStringNo; 47 | byte eNybbleSwap; 48 | FileIO *cFileHandle; 49 | byte *fileBuffer; 50 | #if RETRO_USE_MOD_LOADER 51 | byte isMod; 52 | #endif 53 | }; 54 | 55 | extern char rsdkName[0x400]; 56 | 57 | extern char fileName[0x100]; 58 | extern byte fileBuffer[0x2000]; 59 | extern int fileSize; 60 | extern int vFileSize; 61 | extern int readPos; 62 | extern int readSize; 63 | extern int bufferPosition; 64 | extern int virtualFileOffset; 65 | extern byte eStringPosA; 66 | extern byte eStringPosB; 67 | extern byte eStringNo; 68 | extern byte eNybbleSwap; 69 | extern char encryptionStringA[21]; 70 | extern char encryptionStringB[13]; 71 | #if RETRO_USE_MOD_LOADER 72 | extern byte isModdedFile; 73 | #endif 74 | 75 | extern FileIO *cFileHandle; 76 | 77 | inline void CopyFilePath(char *dest, const char *src) 78 | { 79 | strcpy(dest, src); 80 | for (int i = 0;; ++i) { 81 | if (i >= strlen(dest)) { 82 | break; 83 | } 84 | 85 | if (dest[i] == '/') 86 | dest[i] = '\\'; 87 | } 88 | } 89 | bool CheckRSDKFile(const char *filePath); 90 | 91 | bool LoadFile(const char *filePath, FileInfo *fileInfo); 92 | inline bool CloseFile() 93 | { 94 | int result = 0; 95 | if (cFileHandle) 96 | result = fClose(cFileHandle); 97 | 98 | cFileHandle = NULL; 99 | return result; 100 | } 101 | 102 | void FileRead(void *dest, int size); 103 | 104 | bool ParseVirtualFileSystem(FileInfo *fileInfo); 105 | 106 | inline size_t FillFileBuffer() 107 | { 108 | if (readPos + 0x2000 <= fileSize) 109 | readSize = 0x2000; 110 | else 111 | readSize = fileSize - readPos; 112 | 113 | size_t result = fRead(fileBuffer, 1, readSize, cFileHandle); 114 | readPos += readSize; 115 | bufferPosition = 0; 116 | return result; 117 | } 118 | 119 | inline void GetFileInfo(FileInfo *fileInfo) 120 | { 121 | StrCopy(fileInfo->fileName, fileName); 122 | fileInfo->bufferPosition = bufferPosition; 123 | fileInfo->readPos = readPos - readSize; 124 | fileInfo->fileSize = fileSize; 125 | fileInfo->vFileSize = vFileSize; 126 | fileInfo->virtualFileOffset = virtualFileOffset; 127 | fileInfo->eStringPosA = eStringPosA; 128 | fileInfo->eStringPosB = eStringPosB; 129 | fileInfo->eStringNo = eStringNo; 130 | fileInfo->eNybbleSwap = eNybbleSwap; 131 | #if RETRO_USE_MOD_LOADER 132 | fileInfo->isMod = isModdedFile; 133 | #endif 134 | } 135 | void SetFileInfo(FileInfo *fileInfo); 136 | size_t GetFilePosition(); 137 | void SetFilePosition(int newPos); 138 | bool ReachedEndOfFile(); 139 | 140 | #endif // !READER_H 141 | -------------------------------------------------------------------------------- /FAQ.md: -------------------------------------------------------------------------------- 1 | # General 2 | ### Q: How do I set this up? 3 | A: You can find a tutorial for setting up both the game and mods [here](https://gamebanana.com/tuts/14111). Alternatively, opening the decompilation without any game assets present will generate a TXT file containing a brief guide to setting them up. 4 | 5 | ### Q: Why don't some buttons in the menu work? 6 | A: Buttons like Leaderboards & Achievements require code to be added to support online functionality & menus (though they are still saved in the Udata.bin file), and other things like the Controls and Settings menus in the Blit versions or the Privacy button in the mobile version have no scripts and are instead hardcoded. It's just not worth decompiling any of that, so just use mods to restore/add menus for them. 7 | 8 | ### Q: The screen is tearing, how do I fix it? 9 | A: Try turning on VSync in settings.ini. 10 | 11 | ### Q: Why is my game is running faster than it's supposed to? 12 | A: The Retro Engine has all of its engine and game logic tied to the framerate, meaning the faster your refresh rate is, the faster the game runs. You can fix this by turning off VSync in settings.ini or by changing your device's refresh rate. 13 | 14 | ### Q: I'm on Windows and experiencing issues such as crashes or mods not appearing in the mod menu, what's wrong? 15 | A: A likely reason for this is that you put the decomp in a directory in your user folder (Desktop, Downloads, Documents, etc). These directories are known to cause issues, so move your decomp installation elsewhere, such as the root of the C drive or another drive. If it's still not working, try redownloading and reinstalling the decomp. 16 | 17 | ### Q: I found a bug! 18 | A: Submit an issue in the Issues tab and we might look into it. Keep in mind that this is a decompilation, so bugs that exist in official releases will most likely not be fixed here. 19 | 20 | 21 | # Using Blit/Steam RSDK Files 22 | ### Q: Why is the titlecard text slightly offset when playing in widescreen? 23 | A: This is a known issue that is caused by the scripts from this version of the game. You can either use a mod that modifies `TitleCards/R[X]_TitleCard.txt` to fix it, or simply set the `screenWidth` option in settings.ini to 400 to match the intended value used in the original release. 24 | 25 | ### Q: Why is there a weird spot on the title screen when playing in widescreen? 26 | A: Similar to above, this is a script issue. You can fix it via a mod or by changing the screen width. 27 | 28 | 29 | # Using Mobile RSDK Files 30 | ### Q: Why does pressing B pause the game during gameplay? 31 | A: This is a known script issue with most Sega Forever versions of the game. Using the [decompiled scripts](https://github.com/RSDKModding/RSDKv3-Script-Decompilation) should fix it. 32 | 33 | ### Q: Why are the SEGA and Christian Whitehead logos in the title screen so low resolution? 34 | A: This happens when using the Software Renderer, you can fix this by setting `HardwareRenderer` to true in settings.ini. 35 | 36 | ### Q: Why don't the video files from the mobile version of the game work? 37 | A: The decompilation only supports the OGV video files from the Blit/Steam version of the game. 38 | 39 | 40 | # Using Origins RSDK Files 41 | You can find a guide for fixing most of these issues [here](https://gamebanana.com/tuts/16686). 42 | 43 | ### Q: Why doesn't using the datafile work? 44 | A: The RSDK file from Sonic Origins is encrypted in the RSDKv5 datapack format, not the RSDKv3 format. Repacking the files in the correct format or using Data Folder Mode will fix the issue. 45 | 46 | ### Q: Why is there no audio? 47 | A: Sonic Origins doesn't have any music or sound effects contained in the game's data file, instead storing and handling all in-game audio itself through Hedgehog Engine 2. You can fix this by simply inserting the audio files from another version of the game. Sound effects added in Origins will have to be inserted manually. 48 | 49 | ### Q: Why is the Drop Dash disabled by default? How do I turn it on? 50 | A: By default, the game mode is set to Classic Mode, which disables the Drop Dash. The only way to change this is through a mod. 51 | 52 | ### Q: How do I play as Knuckles or Amy? 53 | A: Sonic Team implemented Knuckles and Amy in a way where they aren't playable on the decomp out of the box. This can be fixed via mods. There are also checks implemented in the engine to prevent playing as these characters on release builds and autobuilds. 54 | 55 | ### Q: Why is the DLC disabled in release builds and autobuilds? 56 | A: Long story short, it's to minimize piracy and ensure an extra layer of legal protection for Sonic Origins Plus. Giving players paid content for free is not the goal of this project. 57 | 58 | 59 | # Miscellaneous 60 | ### Q: Will you do a decompilation for RSDKv4? 61 | A: I already have! You can find it [here](https://github.com/RSDKModding/RSDKv4-Decompilation). 62 | 63 | ### Q: Will you do a decompilation for RSDKv5/Sonic Mania? 64 | A: I already have! You can find Sonic Mania [here](https://github.com/RSDKModding/Sonic-Mania-Decompilation) and RSDKv5 [here](https://github.com/RSDKModding/RSDKv5-Decompilation). 65 | -------------------------------------------------------------------------------- /RSDKv3/Palette.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PALETTE_H 2 | #define PALETTE_H 3 | 4 | #define PALETTE_COUNT (0x8) 5 | #define PALETTE_SIZE (0x100) 6 | 7 | struct Colour { 8 | byte r; 9 | byte g; 10 | byte b; 11 | byte a; 12 | }; 13 | 14 | struct PaletteEntry { 15 | byte r; 16 | byte g; 17 | byte b; 18 | }; 19 | 20 | // Palettes (as RGB565 Colours) 21 | extern PaletteEntry fullPalette32[PALETTE_COUNT][PALETTE_SIZE]; 22 | extern ushort fullPalette[PALETTE_COUNT][PALETTE_SIZE]; 23 | extern ushort *activePalette; // Ptr to the 256 colour set thats active 24 | extern PaletteEntry *activePalette32; 25 | 26 | extern byte gfxLineBuffer[SCREEN_YSIZE]; // Pointers to active palette 27 | extern int GFX_LINESIZE; 28 | extern int GFX_LINESIZE_MINUSONE; 29 | extern int GFX_LINESIZE_DOUBLE; 30 | extern int GFX_FRAMEBUFFERSIZE; 31 | extern int GFX_FBUFFERMINUSONE; 32 | 33 | extern int fadeMode; 34 | extern byte fadeA; 35 | extern byte fadeR; 36 | extern byte fadeG; 37 | extern byte fadeB; 38 | 39 | extern int paletteMode; 40 | 41 | extern int texPaletteNum; 42 | 43 | extern uint gfxPalette16to32[0x10000]; 44 | 45 | #define RGB888_TO_RGB5551(r, g, b) ((((b) >> 3) << 1) | (((g) >> 3) << 6) | (((r) >> 3) << 11) | 0) // used in mobile vers 46 | #define RGB888_TO_RGB565(r, g, b) ((b) >> 3) | (((g) >> 2) << 5) | (((r) >> 3) << 11) // used in pc vers 47 | 48 | #define PACK_RGB888(colour, r, g, b) \ 49 | if (renderType == RENDER_SW) \ 50 | colour = RGB888_TO_RGB565(r, g, b); \ 51 | else if (renderType == RENDER_HW) \ 52 | colour = RGB888_TO_RGB5551(r, g, b); 53 | 54 | void LoadPalette(const char *filePath, int paletteID, int startPaletteIndex, int startIndex, int endIndex); 55 | 56 | inline void SetActivePalette(byte newActivePal, int startLine, int endLine) 57 | { 58 | if (renderType == RENDER_SW) { 59 | if (newActivePal < PALETTE_COUNT) 60 | for (int l = startLine; l < endLine && l < SCREEN_YSIZE; l++) gfxLineBuffer[l] = newActivePal; 61 | 62 | activePalette = fullPalette[gfxLineBuffer[0]]; 63 | activePalette32 = fullPalette32[gfxLineBuffer[0]]; 64 | } 65 | 66 | if (renderType == RENDER_HW) { 67 | if (newActivePal < PALETTE_COUNT) 68 | texPaletteNum = newActivePal; 69 | } 70 | } 71 | 72 | inline void SetPaletteEntry(byte paletteIndex, byte index, byte r, byte g, byte b) 73 | { 74 | if (paletteIndex != 0xFF) { 75 | PACK_RGB888(fullPalette[paletteIndex][index], r, g, b); 76 | fullPalette32[paletteIndex][index].r = r; 77 | fullPalette32[paletteIndex][index].g = g; 78 | fullPalette32[paletteIndex][index].b = b; 79 | 80 | if (renderType == RENDER_HW) { 81 | if (index) 82 | fullPalette[paletteIndex][index] |= 1; 83 | } 84 | } 85 | else { 86 | PACK_RGB888(activePalette[index], r, g, b); 87 | activePalette32[index].r = r; 88 | activePalette32[index].g = g; 89 | activePalette32[index].b = b; 90 | 91 | if (renderType == RENDER_HW) { 92 | if (index) 93 | activePalette[index] |= 1; 94 | } 95 | } 96 | } 97 | 98 | inline void CopyPalette(byte src, byte dest) 99 | { 100 | if (src < PALETTE_COUNT && dest < PALETTE_COUNT) { 101 | for (int i = 0; i < PALETTE_SIZE; ++i) { 102 | fullPalette[dest][i] = fullPalette[src][i]; 103 | fullPalette32[dest][i] = fullPalette32[src][i]; 104 | } 105 | } 106 | } 107 | 108 | inline void RotatePalette(byte startIndex, byte endIndex, bool right) 109 | { 110 | if (right) { 111 | ushort startClr = activePalette[endIndex]; 112 | PaletteEntry startClr32 = activePalette32[endIndex]; 113 | for (int i = endIndex; i > startIndex; --i) { 114 | activePalette[i] = activePalette[i - 1]; 115 | activePalette32[i] = activePalette32[i - 1]; 116 | } 117 | activePalette[startIndex] = startClr; 118 | activePalette32[startIndex] = startClr32; 119 | } 120 | else { 121 | ushort startClr = activePalette[startIndex]; 122 | PaletteEntry startClr32 = activePalette32[startIndex]; 123 | for (int i = startIndex; i < endIndex; ++i) { 124 | activePalette[i] = activePalette[i + 1]; 125 | activePalette32[i] = activePalette32[i + 1]; 126 | } 127 | activePalette[endIndex] = startClr; 128 | activePalette32[endIndex] = startClr32; 129 | } 130 | } 131 | 132 | inline void SetFade(byte R, byte G, byte B, ushort A) 133 | { 134 | fadeMode = 1; 135 | fadeR = R; 136 | fadeG = G; 137 | fadeB = B; 138 | fadeA = A > 0xFF ? 0xFF : A; 139 | } 140 | void SetLimitedFade(byte paletteID, byte R, byte G, byte B, ushort alpha, int startIndex, int endIndex); 141 | 142 | #endif // !PALETTE_H 143 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /RSDKv3/Object.cpp: -------------------------------------------------------------------------------- 1 | #include "RetroEngine.hpp" 2 | 3 | int objectLoop = 0; 4 | int curObjectType = 0; 5 | Entity objectEntityList[ENTITY_COUNT]; 6 | 7 | char typeNames[OBJECT_COUNT][0x40]; 8 | 9 | int OBJECT_BORDER_X1 = 0x80; 10 | int OBJECT_BORDER_X2 = 0; 11 | const int OBJECT_BORDER_Y1 = 0x100; 12 | const int OBJECT_BORDER_Y2 = SCREEN_YSIZE + 0x100; 13 | 14 | void SetObjectTypeName(const char *objectName, int objectID) 15 | { 16 | int objNameID = 0; 17 | int typeNameID = 0; 18 | while (objectName[objNameID]) { 19 | if (objectName[objNameID] != ' ') 20 | typeNames[objectID][typeNameID++] = objectName[objNameID]; 21 | ++objNameID; 22 | } 23 | typeNames[objectID][typeNameID] = 0; 24 | PrintLog("Set Object (%d) name to: %s", objectID, objectName); 25 | } 26 | 27 | void ProcessStartupObjects() 28 | { 29 | scriptFrameCount = 0; 30 | ClearAnimationData(); 31 | activePlayer = 0; 32 | activePlayerCount = 1; 33 | scriptEng.arrayPosition[2] = TEMPENTITY_START; 34 | Entity *entity = &objectEntityList[TEMPENTITY_START]; 35 | for (int i = 0; i < OBJECT_COUNT; ++i) { 36 | ObjectScript *scriptInfo = &objectScriptList[i]; 37 | objectLoop = TEMPENTITY_START; 38 | curObjectType = i; 39 | scriptInfo->frameListOffset = scriptFrameCount; 40 | scriptInfo->spriteSheetID = 0; 41 | entity->type = i; 42 | if (scriptCode[scriptInfo->subStartup.scriptCodePtr] > 0) 43 | ProcessScript(scriptInfo->subStartup.scriptCodePtr, scriptInfo->subStartup.jumpTablePtr, SUB_SETUP); 44 | scriptInfo->frameCount = scriptFrameCount - scriptInfo->frameListOffset; 45 | } 46 | entity->type = 0; 47 | curObjectType = 0; 48 | } 49 | 50 | void ProcessObjects() 51 | { 52 | for (int i = 0; i < DRAWLAYER_COUNT; ++i) drawListEntries[i].listSize = 0; 53 | 54 | for (objectLoop = 0; objectLoop < ENTITY_COUNT; ++objectLoop) { 55 | bool active = false; 56 | int x = 0, y = 0; 57 | Entity *entity = &objectEntityList[objectLoop]; 58 | switch (entity->priority) { 59 | case PRIORITY_BOUNDS: 60 | x = entity->XPos >> 16; 61 | y = entity->YPos >> 16; 62 | active = x > xScrollOffset - OBJECT_BORDER_X1 && x < OBJECT_BORDER_X2 + xScrollOffset && y > yScrollOffset - OBJECT_BORDER_Y1 63 | && y < yScrollOffset + OBJECT_BORDER_Y2; 64 | break; 65 | 66 | case PRIORITY_ACTIVE: 67 | case PRIORITY_ALWAYS: active = true; break; 68 | 69 | case PRIORITY_XBOUNDS: 70 | x = entity->XPos >> 16; 71 | active = x > xScrollOffset - OBJECT_BORDER_X1 && x < OBJECT_BORDER_X2 + xScrollOffset; 72 | break; 73 | 74 | case PRIORITY_BOUNDS_DESTROY: 75 | x = entity->XPos >> 16; 76 | y = entity->YPos >> 16; 77 | if (x <= xScrollOffset - OBJECT_BORDER_X1 || x >= OBJECT_BORDER_X2 + xScrollOffset || y <= yScrollOffset - OBJECT_BORDER_Y1 78 | || y >= yScrollOffset + OBJECT_BORDER_Y2) { 79 | active = false; 80 | entity->type = OBJ_TYPE_BLANKOBJECT; 81 | } 82 | else { 83 | active = true; 84 | } 85 | break; 86 | 87 | case PRIORITY_INACTIVE: active = false; break; 88 | 89 | default: break; 90 | } 91 | 92 | if (active && entity->type > OBJ_TYPE_BLANKOBJECT) { 93 | ObjectScript *scriptInfo = &objectScriptList[entity->type]; 94 | activePlayer = 0; 95 | if (scriptCode[scriptInfo->subMain.scriptCodePtr] > 0) 96 | ProcessScript(scriptInfo->subMain.scriptCodePtr, scriptInfo->subMain.jumpTablePtr, SUB_MAIN); 97 | if (scriptCode[scriptInfo->subPlayerInteraction.scriptCodePtr] > 0) { 98 | while (activePlayer < activePlayerCount) { 99 | if (playerList[activePlayer].objectInteractions) 100 | ProcessScript(scriptInfo->subPlayerInteraction.scriptCodePtr, scriptInfo->subPlayerInteraction.jumpTablePtr, 101 | SUB_PLAYERINTERACTION); 102 | ++activePlayer; 103 | } 104 | } 105 | 106 | if (entity->drawOrder < DRAWLAYER_COUNT) 107 | drawListEntries[entity->drawOrder].entityRefs[drawListEntries[entity->drawOrder].listSize++] = objectLoop; 108 | } 109 | } 110 | } 111 | 112 | void ProcessPausedObjects() 113 | { 114 | for (int i = 0; i < DRAWLAYER_COUNT; ++i) drawListEntries[i].listSize = 0; 115 | 116 | for (objectLoop = 0; objectLoop < ENTITY_COUNT; ++objectLoop) { 117 | Entity *entity = &objectEntityList[objectLoop]; 118 | 119 | if (entity->priority == PRIORITY_ALWAYS && entity->type > OBJ_TYPE_BLANKOBJECT) { 120 | ObjectScript *scriptInfo = &objectScriptList[entity->type]; 121 | activePlayer = 0; 122 | if (scriptCode[scriptInfo->subMain.scriptCodePtr] > 0) 123 | ProcessScript(scriptInfo->subMain.scriptCodePtr, scriptInfo->subMain.jumpTablePtr, SUB_MAIN); 124 | if (scriptCode[scriptInfo->subPlayerInteraction.scriptCodePtr] > 0) { 125 | while (activePlayer < PLAYER_COUNT) { 126 | if (playerList[activePlayer].objectInteractions) 127 | ProcessScript(scriptInfo->subPlayerInteraction.scriptCodePtr, scriptInfo->subPlayerInteraction.jumpTablePtr, 128 | SUB_PLAYERINTERACTION); 129 | ++activePlayer; 130 | } 131 | } 132 | 133 | if (entity->drawOrder < DRAWLAYER_COUNT) 134 | drawListEntries[entity->drawOrder].entityRefs[drawListEntries[entity->drawOrder].listSize++] = objectLoop; 135 | } 136 | } 137 | } -------------------------------------------------------------------------------- /RSDKv3/Animation.cpp: -------------------------------------------------------------------------------- 1 | #include "RetroEngine.hpp" 2 | 3 | AnimationFile animationFileList[ANIFILE_COUNT]; 4 | int animationFileCount = 0; 5 | 6 | SpriteFrame scriptFrames[SPRITEFRAME_COUNT]; 7 | int scriptFrameCount = 0; 8 | 9 | SpriteFrame animFrames[SPRITEFRAME_COUNT]; 10 | int animFrameCount = 0; 11 | SpriteAnimation animationList[ANIMATION_COUNT]; 12 | int animationCount = 0; 13 | Hitbox hitboxList[HITBOX_COUNT]; 14 | int hitboxCount = 0; 15 | 16 | void LoadAnimationFile(const char *filePath) 17 | { 18 | FileInfo info; 19 | if (LoadFile(filePath, &info)) { 20 | byte fileBuffer = 0; 21 | char strBuf[0x21]; 22 | byte sheetIDs[0x18]; 23 | sheetIDs[0] = 0; 24 | 25 | byte sheetCount = 0; 26 | FileRead(&sheetCount, 1); 27 | 28 | // Read & load each spritesheet 29 | for (int s = 0; s < sheetCount; ++s) { 30 | FileRead(&fileBuffer, 1); 31 | if (fileBuffer) { 32 | int i = 0; 33 | for (; i < fileBuffer; ++i) FileRead(&strBuf[i], 1); 34 | strBuf[i] = 0; 35 | GetFileInfo(&info); 36 | CloseFile(); 37 | sheetIDs[s] = AddGraphicsFile(strBuf); 38 | SetFileInfo(&info); 39 | } 40 | } 41 | 42 | byte animCount = 0; 43 | FileRead(&animCount, 1); 44 | AnimationFile *animFile = &animationFileList[animationFileCount]; 45 | animFile->animCount = animCount; 46 | animFile->aniListOffset = animationCount; 47 | 48 | // Read animations 49 | for (int a = 0; a < animCount; ++a) { 50 | SpriteAnimation *anim = &animationList[animationCount++]; 51 | anim->frameListOffset = animFrameCount; 52 | FileRead(&fileBuffer, 1); 53 | FileRead(anim->name, fileBuffer); 54 | anim->name[fileBuffer] = 0; 55 | FileRead(&anim->frameCount, 1); 56 | FileRead(&anim->speed, 1); 57 | FileRead(&anim->loopPoint, 1); 58 | FileRead(&anim->rotationStyle, 1); 59 | 60 | for (int j = 0; j < anim->frameCount; ++j) { 61 | SpriteFrame *frame = &animFrames[animFrameCount++]; 62 | FileRead(&frame->sheetID, 1); 63 | frame->sheetID = sheetIDs[frame->sheetID]; 64 | FileRead(&frame->hitboxID, 1); 65 | FileRead(&fileBuffer, 1); 66 | frame->sprX = fileBuffer; 67 | FileRead(&fileBuffer, 1); 68 | frame->sprY = fileBuffer; 69 | FileRead(&fileBuffer, 1); 70 | frame->width = fileBuffer; 71 | FileRead(&fileBuffer, 1); 72 | frame->height = fileBuffer; 73 | 74 | sbyte buffer = 0; 75 | FileRead(&buffer, 1); 76 | frame->pivotX = buffer; 77 | FileRead(&buffer, 1); 78 | frame->pivotY = buffer; 79 | } 80 | 81 | // 90 Degree (Extra rotation Frames) rotation 82 | if (anim->rotationStyle == ROTSTYLE_STATICFRAMES) 83 | anim->frameCount >>= 1; 84 | } 85 | 86 | // Read Hitboxes 87 | animFile->hitboxListOffset = hitboxCount; 88 | FileRead(&fileBuffer, 1); 89 | for (int i = 0; i < fileBuffer; ++i) { 90 | Hitbox *hitbox = &hitboxList[hitboxCount++]; 91 | for (int d = 0; d < HITBOX_DIR_COUNT; ++d) { 92 | FileRead(&hitbox->left[d], 1); 93 | FileRead(&hitbox->top[d], 1); 94 | FileRead(&hitbox->right[d], 1); 95 | FileRead(&hitbox->bottom[d], 1); 96 | } 97 | } 98 | 99 | CloseFile(); 100 | } 101 | } 102 | void ClearAnimationData() 103 | { 104 | for (int f = 0; f < SPRITEFRAME_COUNT; ++f) MEM_ZERO(scriptFrames[f]); 105 | for (int f = 0; f < SPRITEFRAME_COUNT; ++f) MEM_ZERO(animFrames[f]); 106 | for (int h = 0; h < HITBOX_COUNT; ++h) MEM_ZERO(hitboxList[h]); 107 | for (int a = 0; a < ANIMATION_COUNT; ++a) MEM_ZERO(animationList[a]); 108 | for (int a = 0; a < ANIFILE_COUNT; ++a) MEM_ZERO(animationFileList[a]); 109 | 110 | scriptFrameCount = 0; 111 | animFrameCount = 0; 112 | animationCount = 0; 113 | animationFileCount = 0; 114 | hitboxCount = 0; 115 | } 116 | 117 | AnimationFile *AddAnimationFile(const char *filePath) 118 | { 119 | char path[0x80]; 120 | StrCopy(path, "Data/Animations/"); 121 | StrAdd(path, filePath); 122 | 123 | // If matching anim is found return that, otherwise load a new anim 124 | for (int a = 0; a < 0x100; ++a) { 125 | if (StrLength(animationFileList[a].fileName) <= 0) { 126 | StrCopy(animationFileList[a].fileName, filePath); 127 | LoadAnimationFile(path); 128 | ++animationFileCount; 129 | return &animationFileList[a]; 130 | } 131 | if (StrComp(animationFileList[a].fileName, filePath)) 132 | return &animationFileList[a]; 133 | } 134 | return NULL; 135 | } 136 | 137 | void ProcessObjectAnimation(void *objScr, void *ent) 138 | { 139 | ObjectScript *objectScript = (ObjectScript *)objScr; 140 | Entity *entity = (Entity *)ent; 141 | SpriteAnimation *sprAnim = &animationList[objectScript->animFile->aniListOffset + entity->animation]; 142 | 143 | if (entity->animationSpeed <= 0) { 144 | entity->animationTimer += sprAnim->speed; 145 | } 146 | else { 147 | if (entity->animationSpeed > 0xF0) 148 | entity->animationSpeed = 0xF0; 149 | entity->animationTimer += entity->animationSpeed; 150 | } 151 | 152 | if (entity->animation != entity->prevAnimation) { 153 | entity->prevAnimation = entity->animation; 154 | entity->frame = 0; 155 | entity->animationTimer = 0; 156 | entity->animationSpeed = 0; 157 | } 158 | 159 | if (entity->animationTimer >= 0xF0) { 160 | entity->animationTimer -= 0xF0; 161 | ++entity->frame; 162 | } 163 | 164 | if (entity->frame >= sprAnim->frameCount) 165 | entity->frame = sprAnim->loopPoint; 166 | } 167 | --------------------------------------------------------------------------------