diff --git a/.gitignore b/.gitignore index 54e92f5..d542634 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ [Rr]elease/ [Rr]eleases/ [Bb]uild/ +[Oo]bjects/ x64/ x86/ bld/ @@ -241,4 +242,4 @@ GeneratedArtifacts/ _Pvt_Extensions/ ModelManifest.xml -Ignored/ \ No newline at end of file +Ignored/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e560a72 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,171 @@ +cmake_minimum_required(VERSION 3.7) + +project(RetroEngine) + +option(FORCE_CASE_INSENSITIVE "Forces case insensivity." OFF) +option(RETRO_MOD_LOADER "Enables or disables the mod loader." ON) +option(RETRO_USE_ORIGINAL_CODE "Removes any change that differs from the original code, a playable game can't be built this way." OFF) + +set(RETRO_SDL_VERSION 2 CACHE STRING "Select between SDL2 and SDL1, defaults to SDL2") + +if(RETRO_ORIGINAL_CODE) + set(RETRO_MOD_LOADER OFF) +endif() + +set(RETRO_NAME "Nexus") + +set(RETRO_OUTPUT_NAME ${RETRO_NAME} CACHE STRING "The exported name of the executable.") + +set(RETRO_FILES + Nexus/Animation.cpp + Nexus/Audio.cpp + Nexus/Collision.cpp + Nexus/Debug.cpp + Nexus/Drawing.cpp + Nexus/Ini.cpp + Nexus/Input.cpp + Nexus/fcaseopen.c + Nexus/main.cpp + Nexus/Math.cpp + Nexus/Object.cpp + Nexus/Palette.cpp + Nexus/Player.cpp + Nexus/Reader.cpp + Nexus/RetroEngine.cpp + Nexus/Scene.cpp + Nexus/Script.cpp + Nexus/Sprite.cpp + Nexus/String.cpp + Nexus/Text.cpp + Nexus/Userdata.cpp + Nexus/Video.cpp +) + +if(NOT PLATFORM) + if(WIN32) # THIS ASSUMES VCPKG OR SOURCES !!!!!!! + set(PLATFORM "Windows" CACHE STRING "The platform to compile for.") + elseif(ANDROID) + set(PLATFORM "Android" CACHE STRING "The platform to compile for.") + else() + set(PLATFORM ${CMAKE_SYSTEM_NAME} CACHE STRING "The platform to compile for.") + endif() +endif() + +include(platforms/${PLATFORM}.cmake) + +set_target_properties(RetroEngine PROPERTIES OUTPUT_NAME ${RETRO_OUTPUT_NAME}) + +if(COMPILE_OGG) + set(OGG_DIR dependencies/${DEP_PATH}/libogg) + add_library( + libogg + STATIC + ${OGG_DIR}/src/bitwise.c + ${OGG_DIR}/src/framing.c + ) + + target_compile_options(libogg PRIVATE ${OGG_FLAGS}) + + target_include_directories(libogg PRIVATE ${OGG_DIR}/include) + target_include_directories(RetroEngine PRIVATE ${OGG_DIR}/include) + target_link_libraries(RetroEngine libogg) +endif() + +if(COMPILE_VORBIS) + set(VORBIS_DIR dependencies/${DEP_PATH}/libvorbis) + set(OGG_DIR dependencies/${DEP_PATH}/libogg) + add_library(libvorbis STATIC + ${VORBIS_DIR}/lib/analysis.c + ${VORBIS_DIR}/lib/barkmel.c + ${VORBIS_DIR}/lib/bitrate.c + ${VORBIS_DIR}/lib/block.c + ${VORBIS_DIR}/lib/codebook.c + ${VORBIS_DIR}/lib/envelope.c + ${VORBIS_DIR}/lib/floor0.c + ${VORBIS_DIR}/lib/floor1.c + ${VORBIS_DIR}/lib/info.c + ${VORBIS_DIR}/lib/lookup.c + ${VORBIS_DIR}/lib/lpc.c + ${VORBIS_DIR}/lib/lsp.c + ${VORBIS_DIR}/lib/mapping0.c + ${VORBIS_DIR}/lib/mdct.c + ${VORBIS_DIR}/lib/psy.c + ${VORBIS_DIR}/lib/registry.c + ${VORBIS_DIR}/lib/res0.c + ${VORBIS_DIR}/lib/sharedbook.c + ${VORBIS_DIR}/lib/smallft.c + ${VORBIS_DIR}/lib/synthesis.c + ${VORBIS_DIR}/lib/tone.c + ${VORBIS_DIR}/lib/vorbisenc.c + ${VORBIS_DIR}/lib/vorbisfile.c + ${VORBIS_DIR}/lib/window.c + ) + + target_compile_options(libvorbis PRIVATE ${VORBIS_FLAGS}) + + target_include_directories(libvorbis + PRIVATE + ${VORBIS_DIR}/include + ${VORBIS_DIR}/lib + ${OGG_DIR}/include + ) + target_include_directories(RetroEngine PRIVATE ${VORBIS_DIR}/include) + target_link_libraries(RetroEngine libvorbis libogg) +endif() + +if(COMPILE_THEORA) + set(THEORA_DIR dependencies/${DEP_PATH}/libtheora) + + add_library(libtheora STATIC + ${THEORA_DIR}/lib/analyze.c + ${THEORA_DIR}/lib/apiwrapper.c + ${THEORA_DIR}/lib/bitpack.c + ${THEORA_DIR}/lib/cpu.c + ${THEORA_DIR}/lib/decapiwrapper.c + ${THEORA_DIR}/lib/decinfo.c + ${THEORA_DIR}/lib/decode.c + ${THEORA_DIR}/lib/dequant.c + ${THEORA_DIR}/lib/encapiwrapper.c + ${THEORA_DIR}/lib/encfrag.c + ${THEORA_DIR}/lib/encinfo.c + ${THEORA_DIR}/lib/encode.c + ${THEORA_DIR}/lib/encoder_disabled.c + ${THEORA_DIR}/lib/enquant.c + ${THEORA_DIR}/lib/fdct.c + ${THEORA_DIR}/lib/fragment.c + ${THEORA_DIR}/lib/huffdec.c + ${THEORA_DIR}/lib/huffenc.c + ${THEORA_DIR}/lib/idct.c + ${THEORA_DIR}/lib/info.c + ${THEORA_DIR}/lib/internal.c + ${THEORA_DIR}/lib/mathops.c + ${THEORA_DIR}/lib/mcenc.c + ${THEORA_DIR}/lib/quant.c + ${THEORA_DIR}/lib/rate.c + ${THEORA_DIR}/lib/state.c + ${THEORA_DIR}/lib/tokenize.c + ) + + target_compile_options(libtheora PRIVATE ${THEORA_FLAGS}) + + target_include_directories(libtheora PRIVATE ${THEORA_DIR}/include ${OGG_DIR}/include) + target_include_directories(RetroEngine PRIVATE ${THEORA_DIR}/include) + target_link_libraries(RetroEngine libtheora) +endif() + +target_include_directories(RetroEngine PRIVATE + Nexus/ +) + +if(DEFINED DEP_PATH) + target_include_directories(RetroEngine PRIVATE + dependencies/${DEP_PATH}/ + ) +endif() + + +target_compile_definitions(RetroEngine PRIVATE + RETRO_USE_MOD_LOADER=$ + FORCE_CASE_INSENSITIVE=$ + RETRO_USE_ORIGINAL_CODE=$ +) diff --git a/README.md b/README.md index 11d2fc2..0082eda 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Without assets from the Sonic Nexus 2008 demo, this decompilation will not run. * Clone the repo, follow the instructions in the [depencencies readme for Mac](./dependencies/mac/dependencies.txt) to setup dependencies, then build via the Xcode project. ## Linux +### Make * To setup your build enviroment and library dependecies, run the following commands: * Ubuntu (Mint, Pop!_OS, etc...): `sudo apt install build-essential git libsdl2-dev libvorbis-dev libogg-dev libtheora-dev` * Arch Linux: `sudo pacman -S base-devel git sdl2 libvorbis libogg libtheora` @@ -29,6 +30,21 @@ Without assets from the Sonic Nexus 2008 demo, this decompilation will not run. * The `CXXFLAGS` option can be removed if you do not want optimizations. * -j switch is optional, but will make building faster by running it parallel on multiple cores (8 cores would be -j9.) +### CMake +* Install the following dependencies depending on your platform through your terminal: + * **pacman (Arch):** `sudo pacman -S base-devel cmake sdl2 libogg libtheora libvorbis` + * **apt (Debian/Ubuntu):** `sudo apt install build-essential cmake libsdl2-dev libogg-dev libtheora-dev libvorbis-dev` + * **rpm (Fedora):** `sudo dnf install make gcc cmake sdl2-devel libogg-devel libtheora-devel libvorbis-devel zlib-devel` + * **apk (Alpine/PostmarketOS)** `sudo apk add build-base cmake sdl2-dev libogg-dev libtheora-dev libvorbis-dev` + * Your favorite package manager here, [make a pull request](https://github.com/RSDKModding/RSDKv2-Decompilation/fork) + + +* Then just run the following in the root repository directory: + ``` + cmake -B build + cmake --build build --config release + ``` + ## Unofficial Branches Follow the installation instructions in the readme of each branch. * For the **Nintendo Switch**, go to [LittlePlanetCD's fork](https://github.com/LittlePlanetCD/Sonic-Nexus-Switch). diff --git a/platforms/Linux.cmake b/platforms/Linux.cmake new file mode 100644 index 0000000..f1b6e4f --- /dev/null +++ b/platforms/Linux.cmake @@ -0,0 +1,59 @@ +find_package(PkgConfig REQUIRED) + +add_executable(RetroEngine ${RETRO_FILES}) + +pkg_check_modules(OGG ogg) + +if(NOT OGG_FOUND) + set(COMPILE_OGG TRUE) + message(NOTICE "libogg not found, attempting to build from source") +else() + message("found libogg") + target_link_libraries(RetroEngine ${OGG_STATIC_LIBRARIES}) + target_link_options(RetroEngine PRIVATE ${OGG_STATIC_LDLIBS_OTHER}) + target_compile_options(RetroEngine PRIVATE ${OGG_STATIC_CFLAGS}) +endif() + +pkg_check_modules(THEORA theora theoradec) + +if(NOT THEORA_FOUND) + message("could not find libtheora, attempting to build manually") + set(COMPILE_THEORA TRUE) +else() + message("found libtheora") + target_link_libraries(RetroEngine ${THEORA_STATIC_LIBRARIES}) + target_link_options(RetroEngine PRIVATE ${THEORA_STATIC_LDLIBS_OTHER}) + target_compile_options(RetroEngine PRIVATE ${THEORA_STATIC_CFLAGS}) +endif() + +pkg_check_modules(VORBIS vorbis vorbisfile) #idk what the names are + +if(NOT VORBIS_FOUND) + set(COMPILE_VORBIS TRUE) + message(NOTICE "libvorbis not found, attempting to build from source") +else() + message("found libvorbis") + target_link_libraries(RetroEngine ${VORBIS_STATIC_LIBRARIES}) + target_link_options(RetroEngine PRIVATE ${VORBIS_STATIC_LDLIBS_OTHER}) + target_compile_options(RetroEngine PRIVATE ${VORBIS_STATIC_CFLAGS}) +endif() + + +if(RETRO_SDL_VERSION STREQUAL "2") + pkg_check_modules(SDL2 sdl2 REQUIRED) + target_link_libraries(RetroEngine ${SDL2_STATIC_LIBRARIES}) + target_link_options(RetroEngine PRIVATE ${SDL2_STATIC_LDLIBS_OTHER}) + target_compile_options(RetroEngine PRIVATE ${SDL2_STATIC_CFLAGS}) +elseif(RETRO_SDL_VERSION STREQUAL "1") + pkg_check_modules(SDL1 sdl1 REQUIRED) + target_link_libraries(RetroEngine ${SDL1_STATIC_LIBRARIES}) + target_link_options(RetroEngine PRIVATE ${SDL1_STATIC_LDLIBS_OTHER}) + target_compile_options(RetroEngine PRIVATE ${SDL1_STATIC_CFLAGS}) +endif() + +if(RETRO_USE_MOD_LOADER) + set_target_properties(RetroEngine PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + ) +endif()