Пример #1
0
static BOOL store_printer_dialog_results(HWND hwnd, unsigned int num)
{
    char printer_name[30];
  
    if (num == 0) {
        sprintf(printer_name, "PrinterUserport");
    } else {
        sprintf(printer_name, "Printer%d", num);
    }

    resources_set_int(printer_name, (int)SendMessage(GetDlgItem(hwnd, IDC_PRINTER_TYPE), CB_GETCURSEL, 0, 0));

    if (num == 6) {
        resources_set_string_sprintf("%sDriver", ui_plotter_driver_1520[SendMessage(GetDlgItem(hwnd, IDC_PRINTER_DRIVER), CB_GETCURSEL, 0, 0)], printer_name);
    } else {
        resources_set_string_sprintf("%sDriver", ui_printer_driver_ascii[SendMessage(GetDlgItem(hwnd, IDC_PRINTER_DRIVER), CB_GETCURSEL, 0, 0)], printer_name);
    }

    resources_set_string_sprintf("%sOutput", ui_printer_output_ascii[SendMessage(GetDlgItem(hwnd, IDC_PRINTER_OUTPUT), CB_GETCURSEL, 0, 0)], printer_name);

    resources_set_int_sprintf("%sTextDevice", (int)SendMessage(GetDlgItem(hwnd, IDC_PRINTER_TEXTOUT), CB_GETCURSEL, 0, 0), printer_name);
  
    resources_set_string("PrinterTextDevice1", printertextdevice[0]);
    resources_set_string("PrinterTextDevice2", printertextdevice[1]);
    resources_set_string("PrinterTextDevice3", printertextdevice[2]);

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

    return 1;
}
Пример #2
0
static TUI_MENU_CALLBACK(radio_type_check_callback)
{
    int drive = (int)param >> 16;
    int type = (int)param & 0xffff;
    int value;
    int i;
    int support = (is_fs(type) || drive_check_type(type, drive - 8));

    if (!support) {
        return "N/A";
    }

    if (been_activated) {
        if (is_fs(type)) {
            resources_set_int_sprintf("IECDevice%i", 1, drive);
            resources_set_int_sprintf("FileSystemDevice%i", type, drive);
        } else {
            if (has_fs()) {
                resources_set_int_sprintf("IECDevice%i", 0, drive);
            }
            resources_set_int_sprintf("Drive%iType", type, drive);
        }
        *become_default = 1;
        ui_update_menus();
    } else {
        if (check_current_drive_type(type, drive)) {
            *become_default = 1;
        }
    }
}
Пример #3
0
static void event_playback_attach_image(void *data, unsigned int size)
{
    unsigned int unit, read_only;
    char *orig_filename, *filename = NULL;
    size_t file_len;

    unit = (unsigned int)((char*)data)[0];
    read_only = (unsigned int)((char*)data)[1];
    orig_filename = &((char*)data)[2];
    file_len  = size - strlen(orig_filename) - 3;

    if (file_len > 0) {
        FILE *fd;

        fd = archdep_mkstemp_fd(&filename, MODE_WRITE);

        if (fd == NULL) {
#ifdef HAS_TRANSLATION
            ui_error(translate_text(IDGS_CANNOT_CREATE_IMAGE), filename);
#else
            ui_error(_("Cannot create image file!"));
#endif
            goto error;
        }

        if (fwrite((char*)data + strlen(orig_filename) + 3, file_len, 1, fd) != 1) {
#ifdef HAS_TRANSLATION
            ui_error(translate_text(IDGS_CANNOT_WRITE_IMAGE_FILE_S), filename);
#else
            ui_error(_("Cannot write image file %s"), filename);
#endif
            goto error;
        }

        fclose(fd);
        event_image_append(orig_filename, &filename, 1);
    } else {
        if (event_image_append(orig_filename, &filename, 0) != 0) {
#ifdef HAS_TRANSLATION
            ui_error(translate_text(IDGS_CANNOT_FIND_MAPPED_NAME_S), orig_filename);
#else
            ui_error(_("Cannot find mapped name for %s"), orig_filename);
#endif
            return;
        }
    }

    /* now filename holds the name to attach    */
    /* FIXME: read_only isn't handled for tape  */
    if (unit == 1) {
        tape_image_event_playback(unit, filename);
    } else {
        resources_set_int_sprintf("AttachDevice%dReadonly", read_only, unit);
        file_system_event_playback(unit, filename);
    }
    
error:
    lib_free(filename);
}
Пример #4
0
static TUI_MENU_CALLBACK(toggle_hide_p00_callback)
{
    int drive = (int)param;
    int hide_p00;

    if (been_activated) {
        resources_get_int_sprintf("FSDevice%iHideCBMFiles", &hide_p00, drive);
        resources_set_int_sprintf("FSDevice%iHideCBMFiles", !hide_p00, drive);
        ui_update_menus();
    }
    resources_get_int_sprintf("FSDevice%iHideCBMFiles", &hide_p00, drive);

    return (hide_p00) ? "On" : "Off";
}
Пример #5
0
static TUI_MENU_CALLBACK(toggle_write_p00_callback)
{
    int drive = (int)param;
    int write_p00;

    if (been_activated) {
        resources_get_int_sprintf("FSDevice%iSaveP00", &write_p00, drive);
        resources_set_int_sprintf("FSDevice%iSaveP00", !write_p00, drive);
        ui_update_menus();
    }
    resources_get_int_sprintf("FSDevice%iSaveP00", &write_p00, drive);

    return (write_p00) ? "On" : "Off";
}
Пример #6
0
static void end_resources_dialog(HWND hwnd, unsigned int type)
{
    unsigned int n = 0;

    while (settings[n].realname != NULL) {
        if (settings[n].type == type) {
            int enable;

            enable = (IsDlgButtonChecked(hwnd, settings[n].idc_resource) == BST_CHECKED) ? 1 : 0;

            resources_set_int_sprintf("Romset%s", enable, settings[n].resname);
        }
        n++;
    }
}
Пример #7
0
static TUI_MENU_CALLBACK(radio_expansion_check_callback)
{
    int drive = (int)param >> 16;
    int value = (int)param & 0xffff;
    int type = get_drive_type(drive);
    int ram_support;
    int res_value;
    int i;

    for (i = 0; uidrives[i].type != type; i++) {}
    switch (value) {
        default:
        case 0x2000:
            ram_support = uidrives[i].ram2000;
            break;
        case 0x4000:
            ram_support = uidrives[i].ram4000;
            break;
        case 0x6000:
            ram_support = uidrives[i].ram6000;
            break;
        case 0x8000:
            ram_support = uidrives[i].ram8000;
            break;
        case 0xA000:
            ram_support = uidrives[i].rama000;
            break;
    }

    if (!ram_support) {
        return "N/A";
    }

    if (been_activated) {
        resources_get_int_sprintf("Drive%iRAM%X", &res_value, drive, value);
        resources_set_int_sprintf("Drive%iRAM%X", !res_value, drive, value);
        ui_update_menus();
    }

    resources_get_int_sprintf("Drive%iRAM%X", &res_value, drive, value);

    return (res_value) ? "On" : "Off";
}
Пример #8
0
static TUI_MENU_CALLBACK(ui_set_wobble_callback)
{
    int num = (int)param;

    if (been_activated) {
        int current_wobble, value;
        char buf[10];

        resources_get_int_sprintf("Drive%iWobble", &current_wobble, num);
        sprintf(buf, "%d", current_wobble);

        if (tui_input_string("Wobble", "Enter the wobble:", buf, 10) == 0) {
            value = atoi(buf);
            resources_set_int_sprintf("Drive%iWobble", value, num);
        } else {
            return NULL;
        }
    }
    return NULL;
}
Пример #9
0
static TUI_MENU_CALLBACK(ui_set_rpm_callback)
{
    int num = (int)param;

    if (been_activated) {
        int current_rpm, value;
        char buf[10];

        resources_get_int_sprintf("Drive%iRPM", &current_rpm, num);
        sprintf(buf, "%d", current_rpm);

        if (tui_input_string("RPM", "Enter the RPM (multiplied by 1000):", buf, 10) == 0) {
            value = atoi(buf);
            resources_set_int_sprintf("Drive%iRPM", value, num);
        } else {
            return NULL;
        }
    }
    return NULL;
}
Пример #10
0
static TUI_MENU_CALLBACK(toggle_par_callback)
{
    int drive = (int)param;
    int type = get_drive_type(drive);
    int par_support = drive_check_parallel_cable(type);
    int par;

    if (!par_support || machine_class == VICE_MACHINE_VIC20) {
        return "N/A";
    }

    if (been_activated) {
        resources_get_int_sprintf("Drive%iParallelCable", &par, drive);
        resources_set_int_sprintf("Drive%iParallelCable", !par, drive);
        ui_update_menus();
    }
    resources_get_int_sprintf("Drive%iParallelCable", &par, drive);

    return (par) ? "On" : "Off";
}
Пример #11
0
static UI_CALLBACK(set_heads)
{
    static char input_string[32];
    int num = vice_ptr_to_int(UI_MENU_CB_PARAM);

    if (CHECK_MENUS) {
        int autosize;

        resources_get_int_sprintf("IDE64AutodetectSize%i", &autosize, num);

        if (autosize) {
            ui_menu_set_sensitive(w, 0);
        } else {
            ui_menu_set_sensitive(w, 1);
        }
    } else {
        char *msg_string;
        ui_button_t button;
        int i;
        int heads;

        vsync_suspend_speed_eval();

        resources_get_int_sprintf("IDE64Heads%i", &heads, num);

        sprintf(input_string, "%d", heads);

        msg_string = lib_stralloc(_("Enter number of heads"));
        button = ui_input_string(_("Heads"), msg_string, input_string, 32);
        lib_free(msg_string);
        if (button == UI_BUTTON_OK) {
            i = atoi(input_string);
            if (heads > 0 && heads <= 16 && heads != i) {
                resources_set_int_sprintf("IDE64Heads%i", i, num);
                ui_update_menus();
            }
        }
    }
}
Пример #12
0
static UI_CALLBACK(set_cylinders)
{
    static char input_string[32];
    int num = (int)UI_MENU_CB_PARAM;

    if (CHECK_MENUS) {
        int autosize;

        resources_get_int_sprintf("IDE64AutodetectSize%i", &autosize, num);

        if (autosize) {
            ui_menu_set_sensitive(w, 0);
        } else {
            ui_menu_set_sensitive(w, 1);
        }
    } else {
        char *msg_string;
        ui_button_t button;
        int i;
        int cylinders;

        vsync_suspend_speed_eval();

        resources_get_int_sprintf("IDE64Cylinders%i", &cylinders, num);

        sprintf(input_string, "%d", cylinders);

        msg_string = lib_stralloc(_("Enter number of cylinders"));
        button = ui_input_string(_("Cylinders"), msg_string, input_string, 32);
        lib_free(msg_string);
        if (button == UI_BUTTON_OK) {
            i = atoi(input_string);
            if (cylinders > 0 && cylinders <= 1024 && cylinders != i) {
                resources_set_int_sprintf("IDE64Cylinders%i", i, num);
                ui_update_menus();
            }
        }
    }
}
Пример #13
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;
}
Пример #14
0
static TUI_MENU_CALLBACK(radio_idle_check_callback)
{
    int drive = (int)param >> 16;
    int value = (int)param & 0xffff;
    int type = get_drive_type(drive);
    int idle_support = drive_check_idle_method(type);
    int res_value;

    if (!idle_support) {
        return "N/A";
    }

    if (been_activated) {
        resources_set_int_sprintf("Drive%iIdleMethod", value, drive);
        *become_default = 1;
        ui_update_menus();
    } else {
        resources_get_int_sprintf("Drive%iIdleMethod", &res_value, drive);
        if (res_value == value) {
            *become_default = 1;
        }
    }
}
Пример #15
0
/* Initialize the hardware-level drive emulation (should be called at least
   once before anything else).  Return 0 on success, -1 on error.  */
int drive_init(void)
{
	unsigned int dnr;
	drive_t *drive;

	if (rom_loaded)
		return 0;

	driverom_init();
	drive_image_init();

	for (dnr = 0; dnr < DRIVE_NUM; dnr++)
	{
		char *logname;

		drive = drive_context[dnr]->drive;
		logname = lib_msprintf("Drive %i", dnr + 8);
		lib_free(logname);

		drive_clk[dnr] = 0L;
		drive->clk = &drive_clk[dnr];
		drive->mynumber = dnr;
	}

	if (driverom_load_images() < 0) {
		resources_set_int("Drive8Type", DRIVE_TYPE_NONE);
		resources_set_int("Drive9Type", DRIVE_TYPE_NONE);
		return -1;
	}

#ifdef CELL_DEBUG
	printf("INFO: Finished loading ROM images.\n");
#endif

	rom_loaded = 1;

	drive_overflow_init();

	for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
		drive = drive_context[dnr]->drive;
		drive->drive_ram_expand2 = NULL;
		drive->drive_ram_expand4 = NULL;
		drive->drive_ram_expand6 = NULL;
		drive->drive_ram_expand8 = NULL;
		drive->drive_ram_expanda = NULL;

		machine_drive_port_default(drive_context[dnr]);

		if (drive_check_type(drive->type, dnr) < 1)
			resources_set_int_sprintf("Drive%iType", DRIVE_TYPE_NONE, dnr + 8);

		machine_drive_rom_setup_image(dnr);
	}

	for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
		drive = drive_context[dnr]->drive;
		drive->gcr = gcr_create_image();
		drive->byte_ready_level = 1;
		drive->byte_ready_edge = 1;
		drive->GCR_dirty_track = 0;
		drive->GCR_write_value = 0x55;
		drive->GCR_track_start_ptr = drive->gcr->data;
		drive->GCR_current_track_size = 0;
		drive->attach_clk = (CLOCK)0;
		drive->detach_clk = (CLOCK)0;
		drive->attach_detach_clk = (CLOCK)0;
		drive->old_led_status = 0;
		drive->old_half_track = 0;
		drive->side = 0;
		drive->GCR_image_loaded = 0;
		drive->read_only = 0;
		drive->clock_frequency = 1;
		drive->led_last_change_clk = *(drive->clk);
		drive->led_last_uiupdate_clk = *(drive->clk);
		drive->led_active_ticks = 0;

		rotation_reset(drive);
		drive_image_init_track_size_d64(drive);

		/* Position the R/W head on the directory track.  */
		drive_set_half_track(36, drive);
		drive_led_color[dnr] = DRIVE_ACTIVE_RED;
	}

	for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
		drive = drive_context[dnr]->drive;
		driverom_initialize_traps(drive);

		drivesync_clock_frequency(drive->type, drive);

		rotation_init((drive->clock_frequency == 2) ? 1 : 0, dnr);

		drivecpu_init(drive_context[dnr], drive->type);

		/* Make sure the sync factor is acknowledged correctly.  */
		drivesync_factor(drive_context[dnr]);

		/* Make sure the traps are moved as needed.  */
		if (drive->enable)
			drive_enable(drive_context[dnr]);
	}

	return 0;
}
Пример #16
0
static BOOL CALLBACK dialog_proc(int num, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
    int type;

    switch (msg) {
        case WM_NOTIFY:
            if (((NMHDR FAR *)lparam)->code == (UINT)PSN_APPLY) {
                resources_set_int_sprintf("Drive%dType", dialog_drive_type[num - 8], num);
                resources_set_int_sprintf("Drive%dExtendImagePolicy", dialog_drive_extend[num - 8], num);
                resources_set_int_sprintf("Drive%dIdleMethod", dialog_drive_idle[num - 8], num);
                resources_set_int_sprintf("Drive%dRAM2000", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_2000) == BST_CHECKED ? 1 : 0), num);
                resources_set_int_sprintf("Drive%dRAM4000", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_4000) == BST_CHECKED ? 1 : 0), num);
                resources_set_int_sprintf("Drive%dRAM6000", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_6000) == BST_CHECKED ? 1 : 0), num);
                resources_set_int_sprintf("Drive%dRAM8000", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_8000) == BST_CHECKED ? 1 : 0), num);
                resources_set_int_sprintf("Drive%dRAMA000", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_A000) == BST_CHECKED ? 1 : 0), num);
                resources_set_int_sprintf("Drive%dRTCSave", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_DRIVE_RTC_SAVE) == BST_CHECKED ? 1 : 0), num);
                SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE);
                return TRUE;
            }
            return FALSE;
        case WM_INITDIALOG:
            init_dialog(hwnd, num);
            return TRUE;
        case WM_COMMAND:
            type = LOWORD(wparam);
            switch (type) {
                case IDC_SELECT_DRIVE_TYPE_NONE:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_NONE;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1540:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1540;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1541:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1541;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1541II:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1541II;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1570:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1570;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1571:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1571;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1581:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1581;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_2000:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_2000;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_4000:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_4000;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_EXTEND_NEVER:
                    dialog_drive_extend[num - 8] = DRIVE_EXTEND_NEVER;
                    break;
                case IDC_SELECT_DRIVE_EXTEND_ASK:
                    dialog_drive_extend[num - 8] = DRIVE_EXTEND_ASK;
                    break;
                case IDC_SELECT_DRIVE_EXTEND_ACCESS:
                    dialog_drive_extend[num - 8] = DRIVE_EXTEND_ACCESS;
                    break;
                case IDC_SELECT_DRIVE_IDLE_NO_IDLE:
                    dialog_drive_idle[num - 8] = DRIVE_IDLE_NO_IDLE;
                    break;
                case IDC_SELECT_DRIVE_IDLE_TRAP_IDLE:
                    dialog_drive_idle[num - 8] = DRIVE_IDLE_TRAP_IDLE;
                    break;
                case IDC_SELECT_DRIVE_IDLE_SKIP_CYCLES:
                    dialog_drive_idle[num - 8] = DRIVE_IDLE_SKIP_CYCLES;
                    break;
                case IDC_TOGGLE_DRIVE_EXPANSION_2000:
                case IDC_TOGGLE_DRIVE_EXPANSION_4000:
                case IDC_TOGGLE_DRIVE_EXPANSION_6000:
                case IDC_TOGGLE_DRIVE_EXPANSION_8000:
                case IDC_TOGGLE_DRIVE_EXPANSION_A000:
                case IDC_TOGGLE_DRIVE_RTC_SAVE:
                    break;
            }
            return TRUE;
    }
    return FALSE;
}
Пример #17
0
static BOOL CALLBACK dialog_proc(int num, HWND hwnd, UINT msg,
                                 WPARAM wparam, LPARAM lparam)
{
    char tmp[256];

    switch (msg) {
      case WM_INITDIALOG:
        init_dialog(hwnd, num);
        return TRUE;
      case WM_COMMAND:
        switch (LOWORD(wparam)) {
          case IDC_SELECT_DRIVE_TYPE_NONE:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_NONE, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_1541:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_1541, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_1541II:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_1541II, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_1551:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_1551, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_1570:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_1570, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_1571:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_1571, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_1581:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_1581, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_EXTEND_NEVER:
            resources_set_int_sprintf("Drive%dExtendImagePolicy",
                                      DRIVE_EXTEND_NEVER, num);
            break;
          case IDC_SELECT_DRIVE_EXTEND_ASK:
            resources_set_int_sprintf("Drive%dExtendImagePolicy",
                                      DRIVE_EXTEND_ASK, num);
            break;
          case IDC_SELECT_DRIVE_EXTEND_ACCESS:
            resources_set_int_sprintf("Drive%dExtendImagePolicy",
                                      DRIVE_EXTEND_ACCESS, num);
            break;
          case IDC_SELECT_DRIVE_IDLE_NO_IDLE:
            resources_set_int_sprintf("Drive%dIdleMethod",
                                      DRIVE_IDLE_NO_IDLE, num);
            break;
          case IDC_SELECT_DRIVE_IDLE_TRAP_IDLE:
            resources_set_int_sprintf("Drive%dIdleMethod",
                                      DRIVE_IDLE_TRAP_IDLE, num);
            break;
          case IDC_SELECT_DRIVE_IDLE_SKIP_CYCLES:
            resources_set_int_sprintf("Drive%dIdleMethod",
                                      DRIVE_IDLE_SKIP_CYCLES, num);
            break;
          case IDC_TOGGLE_DRIVE_PARALLEL_CABLE:
            sprintf(tmp, "Drive%dParallelCable", num);
            resources_toggle(tmp, NULL);
            break;
          case IDC_TOGGLE_DRIVE_EXPANSION_2000:
            sprintf(tmp, "Drive%dRAM2000", num);
            resources_toggle(tmp, NULL);
            break;
          case IDC_TOGGLE_DRIVE_EXPANSION_4000:
            sprintf(tmp, "Drive%dRAM4000", num);
            resources_toggle(tmp, NULL);
            break;
          case IDC_TOGGLE_DRIVE_EXPANSION_6000:
            sprintf(tmp, "Drive%dRAM6000", num);
            resources_toggle(tmp, NULL);
            break;
          case IDC_TOGGLE_DRIVE_EXPANSION_8000:
            sprintf(tmp, "Drive%dRAM8000", num);
            resources_toggle(tmp, NULL);
            break;
          case IDC_TOGGLE_DRIVE_EXPANSION_A000:
            sprintf(tmp, "Drive%dRAMA000", num);
            resources_toggle(tmp, NULL);
            break;
          default:
            return FALSE;
        }
        return TRUE;
    }
    return FALSE;
}
Пример #18
0
static BOOL CALLBACK dialog_proc(int num, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
    int type;
    int rpm;
    TCHAR st[MAX_PATH];

    switch (msg) {
        case WM_NOTIFY:
            if (((NMHDR FAR *)lparam)->code == (UINT)PSN_APPLY) {
                resources_set_int_sprintf("Drive%dType", dialog_drive_type[num - 8], num);
                resources_set_int_sprintf("Drive%dExtendImagePolicy", dialog_drive_extend[num - 8], num);
                resources_set_int_sprintf("Drive%dIdleMethod", dialog_drive_idle[num - 8], num);
                resources_set_int_sprintf("Drive%dParallelCable", (int)SendMessage(GetDlgItem(hwnd, IDC_DRIVE_PARALLEL_CABLE), CB_GETCURSEL, 0, 0), num);
                resources_set_int_sprintf("Drive%dRAM2000", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_2000) == BST_CHECKED ? 1 : 0), num);
                resources_set_int_sprintf("Drive%dRAM4000", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_4000) == BST_CHECKED ? 1 : 0), num);
                resources_set_int_sprintf("Drive%dRAM6000", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_6000) == BST_CHECKED ? 1 : 0), num);
                resources_set_int_sprintf("Drive%dRAM8000", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_8000) == BST_CHECKED ? 1 : 0), num);
                resources_set_int_sprintf("Drive%dRAMA000", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_A000) == BST_CHECKED ? 1 : 0), num);
                resources_set_int_sprintf("Drive%dRTCSave", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_DRIVE_RTC_SAVE) == BST_CHECKED ? 1 : 0), num);

                GetDlgItemText(hwnd, IDC_DRIVE_RPM_VALUE, st, MAX_PATH);
                rpm = atoi(st);
                resources_set_int_sprintf("Drive%dRPM", rpm, num);

                GetDlgItemText(hwnd, IDC_DRIVE_WOBBLE_VALUE, st, MAX_PATH);
                rpm = atoi(st);
                resources_set_int_sprintf("Drive%dWobble", rpm, num);

                SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE);
                return TRUE;
            }
            return FALSE;
        case WM_INITDIALOG:
            init_dialog(hwnd, num);
            return TRUE;
        case WM_COMMAND:
            type = LOWORD(wparam);
            switch (type) {
                case IDC_SELECT_DRIVE_TYPE_NONE:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_NONE;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1540:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1540;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1541:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1541;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1541II:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1541II;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1551:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1551;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1570:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1570;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1571:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1571;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1581:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1581;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_2000:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_2000;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_4000:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_4000;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_2031:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_2031;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_2040:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_2040;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_3040:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_3040;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_4040:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_4040;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_1001:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_1001;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_8050:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_8050;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_TYPE_8250:
                    dialog_drive_type[num - 8] = DRIVE_TYPE_8250;
                    enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
                    break;
                case IDC_SELECT_DRIVE_EXTEND_NEVER:
                    dialog_drive_extend[num - 8] = DRIVE_EXTEND_NEVER;
                    break;
                case IDC_SELECT_DRIVE_EXTEND_ASK:
                    dialog_drive_extend[num - 8] = DRIVE_EXTEND_ASK;
                    break;
                case IDC_SELECT_DRIVE_EXTEND_ACCESS:
                    dialog_drive_extend[num - 8] = DRIVE_EXTEND_ACCESS;
                    break;
                case IDC_SELECT_DRIVE_IDLE_NO_IDLE:
                    dialog_drive_idle[num - 8] = DRIVE_IDLE_NO_IDLE;
                    break;
                case IDC_SELECT_DRIVE_IDLE_TRAP_IDLE:
                    dialog_drive_idle[num - 8] = DRIVE_IDLE_TRAP_IDLE;
                    break;
                case IDC_SELECT_DRIVE_IDLE_SKIP_CYCLES:
                    dialog_drive_idle[num - 8] = DRIVE_IDLE_SKIP_CYCLES;
                    break;
                case IDC_DRIVE_PARALLEL_CABLE:
                case IDC_TOGGLE_DRIVE_EXPANSION_2000:
                case IDC_TOGGLE_DRIVE_EXPANSION_4000:
                case IDC_TOGGLE_DRIVE_EXPANSION_6000:
                case IDC_TOGGLE_DRIVE_EXPANSION_8000:
                case IDC_TOGGLE_DRIVE_EXPANSION_A000:
                case IDC_TOGGLE_DRIVE_RTC_SAVE:
                    break;
            }
            return TRUE;
    }
    return FALSE;
}
Пример #19
0
/* Initialize the hardware-level drive emulation (should be called at least
   once before anything else).  Return 0 on success, -1 on error.  */
