From f5270df0193e91e000d2795ed319d3f89c3b1390 Mon Sep 17 00:00:00 2001 From: Jaby Date: Sun, 7 Apr 2024 10:46:35 -0500 Subject: [PATCH] Update C headers to be C++ --- .../src/Overlay/BIOSInfo/bios_info.cpp | 3 +- .../ControllerTest/controller_test.cpp | 1 - .../src/Overlay/FontCycler/font_cycler.cpp | 1 - .../src/Overlay/GPUTest/gpu_test.cpp | 1 - .../src/Overlay/GTETest/gte_test.cpp | 1 - .../Overlay/ScreenCenter/screen_center.cpp | 1 - .../PoolBox/application/src/application.cpp | 2 +- .../PoolBox/application/src/asset_mgr.cpp | 2 +- include/PSX/Auxiliary/array_range.hpp | 2 +- include/PSX/Auxiliary/bits.hpp | 2 +- include/PSX/Auxiliary/literals.hpp | 2 +- include/PSX/Auxiliary/lz4_decompressor.hpp | 2 +- include/PSX/Auxiliary/math_helper.hpp | 2 +- include/PSX/Auxiliary/unaligned_read.hpp | 2 +- include/PSX/File/file_types.hpp | 2 +- include/PSX/GPU/gpu_types.hpp | 2 +- include/PSX/Periphery/raw_controller.hpp | 2 +- include/PSX/System/IOPorts/gpu_io.hpp | 1 - include/PSX/System/syscalls.hpp | 2 +- include/PSX/Timer/frame_time_helper.hpp | 2 +- include/PSX/Timer/frame_timer.hpp | 2 +- include/PSX/Timer/high_res_timer.hpp | 2 +- include/PSX/jabyengine.hpp | 2 +- ...ngine_defines.h => jabyengine_defines.hpp} | 8 ++-- include/limits.h | 36 --------------- include/limits.hpp | 33 ++++++++++++++ include/math.hpp | 9 ++-- include/stdarg.h | 10 ----- include/stdarg.hpp | 7 +++ include/stddef.h | 7 --- include/stddef.hpp | 4 ++ include/stdint.h | 37 ---------------- include/stdint.hpp | 34 ++++++++++++++ include/stdio.h | 8 ---- include/stdio.hpp | 4 ++ include/string.h | 10 ----- include/string.hpp | 5 +++ .../BootLoader/color_debug.hpp | 2 +- src/Library/internal-include/CD/cd_types.hpp | 2 +- .../internal-include/periphery_internal.hpp | 2 +- src/Library/reference/about_inline_n.md | 39 ++-------------- src/Library/src/BootLoader/dma_boot.cpp | 1 - src/Library/src/BootLoader/gpu_boot.cpp | 2 +- src/Library/src/BootLoader/periphery_boot.cpp | 1 - src/Library/src/BootLoader/spu_boot.cpp | 3 +- src/Library/src/BootLoader/start_boot.cpp | 2 +- src/Library/src/BootLoader/syscall_boot.cpp | 2 +- .../src/File/Processor/cd_file_processor.cpp | 2 +- .../src/File/Processor/tim_processor.cpp | 4 +- src/Library/src/GTE/gte.cpp | 8 ++-- src/Library/src/Periphery/periphery.cpp | 1 - src/Library/src/System/string.cpp | 44 +++++++++---------- src/Library/src/System/syscall.cpp | 1 - src/Library/src/run.cpp | 2 +- src/Tools/cpp_out/src/lib.rs | 2 +- support/include/FontWriter/font_writer.hpp | 2 +- support/src/FontWriter/src/default_font.cpp | 2 +- support/src/FontWriter/src/font_writer.cpp | 1 - 58 files changed, 153 insertions(+), 225 deletions(-) rename include/PSX/{jabyengine_defines.h => jabyengine_defines.hpp} (79%) delete mode 100644 include/limits.h create mode 100644 include/limits.hpp delete mode 100644 include/stdarg.h create mode 100644 include/stdarg.hpp delete mode 100644 include/stddef.h create mode 100644 include/stddef.hpp delete mode 100644 include/stdint.h create mode 100644 include/stdint.hpp delete mode 100644 include/stdio.h create mode 100644 include/stdio.hpp delete mode 100644 include/string.h create mode 100644 include/string.hpp diff --git a/examples/PoolBox/application/src/Overlay/BIOSInfo/bios_info.cpp b/examples/PoolBox/application/src/Overlay/BIOSInfo/bios_info.cpp index 23d1f516..55454f43 100644 --- a/examples/PoolBox/application/src/Overlay/BIOSInfo/bios_info.cpp +++ b/examples/PoolBox/application/src/Overlay/BIOSInfo/bios_info.cpp @@ -5,8 +5,7 @@ #include #include #include -#include -#include +#include namespace BIOSInfo { using namespace JabyEngine; diff --git a/examples/PoolBox/application/src/Overlay/ControllerTest/controller_test.cpp b/examples/PoolBox/application/src/Overlay/ControllerTest/controller_test.cpp index 7f8a4a13..2457c201 100644 --- a/examples/PoolBox/application/src/Overlay/ControllerTest/controller_test.cpp +++ b/examples/PoolBox/application/src/Overlay/ControllerTest/controller_test.cpp @@ -1,7 +1,6 @@ #include "../../../include/shared.hpp" #include "include/controller_state.hpp" #include -#include namespace ControllerTest { using namespace JabyEngine; diff --git a/examples/PoolBox/application/src/Overlay/FontCycler/font_cycler.cpp b/examples/PoolBox/application/src/Overlay/FontCycler/font_cycler.cpp index 91a9c28b..c5cc71e1 100644 --- a/examples/PoolBox/application/src/Overlay/FontCycler/font_cycler.cpp +++ b/examples/PoolBox/application/src/Overlay/FontCycler/font_cycler.cpp @@ -1,7 +1,6 @@ #include "../../../include/shared.hpp" #include #include -#include namespace FontCycler { using namespace JabyEngine; diff --git a/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp b/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp index 9851670b..122d0509 100644 --- a/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp +++ b/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp @@ -3,7 +3,6 @@ #include #include #include -#include namespace GPUTest { using namespace JabyEngine; diff --git a/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp b/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp index db9c39cb..8c19aa8a 100644 --- a/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp +++ b/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp @@ -3,7 +3,6 @@ #include "include/GTE_Sprite.hpp" #include "include/gte_test_assets.hpp" #include -#include namespace GTETest { using namespace JabyEngine; diff --git a/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp b/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp index cdfafcfc..186a58d0 100644 --- a/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp +++ b/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp @@ -4,7 +4,6 @@ #include #include #include -#include namespace ScreenCenter { using namespace JabyEngine; diff --git a/examples/PoolBox/application/src/application.cpp b/examples/PoolBox/application/src/application.cpp index f076067c..88a3f630 100644 --- a/examples/PoolBox/application/src/application.cpp +++ b/examples/PoolBox/application/src/application.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include using namespace JabyEngine; diff --git a/examples/PoolBox/application/src/asset_mgr.cpp b/examples/PoolBox/application/src/asset_mgr.cpp index 20251ef3..489ee14e 100644 --- a/examples/PoolBox/application/src/asset_mgr.cpp +++ b/examples/PoolBox/application/src/asset_mgr.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include extern "C" uint32_t __bios_info_start; extern "C" uint32_t __controller_tests_start; diff --git a/include/PSX/Auxiliary/array_range.hpp b/include/PSX/Auxiliary/array_range.hpp index a03d78ac..b473bd2e 100644 --- a/include/PSX/Auxiliary/array_range.hpp +++ b/include/PSX/Auxiliary/array_range.hpp @@ -1,5 +1,5 @@ #pragma once -#include "../../stddef.h" +#include "../../stddef.hpp" namespace JabyEngine { template diff --git a/include/PSX/Auxiliary/bits.hpp b/include/PSX/Auxiliary/bits.hpp index 370764ca..9f8bce3f 100644 --- a/include/PSX/Auxiliary/bits.hpp +++ b/include/PSX/Auxiliary/bits.hpp @@ -1,5 +1,5 @@ #pragma once -#include "../jabyengine_defines.h" +#include "../jabyengine_defines.hpp" #include "types.hpp" namespace JabyEngine { diff --git a/include/PSX/Auxiliary/literals.hpp b/include/PSX/Auxiliary/literals.hpp index 8d0d5fed..0bd57ce1 100644 --- a/include/PSX/Auxiliary/literals.hpp +++ b/include/PSX/Auxiliary/literals.hpp @@ -1,5 +1,5 @@ #pragma once -#include "../../stdint.h" +#include "../../stdint.hpp" namespace JabyEngine { static constexpr int8_t operator""_i8(unsigned long long int value) { diff --git a/include/PSX/Auxiliary/lz4_decompressor.hpp b/include/PSX/Auxiliary/lz4_decompressor.hpp index 39fc105d..cf235949 100644 --- a/include/PSX/Auxiliary/lz4_decompressor.hpp +++ b/include/PSX/Auxiliary/lz4_decompressor.hpp @@ -1,5 +1,5 @@ #pragma once -#include "../../stddef.h" +#include "../../stddef.hpp" #include "array_range.hpp" #include "types.hpp" diff --git a/include/PSX/Auxiliary/math_helper.hpp b/include/PSX/Auxiliary/math_helper.hpp index 68d10098..1ef021b0 100644 --- a/include/PSX/Auxiliary/math_helper.hpp +++ b/include/PSX/Auxiliary/math_helper.hpp @@ -1,6 +1,6 @@ #pragma once #include "types.hpp" -#include +#include namespace JabyEngine { template diff --git a/include/PSX/Auxiliary/unaligned_read.hpp b/include/PSX/Auxiliary/unaligned_read.hpp index 3ba88198..4e40f354 100644 --- a/include/PSX/Auxiliary/unaligned_read.hpp +++ b/include/PSX/Auxiliary/unaligned_read.hpp @@ -1,5 +1,5 @@ #pragma once -#include "../../stdint.h" +#include "../../stdint.hpp" namespace JabyEngine { uint16_t unaligned_lhu(const uint8_t* adr) { diff --git a/include/PSX/File/file_types.hpp b/include/PSX/File/file_types.hpp index 5b4a7ff2..bfdec4ba 100644 --- a/include/PSX/File/file_types.hpp +++ b/include/PSX/File/file_types.hpp @@ -1,7 +1,7 @@ #pragma once #include "../Auxiliary/bits.hpp" #include "../GPU/gpu_types.hpp" -#include "../jabyengine_defines.h" +#include "../jabyengine_defines.hpp" namespace JabyEngine { #pragma pack(push, 1) diff --git a/include/PSX/GPU/gpu_types.hpp b/include/PSX/GPU/gpu_types.hpp index 4017d67b..48c89700 100644 --- a/include/PSX/GPU/gpu_types.hpp +++ b/include/PSX/GPU/gpu_types.hpp @@ -1,6 +1,6 @@ #pragma once #include "../Auxiliary/bits.hpp" -#include "../jabyengine_defines.h" +#include "../jabyengine_defines.hpp" namespace JabyEngine { namespace GPU { diff --git a/include/PSX/Periphery/raw_controller.hpp b/include/PSX/Periphery/raw_controller.hpp index b5bcb270..3d675aee 100644 --- a/include/PSX/Periphery/raw_controller.hpp +++ b/include/PSX/Periphery/raw_controller.hpp @@ -1,5 +1,5 @@ #pragma once -#include "../jabyengine_defines.h" +#include "../jabyengine_defines.hpp" namespace JabyEngine { namespace Periphery { diff --git a/include/PSX/System/IOPorts/gpu_io.hpp b/include/PSX/System/IOPorts/gpu_io.hpp index bd3840b6..21e588a3 100644 --- a/include/PSX/System/IOPorts/gpu_io.hpp +++ b/include/PSX/System/IOPorts/gpu_io.hpp @@ -1,7 +1,6 @@ #pragma once #include "ioport.hpp" #include "../../GPU/gpu_types.hpp" -#include namespace JabyEngine { namespace GPU_IO { diff --git a/include/PSX/System/syscalls.hpp b/include/PSX/System/syscalls.hpp index 28ba8aa5..df0694a5 100644 --- a/include/PSX/System/syscalls.hpp +++ b/include/PSX/System/syscalls.hpp @@ -1,5 +1,5 @@ #pragma once -#include "../jabyengine_defines.h" +#include "../jabyengine_defines.hpp" /* R0 zr Constant Zero diff --git a/include/PSX/Timer/frame_time_helper.hpp b/include/PSX/Timer/frame_time_helper.hpp index d6c32913..e1de8ada 100644 --- a/include/PSX/Timer/frame_time_helper.hpp +++ b/include/PSX/Timer/frame_time_helper.hpp @@ -1,7 +1,7 @@ #ifndef __JABYENGINE_FRAME_TIME_HELPER_HPP__ #define __JABYENGINE_FRAME_TIME_HELPER_HPP__ #include -#include +#include namespace JabyEngine { static constexpr double ms_per_frame = 1000.0/static_cast(GPU::Display::frames_per_sec); diff --git a/include/PSX/Timer/frame_timer.hpp b/include/PSX/Timer/frame_timer.hpp index 45f2e6dd..47888d9a 100644 --- a/include/PSX/Timer/frame_timer.hpp +++ b/include/PSX/Timer/frame_timer.hpp @@ -1,7 +1,7 @@ #ifndef __JABYENGINE_FRAME_TIMER_HPP__ #define __JABYENGINE_FRAME_TIMER_HPP__ #include "frame_time_helper.hpp" -#include +#include namespace JabyEngine { class MasterTime { diff --git a/include/PSX/Timer/high_res_timer.hpp b/include/PSX/Timer/high_res_timer.hpp index d3aa88be..c3e1626e 100644 --- a/include/PSX/Timer/high_res_timer.hpp +++ b/include/PSX/Timer/high_res_timer.hpp @@ -1,6 +1,6 @@ #ifndef __JABYENGINE_HIGH_RES_TIMER_HPP__ #define __JABYENGINE_HIGH_RES_TIMER_HPP__ -#include "../jabyengine_defines.h" +#include "../jabyengine_defines.hpp" #include #include diff --git a/include/PSX/jabyengine.hpp b/include/PSX/jabyengine.hpp index e2b853c1..e3fc483f 100644 --- a/include/PSX/jabyengine.hpp +++ b/include/PSX/jabyengine.hpp @@ -1,5 +1,5 @@ #pragma once -#include "jabyengine_defines.h" +#include "jabyengine_defines.hpp" namespace JabyEngine { typedef void (*MainRoutine)(); diff --git a/include/PSX/jabyengine_defines.h b/include/PSX/jabyengine_defines.hpp similarity index 79% rename from include/PSX/jabyengine_defines.h rename to include/PSX/jabyengine_defines.hpp index fc616984..435b250e 100644 --- a/include/PSX/jabyengine_defines.h +++ b/include/PSX/jabyengine_defines.hpp @@ -1,6 +1,5 @@ -#ifndef __JABYENGINE_DEFINES__H__ -#define __JABYENGINE_DEFINES__H__ -#include "../stddef.h" +#pragma once +#include "../stddef.hpp" #define __used __attribute__((used)) #define __no_align __attribute__((packed)) @@ -22,5 +21,4 @@ #define __constexpr #define START_C_FUNCTIONS #define END_C_FUNCTIONS -#endif -#endif //!__JABYENGINE_DEFINES__H__ \ No newline at end of file +#endif \ No newline at end of file diff --git a/include/limits.h b/include/limits.h deleted file mode 100644 index 49077b0f..00000000 --- a/include/limits.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __LIMITS__H -#define __LIMITS__H - -#define CHAR_BIT 8 -#define SCHAR_MIN (-128) -#define SCHAR_MAX 127 -#define UCHAR_MAX 0xff - -#define CHAR_MIN SCHAR_MIN -#define CHAR_MAX SCHAR_MAX - -#define SHRT_MIN (-32768) -#define SHRT_MAX 32767 -#define USHRT_MAX 0xffff - -#define INT_MIN (-2147483647 - 1) -#define INT_MAX 2147483647 -#define UINT_MAX 0xffffffff - -#define LONG_MIN INT_MIN -#define LONG_MAX INT_MAX -#define ULONG_MAX UINT_MAX - -#define I8_MIN SCHAR_MIN -#define I8_MAX SCHAR_MAX -#define UI8_MAX UCHAR_MAX - -#define I16_MIN SHRT_MIN -#define I16_MAX SHRT_MAX -#define UI16_MAX USHRT_MAX - -#define I32_MIN INT_MIN -#define I32_MAX INT_MAX -#define UI32_MAX UINT_MAX - -#endif //!__LIMITS__H \ No newline at end of file diff --git a/include/limits.hpp b/include/limits.hpp new file mode 100644 index 00000000..c64ed7a0 --- /dev/null +++ b/include/limits.hpp @@ -0,0 +1,33 @@ +#pragma once + +static constexpr auto CHAR_BIT = 8; +static constexpr auto SCHAR_MIN = -128; +static constexpr auto SCHAR_MAX = 127; +static constexpr auto UCHAR_MAX = 0xff; + +static constexpr auto CHAR_MIN = SCHAR_MIN; +static constexpr auto CHAR_MAX = SCHAR_MAX; + +static constexpr auto SHRT_MIN = -32768; +static constexpr auto SHRT_MAX = 32767; +static constexpr auto USHRT_MAX = 0xffff; + +static constexpr auto INT_MIN = -2147483647 - 1; +static constexpr auto INT_MAX = 2147483647; +static constexpr auto UINT_MAX = 0xffffffff; + +static constexpr auto LONG_MIN = INT_MIN; +static constexpr auto LONG_MAX = INT_MAX; +static constexpr auto ULONG_MAX = UINT_MAX; + +static constexpr auto I8_MIN = SCHAR_MIN; +static constexpr auto I8_MAX = SCHAR_MAX; +static constexpr auto UI8_MAX = UCHAR_MAX; + +static constexpr auto I16_MIN = SHRT_MIN; +static constexpr auto I16_MAX = SHRT_MAX; +static constexpr auto UI16_MAX = USHRT_MAX; + +static constexpr auto I32_MIN = INT_MIN; +static constexpr auto I32_MAX = INT_MAX; +static constexpr auto UI32_MAX = UINT_MAX; \ No newline at end of file diff --git a/include/math.hpp b/include/math.hpp index 5d187cc4..a48aa03e 100644 --- a/include/math.hpp +++ b/include/math.hpp @@ -1,5 +1,5 @@ #pragma once -#include "stdint.h" +#include "stdint.hpp" namespace math { template @@ -74,8 +74,5 @@ static constexpr gte_float operator""_gf(long double value) { return gte_float::from_double(value); } -using sin_t = int32_t; -using cos_t = int32_t; - -sin_t sin(deg_t value); -cos_t cos(deg_t value); \ No newline at end of file +gte_float sin(deg_t value); +gte_float cos(deg_t value); \ No newline at end of file diff --git a/include/stdarg.h b/include/stdarg.h deleted file mode 100644 index 8714b050..00000000 --- a/include/stdarg.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __STDARG__H -#define __STDARG__H - -typedef __builtin_va_list va_list; -#define va_start __builtin_va_start -#define va_end __builtin_va_end -#define next_arg __builtin_next_arg -#define va_arg __builtin_va_arg - -#endif // !__STDARG__H \ No newline at end of file diff --git a/include/stdarg.hpp b/include/stdarg.hpp new file mode 100644 index 00000000..d4c85692 --- /dev/null +++ b/include/stdarg.hpp @@ -0,0 +1,7 @@ +#pragma once + +using va_list = __builtin_va_list; +#define va_start __builtin_va_start +#define va_end __builtin_va_end +#define next_arg __builtin_next_arg +#define va_arg __builtin_va_arg \ No newline at end of file diff --git a/include/stddef.h b/include/stddef.h deleted file mode 100644 index ffb37baf..00000000 --- a/include/stddef.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __STDDEF__H -#define __STDDEF__H -#include "stdint.h" - -typedef uintmax_t size_t; - -#endif //!__STDDEF__H \ No newline at end of file diff --git a/include/stddef.hpp b/include/stddef.hpp new file mode 100644 index 00000000..921680bd --- /dev/null +++ b/include/stddef.hpp @@ -0,0 +1,4 @@ +#pragma once +#include "stdint.hpp" + +using size_t = uintmax_t; \ No newline at end of file diff --git a/include/stdint.h b/include/stdint.h deleted file mode 100644 index f27f36cc..00000000 --- a/include/stdint.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef __STDINT__H -#define __STDINT__H - -typedef signed char int8_t; -typedef unsigned char uint8_t; - -typedef short int16_t; -typedef unsigned short uint16_t; - -typedef int int32_t; -typedef unsigned int uint32_t; - -typedef signed char int_least8_t; -typedef unsigned char uint_least8_t; - -typedef short int_least16_t; -typedef unsigned short uint_least16_t; - -typedef int int_least32_t; -typedef unsigned int uint_least32_t; - -typedef signed char int_fast8_t; -typedef unsigned char uint_fast8_t; - -typedef int int_fast16_t; -typedef unsigned int uint_fast16_t; - -typedef int int_fast32_t; -typedef unsigned int uint_fast32_t; - -typedef signed int intmax_t; -typedef unsigned int uintmax_t; - -typedef signed long intptr_t; -typedef unsigned long uintptr_t; - -#endif //!__STDINT__H \ No newline at end of file diff --git a/include/stdint.hpp b/include/stdint.hpp new file mode 100644 index 00000000..07a7e574 --- /dev/null +++ b/include/stdint.hpp @@ -0,0 +1,34 @@ +#pragma once + +using int8_t = signed char; +using uint8_t = unsigned char; + +using int16_t = short; +using uint16_t = unsigned short; + +using int32_t = int; +using uint32_t = unsigned int; + +using int_least8_t = signed char; +using uint_least8_t = unsigned char; + +using int_least16_t = short; +using uint_least16_t = unsigned short; + +using int_least32_t = int; +using uint_least32_t = unsigned int; + +using int_fast8_t = signed char; +using uint_fast8_t = unsigned char; + +using int_fast16_t = int; +using uint_fast16_t = unsigned int; + +using int_fast32_t = int; +using uint_fast32_t = unsigned int; + +using intmax_t = signed int; +using uintmax_t = unsigned int; + +using intptr_t = signed long; +using uintptr_t = unsigned long; \ No newline at end of file diff --git a/include/stdio.h b/include/stdio.h deleted file mode 100644 index 621daccb..00000000 --- a/include/stdio.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __STDIO__H -#define __STDIO__H -#include "PSX/jabyengine_defines.h" - -START_C_FUNCTIONS - int printf(const char* txt, ...) asm("_ZN10JabyEngine7SysCall6printfEPKcz"); -END_C_FUNCTIONS -#endif //!__STDIO__H \ No newline at end of file diff --git a/include/stdio.hpp b/include/stdio.hpp new file mode 100644 index 00000000..79fcaf81 --- /dev/null +++ b/include/stdio.hpp @@ -0,0 +1,4 @@ +#pragma once +#include "PSX/jabyengine_defines.hpp" + +int printf(const char* txt, ...) asm("_ZN10JabyEngine7SysCall6printfEPKcz"); \ No newline at end of file diff --git a/include/string.h b/include/string.h deleted file mode 100644 index a532c14c..00000000 --- a/include/string.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __STRING__H -#define __STRING__H -#include "PSX/jabyengine_defines.h" - -START_C_FUNCTIONS - int strncmp(const char* s1, const char* s2, size_t n); - size_t strlen(const char* str); -END_C_FUNCTIONS - -#endif // !__STRING__H \ No newline at end of file diff --git a/include/string.hpp b/include/string.hpp new file mode 100644 index 00000000..cbc601c6 --- /dev/null +++ b/include/string.hpp @@ -0,0 +1,5 @@ +#pragma once +#include "PSX/jabyengine_defines.hpp" + +int strncmp(const char* s1, const char* s2, size_t n); +size_t strlen(const char* str); \ No newline at end of file diff --git a/src/Library/internal-include/BootLoader/color_debug.hpp b/src/Library/internal-include/BootLoader/color_debug.hpp index 1c3f780f..56b35b49 100644 --- a/src/Library/internal-include/BootLoader/color_debug.hpp +++ b/src/Library/internal-include/BootLoader/color_debug.hpp @@ -1,6 +1,6 @@ #pragma once #include "../GPU/gpu_internal.hpp" -#include +#include namespace JabyEngine { static void render_num(uint8_t value, uint16_t x, uint16_t y) { diff --git a/src/Library/internal-include/CD/cd_types.hpp b/src/Library/internal-include/CD/cd_types.hpp index ac5b9e23..f88fbc96 100644 --- a/src/Library/internal-include/CD/cd_types.hpp +++ b/src/Library/internal-include/CD/cd_types.hpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include namespace JabyEngine { namespace CD { diff --git a/src/Library/internal-include/periphery_internal.hpp b/src/Library/internal-include/periphery_internal.hpp index 601bad55..0138dcdf 100644 --- a/src/Library/internal-include/periphery_internal.hpp +++ b/src/Library/internal-include/periphery_internal.hpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include extern "C" void busy_loop(int count); diff --git a/src/Library/reference/about_inline_n.md b/src/Library/reference/about_inline_n.md index 87206878..0b858063 100644 --- a/src/Library/reference/about_inline_n.md +++ b/src/Library/reference/about_inline_n.md @@ -1,39 +1,8 @@ # inline_n.h - This header is directly lifted from psx-redux and not my creation. I will try to give it my personal touch but the original implementation will be always from [pcsx-redux](https://github.com/grumpycoders/pcsx-redux) and the **grumpycoders**. -```c++ -MATRIX *HiRotMatrix(VECTOR *r, MATRIX *m) { +# GTEMAC.H +Great for reference! It is under `psyq\include\GTEMAC.H` - short s[3],c[3]; - MATRIX tm[3]; - - s[0] = hisin(r->vx); s[1] = hisin(r->vy); s[2] = hisin(r->vz); - c[0] = hicos(r->vx); c[1] = hicos(r->vy); c[2] = hicos(r->vz); - - // mX - m->m[0][0] = ONE; m->m[0][1] = 0; m->m[0][2] = 0; - m->m[1][0] = 0; m->m[1][1] = c[0]; m->m[1][2] = -s[0]; - m->m[2][0] = 0; m->m[2][1] = s[0]; m->m[2][2] = c[0]; - - // mY - tm[0].m[0][0] = c[1]; tm[0].m[0][1] = 0; tm[0].m[0][2] = s[1]; - tm[0].m[1][0] = 0; tm[0].m[1][1] = ONE; tm[0].m[1][2] = 0; - tm[0].m[2][0] = -s[1]; tm[0].m[2][1] = 0; tm[0].m[2][2] = c[1]; - - // mZ - tm[1].m[0][0] = c[2]; tm[1].m[0][1] = -s[2]; tm[1].m[0][2] = 0; - tm[1].m[1][0] = s[2]; tm[1].m[1][1] = c[2]; tm[1].m[1][2] = 0; - tm[1].m[2][0] = 0; tm[1].m[2][1] = 0; tm[1].m[2][2] = ONE; - - PushMatrix(); - - MulMatrix0( m, &tm[0], &tm[2] ); - MulMatrix0( &tm[2], &tm[1], m ); - - PopMatrix(); - - return m; - -} -``` \ No newline at end of file +# LIBGTE.H +Not so helpful but can be found under `psyq\include\LIBGTE.H` \ No newline at end of file diff --git a/src/Library/src/BootLoader/dma_boot.cpp b/src/Library/src/BootLoader/dma_boot.cpp index 0a03dea8..f5ccd6df 100644 --- a/src/Library/src/BootLoader/dma_boot.cpp +++ b/src/Library/src/BootLoader/dma_boot.cpp @@ -1,7 +1,6 @@ #include #include #include -#include namespace JabyEngine { namespace boot { diff --git a/src/Library/src/BootLoader/gpu_boot.cpp b/src/Library/src/BootLoader/gpu_boot.cpp index 1c6d3486..b0e5a406 100644 --- a/src/Library/src/BootLoader/gpu_boot.cpp +++ b/src/Library/src/BootLoader/gpu_boot.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #ifdef JABYENGINE_PAL #include "splash_image_pal_boot.hpp" diff --git a/src/Library/src/BootLoader/periphery_boot.cpp b/src/Library/src/BootLoader/periphery_boot.cpp index c2bfdd5c..be7218d1 100644 --- a/src/Library/src/BootLoader/periphery_boot.cpp +++ b/src/Library/src/BootLoader/periphery_boot.cpp @@ -1,6 +1,5 @@ #include "../../internal-include/periphery_internal.hpp" #include -#include namespace JabyEngine { namespace boot { diff --git a/src/Library/src/BootLoader/spu_boot.cpp b/src/Library/src/BootLoader/spu_boot.cpp index 4b25d658..5654b15f 100644 --- a/src/Library/src/BootLoader/spu_boot.cpp +++ b/src/Library/src/BootLoader/spu_boot.cpp @@ -1,6 +1,5 @@ #include -#include -#include +#include namespace JabyEngine { namespace boot { diff --git a/src/Library/src/BootLoader/start_boot.cpp b/src/Library/src/BootLoader/start_boot.cpp index fc15190a..c97c659e 100644 --- a/src/Library/src/BootLoader/start_boot.cpp +++ b/src/Library/src/BootLoader/start_boot.cpp @@ -1,6 +1,6 @@ #include "../../internal-include/BootLoader/boot_loader.hpp" #include "../../internal-include/GPU/gpu_internal.hpp" -#include +#include #include #include diff --git a/src/Library/src/BootLoader/syscall_boot.cpp b/src/Library/src/BootLoader/syscall_boot.cpp index 364532fd..009a2f3c 100644 --- a/src/Library/src/BootLoader/syscall_boot.cpp +++ b/src/Library/src/BootLoader/syscall_boot.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include namespace JabyEngine { namespace boot { diff --git a/src/Library/src/File/Processor/cd_file_processor.cpp b/src/Library/src/File/Processor/cd_file_processor.cpp index 39b826ae..6a8acc2b 100644 --- a/src/Library/src/File/Processor/cd_file_processor.cpp +++ b/src/Library/src/File/Processor/cd_file_processor.cpp @@ -1,6 +1,6 @@ #include "../../../internal-include/CD/cd_internal.hpp" #include -#include +#include namespace JabyEngine { static constexpr auto DisabledCircularBufferSize = 512; diff --git a/src/Library/src/File/Processor/tim_processor.cpp b/src/Library/src/File/Processor/tim_processor.cpp index 04ba76a3..eab980aa 100644 --- a/src/Library/src/File/Processor/tim_processor.cpp +++ b/src/Library/src/File/Processor/tim_processor.cpp @@ -1,8 +1,8 @@ #include "../../../internal-include/GPU/gpu_internal.hpp" #include "simplehelper.hpp" #include -#include -#include +#include +#include namespace JabyEngine { namespace FileProcessor { diff --git a/src/Library/src/GTE/gte.cpp b/src/Library/src/GTE/gte.cpp index b2df297d..5ec27167 100644 --- a/src/Library/src/GTE/gte.cpp +++ b/src/Library/src/GTE/gte.cpp @@ -19,12 +19,12 @@ static int32_t hisin(int32_t value) { return c >= 0 ? result : -result; } -sin_t sin(deg_t value) { - return hisin(value.raw); +gte_float sin(deg_t value) { + return gte_float{.raw = hisin(value.raw)}; } -cos_t cos(deg_t value) { - return hisin(value.raw + (deg_t::full_circle/4)); +gte_float cos(deg_t value) { + return gte_float{.raw = hisin(value.raw + (deg_t::full_circle/4))}; } namespace JabyEngine { diff --git a/src/Library/src/Periphery/periphery.cpp b/src/Library/src/Periphery/periphery.cpp index ba2132e8..22686bc5 100644 --- a/src/Library/src/Periphery/periphery.cpp +++ b/src/Library/src/Periphery/periphery.cpp @@ -1,6 +1,5 @@ #include "../../internal-include/periphery_internal.hpp" #include -#include namespace JabyEngine { namespace Periphery { diff --git a/src/Library/src/System/string.cpp b/src/Library/src/System/string.cpp index 58076a4a..9d7ab7c4 100644 --- a/src/Library/src/System/string.cpp +++ b/src/Library/src/System/string.cpp @@ -1,27 +1,25 @@ -#include +#include -START_C_FUNCTIONS - int strncmp(const char* s1, const char* s2, size_t n) { - if(n == 0) { - return 0; - } - - do { - if(*s1 != *s2++) { - return (*(unsigned char *)s1 - *(unsigned char *)--s2); - } - - if(*s1++ == 0) { - break; - } - } while(--n != 0); +int strncmp(const char* s1, const char* s2, size_t n) { + if(n == 0) { return 0; } - size_t strlen(const char *str) { - const char* end = str; - - for(; *end; ++end); - return(end - str); - } -END_C_FUNCTIONS \ No newline at end of file + do { + if(*s1 != *s2++) { + return (*(unsigned char *)s1 - *(unsigned char *)--s2); + } + + if(*s1++ == 0) { + break; + } + } while(--n != 0); + return 0; +} + +size_t strlen(const char *str) { + const char* end = str; + + for(; *end; ++end); + return(end - str); +} \ No newline at end of file diff --git a/src/Library/src/System/syscall.cpp b/src/Library/src/System/syscall.cpp index 11ec3291..e28d2fad 100644 --- a/src/Library/src/System/syscall.cpp +++ b/src/Library/src/System/syscall.cpp @@ -1,6 +1,5 @@ #include #include -#include namespace JabyEngine { namespace BIOS { diff --git a/src/Library/src/run.cpp b/src/Library/src/run.cpp index 9f9503c8..4751f2f4 100644 --- a/src/Library/src/run.cpp +++ b/src/Library/src/run.cpp @@ -1,5 +1,5 @@ #include -#include +#include extern "C" uint32_t __bss_start; extern "C" uint32_t __bss_end; diff --git a/src/Tools/cpp_out/src/lib.rs b/src/Tools/cpp_out/src/lib.rs index 38cab58e..918abb28 100644 --- a/src/Tools/cpp_out/src/lib.rs +++ b/src/Tools/cpp_out/src/lib.rs @@ -32,7 +32,7 @@ const UNIX_LINEFEED: &'static str = "\n"; const WINDOWS_LINEFEED: &'static str = "\r\n"; const C_DECLARATIONS: FileDeclarations = FileDeclarations{include: "", var_type: "char"}; -const CPP_DECLARATIONS: FileDeclarations = FileDeclarations{include: "#include ", var_type: "uint8_t"}; +const CPP_DECLARATIONS: FileDeclarations = FileDeclarations{include: "#include ", var_type: "uint8_t"}; fn output_bytes(input: Input, output: &mut Output, line_feed: &str) -> Result { let mut byte_line_count = 0; diff --git a/support/include/FontWriter/font_writer.hpp b/support/include/FontWriter/font_writer.hpp index f5380d56..68cd2e6a 100644 --- a/support/include/FontWriter/font_writer.hpp +++ b/support/include/FontWriter/font_writer.hpp @@ -1,6 +1,6 @@ #pragma once #include "Type/types.hpp" -#include +#include namespace JabyEngine { class FontWriter { diff --git a/support/src/FontWriter/src/default_font.cpp b/support/src/FontWriter/src/default_font.cpp index 08a5169c..df8b90dc 100644 --- a/support/src/FontWriter/src/default_font.cpp +++ b/support/src/FontWriter/src/default_font.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include namespace JabyEngine { static size_t decompress_font(uint32_t* work_area) { diff --git a/support/src/FontWriter/src/font_writer.cpp b/support/src/FontWriter/src/font_writer.cpp index ad7bacf6..87140214 100644 --- a/support/src/FontWriter/src/font_writer.cpp +++ b/support/src/FontWriter/src/font_writer.cpp @@ -2,7 +2,6 @@ #include #include #include -#include namespace JabyEngine { static constexpr auto ITOABufferSize = 32;