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
+2 -2
View File
@@ -14,7 +14,7 @@ struct DynamicModuleControlBase {
/* 0x0C */ /*vtable*/
/* 802621CC */ virtual ~DynamicModuleControlBase();
/* 800188DC */ virtual const char* getModuleName() const {return NULL;};
/* 800188DC */ virtual const char* getModuleName() const { return NULL; };
/* 80263210 */ virtual int getModuleSize() const;
/* 80263200 */ virtual const char* getModuleTypeString() const;
/* 80262470 */ virtual void dump();
@@ -43,7 +43,7 @@ struct DynamicModuleControl : DynamicModuleControlBase {
/* 80263218 */ virtual const char* getModuleName() const;
/* 80263000 */ virtual int getModuleSize() const;
/* 80263070 */ virtual const char* getModuleTypeString() const;
//virtual void dump();
// virtual void dump();
/* 80262C0C */ virtual void dump2();
/* 802627E8 */ virtual bool do_load();
/* 80262AFC */ virtual BOOL do_load_async();
+7 -18
View File
@@ -422,21 +422,18 @@ struct J2DBlendInfo {
mType = other.mType;
mSrcFactor = other.mSrcFactor;
mDstFactor = other.mDstFactor;
//mOp = other.mOp;
// mOp = other.mOp;
}
/* 0x0 */ u8 mType;
/* 0x1 */ u8 mSrcFactor;
/* 0x2 */ u8 mDstFactor;
};
extern J2DBlendInfo j2dDefaultBlendInfo;
struct J2DBlend {
J2DBlend() {
mBlendInfo = j2dDefaultBlendInfo;
}
J2DBlend() { mBlendInfo = j2dDefaultBlendInfo; }
/* 0x0 */ J2DBlendInfo mBlendInfo;
/* 0x3 */ u8 mOp;
@@ -444,9 +441,7 @@ struct J2DBlend {
class J2DPEBlock {
public:
J2DPEBlock() {
initialize();
}
J2DPEBlock() { initialize(); }
/* 802F17FC */ void initialize();
/* 802F1840 */ void setGX();
@@ -475,10 +470,8 @@ public:
class J2DIndBlockFull : public J2DIndBlock {
public:
J2DIndBlockFull() {
initialize();
}
J2DIndBlockFull() { initialize(); }
/* 802F1664 */ virtual void initialize();
/* 802F1730 */ virtual void setGX();
/* 802F1B94 */ virtual void getType();
@@ -515,9 +508,7 @@ private:
/* 0x24 */ J2DTexMtx* mTexMtx[8];
public:
J2DTexGenBlock() {
initialize();
}
J2DTexGenBlock() { initialize(); }
/* 802EB510 */ void initialize();
/* 802EB570 */ void setGX();
@@ -547,9 +538,7 @@ private:
/* 0x12 */ u8 mCullMode;
public:
J2DColorBlock() {
initialize();
}
J2DColorBlock() { initialize(); }
/* 802EB394 */ void initialize();
/* 802EB424 */ void setGX();
-1
View File
@@ -42,7 +42,6 @@ public:
J2DTevBlock* getTevBlock() { return mTevBlock; }
J2DIndBlock* getIndBlock() { return mIndBlock; }
private:
/* 0x04 */ int field_0x4;
/* 0x08 */ int field_0x8;
+2 -2
View File
@@ -50,9 +50,9 @@ public:
/* 802F9A74 */ virtual void setAnimationVF(J2DAnmVisibilityFull*);
/* 802F9A78 */ virtual void setAnimationVC(J2DAnmVtxColor*);
/* 802F99E8 */ virtual J2DPane* createPane(J2DScrnBlockHeader const&, JSURandomInputStream*,
J2DPane*, u32);
J2DPane*, u32);
/* 802F8B98 */ virtual J2DPane* createPane(J2DScrnBlockHeader const&, JSURandomInputStream*,
J2DPane*, u32, JKRArchive*);
J2DPane*, u32, JKRArchive*);
/* 802F8498 */ J2DScreen();
/* 802F85A8 */ void clean();
+1 -1
View File
@@ -219,7 +219,7 @@ inline JKRCompression JKRConvertAttrToCompressionType(u32 attr) {
}
inline void* JKRGetResource(u32 node, const char* path, JKRArchive* archive) {
return JKRArchive::getGlbResource(node,path,archive);
return JKRArchive::getGlbResource(node, path, archive);
}
inline void* JKRGetTypeResource(u32 tag, const char* name, JKRArchive* arc) {
+1 -1
View File
@@ -55,7 +55,7 @@ public:
};
inline bool JKRDetachResource(void* resource, JKRFileLoader* fileLoader) {
return JKRFileLoader::detachResource(resource,fileLoader);
return JKRFileLoader::detachResource(resource, fileLoader);
}
inline void* JKRGetNameResource(const char* name, JKRFileLoader* loader) {
+1 -3
View File
@@ -6,9 +6,7 @@
class JSUMemoryInputStream : JSURandomInputStream {
public:
JSUMemoryInputStream(const void* res, u32 size) {
setBuffer(res, size);
}
JSUMemoryInputStream(const void* res, u32 size) { setBuffer(res, size); }
/* 802552B8 */ ~JSUMemoryInputStream() {}
/* 802DC520 */ void setBuffer(void const*, s32);
+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 */
+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
+11 -5
View File
@@ -3,15 +3,21 @@
#include "dolphin/types.h"
// not sure what the members are.
// OK when the struct is 12 bytes.
typedef struct __va_list_struct {
u8 data[12];
};
char gpr;
char fpr;
char reserved[2];
char* input_arg_area;
char* reg_save_area;
} _va_list_struct;
typedef __va_list_struct __va_list[1];
typedef _va_list_struct __va_list[1];
#ifdef __cplusplus
extern "C" void __va_arg(void*, int);
#else
void __va_arg(void*, int);
#endif
#if IN_VSCODE_EDITOR
#define __builtin_va_info(...)
+25
View File
@@ -3,6 +3,8 @@
// this helps remove useless error from the linter when using vscode.
#ifndef IN_VSCODE_EDITOR
#ifdef __cplusplus
#define SECTION_INIT extern "C" __declspec(section ".init")
#define SECTION_RODATA __declspec(section ".rodata")
#define SECTION_DATA __declspec(section ".data")
@@ -23,6 +25,29 @@
#define COMPILER_STRIP_GATE(NAME, VALUE) SECTION_DEAD void* const cg_##NAME = (void*)(VALUE)
#define ALIGN_DECL(ALIGNMENT) __attribute__((aligned(ALIGNMENT)))
#define REGISTER_CTORS(ADDR, FUNCTION) SECTION_CTORS void* const _ctors_##ADDR = (void*)(FUNCTION);
#else
#define SECTION_INIT __declspec(section ".init")
#define SECTION_RODATA __declspec(section ".rodata")
#define SECTION_DATA __declspec(section ".data")
#define SECTION_SDATA __declspec(section ".sdata")
#define SECTION_SDATA2 __declspec(section ".sdata2")
#define SECTION_BSS __declspec(section ".data")
#define SECTION_SBSS __declspec(section ".sdata")
#define SECTION_SBSS2 __declspec(section ".sdata2")
#define SECTION_CTORS __declspec(section ".ctors")
#define SECTION_DTORS __declspec(section ".dtors")
#define SECTION_EXTAB __declspec(section "extab_")
#define SECTION_EXTABINDEX __declspec(section "extabindex_")
#define SECTION_DEAD __declspec(section ".dead")
#define SECTION_CTORS10 __declspec(section ".ctors$10")
#define SECTION_CTORS15 __declspec(section ".ctors$15")
#define SECTION_DTORS10 __declspec(section ".dtors$10")
#define SECTION_DTORS15 __declspec(section ".dtors$15")
#define COMPILER_STRIP_GATE(NAME, VALUE) SECTION_DEAD void* const cg_##NAME = (void*)(VALUE)
#define ALIGN_DECL(ALIGNMENT) __attribute__((aligned(ALIGNMENT)))
#define REGISTER_CTORS(ADDR, FUNCTION) SECTION_CTORS void* const _ctors_##ADDR = (void*)(FUNCTION);
#endif
#else
#define SECTION_INIT
#define SECTION_RODATA
@@ -1,6 +1,6 @@
#ifndef MSL_COMMON_SRC_ERRNO_H
#define MSL_COMMON_SRC_ERRNO_H
#include "dolphin/types.h"
extern int errno;
#endif /* MSL_COMMON_SRC_ERRNO_H */
+228
View File
@@ -0,0 +1,228 @@
#ifndef FDLIBM_H
#define FDLIBM_H
/* @(#)fdlibm.h 1.5 04/04/22 */
/*
* ====================================================
* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
*
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#ifdef __cplusplus
extern "C" {
#endif
/* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly
but these catch some common cases. */
#if defined(i386) || defined(i486) || defined(intel) || defined(x86) || defined(i86pc) || \
defined(__alpha) || defined(__osf__)
#define __LITTLE_ENDIAN
#endif
#ifdef __LITTLE_ENDIAN
#define __HI(x) *(1 + (int*)&x)
#define __LO(x) *(int*)&x
#define __HIp(x) *(1 + (int*)x)
#define __LOp(x) *(int*)x
#else
#define __HI(x) *(int*)&x
#define __LO(x) *(1 + (int*)&x)
#define __HIp(x) *(int*)x
#define __LOp(x) *(1 + (int*)x)
#endif
// TODO: should __STDC__ actually be defined?
//#ifdef __STDC__
#define __P(p) p
//#else
//#define __P(p) ()
//#endif
/*
* ANSI/POSIX
*/
extern int signgam;
#define MAXFLOAT ((float)3.40282346638528860e+38)
enum fdversion { fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix };
#define _LIB_VERSION_TYPE enum fdversion
#define _LIB_VERSION _fdlib_version
/* if global variable _LIB_VERSION is not desirable, one may
* change the following to be a constant by:
* #define _LIB_VERSION_TYPE const enum version
* In that case, after one initializes the value _LIB_VERSION (see
* s_lib_version.c) during compile time, it cannot be modified
* in the middle of a program
*/
extern _LIB_VERSION_TYPE _LIB_VERSION;
#define _IEEE_ fdlibm_ieee
#define _SVID_ fdlibm_svid
#define _XOPEN_ fdlibm_xopen
#define _POSIX_ fdlibm_posix
struct exception {
int type;
char* name;
double arg1;
double arg2;
double retval;
};
#define HUGE MAXFLOAT
/*
* set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
* (one may replace the following line by "#include <values.h>")
*/
#define X_TLOSS 1.41484755040568800000e+16
#define DOMAIN 1
#define SING 2
#define OVERFLOW 3
#define UNDERFLOW 4
#define TLOSS 5
#define PLOSS 6
/*
* ANSI/POSIX
*/
extern double acos __P((double));
extern double asin __P((double));
extern double atan __P((double));
extern double atan2 __P((double, double));
extern double cos __P((double));
extern double sin __P((double));
extern double tan __P((double));
extern double cosh __P((double));
extern double sinh __P((double));
extern double tanh __P((double));
extern double exp __P((double));
extern double frexp __P((double, int*));
extern double ldexp __P((double, int));
extern double log __P((double));
extern double log10 __P((double));
extern double modf __P((double, double*));
extern double pow __P((double, double));
extern double sqrt __P((double));
extern double ceil __P((double));
extern double fabs __P((double));
extern double floor __P((double));
extern double fmod __P((double, double));
extern double erf __P((double));
extern double erfc __P((double));
extern double gamma __P((double));
extern double hypot __P((double, double));
extern int isnan __P((double));
extern int finite __P((double));
extern double j0 __P((double));
extern double j1 __P((double));
extern double jn __P((int, double));
extern double lgamma __P((double));
extern double y0 __P((double));
extern double y1 __P((double));
extern double yn __P((int, double));
extern double acosh __P((double));
extern double asinh __P((double));
extern double atanh __P((double));
extern double cbrt __P((double));
extern double logb __P((double));
extern double nextafter __P((double, double));
extern double remainder __P((double, double));
#ifdef _SCALB_INT
extern double scalb __P((double, int));
#else
extern double scalb __P((double, double));
#endif
extern int matherr __P((struct exception*));
/*
* IEEE Test Vector
*/
extern double significand __P((double));
/*
* Functions callable from C, intended to support IEEE arithmetic.
*/
extern double copysign __P((double, double));
extern int ilogb __P((double));
extern double rint __P((double));
extern double scalbn __P((double, int));
/*
* BSD math library entry points
*/
extern double expm1 __P((double));
extern double log1p __P((double));
/*
* Reentrant version of gamma & lgamma; passes signgam back by reference
* as the second argument; user must allocate space for signgam.
*/
#ifdef _REENTRANT
extern double gamma_r __P((double, int*));
extern double lgamma_r __P((double, int*));
#endif /* _REENTRANT */
/* ieee style elementary functions */
extern double __ieee754_sqrt __P((double));
extern double __ieee754_acos __P((double));
extern double __ieee754_acosh __P((double));
extern double __ieee754_log __P((double));
extern double __ieee754_atanh __P((double));
extern double __ieee754_asin __P((double));
extern double __ieee754_atan2 __P((double, double));
extern double __ieee754_exp __P((double));
extern double __ieee754_cosh __P((double));
extern double __ieee754_fmod __P((double, double));
extern double __ieee754_pow __P((double, double));
extern double __ieee754_lgamma_r __P((double, int*));
extern double __ieee754_gamma_r __P((double, int*));
extern double __ieee754_lgamma __P((double));
extern double __ieee754_gamma __P((double));
extern double __ieee754_log10 __P((double));
extern double __ieee754_sinh __P((double));
extern double __ieee754_hypot __P((double, double));
extern double __ieee754_j0 __P((double));
extern double __ieee754_j1 __P((double));
extern double __ieee754_y0 __P((double));
extern double __ieee754_y1 __P((double));
extern double __ieee754_jn __P((int, double));
extern double __ieee754_yn __P((int, double));
extern double __ieee754_remainder __P((double, double));
extern int __ieee754_rem_pio2 __P((double, double*));
#ifdef _SCALB_INT
extern double __ieee754_scalb __P((double, int));
#else
extern double __ieee754_scalb __P((double, double));
#endif
/* fdlibm kernel function */
extern double __kernel_standard __P((double, double, int));
extern double __kernel_sin __P((double, double, int));
extern double __kernel_cos __P((double, double));
extern double __kernel_tan __P((double, double, int));
extern int __kernel_rem_pio2 __P((double*, double*, int, int, int, const int*));
#ifdef __cplusplus
};
#endif
#endif /* FDLIBM_H */