From 8a4abb8bbbdaf2e2d2162237f8cb39dbf8143dce Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 29 Sep 2023 05:41:33 +0200 Subject: [PATCH] Update Windows build instructions --- BUILD.md | 20 ++++++++++---------- CODING_STYLE.md | 6 +++--- src/Cafe/OS/libs/coreinit/coreinit_Time.cpp | 13 +------------ 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/BUILD.md b/BUILD.md index 35aaffb..c63251d 100644 --- a/BUILD.md +++ b/BUILD.md @@ -3,20 +3,19 @@ ## Windows Prerequisites: -- A recent version of Visual Studio 2022 (recommended but not required) with the following additional components: - - C++ CMake tools for Windows - - Windows 10/11 SDK - git +- A recent version of Visual Studio 2022 with the following additional components: + - C++ CMake tools for Windows + - Windows 10/11 SDK -Instructions: +Instructions for Visual Studio 2022: 1. Run `git clone --recursive https://github.com/cemu-project/Cemu` -2. Launch `Cemu/generate_vs_solution.bat`. - - If you installed VS to a custom location or use VS 2019, you may need to manually change the path inside the .bat file. -3. Wait until it's done, then open `Cemu/build/Cemu.sln` in Visual Studio. -4. Then build the solution and once finished you can run and debug it, or build it and check the /bin folder for the final Cemu_release.exe. +2. Open the newly created Cemu directory in Visual Studio using the "Open a local folder" option +3. In the menu select Project -> Configure CMake. Wait until it is done, this may take a long time +4. You can now build, run and debug Cemu -You can also skip steps 3-5 and open the root folder of the cloned repo directly in Visual Studio (as a folder) and use the built-in CMake support but be warned that cmake support in VS can be a bit finicky. +Any other IDE should also work as long as it has CMake and MSVC support. CLion and Visual Studio Code have been confirmed to work. ## Linux @@ -46,7 +45,8 @@ To compile Cemu, a recent enough compiler and STL with C++20 support is required 5. You should now have a Cemu executable file in the /bin folder, which you can run using `./bin/Cemu_release`. #### Using GCC -While we use and test Cemu using clang, using GCC might work better with your distro (they should be fairly similar performance/issues wise and should only be considered if compilation is the issue). +While we build and test Cemu using clang, using GCC might work better with your distro (they should be fairly similar performance/issues wise and should only be considered if compilation is the issue). + You can use GCC by doing the following: - make sure you have g++ installed in your system - installation for Ubuntu and derivatives: `sudo apt install g++` diff --git a/CODING_STYLE.md b/CODING_STYLE.md index 26e1173..5476705 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -15,7 +15,7 @@ Cemu comes with a `.clang-format` file which is supported by most IDEs for forma ## About types -Cemu provides it's own set of basic fixed-width types. They are: +Cemu provides its own set of basic fixed-width types. They are: `uint8`, `sint8`, `uint16`, `sint16`, `uint32`, `sint32`, `uint64`, `sint64`. Always use these types over something like `uint32_t`. Using `size_t` is also acceptable where suitable. Avoid C types like `int` or `long`. The only exception is when interacting with external libraries which expect these types as parameters. ## When and where to put brackets @@ -48,7 +48,7 @@ In UI related code you can use `formatWxString`, but be aware that number format ## Strings and encoding -We use UTF-8 encoded `std::string` where possible. Some conversations need special handling and we have helper functions for those: +We use UTF-8 encoded `std::string` where possible. Some conversions need special handling and we have helper functions for those: ```cpp // std::filesystem::path <-> std::string (in precompiled.h) std::string _pathToUtf8(const fs::path& path); @@ -69,7 +69,7 @@ If you want to write to log.txt use `cemuLog_log()`. The log type parameter shou A pretty large part of Cemu's code base are re-implementations of various Cafe OS modules (e.g. `coreinit.rpl`, `gx2.rpl`...). These generally run in the context of the emulated process, thus special care has to be taken to use types with the correct size and endianness when interacting with memory. -Keep in mind that the emulated Espresso CPU is 32bit big-endian, while the host architectures targeted by Cemu are 64bit litte-endian! +Keep in mind that the emulated Espresso CPU is 32bit big-endian, while the host architectures targeted by Cemu are 64bit little-endian! To keep code simple and remove the need for manual endian-swapping, Cemu has templates and aliases of the basic types with explicit endian-ness. For big-endian types add the suffix `be`. Example: `uint32be` diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp index 465439b..5a75b40 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp @@ -28,16 +28,6 @@ namespace coreinit osLib_returnFromFunction64(hCPU, osTime); } - uint64 coreinit_getTimeBase_dummy() - { - return __rdtsc(); - } - - void export_OSGetSystemTimeDummy(PPCInterpreter_t* hCPU) - { - osLib_returnFromFunction64(hCPU, coreinit_getTimeBase_dummy()); - } - void export_OSGetSystemTime(PPCInterpreter_t* hCPU) { osLib_returnFromFunction64(hCPU, coreinit_getTimerTick()); @@ -371,14 +361,13 @@ namespace coreinit void InitializeTimeAndCalendar() { osLib_addFunction("coreinit", "OSGetTime", export_OSGetTime); - osLib_addFunction("coreinit", "OSGetSystemTime", export_OSGetSystemTimeDummy); + osLib_addFunction("coreinit", "OSGetSystemTime", export_OSGetSystemTime); osLib_addFunction("coreinit", "OSGetTick", export_OSGetTick); osLib_addFunction("coreinit", "OSGetSystemTick", export_OSGetSystemTick); cafeExportRegister("coreinit", OSTicksToCalendarTime, LogType::Placeholder); cafeExportRegister("coreinit", OSCalendarTimeToTicks, LogType::Placeholder); - osLib_addFunction("coreinit", "OSGetSystemTime", export_OSGetSystemTime); //timeTest(); }