Match and link dvderror and dvdfatal

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

View File

@ -54,7 +54,9 @@
"osbootinfo.h": "c",
"assert.h": "c",
"math.h": "c",
"gxpriv.h": "c"
"gxpriv.h": "c",
"osfastcast.h": "c",
"osfont.h": "c"
},
"files.autoSave": "onFocusChange",
"files.insertFinalNewline": true,

View File

@ -24,159 +24,6 @@ lbl_803F0100:
.4byte 0x00100007
.4byte 0
.if version < 2
.global lbl_803F0148
lbl_803F0148:
# ROM: 0x3ED148
.4byte 0x0A0A0A83
.4byte 0x47838981
.4byte 0x5B82AA94
.4byte 0xAD90B682
.4byte 0xB582DC82
.4byte 0xB582BD81
.4byte 0x420A0A96
.4byte 0x7B91CC82
.4byte 0xCC837083
.4byte 0x8F815B83
.4byte 0x7B835E83
.4byte 0x9382F089
.4byte 0x9F82B582
.4byte 0xC493648C
.4byte 0xB982F04F
.4byte 0x464682C9
.4byte 0x82B58141
.4byte 0x0A967B91
.4byte 0xCC82CC8E
.4byte 0xE688B590
.4byte 0xE096BE8F
.4byte 0x9182CC8E
.4byte 0x778EA682
.4byte 0xC98F5D82
.4byte 0xC182C482
.4byte 0xAD82BE82
.4byte 0xB382A281
.4byte 0x42000000
.global lbl_803F01B8
lbl_803F01B8:
# ROM: 0x3ED1B8
.asciz "\n\n\nAn error has occurred.\nTurn the power off and refer to the\nNintendo GameCube Instruction Booklet\nfor further instructions."
.balign 4
.global lbl_803F0238
lbl_803F0238:
# ROM: 0x3ED238
.4byte 0x0A0A0A41
.4byte 0x6E206572
.4byte 0x726F7220
.4byte 0x68617320
.4byte 0x6F636375
.4byte 0x72726564
.4byte 0x2E0A5475
.4byte 0x726E2074
.4byte 0x68652070
.4byte 0x6F776572
.4byte 0x206F6666
.4byte 0x20616E64
.4byte 0x20726566
.4byte 0x65722074
.4byte 0x6F207468
.4byte 0x650A4E69
.4byte 0x6E74656E
.4byte 0x646F2047
.4byte 0x616D6543
.4byte 0x75626599
.asciz " Instruction Booklet\nfor further instructions."
.balign 4
.global lbl_803F02B8
lbl_803F02B8:
# ROM: 0x3ED2B8
.asciz "\n\n\nEin Fehler ist aufgetreten.\nBitte schalten Sie den NINTENDO GAMECUBE\naus und lesen Sie die Bedienungsanleitung,\num weitere Informationen zu erhalten."
.balign 4
.global lbl_803F0354
lbl_803F0354:
# ROM: 0x3ED354
.4byte 0x0A0A0A55
.4byte 0x6E652065
.4byte 0x72726575
.4byte 0x72206573
.4byte 0x74207375
.4byte 0x7276656E
.4byte 0x75652E0A
.4byte 0x45746569
.4byte 0x676E657A
.4byte 0x206C6120
.4byte 0x636F6E73
.4byte 0x6F6C6520
.4byte 0x65742072
.4byte 0xE966E972
.asciz "ez-vous au\nmanuel d'instructions NINTENDO GAMECUBE\npour de plus amples informations."
.balign 4
.global lbl_803F03E4
lbl_803F03E4:
# ROM: 0x3ED3E4
.4byte 0x0A0A0A53
.4byte 0x65206861
.4byte 0x2070726F
.4byte 0x64756369
.4byte 0x646F2075
.4byte 0x6E206572
.4byte 0x726F722E
.4byte 0x0A417061
.4byte 0x6761206C
.4byte 0x6120636F
.4byte 0x6E736F6C
.4byte 0x61207920
.4byte 0x636F6E73
.4byte 0x756C7461
.4byte 0x20656C20
.4byte 0x6D616E75
.4byte 0x616C0A64
.4byte 0x6520696E
.4byte 0x73747275
.4byte 0x6363696F
.4byte 0x6E657320
.4byte 0x6465204E
.4byte 0x494E5445
.4byte 0x4E444F20
.4byte 0x47414D45
.4byte 0x43554245
.4byte 0x0A706172
.4byte 0x61206F62
.4byte 0x74656E65
.4byte 0x72206DE1
.4byte 0x7320696E
.4byte 0x666F726D
.4byte 0x616369F3
.4byte 0x6E2E0000
.global lbl_803F046C
lbl_803F046C:
# ROM: 0x3ED46C
.4byte 0x0A0A0A53
.4byte 0x6920E820
.asciz "verificato un errore.\nSpegni (OFF) e controlla il manuale\nd'istruzioni del NINTENDO GAMECUBE\nper ulteriori indicazioni."
.global lbl_803F04EC
lbl_803F04EC:
# ROM: 0x3ED4EC
.asciz "\n\n\nEr is een fout opgetreden.\nZet de NINTENDO GAMECUBE uit en\nraadpleeg de handleiding van de\nNintendo GameCube voor nadere\ninstructies."
.balign 4
.endif
.section .text, "ax"
.global ErrorCode2Num

