Skip to content

Commit

Permalink
[Core/...] [GUI]: Add Nix and add a GUI
Browse files Browse the repository at this point in the history
* [Render|Core]: Fix return, and add CMakePresets

* [GUI]: Add ImGui, fix whitespace, and update some code

* [GUI]: Add ImGui Docking

* [Core]: Add a partial debugger, and ImGui test

* [GUI]: Fix Linux complaining

* [Config]: Allow nixpkgs to use older toml

* [Config]: Change default paths if on Linux

* [Config]: Adjust fonts dir

Fix logic bug in checking userDir to account for Linux
Change fonts structure to better facilitate Nix

* [SFCX]: Fix error messages

* [...]: Fix whitespace and code formatting

* add nix support

* [PPC] Fix missing semi-colon in FPU

* [GUI] Default to not opening the debugger

* [Linux\Nix]: Enable direnv

* [Core] [Nix] Restructure folders and add Linux docs, Fix nix builds

* [Config]: Fix first time init with append path

* [SFCX] [Config] Fix debug prints, Fix path for nix

* [Refactor] Fix non-UTF8 character

---------

Co-authored-by: Michael Bishop <cleverca22@gmail.com>
  • Loading branch information
Vali0004 and cleverca22 authored Mar 4, 2025
1 parent b398b83 commit 7b10ec3
Show file tree
Hide file tree
Showing 140 changed files with 3,744 additions and 2,612 deletions.
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use flake
watch_file flake.nix
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,13 @@ jobs:
with:
name: Xenon-linux64
path: ${{github.workspace}}/build/Xenon

linux_nix:
name: Linux (nix)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- name: Build Xenon
run: nix build .#xenon -L
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
path = third_party/fmt
url = https://github.com/fmtlib/fmt.git
shallow = true
[submodule "third_party/ImGui"]
path = third_party/ImGui
url = https://github.com/ocornut/imgui
branch = docking
34 changes: 29 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ function(create_target_directory_groups target_name)
endforeach()
endfunction()

find_package(fmt 11.1.3 CONFIG)
find_package(fmt 10.2.1 CONFIG)
find_package(SDL3 3.2.4 CONFIG)
find_package(toml11 4.3.0 CONFIG)
find_package(toml11 3.7.1 CONFIG)

add_subdirectory(third_party)

Expand Down Expand Up @@ -153,15 +153,39 @@ set(XCPU
Xenon/Core/XCPU/PPU/PowerPC.h
)

set(IMGUI_DIR third_party/ImGui)
set(IMGUI
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
${IMGUI_DIR}/backends/imgui_impl_opengl3.h
${IMGUI_DIR}/backends/imgui_impl_sdl3.cpp
${IMGUI_DIR}/backends/imgui_impl_sdl3.h
${IMGUI_DIR}/imconfig.h
${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/imgui.h
${IMGUI_DIR}/imgui_demo.cpp
${IMGUI_DIR}/imgui_internal.h
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_tables.cpp
${IMGUI_DIR}/imgui_widgets.cpp
${IMGUI_DIR}/imstb_rectpack.h
${IMGUI_DIR}/imstb_textedit.h
${IMGUI_DIR}/imstb_truetype.h
)

set(OPENGL
third_party/glad/src/glad.c
)

set(RENDER
${OPENGL}
${IMGUI}
Xenon/Render/Abstractions/Texture.h
Xenon/Render/Implementations/OGLTexture.cpp
Xenon/Render/Implementations/OGLTexture.h
Xenon/Render/Implementations/OGLTexture.h
Xenon/Render/GUI/Implementations/OpenGL.cpp
Xenon/Render/GUI/Implementations/OpenGL.h
Xenon/Render/GUI/GUI.cpp
Xenon/Render/GUI/GUI.h
Xenon/Render/Renderer.cpp
Xenon/Render/Renderer.h
)
Expand Down Expand Up @@ -204,7 +228,7 @@ endif()
# Include OPENGL Directory
include_directories(Xenon third_party/glad/include)

target_include_directories(Xenon PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(Xenon PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${IMGUI_DIR})
target_link_libraries(Xenon PRIVATE fmt::fmt SDL3::SDL3 toml11::toml11)

add_definitions(-DNTDDI_VERSION=0x0A000006 -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00)
Expand All @@ -218,4 +242,4 @@ endif()

if (WIN32)
target_sources(Xenon PRIVATE Xenon/Xenon.rc)
endif()
endif()
81 changes: 81 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"version": 3,
"configurePresets": [
{
"name": "windows-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-release",
"displayName": "x64 Release",
"inherits": "x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x86-debug",
"displayName": "x86 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x86-release",
"displayName": "x86 Release",
"inherits": "x86-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "linux-debug",
"displayName": "Linux Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
}
}
}
]
}
2 changes: 2 additions & 0 deletions Deps/Building/building-linux-nix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Compiling Xenon with Nix
TODO
2 changes: 2 additions & 0 deletions Deps/Building/building-linux-ubuntu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Compiling Xenon with Ubuntu
TODO
4 changes: 4 additions & 0 deletions Deps/Building/building-linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Building Xenon for Linux
### Currently, we only offically support 2 ways to do it.
## [**Nix**](https://github.com/xenon-emu/Xenon/blob/main/Deps/Building/building-linux-nix.md)
## [**Ubuntu**](https://github.com/xenon-emu/Xenon/blob/main/Deps/Building/building-linux-ubuntu.md)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Compile Xenon with Visual Studio 2022
# Compiling Xenon with Visual Studio 2022

