Fixed compilation with latest lus

This commit is contained in:
KiritoDv 2024-09-06 23:25:52 -06:00 committed by Sonic Dreamcaster
parent 299aa71966
commit b03d093fc2
5 changed files with 44 additions and 38 deletions

View File

@ -537,3 +537,22 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
)
endif()
endif()
include(ExternalProject)
ExternalProject_Add(Torch
PREFIX Torch
SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools/Torch
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/Torch
)
ExternalProject_Get_Property(Torch install_dir)
set(TORCH_EXECUTABLE ${install_dir}/src/Torch-build/$<CONFIGURATION>/torch)
add_custom_target(
ExtractAssets
DEPENDS Torch
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${TORCH_EXECUTABLE} header -o baserom.us.uncompressed.z64
COMMAND ${TORCH_EXECUTABLE} otr baserom.us.uncompressed.z64
# COMMAND ${TORCH_EXECUTABLE} pack assets starship.otr
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/sf64.otr" "${CMAKE_BINARY_DIR}/sf64.otr"
# COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr"
)

View File

@ -8,7 +8,7 @@ f7475fb11e7e6830f82883412638e8390791ab87:
sort: OFFSET
# logging: ERROR
output:
binary: starship.otr
binary: sf64.otr
code: src/assets
headers: include/assets
modding: src/assets
@ -27,7 +27,7 @@ d064229a32cc05ab85e2381ce07744eb3ffaf530:
gbi: F3DEX
sort: OFFSET
output:
binary: starship.otr
binary: sf64.otr
code: src/assets
headers: include/assets
modding: src/assets

View File

@ -21,7 +21,6 @@
#include <DisplayListFactory.h>
#include <TextureFactory.h>
#include <MatrixFactory.h>
#include <ArrayFactory.h>
#include <BlobFactory.h>
#include <VertexFactory.h>
@ -45,7 +44,7 @@ GameEngine::GameEngine() {
if (const std::string cube_path = Ship::Context::GetPathRelativeToAppDirectory("starship.otr"); std::filesystem::exists(cube_path)) {
OTRFiles.push_back(cube_path);
}
if (const std::string sm64_otr_path = Ship::Context::GetPathRelativeToAppBundle("sm64.otr"); std::filesystem::exists(sm64_otr_path)) {
if (const std::string sm64_otr_path = Ship::Context::GetPathRelativeToAppBundle("sf64.otr"); std::filesystem::exists(sm64_otr_path)) {
OTRFiles.push_back(sm64_otr_path);
}
if (const std::string patches_path = Ship::Context::GetPathRelativeToAppDirectory("mods"); !patches_path.empty() && std::filesystem::exists(patches_path)) {
@ -80,7 +79,6 @@ GameEngine::GameEngine() {
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryVertexV0>(), RESOURCE_FORMAT_BINARY, "Vertex", static_cast<uint32_t>(LUS::ResourceType::Vertex), 0);
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryDisplayListV0>(), RESOURCE_FORMAT_BINARY, "DisplayList", static_cast<uint32_t>(LUS::ResourceType::DisplayList), 0);
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryMatrixV0>(), RESOURCE_FORMAT_BINARY, "Matrix", static_cast<uint32_t>(LUS::ResourceType::Matrix), 0);
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryArrayV0>(), RESOURCE_FORMAT_BINARY, "Array", static_cast<uint32_t>(LUS::ResourceType::Array), 0);
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryBlobV0>(), RESOURCE_FORMAT_BINARY, "Blob", static_cast<uint32_t>(LUS::ResourceType::Blob), 0);
}

View File

@ -2,7 +2,6 @@
#include "Engine.h"
#include "DisplayList.h"
#include "Array.h"
extern "C" int GameEngine_OTRSigCheck(const char* data);
@ -31,24 +30,16 @@ extern "C" void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0) {
}
extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) {
auto data = reinterpret_cast<char*>(texAddr);
char* imgData = (char*)texAddr;
if (texAddr != 0 && GameEngine_OTRSigCheck(data)) {
const auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(data);
const auto type = static_cast<LUS::ResourceType>(res->GetInitData()->Type);
if (texAddr != 0 && GameEngine_OTRSigCheck(imgData)) {
auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(imgData);
switch(type) {
case LUS::ResourceType::DisplayList:
texAddr = reinterpret_cast<uintptr_t>(&std::static_pointer_cast<LUS::DisplayList>(res)->Instructions[0]);
break;
case LUS::ResourceType::Array:
texAddr = reinterpret_cast<uintptr_t>(std::static_pointer_cast<LUS::Array>(res)->Vertices.data());
break;
default:
texAddr = reinterpret_cast<uintptr_t>(res->GetRawPointer());
break;
if (res->GetInitData()->Type == (uint32_t) LUS::ResourceType::DisplayList)
texAddr = (uintptr_t)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);
else {
texAddr = (uintptr_t) res->GetRawPointer();
}
}
__gSPInvalidateTexCache(pkt, texAddr);
}
}

