diff --git a/include/types.h b/include/types.h index b10a917e1..2d819a80e 100644 --- a/include/types.h +++ b/include/types.h @@ -83,7 +83,6 @@ typedef wchar_t wint_t; #define TRUE 1 #define FALSE 0 -#define nullptr 0 #define null 0 #ifndef NULL diff --git a/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/FILE_POS.C b/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/FILE_POS.C index b4b6d28d2..5abd23c4c 100644 --- a/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/FILE_POS.C +++ b/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/FILE_POS.C @@ -15,27 +15,29 @@ int _ftell(FILE* file) { - int charsInUndoBuffer = 0; - int position; + int charsInUndoBuffer = 0; + int position; - u8 tmp_kind = file->mMode.file_kind; - if (!(tmp_kind == __disk_file || tmp_kind == __console_file) || file->mState.error) { - errno = 0x28; - return -1; - } + u8 tmp_kind = file->mMode.file_kind; + if (!(tmp_kind == __disk_file || tmp_kind == __console_file) || file->mState.error) + { + errno = 0x28; + return -1; + } - if (file->mState.io_state == __neutral) - return (file->mPosition); + if (file->mState.io_state == __neutral) + return (file->mPosition); - position = file->mBufferPosition + (file->mBufferPtr - file->mBuffer); + position = file->mBufferPosition + (file->mBufferPtr - file->mBuffer); - if (file->mState.io_state >= __rereading) { - charsInUndoBuffer = file->mState.io_state - __rereading + 1; - position -= charsInUndoBuffer; - } + if (file->mState.io_state >= __rereading) + { + charsInUndoBuffer = file->mState.io_state - __rereading + 1; + position -= charsInUndoBuffer; + } - // got added in later it seems? - /*if (!file->mMode.binary_io) { + // got added in later it seems? + /*if (!file->mMode.binary_io) { int n = file->mBufferPtr - file->mBuffer - charsInUndoBuffer; u8* p = (u8*)file->mBuffer; @@ -44,87 +46,99 @@ int _ftell(FILE* file) position++; }*/ - return (position); + return (position); } int ftell(FILE* stream) { - int retval; + int retval; - __begin_critical_region(stdin_access); - retval = (long)_ftell(stream); - __end_critical_region(stdin_access); - return retval; + __begin_critical_region(stdin_access); + retval = (long)_ftell(stream); + __end_critical_region(stdin_access); + return retval; } -int _fseek(FILE *file, fpos_t offset, int whence) +int _fseek(FILE* file, fpos_t offset, int whence) { - fpos_t pos; - __pos_proc func; - - unsigned char fileKind = file->mMode.file_kind; - if (fileKind != 1 || file->mState.error != 0) { - errno = 0x28; - return -1; - } - - if (file->mState.io_state == 1) { - if (__flush_buffer(file, nullptr) != 0) { - file->mState.error = 1; - file->mBufferLength = 0; - errno = 0x28; - return -1; - } - } - - if (whence == SEEK_CUR) { - whence = SEEK_SET; - - if ((pos = _ftell(file)) < 0) - pos = 0; - - offset += pos; - } - - if ((whence != SEEK_END) && (file->mMode.io_mode != 3) && (file->mState.io_state == 2 || file->mState.io_state == 3)) { - if ((offset >= file->mPosition) || !(offset >= file->mBufferPosition)) { - file->mState.io_state = 0; - } else { - file->mBufferPtr = file->mBuffer + (offset - file->mBufferPosition); - file->mBufferLength = file->mPosition - offset; - file->mState.io_state = 2; - } - } else { - file->mState.io_state = 0; - } - - if (file->mState.io_state == 0) { - - if ((func = file->positionFunc) != nullptr && func(file->mHandle, &offset, whence, file->ref_con) != 0) - { - file->mState.error = 1; - file->mBufferLength = 0; - errno = 0x28; - return -1; - } - else - { - file->mState.eof = 0; - file->mPosition = offset; - file->mBufferLength = 0; - } - } - - return 0; + fpos_t pos; + __pos_proc func; + + unsigned char fileKind = file->mMode.file_kind; + if (fileKind != 1 || file->mState.error != 0) + { + errno = 0x28; + return -1; + } + + if (file->mState.io_state == 1) + { + if (__flush_buffer(file, NULL) != 0) + { + file->mState.error = 1; + file->mBufferLength = 0; + errno = 0x28; + return -1; + } + } + + if (whence == SEEK_CUR) + { + whence = SEEK_SET; + + if ((pos = _ftell(file)) < 0) + pos = 0; + + offset += pos; + } + + if ((whence != SEEK_END) && (file->mMode.io_mode != 3) && + (file->mState.io_state == 2 || file->mState.io_state == 3)) + { + if ((offset >= file->mPosition) || !(offset >= file->mBufferPosition)) + { + file->mState.io_state = 0; + } + else + { + file->mBufferPtr = file->mBuffer + (offset - file->mBufferPosition); + file->mBufferLength = file->mPosition - offset; + file->mState.io_state = 2; + } + } + else + { + file->mState.io_state = 0; + } + + if (file->mState.io_state == 0) + { + if ((func = file->positionFunc) != NULL && + func(file->mHandle, &offset, whence, file->ref_con) != 0) + { + file->mState.error = 1; + file->mBufferLength = 0; + errno = 0x28; + return -1; + } + else + { + file->mState.eof = 0; + file->mPosition = offset; + file->mBufferLength = 0; + } + } + + return 0; } -int fseek(FILE *stream, fpos_t offset, int whence) +int fseek(FILE* stream, fpos_t offset, int whence) { - fpos_t start; - int code; - start = offset; - __begin_critical_region(stdin_access); - code = _fseek(stream, start, whence); // 0 if successful, -1 if error - __end_critical_region(stdin_access); - return code; + fpos_t start; + int code; + start = offset; + __begin_critical_region(stdin_access); + code = _fseek(stream, start, whence); // 0 if successful, -1 if error + __end_critical_region(stdin_access); + return code; } diff --git a/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/ansi_files.c b/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/ansi_files.c index 84b3063ef..7f4b4708b 100644 --- a/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/ansi_files.c +++ b/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/ansi_files.c @@ -14,7 +14,7 @@ extern int __close_console(u32); // clang-format off FILE __files[4] = { - { 0, // _00 + { 0, // _00 0, // _04, open_mode 1, // _04, io_mode 1, // _04, buffer_mode @@ -31,7 +31,7 @@ FILE __files[4] = 0, // _10 0, // _12 0, // _14 - 0, // _18 + 0, // _18 stdin_buff, // _1C sizeof(stdin_buff), // _20 stdin_buff, // _24 @@ -39,14 +39,14 @@ FILE __files[4] = 0, // _2C 0, // _30 0, // _34 - nullptr, // _38 + NULL, // _38 &__read_console, // _3C &__write_console, // _40 &__close_console, // _44 0, // _48 &__files[1] // _4C }, - { 1, // _00 + { 1, // _00 0, // _04, open_mode 2, // _04, io_mode 1, // _04, buffer_mode @@ -63,7 +63,7 @@ FILE __files[4] = 0, // _10 0, // _12 0, // _14 - 0, // _18 + 0, // _18 stdout_buff, // _1C sizeof(stdout_buff), // _20 stdout_buff, // _24 @@ -71,14 +71,14 @@ FILE __files[4] = 0, // _2C 0, // _30 0, // _34 - nullptr, // _38 + NULL, // _38 &__read_console, // _3C &__write_console, // _40 &__close_console, // _44 0, // _48 &__files[2] // _4C }, - { 2, // _00 + { 2, // _00 0, // _04, open_mode 2, // _04, io_mode 0, // _04, buffer_mode @@ -95,7 +95,7 @@ FILE __files[4] = 0, // _10 0, // _12 0, // _14 - 0, // _18 + 0, // _18 stderr_buff, // _1C sizeof(stderr_buff), // _20 stderr_buff, // _24 @@ -103,7 +103,7 @@ FILE __files[4] = 0, // _2C 0, // _30 0, // _34 - nullptr, // _38 + NULL, // _38 &__read_console, // _3C &__write_console, // _40 &__close_console, // _44 @@ -135,7 +135,7 @@ void __close_all() { plast->mMode.file_kind = __unavailable_file; if ((p != NULL) && p->mIsDynamicallyAllocated) - plast->mNextFile = nullptr; + plast->mNextFile = NULL; } } diff --git a/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/file_io.c b/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/file_io.c index ae3b5d100..c28e5ca4d 100644 --- a/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/file_io.c +++ b/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/file_io.c @@ -4,90 +4,100 @@ int fclose(FILE* file) { - int flush_result, close_result; + int flush_result, close_result; - if (file == nullptr) - return (-1); - if (file->mMode.file_kind == __closed_file) - return (0); + if (file == NULL) + return (-1); + if (file->mMode.file_kind == __closed_file) + return (0); - flush_result = fflush(file); + flush_result = fflush(file); - close_result = (*file->closeFunc)(file->mHandle); + close_result = (*file->closeFunc)(file->mHandle); - file->mMode.file_kind = __closed_file; - file->mHandle = 0; + file->mMode.file_kind = __closed_file; + file->mHandle = 0; - if (file->mState.free_buffer) - free(file->mBuffer); - return ((flush_result || close_result) ? -1 : 0); + if (file->mState.free_buffer) + free(file->mBuffer); + return ((flush_result || close_result) ? -1 : 0); } int fflush(FILE* file) { - u32 pos; - - if (file == nullptr) { - return __flush_all(); - } - - if (file->mState.error != 0 || file->mMode.file_kind == __closed_file) { - return -1; - } - - if (file->mMode.io_mode == 1) { - return 0; - } - - if (file->mState.io_state >= 3) { - file->mState.io_state = 2; - } - - if (file->mState.io_state == 2) { - file->mBufferLength = 0; - } - - if (file->mState.io_state != 1) { - file->mState.io_state = 0; - return 0; - } - - if (file->mMode.file_kind != __disk_file || (pos = ftell(file)) < 0) - pos = 0; - - if (__flush_buffer(file, 0) != 0) { - file->mState.error = 1; - file->mBufferLength = 0; - return -1; - } - - file->mState.io_state = 0; - file->mPosition = pos; - file->mBufferLength = 0; - return 0; + u32 pos; + + if (file == NULL) + { + return __flush_all(); + } + + if (file->mState.error != 0 || file->mMode.file_kind == __closed_file) + { + return -1; + } + + if (file->mMode.io_mode == 1) + { + return 0; + } + + if (file->mState.io_state >= 3) + { + file->mState.io_state = 2; + } + + if (file->mState.io_state == 2) + { + file->mBufferLength = 0; + } + + if (file->mState.io_state != 1) + { + file->mState.io_state = 0; + return 0; + } + + if (file->mMode.file_kind != __disk_file || (pos = ftell(file)) < 0) + pos = 0; + + if (__flush_buffer(file, 0) != 0) + { + file->mState.error = 1; + file->mBufferLength = 0; + return -1; + } + + file->mState.io_state = 0; + file->mPosition = pos; + file->mBufferLength = 0; + return 0; } -int __msl_strnicmp(const char *s1, const char *s2, int n) +int __msl_strnicmp(const char* s1, const char* s2, int n) { - int i; - char c1, c2; - - for (i = 0; i < n; i++) { - c1 = tolower(*s1++); - c2 = tolower(*s2++); - - if(c1 < c2) { - return -1; - } - - if (c1 > c2) { - return 1; - } - - if(c1 == '\0') { - return 0; - } - } - return 0; - + int i; + char c1, c2; + + for (i = 0; i < n; i++) + { + c1 = tolower(*s1++); + c2 = tolower(*s2++); + + if (c1 < c2) + { + return -1; + } + + if (c1 > c2) + { + return 1; + } + + if (c1 == '\0') + { + return 0; + } + } + return 0; } diff --git a/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/wchar_io.c b/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/wchar_io.c index da6a0378a..67a8ab47f 100644 --- a/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/wchar_io.c +++ b/src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/wchar_io.c @@ -8,75 +8,76 @@ void putwc(void) { - // UNUSED FUNCTION + // UNUSED FUNCTION } void putwchar(void) { - // UNUSED FUNCTION + // UNUSED FUNCTION } void fputwc(void) { - // UNUSED FUNCTION + // UNUSED FUNCTION } void getwc(void) { - // UNUSED FUNCTION + // UNUSED FUNCTION } void getwchar(void) { - // UNUSED FUNCTION + // UNUSED FUNCTION } void fgetwc(void) { - // UNUSED FUNCTION + // UNUSED FUNCTION } void ungetwc(void) { - // UNUSED FUNCTION + // UNUSED FUNCTION } void fputws(void) { - // UNUSED FUNCTION + // UNUSED FUNCTION } void fgetws(void) { - // UNUSED FUNCTION + // UNUSED FUNCTION } int fwide(FILE* stream, int mode) { - int res; - int orientation; - - if (stream == nullptr || stream->mMode.file_kind == __closed_file) - return 0; - - orientation = stream->mMode.file_orientation; - switch (orientation) { - case __unoriented: - if (mode > 0) - stream->mMode.file_orientation = __wide_oriented; - else if (mode < 0) - stream->mMode.file_orientation = __char_oriented; - - res = mode; - break; - - case __wide_oriented: - res = 1; - break; - - case __char_oriented: - res = -1; - break; - } - return res; + int res; + int orientation; + + if (stream == NULL || stream->mMode.file_kind == __closed_file) + return 0; + + orientation = stream->mMode.file_orientation; + switch (orientation) + { + case __unoriented: + if (mode > 0) + stream->mMode.file_orientation = __wide_oriented; + else if (mode < 0) + stream->mMode.file_orientation = __char_oriented; + + res = mode; + break; + + case __wide_oriented: + res = 1; + break; + + case __char_oriented: + res = -1; + break; + } + return res; } diff --git a/src/SB/Game/zMain.cpp b/src/SB/Game/zMain.cpp index 274fffb15..98fed79aa 100644 --- a/src/SB/Game/zMain.cpp +++ b/src/SB/Game/zMain.cpp @@ -619,7 +619,8 @@ void zMainShowProgressBar() strcpy(acStack_8c, loadingText); acStack_8c[progBar] = '\0'; memcpy(formattedStr, &loadingText[progBar], strlen(loadingText) - progBar); - sprintf(auStack_cc, "{font=0}{h*2}{w*2}%s{color=FFFFFFFF}%s{~:c}", acStack_8c, formattedStr); + sprintf(auStack_cc, "{font=0}{h*2}{w*2}%s{color=FFFFFFFF}%s{~:c}", acStack_8c, + formattedStr); zMainMemCardRenderText(auStack_cc, '\x01'); percentageDone += 10; } @@ -760,7 +761,7 @@ void zMainMemCardSpaceQuery() static void zMainMemCardQueryPost(S32 needed, S32 available, S32 neededFiles, S32 unk0) { - RwCamera* cam = nullptr; + RwCamera* cam = NULL; RwRGBA colour = {}; RwInt32 clearMode = 3; @@ -775,7 +776,7 @@ static void zMainMemCardQueryPost(S32 needed, S32 available, S32 neededFiles, S3 void zMainMemCardRenderText(const char* a, bool enabled) { - RwCamera* cam = nullptr; + RwCamera* cam = NULL; RwRGBA colour = {}; RwInt32 clearMode = 3; diff --git a/src/dolphin/src/card/CARDCheck.c b/src/dolphin/src/card/CARDCheck.c index 9d0771cc9..74d4032db 100644 --- a/src/dolphin/src/card/CARDCheck.c +++ b/src/dolphin/src/card/CARDCheck.c @@ -397,10 +397,10 @@ s32 CARDCheck(s32 channel) result = CARDCheckExAsync(channel, &xferBytes, __CARDSyncCallback); - if (result < 0 || &xferBytes == nullptr) + if (result < 0 || &xferBytes == NULL) { return result; } return __CARDSync(channel); -} \ No newline at end of file +} diff --git a/src/dolphin/src/os/OSFont.c b/src/dolphin/src/os/OSFont.c index a02673de6..e874f0324 100644 --- a/src/dolphin/src/os/OSFont.c +++ b/src/dolphin/src/os/OSFont.c @@ -421,7 +421,7 @@ u32 OSLoadFont(OSFontHeader* fontInfo, void* temp) u8* ptr; int fontCodeT, sheet, numChars, row, column, x, y; - u32 fontSize = ReadFont(temp, OS_FONT_ENCODE_SJIS, nullptr); + u32 fontSize = ReadFont(temp, OS_FONT_ENCODE_SJIS, NULL); if (fontSize) { Decode(temp, (void*)fontInfo); diff --git a/src/dolphin/src/os/OSThread.c b/src/dolphin/src/os/OSThread.c index 4d3dddf37..2d2adf809 100644 --- a/src/dolphin/src/os/OSThread.c +++ b/src/dolphin/src/os/OSThread.c @@ -305,8 +305,8 @@ static OSThread* SelectThread(BOOL yield) if (RunQueueBits == 0) { - SwitchThreadCallback(__OSCurrentThread, nullptr); - __OSCurrentThread = nullptr; + SwitchThreadCallback(__OSCurrentThread, NULL); + __OSCurrentThread = NULL; OSSetCurrentContext(&IdleContext); do { diff --git a/src/dolphin/src/vi/vi.c b/src/dolphin/src/vi/vi.c index 9d47b7d89..9399b4939 100644 --- a/src/dolphin/src/vi/vi.c +++ b/src/dolphin/src/vi/vi.c @@ -270,7 +270,7 @@ static VITimingInfo* getTiming(VITVMode mode) return &timing[9]; } - return nullptr; + return NULL; } void __VIInit(VITVMode mode) @@ -469,8 +469,8 @@ void VIInit(void) value = (((u32)(value)) & ~0x00008000) | (((0)) << 15); __VIRegs[VI_DISP_INT_1] = value; - PreCB = nullptr; - PostCB = nullptr; + PreCB = NULL; + PostCB = NULL; __OSSetInterruptHandler(24, __VIRetraceHandler); __OSUnmaskInterrupts((0x80000000u >> (24))); diff --git a/src/runtime_libs/debugger/embedded/MetroTRK/Os/dolphin/dolphin_trk_glue.c b/src/runtime_libs/debugger/embedded/MetroTRK/Os/dolphin/dolphin_trk_glue.c index 21a02e78b..1b2bc2771 100644 --- a/src/runtime_libs/debugger/embedded/MetroTRK/Os/dolphin/dolphin_trk_glue.c +++ b/src/runtime_libs/debugger/embedded/MetroTRK/Os/dolphin/dolphin_trk_glue.c @@ -10,7 +10,7 @@ s32 gReadCount; s32 gReadPos; s32 gWritePos; -DBCommTable gDBCommTable = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }; +DBCommTable gDBCommTable = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; /* * --INFO--