diff --git a/CMakeLists.txt b/CMakeLists.txt index da7896d..8f75eb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ execute_process( ) # Set Project -project(palladium LANGUAGES C CXX VERSION 0.2.2) +project(palladium LANGUAGES C CXX VERSION 0.2.3) option(PD_BUILD_TESTS "Sets if TestApp and TestBench get build" OFF) @@ -57,32 +57,31 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-psabi -O2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions") +## Core Source Code set(CORE_SRC source/core/common.cpp +source/core/bit_util.cpp +source/core/color.cpp source/core/io.cpp source/core/strings.cpp source/core/sys.cpp source/core/timer.cpp source/core/timetrace.cpp) -add_pd_lib(pd-core SRC_FILES ${CORE_SRC}) - -set(MATHS_SRC -source/maths/bit_util.cpp -source/maths/color.cpp -source/maths/img_blur.cpp -source/maths/img_convert.cpp) -add_pd_lib(pd-maths SRC_FILES ${MATHS_SRC} DEPENDS pd-core) +## Image Source Code +set(IMAGE_SRC +source/image/img_blur.cpp +source/image/img_convert.cpp) +## External Source Code set(EXTERNAL_SRC source/external/stb.cpp) -add_pd_lib(pd-external SRC_FILES ${EXTERNAL_SRC}) +## Drivers Source Code set(DRVS_SRC source/drivers/hid.cpp) -add_pd_lib(pd-drivers SRC_FILES ${DRVS_SRC} DEPENDS pd-maths) - +## Lib3ds Source Code set(L3DS_SRC source/lib3ds/gamepad_icons.cpp source/lib3ds/result_decoder.cpp @@ -90,8 +89,7 @@ source/lib3ds/drv_hid.cpp source/lib3ds/hwinfo.cpp source/lib3ds/os.cpp) -add_pd_lib(pd-lib3ds SRC_FILES ${L3DS_SRC} DEPENDS pd-drivers) - +## Lithium Source Code set(LI_SRC source/lithium/li7_shader.cpp source/lithium/spritesheet.cpp @@ -100,13 +98,11 @@ source/lithium/font.cpp source/lithium/objects.cpp source/lithium/renderer.cpp) -add_pd_lib(pd-lithium SRC_FILES ${LI_SRC} DEPENDS pd-maths pd-external citro3d) - +## Sounbd Source Code set(SOUND_SRC source/sound/mp3.cpp) -add_pd_lib(pd-sound SRC_FILES ${SOUND_SRC} DEPENDS pd-core mpg123) - +## Overlay source Code set(OVL_SRC source/overlays/keyboard.cpp source/overlays/message_mgr.cpp @@ -114,15 +110,13 @@ source/overlays/overlay_mgr.cpp source/overlays/performance.cpp source/overlays/settings.cpp) -add_pd_lib(pd-overlays SRC_FILES ${OVL_SRC} DEPENDS pd-lithium) - +## App Source Code set(APP_SRC source/app/app.cpp source/app/lang.cpp source/app/error.cpp) -add_pd_lib(pd-app SRC_FILES ${APP_SRC} DEPENDS pd-overlays pd-drivers pd-lib3ds) - +## UI7 Source Code set(UI7_SRC source/ui7/drawlist.cpp source/ui7/menu.cpp @@ -134,27 +128,37 @@ source/ui7/container/checkbox.cpp source/ui7/container/image.cpp source/ui7/container/label.cpp) +#### Creating the Libraries (if activated) #### +add_pd_lib(pd-core SRC_FILES ${CORE_SRC}) +add_pd_lib(pd-image SRC_FILES ${IMAGE_SRC} DEPENDS pd-core) +add_pd_lib(pd-external SRC_FILES ${EXTERNAL_SRC}) +add_pd_lib(pd-drivers SRC_FILES ${DRVS_SRC} DEPENDS pd-core) +add_pd_lib(pd-lib3ds SRC_FILES ${L3DS_SRC} DEPENDS pd-drivers) +add_pd_lib(pd-lithium SRC_FILES ${LI_SRC} DEPENDS pd-core pd-image pd-external citro3d) +add_pd_lib(pd-sound SRC_FILES ${SOUND_SRC} DEPENDS pd-core mpg123) +add_pd_lib(pd-overlays SRC_FILES ${OVL_SRC} DEPENDS pd-lithium) +add_pd_lib(pd-app SRC_FILES ${APP_SRC} DEPENDS pd-overlays pd-drivers pd-lib3ds) add_pd_lib(pd-ui7 SRC_FILES ${UI7_SRC} DEPENDS pd-drivers pd-lithium) add_library(palladium INTERFACE) target_link_libraries(palladium INTERFACE -pd-core pd-maths pd-external pd-drivers pd-lib3ds +pd-core pd-image pd-external pd-drivers pd-lib3ds pd-lithium pd-overlays pd-app pd-ui7 ) add_dependencies(palladium -pd-core pd-maths pd-external pd-drivers +pd-core pd-image pd-external pd-drivers pd-lib3ds pd-lithium pd-overlays pd-app pd-ui7 ) add_library(palladium-lite INTERFACE) target_link_libraries(palladium-lite INTERFACE -pd-core pd-maths pd-external pd-drivers pd-lib3ds +pd-core pd-image pd-external pd-drivers pd-lib3ds pd-lithium ) add_dependencies(palladium-lite -pd-core pd-maths pd-external pd-drivers +pd-core pd-image pd-external pd-drivers pd-lib3ds pd-lithium ) diff --git a/README.md b/README.md index f3c92fe..e49c876 100644 --- a/README.md +++ b/README.md @@ -27,17 +27,17 @@ make install | Name | Last Updated | Platform | Depends | |---|---|---|---| -| pd-core | 0.2.2 | multi | none | -| pd-maths | 0.2.0 | multi | pd-core | +| pd-core | 0.2.3 | multi | none | | pd-external | 0.1.0 | multi | none | -| pd-drivers | 0.2.1 | multi | pd-core, pd-maths | -| pd-lib3ds | 0.2.2 | 3ds | pd-core, pd-maths, pd-drivers | +| pd-image | 0.2.3 | multi | pd-core | +| pd-drivers | 0.2.1 | multi | pd-core | +| pd-lib3ds | 0.2.2 | 3ds | pd-core, pd-drivers | | pd-net | 0.2.2 | 3ds | pd-core, pd-lib3ds | -| pd-lithium | 0.2.1 | 3ds | pd-core, pd-maths pd-lib3ds, citro3d | +| pd-lithium | 0.2.1 | 3ds | pd-core, pd-image pd-lib3ds, citro3d | | pd-sound | 0.2.2 | 3ds | pd-core, mpg123 | -| pd-overlays | 0.2.1 | 3ds | pd-core, pd-maths, pd-lib3ds, pd-lithium, pd-ui7 | -| pd-ui7 | 0.2.2 | 3ds | pd-core, pd-maths, pd-lib3ds, pd-lithium | -| pd-app | 0.2.2 | 3ds | pd-core, pd-maths, pd-lib3ds, pd-lithium | +| pd-overlays | 0.2.1 | 3ds | pd-core, pd-image, pd-lib3ds, pd-lithium, pd-ui7 | +| pd-ui7 | 0.2.2 | 3ds | pd-core, pd-image, pd-lib3ds, pd-lithium | +| pd-app | 0.2.2 | 3ds | pd-core, pd-image, pd-lib3ds, pd-lithium | ## Credits | Icon | Username | Description | diff --git a/include/pd.hpp b/include/pd.hpp index 6b164d7..b7dd137 100644 --- a/include/pd.hpp +++ b/include/pd.hpp @@ -25,21 +25,21 @@ SOFTWARE. */ // Core +#include +#include #include #include #include #include #include #include +#include // Graphics #include #include -// Maths -#include -#include -#include -#include -#include +// Image +#include +#include // Drivers #include // Overlays diff --git a/include/pd/maths/bit_util.hpp b/include/pd/core/bit_util.hpp similarity index 100% rename from include/pd/maths/bit_util.hpp rename to include/pd/core/bit_util.hpp diff --git a/include/pd/maths/color.hpp b/include/pd/core/color.hpp similarity index 100% rename from include/pd/maths/color.hpp rename to include/pd/core/color.hpp diff --git a/include/pd/maths/tween.hpp b/include/pd/core/tween.hpp similarity index 99% rename from include/pd/maths/tween.hpp rename to include/pd/core/tween.hpp index 3f0e0b4..b58f395 100644 --- a/include/pd/maths/tween.hpp +++ b/include/pd/core/tween.hpp @@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include namespace PD { template diff --git a/include/pd/maths/vec.hpp b/include/pd/core/vec.hpp similarity index 100% rename from include/pd/maths/vec.hpp rename to include/pd/core/vec.hpp diff --git a/include/pd/drivers/hid.hpp b/include/pd/drivers/hid.hpp index 4d8a27a..503c42c 100644 --- a/include/pd/drivers/hid.hpp +++ b/include/pd/drivers/hid.hpp @@ -24,7 +24,7 @@ SOFTWARE. */ #include -#include +#include namespace PD { class Hid : public SmartCtor { diff --git a/include/pd/maths/img_blur.hpp b/include/pd/image/img_blur.hpp similarity index 82% rename from include/pd/maths/img_blur.hpp rename to include/pd/image/img_blur.hpp index 0290286..7e6cb86 100644 --- a/include/pd/maths/img_blur.hpp +++ b/include/pd/image/img_blur.hpp @@ -25,8 +25,7 @@ SOFTWARE. */ #include -#include -#include +#include namespace PD { namespace ImgBlur { @@ -38,8 +37,11 @@ std::vector GaussianKernel(int radius, float si); /// @param radius // Blur radius /// @param si // Blur sigma /// @param idxfn // Indexing function (if buffer is 3ds tiled) -void GaussianBlur(std::vector &buf, int w, int h, float radius, float si, - std::function idxfn = Img::IndexDefault); +void GaussianBlur( + std::vector &buf, int w, int h, float radius, float si, + std::function idxfn = [](int x, int y, int w) -> int { + return y * w + x; + }); /// @brief Advanced func to access memory directly /// @param buf Referenvce to the buffer /// @param w // width of the image @@ -48,7 +50,10 @@ void GaussianBlur(std::vector &buf, int w, int h, float radius, float si, /// @param radius // Blur radius /// @param si // Blur sigma /// @param idxfn // Indexing function (if buffer is 3ds tiled) -void GaussianBlur(void *buf, int w, int h, int bpp, float radius, float si, - std::function idxfn = Img::IndexDefault); +void GaussianBlur( + void *buf, int w, int h, int bpp, float radius, float si, + std::function idxfn = [](int x, int y, int w) -> int { + return y * w + x; + }); } // namespace ImgBlur } // namespace PD \ No newline at end of file diff --git a/include/pd/maths/img_convert.hpp b/include/pd/image/img_convert.hpp similarity index 100% rename from include/pd/maths/img_convert.hpp rename to include/pd/image/img_convert.hpp diff --git a/include/pd/lithium/command.hpp b/include/pd/lithium/command.hpp index 731fc07..efdd119 100644 --- a/include/pd/lithium/command.hpp +++ b/include/pd/lithium/command.hpp @@ -28,7 +28,7 @@ SOFTWARE. #include #include #include -#include +#include namespace PD { namespace LI { diff --git a/include/pd/lithium/font.hpp b/include/pd/lithium/font.hpp index 23dbf6a..e0022e0 100644 --- a/include/pd/lithium/font.hpp +++ b/include/pd/lithium/font.hpp @@ -27,7 +27,7 @@ SOFTWARE. #include #include #include -#include +#include namespace PD { namespace LI { diff --git a/include/pd/lithium/objects.hpp b/include/pd/lithium/objects.hpp index 4f80cc0..5541d90 100644 --- a/include/pd/lithium/objects.hpp +++ b/include/pd/lithium/objects.hpp @@ -30,7 +30,7 @@ SOFTWARE. #include #include #include -#include +#include namespace PD { namespace LI { diff --git a/include/pd/lithium/rect.hpp b/include/pd/lithium/rect.hpp index c13a386..eae995a 100644 --- a/include/pd/lithium/rect.hpp +++ b/include/pd/lithium/rect.hpp @@ -24,7 +24,7 @@ SOFTWARE. */ #include -#include +#include namespace PD { namespace LI { diff --git a/include/pd/lithium/renderer.hpp b/include/pd/lithium/renderer.hpp index 7e3e2a0..04b04e1 100644 --- a/include/pd/lithium/renderer.hpp +++ b/include/pd/lithium/renderer.hpp @@ -33,7 +33,7 @@ SOFTWARE. #include #include #include -#include +#include namespace PD { namespace LI { diff --git a/include/pd/lithium/screen.hpp b/include/pd/lithium/screen.hpp index e4469dd..53a6f8f 100644 --- a/include/pd/lithium/screen.hpp +++ b/include/pd/lithium/screen.hpp @@ -27,7 +27,7 @@ SOFTWARE. #include #include -#include +#include namespace PD { class Screen : public SmartCtor { diff --git a/include/pd/lithium/texture.hpp b/include/pd/lithium/texture.hpp index 0358208..d8b983b 100644 --- a/include/pd/lithium/texture.hpp +++ b/include/pd/lithium/texture.hpp @@ -28,7 +28,7 @@ SOFTWARE. #include #include -#include +#include namespace PD { class Texture : public SmartCtor { diff --git a/include/pd/lithium/vertex.hpp b/include/pd/lithium/vertex.hpp index a68a63c..c4f7ea1 100644 --- a/include/pd/lithium/vertex.hpp +++ b/include/pd/lithium/vertex.hpp @@ -25,7 +25,7 @@ SOFTWARE. */ #include -#include +#include namespace PD { namespace LI { diff --git a/include/pd/maths/img.hpp b/include/pd/maths/img.hpp deleted file mode 100644 index 46595d2..0000000 --- a/include/pd/maths/img.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -/* -MIT License - -Copyright (c) 2024 - 2025 tobid7 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - */ - -#include -#include - -namespace PD { -namespace Img { -inline int Index3dsTex(int x, int y, int width) { - return ((((y >> 3) * (width >> 3) + (x >> 3)) << 6) + - ((x & 1) | ((y & 1) << 1) | ((x & 2) << 1) | ((y & 2) << 2) | - ((x & 4) << 2) | ((y & 4) << 3))); -} -inline int IndexDefault(int x, int y, int width) { return y * width + x; } -} // namespace Img -} // namespace PD \ No newline at end of file diff --git a/include/pd/overlays/keyboard.hpp b/include/pd/overlays/keyboard.hpp index a84c687..d0569d6 100644 --- a/include/pd/overlays/keyboard.hpp +++ b/include/pd/overlays/keyboard.hpp @@ -24,7 +24,7 @@ SOFTWARE. */ #include -#include +#include #include namespace PD { diff --git a/include/pd/overlays/message_mgr.hpp b/include/pd/overlays/message_mgr.hpp index 207fe23..dd4e4b2 100644 --- a/include/pd/overlays/message_mgr.hpp +++ b/include/pd/overlays/message_mgr.hpp @@ -24,8 +24,8 @@ SOFTWARE. */ #include -#include -#include +#include +#include namespace PD { class MessageMgr : public PD::SmartCtor { diff --git a/include/pd/overlays/settings.hpp b/include/pd/overlays/settings.hpp index 5a0b97e..ad54ada 100644 --- a/include/pd/overlays/settings.hpp +++ b/include/pd/overlays/settings.hpp @@ -24,7 +24,7 @@ SOFTWARE. */ #include -#include +#include #include #include diff --git a/include/pd/ui7/container/container.hpp b/include/pd/ui7/container/container.hpp index af673b7..4ffb958 100644 --- a/include/pd/ui7/container/container.hpp +++ b/include/pd/ui7/container/container.hpp @@ -26,7 +26,7 @@ SOFTWARE. #include #include #include -#include +#include #include namespace PD { diff --git a/include/pd/ui7/menu.hpp b/include/pd/ui7/menu.hpp index d88214e..2ba24ac 100644 --- a/include/pd/ui7/menu.hpp +++ b/include/pd/ui7/menu.hpp @@ -24,7 +24,7 @@ SOFTWARE. */ #include -#include +#include #include #include #include diff --git a/source/maths/bit_util.cpp b/source/core/bit_util.cpp similarity index 97% rename from source/maths/bit_util.cpp rename to source/core/bit_util.cpp index ef71fa7..c05e418 100644 --- a/source/maths/bit_util.cpp +++ b/source/core/bit_util.cpp @@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include namespace PD::BitUtil { bool IsSingleBit(u32 v) { return v && !(v & (v - 1)); } diff --git a/source/maths/color.cpp b/source/core/color.cpp similarity index 98% rename from source/maths/color.cpp rename to source/core/color.cpp index a9a7e20..f742220 100644 --- a/source/maths/color.cpp +++ b/source/core/color.cpp @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include namespace PD { // The Solution of the biggest performance issue diff --git a/source/maths/img_blur.cpp b/source/image/img_blur.cpp similarity index 97% rename from source/maths/img_blur.cpp rename to source/image/img_blur.cpp index 33cf2da..750328b 100644 --- a/source/maths/img_blur.cpp +++ b/source/image/img_blur.cpp @@ -24,8 +24,8 @@ SOFTWARE. #include #include -#include -#include +#include +#include namespace PD { namespace ImgBlur { diff --git a/source/maths/img_convert.cpp b/source/image/img_convert.cpp similarity index 94% rename from source/maths/img_convert.cpp rename to source/image/img_convert.cpp index 5357d59..50b3879 100644 --- a/source/maths/img_convert.cpp +++ b/source/image/img_convert.cpp @@ -21,8 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include -#include +#include namespace PD::ImgConvert { void RGB24toRGBA32(std::vector &out, const std::vector &in, @@ -42,7 +41,7 @@ void RGB24toRGBA32(std::vector &out, const std::vector &in, void Reverse32(std::vector &buf, const int &w, const int &h) { for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { - int i = Img::IndexDefault(x, y, w); + int i = y * w + x; u8 t0 = buf[i + 0]; u8 t1 = buf[i + 1]; buf[i + 0] = buf[i + 3]; diff --git a/source/lithium/texture.cpp b/source/lithium/texture.cpp index a7bb01d..30f7771 100644 --- a/source/lithium/texture.cpp +++ b/source/lithium/texture.cpp @@ -30,8 +30,8 @@ SOFTWARE. #include #include #include -#include -#include +#include +#include namespace PD { GPU_TEXCOLOR GetTexFmt(Texture::Type type) { diff --git a/source/overlays/keyboard.cpp b/source/overlays/keyboard.cpp index 5d3f8db..1e82dc3 100644 --- a/source/overlays/keyboard.cpp +++ b/source/overlays/keyboard.cpp @@ -22,7 +22,7 @@ SOFTWARE. */ #include -#include +#include #include #include diff --git a/source/ui7/theme.cpp b/source/ui7/theme.cpp index 33b10e0..4156277 100644 --- a/source/ui7/theme.cpp +++ b/source/ui7/theme.cpp @@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include #include namespace PD { diff --git a/test/app/main.cpp b/test/app/main.cpp index 2fa6285..671e195 100644 --- a/test/app/main.cpp +++ b/test/app/main.cpp @@ -25,7 +25,6 @@ SOFTWARE. #include #include -#include class Test : public PD::App { public: