From 07e3aba22c0520c5646cb0d39dea67914a95d625 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 29 Jun 2024 22:16:04 -0400 Subject: [PATCH] Better support for internal floppy --- src/config.c | 21 ++++++++ src/include/86box/fdc_ext.h | 3 +- src/machine/m_xt.c | 105 +++++++++++++++++------------------- 3 files changed, 73 insertions(+), 56 deletions(-) diff --git a/src/config.c b/src/config.c index ab23ddb4f..a98111edc 100644 --- a/src/config.c +++ b/src/config.c @@ -792,10 +792,31 @@ load_storage_controllers(void) } p = ini_section_get_string(cat, "fdc", NULL); +#if 0 if (p != NULL) fdc_type = fdc_card_get_from_internal_name(p); else fdc_type = FDC_INTERNAL; +#else + if (p == NULL) { + if (machine_has_flags(machine, 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_card_get_from_internal_name(p); + + if (free_p) { + free(p); + p = NULL; + free_p = 0; + } +#endif p = ini_section_get_string(cat, "hdc", NULL); if (p == NULL) { diff --git a/src/include/86box/fdc_ext.h b/src/include/86box/fdc_ext.h index 0d821ac11..2c46d0704 100644 --- a/src/include/86box/fdc_ext.h +++ b/src/include/86box/fdc_ext.h @@ -25,7 +25,8 @@ extern int fdc_type; /* Controller types. */ -#define FDC_INTERNAL 0 +#define FDC_NONE 0 +#define FDC_INTERNAL 1 extern const device_t fdc_b215_device; extern const device_t fdc_pii151b_device; diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index ded68f5dc..adca9f4de 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -23,15 +23,15 @@ extern const device_t vendex_xt_rtc_onboard_device; static void -machine_xt_common_init(const machine_t *model) +machine_xt_common_init(const machine_t *model, int fixed_floppy) { + if ((fdc_type == FDC_INTERNAL) || fixed_floppy) + device_add(&fdc_xt_device); + machine_common_init(model); pit_devs[0].set_out_func(pit_devs[0].data, 1, pit_refresh_timer_xt); - if (fdc_type == FDC_INTERNAL) - device_add(&fdc_xt_device); - nmi_init(); standalone_gameport_type = &gameport_device; } @@ -59,7 +59,7 @@ machine_pc_init(const machine_t *model) device_add(&keyboard_pc_device); - machine_xt_common_init(model); + machine_xt_common_init(model, 0); return ret; } @@ -93,19 +93,11 @@ machine_pc82_init(const machine_t *model) device_add(&keyboard_pc82_device); device_add(&ibm_5161_device); - machine_xt_common_init(model); + machine_xt_common_init(model, 0); return ret; } -static void -machine_xt_init_ex(const machine_t *model) -{ - device_add(&keyboard_xt_device); - - machine_xt_common_init(model); -} - int machine_xt_init(const machine_t *model) { @@ -127,10 +119,12 @@ machine_xt_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_init_ex(model); + device_add(&keyboard_xt_device); device_add(&ibm_5161_device); + machine_xt_common_init(model, 0); + return ret; } @@ -145,7 +139,9 @@ machine_genxt_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_init_ex(model); + device_add(&keyboard_xt_device); + + machine_xt_common_init(model, 0); return ret; } @@ -170,17 +166,17 @@ machine_xt86_init(const machine_t *model) device_add(&keyboard_xt86_device); device_add(&ibm_5161_device); - machine_xt_common_init(model); + machine_xt_common_init(model, 0); return ret; } static void -machine_xt_clone_init(const machine_t *model) +machine_xt_clone_init(const machine_t *model, int fixed_floppy) { device_add(&keyboard_xtclone_device); - machine_xt_common_init(model); + machine_xt_common_init(model, fixed_floppy); } int @@ -194,7 +190,7 @@ machine_xt_americxt_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -210,7 +206,7 @@ machine_xt_amixt_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -226,7 +222,7 @@ machine_xt_znic_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -242,7 +238,7 @@ machine_xt_dtk_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -258,7 +254,7 @@ machine_xt_jukopc_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -274,7 +270,7 @@ machine_xt_openxt_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -294,7 +290,7 @@ machine_xt_pcxt_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -312,7 +308,7 @@ machine_xt_pxxt_init(const machine_t *model) device_add(&keyboard_xt_device); - machine_xt_common_init(model); + machine_xt_common_init(model, 0); return ret; } @@ -329,7 +325,7 @@ machine_xt_iskra3104_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -363,7 +359,7 @@ machine_xt_pravetz16_imko4_init(const machine_t *model) device_add(&keyboard_pravetz_device); - machine_xt_common_init(model); + machine_xt_common_init(model, 0); return ret; } @@ -379,7 +375,10 @@ machine_xt_micoms_xl7turbo_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_init_ex(model); + device_add(&keyboard_xt_device); + + machine_xt_common_init(model, 0); + return ret; } @@ -394,7 +393,7 @@ machine_xt_pc4i_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -412,7 +411,7 @@ machine_xt_mpc1600_init(const machine_t *model) device_add(&keyboard_pc82_device); - machine_xt_common_init(model); + machine_xt_common_init(model, 0); return ret; } @@ -435,7 +434,7 @@ machine_xt_pcspirit_init(const machine_t *model) device_add(&keyboard_pc82_device); - machine_xt_common_init(model); + machine_xt_common_init(model, 0); return ret; } @@ -453,7 +452,7 @@ machine_xt_pc700_init(const machine_t *model) device_add(&keyboard_pc_device); - machine_xt_common_init(model); + machine_xt_common_init(model, 0); return ret; } @@ -471,7 +470,7 @@ machine_xt_pc500_init(const machine_t *model) device_add(&keyboard_pc_device); - machine_xt_common_init(model); + machine_xt_common_init(model, 0); return ret; } @@ -487,18 +486,20 @@ machine_xt_vendex_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + /* On-board FDC cannot be disabled */ + machine_xt_clone_init(model, 1); + device_add(&vendex_xt_rtc_onboard_device); return ret; } static void -machine_xt_hyundai_common_init(const machine_t *model) +machine_xt_hyundai_common_init(const machine_t *model, int fixed_floppy) { device_add(&keyboard_xt_hyundai_device); - machine_xt_common_init(model); + machine_xt_common_init(model, fixed_floppy); } int @@ -512,10 +513,8 @@ machine_xt_super16t_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_hyundai_common_init(model); - /* On-board FDC cannot be disabled */ - device_add(&fdc_xt_device); + machine_xt_hyundai_common_init(model, 1); return ret; } @@ -531,10 +530,8 @@ machine_xt_super16te_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_hyundai_common_init(model); - /* On-board FDC cannot be disabled */ - device_add(&fdc_xt_device); + machine_xt_hyundai_common_init(model, 1); return ret; } @@ -550,10 +547,8 @@ machine_xt_top88_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); - /* On-board FDC cannot be disabled */ - device_add(&fdc_xt_device); + machine_xt_clone_init(model, 1); return ret; } @@ -569,7 +564,7 @@ machine_xt_kaypropc_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -585,10 +580,8 @@ machine_xt_sansx16_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); - /* On-board FDC cannot be disabled */ - device_add(&fdc_xt_device); + machine_xt_clone_init(model, 1); return ret; } @@ -604,7 +597,7 @@ machine_xt_bw230_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -620,7 +613,7 @@ machine_xt_v20xt_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -636,7 +629,7 @@ machine_xt_pb8810_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_clone_init(model); + machine_xt_clone_init(model, 0); return ret; } @@ -652,7 +645,9 @@ machine_xt_glabios_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_xt_init_ex(model); + device_add(&keyboard_xt_device); + + machine_xt_common_init(model, 0); return ret; }