Debian Codegraph @

mednafen/mednafen.cpp

raw symbols SCIP
1 /* Mednafen - Multi-system Emulator
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18 #include "mednafen.h"cxx . . $ `<file>/mednafen/mednafen.h`/
19
20 #include <string.h>
21 #include <stdarg.h>
22 #include <errno.h>
23 #include <list>
24 #include <algorithm>
25
26 #include "general.h"cxx . . $ `<file>/mednafen/general.h`/
27
28 #include "state.h"cxx . . $ `<file>/mednafen/state.h`/
29 #include "video/surface.h"cxx . . $ `<file>/mednafen/video/surface.h`/
30 #include "file.h"cxx . . $ `<file>/mednafen/file.h`/
31
32 #include "mempatcher.h"cxx . . $ `<file>/mednafen/mempatcher.h`/
33
34 #ifdef _MSC_VER
35 #include "msvc_compat.h"
36 #endif
37
38 extern MDFNGIcxx . . $ MDFNGI# EmulatedVBcxx . . $ EmulatedVB.;
39 MDFNGIcxx . . $ MDFNGI# *MDFNGameInfocxx . . $ MDFNGameInfo. = &EmulatedVBcxx . . $ EmulatedVB.;
40
41 /* forward declarations */
42 extern void MDFND_DispMessagecxx . . $ MDFND_DispMessage(f25546b61a629de7).(unsigned char *str);
43
44 void MDFN_DispMessagecxx . . $ MDFN_DispMessage(326aeb464d16410c).(const char *format, ...)
45 {
46 va_list ap;
47 va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap,format);
48 char *msg = new char[4096];
49
50 vsnprintf(msg, 4096, format,ap);
51 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap);
52
53 MDFND_DispMessagecxx . . $ MDFND_DispMessage(f25546b61a629de7).((uint8_tcxx . . $ uint8_t#*)msg);
54 }
55
56 void MDFN_ResetMessagescxx . . $ MDFN_ResetMessages(49f6e7a06ebc5aa8).(void)
57 {
58 MDFND_DispMessagecxx . . $ MDFND_DispMessage(f25546b61a629de7).(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
59 }
60
61
62 MDFNGIcxx . . $ MDFNGI# *MDFNI_LoadGamecxx . . $ MDFNI_LoadGame(acefc047a690e6dc).(const char *force_module, const char *name)
63 {
64 MDFNFILEcxx . . $ MDFNFILE# GameFilecxx . . $ MDFNFILE#MDFNFILE(49f6e7a06ebc5aa8).;
65 stdcxx . . $ std/::vectorcxx . . $ std/vector#<FileExtensionSpecStructcxx . . $ FileExtensionSpecStruct#> valid_iaecxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
66 MDFNGameInfocxx . . $ MDFNGameInfo. = &EmulatedVBcxx . . $ EmulatedVB.;
67
68 MDFN_printfcxx . . $ MDFN_printf(326aeb464d16410c).(_cxx . . $ `mednafen/mednafen.h:9:9`!("Loading %s...\n"),name);
69
70 MDFN_indentcxx . . $ MDFN_indent(d4f767463ce0a6b3).(1);
71
72 // Construct a NULL-delimited list of known file extensions for MDFN_fopen()
73 const FileExtensionSpecStructcxx . . $ FileExtensionSpecStruct# *curexts = MDFNGameInfocxx . . $ MDFNGameInfo.->FileExtensionscxx . . $ $anonymous_type_643ef407c229d02_12#FileExtensions.;
74
75 while(curexts->extensioncxx . . $ $anonymous_type_643ef407c229d02_0#extension. && curexts->descriptioncxx . . $ $anonymous_type_643ef407c229d02_0#description.)
76 {
77 valid_iae.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(*curexts);
78 curexts++;
79 }
80
81 if(!GameFile.Opencxx . . $ MDFNFILE#Open(eb4f300025480a43).(name, &valid_iae[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0], _cxx . . $ `mednafen/mednafen.h:9:9`!("game")))
82 {
83 MDFNGameInfocxx . . $ MDFNGameInfo. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
84 return 0;
85 }
86
87 MDFN_printfcxx . . $ MDFN_printf(326aeb464d16410c).(_cxx . . $ `mednafen/mednafen.h:9:9`!("Using module: %s(%s)\n\n"), MDFNGameInfocxx . . $ MDFNGameInfo.->shortnamecxx . . $ $anonymous_type_643ef407c229d02_12#shortname., MDFNGameInfocxx . . $ MDFNGameInfo.->fullnamecxx . . $ $anonymous_type_643ef407c229d02_12#fullname.);
88 MDFN_indentcxx . . $ MDFN_indent(d4f767463ce0a6b3).(1);
89
90 //
91 // Load per-game settings
92 //
93 // Maybe we should make a "pgcfg" subdir, and automatically load all files in it?
94 // End load per-game settings
95 //
96
97 if(MDFNGameInfocxx . . $ MDFNGameInfo.->Loadcxx . . $ $anonymous_type_643ef407c229d02_12#Load.(name, &GameFile) <= 0)
98 {
99 GameFile.Closecxx . . $ MDFNFILE#Close(c9857a73d68e59ba).();
100 MDFN_indentcxx . . $ MDFN_indent(d4f767463ce0a6b3).(-2);
101 MDFNGameInfocxx . . $ MDFNGameInfo. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
102 return(0);
103 }
104
105 MDFN_LoadGameCheatscxx . . $ MDFN_LoadGameCheats(5d22bdacc48458e8).(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
106 MDFNMP_InstallReadPatchescxx . . $ MDFNMP_InstallReadPatches(49f6e7a06ebc5aa8).();
107
108 MDFN_ResetMessagescxx . . $ MDFN_ResetMessages(49f6e7a06ebc5aa8).(); // Save state, status messages, etc.
109
110 MDFN_indentcxx . . $ MDFN_indent(d4f767463ce0a6b3).(-2);
111
112 if(!MDFNGameInfocxx . . $ MDFNGameInfo.->namecxx . . $ $anonymous_type_643ef407c229d02_12#name.)
113 {
114 unsigned int x;
115 char *tmp;
116
117 MDFNGameInfocxx . . $ MDFNGameInfo.->namecxx . . $ $anonymous_type_643ef407c229d02_12#name. = (uint8_tcxx . . $ uint8_t#*)strdup(GetFNComponent(name));
118
119 for(x=0;x<strlen((char *)MDFNGameInfocxx . . $ MDFNGameInfo.->namecxx . . $ $anonymous_type_643ef407c229d02_12#name.);x++)
120 {
121 if(MDFNGameInfocxx . . $ MDFNGameInfo.->namecxx . . $ $anonymous_type_643ef407c229d02_12#name.[x] == '_')
122 MDFNGameInfocxx . . $ MDFNGameInfo.->namecxx . . $ $anonymous_type_643ef407c229d02_12#name.[x] = ' ';
123 }
124 if((tmp = strrchr((char *)MDFNGameInfocxx . . $ MDFNGameInfo.->namecxx . . $ $anonymous_type_643ef407c229d02_12#name., '.')))
125 *tmp = 0;
126 }
127
128 return(MDFNGameInfocxx . . $ MDFNGameInfo.);
129 }
130
131 void MDFNI_CloseGamecxx . . $ MDFNI_CloseGame(49f6e7a06ebc5aa8).(void)
132 {
133 if(!MDFNGameInfocxx . . $ MDFNGameInfo.)
134 return;
135
136 MDFN_FlushGameCheatscxx . . $ MDFN_FlushGameCheats(d4f767463ce0a6b3).(0);
137
138 MDFNGameInfocxx . . $ MDFNGameInfo.->CloseGamecxx . . $ $anonymous_type_643ef407c229d02_12#CloseGame.();
139
140 if(MDFNGameInfocxx . . $ MDFNGameInfo.->namecxx . . $ $anonymous_type_643ef407c229d02_12#name.)
141 freecxx . . $ free(bd21765a0afc8e3c).(MDFNGameInfocxx . . $ MDFNGameInfo.->namecxx . . $ $anonymous_type_643ef407c229d02_12#name.);
142 MDFNGameInfocxx . . $ MDFNGameInfo.->namecxx . . $ $anonymous_type_643ef407c229d02_12#name. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
143
144 MDFNMP_Killcxx . . $ MDFNMP_Kill(49f6e7a06ebc5aa8).();
145
146 MDFNGameInfocxx . . $ MDFNGameInfo. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
147 }
148
149 bool MDFNI_InitializeModulecxx . . $ MDFNI_InitializeModule(c9857a73d68e59ba).(void)
150 {
151 return(1);
152 }
153
154 int MDFNI_Initializecxx . . $ MDFNI_Initialize(5c4306d8553b3696).(const char *basedir)
155 {
156 return(1);
157 }
158
159 static int curindentcxx . . $ curindent. = 0;
160
161 void MDFN_indentcxx . . $ MDFN_indent(d4f767463ce0a6b3).(int indent)
162 {
163 curindentcxx . . $ curindent. += indent;
164 }
165
166 static uint8cxx . . $ uint8# lastcharcxx . . $ lastchar. = 0;
167
168 void MDFN_printfcxx . . $ MDFN_printf(326aeb464d16410c).(const char *format, ...)
169 {
170 char *format_temp;
171 char *temp;
172 unsigned int x, newlen;
173
174 va_list ap;
175 va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap,format);
176
177
178 // First, determine how large our format_temp buffer needs to be.
179 uint8cxx . . $ uint8# lastchar_backup = lastcharcxx . . $ lastchar.; // Save lastchar!
180 for(newlen=x=0;x<strlen(format);x++)
181 {
182 if(lastcharcxx . . $ lastchar. == '\n' && format[x] != '\n')
183 {
184 int y;
185 for(y=0;y<curindentcxx . . $ curindent.;y++)
186 newlen++;
187 }
188 newlen++;
189 lastcharcxx . . $ lastchar. = format[x];
190 }
191
192 format_temp = (char *)malloccxx . . $ malloc(9f008b2a9698428b).(newlen + 1); // Length + NULL character, duh
193
194 // Now, construct our format_temp string
195 lastcharcxx . . $ lastchar. = lastchar_backup; // Restore lastchar
196 for(newlen=x=0;x<strlen(format);x++)
197 {
198 if(lastcharcxx . . $ lastchar. == '\n' && format[x] != '\n')
199 {
200 int y;
201 for(y=0;y<curindentcxx . . $ curindent.;y++)
202 format_temp[newlen++] = ' ';
203 }
204 format_temp[newlen++] = format[x];
205 lastcharcxx . . $ lastchar. = format[x];
206 }
207
208 format_temp[newlen] = 0;
209
210 temp = new char[4096];
211 vsnprintf(temp, 4096, format_temp, ap);
212 freecxx . . $ free(bd21765a0afc8e3c).(format_temp);
213
214 MDFND_Messagecxx . . $ MDFND_Message(85c52e162fed56f9).(temp);
215 freecxx . . $ free(bd21765a0afc8e3c).(temp);
216
217 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap);
218 }
219
220 void MDFN_PrintErrorcxx . . $ MDFN_PrintError(326aeb464d16410c).(const char *format, ...)
221 {
222 char *temp;
223
224 va_list ap;
225
226 va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, format);
227 temp = new char[4096];
228 vsnprintf(temp, 4096, format, ap);
229 MDFND_PrintErrorcxx . . $ MDFND_PrintError(85c52e162fed56f9).(temp);
230 freecxx . . $ free(bd21765a0afc8e3c).(temp);
231
232 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap);
233 }
234
235 void MDFN_DebugPrintRealcxx . . $ MDFN_DebugPrintReal(b8982657348efbf7).(const char *file, const int line, const char *format, ...)
236 {
237 char *temp;
238
239 va_list ap;
240
241 va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, format);
242
243 temp = new char[4096];
244 vsnprintf(temp, 4096, format, ap);
245 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s:%d %s\n", file, line, temp);
246 freecxx . . $ free(bd21765a0afc8e3c).(temp);
247
248 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap);
249 }