Update C headers to be C++

This commit is contained in:
2024-04-07 10:46:35 -05:00
parent 6702e60864
commit 3ef946ad4b
58 changed files with 153 additions and 225 deletions

View File

@@ -1,5 +1,5 @@
#pragma once
#include "../../stddef.h"
#include "../../stddef.hpp"
namespace JabyEngine {
template<typename T>

View File

@@ -1,5 +1,5 @@
#pragma once
#include "../jabyengine_defines.h"
#include "../jabyengine_defines.hpp"
#include "types.hpp"
namespace JabyEngine {

View File

@@ -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) {

View File

@@ -1,5 +1,5 @@
#pragma once
#include "../../stddef.h"
#include "../../stddef.hpp"
#include "array_range.hpp"
#include "types.hpp"

View File

@@ -1,6 +1,6 @@
#pragma once
#include "types.hpp"
#include <stddef.h>
#include <stddef.hpp>
namespace JabyEngine {
template<typename T>

View File

@@ -1,5 +1,5 @@
#pragma once
#include "../../stdint.h"
#include "../../stdint.hpp"
namespace JabyEngine {
uint16_t unaligned_lhu(const uint8_t* adr) {

View File

@@ -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)

View File

@@ -1,6 +1,6 @@
#pragma once
#include "../Auxiliary/bits.hpp"
#include "../jabyengine_defines.h"
#include "../jabyengine_defines.hpp"
namespace JabyEngine {
namespace GPU {

View File

@@ -1,5 +1,5 @@
#pragma once
#include "../jabyengine_defines.h"
#include "../jabyengine_defines.hpp"
namespace JabyEngine {
namespace Periphery {

View File

@@ -1,7 +1,6 @@
#pragma once
#include "ioport.hpp"
#include "../../GPU/gpu_types.hpp"
#include <stdio.h>
namespace JabyEngine {
namespace GPU_IO {

View File

@@ -1,5 +1,5 @@
#pragma once
#include "../jabyengine_defines.h"
#include "../jabyengine_defines.hpp"
/*
R0 zr Constant Zero

View File

@@ -1,7 +1,7 @@
#ifndef __JABYENGINE_FRAME_TIME_HELPER_HPP__
#define __JABYENGINE_FRAME_TIME_HELPER_HPP__
#include <PSX/GPU/gpu.hpp>
#include <limits.h>
#include <limits.hpp>
namespace JabyEngine {
static constexpr double ms_per_frame = 1000.0/static_cast<double>(GPU::Display::frames_per_sec);

View File

@@ -1,7 +1,7 @@
#ifndef __JABYENGINE_FRAME_TIMER_HPP__
#define __JABYENGINE_FRAME_TIMER_HPP__
#include "frame_time_helper.hpp"
#include <stdint.h>
#include <stdint.hpp>
namespace JabyEngine {
class MasterTime {

View File

@@ -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 <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/IOPorts/timer_io.hpp>

View File

@@ -1,5 +1,5 @@
#pragma once
#include "jabyengine_defines.h"
#include "jabyengine_defines.hpp"
namespace JabyEngine {
typedef void (*MainRoutine)();

View File

@@ -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__
#endif

View File

@@ -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

33
include/limits.hpp Normal file
View File

@@ -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;

View File

@@ -1,5 +1,5 @@
#pragma once
#include "stdint.h"
#include "stdint.hpp"
namespace math {
template<typename T>
@@ -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);
gte_float sin(deg_t value);
gte_float cos(deg_t value);

View File

@@ -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

7
include/stdarg.hpp Normal file
View File

@@ -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

View File

@@ -1,7 +0,0 @@
#ifndef __STDDEF__H
#define __STDDEF__H
#include "stdint.h"
typedef uintmax_t size_t;
#endif //!__STDDEF__H

4
include/stddef.hpp Normal file
View File

@@ -0,0 +1,4 @@
#pragma once
#include "stdint.hpp"
using size_t = uintmax_t;

View File

@@ -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

34
include/stdint.hpp Normal file
View File

@@ -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;

View File

@@ -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

4
include/stdio.hpp Normal file
View File

@@ -0,0 +1,4 @@
#pragma once
#include "PSX/jabyengine_defines.hpp"
int printf(const char* txt, ...) asm("_ZN10JabyEngine7SysCall6printfEPKcz");

View File

@@ -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

5
include/string.hpp Normal file
View File

@@ -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);