summaryrefslogtreecommitdiff
path: root/src/Dolphin/dvd/dvdfatal.c
blob: ea8093c2e69e1efbaf9b617ddfc9ee72a0bd9772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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<83>G<83><89><81>[<82>ª<94>­<90>¶<82>µ<82>Ü<82>µ<82>½<81>B"
                       "\n\n<96>{<91>Ì<82>Ì<83>p<83><8f><81>[<83>{<83>^<83><93><82>ð<89><9f><82>µ<82>Ä<93>d<8c>¹<82>ðOFF<82>É<82>µ<81>A"
                       "\n<96>{<91>Ì<82>Ì<8e>æ<88>µ<90>à<96>¾<8f><91><82>Ì<8e>w<8e>¦<82>É<8f>]<82>Á<82>Ä<82>­<82>¾<82>³<82>¢<81>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);
}

#ifdef FULL_FRANK
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();
}