int drive_init(void)
{
    unsigned int dnr;
    drive_t *drive;

    if (rom_loaded) {
        return 0;
    }

    drive_init_was_called = 1;

    driverom_init();
    drive_image_init();

    drive_log = log_open("Drive");

    for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
        char *logname;

        drive = drive_context[dnr]->drive;
        logname = lib_msprintf("Drive %i", dnr + 8);
        drive->log = log_open(logname);
        lib_free(logname);

        drive_clk[dnr] = 0L;
        drive->clk = &drive_clk[dnr];
        drive->mynumber = dnr;
    }

    if (driverom_load_images() < 0) {
        resources_set_int("Drive8Type", DRIVE_TYPE_NONE);
        resources_set_int("Drive9Type", DRIVE_TYPE_NONE);
        resources_set_int("Drive10Type", DRIVE_TYPE_NONE);
        resources_set_int("Drive11Type", DRIVE_TYPE_NONE);
        return -1;
    }

    log_message(drive_log, "Finished loading ROM images.");
    rom_loaded = 1;

    drive_overflow_init();

    for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
        drive = drive_context[dnr]->drive;

        machine_drive_port_default(drive_context[dnr]);

        if (drive_check_type(drive->type, dnr) < 1) {
            resources_set_int_sprintf("Drive%iType", DRIVE_TYPE_NONE, dnr + 8);
        }

        machine_drive_rom_setup_image(dnr);
    }

    for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
        drive = drive_context[dnr]->drive;
        drive->gcr = gcr_create_image();
        drive->p64 = lib_calloc(1, sizeof(TP64Image));
        P64ImageCreate(drive->p64);
        drive->byte_ready_level = 1;
        drive->byte_ready_edge = 1;
        drive->GCR_dirty_track = 0;
        drive->GCR_write_value = 0x55;
        drive->GCR_track_start_ptr = NULL;
        drive->GCR_current_track_size = 0;
        drive->attach_clk = (CLOCK)0;
        drive->detach_clk = (CLOCK)0;
        drive->attach_detach_clk = (CLOCK)0;
        drive->old_led_status = 0;
        drive->old_half_track = 0;
        drive->side = 0;
        drive->GCR_image_loaded = 0;
        drive->P64_image_loaded = 0;
        drive->P64_dirty = 0;
        drive->read_only = 0;
        drive->clock_frequency = 1;
        drive->led_last_change_clk = *(drive->clk);
        drive->led_last_uiupdate_clk = *(drive->clk);
        drive->led_active_ticks = 0;

        rotation_reset(drive);

        /* Position the R/W head on the directory track.  */
        drive_set_half_track(36, 0, drive);
        drive_set_active_led_color(drive->type, dnr);
    }

    for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
        drive = drive_context[dnr]->drive;
        driverom_initialize_traps(drive);

        drivesync_clock_frequency(drive->type, drive);

        rotation_init((drive->clock_frequency == 2) ? 1 : 0, dnr);

        if (drive->type == DRIVE_TYPE_2000 || drive->type == DRIVE_TYPE_4000) {
            drivecpu65c02_init(drive_context[dnr], drive->type);
        } else {
            drivecpu_init(drive_context[dnr], drive->type);
        }

        /* Make sure the sync factor is acknowledged correctly.  */
        drivesync_factor(drive_context[dnr]);

        /* Make sure the traps are moved as needed.  */
        if (drive->enable) {
            drive_enable(drive_context[dnr]);
        }
    }

    return 0;
}
Пример #20
0
void set_drive_type(int drive,int val)
{
	   if(retro_ui_finalized== 1)
			resources_set_int_sprintf("Drive%iType", val, drive);
}
Пример #21
0
static BOOL CALLBACK dialog_proc(int num, HWND hwnd, UINT msg,
                                 WPARAM wparam, LPARAM lparam)
{
    switch (msg) {
      case WM_INITDIALOG:
        init_dialog(hwnd, num);
        return TRUE;
      case WM_COMMAND:
        switch (LOWORD(wparam)) {
          case IDC_SELECT_DRIVE_TYPE_NONE:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_NONE, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_2031:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_2031, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_2040:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_2040, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_3040:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_3040, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_4040:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_4040, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_1001:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_1001, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_8050:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_8050, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_TYPE_8250:
            resources_set_int_sprintf("Drive%dType", DRIVE_TYPE_8250, num);
            enable_controls_for_drive_settings(hwnd, LOWORD(wparam));
            break;
          case IDC_SELECT_DRIVE_EXTEND_NEVER:
            resources_set_int_sprintf("Drive%dExtendImagePolicy",
                                      DRIVE_EXTEND_NEVER, num);
            break;
          case IDC_SELECT_DRIVE_EXTEND_ASK:
            resources_set_int_sprintf("Drive%dExtendImagePolicy",
                                      DRIVE_EXTEND_ASK, num);
            break;
          case IDC_SELECT_DRIVE_EXTEND_ACCESS:
            resources_set_int_sprintf("Drive%dExtendImagePolicy",
                                      DRIVE_EXTEND_ACCESS, num);
            break;
          default:
            return FALSE;
        }
        return TRUE;
    }
    return FALSE;
}
Пример #22
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);
}