Exemplo n.º 1
0
  void checkfilename (char *currentfilename)
  {
  	char *ret = NULL, *fname = NULL;
  	char *ptr;
  	char actualpath [PATH_MAX];
  	struct dirent **namelist;
  	DIR *dir;
  	
  	if ((dir = opendir(currentfilename)))
  	{ 
  	  dirList=currentfilename;
  	  ptr = realpath(currentfilename, actualpath);
  	  strcpy(currentDir, ptr);
  	  closedir(dir);
  	}
  	else 
  	{
  	  if ((menu_load_type == MENU_SELECT_FILE) && confirmselection)
  	  {
		selectedFilePath=currentfilename;
	  if (autostart_autodetect(selectedFilePath.c_str(), NULL, 0, AUTOSTART_MODE_RUN) < 0) {
                //ui_error("could not start auto-image");
            }
#ifdef ANDROID	  
		SDL_ANDROID_SetScreenKeyboardShown(1);
#endif
		running = false;
	  }
	  else if ((menu_load_type == MENU_SELECT_DRIVE8) && confirmselection)
  	  {
		selectedFilePath8=currentfilename;
		int err8 = file_system_attach_disk(8, selectedFilePath8.c_str());
	  }
	  else if ((menu_load_type == MENU_SELECT_DRIVE9) && confirmselection)
  	  {
		selectedFilePath9=currentfilename;
		int err9 = file_system_attach_disk(9, selectedFilePath9.c_str());
	  }
	  else if ((menu_load_type == MENU_SELECT_DRIVE10) && confirmselection)
  	  {
		selectedFilePath10=currentfilename;
		int err10 = file_system_attach_disk(10, selectedFilePath9.c_str());
	  }
	  else if ((menu_load_type == MENU_SELECT_DRIVE11) && confirmselection)
  	  {
		selectedFilePath11=currentfilename;
		int err11 = file_system_attach_disk(11, selectedFilePath10.c_str());
	  }
  	  if (confirmselection)
	    unraise_loadMenu_guichan();
  	}
  }
Exemplo n.º 2
0
static int set_attach_device_readonly(int value, void *param)
{
    unsigned int unit = vice_ptr_to_uint(param);
    const char *old_filename;
    char *new_filename;
    int rc;
    int val = value ? 1 : 0;

    /* Do nothing if resource is unchanged. */
    if (attach_device_readonly_enabled[unit - 8] == val) {
        return 0;
    }

    old_filename = file_system_get_disk_name(unit);

    /* If no disk is attached, just changed the resource.  */
    if (old_filename == NULL) {
        attach_device_readonly_enabled[unit - 8] = val;
        return 0;
    }

    /* Old filename will go away after the image is detached.  */
    new_filename = lib_stralloc(old_filename);

    file_system_detach_disk(unit);
    attach_device_readonly_enabled[unit - 8] = val;

    rc = file_system_attach_disk(unit, new_filename);

    lib_free(new_filename);

    return rc;
}
Exemplo n.º 3
0
static TUI_MENU_CALLBACK(create_disk_image_callback)
{
    if (been_activated) {
        unsigned int drive;

        drive = (unsigned int)param;

        if (file_name == NULL) {
            tui_error("Specify a disk image name.");
            return NULL;
        }

        if (vdrive_internal_create_format_disk_image(file_name, format_name, image_type[file_type]) < 0) {
            tui_error("Could not create disk image!");
            return NULL;
        }

        if (drive > 0) {
            if (file_system_attach_disk(drive, file_name) < 0) {
                tui_error("Could not attach disk image!");
                return NULL;
            }
        }

        ui_update_menus();
    }

    return NULL;
}
Exemplo n.º 4
0
/* Autostart disk image `file_name'.  */
int autostart_disk(const char *file_name, const char *program_name,
                   unsigned int program_number, unsigned int runmode)
{
    char *name = NULL;

    if (network_connected() || !file_name || !autostart_enabled)
        return -1;

    /* Get program name first to avoid more than one file handle open on
       image.  */
    if (!program_name && program_number > 0)
        name = image_contents_filename_by_number(IMAGE_CONTENTS_DISK,
                                                 file_name, 0, program_number);
    else
        name = lib_stralloc(program_name ? program_name : "*");

    if (name) {
        autostart_disk_cook_name(&name);
        if (!(file_system_attach_disk(8, file_name) < 0)) {
            log_message(autostart_log,
                        "Attached file `%s' as a disk image.", file_name);
            reboot_for_autostart(name, AUTOSTART_HASDISK, runmode);
            lib_free(name);

            return 0;
        }
    }

    autostartmode = AUTOSTART_ERROR;
    deallocate_program_name();
    if (name)
        lib_free(name);

    return -1;
}
Exemplo n.º 5
0
void initcmdline_check_attach(void)
{
    if (machine_class != VICE_MACHINE_VSID) {
        /* Handle general-purpose command-line options.  */

        /* `-autostart' */
        if (autostart_string != NULL) {
            autostart_autodetect_opt_prgname(autostart_string, 0, autostart_mode);
        }
        /* `-8', `-9', `-10' and `-11': Attach specified disk image.  */
        {
            int i;

            for (i = 0; i < 4; i++) {
                if (startup_disk_images[i] != NULL
                    && file_system_attach_disk(i + 8, startup_disk_images[i])
                    < 0) {
                    log_error(LOG_DEFAULT,
                              "Cannot attach disk image `%s' to unit %d.",
                              startup_disk_images[i], i + 8);
                }
            }
        }

        /* `-1': Attach specified tape image.  */
        if (startup_tape_image && tape_image_attach(1, startup_tape_image) < 0) {
            log_error(LOG_DEFAULT, "Cannot attach tape image `%s'.",
                      startup_tape_image);
        }
    }

    cmdline_free_autostart_string();
}
Exemplo n.º 6
0
void uiattach_aros(video_canvas_t *canvas, int unit)
{
  char *fname=NULL;
  char select_txt[50];

  if (unit==1)
  {
    fname=BrowseFile("Select file for tape","#?", canvas);
    if (fname!=NULL)
    {
      if (tape_image_attach(1, fname) < 0)
        ui_error(translate_text(IDMES_CANNOT_ATTACH_FILE));
    }
  }
  else
  {
    sprintf(select_txt,"Select file for unit %d",unit);
    fname=BrowseFile(select_txt, "#?", canvas);
    if (fname!=NULL)
    {
      if (file_system_attach_disk(unit, fname) < 0)
        ui_error(translate_text(IDMES_CANNOT_ATTACH_FILE));
    }
  }
}
Exemplo n.º 7
0
static void uiattach_disk_dialog(HWND hwnd, WPARAM wparam)
{
    TCHAR *st_name;
    char *resource;
    int unit = 8;
    int autostart_index = -1;

    SuspendFullscreenModeKeep(hwnd);
    switch (wparam & 0xffff) {
    case IDM_ATTACH_8:
        unit = 8;
        break;
    case IDM_ATTACH_9:
        unit = 9;
        break;
    case IDM_ATTACH_10:
        unit = 10;
        break;
    case IDM_ATTACH_11:
        unit = 11;
        break;
    }
    resource = lib_msprintf("AttachDevice%dReadonly", unit);
    if ((st_name = uilib_select_file_autostart(hwnd,
                   translate_text(IDS_ATTACH_DISK_IMAGE),
                   UILIB_FILTER_DISK |
#ifdef HAVE_ZLIB
                   UILIB_FILTER_ZIP |
#endif
                   UILIB_FILTER_ALL,
                   UILIB_SELECTOR_TYPE_FILE_LOAD,
                   UILIB_SELECTOR_STYLE_DISK,
                   &autostart_index, resource)) != NULL) {
        char *name;

        name = system_wcstombs_alloc(st_name);
        if (autostart_index >= 0) {
            if (autostart_autodetect(name, NULL, autostart_index, AUTOSTART_MODE_RUN) < 0) {
                ui_error(translate_text(IDS_CANNOT_AUTOSTART_FILE));
            }
        } else {
            if (file_system_attach_disk(unit, name) < 0) {
                ui_error(translate_text(IDS_CANNOT_ATTACH_FILE));
            }
        }
        system_wcstombs_free(name);
        lib_free(st_name);
    }
    ResumeFullscreenModeKeep(hwnd);
    lib_free(resource);
}
Exemplo n.º 8
0
static void ui_fliplist_select_cb(GtkWidget *widget, gpointer data)
{
    int unit = GPOINTER_TO_INT(data) & 0xff;
    int index = (GPOINTER_TO_INT(data) >> 8) & 0xff;
    int i;
    if (index == 0) {
        fliplist_t list = fliplist_init_iterate(unit);
        const char *image = fliplist_get_image(list);
        file_system_attach_disk(unit, image);
    } else {
        for (i = 0; i < index; ++i) {
            fliplist_attach_head(unit, 1);
        }
    }
}
Exemplo n.º 9
0
void fliplist_attach_head (unsigned int unit, int direction)
{
    if (fliplist[unit - 8] == NULL) {
        return;
    }

    if (direction) {
        fliplist[unit - 8] = fliplist[unit - 8]->next;
    } else {
        fliplist[unit - 8] = fliplist[unit - 8]->prev;
    }

    if (file_system_attach_disk(fliplist[unit - 8]->unit, fliplist[unit - 8]->image) < 0) {
        /* shouldn't happen, so ignore it */
    }
}
Exemplo n.º 10
0
static BOOL store_dialog_results(HWND hwnd, unsigned int num)
{
    char s[MAX_PATH];
    TCHAR st[MAX_PATH];
    int devtype = ATTACH_DEVICE_NONE;

    if (iec_available_busses() & IEC_BUS_IEC) {
        resources_set_int_sprintf("IECDevice%d", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_USEIECDEVICE) == BST_CHECKED), num);
    }

    if (IsDlgButtonChecked(hwnd, IDC_SELECTDISK) == BST_CHECKED || IsDlgButtonChecked(hwnd, IDC_SELECTDIR) == BST_CHECKED) {
        devtype = ATTACH_DEVICE_FS;
    }
