Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/yabause/src/error.c
2 views
1
/* Copyright 2005-2006 Theo Berkau
2
3
This file is part of Yabause.
4
5
Yabause is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
9
10
Yabause is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with Yabause; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
*/
19
20
#include <stdio.h>
21
#include <stdlib.h>
22
#include <string.h>
23
#include "error.h"
24
#include "yui.h"
25
26
//////////////////////////////////////////////////////////////////////////////
27
28
static void AllocAmendPrintString(const char *string1, const char *string2)
29
{
30
char *string;
31
32
if ((string = (char *)malloc(strlen(string1) + strlen(string2) + 2)) == NULL)
33
return;
34
35
sprintf(string, "%s%s\n", string1, string2);
36
YuiErrorMsg(string);
37
38
free(string);
39
}
40
41
//////////////////////////////////////////////////////////////////////////////
42
43
void YabSetError(int type, const void *extra)
44
{
45
char tempstr[512];
46
SH2_struct *sh;
47
48
switch (type)
49
{
50
case YAB_ERR_FILENOTFOUND:
51
AllocAmendPrintString(_("File not found: "), extra);
52
break;
53
case YAB_ERR_MEMORYALLOC:
54
YuiErrorMsg(_("Error allocating memory\n"));
55
break;
56
case YAB_ERR_FILEREAD:
57
AllocAmendPrintString(_("Error reading file: "), extra);
58
break;
59
case YAB_ERR_FILEWRITE:
60
AllocAmendPrintString(_("Error writing file: "), extra);
61
break;
62
case YAB_ERR_CANNOTINIT:
63
AllocAmendPrintString(_("Cannot initialize "), extra);
64
break;
65
case YAB_ERR_SH2INVALIDOPCODE:
66
sh = (SH2_struct *)extra;
67
SH2GetRegisters(sh, &sh->regs);
68
sprintf(tempstr, "%s SH2 invalid opcode\n\n"
69
"R0 = %08lX\tR12 = %08lX\n"
70
"R1 = %08lX\tR13 = %08lX\n"
71
"R2 = %08lX\tR14 = %08lX\n"
72
"R3 = %08lX\tR15 = %08lX\n"
73
"R4 = %08lX\tSR = %08lX\n"
74
"R5 = %08lX\tGBR = %08lX\n"
75
"R6 = %08lX\tVBR = %08lX\n"
76
"R7 = %08lX\tMACH = %08lX\n"
77
"R8 = %08lX\tMACL = %08lX\n"
78
"R9 = %08lX\tPR = %08lX\n"
79
"R10 = %08lX\tPC = %08lX\n"
80
"R11 = %08lX\n", sh->isslave ? "Slave" : "Master",
81
(long)sh->regs.R[0], (long)sh->regs.R[12],
82
(long)sh->regs.R[1], (long)sh->regs.R[13],
83
(long)sh->regs.R[2], (long)sh->regs.R[14],
84
(long)sh->regs.R[3], (long)sh->regs.R[15],
85
(long)sh->regs.R[4], (long)sh->regs.SR.all,
86
(long)sh->regs.R[5], (long)sh->regs.GBR,
87
(long)sh->regs.R[6], (long)sh->regs.VBR,
88
(long)sh->regs.R[7], (long)sh->regs.MACH,
89
(long)sh->regs.R[8], (long)sh->regs.MACL,
90
(long)sh->regs.R[9], (long)sh->regs.PR,
91
(long)sh->regs.R[10], (long)sh->regs.PC,
92
(long)sh->regs.R[11]);
93
YuiErrorMsg(tempstr);
94
break;
95
case YAB_ERR_SH2READ:
96
YuiErrorMsg(_("SH2 read error\n")); // fix me
97
break;
98
case YAB_ERR_SH2WRITE:
99
YuiErrorMsg(_("SH2 write error\n")); // fix me
100
break;
101
case YAB_ERR_SDL:
102
AllocAmendPrintString(_("SDL Error: "), extra);
103
break;
104
case YAB_ERR_OTHER:
105
YuiErrorMsg((char *)extra);
106
break;
107
case YAB_ERR_UNKNOWN:
108
default:
109
YuiErrorMsg(_("Unknown error occurred\n"));
110
break;
111
}
112
}
113
114
//////////////////////////////////////////////////////////////////////////////
115
116
117