src/emu/romload.c
| r7714 | r7715 | |
| 1257 | 1257 | } |
| 1258 | 1258 | |
| 1259 | 1259 | |
| 1260 | #ifdef MESS |
| 1260 | 1261 | /*------------------------------------------------- |
| 1262 | load_software_part_region - load a software part |
| 1263 | |
| 1264 | This is used by MESS when loading a piece of |
| 1265 | software. The code should be merged with |
| 1266 | process_region_list or updated to use a slight |
| 1267 | more general process_region_list. |
| 1268 | -------------------------------------------------*/ |
| 1269 | |
| 1270 | void load_software_part_region(running_device *device, char *swlist, char *swname, rom_entry *start_region) |
| 1271 | { |
| 1272 | astring *regiontag = astring_alloc(); |
| 1273 | astring *locationtag = astring_alloc(); |
| 1274 | const rom_entry *region; |
| 1275 | rom_load_data *romdata = device->machine->romload_data; |
| 1276 | |
| 1277 | /* Make sure we are passed a device */ |
| 1278 | assert(device!=NULL); |
| 1279 | |
| 1280 | astring_assemble_3( locationtag, swlist, PATH_SEPARATOR, swname ); |
| 1281 | |
| 1282 | romdata->errorstring.reset(); |
| 1283 | |
| 1284 | /* loop until we hit the end */ |
| 1285 | for (region = start_region; region != NULL; region = rom_next_region(region)) |
| 1286 | { |
| 1287 | UINT32 regionlength = ROMREGION_GETLENGTH(region); |
| 1288 | UINT32 regionflags = ROMREGION_GETFLAGS(region); |
| 1289 | |
| 1290 | astring_assemble_3( regiontag, device->tag(), ":", ROMREGION_GETTAG(region) ); |
| 1291 | LOG(("Processing region \"%s\" (length=%X)\n", astring_c(regiontag), regionlength)); |
| 1292 | |
| 1293 | /* the first entry must be a region */ |
| 1294 | assert(ROMENTRY_ISREGION(region)); |
| 1295 | |
| 1296 | /* if this is a device region, override with the device width and endianness */ |
| 1297 | if (devtag_get_device(romdata->machine, astring_c(regiontag)) != NULL) |
| 1298 | regionflags = normalize_flags_for_device(romdata->machine, regionflags, astring_c(regiontag)); |
| 1299 | |
| 1300 | /* remember the base and length */ |
| 1301 | romdata->region = memory_region_alloc(romdata->machine, astring_c(regiontag), regionlength, regionflags); |
| 1302 | LOG(("Allocated %X bytes @ %p\n", romdata->region->length, romdata->region->base.v)); |
| 1303 | |
| 1304 | /* clear the region if it's requested */ |
| 1305 | if (ROMREGION_ISERASE(region)) |
| 1306 | memset(romdata->region->base.v, ROMREGION_GETERASEVAL(region), romdata->region->length); |
| 1307 | |
| 1308 | /* or if it's sufficiently small (<= 4MB) */ |
| 1309 | else if (romdata->region->length <= 0x400000) |
| 1310 | memset(romdata->region->base.v, 0, romdata->region->length); |
| 1311 | |
| 1312 | #ifdef MAME_DEBUG |
| 1313 | /* if we're debugging, fill region with random data to catch errors */ |
| 1314 | else |
| 1315 | fill_random(romdata->machine, romdata->region->base.u8, romdata->region->length); |
| 1316 | #endif |
| 1317 | |
| 1318 | /* now process the entries in the region */ |
| 1319 | if (ROMREGION_ISROMDATA(region)) |
| 1320 | process_rom_entries(romdata, astring_c(locationtag), region + 1); |
| 1321 | else if (ROMREGION_ISDISKDATA(region)) |
| 1322 | process_disk_entries(romdata, astring_c(locationtag), region + 1); |
| 1323 | } |
| 1324 | |
| 1325 | /* now go back and post-process all the regions */ |
| 1326 | for (region = start_region; region != NULL; region = rom_next_region(region)) |
| 1327 | region_post_process(romdata, ROMREGION_GETTAG(region)); |
| 1328 | |
| 1329 | astring_free(regiontag); |
| 1330 | astring_free(locationtag); |
| 1331 | |
| 1332 | /* display the results and exit */ |
| 1333 | display_rom_load_results(romdata); |
| 1334 | } |
| 1335 | #endif |
| 1336 | |
| 1337 | |
| 1338 | /*------------------------------------------------- |
| 1261 | 1339 | process_region_list - process a region list |
| 1262 | 1340 | -------------------------------------------------*/ |
| 1263 | 1341 | |