--- trunk/src/file.c 2007/10/08 16:20:58 32 +++ trunk/src/file.c 2007/10/08 16:21:17 34 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2006 Anders Gavare. All rights reserved. + * Copyright (C) 2003-2007 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: file.c,v 1.135 2006/10/27 04:21:15 debug Exp $ + * $Id: file.c,v 1.140 2007/02/10 14:29:54 debug Exp $ * * This file contains functions which load executable images into (emulated) * memory. File formats recognized so far are: @@ -1405,7 +1405,7 @@ ok = 1; } break; - case ARCH_AVR32: + /* case ARCH_AVR32: switch (emachine) { case 6317: ok = 1; @@ -1428,7 +1428,7 @@ case EM_IA_64: ok = 1; } - break; + break; */ case ARCH_M68K: switch (emachine) { case EM_68K: @@ -1462,7 +1462,7 @@ ok = 1; } break; - case ARCH_X86: + /* case ARCH_X86: switch (emachine) { case EM_386: case EM_486: @@ -1474,7 +1474,7 @@ ok = 1; break; } - break; + break; */ default: fatal("file.c: INTERNAL ERROR: Unimplemented arch!\n"); } @@ -2086,6 +2086,31 @@ "floppy image. Maybe you forgot the\n-d switch?\n"); /* + * Ugly hack for Dreamcast: When booting from a Dreamcast CDROM + * image, a temporary file is extracted into /tmp/gxemul.*, but this + * is a "scrambled" raw binary. This code unscrambles it, and loads + * it as a raw binary. + */ + if (machine->machine_type == MACHINE_DREAMCAST && + strncmp(filename, "/tmp/gxemul.", 12) == 0) { + char *tmp_filename = malloc(strlen(filename) + 100); + snprintf(tmp_filename, strlen(filename) + 100, + "%s.descrambled", filename); + debug("descrambling into %s\n", tmp_filename); + dreamcast_descramble(filename, tmp_filename); + + snprintf(tmp_filename, strlen(filename) + 100, + "0x8c010000:%s.descrambled", filename); + debug("loading descrambled Dreamcast binary\n"); + file_load_raw(machine, mem, tmp_filename, entrypointp); + free(tmp_filename); + + /* Hack: Start a "boot from CDROM" sequence: */ + *entrypointp = 0x8c000080; + goto ret; + } + + /* * Last resort: symbol definitions from nm (or nm -S): * * If the buf contains typical 'binary' characters, then print