Added ability to disable floppy image BPB checking per drive, enabled by default.

This commit is contained in:
OBattler
2017-07-27 17:14:52 +02:00
parent c211c53d32
commit 306ae2fd32
7 changed files with 106 additions and 16 deletions

View File

@@ -461,8 +461,10 @@ BEGIN
COMBOBOX IDC_COMBO_FD_TYPE,33,85,90,12,CBS_DROPDOWNLIST | COMBOBOX IDC_COMBO_FD_TYPE,33,85,90,12,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP WS_VSCROLL | WS_TABSTOP
LTEXT "Type:",IDT_1738,7,86,24,8 LTEXT "Type:",IDT_1738,7,86,24,8
CONTROL "Turbo timings (no accuracy)",IDC_CHECKTURBO,"Button", CONTROL "Turbo timings",IDC_CHECKTURBO,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,131,86,129,10 BS_AUTOCHECKBOX | WS_TABSTOP,131,86,64,10
CONTROL "Check BPB",IDC_CHECKBPB,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,196,86,64,10
CONTROL "List1",IDC_LIST_CDROM_DRIVES,"SysListView32",LVS_REPORT | CONTROL "List1",IDC_LIST_CDROM_DRIVES,"SysListView32",LVS_REPORT |
LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER |
WS_TABSTOP,7,116,253,60 WS_TABSTOP,7,116,253,60
@@ -838,6 +840,7 @@ BEGIN
IDS_2167 "&Reload previous image" IDS_2167 "&Reload previous image"
IDS_2168 "&Image..." IDS_2168 "&Image..."
IDS_2169 "Image (&Write-protected)..." IDS_2169 "Image (&Write-protected)..."
IDS_2170 "Check BPB"
IDS_3072 "None" IDS_3072 "None"
IDS_3073 "[Bus] Bus mouse" IDS_3073 "[Bus] Bus mouse"

View File

@@ -163,17 +163,18 @@
#define IDC_LIST_FLOPPY_DRIVES 1151 #define IDC_LIST_FLOPPY_DRIVES 1151
#define IDC_COMBO_FD_TYPE 1152 #define IDC_COMBO_FD_TYPE 1152
#define IDC_CHECKTURBO 1153 #define IDC_CHECKTURBO 1153
#define IDC_BUTTON_FDD_ADD 1154 // status bar menu #define IDC_CHECKBPB 1154
#define IDC_BUTTON_FDD_EDIT 1155 // status bar menu #define IDC_BUTTON_FDD_ADD 1155 // status bar menu
#define IDC_BUTTON_FDD_REMOVE 1156 // status bar menu #define IDC_BUTTON_FDD_EDIT 1156 // status bar menu
#define IDC_LIST_CDROM_DRIVES 1157 #define IDC_BUTTON_FDD_REMOVE 1157 // status bar menu
#define IDC_COMBO_CD_BUS 1158 #define IDC_LIST_CDROM_DRIVES 1158
#define IDC_COMBO_CD_ID 1159 #define IDC_COMBO_CD_BUS 1159
#define IDC_COMBO_CD_LUN 1160 #define IDC_COMBO_CD_ID 1160
#define IDC_COMBO_CD_CHANNEL_IDE 1161 #define IDC_COMBO_CD_LUN 1161
#define IDC_BUTTON_CDROM_ADD 1162 // status bar menu #define IDC_COMBO_CD_CHANNEL_IDE 1162
#define IDC_BUTTON_CDROM_EDIT 1163 // status bar menu #define IDC_BUTTON_CDROM_ADD 1163 // status bar menu
#define IDC_BUTTON_CDROM_REMOVE 1164 // status bar menu #define IDC_BUTTON_CDROM_EDIT 1164 // status bar menu
#define IDC_BUTTON_CDROM_REMOVE 1165 // status bar menu
/* For the DeviceConfig code, re-do later. */ /* For the DeviceConfig code, re-do later. */
@@ -319,6 +320,7 @@
#define IDS_2167 2167 // "RLL" #define IDS_2167 2167 // "RLL"
#define IDS_2168 2168 // "IDE (PIO-only)" #define IDS_2168 2168 // "IDE (PIO-only)"
#define IDS_2169 2169 // "%01i:%01i" #define IDS_2169 2169 // "%01i:%01i"
#define IDS_2170 2170 // "%01i:%01i"
#define IDS_3072 3072 #define IDS_3072 3072
#define IDS_3073 3073 #define IDS_3073 3073
@@ -391,7 +393,7 @@
#define IDS_LANG_ENUS IDS_6144 #define IDS_LANG_ENUS IDS_6144
#define STRINGS_NUM_2048 122 #define STRINGS_NUM_2048 123
#define STRINGS_NUM_3072 11 #define STRINGS_NUM_3072 11
#define STRINGS_NUM_4096 20 #define STRINGS_NUM_4096 20
#define STRINGS_NUM_4352 7 #define STRINGS_NUM_4352 7

