Merge pull request #1097 from richardg867/master

Programmatic CPU table
This commit is contained in:
Miran Grča
2020-11-18 05:47:49 +01:00
committed by GitHub
19 changed files with 1895 additions and 1430 deletions

View File

@@ -74,7 +74,8 @@ static int first_cat = 0;
static int dpi = 96;
/* Machine category */
static int temp_machine_type, temp_machine, temp_cpu_m, temp_cpu, temp_wait_states, temp_fpu, temp_sync;
static int temp_machine_type, temp_machine, temp_cpu, temp_wait_states, temp_fpu, temp_sync;
static cpu_family_t *temp_cpu_f;
static uint32_t temp_mem_size;
#ifdef USE_DYNAREC
static int temp_dynarec;
@@ -126,6 +127,7 @@ static uint32_t displayed_category = 0;
extern int is486;
static int listtomachinetype[256], listtomachine[256];
static int listtocpufamily[256], listtocpu[256];
static int settings_list_to_device[2][20], settings_list_to_fdc[20];
static int settings_list_to_midi[20], settings_list_to_midi_in[20];
static int settings_list_to_hdc[20];
@@ -296,7 +298,7 @@ win_settings_init(void)
/* Machine category */
temp_machine_type = machines[machine].type;
temp_machine = machine;
temp_cpu_m = cpu_manufacturer;
temp_cpu_f = cpu_f;
temp_wait_states = cpu_waitstates;
temp_cpu = cpu;
temp_mem_size = mem_size;
@@ -416,7 +418,7 @@ win_settings_changed(void)
/* Machine category */
i = i || (machine != temp_machine);
i = i || (cpu_manufacturer != temp_cpu_m);
i = i || (cpu_f != temp_cpu_f);
i = i || (cpu_waitstates != temp_wait_states);
i = i || (cpu != temp_cpu);
i = i || (mem_size != temp_mem_size);
@@ -528,7 +530,7 @@ win_settings_save(void)
/* Machine category */
machine = temp_machine;
cpu_manufacturer = temp_cpu_m;
cpu_f = temp_cpu_f;
cpu_waitstates = temp_wait_states;
cpu = temp_cpu;
mem_size = temp_mem_size;
@@ -638,8 +640,8 @@ win_settings_machine_recalc_fpu(HWND hdlg)
settings_reset_content(hdlg, IDC_COMBO_FPU);
c = 0;
while (1) {
stransi = (char *) fpu_get_name_from_index(temp_machine, temp_cpu_m, temp_cpu, c);
type = fpu_get_type_from_index(temp_machine, temp_cpu_m, temp_cpu, c);
stransi = (char *) fpu_get_name_from_index(temp_cpu_f, temp_cpu, c);
type = fpu_get_type_from_index(temp_cpu_f, temp_cpu, c);
if (!stransi)
break;
@@ -653,7 +655,7 @@ win_settings_machine_recalc_fpu(HWND hdlg)
settings_enable_window(hdlg, IDC_COMBO_FPU, c > 1);
temp_fpu = fpu_get_type_from_index(temp_machine, temp_cpu_m, temp_cpu, settings_get_cur_sel(hdlg, IDC_COMBO_FPU));
temp_fpu = fpu_get_type_from_index(temp_cpu_f, temp_cpu, settings_get_cur_sel(hdlg, IDC_COMBO_FPU));
}
@@ -665,11 +667,11 @@ win_settings_machine_recalc_cpu(HWND hdlg)
int cpu_flags;
#endif
cpu_type = machines[temp_machine].cpu[temp_cpu_m].cpus[temp_cpu].cpu_type;
cpu_type = temp_cpu_f->cpus[temp_cpu].cpu_type;
settings_enable_window(hdlg, IDC_COMBO_WS, (cpu_type >= CPU_286) && (cpu_type <= CPU_386DX));
#ifdef USE_DYNAREC
cpu_flags = machines[temp_machine].cpu[temp_cpu_m].cpus[temp_cpu].cpu_flags;
cpu_flags = temp_cpu_f->cpus[temp_cpu].cpu_flags;
if (!(cpu_flags & CPU_SUPPORTS_DYNAREC) && (cpu_flags & CPU_REQUIRES_DYNAREC))
fatal("Attempting to select a CPU that requires the recompiler and does not support it at the same time\n");
if (!(cpu_flags & CPU_SUPPORTS_DYNAREC) || (cpu_flags & CPU_REQUIRES_DYNAREC)) {
@@ -692,24 +694,39 @@ win_settings_machine_recalc_cpu(HWND hdlg)
static void
win_settings_machine_recalc_cpu_m(HWND hdlg)
{
int c;
int c, i, first_eligible = -1, current_eligible = 0, last_eligible = 0;
LPTSTR lptsTemp;
char *stransi;
lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR));
settings_reset_content(hdlg, IDC_COMBO_CPU);
c = 0;
while (machines[temp_machine].cpu[temp_cpu_m].cpus[c].cpu_type != -1) {
stransi = (char *) machines[temp_machine].cpu[temp_cpu_m].cpus[c].name;
mbstowcs(lptsTemp, stransi, strlen(stransi) + 1);
settings_add_string(hdlg, IDC_COMBO_CPU, (LPARAM)(LPCSTR)lptsTemp);
c = i = 0;
while (temp_cpu_f->cpus[c].cpu_type != 0) {
if (cpu_is_eligible(temp_cpu_f, c, temp_machine)) {
stransi = (char *) temp_cpu_f->cpus[c].name;
mbstowcs(lptsTemp, stransi, strlen(stransi) + 1);
settings_add_string(hdlg, IDC_COMBO_CPU, (LPARAM)(LPCSTR)lptsTemp);
if (first_eligible == -1)
first_eligible = i;
if (temp_cpu == c)
current_eligible = i;
last_eligible = i;
listtocpu[i++] = c;
}
c++;
}
settings_enable_window(hdlg, IDC_COMBO_CPU, c != 1);
if (temp_cpu >= c)
temp_cpu = (c - 1);
settings_set_cur_sel(hdlg, IDC_COMBO_CPU, temp_cpu);
if (i == 0)
fatal("No eligible CPUs for the selected family\n");
settings_enable_window(hdlg, IDC_COMBO_CPU, i != 1);
if (current_eligible < first_eligible)
current_eligible = first_eligible;
else if (current_eligible > last_eligible)
current_eligible = last_eligible;
temp_cpu = listtocpu[current_eligible];
settings_set_cur_sel(hdlg, IDC_COMBO_CPU, current_eligible);
win_settings_machine_recalc_cpu(hdlg);
@@ -721,9 +738,9 @@ static void
win_settings_machine_recalc_machine(HWND hdlg)
{
HWND h;
int c, is_at;
int c, i, current_eligible, is_at;
LPTSTR lptsTemp;
const char *stransi;
char *stransi;
UDACCEL accel;
device_t *d;
@@ -733,18 +750,31 @@ win_settings_machine_recalc_machine(HWND hdlg)
settings_enable_window(hdlg, IDC_CONFIGURE_MACHINE, d && d->config);
settings_reset_content(hdlg, IDC_COMBO_CPU_TYPE);
c = 0;
while (machines[temp_machine].cpu[c].cpus != NULL && c < 4) {
stransi = machines[temp_machine].cpu[c].name;
mbstowcs(lptsTemp, stransi, strlen(stransi) + 1);
settings_add_string(hdlg, IDC_COMBO_CPU_TYPE, (LPARAM)(LPCSTR)lptsTemp);
c = i = 0;
current_eligible = -1;
while (cpu_families[c].package != 0) {
if (cpu_family_is_eligible(&cpu_families[c], temp_machine)) {
stransi = malloc(strlen((char *) cpu_families[c].manufacturer) + strlen((char *) cpu_families[c].name) + 2);
sprintf(stransi, "%s %s", (char *) cpu_families[c].manufacturer, (char *) cpu_families[c].name);
mbstowcs(lptsTemp, stransi, strlen(stransi) + 1);
free(stransi);
settings_add_string(hdlg, IDC_COMBO_CPU_TYPE, (LPARAM)(LPCSTR)lptsTemp);
if (&cpu_families[c] == temp_cpu_f)
current_eligible = i;
listtocpufamily[i++] = c;
}
c++;
}
if (i == 0)
fatal("No eligible CPU families for the selected machine\n");
settings_enable_window(hdlg, IDC_COMBO_CPU_TYPE, TRUE);
if (temp_cpu_m >= c)
temp_cpu_m = (c - 1);
settings_set_cur_sel(hdlg, IDC_COMBO_CPU_TYPE, temp_cpu_m);
settings_enable_window(hdlg, IDC_COMBO_CPU_TYPE, c != 1);
if (current_eligible == -1) {
temp_cpu_f = &cpu_families[listtocpufamily[0]];
settings_set_cur_sel(hdlg, IDC_COMBO_CPU_TYPE, 0);
} else {
settings_set_cur_sel(hdlg, IDC_COMBO_CPU_TYPE, current_eligible);
}
settings_enable_window(hdlg, IDC_COMBO_CPU_TYPE, i != 1);
win_settings_machine_recalc_cpu_m(hdlg);
@@ -907,20 +937,20 @@ win_settings_machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
break;
case IDC_COMBO_CPU_TYPE:
if (HIWORD(wParam) == CBN_SELCHANGE) {
temp_cpu_m = settings_get_cur_sel(hdlg, IDC_COMBO_CPU_TYPE);
temp_cpu_f = &cpu_families[listtocpufamily[settings_get_cur_sel(hdlg, IDC_COMBO_CPU_TYPE)]];
temp_cpu = 0;
win_settings_machine_recalc_cpu_m(hdlg);
}
break;
case IDC_COMBO_CPU:
if (HIWORD(wParam) == CBN_SELCHANGE) {
temp_cpu = settings_get_cur_sel(hdlg, IDC_COMBO_CPU);
temp_cpu = listtocpu[settings_get_cur_sel(hdlg, IDC_COMBO_CPU)];
win_settings_machine_recalc_cpu(hdlg);
}
break;
case IDC_COMBO_FPU:
if (HIWORD(wParam) == CBN_SELCHANGE) {
temp_fpu = fpu_get_type_from_index(temp_machine, temp_cpu_m, temp_cpu,
temp_fpu = fpu_get_type_from_index(temp_cpu_f, temp_cpu,
settings_get_cur_sel(hdlg, IDC_COMBO_FPU));
}
break;
@@ -3956,8 +3986,8 @@ mo_recalc_location_controls(HWND hdlg, int assign_id)
switch(bus) {
case MO_BUS_ATAPI: /* ATAPI */
settings_show_window(hdlg, IDT_1772, TRUE);
settings_show_window(hdlg, IDC_COMBO_MO_CHANNEL_IDE, TRUE);
settings_show_window(hdlg, IDT_1772, TRUE);
settings_show_window(hdlg, IDC_COMBO_MO_CHANNEL_IDE, TRUE);
if (assign_id)
temp_mo_drives[lv1_current_sel].ide_channel = next_free_ide_channel();
@@ -3965,8 +3995,8 @@ mo_recalc_location_controls(HWND hdlg, int assign_id)
settings_set_cur_sel(hdlg, IDC_COMBO_MO_CHANNEL_IDE, temp_mo_drives[lv1_current_sel].ide_channel);
break;
case MO_BUS_SCSI: /* SCSI */
settings_show_window(hdlg, IDT_1771, TRUE);
settings_show_window(hdlg, IDC_COMBO_MO_ID, TRUE);
settings_show_window(hdlg, IDT_1771, TRUE);
settings_show_window(hdlg, IDC_COMBO_MO_ID, TRUE);
if (assign_id)
next_free_scsi_id((uint8_t *) &temp_mo_drives[lv1_current_sel].scsi_device_id);
@@ -4022,8 +4052,8 @@ zip_recalc_location_controls(HWND hdlg, int assign_id)
switch(bus) {
case ZIP_BUS_ATAPI: /* ATAPI */
settings_show_window(hdlg, IDT_1755, TRUE);
settings_show_window(hdlg, IDC_COMBO_ZIP_CHANNEL_IDE, TRUE);
settings_show_window(hdlg, IDT_1755, TRUE);
settings_show_window(hdlg, IDC_COMBO_ZIP_CHANNEL_IDE, TRUE);
if (assign_id)
temp_zip_drives[lv2_current_sel].ide_channel = next_free_ide_channel();
@@ -4031,8 +4061,8 @@ zip_recalc_location_controls(HWND hdlg, int assign_id)
settings_set_cur_sel(hdlg, IDC_COMBO_ZIP_CHANNEL_IDE, temp_zip_drives[lv2_current_sel].ide_channel);
break;
case ZIP_BUS_SCSI: /* SCSI */
settings_show_window(hdlg, IDT_1754, TRUE);
settings_show_window(hdlg, IDC_COMBO_ZIP_ID, TRUE);
settings_show_window(hdlg, IDT_1754, TRUE);
settings_show_window(hdlg, IDC_COMBO_ZIP_ID, TRUE);
if (assign_id)
next_free_scsi_id((uint8_t *) &temp_zip_drives[lv2_current_sel].scsi_device_id);