#ifdef HAVE_OPENCBM
    if (opencbmlib_is_available()) {
        if (IsDlgButtonChecked(hwnd, IDC_SELECTREAL) == BST_CHECKED) {
            devtype = ATTACH_DEVICE_REAL;
        }
    }
#endif
    resources_set_int_sprintf("FileSystemDevice%d", devtype, num);

    resources_set_int_sprintf("FSDevice%dConvertP00", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_READP00) == BST_CHECKED), num);
    resources_set_int_sprintf("FSDevice%dSaveP00", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_WRITEP00) == BST_CHECKED), num);
    resources_set_int_sprintf("FSDevice%dHideCBMFiles", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_HIDENONP00) == BST_CHECKED), num);
    resources_set_int_sprintf("AttachDevice%dReadonly", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_ATTACH_READONLY) == BST_CHECKED), num);

    GetDlgItemText(hwnd, IDC_DIR, st, MAX_PATH);
    system_wcstombs(s, st, MAX_PATH);
    resources_set_string_sprintf("FSDevice%dDir", s, num);

    if (IsDlgButtonChecked(hwnd, IDC_SELECTDISK) == BST_CHECKED) {
        GetDlgItemText(hwnd, IDC_DISKIMAGE, st, MAX_PATH);
        system_wcstombs(s, st, MAX_PATH);
        if (file_system_attach_disk(num, s) < 0 ) {
            ui_error(translate_text(IDS_CANNOT_ATTACH_FILE));
            return 0;
        }
    } else {
        if ((IsDlgButtonChecked(hwnd, IDC_SELECTDIR) == BST_CHECKED) && file_system_get_disk_name(num)) {
            file_system_detach_disk(num);
        }
    }

    return 1;
}
Exemplo n.º 11
0
static TUI_MENU_CALLBACK(attach_disk_callback)
{
    const char *s;

    if (been_activated) {
        char *default_item, *directory;
        char *name, *file;
        unsigned int file_number = 0;

        s = file_system_get_disk_name((unsigned int)param);
        util_fname_split(s, &directory, &default_item);

        name = tui_file_selector("Attach a disk image", directory, 
                                 "*.d64;*.d71;*.d81;*.g64;*.g41;*.x64;*.p64;*.d80;*.d82;*.d67;*.d1m;*.d2m;*.d4m;"
                                 "*.d6z;*.d7z;*.d8z;*.g6z;*.g4z;*.x6z;*.zip;*.gz;*.lzh",
                                 default_item, diskcontents_filesystem_read, &file,
                                 &file_number);
        if (file_number > 0) {
            if (autostart_disk(name, NULL, file_number, AUTOSTART_MODE_RUN) < 0) {
                tui_error("Cannot autostart disk image.");
            } else {
                *behavior = TUI_MENU_BEH_RESUME;
            }
        } else if (name != NULL && (s == NULL || strcasecmp(name, s) != 0) && file_system_attach_disk((int)param, name) < 0) {
            tui_error("Invalid disk image.");
        }

        lib_free(file);

        ui_update_menus();

        lib_free(directory);
        lib_free(default_item);
        lib_free(name);
    }

    s = file_system_get_disk_name((unsigned int)param);

    if (s == NULL || *s == '\0') {
        return "(none)";
    } else {
        return s;
    }
}
Exemplo n.º 12
0
/* Autostart disk image `file_name'.  */
int autostart_disk(const char *file_name, const char *program_name,
                   unsigned int program_number, unsigned int runmode)
{
    char *name = NULL;

    if (network_connected() || event_record_active() || event_playback_active()
        || !file_name || !autostart_enabled) {
        return -1;
    }

    /* Get program name first to avoid more than one file handle open on
       image.  */
    if (!program_name && program_number > 0) {
        image_contents_t *contents = diskcontents_filesystem_read(file_name);
        if (contents) {
            name = image_contents_filename_by_number(contents, program_number);
            image_contents_destroy(contents);
        }
    } else {
        name = lib_stralloc(program_name ? program_name : "*");
    }

    if (name) {
        autostart_disk_cook_name(&name);
        if (!(file_system_attach_disk(8, file_name) < 0)) {
            log_message(autostart_log,
                        "Attached file `%s' as a disk image.", file_name);
            reboot_for_autostart(name, AUTOSTART_HASDISK, runmode);
            lib_free(name);

            return 0;
        }
    }

    autostartmode = AUTOSTART_ERROR;
    deallocate_program_name();
    lib_free(name);

    return -1;
}
Exemplo n.º 13
0
static void uiattach_disk_dialog(video_canvas_t *canvas, int idm)
{
    char *name;
    char *resource;
    int unit = 8;
    int autostart_index = -1;

    switch (idm) {
        case IDM_ATTACH_8:
            unit = 8;
            break;
        case IDM_ATTACH_9:
            unit = 9;
            break;
        case IDM_ATTACH_10:
            unit = 10;
            break;
        case IDM_ATTACH_11:
            unit = 11;
            break;
    }
    resource = lib_msprintf("AttachDevice%dReadonly", unit);
    if ((name = uilib_select_file_autostart(translate_text(IDMS_ATTACH_DISK_IMAGE),
                                            UILIB_FILTER_DISK | UILIB_FILTER_ZIP | UILIB_FILTER_ALL,
                                            UILIB_SELECTOR_TYPE_FILE_LOAD, UILIB_SELECTOR_STYLE_DISK,
                                            &autostart_index, resource)) != NULL) {
        if (autostart_index >= 0) {
            if (autostart_autodetect(name, NULL, autostart_index, AUTOSTART_MODE_RUN) < 0) {
                ui_error(translate_text(IDMES_CANNOT_AUTOSTART_FILE));
            }
        } else {
            if (file_system_attach_disk(unit, name) < 0) {
                ui_error(translate_text(IDMES_CANNOT_ATTACH_FILE));
            }
        }
        lib_free(name);
    }
    lib_free(resource);
}
Exemplo n.º 14
0
int autostart_prg_with_disk_image(const char *file_name, fileio_info_t *fh, const char *image_name)
{
	const int drive = 8;
	const int secondary = 1;
	autostart_prg_t *prg;
	vdrive_t *vdrive;
	int i;
	int old_tde_state;
	int file_name_size;
	BYTE lo,hi;

	/* read prg file */ 
	prg = load_prg(file_name, fh);
	if (prg == NULL) {
		return -1;
	}

	/* disable TDE */
	resources_get_int("DriveTrueEmulation", &old_tde_state);
	if (old_tde_state != 0)
		resources_set_int("DriveTrueEmulation", 0);

	/* create empty image */
	if (vdrive_internal_create_format_disk_image(image_name, 
				(char *)"AUTOSTART", DISK_IMAGE_TYPE_D64) <0 ) {
		//log_error(log, "Error creating autostart disk image: %s", image_name);
		free_prg(prg);
		return -1;
	}

	/* attach disk image */
	if (file_system_attach_disk(drive, image_name) < 0) {
		//log_error(log, "Could not attach disk image: %s", image_name);
		free_prg(prg);
		return -1;
	}

	/* copy file to disk */
	vdrive = file_system_get_vdrive((unsigned int)drive);
	if (vdrive == NULL) {
		free_prg(prg);
		return -1;
	}

	/* get file name size */
	file_name_size = strlen((const char *)fh->name);
	if (file_name_size > 16) {
		file_name_size = 16;
	}

	/* open file on disk */
	if (vdrive_iec_open(vdrive, (const BYTE *)fh->name,
				file_name_size, secondary, NULL) != SERIAL_OK) {
		//log_error(log, "Could not open file");
		free_prg(prg);
		return -1;
	}

	/* write start address to file */
	lo = (BYTE)(prg->start_addr & 0xff);
	hi = (BYTE)((prg->start_addr >> 8) & 0xff);
	if ((vdrive_iec_write(vdrive, lo, secondary) != SERIAL_OK) ||
			(vdrive_iec_write(vdrive, hi, secondary) != SERIAL_OK)) {
		//log_error(log, "Could not write file");
		free_prg(prg);
		return -1;
	}

	/* write PRG data to file */
	for (i = 0; i < prg->size; i++) {
		if (vdrive_iec_write(vdrive, prg->data[i], secondary) != SERIAL_OK) {
			//log_error(log, "Could not write file");
			free_prg(prg);
			return -1;
		}
	}

	/* close file */
	if (vdrive_iec_close(vdrive, secondary) != SERIAL_OK) {
		//log_error(log, "Could not close file");
		free_prg(prg);
		return -1;
	}

	/* free prg file */
	free_prg(prg);

	/* re-enable TDE */
	if (old_tde_state != 0)
		resources_set_int("DriveTrueEmulation", old_tde_state);

	/* ready */
	return 0;
}
Exemplo n.º 15
0
int autostart_prg_with_disk_image(const char *file_name,
                                  fileio_info_t *fh,
                                  log_t log,
                                  const char *image_name)
{
    const int drive = 8;
    const int secondary = 1;
    autostart_prg_t *prg;
    vdrive_t *vdrive;
    int i;
    int old_tde_state;
    int file_name_size;
    BYTE data;
    unsigned int disk_image_type;
    int result, result2;

    /* identify disk image type */
    switch (drive_get_disk_drive_type(drive - 8)) {
    case DRIVE_TYPE_1540:
    case DRIVE_TYPE_1541:
    case DRIVE_TYPE_1541II:
    case DRIVE_TYPE_1551:
    case DRIVE_TYPE_1570:
    case DRIVE_TYPE_2031:
        disk_image_type = DISK_IMAGE_TYPE_D64;
        break;
    case DRIVE_TYPE_2040:
    case DRIVE_TYPE_3040:
    case DRIVE_TYPE_4040:
        disk_image_type = DISK_IMAGE_TYPE_D67;
        break;
    case DRIVE_TYPE_1571:
    case DRIVE_TYPE_1571CR:
        disk_image_type = DISK_IMAGE_TYPE_D71;
        break;
    case DRIVE_TYPE_1581:
    case DRIVE_TYPE_2000:
    case DRIVE_TYPE_4000:
        disk_image_type = DISK_IMAGE_TYPE_D81;
        break;
    case DRIVE_TYPE_8050:
        disk_image_type = DISK_IMAGE_TYPE_D80;
        break;
    case DRIVE_TYPE_8250:
    case DRIVE_TYPE_1001:
        disk_image_type = DISK_IMAGE_TYPE_D82;
        break;
    default:
        log_error(log, "No idea what disk image format to use.");
        return -1;
    }

    /* read prg file */
    prg = load_prg(file_name, fh, log);
    if (prg == NULL) {
        return -1;
    }

    /* disable TDE */
    resources_get_int("DriveTrueEmulation", &old_tde_state);
    if (old_tde_state != 0) {
        log_message(log, "Turning true drive emulation off.");
        resources_set_int("DriveTrueEmulation", 0);
    }

    do {
        result = -1;

        /* create empty image */
        if (vdrive_internal_create_format_disk_image(image_name, (char *)"AUTOSTART", disk_image_type) < 0) {
            log_error(log, "Error creating autostart disk image: %s", image_name);
            break;
        }

        /* attach disk image */
        if (file_system_attach_disk(drive, image_name) < 0) {
            log_error(log, "Could not attach disk image: %s", image_name);
            break;
        }

        /* get vdrive */
        vdrive = file_system_get_vdrive((unsigned int)drive);
        if (vdrive == NULL) {
            break;
        }

        /* get file name size */
        file_name_size = strlen((const char *)fh->name);
        if (file_name_size > 16) {
            file_name_size = 16;
        }

        /* open file on disk */
        if (vdrive_iec_open(vdrive, (const BYTE *)fh->name, file_name_size, secondary, NULL) != SERIAL_OK) {
            log_error(log, "Could not open file");
            break;
        }

        result2 = 0;
        /* write PRG data to file */
        for (i = -2; i < (int)prg->size; i++) {
            switch (i) {
            case -2:
                data = (BYTE)prg->start_addr;
                break;
            case -1:
                data = (BYTE)(prg->start_addr >> 8);
                break;
            default:
                data = prg->data[i];
                break;
            }
            if (vdrive_iec_write(vdrive, data, secondary) != SERIAL_OK) {
                log_error(log, "Could not write file");
                result2 = -1;
                break;
            }
        }

        /* close file */
        if (vdrive_iec_close(vdrive, secondary) != SERIAL_OK) {
            log_error(log, "Could not close file");
            break;
        }
        result = result2;
    } while (0);

    /* free prg file */
    free_prg(prg);

    /* re-enable TDE */
    if (old_tde_state != 0) {
        log_message(log, "Turning true drive emulation on.");
        resources_set_int("DriveTrueEmulation", old_tde_state);
    }

    /* ready */
    return result;
}
Exemplo n.º 16
0
static UI_CALLBACK(attach_from_fliplist2)
{
    file_system_attach_disk(fliplist_get_unit((void *)UI_MENU_CB_PARAM),
                            fliplist_get_image((void *)UI_MENU_CB_PARAM));
}
Exemplo n.º 17
0
static BOOL FdmDoLoadAction(HWND hwnd, const char *szpath, int act, int sact)
{
    switch (act) {
        case 0:
            return file_system_attach_disk(sact + 8, szpath);
        case 1:
            return tape_image_attach(1, szpath);
        case 2:
            return fliplist_load_list(sact + 8, szpath, FALSE);
        case 3:
            return fliplist_load_list(sact + 8, szpath, TRUE);
        case 4:
            return trap(hwnd, load_snapshot, szpath);
        case 5:
            switch (sact) {
                case 0:
                    return resources_set_string(VIDEO_PALETTE, szpath);
#ifdef __X128__
                case 1:
                    return resources_set_string("VDC_PaletteFile", szpath);
#endif
#ifdef __XCBM__
                case 1:
                    return resources_set_string("ViciiPaletteFile", szpath);
#endif
            }
            return -1;
        case 6: // rom img
            return resources_set_string("KeymapFile", szpath);
        case 7:
            switch (sact) {
                case 0:
                    return resources_set_string("KernalName", szpath);
                case 1:
                    return resources_set_string("ChargenName", szpath);
                case 2:
                    return resources_set_string("DosName1541", szpath);
                case 3:
                    return resources_set_string("DosName154ii", szpath);
                case 4:
                    return resources_set_string("DosName1571", szpath);
                case 5:
                    return resources_set_string("DosName1581", szpath);
                case 6:
                    return resources_set_string("DosName2031", szpath);
                case 7:
                    return resources_set_string("DosName1001", szpath);
                case 8:
                    return resources_set_string("DosName2040", szpath);
                case 9:
                    return resources_set_string("DosName3040", szpath);
                case 10:
                    return resources_set_string("DosName4040", szpath);
                case 11:
                    return resources_set_string("BasicName", szpath);
                case 12:
                    return resources_set_string("Z80BiosName", szpath);
                case 13:
                    return resources_set_string("Kernal64Name", szpath);
                case 14:
                    return resources_set_string("Basic64Name", szpath);
                case 15:
                    return resources_set_string("Chargen64Name", szpath);
                case 16:
                    return resources_set_string("ChargenIntName", szpath);
                case 17:
                    return resources_set_string("ChargenDEName", szpath);
                case 18:
                    return resources_set_string("ChargenFRName", szpath);
                case 19:
                    return resources_set_string("ChargenSEName", szpath);
                case 20:
                    return resources_set_string("KernalIntName", szpath);
                case 21:
                    return resources_set_string("KernalDEName", szpath);
                case 22:
                    return resources_set_string("KernalFIName", szpath);
                case 23:
                    return resources_set_string("KernalFRName", szpath);
                case 24:
                    return resources_set_string("KernalITName", szpath);
                case 25:
                    return resources_set_string("KernalNOName", szpath);
                case 26:
                    return resources_set_string("KernalSEName", szpath);
                case 27:
                    return resources_set_string("BasicHiName", szpath);
                case 28:
                    return resources_set_string("BasicLoName", szpath);
            }
            return -1;
        case 8:
            return machine_romset_file_load(szpath);
        case 9:
            return resources_load(szpath);
#if defined __X64__ || defined __X128__
        case 10:
            switch (sact) {
                case 0:
                    return cartridge_attach_image(CARTRIDGE_CRT, szpath);
                case 1:
                    return cartridge_attach_image(CARTRIDGE_GENERIC_8KB, szpath);
                case 2:
                    return cartridge_attach_image(CARTRIDGE_GENERIC_16KB, szpath);
                case 3:
                    return cartridge_attach_image(CARTRIDGE_ACTION_REPLAY, szpath);
                case 4:
                    return cartridge_attach_image(CARTRIDGE_ATOMIC_POWER, szpath);
                case 5:
                    return cartridge_attach_image(CARTRIDGE_EPYX_FASTLOAD, szpath);
                case 6:
                    return cartridge_attach_image(CARTRIDGE_SUPER_SNAPSHOT, szpath);
                case 7:
                    return cartridge_attach_image(CARTRIDGE_SUPER_SNAPSHOT_V5, szpath);
                case 8:
                    return cartridge_attach_image(CARTRIDGE_WESTERMANN, szpath);
                case 9:
                    return cartridge_attach_image(CARTRIDGE_IEEE488, szpath);
                case 10:
                    return cartridge_attach_image(CARTRIDGE_IDE64, szpath);
            }
            return -1;
#endif
#ifdef __XPET__
        case 10:
            switch (sact) {
                case 0:
                    return resources_set_string("RomModule9Name", szpath);
                case 1:
                    return resources_set_string("RomModuleAName", szpath);
                case 2:
                    return resources_set_string("RomModuleBName", szpath);
            }
            return -1;
#endif
#ifdef __XCBM__
        case 10:
            switch (sact) {
                case 0:
                    return resources_set_string("Cart1Name", szpath);
                case 1:
                    return resources_set_string("Cart2Name", szpath);
                case 2:
                    return resources_set_string("Cart4Name", szpath);
                case 3:
                    return resources_set_string("Cart6Name", szpath);
            }
            return -1;
#endif
#ifdef __X128__
        case 11:
            switch (sact) {
                case 0:
                    return resources_set_string("InternalFunctionName", szpath);
                case 1:
                    return resources_set_string("ExternalFunctionName", szpath);
            }
            return -1;
#endif
    }
    return -1;
}
Exemplo n.º 18
0
static MRESULT EXPENTRY pm_drive(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    static int drive = 0;

    switch (msg) {
        case WM_INITDLG:
            {
                int val, i = 0;
                HWND ihwnd = WinWindowFromID(hwnd, CBS_IMAGE);

                while (i < 10 && ui_status.imageHist[i][0]) {
                    WinLboxInsertItem(ihwnd, ui_status.imageHist[i++]);
                }
                WinLboxInsertItem(ihwnd, "");
                resources_get_int("DriveTrueEmulation", &val);
                WinCheckButton(hwnd, CB_TRUEDRIVE, val);
                WinCheckButton(hwnd, RB_DRIVE8|drive, 1);
                WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0);
                WinSendMsg(hwnd, WM_DRIVESTATE, (void*)ui_status.lastDriveState, NULL);
                for (i = 0; i < 3; i++) {
                    WinSendMsg(hwnd, WM_TRACK, (void*)i, (void*)(int)(ui_status.lastTrack[i] * 2));
                }
        }
        break;
    case WM_COMMAND:
        switch (LONGFROMMP(mp1)) {
            case PB_CREATE:
                create_dialog(hwnd);
                return FALSE;
            case PB_ATTACH:
                ViceFileDialog(hwnd, 0x0100 | (drive + 1), FDS_OPEN_DIALOG);
                return FALSE;
            case PB_DETACH:
                file_system_detach_disk(drive + 8);
                return FALSE;
            case PB_FLIPADD:
                fliplist_add_image(drive + 8);
                return FALSE;
            case PB_FLIPREMOVE:
                fliplist_remove(drive + 8, NULL);
                return FALSE;
            case PB_FLIP:
                fliplist_attach_head(drive + 8, FLIP_NEXT);
                return FALSE;
        }
        break;
    case WM_CONTROL:
        {
            switch (SHORT1FROMMP(mp1)) {
                case RB_DRIVE8:
                case RB_DRIVE9:
                case RB_DRIVE10:
                case RB_DRIVE11:
                    WinSendMsg(hwnd, WM_SWITCH, (void*)(SHORT1FROMMP(mp1) & 0x3), 0);
                    break;
                case CB_TRUEDRIVE:
                    toggle("DriveTrueEmulation");
                    WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0);
                    break;
                case CB_CONVERTP00:
                    toggle_drive_res("FSDevice%dConvertP00", drive);//);
                    WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0);
                    break;
                case CB_SAVEP00:
                    toggle_drive_res("FileDevice%dSaveP00", drive);
                    break;
                case CB_ALLOWACCESS:
                    toggle_drive_res("FileSystemDevice%d", drive);
                    WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0);
                    break;
                case CB_HIDENONP00:
                    toggle_drive_res("FSDevice%dHideCBMFiles", drive);
                    break;
                case CB_MEM2000:
                    toggle_drive_res("Drive%dRAM2000", drive);
                    break;
                case CB_MEM4000:
                    toggle_drive_res("Drive%dRAM4000", drive);
                    break;
                case CB_MEM6000:
                    toggle_drive_res("Drive%dRAM6000", drive);
                    break;
                case CB_MEM8000:
                    toggle_drive_res("Drive%dRAM8000", drive);
                    break;
                case CB_MEMA000:
                    toggle_drive_res("Drive%dRAMA000", drive);
                    break;
                case CB_READONLY:
                    toggle_drive_res("AttachDevice%dReadonly", drive);
                    break;
                case CB_PARALLEL:
                    if (drive == 0 || drive == 1) {
                        toggle_drive_res("Drive%dParallelCable", drive);
                    }
                    break;
                case RB_NEVER:
                case RB_ASK:
                case RB_ALWAYS:
                    if (drive == 0 || drive == 1) {
                        resources_set_int_sprintf("Drive%dExtendImagePolicy", (SHORT1FROMMP(mp1) & 0x3), drive + 8);
                    }
                    break;
                case RB_NONE:
                case RB_TRAP:
                case RB_SKIP:
                    if (drive == 0 || drive == 1) {
                        resources_set_int_sprintf("Drive%dIdleMethod", (SHORT1FROMMP(mp1) & 0x3), drive + 8);
                    }
                    break;
               case CBS_IMAGE:
                   if (SHORT2FROMMP(mp1) == CBN_ENTER) {
                       char psz[CCHMAXPATH];

                       WinLboxQuerySelectedItemText(hwnd, CBS_IMAGE, psz, CCHMAXPATH);

                       if (!strlen(psz)) {
                           file_system_detach_disk(drive + 8);
                           return FALSE;
                       }

                       if (file_system_attach_disk(drive + 8, psz)) {
                           WinMessageBox(HWND_DESKTOP, hwnd, "Cannot attach specified file.", "VICE/2 Error", 0, MB_OK);
                       }
                   }
                   return FALSE;
                case CBS_PATH:
                    switch (SHORT2FROMMP(mp1)) {
                        case SPBN_CHANGE:
                            {
                                char path[255];

                                WinSendDlgMsg(hwnd, CBS_PATH, SPBM_QUERYVALUE, &path, 255);
                                if (!chdir(path)) {
                                    resources_set_string_sprintf("FSDevice%dDir", path, drive + 8);
                                }
                            }
                            break;
                        case SPBN_KILLFOCUS:
                            {
                                const char *path;

                                resources_get_string_sprintf("FSDevice%dDir", &path, drive + 8);
                                WinSendDlgMsg(hwnd, CBS_PATH, SPBM_SETARRAY, &path, 1);
                                WinSetDlgSpinVal(hwnd, CBS_PATH, 0);
                            }
                            break;
                    }
                    return FALSE;
                case CBS_TYPE:
                    if (SHORT2FROMMP(mp1) == CBN_ENTER && (drive == 0 || drive == 1)) {
                        const int nr  = WinQueryLboxSelectedItem((HWND)mp2);
                        const int val = WinLboxItemHandle((HWND)mp2, nr);

                        resources_set_int_sprintf("Drive%dType", val, drive + 8);
                    }
                    return FALSE;
            }
        }
        break;
    case WM_DRIVEIMAGE:
        {
            HWND ihwnd = WinWindowFromID(hwnd, CBS_IMAGE);
            const char *name = (char *)mp1;

            int pos;
            for (pos = 0; pos < 9; pos++) {
                WinDeleteLboxItem(ihwnd, 0);
            }

            pos = 0;
            while (pos < 10 && ui_status.imageHist[pos][0]) {
                WinLboxInsertItem(ihwnd, ui_status.imageHist[pos++]);
            }

            WinLboxInsertItem(ihwnd, "");

            if (drive == (int)mp2) {
                WinLboxSelectItem(ihwnd, name[0] ? 0 : pos);
            }
        }
        return FALSE;
    case WM_TRACK:
        if (!(ui_status.lastDriveState & (1 << (int)mp1))) {
            break;
        }

        WinSetDlgSpinVal(hwnd, SPB_TRACK8+(int)mp1, (int)((int)mp2 / 2));
        WinShowDlg(hwnd, SS_HALFTRACK8 + (int)mp1, ((int)mp2 % 2));
        break;
    case WM_DRIVELEDS:
        WinShowDlg(hwnd, SS_LED8+(int)mp1, (int)mp2);
        break;
    case WM_DRIVESTATE:
        WinShowDlg(hwnd, SPB_TRACK8, (int)mp1 & 1 == 1);
        WinShowDlg(hwnd, SS_HALFTRACK8, (int)mp1 & 1 == 1);
        WinShowDlg(hwnd, SPB_TRACK9, (int)mp1 & 2 == 1);
        WinShowDlg(hwnd, SS_HALFTRACK9, (int)mp1 & 2 == 1);
        WinShowDlg(hwnd, SS_LED8, 0);
        WinShowDlg(hwnd, SS_LED9, 0);
        break;
    case WM_SWITCH:
        drive = (int)mp1;
            {
                const HWND lbox = WinWindowFromID(hwnd, CBS_TYPE);
                int type = 0;
                int val;
                int res;
                int drive89 = (drive == 0 || drive == 1);

                resources_get_int("DriveTrueEmulation", &val);

                WinLboxEmpty(lbox);

                if (drive89) {
                    int i, nr;

                    WinCheckButton(hwnd, RB_NEVER | get_drive_res("Drive%dExtendImagePolicy", drive), 1);
                    WinCheckButton(hwnd, RB_NONE | get_drive_res("Drive%dIdleMethod", drive), 1);

                    nr = 0;
                    res = get_drive_res("Drive%dType", drive);
                    for (i = 0; i < nDRIVES; i++) {
                        if (!drive_check_type(driveRes[i], drive)) {
                            continue;
                        }

                        WinLboxInsertItem(lbox, driveName[i]);
                        WinLboxSetItemHandle(lbox, nr, driveRes[i]);

                        if (res == driveRes[i]) {
                            type = nr;
                        }

                        nr++;
                    }
                } else {
                    WinCheckButton(hwnd, RB_NEVER, 0);
                    WinCheckButton(hwnd, RB_ASK, 0);
                    WinCheckButton(hwnd, RB_ALWAYS, 0);
                    WinCheckButton(hwnd, RB_NONE, 0);
                    WinCheckButton(hwnd, RB_SKIP, 0);
                    WinCheckButton(hwnd, RB_TRAP, 0);
                }
                WinLboxSelectItem(lbox, type);

                WinCheckButton(hwnd, CB_PARALLEL, drive89 && get_drive_res("Drive%dParallelCable", drive) != 0);
                WinCheckButton(hwnd, CB_MEM2000, drive89 && get_drive_res("Drive%dRAM2000", drive) != 0);
                WinCheckButton(hwnd, CB_MEM4000, drive89 && get_drive_res("Drive%dRAM4000", drive) != 0);
                WinCheckButton(hwnd, CB_MEM6000, drive89 && get_drive_res("Drive%dRAM6000", drive) != 0);
                WinCheckButton(hwnd, CB_MEM8000, drive89 && get_drive_res("Drive%dRAM8000", drive) != 0);
                WinCheckButton(hwnd, CB_MEMA000, drive89 && get_drive_res("Drive%dRAMA000", drive) != 0);
                WinEnableControl(hwnd, CB_PARALLEL, drive89 && val);
                WinEnableControl(hwnd, RB_NEVER, drive89 && val);
                WinEnableControl(hwnd, RB_ASK, drive89 && val);
                WinEnableControl(hwnd, RB_ALWAYS, drive89 && val);
                WinEnableControl(hwnd, RB_NONE, drive89 && val);
                WinEnableControl(hwnd, RB_SKIP, drive89 && val);
                WinEnableControl(hwnd, RB_TRAP, drive89 && val);
                WinEnableControl(hwnd, CBS_TYPE, drive89 && val);
                WinEnableControl(hwnd, CB_MEM2000, drive89 && val);
                WinEnableControl(hwnd, CB_MEM4000, drive89 && val);
                WinEnableControl(hwnd, CB_MEM6000, drive89 && val);
                WinEnableControl(hwnd, CB_MEM8000, drive89 && val);
                WinEnableControl(hwnd, CB_MEMA000, drive89 && val);
                {
                    int acc  = get_drive_res("FileSystemDevice%d", drive) != 0;
                    int conv = get_drive_res("FSDevice%dConvertP00", drive) != 0;

                    if (!conv) {
                        resources_set_int_sprintf("FSDevice%dHideCBMFiles", 0, drive + 8);
                    }

                    WinCheckButton(hwnd, CB_ALLOWACCESS, acc);
                    WinCheckButton(hwnd, CB_CONVERTP00, conv);
                    WinCheckButton(hwnd, CB_SAVEP00, get_drive_res("FSDevice%dSaveP00", drive) != 0);
                    WinCheckButton(hwnd, CB_HIDENONP00, get_drive_res("FSDevice%dHideCBMFiles", drive) != 0);
                    WinEnableControl(hwnd, CB_ALLOWACCESS, !(drive89 && val));
                    WinEnableControl(hwnd, CB_SAVEP00, !(drive89 && val) && acc);
                    WinEnableControl(hwnd, CB_CONVERTP00, !(drive89 && val) && acc);
                    WinEnableControl(hwnd, CBS_PATH, !(drive89 && val) && acc);
                    WinEnableControl(hwnd, CB_HIDENONP00, !(drive89 && val) && acc && conv);

                    WinCheckButton(hwnd, CB_READONLY, get_drive_res("AttachDevice%dReadonly", drive) != 0);
                }
                {
                    char tmp[CCHMAXPATH];
                    int max = WinDlgLboxQueryCount(hwnd, CBS_IMAGE);
                    int pos = -1;

                    do {
                        WinLboxQueryItem(hwnd, CBS_IMAGE, ++pos, tmp, CCHMAXPATH);
                    }
                    while (pos < max && strcmp(ui_status.lastImage[drive], tmp));
                    WinDlgLboxSelectItem(hwnd, CBS_IMAGE, pos);
                }
                {
                    const char *path;
                    resources_get_string_sprintf("FSDevice%dDir", &path, drive + 8);
                    WinSendDlgMsg(hwnd, CBS_PATH, SPBM_SETARRAY, &path, 1);
                    WinSetDlgSpinVal(hwnd, CBS_PATH, 0);
                }
            }
            return FALSE;

    }
    return WinDefDlgProc (hwnd, msg, mp1, mp2);
}
Exemplo n.º 19
0
static int drive_snapshot_read_image_module(snapshot_t *s, unsigned int dnr)
{
    BYTE major_version, minor_version;
    snapshot_module_t *m;
    char snap_module_name[10];
    WORD word;
    char *filename = NULL;
    char *request_str;
    int len = 0;
    FILE *fp;
    BYTE sector_data[0x100];
    disk_addr_t dadr;
    int rc;
    drive_t *drive;

    drive = drive_context[dnr]->drive;

    sprintf(snap_module_name, "NOIMAGE%i", dnr);

    m = snapshot_module_open(s, snap_module_name,
                             &major_version, &minor_version);
    if (m != NULL) {
        file_system_detach_disk(dnr + 8);
        snapshot_module_close(m);
        return 0;
    }

    sprintf(snap_module_name, "IMAGE%i", dnr);

    m = snapshot_module_open(s, snap_module_name,
                             &major_version, &minor_version);
    if (m == NULL) {
        return 0;
    }

    if (major_version > IMAGE_SNAP_MAJOR || minor_version > IMAGE_SNAP_MINOR) {
        log_error(drive_snapshot_log,
                  "Snapshot module version (%d.%d) newer than %d.%d.",
                  major_version, minor_version,
                  IMAGE_SNAP_MAJOR, IMAGE_SNAP_MINOR);
    }

    if (SMR_W(m, &word) < 0) {
        snapshot_module_close(m);
        return -1;
    }

    switch (word) {
        case 1581:
            len = D81_FILE_SIZE;
            break;
        case 8050:
            len = D80_FILE_SIZE;
            break;
        case 8250:
            len = D82_FILE_SIZE;
            break;
        default:
            log_error(drive_snapshot_log,
                      "Snapshot of disk image unknown (type %d)",
                      (int)word);
            snapshot_module_close(m);
            return -1;
    }

    /* create temporary file of the right size */
    fp = archdep_mkstemp_fd(&filename, MODE_WRITE);

    if (fp == NULL) {
        log_error(drive_snapshot_log, "Could not create temporary file!");
        snapshot_module_close(m);
        return -1;
    }

    /* blow up the file to needed size */
    if (fseek(fp, len - 1, SEEK_SET) < 0
        || (fputc(0, fp) == EOF)) {
        log_error(drive_snapshot_log, "Could not create large temporary file");
        fclose(fp);
        lib_free(filename);
        snapshot_module_close(m);
        return -1;
    }

    fclose(fp);
    lib_free(filename);

    if (file_system_attach_disk(dnr + 8, filename) < 0) {
        log_error(drive_snapshot_log, "Invalid Disk Image");
        lib_free(filename);
        snapshot_module_close(m);
        return -1;
    }

    request_str = lib_msprintf("Disk image unit #%d imported from snapshot",
                               dnr + 8);
    zfile_close_action(filename, ZFILE_REQUEST, request_str);
    lib_free(request_str);

    /* we use the return code to step through the tracks. So we do not
       need any geometry info. */
    SMR_BA(m, sector_data, 0x100);
    for (dadr.track = 1;; dadr.track++) {
        rc = 0;
        for (dadr.sector = 0;; dadr.sector++) {
            rc = disk_image_write_sector(drive->image, sector_data, &dadr);
            if (rc == 0) {
                SMR_BA(m, sector_data, 0x100);
            } else {
                break;
            }
        }
        if (dadr.sector == 0) {
            break;
        }
    }

    vdrive_bam_reread_bam(dnr + 8);

    snapshot_module_close(m);
    m = NULL;

    return 0;
}
Exemplo n.º 20
0
/**
 * Show and process the floppy disk image dialog.
 */
