From 682dc64f96d1c3e81d87bd0d8f2deab875bcf8aa Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Sun, 17 Sep 2023 16:17:19 -0400 Subject: [PATCH] Replaced primitive types with NitroSDK types --- include/main_debug.h | 16 ++++++++-------- include/main_pack.h | 2 +- src/main_debug.c | 44 ++++++++++++++++++++++---------------------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/include/main_debug.h b/include/main_debug.h index 13b7cbeb..adf0d413 100644 --- a/include/main_debug.h +++ b/include/main_debug.h @@ -5,8 +5,8 @@ // Program position info (basically stack trace info) for debug logging. struct prog_pos_info { - char* file; // file name - int line; // line number + u8* file; // file name + s32 line; // line number }; // Flags listed in the debug menu @@ -73,7 +73,7 @@ void InitDebugStripped6(void); // prog_pos: program position info // msg: base message // return: number of characters printed, excluding the null-terminator -int AppendProgPos(char* str, struct prog_pos_info* prog_pos, const char* msg); +s32 AppendProgPos(u8* str, struct prog_pos_info* prog_pos, const u8* msg); // Does nothing, only called in the debug initialization function. void InitDebugStripped5(void); @@ -83,17 +83,17 @@ void InitDebugStripped5(void); // If message is a null pointer, the string " Print " is used instead. // msg: message // prog_pos: program position info (can be null) -void DebugPrintTrace(const char* msg, struct prog_pos_info* prog_pos); +void DebugPrintTrace(const u8* msg, struct prog_pos_info* prog_pos); // Would display a printf format string on the top screen in the debug binary. // This still constructs the string with vsprintf, but doesn't actually do anything with it in the final binary. // Identical to DebugPrint0 in release builds. -void DebugDisplay(const char* fmt, ...); +void DebugDisplay(const u8* fmt, ...); // Would log a printf format string in the debug binary. // This still constructs the string with vsprintf, but doesn't actually do anything with it in the final binary. // Identical to DebugDisplay in release builds. -void DebugPrint0(const char* fmt, ...); +void DebugPrint0(const u8* fmt, ...); // Would have initialized the second set of debug flags. // Does nothing in release binary. @@ -112,7 +112,7 @@ void SetDebugLogFlag(enum debug_log_flag flag, u32 val); // Would log a printf format string in the debug binary. A no-op in the final binary. // level: log level // fmt: format -void DebugPrint(u8 level, const char* fmt, ...); +void DebugPrint(u8 level, const u8* fmt, ...); // Does nothing, only called in the debug initialization function. void InitDebugStripped4(void); @@ -128,6 +128,6 @@ void InitDebugStripped1(void); // Display some debug messages, then hangs the process. // This function is called in lots of places to bail on a fatal error. Looking at the static data callers use to fill in the program position info is informative, as it tells you the original file name (probably from the standard __FILE__ macro) and line number (probably from the standard __LINE__ macro) in the source code. -void FatalError(struct prog_pos_info *prog_pos, const char* fmt, ...); +void FatalError(struct prog_pos_info *prog_pos, const u8* fmt, ...); #endif //PMDSKY_MAIN_DEBUG_H \ No newline at end of file diff --git a/include/main_pack.h b/include/main_pack.h index 402f92ba..c7431e10 100644 --- a/include/main_pack.h +++ b/include/main_pack.h @@ -3,7 +3,7 @@ #include -// Open the 6 files at PACK_FILE_PATHS_TABLE into PACK_FILE_OPENED. Called during game initialization. +// Open the 6 files at PACK_FILE_PATHS_TABLE into PACK_FILES_OPENED. Called during game initialization. void OpenAllPackFiles(void); // Call GetFileLengthInPack after looking up the global Pack archive by its number diff --git a/src/main_debug.c b/src/main_debug.c index 27b00303..478adf93 100644 --- a/src/main_debug.c +++ b/src/main_debug.c @@ -1,19 +1,19 @@ #include "main_debug.h" -extern int vsprintf(char* str, const char* format, va_list ap); -extern char* strcpy(char* dest, const char* src); -extern char* strcat(char* dest, const char* src); +extern s32 vsprintf(u8* str, const u8* format, va_list ap); +extern u8* strcpy(u8* dest, const u8* src); +extern u8* strcat(u8* dest, const u8* src); extern void WaitForever(void); -extern int sprintf(char* str, const char* format, ...); +extern s32 sprintf(u8* str, const u8* format, ...); -extern char STRING_DEBUG_EMPTY; -extern char STRING_DEBUG_FORMAT_LINE_FILE; -extern char STRING_DEBUG_NO_PROG_POS; -extern char STRING_DEBUG_SPACED_PRINT; -extern char STRING_DEBUG_FATAL; -extern char STRING_DEBUG_NEWLINE; -extern char STRING_DEBUG_LOG_NULL; -extern char STRING_DEBUG_STRING_NEWLINE; +extern u8 STRING_DEBUG_EMPTY; +extern u8 STRING_DEBUG_FORMAT_LINE_FILE; +extern u8 STRING_DEBUG_NO_PROG_POS; +extern u8 STRING_DEBUG_SPACED_PRINT; +extern u8 STRING_DEBUG_FATAL; +extern u8 STRING_DEBUG_NEWLINE; +extern u8 STRING_DEBUG_LOG_NULL; +extern u8 STRING_DEBUG_STRING_NEWLINE; extern BOOL DEBUG_IS_INITIALIZED; @@ -42,7 +42,7 @@ void SetDebugFlag(enum debug_flag flag, u32 val) {} void InitDebugStripped6(void) {} -int AppendProgPos(char* str, struct prog_pos_info* prog_pos, const char* msg) { +s32 AppendProgPos(u8* str, struct prog_pos_info* prog_pos, const u8* msg) { if (msg == NULL) { msg = &STRING_DEBUG_EMPTY; }; @@ -56,8 +56,8 @@ int AppendProgPos(char* str, struct prog_pos_info* prog_pos, const char* msg) { void InitDebugStripped5(void) {} -void DebugPrintTrace(const char* msg, struct prog_pos_info* prog_pos) { - char message_buffer[256]; +void DebugPrintTrace(const u8* msg, struct prog_pos_info* prog_pos) { + u8 message_buffer[256]; if (prog_pos != NULL) { if (msg != NULL) { @@ -76,18 +76,18 @@ void DebugPrintTrace(const char* msg, struct prog_pos_info* prog_pos) { // Call to function that actually print something would have been here } -void DebugDisplay(const char* fmt, ...) { +void DebugDisplay(const u8* fmt, ...) { va_list args; va_start(args, fmt); - char message_buffer[256]; + u8 message_buffer[256]; vsprintf(message_buffer, fmt, args); // Would have called the "display to top screen" function here } -void DebugPrint0(const char* fmt, ...) { +void DebugPrint0(const u8* fmt, ...) { va_list args; va_start(args, fmt); - char message_buffer[256]; + u8 message_buffer[256]; vsprintf(message_buffer, fmt, args); } @@ -99,16 +99,16 @@ u32 GetDebugLogFlag(enum debug_log_flag flag) { void SetDebugLogFlag(enum debug_log_flag flag, u32 val) {} -void DebugPrint(u8 level, const char* fmt, ...) {} +void DebugPrint(u8 level, const u8* fmt, ...) {} void InitDebugStripped4(void) {} void InitDebugStripped3(void) {} void InitDebugStripped2(void) {} void InitDebugStripped1(void) {} -void FatalError(struct prog_pos_info *prog_pos, const char* fmt, ...) { +void FatalError(struct prog_pos_info *prog_pos, const u8* fmt, ...) { va_list args; - char message_buffer[256]; + u8 message_buffer[256]; DebugPrintTrace(&STRING_DEBUG_FATAL, prog_pos); if (fmt != NULL) { va_start(args, fmt);