src/emu/diimage.c
| r14562 | r14563 | |
| 38 | 38 | ***************************************************************************/ |
| 39 | 39 | |
| 40 | 40 | #include "emu.h" |
| 41 | #include "emuopts.h" |
| 41 | 42 | #include "ui.h" |
| 42 | 43 | #include "zippath.h" |
| 43 | 44 | #include "uiimage.h" |
| r14562 | r14563 | |
| 845 | 846 | load_internal - core image loading |
| 846 | 847 | -------------------------------------------------*/ |
| 847 | 848 | |
| 848 | | bool device_image_interface::load_internal(const char *path, bool is_create, int create_format, option_resolution *create_args) |
| 849 | bool device_image_interface::load_internal(const char *path, bool is_create, int create_format, option_resolution *create_args, bool just_load) |
| 849 | 850 | { |
| 850 | 851 | UINT32 open_plan[4]; |
| 851 | 852 | int i; |
| r14562 | r14563 | |
| 926 | 927 | /* success! */ |
| 927 | 928 | |
| 928 | 929 | done: |
| 930 | if (just_load) { |
| 931 | if(m_err) clear(); |
| 932 | return m_err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS; |
| 933 | } |
| 929 | 934 | if (m_err!=0) { |
| 930 | 935 | if (!m_init_phase) |
| 931 | 936 | { |
| r14562 | r14563 | |
| 962 | 967 | |
| 963 | 968 | bool device_image_interface::load(const char *path) |
| 964 | 969 | { |
| 965 | | return load_internal(path, FALSE, 0, NULL); |
| 970 | return load_internal(path, FALSE, 0, NULL, FALSE); |
| 966 | 971 | } |
| 967 | 972 | |
| 973 | /*------------------------------------------------- |
| 974 | load_for_slot - load an image for slot device |
| 975 | -------------------------------------------------*/ |
| 968 | 976 | |
| 977 | bool device_image_interface::load_for_slot(emu_options &options) |
| 978 | { |
| 979 | const char* path = options.value(instance_name()); |
| 980 | if (strlen(path)>0) |
| 981 | { |
| 982 | set_init_phase(); |
| 983 | if (load_internal(path, FALSE, 0, NULL, TRUE)==IMAGE_INIT_PASS) |
| 984 | { |
| 985 | if (software_entry()==NULL) return true; |
| 986 | } |
| 987 | } |
| 988 | return false; |
| 989 | } |
| 990 | |
| 969 | 991 | /*------------------------------------------------- |
| 970 | 992 | image_finish_load - special call - only use |
| 971 | 993 | from core |
| r14562 | r14563 | |
| 1016 | 1038 | bool device_image_interface::create(const char *path, const image_device_format *create_format, option_resolution *create_args) |
| 1017 | 1039 | { |
| 1018 | 1040 | int format_index = (create_format != NULL) ? create_format->m_index : 0; |
| 1019 | | return load_internal(path, TRUE, format_index, create_args); |
| 1041 | return load_internal(path, TRUE, format_index, create_args, FALSE); |
| 1020 | 1042 | } |
| 1021 | 1043 | |
| 1022 | 1044 | |
src/emu/diimage.h
| r14562 | r14563 | |
| 246 | 246 | image_device_format *formatlist() const { return m_formatlist; } |
| 247 | 247 | |
| 248 | 248 | bool load(const char *path); |
| 249 | bool load_for_slot(emu_options &options); |
| 249 | 250 | bool finish_load(); |
| 250 | 251 | void unload(); |
| 251 | 252 | bool create(const char *path, const image_device_format *create_format, option_resolution *create_args); |
| r14562 | r14563 | |
| 253 | 254 | int reopen_for_write(const char *path); |
| 254 | 255 | |
| 255 | 256 | protected: |
| 256 | | bool load_internal(const char *path, bool is_create, int create_format, option_resolution *create_args); |
| 257 | bool load_internal(const char *path, bool is_create, int create_format, option_resolution *create_args, bool just_load); |
| 257 | 258 | void determine_open_plan(int is_create, UINT32 *open_plan); |
| 258 | 259 | image_error_t load_image_by_path(UINT32 open_flags, const char *path); |
| 259 | 260 | void clear(); |
src/mess/machine/c64exp.c
| r14562 | r14563 | |
| 8 | 8 | **********************************************************************/ |
| 9 | 9 | |
| 10 | 10 | #include "emu.h" |
| 11 | | #include "emuopts.h" |
| 12 | 11 | #include "machine/c64exp.h" |
| 13 | 12 | #include "formats/cbm_crt.h" |
| 14 | 13 | #include "formats/imageutl.h" |
| r14562 | r14563 | |
| 289 | 288 | |
| 290 | 289 | UINT16 hardware = pick_integer_be(header.hardware, 0, 2); |
| 291 | 290 | |
| 292 | | // TODO support other cartridge hardware |
| 293 | | if (hardware != CRT_C64_STANDARD) |
| 294 | | return IMAGE_INIT_FAIL; |
| 295 | | |
| 296 | 291 | if (LOG) |
| 297 | 292 | { |
| 298 | 293 | logerror("Name: %s\n", header.name); |
| r14562 | r14563 | |
| 404 | 399 | |
| 405 | 400 | const char * c64_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options) |
| 406 | 401 | { |
| 402 | if (load_for_slot(options)) |
| 403 | { |
| 404 | if (!mame_stricmp(filetype(), "crt")) |
| 405 | { |
| 406 | // read the header |
| 407 | cbm_crt_header header; |
| 408 | fread(&header, CRT_HEADER_LENGTH); |
| 409 | |
| 410 | if (memcmp(header.signature, CRT_SIGNATURE, 16) == 0) |
| 411 | { |
| 412 | UINT16 hardware = pick_integer_be(header.hardware, 0, 2); |
| 413 | return CRT_C64_SLOT_NAMES[hardware]; |
| 414 | } |
| 415 | } |
| 416 | } |
| 407 | 417 | return software_get_default_slot(config, options, this, "standard"); |
| 408 | 418 | } |
| 409 | 419 | |