View File

@ -1,5 +1,161 @@
.include "macros.inc"
.section .data
.balign 8
.if version < 2
.global lbl_803F0148
lbl_803F0148:
# ROM: 0x3ED148
.4byte 0x0A0A0A83
.4byte 0x47838981
.4byte 0x5B82AA94
.4byte 0xAD90B682
.4byte 0xB582DC82
.4byte 0xB582BD81
.4byte 0x420A0A96
.4byte 0x7B91CC82
.4byte 0xCC837083
.4byte 0x8F815B83
.4byte 0x7B835E83
.4byte 0x9382F089
.4byte 0x9F82B582
.4byte 0xC493648C
.4byte 0xB982F04F
.4byte 0x464682C9
.4byte 0x82B58141
.4byte 0x0A967B91
.4byte 0xCC82CC8E
.4byte 0xE688B590
.4byte 0xE096BE8F
.4byte 0x9182CC8E
.4byte 0x778EA682
.4byte 0xC98F5D82
.4byte 0xC182C482
.4byte 0xAD82BE82
.4byte 0xB382A281
.4byte 0x42000000
.global lbl_803F01B8
lbl_803F01B8:
# ROM: 0x3ED1B8
.asciz "\n\n\nAn error has occurred.\nTurn the power off and refer to the\nNintendo GameCube Instruction Booklet\nfor further instructions."
.balign 4
.global lbl_803F0238
lbl_803F0238:
# ROM: 0x3ED238
.4byte 0x0A0A0A41
.4byte 0x6E206572
.4byte 0x726F7220
.4byte 0x68617320
.4byte 0x6F636375
.4byte 0x72726564
.4byte 0x2E0A5475
.4byte 0x726E2074
.4byte 0x68652070
.4byte 0x6F776572
.4byte 0x206F6666
.4byte 0x20616E64
.4byte 0x20726566
.4byte 0x65722074
.4byte 0x6F207468
.4byte 0x650A4E69
.4byte 0x6E74656E
.4byte 0x646F2047
.4byte 0x616D6543
.4byte 0x75626599
.asciz " Instruction Booklet\nfor further instructions."
.balign 4
.global lbl_803F02B8
lbl_803F02B8:
# ROM: 0x3ED2B8
.asciz "\n\n\nEin Fehler ist aufgetreten.\nBitte schalten Sie den NINTENDO GAMECUBE\naus und lesen Sie die Bedienungsanleitung,\num weitere Informationen zu erhalten."
.balign 4
.global lbl_803F0354
lbl_803F0354:
# ROM: 0x3ED354
.4byte 0x0A0A0A55
.4byte 0x6E652065
.4byte 0x72726575
.4byte 0x72206573
.4byte 0x74207375
.4byte 0x7276656E
.4byte 0x75652E0A
.4byte 0x45746569
.4byte 0x676E657A
.4byte 0x206C6120
.4byte 0x636F6E73
.4byte 0x6F6C6520
.4byte 0x65742072
.4byte 0xE966E972
.asciz "ez-vous au\nmanuel d'instructions NINTENDO GAMECUBE\npour de plus amples informations."
.balign 4
.global lbl_803F03E4
lbl_803F03E4:
# ROM: 0x3ED3E4
.4byte 0x0A0A0A53
.4byte 0x65206861
.4byte 0x2070726F
.4byte 0x64756369
.4byte 0x646F2075
.4byte 0x6E206572
.4byte 0x726F722E
.4byte 0x0A417061
.4byte 0x6761206C
.4byte 0x6120636F
.4byte 0x6E736F6C
.4byte 0x61207920
.4byte 0x636F6E73
.4byte 0x756C7461
.4byte 0x20656C20
.4byte 0x6D616E75
.4byte 0x616C0A64
.4byte 0x6520696E
.4byte 0x73747275
.4byte 0x6363696F
.4byte 0x6E657320
.4byte 0x6465204E
.4byte 0x494E5445
.4byte 0x4E444F20
.4byte 0x47414D45
.4byte 0x43554245
.4byte 0x0A706172
.4byte 0x61206F62
.4byte 0x74656E65
.4byte 0x72206DE1
.4byte 0x7320696E
.4byte 0x666F726D
.4byte 0x616369F3
.4byte 0x6E2E0000
.global lbl_803F046C
lbl_803F046C:
# ROM: 0x3ED46C
.4byte 0x0A0A0A53
.4byte 0x6920E820
.asciz "verificato un errore.\nSpegni (OFF) e controlla il manuale\nd'istruzioni del NINTENDO GAMECUBE\nper ulteriori indicazioni."
.global lbl_803F04EC
lbl_803F04EC:
# ROM: 0x3ED4EC
.asciz "\n\n\nEr is een fout opgetreden.\nZet de NINTENDO GAMECUBE uit en\nraadpleeg de handleiding van de\nNintendo GameCube voor nadere\ninstructies."
.balign 4
.endif
.if version < 2
.section .sdata