### (Prerequisite) Download [**Git for Windows**](https://git-scm.com/download/win)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added Deps/fonts/Roboto-Black.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-BlackItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-Bold.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-BoldItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-ExtraBold.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-ExtraBoldItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-ExtraLight.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-ExtraLightItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-Italic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-Light.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-LightItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-Medium.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-MediumItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-Regular.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-SemiBold.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-SemiBoldItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-Thin.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto-ThinItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-Black.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-BlackItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-Bold.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-BoldItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-ExtraBold.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-ExtraBoldItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-ExtraLight.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-ExtraLightItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-Italic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-Light.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-LightItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-Medium.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-MediumItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-Regular.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-SemiBold.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-SemiBoldItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-Thin.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_Condensed-ThinItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-Black.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-BlackItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-Bold.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-BoldItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-ExtraBold.ttf
Binary file not shown.
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-ExtraLight.ttf
Binary file not shown.
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-Italic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-Light.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-LightItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-Medium.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-MediumItalic.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-Regular.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-SemiBold.ttf
Binary file not shown.
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-Thin.ttf
Binary file not shown.
Binary file added Deps/fonts/Roboto_SemiCondensed-ThinItalic.ttf
Binary file not shown.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

<p align="center">
<a href="https://discord.gg/TDvbdXRRQ6">
<img src="https://github.com/xenon-emu/Xenon/blob/main/Docs/screenshots/Xell_Reloaded.png" width="450">
<img src="https://github.com/xenon-emu/Xenon/blob/main/Docs/screenshots/WinDBG.png" width="510">
<img src="https://github.com/xenon-emu/Xenon/blob/main/Deps/Screenshots/Xell_Reloaded.png" width="450">
<img src="https://github.com/xenon-emu/Xenon/blob/main/Deps/Screenshots/WinDBG.png" width="510">
</p>

# Xenon
Expand All @@ -40,7 +40,9 @@ We need talented developers more than ever to contribute to the project and move
</a>

# Building
Check the build instructions for [**Windows**](https://github.com/xenon-emu/Xenon/blob/main/Docs/Building/building-windows.md).
#### [**Windows**](https://github.com/xenon-emu/Xenon/blob/main/Deps/Building/building-windows.md)
####
#### [**Linux**](https://github.com/xenon-emu/Xenon/blob/main/Deps/Building/building-linux.md)

# License
- [**GPL-2.0 license**](https://github.com/xenon-emu/Xenon/blob/main/LICENSE)
77 changes: 77 additions & 0 deletions Xenon/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"files.associations": {
"xtr1common": "cpp",
"xstring": "cpp",
"algorithm": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"deque": "cpp",
"exception": "cpp",
"filesystem": "cpp",
"format": "cpp",
"forward_list": "cpp",
"fstream": "cpp",
"functional": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"list": "cpp",
"locale": "cpp",
"map": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"optional": "cpp",
"ostream": "cpp",
"queue": "cpp",
"ratio": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"string": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"utility": "cpp",
"vector": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xtree": "cpp",
"xutility": "cpp"
}
}
28 changes: 14 additions & 14 deletions Xenon/Base/Alignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@ namespace Base {

template <typename T>
[[nodiscard]] constexpr T AlignUp(T value, size_t size) {
static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
auto mod{static_cast<T>(value % size)};
value -= mod;
return static_cast<T>(mod == T{0} ? value : value + size);
static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
auto mod{static_cast<T>(value % size)};
value -= mod;
return static_cast<T>(mod == T{0} ? value : value + size);
}

template <typename T>
[[nodiscard]] constexpr T AlignDown(T value, size_t size) {
static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
return static_cast<T>(value - value % size);
static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
return static_cast<T>(value - value % size);
}

template <typename T>
requires std::is_integral_v<T>
requires std::is_integral_v<T>
[[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) {
return (value & (alignment - 1)) == 0;
return (value & (alignment - 1)) == 0;
}

template <typename T>
requires std::is_integral_v<T>
requires std::is_integral_v<T>
[[nodiscard]] constexpr bool Is16KBAligned(T value) {
return (value & 0x3FFF) == 0;
return (value & 0x3FFF) == 0;
}

template <typename T>
requires std::is_integral_v<T>
requires std::is_integral_v<T>
[[nodiscard]] constexpr bool Is64KBAligned(T value) {
return (value & 0xFFFF) == 0;
return (value & 0xFFFF) == 0;
}

template <typename T>
requires std::is_integral_v<T>
requires std::is_integral_v<T>
[[nodiscard]] constexpr bool Is2MBAligned(T value) {
return (value & 0x1FFFFF) == 0;
return (value & 0x1FFFFF) == 0;
}

} // namespace Base
18 changes: 9 additions & 9 deletions Xenon/Base/Assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
#endif // _MSVC_VER

void assert_fail_impl() {
Base::Log::Stop();
std::fflush(stdout);
Crash();
Base::Log::Stop();
std::fflush(stdout);
Crash();
}

[[noreturn]] void unreachable_impl() {
Base::Log::Stop();
std::fflush(stdout);
Crash();
throw std::runtime_error("Unreachable code");
Base::Log::Stop();
std::fflush(stdout);
Crash();
throw std::runtime_error("Unreachable code");
}

void assert_fail_debug_msg(const std::string& msg) {
LOG_CRITICAL(Debug, "Assertion Failed!\n{}", msg.data());
assert_fail_impl();
LOG_CRITICAL(Debug, "Assertion Failed!\n{}", msg.data());
assert_fail_impl();
}
Loading

0 comments on commit 7b10ec3

Please sign in to comment.