diff options
| author | jdflyer <yeacub@gmail.com> | 2021-01-31 18:03:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-31 20:03:38 -0500 |
| commit | f1924e91f4a1ea1dea62b4fb0a1342f94a55ccfe (patch) | |
| tree | 143b3d8aa6bb5e975c8aa0bcf18975f797d8ba8c /src/m_Do/m_Do_printf.cpp | |
| parent | 24d529f67b310b50ac1ee22ffb6e1e06645985d9 (diff) | |
d_kyeff, d_kyeff2, m_Do_printf, and m_Do_graphic (#109)
* Split d_kyeff
* Partially matched d_kyeff
* split d_kyeff2
* Match d_kyeff2
* split m_Do_printf
* m_Do_printf partially matched
* hotfix and clang-format
* split m_Do_graphic
* rename symbols in m_Do_graphic
* Match a few functions in m_Do_graphic
* Fix Merge Errors
* Delete sh.exe.stackdump
* Update OSReportInit
Diffstat (limited to 'src/m_Do/m_Do_printf.cpp')
| -rw-r--r-- | src/m_Do/m_Do_printf.cpp | 132 |
1 files changed, 131 insertions, 1 deletions
diff --git a/src/m_Do/m_Do_printf.cpp b/src/m_Do/m_Do_printf.cpp index 4bf93c8658..9e97e64e2d 100644 --- a/src/m_Do/m_Do_printf.cpp +++ b/src/m_Do/m_Do_printf.cpp @@ -1 +1,131 @@ -// ok +#include "m_Do/m_Do_printf/m_Do_printf.h" +#include "global.h" +#include "m_Do/m_Do_ext/m_Do_ext.h" +#include "os/OS.h" + +asm void OSSwitchFiberEx(u32, u32, u32, u32, u32, u32) { + nofralloc +#include "m_Do/m_Do_printf/asm/func_80006798.s" +} + +void my_PutString(const char* message) { + fputs(message, &lbl_803D29B0.stdout); +} + +void OSVAttention(const char* fmt, __va_list_struct* va_list) { + mDoPrintf_vprintf(fmt, va_list); +} + +extern "C" { +asm void OSAttention(char* msg, ...) { + nofralloc +#include "m_Do/m_Do_printf/asm/func_80006814.s" +} + +void OSReportDisable(void) { + lbl_80450B98 = true; +} + +void OSReportEnable(void) { + lbl_80450B98 = false; +} + +void OSReportForceEnableOn(void) { + lbl_80450B9C = true; +} + +void OSReportForceEnableOff(void) { + lbl_80450B9C = false; +} +}; // extern "C" + +void OSReportInit(void) { + if (lbl_80450BB4 == false) { + lbl_80450BB4 = true; + } +} + +void mDoPrintf_vprintf_Interrupt(const char* format, __va_list_struct* list) { + s32 enable; + + enable = OSDisableInterrupts(); + if (lbl_80450BB5 == false) { + lbl_80450BB5 = true; + OSSwitchFiberEx((u32)format, (u32)list, 0, 0, (u32)&vprintf, + (u32)&lbl_803DB740.stack[0x800]); + lbl_80450BB5 = false; + } + OSRestoreInterrupts(enable); +} + +void mDoPrintf_vprintf_Thread(const char* format, __va_list_struct* list) { + vprintf(format, list); +} + +void mDoPrintf_vprintf(const char* format, __va_list_struct* list) { + OSThread* thread; + u8* stack_pointer; + + thread = mDoExt_GetCurrentRunningThread(); + if (thread == NULL) { + mDoPrintf_vprintf_Interrupt(format, list); + } else { + stack_pointer = OSGetStackPointer(); + if ((stack_pointer < thread->stack_end + 0xa00) || (stack_pointer > thread->stack_base)) { + mDoPrintf_vprintf_Interrupt(format, list); + } else { + mDoPrintf_vprintf_Thread(format, list); + } + } +} + +extern "C" { +void mDoPrintf_VReport(const char* format, __va_list_struct* list) { + OSThread* thread; + + if (lbl_80450BB4 == false) { + OSReportInit(); + } + if ((lbl_80450B9C) || (lbl_80450B98 == false)) { + thread = mDoExt_GetCurrentRunningThread(); + if ((lbl_80450BA0 == NULL) || (lbl_80450BA0 == thread)) { + mDoPrintf_vprintf(format, list); + lbl_80450BA4++; // increment print counts + } + } +} + +void OSVReport(const char* format, __va_list_struct* list) { + mDoPrintf_VReport(format, list); +} + +asm void OSReport(char* fmt, ...) { + nofralloc +#include "m_Do/m_Do_printf/asm/func_80006ABC.s" +} + +asm void OSReport_FatalError(char* fmt, ...) { + nofralloc +#include "m_Do/m_Do_printf/asm/func_80006B3C.s" +} + +asm void OSReport_Error(char* fmt, ...) { + nofralloc +#include "m_Do/m_Do_printf/asm/func_80006C0C.s" +} + +asm void OSReport_Warning(char* fmt, ...) { + nofralloc +#include "m_Do/m_Do_printf/asm/func_80006CEC.s" +} + +asm void OSReport_System(char* fmt, ...) { + nofralloc +#include "m_Do/m_Do_printf/asm/func_80006DCC.s" +} + +asm void OSPanic(char* file, s32 line, char* fmt, ...) { + nofralloc +#include "m_Do/m_Do_printf/asm/func_80006E7C.s" +} +}; // extern "C" |
