src/emu/diimage.c
| r8703 | r8704 | |
| 271 | 271 | void device_image_interface::clear_error() |
| 272 | 272 | { |
| 273 | 273 | m_err = IMAGE_ERROR_SUCCESS; |
| 274 | | if (m_err_message.len()==0) |
| 274 | if (m_err_message.len()!=0) |
| 275 | 275 | { |
| 276 | | //image_freeptr(image->dev, image->err_message); |
| 277 | 276 | m_err_message.reset(); |
| 278 | 277 | } |
| 279 | 278 | } |
| r8703 | r8704 | |
| 284 | 283 | error - returns the error text for an image |
| 285 | 284 | error |
| 286 | 285 | -------------------------------------------------*/ |
| 286 | static const char *const messages[] = |
| 287 | { |
| 288 | "", |
| 289 | "Internal error", |
| 290 | "Unsupported operation", |
| 291 | "Out of memory", |
| 292 | "File not found", |
| 293 | "Invalid image", |
| 294 | "File already open", |
| 295 | "Unspecified error" |
| 296 | }; |
| 287 | 297 | |
| 288 | 298 | const char *device_image_interface::error() |
| 289 | 299 | { |
| 290 | | static const char *const messages[] = |
| 291 | | { |
| 292 | | NULL, |
| 293 | | "Internal error", |
| 294 | | "Unsupported operation", |
| 295 | | "Out of memory", |
| 296 | | "File not found", |
| 297 | | "Invalid image", |
| 298 | | "File already open", |
| 299 | | "Unspecified error" |
| 300 | | }; |
| 301 | | |
| 302 | | return m_err_message.len()==0 ? m_err_message : astring(messages[m_err]); |
| 300 | return (m_err_message.len()!=0) ? m_err_message.cstr() : messages[m_err]; |
| 303 | 301 | } |
| 304 | 302 | |
| 305 | 303 | |
src/emu/devimage.c
| r8703 | r8704 | |
| 345 | 345 | |
| 346 | 346 | bool legacy_image_device_base::load_internal(const char *path, bool is_create, int create_format, option_resolution *create_args) |
| 347 | 347 | { |
| 348 | | image_error_t err; |
| 349 | 348 | UINT32 open_plan[4]; |
| 350 | 349 | int i; |
| 351 | 350 | bool softload = FALSE; |
| r8703 | r8704 | |
| 360 | 359 | m_is_loading = TRUE; |
| 361 | 360 | |
| 362 | 361 | /* record the filename */ |
| 363 | | err = set_image_filename(path); |
| 364 | | if (err) |
| 362 | m_err = set_image_filename(path); |
| 363 | if (m_err) |
| 365 | 364 | goto done; |
| 366 | 365 | |
| 367 | 366 | /* Check if there's a software list defined for this device and use that if we're not creating an image */ |
| r8703 | r8704 | |
| 375 | 374 | for (i = 0; !m_file && open_plan[i]; i++) |
| 376 | 375 | { |
| 377 | 376 | /* open the file */ |
| 378 | | err = load_image_by_path(open_plan[i], path); |
| 379 | | if (err && (err != IMAGE_ERROR_FILENOTFOUND)) |
| 377 | m_err = load_image_by_path(open_plan[i], path); |
| 378 | if (m_err && (m_err != IMAGE_ERROR_FILENOTFOUND)) |
| 380 | 379 | goto done; |
| 381 | 380 | } |
| 382 | 381 | } |
| r8703 | r8704 | |
| 392 | 391 | |
| 393 | 392 | /* did we fail to find the file? */ |
| 394 | 393 | if (!is_loaded() && !softload) |
| 395 | | { |
| 396 | | err = IMAGE_ERROR_FILENOTFOUND; |
| 394 | { |
| 395 | m_err = IMAGE_ERROR_FILENOTFOUND; |
| 397 | 396 | goto done; |
| 398 | 397 | } |
| 399 | 398 | |
| r8703 | r8704 | |
| 402 | 401 | m_create_args = create_args; |
| 403 | 402 | |
| 404 | 403 | if (m_init_phase==FALSE) { |
| 405 | | err = (image_error_t)finish_load(); |
| 406 | | if (err) |
| 404 | m_err = (image_error_t)finish_load(); |
| 405 | if (m_err) |
| 407 | 406 | goto done; |
| 408 | 407 | } |
| 409 | 408 | /* success! */ |
| 410 | 409 | |
| 411 | 410 | done: |
| 412 | | if (m_err) { |
| 411 | if (m_err!=0) { |
| 413 | 412 | if (!m_init_phase) |
| 414 | 413 | { |
| 415 | 414 | if (machine->phase() == MACHINE_PHASE_RUNNING) |
| r8703 | r8704 | |
| 434 | 433 | } |
| 435 | 434 | } |
| 436 | 435 | } |
| 437 | | return err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS; |
| 436 | return m_err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS; |
| 438 | 437 | } |
| 439 | 438 | |
| 440 | 439 | |
| r8703 | r8704 | |
| 606 | 605 | void *legacy_image_device_base::get_device_specific_call() |
| 607 | 606 | { |
| 608 | 607 | return (void*) m_config.get_legacy_config_fct(DEVINFO_FCT_DEVICE_SPECIFIC); |
| 609 | | } |
| 608 | } |
| | No newline at end of file |
src/emu/image.c
| r8703 | r8704 | |
| 225 | 225 | if (result) |
| 226 | 226 | { |
| 227 | 227 | /* retrieve image error message */ |
| 228 | | const char *image_err = image->error(); |
| 228 | astring image_err = astring(image->error()); |
| 229 | 229 | const char *image_basename_str = image->basename(); |
| 230 | | |
| 231 | 230 | /* unload all images */ |
| 232 | 231 | image_unload_all(*machine); |
| 233 | 232 | |
| 234 | 233 | fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s", |
| 235 | 234 | image->image_config().devconfig().name(), |
| 236 | 235 | image_basename_str, |
| 237 | | image_err); |
| 236 | image_err.cstr()); |
| 238 | 237 | } |
| 239 | 238 | } |
| 240 | 239 | else |
| r8703 | r8704 | |
| 267 | 266 | if (result) |
| 268 | 267 | { |
| 269 | 268 | /* retrieve image error message */ |
| 270 | | const char *image_err = image->error(); |
| 269 | astring image_err = astring(image->error()); |
| 271 | 270 | const char *image_basename_str = image->basename(); |
| 272 | 271 | |
| 273 | 272 | /* unload all images */ |
| r8703 | r8704 | |
| 276 | 275 | fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s", |
| 277 | 276 | image->image_config().devconfig().name(), |
| 278 | 277 | image_basename_str, |
| 279 | | image_err); |
| 278 | image_err.cstr()); |
| 280 | 279 | } |
| 281 | 280 | } |
| 282 | 281 | |