void DlgFloppy_Main(void)
{
	int but, i;
	char *newdisk;
	char dlgname[MAX_FLOPPYDRIVES][64], dlgdiskdir[64];

	SDLGui_CenterDlg(floppydlg);

	/* Set up dialog to actual values: */
 const char *name;

 floppydlg[FLOPPYDLG_ATTACH2FLIPLIST].state &= ~SG_SELECTED;

 name = file_system_get_disk_name(8); /* Filename */
 if (!name)dlgname[0][0] = '\0';
 else File_ShrinkName(dlgname[0], name,floppydlg[FLOPPYDLG_DISKA].w);
 floppydlg[FLOPPYDLG_DISKA].txt = dlgname[0];

 name = file_system_get_disk_name(9); /* Filename */
 if (!name)dlgname[1][0] = '\0';
 else File_ShrinkName(dlgname[1], name,floppydlg[FLOPPYDLG_DISKB].w);
 floppydlg[FLOPPYDLG_DISKB].txt = dlgname[1];

 name = file_system_get_disk_name(10); /* Filename */
 if (!name)dlgname[2][0] = '\0';
 else File_ShrinkName(dlgname[2], name,floppydlg[FLOPPYDLG_DISK2].w);
 floppydlg[FLOPPYDLG_DISK2].txt = dlgname[2];

 name = file_system_get_disk_name(11); /* Filename */
 if (!name)dlgname[3][0] = '\0';
 else File_ShrinkName(dlgname[3], name,floppydlg[FLOPPYDLG_DISK3].w);
 floppydlg[FLOPPYDLG_DISK3].txt = dlgname[3];

	/* Default image directory: */
	File_ShrinkName(dlgdiskdir,szDiskImageDirectory,
	                floppydlg[FLOPPYDLG_IMGDIR].w);
	floppydlg[FLOPPYDLG_IMGDIR].txt = dlgdiskdir;


	/* Draw and process the dialog */
	do
	{       
		but = SDLGui_DoDialog(floppydlg, NULL);
		switch (but)
		{
		 case FLOPPYDLG_EJECTA:                         /* Eject disk in drive A: */
			Floppy_SetDiskFileNameNone(0);
			dlgname[0][0] = '\0';
			file_system_detach_disk(GET_DRIVE(8));

			break;
		 case FLOPPYDLG_BROWSEA:                        /* Choose a new disk A: */
			DlgDisk_BrowseDisk(dlgname[0], 0, FLOPPYDLG_DISKA);

			if (strlen(szDiskFileName[0]) > 0){

			int drivetype;

			printf("load (%s)-",szDiskFileName[0]);
			resources_get_int_sprintf("Drive%iType", &drivetype, GET_DRIVE(8));
			printf("(Drive%iType)\n",drivetype);

			cartridge_detach_image(-1);
			tape_image_detach(1);
//			file_system_detach_disk(GET_DRIVE(8));

			if(File_DoesFileExtensionMatch(szDiskFileName[0],"CRT"))
				cartridge_attach_image(CARTRIDGE_CRT, szDiskFileName[0]);
			else {
//FIXME
/*
				if(File_DoesFileExtensionMatch(szDiskFileName[0],"D81") && drivetype!=1581)
						resources_set_int_sprintf("Drive%iType", 1581,  GET_DRIVE(8));
				else if (drivetype!=1542 && !File_DoesFileExtensionMatch(szDiskFileName[0],"D81"))
						resources_set_int_sprintf("Drive%iType", 1542,  GET_DRIVE(8));
*/			

				if (floppydlg[FLOPPYDLG_ATTACH2FLIPLIST].state & SG_SELECTED){
					file_system_detach_disk(GET_DRIVE(8));
					printf("Attach to flip list\n");
					file_system_attach_disk(8, szDiskFileName[0]);
					fliplist_add_image(8)	;
				}
				else {
					printf("autostart\n");
					autostart_autodetect(szDiskFileName[0], NULL, 0, AUTOSTART_MODE_RUN);
				}

			}

			}

			break;
		 case FLOPPYDLG_EJECTB:                         /* Eject disk in drive B: */
			Floppy_SetDiskFileNameNone(1);
			dlgname[1][0] = '\0';
			file_system_detach_disk(GET_DRIVE(9));

			break;
		case FLOPPYDLG_BROWSEB:                         /* Choose a new disk B: */
			DlgDisk_BrowseDisk(dlgname[1], 1, FLOPPYDLG_DISKB);

			if (strlen(szDiskFileName[1]) > 0){
				
			file_system_detach_disk(GET_DRIVE(9));
     		file_system_attach_disk(9, szDiskFileName[1]);
	
			}

		 case FLOPPYDLG_EJECT2:                         /* Eject disk in drive A: */
			Floppy_SetDiskFileNameNone(2);
			dlgname[2][0] = '\0';
			file_system_detach_disk(GET_DRIVE(10));
			break;
		 case FLOPPYDLG_BROWSE2:                        /* Choose a new disk A: */
			DlgDisk_BrowseDisk(dlgname[2], 0, FLOPPYDLG_DISK2);

			if (strlen(szDiskFileName[2]) > 0){
					//strcpy(prefs->DrivePath[2], szDiskFileName[2]);
			}

			break;
		 case FLOPPYDLG_EJECT3:                         /* Eject disk in drive B: */
			Floppy_SetDiskFileNameNone(3);
			dlgname[3][0] = '\0';
			file_system_detach_disk(GET_DRIVE(11));
			break;
		case FLOPPYDLG_BROWSE3:                         /* Choose a new disk B: */
			DlgDisk_BrowseDisk(dlgname[3], 1, FLOPPYDLG_DISKB);

			if (strlen(szDiskFileName[3]) > 0){

//					strcpy(prefs->DrivePath[3], szDiskFileName[3]);
			}

			break;
		 case FLOPPYDLG_BROWSEIMG:
			DlgDisk_BrowseDir(dlgdiskdir,szDiskImageDirectory,floppydlg[FLOPPYDLG_IMGDIR].w);
			break;
/*
		 case FLOPPYDLG_CREATEIMG:
			newdisk = DlgNewDisk_Main();
			if (newdisk)
			{
				DlgFloppy_QueryInsert(dlgname[0], FLOPPYDLG_DISKA,
						      dlgname[1], FLOPPYDLG_DISKB,
						      newdisk);
				free(newdisk);
			}
			break;
*/
		}
                gui_poll_events();
	}
	while (but != FLOPPYDLG_EXIT && but != SDLGUI_QUIT
	        && but != SDLGUI_ERROR && !bQuitProgram);

/*
	if (floppydlg[FLOPPYDLG_AUTOSTART].state & SG_SELECTED){

			if(!ThePrefs.Emul1541Proc){
					prefs->Emul1541Proc = !prefs->Emul1541Proc;
			}
	}
	else {
			if(ThePrefs.Emul1541Proc){
					prefs->Emul1541Proc = !prefs->Emul1541Proc;
			}	

	}
*/

}