mirror of https://github.com/PrimeDecomp/prime.git
Cleanup and comment RAssertDolphin
Former-commit-id: 2eb4fdb0fe9173604a5a8555b9ddf57194a1012c
This commit is contained in:
parent
18d745d0ea
commit
d0f0f7088e
|
@ -10,6 +10,7 @@
|
||||||
"[python]": {
|
"[python]": {
|
||||||
"editor.defaultFormatter": "ms-python.black-formatter"
|
"editor.defaultFormatter": "ms-python.black-formatter"
|
||||||
},
|
},
|
||||||
|
"clangd.arguments": ["--header-insertion=never"],
|
||||||
"clangd.fallbackFlags": [
|
"clangd.fallbackFlags": [
|
||||||
"-I${workspaceFolder}/include",
|
"-I${workspaceFolder}/include",
|
||||||
"-I${workspaceFolder}/libc",
|
"-I${workspaceFolder}/libc",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#include "Kyoto/Basics/RAssertDolphin.hpp"
|
#include "Kyoto/Basics/RAssertDolphin.hpp"
|
||||||
|
|
||||||
#include "dolphin/ai.h"
|
#include "dolphin/os/OSError.h"
|
||||||
#include "dolphin/os/OSMemory.h"
|
#include "dolphin/os/OSMemory.h"
|
||||||
#include "dolphin/pad.h"
|
#include "dolphin/pad.h"
|
||||||
#include "dolphin/vi.h"
|
#include "dolphin/vi.h"
|
||||||
|
@ -16,6 +16,8 @@ static const GXColor bg = {128, 0, 0, 0};
|
||||||
static const GXColor fg = {255, 255, 255, 0};
|
static const GXColor fg = {255, 255, 255, 0};
|
||||||
static const uchar ExitButtons[4] = {PAD_BUTTON_RIGHT, PAD_BUTTON_LEFT, PAD_BUTTON_DOWN,
|
static const uchar ExitButtons[4] = {PAD_BUTTON_RIGHT, PAD_BUTTON_LEFT, PAD_BUTTON_DOWN,
|
||||||
PAD_BUTTON_UP};
|
PAD_BUTTON_UP};
|
||||||
|
#define INITIAL_COMBO (PAD_BUTTON_X | PAD_BUTTON_Y | PAD_TRIGGER_Z)
|
||||||
|
#define DPAD (PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT | PAD_BUTTON_UP | PAD_BUTTON_DOWN)
|
||||||
|
|
||||||
static void hack() {
|
static void hack() {
|
||||||
static const char* tmp1 = "%s\0\n";
|
static const char* tmp1 = "%s\0\n";
|
||||||
|
@ -26,7 +28,7 @@ void ErrorHandler(OSError code, OSContext* context, int dsisr, int dar) {
|
||||||
OSContext newContext;
|
OSContext newContext;
|
||||||
uint loopExitCriteria;
|
uint loopExitCriteria;
|
||||||
PADStatus pads[4];
|
PADStatus pads[4];
|
||||||
uchar local_60[4];
|
uchar exitButtons[4];
|
||||||
u32* gpr;
|
u32* gpr;
|
||||||
uint i;
|
uint i;
|
||||||
uint len;
|
uint len;
|
||||||
|
@ -42,34 +44,47 @@ void ErrorHandler(OSError code, OSContext* context, int dsisr, int dar) {
|
||||||
VIFlush();
|
VIFlush();
|
||||||
|
|
||||||
#if VERSION >= 1
|
#if VERSION >= 1
|
||||||
|
// Pivot to a new context for a clean CPU state
|
||||||
OSClearContext(&newContext);
|
OSClearContext(&newContext);
|
||||||
OSSetCurrentContext(&newContext);
|
OSSetCurrentContext(&newContext);
|
||||||
OSEnableInterrupts();
|
OSEnableInterrupts();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// We have an error, lets loop until the player correctly inputs the debug combo:
|
||||||
|
// Hold X+Y+Z Followed by pressing left, right, down, up in that order
|
||||||
while (loopExitCriteria < 4) {
|
while (loopExitCriteria < 4) {
|
||||||
PADRead(pads);
|
PADRead(pads);
|
||||||
|
|
||||||
#if VERSION >= 1
|
#if VERSION >= 1
|
||||||
|
// If port 1 is unpopulated, spin until a controller is plugged in
|
||||||
while (pads[1].err == PAD_ERR_NO_CONTROLLER) {
|
while (pads[1].err == PAD_ERR_NO_CONTROLLER) {
|
||||||
|
// Reset port 1
|
||||||
PADReset(PAD_CHAN1_BIT);
|
PADReset(PAD_CHAN1_BIT);
|
||||||
|
// Get current state
|
||||||
PADRead(pads);
|
PADRead(pads);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pads[1].err == PAD_ERR_NONE) {
|
if (pads[1].err == PAD_ERR_NONE) {
|
||||||
*(uint*)local_60 = *(uint*)ExitButtons;
|
// Dunno why we're doing this but, it matches...
|
||||||
if ((pads[1].button & 0xc10) == 0xc10) {
|
*(uint*)exitButtons = *(uint*)ExitButtons;
|
||||||
if ((pads[1].button & 0xf) != 0) {
|
|
||||||
if ((pads[1].button & local_60[loopExitCriteria]) != 0) {
|
// Check for X + Y + Z to initiate loop exit
|
||||||
|
if ((pads[1].button & INITIAL_COMBO) == INITIAL_COMBO) {
|
||||||
|
// Is the player pressing any DPAD button?
|
||||||
|
if ((pads[1].button & DPAD) != 0) {
|
||||||
|
// Ok, check combo order
|
||||||
|
if ((pads[1].button & exitButtons[loopExitCriteria]) != 0) {
|
||||||
loopExitCriteria += 1;
|
loopExitCriteria += 1;
|
||||||
|
|
||||||
} else if ((loopExitCriteria != 0) &&
|
} else if ((loopExitCriteria != 0) &&
|
||||||
((pads[1].button & local_60[loopExitCriteria - 1]) == 0)) {
|
((pads[1].button & exitButtons[loopExitCriteria - 1]) == 0)) {
|
||||||
|
// If any of the buttons are unset, or were pressed in the wrong order, reset
|
||||||
loopExitCriteria = 0;
|
loopExitCriteria = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Player let go of X+Y+Z, reset loop
|
||||||
loopExitCriteria = 0;
|
loopExitCriteria = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,10 +144,10 @@ void ErrorHandler(OSError code, OSContext* context, int dsisr, int dar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetErrorHandlers() {
|
void SetErrorHandlers() {
|
||||||
OSSetErrorHandler(2, (OSErrorHandler)ErrorHandler);
|
OSSetErrorHandler(OS_ERROR_DSI, (OSErrorHandler)ErrorHandler);
|
||||||
OSSetErrorHandler(3, (OSErrorHandler)ErrorHandler);
|
OSSetErrorHandler(OS_ERROR_ISI, (OSErrorHandler)ErrorHandler);
|
||||||
OSSetErrorHandler(5, (OSErrorHandler)ErrorHandler);
|
OSSetErrorHandler(OS_ERROR_ALIGNMENT, (OSErrorHandler)ErrorHandler);
|
||||||
OSSetErrorHandler(15, (OSErrorHandler)ErrorHandler);
|
OSSetErrorHandler(OS_ERROR_PROTECTION, (OSErrorHandler)ErrorHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rs_debugger_printf(const char* format, ...) {
|
void rs_debugger_printf(const char* format, ...) {
|
||||||
|
|
Loading…
Reference in New Issue