some MSL_C work (#192)

* wip

* bunch of MSL_C files

thanks to pikmin2 decomp for their work

* format / asm

* progress

* fix

* fix remove-asm to work with C files

* init / start
This commit is contained in:
TakaRikka
2022-04-24 04:02:50 -07:00
committed by GitHub
parent a1099217d6
commit 589cc12296
154 changed files with 2388 additions and 3088 deletions
+46 -19
View File
@@ -1,39 +1,66 @@
#ifndef MSL_COMMON_SRC_ANSI_FILES_H
#define MSL_COMMON_SRC_ANSI_FILES_H
#include "dolphin/types.h"
enum __file_kinds {
/* 0x0 */ CLOSED_FILE,
/* 0x1 */ DISK_FILE,
/* 0x2 */ CONSOLE_FILE,
/* 0x3 */ UNAVAILABLE_FILE,
};
struct FILE {
/* 0x00 */ u32 handle;
/* 0x04 */ u32 file_mode;
/* 0x08 */ u32 file_state;
/* 0x0C */ u8 flag;
enum __file_orientation {
/* 0x0 */ UNORIENTED,
/* 0x1 */ CHAR_ORIENTED,
/* 0x2 */ WIDE_ORIENTED,
};
typedef struct _file_modes {
unsigned int open_mode : 2;
unsigned int io_mode : 3;
unsigned int buffer_mode : 2;
unsigned int file_kind : 3;
unsigned int file_orientation : 2;
unsigned int binary_io : 1;
} file_modes;
typedef struct _file_states {
unsigned int io_state : 3;
unsigned int free_buffer : 1;
unsigned char eof;
unsigned char error;
} file_states;
typedef struct _FILE {
/* 0x00 */ unsigned int handle;
/* 0x04 */ file_modes file_mode;
/* 0x08 */ file_states file_state;
/* 0x0C */ unsigned char flag;
/* 0x0D */ char char_buffer;
/* 0x0E */ char char_buffer_2;
/* 0x0F */ char ungetc_buffer[2];
/* 0x12 */ u16 ungetc_wide_buffer[2];
/* 0x18 */ u32 position;
/* 0x1C */ u8* buffer;
/* 0x20 */ u32 buffer_size;
/* 0x24 */ u8* buffer_ptr;
/* 0x28 */ u32 buffer_length;
/* 0x2C */ u32 buffer_alignment;
/* 0x30 */ u32 buffer_length2;
/* 0x34 */ u32 buffer_position;
/* 0x12 */ unsigned short ungetc_wide_buffer[2];
/* 0x18 */ unsigned int position;
/* 0x1C */ unsigned char* buffer;
/* 0x20 */ unsigned int buffer_size;
/* 0x24 */ unsigned char* buffer_ptr;
/* 0x28 */ unsigned int buffer_length;
/* 0x2C */ unsigned int buffer_alignment;
/* 0x30 */ unsigned int buffer_length2;
/* 0x34 */ unsigned int buffer_position;
/* 0x38 */ void* position_fn;
/* 0x3C */ void* read_fn;
/* 0x40 */ void* write_fn;
/* 0x44 */ void* close_fn;
/* 0x48 */ void* unknown;
/* 0x4C */ struct FILE* next_file;
};
/* 0x4C */ struct _FILE* next_file;
} FILE;
struct files {
typedef struct _files {
FILE stdin;
FILE stdout;
FILE stderr;
FILE empty;
};
} files;
extern files __files;
+9 -1
View File
@@ -4,6 +4,14 @@
#include "MSL_C/MSL_Common/Src/ansi_files.h"
#include "dolphin/types.h"
extern "C" int fputs(const char*, FILE*);
#ifdef __cplusplus
extern "C" {
#endif
int fputs(const char*, FILE*);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_CHAR_IO_H */
+7 -1
View File
@@ -3,8 +3,14 @@
#include "dolphin/types.h"
#ifdef __cplusplus
extern "C" {
#endif
int tolower(int);
};
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_CTYPE_H */
-6
View File
@@ -1,6 +0,0 @@
#ifndef MSL_COMMON_SRC_ERRNO_H
#define MSL_COMMON_SRC_ERRNO_H
#include "dolphin/types.h"
#endif /* MSL_COMMON_SRC_ERRNO_H */
+1
View File
@@ -14,6 +14,7 @@
#define fpclassify(x) ((sizeof(x) == sizeof(float)) ? __fpclassifyf(x) : __fpclassifyd(x))
#define signbit(x) ((sizeof(x) == sizeof(float)) ? __signbitf(x) : __signbitd(x))
#define isfinite(x) ((fpclassify(x) > 2))
#define __signbitf(x) ((*(u8*)&(x)) & 0x80)
+9 -1
View File
@@ -3,6 +3,14 @@
#include "dolphin/types.h"
extern "C" int memcmp(const void*, const void*, size_t);
#ifdef __cplusplus
extern "C" {
#endif
int memcmp(const void*, const void*, size_t);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_MEM_H */
+13 -5
View File
@@ -4,10 +4,18 @@
#include "Runtime.PPCEABI.H/__va_arg.h"
#include "dolphin/types.h"
extern "C" size_t sprintf(const char*, const char*, ...);
extern "C" size_t snprintf(const char*, size_t, const char*, ...);
extern "C" size_t vsnprintf(char*, size_t, const char*, va_list);
extern "C" size_t vprintf(const char*, va_list);
extern "C" size_t printf(const char*, ...);
#ifdef __cplusplus
extern "C" {
#endif
size_t sprintf(const char*, const char*, ...);
size_t snprintf(const char*, size_t, const char*, ...);
size_t vsnprintf(char*, size_t, const char*, va_list);
size_t vprintf(const char*, va_list);
size_t printf(const char*, ...);
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_PRINTF_H */
+8 -2
View File
@@ -3,8 +3,11 @@
#include "dolphin/types.h"
#ifdef __cplusplus
extern "C" {
void* memcpy(void*, const void*, s32);
#endif
void* memcpy(void*, const void*, size_t);
void* memset(void*, int, u32);
char* strrchr(const char*, int);
char* strchr(const char*, int);
@@ -16,6 +19,9 @@ char* strcpy(char*, const char*);
u32 strlen(const char*);
int stricmp(const char*, const char*);
};
#ifdef __cplusplus
}
#endif
#endif /* MSL_COMMON_SRC_STRING_H */
+40 -34
View File
@@ -4,57 +4,60 @@
#include "MSL_C/MSL_Common/Src/float.h"
#include "dolphin/types.h"
#ifdef __cplusplus
extern "C" {
s32 abs(s32);
f64 acos(f64);
f32 acosf(f32);
f64 asin(f64);
f64 atan(f64);
f64 atan2(f64);
f64 ceil(f64);
f64 copysign(f64, f64);
f64 cos(f64);
f32 cosf(f32);
f64 exp(f64);
#endif
extern f32 __fabsf(f32);
inline f64 fabs(f64 f) {
int abs(int);
double acos(double);
float acosf(float);
double asin(double);
double atan(double);
double atan2(double, double);
double ceil(double);
double copysign(double, double);
double cos(double);
float cosf(float);
double exp(double);
extern float __fabsf(float);
inline double fabs(double f) {
return __fabsf(f);
}
inline f64 fabsf2(f32 f) {
inline double fabsf2(float f) {
return __fabsf(f);
}
inline f32 fabsf(f32 f) {
inline float fabsf(float f) {
return fabsf2(f);
}
f64 floor(f64);
f64 fmod(f64, f64);
inline f32 fmodf(f32 f1, f32 f2) {
double floor(double);
double fmod(double, double);
inline float fmodf(float f1, float f2) {
return fmod(f1, f2);
}
f64 frexp(f64, s32*);
f64 ldexp(f64, s32);
f64 modf(f64, f64*);
f64 pow(f64, f64);
f64 sin(f64);
f32 sinf(f32);
f64 sqrt(f64);
f64 tan(f64);
f32 tanf(f32);
double frexp(double, int*);
double ldexp(double, int);
double modf(double, double*);
double pow(double, double);
double sin(double);
float sinf(float);
double sqrt(double);
double tan(double);
float tanf(float);
extern f32 __float_nan[4];
extern f32 __float_epsilon[4];
extern f32 __float_max[4];
extern float __float_nan[4];
extern float __float_epsilon[4];
extern float __float_max[4];
inline f64 sqrt_step(f64 tmpd, f32 mag) {
inline double sqrt_step(double tmpd, float mag) {
return tmpd * 0.5 * (3.0 - mag * (tmpd * tmpd));
}
inline f32 sqrtf(f32 mag) {
inline float sqrtf(float mag) {
if (mag > 0.0f) {
f64 tmpd = __frsqrte(mag);
double tmpd = __frsqrte(mag);
tmpd = sqrt_step(tmpd, mag);
tmpd = sqrt_step(tmpd, mag);
tmpd = sqrt_step(tmpd, mag);
@@ -67,6 +70,9 @@ inline f32 sqrtf(f32 mag) {
return mag;
}
}
}
#ifdef __cplusplus
};
#endif
#endif