summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrozlette <uberpanzermensch@gmail.com>2020-01-12 18:17:55 -0600
committerrozlette <uberpanzermensch@gmail.com>2020-01-12 18:17:55 -0600
commit76c3d660a97526809b58ecc635ad46ef6bdaeefa (patch)
tree2c61a995379ac75d4bfe96971e0e58ff871a3aac /src
parent36f623023df488c17fda71940ddd3b6bc5a18a06 (diff)
Port over fault_drawer.c from oot decomp. Not much effort was made to fix nonmatching
Diffstat (limited to 'src')
-rw-r--r--src/boot_O2_g3_trapuv/fault.c6
-rw-r--r--src/boot_O2_g3_trapuv/fault_drawer.c118
2 files changed, 120 insertions, 4 deletions
diff --git a/src/boot_O2_g3_trapuv/fault.c b/src/boot_O2_g3_trapuv/fault.c
index df0395808..98af26288 100644
--- a/src/boot_O2_g3_trapuv/fault.c
+++ b/src/boot_O2_g3_trapuv/fault.c
@@ -810,12 +810,10 @@ void Fault_ThreadEntry(void* arg) {
if (msg == (OSMesg)1) {
faultCtxt->msgId = 1;
Fault_Log(D_80098A88);
- }
- else if (msg == (OSMesg)2) {
+ } else if (msg == (OSMesg)2) {
faultCtxt->msgId = 2;
Fault_Log(D_80098AC0);
- }
- else if (msg == (OSMesg)3) {
+ } else if (msg == (OSMesg)3) {
Fault_SetOptions();
faultedThread = NULL;
continue;
diff --git a/src/boot_O2_g3_trapuv/fault_drawer.c b/src/boot_O2_g3_trapuv/fault_drawer.c
new file mode 100644
index 000000000..65a2da401
--- /dev/null
+++ b/src/boot_O2_g3_trapuv/fault_drawer.c
@@ -0,0 +1,118 @@
+#include <ultra64.h>
+#include <global.h>
+
+void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled) {
+ faultDrawContext->osSyncPrintfEnabled = enabled;
+}
+
+
+#ifdef NON_MATCHING
+//This function needs a lot of work
+void FaultDrawer_DrawRecImpl(s32 xstart, s32 ystart, s32 xend, s32 yend, u16 color) {
+ s32 x;
+ s32 y;
+ u16* fb;
+ if (faultDrawContext->w - xstart > 0 && faultDrawContext->h - ystart > 0) {
+ for (y = 0; y < yend - ystart + 1; y++) {
+ fb = &faultDrawContext->fb[faultDrawContext->w * y];
+ for (x = 0; x < xend - xstart + 1; x++) {
+ *fb++ = color;
+ }
+ }
+
+ osWritebackDCacheAll();
+ }
+}
+#else
+GLOBAL_ASM("./asm/nonmatching/fault_drawer/FaultDrawer_DrawRecImpl.asm")
+#endif
+
+GLOBAL_ASM("./asm/nonmatching/fault_drawer/FaultDrawer_DrawChar.asm")
+
+s32 FaultDrawer_ColorToPrintColor(u16 color) {
+ s32 i;
+ for (i = 0; i < 10; i++) {
+ if (color == faultDrawContext->printColors[i]) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+void FaultDrawer_UpdatePrintColor() {
+ s32 idx;
+ if (faultDrawContext->osSyncPrintfEnabled) {
+ Fault_Log(D_80099050);
+ idx = FaultDrawer_ColorToPrintColor(faultDrawContext->foreColor);
+ if (idx >= 0 && idx < 8) {
+ Fault_Log(D_80099054, idx);
+ }
+ idx = FaultDrawer_ColorToPrintColor(faultDrawContext->backColor);
+ if (idx >= 0 && idx < 8) {
+ Fault_Log(D_8009905C, idx);
+ }
+ }
+}
+
+void FaultDrawer_SetForeColor(u16 color) {
+ faultDrawContext->foreColor = color;
+ FaultDrawer_UpdatePrintColor();
+}
+
+void FaultDrawer_SetBackColor(u16 color) {
+ faultDrawContext->backColor = color;
+ FaultDrawer_UpdatePrintColor();
+}
+
+void FaultDrawer_SetFontColor(u16 color) {
+ FaultDrawer_SetForeColor((u16)(color | 1)); //force alpha to be set
+}
+
+void FaultDrawer_SetCharPad(s8 padW, s8 padH) {
+ faultDrawContext->charWPad = padW;
+ faultDrawContext->charHPad = padH;
+}
+
+void FaultDrawer_SetCursor(s32 x, s32 y) {
+ if (faultDrawContext->osSyncPrintfEnabled) {
+ Fault_Log(D_80099064, (y - faultDrawContext->yStart) / (faultDrawContext->charH + faultDrawContext->charHPad), (x - faultDrawContext->xStart) / (faultDrawContext->charW + faultDrawContext->charWPad));
+ }
+ faultDrawContext->cursorX = x;
+ faultDrawContext->cursorY = y;
+}
+
+void FaultDrawer_FillScreen() {
+ if (faultDrawContext->osSyncPrintfEnabled) {
+ Fault_Log(D_80099070);
+ }
+
+ FaultDrawer_DrawRecImpl(faultDrawContext->xStart, faultDrawContext->yStart, faultDrawContext->xEnd, faultDrawContext->yEnd, faultDrawContext->backColor | 1);
+ FaultDrawer_SetCursor(faultDrawContext->xStart, faultDrawContext->yStart);
+}
+
+GLOBAL_ASM("./asm/nonmatching/fault_drawer/FaultDrawer_FormatStringFunc.asm")
+
+void FaultDrawer_VPrintf(char* str, char* args) { //va_list
+ _Printf((printf_func)FaultDrawer_FormatStringFunc, faultDrawContext, str, args);
+}
+
+GLOBAL_ASM("./asm/nonmatching/fault_drawer/FaultDrawer_Printf.asm")
+
+GLOBAL_ASM("./asm/nonmatching/fault_drawer/FaultDrawer_DrawText.asm")
+
+void FaultDrawer_SetDrawerFB(void* fb, u16 w, u16 h) {
+ faultDrawContext->fb = (u16*)fb;
+ faultDrawContext->w = w;
+ faultDrawContext->h = h;
+}
+
+void FaultDrawer_SetInputCallback(void(*callback)()) {
+ faultDrawContext->inputCallback = callback;
+}
+
+void FaultDrawer_Init() {
+ faultDrawContext = &faultDrawContextStruct;
+ _bcopy(&faultDrawContextInit, faultDrawContext, sizeof(FaultDrawer));
+ faultDrawContext->fb = (u16*)((osMemSize | 0x80000000) - 0x25800);
+}
+