From a77c88addf0c03fdb8dbea6287cfeda57f9a2c91 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 16 Jun 2020 16:25:23 +0200 Subject: [PATCH 01/12] Added external Floppy disk controller support. --- src/config.c | 23 ++++ src/floppy/fdc.c | 113 ++++++++++++++++ src/floppy/fdc_pii15xb.c | 221 ++++++++++++++++++++++++++++++++ src/include/86box/config.h | 3 +- src/include/86box/fdc.h | 14 ++ src/include/86box/fdc_pii15xb.h | 56 ++++++++ src/include/86box/machine.h | 4 + src/include/86box/resource.h | 3 + src/win/86Box.rc | 7 +- src/win/win_settings.c | 94 +++++++++++++- 10 files changed, 535 insertions(+), 3 deletions(-) create mode 100644 src/floppy/fdc_pii15xb.c create mode 100644 src/include/86box/fdc_pii15xb.h diff --git a/src/config.c b/src/config.c index 65d0cd2e4..1beb305c7 100644 --- a/src/config.c +++ b/src/config.c @@ -783,6 +783,26 @@ load_other_peripherals(void) else scsi_card_current = 0; + if (machines[machine].flags & MACHINE_FDC_FIXED) { + config_delete_var(cat, "fdc"); + fdc_type = FDC_INTERNAL; + } else { + p = config_get_string(cat, "fdc", NULL); + if (p == NULL) { + if (machines[machine].flags & MACHINE_FDC) { + p = (char *)malloc((strlen("internal")+1)*sizeof(char)); + strcpy(p, "internal"); + } else { + p = (char *)malloc((strlen("none")+1)*sizeof(char)); + strcpy(p, "none"); + } + free_p = 1; + } + fdc_type = fdc_ext_get_from_internal_name(p); + if (free_p) + free(p); + } + p = config_get_string(cat, "hdc", NULL); if (p == NULL) { if (machines[machine].flags & MACHINE_HDC) { @@ -1744,6 +1764,9 @@ save_other_peripherals(void) config_set_string(cat, "scsicard", scsi_card_get_internal_name(scsi_card_current)); + config_set_string(cat, "fdc", + fdc_ext_get_internal_name(fdc_type)); + config_set_string(cat, "hdc", hdc_get_internal_name(hdc_current)); diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 66e665f76..5301804ba 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -35,6 +35,7 @@ #include <86box/ui.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_pii15xb.h> extern uint64_t motoron[FDD_NUM]; @@ -89,6 +90,9 @@ int lastbyte=0; int floppymodified[4]; int floppyrate[4]; + +int fdc_type; + #ifdef ENABLE_FDC_LOG int fdc_do_log = ENABLE_FDC_LOG; @@ -110,6 +114,105 @@ fdc_log(const char *fmt, ...) #endif +typedef struct { + const char *internal_name; + const device_t *device; +} fdc_ext_t; + + +static const device_t fdc_none_device = { + "None", + 0, FDC_NONE, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL +}; +static const device_t fdc_internal_device = { + "Internal Floppy Drive Controller", + 0, FDC_INTERNAL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL +}; + + +static fdc_ext_t fdc_devices[] = { + { "none", &fdc_none_device }, + { "internal", &fdc_internal_device }, + { "dtk_pii151b", &fdc_pii151b_device }, + { "dtk_pii158b", &fdc_pii158b_device }, + { NULL, NULL } +}; + +char * +fdc_ext_get_name(int fdc_ext) +{ + return((char *)fdc_devices[fdc_ext].device->name); +} + + +char * +fdc_ext_get_internal_name(int fdc_ext) +{ + return((char *)fdc_devices[fdc_ext].internal_name); +} + +int +fdc_ext_get_id(char *s) +{ + int c = 0; + + while (strlen((char *) fdc_devices[c].name)) + { + if (!strcmp((char *) fdc_devices[c].name, s)) + return c; + c++; + } + + return 0; +} + +int +fdc_ext_get_from_internal_name(char *s) +{ + int c = 0; + + while (fdc_devices[c].internal_name != NULL) { + if (! strcmp((char *)fdc_devices[c].internal_name, s)) + return(c); + c++; + } + + return(0); +} + +const device_t * +fdc_ext_get_device(int fdc_ext) +{ + return(fdc_devices[fdc_ext].device); +} + + +int +fdc_ext_has_config(int fdc_ext) +{ + const device_t *dev = fdc_ext_get_device(fdc_ext); + + if (dev == NULL) return(0); + + if (dev->config == NULL) return(0); + + return(1); +} + +int +fdc_ext_available(int fdc_ext) +{ + return(device_available(fdc_devices[fdc_ext].device)); +} + + + uint8_t fdc_get_current_drive(void) { @@ -2271,3 +2374,13 @@ const device_t fdc_at_nsc_device = { fdc_reset, NULL, NULL, NULL }; + +const device_t fdc_dp8473_device = { + "NS DP8473 Floppy Drive Controller", + 0, + FDC_FLAG_NSDP, + fdc_init, + fdc_close, + fdc_reset, + NULL, NULL, NULL +}; diff --git a/src/floppy/fdc_pii15xb.c b/src/floppy/fdc_pii15xb.c new file mode 100644 index 000000000..2f3c4c1f3 --- /dev/null +++ b/src/floppy/fdc_pii15xb.c @@ -0,0 +1,221 @@ +/* + * VARCem Virtual ARchaeological Computer EMulator. + * An emulator of (mostly) x86-based PC systems and devices, + * using the ISA,EISA,VLB,MCA and PCI system buses, roughly + * spanning the era between 1981 and 1995. + * + * This file is part of the VARCem Project. + * + * Implementation of the DTK PII-151B and PII-158B cards. + * + * These are DP8473-based floppy controller ISA cards for XT + * class systems, and allow usage of standard and high-density + * drives on them. They have their own BIOS which takes over + * from the standard system BIOS. + * + * Author: Fred N. van Kempen, + * + * Copyright 2019 Fred N. van Kempen. + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the entire + * above notice, this list of conditions and the following + * disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names + * of its contributors may be used to endorse or promote + * products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#define HAVE_STDARG_H +#include <86box/86box.h> +#include <86box/device.h> +#include <86box/io.h> +#include <86box/mem.h> +#include <86box/pic.h> +#include <86box/rom.h> +#include <86box/machine.h> +#include <86box/timer.h> +#include <86box/plat.h> +#include <86box/ui.h> +#include <86box/fdc.h> +#include <86box/fdd.h> +#include <86box/fdc_pii15xb.h> + +#define ROM_PII_151B L"floppy/dtk/pii-151b.rom" +#define ROM_PII_158B L"floppy/dtk/pii-158b.rom" + +typedef struct { + const char *name; + int type; + + uint32_t bios_addr, + bios_size; + rom_t bios_rom; + + fdc_t *fdc; +} pii_t; + + +/* Load and enable a BIOS ROM if we have one, and is enabled. */ +static void +set_bios(pii_t *dev, const wchar_t *fn) +{ + uint32_t temp; + FILE *fp; + + /* Only do this if needed. */ + if ((fn == NULL) || (dev->bios_addr == 0)) return; + + if ((fp = rom_fopen(fn, L"rb")) == NULL) return; + + (void)fseek(fp, 0L, SEEK_END); + temp = ftell(fp); + (void)fclose(fp); + + /* Assume 128K, then go down. */ + dev->bios_size = 0x020000; + while (temp < dev->bios_size) + dev->bios_size >>= 1; + + /* Create a memory mapping for the space. */ + rom_init(&dev->bios_rom, fn, dev->bios_addr, + dev->bios_size, dev->bios_size-1, 0, MEM_MAPPING_EXTERNAL); +} + + +static void +pii_close(void *priv) +{ + pii_t *dev = (pii_t *)priv; + + free(dev); +} + + +static void * +pii_init(const device_t *info) +{ + pii_t *dev; + + dev = (pii_t *)mem_alloc(sizeof(pii_t)); + memset(dev, 0x00, sizeof(pii_t)); + dev->type = info->local; + + dev->bios_addr = device_get_config_hex20("bios_addr"); + + if (dev->bios_addr != 0x000000) { + switch (dev->type) + case 151: + set_bios(dev, ROM_PII_151B); + break; + case 158: + set_bios(dev, ROM_PII_158B); + break; + } + + /* Attach the DP8473 chip. */ + dev->fdc = device_add(&fdc_dp8473_device); + + //pclog("FDC: %s (I/O=%04X, flags=%08x)\n", + // info->name, dev->fdc->base_address, dev->fdc->flags); + + return(dev); +} + +static int pii_151b_available(void) +{ + return rom_present(ROM_PII_151B); +} + +static int pii_158_available(void) +{ + return rom_present(ROM_PII_158B); +} + +static const device_config_t pii_config[] = { + { + "bios_addr", "BIOS address", CONFIG_HEX20, "", 0x0ce000, + { + { + "Disabled", 0 + }, + { + "CA00H", 0x0ca000 + }, + { + "CC00H", 0x0cc000 + }, + { + "CE00H", 0x0ce000 + }, + { + "" + } + } + }, + { + "speed", "Drive Speed", CONFIG_SELECTION, "", 0, + { + { + "Single", 0 + }, + { + "Dual", 1 + }, + { + "" + } + } + }, + { + "", "", -1 + } +}; + +const device_t fdc_pii151b_device = { + "DTK PII-151B (MiniMicro) Floppy Drive Controller", + DEVICE_ISA, + 151, + pii_init, pii_close, NULL, + pii_151b_available, NULL, NULL, + pii_config +}; + +const device_t fdc_pii158b_device = { + "DTK PII-158B (MiniMicro4) Floppy Drive Controller", + DEVICE_ISA, + 158, + pii_init, pii_close, NULL, + pii_158_available, NULL, NULL, + pii_config +}; diff --git a/src/include/86box/config.h b/src/include/86box/config.h index 969bc2489..1a82a0879 100644 --- a/src/include/86box/config.h +++ b/src/include/86box/config.h @@ -117,7 +117,8 @@ typedef struct { parallel_enabled[3]; /* LPT1, LPT2, LPT3 enabled */ /* Other peripherals category */ - int hdc, /* Hard disk controller */ + int fdc_type, /* Floppy disk controller type */ + hdc, /* Hard disk controller */ scsi_card, /* SCSI controller */ ide_ter_enabled, /* Tertiary IDE controller enabled */ ide_qua_enabled, /* Quaternary IDE controller enabled */ diff --git a/src/include/86box/fdc.h b/src/include/86box/fdc.h index cae83896a..726f7cedb 100644 --- a/src/include/86box/fdc.h +++ b/src/include/86box/fdc.h @@ -22,6 +22,11 @@ #ifndef EMU_FDC_H # define EMU_FDC_H +extern int fdc_type; + +/* Controller types. */ +#define FDC_NONE 0 +#define FDC_INTERNAL 1 #define FDC_FLAG_PCJR 0x01 /* PCjr */ #define FDC_FLAG_DISKCHG_ACTLOW 0x02 /* Amstrad, PS/1, PS/2 ISA */ @@ -33,6 +38,7 @@ #define FDC_FLAG_NSC 0x80 /* PC87306, PC87309 */ #define FDC_FLAG_TOSHIBA 0x100 /* T1000, T1200 */ #define FDC_FLAG_AMSTRAD 0x200 /* Non-AT Amstrad machines */ +#define FDC_FLAG_NSDP 0x400 /* DP8473N, DP8473V */ typedef struct { @@ -178,7 +184,15 @@ extern const device_t fdc_at_ps1_device; extern const device_t fdc_at_smc_device; extern const device_t fdc_at_winbond_device; extern const device_t fdc_at_nsc_device; +extern const device_t fdc_dp8473_device; #endif +extern char *fdc_ext_get_name(int fdc_ext); +extern char *fdc_ext_get_internal_name(int fdc_ext); +extern int fdc_ext_get_id(char *s); +extern int fdc_ext_get_from_internal_name(char *s); +extern const device_t *fdc_ext_get_device(int fdc_ext); +extern int fdc_ext_has_config(int fdc_ext); +extern int fdc_ext_available(int fdc_ext); #endif /*EMU_FDC_H*/ diff --git a/src/include/86box/fdc_pii15xb.h b/src/include/86box/fdc_pii15xb.h new file mode 100644 index 000000000..157004474 --- /dev/null +++ b/src/include/86box/fdc_pii15xb.h @@ -0,0 +1,56 @@ +/* + * VARCem Virtual ARchaeological Computer EMulator. + * An emulator of (mostly) x86-based PC systems and devices, + * using the ISA,EISA,VLB,MCA and PCI system buses, roughly + * spanning the era between 1981 and 1995. + * + * This file is part of the VARCem Project. + * + * Implementation of the DTK PII-151B and PII-158B cards. + * + * These are DP8473-based floppy controller ISA cards for XT + * class systems, and allow usage of standard and high-density + * drives on them. They have their own BIOS which takes over + * from the standard system BIOS. + * + * Author: Fred N. van Kempen, + * + * Copyright 2019 Fred N. van Kempen. + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the entire + * above notice, this list of conditions and the following + * disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names + * of its contributors may be used to endorse or promote + * products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef FLOPPY_PII15XB_H +# define FLOPPY_PII15XB_H + +extern const device_t fdc_pii151b_device; +extern const device_t fdc_pii158b_device; + +#endif /*FLOPPY_PII15XB_H*/ diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 1d91905f9..d8caefefb 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -40,6 +40,8 @@ #define MACHINE_MOUSE 0x008000 /* sys has int mouse */ #define MACHINE_SOUND 0x010000 /* sys has int sound */ #define MACHINE_NONMI 0x020000 /* sys does not have NMI's */ +#define MACHINE_FDC 0x040000 /* sys has int FDC */ +#define MACHINE_FDC_FIXED 0x080000 /* sys has ONLY int FDC */ #else #define MACHINE_PC 0x000000 /* PC architecture */ #define MACHINE_AT 0x000001 /* PC/AT architecture */ @@ -57,6 +59,8 @@ #define MACHINE_MOUSE 0x008000 /* sys has int mouse */ #define MACHINE_SOUND 0x010000 /* sys has int sound */ #define MACHINE_NONMI 0x020000 /* sys does not have NMI's */ +#define MACHINE_FDC 0x040000 /* sys has int FDC */ +#define MACHINE_FDC_FIXED 0x080000 /* sys has ONLY int FDC */ #endif #define IS_ARCH(m, a) (machines[(m)].flags & (a)) ? 1 : 0; diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index 7c225fe00..56da6b3b2 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -99,6 +99,7 @@ #define IDT_1765 1765 /* Board #3: */ #define IDT_1766 1766 /* Board #4: */ #define IDT_1767 1767 /* ISA RTC: */ +#define IDT_1768 1768 /* Ext FD Controller: */ /* @@ -180,6 +181,8 @@ #define IDC_CHECK_POSTCARD 1130 #define IDC_COMBO_ISARTC 1131 #define IDC_CONFIGURE_ISARTC 1132 +#define IDC_COMBO_FDC_EXT 1133 +#define IDC_CONFIGURE_FDC_EXT 1134 #define IDC_GROUP_ISAMEM 1140 #define IDC_COMBO_ISAMEM_1 1141 #define IDC_COMBO_ISAMEM_2 1142 diff --git a/src/win/86Box.rc b/src/win/86Box.rc index 9370caf34..c2000852a 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -551,7 +551,12 @@ BEGIN LTEXT "#4:",IDT_1766,12,172,21,10 COMBOBOX IDC_COMBO_ISAMEM_4,25,171,190,120, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_4,217,171,38,12 + PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_4,217,171,38,12 + + LTEXT "External FD Controller:",IDT_1768,7,190,48,10 + COMBOBOX IDC_COMBO_FDC_EXT,64,189,155,120,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Configure",IDC_CONFIGURE_FDC_EXT,217,185,38,12 END DLG_CFG_HARD_DISKS DIALOG DISCARDABLE 97, 0, 267, 154 diff --git a/src/win/win_settings.c b/src/win/win_settings.c index cf3304427..b198eef46 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -51,6 +51,7 @@ #include <86box/hdc.h> #include <86box/hdc_ide.h> #include <86box/zip.h> +#include <86box/fdc.h> #include <86box/fdd.h> #include <86box/network.h> #include <86box/sound.h> @@ -95,7 +96,7 @@ static int temp_lpt_devices[3]; static int temp_serial[2], temp_lpt[3]; /* Other peripherals category */ -static int temp_hdc, temp_scsi_card, temp_ide_ter, temp_ide_qua; +static int temp_fdc_ext, temp_hdc, temp_scsi_card, temp_ide_ter, temp_ide_qua; static int temp_bugger; static int temp_postcard; static int temp_isartc; @@ -247,6 +248,7 @@ win_settings_init(void) /* Other peripherals category */ temp_scsi_card = scsi_card_current; + temp_fdc_ext = fdc_type; temp_hdc = hdc_current; temp_ide_ter = ide_ter_enabled; temp_ide_qua = ide_qua_enabled; @@ -356,6 +358,7 @@ win_settings_changed(void) /* Peripherals category */ i = i || (scsi_card_current != temp_scsi_card); + i = i || (fdc_type != temp_fdc_ext); i = i || (hdc_current != temp_hdc); i = i || (temp_ide_ter != ide_ter_enabled); i = i || (temp_ide_qua != ide_qua_enabled); @@ -462,6 +465,7 @@ win_settings_save(void) /* Peripherals category */ scsi_card_current = temp_scsi_card; hdc_current = temp_hdc; + fdc_type = temp_fdc_ext; ide_ter_enabled = temp_ide_ter; ide_qua_enabled = temp_ide_qua; bugger_enabled = temp_bugger; @@ -1584,6 +1588,48 @@ win_settings_ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; } +static void +recalc_fdc_list(HWND hdlg) +{ + HWND h = GetDlgItem(hdlg, IDC_COMBO_FDC_EXT); + int c = 0, d = 0; + int found_card = 0; + WCHAR szText[512]; + + SendMessage(h, CB_RESETCONTENT, 0, 0); + SendMessage(h, CB_SETCURSEL, 0, 0); + + while (1) { + /* Skip "internal" if machine doesn't have it. */ + if ((c == 1) && !(machines[temp_machine].flags & MACHINE_FDC)) { + c++; + continue; + } + + char *s = fdc_ext_get_name(c); + + if (!s[0]) + break; + + if (fdc_ext_available(c) && + device_is_valid(fdc_ext_get_device(c), machines[temp_machine].flags)) { + mbstowcs(szText, s, strlen(s) + 1); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) szText); + if (c == temp_fdc_ext) { + SendMessage(h, CB_SETCURSEL, d, 0); + found_card = 1; + } + + d++; + } + + c++; + } + if (!found_card) + SendMessage(h, CB_SETCURSEL, 0, 0); + EnableWindow(h, (machines[temp_machine].flags & MACHINE_FDC_FIXED) ? FALSE : TRUE); +} + static void recalc_hdc_list(HWND hdlg) @@ -1648,6 +1694,15 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); stransi = (char *) malloc(512); + /*FD (Ext) controller config*/ + recalc_fdc_list(hdlg); + + h = GetDlgItem(hdlg, IDC_CONFIGURE_FDC_EXT); + if (fdc_ext_has_config(temp_fdc_ext)) + EnableWindow(h, TRUE); + else + EnableWindow(h, FALSE); + /*HD controller config*/ recalc_hdc_list(hdlg); @@ -1776,6 +1831,38 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa case WM_COMMAND: switch (LOWORD(wParam)) { + case IDC_CONFIGURE_FDC_EXT: + lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); + stransi = (char *) malloc(512); + + h = GetDlgItem(hdlg, IDC_COMBO_FDC_EXT); + SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp); + wcstombs(stransi, lptsTemp, 512); + temp_deviceconfig |= deviceconfig_open(hdlg, (void *)fdc_ext_get_device(fdc_ext_get_id(stransi))); + + free(stransi); + free(lptsTemp); + break; + + case IDC_COMBO_FDC_EXT: + lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); + stransi = (char *) malloc(512); + + h = GetDlgItem(hdlg, IDC_COMBO_FDC_EXT); + SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp); + wcstombs(stransi, lptsTemp, 512); + temp_fdc_ext = fdc_ext_get_id(stransi); + + h = GetDlgItem(hdlg, IDC_CONFIGURE_FDC_EXT); + if (fdc_ext_has_config(temp_fdc_ext)) + EnableWindow(h, TRUE); + else + EnableWindow(h, FALSE); + + free(stransi); + free(lptsTemp); + break; + case IDC_CONFIGURE_HDC: lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); stransi = (char *) malloc(512); @@ -1898,6 +1985,11 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); stransi = (char *) malloc(512); + h = GetDlgItem(hdlg, IDC_COMBO_FDC_EXT); + SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp); + wcstombs(stransi, lptsTemp, 512); + temp_fdc_ext = fdc_ext_get_id(stransi); + h = GetDlgItem(hdlg, IDC_COMBO_HDC); SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp); wcstombs(stransi, lptsTemp, 512); From c2840cf6cb525c8a9db094539210f83ba77bf69e Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 16 Jun 2020 16:33:36 +0200 Subject: [PATCH 02/12] Fixed the UI for the external FDC. --- src/floppy/fdc.c | 2 +- src/floppy/fdc_pii15xb.c | 2 +- src/include/86box/fdc.h | 12 ------- src/include/86box/fdc_ext.h | 42 +++++++++++++++++++++++++ src/include/86box/fdc_pii15xb.h | 56 --------------------------------- 5 files changed, 44 insertions(+), 70 deletions(-) create mode 100644 src/include/86box/fdc_ext.h delete mode 100644 src/include/86box/fdc_pii15xb.h diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 5301804ba..6882fea70 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -35,7 +35,7 @@ #include <86box/ui.h> #include <86box/fdd.h> #include <86box/fdc.h> -#include <86box/fdc_pii15xb.h> +#include <86box/fdc_ext.h> extern uint64_t motoron[FDD_NUM]; diff --git a/src/floppy/fdc_pii15xb.c b/src/floppy/fdc_pii15xb.c index 2f3c4c1f3..38d7c53d3 100644 --- a/src/floppy/fdc_pii15xb.c +++ b/src/floppy/fdc_pii15xb.c @@ -68,8 +68,8 @@ #include <86box/plat.h> #include <86box/ui.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/fdd.h> -#include <86box/fdc_pii15xb.h> #define ROM_PII_151B L"floppy/dtk/pii-151b.rom" #define ROM_PII_158B L"floppy/dtk/pii-158b.rom" diff --git a/src/include/86box/fdc.h b/src/include/86box/fdc.h index 726f7cedb..56249069b 100644 --- a/src/include/86box/fdc.h +++ b/src/include/86box/fdc.h @@ -24,10 +24,6 @@ extern int fdc_type; -/* Controller types. */ -#define FDC_NONE 0 -#define FDC_INTERNAL 1 - #define FDC_FLAG_PCJR 0x01 /* PCjr */ #define FDC_FLAG_DISKCHG_ACTLOW 0x02 /* Amstrad, PS/1, PS/2 ISA */ #define FDC_FLAG_AT 0x04 /* AT+, PS/x */ @@ -187,12 +183,4 @@ extern const device_t fdc_at_nsc_device; extern const device_t fdc_dp8473_device; #endif -extern char *fdc_ext_get_name(int fdc_ext); -extern char *fdc_ext_get_internal_name(int fdc_ext); -extern int fdc_ext_get_id(char *s); -extern int fdc_ext_get_from_internal_name(char *s); -extern const device_t *fdc_ext_get_device(int fdc_ext); -extern int fdc_ext_has_config(int fdc_ext); -extern int fdc_ext_available(int fdc_ext); - #endif /*EMU_FDC_H*/ diff --git a/src/include/86box/fdc_ext.h b/src/include/86box/fdc_ext.h new file mode 100644 index 000000000..735a06d88 --- /dev/null +++ b/src/include/86box/fdc_ext.h @@ -0,0 +1,42 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Implementation of the NEC uPD-765 and compatible floppy disk + * controller. + * + * + * + * Authors: Sarah Walker, + * Miran Grca, + * Fred N. van Kempen, + * + * Copyright 2008-2020 Sarah Walker. + * Copyright 2016-2020 Miran Grca. + * Copyright 2018-2020 Fred N. van Kempen. + */ +#ifndef EMU_FDC_EXT_H +# define EMU_FDC_EXT_H + +extern int fdc_type; + +/* Controller types. */ +#define FDC_NONE 0 +#define FDC_INTERNAL 1 + +extern const device_t fdc_pii151b_device; +extern const device_t fdc_pii158b_device; + +extern char *fdc_ext_get_name(int fdc_ext); +extern char *fdc_ext_get_internal_name(int fdc_ext); +extern int fdc_ext_get_id(char *s); +extern int fdc_ext_get_from_internal_name(char *s); +extern const device_t *fdc_ext_get_device(int fdc_ext); +extern int fdc_ext_has_config(int fdc_ext); +extern int fdc_ext_available(int fdc_ext); + +#endif /*EMU_FDC_H*/ diff --git a/src/include/86box/fdc_pii15xb.h b/src/include/86box/fdc_pii15xb.h deleted file mode 100644 index 157004474..000000000 --- a/src/include/86box/fdc_pii15xb.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * VARCem Virtual ARchaeological Computer EMulator. - * An emulator of (mostly) x86-based PC systems and devices, - * using the ISA,EISA,VLB,MCA and PCI system buses, roughly - * spanning the era between 1981 and 1995. - * - * This file is part of the VARCem Project. - * - * Implementation of the DTK PII-151B and PII-158B cards. - * - * These are DP8473-based floppy controller ISA cards for XT - * class systems, and allow usage of standard and high-density - * drives on them. They have their own BIOS which takes over - * from the standard system BIOS. - * - * Author: Fred N. van Kempen, - * - * Copyright 2019 Fred N. van Kempen. - * - * Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the - * following conditions are met: - * - * 1. Redistributions of source code must retain the entire - * above notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names - * of its contributors may be used to endorse or promote - * products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef FLOPPY_PII15XB_H -# define FLOPPY_PII15XB_H - -extern const device_t fdc_pii151b_device; -extern const device_t fdc_pii158b_device; - -#endif /*FLOPPY_PII15XB_H*/ From 118192e5982299c7c587899645aad668cdbd713c Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 16 Jun 2020 16:37:48 +0200 Subject: [PATCH 03/12] Fixed the fix. --- src/floppy/fdc.c | 14 +++++++++++++- src/include/86box/fdc_ext.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 6882fea70..5f4ce695a 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -35,7 +35,7 @@ #include <86box/ui.h> #include <86box/fdd.h> #include <86box/fdc.h> -#include <86box/fdc_ext.h> +#include <86box/fdc_pii15xb.h> extern uint64_t motoron[FDD_NUM]; @@ -144,6 +144,18 @@ static fdc_ext_t fdc_devices[] = { { NULL, NULL } }; +/* Reset the HDC, whichever one that is. */ +void +fdc_ext_reset(void) +{ + fdc_log("FDC: reset(current=%d, internal=%d)\n", + fdc_type, (machines[machine].flags & MACHINE_FDC) ? 1 : 0); + + /* If we have a valid controller, add its device. */ + if (fdc_type > 1) + device_add(fdc_devices[fdc_type].device); +} + char * fdc_ext_get_name(int fdc_ext) { diff --git a/src/include/86box/fdc_ext.h b/src/include/86box/fdc_ext.h index 735a06d88..4cb1ec686 100644 --- a/src/include/86box/fdc_ext.h +++ b/src/include/86box/fdc_ext.h @@ -31,6 +31,8 @@ extern int fdc_type; extern const device_t fdc_pii151b_device; extern const device_t fdc_pii158b_device; +extern void fdc_ext_reset(void); + extern char *fdc_ext_get_name(int fdc_ext); extern char *fdc_ext_get_internal_name(int fdc_ext); extern int fdc_ext_get_id(char *s); From aeae97fafc696c04ef7706c30720d3c45f3081e2 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 16 Jun 2020 16:41:35 +0200 Subject: [PATCH 04/12] Fixed the fix 2. --- src/config.c | 1 + src/floppy/fdc.c | 2 +- src/pc.c | 2 ++ src/win/win_settings.c | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index 1beb305c7..5aea7fe5b 100644 --- a/src/config.c +++ b/src/config.c @@ -47,6 +47,7 @@ #include <86box/hdc_ide.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/gameport.h> #include <86box/machine.h> #include <86box/mouse.h> diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 5f4ce695a..fb5e24e62 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -35,7 +35,7 @@ #include <86box/ui.h> #include <86box/fdd.h> #include <86box/fdc.h> -#include <86box/fdc_pii15xb.h> +#include <86box/fdc_ext.h> extern uint64_t motoron[FDD_NUM]; diff --git a/src/pc.c b/src/pc.c index e720cf529..3226cfd9c 100644 --- a/src/pc.c +++ b/src/pc.c @@ -769,6 +769,8 @@ pc_reset_hard_init(void) */ mouse_reset(); + fdc_ext_reset(); + /* Reset the Hard Disk Controller module. */ hdc_reset(); /* Reset and reconfigure the SCSI layer. */ diff --git a/src/win/win_settings.c b/src/win/win_settings.c index b198eef46..7ade9ea24 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -52,6 +52,7 @@ #include <86box/hdc_ide.h> #include <86box/zip.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/fdd.h> #include <86box/network.h> #include <86box/sound.h> From 465789bd5c9e2b260f3a3387c369dc27880820d0 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 16 Jun 2020 16:44:25 +0200 Subject: [PATCH 05/12] Fixed the fix 3 (grr). --- src/floppy/fdc.c | 4 ++-- src/win/Makefile.mingw | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index fb5e24e62..94d588bd6 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -174,9 +174,9 @@ fdc_ext_get_id(char *s) { int c = 0; - while (strlen((char *) fdc_devices[c].name)) + while (strlen((char *) fdc_devices[c].internal_name)) { - if (!strcmp((char *) fdc_devices[c].name, s)) + if (!strcmp((char *) fdc_devices[c].internal_name, s)) return c; c++; } diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 7511ba61c..3d48ac37a 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -598,7 +598,8 @@ SIOOBJ := sio_acc3221.o \ sio_w83877f.o sio_w83977f.o \ sio_um8669f.o -FDDOBJ := fdd.o fdc.o fdi2raw.o \ +FDDOBJ := fdd.o fdc.o fdc_pii15xb.o \ + fdi2raw.o \ fdd_common.o fdd_86f.o \ fdd_fdi.o fdd_imd.o fdd_img.o fdd_json.o \ fdd_mfm.o fdd_td0.o From cfc8af3d05f121c278fd39169c9801bedb0a9c2a Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 16 Jun 2020 16:50:16 +0200 Subject: [PATCH 06/12] Fixed the fix 4. --- src/floppy/fdc_pii15xb.c | 9 +++++---- src/win/win_settings.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/floppy/fdc_pii15xb.c b/src/floppy/fdc_pii15xb.c index 38d7c53d3..b41f2e9e1 100644 --- a/src/floppy/fdc_pii15xb.c +++ b/src/floppy/fdc_pii15xb.c @@ -67,9 +67,9 @@ #include <86box/timer.h> #include <86box/plat.h> #include <86box/ui.h> +#include <86box/fdd.h> #include <86box/fdc.h> #include <86box/fdc_ext.h> -#include <86box/fdd.h> #define ROM_PII_151B L"floppy/dtk/pii-151b.rom" #define ROM_PII_158B L"floppy/dtk/pii-158b.rom" @@ -88,7 +88,7 @@ typedef struct { /* Load and enable a BIOS ROM if we have one, and is enabled. */ static void -set_bios(pii_t *dev, const wchar_t *fn) +set_bios(pii_t *dev, wchar_t *fn) { uint32_t temp; FILE *fp; @@ -127,20 +127,21 @@ pii_init(const device_t *info) { pii_t *dev; - dev = (pii_t *)mem_alloc(sizeof(pii_t)); + dev = (pii_t *)malloc(sizeof(pii_t)); memset(dev, 0x00, sizeof(pii_t)); dev->type = info->local; dev->bios_addr = device_get_config_hex20("bios_addr"); if (dev->bios_addr != 0x000000) { - switch (dev->type) + switch (dev->type) { case 151: set_bios(dev, ROM_PII_151B); break; case 158: set_bios(dev, ROM_PII_158B); break; + } } /* Attach the DP8473 chip. */ diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 7ade9ea24..8f5db211b 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -51,9 +51,9 @@ #include <86box/hdc.h> #include <86box/hdc_ide.h> #include <86box/zip.h> +#include <86box/fdd.h> #include <86box/fdc.h> #include <86box/fdc_ext.h> -#include <86box/fdd.h> #include <86box/network.h> #include <86box/sound.h> #include <86box/midi.h> From c1f1331c04af853b86138b4cd7542f2b0463a8a2 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 16 Jun 2020 16:53:24 +0200 Subject: [PATCH 07/12] Added fdc_ext.h header to pc.c --- src/pc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pc.c b/src/pc.c index 3226cfd9c..cf2747b0f 100644 --- a/src/pc.c +++ b/src/pc.c @@ -59,6 +59,7 @@ #include <86box/gameport.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/hdd.h> #include <86box/hdc.h> #include <86box/hdc_ide.h> From f62fc73862b2f771ba19dc77d14c1c174ee3755e Mon Sep 17 00:00:00 2001 From: TC1995 Date: Wed, 17 Jun 2020 00:32:48 +0200 Subject: [PATCH 08/12] (Re-)added the Deskpro 386, but only in the development/incomplete section of the code definitions. Selected XT and AT clones can use either their built-in FDC controller or an external one (the IBM AT and Compaq AT machines don't support booting from a 1.44M floppy so this makes the external floppy useful). Added the FDC to the Adaptec AHA-154xCF ("2" variant) and defaulted to None to keep compatibility with existing FDC's. --- src/config.c | 29 ++++---- src/cpu/cpu.h | 1 + src/cpu/cpu_table.c | 10 +++ src/floppy/fdc.c | 33 +++------ src/floppy/fdc_pii15xb.c | 24 ++---- src/include/86box/fdc_ext.h | 3 +- src/include/86box/machine.h | 3 +- src/include/86box/scsi_x54x.h | 4 +- src/machine/m_at.c | 4 +- src/machine/m_at_compaq.c | 32 +++++++- src/machine/m_tandy.c | 5 +- src/machine/m_xt.c | 5 +- src/machine/m_xt_compaq.c | 4 +- src/machine/m_xt_zenith.c | 7 +- src/machine/machine_table.c | 3 +- src/scsi/scsi_aha154x.c | 136 +++++++++++++++++++++++++++++++++- src/scsi/scsi_buslogic.c | 2 + src/scsi/scsi_x54x.c | 2 + src/win/86Box.rc | 4 +- src/win/win_settings.c | 1 - 20 files changed, 235 insertions(+), 77 deletions(-) diff --git a/src/config.c b/src/config.c index 5aea7fe5b..bd4ddb40c 100644 --- a/src/config.c +++ b/src/config.c @@ -784,24 +784,21 @@ load_other_peripherals(void) else scsi_card_current = 0; - if (machines[machine].flags & MACHINE_FDC_FIXED) { - config_delete_var(cat, "fdc"); + p = config_get_string(cat, "fdc", NULL); + if (p == NULL) { + p = (char *)malloc((strlen("internal")+1)*sizeof(char)); + strcpy(p, "internal"); + free_p = 1; + } + + if (!strcmp(p, "internal")) fdc_type = FDC_INTERNAL; - } else { - p = config_get_string(cat, "fdc", NULL); - if (p == NULL) { - if (machines[machine].flags & MACHINE_FDC) { - p = (char *)malloc((strlen("internal")+1)*sizeof(char)); - strcpy(p, "internal"); - } else { - p = (char *)malloc((strlen("none")+1)*sizeof(char)); - strcpy(p, "none"); - } - free_p = 1; - } + else fdc_type = fdc_ext_get_from_internal_name(p); - if (free_p) - free(p); + + if (free_p) { + free(p); + p = NULL; } p = config_get_string(cat, "hdc", NULL); diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 567b40fc0..985696b53 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -128,6 +128,7 @@ extern CPU cpus_8086[]; extern CPU cpus_286[]; extern CPU cpus_i386SX[]; extern CPU cpus_i386DX[]; +extern CPU cpus_i386DX_Compaq[]; extern CPU cpus_Am386SX[]; extern CPU cpus_Am386DX[]; extern CPU cpus_486SLC[]; diff --git a/src/cpu/cpu_table.c b/src/cpu/cpu_table.c index 82f99b3ab..d6939f78e 100644 --- a/src/cpu/cpu_table.c +++ b/src/cpu/cpu_table.c @@ -186,6 +186,16 @@ CPU cpus_i386DX[] = { {"", -1, 0, 0, 0, 0, 0, 0, 0,0,0,0, 0} }; +CPU cpus_i386DX_Compaq[] = { + /*i386DX/RapidCAD*/ + {"i386DX/16", CPU_386DX, fpus_80286, 16000000, 1, 0x0308, 0, 0, 0, 3,3,3,3, 2}, + {"i386DX/20", CPU_386DX, fpus_80286, 20000000, 1, 0x0308, 0, 0, 0, 4,4,3,3, 3}, + {"i386DX/25", CPU_386DX, fpus_80286, 25000000, 1, 0x0308, 0, 0, 0, 4,4,3,3, 3}, + {"i386DX/33", CPU_386DX, fpus_80286, 33333333, 1, 0x0308, 0, 0, 0, 6,6,3,3, 4}, + {"i386DX/40", CPU_386DX, fpus_80286, 40000000, 1, 0x0308, 0, 0, 0, 7,7,3,3, 5}, + {"", -1, 0, 0, 0, 0, 0, 0, 0,0,0,0, 0} +}; + CPU cpus_Am386SX[] = { /*Am386SX*/ {"Am386SX/16", CPU_386SX, fpus_80386, 16000000, 1, 0x2308, 0, 0, 0, 3,3,3,3, 2}, diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 94d588bd6..bea1c86f3 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -115,21 +115,15 @@ fdc_log(const char *fmt, ...) typedef struct { + const char *name; const char *internal_name; const device_t *device; } fdc_ext_t; -static const device_t fdc_none_device = { - "None", - 0, FDC_NONE, - NULL, NULL, NULL, - NULL, NULL, NULL, - NULL -}; static const device_t fdc_internal_device = { "Internal Floppy Drive Controller", - 0, FDC_INTERNAL, + 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL @@ -137,29 +131,25 @@ static const device_t fdc_internal_device = { static fdc_ext_t fdc_devices[] = { - { "none", &fdc_none_device }, - { "internal", &fdc_internal_device }, - { "dtk_pii151b", &fdc_pii151b_device }, - { "dtk_pii158b", &fdc_pii158b_device }, - { NULL, NULL } + { "Internal controller", "internal", &fdc_internal_device }, + { "DTK PII-151B", "dtk_pii151b", &fdc_pii151b_device }, + { "DTK PII-158B", "dtk_pii158b", &fdc_pii158b_device }, + { "", NULL, NULL } }; -/* Reset the HDC, whichever one that is. */ +/* Reset the FDC, whichever one that is. */ void fdc_ext_reset(void) { - fdc_log("FDC: reset(current=%d, internal=%d)\n", - fdc_type, (machines[machine].flags & MACHINE_FDC) ? 1 : 0); - /* If we have a valid controller, add its device. */ - if (fdc_type > 1) + if (fdc_type > 0) device_add(fdc_devices[fdc_type].device); } char * fdc_ext_get_name(int fdc_ext) { - return((char *)fdc_devices[fdc_ext].device->name); + return((char *)fdc_devices[fdc_ext].name); } @@ -174,9 +164,9 @@ fdc_ext_get_id(char *s) { int c = 0; - while (strlen((char *) fdc_devices[c].internal_name)) + while (strlen((char *) fdc_devices[c].name)) { - if (!strcmp((char *) fdc_devices[c].internal_name, s)) + if (!strcmp((char *) fdc_devices[c].name, s)) return c; c++; } @@ -2253,7 +2243,6 @@ fdc_init(const device_t *info) memset(fdc, 0, sizeof(fdc_t)); fdc->flags = info->local; - fdc_reset(fdc); fdc->irq = 6; diff --git a/src/floppy/fdc_pii15xb.c b/src/floppy/fdc_pii15xb.c index b41f2e9e1..55dd55460 100644 --- a/src/floppy/fdc_pii15xb.c +++ b/src/floppy/fdc_pii15xb.c @@ -71,8 +71,8 @@ #include <86box/fdc.h> #include <86box/fdc_ext.h> -#define ROM_PII_151B L"floppy/dtk/pii-151b.rom" -#define ROM_PII_158B L"floppy/dtk/pii-158b.rom" +#define ROM_PII_151B L"roms/floppy/dtk/pii-151b.rom" +#define ROM_PII_158B L"roms/floppy/dtk/pii-158b.rom" typedef struct { const char *name; @@ -81,8 +81,8 @@ typedef struct { uint32_t bios_addr, bios_size; rom_t bios_rom; - - fdc_t *fdc; + + fdc_t *fdc; } pii_t; @@ -145,7 +145,7 @@ pii_init(const device_t *info) } /* Attach the DP8473 chip. */ - dev->fdc = device_add(&fdc_dp8473_device); + dev->fdc = device_add(&fdc_at_device); //pclog("FDC: %s (I/O=%04X, flags=%08x)\n", // info->name, dev->fdc->base_address, dev->fdc->flags); @@ -184,20 +184,6 @@ static const device_config_t pii_config[] = { } } }, - { - "speed", "Drive Speed", CONFIG_SELECTION, "", 0, - { - { - "Single", 0 - }, - { - "Dual", 1 - }, - { - "" - } - } - }, { "", "", -1 } diff --git a/src/include/86box/fdc_ext.h b/src/include/86box/fdc_ext.h index 4cb1ec686..d92bba9de 100644 --- a/src/include/86box/fdc_ext.h +++ b/src/include/86box/fdc_ext.h @@ -25,8 +25,7 @@ extern int fdc_type; /* Controller types. */ -#define FDC_NONE 0 -#define FDC_INTERNAL 1 +#define FDC_INTERNAL 0 extern const device_t fdc_pii151b_device; extern const device_t fdc_pii158b_device; diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index d8caefefb..b745f757e 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -41,7 +41,6 @@ #define MACHINE_SOUND 0x010000 /* sys has int sound */ #define MACHINE_NONMI 0x020000 /* sys does not have NMI's */ #define MACHINE_FDC 0x040000 /* sys has int FDC */ -#define MACHINE_FDC_FIXED 0x080000 /* sys has ONLY int FDC */ #else #define MACHINE_PC 0x000000 /* PC architecture */ #define MACHINE_AT 0x000001 /* PC/AT architecture */ @@ -60,7 +59,6 @@ #define MACHINE_SOUND 0x010000 /* sys has int sound */ #define MACHINE_NONMI 0x020000 /* sys does not have NMI's */ #define MACHINE_FDC 0x040000 /* sys has int FDC */ -#define MACHINE_FDC_FIXED 0x080000 /* sys has ONLY int FDC */ #endif #define IS_ARCH(m, a) (machines[(m)].flags & (a)) ? 1 : 0; @@ -282,6 +280,7 @@ extern int machine_at_cmdpc_init(const machine_t *); extern int machine_at_portableii_init(const machine_t *); extern int machine_at_portableiii_init(const machine_t *); extern int machine_at_portableiii386_init(const machine_t *); +extern int machine_at_deskpro386_init(const machine_t *); #ifdef EMU_DEVICE_H extern const device_t *at_cpqiii_get_device(void); #endif diff --git a/src/include/86box/scsi_x54x.h b/src/include/86box/scsi_x54x.h index 175fdfe6c..6c8164902 100644 --- a/src/include/86box/scsi_x54x.h +++ b/src/include/86box/scsi_x54x.h @@ -423,7 +423,7 @@ typedef struct { PendingInterrupt, Lock, target_data_len, pad0; - uint32_t Base, rom_addr, /* address of BIOS ROM */ + uint32_t Base, fdc_address, rom_addr, /* address of BIOS ROM */ CmdParamLeft, Outgoing, transfer_size; @@ -486,6 +486,8 @@ typedef struct { pc_timer_t timer, ResetCB; Req_t Req; + + fdc_t *fdc; } x54x_t; diff --git a/src/machine/m_at.c b/src/machine/m_at.c index 90f4fc40c..7adc98ecd 100644 --- a/src/machine/m_at.c +++ b/src/machine/m_at.c @@ -49,6 +49,7 @@ #include <86box/device.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/nvr.h> #include <86box/gameport.h> #include <86box/keyboard.h> @@ -102,7 +103,8 @@ machine_at_ibm_common_init(const machine_t *model) mem_remap_top(384); - device_add(&fdc_at_device); + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_at_device); } diff --git a/src/machine/m_at_compaq.c b/src/machine/m_at_compaq.c index 7cd3f254e..6601d9399 100644 --- a/src/machine/m_at_compaq.c +++ b/src/machine/m_at_compaq.c @@ -33,6 +33,7 @@ #include <86box/device.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/hdc.h> #include <86box/hdc_ide.h> #include <86box/machine.h> @@ -45,7 +46,8 @@ enum { COMPAQ_PORTABLEII = 0, COMPAQ_PORTABLEIII, - COMPAQ_PORTABLEIII386 + COMPAQ_PORTABLEIII386, + COMPAQ_DESKPRO386 }; #define CGA_RGB 0 @@ -809,9 +811,11 @@ machine_at_compaq_init(const machine_t *model, int type) { machine_at_init(model); - mem_remap_top(384); + if (type != COMPAQ_DESKPRO386) + mem_remap_top(384); - device_add(&fdc_at_device); + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_at_device); mem_mapping_add(&ram_mapping, 0xfa0000, 0x60000, read_ram, read_ramw, read_raml, @@ -833,6 +837,11 @@ machine_at_compaq_init(const machine_t *model, int type) if (gfxcard == VID_INTERNAL) device_add(&compaq_plasma_device); break; + + case COMPAQ_DESKPRO386: + if (hdc_current == 1) + device_add(&ide_isa_device); + break; } } @@ -889,3 +898,20 @@ machine_at_portableiii386_init(const machine_t *model) return ret; } + +int +machine_at_deskpro386_init(const machine_t *model) +{ + int ret; + + ret = bios_load_interleavedr(L"roms/machines/deskpro386/109592-005.U11.bin", + L"roms/machines/deskpro386/109591-005.U13.bin", + 0x000f8000, 65536, 0); + + if (bios_only || !ret) + return ret; + + machine_at_compaq_init(model, COMPAQ_DESKPRO386); + + return ret; +} \ No newline at end of file diff --git a/src/machine/m_tandy.c b/src/machine/m_tandy.c index 3fee77bba..26777dc77 100644 --- a/src/machine/m_tandy.c +++ b/src/machine/m_tandy.c @@ -35,6 +35,7 @@ #include <86box/nvr.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/gameport.h> #include <86box/keyboard.h> #include <86box/sound.h> @@ -1495,7 +1496,8 @@ machine_tandy1k_init(const machine_t *model, int type) device_add(&keyboard_tandy_device); keyboard_set_table(scancode_tandy); - device_add(&fdc_xt_device); + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_xt_device); switch(type) { case TYPE_TANDY: @@ -1524,6 +1526,7 @@ machine_tandy1k_init(const machine_t *model, int type) device_add_ex(&vid_device_sl, dev); device_add(&pssj_device); device_add(&eep_1000sl2_device); + break; } if (joystick_type != JOYSTICK_TYPE_NONE) diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index 0cbf071d1..a34fe5b38 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -10,6 +10,7 @@ #include <86box/device.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/gameport.h> #include <86box/ibm_5161.h> #include <86box/keyboard.h> @@ -24,7 +25,9 @@ machine_xt_common_init(const machine_t *model) pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt); - device_add(&fdc_xt_device); + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_xt_device); + nmi_init(); if (joystick_type != JOYSTICK_TYPE_NONE) device_add(&gameport_device); diff --git a/src/machine/m_xt_compaq.c b/src/machine/m_xt_compaq.c index 575500ffb..1b84a10de 100644 --- a/src/machine/m_xt_compaq.c +++ b/src/machine/m_xt_compaq.c @@ -31,6 +31,7 @@ #include <86box/device.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/gameport.h> #include <86box/keyboard.h> #include <86box/lpt.h> @@ -53,7 +54,8 @@ machine_xt_compaq_init(const machine_t *model) pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt); device_add(&keyboard_xt_compaq_device); - device_add(&fdc_xt_device); + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_xt_device); nmi_init(); if (joystick_type != JOYSTICK_TYPE_NONE) device_add(&gameport_device); diff --git a/src/machine/m_xt_zenith.c b/src/machine/m_xt_zenith.c index 0d527d20b..c0448bd09 100644 --- a/src/machine/m_xt_zenith.c +++ b/src/machine/m_xt_zenith.c @@ -36,6 +36,7 @@ #include <86box/device.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/gameport.h> #include <86box/keyboard.h> #include <86box/lpt.h> @@ -116,8 +117,10 @@ machine_xt_zenith_init(const machine_t *model) return ret; machine_common_init(model); - - device_add(&fdc_xt_device); + + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_xt_device); + lpt1_remove(); /* only one parallel port */ lpt2_remove(); lpt1_init(0x278); diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index f45611935..390a90703 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -88,7 +88,7 @@ const machine_t machines[] = { /* 8088 Machines */ { "[8088] IBM PC (1981)", "ibmpc", MACHINE_TYPE_8088, {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA, 16, 64, 16, 0, machine_pc_init, NULL }, { "[8088] IBM PC (1982)", "ibmpc82", MACHINE_TYPE_8088, {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA, 256, 256, 256, 0, machine_pc82_init, NULL }, - { "[8088] IBM PCjr", "ibmpcjr", MACHINE_TYPE_8088, {{"Intel", cpus_pcjr}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_VIDEO | MACHINE_VIDEO_FIXED, 128, 640, 128, 0, machine_pcjr_init, pcjr_get_device }, + { "[8088] IBM PCjr", "ibmpcjr", MACHINE_TYPE_8088, {{"Intel", cpus_pcjr}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_VIDEO | MACHINE_VIDEO_FIXED, 128, 640, 128, 0, machine_pcjr_init, pcjr_get_device }, { "[8088] IBM XT (1982)", "ibmxt", MACHINE_TYPE_8088, {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA, 64, 256, 64, 0, machine_xt_init, NULL }, { "[8088] IBM XT (1986)", "ibmxt86", MACHINE_TYPE_8088, {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA, 256, 640, 64, 0, machine_xt86_init, NULL }, { "[8088] AMI XT clone", "amixt", MACHINE_TYPE_8088, {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA, 64, 640, 64, 0, machine_xt_amixt_init, NULL }, @@ -178,6 +178,7 @@ const machine_t machines[] = { /* 386DX machines */ { "[ACC 2168] AMI 386DX clone", "acc386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512, 16384, 128, 127, machine_at_acc386_init, NULL }, { "[SiS Rabbit] ASUS 386DX ISA", "asus386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512, 16384, 128, 127, machine_at_asus386_init, NULL }, + { "[ISA] Compaq Deskpro 386", "deskpro386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX_Compaq}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 1, 14, 1, 127, machine_at_deskpro386_init, NULL }, { "[ISA] Compaq Portable III (386)", "portableiii386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT | MACHINE_HDC | MACHINE_VIDEO, 1, 14, 1, 127, machine_at_portableiii386_init, at_cpqiii_get_device }, { "[ISA] Micronics 386 clone", "micronics386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512, 8192, 128, 127, machine_at_micronics386_init, NULL }, { "[C&T 386] ECS 386/32", "ecs386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT, 1, 16, 1, 127, machine_at_ecs386_init, NULL }, diff --git a/src/scsi/scsi_aha154x.c b/src/scsi/scsi_aha154x.c index e8342ad90..8e50864e1 100644 --- a/src/scsi/scsi_aha154x.c +++ b/src/scsi/scsi_aha154x.c @@ -36,6 +36,8 @@ #include <86box/dma.h> #include <86box/pic.h> #include <86box/plat.h> +#include <86box/fdd.h> +#include <86box/fdc.h> #include <86box/scsi.h> #include <86box/scsi_aha154x.h> #include <86box/scsi_x54x.h> @@ -187,6 +189,13 @@ aha154x_eeprom(x54x_t *dev, uint8_t cmd,uint8_t arg,uint8_t len,uint8_t off,uint r = 0; aha_eeprom_save(dev); + + if (dev->type == AHA_154xCF) { + if (dev->fdc_address > 0) { + fdc_remove(dev->fdc); + fdc_set_base(dev->fdc, dev->fdc_address); + } + } } if (cmd == 0x23) { @@ -702,6 +711,8 @@ aha_initnvr(x54x_t *dev) /* Initialize the on-board EEPROM. */ dev->nvr[0] = dev->HostID; /* SCSI ID 7 */ dev->nvr[0] |= (0x10 | 0x20 | 0x40); + if (dev->fdc_address == 0x370) + dev->nvr[0] |= EE0_ALTFLOP; dev->nvr[1] = dev->Irq-9; /* IRQ15 */ dev->nvr[1] |= (dev->DmaChannel<<4); /* DMA6 */ dev->nvr[2] = (EE2_HABIOS | /* BIOS enabled */ @@ -757,6 +768,10 @@ aha_init(const device_t *info) dev->Irq = device_get_config_int("irq"); dev->DmaChannel = device_get_config_int("dma"); dev->rom_addr = device_get_config_hex20("bios_addr"); + if (!(dev->bus & DEVICE_MCA)) + dev->fdc_address = device_get_config_hex16("fdc_addr"); + else + dev->fdc_address = 0; dev->HostID = 7; /* default HA ID */ dev->setup_info_len = sizeof(aha_setup_t); dev->max_id = 7; @@ -834,6 +849,8 @@ aha_init(const device_t *info) dev->ven_get_irq = aha_get_irq; /* function to return IRQ from EEPROM */ dev->ven_get_dma = aha_get_dma; /* function to return DMA channel from EEPROM */ dev->ha_bps = 10000000.0; /* fast SCSI */ + if (dev->fdc_address > 0) + dev->fdc = device_add(&fdc_at_device); break; case AHA_154xCP: @@ -1022,7 +1039,6 @@ static const device_config_t aha_154xb_config[] = { } }; - static const device_config_t aha_154x_config[] = { { "base", "Address", CONFIG_HEX16, "", 0x334, @@ -1122,6 +1138,122 @@ static const device_config_t aha_154x_config[] = { }; +static const device_config_t aha_154xcf_config[] = { + { + "base", "Address", CONFIG_HEX16, "", 0x334, + { + { + "None", 0 + }, + { + "0x330", 0x330 + }, + { + "0x334", 0x334 + }, + { + "0x230", 0x230 + }, + { + "0x234", 0x234 + }, + { + "0x130", 0x130 + }, + { + "0x134", 0x134 + }, + { + "" + } + }, + }, + { + "irq", "IRQ", CONFIG_SELECTION, "", 9, + { + { + "IRQ 9", 9 + }, + { + "IRQ 10", 10 + }, + { + "IRQ 11", 11 + }, + { + "IRQ 12", 12 + }, + { + "IRQ 14", 14 + }, + { + "IRQ 15", 15 + }, + { + "" + } + }, + }, + { + "dma", "DMA channel", CONFIG_SELECTION, "", 6, + { + { + "DMA 5", 5 + }, + { + "DMA 6", 6 + }, + { + "DMA 7", 7 + }, + { + "" + } + }, + }, + { + "bios_addr", "BIOS Address", CONFIG_HEX20, "", 0, + { + { + "Disabled", 0 + }, + { + "C800H", 0xc8000 + }, + { + "D000H", 0xd0000 + }, + { + "D800H", 0xd8000 + }, + { + "" + } + }, + }, + { + "fdc_addr", "FDC address", CONFIG_HEX16, "", 0, + { + { + "None", 0 + }, + { + "0x3f0", 0x3f0 + }, + { + "0x370", 0x370 + }, + { + "" + } + }, + }, + { + "", "", -1 + } +}; + + const device_t aha154xa_device = { "Adaptec AHA-154xA", DEVICE_ISA | DEVICE_AT, @@ -1155,7 +1287,7 @@ const device_t aha154xcf_device = { AHA_154xCF, aha_init, x54x_close, NULL, NULL, NULL, NULL, - aha_154x_config + aha_154xcf_config }; const device_t aha1640_device = { diff --git a/src/scsi/scsi_buslogic.c b/src/scsi/scsi_buslogic.c index 71529ef32..a3e7b6161 100644 --- a/src/scsi/scsi_buslogic.c +++ b/src/scsi/scsi_buslogic.c @@ -37,6 +37,8 @@ #include <86box/device.h> #include <86box/nvr.h> #include <86box/dma.h> +#include <86box/fdd.h> +#include <86box/fdc.h> #include <86box/pic.h> #include <86box/pci.h> #include <86box/plat.h> diff --git a/src/scsi/scsi_x54x.c b/src/scsi/scsi_x54x.c index 0f301abdf..a3e8d2f0d 100644 --- a/src/scsi/scsi_x54x.c +++ b/src/scsi/scsi_x54x.c @@ -38,6 +38,8 @@ #include <86box/mem.h> #include <86box/rom.h> #include <86box/device.h> +#include <86box/fdd.h> +#include <86box/fdc.h> #include <86box/nvr.h> #include <86box/plat.h> #include <86box/scsi.h> diff --git a/src/win/86Box.rc b/src/win/86Box.rc index c2000852a..f8291582d 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -553,10 +553,10 @@ BEGIN CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_4,217,171,38,12 - LTEXT "External FD Controller:",IDT_1768,7,190,48,10 + LTEXT "FDC Controller:",IDT_1768,7,190,48,10 COMBOBOX IDC_COMBO_FDC_EXT,64,189,155,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Configure",IDC_CONFIGURE_FDC_EXT,217,185,38,12 + PUSHBUTTON "Configure",IDC_CONFIGURE_FDC_EXT,217,189,38,12 END DLG_CFG_HARD_DISKS DIALOG DISCARDABLE 97, 0, 267, 154 diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 8f5db211b..fdc148859 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -1628,7 +1628,6 @@ recalc_fdc_list(HWND hdlg) } if (!found_card) SendMessage(h, CB_SETCURSEL, 0, 0); - EnableWindow(h, (machines[temp_machine].flags & MACHINE_FDC_FIXED) ? FALSE : TRUE); } From 90d1ddac52d1e4e94cbf79f9c12339bb184d06c7 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Wed, 17 Jun 2020 00:51:06 +0200 Subject: [PATCH 09/12] Hopefully fixed the UI for the Internal/External FDC hookup. --- src/win/win_settings.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/win/win_settings.c b/src/win/win_settings.c index fdc148859..f33f32c07 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -1601,12 +1601,6 @@ recalc_fdc_list(HWND hdlg) SendMessage(h, CB_SETCURSEL, 0, 0); while (1) { - /* Skip "internal" if machine doesn't have it. */ - if ((c == 1) && !(machines[temp_machine].flags & MACHINE_FDC)) { - c++; - continue; - } - char *s = fdc_ext_get_name(c); if (!s[0]) From b97b9ae2f96de99cb05261770e3a37fc523425cc Mon Sep 17 00:00:00 2001 From: TC1995 Date: Wed, 17 Jun 2020 14:29:24 +0200 Subject: [PATCH 10/12] Merged all the latest and missed 86box commits. Finally fixed the configuration UI of the FDC's. --- src/config.c | 24 ++---- src/floppy/fdc.c | 148 +++++++++++++++-------------------- src/include/86box/fdc_ext.h | 15 ++-- src/include/86box/language.h | 3 +- src/include/86box/resource.h | 4 +- src/machine/m_xt.c | 3 + src/machine/machine_table.c | 9 +-- src/pc.c | 4 +- src/pic.c | 31 ++++++++ src/video/vid_cl54xx.c | 4 +- src/win/86Box.rc | 5 +- src/win/win_settings.c | 134 +++++++++++++------------------ 12 files changed, 183 insertions(+), 201 deletions(-) diff --git a/src/config.c b/src/config.c index bd4ddb40c..e1d0ad6d4 100644 --- a/src/config.c +++ b/src/config.c @@ -785,21 +785,10 @@ load_other_peripherals(void) scsi_card_current = 0; p = config_get_string(cat, "fdc", NULL); - if (p == NULL) { - p = (char *)malloc((strlen("internal")+1)*sizeof(char)); - strcpy(p, "internal"); - free_p = 1; - } - - if (!strcmp(p, "internal")) + if (p != NULL) + fdc_type = fdc_card_get_from_internal_name(p); + else fdc_type = FDC_INTERNAL; - else - fdc_type = fdc_ext_get_from_internal_name(p); - - if (free_p) { - free(p); - p = NULL; - } p = config_get_string(cat, "hdc", NULL); if (p == NULL) { @@ -1762,8 +1751,11 @@ save_other_peripherals(void) config_set_string(cat, "scsicard", scsi_card_get_internal_name(scsi_card_current)); - config_set_string(cat, "fdc", - fdc_ext_get_internal_name(fdc_type)); + if (fdc_type == FDC_INTERNAL) + config_delete_var(cat, "fdc"); + else + config_set_string(cat, "fdc", + fdc_card_get_internal_name(fdc_type)); config_set_string(cat, "hdc", hdc_get_internal_name(hdc_current)); diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index bea1c86f3..189f3d678 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -91,7 +91,7 @@ int floppymodified[4]; int floppyrate[4]; -int fdc_type; +int fdc_type = 0; #ifdef ENABLE_FDC_LOG int fdc_do_log = ENABLE_FDC_LOG; @@ -114,106 +114,84 @@ fdc_log(const char *fmt, ...) #endif -typedef struct { +typedef const struct { const char *name; const char *internal_name; const device_t *device; -} fdc_ext_t; +} fdc_cards_t; - -static const device_t fdc_internal_device = { - "Internal Floppy Drive Controller", - 0, 0, - NULL, NULL, NULL, - NULL, NULL, NULL, - NULL +/* All emulated machines have at least one integrated FDC controller */ +static fdc_cards_t fdc_cards[] = { + { "Internal controller", "internal", NULL, }, + { "DTK PII-151B", "dtk_pii151b", &fdc_pii151b_device, }, + { "DTK PII-158B", "dtk_pii158b", &fdc_pii158b_device, }, + { "", "", NULL, }, }; - -static fdc_ext_t fdc_devices[] = { - { "Internal controller", "internal", &fdc_internal_device }, - { "DTK PII-151B", "dtk_pii151b", &fdc_pii151b_device }, - { "DTK PII-158B", "dtk_pii158b", &fdc_pii158b_device }, - { "", NULL, NULL } -}; - -/* Reset the FDC, whichever one that is. */ -void -fdc_ext_reset(void) -{ - /* If we have a valid controller, add its device. */ - if (fdc_type > 0) - device_add(fdc_devices[fdc_type].device); -} - -char * -fdc_ext_get_name(int fdc_ext) -{ - return((char *)fdc_devices[fdc_ext].name); -} - - -char * -fdc_ext_get_internal_name(int fdc_ext) -{ - return((char *)fdc_devices[fdc_ext].internal_name); -} - int -fdc_ext_get_id(char *s) +fdc_card_available(int card) { - int c = 0; - - while (strlen((char *) fdc_devices[c].name)) - { - if (!strcmp((char *) fdc_devices[c].name, s)) - return c; - c++; - } - - return 0; -} - -int -fdc_ext_get_from_internal_name(char *s) -{ - int c = 0; - - while (fdc_devices[c].internal_name != NULL) { - if (! strcmp((char *)fdc_devices[c].internal_name, s)) - return(c); - c++; - } - - return(0); -} - -const device_t * -fdc_ext_get_device(int fdc_ext) -{ - return(fdc_devices[fdc_ext].device); -} - - -int -fdc_ext_has_config(int fdc_ext) -{ - const device_t *dev = fdc_ext_get_device(fdc_ext); - - if (dev == NULL) return(0); - - if (dev->config == NULL) return(0); + if (fdc_cards[card].device) + return(device_available(fdc_cards[card].device)); return(1); } -int -fdc_ext_available(int fdc_ext) + +char * +fdc_card_getname(int card) { - return(device_available(fdc_devices[fdc_ext].device)); + return((char *) fdc_cards[card].name); } +const device_t * +fdc_card_getdevice(int card) +{ + return(fdc_cards[card].device); +} + + +int +fdc_card_has_config(int card) +{ + if (! fdc_cards[card].device) return(0); + + return(fdc_cards[card].device->config ? 1 : 0); +} + + +char * +fdc_card_get_internal_name(int card) +{ + return((char *) fdc_cards[card].internal_name); +} + + +int +fdc_card_get_from_internal_name(char *s) +{ + int c = 0; + + while (strlen((char *) fdc_cards[c].internal_name)) { + if (!strcmp((char *) fdc_cards[c].internal_name, s)) + return(c); + c++; + } + + return(0); +} + + +void +fdc_card_init(void) +{ + if (!fdc_cards[fdc_type].device) + return; + + device_add(fdc_cards[fdc_type].device); +} + uint8_t fdc_get_current_drive(void) diff --git a/src/include/86box/fdc_ext.h b/src/include/86box/fdc_ext.h index d92bba9de..1e10e4b7a 100644 --- a/src/include/86box/fdc_ext.h +++ b/src/include/86box/fdc_ext.h @@ -30,14 +30,13 @@ extern int fdc_type; extern const device_t fdc_pii151b_device; extern const device_t fdc_pii158b_device; -extern void fdc_ext_reset(void); +extern void fdc_card_init(void); -extern char *fdc_ext_get_name(int fdc_ext); -extern char *fdc_ext_get_internal_name(int fdc_ext); -extern int fdc_ext_get_id(char *s); -extern int fdc_ext_get_from_internal_name(char *s); -extern const device_t *fdc_ext_get_device(int fdc_ext); -extern int fdc_ext_has_config(int fdc_ext); -extern int fdc_ext_available(int fdc_ext); +extern char *fdc_card_getname(int card); +extern char *fdc_card_get_internal_name(int card); +extern int fdc_card_get_from_internal_name(char *s); +extern const device_t *fdc_card_getdevice(int card); +extern int fdc_card_has_config(int card); +extern int fdc_card_available(int card); #endif /*EMU_FDC_H*/ diff --git a/src/include/86box/language.h b/src/include/86box/language.h index b95f692f7..d5a6d9b8f 100644 --- a/src/include/86box/language.h +++ b/src/include/86box/language.h @@ -91,6 +91,7 @@ #define IDS_2115 2115 // "MO %i (%03i): %ls" #define IDS_2116 2116 // "MO images (*.IM?)\0*.IM..." #define IDS_2117 2117 // "Welcome to 86Box!" +#define IDS_2118 2118 // "Internal controller" #define IDS_4096 4096 // "Hard disk (%s)" #define IDS_4097 4097 // "%01i:%01i" @@ -169,7 +170,7 @@ #define IDS_LANG_ENUS IDS_7168 -#define STR_NUM_2048 70 +#define STR_NUM_2048 71 #define STR_NUM_3072 11 #define STR_NUM_4096 18 #define STR_NUM_4352 7 diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index 56da6b3b2..afcb33e5b 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -181,8 +181,8 @@ #define IDC_CHECK_POSTCARD 1130 #define IDC_COMBO_ISARTC 1131 #define IDC_CONFIGURE_ISARTC 1132 -#define IDC_COMBO_FDC_EXT 1133 -#define IDC_CONFIGURE_FDC_EXT 1134 +#define IDC_COMBO_FDC 1133 +#define IDC_CONFIGURE_FDC 1134 #define IDC_GROUP_ISAMEM 1140 #define IDC_COMBO_ISAMEM_1 1141 #define IDC_COMBO_ISAMEM_2 1142 diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index a34fe5b38..2f55040e6 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -267,6 +267,9 @@ machine_xt_hed919_init(const machine_t *model) machine_xt_clone_init(model); + if (mem_size > 640) + mem_remap_top(mem_size - 640); + return ret; } diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 390a90703..ead2aa964 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -88,7 +88,7 @@ const machine_t machines[] = { /* 8088 Machines */ { "[8088] IBM PC (1981)", "ibmpc", MACHINE_TYPE_8088, {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA, 16, 64, 16, 0, machine_pc_init, NULL }, { "[8088] IBM PC (1982)", "ibmpc82", MACHINE_TYPE_8088, {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA, 256, 256, 256, 0, machine_pc82_init, NULL }, - { "[8088] IBM PCjr", "ibmpcjr", MACHINE_TYPE_8088, {{"Intel", cpus_pcjr}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_VIDEO | MACHINE_VIDEO_FIXED, 128, 640, 128, 0, machine_pcjr_init, pcjr_get_device }, + { "[8088] IBM PCjr", "ibmpcjr", MACHINE_TYPE_8088, {{"Intel", cpus_pcjr}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_VIDEO | MACHINE_VIDEO_FIXED, 128, 640, 128, 0, machine_pcjr_init, pcjr_get_device }, { "[8088] IBM XT (1982)", "ibmxt", MACHINE_TYPE_8088, {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA, 64, 256, 64, 0, machine_xt_init, NULL }, { "[8088] IBM XT (1986)", "ibmxt86", MACHINE_TYPE_8088, {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA, 256, 640, 64, 0, machine_xt86_init, NULL }, { "[8088] AMI XT clone", "amixt", MACHINE_TYPE_8088, {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA, 64, 640, 64, 0, machine_xt_amixt_init, NULL }, @@ -176,12 +176,11 @@ const machine_t machines[] = { { "[MCA] IBM PS/2 model 55SX", "ibmps2_m55sx", MACHINE_TYPE_386SX, {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"IBM",cpus_IBM486SLC},{"", NULL}}, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_VIDEO, 1, 8, 1, 63, machine_ps2_model_55sx_init, NULL }, /* 386DX machines */ - { "[ACC 2168] AMI 386DX clone", "acc386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512, 16384, 128, 127, machine_at_acc386_init, NULL }, - { "[SiS Rabbit] ASUS 386DX ISA", "asus386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512, 16384, 128, 127, machine_at_asus386_init, NULL }, - { "[ISA] Compaq Deskpro 386", "deskpro386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX_Compaq}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 1, 14, 1, 127, machine_at_deskpro386_init, NULL }, + { "[ACC 2168] AMI 386DX clone", "acc386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512, 16384, 128, 127, machine_at_acc386_init, NULL }, + { "[SiS Rabbit] ASUS ISA-386C", "asus386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512, 16384, 128, 127, machine_at_asus386_init, NULL }, { "[ISA] Compaq Portable III (386)", "portableiii386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT | MACHINE_HDC | MACHINE_VIDEO, 1, 14, 1, 127, machine_at_portableiii386_init, at_cpqiii_get_device }, { "[ISA] Micronics 386 clone", "micronics386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512, 8192, 128, 127, machine_at_micronics386_init, NULL }, - { "[C&T 386] ECS 386/32", "ecs386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT, 1, 16, 1, 127, machine_at_ecs386_init, NULL }, + { "[C&T 386] ECS 386/32", "ecs386", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_AT, 1, 16, 1, 127, machine_at_ecs386_init, NULL }, /* 386DX machines which utilize the VLB bus */ { "[OPTi 495] Award 386DX clone", "award386dx", MACHINE_TYPE_386DX, {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 32, 1, 127, machine_at_opti495_init, NULL }, diff --git a/src/pc.c b/src/pc.c index cf2747b0f..6b1d57ce0 100644 --- a/src/pc.c +++ b/src/pc.c @@ -748,6 +748,8 @@ pc_reset_hard_init(void) /* Reset any ISA RTC cards. */ isartc_reset(); + + fdc_card_init(); fdd_reset(); @@ -770,8 +772,6 @@ pc_reset_hard_init(void) */ mouse_reset(); - fdc_ext_reset(); - /* Reset the Hard Disk Controller module. */ hdc_reset(); /* Reset and reconfigure the SCSI layer. */ diff --git a/src/pic.c b/src/pic.c index b740406ed..a42d6fa28 100644 --- a/src/pic.c +++ b/src/pic.c @@ -240,11 +240,37 @@ pic_write(uint16_t addr, uint8_t val, void *priv) pic.ocw3 = val; if (val & 2) pic.read=(val & 1); + pic.read |= (val & 5); } } } +static int +pic_highest_req(PIC* target_pic, int pic2) +{ + uint8_t pending = target_pic->pend & ~target_pic->mask; + int i, highest = 0; + int min = 0, max = 8; + + if (AT && pic2) { + min = 8; + max = 16; + } + + for (i = min; i < max; i++) { + if ((!AT || (i != 2)) && (pending & (1 << (i & 7)))) { + highest = (i & 7) | 0x80; + break; + } + } + + target_pic->read &= ~4; + + return highest; +} + + uint8_t pic_read(uint16_t addr, void *priv) { @@ -260,6 +286,8 @@ pic_read(uint16_t addr, void *priv) ret = ((pic.vector & 0xf8) >> 3) << 0; else if (addr & 1) ret = pic.mask; + else if (pic.read & 5) + ret = pic_highest_req(&pic, 0); else if (pic.read) { if (AT) ret = pic.ins | (pic2.ins ? 4 : 0); @@ -394,6 +422,7 @@ pic2_write(uint16_t addr, uint8_t val, void *priv) pic2.ocw3 = val; if (val & 2) pic2.read=(val & 1); + pic2.read |= (val & 5); } } } @@ -414,6 +443,8 @@ pic2_read(uint16_t addr, void *priv) ret = ((pic2.vector & 0xf8) >> 3) << 0; else if (addr & 1) ret = pic2.mask; + else if (pic2.read & 5) + ret = pic_highest_req(&pic2, 1); else if (pic2.read) ret = pic2.ins; else diff --git a/src/video/vid_cl54xx.c b/src/video/vid_cl54xx.c index f3f428f7e..07ffad50a 100644 --- a/src/video/vid_cl54xx.c +++ b/src/video/vid_cl54xx.c @@ -3392,7 +3392,7 @@ static const device_config_t gd5434_config[] = const device_t gd5401_isa_device = { "Cirrus Logic GD-5401 (ACUMOS AVGA1)", - DEVICE_AT | DEVICE_ISA, + DEVICE_ISA, CIRRUS_ID_CLGD5401, gd54xx_init, gd54xx_close, NULL, @@ -3405,7 +3405,7 @@ const device_t gd5401_isa_device = const device_t gd5402_isa_device = { "Cirrus Logic GD-5402 (ACUMOS AVGA2)", - DEVICE_AT | DEVICE_ISA, + DEVICE_ISA, CIRRUS_ID_CLGD5402, gd54xx_init, gd54xx_close, NULL, diff --git a/src/win/86Box.rc b/src/win/86Box.rc index f8291582d..4ca9269a6 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -554,9 +554,9 @@ BEGIN PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_4,217,171,38,12 LTEXT "FDC Controller:",IDT_1768,7,190,48,10 - COMBOBOX IDC_COMBO_FDC_EXT,64,189,155,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_FDC,64,189,155,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Configure",IDC_CONFIGURE_FDC_EXT,217,189,38,12 + PUSHBUTTON "Configure",IDC_CONFIGURE_FDC,217,189,38,12 END DLG_CFG_HARD_DISKS DIALOG DISCARDABLE 97, 0, 267, 154 @@ -968,6 +968,7 @@ BEGIN IDS_2115 "MO %i (%03i): %ls" IDS_2116 "MO images (*.IM?)\0*.IM?\0All files (*.*)\0*.*\0" IDS_2117 "Welcome to 86Box!" + IDS_2118 "Internal controller" END STRINGTABLE DISCARDABLE diff --git a/src/win/win_settings.c b/src/win/win_settings.c index f33f32c07..3ddd0dffb 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -97,7 +97,7 @@ static int temp_lpt_devices[3]; static int temp_serial[2], temp_lpt[3]; /* Other peripherals category */ -static int temp_fdc_ext, temp_hdc, temp_scsi_card, temp_ide_ter, temp_ide_qua; +static int temp_fdc_card, temp_hdc, temp_scsi_card, temp_ide_ter, temp_ide_qua; static int temp_bugger; static int temp_postcard; static int temp_isartc; @@ -125,6 +125,7 @@ extern int is486; static int listtomachinetype[256], machinetypetolist[256]; static int listtomachine[256], machinetolist[256]; static int settings_device_to_list[2][20], settings_list_to_device[2][20]; +static int settings_fdc_to_list[2][20], settings_list_to_fdc[2][20]; static int settings_midi_to_list[20], settings_list_to_midi[20]; static int settings_midi_in_to_list[20], settings_list_to_midi_in[20]; @@ -249,7 +250,7 @@ win_settings_init(void) /* Other peripherals category */ temp_scsi_card = scsi_card_current; - temp_fdc_ext = fdc_type; + temp_fdc_card = fdc_type; temp_hdc = hdc_current; temp_ide_ter = ide_ter_enabled; temp_ide_qua = ide_qua_enabled; @@ -359,7 +360,7 @@ win_settings_changed(void) /* Peripherals category */ i = i || (scsi_card_current != temp_scsi_card); - i = i || (fdc_type != temp_fdc_ext); + i = i || (fdc_type != temp_fdc_card); i = i || (hdc_current != temp_hdc); i = i || (temp_ide_ter != ide_ter_enabled); i = i || (temp_ide_qua != ide_qua_enabled); @@ -466,7 +467,7 @@ win_settings_save(void) /* Peripherals category */ scsi_card_current = temp_scsi_card; hdc_current = temp_hdc; - fdc_type = temp_fdc_ext; + fdc_type = temp_fdc_card; ide_ter_enabled = temp_ide_ter; ide_qua_enabled = temp_ide_qua; bugger_enabled = temp_bugger; @@ -1589,42 +1590,6 @@ win_settings_ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; } -static void -recalc_fdc_list(HWND hdlg) -{ - HWND h = GetDlgItem(hdlg, IDC_COMBO_FDC_EXT); - int c = 0, d = 0; - int found_card = 0; - WCHAR szText[512]; - - SendMessage(h, CB_RESETCONTENT, 0, 0); - SendMessage(h, CB_SETCURSEL, 0, 0); - - while (1) { - char *s = fdc_ext_get_name(c); - - if (!s[0]) - break; - - if (fdc_ext_available(c) && - device_is_valid(fdc_ext_get_device(c), machines[temp_machine].flags)) { - mbstowcs(szText, s, strlen(s) + 1); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) szText); - if (c == temp_fdc_ext) { - SendMessage(h, CB_SETCURSEL, d, 0); - found_card = 1; - } - - d++; - } - - c++; - } - if (!found_card) - SendMessage(h, CB_SETCURSEL, 0, 0); -} - - static void recalc_hdc_list(HWND hdlg) { @@ -1681,6 +1646,7 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa char *stransi; const device_t *scsi_dev; const device_t *dev; + const device_t *fdc_dev; char *s; switch (message) { @@ -1688,15 +1654,6 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); stransi = (char *) malloc(512); - /*FD (Ext) controller config*/ - recalc_fdc_list(hdlg); - - h = GetDlgItem(hdlg, IDC_CONFIGURE_FDC_EXT); - if (fdc_ext_has_config(temp_fdc_ext)) - EnableWindow(h, TRUE); - else - EnableWindow(h, FALSE); - /*HD controller config*/ recalc_hdc_list(hdlg); @@ -1706,6 +1663,43 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa else EnableWindow(h, FALSE); + + /*FD controller config*/ + h = GetDlgItem(hdlg, IDC_COMBO_FDC); + c = d = 0; + while (1) { + char *s = fdc_card_getname(c); + + if (!s[0]) + break; + + settings_fdc_to_list[0][c] = d; + + if (fdc_card_available(c)) { + fdc_dev = fdc_card_getdevice(c); + + if (device_is_valid(fdc_dev, machines[temp_machine].flags)) { + if (c == 0) + SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2118)); + else { + mbstowcs(lptsTemp, s, strlen(s) + 1); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); + } + settings_list_to_fdc[0][d] = c; + d++; + } + } + + c++; + } + SendMessage(h, CB_SETCURSEL, settings_fdc_to_list[0][temp_fdc_card], 0); + + EnableWindow(h, d ? TRUE : FALSE); + + h = GetDlgItem(hdlg, IDC_CONFIGURE_FDC); + EnableWindow(h, fdc_card_has_config(temp_fdc_card) ? TRUE : FALSE); + + /*SCSI config*/ h = GetDlgItem(hdlg, IDC_COMBO_SCSI); c = d = 0; @@ -1825,37 +1819,23 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa case WM_COMMAND: switch (LOWORD(wParam)) { - case IDC_CONFIGURE_FDC_EXT: - lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); - stransi = (char *) malloc(512); + case IDC_CONFIGURE_FDC: + h = GetDlgItem(hdlg, IDC_COMBO_FDC); + temp_fdc_card = settings_list_to_fdc[0][SendMessage(h, CB_GETCURSEL, 0, 0)]; - h = GetDlgItem(hdlg, IDC_COMBO_FDC_EXT); - SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp); - wcstombs(stransi, lptsTemp, 512); - temp_deviceconfig |= deviceconfig_open(hdlg, (void *)fdc_ext_get_device(fdc_ext_get_id(stransi))); - - free(stransi); - free(lptsTemp); + temp_deviceconfig |= deviceconfig_open(hdlg, (void *)fdc_card_getdevice(temp_fdc_card)); break; - case IDC_COMBO_FDC_EXT: - lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); - stransi = (char *) malloc(512); + case IDC_COMBO_FDC: + h = GetDlgItem(hdlg, IDC_COMBO_FDC); + temp_fdc_card = settings_list_to_fdc[0][SendMessage(h, CB_GETCURSEL, 0, 0)]; - h = GetDlgItem(hdlg, IDC_COMBO_FDC_EXT); - SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp); - wcstombs(stransi, lptsTemp, 512); - temp_fdc_ext = fdc_ext_get_id(stransi); - - h = GetDlgItem(hdlg, IDC_CONFIGURE_FDC_EXT); - if (fdc_ext_has_config(temp_fdc_ext)) + h = GetDlgItem(hdlg, IDC_CONFIGURE_FDC); + if (fdc_card_has_config(temp_fdc_card)) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); - - free(stransi); - free(lptsTemp); - break; + break; case IDC_CONFIGURE_HDC: lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); @@ -1979,16 +1959,14 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); stransi = (char *) malloc(512); - h = GetDlgItem(hdlg, IDC_COMBO_FDC_EXT); - SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp); - wcstombs(stransi, lptsTemp, 512); - temp_fdc_ext = fdc_ext_get_id(stransi); - h = GetDlgItem(hdlg, IDC_COMBO_HDC); SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp); wcstombs(stransi, lptsTemp, 512); temp_hdc = hdc_get_id(stransi); + h = GetDlgItem(hdlg, IDC_COMBO_FDC); + temp_fdc_card = settings_list_to_fdc[0][SendMessage(h, CB_GETCURSEL, 0, 0)]; + h = GetDlgItem(hdlg, IDC_COMBO_SCSI); temp_scsi_card = settings_list_to_device[0][SendMessage(h, CB_GETCURSEL, 0, 0)]; From 75badaf8a5f0ac56d3f970035d2b25d115de2cf9 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Wed, 17 Jun 2020 14:42:52 +0200 Subject: [PATCH 11/12] Removed the compaq deskpro 386 stuff. --- src/include/86box/machine.h | 1 - src/machine/m_at_compaq.c | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index b745f757e..98e1ad1d3 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -280,7 +280,6 @@ extern int machine_at_cmdpc_init(const machine_t *); extern int machine_at_portableii_init(const machine_t *); extern int machine_at_portableiii_init(const machine_t *); extern int machine_at_portableiii386_init(const machine_t *); -extern int machine_at_deskpro386_init(const machine_t *); #ifdef EMU_DEVICE_H extern const device_t *at_cpqiii_get_device(void); #endif diff --git a/src/machine/m_at_compaq.c b/src/machine/m_at_compaq.c index 6601d9399..aed26a6f6 100644 --- a/src/machine/m_at_compaq.c +++ b/src/machine/m_at_compaq.c @@ -898,20 +898,3 @@ machine_at_portableiii386_init(const machine_t *model) return ret; } - -int -machine_at_deskpro386_init(const machine_t *model) -{ - int ret; - - ret = bios_load_interleavedr(L"roms/machines/deskpro386/109592-005.U11.bin", - L"roms/machines/deskpro386/109591-005.U13.bin", - 0x000f8000, 65536, 0); - - if (bios_only || !ret) - return ret; - - machine_at_compaq_init(model, COMPAQ_DESKPRO386); - - return ret; -} \ No newline at end of file From 33eec2ef526da374b91ad50c202177b93aa639da Mon Sep 17 00:00:00 2001 From: TC1995 Date: Wed, 17 Jun 2020 14:49:23 +0200 Subject: [PATCH 12/12] Removed last instances of the deskpro 386 code. --- src/cpu/cpu.h | 1 - src/cpu/cpu_table.c | 9 --------- 2 files changed, 10 deletions(-) diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 985696b53..567b40fc0 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -128,7 +128,6 @@ extern CPU cpus_8086[]; extern CPU cpus_286[]; extern CPU cpus_i386SX[]; extern CPU cpus_i386DX[]; -extern CPU cpus_i386DX_Compaq[]; extern CPU cpus_Am386SX[]; extern CPU cpus_Am386DX[]; extern CPU cpus_486SLC[]; diff --git a/src/cpu/cpu_table.c b/src/cpu/cpu_table.c index d6939f78e..71df19605 100644 --- a/src/cpu/cpu_table.c +++ b/src/cpu/cpu_table.c @@ -186,15 +186,6 @@ CPU cpus_i386DX[] = { {"", -1, 0, 0, 0, 0, 0, 0, 0,0,0,0, 0} }; -CPU cpus_i386DX_Compaq[] = { - /*i386DX/RapidCAD*/ - {"i386DX/16", CPU_386DX, fpus_80286, 16000000, 1, 0x0308, 0, 0, 0, 3,3,3,3, 2}, - {"i386DX/20", CPU_386DX, fpus_80286, 20000000, 1, 0x0308, 0, 0, 0, 4,4,3,3, 3}, - {"i386DX/25", CPU_386DX, fpus_80286, 25000000, 1, 0x0308, 0, 0, 0, 4,4,3,3, 3}, - {"i386DX/33", CPU_386DX, fpus_80286, 33333333, 1, 0x0308, 0, 0, 0, 6,6,3,3, 4}, - {"i386DX/40", CPU_386DX, fpus_80286, 40000000, 1, 0x0308, 0, 0, 0, 7,7,3,3, 5}, - {"", -1, 0, 0, 0, 0, 0, 0, 0,0,0,0, 0} -}; CPU cpus_Am386SX[] = { /*Am386SX*/