Hard disc controllers can now be selected on all machines.

Added device configuration for hard disc controller to Wx GUI.
This commit is contained in:
SarahW 2017-10-01 15:42:32 +01:00
commit 06f7cd3c6c
10 changed files with 3759 additions and 3574 deletions

View file

@ -45,6 +45,9 @@ extern void deviceconfig_open(void* hwnd, device_t *device);
extern int hdconf_init(void* hdlg);
extern int hdconf_update(void* hdlg);
static int hdd_controller_selected_has_config(void *hdlg);
static device_t *hdd_controller_selected_get_device(void *hdlg);
static int mouse_valid(int type, int model)
{
if (((type & MOUSE_TYPE_IF_MASK) == MOUSE_TYPE_PS2)
@ -142,72 +145,75 @@ static void recalc_snd_list(void* hdlg, int model)
wx_sendmessage(h, WX_CB_SETCURSEL, settings_sound_to_list[sound_card_current], 0);
}
static void recalc_hdd_list(void* hdlg, int model, int use_selected_hdd)
static void recalc_hdd_list(void* hdlg, int model, int use_selected_hdd, int force_ide)
{
void* h;
char *s;
int valid = 0;
char old_name[16];
int c, d;
h = wx_getdlgitem(hdlg, WX_ID("IDC_COMBOHDD"));
if (models[model].flags & MODEL_HAS_IDE)
if (force_ide)
strcpy(old_name, "ide");
else if (use_selected_hdd)
{
wx_sendmessage(h, WX_CB_RESETCONTENT, 0, 0);
wx_sendmessage(h, WX_CB_ADDSTRING, 0, (LONG_PARAM)"Internal IDE");
wx_enablewindow(h, FALSE);
wx_sendmessage(h, WX_CB_SETCURSEL, 0, 0);
c = wx_sendmessage(h, WX_CB_GETCURSEL, 0, 0);
if (c != -1 && hdd_names[c])
strncpy(old_name, hdd_names[c], sizeof(old_name)-1);
else
{
if (models[model].flags & MODEL_HAS_IDE)
strcpy(old_name, "none");
else
strcpy(old_name, "ide");
}
}
else
{
char *s;
int valid = 0;
char old_name[16];
int c, d;
if (use_selected_hdd)
{
c = wx_sendmessage(h, WX_CB_GETCURSEL, 0, 0);
if (c != -1 && hdd_names[c])
strncpy(old_name, hdd_names[c], sizeof(old_name)-1);
else
strcpy(old_name, "none");
}
else
strncpy(old_name, hdd_controller_name, sizeof(old_name)-1);
wx_sendmessage(h, WX_CB_RESETCONTENT, 0, 0);
c = d = 0;
while (1)
{
s = hdd_controller_get_name(c);
if (s[0] == 0)
wx_sendmessage(h, WX_CB_RESETCONTENT, 0, 0);
c = d = 0;
while (1)
{
s = hdd_controller_get_name(c);
if (s[0] == 0)
break;
if ((((hdd_controller_get_flags(c) & DEVICE_AT) && !(models[model].flags & MODEL_AT)) ||
(hdd_controller_get_flags(c) & DEVICE_MCA) != (models[model].flags & MODEL_MCA)) && c)
{
c++;
continue;
}
if (!hdd_controller_available(c))
{
c++;
continue;
}
wx_sendmessage(h, WX_CB_ADDSTRING, 0, (LONG_PARAM)s);
hdd_names[d] = hdd_controller_get_internal_name(c);
if (!strcmp(old_name, hdd_names[d]))
{
wx_sendmessage(h, WX_CB_SETCURSEL, d, 0);
valid = 1;
}
if ((((hdd_controller_get_flags(c) & DEVICE_AT) && !(models[model].flags & MODEL_AT)) ||
(hdd_controller_get_flags(c) & DEVICE_MCA) != (models[model].flags & MODEL_MCA)) && c)
{
c++;
d++;
continue;
}
if (!hdd_controller_available(c))
{
c++;
continue;
}
wx_sendmessage(h, WX_CB_ADDSTRING, 0, (LONG_PARAM)s);
hdd_names[d] = hdd_controller_get_internal_name(c);
if (!valid)
if (!strcmp(old_name, hdd_names[d]))
{
wx_sendmessage(h, WX_CB_SETCURSEL, d, 0);
valid = 1;
}
c++;
d++;
}
if (!valid)
wx_sendmessage(h, WX_CB_SETCURSEL, 0, 0);
wx_enablewindow(h, TRUE);
h = wx_getdlgitem(hdlg, WX_ID("IDC_CONFIGUREHDD"));
if (hdd_controller_selected_has_config(hdlg))
wx_enablewindow(h, TRUE);
}
else
wx_enablewindow(h, FALSE);
}
#ifdef USE_NETWORKING
@ -469,6 +475,7 @@ int config_dlgsave(void* hdlg)
return TRUE;
}
static int prev_model;
int config_dlgproc(void* hdlg, int message, INT_PARAM wParam, LONG_PARAM lParam)
{
char temp_str[256];
@ -510,6 +517,7 @@ int config_dlgproc(void* hdlg, int message, INT_PARAM wParam, LONG_PARAM lParam)
c++;
}
wx_sendmessage(h, WX_CB_SETCURSEL, modeltolist[model], 0);
prev_model = model;
recalc_vid_list(hdlg, romstomodel[romset]);
@ -711,7 +719,7 @@ int config_dlgproc(void* hdlg, int message, INT_PARAM wParam, LONG_PARAM lParam)
}
wx_sendmessage(h, WX_CB_SETCURSEL, d, 0);
recalc_hdd_list(hdlg, romstomodel[romset], 0);
recalc_hdd_list(hdlg, romstomodel[romset], 0, 0);
hd_changed = 0;
new_cdrom_channel = cdrom_channel;
@ -735,8 +743,15 @@ int config_dlgproc(void* hdlg, int message, INT_PARAM wParam, LONG_PARAM lParam)
{
if (wParam == WX_ID("IDC_COMBO1"))
{
int force_ide = 0;
h = wx_getdlgitem(hdlg, WX_ID("IDC_COMBO1"));
temp_model = listtomodel[wx_sendmessage(h, WX_CB_GETCURSEL, 0, 0)];
if ((models[temp_model].flags & MODEL_HAS_IDE) && !(models[prev_model].flags & MODEL_HAS_IDE))
force_ide = 1;
prev_model = temp_model;
/*Rebuild manufacturer list*/
h = wx_getdlgitem(hdlg, WX_ID("IDC_COMBOCPUM"));
@ -851,7 +866,7 @@ int config_dlgproc(void* hdlg, int message, INT_PARAM wParam, LONG_PARAM lParam)
recalc_vid_list(hdlg, temp_model);
recalc_hdd_list(hdlg, temp_model, 1);
recalc_hdd_list(hdlg, temp_model, 1, force_ide);
recalc_snd_list(hdlg, temp_model);
#ifdef USE_NETWORKING
@ -989,6 +1004,10 @@ int config_dlgproc(void* hdlg, int message, INT_PARAM wParam, LONG_PARAM lParam)
{
hdconf_update(hdlg);
}
else if (wParam == WX_ID("IDC_CONFIGUREHDD"))
{
deviceconfig_open(hdlg, (void *)hdd_controller_selected_get_device(hdlg));
}
#ifdef USE_NETWORKING
else if (wParam == WX_ID("IDC_COMBO_NETCARD"))
{
@ -1088,6 +1107,22 @@ static int hdd_controller_selected_is_mfm(void* hdlg)
return hdd_controller_is_mfm(hdd_names[c]);
return 0;
}
static int hdd_controller_selected_has_config(void* hdlg)
{
void* h = wx_getdlgitem(hdlg, WX_ID("IDC_COMBOHDD"));
int c = wx_sendmessage(h, WX_CB_GETCURSEL, 0, 0);
if (hdd_names[c])
return hdd_controller_has_config(hdd_names[c]);
return 0;
}
static device_t *hdd_controller_selected_get_device(void *hdlg)
{
void* h = wx_getdlgitem(hdlg, WX_ID("IDC_COMBOHDD"));
int c = wx_sendmessage(h, WX_CB_GETCURSEL, 0, 0);
if (hdd_names[c])
return hdd_controller_get_device(hdd_names[c]);
return NULL;
}
static void check_hd_type(void* hdlg, off64_t sz)
{
@ -1521,6 +1556,7 @@ int hdconf_init(void* hdlg)
int hdconf_update(void* hdlg)
{
char s[260];
void *h;
int is_mfm = hdd_controller_selected_is_mfm(hdlg);
@ -1561,6 +1597,12 @@ int hdconf_update(void* hdlg)
}
}
h = wx_getdlgitem(hdlg, WX_ID("IDC_CONFIGUREHDD"));
if (hdd_controller_selected_has_config(hdlg))
wx_enablewindow(h, TRUE);
else
wx_enablewindow(h, FALSE);
return TRUE;
}