View File

@@ -78,6 +78,7 @@ static hard_disk_t temp_hdc[HDC_NUM];
/* Removable devices category */ /* Removable devices category */
static int temp_fdd_types[FDD_NUM]; static int temp_fdd_types[FDD_NUM];
static int temp_fdd_turbo[FDD_NUM]; static int temp_fdd_turbo[FDD_NUM];
static int temp_fdd_check_bpb[FDD_NUM];
static cdrom_drive_t temp_cdrom_drives[CDROM_NUM]; static cdrom_drive_t temp_cdrom_drives[CDROM_NUM];
static HWND hwndParentDialog, hwndChildDialog; static HWND hwndParentDialog, hwndChildDialog;
@@ -158,6 +159,7 @@ static void win_settings_init(void)
{ {
temp_fdd_types[i] = fdd_get_type(i); temp_fdd_types[i] = fdd_get_type(i);
temp_fdd_turbo[i] = fdd_get_turbo(i); temp_fdd_turbo[i] = fdd_get_turbo(i);
temp_fdd_check_bpb[i] = fdd_get_check_bpb(i);
} }
memcpy(temp_cdrom_drives, cdrom_drives, CDROM_NUM * sizeof(cdrom_drive_t)); memcpy(temp_cdrom_drives, cdrom_drives, CDROM_NUM * sizeof(cdrom_drive_t));
} }
@@ -224,6 +226,7 @@ static int win_settings_changed(void)
{ {
i = i || (temp_fdd_types[j] != fdd_get_type(j)); i = i || (temp_fdd_types[j] != fdd_get_type(j));
i = i || (temp_fdd_turbo[j] != fdd_get_turbo(j)); i = i || (temp_fdd_turbo[j] != fdd_get_turbo(j));
i = i || (temp_fdd_check_bpb[j] != fdd_get_check_bpb(j));
} }
i = i || memcmp(cdrom_drives, temp_cdrom_drives, CDROM_NUM * sizeof(cdrom_drive_t)); i = i || memcmp(cdrom_drives, temp_cdrom_drives, CDROM_NUM * sizeof(cdrom_drive_t));
@@ -327,6 +330,7 @@ static void win_settings_save(void)
{ {
fdd_set_type(i, temp_fdd_types[i]); fdd_set_type(i, temp_fdd_types[i]);
fdd_set_turbo(i, temp_fdd_turbo[i]); fdd_set_turbo(i, temp_fdd_turbo[i]);
fdd_set_check_bpb(i, temp_fdd_check_bpb[i]);
} }
memcpy(cdrom_drives, temp_cdrom_drives, CDROM_NUM * sizeof(cdrom_drive_t)); memcpy(cdrom_drives, temp_cdrom_drives, CDROM_NUM * sizeof(cdrom_drive_t));
@@ -3531,6 +3535,16 @@ static BOOL win_settings_floppy_drives_recalc_list(HWND hwndList)
{ {
return FALSE; return FALSE;
} }
lvI.iSubItem = 2;
lvI.pszText = win_language_get_string_from_id(temp_fdd_check_bpb[i] ? IDS_2060 : IDS_2061);
lvI.iItem = i;
lvI.iImage = 0;
if (ListView_SetItem(hwndList, &lvI) == -1)
{
return FALSE;
}
} }
return TRUE; return TRUE;
@@ -3603,7 +3617,7 @@ static BOOL win_settings_floppy_drives_init_columns(HWND hwndList)
lvc.iSubItem = 1; lvc.iSubItem = 1;
lvc.pszText = win_language_get_string_from_id(IDS_2059); lvc.pszText = win_language_get_string_from_id(IDS_2059);
lvc.cx = 100; lvc.cx = 50;
lvc.fmt = LVCFMT_LEFT; lvc.fmt = LVCFMT_LEFT;
if (ListView_InsertColumn(hwndList, 1, &lvc) == -1) if (ListView_InsertColumn(hwndList, 1, &lvc) == -1)
@@ -3611,6 +3625,16 @@ static BOOL win_settings_floppy_drives_init_columns(HWND hwndList)
return FALSE; return FALSE;
} }
lvc.iSubItem = 2;
lvc.pszText = win_language_get_string_from_id(IDS_2170);
lvc.cx = 75;
lvc.fmt = LVCFMT_LEFT;
if (ListView_InsertColumn(hwndList, 2, &lvc) == -1)
{
return FALSE;
}
return TRUE; return TRUE;
} }
@@ -3710,6 +3734,16 @@ static void win_settings_floppy_drives_update_item(HWND hwndList, int i)
{ {
return; return;
} }
lvI.iSubItem = 2;
lvI.pszText = win_language_get_string_from_id(temp_fdd_check_bpb[i] ? IDS_2060 : IDS_2061);
lvI.iItem = i;
lvI.iImage = 0;
if (ListView_SetItem(hwndList, &lvI) == -1)
{
return;
}
} }
static void win_settings_cdrom_drives_update_item(HWND hwndList, int i) static void win_settings_cdrom_drives_update_item(HWND hwndList, int i)
@@ -3897,6 +3931,9 @@ static BOOL CALLBACK win_settings_removable_devices_proc(HWND hdlg, UINT message
h = GetDlgItem(hdlg, IDC_CHECKTURBO); h = GetDlgItem(hdlg, IDC_CHECKTURBO);
SendMessage(h, BM_SETCHECK, temp_fdd_turbo[fdlv_current_sel], 0); SendMessage(h, BM_SETCHECK, temp_fdd_turbo[fdlv_current_sel], 0);
h = GetDlgItem(hdlg, IDC_CHECKBPB);
SendMessage(h, BM_SETCHECK, temp_fdd_check_bpb[fdlv_current_sel], 0);
cdlv_current_sel = 0; cdlv_current_sel = 0;
h = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES); h = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES);
win_settings_cdrom_drives_init_columns(h); win_settings_cdrom_drives_init_columns(h);
@@ -3958,6 +3995,8 @@ static BOOL CALLBACK win_settings_removable_devices_proc(HWND hdlg, UINT message
SendMessage(h, CB_SETCURSEL, temp_fdd_types[fdlv_current_sel], 0); SendMessage(h, CB_SETCURSEL, temp_fdd_types[fdlv_current_sel], 0);
h = GetDlgItem(hdlg, IDC_CHECKTURBO); h = GetDlgItem(hdlg, IDC_CHECKTURBO);
SendMessage(h, BM_SETCHECK, temp_fdd_turbo[fdlv_current_sel], 0); SendMessage(h, BM_SETCHECK, temp_fdd_turbo[fdlv_current_sel], 0);
h = GetDlgItem(hdlg, IDC_CHECKBPB);
SendMessage(h, BM_SETCHECK, temp_fdd_check_bpb[fdlv_current_sel], 0);
rd_ignore_change = 0; rd_ignore_change = 0;
} }
else if ((((LPNMHDR)lParam)->code == LVN_ITEMCHANGED) && (((LPNMHDR)lParam)->idFrom == IDC_LIST_CDROM_DRIVES)) else if ((((LPNMHDR)lParam)->code == LVN_ITEMCHANGED) && (((LPNMHDR)lParam)->idFrom == IDC_LIST_CDROM_DRIVES))
@@ -4035,6 +4074,20 @@ static BOOL CALLBACK win_settings_removable_devices_proc(HWND hdlg, UINT message
rd_ignore_change = 0; rd_ignore_change = 0;
return FALSE; return FALSE;
case IDC_CHECKBPB:
if (rd_ignore_change)
{
return FALSE;
}
rd_ignore_change = 1;
h = GetDlgItem(hdlg, IDC_CHECKBPB);
temp_fdd_check_bpb[fdlv_current_sel] = SendMessage(h, BM_GETCHECK, 0, 0);
h = GetDlgItem(hdlg, IDC_LIST_FLOPPY_DRIVES);
win_settings_floppy_drives_update_item(h, fdlv_current_sel);
rd_ignore_change = 0;
return FALSE;
case IDC_COMBO_CD_BUS: case IDC_COMBO_CD_BUS:
if (rd_ignore_change) if (rd_ignore_change)
{ {

View File

@@ -1547,6 +1547,8 @@ static void loadconfig_removable_devices(void)
ui_writeprot[c] = !!config_get_int(cat, temps, 0); ui_writeprot[c] = !!config_get_int(cat, temps, 0);
sprintf(temps, "fdd_%02i_turbo", c + 1); sprintf(temps, "fdd_%02i_turbo", c + 1);
fdd_set_turbo(c, !!config_get_int(cat, temps, 0)); fdd_set_turbo(c, !!config_get_int(cat, temps, 0));
sprintf(temps, "fdd_%02i_check_bpb", c + 1);
fdd_set_check_bpb(c, !!config_get_int(cat, temps, 1));
/* Check, whether each value is default, if yes, delete it so that only non-default values will later be saved. */ /* Check, whether each value is default, if yes, delete it so that only non-default values will later be saved. */
if (fdd_get_type(c) == ((c < 2) ? 2 : 0)) if (fdd_get_type(c) == ((c < 2) ? 2 : 0))
@@ -1572,6 +1574,12 @@ static void loadconfig_removable_devices(void)
sprintf(temps, "fdd_%02i_turbo", c + 1); sprintf(temps, "fdd_%02i_turbo", c + 1);
config_delete_var(cat, temps); config_delete_var(cat, temps);
} }
if (fdd_get_check_bpb(c) == 1)
{
sprintf(temps, "fdd_%02i_check_bpb", c + 1);
config_delete_var(cat, temps);
}
} }
memset(temps, 0, 512); memset(temps, 0, 512);
@@ -2455,6 +2463,16 @@ static void saveconfig_removable_devices(void)
{ {
config_set_int(cat, temps, fdd_get_turbo(c)); config_set_int(cat, temps, fdd_get_turbo(c));
} }
sprintf(temps, "fdd_%02i_check_bpb", c + 1);
if (fdd_get_check_bpb(c) == 1)
{
config_delete_var(cat, temps);
}
else
{
config_set_int(cat, temps, fdd_get_check_bpb(c));
}
} }
memset(temps, '\0', sizeof(temps)); memset(temps, '\0', sizeof(temps));

