- printf("[CFG] Failed to open file %s for ROM mapping. Using onboard ROM instead, if available.\n", filename);
- goto mapping_failed;
+ if (!autodump) {
+ printf("[CFG] Failed to open file %s for ROM mapping. Using onboard ROM instead, if available.\n", filename);
+ goto mapping_failed;
+ } else if (autodump == MAPCMD_AUTODUMP_FILE) {
+ printf("[CFG] Could not open file %s for ROM mapping. Autodump flag is set, dumping to file.\n", filename);
+ dump_range_to_file(cfg->map_offset[index], cfg->map_size[index], filename);
+ in = fopen(filename, "rb");
+ if (in == NULL) {
+ printf("[CFG] Could not open dumped file for reading. Using onboard ROM instead, if available.\n");
+ goto mapping_failed;
+ }
+ } else if (autodump == MAPCMD_AUTODUMP_MEM) {
+ printf("[CFG] Could not open file %s for ROM mapping. Autodump flag is set, dumping to memory.\n", filename);
+ cfg->map_data[index] = dump_range_to_memory(cfg->map_offset[index], cfg->map_size[index]);
+ cfg->rom_size[index] = cfg->map_size[index];
+ if (cfg->map_data[index] == NULL) {
+ printf("[CFG] Could not dump range to memory. Using onboard ROM instead, if available.\n");
+ goto mapping_failed;
+ }
+ goto skip_file_ops;
+ }