Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
emoose committed Jun 3, 2024
0 parents commit e5e66f3
Show file tree
Hide file tree
Showing 25 changed files with 3,006 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

build/*
build_x86/*
.vscode/*
out/*
.vs/*
rel/*
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "external/spdlog"]
path = external/spdlog
url = https://github.com/gabime/spdlog
[submodule "external/ModUtils"]
path = external/ModUtils
url = https://github.com/CookiePLMonster/ModUtils
[submodule "external/ini-cpp"]
path = external/ini-cpp
url = https://github.com/SSARCandy/ini-cpp
175 changes: 175 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# This file is automatically generated from cmake.toml - DO NOT EDIT
# See https://github.com/build-cpp/cmkr for more information

cmake_minimum_required(VERSION 3.15)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-tree builds are not supported. Run CMake from a separate directory: cmake -B build")
endif()

set(CMKR_ROOT_PROJECT OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CMKR_ROOT_PROJECT ON)

# Bootstrap cmkr and automatically regenerate CMakeLists.txt
include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT)
if(CMKR_INCLUDE_RESULT)
cmkr()
endif()

# Enable folder support
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Create a configure-time dependency on cmake.toml to improve IDE support
configure_file(cmake.toml cmake.toml COPYONLY)
endif()

project(outrun2006tweaks-proj)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")

set(ASMJIT_STATIC ON CACHE BOOL "" FORCE)

option(ZYDIS_BUILD_TOOLS "" OFF)
option(ZYDIS_BUILD_EXAMPLES "" OFF)

if ("${CMAKE_BUILD_TYPE}" MATCHES "Release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")

# Statically compile runtime
string(REGEX REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE "/MD" "/MT" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REGEX REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REGEX REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")

set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
message(NOTICE "Building in Release mode")
endif()

include(FetchContent)

message(STATUS "Fetching zydis (v4.0.0)...")
FetchContent_Declare(zydis
GIT_REPOSITORY
"https://github.com/zyantific/zydis"
GIT_TAG
v4.0.0
)
FetchContent_MakeAvailable(zydis)

message(STATUS "Fetching safetyhook (629558c64009a7291ba6ed5cfb49187086a27a47)...")
FetchContent_Declare(safetyhook
GIT_REPOSITORY
"https://github.com/cursey/safetyhook"
GIT_TAG
629558c64009a7291ba6ed5cfb49187086a27a47
)
FetchContent_MakeAvailable(safetyhook)

# Target: spdlog
set(spdlog_SOURCES
"external/spdlog/src/async.cpp"
"external/spdlog/src/bundled_fmtlib_format.cpp"
"external/spdlog/src/cfg.cpp"
"external/spdlog/src/color_sinks.cpp"
"external/spdlog/src/file_sinks.cpp"
"external/spdlog/src/spdlog.cpp"
"external/spdlog/src/stdout_sinks.cpp"
cmake.toml
)

add_library(spdlog STATIC)

target_sources(spdlog PRIVATE ${spdlog_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${spdlog_SOURCES})

target_compile_definitions(spdlog PUBLIC
SPDLOG_COMPILED_LIB
)

target_include_directories(spdlog PUBLIC
"external/spdlog/include"
)

# Target: outrun2006tweaks
set(outrun2006tweaks_SOURCES
"src/Proxy.cpp"
"src/dllmain.cpp"
"src/hook_mgr.cpp"
"src/hooks_framerate.cpp"
"src/hooks_graphics.cpp"
"src/Proxy.def"
"src/Resource.rc"
"external/ModUtils/Patterns.cpp"
"src/Proxy.hpp"
"src/game.hpp"
"src/hook_mgr.hpp"
"src/plugin.hpp"
"src/resource.h"
"external/ModUtils/Patterns.h"
"external/ModUtils/MemoryMgr.h"
cmake.toml
)

add_library(outrun2006tweaks SHARED)

target_sources(outrun2006tweaks PRIVATE ${outrun2006tweaks_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${outrun2006tweaks_SOURCES})

target_compile_definitions(outrun2006tweaks PUBLIC
_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING
)

target_compile_features(outrun2006tweaks PUBLIC
cxx_std_20
)

target_compile_options(outrun2006tweaks PUBLIC
"/GR-"
"/GS-"
"/bigobj"
"/EHa"
"/MP"
)

target_include_directories(outrun2006tweaks PUBLIC
"shared/"
"src/"
"include/"
"external/ModUtils/"
"external/ini-cpp/ini/"
)

target_link_libraries(outrun2006tweaks PUBLIC
spdlog
safetyhook
version.lib
)

target_link_options(outrun2006tweaks PUBLIC
"/DEBUG"
"/OPT:REF"
"/OPT:ICF"
)

set_target_properties(outrun2006tweaks PROPERTIES
OUTPUT_NAME
dinput8
SUFFIX
.dll
RUNTIME_OUTPUT_DIRECTORY_RELEASE
"${CMAKE_BINARY_DIR}/bin/${CMKR_TARGET}"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO
"${CMAKE_BINARY_DIR}/bin/${CMKR_TARGET}"
LIBRARY_OUTPUT_DIRECTORY_RELEASE
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
ARCHIVE_OUTPUT_DIRECTORY_RELEASE
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 emoose

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
44 changes: 44 additions & 0 deletions Outrun2006Tweaks.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[Performance]
# Framelimit: The max framerate for the game to use, this will also override the fullscreen refresh rate that the game requests.
# Set to 0 to disable this framelimiter, in case you want to use an external one instead.
FramerateLimit = 60

# FramerateFastLoad: Unlimits the framerate during load screens to help reduce load times.
# (disabling vsync may improve this even more)
FramerateFastLoad = true

# FramerateUnlockExperimental: forces game to update at 60Hz, while rendering can run at a higher rate (experimental!)
# Prevents game from speeding up when playing with FramerateLimit above 60FPS.
# Though since game is still running at 60Hz internally, so this isn't as good as a true framerate unlock, but might still be useful for some.
# (currently higher FPS has issues with certain animated textures / UI elements being drawn too quickly, not too noticeable at 120/144, but can be disorientating at 3000+FPS)
# Should be fine to leave this enabled in most cases, but if you have issues feel free to disable this here.
FramerateUnlockExperimental = true

[Window]
# WindowedBorderless: Forces windowed mode to become borderless, also fixes positioning of it to 0,0.
# Make sure to edit outrun2006.ini and change "DX/WINDOWED = 0" to "DX/WINDOWED = 1" for borderless to become active.
WindowedBorderless = true

# WindowedHideMouseCursor: Hides mouse cursor while game window is active.
WindowedHideMouseCursor = true

# DisableDPIScaling: Disables DPI scaling on game window, can help fix issues when screen DPI is set above 100%
DisableDPIScaling = true

[Graphics]
# AnisotropicFiltering: Level of AF for game to use, 1 - 16, 0 to leave it at games default.
AnisotropicFiltering = 16

# TransparencySupersampling: Allows game to enable transparency supersampling, heavily reducing aliasing on things like barriers or the cloth around the track edge.
# May only work on NVIDIA cards.
TransparencySupersampling = true

# ScreenEdgeCullFix: Fixes issues with certain stage objects being culled out before they reach edge of screen when playing at non-4:3 aspect ratio.
ScreenEdgeCullFix = true

# DisableVehicleLODs: Disables LODs on vehicles, reducing the ugly pop-in they have.
# Likely has a tiny performance hit, probably not noticeable on modern machines.
DisableVehicleLODs = true

# DisableStageCulling: Disables culling of certain stage objects, so most distant objects won't obviously pop in to view.
DisableStageCulling = true
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Outrun2006Tweaks
A wrapper DLL that can patch in some minor fixes & tweaks into Outrun 2006: Coast 2 Coast.

### Features
- Game can now run in borderless windowed mode; mouse cursor will now be hidden while game is active
- Adds a built-in framelimiter to prevent game from speeding up
- (experimentally adds a fix to allow game to run at higher FPS without speedup too, more info below)
- Fixes objects being culled out before reaching edge of screen
- Allows disabling vehicle LODs to reduce the ugly pop-in of them
- Disables culling of certain stage objects
- Can force anisotropic filtering level & enable transparency supersampling, greatly reducing aliasing around the edges of track.
- Automatically disables DPI scaling on the game window, fixing scaling issues with certain setups
- Allows game to load in lens flare data from correct path if necessary, fixing lens flare issues.

All of the above can be toggled/customized via the Outrun2006Tweaks.ini file.

There's also a semi-experimental fix to allow running above 60FPS without speedup, by locking the games tickrate to 60FPS while draw-rate is unlimited.
Since the game will still internally update at 60FPS this won't give as much benefit as a true framerate-unlock though.
(some things like animated textures & UI text also unfortunately have speed issues with it...)

### Setup
As the Steam release is packed with an ancient steamstub - which doesn't seem to work with DLL wrappers - an unpacked version of the game EXE is included with this tweaks pack.

This replacement EXE should be compatible with both the Steam release and the original DVD.

To set it up just extract the files from the release ZIP into your `Outrun2006 Coast 2 Coast` folder, where `OR2006C2C.EXE` is located, replacing the original EXE.

After that you can edit the `Outrun2006Tweaks.ini` to customize the tweaks to your liking.

### TODO
- even with LODs & culling disabled some distant cars still pop into view, can distance of them loading in be increased?
- likewise certain parts of the stage have pop-in, usually happens when some part is obscured by some other geometry, occlusion culling maybe?
- car shadow improvements? seems player car uses different shadowing to other cars, could that be added to those too?
- (the existing car shadows also seem to disappear after some distance, could it be increased?)
- input improvements: deadzone, rumble?
- fix broken car horn (haven't seen any code for it yet though...)
- game retiming? probably a pipe dream - seems game is meant for 60.2Hz tickrate, lots of things coded for that & using 0.0166112... frametimes
- a way to change music mid-race would be sweet
- intro/splash skip

### Thanks
Thanks to [debugging.games](http://debugging.games) for hosting debug symbols for Outrun 2 SP (Lindburgh), very useful for looking into Outrun2006.
6 changes: 6 additions & 0 deletions build_vs2022.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
git pull --recurse-submodules
git submodule update --init --recursive
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A Win32
cmake --build . --config Release
Loading

0 comments on commit e5e66f3

Please sign in to comment.