View File

@ -755,9 +755,9 @@ LIBS = [
["Dolphin/dvd/dvdfs", True],
["Dolphin/dvd/dvd", False],
"Dolphin/dvd/dvdqueue",
"Dolphin/dvd/dvderror",
["Dolphin/dvd/dvderror", True],
["Dolphin/dvd/dvdidutils", True],
"Dolphin/dvd/dvdfatal",
["Dolphin/dvd/dvdfatal", True],
["Dolphin/dvd/fstload", True],
],
},

View File

@ -87,7 +87,7 @@ typedef struct {
void DVDInit();
BOOL DVDClose(DVDFileInfo* f);
void DVDSetAutoFatalMessaging(BOOL);
BOOL DVDSetAutoFatalMessaging(BOOL);
void DVDReset();
s32 DVDCancel(DVDCommandBlock* block);

View File

@ -7,6 +7,17 @@
extern "C" {
#endif
#define OS_FONT_ENCODE_ANSI 0u
#define OS_FONT_ENCODE_SJIS 1u
#define OS_FONT_ENCODE_UTF8 3u // UTF-8 [RFC 3629]
#define OS_FONT_ENCODE_UTF16 4u // UTF-16BE [RFC 2781]
#define OS_FONT_ENCODE_UTF32 5u // UTF-32
#define OS_FONT_ENCODE_MAX 5u
#define OS_FONT_ENCODE_VOID 0xffffu
#define OS_FONT_PROPORTIONAL FALSE
#define OS_FONT_FIXED TRUE
u16 OSGetFontEncode(void);
u16 OSSetFontEncode(u16 encode);

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エラーが発生しました。"
"\n\n本体のパワーボタンを押して電源をOFFにし、"
"\n本体の取扱説明書の指示に従ってください。";
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();
}