mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-12-19 14:32:19 +00:00
Add SDL and create basic window
This commit is contained in:
parent
c20aadac60
commit
2122f247ac
18 changed files with 107 additions and 47 deletions
4
.gitmodules
vendored
4
.gitmodules
vendored
|
|
@ -1,3 +1,7 @@
|
||||||
[submodule "thirdparty/PowerRecomp"]
|
[submodule "thirdparty/PowerRecomp"]
|
||||||
path = thirdparty/PowerRecomp
|
path = thirdparty/PowerRecomp
|
||||||
url = https://github.com/hedge-dev/PowerRecomp
|
url = https://github.com/hedge-dev/PowerRecomp
|
||||||
|
[submodule "thirdparty/SDL"]
|
||||||
|
path = thirdparty/SDL
|
||||||
|
url = https://github.com/libsdl-org/SDL.git
|
||||||
|
branch = SDL2
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ endif()
|
||||||
|
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
|
||||||
|
set(SDL_STATIC ON)
|
||||||
|
|
||||||
add_subdirectory(${SWA_THIRDPARTY_ROOT})
|
add_subdirectory(${SWA_THIRDPARTY_ROOT})
|
||||||
project("UnleashedRecomp-ALL")
|
project("UnleashedRecomp-ALL")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ set(TARGET_NAME "SWA")
|
||||||
file(GLOB "*.cpp")
|
file(GLOB "*.cpp")
|
||||||
|
|
||||||
add_compile_definitions(SWA_IMPL)
|
add_compile_definitions(SWA_IMPL)
|
||||||
|
add_compile_definitions(SDL_MAIN_HANDLED)
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
"/D_HAS_EXCEPTIONS=0"
|
"/D_HAS_EXCEPTIONS=0"
|
||||||
"/fp:strict"
|
"/fp:strict"
|
||||||
|
|
@ -14,6 +15,11 @@ add_compile_options(
|
||||||
|
|
||||||
file(GLOB SWA_RECOMPILED_SOURCES "ppc/*.cpp")
|
file(GLOB SWA_RECOMPILED_SOURCES "ppc/*.cpp")
|
||||||
|
|
||||||
|
set(SWA_PRECOMPILED_HEADERS
|
||||||
|
"ppc/ppc_recomp_shared.h"
|
||||||
|
"stdafx.h"
|
||||||
|
)
|
||||||
|
|
||||||
set(SWA_KERNEL_CXX_SOURCES
|
set(SWA_KERNEL_CXX_SOURCES
|
||||||
"kernel/imports.cpp"
|
"kernel/imports.cpp"
|
||||||
"kernel/xdm.cpp"
|
"kernel/xdm.cpp"
|
||||||
|
|
@ -30,6 +36,7 @@ set(SWA_CPU_CXX_SOURCES
|
||||||
|
|
||||||
set(SWA_GPU_CXX_SOURCES
|
set(SWA_GPU_CXX_SOURCES
|
||||||
"gpu/window.cpp"
|
"gpu/window.cpp"
|
||||||
|
"gpu/video.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SWA_APU_CXX_SOURCES
|
set(SWA_APU_CXX_SOURCES
|
||||||
|
|
@ -58,9 +65,10 @@ target_link_libraries(UnleashedRecomp PUBLIC
|
||||||
o1heap
|
o1heap
|
||||||
xxHash::xxhash
|
xxHash::xxhash
|
||||||
unordered_dense::unordered_dense
|
unordered_dense::unordered_dense
|
||||||
|
SDL2::SDL2-static
|
||||||
winmm
|
winmm
|
||||||
ntdll
|
ntdll
|
||||||
comctl32
|
comctl32
|
||||||
)
|
)
|
||||||
target_include_directories(UnleashedRecomp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(UnleashedRecomp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
target_precompile_headers(UnleashedRecomp PUBLIC "ppc/ppc_recomp_shared.h")
|
target_precompile_headers(UnleashedRecomp PUBLIC ${SWA_PRECOMPILED_HEADERS})
|
||||||
|
|
|
||||||
|
|
@ -136,8 +136,3 @@ DWORD SetThreadIdealProcessorImpl(uint32_t hThread, DWORD dwIdealProcessor)
|
||||||
GUEST_FUNCTION_HOOK(sub_82DFA2E8, SetThreadNameImpl);
|
GUEST_FUNCTION_HOOK(sub_82DFA2E8, SetThreadNameImpl);
|
||||||
GUEST_FUNCTION_HOOK(sub_82BD57A8, GetThreadPriorityImpl);
|
GUEST_FUNCTION_HOOK(sub_82BD57A8, GetThreadPriorityImpl);
|
||||||
GUEST_FUNCTION_HOOK(sub_82BD5910, SetThreadIdealProcessorImpl);
|
GUEST_FUNCTION_HOOK(sub_82BD5910, SetThreadIdealProcessorImpl);
|
||||||
|
|
||||||
void GuestThread::InitHooks()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,4 @@ struct GuestThread
|
||||||
static void SetThreadName(uint32_t id, const char* name);
|
static void SetThreadName(uint32_t id, const char* name);
|
||||||
static void SetLastError(DWORD error);
|
static void SetLastError(DWORD error);
|
||||||
static PPCContext* Invoke(uint32_t address);
|
static PPCContext* Invoke(uint32_t address);
|
||||||
static void InitHooks();
|
|
||||||
};
|
};
|
||||||
|
|
@ -1 +1,19 @@
|
||||||
#include "Window.h"
|
#include "window.h"
|
||||||
|
#include <config.h>
|
||||||
|
#include <kernel/function.h>
|
||||||
|
|
||||||
|
SDL_Window* Window::s_window = nullptr;
|
||||||
|
void* Window::s_windowHandle = nullptr;
|
||||||
|
|
||||||
|
void Window::Init()
|
||||||
|
{
|
||||||
|
auto title = Config::Language == ELanguage_Japanese
|
||||||
|
? "Sonic World Adventure"
|
||||||
|
: "SONIC UNLEASHED";
|
||||||
|
|
||||||
|
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||||
|
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
|
||||||
|
|
||||||
|
s_window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_RESIZABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
struct Window
|
||||||
|
{
|
||||||
|
static SDL_Window* s_window;
|
||||||
|
static void* s_windowHandle;
|
||||||
|
|
||||||
|
static void Init();
|
||||||
|
};
|
||||||
|
|
|
||||||
23
UnleashedRecomp/gpu/video.cpp
Normal file
23
UnleashedRecomp/gpu/video.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include <stdafx.h>
|
||||||
|
#include "video.h"
|
||||||
|
#include "window.h"
|
||||||
|
#include "kernel/function.h"
|
||||||
|
|
||||||
|
void VdInitializeSystem()
|
||||||
|
{
|
||||||
|
Window::Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void* VdGetGlobalDevice()
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Direct3D stubs
|
||||||
|
GUEST_FUNCTION_STUB(sub_824EB290);
|
||||||
|
GUEST_FUNCTION_STUB(sub_82BDA8C0);
|
||||||
|
GUEST_FUNCTION_STUB(sub_82BE05B8);
|
||||||
|
|
||||||
|
// Movie player stubs
|
||||||
|
GUEST_FUNCTION_STUB(sub_82AE3638);
|
||||||
|
GUEST_FUNCTION_STUB(sub_82AE2BF8);
|
||||||
4
UnleashedRecomp/gpu/video.h
Normal file
4
UnleashedRecomp/gpu/video.h
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void VdInitializeSystem();
|
||||||
|
SWA_API void* VdGetGlobalDevice();
|
||||||
|
|
@ -103,7 +103,7 @@ uint32_t RtlSizeHeap(uint32_t heapHandle, uint32_t flags, uint32_t memoryPointer
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t XAlloc(uint32_t size, uint32_t flags)
|
SWA_API uint32_t XAlloc(uint32_t size, uint32_t flags)
|
||||||
{
|
{
|
||||||
void* ptr = (flags & 0x80000000) != 0 ?
|
void* ptr = (flags & 0x80000000) != 0 ?
|
||||||
gUserHeap.AllocPhysical(size, (1ull << ((flags >> 24) & 0xF))) :
|
gUserHeap.AllocPhysical(size, (1ull << ((flags >> 24) & 0xF))) :
|
||||||
|
|
@ -116,7 +116,7 @@ uint32_t XAlloc(uint32_t size, uint32_t flags)
|
||||||
return gMemory.MapVirtual(ptr);
|
return gMemory.MapVirtual(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFree(uint32_t baseAddress, uint32_t flags)
|
SWA_API void XFree(uint32_t baseAddress, uint32_t flags)
|
||||||
{
|
{
|
||||||
if (baseAddress != NULL)
|
if (baseAddress != NULL)
|
||||||
gUserHeap.Free(gMemory.Translate(baseAddress));
|
gUserHeap.Free(gMemory.Translate(baseAddress));
|
||||||
|
|
|
||||||
|
|
@ -30,31 +30,11 @@ DWORD GuestTimeoutToMilliseconds(XLPQWORD timeout)
|
||||||
return timeout ? (*timeout * -1) / 10000 : INFINITE;
|
return timeout ? (*timeout * -1) / 10000 : INFINITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XboxKrnlVersion()
|
|
||||||
{
|
|
||||||
printf("!!! STUB !!! XboxKrnlVersion\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void VdGpuClockInMHz()
|
|
||||||
{
|
|
||||||
printf("!!! STUB !!! VdGpuClockInMHz\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void VdHSIOCalibrationLock()
|
void VdHSIOCalibrationLock()
|
||||||
{
|
{
|
||||||
printf("!!! STUB !!! VdHSIOCalibrationLock\n");
|
printf("!!! STUB !!! VdHSIOCalibrationLock\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void VdGlobalXamDevice()
|
|
||||||
{
|
|
||||||
printf("!!! STUB !!! VdGlobalXamDevice\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void VdGlobalDevice()
|
|
||||||
{
|
|
||||||
printf("!!! STUB !!! VdGlobalDevice\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeCertMonitorData()
|
void KeCertMonitorData()
|
||||||
{
|
{
|
||||||
printf("!!! STUB !!! KeCertMonitorData\n");
|
printf("!!! STUB !!! KeCertMonitorData\n");
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ uint32_t Memory::MapVirtual(void* host) const noexcept
|
||||||
return static_cast<uint32_t>(static_cast<char*>(host) - base);
|
return static_cast<uint32_t>(static_cast<char*>(host) - base);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void* MmGetHostAddress(uint32_t ptr)
|
SWA_API void* MmGetHostAddress(uint32_t ptr)
|
||||||
{
|
{
|
||||||
return gMemory.Translate(ptr);
|
return gMemory.Translate(ptr);
|
||||||
}
|
}
|
||||||
|
|
@ -18,4 +18,5 @@ public:
|
||||||
uint32_t MapVirtual(void* host) const noexcept;
|
uint32_t MapVirtual(void* host) const noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SWA_API void* MmGetHostAddress(uint32_t ptr);
|
||||||
extern Memory gMemory;
|
extern Memory gMemory;
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include <stdafx.h>
|
#include <stdafx.h>
|
||||||
#include <cpu/code_cache.h>
|
#include <cpu/code_cache.h>
|
||||||
#include <cpu/guest_thread.h>
|
#include <cpu/guest_thread.h>
|
||||||
|
#include <gpu/video.h>
|
||||||
#include <kernel/function.h>
|
#include <kernel/function.h>
|
||||||
#include <kernel/memory.h>
|
#include <kernel/memory.h>
|
||||||
#include <kernel/heap.h>
|
#include <kernel/heap.h>
|
||||||
|
|
@ -18,7 +19,8 @@ Memory gMemory{ reinterpret_cast<void*>(0x100000000), 0x100000000 };
|
||||||
Heap gUserHeap;
|
Heap gUserHeap;
|
||||||
CodeCache gCodeCache;
|
CodeCache gCodeCache;
|
||||||
|
|
||||||
int main()
|
// Name inspired from nt's entry point
|
||||||
|
void KiSystemStartup()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||||
|
|
@ -50,16 +52,18 @@ int main()
|
||||||
|
|
||||||
// OS mounts game data to D:
|
// OS mounts game data to D:
|
||||||
XamContentCreateEx(0, "D", &gameContent, OPEN_EXISTING, nullptr, nullptr, 0, 0, nullptr);
|
XamContentCreateEx(0, "D", &gameContent, OPEN_EXISTING, nullptr, nullptr, 0, 0, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t LdrLoadModule(const char* path)
|
||||||
|
{
|
||||||
auto loadResult = LoadFile(FileSystem::TransformPath(GAME_XEX_PATH));
|
auto loadResult = LoadFile(FileSystem::TransformPath(GAME_XEX_PATH));
|
||||||
if (!loadResult.has_value())
|
if (!loadResult.has_value())
|
||||||
{
|
{
|
||||||
assert("Failed to load default.xex" && false);
|
assert("Failed to load module" && false);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* xex = reinterpret_cast<XEX_HEADER*>(loadResult->data());
|
auto* xex = reinterpret_cast<XEX_HEADER*>(loadResult->data());
|
||||||
auto headers = reinterpret_cast<XEX_OPTIONAL_HEADER*>(&xex[1]);
|
|
||||||
auto security = reinterpret_cast<XEX2_SECURITY_INFO*>((char*)xex + xex->AddressOfSecurityInfo);
|
auto security = reinterpret_cast<XEX2_SECURITY_INFO*>((char*)xex + xex->AddressOfSecurityInfo);
|
||||||
|
|
||||||
gMemory.Alloc(security->ImageBase, security->SizeOfImage, MEM_COMMIT);
|
gMemory.Alloc(security->ImageBase, security->SizeOfImage, MEM_COMMIT);
|
||||||
|
|
@ -89,6 +93,17 @@ int main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
KiSystemStartup();
|
||||||
|
|
||||||
|
uint32_t entry = LdrLoadModule(FileSystem::TransformPath(GAME_XEX_PATH));
|
||||||
|
|
||||||
|
VdInitializeSystem();
|
||||||
|
|
||||||
GuestThread::Start(entry);
|
GuestThread::Start(entry);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
1
thirdparty/CMakeLists.txt
vendored
1
thirdparty/CMakeLists.txt
vendored
|
|
@ -16,3 +16,4 @@ FetchContent_MakeAvailable(xxHash)
|
||||||
|
|
||||||
add_subdirectory(${SWA_THIRDPARTY_ROOT}/PowerRecomp)
|
add_subdirectory(${SWA_THIRDPARTY_ROOT}/PowerRecomp)
|
||||||
add_subdirectory(${SWA_THIRDPARTY_ROOT}/o1heap)
|
add_subdirectory(${SWA_THIRDPARTY_ROOT}/o1heap)
|
||||||
|
add_subdirectory(${SWA_THIRDPARTY_ROOT}/SDL)
|
||||||
|
|
|
||||||
2
thirdparty/PowerRecomp
vendored
2
thirdparty/PowerRecomp
vendored
|
|
@ -1 +1 @@
|
||||||
Subproject commit c4de70262f0bc6e44c95df99772c136d1bdd71cc
|
Subproject commit 54cb41c4db6aee0c347835490405bd19f97f6c20
|
||||||
1
thirdparty/SDL
vendored
Submodule
1
thirdparty/SDL
vendored
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 1edaad17218d67b567c149badce9ef0fc67f65fa
|
||||||
Loading…
Add table
Reference in a new issue