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 */