diff options
| author | Derek Hensley <hensley.derek58@gmail.com> | 2023-08-28 09:59:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-28 09:59:31 -0700 |
| commit | 1e3511efea9cf4379a04fca77f6a00cb170da28c (patch) | |
| tree | 7650c04105d35d867939d19e3421102ae511102f /include/fault.h | |
| parent | fcfbb6c52feec4a01b46f0c2bcc037af373d4fe9 (diff) | |
Fault + Fault_drawer (#77)
* Fault OK
* fault_drawer OK
* Cleanup
* Cleanup pt 2
* Forgot to save
* PR
Diffstat (limited to 'include/fault.h')
| -rw-r--r-- | include/fault.h | 128 |
1 files changed, 68 insertions, 60 deletions
diff --git a/include/fault.h b/include/fault.h index b24f732..4cf3c51 100644 --- a/include/fault.h +++ b/include/fault.h @@ -2,8 +2,31 @@ #define FAULT_H #include "ultra64.h" +#include "unk.h" #include "attributes.h" +#include "libc/stdarg.h" #include "libc/stdint.h" +#include "libu64/pad.h" +#include "stack.h" + +// These are the same as the 3-bit ansi color codes +#define FAULT_COLOR_BLACK 0 +#define FAULT_COLOR_RED 1 +#define FAULT_COLOR_GREEN 2 +#define FAULT_COLOR_YELLOW 3 +#define FAULT_COLOR_BLUE 4 +#define FAULT_COLOR_MAGENTA 5 +#define FAULT_COLOR_CYAN 6 +#define FAULT_COLOR_WHITE 7 +// Additional color codes +#define FAULT_COLOR_DARK_GRAY 8 +#define FAULT_COLOR_LIGHT_GRAY 9 + +#define FAULT_COLOR_STRINGIFY(s) #s +#define FAULT_COLOR_EXPAND_AND_STRINGIFY(s) FAULT_COLOR_STRINGIFY(s) + +#define FAULT_ESC '\x1A' +#define FAULT_COLOR(n) "\x1A" FAULT_COLOR_EXPAND_AND_STRINGIFY(FAULT_COLOR_ ## n) typedef void (*FaultClientCallback)(void*, void*); @@ -26,67 +49,52 @@ typedef struct FaultAddrConvClient { /* 0x8 */ void* arg; } FaultAddrConvClient; // size = 0xC -// void Fault_SleepImpl(); -// void Fault_ClientProcessThread(); -// void Fault_ClientRunTask(); -// void Fault_ProcessClient(); -void Fault_AddClient(FaultClient* client, FaultClientCallback callback, void* arg0, void* arg1); -void Fault_RemoveClient(FaultClient* client); -void Fault_AddAddrConvClient(FaultAddrConvClient* client, FaultAddrConvClientCallback callback, void* arg); -void Fault_RemoveAddrConvClient(FaultAddrConvClient* client); -// void Fault_ConvertAddress(); -// void Fault_Sleep(); -// void Fault_PadCallback(); -// void Fault_UpdatePadImpl(); -// void Fault_WaitForInputImpl(); -// void Fault_WaitForInput(); -// void Fault_DrawRec(); -// void Fault_FillScreenBlack(); -// void Fault_FillScreenRed(); -// void Fault_DrawCornerRec(); -// void Fault_PrintFReg(); -// void Fault_LogFReg(); -// void Fault_PrintFPCSR(); -// void Fault_LogFPCSR(); -// void Fault_PrintThreadContext(); -// void Fault_LogThreadContext(); -// void Fault_FindFaultedThread(); -// void Fault_Wait5Seconds(); -// void Fault_WaitForButtonCombo(); -// void Fault_DrawMemDumpContents(); -// void Fault_DrawMemDump(); -// void Fault_WalkStack(); -// void Fault_DrawStackTrace(); -// void Fault_LogStackTrace(); -// void Fault_ResumeThread(); -// void Fault_DisplayFrameBuffer(); -// void Fault_ProcessClients(); -// void Fault_UpdatePad(); -// void Fault_ThreadEntry(); -// void Fault_SetFrameBuffer(); -// void Fault_Init(); -// void Fault_HungupFaultClient(); -NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2); -// NORETURN void Fault_AddHungupAndCrash(); - -// void FaultDrawer_SetOsSyncPrintfEnabled(); -// void FaultDrawer_DrawRecImpl(); -// void FaultDrawer_DrawChar(); -// void FaultDrawer_ColorToPrintColor(); -// void FaultDrawer_UpdatePrintColor(); -// void FaultDrawer_SetForeColor(); -// void FaultDrawer_SetBackColor(); +typedef struct FaultMgr { + /* 0x000 */ OSThread thread; + /* 0x1B0 */ STACK(stack, 0x600); // probably an unused internal thread stack for `fault_ClientRunTask`/`clientThreadSp` + /* 0x7B0 */ OSMesgQueue queue; + /* 0x7C8 */ OSMesg msg[1]; + /* 0x7CC */ u8 exit; + /* 0x7CD */ u8 msgId; + /* 0x7CE */ u8 faultHandlerEnabled; + /* 0x7CF */ u8 autoScroll; + /* 0x7D0 */ OSThread* faultedThread; + /* 0x7D4 */ void (*padCallback)(Input* inputs); + /* 0x7D8 */ FaultClient* clients; + /* 0x7DC */ FaultAddrConvClient* addrConvClients; + /* 0x7E0 */ UNK_TYPE1 unk_7E0[0x4]; + /* 0x7E4 */ Input inputs[MAXCONTROLLERS]; + /* 0x844 */ void* fb; + /* 0x848 */ void* clientThreadSp; +} FaultMgr; // size = 0x850 + + +void fault_AddClient(FaultClient* client, FaultClientCallback callback, void* arg0, void* arg1); +void fault_RemoveClient(FaultClient* client); +void fault_AddressConverterAddClient(FaultAddrConvClient* client, FaultAddrConvClientCallback callback, void* arg); +void fault_AddressConverterRemoveClient(FaultAddrConvClient* client); +void fault_WaitForInput(void); +void fault_FillScreenBlack(void); +void fault_SetFrameBuffer(void* fb, u16 w, u16 h); +void fault_Init(void); +NORETURN void fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2); +NORETURN void fault_AddHungupAndCrash(const char* file, s32 line); + +void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled); +void FaultDrawer_DrawRecImpl(s32 xStart, s32 yStart, s32 xEnd, s32 yEnd, u16 color); +void FaultDrawer_SetForeColor(u16 color); +void FaultDrawer_SetBackColor(u16 color); void FaultDrawer_SetFontColor(u16 color); void FaultDrawer_SetCharPad(s8 padW, s8 padH); -void FaultDrawer_SetCursor(s32 arg0, s32 arg1); -// void FaultDrawer_FillScreen(); -// void FaultDrawer_PrintCallback(); -// void FaultDrawer_VPrintf(); -void FaultDrawer_Printf(const char* fmt, ...); -// void FaultDrawer_DrawText(); -// void FaultDrawer_SetDrawerFB(); -// void FaultDrawer_SetInputCallback(); -// void FaultDrawer_WritebackFBDCache(); -// void FaultDrawer_Init(); +void FaultDrawer_SetCursor(s32 x, s32 y); +void FaultDrawer_FillScreen(void); +s32 FaultDrawer_VPrintf(const char* fmt, va_list args); +s32 FaultDrawer_Printf(const char* fmt, ...); +void FaultDrawer_DrawText(s32 x, s32 y, const char* fmt, ...); +void FaultDrawer_SetDrawerFB(void* fb, u16 w, u16 h); +void FaultDrawer_SetInputCallback(void (*callback)(void)); +void FaultDrawer_Init(void); + +extern FaultMgr gFaultMgr; #endif |
