diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2022-04-24 04:02:50 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-24 13:02:50 +0200 |
| commit | 589cc12296ae7253c62655859a5eef92ee42dbaf (patch) | |
| tree | dd8556994b43ed23dff2aed6bb4c019e5c0d7ec9 /libs | |
| parent | a1099217d65362f16dd90284670a7dd37702a3ca (diff) | |
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
Diffstat (limited to 'libs')
81 files changed, 1773 insertions, 1335 deletions
diff --git a/libs/JSystem/J2DGraph/J2DScreen.cpp b/libs/JSystem/J2DGraph/J2DScreen.cpp index d34ece206f..722443fe81 100644 --- a/libs/JSystem/J2DGraph/J2DScreen.cpp +++ b/libs/JSystem/J2DGraph/J2DScreen.cpp @@ -4,15 +4,15 @@ // #include "JSystem/J2DGraph/J2DScreen.h" +#include "JSystem/J2DGraph/J2DMaterialFactory.h" +#include "JSystem/J2DGraph/J2DOrthoGraph.h" +#include "JSystem/J2DGraph/J2DPictureEx.h" +#include "JSystem/J2DGraph/J2DTextBoxEx.h" +#include "JSystem/J2DGraph/J2DWindowEx.h" #include "JSystem/JGeometry.h" +#include "JSystem/JSupport/JSUMemoryStream.h" #include "dol2asm.h" #include "dolphin/types.h" -#include "JSystem/JSupport/JSUMemoryStream.h" -#include "JSystem/J2DGraph/J2DTextBoxEx.h" -#include "JSystem/J2DGraph/J2DWindowEx.h" -#include "JSystem/J2DGraph/J2DPictureEx.h" -#include "JSystem/J2DGraph/J2DOrthoGraph.h" -#include "JSystem/J2DGraph/J2DMaterialFactory.h" // // Forward References: @@ -356,12 +356,12 @@ bool J2DScreen::getScreenInformation(JSURandomInputStream* stream) { * makeHierarchyPanes__9J2DScreenFP7J2DPaneP20JSURandomInputStreamUlP10JKRArchive */ // goto can probably be replaced s32 J2DScreen::makeHierarchyPanes(J2DPane* basePane, JSURandomInputStream* stream, u32 param_2, - JKRArchive* archive) { + JKRArchive* archive) { J2DScrnBlockHeader header; J2DPane* next_pane = basePane; do { - loop: + loop: stream->peek(&header, sizeof(J2DScrnBlockHeader)); switch (header.mTag) { @@ -382,7 +382,7 @@ s32 J2DScreen::makeHierarchyPanes(J2DPane* basePane, JSURandomInputStream* strea case 'TEX1': J2DResReference* texRes = getResReference(stream, param_2); mTexRes = texRes; - + if (texRes != NULL) { goto loop; } @@ -390,7 +390,7 @@ s32 J2DScreen::makeHierarchyPanes(J2DPane* basePane, JSURandomInputStream* strea case 'FNT1': J2DResReference* fntRes = getResReference(stream, param_2); mFontRes = fntRes; - + if (fntRes != NULL) { goto loop; } @@ -407,8 +407,7 @@ s32 J2DScreen::makeHierarchyPanes(J2DPane* basePane, JSURandomInputStream* strea } else { next_pane = createPane(header, stream, basePane, param_2, archive); } - } - while (next_pane != NULL); + } while (next_pane != NULL); return 2; } @@ -452,7 +451,7 @@ J2DPane* J2DScreen::createPane(J2DScrnBlockHeader const& header, JSURandomInputS case 'TBX2': if (param_3 & 0x1F0000) { newPane = new J2DTextBoxEx(basePane, stream, param_3, mMaterials); - break; + break; } newPane = new J2DTextBox(basePane, stream, param_3, mMaterials); break; @@ -465,7 +464,7 @@ J2DPane* J2DScreen::createPane(J2DScrnBlockHeader const& header, JSURandomInputS stream->seek(start, JSUStreamSeekFrom_SET); break; } - + return newPane; } @@ -508,7 +507,8 @@ void J2DScreen::draw(f32 param_0, f32 param_1, J2DGrafContext const* grafCtx) { GXSetVtxDesc(GX_VA_TEX0, GX_NONE); GXSetCullMode(GX_CULL_NONE); GXSetNumTexGens(0); - GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE); + GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, + GX_AF_NONE); for (int i = 0; i < 4; i++) { GXSetTevSwapModeTable((GXTevSwapSel)i, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); } @@ -628,8 +628,7 @@ asm J2DResReference* J2DScreen::getResReference(JSURandomInputStream* param_0, u * createMaterial__9J2DScreenFP20JSURandomInputStreamUlP10JKRArchive */ // nametab section has issues #ifdef NONMATCHING -bool J2DScreen::createMaterial(JSURandomInputStream* stream, u32 param_1, - JKRArchive* archive) { +bool J2DScreen::createMaterial(JSURandomInputStream* stream, u32 param_1, JKRArchive* archive) { s32 position = stream->getPosition(); J2DScrnBlockHeader header; @@ -655,7 +654,8 @@ bool J2DScreen::createMaterial(JSURandomInputStream* stream, u32 param_1, } if (param_1 & 0x1F0000) { - u32 offset = buffer[0x14] << 0x18 | buffer[0x15] << 0x10 | buffer[0x16] << 8 | buffer[0x17]; + u32 offset = + buffer[0x14] << 0x18 | buffer[0x15] << 0x10 | buffer[0x16] << 8 | buffer[0x17]; char* sec = (char*)buffer + offset; u16* sec_s = (u16*)sec + *(u16*)sec; @@ -726,7 +726,7 @@ void* J2DScreen::getNameResource(char const* resName) { /* 802F9690-802F9704 2F3FD0 0074+00 0/0 30/30 3/3 .text animation__9J2DScreenFv */ void J2DScreen::animation() { animationPane(mTransform); - + for (u16 i = 0; i < mMaterialNum; i++) { mMaterials[i].animation(); } @@ -741,7 +741,7 @@ void J2DScreen::setAnimation(J2DAnmColor* anmColor) { u16 matID = anmColor->getUpdateMaterialID(i); if (matID < mMaterialNum) { mMaterials[matID].setAnimation(anmColor); - } + } } } @@ -755,7 +755,7 @@ void J2DScreen::setAnimation(J2DAnmTextureSRTKey* anmSRTKey) { u16 matID = anmSRTKey->getUpdateMaterialID(i); if (matID < mMaterialNum) { mMaterials[matID].setAnimation(anmSRTKey); - } + } } } @@ -769,7 +769,7 @@ void J2DScreen::setAnimation(J2DAnmTexPattern* anmPattern) { u16 matID = anmPattern->getUpdateMaterialID(i); if (matID < mMaterialNum) { mMaterials[matID].setAnimation(anmPattern); - } + } } } @@ -783,7 +783,7 @@ void J2DScreen::setAnimation(J2DAnmTevRegKey* anmRegKey) { u16 matID = anmRegKey->getCRegUpdateMaterialID(i); if (matID < mMaterialNum) { mMaterials[matID].setAnimation(anmRegKey); - } + } } u16 kMatNum = anmRegKey->getKRegUpdateMaterialNum(); @@ -791,7 +791,7 @@ void J2DScreen::setAnimation(J2DAnmTevRegKey* anmRegKey) { u16 matID = anmRegKey->getKRegUpdateMaterialID(i); if (matID < mMaterialNum) { mMaterials[matID].setAnimation(anmRegKey); - } + } } } @@ -810,7 +810,7 @@ void J2DScreen::setAnimation(J2DAnmVisibilityFull* anmVisibility) { /* 802F99E8-802F9A18 2F4328 0030+00 1/0 0/0 0/0 .text * createPane__9J2DScreenFRC18J2DScrnBlockHeaderP20JSURandomInputStreamP7J2DPaneUl */ J2DPane* J2DScreen::createPane(J2DScrnBlockHeader const& header, JSURandomInputStream* stream, - J2DPane* basePane, u32 param_3) { + J2DPane* basePane, u32 param_3) { return createPane(header, stream, basePane, param_3, NULL); } diff --git a/libs/MSL_C/MSL_Common/Src/FILE_POS.cpp b/libs/MSL_C/MSL_Common/Src/FILE_POS.c index 76dd37390f..dad60257d7 100644 --- a/libs/MSL_C/MSL_Common/Src/FILE_POS.cpp +++ b/libs/MSL_C/MSL_Common/Src/FILE_POS.c @@ -11,18 +11,18 @@ // Forward References: // -extern "C" void fseek(); -extern "C" static void _fseek(); -extern "C" void ftell(); +void fseek(); +static void _fseek(); +void ftell(); // // External References: // -extern "C" void __flush_buffer(); -extern "C" void __end_critical_region(); -extern "C" void __begin_critical_region(); -extern "C" extern u8 errno[4 + 4 /* padding */]; +void __flush_buffer(); +void __end_critical_region(); +void __begin_critical_region(); +extern u8 errno[4 + 4 /* padding */]; // // Declarations: diff --git a/libs/MSL_C/MSL_Common/Src/abort_exit.cpp b/libs/MSL_C/MSL_Common/Src/abort_exit.c index c7014cb234..4dc61f92d3 100644 --- a/libs/MSL_C/MSL_Common/Src/abort_exit.cpp +++ b/libs/MSL_C/MSL_Common/Src/abort_exit.c @@ -11,20 +11,20 @@ // Forward References: // -extern "C" void exit(); -extern "C" void abort(); -extern "C" extern u8 data_804519A0[8]; +void exit(); +void abort(); +extern u8 data_804519A0[8]; // // External References: // -extern "C" void _ExitProcess(); -extern "C" void __destroy_global_chain(); -extern "C" void __end_critical_region(); -extern "C" void __begin_critical_region(); -extern "C" void __kill_critical_regions(); -extern "C" void raise(); +void _ExitProcess(); +void __destroy_global_chain(); +void __end_critical_region(); +void __begin_critical_region(); +void __kill_critical_regions(); +void raise(); SECTION_DTORS10 extern void* const __destroy_global_chain_reference; // @@ -35,18 +35,23 @@ SECTION_DTORS10 extern void* const __destroy_global_chain_reference; /* 8044D440-8044D540 07A160 0100+00 2/2 0/0 0/0 .bss __atexit_funcs */ static u8 __atexit_funcs[256]; -/* 80451990-80451994 000E90 0004+00 2/2 0/0 0/0 .sbss __aborting */ -static u8 __aborting[4]; +/* ############################################################################################## */ +/* 804519A0-804519A8 000EA0 0008+00 0/0 1/1 0/0 .sbss None */ +extern u8 data_804519A0[8]; +u8 data_804519A0[8]; -/* 80451994-80451998 000E94 0004+00 2/2 0/0 0/0 .sbss __atexit_curr_func */ -static u8 __atexit_curr_func[4]; +/* 8045199C-804519A0 000E9C 0004+00 2/2 0/0 0/0 .sbss __console_exit */ +static u8 __console_exit[4]; /* 80451998-8045199C 000E98 0004+00 1/1 1/1 0/0 .sbss __stdio_exit */ extern u8 __stdio_exit[4]; u8 __stdio_exit[4]; -/* 8045199C-804519A0 000E9C 0004+00 2/2 0/0 0/0 .sbss __console_exit */ -static u8 __console_exit[4]; +/* 80451994-80451998 000E94 0004+00 2/2 0/0 0/0 .sbss __atexit_curr_func */ +static u8 __atexit_curr_func[4]; + +/* 80451990-80451994 000E90 0004+00 2/2 0/0 0/0 .sbss __aborting */ +static u8 __aborting[4]; /* 803629CC-80362ABC 35D30C 00F0+00 0/0 2/2 0/0 .text exit */ #pragma push @@ -67,8 +72,3 @@ asm void abort() { #include "asm/MSL_C/MSL_Common/Src/abort_exit/abort.s" } #pragma pop - -/* ############################################################################################## */ -/* 804519A0-804519A8 000EA0 0008+00 0/0 1/1 0/0 .sbss None */ -extern u8 data_804519A0[8]; -u8 data_804519A0[8]; diff --git a/libs/MSL_C/MSL_Common/Src/alloc.cpp b/libs/MSL_C/MSL_Common/Src/alloc.c index de11b1b541..41c4f7ca57 100644 --- a/libs/MSL_C/MSL_Common/Src/alloc.cpp +++ b/libs/MSL_C/MSL_Common/Src/alloc.c @@ -11,20 +11,20 @@ // Forward References: // -extern "C" void free(); -extern "C" void __pool_free(); -extern "C" static void deallocate_from_fixed_pools(); -extern "C" static void deallocate_from_var_pools(); +void free(); +void __pool_free(); +static void deallocate_from_fixed_pools(); +static void deallocate_from_var_pools(); // // External References: // SECTION_INIT void memset(); -extern "C" void __sys_free(); -extern "C" void __end_critical_region(); -extern "C" void __begin_critical_region(); -extern "C" extern u8 data_804519A0[8]; +void __sys_free(); +void __end_critical_region(); +void __begin_critical_region(); +extern u8 data_804519A0[8]; // // Declarations: diff --git a/libs/MSL_C/MSL_Common/Src/ansi_files.c b/libs/MSL_C/MSL_Common/Src/ansi_files.c new file mode 100644 index 0000000000..39b0e2c306 --- /dev/null +++ b/libs/MSL_C/MSL_Common/Src/ansi_files.c @@ -0,0 +1,181 @@ +// +// Generated By: dol2asm +// Translation Unit: MSL_Common/Src/ansi_files +// + +#include "MSL_C/MSL_Common/Src/ansi_files.h" +#include "dol2asm.h" +#include "dolphin/types.h" + +// +// Forward References: +// + +unsigned int __flush_all(); +void __close_all(); + +// +// External References: +// + +void free(FILE*); +void __end_critical_region(int); +void __begin_critical_region(int); +int fflush(FILE*); +void fclose(FILE*); +int __close_console(unsigned int); +int __write_console(int, int, int*, int); +int __read_console(unsigned int, unsigned int, unsigned int*); + +// +// Declarations: +// + +/* ############################################################################################## */ +/* 8044D778-8044D878 07A498 0100+00 1/0 0/0 0/0 .bss stdin_buff */ +static u8 stdin_buff[0x100]; + +/* 8044D678-8044D778 07A398 0100+00 1/0 0/0 0/0 .bss stdout_buff */ +static u8 stdout_buff[0x100]; + +/* 8044D578-8044D678 07A298 0100+00 1/0 0/0 0/0 .bss stderr_buff */ +static u8 stderr_buff[0x100]; + +/* 803D29B0-803D2AF0 -00001 0140+00 3/2 15/15 0/0 .data __files */ +SECTION_DATA extern files __files = { + {0, + 0, + 1, + 1, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + {0, 0}, + {0, 0}, + 0, + stdin_buff, + 0x00000100, + stdin_buff, + 0, + 0, + 0, + 0, + NULL, + __read_console, + __write_console, + __close_console, + NULL, + &__files.stdout}, + {1, + 0, + 2, + 1, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + {0, 0}, + {0, 0}, + 0, + stdout_buff, + 0x00000100, + stdout_buff, + 0, + 0, + 0, + 0, + NULL, + __read_console, + __write_console, + __close_console, + NULL, + &__files.stderr}, + {2, + 0, + 2, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + {0, 0}, + {0, 0}, + 0, + stderr_buff, + 0x00000100, + stderr_buff, + 0, + 0, + 0, + 0, + NULL, + __read_console, + __write_console, + __close_console, + NULL, + &__files.empty}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, + {0, 0}, 0, NULL, 0x00000000, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL}, +}; + +/* 8036300C-8036307C 35D94C 0070+00 0/0 2/2 0/0 .text __flush_all */ +unsigned int __flush_all(void) { + unsigned int ret = 0; + FILE* file = &__files.stdin; + + while (file) { + if (file->file_mode.file_kind != 0 && fflush(file)) { + ret = -1; + } + file = file->next_file; + } + + return ret; +} + +/* 8036307C-80363124 35D9BC 00A8+00 0/0 1/1 0/0 .text __close_all */ +void __close_all(void) { + FILE* file = &__files.stdin; + FILE* last_file; + + __begin_critical_region(2); + + while (file != NULL) { + if (file->file_mode.file_kind != CLOSED_FILE) { + fclose(file); + } + + last_file = file; + file = file->next_file; + + if (last_file->flag) { + free(last_file); + } else { + last_file->file_mode.file_kind = UNAVAILABLE_FILE; + if (file != NULL && file->flag) { + last_file->next_file = NULL; + } + } + } + + __end_critical_region(2); +} diff --git a/libs/MSL_C/MSL_Common/Src/ansi_files.cpp b/libs/MSL_C/MSL_Common/Src/ansi_files.cpp deleted file mode 100644 index 7aa06d6f38..0000000000 --- a/libs/MSL_C/MSL_Common/Src/ansi_files.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: MSL_Common/Src/ansi_files -// - -#include "MSL_C/MSL_Common/Src/ansi_files.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void __flush_all(); -extern "C" void __close_all(); - -// -// External References: -// - -extern "C" void free(); -extern "C" void __end_critical_region(); -extern "C" void __begin_critical_region(); -extern "C" void fflush(); -extern "C" void fclose(); -extern "C" bool __close_console(); -extern "C" void __write_console(); -extern "C" void __read_console(); - -// -// Declarations: -// - -/* ############################################################################################## */ -/* 8044D578-8044D678 07A298 0100+00 1/0 0/0 0/0 .bss stderr_buff */ -extern "C" u8 stderr_buff[256]; - -/* 8044D678-8044D778 07A398 0100+00 1/0 0/0 0/0 .bss stdout_buff */ -extern "C" u8 stdout_buff[256]; - -/* 8044D778-8044D878 07A498 0100+00 1/0 0/0 0/0 .bss stdin_buff */ -extern "C" u8 stdin_buff[256]; - -/* 803D29B0-803D2AF0 -00001 0140+00 3/2 15/15 0/0 .data __files */ -SECTION_DATA extern files __files = {{0, - 0x0A800000, - 0, - 0, - 0, - 0, - {0, 0}, - {0, 0}, - 0, - stdin_buff, - 0x00000100, - stdin_buff, - 0, - 0, - 0, - 0, - NULL, - __read_console, - __write_console, - __close_console, - NULL, - &__files.stdout}, - {1, - 0x12800000, - 0, - 0, - 0, - 0, - {0, 0}, - {0, 0}, - 0, - stdout_buff, - 0x00000100, - stdout_buff, - 0, - 0, - 0, - 0, - NULL, - __read_console, - __write_console, - __close_console, - NULL, - &__files.stderr}, - {2, - 0x10800000, - 0, - 0, - 0, - 0, - {0, 0}, - {0, 0}, - 0, - stderr_buff, - 0x00000100, - stderr_buff, - 0, - 0, - 0, - 0, - NULL, - __read_console, - __write_console, - __close_console, - NULL, - &__files.empty}, - {0, 0x00000000, 0, 0, 0, 0, {0, 0}, {0, 0}, - 0, NULL, 0x00000000, NULL, 0, 0, 0, 0, - NULL, NULL, NULL, NULL, NULL, NULL}}; - -/* 8044D578-8044D678 07A298 0100+00 1/0 0/0 0/0 .bss stderr_buff */ -static u8 stderr_buff[256]; - -/* 8044D678-8044D778 07A398 0100+00 1/0 0/0 0/0 .bss stdout_buff */ -static u8 stdout_buff[256]; - -/* 8044D778-8044D878 07A498 0100+00 1/0 0/0 0/0 .bss stdin_buff */ -static u8 stdin_buff[256]; - -/* 8036300C-8036307C 35D94C 0070+00 0/0 2/2 0/0 .text __flush_all */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __flush_all() { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/ansi_files/__flush_all.s" -} -#pragma pop - -/* 8036307C-80363124 35D9BC 00A8+00 0/0 1/1 0/0 .text __close_all */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __close_all() { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/ansi_files/__close_all.s" -} -#pragma pop diff --git a/libs/MSL_C/MSL_Common/Src/arith.cpp b/libs/MSL_C/MSL_Common/Src/arith.c index 41273b24e8..f3833afe37 100644 --- a/libs/MSL_C/MSL_Common/Src/arith.cpp +++ b/libs/MSL_C/MSL_Common/Src/arith.c @@ -11,8 +11,8 @@ // Forward References: // -extern "C" void div(); -extern "C" void abs(); +void div(); +void abs(); // // External References: diff --git a/libs/MSL_C/MSL_Common/Src/buffer_io.cpp b/libs/MSL_C/MSL_Common/Src/buffer_io.c index a74b79c538..fde0e98e1f 100644 --- a/libs/MSL_C/MSL_Common/Src/buffer_io.cpp +++ b/libs/MSL_C/MSL_Common/Src/buffer_io.c @@ -11,8 +11,8 @@ // Forward References: // -extern "C" void __flush_buffer(); -extern "C" void __prep_buffer(); +void __flush_buffer(); +void __prep_buffer(); // // External References: diff --git a/libs/MSL_C/MSL_Common/Src/char_io.cpp b/libs/MSL_C/MSL_Common/Src/char_io.c index 31308c70c2..5fd56198bb 100644 --- a/libs/MSL_C/MSL_Common/Src/char_io.cpp +++ b/libs/MSL_C/MSL_Common/Src/char_io.c @@ -11,19 +11,19 @@ // Forward References: // -extern "C" void __put_char(); +void __put_char(); // // External References: // -extern "C" void __flush_buffer(); -extern "C" void __prep_buffer(); -extern "C" void __end_critical_region(); -extern "C" void __begin_critical_region(); -extern "C" void fseek(); -extern "C" void __stdio_atexit(); -extern "C" void fwide(); +void __flush_buffer(); +void __prep_buffer(); +void __end_critical_region(); +void __begin_critical_region(); +void fseek(); +void __stdio_atexit(); +void fwide(); // // Declarations: diff --git a/libs/MSL_C/MSL_Common/Src/ctype.cpp b/libs/MSL_C/MSL_Common/Src/ctype.c index 1fcc9b0527..beb4563240 100644 --- a/libs/MSL_C/MSL_Common/Src/ctype.cpp +++ b/libs/MSL_C/MSL_Common/Src/ctype.c @@ -11,7 +11,7 @@ // Forward References: // -extern "C" extern u8 __upper_map[256]; +extern unsigned char __upper_map[256]; // // External References: @@ -23,7 +23,7 @@ extern "C" extern u8 __upper_map[256]; /* ############################################################################################## */ /* 803D2C18-803D2D18 02FD38 0100+00 0/0 3/3 0/0 .data __ctype_map */ -SECTION_DATA extern u8 __ctype_map[256] = { +SECTION_DATA extern unsigned char __ctype_map[256] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, @@ -43,7 +43,7 @@ SECTION_DATA extern u8 __ctype_map[256] = { }; /* 803D2D18-803D2E18 02FE38 0100+00 1/1 3/3 0/0 .data __lower_map */ -SECTION_DATA extern u8 __lower_map[256] = { +SECTION_DATA extern unsigned char __lower_map[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, @@ -63,18 +63,19 @@ SECTION_DATA extern u8 __lower_map[256] = { }; /* 80365470-80365494 35FDB0 0024+00 0/0 4/4 0/0 .text tolower */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm int tolower(int) { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/ctype/tolower.s" +int tolower(int __c) { + { + if (__c == -1) { + return 0xffffffff; + } + + return (unsigned int)__lower_map[__c & 0xff]; + } } -#pragma pop /* ############################################################################################## */ /* 803D2E18-803D2F18 02FF38 0100+00 0/0 1/1 0/0 .data __upper_map */ -SECTION_DATA extern u8 __upper_map[256] = { +SECTION_DATA extern unsigned char __upper_map[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, diff --git a/libs/MSL_C/MSL_Common/Src/direct_io.cpp b/libs/MSL_C/MSL_Common/Src/direct_io.c index ab240bccef..47b4141973 100644 --- a/libs/MSL_C/MSL_Common/Src/direct_io.cpp +++ b/libs/MSL_C/MSL_Common/Src/direct_io.c @@ -11,22 +11,22 @@ // Forward References: // -extern "C" void __fwrite(); -extern "C" void fwrite(); +void __fwrite(); +void fwrite(); // // External References: // SECTION_INIT void memcpy(); -extern "C" void __flush_buffer(); -extern "C" void __prep_buffer(); -extern "C" void __end_critical_region(); -extern "C" void __begin_critical_region(); -extern "C" void fseek(); -extern "C" void __memrchr(); -extern "C" void __stdio_atexit(); -extern "C" void fwide(); +void __flush_buffer(); +void __prep_buffer(); +void __end_critical_region(); +void __begin_critical_region(); +void fseek(); +void __memrchr(); +void __stdio_atexit(); +void fwide(); // // Declarations: diff --git a/libs/MSL_C/MSL_Common/Src/errno.c b/libs/MSL_C/MSL_Common/Src/errno.c new file mode 100644 index 0000000000..dca8350e9d --- /dev/null +++ b/libs/MSL_C/MSL_Common/Src/errno.c @@ -0,0 +1,10 @@ +// +// Generated By: dol2asm +// Translation Unit: MSL_Common/Src/errno +// + +#include "errno.h" + +/* ############################################################################################## */ +/* 804519A8-804519B0 000EA8 0004+04 0/0 6/6 0/0 .sbss errno */ +int errno; diff --git a/libs/MSL_C/MSL_Common/Src/errno.cpp b/libs/MSL_C/MSL_Common/Src/errno.cpp deleted file mode 100644 index f96ecd6337..0000000000 --- a/libs/MSL_C/MSL_Common/Src/errno.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: MSL_Common/Src/errno -// - -#include "MSL_C/MSL_Common/Src/errno.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" extern u8 errno[4 + 4 /* padding */]; - -// -// External References: -// - -// -// Declarations: -// - -/* ############################################################################################## */ -/* 804519A8-804519B0 000EA8 0004+04 0/0 6/6 0/0 .sbss errno */ -extern u8 errno[4 + 4 /* padding */]; -u8 errno[4 + 4 /* padding */]; diff --git a/libs/MSL_C/MSL_Common/Src/extras.cpp b/libs/MSL_C/MSL_Common/Src/extras.c index 3d21071532..4fc1b12b31 100644 --- a/libs/MSL_C/MSL_Common/Src/extras.cpp +++ b/libs/MSL_C/MSL_Common/Src/extras.c @@ -11,15 +11,15 @@ // Forward References: // -extern "C" void strnicmp(); -extern "C" void stricmp(); +void strnicmp(); +void stricmp(); // // External References: // -extern "C" void __msl_strnicmp(); -extern "C" extern u8 __lower_map[256]; +void __msl_strnicmp(); +extern u8 __lower_map[256]; // // Declarations: diff --git a/libs/MSL_C/MSL_Common/Src/file_io.cpp b/libs/MSL_C/MSL_Common/Src/file_io.c index 1f78637fa6..332ee0b5a2 100644 --- a/libs/MSL_C/MSL_Common/Src/file_io.cpp +++ b/libs/MSL_C/MSL_Common/Src/file_io.c @@ -11,19 +11,19 @@ // Forward References: // -extern "C" void __msl_strnicmp(); -extern "C" void fflush(); -extern "C" void fclose(); +void __msl_strnicmp(); +void fflush(); +void fclose(); // // External References: // -extern "C" void free(); -extern "C" void __flush_all(); -extern "C" void __flush_buffer(); -extern "C" void ftell(); -extern "C" extern u8 __lower_map[256]; +void free(); +void __flush_all(); +void __flush_buffer(); +void ftell(); +extern u8 __lower_map[256]; // // Declarations: diff --git a/libs/MSL_C/MSL_Common/Src/float.cpp b/libs/MSL_C/MSL_Common/Src/float.c index ec43cf90b4..ac0853bb14 100644 --- a/libs/MSL_C/MSL_Common/Src/float.cpp +++ b/libs/MSL_C/MSL_Common/Src/float.c @@ -11,11 +11,11 @@ // Forward References: // -extern "C" extern u32 __float_nan; -extern "C" extern u32 __float_huge; -extern "C" extern u32 __float_max; -extern "C" extern u32 __float_epsilon; -extern "C" extern f32 data_80450AF0; +extern u32 __float_nan; +extern u32 __float_huge; +extern u32 __float_max; +extern u32 __float_epsilon; +extern f32 data_80450AF0; // // External References: diff --git a/libs/MSL_C/MSL_Common/Src/mbstring.cpp b/libs/MSL_C/MSL_Common/Src/mbstring.c index 9599770fa8..cd9b3e72f6 100644 --- a/libs/MSL_C/MSL_Common/Src/mbstring.cpp +++ b/libs/MSL_C/MSL_Common/Src/mbstring.c @@ -11,13 +11,13 @@ // Forward References: // -extern "C" void wcstombs(); +void wcstombs(); // // External References: // -extern "C" void strncpy(); +void strncpy(); // // Declarations: diff --git a/libs/MSL_C/MSL_Common/Src/mem.c b/libs/MSL_C/MSL_Common/Src/mem.c new file mode 100644 index 0000000000..bdf297797a --- /dev/null +++ b/libs/MSL_C/MSL_Common/Src/mem.c @@ -0,0 +1,124 @@ +// +// Generated By: dol2asm +// Translation Unit: MSL_Common/Src/mem +// + +#include "MSL_C/MSL_Common/Src/mem.h" +#include "dol2asm.h" +#include "dolphin/types.h" + +// +// Forward References: +// + +unsigned char* __memrchr(unsigned char*, unsigned char, size_t); +void* memchr(unsigned char*, int, size_t); +void* memmove(void* dst, const void* src, size_t len); + +// +// External References: +// + +void __copy_longs_rev_unaligned(void* dst, const void* src, size_t len); +void __copy_longs_unaligned(void* dst, const void* src, size_t len); +void __copy_longs_rev_aligned(void* dst, const void* src, size_t len); +void __copy_longs_aligned(void* dst, const void* src, size_t len); + +// +// Declarations: +// + +/* 8036608C-803660D8 3609CC 004C+00 0/0 19/19 5/5 .text memcmp */ +int memcmp(const void* __s1, const void* __s2, size_t __n) { + const unsigned char* val1 = ((const unsigned char*)__s1 - 1); + const unsigned char* val2 = ((const unsigned char*)__s2 - 1); + + size_t size = __n + 1; + while (--size > 0) { + if (*++val1 != *++val2) { + return val1[0] < val2[0] ? -1 : 1; + } + } + + return 0; +} + +/* 803660D8-80366104 360A18 002C+00 0/0 1/1 0/0 .text __memrchr */ +unsigned char* __memrchr(unsigned char* s, unsigned char c, size_t n) { + int n_count; + size_t char_check; + + char_check = (unsigned char)c; + s = &s[n]; + n_count = n + 1; + while (--n_count) { + if (*--s == char_check) { + return s; + } + } + + return NULL; +} + +/* 80366104-80366130 360A44 002C+00 0/0 1/1 0/0 .text memchr */ +void* memchr(unsigned char* s, int c, size_t n) { + int n_count; + size_t char_check; + + char_check = (unsigned char)c; + s = &s[-1]; + n_count = n + 1; + while (--n_count) { + if (*++s == char_check) { + return s; + } + } + + return NULL; +} + +/* 80366130-803661FC 360A70 00CC+00 0/0 2/2 0/0 .text memmove */ +void* memmove(void* dst, const void* src, size_t len) { + unsigned char* csrc; + unsigned char* cdst; + + int reverse = (unsigned int)src < (unsigned int)dst; + + if (len >= 32) { + if (((unsigned int)dst ^ (unsigned int)src) & 3) { + if (!reverse) { + __copy_longs_unaligned(dst, src, len); + } else { + __copy_longs_rev_unaligned(dst, src, len); + } + } else { + if (!reverse) { + __copy_longs_aligned(dst, src, len); + } else { + __copy_longs_rev_aligned(dst, src, len); + } + } + + return dst; + } else { + if (!reverse) { + csrc = ((unsigned char*)src) - 1; + cdst = ((unsigned char*)dst) - 1; + len++; + + while (--len > 0) { + *++cdst = *++csrc; + } + } else { + csrc = (unsigned char*)src + len; + cdst = (unsigned char*)dst + len; + len++; + + while (--len > 0) { + *--cdst = *--csrc; + } + } + } + + return dst; +} diff --git a/libs/MSL_C/MSL_Common/Src/mem.cpp b/libs/MSL_C/MSL_Common/Src/mem.cpp deleted file mode 100644 index 0037ddf0f8..0000000000 --- a/libs/MSL_C/MSL_Common/Src/mem.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: MSL_Common/Src/mem -// - -#include "MSL_C/MSL_Common/Src/mem.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void __memrchr(); -extern "C" void memchr(); -extern "C" void memmove(); - -// -// External References: -// - -extern "C" void __copy_longs_rev_unaligned(); -extern "C" void __copy_longs_unaligned(); -extern "C" void __copy_longs_rev_aligned(); -extern "C" void __copy_longs_aligned(); - -// -// Declarations: -// - -/* 8036608C-803660D8 3609CC 004C+00 0/0 19/19 5/5 .text memcmp */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm int memcmp(const void*, const void*, size_t) { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/mem/memcmp.s" -} -#pragma pop - -/* 803660D8-80366104 360A18 002C+00 0/0 1/1 0/0 .text __memrchr */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __memrchr() { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/mem/__memrchr.s" -} -#pragma pop - -/* 80366104-80366130 360A44 002C+00 0/0 1/1 0/0 .text memchr */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void memchr() { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/mem/memchr.s" -} -#pragma pop - -/* 80366130-803661FC 360A70 00CC+00 0/0 2/2 0/0 .text memmove */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void memmove() { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/mem/memmove.s" -} -#pragma pop diff --git a/libs/MSL_C/MSL_Common/Src/mem_funcs.cpp b/libs/MSL_C/MSL_Common/Src/mem_funcs.c index 8da43ba803..0c3966539f 100644 --- a/libs/MSL_C/MSL_Common/Src/mem_funcs.cpp +++ b/libs/MSL_C/MSL_Common/Src/mem_funcs.c @@ -11,10 +11,10 @@ // Forward References: // -extern "C" void __copy_longs_rev_unaligned(); -extern "C" void __copy_longs_unaligned(); -extern "C" void __copy_longs_rev_aligned(); -extern "C" void __copy_longs_aligned(); +void __copy_longs_rev_unaligned(); +void __copy_longs_unaligned(); +void __copy_longs_rev_aligned(); +void __copy_longs_aligned(); // // External References: diff --git a/libs/MSL_C/MSL_Common/Src/misc_io.cpp b/libs/MSL_C/MSL_Common/Src/misc_io.c index 851de5b75d..9dd9827d9b 100644 --- a/libs/MSL_C/MSL_Common/Src/misc_io.cpp +++ b/libs/MSL_C/MSL_Common/Src/misc_io.c @@ -11,25 +11,20 @@ // Forward References: // -extern "C" void __stdio_atexit(); +void __stdio_atexit(); // // External References: // -extern "C" void __close_all(); -extern "C" extern u8 __stdio_exit[4]; +void __close_all(void); +extern void (*__stdio_exit)(void); // // Declarations: // /* 803664CC-803664DC 360E0C 0010+00 0/0 2/2 0/0 .text __stdio_atexit */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __stdio_atexit() { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/misc_io/__stdio_atexit.s" +void __stdio_atexit() { + __stdio_exit = __close_all; } -#pragma pop diff --git a/libs/MSL_C/MSL_Common/Src/printf.cpp b/libs/MSL_C/MSL_Common/Src/printf.c index 81abda1770..fa801a005a 100644 --- a/libs/MSL_C/MSL_Common/Src/printf.cpp +++ b/libs/MSL_C/MSL_Common/Src/printf.c @@ -12,37 +12,37 @@ // Forward References: // -extern "C" void fprintf(); -extern "C" void __StringWrite(); -extern "C" void __FileWrite(); -extern "C" void __pformatter(); -extern "C" static void float2str(); -extern "C" static void round_decimal(); -extern "C" static void double2hex(); -extern "C" static void longlong2str(); -extern "C" static void long2str(); -extern "C" static void parse_format(); -extern "C" extern char const* const MSL_Common_Src_printf__stringBase0; +void fprintf(); +void __StringWrite(); +void __FileWrite(); +void __pformatter(); +static void float2str(); +static void round_decimal(); +static void double2hex(); +static void longlong2str(); +static void long2str(); +static void parse_format(); +extern char const* const MSL_Common_Src_printf__stringBase0; // // External References: // SECTION_INIT void memcpy(); -extern "C" void __div2u(); -extern "C" void __mod2u(); -extern "C" void __num2dec(); -extern "C" void __end_critical_region(); -extern "C" void __begin_critical_region(); -extern "C" void fwrite(); -extern "C" void wcstombs(); -extern "C" void memchr(); -extern "C" void strchr(); -extern "C" void strcpy(); -extern "C" void strlen(); -extern "C" void fwide(); -extern "C" extern void* __files[80]; -extern "C" extern u8 __ctype_map[256]; +void __div2u(); +void __mod2u(); +void __num2dec(); +void __end_critical_region(); +void __begin_critical_region(); +void fwrite(); +void wcstombs(); +void memchr(); +void strchr(); +void strcpy(); +void strlen(); +void fwide(); +extern void* __files[80]; +extern u8 __ctype_map[256]; // // Declarations: diff --git a/libs/MSL_C/MSL_Common/Src/scanf.cpp b/libs/MSL_C/MSL_Common/Src/scanf.c index 346ecbd077..f3f3fe048f 100644 --- a/libs/MSL_C/MSL_Common/Src/scanf.cpp +++ b/libs/MSL_C/MSL_Common/Src/scanf.c @@ -11,7 +11,7 @@ // Forward References: // -extern "C" void __StringRead(); +void __StringRead(); // // External References: diff --git a/libs/MSL_C/MSL_Common/Src/signal.cpp b/libs/MSL_C/MSL_Common/Src/signal.c index 73ac1de6fa..676d4a5373 100644 --- a/libs/MSL_C/MSL_Common/Src/signal.cpp +++ b/libs/MSL_C/MSL_Common/Src/signal.c @@ -11,15 +11,15 @@ // Forward References: // -extern "C" void raise(); +void raise(); // // External References: // -extern "C" void exit(); -extern "C" void __end_critical_region(); -extern "C" void __begin_critical_region(); +void exit(); +void __end_critical_region(); +void __begin_critical_region(); // // Declarations: diff --git a/libs/MSL_C/MSL_Common/Src/string.c b/libs/MSL_C/MSL_Common/Src/string.c new file mode 100644 index 0000000000..df42867b38 --- /dev/null +++ b/libs/MSL_C/MSL_Common/Src/string.c @@ -0,0 +1,257 @@ +// +// Generated By: dol2asm +// Translation Unit: MSL_Common/Src/string +// + +#include "MSL_C/MSL_Common/Src/string.h" +#include "dol2asm.h" +#include "dolphin/types.h" + +#define K1 0x80808080 +#define K2 0xFEFEFEFF + +// +// Declarations: +// + +/* 803688DC-80368924 36321C 0048+00 0/0 1/1 0/0 .text strrchr */ +char* strrchr(const char* str, int chr) { + const u8* p = (u8*)str - 1; + const u8* q = NULL; + u32 c = (chr & 0xFF); + + u32 ch; + while (ch = *++p) { + if (ch == c) { + q = p; + } + } + + if (q != NULL) { + return (char*)q; + } + + return c ? NULL : (char*)p; +} + +/* 80368924-80368954 363264 0030+00 0/0 3/3 0/0 .text strchr */ +char* strchr(const char* str, int chr) { + const u8* p = (u8*)str - 1; + u32 c = (chr & 0xFF); + + u32 ch; + while (ch = *++p) { + if (ch == c) { + return (char*)p; + } + } + + return c ? NULL : (char*)p; +} + +/* 80368954-80368994 363294 0040+00 0/0 6/6 0/0 .text strncmp */ +int strncmp(const char* strA, const char* strB, u32 n) { + const u8* p1 = (u8*)strA - 1; + const u8* p2 = (u8*)strB - 1; + u32 c1, c2; + + n++; + while (--n) { + if ((c1 = *++p1) != (c2 = *++p2)) { + return c1 - c2; + } else if (c1 == 0) { + break; + } + } + + return 0; +} + +/* 80368994-80368ABC 3632D4 0128+00 0/0 155/155 279/279 .text strcmp */ +int strcmp(const char* strA, const char* strB) { + register u8* left = (u8*)strA; + register u8* right = (u8*)strB; + u32 align, l1, r1, x; + + l1 = *left; + r1 = *right; + if (l1 - r1) { + return l1 - r1; + } + + if ((align = ((int)left & 3)) != ((int)right & 3)) { + goto bytecopy; + } + + if (align) { + if (l1 == 0) { + return 0; + } + for (align = 3 - align; align; align--) { + l1 = *(++left); + r1 = *(++right); + if (l1 - r1) { + return l1 - r1; + } + if (l1 == 0) { + return 0; + } + } + left++; + right++; + } + + l1 = *(int*)left; + r1 = *(int*)right; + x = l1 + K2; + if (x & K1) { + goto adjust; + } + + while (l1 == r1) { + l1 = *(++((int*)(left))); + r1 = *(++((int*)(right))); + x = l1 + K2; + if (x & K1) { + goto adjust; + } + } + + if (l1 > r1) { + return 1; + } + return -1; + +adjust: + l1 = *left; + r1 = *right; + if (l1 - r1) { + return l1 - r1; + } + +bytecopy: + if (l1 == 0) { + return 0; + } + + do { + l1 = *(++left); + r1 = *(++right); + if (l1 - r1) { + return l1 - r1; + } + if (l1 == 0) { + return 0; + } + } while (1); +} + +/* 80368ABC-80368AE8 3633FC 002C+00 0/0 20/20 8/8 .text strcat */ +char* strcat(char* dst, const char* src) { + const u8* p = (u8*)src - 1; + u8* q = (u8*)dst - 1; + + while (*++q) { + } + + q--; + + while (*++q = *++p) { + } + + return dst; +} + +/* 80368AE8-80368B2C 363428 0044+00 0/0 9/9 1/1 .text strncpy */ +char* strncpy(char* dst, const char* src, size_t n) { + const u8* p = (const u8*)src - 1; + u8* q = (u8*)dst - 1; + + n++; + while (--n) { + if (!(*++q = *++p)) { + while (--n) { + *++q = 0; + } + break; + } + } + + return dst; +} + +/* 80368B2C-80368BE4 36346C 00B8+00 0/0 131/131 13/13 .text strcpy */ +char* strcpy(char* dst, const char* src) { + register u8 *destb, *fromb; + register u32 w, t, align; + + fromb = (u8*)src; + destb = (u8*)dst; + + if ((align = ((int)fromb & 3)) != ((int)destb & 3)) { + goto bytecopy; + } + + if (align) { + if ((*destb = *fromb) == 0) { + return dst; + } + + for (align = 3 - align; align; align--) { + if ((*(++destb) = *(++fromb)) == 0) { + return dst; + } + } + ++destb; + ++fromb; + } + + w = *((int*)(fromb)); + + t = w + K2; + + t &= K1; + if (t) { + goto bytecopy; + } + --((int*)(destb)); + + do { + *(++((int*)(destb))) = w; + w = *(++((int*)(fromb))); + + t = w + K2; + t &= K1; + if (t) { + goto adjust; + } + } while (1); + +adjust: + ++((int*)(destb)); + +bytecopy: + if ((*destb = *fromb) == 0) { + return dst; + } + + do { + if ((*(++destb) = *(++fromb)) == 0) { + return dst; + } + } while (1); + + return dst; +} + +/* 80368BE4-80368C00 363524 001C+00 0/0 28/28 8/8 .text strlen */ +u32 strlen(const char* str) { + size_t len = -1; + u8* p = (u8*)str - 1; + + do { + len++; + } while (*++p); + + return len; +} diff --git a/libs/MSL_C/MSL_Common/Src/string.cpp b/libs/MSL_C/MSL_Common/Src/string.cpp deleted file mode 100644 index ce6e6cfbea..0000000000 --- a/libs/MSL_C/MSL_Common/Src/string.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: MSL_Common/Src/string -// - -#include "MSL_C/MSL_Common/Src/string.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// External References: -// - -extern "C" void _epilog(); - -// -// Declarations: -// - -/* 803688DC-80368924 36321C 0048+00 0/0 1/1 0/0 .text strrchr */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm char* strrchr(const char*, int) { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/string/strrchr.s" -} -#pragma pop - -/* 80368924-80368954 363264 0030+00 0/0 3/3 0/0 .text strchr */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm char* strchr(const char*, int) { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/string/strchr.s" -} -#pragma pop - -/* 80368954-80368994 363294 0040+00 0/0 6/6 0/0 .text strncmp */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm int strncmp(const char*, const char*, u32) { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/string/strncmp.s" -} -#pragma pop - -/* 80368994-80368ABC 3632D4 0128+00 0/0 155/155 279/279 .text strcmp */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm int strcmp(const char*, const char*) { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/string/strcmp.s" -} -#pragma pop - -/* 80368ABC-80368AE8 3633FC 002C+00 0/0 20/20 8/8 .text strcat */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm char* strcat(char*, const char*) { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/string/strcat.s" -} -#pragma pop - -/* 80368AE8-80368B2C 363428 0044+00 0/0 9/9 1/1 .text strncpy */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm char* strncpy(char*, const char*, u32) { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/string/strncpy.s" -} -#pragma pop - -/* 80368B2C-80368BE4 36346C 00B8+00 0/0 131/131 13/13 .text strcpy */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm char* strcpy(char*, const char*) { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/string/strcpy.s" -} -#pragma pop - -/* 80368BE4-80368C00 363524 001C+00 0/0 28/28 8/8 .text strlen */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm u32 strlen(const char*) { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/string/strlen.s" -} -#pragma pop diff --git a/libs/MSL_C/MSL_Common/Src/strtoul.cpp b/libs/MSL_C/MSL_Common/Src/strtoul.c index 7ac0c47c61..3cc0b88b90 100644 --- a/libs/MSL_C/MSL_Common/Src/strtoul.cpp +++ b/libs/MSL_C/MSL_Common/Src/strtoul.c @@ -11,18 +11,18 @@ // Forward References: // -extern "C" void strtol(); -extern "C" void strtoul(); -extern "C" void __strtoul(); +void strtol(); +void strtoul(); +void __strtoul(); // // External References: // -extern "C" void __StringRead(); -extern "C" extern u8 __ctype_map[256]; -extern "C" extern u8 __upper_map[256]; -extern "C" extern u8 errno[4 + 4 /* padding */]; +void __StringRead(); +extern u8 __ctype_map[256]; +extern u8 __upper_map[256]; +extern u8 errno[4 + 4 /* padding */]; // // Declarations: diff --git a/libs/MSL_C/MSL_Common/Src/wchar_io.c b/libs/MSL_C/MSL_Common/Src/wchar_io.c new file mode 100644 index 0000000000..f6ac7a3f99 --- /dev/null +++ b/libs/MSL_C/MSL_Common/Src/wchar_io.c @@ -0,0 +1,44 @@ +// +// Generated By: dol2asm +// Translation Unit: MSL_Common/Src/wchar_io +// + +#include "MSL_C/MSL_Common/Src/wchar_io.h" +#include "MSL_C/MSL_Common/Src/ansi_files.h" +#include "dol2asm.h" +#include "dolphin/types.h" + +// +// Forward References: +// + +int fwide(FILE* file, int mode); + +// +// External References: +// + +// +// Declarations: +// + +/* 80369114-8036919C 363A54 0088+00 0/0 5/5 0/0 .text fwide */ +int fwide(FILE* file, int mode) { + if (file == NULL || file->file_mode.file_kind == CLOSED_FILE) { + return 0; + } + + switch (file->file_mode.file_orientation) { + case UNORIENTED: + if (mode > 0) { + file->file_mode.file_orientation = WIDE_ORIENTED; + } else if (mode < 0) { + file->file_mode.file_orientation = CHAR_ORIENTED; + } + return mode; + case WIDE_ORIENTED: + return 1; + case CHAR_ORIENTED: + return -1; + } +} diff --git a/libs/MSL_C/MSL_Common/Src/wchar_io.cpp b/libs/MSL_C/MSL_Common/Src/wchar_io.cpp deleted file mode 100644 index 8e71f35b42..0000000000 --- a/libs/MSL_C/MSL_Common/Src/wchar_io.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: MSL_Common/Src/wchar_io -// - -#include "MSL_C/MSL_Common/Src/wchar_io.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void fwide(); - -// -// External References: -// - -// -// Declarations: -// - -/* 80369114-8036919C 363A54 0088+00 0/0 5/5 0/0 .text fwide */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void fwide() { - nofralloc -#include "asm/MSL_C/MSL_Common/Src/wchar_io/fwide.s" -} -#pragma pop diff --git a/libs/MSL_C/MSL_Common_Embedded/Src/ansi_fp.cpp b/libs/MSL_C/MSL_Common_Embedded/Src/ansi_fp.c index 7dde1664fb..4cdf13f636 100644 --- a/libs/MSL_C/MSL_Common_Embedded/Src/ansi_fp.cpp +++ b/libs/MSL_C/MSL_Common_Embedded/Src/ansi_fp.c @@ -11,22 +11,22 @@ // Forward References: // -extern "C" void __num2dec(); -extern "C" void __num2dec_internal(); -extern "C" void __two_exp(); -extern "C" void __timesdec(); -extern "C" extern char const* const MSL_Common_Embedded_Src_ansi_fp__stringBase0; +void __num2dec(); +void __num2dec_internal(); +void __two_exp(); +void __timesdec(); +extern char const* const MSL_Common_Embedded_Src_ansi_fp__stringBase0; // // External References: // -extern "C" void __div2u(); -extern "C" void __mod2u(); -extern "C" void __cvt_dbl_usll(); -extern "C" void frexp(); -extern "C" void ldexp(); -extern "C" void modf(); +void __div2u(); +void __mod2u(); +void __cvt_dbl_usll(); +void frexp(); +void ldexp(); +void modf(); // // Declarations: diff --git a/libs/MSL_C/Makefile b/libs/MSL_C/Makefile index eda4f12ce3..e5ab9f3fbd 100644 --- a/libs/MSL_C/Makefile +++ b/libs/MSL_C/Makefile @@ -3,62 +3,62 @@ # LIBMSL_C_PPCEABI_BARE_H_A_CPP_FILES := \ - libs/MSL_C/MSL_Common/Src/abort_exit.cpp \ - libs/MSL_C/MSL_Common/Src/alloc.cpp \ - libs/MSL_C/MSL_Common/Src/errno.cpp \ - libs/MSL_C/MSL_Common/Src/ansi_files.cpp \ - libs/MSL_C/MSL_Common_Embedded/Src/ansi_fp.cpp \ - libs/MSL_C/MSL_Common/Src/arith.cpp \ - libs/MSL_C/MSL_Common/Src/buffer_io.cpp \ - libs/MSL_C/MSL_Common/Src/char_io.cpp \ - libs/MSL_C/PPC_EABI/Src/critical_regions.gamecube.cpp \ - libs/MSL_C/MSL_Common/Src/ctype.cpp \ - libs/MSL_C/MSL_Common/Src/direct_io.cpp \ - libs/MSL_C/MSL_Common/Src/file_io.cpp \ - libs/MSL_C/MSL_Common/Src/FILE_POS.cpp \ - libs/MSL_C/MSL_Common/Src/mbstring.cpp \ - libs/MSL_C/MSL_Common/Src/mem.cpp \ - libs/MSL_C/MSL_Common/Src/mem_funcs.cpp \ - libs/MSL_C/MSL_Common/Src/misc_io.cpp \ - libs/MSL_C/MSL_Common/Src/printf.cpp \ - libs/MSL_C/MSL_Common/Src/scanf.cpp \ - libs/MSL_C/MSL_Common/Src/float.cpp \ - libs/MSL_C/MSL_Common/Src/signal.cpp \ - libs/MSL_C/MSL_Common/Src/string.cpp \ - libs/MSL_C/MSL_Common/Src/strtoul.cpp \ - libs/MSL_C/MSL_Common/Src/wchar_io.cpp \ - libs/MSL_C/PPC_EABI/Src/uart_console_io_gcn.cpp \ - libs/MSL_C/Math/Double_precision/e_acos.cpp \ - libs/MSL_C/Math/Double_precision/e_asin.cpp \ - libs/MSL_C/Math/Double_precision/e_atan2.cpp \ - libs/MSL_C/Math/Double_precision/e_exp.cpp \ - libs/MSL_C/Math/Double_precision/e_fmod.cpp \ - libs/MSL_C/Math/Double_precision/e_pow.cpp \ - libs/MSL_C/Math/Double_precision/e_rem_pio2.cpp \ - libs/MSL_C/Math/Double_precision/k_cos.cpp \ - libs/MSL_C/Math/Double_precision/k_rem_pio2.cpp \ - libs/MSL_C/Math/Double_precision/k_sin.cpp \ - libs/MSL_C/Math/Double_precision/k_tan.cpp \ - libs/MSL_C/Math/Double_precision/s_atan.cpp \ - libs/MSL_C/Math/Double_precision/s_ceil.cpp \ - libs/MSL_C/Math/Double_precision/s_copysign.cpp \ - libs/MSL_C/Math/Double_precision/s_cos.cpp \ - libs/MSL_C/Math/Double_precision/s_floor.cpp \ - libs/MSL_C/Math/Double_precision/s_frexp.cpp \ - libs/MSL_C/Math/Double_precision/s_ldexp.cpp \ - libs/MSL_C/Math/Double_precision/s_modf.cpp \ - libs/MSL_C/Math/Double_precision/s_sin.cpp \ - libs/MSL_C/Math/Double_precision/s_tan.cpp \ - libs/MSL_C/Math/Double_precision/w_acos.cpp \ - libs/MSL_C/Math/Double_precision/w_asin.cpp \ - libs/MSL_C/Math/Double_precision/w_atan2.cpp \ - libs/MSL_C/Math/Double_precision/w_exp.cpp \ - libs/MSL_C/Math/Double_precision/w_fmod.cpp \ - libs/MSL_C/Math/Double_precision/w_pow.cpp \ - libs/MSL_C/Math/Double_precision/e_sqrt.cpp \ - libs/MSL_C/PPC_EABI/Src/math_ppc.cpp \ - libs/MSL_C/Math/Double_precision/w_sqrt.cpp \ - libs/MSL_C/MSL_Common/Src/extras.cpp \ + libs/MSL_C/MSL_Common/Src/abort_exit.c \ + libs/MSL_C/MSL_Common/Src/alloc.c \ + libs/MSL_C/MSL_Common/Src/errno.c \ + libs/MSL_C/MSL_Common/Src/ansi_files.c \ + libs/MSL_C/MSL_Common_Embedded/Src/ansi_fp.c \ + libs/MSL_C/MSL_Common/Src/arith.c \ + libs/MSL_C/MSL_Common/Src/buffer_io.c \ + libs/MSL_C/MSL_Common/Src/char_io.c \ + libs/MSL_C/PPC_EABI/Src/critical_regions.gamecube.c \ + libs/MSL_C/MSL_Common/Src/ctype.c \ + libs/MSL_C/MSL_Common/Src/direct_io.c \ + libs/MSL_C/MSL_Common/Src/file_io.c \ + libs/MSL_C/MSL_Common/Src/FILE_POS.c \ + libs/MSL_C/MSL_Common/Src/mbstring.c \ + libs/MSL_C/MSL_Common/Src/mem.c \ + libs/MSL_C/MSL_Common/Src/mem_funcs.c \ + libs/MSL_C/MSL_Common/Src/misc_io.c \ + libs/MSL_C/MSL_Common/Src/printf.c \ + libs/MSL_C/MSL_Common/Src/scanf.c \ + libs/MSL_C/MSL_Common/Src/float.c \ + libs/MSL_C/MSL_Common/Src/signal.c \ + libs/MSL_C/MSL_Common/Src/string.c \ + libs/MSL_C/MSL_Common/Src/strtoul.c \ + libs/MSL_C/MSL_Common/Src/wchar_io.c \ + libs/MSL_C/PPC_EABI/Src/uart_console_io_gcn.c \ + libs/MSL_C/Math/Double_precision/e_acos.c \ + libs/MSL_C/Math/Double_precision/e_asin.c \ + libs/MSL_C/Math/Double_precision/e_atan2.c \ + libs/MSL_C/Math/Double_precision/e_exp.c \ + libs/MSL_C/Math/Double_precision/e_fmod.c \ + libs/MSL_C/Math/Double_precision/e_pow.c \ + libs/MSL_C/Math/Double_precision/e_rem_pio2.c \ + libs/MSL_C/Math/Double_precision/k_cos.c \ + libs/MSL_C/Math/Double_precision/k_rem_pio2.c \ + libs/MSL_C/Math/Double_precision/k_sin.c \ + libs/MSL_C/Math/Double_precision/k_tan.c \ + libs/MSL_C/Math/Double_precision/s_atan.c \ + libs/MSL_C/Math/Double_precision/s_ceil.c \ + libs/MSL_C/Math/Double_precision/s_copysign.c \ + libs/MSL_C/Math/Double_precision/s_cos.c \ + libs/MSL_C/Math/Double_precision/s_floor.c \ + libs/MSL_C/Math/Double_precision/s_frexp.c \ + libs/MSL_C/Math/Double_precision/s_ldexp.c \ + libs/MSL_C/Math/Double_precision/s_modf.c \ + libs/MSL_C/Math/Double_precision/s_sin.c \ + libs/MSL_C/Math/Double_precision/s_tan.c \ + libs/MSL_C/Math/Double_precision/w_acos.c \ + libs/MSL_C/Math/Double_precision/w_asin.c \ + libs/MSL_C/Math/Double_precision/w_atan2.c \ + libs/MSL_C/Math/Double_precision/w_exp.c \ + libs/MSL_C/Math/Double_precision/w_fmod.c \ + libs/MSL_C/Math/Double_precision/w_pow.c \ + libs/MSL_C/Math/Double_precision/e_sqrt.c \ + libs/MSL_C/PPC_EABI/Src/math_ppc.c \ + libs/MSL_C/Math/Double_precision/w_sqrt.c \ + libs/MSL_C/MSL_Common/Src/extras.c \ LIBMSL_C_PPCEABI_BARE_H_A_O_FILES := \ $(BUILD_DIR)/libs/MSL_C/MSL_Common/Src/abort_exit.o \ @@ -119,6 +119,8 @@ LIBMSL_C_PPCEABI_BARE_H_A_O_FILES := \ $(BUILD_DIR)/libs/MSL_C/MSL_Common/Src/extras.o \ LIBMSL_C_PPCEABI_BARE_H_A_CFLAGS := \ + -O4,p \ + -lang=c \ LIBMSL_C_PPCEABI_BARE_H_A_LDFLAGS := \ -nodefaults \ @@ -131,9 +133,9 @@ $(BUILD_DIR)/libMSL_C.a: $(LIBMSL_C_PPCEABI_BARE_H_A_O_FILES) @echo $(LIBMSL_C_PPCEABI_BARE_H_A_O_FILES) > build/LIBMSL_C_PPCEABI_BARE_H_A_ofiles @$(LD) -xm l $(LIBMSL_C_PPCEABI_BARE_H_A_LDFLAGS) -o $(BUILD_DIR)/libMSL_C.a @build/LIBMSL_C_PPCEABI_BARE_H_A_ofiles -$(BUILD_DIR)/libs/MSL_C/%.o: libs/MSL_C/%.cpp +$(BUILD_DIR)/libs/MSL_C/%.o: libs/MSL_C/%.c @mkdir -p $(@D) @echo building... $< - @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).cpp - @$(CC) $(CFLAGS) $(LIBMSL_C_PPCEABI_BARE_H_A_CFLAGS) -c -o $@ $(basename $@).cpp + @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c + @$(CC) $(CFLAGS) $(LIBMSL_C_PPCEABI_BARE_H_A_CFLAGS) -c -o $@ $(basename $@).c diff --git a/libs/MSL_C/Math/Double_precision/e_acos.cpp b/libs/MSL_C/Math/Double_precision/e_acos.c index 49f917ccb1..f23b7f0463 100644 --- a/libs/MSL_C/Math/Double_precision/e_acos.cpp +++ b/libs/MSL_C/Math/Double_precision/e_acos.c @@ -11,14 +11,14 @@ // Forward References: // -extern "C" void __ieee754_acos(); +void __ieee754_acos(); // // External References: // -extern "C" void sqrt(); -extern "C" extern u32 __float_nan; +void sqrt(); +extern u32 __float_nan; // // Declarations: diff --git a/libs/MSL_C/Math/Double_precision/e_asin.cpp b/libs/MSL_C/Math/Double_precision/e_asin.c index 7f601e4c6b..fa5656cf07 100644 --- a/libs/MSL_C/Math/Double_precision/e_asin.cpp +++ b/libs/MSL_C/Math/Double_precision/e_asin.c @@ -11,14 +11,14 @@ // Forward References: // -extern "C" void __ieee754_asin(); +void __ieee754_asin(); // // External References: // -extern "C" void sqrt(); -extern "C" extern u32 __float_nan; +void sqrt(); +extern u32 __float_nan; // // Declarations: diff --git a/libs/MSL_C/Math/Double_precision/e_atan2.cpp b/libs/MSL_C/Math/Double_precision/e_atan2.c index bba40e9696..db6f4e8742 100644 --- a/libs/MSL_C/Math/Double_precision/e_atan2.cpp +++ b/libs/MSL_C/Math/Double_precision/e_atan2.c @@ -11,13 +11,13 @@ // Forward References: // -extern "C" void __ieee754_atan2(); +void __ieee754_atan2(); // // External References: // -extern "C" void atan(); +void atan(); // // Declarations: diff --git a/libs/MSL_C/Math/Double_precision/e_exp.cpp b/libs/MSL_C/Math/Double_precision/e_exp.c index c78a9f7d53..97c162b682 100644 --- a/libs/MSL_C/Math/Double_precision/e_exp.cpp +++ b/libs/MSL_C/Math/Double_precision/e_exp.c @@ -11,7 +11,7 @@ // Forward References: // -extern "C" void __ieee754_exp(); +void __ieee754_exp(); // // External References: diff --git a/libs/MSL_C/Math/Double_precision/e_fmod.c b/libs/MSL_C/Math/Double_precision/e_fmod.c new file mode 100644 index 0000000000..200db3bc97 --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/e_fmod.c @@ -0,0 +1,167 @@ + +/* @(#)e_fmod.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * __ieee754_fmod(x,y) + * Return x mod y in exact arithmetic + * Method: shift and subtract + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +static const double one = 1.0, Zero[] = { + 0.0, + -0.0, +}; +#else +static double one = 1.0, Zero[] = { + 0.0, + -0.0, +}; +#endif + +#ifdef __STDC__ +double __ieee754_fmod(double x, double y) +#else +double __ieee754_fmod(x, y) double x, y; +#endif +{ + int n, hx, hy, hz, ix, iy, sx, i; + unsigned lx, ly, lz; + + hx = __HI(x); /* high word of x */ + lx = __LO(x); /* low word of x */ + hy = __HI(y); /* high word of y */ + ly = __LO(y); /* low word of y */ + sx = hx & 0x80000000; /* sign of x */ + hx ^= sx; /* |x| */ + hy &= 0x7fffffff; /* |y| */ + + /* purge off exception values */ + if ((hy | ly) == 0 || (hx >= 0x7ff00000) || /* y=0,or x not finite */ + ((hy | ((ly | -ly) >> 31)) > 0x7ff00000)) /* or y is NaN */ + return (x * y) / (x * y); + if (hx <= hy) { + if ((hx < hy) || (lx < ly)) + return x; /* |x|<|y| return x */ + if (lx == ly) + return Zero[(unsigned)sx >> 31]; /* |x|=|y| return x*0*/ + } + + /* determine ix = ilogb(x) */ + if (hx < 0x00100000) { /* subnormal x */ + if (hx == 0) { + for (ix = -1043, i = lx; i > 0; i <<= 1) + ix -= 1; + } else { + for (ix = -1022, i = (hx << 11); i > 0; i <<= 1) + ix -= 1; + } + } else + ix = (hx >> 20) - 1023; + + /* determine iy = ilogb(y) */ + if (hy < 0x00100000) { /* subnormal y */ + if (hy == 0) { + for (iy = -1043, i = ly; i > 0; i <<= 1) + iy -= 1; + } else { + for (iy = -1022, i = (hy << 11); i > 0; i <<= 1) + iy -= 1; + } + } else + iy = (hy >> 20) - 1023; + + /* set up {hx,lx}, {hy,ly} and align y to x */ + if (ix >= -1022) + hx = 0x00100000 | (0x000fffff & hx); + else { /* subnormal x, shift x to normal */ + n = -1022 - ix; + if (n <= 31) { + hx = (hx << n) | (lx >> (32 - n)); + lx <<= n; + } else { + hx = lx << (n - 32); + lx = 0; + } + } + if (iy >= -1022) + hy = 0x00100000 | (0x000fffff & hy); + else { /* subnormal y, shift y to normal */ + n = -1022 - iy; + if (n <= 31) { + hy = (hy << n) | (ly >> (32 - n)); + ly <<= n; + } else { + hy = ly << (n - 32); + ly = 0; + } + } + + /* fix point fmod */ + n = ix - iy; + while (n--) { + hz = hx - hy; + lz = lx - ly; + if (lx < ly) + hz -= 1; + if (hz < 0) { + hx = hx + hx + (lx >> 31); + lx = lx + lx; + } else { + if ((hz | lz) == 0) /* return sign(x)*0 */ + return Zero[(unsigned)sx >> 31]; + hx = hz + hz + (lz >> 31); + lx = lz + lz; + } + } + hz = hx - hy; + lz = lx - ly; + if (lx < ly) + hz -= 1; + if (hz >= 0) { + hx = hz; + lx = lz; + } + + /* convert back to floating value and restore the sign */ + if ((hx | lx) == 0) /* return sign(x)*0 */ + return Zero[(unsigned)sx >> 31]; + while (hx < 0x00100000) { /* normalize x */ + hx = hx + hx + (lx >> 31); + lx = lx + lx; + iy -= 1; + } + if (iy >= -1022) { /* normalize output */ + hx = ((hx - 0x00100000) | ((iy + 1023) << 20)); + __HI(x) = hx | sx; + __LO(x) = lx; + } else { /* subnormal output */ + n = -1022 - iy; + if (n <= 20) { + lx = (lx >> n) | ((unsigned)hx << (32 - n)); + hx >>= n; + } else if (n <= 31) { + lx = (hx << (32 - n)) | (lx >> n); + hx = sx; + } else { + lx = hx >> (n - 32); + hx = sx; + } + __HI(x) = hx | sx; + __LO(x) = lx; + x *= one; /* create necessary signal */ + } + return x; /* exact output */ +}
\ No newline at end of file diff --git a/libs/MSL_C/Math/Double_precision/e_fmod.cpp b/libs/MSL_C/Math/Double_precision/e_fmod.cpp deleted file mode 100644 index fc46e25869..0000000000 --- a/libs/MSL_C/Math/Double_precision/e_fmod.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/e_fmod -// - -#include "MSL_C/Math/Double_precision/e_fmod.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void __ieee754_fmod(); - -// -// External References: -// - -// -// Declarations: -// - -/* ############################################################################################## */ -/* 803A2370-803A2380 02E9D0 0010+00 1/1 0/0 0/0 .rodata Zero */ -SECTION_RODATA static u8 const Zero[16] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x803A2370, &Zero); - -/* 80369B9C-80369ED8 3644DC 033C+00 0/0 1/1 0/0 .text __ieee754_fmod */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __ieee754_fmod() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/e_fmod/__ieee754_fmod.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/e_pow.cpp b/libs/MSL_C/Math/Double_precision/e_pow.c index 310be3d34a..77445aff0b 100644 --- a/libs/MSL_C/Math/Double_precision/e_pow.cpp +++ b/libs/MSL_C/Math/Double_precision/e_pow.c @@ -11,16 +11,16 @@ // Forward References: // -extern "C" void __ieee754_pow(); +void __ieee754_pow(); // // External References: // -extern "C" void ldexp(); -extern "C" void sqrt(); -extern "C" extern u32 __float_nan; -extern "C" extern u8 errno[4 + 4 /* padding */]; +void ldexp(); +void sqrt(); +extern u32 __float_nan; +extern u8 errno[4 + 4 /* padding */]; // // Declarations: diff --git a/libs/MSL_C/Math/Double_precision/e_rem_pio2.cpp b/libs/MSL_C/Math/Double_precision/e_rem_pio2.c index d6677ddff1..d2d70f9f87 100644 --- a/libs/MSL_C/Math/Double_precision/e_rem_pio2.cpp +++ b/libs/MSL_C/Math/Double_precision/e_rem_pio2.c @@ -11,13 +11,13 @@ // Forward References: // -extern "C" void __ieee754_rem_pio2(); +void __ieee754_rem_pio2(); // // External References: // -extern "C" void __kernel_rem_pio2(); +void __kernel_rem_pio2(); // // Declarations: diff --git a/libs/MSL_C/Math/Double_precision/e_sqrt.cpp b/libs/MSL_C/Math/Double_precision/e_sqrt.c index a54a115c59..744a175515 100644 --- a/libs/MSL_C/Math/Double_precision/e_sqrt.cpp +++ b/libs/MSL_C/Math/Double_precision/e_sqrt.c @@ -11,14 +11,14 @@ // Forward References: // -extern "C" void __ieee754_sqrt(); +void __ieee754_sqrt(); // // External References: // -extern "C" extern u32 __float_nan; -extern "C" extern u8 errno[4 + 4 /* padding */]; +extern u32 __float_nan; +extern u8 errno[4 + 4 /* padding */]; // // Declarations: diff --git a/libs/MSL_C/Math/Double_precision/k_cos.cpp b/libs/MSL_C/Math/Double_precision/k_cos.c index 8b52238de4..1707287c24 100644 --- a/libs/MSL_C/Math/Double_precision/k_cos.cpp +++ b/libs/MSL_C/Math/Double_precision/k_cos.c @@ -11,7 +11,7 @@ // Forward References: // -extern "C" void __kernel_cos(); +void __kernel_cos(); // // External References: diff --git a/libs/MSL_C/Math/Double_precision/k_rem_pio2.cpp b/libs/MSL_C/Math/Double_precision/k_rem_pio2.c index 7f632503bd..e09d2b995b 100644 --- a/libs/MSL_C/Math/Double_precision/k_rem_pio2.cpp +++ b/libs/MSL_C/Math/Double_precision/k_rem_pio2.c @@ -11,16 +11,16 @@ // Forward References: // -extern "C" void __kernel_rem_pio2(); +void __kernel_rem_pio2(); // // External References: // -extern "C" void _savefpr_25(); -extern "C" void _restfpr_25(); -extern "C" void floor(); -extern "C" void ldexp(); +void _savefpr_25(); +void _restfpr_25(); +void floor(); +void ldexp(); // // Declarations: diff --git a/libs/MSL_C/Math/Double_precision/k_sin.cpp b/libs/MSL_C/Math/Double_precision/k_sin.c index dd1f7021fa..7e4bd136d9 100644 --- a/libs/MSL_C/Math/Double_precision/k_sin.cpp +++ b/libs/MSL_C/Math/Double_precision/k_sin.c @@ -11,7 +11,7 @@ // Forward References: // -extern "C" void __kernel_sin(); +void __kernel_sin(); // // External References: diff --git a/libs/MSL_C/Math/Double_precision/k_tan.cpp b/libs/MSL_C/Math/Double_precision/k_tan.c index d9b04e8f8a..04f0eed1b7 100644 --- a/libs/MSL_C/Math/Double_precision/k_tan.cpp +++ b/libs/MSL_C/Math/Double_precision/k_tan.c @@ -11,7 +11,7 @@ // Forward References: // -extern "C" void __kernel_tan(); +void __kernel_tan(); // // External References: diff --git a/libs/MSL_C/Math/Double_precision/s_atan.cpp b/libs/MSL_C/Math/Double_precision/s_atan.c index 41dbd4859d..f77db189e7 100644 --- a/libs/MSL_C/Math/Double_precision/s_atan.cpp +++ b/libs/MSL_C/Math/Double_precision/s_atan.c @@ -11,7 +11,7 @@ // Forward References: // -extern "C" void atan(); +void atan(); // // External References: diff --git a/libs/MSL_C/Math/Double_precision/s_ceil.c b/libs/MSL_C/Math/Double_precision/s_ceil.c new file mode 100644 index 0000000000..91d3d34734 --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/s_ceil.c @@ -0,0 +1,90 @@ + +/* @(#)s_ceil.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * ceil(x) + * Return x rounded toward -inf to integral value + * Method: + * Bit twiddling. + * Exception: + * Inexact flag raised if x not equal to ceil(x). + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +static const double huge = 1.0e300; +#else +static double huge = 1.0e300; +#endif + +#ifdef __STDC__ +double ceil(double x) +#else +double ceil(x) double x; +#endif +{ + int i0, i1, j0; + unsigned i, j; + i0 = __HI(x); + i1 = __LO(x); + j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + if (j0 < 20) { + if (j0 < 0) { /* raise inexact if x != 0 */ + if (huge + x > 0.0) { /* return 0*sign(x) if |x|<1 */ + if (i0 < 0) { + i0 = 0x80000000; + i1 = 0; + } else if ((i0 | i1) != 0) { + i0 = 0x3ff00000; + i1 = 0; + } + } + } else { + i = (0x000fffff) >> j0; + if (((i0 & i) | i1) == 0) + return x; /* x is integral */ + if (huge + x > 0.0) { /* raise inexact flag */ + if (i0 > 0) + i0 += (0x00100000) >> j0; + i0 &= (~i); + i1 = 0; + } + } + } else if (j0 > 51) { + if (j0 == 0x400) + return x + x; /* inf or NaN */ + else + return x; /* x is integral */ + } else { + i = ((unsigned)(0xffffffff)) >> (j0 - 20); + if ((i1 & i) == 0) + return x; /* x is integral */ + if (huge + x > 0.0) { /* raise inexact flag */ + if (i0 > 0) { + if (j0 == 20) + i0 += 1; + else { + j = i1 + (1 << (52 - j0)); + if (j < i1) + i0 += 1; /* got a carry */ + i1 = j; + } + } + i1 &= (~i); + } + } + __HI(x) = i0; + __LO(x) = i1; + return x; +}
\ No newline at end of file diff --git a/libs/MSL_C/Math/Double_precision/s_ceil.cpp b/libs/MSL_C/Math/Double_precision/s_ceil.cpp deleted file mode 100644 index c93a5506c7..0000000000 --- a/libs/MSL_C/Math/Double_precision/s_ceil.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/s_ceil -// - -#include "MSL_C/Math/Double_precision/s_ceil.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void ceil(); - -// -// External References: -// - -// -// Declarations: -// - -/* ############################################################################################## */ -/* 80456AE0-80456AE8 0050E0 0008+00 1/1 0/0 0/0 .sdata2 @124 */ -SECTION_SDATA2 static f64 lit_124 = 1e+300; - -/* 80456AE8-80456AF0 0050E8 0008+00 1/1 0/0 0/0 .sdata2 @125 */ -SECTION_SDATA2 static u8 lit_125[8] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -/* 8036BEBC-8036C000 3667FC 0144+00 0/0 2/2 0/0 .text ceil */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void ceil() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/s_ceil/ceil.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/s_copysign.c b/libs/MSL_C/Math/Double_precision/s_copysign.c new file mode 100644 index 0000000000..14fd4ae8ce --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/s_copysign.c @@ -0,0 +1,30 @@ + +/* @(#)s_copysign.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * copysign(double x, double y) + * copysign(x,y) returns a value with the magnitude of x and + * with the sign bit of y. + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +double copysign(double x, double y) +#else +double copysign(x, y) double x, y; +#endif +{ + __HI(x) = (__HI(x) & 0x7fffffff) | (__HI(y) & 0x80000000); + return x; +}
\ No newline at end of file diff --git a/libs/MSL_C/Math/Double_precision/s_copysign.cpp b/libs/MSL_C/Math/Double_precision/s_copysign.cpp deleted file mode 100644 index 5e27a452d1..0000000000 --- a/libs/MSL_C/Math/Double_precision/s_copysign.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/s_copysign -// - -#include "MSL_C/Math/Double_precision/s_copysign.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void copysign(); - -// -// External References: -// - -// -// Declarations: -// - -/* 8036C000-8036C028 366940 0028+00 0/0 1/1 0/0 .text copysign */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void copysign() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/s_copysign/copysign.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/s_cos.c b/libs/MSL_C/Math/Double_precision/s_cos.c new file mode 100644 index 0000000000..f1d4d56d18 --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/s_cos.c @@ -0,0 +1,81 @@ +/* @(#)s_cos.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* cos(x) + * Return cosine function of x. + * + * kernel function: + * __kernel_sin ... sine function on [-pi/4,pi/4] + * __kernel_cos ... cosine function on [-pi/4,pi/4] + * __ieee754_rem_pio2 ... argument reduction routine + * + * Method. + * Let S,C and T denote the sin, cos and tan respectively on + * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 + * in [-pi/4 , +pi/4], and let n = k mod 4. + * We have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C T + * 1 C -S -1/T + * 2 -S -C T + * 3 -C S -1/T + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * TRIG(x) returns trig(x) nearly rounded + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +double cos(double x) +#else +double cos(x) double x; +#endif +{ + double y[2], z = 0.0; + int n, ix; + + /* High word of x. */ + ix = __HI(x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if (ix <= 0x3fe921fb) + return __kernel_cos(x, z); + + /* cos(Inf or NaN) is NaN */ + else if (ix >= 0x7ff00000) + return x - x; + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2(x, y); + switch (n & 3) { + case 0: + return __kernel_cos(y[0], y[1]); + case 1: + return -__kernel_sin(y[0], y[1], 1); + case 2: + return -__kernel_cos(y[0], y[1]); + default: + return __kernel_sin(y[0], y[1], 1); + } + } +}
\ No newline at end of file diff --git a/libs/MSL_C/Math/Double_precision/s_cos.cpp b/libs/MSL_C/Math/Double_precision/s_cos.cpp deleted file mode 100644 index f929cfa6dc..0000000000 --- a/libs/MSL_C/Math/Double_precision/s_cos.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/s_cos -// - -#include "MSL_C/Math/Double_precision/s_cos.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void cos(); - -// -// External References: -// - -extern "C" void __ieee754_rem_pio2(); -extern "C" void __kernel_cos(); -extern "C" void __kernel_sin(); - -// -// Declarations: -// - -/* ############################################################################################## */ -/* 80456AF0-80456AF8 0050F0 0008+00 1/1 0/0 0/0 .sdata2 @67 */ -SECTION_SDATA2 static u8 lit_67[8] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -/* 8036C028-8036C0FC 366968 00D4+00 0/0 12/12 0/0 .text cos */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cos() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/s_cos/cos.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/s_floor.c b/libs/MSL_C/Math/Double_precision/s_floor.c new file mode 100644 index 0000000000..3eea609ce3 --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/s_floor.c @@ -0,0 +1,89 @@ + +/* @(#)s_floor.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * floor(x) + * Return x rounded toward -inf to integral value + * Method: + * Bit twiddling. + * Exception: + * Inexact flag raised if x not equal to floor(x). + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +static const double huge = 1.0e300; +#else +static double huge = 1.0e300; +#endif + +#ifdef __STDC__ +double floor(double x) +#else +double floor(x) double x; +#endif +{ + int i0, i1, j0; + unsigned i, j; + i0 = __HI(x); + i1 = __LO(x); + j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + if (j0 < 20) { + if (j0 < 0) { /* raise inexact if x != 0 */ + if (huge + x > 0.0) { /* return 0*sign(x) if |x|<1 */ + if (i0 >= 0) { + i0 = i1 = 0; + } else if (((i0 & 0x7fffffff) | i1) != 0) { + i0 = 0xbff00000; + i1 = 0; + } + } + } else { + i = (0x000fffff) >> j0; + if (((i0 & i) | i1) == 0) + return x; /* x is integral */ + if (huge + x > 0.0) { /* raise inexact flag */ + if (i0 < 0) + i0 += (0x00100000) >> j0; + i0 &= (~i); + i1 = 0; + } + } + } else if (j0 > 51) { + if (j0 == 0x400) + return x + x; /* inf or NaN */ + else + return x; /* x is integral */ + } else { + i = ((unsigned)(0xffffffff)) >> (j0 - 20); + if ((i1 & i) == 0) + return x; /* x is integral */ + if (huge + x > 0.0) { /* raise inexact flag */ + if (i0 < 0) { + if (j0 == 20) + i0 += 1; + else { + j = i1 + (1 << (52 - j0)); + if (j < i1) + i0 += 1; /* got a carry */ + i1 = j; + } + } + i1 &= (~i); + } + } + __HI(x) = i0; + __LO(x) = i1; + return x; +}
\ No newline at end of file diff --git a/libs/MSL_C/Math/Double_precision/s_floor.cpp b/libs/MSL_C/Math/Double_precision/s_floor.cpp deleted file mode 100644 index b18fe98819..0000000000 --- a/libs/MSL_C/Math/Double_precision/s_floor.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/s_floor -// - -#include "MSL_C/Math/Double_precision/s_floor.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void floor(); - -// -// External References: -// - -// -// Declarations: -// - -/* ############################################################################################## */ -/* 80456AF8-80456B00 0050F8 0008+00 1/1 0/0 0/0 .sdata2 @124 */ -SECTION_SDATA2 static f64 lit_124 = 1e+300; - -/* 80456B00-80456B08 005100 0008+00 1/1 0/0 0/0 .sdata2 @125 */ -SECTION_SDATA2 static u8 lit_125[8] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -/* 8036C0FC-8036C244 366A3C 0148+00 0/0 5/5 0/0 .text floor */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void floor() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/s_floor/floor.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/s_frexp.c b/libs/MSL_C/Math/Double_precision/s_frexp.c new file mode 100644 index 0000000000..48bcbf21ed --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/s_frexp.c @@ -0,0 +1,57 @@ + +/* @(#)s_frexp.c 1.4 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * for non-zero x + * x = frexp(arg,&exp); + * return a double fp quantity x such that 0.5 <= |x| <1.0 + * and the corresponding binary exponent "exp". That is + * arg = x*2^exp. + * If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg + * with *exp=0. + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +static const double +#else +static double +#endif + two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ + +#ifdef __STDC__ +double frexp(double x, int* eptr) +#else +double frexp(x, eptr) double x; +int* eptr; +#endif +{ + int hx, ix, lx; + hx = __HI(x); + ix = 0x7fffffff & hx; + lx = __LO(x); + *eptr = 0; + if (ix >= 0x7ff00000 || ((ix | lx) == 0)) + return x; /* 0,inf,nan */ + if (ix < 0x00100000) { /* subnormal */ + x *= two54; + hx = __HI(x); + ix = hx & 0x7fffffff; + *eptr = -54; + } + *eptr += (ix >> 20) - 1022; + hx = (hx & 0x800fffff) | 0x3fe00000; + __HI(x) = hx; + return x; +}
\ No newline at end of file diff --git a/libs/MSL_C/Math/Double_precision/s_frexp.cpp b/libs/MSL_C/Math/Double_precision/s_frexp.cpp deleted file mode 100644 index f9ddfc6865..0000000000 --- a/libs/MSL_C/Math/Double_precision/s_frexp.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/s_frexp -// - -#include "MSL_C/Math/Double_precision/s_frexp.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void frexp(); - -// -// External References: -// - -// -// Declarations: -// - -/* ############################################################################################## */ -/* 80456B08-80456B10 005108 0008+00 1/1 0/0 0/0 .sdata2 @57 */ -SECTION_SDATA2 static f64 lit_57 = 1.8014398509481984e+16; - -/* 8036C244-8036C2D0 366B84 008C+00 0/0 1/1 0/0 .text frexp */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void frexp() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/s_frexp/frexp.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/s_ldexp.cpp b/libs/MSL_C/Math/Double_precision/s_ldexp.c index 6f99499ba6..11de93eec0 100644 --- a/libs/MSL_C/Math/Double_precision/s_ldexp.cpp +++ b/libs/MSL_C/Math/Double_precision/s_ldexp.c @@ -11,13 +11,13 @@ // Forward References: // -extern "C" void ldexp(); +void ldexp(); // // External References: // -extern "C" void copysign(); +void copysign(); // // Declarations: diff --git a/libs/MSL_C/Math/Double_precision/s_modf.c b/libs/MSL_C/Math/Double_precision/s_modf.c new file mode 100644 index 0000000000..63357bb06a --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/s_modf.c @@ -0,0 +1,79 @@ + +/* @(#)s_modf.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * modf(double x, double *iptr) + * return fraction part of x, and return x's integral part in *iptr. + * Method: + * Bit twiddling. + * + * Exception: + * No exception. + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +static const double one = 1.0; +#else +static double one = 1.0; +#endif + +#ifdef __STDC__ +double modf(double x, double* iptr) +#else +double modf(x, iptr) double x, *iptr; +#endif +{ + int i0, i1, j0; + unsigned i; + i0 = __HI(x); /* high x */ + i1 = __LO(x); /* low x */ + j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; /* exponent of x */ + if (j0 < 20) { /* integer part in high x */ + if (j0 < 0) { /* |x|<1 */ + __HIp(iptr) = i0 & 0x80000000; + __LOp(iptr) = 0; /* *iptr = +-0 */ + return x; + } else { + i = (0x000fffff) >> j0; + if (((i0 & i) | i1) == 0) { /* x is integral */ + *iptr = x; + __HI(x) &= 0x80000000; + __LO(x) = 0; /* return +-0 */ + return x; + } else { + __HIp(iptr) = i0 & (~i); + __LOp(iptr) = 0; + return x - *iptr; + } + } + } else if (j0 > 51) { /* no fraction part */ + *iptr = x * one; + __HI(x) &= 0x80000000; + __LO(x) = 0; /* return +-0 */ + return x; + } else { /* fraction part in low x */ + i = ((unsigned)(0xffffffff)) >> (j0 - 20); + if ((i1 & i) == 0) { /* x is integral */ + *iptr = x; + __HI(x) &= 0x80000000; + __LO(x) = 0; /* return +-0 */ + return x; + } else { + __HIp(iptr) = i0; + __LOp(iptr) = i1 & (~i); + return x - *iptr; + } + } +}
\ No newline at end of file diff --git a/libs/MSL_C/Math/Double_precision/s_modf.cpp b/libs/MSL_C/Math/Double_precision/s_modf.cpp deleted file mode 100644 index 00348526db..0000000000 --- a/libs/MSL_C/Math/Double_precision/s_modf.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/s_modf -// - -#include "MSL_C/Math/Double_precision/s_modf.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void modf(); - -// -// External References: -// - -// -// Declarations: -// - -/* 8036C494-8036C590 366DD4 00FC+00 0/0 1/1 0/0 .text modf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void modf() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/s_modf/modf.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/s_sin.c b/libs/MSL_C/Math/Double_precision/s_sin.c new file mode 100644 index 0000000000..b2ba68868b --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/s_sin.c @@ -0,0 +1,82 @@ + +/* @(#)s_sin.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* sin(x) + * Return sine function of x. + * + * kernel function: + * __kernel_sin ... sine function on [-pi/4,pi/4] + * __kernel_cos ... cose function on [-pi/4,pi/4] + * __ieee754_rem_pio2 ... argument reduction routine + * + * Method. + * Let S,C and T denote the sin, cos and tan respectively on + * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 + * in [-pi/4 , +pi/4], and let n = k mod 4. + * We have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C T + * 1 C -S -1/T + * 2 -S -C T + * 3 -C S -1/T + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * TRIG(x) returns trig(x) nearly rounded + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +double sin(double x) +#else +double sin(x) double x; +#endif +{ + double y[2], z = 0.0; + int n, ix; + + /* High word of x. */ + ix = __HI(x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if (ix <= 0x3fe921fb) + return __kernel_sin(x, z, 0); + + /* sin(Inf or NaN) is NaN */ + else if (ix >= 0x7ff00000) + return x - x; + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2(x, y); + switch (n & 3) { + case 0: + return __kernel_sin(y[0], y[1], 1); + case 1: + return __kernel_cos(y[0], y[1]); + case 2: + return -__kernel_sin(y[0], y[1], 1); + default: + return -__kernel_cos(y[0], y[1]); + } + } +}
\ No newline at end of file diff --git a/libs/MSL_C/Math/Double_precision/s_sin.cpp b/libs/MSL_C/Math/Double_precision/s_sin.cpp deleted file mode 100644 index 516f21184a..0000000000 --- a/libs/MSL_C/Math/Double_precision/s_sin.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/s_sin -// - -#include "MSL_C/Math/Double_precision/s_sin.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void sin(); - -// -// External References: -// - -extern "C" void __ieee754_rem_pio2(); -extern "C" void __kernel_cos(); -extern "C" void __kernel_sin(); - -// -// Declarations: -// - -/* ############################################################################################## */ -/* 80456B38-80456B40 005138 0008+00 1/1 0/0 0/0 .sdata2 @67 */ -SECTION_SDATA2 static u8 lit_67[8] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -/* 8036C590-8036C668 366ED0 00D8+00 0/0 11/11 2/2 .text sin */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void sin() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/s_sin/sin.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/s_tan.c b/libs/MSL_C/Math/Double_precision/s_tan.c new file mode 100644 index 0000000000..77d77a18af --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/s_tan.c @@ -0,0 +1,73 @@ + +/* @(#)s_tan.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* tan(x) + * Return tangent function of x. + * + * kernel function: + * __kernel_tan ... tangent function on [-pi/4,pi/4] + * __ieee754_rem_pio2 ... argument reduction routine + * + * Method. + * Let S,C and T denote the sin, cos and tan respectively on + * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 + * in [-pi/4 , +pi/4], and let n = k mod 4. + * We have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C T + * 1 C -S -1/T + * 2 -S -C T + * 3 -C S -1/T + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * TRIG(x) returns trig(x) nearly rounded + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +double tan(double x) +#else +double tan(x) double x; +#endif +{ + double y[2], z = 0.0; + int n, ix; + + /* High word of x. */ + ix = __HI(x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if (ix <= 0x3fe921fb) + return __kernel_tan(x, z, 1); + + /* tan(Inf or NaN) is NaN */ + else if (ix >= 0x7ff00000) + return x - x; /* NaN */ + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2(x, y); + return __kernel_tan(y[0], y[1], 1 - ((n & 1) << 1)); /* 1 -- n even + -1 -- n odd */ + } +}
\ No newline at end of file diff --git a/libs/MSL_C/Math/Double_precision/s_tan.cpp b/libs/MSL_C/Math/Double_precision/s_tan.cpp deleted file mode 100644 index 9542b030cb..0000000000 --- a/libs/MSL_C/Math/Double_precision/s_tan.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/s_tan -// - -#include "MSL_C/Math/Double_precision/s_tan.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void tan(); - -// -// External References: -// - -extern "C" void __ieee754_rem_pio2(); -extern "C" void __kernel_tan(); - -// -// Declarations: -// - -/* ############################################################################################## */ -/* 80456B40-80456B48 005140 0008+00 1/1 0/0 0/0 .sdata2 @58 */ -SECTION_SDATA2 static u8 lit_58[8] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -/* 8036C668-8036C6E0 366FA8 0078+00 0/0 7/7 4/4 .text tan */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void tan() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/s_tan/tan.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/w_acos.c b/libs/MSL_C/Math/Double_precision/w_acos.c new file mode 100644 index 0000000000..a6c331a101 --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/w_acos.c @@ -0,0 +1,6 @@ +#include "fdlibm.h" + +/* 8036C6E0-8036C700 367020 0020+00 0/0 2/2 3/3 .text acos */ +double acos(double x) { + return __ieee754_acos(x); +}
\ No newline at end of file diff --git a/libs/MSL_C/Math/Double_precision/w_acos.cpp b/libs/MSL_C/Math/Double_precision/w_acos.cpp deleted file mode 100644 index 7108ae082c..0000000000 --- a/libs/MSL_C/Math/Double_precision/w_acos.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/w_acos -// - -#include "MSL_C/Math/Double_precision/w_acos.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void acos(); - -// -// External References: -// - -extern "C" void __ieee754_acos(); - -// -// Declarations: -// - -/* 8036C6E0-8036C700 367020 0020+00 0/0 2/2 3/3 .text acos */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void acos() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/w_acos/acos.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/w_asin.c b/libs/MSL_C/Math/Double_precision/w_asin.c new file mode 100644 index 0000000000..aa43f56c05 --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/w_asin.c @@ -0,0 +1,6 @@ +#include "fdlibm.h" + +/* 8036C700-8036C720 367040 0020+00 0/0 2/2 0/0 .text asin */ +double asin(double x) { + return __ieee754_asin(x); +} diff --git a/libs/MSL_C/Math/Double_precision/w_asin.cpp b/libs/MSL_C/Math/Double_precision/w_asin.cpp deleted file mode 100644 index ae7db8510e..0000000000 --- a/libs/MSL_C/Math/Double_precision/w_asin.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/w_asin -// - -#include "MSL_C/Math/Double_precision/w_asin.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void asin(); - -// -// External References: -// - -extern "C" void __ieee754_asin(); - -// -// Declarations: -// - -/* 8036C700-8036C720 367040 0020+00 0/0 2/2 0/0 .text asin */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void asin() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/w_asin/asin.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/w_atan2.c b/libs/MSL_C/Math/Double_precision/w_atan2.c new file mode 100644 index 0000000000..8a2dd2ec73 --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/w_atan2.c @@ -0,0 +1,6 @@ +#include "fdlibm.h" + +/* 8036C720-8036C740 367060 0020+00 0/0 6/6 0/0 .text atan2 */ +double atan2(double x, double y) { + return __ieee754_atan2(x, y); +}
\ No newline at end of file diff --git a/libs/MSL_C/Math/Double_precision/w_atan2.cpp b/libs/MSL_C/Math/Double_precision/w_atan2.cpp deleted file mode 100644 index 4e97e2cfab..0000000000 --- a/libs/MSL_C/Math/Double_precision/w_atan2.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/w_atan2 -// - -#include "MSL_C/Math/Double_precision/w_atan2.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void atan2(); - -// -// External References: -// - -extern "C" void __ieee754_atan2(); - -// -// Declarations: -// - -/* 8036C720-8036C740 367060 0020+00 0/0 6/6 0/0 .text atan2 */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void atan2() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/w_atan2/atan2.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/w_exp.c b/libs/MSL_C/Math/Double_precision/w_exp.c new file mode 100644 index 0000000000..ea32cb9e1e --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/w_exp.c @@ -0,0 +1,6 @@ +#include "fdlibm.h" + +/* 8036C740-8036C760 367080 0020+00 0/0 1/1 0/0 .text exp */ +double exp(double x) { + return __ieee754_exp(x); +} diff --git a/libs/MSL_C/Math/Double_precision/w_exp.cpp b/libs/MSL_C/Math/Double_precision/w_exp.cpp deleted file mode 100644 index 13e6c78b57..0000000000 --- a/libs/MSL_C/Math/Double_precision/w_exp.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/w_exp -// - -#include "MSL_C/Math/Double_precision/w_exp.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void exp(); - -// -// External References: -// - -extern "C" void __ieee754_exp(); - -// -// Declarations: -// - -/* 8036C740-8036C760 367080 0020+00 0/0 1/1 0/0 .text exp */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void exp() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/w_exp/exp.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/w_fmod.c b/libs/MSL_C/Math/Double_precision/w_fmod.c new file mode 100644 index 0000000000..2d24fd1534 --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/w_fmod.c @@ -0,0 +1,6 @@ +#include "fdlibm.h" + +/* 8036C760-8036C780 3670A0 0020+00 0/0 8/8 0/0 .text fmod */ +double fmod(double x, double y) { + return __ieee754_fmod(x, y); +} diff --git a/libs/MSL_C/Math/Double_precision/w_fmod.cpp b/libs/MSL_C/Math/Double_precision/w_fmod.cpp deleted file mode 100644 index adf0b076ea..0000000000 --- a/libs/MSL_C/Math/Double_precision/w_fmod.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/w_fmod -// - -#include "MSL_C/Math/Double_precision/w_fmod.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void fmod(); - -// -// External References: -// - -extern "C" void __ieee754_fmod(); - -// -// Declarations: -// - -/* 8036C760-8036C780 3670A0 0020+00 0/0 8/8 0/0 .text fmod */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void fmod() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/w_fmod/fmod.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/w_pow.c b/libs/MSL_C/Math/Double_precision/w_pow.c new file mode 100644 index 0000000000..8dac75e354 --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/w_pow.c @@ -0,0 +1,6 @@ +#include "fdlibm.h" + +/* 8036C780-8036C7A0 3670C0 0020+00 0/0 3/3 24/24 .text pow */ +double pow(double x, double y) { + return __ieee754_pow(x, y); +} diff --git a/libs/MSL_C/Math/Double_precision/w_pow.cpp b/libs/MSL_C/Math/Double_precision/w_pow.cpp deleted file mode 100644 index 7d05a7cdec..0000000000 --- a/libs/MSL_C/Math/Double_precision/w_pow.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/w_pow -// - -#include "MSL_C/Math/Double_precision/w_pow.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void pow(); - -// -// External References: -// - -extern "C" void __ieee754_pow(); - -// -// Declarations: -// - -/* 8036C780-8036C7A0 3670C0 0020+00 0/0 3/3 24/24 .text pow */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void pow() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/w_pow/pow.s" -} -#pragma pop diff --git a/libs/MSL_C/Math/Double_precision/w_sqrt.c b/libs/MSL_C/Math/Double_precision/w_sqrt.c new file mode 100644 index 0000000000..b455656983 --- /dev/null +++ b/libs/MSL_C/Math/Double_precision/w_sqrt.c @@ -0,0 +1,6 @@ +#include "fdlibm.h" + +/* 8036CA54-8036CA74 367394 0020+00 0/0 8/8 1/1 .text sqrt */ +double sqrt(double x) { + return __ieee754_sqrt(x); +} diff --git a/libs/MSL_C/Math/Double_precision/w_sqrt.cpp b/libs/MSL_C/Math/Double_precision/w_sqrt.cpp deleted file mode 100644 index 64d3d13687..0000000000 --- a/libs/MSL_C/Math/Double_precision/w_sqrt.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: Math/Double_precision/w_sqrt -// - -#include "MSL_C/Math/Double_precision/w_sqrt.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void sqrt(); - -// -// External References: -// - -extern "C" void __ieee754_sqrt(); - -// -// Declarations: -// - -/* 8036CA54-8036CA74 367394 0020+00 0/0 8/8 1/1 .text sqrt */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void sqrt() { - nofralloc -#include "asm/MSL_C/Math/Double_precision/w_sqrt/sqrt.s" -} -#pragma pop diff --git a/libs/MSL_C/PPC_EABI/Src/critical_regions.gamecube.cpp b/libs/MSL_C/PPC_EABI/Src/critical_regions.gamecube.c index 4a39451328..4d4a55a2d7 100644 --- a/libs/MSL_C/PPC_EABI/Src/critical_regions.gamecube.cpp +++ b/libs/MSL_C/PPC_EABI/Src/critical_regions.gamecube.c @@ -11,9 +11,9 @@ // Forward References: // -extern "C" void __end_critical_region(); -extern "C" void __begin_critical_region(); -extern "C" void __kill_critical_regions(); +void __end_critical_region(); +void __begin_critical_region(); +void __kill_critical_regions(); // // External References: diff --git a/libs/MSL_C/PPC_EABI/Src/math_ppc.c b/libs/MSL_C/PPC_EABI/Src/math_ppc.c new file mode 100644 index 0000000000..b969b12967 --- /dev/null +++ b/libs/MSL_C/PPC_EABI/Src/math_ppc.c @@ -0,0 +1,42 @@ +// +// Generated By: dol2asm +// Translation Unit: PPC_EABI/Src/math_ppc +// + +#include "MSL_C/PPC_EABI/Src/math_ppc.h" +#include "dol2asm.h" +#include "dolphin/types.h" +#include "fdlibm.h" + +// +// Forward References: +// + +float tanf(float); +float sinf(float); +float cosf(float); +float acosf(float); + +// +// Declarations: +// + +/* 8036C9C4-8036C9E8 367304 0024+00 0/0 2/2 0/0 .text tanf */ +float tanf(float x) { + return tan(x); +} + +/* 8036C9E8-8036CA0C 367328 0024+00 0/0 4/4 0/0 .text sinf */ +float sinf(float x) { + return sin(x); +} + +/* 8036CA0C-8036CA30 36734C 0024+00 0/0 4/4 0/0 .text cosf */ +float cosf(float x) { + return cos(x); +} + +/* 8036CA30-8036CA54 367370 0024+00 0/0 1/1 0/0 .text acosf */ +float acosf(float x) { + return acos(x); +} diff --git a/libs/MSL_C/PPC_EABI/Src/math_ppc.cpp b/libs/MSL_C/PPC_EABI/Src/math_ppc.cpp deleted file mode 100644 index 0341e41502..0000000000 --- a/libs/MSL_C/PPC_EABI/Src/math_ppc.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: PPC_EABI/Src/math_ppc -// - -#include "MSL_C/PPC_EABI/Src/math_ppc.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" void tanf(); -extern "C" void sinf(); -extern "C" void cosf(); -extern "C" void acosf(); - -// -// External References: -// - -extern "C" void cos(); -extern "C" void sin(); -extern "C" void tan(); -extern "C" void acos(); - -// -// Declarations: -// - -/* 8036C9C4-8036C9E8 367304 0024+00 0/0 2/2 0/0 .text tanf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void tanf() { - nofralloc -#include "asm/MSL_C/PPC_EABI/Src/math_ppc/tanf.s" -} -#pragma pop - -/* 8036C9E8-8036CA0C 367328 0024+00 0/0 4/4 0/0 .text sinf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void sinf() { - nofralloc -#include "asm/MSL_C/PPC_EABI/Src/math_ppc/sinf.s" -} -#pragma pop - -/* 8036CA0C-8036CA30 36734C 0024+00 0/0 4/4 0/0 .text cosf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cosf() { - nofralloc -#include "asm/MSL_C/PPC_EABI/Src/math_ppc/cosf.s" -} -#pragma pop - -/* 8036CA30-8036CA54 367370 0024+00 0/0 1/1 0/0 .text acosf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void acosf() { - nofralloc -#include "asm/MSL_C/PPC_EABI/Src/math_ppc/acosf.s" -} -#pragma pop diff --git a/libs/MSL_C/PPC_EABI/Src/uart_console_io_gcn.c b/libs/MSL_C/PPC_EABI/Src/uart_console_io_gcn.c new file mode 100644 index 0000000000..89458682ff --- /dev/null +++ b/libs/MSL_C/PPC_EABI/Src/uart_console_io_gcn.c @@ -0,0 +1,61 @@ +// +// Generated By: dol2asm +// Translation Unit: PPC_EABI/Src/uart_console_io_gcn +// + +#include "MSL_C/PPC_EABI/Src/uart_console_io_gcn.h" +#include "dol2asm.h" +#include "dolphin/types.h" + +// +// Forward References: +// + +int __close_console(); +int __write_console(s32 arg0, s32 arg1, s32* arg2, s32 arg3); + +// +// External References: +// + +s32 OSGetConsoleType(void); +s32 InitializeUART(u32); +s32 WriteUARTN(s32, s32); +s32 __TRK_write_console(s32, s32, s32*, s32); + +// +// Declarations: +// + +/* 8036919C-803691A4 363ADC 0008+00 0/0 1/0 0/0 .text __close_console */ +int __close_console() { + return 0; +} + +/* 803691A4-80369274 363AE4 00D0+00 0/0 1/0 0/0 .text __write_console */ +int __write_console(s32 param_0, s32 param_1, s32* param_2, s32 param_3) { + static int initialized; + + if ((OSGetConsoleType() & 0x20000000) == 0) { + int uart_init = 0; + if (initialized == FALSE) { + uart_init = InitializeUART(0xE100); + + if (uart_init == 0) { + initialized = 1; + } + } + + if (uart_init != 0) { + return 1; + } + + if (WriteUARTN(param_1, *param_2) != 0) { + *param_2 = 0; + return 1; + } + } + + __TRK_write_console(param_0, param_1, param_2, param_3); + return 0; +} diff --git a/libs/MSL_C/PPC_EABI/Src/uart_console_io_gcn.cpp b/libs/MSL_C/PPC_EABI/Src/uart_console_io_gcn.cpp deleted file mode 100644 index 0309c70886..0000000000 --- a/libs/MSL_C/PPC_EABI/Src/uart_console_io_gcn.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// -// Generated By: dol2asm -// Translation Unit: PPC_EABI/Src/uart_console_io_gcn -// - -#include "MSL_C/PPC_EABI/Src/uart_console_io_gcn.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Forward References: -// - -extern "C" bool __close_console(); -extern "C" void __write_console(); - -// -// External References: -// - -extern "C" void OSGetConsoleType(); -extern "C" void InitializeUART(); -extern "C" void WriteUARTN(); -extern "C" void __TRK_write_console(); - -// -// Declarations: -// - -/* 8036919C-803691A4 363ADC 0008+00 0/0 1/0 0/0 .text __close_console */ -bool __close_console() { - return false; -} - -/* ############################################################################################## */ -/* 804519B0-804519B8 000EB0 0004+04 1/1 0/0 0/0 .sbss initialized$60 */ -static u8 initialized[4 + 4 /* padding */]; - -/* 803691A4-80369274 363AE4 00D0+00 0/0 1/0 0/0 .text __write_console */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __write_console() { - nofralloc -#include "asm/MSL_C/PPC_EABI/Src/uart_console_io_gcn/__write_console.s" -} -#pragma pop |