View File

@@ -710,7 +710,7 @@ jump_if_fdf:
pclog("BPB reports %i sides and %i bytes per sector (%i sectors total)\n", bpb_sides, bpb_bps, bpb_total); pclog("BPB reports %i sides and %i bytes per sector (%i sectors total)\n", bpb_sides, bpb_bps, bpb_total);
if (((bpb_sides < 1) || (bpb_sides > 2) || !bps_is_valid(bpb_bps) || !first_byte_is_valid(first_byte)) && !fdi && !cqm) if ((((bpb_sides < 1) || (bpb_sides > 2) || !bps_is_valid(bpb_bps) || !first_byte_is_valid(first_byte)) && !fdi && !cqm) || !fdd_get_check_bpb(drive))
{ {
/* The BPB is giving us a wacky number of sides and/or bytes per sector, therefore it is most probably /* The BPB is giving us a wacky number of sides and/or bytes per sector, therefore it is most probably
not a BPB at all, so we have to guess the parameters from file size. */ not a BPB at all, so we have to guess the parameters from file size. */

View File

@@ -32,6 +32,8 @@ static struct
int head; int head;
int turbo; int turbo;
int check_bpb;
} fdd[FDD_NUM]; } fdd[FDD_NUM];
/* Flags: /* Flags:
@@ -329,6 +331,16 @@ int fdd_get_turbo(int drive)
return fdd[drive].turbo; return fdd[drive].turbo;
} }
void fdd_set_check_bpb(int drive, int check_bpb)
{
fdd[drive].check_bpb = check_bpb;
}
int fdd_get_check_bpb(int drive)
{
return fdd[drive].check_bpb;
}
int fdd_get_densel(int drive) int fdd_get_densel(int drive)
{ {
if (drive_types[fdd[drive].type].flags & FLAG_INVERT_DENSEL) if (drive_types[fdd[drive].type].flags & FLAG_INVERT_DENSEL)

View File

@@ -32,6 +32,8 @@ void fdd_set_head(int drive, int head);
int fdd_get_head(int drive); int fdd_get_head(int drive);
void fdd_set_turbo(int drive, int turbo); void fdd_set_turbo(int drive, int turbo);
int fdd_get_turbo(int drive); int fdd_get_turbo(int drive);
void fdd_set_check_bpb(int drive, int check_bpb);
int fdd_get_check_bpb(int drive);
void fdd_set_type(int drive, int type); void fdd_set_type(int drive, int type);
int fdd_get_type(int drive); int fdd_get_type(int drive);