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,6 +1,6 @@
#pragma once
#include "../GPU/gpu_internal.hpp"
#include <stdio.h>
#include <stdio.hpp>
namespace JabyEngine {
static void render_num(uint8_t value, uint16_t x, uint16_t y) {

View File

@@ -2,7 +2,7 @@
#include <PSX/AutoLBA/auto_lba.hpp>
#include <PSX/Auxiliary/math_helper.hpp>
#include <PSX/System/IOPorts/cd_io.hpp>
#include <stddef.h>
#include <stddef.hpp>
namespace JabyEngine {
namespace CD {

View File

@@ -2,7 +2,7 @@
#include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/IOPorts/periphery_io.hpp>
#include <PSX/Periphery/periphery.hpp>
#include <stdio.h>
#include <stdio.hpp>
extern "C" void busy_loop(int count);

View File

@@ -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;
}
```
# LIBGTE.H
Not so helpful but can be found under `psyq\include\LIBGTE.H`

View File

@@ -1,7 +1,6 @@
#include <PSX/System/IOPorts/dma_io.hpp>
#include <PSX/System/syscalls.hpp>
#include <PSX/System/IOPorts/interrupt_io.hpp>
#include <stdio.h>
namespace JabyEngine {
namespace boot {

View File

@@ -4,7 +4,7 @@
#include <PSX/File/Processor/file_processor.hpp>
#include <PSX/GPU/gpu.hpp>
#include <PSX/System/syscalls.hpp>
#include <stdio.h>
#include <stdio.hpp>
#ifdef JABYENGINE_PAL
#include "splash_image_pal_boot.hpp"

View File

@@ -1,6 +1,5 @@
#include "../../internal-include/periphery_internal.hpp"
#include <PSX/System/syscalls.hpp>
#include <stdio.h>
namespace JabyEngine {
namespace boot {

View File

@@ -1,6 +1,5 @@
#include <PSX/System/IOPorts/spu_io.hpp>
#include <stdio.h>
#include <limits.h>
#include <limits.hpp>
namespace JabyEngine {
namespace boot {

View File

@@ -1,6 +1,6 @@
#include "../../internal-include/BootLoader/boot_loader.hpp"
#include "../../internal-include/GPU/gpu_internal.hpp"
#include <stdio.h>
#include <stdio.hpp>
#include <PSX/GTE/gte.hpp>
#include <PSX/System/syscalls.hpp>

View File

@@ -1,6 +1,6 @@
#include <PSX/Auxiliary/math_helper.hpp>
#include <PSX/System/syscalls.hpp>
#include <string.h>
#include <string.hpp>
namespace JabyEngine {
namespace boot {

View File

@@ -1,6 +1,6 @@
#include "../../../internal-include/CD/cd_internal.hpp"
#include <PSX/File/Processor/cd_file_processor.hpp>
#include <stdio.h>
#include <stdio.hpp>
namespace JabyEngine {
static constexpr auto DisabledCircularBufferSize = 512;

View File

@@ -1,8 +1,8 @@
#include "../../../internal-include/GPU/gpu_internal.hpp"
#include "simplehelper.hpp"
#include <PSX/GPU/gpu_types.hpp>
#include <limits.h>
#include <stdio.h>
#include <limits.hpp>
#include <stdio.hpp>
namespace JabyEngine {
namespace FileProcessor {

View File

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

View File

@@ -1,6 +1,5 @@
#include "../../internal-include/periphery_internal.hpp"
#include <PSX/Periphery/periphery.hpp>
#include <stdio.h>
namespace JabyEngine {
namespace Periphery {

View File

@@ -1,27 +1,25 @@
#include <string.h>
#include <string.hpp>
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
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);
}

View File

@@ -1,6 +1,5 @@
#include <PSX/Auxiliary/math_helper.hpp>
#include <PSX/System/syscalls.hpp>
#include <string.h>
namespace JabyEngine {
namespace BIOS {

View File

@@ -1,5 +1,5 @@
#include <PSX/GPU/gpu_primitives.hpp>
#include <stdio.h>
#include <stdio.hpp>
extern "C" uint32_t __bss_start;
extern "C" uint32_t __bss_end;

View File

@@ -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 <stdint.h>", var_type: "uint8_t"};
const CPP_DECLARATIONS: FileDeclarations = FileDeclarations{include: "#include <stdint.hpp>", var_type: "uint8_t"};
fn output_bytes(input: Input, output: &mut Output, line_feed: &str) -> Result<usize, std::io::Error> {
let mut byte_line_count = 0;