Lines 22-28
Link Here
|
22 |
#include <string.h> |
22 |
#include <string.h> |
23 |
#include <sys/types.h> |
23 |
#include <sys/types.h> |
24 |
#include <sys/stat.h> |
24 |
#include <sys/stat.h> |
25 |
|
25 |
#include <fcntl.h> |
|
|
26 |
|
26 |
#include "AutoBuild.h" |
27 |
#include "AutoBuild.h" |
27 |
|
28 |
|
28 |
#include "SDL.h" |
29 |
#include "SDL.h" |
Lines 170-175
Link Here
|
170 |
void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int) = NULL; |
171 |
void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int) = NULL; |
171 |
void (*ifbFunction)(u8*,u32,int,int) = NULL; |
172 |
void (*ifbFunction)(u8*,u32,int,int) = NULL; |
172 |
int ifbType = 0; |
173 |
int ifbType = 0; |
|
|
174 |
char cheatfile[2048] = ""; |
173 |
char filename[2048]; |
175 |
char filename[2048]; |
174 |
char ipsname[2048]; |
176 |
char ipsname[2048]; |
175 |
char biosFileName[2048]; |
177 |
char biosFileName[2048]; |
Lines 305-310
Link Here
|
305 |
{ "agb-print", no_argument, &sdlAgbPrint, 1 }, |
307 |
{ "agb-print", no_argument, &sdlAgbPrint, 1 }, |
306 |
{ "auto-frameskip", no_argument, &autoFrameSkip, 1 }, |
308 |
{ "auto-frameskip", no_argument, &autoFrameSkip, 1 }, |
307 |
{ "bios", required_argument, 0, 'b' }, |
309 |
{ "bios", required_argument, 0, 'b' }, |
|
|
310 |
{ "cheat", required_argument, 0, 'C' }, |
308 |
{ "config", required_argument, 0, 'c' }, |
311 |
{ "config", required_argument, 0, 'c' }, |
309 |
{ "debug", no_argument, 0, 'd' }, |
312 |
{ "debug", no_argument, 0, 'd' }, |
310 |
{ "filter", required_argument, 0, 'f' }, |
313 |
{ "filter", required_argument, 0, 'f' }, |
Lines 1872-1877
Link Here
|
1872 |
4 - IYUV\n\ |
1875 |
4 - IYUV\n\ |
1873 |
-b, --bios=BIOS Use given bios file\n\ |
1876 |
-b, --bios=BIOS Use given bios file\n\ |
1874 |
-c, --config=FILE Read the given configuration file\n\ |
1877 |
-c, --config=FILE Read the given configuration file\n\ |
|
|
1878 |
-C, --cheat=FILE Read the given cheat file\n\ |
1875 |
-d, --debug Enter debugger\n\ |
1879 |
-d, --debug Enter debugger\n\ |
1876 |
-f, --filter=FILTER Select filter:\n\ |
1880 |
-f, --filter=FILTER Select filter:\n\ |
1877 |
--filter-normal 0 - normal mode\n\ |
1881 |
--filter-normal 0 - normal mode\n\ |
Lines 1988-1993
Link Here
|
1988 |
fclose(f); |
1992 |
fclose(f); |
1989 |
} |
1993 |
} |
1990 |
break; |
1994 |
break; |
|
|
1995 |
case 'C': |
1996 |
{ |
1997 |
if(optarg == NULL) { |
1998 |
fprintf(stderr, "Missing cheat file name\n"); |
1999 |
exit(-1); |
2000 |
} |
2001 |
strncpy(cheatfile,optarg,2047); |
2002 |
cheatfile[2047]='\0'; |
2003 |
} |
2004 |
break; |
1991 |
case 'd': |
2005 |
case 'd': |
1992 |
debugger = true; |
2006 |
debugger = true; |
1993 |
break; |
2007 |
break; |
Lines 2245-2250
Link Here
|
2245 |
CPUReset(); |
2259 |
CPUReset(); |
2246 |
} |
2260 |
} |
2247 |
} |
2261 |
} |
|
|
2262 |
if (strcmp(cheatfile, "") != 0) { |
2263 |
int fd; |
2264 |
fd = open(cheatfile,O_RDONLY); |
2265 |
if (fd != -1) { |
2266 |
struct stat buf; |
2267 |
fstat(fd,&buf); |
2268 |
if (buf.st_size <= 65536) { |
2269 |
char buffer[buf.st_size+1]; |
2270 |
buffer[buf.st_size] = '\0'; |
2271 |
if (read(fd, buffer, buf.st_size) != buf.st_size) |
2272 |
printf("Cheat file read error.\n"); |
2273 |
else { |
2274 |
int i = 0, c = 0; |
2275 |
char *code, *desc; |
2276 |
while (c < buf.st_size) { |
2277 |
code = desc = ""; |
2278 |
while (c < buf.st_size && |
2279 |
buffer[c] == ' ' || buffer[c] == '\t' || |
2280 |
buffer[c] == '\n' || buffer[c] == '\r') |
2281 |
c++; |
2282 |
if (c < buf.st_size) { |
2283 |
code = &buffer[c]; |
2284 |
while (c < buf.st_size && |
2285 |
buffer[c] != '#' && |
2286 |
buffer[c] != '\r' && |
2287 |
buffer[c] != '\n') |
2288 |
c++; |
2289 |
if (c < buf.st_size) { |
2290 |
if (buffer[c] == '#') { |
2291 |
buffer[c++] = '\0'; |
2292 |
desc = &buffer[c]; |
2293 |
while (c < buf.st_size && |
2294 |
buffer[c] != '\r' && |
2295 |
buffer[c] != '\n') |
2296 |
c++; |
2297 |
if (c < buf.st_size) |
2298 |
buffer[c++] = '\0'; |
2299 |
} else |
2300 |
buffer[c++] = '\0'; |
2301 |
|
2302 |
} |
2303 |
if (strlen(code) >= 17) { |
2304 |
code[17] = '\0'; |
2305 |
printf("GSA Code: #%s# ; Desc: #%s#\n", code, desc); |
2306 |
int j; |
2307 |
for (j = 8; j < 17; j++) |
2308 |
{ |
2309 |
code[j] = code[j+1]; |
2310 |
} |
2311 |
cheatsAddGSACode(code, desc, 1); |
2312 |
cheatsEnable(i++); |
2313 |
} else if (strlen(code) >= 13) { |
2314 |
code[13] = '\0'; |
2315 |
printf("CBA Code: #%s# ; Desc: #%s#\n", code, desc); |
2316 |
cheatsAddCBACode(code, desc); |
2317 |
cheatsEnable(i++); |
2318 |
} |
2319 |
} |
2320 |
} |
2321 |
} |
2322 |
} else { |
2323 |
printf("Cheat file too large (>64K).\n"); |
2324 |
} |
2325 |
} else |
2326 |
printf("Cheat file error.\n"); |
2327 |
} |
2248 |
} |
2328 |
} |
2249 |
} |
2329 |
} |
2250 |
|
2330 |
|