Match and link dvderror and dvdfatal

Former-commit-id: 5334004619
This commit is contained in:
2023-01-12 17:23:52 -08:00
parent 947259c900
commit ef7c00113a
8 changed files with 365 additions and 157 deletions

View File

@@ -0,0 +1,56 @@
#include "dolphin/DVDPriv.h"
#include "dolphin/OSRtcPriv.h"
static u32 ErrorTable[] = {
0, 0x00023A00, 0x00062800, 0x00030200, 0x00031100, 0x00052000,
0x00052001, 0x00052100, 0x00052400, 0x00052401, 0x00052402, 0x000B5A01,
0x00056300, 0x00020401, 0x00020400, 0x00040800, 0x00100007, 0,
};
static u8 ErrorCode2Num(u32 errorCode) {
u32 i;
for (i = 0; i < sizeof(ErrorTable) / sizeof(ErrorTable[0]); i++) {
if (ErrorTable[i] == errorCode) {
return (u8)i;
}
}
if ((errorCode >= 0x00100000) && (errorCode <= 0x00100008)) {
return 17;
}
return 29;
}
static u8 Convert(u32 error) {
u32 statusCode;
u32 errorCode;
u8 errorNum;
if (error == 0x01234567)
return 255;
if (error == 0x01234568)
return 254;
statusCode = (error & 0xff000000) >> 24;
errorCode = error & 0x00ffffff;
errorNum = ErrorCode2Num(errorCode);
if (statusCode >= 6)
statusCode = 6;
return (u8)(statusCode * 30 + errorNum);
}
void __DVDStoreErrorCode(u32 error) {
OSSramEx* sram;
u8 num;
num = Convert(error);
sram = __OSLockSramEx();
sram->dvdErrorCode = num;
__OSUnlockSramEx(TRUE);
}

136
src/Dolphin/dvd/dvdfatal.c Normal file
View File

@@ -0,0 +1,136 @@
#include "dolphin/DVDPriv.h"
#include "dolphin/gx/GXStruct.h"
#include "dolphin/os.h"
#include "dolphin/vi.h"
void __DVDPrintFatalMessage(void);
static void (*FatalFunc)(void) = NULL;
const char* Japanese = "\n\n\n<EFBFBD>G<EFBFBD><EFBFBD><EFBFBD>[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B"
"\n\n<EFBFBD>{<7B>̂̃p<CC83><70><EFBFBD>[<5B>{<7B>^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ēd<C493><64><EFBFBD><EFBFBD>OFF<46>ɂ<EFBFBD><C982>A"
"\n<EFBFBD>{<7B>̂̎戵<CC8E><E688B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̎w<CC8E><77><EFBFBD>ɏ]<5D><><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B";
const char* English = "\n\n\nAn error has occurred."
"\nTurn the power off and refer to the"
"\nNintendo GameCube Instruction Booklet"
"\nfor further instructions.";
const char* const Europe[] = {
// English
"\n\n\nAn error has occurred."
"\nTurn the power off and refer to the"
"\nNintendo GameCube""\x99"" Instruction Booklet"
"\nfor further instructions.",
// German
"\n\n\nEin Fehler ist aufgetreten."
"\nBitte schalten Sie den NINTENDO GAMECUBE"
"\naus und lesen Sie die Bedienungsanleitung,"
"\num weitere Informationen zu erhalten.",
// French
"\n\n\nUne erreur est survenue."
"\nEteignez la console et r" "\xe9" "f" "\xe9" "rez-vous au"
"\nmanuel d'instructions NINTENDO GAMECUBE"
"\npour de plus amples informations.",
// Spanish
"\n\n\nSe ha producido un error."
"\nApaga la consola y consulta el manual"
"\nde instrucciones de NINTENDO GAMECUBE"
"\npara obtener m""\xe1""s informaci""\xf3""n.",
// Italian
"\n\n\nSi \xe8 verificato un errore."
"\nSpegni (OFF) e controlla il manuale"
"\nd'istruzioni del NINTENDO GAMECUBE"
"\nper ulteriori indicazioni.",
// Dutch
"\n\n\nEr is een fout opgetreden."
"\nZet de NINTENDO GAMECUBE uit en"
"\nraadpleeg de handleiding van de"
"\nNintendo GameCube voor nadere"
"\ninstructies.",
};
static void ShowMessage(void) {
const char* message;
GXColor bg = {0, 0, 0, 0};
GXColor fg = {255, 255, 255, 0};
if (VIGetTvFormat() == VI_NTSC) {
if (OSGetFontEncode() == OS_FONT_ENCODE_SJIS) {
message = Japanese;
} else {
message = English;
}
} else {
message = Europe[OSGetLanguage()];
}
OSFatal(fg, bg, message);
}
#if NONMATCHING
BOOL DVDSetAutoFatalMessaging(BOOL enable) {
BOOL enabled;
BOOL prev;
enabled = OSDisableInterrupts();
prev = FatalFunc ? TRUE : FALSE;
FatalFunc = enable ? ShowMessage : NULL;
OSRestoreInterrupts(enabled);
return prev;
}
#else
/* clang-format off */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm BOOL DVDSetAutoFatalMessaging(BOOL enable) {
nofralloc
mflr r0
stw r0, 4(r1)
stwu r1, -0x18(r1)
stw r31, 0x14(r1)
stw r30, 0x10(r1)
mr r30, r3
bl OSDisableInterrupts
lwz r0, FatalFunc
cmplwi r0, 0
beq lbl_80374DFC
li r31, 1
b lbl_80374E00
lbl_80374DFC:
li r31, 0
lbl_80374E00:
cmpwi r30, 0
beq lbl_80374E14
lis r4, ShowMessage@ha
addi r0, r4, ShowMessage@l
b lbl_80374E18
lbl_80374E14:
li r0, 0
lbl_80374E18:
stw r0, FatalFunc
bl OSRestoreInterrupts
mr r3, r31
lwz r0, 0x1c(r1)
lwz r31, 0x14(r1)
lwz r30, 0x10(r1)
addi r1, r1, 0x18
mtlr r0
blr
}
#pragma pop
/* clang-format off */
#endif
void __DVDPrintFatalMessage(void) {
if (!FatalFunc) {
return;
}
FatalFunc();
}