Merge pull request #3074 from jriwanek-forks/more-fdc

Add tertiary and quaternary FDC options + improvements to monster FDC
This commit is contained in:
Miran Grča
2023-02-03 06:46:05 +01:00
committed by GitHub
3 changed files with 113 additions and 7 deletions

View File

@@ -2280,6 +2280,12 @@ fdc_reset(void *priv)
} else if (fdc->flags & FDC_FLAG_SEC) {
fdc->dma = 1;
fdc->specify[1] = 0;
} else if (fdc->flags & FDC_FLAG_TER) {
fdc->dma = 1;
fdc->specify[1] = 0;
} else if (fdc->flags & FDC_FLAG_QUA) {
fdc->dma = 1;
fdc->specify[1] = 0;
} else {
fdc->dma = 1;
fdc->specify[1] = 0;
@@ -2297,6 +2303,10 @@ fdc_reset(void *priv)
fdc_remove(fdc);
if (fdc->flags & FDC_FLAG_SEC) {
fdc_set_base(fdc, FDC_SECONDARY_ADDR);
} else if (fdc->flags & FDC_FLAG_TER) {
fdc_set_base(fdc, FDC_TERTIARY_ADDR);
} else if (fdc->flags & FDC_FLAG_QUA) {
fdc_set_base(fdc, FDC_QUATERNARY_ADDR);
} else {
fdc_set_base(fdc, (fdc->flags & FDC_FLAG_PCJR) ? FDC_PRIMARY_PCJR_ADDR : FDC_PRIMARY_ADDR);
}
@@ -2337,6 +2347,10 @@ fdc_init(const device_t *info)
timer_add(&fdc->watchdog_timer, fdc_watchdog_poll, fdc, 0);
else if (fdc->flags & FDC_FLAG_SEC)
fdc->dma_ch = FDC_SECONDARY_DMA;
else if (fdc->flags & FDC_FLAG_TER)
fdc->dma_ch = FDC_TERTIARY_DMA;
else if (fdc->flags & FDC_FLAG_QUA)
fdc->dma_ch = FDC_QUATERNARY_DMA;
else
fdc->dma_ch = FDC_PRIMARY_DMA;
@@ -2390,6 +2404,34 @@ const device_t fdc_xt_sec_device = {
.config = NULL
};
const device_t fdc_xt_ter_device = {
.name = "PC/XT Floppy Drive Controller (Tertiary)",
.internal_name = "fdc_xt_ter",
.flags = FDC_FLAG_TER,
.local = 0,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
{ .available = NULL },
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_xt_qua_device = {
.name = "PC/XT Floppy Drive Controller (Quaternary)",
.internal_name = "fdc_xt_qua",
.flags = FDC_FLAG_QUA,
.local = 0,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
{ .available = NULL },
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_xt_t1x00_device = {
.name = "PC/XT Floppy Drive Controller (Toshiba)",
.internal_name = "fdc_xt_t1x00",
@@ -2474,6 +2516,34 @@ const device_t fdc_at_sec_device = {
.config = NULL
};
const device_t fdc_at_ter_device = {
.name = "PC/AT Floppy Drive Controller (Tertiary)",
.internal_name = "fdc_at_ter",
.flags = 0,
.local = FDC_FLAG_AT | FDC_FLAG_TER,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
{ .available = NULL },
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_at_qua_device = {
.name = "PC/AT Floppy Drive Controller (Quaternary)",
.internal_name = "fdc_at_qua",
.flags = 0,
.local = FDC_FLAG_AT | FDC_FLAG_QUA,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
{ .available = NULL },
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_at_actlow_device = {
.name = "PC/AT Floppy Drive Controller (Active low)",
.internal_name = "fdc_at_actlow",

View File

@@ -39,6 +39,8 @@
typedef struct
{
rom_t bios_rom;
fdc_t *fdc_pri;
fdc_t *fdc_sec;
} monster_fdc_t;
static void
@@ -57,14 +59,29 @@ monster_fdc_init(const device_t *info)
dev = (monster_fdc_t *)malloc(sizeof(monster_fdc_t));
memset(dev, 0, sizeof(monster_fdc_t));
#if 0
uint8_t sec_irq = device_get_config_int("sec_irq");
uint8_t sec_dma = device_get_config_int("sec_dma");
#endif
if (BIOS_ADDR != 0)
rom_init(&dev->bios_rom, ROM_MONSTER_FDC, BIOS_ADDR, 0x2000, 0x1ffff, 0, MEM_MAPPING_EXTERNAL);
// Primary FDC
device_add(&fdc_at_device);
dev->fdc_pri = device_add(&fdc_at_device);
#if 0
// Secondary FDC
// device_add(&fdc_at_sec_device);
uint8_t sec_enabled = device_get_config_int("sec_enabled");
if (sec_enabled)
dev->fdc_sec = device_add(&fdc_at_sec_device);
fdc_set_irq(dev->fdc_sec, sec_irq);
fdc_set_dma_ch(dev->fdc_sec, sec_dma);
#endif
#if 0
uint8_t rom_writes_enabled = device_get_config_int("rom_writes_enabled");
#endif
return dev;
}
@@ -76,7 +93,14 @@ static int monster_fdc_available(void)
static const device_config_t monster_fdc_config[] = {
// clang-format off
/*
#if 0
{
.name = "sec_enabled",
.description = "Enable Secondary Controller",
.type = CONFIG_BINARY,
.default_string = "",
.default_int = 0
},
{
.name = "sec_irq",
.description = "Secondary Controller IRQ",
@@ -137,7 +161,7 @@ static const device_config_t monster_fdc_config[] = {
{ .description = "" }
}
},
*/
#endif
{
.name = "bios_addr",
.description = "BIOS Address:",
@@ -157,7 +181,7 @@ static const device_config_t monster_fdc_config[] = {
{ .description = "" }
}
},
/*
#if 0
{
.name = "bios_size",
.description = "BIOS Size:",
@@ -172,8 +196,14 @@ static const device_config_t monster_fdc_config[] = {
{ .description = "" }
}
},
*/
// BIOS extension ROM writes: Enabled/Disabled
{
.name = "rom_writes_enabled",
.description = "Enable BIOS extension ROM Writes",
.type = CONFIG_BINARY,
.default_string = "",
.default_int = 0
},
#endif
{ .name = "", .description = "", .type = CONFIG_END }
// clang-format on
};

View File

@@ -53,6 +53,8 @@ extern int fdc_type;
#define FDC_FLAG_UMC 0x400 /* UMC UM8398 */
#define FDC_FLAG_ALI 0x800 /* ALi M512x / M1543C */
#define FDC_FLAG_SEC 0x1000 /* Is Secondary */
#define FDC_FLAG_TER 0x2000 /* Is Tertiary */
#define FDC_FLAG_QUA 0x3000 /* Is Quaternary */
typedef struct {
uint8_t dor, stat, command, processed_cmd, dat, st0, swap, dtl;
@@ -187,12 +189,16 @@ extern uint8_t fdc_get_current_drive(void);
#ifdef EMU_DEVICE_H
extern const device_t fdc_xt_device;
extern const device_t fdc_xt_sec_device;
extern const device_t fdc_xt_ter_device;
extern const device_t fdc_xt_qua_device;
extern const device_t fdc_xt_t1x00_device;
extern const device_t fdc_xt_tandy_device;
extern const device_t fdc_xt_amstrad_device;
extern const device_t fdc_pcjr_device;
extern const device_t fdc_at_device;
extern const device_t fdc_at_sec_device;
extern const device_t fdc_at_ter_device;
extern const device_t fdc_at_qua_device;
extern const device_t fdc_at_actlow_device;
extern const device_t fdc_at_ps1_device;
extern const device_t fdc_at_smc_device;