diff --git a/ps2xRuntime/CMakeLists.txt b/ps2xRuntime/CMakeLists.txt index 135f996..87989d7 100644 --- a/ps2xRuntime/CMakeLists.txt +++ b/ps2xRuntime/CMakeLists.txt @@ -25,11 +25,18 @@ add_library(ps2_runtime STATIC src/ps2_syscalls.cpp ) +add_executable(ps2EntryRunner + src/register_functions.cpp + src/main.cpp +) + target_include_directories(ps2_runtime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ) target_link_libraries(ps2_runtime PRIVATE raylib) +target_link_libraries(ps2EntryRunner PRIVATE raylib) +target_link_libraries(ps2EntryRunner PRIVATE ps2_runtime) install(TARGETS ps2_runtime LIBRARY DESTINATION lib diff --git a/ps2xRuntime/include/ps2_runtime.h b/ps2xRuntime/include/ps2_runtime.h index 3c2e300..0ee42d3 100644 --- a/ps2xRuntime/include/ps2_runtime.h +++ b/ps2xRuntime/include/ps2_runtime.h @@ -326,8 +326,6 @@ public: void registerFunction(uint32_t address, RecompiledFunction func); RecompiledFunction lookupFunction(uint32_t address); - void registerBuiltinStubs(); - private: PS2Memory m_memory; R5900Context m_cpuContext; diff --git a/ps2xRuntime/include/register_functions.h b/ps2xRuntime/include/register_functions.h new file mode 100644 index 0000000..7515a14 --- /dev/null +++ b/ps2xRuntime/include/register_functions.h @@ -0,0 +1,8 @@ +#ifndef REGISTER_FUNCTIONS_H +#define REGISTER_FUNCTIONS_H + +#include "ps2_runtime.h" + +void registerAllFunctions(PS2Runtime &runtime); + +#endif // REGISTER_FUNCTIONS_H \ No newline at end of file diff --git a/ps2xRuntime/src/main.cpp b/ps2xRuntime/src/main.cpp new file mode 100644 index 0000000..436a632 --- /dev/null +++ b/ps2xRuntime/src/main.cpp @@ -0,0 +1,34 @@ +#include "ps2_runtime.h" +#include "register_functions.h" +#include +#include + +int main(int argc, char *argv[]) +{ + if (argc < 2) + { + std::cout << "Usage: " << argv[0] << " " << std::endl; + return 1; + } + + std::string elfPath = argv[1]; + + PS2Runtime runtime; + if (!runtime.initialize()) + { + std::cerr << "Failed to initialize PS2 runtime" << std::endl; + return 1; + } + + registerAllFunctions(runtime); + + if (!runtime.loadELF(elfPath)) + { + std::cerr << "Failed to load ELF file: " << elfPath << std::endl; + return 1; + } + + runtime.run(); + + return 0; +} \ No newline at end of file diff --git a/ps2xRuntime/src/ps2_runtime.cpp b/ps2xRuntime/src/ps2_runtime.cpp index 39242e4..df0dad6 100644 --- a/ps2xRuntime/src/ps2_runtime.cpp +++ b/ps2xRuntime/src/ps2_runtime.cpp @@ -76,16 +76,9 @@ bool PS2Runtime::initialize() return false; } - registerBuiltinStubs(); - return true; } -void PS2Runtime::registerBuiltinStubs() -{ - // TODO -} - bool PS2Runtime::loadELF(const std::string &elfPath) { std::ifstream file(elfPath, std::ios::binary); diff --git a/ps2xRuntime/src/register_functions.cpp b/ps2xRuntime/src/register_functions.cpp new file mode 100644 index 0000000..42a234b --- /dev/null +++ b/ps2xRuntime/src/register_functions.cpp @@ -0,0 +1,6 @@ +#include "register_functions.h" + +// Replace this file with the actual implementation of the functions that was generated by the compiler +void registerAllFunctions(PS2Runtime &runtime) +{ +} \ No newline at end of file