/* SDEXT emulation currently excepts the cartridge area (segments 4-7) to be filled * with the FLASH ROM content. Even segment 7, which will be copied to the second 64K "hidden" * and pagable flash area of the SD cartridge. Currently, there is no support for the full * sized SDEXT flash image */ void sdext_init ( void ) { /* try to detect SDEXT ROM extension and only turn on emulation if it exists */ if (sdext_detect_rom()) { WARNING_WINDOW("No SD-card cartridge ROM code found in loaded ROM set. SD card hardware emulation has been disabled!"); *sdimg_path = 0; sdf = NULL; SD_DEBUG("SDEXT: init: REFUSE: no SD-card cartridge ROM code found in loaded ROM set." NL); return; } SD_DEBUG("SDEXT: init: cool, SD-card cartridge ROM code seems to be found in loaded ROM set, enabling SD card hardware emulation ..." NL); sdf = open_emu_file(config_getopt_str("sdimg"), "rb", sdimg_path); // open in read-only mode, to get the path if (sdf) { fclose(sdf); sdf = fopen(sdimg_path, "r+b"); if (sdf) { DEBUGPRINT("SDEXT: SD image file is re-open in read/write mode, good (fd=%d)." NL, fileno(sdf)); } else { sdf = fopen(sdimg_path, "rb"); DEBUGPRINT("SDEXT: SD image cannot be re-open in read-write mode, using read-only access (fd=%d)." NL, fileno(sdf)); } } if (!sdf) { WARNING_WINDOW("SD card image file \"%s\" cannot be open: %s. You can use Xep128 but SD card access won't work!", sdimg_path, ERRSTR()); *sdimg_path = 0; } else { sdfd = fileno(sdf); sd_card_size = lseek(sdfd, 0, SEEK_END); SD_DEBUG("SDEXT: SD card size is: %ld bytes" NL, sd_card_size); if (sd_card_size > MAX_CARD_SIZE || sd_card_size < MIN_CARD_SIZE) { fclose(sdf); sdf = NULL; ERROR_WINDOW("SD card image file \"%s\" is too small or large, valid range is %ld - %ld Mbytes, but this one is %ld bytes long (about %ld Mbytes). SD access has been disabled!", sdimg_path, MIN_CARD_SIZE >> 20, MAX_CARD_SIZE >> 20, sd_card_size, sd_card_size >> 20 ); *sdimg_path = 0; } }
void c65_d81_init ( const char *dfn ) { atexit(c65_d81_shutdown); fdc_init(); disk_inserted = 0; read_only = 1; if (disk_fd >= 0) close(disk_fd); disk_fd = -1; if (dfn) { // Note about O_BINARY: it's a windows stuff, it won't work without that. // HOWEVER, O_BINARY defined as zero on non-win archs in one of my include headers, thus it won't bother us with the good OSes :) disk_fd = open(dfn, O_RDWR|O_BINARY); // First, try to open D81 file in read-write mode if (disk_fd < 0) { disk_fd = open(dfn, O_RDONLY|O_BINARY); // If R/W was not ok, try read-only! if (disk_fd >= 0) { WARNING_WINDOW("Disk image \"%s\" could be open only in read-only mode", dfn); disk_inserted = 1; } else { ERROR_WINDOW("Couldn't open disk image \"%s\": %s", dfn, strerror(errno)); } } else { disk_inserted = 1; read_only = 0; } } if (disk_inserted) { off_t size = lseek(disk_fd, 0, SEEK_END); if (size < 0) FATAL("D81: host-OS error while testing image size: %s", strerror(errno)); if (size != D81_SIZE) { ERROR_WINDOW("Image size is wrong, got %d, should be %d", (int)size, D81_SIZE); disk_inserted = 0; } } if (!disk_inserted) { read_only = 1; if (disk_fd >= 0) { close(disk_fd); disk_fd = -1; } ERROR_WINDOW("No valid D81 found, or given (in command line). There will be no available disk emulated."); } fdc_set_disk(disk_inserted, !read_only); }