Files
86Box/src/floppy/fdc.c

2687 lines
87 KiB
C
Raw Normal View History

/*
* 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.
*
2020-03-25 00:46:02 +02:00
*
*
2023-01-06 15:36:29 -05:00
* Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
2017-10-17 01:59:09 -04:00
*
* Copyright 2008-2020 Sarah Walker.
* Copyright 2016-2020 Miran Grca.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include <86box/86box.h>
#include <86box/device.h>
2020-02-29 19:12:23 +01:00
#include "cpu.h"
#include <86box/machine.h>
#include <86box/io.h>
#include <86box/dma.h>
#include <86box/pic.h>
#include <86box/timer.h>
#include <86box/ui.h>
#include <86box/fdd.h>
#include <86box/fdc.h>
2020-06-16 16:41:35 +02:00
#include <86box/fdc_ext.h>
2023-07-26 10:57:01 -04:00
#include <86box/plat_fallthrough.h>
2023-06-26 12:47:04 -04:00
#include <86box/plat_unused.h>
#include <86box/fifo.h>
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
extern uint64_t motoron[FDD_NUM];
const uint8_t command_has_drivesel[32] = {
2022-09-18 17:14:15 -04:00
0, 0,
1, /* READ TRACK */
0,
1, /* SENSE DRIVE STATUS */
1, /* WRITE DATA */
1, /* READ DATA */
1, /* RECALIBRATE */
0,
1, /* WRITE DELETED DATA */
1, /* READ ID */
0,
1, /* READ DELETED DATA */
1, /* FORMAT TRACK */
0,
1, /* SEEK, RELATIVE SEEK */
0,
1, /* SCAN EQUAL */
0, 0, 0, 0,
1, /* VERIFY */
0, 0,
1, /* SCAN LOW OR EQUAL */
0, 0, 0,
1, /* SCAN HIGH OR EQUAL */
0, 0
};
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
static uint8_t current_drive = 0;
static void fdc_callback(void *priv);
2022-09-18 17:14:15 -04:00
int lastbyte = 0;
int floppymodified[4];
int floppyrate[4];
2024-07-20 20:02:34 -04:00
int fdc_current[FDC_MAX] = { 0, 0 };
#ifdef ENABLE_FDC_LOG
int fdc_do_log = ENABLE_FDC_LOG;
static void
fdc_log(const char *fmt, ...)
{
2022-09-18 17:14:15 -04:00
va_list ap;
2022-09-18 17:14:15 -04:00
if (fdc_do_log) {
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
}
#else
2022-09-18 17:14:15 -04:00
# define fdc_log(fmt, ...)
#endif
typedef const struct {
2022-09-18 17:14:15 -04:00
const device_t *device;
} fdc_cards_t;
static fdc_cards_t fdc_cards[] = {
2022-09-18 17:14:15 -04:00
// clang-format off
{ &device_none },
{ &device_internal },
{ &fdc_b215_device },
{ &fdc_pii151b_device },
{ &fdc_pii158b_device },
{ &fdc_compaticard_i_device },
{ &fdc_compaticard_ii_device },
#if 0
{ &fdc_compaticard_iv_device },
#endif
{ &fdc_monster_device },
{ NULL }
2022-09-18 17:14:15 -04:00
// clang-format on
};
int
fdc_card_available(int card)
2020-06-16 16:37:48 +02:00
{
if (fdc_cards[card].device)
2022-09-18 17:14:15 -04:00
return (device_available(fdc_cards[card].device));
2023-05-16 15:43:20 -04:00
return 1;
2020-06-16 16:37:48 +02:00
}
const device_t *
fdc_card_getdevice(int card)
{
2022-09-18 17:14:15 -04:00
return (fdc_cards[card].device);
}
int
fdc_card_has_config(int card)
{
2022-09-18 17:14:15 -04:00
if (!fdc_cards[card].device)
2023-05-16 15:43:20 -04:00
return 0;
2022-09-18 17:14:15 -04:00
return (device_has_config(fdc_cards[card].device) ? 1 : 0);
}
2023-08-21 20:23:04 -04:00
const char *
fdc_card_get_internal_name(int card)
{
return device_get_internal_name(fdc_cards[card].device);
}
int
fdc_card_get_from_internal_name(char *s)
{
int c = 0;
while (fdc_cards[c].device != NULL) {
2023-08-21 20:23:04 -04:00
if (!strcmp(fdc_cards[c].device->internal_name, s))
2023-05-16 15:43:20 -04:00
return c;
2022-09-18 17:14:15 -04:00
c++;
}
2022-02-20 02:26:27 -05:00
2023-05-16 15:43:20 -04:00
return 0;
}
void
fdc_card_init(void)
{
if ((fdc_current[0] > FDC_INTERNAL) && fdc_cards[fdc_current[0]].device)
device_add_inst(fdc_cards[fdc_current[0]].device, 0);
}
uint8_t
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
fdc_get_current_drive(void)
{
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
return current_drive;
}
void
2023-06-28 13:46:28 -04:00
fdc_ctrl_reset(void *priv)
{
2023-06-28 13:46:28 -04:00
fdc_t *fdc = (fdc_t *) priv;
fdc->stat = 0x80;
2022-09-18 17:14:15 -04:00
fdc->pnum = fdc->ptot = 0;
fdc->st0 = 0;
fdc->lock = 0;
fdc->head = 0;
fdc->step = 0;
fdc->power_down = 0;
}
sector_id_t
fdc_get_read_track_sector(fdc_t *fdc)
{
return fdc->read_track_sector;
}
int
fdc_get_compare_condition(fdc_t *fdc)
{
switch (fdc->interrupt) {
2022-09-18 17:14:15 -04:00
default:
2023-06-28 13:46:28 -04:00
case 0x11:
2022-09-18 17:14:15 -04:00
return 0;
case 0x19:
return 1;
case 0x1D:
return 2;
}
}
int
fdc_is_deleted(fdc_t *fdc)
{
return fdc->deleted & 1;
}
int
fdc_is_sk(fdc_t *fdc)
{
return (fdc->deleted & 0x20) ? 1 : 0;
}
void
fdc_set_wrong_am(fdc_t *fdc)
{
fdc->wrong_am = 1;
}
int
fdc_get_drive(fdc_t *fdc)
{
return (int) fdc->drive;
}
2022-09-18 17:14:15 -04:00
int fdc_get_bitcell_period(fdc_t *fdc);
int fdc_get_bit_rate(fdc_t *fdc);
static void fdc_rate(fdc_t *fdc, int drive);
int
fdc_get_perp(fdc_t *fdc)
{
if (!(fdc->flags & FDC_FLAG_AT) || (fdc->flags & FDC_FLAG_PCJR))
2022-09-18 17:14:15 -04:00
return 0;
return (int) fdc->perp;
}
int
fdc_get_gap2(fdc_t *fdc, int drive)
{
int auto_gap2 = 22;
if (!(fdc->flags & FDC_FLAG_AT) || (fdc->flags & FDC_FLAG_PCJR))
2022-09-18 17:14:15 -04:00
return 22;
if (fdc->perp & 3)
2022-09-18 17:14:15 -04:00
return ((fdc->perp & 3) == 3) ? 41 : 22;
else {
2022-09-18 17:14:15 -04:00
auto_gap2 = (fdc_get_bit_rate(fdc) >= 3) ? 41 : 22;
return (fdc->perp & (4 << drive)) ? auto_gap2 : 22;
}
}
int
fdc_get_format_n(fdc_t *fdc)
{
return (int) fdc->format_n;
}
int
fdc_is_mfm(fdc_t *fdc)
{
return fdc->mfm ? 1 : 0;
}
void
fdc_request_next_sector_id(fdc_t *fdc)
{
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->dma)
2022-09-18 17:14:15 -04:00
fdc->stat = 0xf0;
else {
2022-09-18 17:14:15 -04:00
dma_set_drq(fdc->dma_ch, 1);
fdc->stat = 0x50;
}
}
void
fdc_stop_id_request(fdc_t *fdc)
{
fdc->stat &= 0x7f;
}
int
fdc_get_gap(fdc_t *fdc)
{
return (int) fdc->gap;
}
int
fdc_get_dtl(fdc_t *fdc)
{
return fdc->dtl;
}
int
fdc_get_format_sectors(fdc_t *fdc)
{
return (int) fdc->format_sectors;
}
2022-09-18 17:14:15 -04:00
static void
fdc_int(fdc_t *fdc, int set_fintr)
{
2018-02-02 18:39:48 +01:00
int ienable = 0;
if (!(fdc->flags & FDC_FLAG_PCJR))
2022-09-18 17:14:15 -04:00
ienable = !!(fdc->dor & 8);
2018-02-02 18:39:48 +01:00
if (ienable)
2022-09-18 17:14:15 -04:00
picint(1 << fdc->irq);
2018-02-02 18:39:48 +01:00
if (set_fintr)
2022-09-18 17:14:15 -04:00
fdc->fintr = 1;
fdc_log("fdc_int(%i): fdc->fintr = %i\n", set_fintr, fdc->fintr);
}
static void
fdc_watchdog_poll(void *priv)
{
fdc_t *fdc = (fdc_t *) priv;
fdc->watchdog_count--;
if (fdc->watchdog_count)
2022-09-18 17:14:15 -04:00
timer_advance_u64(&fdc->watchdog_timer, 1000 * TIMER_USEC);
else {
2022-09-18 17:14:15 -04:00
if (fdc->dor & 0x20)
picint(1 << fdc->irq);
}
}
/* fdc->rwc per Winbond W83877F datasheet:
0 = normal;
1 = 500 kbps, 360 rpm;
2 = 500 kbps, 300 rpm;
3 = 250 kbps
Drive is only aware of selected rate and densel, so on real hardware, the rate expected by fdc_t and the rate actually being
processed by drive can mismatch, in which case the fdc_t won't receive the correct data.
*/
void
fdc_update_rates(fdc_t *fdc)
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
{
fdc_rate(fdc, 0);
fdc_rate(fdc, 1);
fdc_rate(fdc, 2);
fdc_rate(fdc, 3);
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
}
void
fdc_set_power_down(fdc_t *fdc, uint8_t power_down)
{
fdc->power_down = power_down;
}
void
fdc_update_max_track(fdc_t *fdc, int max_track)
{
fdc->max_track = max_track;
}
void
fdc_update_enh_mode(fdc_t *fdc, int enh_mode)
{
fdc->enh_mode = !!enh_mode;
fdc_update_rates(fdc);
}
int
fdc_get_rwc(fdc_t *fdc, int drive)
{
return fdc->rwc[drive];
}
void
fdc_update_rwc(fdc_t *fdc, int drive, int rwc)
{
fdc_log("FDD %c: New RWC is %i\n", 0x41 + drive, rwc);
fdc->rwc[drive] = rwc;
fdc_rate(fdc, drive);
}
int
fdc_get_boot_drive(fdc_t *fdc)
{
return fdc->boot_drive;
}
void
fdc_update_boot_drive(fdc_t *fdc, int boot_drive)
{
fdc->boot_drive = boot_drive;
}
void
fdc_update_densel_polarity(fdc_t *fdc, int densel_polarity)
{
fdc_log("FDC: New DENSEL polarity is %i\n", densel_polarity);
fdc->densel_polarity = densel_polarity;
fdc_update_rates(fdc);
}
uint8_t
fdc_get_densel_polarity(fdc_t *fdc)
{
return fdc->densel_polarity;
}
void
fdc_update_densel_force(fdc_t *fdc, int densel_force)
{
fdc_log("FDC: New DENSEL force is %i\n", densel_force);
fdc->densel_force = densel_force;
fdc_update_rates(fdc);
}
void
fdc_update_drvrate(fdc_t *fdc, int drive, int drvrate)
{
fdc_log("FDD %c: New drive rate is %i\n", 0x41 + drive, drvrate);
fdc->drvrate[drive] = drvrate;
fdc_rate(fdc, drive);
}
void
fdc_update_drv2en(fdc_t *fdc, int drv2en)
{
fdc->drv2en = !!drv2en;
}
void
fdc_update_rate(fdc_t *fdc, int drive)
{
if (((fdc->rwc[drive] == 1) || (fdc->rwc[drive] == 2)) && fdc->enh_mode)
2022-09-18 17:14:15 -04:00
fdc->bit_rate = 500;
else if ((fdc->rwc[drive] == 3) && fdc->enh_mode)
2022-09-18 17:14:15 -04:00
fdc->bit_rate = 250;
else switch (fdc->rate) {
default:
break;
case 0: /*High density*/
fdc->bit_rate = 500;
break;
case 1: /*Double density (360 rpm)*/
switch (fdc->drvrate[drive]) {
default:
break;
case 0:
fdc->bit_rate = 300;
break;
case 1:
fdc->bit_rate = 500;
break;
case 2:
fdc->bit_rate = 2000;
break;
}
break;
case 2: /*Double density*/
fdc->bit_rate = 250;
break;
case 3: /*Extended density*/
fdc->bit_rate = 1000;
break;
}
fdc->bitcell_period = (1000000 / fdc->bit_rate) * 2; /*Bitcell period in ns*/
}
int
fdc_get_bit_rate(fdc_t *fdc)
{
2022-09-18 17:14:15 -04:00
switch (fdc->bit_rate) {
case 500:
return 0;
case 300:
return 1;
case 2000:
return 1 | 4;
case 250:
return 2;
case 1000:
return 3;
2023-06-28 13:46:28 -04:00
2022-09-18 17:14:15 -04:00
default:
2023-06-28 13:46:28 -04:00
break;
}
return 2;
}
int
fdc_get_bitcell_period(fdc_t *fdc)
{
return fdc->bitcell_period;
}
static int
fdc_get_densel(fdc_t *fdc, int drive)
{
if (fdc->enh_mode) {
2022-09-18 17:14:15 -04:00
switch (fdc->rwc[drive]) {
case 1:
case 3:
return 0;
case 2:
return 1;
2023-06-28 13:46:28 -04:00
default:
break;
2022-09-18 17:14:15 -04:00
}
}
if (!(fdc->flags & FDC_FLAG_NSC)) {
2022-09-18 17:14:15 -04:00
switch (fdc->densel_force) {
case 2:
return 1;
case 3:
return 0;
2023-06-28 13:46:28 -04:00
default:
break;
2022-09-18 17:14:15 -04:00
}
} else {
2022-09-18 17:14:15 -04:00
switch (fdc->densel_force) {
case 0:
return 0;
case 1:
return 1;
2023-06-28 13:46:28 -04:00
default:
break;
2022-09-18 17:14:15 -04:00
}
}
switch (fdc->rate) {
2022-09-18 17:14:15 -04:00
case 0:
case 3:
return fdc->densel_polarity ? 1 : 0;
case 1:
case 2:
return fdc->densel_polarity ? 0 : 1;
2023-06-28 13:46:28 -04:00
default:
break;
}
return 0;
}
static void
fdc_rate(fdc_t *fdc, int drive)
{
fdc_update_rate(fdc, drive);
fdc_log("FDD %c: [%i] Setting rate: %i, %i, %i (%i, %i, %i)\n", 0x41 + drive, fdc->enh_mode, fdc->drvrate[drive], fdc->rate, fdc_get_densel(fdc, drive), fdc->rwc[drive], fdc->densel_force, fdc->densel_polarity);
fdd_set_densel(fdc_get_densel(fdc, drive));
fdc_log("FDD %c: [%i] Densel: %i\n", 0x41 + drive, fdc->enh_mode, fdc_get_densel(fdc, drive));
}
int
real_drive(fdc_t *fdc, int drive)
{
if (drive < 2)
2022-09-18 17:14:15 -04:00
return drive ^ fdc->swap;
else
2022-09-18 17:14:15 -04:00
return drive;
}
void
fdc_seek(fdc_t *fdc, int drive, int params)
{
fdd_seek(real_drive(fdc, drive), params);
fdc->stat |= (1 << fdc->drive);
}
static void
fdc_bad_command(fdc_t *fdc)
{
2022-09-18 17:14:15 -04:00
fdc->stat = 0x10;
fdc->interrupt = 0xfc;
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
timer_set_delay_u64(&fdc->timer, 100 * TIMER_USEC);
}
static void
fdc_io_command_phase1(fdc_t *fdc, int out)
{
fifo_reset(fdc->fifo_p);
fdc_rate(fdc, fdc->drive);
fdc->head = fdc->params[2];
fdd_set_head(real_drive(fdc, fdc->drive), (fdc->params[0] & 4) ? 1 : 0);
2022-09-18 17:14:15 -04:00
fdc->sector = fdc->params[3];
fdc->eot[fdc->drive] = fdc->params[5];
2022-09-18 17:14:15 -04:00
fdc->gap = fdc->params[6];
fdc->dtl = fdc->params[7];
fdc->rw_track = fdc->params[1];
2020-06-20 22:34:51 +02:00
if (fdc->config & 0x40) {
2022-09-18 17:14:15 -04:00
if (fdc->rw_track != fdc->pcn[fdc->params[0] & 3]) {
fdc_seek(fdc, fdc->drive, ((int) fdc->rw_track) - ((int) fdc->pcn[fdc->params[0] & 3]));
fdc->pcn[fdc->params[0] & 3] = fdc->rw_track;
}
2020-06-20 22:34:51 +02:00
}
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
ui_sb_update_icon(SB_FLOPPY | real_drive(fdc, fdc->drive), 1);
fdc->stat = out ? 0x10 : 0x50;
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->dma) {
2022-09-18 17:14:15 -04:00
fdc->stat |= 0x20;
if (out)
fdc->stat |= 0x80;
} else
2022-09-18 17:14:15 -04:00
dma_set_drq(fdc->dma_ch, 1);
}
static void
fdc_sis(fdc_t *fdc)
{
int drive_num;
2022-09-18 17:14:15 -04:00
fdc->stat = (fdc->stat & 0xf) | 0xd0;
2018-02-02 18:39:48 +01:00
if (fdc->reset_stat) {
2022-09-18 17:14:15 -04:00
drive_num = real_drive(fdc, 4 - fdc->reset_stat);
if ((drive_num < FDD_NUM) && fdd_get_flags(drive_num)) {
fdd_stop(drive_num);
fdd_set_head(drive_num, 0);
fdc->res[9] = 0xc0 | (4 - fdc->reset_stat) | (fdd_get_head(drive_num) ? 4 : 0);
} else
fdc->res[9] = 0xc0 | (4 - fdc->reset_stat);
fdc->reset_stat--;
} else {
2022-09-18 17:14:15 -04:00
if (fdc->fintr) {
fdc->res[9] = (fdc->st0 & ~0x04) | (fdd_get_head(real_drive(fdc, fdc->drive)) ? 4 : 0);
fdc->fintr = 0;
} else {
fdc->res[10] = 0x80;
fdc->paramstogo = 1;
return;
}
}
fdc->res[10] = fdc->pcn[fdc->res[9] & 3];
fdc_log("Sense interrupt status: 2 parameters to go\n");
fdc->paramstogo = 2;
}
static void
fdc_soft_reset(fdc_t *fdc)
{
if (fdc->power_down) {
timer_set_delay_u64(&fdc->timer, 1000 * TIMER_USEC);
fdc->interrupt = -5;
} else {
timer_set_delay_u64(&fdc->timer, 8 * TIMER_USEC);
fdc->interrupt = -1;
fdc->perp &= 0xfc;
for (int i = 0; i < FDD_NUM; i++)
ui_sb_update_icon(SB_FLOPPY | i, 0);
fdc_ctrl_reset(fdc);
}
}
static void
fdc_write(uint16_t addr, uint8_t val, void *priv)
{
fdc_t *fdc = (fdc_t *) priv;
2023-05-16 15:43:20 -04:00
int drive;
int drive_num;
fdc_log("Write FDC %04X %02X\n", addr, val);
cycles -= ISA_CYCLES(8);
if (!fdc->power_down || ((addr & 7) == 2) || ((addr & 7) == 4)) switch (addr & 7) {
2022-09-18 17:14:15 -04:00
case 0:
return;
case 1:
return;
case 2: /*DOR*/
if (fdc->flags & FDC_FLAG_PCJR) {
if ((fdc->dor & 0x40) && !(val & 0x40)) {
timer_set_delay_u64(&fdc->watchdog_timer, 1000 * TIMER_USEC);
fdc->watchdog_count = 1000;
picintc(1 << fdc->irq);
}
if ((val & 0x80) && !(fdc->dor & 0x80)) {
timer_set_delay_u64(&fdc->timer, 8 * TIMER_USEC);
fdc->interrupt = -1;
ui_sb_update_icon(SB_FLOPPY | 0, 0);
fdc_ctrl_reset(fdc);
}
if (!fdd_get_flags(0))
val &= 0xfe;
fdd_set_motor_enable(0, val & 0x01);
fdc->st0 &= ~0x07;
fdc->st0 |= (fdd_get_head(0) ? 4 : 0);
} else {
if (!(val & 8) && (fdc->dor & 8)) {
fdc->tc = 1;
fdc_int(fdc, 1);
}
if (!(val & 4)) {
fdd_stop(real_drive(fdc, val & 3));
fdc->stat = 0x00;
fdc->pnum = fdc->ptot = 0;
}
if ((val & 4) && !(fdc->dor & 4))
fdc_soft_reset(fdc);
2022-09-18 17:14:15 -04:00
/* We can now simplify this since each motor now spins separately. */
for (int i = 0; i < FDD_NUM; i++) {
2022-09-18 17:14:15 -04:00
drive_num = real_drive(fdc, i);
if ((!fdd_get_flags(drive_num)) || (drive_num >= FDD_NUM))
val &= ~(0x10 << drive_num);
else
fdd_set_motor_enable(i, (val & (0x10 << drive_num)));
}
drive_num = real_drive(fdc, val & 0x03);
current_drive = drive_num;
fdc->st0 = (fdc->st0 & 0xf8) | (val & 0x03) | (fdd_get_head(drive_num) ? 4 : 0);
}
fdc->dor = val;
return;
case 3: /* TDR */
if (fdc->enh_mode) {
drive = real_drive(fdc, fdc->dor & 3);
fdc_update_rwc(fdc, drive, (val & 0x30) >> 4);
}
2024-08-23 09:34:26 +09:00
/* Bit 2: FIFO test mode (PS/55 only? This is not documented in neither the PS/2 HITR nor the 82077AA datasheet.)
The Power-on Self Test of PS/55 writes and verifies 8 bytes of FIFO buffer through I/O 3F5h.
If it fails, then floppy drives will be treated as DD drives. */
if (fdc->flags & FDC_FLAG_PS2_MCA) {
2025-02-17 00:11:33 +09:00
if (val & 0x04) {
fdc->tfifo = 8;
fdc->fifointest = 1;
2025-02-17 00:11:33 +09:00
} else {
fdc->tfifo = 1;
fdc->fifointest = 0;
}
}
2022-09-18 17:14:15 -04:00
return;
case 4: /* DSR */
2024-04-18 03:50:48 +02:00
if (!(fdc->flags & FDC_FLAG_NO_DSR_RESET)) {
if (!(val & 0x80)) {
timer_set_delay_u64(&fdc->timer, 8 * TIMER_USEC);
fdc->interrupt = -6;
}
if (fdc->power_down || ((val & 0x80) && !(fdc->dsr & 0x80)))
fdc_soft_reset(fdc);
}
fdc->dsr = val;
2022-09-18 17:14:15 -04:00
return;
case 5: /*Command register*/
2025-02-17 00:11:33 +09:00
if (fdc->fifointest) {
/* Write FIFO buffer in the test mode (PS/55) */
2025-02-17 00:11:33 +09:00
fdc_log("FIFO buffer position = %X\n", ((fifo_t *) fdc->fifo_p)->end);
fifo_write(val, fdc->fifo_p);
if (fifo_get_full(fdc->fifo_p))
fdc->stat &= ~0x80;
break;
}
2022-09-18 17:14:15 -04:00
if ((fdc->stat & 0xf0) == 0xb0) {
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->fifo) {
fdc->dat = val;
fdc->stat &= ~0x80;
} else {
fifo_write(val, fdc->fifo_p);
if (fifo_get_full(fdc->fifo_p))
2022-09-18 17:14:15 -04:00
fdc->stat &= ~0x80;
}
break;
}
if (fdc->pnum == fdc->ptot) {
if ((fdc->stat & 0xf0) != 0x80) {
/* If bit 4 of the MSR is set, or the MSR is 0x00,
the fdc_t is NOT in the command phase, therefore
do NOT accept commands. */
return;
}
fdc->stat &= 0xf;
fdc->tc = 0;
fdc->data_ready = 0;
fdc->command = val;
fdc->stat |= 0x10;
fdc_log("Starting FDC command %02X\n", fdc->command);
fdc->error = 0;
if (((fdc->command & 0x1f) == 0x02) || ((fdc->command & 0x1f) == 0x05) ||
((fdc->command & 0x1f) == 0x06) || ((fdc->command & 0x1f) == 0x0a) ||
((fdc->command & 0x1f) == 0x0c) || ((fdc->command & 0x1f) == 0x0d) ||
((fdc->command & 0x1f) == 0x11) || ((fdc->command & 0x1f) == 0x16) ||
((fdc->command & 0x1f) == 0x19) || ((fdc->command & 0x1f) == 0x1d))
2022-09-18 17:14:15 -04:00
fdc->processed_cmd = fdc->command & 0x1f;
else
fdc->processed_cmd = fdc->command;
switch (fdc->processed_cmd) {
case 0x01: /*Mode*/
if (fdc->flags & FDC_FLAG_NSC) {
fdc->pnum = 0;
fdc->ptot = 4;
fdc->stat |= 0x90;
fdc->format_state = 0;
} else
fdc_bad_command(fdc);
break;
case 0x02: /*Read track*/
fdc->satisfying_sectors = 0;
fdc->sc = 0;
fdc->wrong_am = 0;
fdc->pnum = 0;
fdc->ptot = 8;
fdc->stat |= 0x90;
fdc->mfm = (fdc->command & 0x40) ? 1 : 0;
break;
case 0x03: /*Specify*/
fdc->pnum = 0;
fdc->ptot = 2;
fdc->stat |= 0x90;
break;
case 0x04: /*Sense drive status*/
fdc->pnum = 0;
fdc->ptot = 1;
fdc->stat |= 0x90;
break;
case 0x05: /*Write data*/
case 0x09: /*Write deleted data*/
fdc->satisfying_sectors = 0;
fdc->sc = 0;
fdc->wrong_am = 0;
fdc->deleted = ((fdc->command & 0x1F) == 9) ? 1 : 0;
fdc->pnum = 0;
fdc->ptot = 8;
fdc->stat |= 0x90;
fdc->mfm = (fdc->command & 0x40) ? 1 : 0;
break;
case 0x06: /*Read data*/
case 0x0c: /*Read deleted data*/
case 0x11: /*Scan equal*/
case 0x19: /*Scan low or equal*/
case 0x16: /*Verify*/
case 0x1d: /*Scan high or equal*/
fdc->satisfying_sectors = 0;
fdc->sc = 0;
fdc->wrong_am = 0;
fdc->deleted = ((fdc->command & 0x1F) == 0xC) ? 1 : 0;
if ((fdc->command & 0x1F) == 0x16)
fdc->deleted = 2;
fdc->deleted |= (fdc->command & 0x20);
fdc->pnum = 0;
fdc->ptot = 8;
fdc->stat |= 0x90;
fdc->mfm = (fdc->command & 0x40) ? 1 : 0;
break;
case 0x17: /*Powerdown mode*/
if (!(fdc->flags & FDC_FLAG_ALI)) {
fdc_bad_command(fdc);
break;
}
2023-08-09 19:44:56 -04:00
fallthrough;
2022-09-18 17:14:15 -04:00
case 0x07: /*Recalibrate*/
fdc->pnum = 0;
fdc->ptot = 1;
fdc->stat |= 0x90;
break;
case 0x08: /*Sense interrupt status*/
fdc_log("fdc->fintr = %i, fdc->reset_stat = %i\n", fdc->fintr, fdc->reset_stat);
fdc->lastdrive = fdc->drive;
fdc_sis(fdc);
break;
case 0x0a: /*Read sector ID*/
fdc->pnum = 0;
fdc->ptot = 1;
fdc->stat |= 0x90;
fdc->mfm = (fdc->command & 0x40) ? 1 : 0;
break;
case 0x0d: /*Format track*/
fdc->pnum = 0;
fdc->ptot = 5;
fdc->stat |= 0x90;
fdc->mfm = (fdc->command & 0x40) ? 1 : 0;
fdc->format_state = 0;
break;
case 0x0e: /*Dump registers*/
if (fdc->flags & FDC_FLAG_NEC) {
fdc_bad_command(fdc);
break;
}
2022-09-18 17:14:15 -04:00
fdc->lastdrive = fdc->drive;
fdc->interrupt = 0x0e;
fdc_callback(fdc);
break;
case 0x0f: /*Seek*/
fdc->pnum = 0;
fdc->ptot = 2;
fdc->stat |= 0x90;
break;
case 0x18: /*NSC*/
if (!(fdc->flags & FDC_FLAG_NSC)) {
fdc_bad_command(fdc);
break;
}
2023-08-09 19:44:56 -04:00
fallthrough;
2022-09-18 17:14:15 -04:00
case 0x10: /*Get version*/
case 0x14: /*Unlock*/
case 0x94: /*Lock*/
if (fdc->flags & FDC_FLAG_NEC) {
fdc_bad_command(fdc);
break;
}
2022-09-18 17:14:15 -04:00
fdc->lastdrive = fdc->drive;
fdc->interrupt = fdc->command;
fdc_callback(fdc);
break;
case 0x12: /*Set perpendicular mode*/
if ((fdc->flags & FDC_FLAG_AT) && !(fdc->flags & FDC_FLAG_PCJR)) {
fdc->pnum = 0;
fdc->ptot = 1;
fdc->stat |= 0x90;
} else
fdc_bad_command(fdc);
break;
case 0x13: /*Configure*/
if (fdc->flags & FDC_FLAG_NEC) {
fdc_bad_command(fdc);
break;
}
2022-09-18 17:14:15 -04:00
fdc->pnum = 0;
fdc->ptot = 3;
fdc->stat |= 0x90;
break;
default:
fdc_bad_command(fdc);
break;
}
} else {
fdc->stat = 0x10 | (fdc->stat & 0xf);
fdc->params[fdc->pnum++] = val;
if (fdc->pnum == 1) {
if (command_has_drivesel[fdc->command & 0x1F]) {
if (fdc->flags & FDC_FLAG_PCJR)
fdc->drive = 0;
else
fdc->drive = fdc->dor & 3;
fdc->rw_drive = fdc->params[0] & 3;
if (((fdc->command & 0x1F) == 7) || ((fdc->command & 0x1F) == 15))
fdc->stat |= (1 << real_drive(fdc, fdc->drive));
}
}
if (fdc->pnum == fdc->ptot) {
fdc_log("Got all params %02X\n", fdc->command);
fifo_reset(fdc->fifo_p);
2022-09-18 17:14:15 -04:00
fdc->interrupt = fdc->processed_cmd;
fdc->reset_stat = 0;
/* Disable timer if enabled. */
timer_disable(&fdc->timer);
/* Start timer if needed at this point. */
switch (fdc->interrupt & 0x1f) {
case 0x02: /* Read a track */
case 0x03: /* Specify */
case 0x0a: /* Read sector ID */
case 0x05: /* Write data */
case 0x06: /* Read data */
case 0x09: /* Write deleted data */
case 0x0c: /* Read deleted data */
case 0x11: /* Scan equal */
case 0x12: /* Perpendicular mode */
case 0x16: /* Verify */
case 0x19: /* Scan low or equal */
case 0x1d: /* Scan high or equal */
/* Do nothing. */
break;
case 0x07: /* Recalibrate */
case 0x0f: /* Seek */
if (fdc->flags & FDC_FLAG_PCJR)
timer_set_delay_u64(&fdc->timer, 1000 * TIMER_USEC);
else
timer_set_delay_u64(&fdc->timer, 256 * TIMER_USEC);
break;
default:
timer_set_delay_u64(&fdc->timer, 256 * TIMER_USEC);
break;
}
/* Process the firt phase of the command. */
switch (fdc->processed_cmd) {
case 0x02: /* Read a track */
fdc_io_command_phase1(fdc, 0);
fdc->read_track_sector.id.c = fdc->params[1];
fdc->read_track_sector.id.h = fdc->params[2];
fdc->read_track_sector.id.r = 1;
fdc->read_track_sector.id.n = fdc->params[4];
if ((fdc->head & 0x01) && !fdd_is_double_sided(real_drive(fdc, fdc->drive))) {
fdc_noidam(fdc);
return;
}
fdd_readsector(real_drive(fdc, fdc->drive), SECTOR_FIRST, fdc->params[1], fdc->head, fdc->rate, fdc->params[4]);
break;
case 0x03: /* Specify */
fdc->stat = 0x80;
fdc->specify[0] = fdc->params[0];
fdc->specify[1] = fdc->params[1];
fdc->dma = (fdc->specify[1] & 1) ^ 1;
if (!fdc->dma)
dma_set_drq(fdc->dma_ch, 0);
break;
case 0x04: /*Sense drive status*/
fdd_set_head(real_drive(fdc, fdc->drive), (fdc->params[0] & 4) ? 1 : 0);
break;
case 0x05: /* Write data */
case 0x09: /* Write deleted data */
fdc_io_command_phase1(fdc, 1);
if ((fdc->head & 0x01) && !fdd_is_double_sided(real_drive(fdc, fdc->drive))) {
fdc_noidam(fdc);
return;
}
fdd_writesector(real_drive(fdc, fdc->drive), fdc->sector, fdc->params[1], fdc->head, fdc->rate, fdc->params[4]);
break;
case 0x11: /* Scan equal */
case 0x19: /* Scan low or equal */
case 0x1d: /* Scan high or equal */
fdc_io_command_phase1(fdc, 1);
if ((fdc->head & 0x01) && !fdd_is_double_sided(real_drive(fdc, fdc->drive))) {
fdc_noidam(fdc);
return;
}
fdd_comparesector(real_drive(fdc, fdc->drive), fdc->sector, fdc->params[1], fdc->head, fdc->rate, fdc->params[4]);
break;
case 0x16: /* Verify */
if (fdc->params[0] & 0x80)
fdc->sc = fdc->params[7];
2023-08-09 19:44:56 -04:00
fallthrough;
2022-09-18 17:14:15 -04:00
case 0x06: /* Read data */
case 0x0c: /* Read deleted data */
fdc_io_command_phase1(fdc, 0);
fdc_log("Reading sector (drive %i) (%i) (%i %i %i %i) (%i %i %i)\n", fdc->drive, fdc->params[0], fdc->params[1], fdc->params[2], fdc->params[3], fdc->params[4], fdc->params[5], fdc->params[6], fdc->params[7]);
if ((fdc->head & 0x01) && !fdd_is_double_sided(real_drive(fdc, fdc->drive))) {
fdc_noidam(fdc);
return;
}
if (((dma_mode(2) & 0x0C) == 0x00) && !(fdc->flags & FDC_FLAG_PCJR) && fdc->dma) {
/* DMA is in verify mode, treat this like a VERIFY command. */
fdc_log("Verify-mode read!\n");
fdc->tc = 1;
fdc->deleted |= 2;
}
fdd_readsector(real_drive(fdc, fdc->drive), fdc->sector, fdc->params[1], fdc->head, fdc->rate, fdc->params[4]);
break;
case 0x07: /* Recalibrate */
fdc->rw_drive = fdc->params[0] & 3;
fdc->stat = (1 << real_drive(fdc, fdc->drive));
if (!(fdc->flags & FDC_FLAG_PCJR))
fdc->stat |= 0x80;
fdc->st0 = fdc->params[0] & 3;
fdc->st0 |= fdd_get_head(real_drive(fdc, fdc->drive)) ? 0x04 : 0x00;
fdc->st0 |= 0x80;
drive_num = real_drive(fdc, fdc->drive);
/* Three conditions under which the command should fail. */
if ((drive_num >= FDD_NUM) || !fdd_get_flags(drive_num) || !motoron[drive_num] || fdd_track0(drive_num)) {
fdc_log("Failed recalibrate\n");
if ((drive_num >= FDD_NUM) || !fdd_get_flags(drive_num) || !motoron[drive_num])
fdc->st0 = 0x70 | (fdc->params[0] & 3);
else
fdc->st0 = 0x20 | (fdc->params[0] & 3);
fdc->pcn[fdc->params[0] & 3] = 0;
if (fdc->flags & FDC_FLAG_PCJR) {
fdc->fintr = 1;
fdc->interrupt = -4;
} else {
timer_disable(&fdc->timer);
fdc->interrupt = -3;
fdc_callback(fdc);
}
break;
}
if ((real_drive(fdc, fdc->drive) != 1) || fdc->drv2en)
fdc_seek(fdc, fdc->drive, -fdc->max_track);
fdc_log("Recalibrating...\n");
fdc->seek_dir = fdc->step = 1;
break;
case 0x0a: /* Read sector ID */
fdc_rate(fdc, fdc->drive);
fdc->head = (fdc->params[0] & 4) ? 1 : 0;
fdd_set_head(real_drive(fdc, fdc->drive), (fdc->params[0] & 4) ? 1 : 0);
if ((real_drive(fdc, fdc->drive) != 1) || fdc->drv2en) {
fdd_readaddress(real_drive(fdc, fdc->drive), fdc->head, fdc->rate);
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->dma)
fdc->stat = 0x70;
else
fdc->stat = 0x50;
} else
fdc_noidam(fdc);
break;
case 0x0d: /* Format */
fdc_rate(fdc, fdc->drive);
fdc->head = (fdc->params[0] & 4) ? 1 : 0;
fdd_set_head(real_drive(fdc, fdc->drive), (fdc->params[0] & 4) ? 1 : 0);
fdc->gap = fdc->params[3];
fdc->format_sectors = fdc->params[2];
fdc->format_n = fdc->params[1];
fdc->format_state = 1;
fdc->stat = 0x10;
break;
case 0x0f: /* Seek */
fdc->rw_drive = fdc->params[0] & 3;
fdc->stat = (1 << fdc->drive);
if (!(fdc->flags & FDC_FLAG_PCJR))
fdc->stat |= 0x80;
fdc->head = 0; /* TODO: See if this is correct. */
fdc->st0 = fdc->params[0] & 0x03;
fdc->st0 |= (fdc->params[0] & 4);
fdc->st0 |= 0x80;
fdd_set_head(real_drive(fdc, fdc->drive), (fdc->params[0] & 4) ? 1 : 0);
drive_num = real_drive(fdc, fdc->drive);
/* Three conditions under which the command should fail. */
if (!fdd_get_flags(drive_num) || (drive_num >= FDD_NUM) || !motoron[drive_num]) {
/* Yes, failed SEEK's still report success, unlike failed RECALIBRATE's. */
fdc->st0 = 0x20 | (fdc->params[0] & 3);
if (fdc->command & 0x80) {
if (fdc->command & 0x40)
fdc->pcn[fdc->params[0] & 3] += fdc->params[1];
else
fdc->pcn[fdc->params[0] & 3] -= fdc->params[1];
} else
fdc->pcn[fdc->params[0] & 3] = fdc->params[1];
if (fdc->flags & FDC_FLAG_PCJR) {
fdc->fintr = 1;
fdc->interrupt = -4;
} else {
timer_disable(&fdc->timer);
fdc->interrupt = -3;
fdc_callback(fdc);
}
break;
}
if (fdc->command & 0x80) {
if (fdc->params[1]) {
if (fdc->command & 0x40) {
/* Relative seek inwards. */
fdc->seek_dir = 0;
fdc_seek(fdc, fdc->drive, fdc->params[1]);
fdc->pcn[fdc->params[0] & 3] += fdc->params[1];
} else {
/* Relative seek outwards. */
fdc->seek_dir = 1;
fdc_seek(fdc, fdc->drive, -fdc->params[1]);
fdc->pcn[fdc->params[0] & 3] -= fdc->params[1];
}
fdc->step = 1;
} else {
fdc->st0 = 0x20 | (fdc->params[0] & 3);
if (fdc->flags & FDC_FLAG_PCJR) {
fdc->fintr = 1;
fdc->interrupt = -4;
} else {
timer_disable(&fdc->timer);
fdc->interrupt = -3;
fdc_callback(fdc);
}
break;
}
} else {
fdc_log("Seeking to track %i (PCN = %i)...\n", fdc->params[1], fdc->pcn[fdc->params[0] & 3]);
if ((fdc->params[1] - fdc->pcn[fdc->params[0] & 3]) == 0) {
fdc_log("Failed seek\n");
fdc->st0 = 0x20 | (fdc->params[0] & 3);
if (fdc->flags & FDC_FLAG_PCJR) {
fdc->fintr = 1;
fdc->interrupt = -4;
} else {
timer_disable(&fdc->timer);
fdc->interrupt = -3;
fdc_callback(fdc);
}
break;
}
if (fdc->params[1] > fdc->pcn[fdc->params[0] & 3])
fdc->seek_dir = 0;
else
fdc->seek_dir = 1;
fdc_seek(fdc, fdc->drive, fdc->params[1] - fdc->pcn[fdc->params[0] & 3]);
fdc->pcn[fdc->params[0] & 3] = fdc->params[1];
fdc->step = 1;
}
break;
case 0x12: /* Perpendicular mode */
fdc->stat = 0x80;
if (fdc->params[0] & 0x80)
fdc->perp = fdc->params[0] & 0x3f;
else {
fdc->perp &= 0xfc;
fdc->perp |= (fdc->params[0] & 0x03);
}
return;
2023-06-28 13:46:28 -04:00
default:
break;
2022-09-18 17:14:15 -04:00
}
} else
fdc->stat = 0x90 | (fdc->stat & 0xf);
}
return;
case 7:
if (!(fdc->flags & FDC_FLAG_TOSHIBA) && !(fdc->flags & FDC_FLAG_AT) && !(fdc->flags & FDC_FLAG_UMC))
return;
fdc->rate = val & 0x03;
if (fdc->flags & FDC_FLAG_PS2)
2022-09-18 17:14:15 -04:00
fdc->noprec = !!(val & 0x04);
return;
2023-06-28 13:46:28 -04:00
default:
break;
}
}
2018-03-02 19:33:02 +01:00
uint8_t
fdc_read(uint16_t addr, void *priv)
{
2022-09-18 17:14:15 -04:00
fdc_t *fdc = (fdc_t *) priv;
uint8_t ret = 0xff;
int drive = 0;
cycles -= ISA_CYCLES(8);
if (!fdc->power_down || ((addr & 7) == 2)) switch (addr & 7) {
2022-09-18 17:14:15 -04:00
case 0: /* STA */
if (fdc->flags & FDC_FLAG_PS2) {
2022-09-18 17:14:15 -04:00
drive = real_drive(fdc, fdc->dor & 3);
ret = 0x00;
/* TODO:
Bit 2: INDEX (best return always 0 as it goes by very fast)
*/
if (fdc->seek_dir) /* nDIRECTION */
2022-09-18 17:14:15 -04:00
ret |= 0x01;
if (writeprot[drive]) /* WRITEPROT */
2022-09-18 17:14:15 -04:00
ret |= 0x02;
if (!fdd_get_head(drive)) /* nHDSEL */
2022-09-18 17:14:15 -04:00
ret |= 0x08;
if (fdd_track0(drive)) /* TRK0 */
2022-09-18 17:14:15 -04:00
ret |= 0x10;
if (fdc->step) /* STEP */
2022-09-18 17:14:15 -04:00
ret |= 0x20;
if (dma_get_drq(fdc->dma_ch)) /* DRQ */
ret |= 0x40;
if (fdc->fintr || fdc->reset_stat) /* INTR */
ret |= 0x80;
} else if (fdc->flags & FDC_FLAG_PS2_MCA) {
drive = real_drive(fdc, fdc->dor & 3);
ret = 0x04;
/* TODO:
Bit 2: nINDEX (best return always 1 as it goes by very fast)
*/
if (!fdc->seek_dir) /* DIRECTION */
ret |= 0x01;
if (!writeprot[drive]) /* nWRITEPROT */
ret |= 0x02;
if (fdd_get_head(drive)) /* HDSEL */
ret |= 0x08;
if (!fdd_track0(drive)) /* nTRK0 */
ret |= 0x10;
if (fdc->step) /* STEP */
2022-09-18 17:14:15 -04:00
ret |= 0x20;
if (!fdd_get_type(1)) /* -Drive 2 Installed */
2022-09-18 17:14:15 -04:00
ret |= 0x40;
if (fdc->fintr || fdc->reset_stat) /* INTR */
ret |= 0x80;
} else
2022-09-18 17:14:15 -04:00
ret = 0xff;
break;
case 1: /* STB */
if (fdc->flags & FDC_FLAG_PS2) {
2022-09-18 17:14:15 -04:00
drive = real_drive(fdc, fdc->dor & 3);
ret = 0x00;
if (!fdd_get_type(1)) /* -Drive 2 Installed */
2022-09-18 17:14:15 -04:00
ret |= 0x80;
switch (drive) { /* -Drive Select 1,0 */
2022-09-18 17:14:15 -04:00
case 0:
ret |= 0x43;
break;
case 1:
ret |= 0x23;
break;
case 2:
ret |= 0x62;
break;
case 3:
ret |= 0x61;
break;
2023-06-28 13:46:28 -04:00
default:
break;
2022-09-18 17:14:15 -04:00
}
} else if (fdc->flags & FDC_FLAG_PS2_MCA) {
drive = real_drive(fdc, fdc->dor & 3);
ret = 0xc0;
ret |= (fdc->dor & 0x01) << 5; /* Drive Select 0 */
ret |= (fdc->dor & 0x30) >> 4; /* Motor Select 1, 0 */
2022-09-18 17:14:15 -04:00
} else {
if (is486 || !fdc->enable_3f1)
ret = 0xff;
else {
if (fdc->flags & FDC_FLAG_UMC) {
drive = real_drive(fdc, fdc->dor & 1);
ret = !fdd_is_dd(drive) ? ((fdc->dor & 1) ? 2 : 1) : 0;
} else {
/* TODO: What is this and what is it used for?
It's almost identical to the PS/2 MCA mode. */
2022-09-18 17:14:15 -04:00
drive = real_drive(fdc, fdc->dor & 3);
ret = 0x70;
ret &= ~(drive ? 0x40 : 0x20);
ret |= (fdc->dor & 0x30) >> 4; /* Motor Select 1, 0 */
2022-09-18 17:14:15 -04:00
}
}
}
break;
case 2:
ret = fdc->dor;
break;
case 3:
drive = real_drive(fdc, fdc->dor & 3);
/* TODO: FDC_FLAG_PS2_TDR? */
if ((fdc->flags & FDC_FLAG_PS2) || (fdc->flags & FDC_FLAG_PS2_MCA)) {
2022-09-18 17:14:15 -04:00
/* PS/1 Model 2121 seems return drive type in port
* 0x3f3, despite the 82077AA fdc_t not implementing
* this. This is presumably implemented outside the
* fdc_t on one of the motherboard's support chips.
*
* Confirmed: 00=1.44M 3.5
2023-01-06 15:36:05 -05:00
* 10=2.88M 3.5
* 20=1.2M 5.25
* 30=1.2M 5.25
2022-09-18 17:14:15 -04:00
*
* as reported by Configur.exe.
*/
if (fdd_is_525(drive))
ret = 0x20;
else if (fdd_is_ed(drive))
ret = 0x10;
else
ret = 0x00;
/* PS/55 POST throws an error and halt if ret = 1 or 2, somehow. */
} else if (!fdc->enh_mode)
2022-09-18 17:14:15 -04:00
ret = 0x20;
else
ret = fdc->rwc[drive] << 4;
break;
case 4: /*Status*/
ret = fdc->stat;
break;
case 5: /*Data*/
2025-02-17 00:11:33 +09:00
if (fdc->fifointest) {
/* Read FIFO buffer in the test mode (PS/55) */
ret = fifo_read(fdc->fifo_p);
break;
}
2022-09-18 17:14:15 -04:00
if ((fdc->stat & 0xf0) == 0xf0) {
fdc->stat &= ~0x80;
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->fifo) {
fdc->data_ready = 0;
ret = fdc->dat;
} else
ret = fifo_read(fdc->fifo_p);
2022-09-18 17:14:15 -04:00
break;
}
if (fdc->paramstogo) {
fdc->stat &= ~0x80;
2022-09-18 17:14:15 -04:00
fdc_log("%i parameters to go\n", fdc->paramstogo);
fdc->paramstogo--;
ret = fdc->res[10 - fdc->paramstogo];
if (!fdc->paramstogo)
fdc->stat = 0x80;
else
fdc->stat |= 0xC0;
} else if (fdc->dma) {
ret = fdc->dat;
break;
2022-09-18 17:14:15 -04:00
} else {
fdc->stat &= ~0x80;
2022-09-18 17:14:15 -04:00
if (lastbyte)
fdc->stat = 0x80;
lastbyte = 0;
ret = fdc->dat;
fdc->data_ready = 0;
}
fdc->stat &= 0xf0;
break;
case 7: /*Disk change*/
drive = real_drive(fdc, fdc->dor & 3);
if (fdc->flags & FDC_FLAG_PS2) {
2022-09-18 17:14:15 -04:00
if (fdc->dor & (0x10 << drive)) {
ret = (fdd_changed[drive] || drive_empty[drive]) ? 0x00 : 0x80;
ret |= (fdc->dor & 0x08);
ret |= (fdc->noprec << 2);
ret |= (fdc->rate & 0x03);
} else
ret = 0x00;
} else if (fdc->flags & FDC_FLAG_PS2_MCA) {
if (fdc->dor & (0x10 << drive)) {
ret = (fdd_changed[drive] || drive_empty[drive]) ? 0x80 : 0x00;
ret |= ((fdc->rate & 0x03) << 1);
ret |= fdc_get_densel(fdc, drive);
ret |= 0x78;
} else
ret = 0xf9;
2022-09-18 17:14:15 -04:00
} else {
if (fdc->dor & (0x10 << drive)) {
if ((drive == 1) && (fdc->flags & FDC_FLAG_TOSHIBA))
ret = 0x00;
else
ret = (fdd_changed[drive] || drive_empty[drive]) ? 0x80 : 0x00;
} else
ret = 0x00;
if (fdc->flags & FDC_FLAG_DISKCHG_ACTLOW) /*PC2086/3086 seem to reverse this bit*/
ret ^= 0x80;
/* 0 = ????, 1 = Ext. FDD off, 2 = Ext. FDD = FDD A, 3 = Ext. FDD = FDD B */
if (fdc->flags & FDC_FLAG_TOSHIBA) {
ret |= (3 << 5);
ret |= 0x01;
} else
ret |= 0x7F;
}
fdc->step = 0;
break;
default:
ret = 0xFF;
}
fdc_log("[%04X:%08X] Read FDC %04X %02X [%i:%02X]\n", CS, cpu_state.pc, addr, ret, drive, fdc->dor & (0x10 << drive));
return ret;
}
static void
fdc_poll_common_finish(fdc_t *fdc, int compare, int st5)
{
fdc_int(fdc, 1);
if (!(fdc->flags & FDC_FLAG_FINTR))
2022-09-18 17:14:15 -04:00
fdc->fintr = 0;
fdc->stat = 0xD0;
2018-02-02 18:39:48 +01:00
fdc->st0 = fdc->res[4] = (fdd_get_head(real_drive(fdc, fdc->drive)) ? 4 : 0) | fdc->rw_drive;
2022-09-18 17:14:15 -04:00
fdc->res[5] = st5;
fdc->res[6] = 0;
if (fdc->error) {
2022-09-18 17:14:15 -04:00
fdc->error = 0;
fdc->st0 |= 0x40;
2022-09-18 17:14:15 -04:00
fdc->res[4] |= 0x40;
fdc->res[5] |= fdc->st5;
fdc->res[6] |= fdc->st6;
}
if (fdc->wrong_am) {
2022-09-18 17:14:15 -04:00
fdc->res[6] |= 0x40;
fdc->wrong_am = 0;
}
if (compare == 1) {
2022-09-18 17:14:15 -04:00
if (!fdc->satisfying_sectors)
fdc->res[6] |= 4;
else if (fdc->satisfying_sectors == (fdc->params[5] << ((fdc->command & 80) ? 1 : 0)))
fdc->res[6] |= 8;
} else if (compare == 2) {
2022-09-18 17:14:15 -04:00
if (fdc->satisfying_sectors & 1)
fdc->res[5] |= 0x20;
if (fdc->satisfying_sectors & 2) {
fdc->res[5] |= 0x20;
fdc->res[6] |= 0x20;
}
if (fdc->satisfying_sectors & 4)
fdc->res[5] |= 0x04;
if (fdc->satisfying_sectors & 8) {
fdc->res[5] |= 0x04;
fdc->res[6] |= 0x02;
}
if (fdc->satisfying_sectors & 0x10) {
fdc->res[5] |= 0x04;
fdc->res[6] |= 0x10;
}
}
2022-09-18 17:14:15 -04:00
fdc->res[7] = fdc->rw_track;
fdc->res[8] = fdc->head;
fdc->res[9] = fdc->sector;
fdc->res[10] = fdc->params[4];
fdc_log("Read/write finish (%02X %02X %02X %02X %02X %02X %02X)\n", fdc->res[4], fdc->res[5], fdc->res[6], fdc->res[7], fdc->res[8], fdc->res[9], fdc->res[10]);
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
ui_sb_update_icon(SB_FLOPPY | real_drive(fdc, fdc->drive), 0);
fdc->paramstogo = 7;
dma_set_drq(fdc->dma_ch, 0);
}
static void
fdc_poll_readwrite_finish(fdc_t *fdc, int compare)
{
if ((fdc->interrupt == 5) || (fdc->interrupt == 9))
2022-09-18 17:14:15 -04:00
fdd_do_writeback(real_drive(fdc, fdc->drive));
fdc->interrupt = -2;
fdc_poll_common_finish(fdc, compare, 0);
}
static void
fdc_no_dma_end(fdc_t *fdc, int compare)
{
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
timer_disable(&fdc->timer);
fdc_poll_common_finish(fdc, compare, 0x80);
}
static void
fdc_callback(void *priv)
{
2022-09-18 17:14:15 -04:00
fdc_t *fdc = (fdc_t *) priv;
int compare = 0;
int drive_num = 0;
int old_sector = 0;
2018-02-02 05:19:41 +01:00
fdc_log("fdc_callback(): %i\n", fdc->interrupt);
switch (fdc->interrupt) {
2022-09-18 17:14:15 -04:00
case -3: /*End of command with interrupt*/
case -4: /*Recalibrate/seek interrupt (PCjr only)*/
fdc_int(fdc, fdc->interrupt & 1);
fdc->stat = (fdc->stat & 0xf) | 0x80;
return;
case -2: /*End of command*/
fdc->stat = (fdc->stat & 0xf) | 0x80;
return;
case -5: /*Reset in power down mode */
fdc->perp &= 0xfc;
for (uint8_t i = 0; i < FDD_NUM; i++)
ui_sb_update_icon(SB_FLOPPY | i, 0);
fdc_ctrl_reset(fdc);
fdc->fintr = 0;
memset(fdc->pcn, 0x00, 4 * sizeof(uint16_t));
return;
2022-09-18 17:14:15 -04:00
case -1: /*Reset*/
fdc_int(fdc, 1);
fdc->fintr = 0;
memset(fdc->pcn, 0x00, 4 * sizeof(uint16_t));
2022-09-18 17:14:15 -04:00
fdc->reset_stat = 4;
return;
case -6: /*DSR Reset clear*/
fdc->dsr |= 0x80;
return;
2022-09-18 17:14:15 -04:00
case 0x01: /* Mode */
fdc->stat = 0x80;
fdc->densel_force = (fdc->params[2] & 0xC0) >> 6;
return;
case 0x02: /* Read track */
ui_sb_update_icon(SB_FLOPPY | real_drive(fdc, fdc->drive), 1);
fdc->eot[fdc->drive]--;
fdc->read_track_sector.id.r++;
if (!fdc->eot[fdc->drive] || fdc->tc) {
fdc_poll_readwrite_finish(fdc, 2);
return;
} else {
fdd_readsector(real_drive(fdc, fdc->drive), SECTOR_NEXT, fdc->rw_track, fdc->head, fdc->rate, fdc->params[4]);
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->dma)
fdc->stat = 0x70;
else {
dma_set_drq(fdc->dma_ch, 1);
fdc->stat = 0x50;
}
}
return;
case 0x04: /* Sense drive status */
fdc->res[10] = (fdc->params[0] & 7) | 0x20;
if (fdd_is_double_sided(real_drive(fdc, fdc->drive)))
fdc->res[10] |= 0x08;
if ((real_drive(fdc, fdc->drive) != 1) || fdc->drv2en) {
if (fdd_track0(real_drive(fdc, fdc->drive)))
fdc->res[10] |= 0x10;
}
if (writeprot[fdc->drive])
fdc->res[10] |= 0x40;
fdc->stat = (fdc->stat & 0xf) | 0xd0;
fdc->paramstogo = 1;
fdc->interrupt = 0;
return;
case 0x05: /* Write data */
case 0x09: /* Write deleted data */
case 0x06: /* Read data */
case 0x0c: /* Read deleted data */
case 0x11: /* Scan equal */
case 0x19: /* Scan low or equal */
case 0x1c: /* Verify */
case 0x1d: /* Scan high or equal */
if ((fdc->interrupt == 0x11) || (fdc->interrupt == 0x19) || (fdc->interrupt == 0x1D))
compare = 1;
else
compare = 0;
if ((fdc->interrupt == 6) || (fdc->interrupt == 0xC)) {
if (fdc->wrong_am && !(fdc->deleted & 0x20)) {
/* Mismatching data address mark and no skip, set TC. */
fdc->tc = 1;
}
}
old_sector = fdc->sector;
if (fdc->tc) {
/* This is needed so that the correct results are returned
in case of TC. */
if (fdc->sector == fdc->params[5]) {
if (!(fdc->command & 0x80)) {
fdc->rw_track++;
fdc->sector = 1;
} else {
if (fdc->head)
fdc->rw_track++;
fdc->head ^= 1;
fdd_set_head(real_drive(fdc, fdc->drive), fdc->head);
fdc->sector = 1;
}
} else
fdc->sector++;
fdc_poll_readwrite_finish(fdc, compare);
return;
}
if ((fdc->interrupt == 0x16) && (fdc->params[0] & 0x80)) {
/* VERIFY command, EC set */
fdc->sc--;
if (!fdc->sc) {
fdc->sector++;
fdc_poll_readwrite_finish(fdc, 0);
return;
}
/* The rest is processed normally per MT flag and EOT. */
} else if ((fdc->interrupt == 0x16) && !(fdc->params[0] & 0x80)) {
/* VERIFY command, EC clear */
if ((fdc->sector == old_sector) && (fdc->head == (fdc->command & 0x80) ? 1 : 0)) {
fdc->sector++;
fdc_poll_readwrite_finish(fdc, 0);
return;
}
}
if (fdc->sector == fdc->params[5]) {
/* Reached end of track, MT bit is clear */
if (!(fdc->command & 0x80)) {
if (fdc->dma) {
fdc->rw_track++;
fdc->sector = 1;
}
2022-09-18 17:14:15 -04:00
if (!(fdc->flags & FDC_FLAG_PCJR) && fdc->dma && (old_sector == 255))
fdc_no_dma_end(fdc, compare);
else
fdc_poll_readwrite_finish(fdc, compare);
return;
}
/* Reached end of track, MT bit is set, head is 1 */
if (fdd_get_head(real_drive(fdc, fdc->drive)) == 1) {
if (fdc->dma) {
fdc->rw_track++;
fdc->sector = 1;
fdc->head &= 0xFE;
fdd_set_head(real_drive(fdc, fdc->drive), 0);
}
2022-09-18 17:14:15 -04:00
if (!(fdc->flags & FDC_FLAG_PCJR) && fdc->dma && (old_sector == 255))
fdc_no_dma_end(fdc, compare);
else
fdc_poll_readwrite_finish(fdc, compare);
return;
}
2023-05-16 15:43:20 -04:00
if (fdd_get_head(real_drive(fdc, fdc->drive)) == 0) {
fdc->sector = 1;
fdc->head |= 1;
2022-09-18 17:14:15 -04:00
fdd_set_head(real_drive(fdc, fdc->drive), 1);
if (!fdd_is_double_sided(real_drive(fdc, fdc->drive))) {
fdc_noidam(fdc);
return;
}
}
} else if (fdc->sector < fdc->params[5])
fdc->sector++;
else if (fdc->params[5] == 0)
fdc->sector++;
2022-09-18 17:14:15 -04:00
ui_sb_update_icon(SB_FLOPPY | real_drive(fdc, fdc->drive), 1);
switch (fdc->interrupt) {
case 5:
case 9:
fdd_writesector(real_drive(fdc, fdc->drive), fdc->sector, fdc->rw_track, fdc->head, fdc->rate, fdc->params[4]);
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->dma)
fdc->stat = 0xb0;
else {
dma_set_drq(fdc->dma_ch, 1);
fdc->stat = 0x10;
2022-09-18 17:14:15 -04:00
}
break;
case 6:
case 0xC:
case 0x16:
fdd_readsector(real_drive(fdc, fdc->drive), fdc->sector, fdc->rw_track, fdc->head, fdc->rate, fdc->params[4]);
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->dma)
fdc->stat = 0x70;
else {
dma_set_drq(fdc->dma_ch, 1);
fdc->stat = 0x50;
}
break;
case 0x11:
case 0x19:
case 0x1D:
fdd_comparesector(real_drive(fdc, fdc->drive), fdc->sector, fdc->rw_track, fdc->head, fdc->rate, fdc->params[4]);
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->dma)
fdc->stat = 0xb0;
else {
dma_set_drq(fdc->dma_ch, 1);
fdc->stat = 0x10;
2022-09-18 17:14:15 -04:00
}
break;
2023-06-28 13:46:28 -04:00
default:
break;
2022-09-18 17:14:15 -04:00
}
return;
case 0x07: /* Recalibrate */
fdc->pcn[fdc->params[0] & 3] = 0;
drive_num = real_drive(fdc, fdc->rw_drive);
fdc->st0 = 0x20 | (fdc->params[0] & 3);
if (!fdd_track0(drive_num))
fdc->st0 |= 0x50;
if (fdc->flags & FDC_FLAG_PCJR) {
fdc->fintr = 1;
fdc->interrupt = -4;
} else
fdc->interrupt = -3;
timer_set_delay_u64(&fdc->timer, 2048 * TIMER_USEC);
fdc->stat = 0x80 | (1 << fdc->rw_drive);
return;
case 0x0d: /*Format track*/
if (fdc->format_state == 1) {
fdc->format_state = 2;
timer_set_delay_u64(&fdc->timer, 8 * TIMER_USEC);
} else if (fdc->format_state == 2) {
fdd_format(real_drive(fdc, fdc->drive), fdc->head, fdc->rate, fdc->params[4]);
fdc->format_state = 3;
} else {
fdc->interrupt = -2;
fdc_int(fdc, 1);
if (!(fdc->flags & FDC_FLAG_FINTR))
2022-09-18 17:14:15 -04:00
fdc->fintr = 0;
fdc->stat = 0xD0;
fdc->st0 = fdc->res[4] = (fdd_get_head(real_drive(fdc, fdc->drive)) ? 4 : 0) | fdc->drive;
fdc->res[5] = fdc->res[6] = 0;
fdc->res[7] = fdc->format_sector_id.id.c;
fdc->res[8] = fdc->format_sector_id.id.h;
fdc->res[9] = fdc->format_sector_id.id.r;
fdc->res[10] = fdc->format_sector_id.id.n;
fdc->paramstogo = 7;
fdc->format_state = 0;
return;
}
return;
case 0x0e: /*Dump registers*/
fdc->stat = (fdc->stat & 0xf) | 0xd0;
fdc->res[1] = fdc->pcn[0];
fdc->res[2] = fdc->pcn[1];
fdc->res[3] = fdc->pcn[2];
fdc->res[4] = fdc->pcn[3];
fdc->res[5] = fdc->specify[0];
fdc->res[6] = fdc->specify[1];
fdc->res[7] = fdc->eot[fdc->drive];
fdc->res[8] = (fdc->perp & 0x7f) | ((fdc->lock) ? 0x80 : 0);
fdc->res[9] = fdc->config;
fdc->res[10] = fdc->pretrk;
fdc->paramstogo = 10;
fdc->interrupt = 0;
return;
case 0x0f: /*Seek*/
fdc->st0 = 0x20 | (fdc->params[0] & 3);
fdc->stat = 0x80 | (1 << fdc->rw_drive);
if (fdc->flags & FDC_FLAG_PCJR) {
fdc->fintr = 1;
fdc->interrupt = -4;
timer_set_delay_u64(&fdc->timer, 1024 * TIMER_USEC);
} else {
fdc->interrupt = -3;
fdc_callback(fdc);
}
return;
case 0x10: /*Version*/
case 0x18: /*NSC*/
fdc->stat = (fdc->stat & 0xf) | 0xd0;
fdc->res[10] = (fdc->interrupt & 0x08) ? 0x73 : 0x90;
fdc->paramstogo = 1;
fdc->interrupt = 0;
return;
case 0x17: /*Powerdown mode*/
fdc->stat = (fdc->stat & 0xf) | 0xd0;
fdc->res[10] = fdc->params[0];
fdc->paramstogo = 1;
fdc->interrupt = 0;
return;
case 0x13: /*Configure*/
fdc->config = fdc->params[1];
fdc->pretrk = fdc->params[2];
fdc->fifo = (fdc->params[1] & 0x20) ? 0 : 1;
fdc->tfifo = (fdc->params[1] & 0xF);
fifo_reset(fdc->fifo_p);
fifo_set_len(fdc->fifo_p, fdc->tfifo + 1);
fifo_set_trigger_len(fdc->fifo_p, fdc->tfifo + 1);
2022-09-18 17:14:15 -04:00
fdc->stat = 0x80;
return;
case 0x14: /*Unlock*/
case 0x94: /*Lock*/
fdc->lock = (fdc->interrupt & 0x80) ? 1 : 0;
fdc->stat = (fdc->stat & 0xf) | 0xd0;
fdc->res[10] = (fdc->interrupt & 0x80) ? 0x10 : 0x00;
fdc->paramstogo = 1;
fdc->interrupt = 0;
return;
case 0xfc: /*Invalid*/
fdc->dat = fdc->st0 = 0x80;
fdc->stat = (fdc->stat & 0xf) | 0xd0;
fdc->res[10] = fdc->st0;
fdc->paramstogo = 1;
fdc->interrupt = 0;
return;
2023-06-28 13:46:28 -04:00
default:
break;
}
}
void
fdc_error(fdc_t *fdc, int st5, int st6)
{
dma_set_drq(fdc->dma_ch, 0);
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
timer_disable(&fdc->timer);
fdc_int(fdc, 1);
if (!(fdc->flags & FDC_FLAG_FINTR))
2022-09-18 17:14:15 -04:00
fdc->fintr = 0;
fdc->stat = 0xD0;
2018-02-02 18:39:48 +01:00
fdc->st0 = fdc->res[4] = 0x40 | (fdd_get_head(real_drive(fdc, fdc->drive)) ? 4 : 0) | fdc->rw_drive;
if (fdc->head && !fdd_is_double_sided(real_drive(fdc, fdc->drive)))
2022-09-18 17:14:15 -04:00
fdc->st0 |= 0x08;
fdc->res[5] = st5;
fdc->res[6] = st6;
if (fdc->wrong_am) {
fdc->res[6] |= 0x40;
fdc->wrong_am = 0;
}
fdc_log("FDC Error: %02X %02X %02X\n", fdc->res[4], fdc->res[5], fdc->res[6]);
2022-09-18 17:14:15 -04:00
switch (fdc->interrupt) {
case 0x02:
case 0x05:
case 0x06:
case 0x09:
case 0x0C:
case 0x11:
case 0x16:
case 0x19:
case 0x1D:
fdc->res[7] = fdc->rw_track;
fdc->res[8] = fdc->head;
fdc->res[9] = fdc->sector;
fdc->res[10] = fdc->params[4];
break;
default:
fdc->res[7] = 0;
fdc->res[8] = 0;
fdc->res[9] = 0;
fdc->res[10] = 0;
break;
}
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
ui_sb_update_icon(SB_FLOPPY | real_drive(fdc, fdc->drive), 0);
fdc->paramstogo = 7;
}
void
fdc_overrun(fdc_t *fdc)
{
fdd_stop(fdc->drive);
fdc_error(fdc, 0x10, 0);
}
int
fdc_is_verify(fdc_t *fdc)
{
return (fdc->deleted & 2) ? 1 : 0;
}
int
fdc_data(fdc_t *fdc, uint8_t data, int last)
{
2023-05-16 15:43:20 -04:00
int result = 0;
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
if (fdc->deleted & 2) {
2022-09-18 17:14:15 -04:00
/* We're in a VERIFY command, so return with 0. */
return 0;
}
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->dma) {
2022-09-18 17:14:15 -04:00
if (fdc->tc)
return 0;
if (fdc->data_ready) {
fdc_overrun(fdc);
return -1;
}
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->fifo || (fdc->tfifo < 1)) {
fdc->dat = data;
fdc->data_ready = 1;
fdc->stat = 0xf0;
} else {
/* FIFO enabled */
fifo_write(data, fdc->fifo_p);
if (fifo_get_full(fdc->fifo_p)) {
2022-09-18 17:14:15 -04:00
/* We have wrapped around, means FIFO is over */
fdc->data_ready = 1;
fdc->stat = 0xf0;
}
}
} else {
2022-09-18 17:14:15 -04:00
if (fdc->tc)
return -1;
if (!fdc->fifo || (fdc->tfifo < 1)) {
fdc->data_ready = 1;
fdc->stat = 0x50;
2022-09-18 17:14:15 -04:00
dma_set_drq(fdc->dma_ch, 1);
fdc->dat = data;
2022-09-18 17:14:15 -04:00
result = dma_channel_write(fdc->dma_ch, data);
if (result & DMA_OVER) {
dma_set_drq(fdc->dma_ch, 0);
fdc->tc = 1;
return -1;
}
dma_set_drq(fdc->dma_ch, 0);
} else {
/* FIFO enabled */
fifo_write(data, fdc->fifo_p);
if (last || fifo_get_full(fdc->fifo_p)) {
2022-09-18 17:14:15 -04:00
/* We have wrapped around, means FIFO is over */
fdc->data_ready = 1;
fdc->stat = 0x50;
2022-09-18 17:14:15 -04:00
dma_set_drq(fdc->dma_ch, 1);
while (!fifo_get_empty(fdc->fifo_p)) {
result = dma_channel_write(fdc->dma_ch, fifo_read(fdc->fifo_p));
2022-09-18 17:14:15 -04:00
if (result & DMA_OVER) {
dma_set_drq(fdc->dma_ch, 0);
fdc->tc = 1;
return -1;
}
}
dma_set_drq(fdc->dma_ch, 0);
}
}
}
return 0;
}
void
fdc_track_finishread(fdc_t *fdc, int condition)
{
fdc->stat = 0x10;
fdc->satisfying_sectors |= condition;
fdc_callback(fdc);
}
void
fdc_sector_finishcompare(fdc_t *fdc, int satisfying)
{
fdc->stat = 0x10;
2020-06-28 13:39:29 +02:00
if (satisfying)
2022-09-18 17:14:15 -04:00
fdc->satisfying_sectors++;
fdc_callback(fdc);
}
void
fdc_sector_finishread(fdc_t *fdc)
{
2022-09-18 17:14:15 -04:00
fdc->stat = 0x10;
fdc_callback(fdc);
}
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
/* There is no sector ID. */
void
fdc_noidam(fdc_t *fdc)
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
{
fdc_error(fdc, 1, 0);
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
}
/* Sector ID's are there, but there is no sector. */
2022-09-18 17:14:15 -04:00
void
fdc_nosector(fdc_t *fdc)
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
{
fdc_error(fdc, 4, 0);
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
}
/* There is no sector data. */
2022-09-18 17:14:15 -04:00
void
fdc_nodataam(fdc_t *fdc)
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
{
fdc_error(fdc, 1, 1);
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
}
/* Abnormal termination with both status 1 and 2 set to 0, used when abnormally
terminating the fdc_t FORMAT TRACK command. */
2022-09-18 17:14:15 -04:00
void
fdc_cannotformat(fdc_t *fdc)
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
{
fdc_error(fdc, 0, 0);
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
}
void
fdc_datacrcerror(fdc_t *fdc)
{
fdc_error(fdc, 0x20, 0x20);
}
void
fdc_headercrcerror(fdc_t *fdc)
{
fdc_error(fdc, 0x20, 0);
}
void
fdc_wrongcylinder(fdc_t *fdc)
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
{
fdc_error(fdc, 4, 0x10);
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
}
void
fdc_badcylinder(fdc_t *fdc)
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
{
fdc_error(fdc, 4, 0x02);
Applied all mainline PCem commits; Added experimental NVidia Riva TNT2 emulation (patch from MoochMcGee); ASUS P/I-P54TP4XE, ASUS P/I-P55T2P4, and ASUS P/I-P55TVP4 are back; National Semiconductor PC87306 Super I/O chip now correctly reenables devices after a chip power cycle; Several FDC improvements and the behavior is now a bit closer to real hardware (based on actual tests); Added MR Intel Advanced/ATX with Microid Research BIOS with support for 4 floppy drives and up to 4 IDE controllers; Added floppy drives 3 and 4, bringing the maximum to 4; You can now connect hard disks to the tertiary IDE controller; Correct undocumented behavior of the LEA instruction with register is back on 286 and later CPU's; Pentium-rea models with Intel chipsets now have port 92 (with alternate reset and alternate A20 toggle); Overhauled DMA channel read and write routines and fixed cascading; Improved IMG detection of a bad BPB (or complete lack of a BPB); Added preliminary emulation of PS/2 1.44 MB and PC-98 1.25 MB 3-mode drives (both have an inverted DENSEL pin); Removed the incorrect Amstrad mouse patch from TheCollector1995; Fixed ATAPI CD-ROM disk change detection; Windows IOCTL CD-ROM handler now tries to use direct SCSI passthrough for more things, including obtaining CD-ROM capacity; The Diamond Stealth32 (ET4000/W32p) now also works correctly on the two Award SiS 496/497 boxes; The (S)VGA handler now converts 6-bit RAMDAC RGB channels to standard 8-bit RGB using a lookup table generated at emulator start, calculated using the correct intensity conversion method and treating intensity 64 as equivalent to 63; Moved a few options from the Configuration dialog box to the menu; SIO, PIIX, and PIIX3 now have the reset control register on port CF9 as they should; Several bugfixes.
2016-12-23 03:16:24 +01:00
}
void
fdc_writeprotect(fdc_t *fdc)
{
fdc_error(fdc, 0x02, 0);
}
2022-09-18 17:14:15 -04:00
int
fdc_getdata(fdc_t *fdc, int last)
{
2023-05-16 15:43:20 -04:00
int data = 0;
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->dma) {
2022-09-18 17:14:15 -04:00
if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->fifo || (fdc->tfifo < 1)) {
data = fdc->dat;
2022-09-18 17:14:15 -04:00
if (!last)
fdc->stat = 0xb0;
} else {
data = fifo_read(fdc->fifo_p);
if (!last && fifo_get_empty(fdc->fifo_p))
2022-09-18 17:14:15 -04:00
fdc->stat = 0xb0;
}
} else {
2022-09-18 17:14:15 -04:00
if (!fdc->fifo || (fdc->tfifo < 1)) {
data = dma_channel_read(fdc->dma_ch);
dma_set_drq(fdc->dma_ch, 0);
if (data & DMA_OVER)
fdc->tc = 1;
if (!last) {
dma_set_drq(fdc->dma_ch, 1);
fdc->stat = 0x10;
2022-09-18 17:14:15 -04:00
}
} else {
if (fifo_get_empty(fdc->fifo_p)) {
while (!fifo_get_full(fdc->fifo_p)) {
2022-09-18 17:14:15 -04:00
data = dma_channel_read(fdc->dma_ch);
fifo_write(data, fdc->fifo_p);
2022-09-18 17:14:15 -04:00
if (data & DMA_OVER) {
dma_set_drq(fdc->dma_ch, 0);
fdc->tc = 1;
break;
}
}
dma_set_drq(fdc->dma_ch, 0);
}
data = fifo_read(fdc->fifo_p);
2022-09-18 17:14:15 -04:00
if (!last && fifo_get_empty(fdc->fifo_p)) {
2022-09-18 17:14:15 -04:00
dma_set_drq(fdc->dma_ch, 1);
fdc->stat = 0x10;
2022-09-18 17:14:15 -04:00
}
}
}
return data & 0xff;
}
void
2023-06-26 12:47:04 -04:00
fdc_sectorid(fdc_t *fdc, uint8_t track, uint8_t side, uint8_t sector, uint8_t size, UNUSED(uint8_t crc1), UNUSED(uint8_t crc2))
{
fdc_int(fdc, 1);
fdc->stat = 0xD0;
2018-02-02 18:39:48 +01:00
fdc->st0 = fdc->res[4] = (fdd_get_head(real_drive(fdc, fdc->drive)) ? 4 : 0) | fdc->drive;
2022-09-18 17:14:15 -04:00
fdc->res[5] = 0;
fdc->res[6] = 0;
fdc->res[7] = track;
fdc->res[8] = side;
fdc->res[9] = sector;
fdc->res[10] = size;
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
ui_sb_update_icon(SB_FLOPPY | real_drive(fdc, fdc->drive), 0);
fdc->paramstogo = 7;
dma_set_drq(fdc->dma_ch, 0);
}
uint8_t
fdc_get_swwp(fdc_t *fdc)
{
return fdc->swwp;
}
void
fdc_set_swwp(fdc_t *fdc, uint8_t swwp)
{
fdc->swwp = swwp;
}
uint8_t
fdc_get_diswr(fdc_t *fdc)
{
if (!fdc)
2022-09-18 17:14:15 -04:00
return 0;
return fdc->disable_write;
}
void
fdc_set_diswr(fdc_t *fdc, uint8_t diswr)
{
fdc->disable_write = diswr;
}
uint8_t
fdc_get_swap(fdc_t *fdc)
{
return fdc->swap;
}
void
fdc_set_swap(fdc_t *fdc, uint8_t swap)
{
fdc->swap = swap;
}
2020-02-29 19:12:23 +01:00
void
fdc_set_irq(fdc_t *fdc, int irq)
{
fdc->irq = irq;
}
void
fdc_set_dma_ch(fdc_t *fdc, int dma_ch)
{
fdc->dma_ch = dma_ch;
}
void
fdc_set_base(fdc_t *fdc, int base)
{
int super_io = (fdc->flags & FDC_FLAG_SUPERIO);
2022-09-18 17:14:15 -04:00
if (fdc->flags & FDC_FLAG_NSC) {
io_sethandler(base + 2, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
io_sethandler(base + 4, 0x0002, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
io_sethandler(base + 7, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
} else {
2022-09-18 17:14:15 -04:00
if ((fdc->flags & FDC_FLAG_AT) || (fdc->flags & FDC_FLAG_AMSTRAD)) {
io_sethandler(base + (super_io ? 2 : 0), super_io ? 0x0004 : 0x0006, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
io_sethandler(base + 7, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
} else {
if (fdc->flags & FDC_FLAG_PCJR)
io_sethandler(base, 0x0010, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
else {
if (fdc->flags & FDC_FLAG_UMC)
io_sethandler(base + 0x0001, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc);
io_sethandler(base + 0x0002, 0x0001, NULL, NULL, NULL, fdc_write, NULL, NULL, fdc);
io_sethandler(base + 0x0004, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc);
io_sethandler(base + 0x0005, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
if ((fdc->flags & FDC_FLAG_TOSHIBA) || (fdc->flags & FDC_FLAG_UMC))
io_sethandler(base + 0x0007, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
}
}
}
fdc->base_address = base;
fdc_log("FDC Base address set%s (%04X)\n", super_io ? " for Super I/O" : "", fdc->base_address);
}
void
fdc_remove(fdc_t *fdc)
{
int super_io = (fdc->flags & FDC_FLAG_SUPERIO);
fdc_log("FDC Removed (%04X)\n", fdc->base_address);
2022-09-18 17:14:15 -04:00
if (fdc->flags & FDC_FLAG_NSC) {
io_removehandler(fdc->base_address + 2, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
io_removehandler(fdc->base_address + 4, 0x0002, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
io_removehandler(fdc->base_address + 7, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
} else {
2022-09-18 17:14:15 -04:00
if ((fdc->flags & FDC_FLAG_AT) || (fdc->flags & FDC_FLAG_AMSTRAD)) {
io_removehandler(fdc->base_address + (super_io ? 2 : 0), super_io ? 0x0004 : 0x0006, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
io_removehandler(fdc->base_address + 7, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
} else {
if (fdc->flags & FDC_FLAG_PCJR)
io_removehandler(fdc->base_address, 0x0010, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
else {
if (fdc->flags & FDC_FLAG_UMC)
io_removehandler(fdc->base_address + 0x0001, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc);
io_removehandler(fdc->base_address + 0x0002, 0x0001, NULL, NULL, NULL, fdc_write, NULL, NULL, fdc);
io_removehandler(fdc->base_address + 0x0004, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc);
io_removehandler(fdc->base_address + 0x0005, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
if ((fdc->flags & FDC_FLAG_TOSHIBA) || (fdc->flags & FDC_FLAG_UMC))
io_removehandler(fdc->base_address + 0x0007, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc);
}
}
}
}
void
fdc_reset(void *priv)
{
uint8_t default_rwc;
fdc_t *fdc = (fdc_t *) priv;
default_rwc = (fdc->flags & FDC_FLAG_START_RWC_1) ? 1 : 0;
fdc->enable_3f1 = 1;
fdc_update_enh_mode(fdc, 0);
if (fdc->flags & FDC_FLAG_DENSEL_INVERT)
2022-09-18 17:14:15 -04:00
fdc_update_densel_polarity(fdc, 0);
else
2022-09-18 17:14:15 -04:00
fdc_update_densel_polarity(fdc, 1);
if (fdc->flags & FDC_FLAG_NSC)
2022-09-18 17:14:15 -04:00
fdc_update_densel_force(fdc, 3);
else
2022-09-18 17:14:15 -04:00
fdc_update_densel_force(fdc, 0);
fdc_update_rwc(fdc, 0, default_rwc);
fdc_update_rwc(fdc, 1, default_rwc);
fdc_update_rwc(fdc, 2, default_rwc);
fdc_update_rwc(fdc, 3, default_rwc);
fdc_update_drvrate(fdc, 0, 0);
fdc_update_drvrate(fdc, 1, 0);
fdc_update_drvrate(fdc, 2, 0);
fdc_update_drvrate(fdc, 3, 0);
fdc_update_drv2en(fdc, 1);
fdc_update_rates(fdc);
2022-09-18 17:14:15 -04:00
fdc->fifo = 0;
fdc->tfifo = 1;
fdc->fifointest = 0;
if (fdc->flags & FDC_FLAG_PCJR) {
2022-09-18 17:14:15 -04:00
fdc->dma = 0;
fdc->specify[1] = 1;
2022-12-20 21:23:55 -05:00
} 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 {
2022-09-18 17:14:15 -04:00
fdc->dma = 1;
fdc->specify[1] = 0;
}
fdc->config = 0x20;
fdc->pretrk = 0;
2022-09-18 17:14:15 -04:00
fdc->swwp = 0;
fdc->disable_write = 0;
fdc_ctrl_reset(fdc);
if (!(fdc->flags & FDC_FLAG_AT))
fdc->rate = 2;
fdc->max_track = (fdc->flags & FDC_FLAG_MORE_TRACKS) ? 85 : 79;
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);
current_drive = 0;
2023-05-16 15:43:20 -04:00
for (uint8_t i = 0; i < FDD_NUM; i++)
2022-09-18 17:14:15 -04:00
ui_sb_update_icon(SB_FLOPPY | i, 0);
fdc->power_down = 0;
}
static void
fdc_close(void *priv)
{
fdc_t *fdc = (fdc_t *) priv;
/* Stop timers. */
timer_disable(&fdc->watchdog_timer);
timer_disable(&fdc->timer);
fifo_close(fdc->fifo_p);
free(fdc);
}
static void *
fdc_init(const device_t *info)
{
2025-01-07 00:42:06 -05:00
fdc_t *fdc = (fdc_t *) calloc(1, sizeof(fdc_t));
fdc->flags = info->local;
if (fdc->flags & FDC_FLAG_SEC)
fdc->irq = FDC_SECONDARY_IRQ;
2023-02-03 01:03:55 -05:00
else if (fdc->flags & FDC_FLAG_TER)
fdc->irq = FDC_TERTIARY_IRQ;
else if (fdc->flags & FDC_FLAG_QUA)
fdc->irq = FDC_QUATERNARY_IRQ;
else
fdc->irq = FDC_PRIMARY_IRQ;
if (fdc->flags & FDC_FLAG_PCJR)
2022-09-18 17:14:15 -04:00
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
2022-09-18 17:14:15 -04:00
fdc->dma_ch = FDC_PRIMARY_DMA;
fdc_log("FDC added: %04X (flags: %08X)\n", fdc->base_address, fdc->flags);
fdc->fifo_p = (void *) fifo16_init();
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
timer_add(&fdc->timer, fdc_callback, fdc, 0);
d86f_set_fdc(fdc);
fdi_set_fdc(fdc);
fdd_set_fdc(fdc);
imd_set_fdc(fdc);
img_set_fdc(fdc);
mfm_set_fdc(fdc);
fdc_reset(fdc);
return fdc;
}
void
fdc_3f1_enable(fdc_t *fdc, int enable)
{
fdc->enable_3f1 = !!enable;
}
const device_t fdc_xt_device = {
2022-09-18 17:14:15 -04:00
.name = "PC/XT Floppy Drive Controller",
2022-03-13 09:38:53 -04:00
.internal_name = "fdc_xt",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = 0,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-03-13 09:38:53 -04:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_xt_sec_device = {
2022-11-19 08:49:04 -05:00
.name = "PC/XT Floppy Drive Controller (Secondary)",
2023-02-03 01:03:55 -05:00
.internal_name = "fdc_xt_sec",
2022-11-19 08:49:04 -05:00
.flags = FDC_FLAG_SEC,
.local = 0,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
.speed_changed = NULL,
2022-11-19 08:49:04 -05:00
.force_redraw = NULL,
.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,
2025-01-07 01:12:42 -05:00
.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,
2025-01-07 01:12:42 -05:00
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_xt_t1x00_device = {
2022-09-18 17:14:15 -04:00
.name = "PC/XT Floppy Drive Controller (Toshiba)",
2022-03-13 09:38:53 -04:00
.internal_name = "fdc_xt_t1x00",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = FDC_FLAG_TOSHIBA,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-03-13 09:38:53 -04:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
};
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
const device_t fdc_xt_amstrad_device = {
2022-09-18 17:14:15 -04:00
.name = "PC/XT Floppy Drive Controller (Amstrad)",
2022-03-13 09:38:53 -04:00
.internal_name = "fdc_xt_amstrad",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = FDC_FLAG_DISKCHG_ACTLOW | FDC_FLAG_AMSTRAD,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-03-13 09:38:53 -04:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
};
const device_t fdc_xt_tandy_device = {
2022-09-18 17:14:15 -04:00
.name = "PC/XT Floppy Drive Controller (Tandy)",
2022-03-13 09:38:53 -04:00
.internal_name = "fdc_xt_tandy",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = FDC_FLAG_AMSTRAD,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-03-13 09:38:53 -04:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_xt_umc_um8398_device = {
.name = "PC/XT Floppy Drive Controller (UMC UM8398)",
.internal_name = "fdc_xt_umc_um8398",
.flags = 0,
.local = FDC_FLAG_UMC,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-03-13 09:38:53 -04:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_pcjr_device = {
2022-09-18 17:14:15 -04:00
.name = "PCjr Floppy Drive Controller",
2022-03-13 09:38:53 -04:00
.internal_name = "fdc_pcjr",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = FDC_FLAG_PCJR,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-03-13 09:38:53 -04:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_at_device = {
2022-09-18 17:14:15 -04:00
.name = "PC/AT Floppy Drive Controller",
2022-03-13 09:38:53 -04:00
.internal_name = "fdc_at",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = FDC_FLAG_AT,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-03-13 09:38:53 -04:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_at_sec_device = {
2022-11-19 08:49:04 -05:00
.name = "PC/AT Floppy Drive Controller (Secondary)",
.internal_name = "fdc_at_sec",
2022-11-19 08:49:04 -05:00
.flags = 0,
.local = FDC_FLAG_AT | FDC_FLAG_SEC,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
.speed_changed = NULL,
2022-11-19 08:49:04 -05:00
.force_redraw = NULL,
.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,
2025-01-07 01:12:42 -05:00
.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,
2025-01-07 01:12:42 -05:00
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_at_actlow_device = {
2022-09-18 17:14:15 -04:00
.name = "PC/AT Floppy Drive Controller (Active low)",
2022-03-13 09:38:53 -04:00
.internal_name = "fdc_at_actlow",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = FDC_FLAG_DISKCHG_ACTLOW | FDC_FLAG_AT,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2024-04-18 03:50:48 +02:00
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_at_smc_device = {
2022-09-18 17:14:15 -04:00
.name = "PC/AT Floppy Drive Controller (SM(s)C FDC37Cxxx)",
2022-03-13 09:38:53 -04:00
.internal_name = "fdc_at_smc",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = FDC_FLAG_AT | FDC_FLAG_SUPERIO,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-03-13 09:38:53 -04:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
};
2022-07-23 03:19:51 +02:00
const device_t fdc_at_ali_device = {
2022-09-18 17:14:15 -04:00
.name = "PC/AT Floppy Drive Controller (ALi M512x/M1543C)",
2022-07-23 03:19:51 +02:00
.internal_name = "fdc_at_ali",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = FDC_FLAG_AT | FDC_FLAG_SUPERIO | FDC_FLAG_ALI,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-07-23 03:19:51 +02:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
2022-07-23 03:19:51 +02:00
};
const device_t fdc_at_winbond_device = {
2022-09-18 17:14:15 -04:00
.name = "PC/AT Floppy Drive Controller (Winbond W83x77F)",
2022-03-13 09:38:53 -04:00
.internal_name = "fdc_at_winbond",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = FDC_FLAG_AT | FDC_FLAG_SUPERIO | FDC_FLAG_START_RWC_1 | FDC_FLAG_MORE_TRACKS,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-03-13 09:38:53 -04:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_at_nsc_device = {
2022-09-18 17:14:15 -04:00
.name = "PC/AT Floppy Drive Controller (NSC PC8730x)",
2022-03-13 09:38:53 -04:00
.internal_name = "fdc_at_nsc",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = FDC_FLAG_AT | FDC_FLAG_MORE_TRACKS | FDC_FLAG_NSC,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-03-13 09:38:53 -04:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_at_nsc_dp8473_device = {
.name = "PC/AT Floppy Drive Controller (NSC DP8473)",
.internal_name = "fdc_at_nsc_dp8473",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = FDC_FLAG_AT | FDC_FLAG_NEC | FDC_FLAG_NO_DSR_RESET,
2022-09-18 17:14:15 -04:00
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-03-13 09:38:53 -04:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_ps2_device = {
.name = "PS/2 Model 25/30 Floppy Drive Controller",
.internal_name = "fdc_ps2",
2022-09-18 17:14:15 -04:00
.flags = 0,
.local = FDC_FLAG_FINTR | FDC_FLAG_DENSEL_INVERT | FDC_FLAG_NO_DSR_RESET | FDC_FLAG_DISKCHG_ACTLOW |
FDC_FLAG_AT | FDC_FLAG_PS2,
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t fdc_ps2_mca_device = {
.name = "PS/2 MCA Floppy Drive Controller",
.internal_name = "fdc_ps2_mca",
.flags = 0,
.local = FDC_FLAG_FINTR | FDC_FLAG_DENSEL_INVERT | FDC_FLAG_NO_DSR_RESET | FDC_FLAG_AT |
FDC_FLAG_PS2_MCA,
2022-09-18 17:14:15 -04:00
.init = fdc_init,
.close = fdc_close,
.reset = fdc_reset,
2025-01-07 01:12:42 -05:00
.available = NULL,
2022-03-13 09:38:53 -04:00
.speed_changed = NULL,
2022-09-18 17:14:15 -04:00
.force_redraw = NULL,
.config = NULL
};