1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-04 08:46:07 +00:00
oot/src/boot/is_debug.c

87 lines
2.2 KiB
C
Raw Normal View History

#include "global.h"
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
OSPiHandle* sISVHandle; // official name : is_Handle
2020-03-17 04:31:30 +00:00
#define gISVDbgPrnAdrs ((ISVDbg*)0xb3ff0000)
#define ASCII_TO_U32(a, b, c, d) ((u32)((a << 24) | (b << 16) | (c << 8) | (d << 0)))
2020-03-22 21:19:43 +00:00
void isPrintfInit() {
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
}
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);
_Printf(&is_proutSyncPrintf, NULL, fmt, args);
}
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);
_Printf(&is_proutSyncPrintf, NULL, fmt, args);
}
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);
_Printf(&is_proutSyncPrintf, NULL, fmt, args);
}
2020-03-22 21:19:43 +00:00
u32 is_proutSyncPrintf(void* arg0, const char* str, s32 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')) {
2020-03-17 04:31:30 +00:00
return 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;
2020-03-22 21:19:43 +00:00
if (end >= 0xffe0) {
2020-03-17 04:31:30 +00:00
end -= 0xffe0;
2020-03-22 21:19:43 +00:00
if (pos < end || start < pos) {
2020-03-17 04:31:30 +00:00
return 1;
2020-03-22 21:19:43 +00:00
}
} else {
if (start < pos && pos < end) {
2020-03-17 04:31:30 +00:00
return 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) {
2020-03-17 04:31:30 +00:00
u32 addr = (u32)&gISVDbgPrnAdrs->data + (start & 0xffffffc);
s32 shift = ((3 - (start & 3)) * 8);
2020-03-22 21:19:43 +00:00
if (*str) {
2020-03-17 04:31:30 +00:00
osEPiReadIo(sISVHandle, addr, &data);
osEPiWriteIo(sISVHandle, addr, (*str << shift) | (data & ~(0xff << shift)));
start++;
2020-03-22 21:19:43 +00:00
if (start >= 0xffe0) {
2020-03-17 04:31:30 +00:00
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);
return 1;
}
2020-03-22 21:19:43 +00:00
void func_80002384(const char* exp, const char* file, u32 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
}