2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2021-10-03 03:17:09 +00:00
|
|
|
#define gISVDbgPrnAdrs ((ISVDbg*)0xB3FF0000)
|
2020-03-17 04:31:30 +00:00
|
|
|
#define ASCII_TO_U32(a, b, c, d) ((u32)((a << 24) | (b << 16) | (c << 8) | (d << 0)))
|
|
|
|
|
2024-01-30 18:54:38 +00:00
|
|
|
#if OOT_DEBUG
|
2024-02-27 06:53:10 +00:00
|
|
|
OSPiHandle* sISVHandle; // official name : is_Handle
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
void isPrintfInit(void) {
|
2020-03-17 04:31:30 +00:00
|
|
|
sISVHandle = osCartRomInit();
|
|
|
|
osEPiWriteIo(sISVHandle, (u32)&gISVDbgPrnAdrs->put, 0);
|
|
|
|
osEPiWriteIo(sISVHandle, (u32)&gISVDbgPrnAdrs->get, 0);
|
2020-03-22 21:19:43 +00:00
|
|
|
osEPiWriteIo(sISVHandle, (u32)&gISVDbgPrnAdrs->magic, ASCII_TO_U32('I', 'S', '6', '4'));
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
2024-01-29 17:10:28 +00:00
|
|
|
#endif
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
void osSyncPrintfUnused(const char* fmt, ...) {
|
2020-03-17 04:31:30 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
|
2024-01-30 18:54:38 +00:00
|
|
|
#if OOT_DEBUG
|
2021-02-14 00:49:40 +00:00
|
|
|
_Printf(is_proutSyncPrintf, NULL, fmt, args);
|
2024-01-29 17:10:28 +00:00
|
|
|
#endif
|
2021-09-07 16:17:19 +00:00
|
|
|
|
|
|
|
va_end(args);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
void osSyncPrintf(const char* fmt, ...) {
|
2020-03-17 04:31:30 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
|
2024-01-30 18:54:38 +00:00
|
|
|
#if OOT_DEBUG
|
2021-02-14 00:49:40 +00:00
|
|
|
_Printf(is_proutSyncPrintf, NULL, fmt, args);
|
2024-01-29 17:10:28 +00:00
|
|
|
#endif
|
2021-09-20 16:51:35 +00:00
|
|
|
|
2021-09-07 16:17:19 +00:00
|
|
|
va_end(args);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
// assumption
|
|
|
|
void rmonPrintf(const char* fmt, ...) {
|
2020-03-17 04:31:30 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
|
2024-01-30 18:54:38 +00:00
|
|
|
#if OOT_DEBUG
|
2021-02-14 00:49:40 +00:00
|
|
|
_Printf(is_proutSyncPrintf, NULL, fmt, args);
|
2024-01-29 17:10:28 +00:00
|
|
|
#endif
|
2021-09-20 16:51:35 +00:00
|
|
|
|
2021-09-07 16:17:19 +00:00
|
|
|
va_end(args);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2024-01-30 18:54:38 +00:00
|
|
|
#if OOT_DEBUG
|
2023-10-27 14:06:44 +00:00
|
|
|
void* is_proutSyncPrintf(void* arg, const char* str, size_t count) {
|
2020-03-17 04:31:30 +00:00
|
|
|
u32 data;
|
|
|
|
s32 pos;
|
|
|
|
s32 start;
|
|
|
|
s32 end;
|
|
|
|
|
|
|
|
osEPiReadIo(sISVHandle, (u32)&gISVDbgPrnAdrs->magic, &data);
|
2020-03-22 21:19:43 +00:00
|
|
|
if (data != ASCII_TO_U32('I', 'S', '6', '4')) {
|
2022-06-16 00:15:44 +00:00
|
|
|
return (void*)1;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
osEPiReadIo(sISVHandle, (u32)&gISVDbgPrnAdrs->get, &data);
|
|
|
|
pos = data;
|
|
|
|
osEPiReadIo(sISVHandle, (u32)&gISVDbgPrnAdrs->put, &data);
|
|
|
|
start = data;
|
|
|
|
end = start + count;
|
2021-10-03 03:17:09 +00:00
|
|
|
if (end >= 0xFFE0) {
|
|
|
|
end -= 0xFFE0;
|
2020-03-22 21:19:43 +00:00
|
|
|
if (pos < end || start < pos) {
|
2022-06-16 00:15:44 +00:00
|
|
|
return (void*)1;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (start < pos && pos < end) {
|
2022-06-16 00:15:44 +00:00
|
|
|
return (void*)1;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
2020-03-22 21:19:43 +00:00
|
|
|
while (count) {
|
2021-10-03 03:17:09 +00:00
|
|
|
u32 addr = (u32)&gISVDbgPrnAdrs->data + (start & 0xFFFFFFC);
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 shift = ((3 - (start & 3)) * 8);
|
2021-10-03 03:17:09 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (*str) {
|
2020-03-17 04:31:30 +00:00
|
|
|
osEPiReadIo(sISVHandle, addr, &data);
|
2021-10-03 03:17:09 +00:00
|
|
|
osEPiWriteIo(sISVHandle, addr, (*str << shift) | (data & ~(0xFF << shift)));
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
start++;
|
2021-10-03 03:17:09 +00:00
|
|
|
if (start >= 0xFFE0) {
|
|
|
|
start -= 0xFFE0;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
count--;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
osEPiWriteIo(sISVHandle, (u32)&gISVDbgPrnAdrs->put, start);
|
2021-02-14 00:49:40 +00:00
|
|
|
|
2022-06-16 00:15:44 +00:00
|
|
|
return (void*)1;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2024-02-27 07:37:33 +00:00
|
|
|
NORETURN void func_80002384(const char* exp, const char* file, int line) {
|
2020-03-17 04:31:30 +00:00
|
|
|
osSyncPrintf("File:%s Line:%d %s \n", file, line, exp);
|
2020-03-22 21:19:43 +00:00
|
|
|
while (true) {
|
2020-03-17 04:31:30 +00:00
|
|
|
;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
2024-01-29 17:10:28 +00:00
|
|
|
#endif
|