View File

@ -111,16 +111,15 @@ void DrawSettingsMenu(){
// })) {
// audio_set_player_volume(SEQ_PLAYER_ENV, CVarGetFloat("gEnvironmentVolume", 1.0f));
// }
//
// static std::unordered_map<Ship::AudioBackend, const char*> audioBackendNames = {
// { Ship::AudioBackend::WASAPI, "Windows Audio Session API" },
// { Ship::AudioBackend::PULSE, "PulseAudio" },
// { Ship::AudioBackend::SDL, "SDL" },
// };
//
// ImGui::Text("Audio API (Needs reload)");
// auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetAudioBackend();
//
// if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
// UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f);
// }
@ -136,7 +135,7 @@ void DrawSettingsMenu(){
// if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
// UIWidgets::ReEnableComponent("");
// }
//
// ImGui::EndMenu();
// }
@ -188,7 +187,7 @@ void DrawSettingsMenu(){
{ // FPS Slider
const int minFps = 30;
static int maxFps;
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) {
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) {
maxFps = 360;
} else {
maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
@ -256,12 +255,12 @@ void DrawSettingsMenu(){
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
#else
bool matchingRefreshRate =
CVarGetInteger("gMatchRefreshRate", 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::DX11;
CVarGetInteger("gMatchRefreshRate", 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::FAST3D_DXGI_DX11;
UIWidgets::CVarSliderInt((currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", "gInterpolationFPS", minFps, maxFps, 1, {
.disabled = matchingRefreshRate
});
#endif
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) {
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) {
UIWidgets::Tooltip(
"Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely "
"visual and does not impact game logic, execution of glitches etc.\n\n"
@ -275,7 +274,7 @@ void DrawSettingsMenu(){
}
} // END FPS Slider
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) {
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) {
UIWidgets::Spacer(0);
if (ImGui::Button("Match Refresh Rate")) {
int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
@ -290,7 +289,7 @@ void DrawSettingsMenu(){
UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate");
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) {
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) {
UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS",
"##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false);
UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time.");
@ -300,17 +299,16 @@ void DrawSettingsMenu(){
static std::unordered_map<Ship::WindowBackend, const char*> windowBackendNames = {
{ Ship::WindowBackend::DX11, "DirectX" },
{ Ship::WindowBackend::SDL_OPENGL, "OpenGL"},
{ Ship::WindowBackend::SDL_METAL, "Metal" },
{ Ship::WindowBackend::GX2, "GX2"}
{ Ship::WindowBackend::FAST3D_DXGI_DX11, "DirectX" },
{ Ship::WindowBackend::FAST3D_SDL_OPENGL, "OpenGL"},
{ Ship::WindowBackend::FAST3D_SDL_METAL, "Metal" }
};
ImGui::Text("Renderer API (Needs reload)");
Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend();
Ship::WindowBackend configWindowBackend;
int configWindowBackendId = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1);
if (configWindowBackendId != -1 && configWindowBackendId < static_cast<int>(Ship::WindowBackend::BACKEND_COUNT)) {
if (configWindowBackendId != -1 && configWindowBackendId < static_cast<int>(Ship::WindowBackend::WINDOW_BACKEND_COUNT)) {
configWindowBackend = static_cast<Ship::WindowBackend>(configWindowBackendId);
} else {
configWindowBackend = runningWindowBackend;
@ -364,7 +362,7 @@ void DrawSettingsMenu(){
void DrawMenuBarIcon() {
static bool gameIconLoaded = false;
if (!gameIconLoaded) {
// Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTexture("Game_Icon", "textures/icons/gIcon.png");
// Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("Game_Icon", "textures/icons/gIcon.png", ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
gameIconLoaded = false;
}