diff --git a/CMakeLists.txt b/CMakeLists.txt index d3a44cb..2d69f62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,13 +52,13 @@ project(${DUSK_LIBRARY_TARGET_NAME} # Either, create library and binary separately (used for tests), or make them # one in the same so all code is in the binary only. +# Binary Executable +add_executable(${DUSK_BINARY_TARGET_NAME} ${DUSK_SOURCES_DIR}/dusk/null.c) + if(ENABLE_TESTS) # MainLibrary add_library(${DUSK_LIBRARY_TARGET_NAME} STATIC) - # Binary Executable - add_executable(${DUSK_BINARY_TARGET_NAME} ${DUSK_SOURCES_DIR}/null.c) - # Link library to binary target_link_libraries(${DUSK_BINARY_TARGET_NAME} PUBLIC @@ -66,7 +66,6 @@ if(ENABLE_TESTS) ) else() set(DUSK_LIBRARY_TARGET_NAME "${DUSK_BINARY_TARGET_NAME}" CACHE INTERNAL ${DUSK_CACHE_TARGET}) - add_executable(${DUSK_BINARY_TARGET_NAME} ${DUSK_SOURCES_DIR}/null.c) endif() # Definitions diff --git a/src/dusk/display/platform/CMakeLists.txt b/archive/platform/CMakeLists.txt similarity index 100% rename from src/dusk/display/platform/CMakeLists.txt rename to archive/platform/CMakeLists.txt diff --git a/src/dusk/display/platform/dolphin.c b/archive/platform/dolphin.c similarity index 100% rename from src/dusk/display/platform/dolphin.c rename to archive/platform/dolphin.c diff --git a/src/dusk/display/platform/dolphin.h b/archive/platform/dolphin.h similarity index 100% rename from src/dusk/display/platform/dolphin.h rename to archive/platform/dolphin.h diff --git a/src/dusk/display/platform/psp.c b/archive/platform/psp.c similarity index 100% rename from src/dusk/display/platform/psp.c rename to archive/platform/psp.c diff --git a/src/dusk/display/platform/psp.h b/archive/platform/psp.h similarity index 100% rename from src/dusk/display/platform/psp.h rename to archive/platform/psp.h diff --git a/src/dusk/display/platform/sdl2.c b/archive/platform/sdl2.c similarity index 100% rename from src/dusk/display/platform/sdl2.c rename to archive/platform/sdl2.c diff --git a/src/dusk/display/platform/sdl2.h b/archive/platform/sdl2.h similarity index 100% rename from src/dusk/display/platform/sdl2.h rename to archive/platform/sdl2.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a4cf254..15eaeca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,9 +7,13 @@ add_subdirectory(dusk) if(DUSK_TARGET_SYSTEM STREQUAL "linux") add_subdirectory(dusklinux) + add_subdirectory(dusksdl2) + add_subdirectory(duskopengl) elseif(DUSK_TARGET_SYSTEM STREQUAL "psp") add_subdirectory(duskpsp) + add_subdirectory(dusksdl2) + add_subdirectory(duskopengl) elseif(DUSK_TARGET_SYSTEM STREQUAL "gamecube" OR DUSK_TARGET_SYSTEM STREQUAL "wii") add_subdirectory(duskdolphin) diff --git a/src/dusk/debug/platform/dolphin.h b/src/dusk/debug/platform/dolphin.h deleted file mode 100644 index 5380e27..0000000 --- a/src/dusk/debug/platform/dolphin.h +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2026 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "debug/debug.h" - -/** - * Platform-specific debug print function for Dolphin. - * - * @param message The message format string. - * @param ... Additional arguments for the format string. - */ -void debugPrintDolphin(const char_t *message, ...); - -/** - * Flushes the Dolphin debug output buffer. - */ -void debugFlushDolphin(); \ No newline at end of file diff --git a/src/dusk/debug/platform/psp.h b/src/dusk/debug/platform/psp.h deleted file mode 100644 index 9af40db..0000000 --- a/src/dusk/debug/platform/psp.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2026 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "debug/debug.h" - -/** - * Platform-specific debug print function for PSP. - * - * @param message The message format string. - * @param ... Additional arguments for the format string. - */ -void debugPrintPSP(const char_t *message, ...); \ No newline at end of file diff --git a/src/dusk/display/CMakeLists.txt b/src/dusk/display/CMakeLists.txt index 08e7eb8..08af9fc 100644 --- a/src/dusk/display/CMakeLists.txt +++ b/src/dusk/display/CMakeLists.txt @@ -17,7 +17,6 @@ target_sources(${DUSK_LIBRARY_TARGET_NAME} add_subdirectory(camera) add_subdirectory(mesh) add_subdirectory(texture) -add_subdirectory(platform) # Color definitions dusk_run_python( diff --git a/src/dusk/display/display.h b/src/dusk/display/display.h index 968e4af..0407fff 100644 --- a/src/dusk/display/display.h +++ b/src/dusk/display/display.h @@ -10,19 +10,9 @@ #include "error/error.h" #include "display/camera/camera.h" #include "display/framebuffer.h" -#if DISPLAY_SDL2 - #include "display/platform/sdl2.h" -#elif DOLPHIN - #include "display/platform/dolphin.h" -#endif +#include "display/displayplatform.h" -typedef struct { - #if DISPLAY_SDL2 - displaysdl2_t sdl2; - #elif DOLPHIN - displaydolphin_t dolphin; - #endif -} display_t; +typedef displayplatform_t display_t; extern display_t DISPLAY; diff --git a/src/duskdolphin/CMakeLists.txt b/src/duskdolphin/CMakeLists.txt index 4e1b430..6b8f187 100644 --- a/src/duskdolphin/CMakeLists.txt +++ b/src/duskdolphin/CMakeLists.txt @@ -2,3 +2,12 @@ # # This software is released under the MIT License. # https://opensource.org/licenses/MIT + +# Includes +target_include_directories(${DUSK_LIBRARY_TARGET_NAME} + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} +) + +# Subdirs +add_subdirectory(debug) \ No newline at end of file diff --git a/src/dusk/debug/platform/CMakeLists.txt b/src/duskdolphin/debug/CMakeLists.txt similarity index 88% rename from src/dusk/debug/platform/CMakeLists.txt rename to src/duskdolphin/debug/CMakeLists.txt index 544b265..192f9b7 100644 --- a/src/dusk/debug/platform/CMakeLists.txt +++ b/src/duskdolphin/debug/CMakeLists.txt @@ -7,6 +7,5 @@ target_sources(${DUSK_LIBRARY_TARGET_NAME} PUBLIC - psp.c - dolphin.c + debug.c ) \ No newline at end of file diff --git a/src/dusk/debug/platform/dolphin.c b/src/duskdolphin/debug/debug.c similarity index 94% rename from src/dusk/debug/platform/dolphin.c rename to src/duskdolphin/debug/debug.c index c19c2ed..a79a452 100644 --- a/src/dusk/debug/platform/dolphin.c +++ b/src/duskdolphin/debug/debug.c @@ -10,7 +10,7 @@ static char_t DEBUG_ERROR_BUFFER[16*1024] = {0}; -void debugPrintDolphin(const char_t *message, ...) { +void debugPrint(const char_t *message, ...) { // append to error buffer size_t start = strlen(DEBUG_ERROR_BUFFER); va_list args; @@ -24,7 +24,7 @@ void debugPrintDolphin(const char_t *message, ...) { va_end(args); } -void debugFlushDolphin() { +void debugFlush() { // Either create graphics, or hijack the displays' graphics. void *xfb = NULL; GXRModeObj *rmode = NULL; diff --git a/src/duskdolphin/display/displayplatform.h b/src/duskdolphin/display/displayplatform.h new file mode 100644 index 0000000..f2d7268 --- /dev/null +++ b/src/duskdolphin/display/displayplatform.h @@ -0,0 +1,9 @@ +/** + * Copyright (c) 2026 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "display/displaysdl2.h" \ No newline at end of file diff --git a/src/dusklinux/CMakeLists.txt b/src/dusklinux/CMakeLists.txt index b3f0dba..6b8f187 100644 --- a/src/dusklinux/CMakeLists.txt +++ b/src/dusklinux/CMakeLists.txt @@ -3,5 +3,11 @@ # This software is released under the MIT License. # https://opensource.org/licenses/MIT +# Includes +target_include_directories(${DUSK_LIBRARY_TARGET_NAME} + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} +) + # Subdirs add_subdirectory(debug) \ No newline at end of file diff --git a/src/dusklinux/duskplatform.h b/src/dusklinux/duskplatform.h index 2b65475..223902d 100644 --- a/src/dusklinux/duskplatform.h +++ b/src/dusklinux/duskplatform.h @@ -6,3 +6,4 @@ */ #pragma once +#include "dusksdl2.h" \ No newline at end of file diff --git a/src/duskopengl/CMakeLists.txt b/src/duskopengl/CMakeLists.txt new file mode 100644 index 0000000..ea21ad6 --- /dev/null +++ b/src/duskopengl/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) 2026 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Includes +target_include_directories(${DUSK_LIBRARY_TARGET_NAME} + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} +) + +# Subdirs \ No newline at end of file diff --git a/src/duskopengl/duskopengl.h b/src/duskopengl/duskopengl.h new file mode 100644 index 0000000..127e1eb --- /dev/null +++ b/src/duskopengl/duskopengl.h @@ -0,0 +1,8 @@ +/** + * Copyright (c) 2026 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once \ No newline at end of file diff --git a/src/duskpsp/CMakeLists.txt b/src/duskpsp/CMakeLists.txt index e69de29..7407c40 100644 --- a/src/duskpsp/CMakeLists.txt +++ b/src/duskpsp/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright (c) 2026 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Includes +target_include_directories(${DUSK_LIBRARY_TARGET_NAME} + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} +) + +# Subdirs +add_subdirectory(debug) \ No newline at end of file diff --git a/src/duskpsp/debug/CMakeLists.txt b/src/duskpsp/debug/CMakeLists.txt new file mode 100644 index 0000000..192f9b7 --- /dev/null +++ b/src/duskpsp/debug/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) 2026 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Sources + +target_sources(${DUSK_LIBRARY_TARGET_NAME} + PUBLIC + debug.c +) \ No newline at end of file diff --git a/src/dusk/debug/platform/psp.c b/src/duskpsp/debug/debug.c similarity index 80% rename from src/dusk/debug/platform/psp.c rename to src/duskpsp/debug/debug.c index 6ee191d..ef19a85 100644 --- a/src/dusk/debug/platform/psp.c +++ b/src/duskpsp/debug/debug.c @@ -7,7 +7,7 @@ #include "psp.h" -void debugPrintPSP(const char_t *message, ...) { +void debugPrint(const char_t *message, ...) { FILE *file = fopen("ms0:/PSP/GAME/Dusk/debug.log", "a"); if(!file) return; @@ -16,4 +16,8 @@ void debugPrintPSP(const char_t *message, ...) { vfprintf(file, message, args); va_end(args); fclose(file); +} + +void debugFlush() { + fflush(stdout); } \ No newline at end of file diff --git a/src/dusksdl2/CMakeLists.txt b/src/dusksdl2/CMakeLists.txt new file mode 100644 index 0000000..ea21ad6 --- /dev/null +++ b/src/dusksdl2/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) 2026 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Includes +target_include_directories(${DUSK_LIBRARY_TARGET_NAME} + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} +) + +# Subdirs \ No newline at end of file diff --git a/src/dusksdl2/display/displaysdl2.h b/src/dusksdl2/display/displaysdl2.h new file mode 100644 index 0000000..bc53421 --- /dev/null +++ b/src/dusksdl2/display/displaysdl2.h @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2026 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "dusk.h" + +typedef struct { + SDL_Window *window; + SDL_GLContext glContext; + bool_t usingShaderedPalettes; +} displayplatform_t; \ No newline at end of file diff --git a/src/dusksdl2/dusksdl2.h b/src/dusksdl2/dusksdl2.h new file mode 100644 index 0000000..c92f39e --- /dev/null +++ b/src/dusksdl2/dusksdl2.h @@ -0,0 +1,9 @@ +/** + * Copyright (c) 2026 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "duskopengl.h" \ No newline at end of file