From f050810e2f3ba4e04d16a4d8b37108d95a4ea26f Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 10 Dec 2017 15:16:24 +0100 Subject: [PATCH] Added the NCR 53C810 PCI SCSI controller; Fixed the behavior of the CD-ROM GET CONFIGURATION command when unimplemented features are requested; Fixed the behavior of the CD-ROM READ DVD STRUCTURE command in some situations and made it correctly report 05/30/02 for incompatible format; Reworked the PS/2 Model 80 Type 2 memory handling a bit; The emulator now allocates the few MB of space needed for pages for the entire 4 GB RAM space at the startup and only memset's it to 0 on hard reset - should make sure DMA page reads from/writes to memory-mapped devices no longer crash the emulator on invalidating the memory range; Applied app applicable PCem patches; The PS/1 Model 2133 now also applies PS/2-style NMI mask handling - fixes the 486 recompiler on this machine; Added the missing #include of "cpu/cpu.h" in io.c, fixes compiling when I/O tracing is enabled. --- src/cdrom/cdrom.c | 151 +++++++++++++++++++++++------------- src/config.c | 21 ++++- src/disk/hdc_esdi_at.c | 28 +++---- src/disk/hdc_esdi_mca.c | 67 +++++++++++++++- src/disk/hdc_mfm_at.c | 22 +++--- src/dma.c | 35 ++++++++- src/dma.h | 3 +- src/io.c | 1 + src/machine/m_ps1.c | 3 + src/machine/m_ps2_mca.c | 142 ++++++++++++++++++++++++++------- src/machine/machine_table.c | 2 +- src/mem.c | 12 ++- src/nvr_at.c | 5 +- src/scsi/scsi.c | 2 + src/scsi/scsi_buslogic.c | 4 +- src/scsi/scsi_disk.c | 7 ++ src/sound/openal.c | 6 ++ src/sound/sound.c | 3 +- src/sound/sound.h | 4 +- src/win/Makefile.mingw | 8 +- 20 files changed, 397 insertions(+), 129 deletions(-) diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 20dc68d1e..4ae82c5f2 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)cdrom.c 1.0.24 2017/12/09 + * Version: @(#)cdrom.c 1.0.25 2017/12/10 * * Author: Miran Grca, * @@ -21,7 +21,6 @@ #include #include #include -#define HAVE_STDARG_H #include "../86box.h" #include "../config.h" #include "../timer.h" @@ -724,15 +723,15 @@ int cdrom_do_log = ENABLE_CDROM_LOG; static void -cdrom_log(const char *fmt, ...) +cdrom_log(const char *format, ...) { #ifdef ENABLE_CDROM_LOG va_list ap; if (cdrom_do_log) { - va_start(ap, fmt); - pclog_ex(fmt, ap); + va_start(ap, format); + pclog_ex(format, ap); va_end(ap); } #endif @@ -1502,7 +1501,7 @@ static void cdrom_incompatible_format(uint8_t id) { cdrom_sense_key = SENSE_ILLEGAL_REQUEST; cdrom_asc = ASC_INCOMPATIBLE_FORMAT; - cdrom_ascq = 0; + cdrom_ascq = 2; cdrom_cmd_error(id); } @@ -1717,22 +1716,6 @@ int cdrom_read_blocks(uint8_t id, uint32_t *len, int first_batch) } /*SCSI Get Configuration*/ -uint8_t cdrom_set_profile(uint8_t *buf, uint8_t *index, uint16_t profile) -{ - uint8_t *buf_profile = buf + 12; /* start of profiles */ - - buf_profile += ((*index) * 4); /* start of indexed profile */ - buf_profile[0] = (profile >> 8) & 0xff; - buf_profile[1] = profile & 0xff; - buf_profile[2] = ((buf_profile[0] == buf[6]) && (buf_profile[1] == buf[7])); - - /* each profile adds 4 bytes to the response */ - (*index)++; - buf[11] += 4; /* Additional Length */ - - return 4; -} - /*SCSI Read DVD Structure*/ static int cdrom_read_dvd_structure(uint8_t id, int format, const uint8_t *packet, uint8_t *buf) { @@ -2085,13 +2068,13 @@ void cdrom_command(uint8_t id, uint8_t *cdb) int msf; int pos=0; uint32_t max_len; + uint32_t feature; uint32_t used_len; unsigned idx = 0; unsigned size_idx; unsigned preamble_len; int toc_format; uint32_t alloc_length; - uint8_t index = 0; int block_desc = 0; int format = 0; int ret; @@ -2101,8 +2084,11 @@ void cdrom_command(uint8_t id, uint8_t *cdb) char device_identify_ex[15] = { '8', '6', 'B', '_', 'C', 'D', '0', '0', ' ', 'v', '1', '.', '0', '0', 0 }; int32_t blen = 0; int32_t *BufLen; + uint8_t *b; + uint32_t profiles[2] = { MMC_PROFILE_CD_ROM, MMC_PROFILE_DVD_ROM }; + uint32_t i = 0; -#if 1 +#if 0 int CdbLength; #endif if (cdrom_drives[id].bus_type == CDROM_BUS_SCSI) { @@ -2133,9 +2119,10 @@ void cdrom_command(uint8_t id, uint8_t *cdb) cdrom_log("CD-ROM %i: Command 0x%02X, Sense Key %02X, Asc %02X, Ascq %02X, Unit attention: %i\n", id, cdb[0], cdrom_sense_key, cdrom_asc, cdrom_ascq, cdrom[id].unit_attention); cdrom_log("CD-ROM %i: Request length: %04X\n", id, cdrom[id].request_length); -#if 1 +#if 0 for (CdbLength = 1; CdbLength < cdrom[id].cdb_len; CdbLength++) - cdrom_log("CD-ROM %i: CDB[%d] = %d\n", id, CdbLength, cdb[CdbLength]); + pclog("cdblog CD-ROM %i: CDB[%d] = %d\n", id, CdbLength, cdb[CdbLength]); + // cdrom_log("CD-ROM %i: CDB[%d] = %d\n", id, CdbLength, cdb[CdbLength]); #endif } @@ -2447,40 +2434,92 @@ cdrom_readtoc_fallback: case GPCMD_GET_CONFIGURATION: SCSIPhase = SCSI_PHASE_DATA_IN; - + /* XXX: could result in alignment problems in some architectures */ + feature = (cdb[2] << 8) | cdb[3]; max_len = (cdb[7] << 8) | cdb[8]; - index = 0; - /* only feature 0 is supported */ - if (cdb[2] != 0 || cdb[3] != 0) { + if ((cdb[2] != 0) || (cdb[3] > 2)) { cdrom_invalid_field(id); return; } cdrom_buf_alloc(id, 65536); memset(cdbufferb, 0, max_len); + + alloc_length = 0; + b = cdbufferb; + /* * the number of sectors from the media tells us which profile * to use as current. 0 means there is no media */ - len = cdrom_drives[id].handler->size(id); - if (len > CD_MAX_SECTORS) { - cdbufferb[6] = (MMC_PROFILE_DVD_ROM >> 8) & 0xff; - cdbufferb[7] = MMC_PROFILE_DVD_ROM & 0xff; - } else if (len <= CD_MAX_SECTORS) { - cdbufferb[6] = (MMC_PROFILE_CD_ROM >> 8) & 0xff; - cdbufferb[7] = MMC_PROFILE_CD_ROM & 0xff; + if (cdrom_drives[id].handler->ready(id)) { + len = cdrom_drives[id].handler->size(id); + if (len > CD_MAX_SECTORS) { + b[6] = (MMC_PROFILE_DVD_ROM >> 8) & 0xff; + b[7] = MMC_PROFILE_DVD_ROM & 0xff; + ret = 1; + } else if (len <= CD_MAX_SECTORS) { + b[6] = (MMC_PROFILE_CD_ROM >> 8) & 0xff; + b[7] = MMC_PROFILE_CD_ROM & 0xff; + ret = 0; + } + } else { + ret = 2; } - cdbufferb[10] = 0x02 | 0x01; /* persistent and current */ - alloc_length = 12; /* headers: 8 + 4 */ - alloc_length += cdrom_set_profile(cdbufferb, &index, MMC_PROFILE_DVD_ROM); - alloc_length += cdrom_set_profile(cdbufferb, &index, MMC_PROFILE_CD_ROM); + + alloc_length = 8; + b += 8; + + if ((feature == 0) || ((cdb[1] & 3) < 2)) { + b[2] = (0 << 2) | 0x02 | 0x01; /* persistent and current */ + b[3] = 8; + + alloc_length += 4; + b += 4; + + for (i = 0; i < 2; i++) { + b[0] = (profiles[i] >> 8) & 0xff; + b[1] = profiles[i] & 0xff; + + if (ret == i) + b[2] |= 1; + + alloc_length += 4; + b += 4; + } + } + if ((feature == 1) || ((cdb[1] & 3) < 2)) { + b[1] = 1; + b[2] = (2 << 2) | 0x02 | 0x01; /* persistent and current */ + b[3] = 8; + + if (cdrom_drives[id].bus_type == CDROM_BUS_SCSI) + b[7] = 1; + else + b[7] = 2; + b[8] = 1; + + alloc_length += 12; + b += 12; + } + if ((feature == 2) || ((cdb[1] & 3) < 2)) { + b[1] = 2; + b[2] = (1 << 2) | 0x02 | 0x01; /* persistent and current */ + b[3] = 4; + + b[4] = 2; + + alloc_length += 8; + b += 8; + } + cdbufferb[0] = ((alloc_length - 4) >> 24) & 0xff; cdbufferb[1] = ((alloc_length - 4) >> 16) & 0xff; cdbufferb[2] = ((alloc_length - 4) >> 8) & 0xff; - cdbufferb[3] = (alloc_length - 4) & 0xff; + cdbufferb[3] = (alloc_length - 4) & 0xff; alloc_length = MIN(alloc_length, max_len); @@ -2580,7 +2619,6 @@ cdrom_readtoc_fallback: } len = MIN(len, max_len); - pclog("READ_DISC_INFORMATION: len = %i\n", len); cdrom_set_buf_len(id, BufLen, &len); @@ -2789,16 +2827,15 @@ cdrom_readtoc_fallback: case GPCMD_READ_DVD_STRUCTURE: SCSIPhase = SCSI_PHASE_DATA_IN; - alloc_length = (((uint32_t) cdb[6]) << 24) | (((uint32_t) cdb[7]) << 16) | (((uint32_t) cdb[8]) << 8) | ((uint32_t) cdb[9]); - alloc_length = MIN(alloc_length, 256 * 512 + 4); + alloc_length = (((uint32_t) cdb[8]) << 8) | ((uint32_t) cdb[9]); cdrom_buf_alloc(id, alloc_length); if (cdrom_drives[id].handler->pass_through) { ret = cdrom_pass_through(id, &len, cdrom[id].current_cdb, cdbufferb); - if (!ret) + if (!ret) { return; - else { + } else { if (cdrom_drives[id].bus_type == CDROM_BUS_SCSI) { if (*BufLen == -1) *BufLen = len; @@ -2809,16 +2846,12 @@ cdrom_readtoc_fallback: } } } else { - len = (((uint32_t) cdb[6]) << 24) | (((uint32_t) cdb[7]) << 16) | (((uint32_t) cdb[8]) << 8) | ((uint32_t) cdb[9]); - alloc_length = len; + len = cdrom_drives[id].handler->size(id); - if (cdb[7] < 0xff) { + if (cdb[7] < 0xc0) { if (len <= CD_MAX_SECTORS) { cdrom_incompatible_format(id); return; - } else { - cdrom_invalid_field(id); - return; } } @@ -2954,19 +2987,29 @@ cdrom_readtoc_fallback: cdbufferb[0] = 5; /*CD-ROM*/ cdbufferb[1] = 0x80; /*Removable*/ cdbufferb[2] = (cdrom_drives[id].bus_type == CDROM_BUS_SCSI) ? 0x02 : 0x00; /*SCSI-2 compliant*/ - cdbufferb[3] = (cdrom_drives[id].bus_type == CDROM_BUS_SCSI) ? 0x02 : 0x21; + cdbufferb[3] = (cdrom_drives[id].bus_type == CDROM_BUS_SCSI) ? 0x12 : 0x21; cdbufferb[4] = 31; + if (cdrom_drives[id].bus_type == CDROM_BUS_SCSI) { + cdbufferb[6] = 1; /* 16-bit transfers supported */ + cdbufferb[7] = 0x20; /* Wide bus supported */ + } ide_padstr8(cdbufferb + 8, 8, EMU_NAME); /* Vendor */ ide_padstr8(cdbufferb + 16, 16, device_identify); /* Product */ ide_padstr8(cdbufferb + 32, 4, EMU_VERSION); /* Revision */ idx = 36; + + if (max_len == 96) { + cdbufferb[4] = 91; + idx = 96; + } } atapi_out: cdbufferb[size_idx] = idx - preamble_len; len=idx; + len = MIN(len, max_len); cdrom_set_buf_len(id, BufLen, &len); cdrom_data_command_finish(id, len, len, max_len, 0); diff --git a/src/config.c b/src/config.c index 1bce6a7ee..e4cae081b 100644 --- a/src/config.c +++ b/src/config.c @@ -8,7 +8,7 @@ * * Configuration file handler. * - * Version: @(#)config.c 1.0.33 2017/12/03 + * Version: @(#)config.c 1.0.34 2017/12/09 * * Authors: Sarah Walker, * Miran Grca, @@ -446,6 +446,10 @@ load_general(void) window_w = window_h = window_x = window_y = 0; } + sound_gain[0] = config_get_int(cat, "sound_gain_main", 0); + sound_gain[1] = config_get_int(cat, "sound_gain_cd", 0); + sound_gain[2] = config_get_int(cat, "sound_gain_midi", 0); + #ifdef USE_LANGUAGE /* * Currently, 86Box is English (US) only, but in the future @@ -1232,6 +1236,21 @@ save_general(void) config_delete_var(cat, "window_coordinates"); } + if (sound_gain[0] != 0) + config_set_int(cat, "sound_gain_main", sound_gain[0]); + else + config_delete_var(cat, "sound_gain_main"); + + if (sound_gain[1] != 0) + config_set_int(cat, "sound_gain_cd", sound_gain[1]); + else + config_delete_var(cat, "sound_gain_cd"); + + if (sound_gain[2] != 0) + config_set_int(cat, "sound_gain_midi", sound_gain[2]); + else + config_delete_var(cat, "sound_gain_midi"); + #ifdef USE_LANGUAGE if (plat_langid == 0x0409) config_delete_var(cat, "language"); diff --git a/src/disk/hdc_esdi_at.c b/src/disk/hdc_esdi_at.c index f85c23aaa..6dc05e237 100644 --- a/src/disk/hdc_esdi_at.c +++ b/src/disk/hdc_esdi_at.c @@ -32,6 +32,8 @@ #include "../mem.h" #include "../pic.h" #include "../rom.h" +#include "../cpu/cpu.h" +#include "../machine/machine.h" #include "../timer.h" #include "../plat.h" #include "../ui.h" @@ -206,7 +208,7 @@ esdi_writew(uint16_t port, uint16_t val, void *priv) if (esdi->pos >= 512) { esdi->pos = 0; esdi->status = STAT_BUSY; - timer_process(); + timer_clock(); esdi->callback = 6LL*HDC_TIME; timer_update_outstanding(); } @@ -269,7 +271,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) case CMD_RESTORE: esdi->command &= ~0x0f; /*mask off step rate*/ esdi->status = STAT_BUSY; - timer_process(); + timer_clock(); esdi->callback = 200LL*HDC_TIME; timer_update_outstanding(); break; @@ -277,7 +279,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) case CMD_SEEK: esdi->command &= ~0x0f; /*mask off step rate*/ esdi->status = STAT_BUSY; - timer_process(); + timer_clock(); esdi->callback = 200LL*HDC_TIME; timer_update_outstanding(); break; @@ -286,7 +288,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) switch (val) { case CMD_NOP: esdi->status = STAT_BUSY; - timer_process(); + timer_clock(); esdi->callback = 200LL*HDC_TIME; timer_update_outstanding(); break; @@ -301,7 +303,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) case 0xa0: esdi->status = STAT_BUSY; - timer_process(); + timer_clock(); esdi->callback = 200LL*HDC_TIME; timer_update_outstanding(); break; @@ -321,7 +323,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) case CMD_VERIFY+1: esdi->command &= ~0x01; esdi->status = STAT_BUSY; - timer_process(); + timer_clock(); esdi->callback = 200LL*HDC_TIME; timer_update_outstanding(); break; @@ -333,14 +335,14 @@ esdi_write(uint16_t port, uint8_t val, void *priv) case CMD_SET_PARAMETERS: /* Initialize Drive Parameters */ esdi->status = STAT_BUSY; - timer_process(); + timer_clock(); esdi->callback = 30LL*HDC_TIME; timer_update_outstanding(); break; case CMD_DIAGNOSE: /* Execute Drive Diagnostics */ esdi->status = STAT_BUSY; - timer_process(); + timer_clock(); esdi->callback = 200LL*HDC_TIME; timer_update_outstanding(); break; @@ -348,7 +350,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) case 0xe0: /*???*/ case CMD_READ_PARAMETERS: esdi->status = STAT_BUSY; - timer_process(); + timer_clock(); esdi->callback = 200LL*HDC_TIME; timer_update_outstanding(); break; @@ -357,7 +359,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) pclog("WD1007: bad command %02X\n", val); case 0xe8: /*???*/ esdi->status = STAT_BUSY; - timer_process(); + timer_clock(); esdi->callback = 200LL*HDC_TIME; timer_update_outstanding(); break; @@ -367,7 +369,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) case 0x3f6: /* Device control */ if ((esdi->fdisk & 0x04) && !(val & 0x04)) { - timer_process(); + timer_clock(); esdi->callback = 500LL*HDC_TIME; timer_update_outstanding(); esdi->reset = 1; @@ -376,7 +378,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) if (val & 0x04) { /*Drive held in reset*/ - timer_process(); + timer_clock(); esdi->callback = 0LL; timer_update_outstanding(); esdi->status = STAT_BUSY; @@ -404,7 +406,7 @@ esdi_readw(uint16_t port, void *priv) if (esdi->secount) { next_sector(esdi); esdi->status = STAT_BUSY; - timer_process(); + timer_clock(); esdi->callback = 6LL*HDC_TIME; timer_update_outstanding(); } else { diff --git a/src/disk/hdc_esdi_mca.c b/src/disk/hdc_esdi_mca.c index 47861f841..c2d0bf5c2 100644 --- a/src/disk/hdc_esdi_mca.c +++ b/src/disk/hdc_esdi_mca.c @@ -185,6 +185,7 @@ typedef struct esdi { #define CMD_READ_VERIFY 0x03 #define CMD_WRITE_VERIFY 0x04 #define CMD_SEEK 0x05 +#define CMD_GET_DEV_STATUS 0x08 #define CMD_GET_DEV_CONFIG 0x09 #define CMD_GET_POS_INFO 0x0a @@ -249,6 +250,25 @@ device_not_present(esdi_t *dev) set_irq(dev); } +static void rba_out_of_range(esdi_t *dev) +{ + dev->status_len = 9; + dev->status_data[0] = dev->command | STATUS_LEN(9) | dev->cmd_dev; + dev->status_data[1] = 0x0e01; /*Command block error, invalid parameter*/ + dev->status_data[2] = 0x0007; /*RBA out of range*/ + dev->status_data[3] = 0; + dev->status_data[4] = 0; + dev->status_data[5] = 0; + dev->status_data[6] = 0; + dev->status_data[7] = 0; + dev->status_data[8] = 0; + + dev->status = STATUS_IRQ | STATUS_STATUS_OUT_FULL; + dev->irq_status = dev->cmd_dev | IRQ_CMD_COMPLETE_FAILURE; + dev->irq_in_progress = 1; + set_irq(dev); +} + #define ESDI_ADAPTER_ONLY() do \ { \ if (dev->cmd_dev != ATTN_HOST_ADAPTER) \ @@ -306,6 +326,11 @@ esdi_callback(void *priv) dev->sector_pos = 0; dev->sector_count = dev->cmd_data[1]; + if ((dev->rba + dev->sector_count) > hdd_image_get_last_sector(drive->hdd_num)) { + rba_out_of_range(dev); + return; + } + dev->status = STATUS_IRQ | STATUS_CMD_IN_PROGRESS | STATUS_TRANSFER_REQ; dev->irq_status = dev->cmd_dev | IRQ_DATA_TRANSFER_READY; dev->irq_in_progress = 1; @@ -375,6 +400,11 @@ esdi_callback(void *priv) dev->sector_pos = 0; dev->sector_count = dev->cmd_data[1]; + if ((dev->rba + dev->sector_count) > hdd_image_get_last_sector(drive->hdd_num)) { + rba_out_of_range(dev); + return; + } + dev->status = STATUS_IRQ | STATUS_CMD_IN_PROGRESS | STATUS_TRANSFER_REQ; dev->irq_status = dev->cmd_dev | IRQ_DATA_TRANSFER_READY; dev->irq_in_progress = 1; @@ -436,6 +466,11 @@ esdi_callback(void *priv) return; } + if ((dev->rba + dev->sector_count) > hdd_image_get_last_sector(drive->hdd_num)) { + rba_out_of_range(dev); + return; + } + dev->status = STATUS_IRQ; dev->irq_status = dev->cmd_dev | IRQ_CMD_COMPLETE_SUCCESS; dev->irq_in_progress = 1; @@ -456,6 +491,36 @@ esdi_callback(void *priv) set_irq(dev); break; + case CMD_GET_DEV_STATUS: + ESDI_DRIVE_ONLY(); + + if (! drive->present) { + device_not_present(dev); + return; + } + + if (dev->status_pos) + fatal("Status send in progress\n"); + if ((dev->status & STATUS_IRQ) || dev->irq_in_progress) + fatal("IRQ in progress %02x %i\n", dev->status, dev->irq_in_progress); + + dev->status_len = 9; + dev->status_data[0] = CMD_GET_DEV_STATUS | STATUS_LEN(9) | STATUS_DEVICE_HOST_ADAPTER; + dev->status_data[1] = 0x0000; /*Error bits*/ + dev->status_data[2] = 0x1900; /*Device status*/ + dev->status_data[3] = 0; /*ESDI Standard Status*/ + dev->status_data[4] = 0; /*ESDI Vendor Unique Status*/ + dev->status_data[5] = 0; + dev->status_data[6] = 0; + dev->status_data[7] = 0; + dev->status_data[8] = 0; + + dev->status = STATUS_IRQ | STATUS_STATUS_OUT_FULL; + dev->irq_status = dev->cmd_dev | IRQ_CMD_COMPLETE_SUCCESS; + dev->irq_in_progress = 1; + set_irq(dev); + break; + case CMD_GET_DEV_CONFIG: ESDI_DRIVE_ONLY(); @@ -470,7 +535,7 @@ esdi_callback(void *priv) fatal("IRQ in progress %02x %i\n", dev->status, dev->irq_in_progress); dev->status_len = 6; - dev->status_data[0] = CMD_GET_POS_INFO | STATUS_LEN(6) | STATUS_DEVICE_HOST_ADAPTER; + dev->status_data[0] = CMD_GET_DEV_CONFIG | STATUS_LEN(6) | STATUS_DEVICE_HOST_ADAPTER; dev->status_data[1] = 0x10; /*Zero defect*/ dev->status_data[2] = drive->sectors & 0xffff; dev->status_data[3] = drive->sectors >> 16; diff --git a/src/disk/hdc_mfm_at.c b/src/disk/hdc_mfm_at.c index 50513dc11..907338b6a 100644 --- a/src/disk/hdc_mfm_at.c +++ b/src/disk/hdc_mfm_at.c @@ -32,6 +32,8 @@ #include "../device.h" #include "../io.h" #include "../pic.h" +#include "../cpu/cpu.h" +#include "../machine/machine.h" #include "../timer.h" #include "../plat.h" #include "../ui.h" @@ -223,7 +225,7 @@ mfm_cmd(mfm_t *mfm, uint8_t val) mfm->drvsel, val); mfm->command = 0xff; mfm->status = STAT_BUSY; - timer_process(); + timer_clock(); mfm->callback = 200LL*MFM_TIME; timer_update_outstanding(); @@ -250,7 +252,7 @@ mfm_cmd(mfm_t *mfm, uint8_t val) drive->steprate = (val & 0x0f); mfm->command = (val & 0xf0); mfm->status = STAT_BUSY; - timer_process(); + timer_clock(); mfm->callback = 200LL*MFM_TIME; timer_update_outstanding(); break; @@ -269,7 +271,7 @@ mfm_cmd(mfm_t *mfm, uint8_t val) if (val & 2) fatal("WD1003: READ with ECC\n"); mfm->status = STAT_BUSY; - timer_process(); + timer_clock(); mfm->callback = 200LL*MFM_TIME; timer_update_outstanding(); break; @@ -293,7 +295,7 @@ mfm_cmd(mfm_t *mfm, uint8_t val) case CMD_VERIFY+1: mfm->command = (val & 0xfe); mfm->status = STAT_BUSY; - timer_process(); + timer_clock(); mfm->callback = 200LL*MFM_TIME; timer_update_outstanding(); break; @@ -307,7 +309,7 @@ mfm_cmd(mfm_t *mfm, uint8_t val) case CMD_DIAGNOSE: mfm->command = val; mfm->status = STAT_BUSY; - timer_process(); + timer_clock(); mfm->callback = 200LL*MFM_TIME; timer_update_outstanding(); break; @@ -350,7 +352,7 @@ mfm_cmd(mfm_t *mfm, uint8_t val) default: pclog("WD1003: bad command %02X\n", val); mfm->status = STAT_BUSY; - timer_process(); + timer_clock(); mfm->callback = 200LL*MFM_TIME; timer_update_outstanding(); break; @@ -370,7 +372,7 @@ mfm_writew(uint16_t port, uint16_t val, void *priv) if (mfm->pos >= 512) { mfm->pos = 0; mfm->status = STAT_BUSY; - timer_process(); + timer_clock(); mfm->callback = 6LL*MFM_TIME; timer_update_outstanding(); } @@ -428,7 +430,7 @@ mfm_write(uint16_t port, uint8_t val, void *priv) if ((mfm->fdisk & 0x04) && !(val & 0x04)) { mfm->status = STAT_BUSY; mfm->reset = 1; - timer_process(); + timer_clock(); mfm->callback = 500LL*MFM_TIME; timer_update_outstanding(); } @@ -437,7 +439,7 @@ mfm_write(uint16_t port, uint8_t val, void *priv) /* Drive held in reset. */ mfm->status = STAT_BUSY; mfm->callback = 0LL; - timer_process(); + timer_clock(); timer_update_outstanding(); } mfm->fdisk = val; @@ -462,7 +464,7 @@ mfm_readw(uint16_t port, void *priv) if (mfm->secount) { next_sector(mfm); mfm->status = STAT_BUSY; - timer_process(); + timer_clock(); mfm->callback = 6LL*MFM_TIME; timer_update_outstanding(); } else { diff --git a/src/dma.c b/src/dma.c index f3cadd121..f3543ef47 100644 --- a/src/dma.c +++ b/src/dma.c @@ -194,6 +194,21 @@ static uint8_t dma_ps2_read(uint16_t addr, void *priv) temp = (dma.xfr_channel & 4) ? (dma16.cc[dma.xfr_channel & 3] & 0xff) : (dma.cc[dma.xfr_channel] & 0xff); dma.byte_ptr = (dma.byte_ptr + 1) & 1; break; + case 6: /*Read DMA status*/ + if (dma.byte_ptr) + { + temp = dma16.stat_rq | (dma16.stat << 4); + dma16.stat = 0; + dma16.stat_rq = 0; + } + else + { + temp = dma.stat_rq | (dma.stat << 4); + dma.stat = 0; + dma.stat_rq = 0; + } + dma.byte_ptr = (dma.byte_ptr + 1) & 1; + break; case 7: /*Mode*/ temp = (dma.xfr_channel & 4) ? dma16.ps2_mode[dma.xfr_channel & 3] : dma.ps2_mode[dma.xfr_channel]; break; @@ -551,6 +566,7 @@ int dma_channel_read(int channel) return DMA_NODATA; temp = _dma_read(dma.ac[channel]); + dma.stat_rq |= (1 << channel); if (dma.mode[channel] & 0x20) { @@ -594,6 +610,7 @@ int dma_channel_read(int channel) temp = _dma_read(dma16.ac[channel]) | (_dma_read(dma16.ac[channel] + 1) << 8); + dma16.stat_rq |= (1 << channel); if (dma16.mode[channel] & 0x20) { @@ -646,6 +663,7 @@ int dma_channel_write(int channel, uint16_t val) return DMA_NODATA; _dma_write(dma.ac[channel], val); + dma.stat_rq |= (1 << channel); if (dma.mode[channel] & 0x20) { @@ -688,6 +706,7 @@ int dma_channel_write(int channel, uint16_t val) _dma_write(dma16.ac[channel], val); _dma_write(dma16.ac[channel] + 1, val >> 8); + dma16.stat_rq |= (1 << channel); if (dma16.mode[channel] & 0x20) { @@ -738,11 +757,23 @@ int dma_mode(int channel) /* DMA Bus Master Page Read/Write */ void DMAPageRead(uint32_t PhysAddress, char *DataRead, uint32_t TotalSize) { - memcpy(DataRead, &ram[PhysAddress], TotalSize); + int i = 0; + + // memcpy(DataRead, &ram[PhysAddress], TotalSize); + + for (i = 0; i < TotalSize; i++) + DataRead[i] = mem_readb_phys(PhysAddress + i); } void DMAPageWrite(uint32_t PhysAddress, const char *DataWrite, uint32_t TotalSize) { + int i = 0; + + // mem_invalidate_range(PhysAddress, PhysAddress + TotalSize - 1); + // memcpy(&ram[PhysAddress], DataWrite, TotalSize); + + for (i = 0; i < TotalSize; i++) + mem_writeb_phys(PhysAddress + i, DataWrite[i]); + mem_invalidate_range(PhysAddress, PhysAddress + TotalSize - 1); - memcpy(&ram[PhysAddress], DataWrite, TotalSize); } diff --git a/src/dma.h b/src/dma.h index d8bbbbf04..e41e5df16 100644 --- a/src/dma.h +++ b/src/dma.h @@ -34,7 +34,8 @@ typedef struct DMA { uint8_t m, mode[4]; uint8_t page[4]; - uint8_t stat; + uint8_t stat, + stat_rq; uint8_t command; uint8_t request; diff --git a/src/io.c b/src/io.c index c2f5acdce..92ac6073b 100644 --- a/src/io.c +++ b/src/io.c @@ -7,6 +7,7 @@ #include #include "86box.h" #include "io.h" +#include "cpu/cpu.h" uint8_t (*port_inb[0x10000][2])(uint16_t addr, void *priv); diff --git a/src/machine/m_ps1.c b/src/machine/m_ps1.c index 3ba390f25..41f9e7030 100644 --- a/src/machine/m_ps1.c +++ b/src/machine/m_ps1.c @@ -50,6 +50,7 @@ #include "../pic.h" #include "../pit.h" #include "../mem.h" +#include "../nmi.h" #include "../rom.h" #include "../timer.h" #include "../device.h" @@ -590,4 +591,6 @@ machine_ps1_m2133_init(machine_t *model) ps1_common_init(model); ps1_setup(2133); + + nmi_mask = 0x80; } diff --git a/src/machine/m_ps2_mca.c b/src/machine/m_ps2_mca.c index a910c0f87..058dc2f07 100644 --- a/src/machine/m_ps2_mca.c +++ b/src/machine/m_ps2_mca.c @@ -11,6 +11,7 @@ #include "../pit.h" #include "../mca.h" #include "../mem.h" +#include "../nmi.h" #include "../rom.h" #include "../device.h" #include "../nvr.h" @@ -38,6 +39,7 @@ static struct mem_mapping_t shadow_mapping; mem_mapping_t split_mapping; + mem_mapping_t split_mapping_2; mem_mapping_t expansion_mapping; uint8_t (*planar_read)(uint16_t port); @@ -84,30 +86,61 @@ static void ps2_write_shadow_raml(uint32_t addr, uint32_t val, void *priv) static uint8_t ps2_read_split_ram(uint32_t addr, void *priv) { - addr = (addr & 0x3ffff) + 0xa0000; + addr = (addr & 0x1ffff) + 0x80000; return mem_read_ram(addr, priv); } static uint16_t ps2_read_split_ramw(uint32_t addr, void *priv) { - addr = (addr & 0x3ffff) + 0xa0000; + addr = (addr & 0x1ffff) + 0x80000; return mem_read_ramw(addr, priv); } static uint32_t ps2_read_split_raml(uint32_t addr, void *priv) { - addr = (addr & 0x3ffff) + 0xa0000; + addr = (addr & 0x1ffff) + 0x80000; return mem_read_raml(addr, priv); } static void ps2_write_split_ram(uint32_t addr, uint8_t val, void *priv) { - addr = (addr & 0x3ffff) + 0xa0000; + addr = (addr & 0x1ffff) + 0x80000; mem_write_ram(addr, val, priv); } static void ps2_write_split_ramw(uint32_t addr, uint16_t val, void *priv) { - addr = (addr & 0x3ffff) + 0xa0000; + addr = (addr & 0x1ffff) + 0x80000; mem_write_ramw(addr, val, priv); } static void ps2_write_split_raml(uint32_t addr, uint32_t val, void *priv) +{ + addr = (addr & 0x1ffff) + 0x80000; + mem_write_raml(addr, val, priv); +} + +static uint8_t ps2_read_split_2_ram(uint32_t addr, void *priv) +{ + addr = (addr & 0x3ffff) + 0xa0000; + return mem_read_ram(addr, priv); +} +static uint16_t ps2_read_split_2_ramw(uint32_t addr, void *priv) +{ + addr = (addr & 0x3ffff) + 0xa0000; + return mem_read_ramw(addr, priv); +} +static uint32_t ps2_read_split_2_raml(uint32_t addr, void *priv) +{ + addr = (addr & 0x3ffff) + 0xa0000; + return mem_read_raml(addr, priv); +} +static void ps2_write_split_2_ram(uint32_t addr, uint8_t val, void *priv) +{ + addr = (addr & 0x3ffff) + 0xa0000; + mem_write_ram(addr, val, priv); +} +static void ps2_write_split_2_ramw(uint32_t addr, uint16_t val, void *priv) +{ + addr = (addr & 0x3ffff) + 0xa0000; + mem_write_ramw(addr, val, priv); +} +static void ps2_write_split_2_raml(uint32_t addr, uint32_t val, void *priv) { addr = (addr & 0x3ffff) + 0xa0000; mem_write_raml(addr, val, priv); @@ -645,21 +678,39 @@ static void ps2_mca_board_model_55sx_init() static void mem_encoding_update() { - if (ps2.split_addr >= mem_size*1024) - mem_mapping_disable(&ps2.split_mapping); + mem_mapping_disable(&ps2.split_mapping); + mem_mapping_disable(&ps2.split_mapping_2); - ps2.split_addr = (ps2.mem_regs[0] & 0xf) << 20; + ps2.split_addr = ((uint32_t) (ps2.mem_regs[0] & 0xf)) << 20; - if (ps2.mem_regs[1] & 2) + if (ps2.mem_regs[1] & 2) { mem_set_mem_state(0xe0000, 0x20000, MEM_READ_EXTERNAL | MEM_WRITE_INTERNAL); - else + pclog("PS/2 Model 80-111: ROM space enabled\n"); + } else { mem_set_mem_state(0xe0000, 0x20000, MEM_READ_INTERNAL | MEM_WRITE_DISABLED); + pclog("PS/2 Model 80-111: ROM space disabled\n"); + } + + if (ps2.mem_regs[1] & 4) { + mem_mapping_set_addr(&ram_low_mapping, 0x00000, 0x80000); + pclog("PS/2 Model 80-111: 00080000- 0009FFFF disabled\n"); + } else { + mem_mapping_set_addr(&ram_low_mapping, 0x00000, 0xa0000); + pclog("PS/2 Model 80-111: 00080000- 0009FFFF enabled\n"); + } if (!(ps2.mem_regs[1] & 8)) { - if (ps2.split_addr >= mem_size*1024) - mem_mapping_set_addr(&ps2.split_mapping, ps2.split_addr, 256*1024); - } + if (ps2.mem_regs[1] & 4) { + mem_mapping_set_addr(&ps2.split_mapping, ps2.split_addr, 128*1024); + mem_mapping_set_addr(&ps2.split_mapping_2, ps2.split_addr+(128*1024), 256*1024); + } else + mem_mapping_set_addr(&ps2.split_mapping_2, ps2.split_addr, 256*1024); + + pclog("PS/2 Model 80-111: Split memory block enabled at %08X\n", ps2.split_addr); + } else { + pclog("PS/2 Model 80-111: Split memory block disabled\n"); + } } static uint8_t mem_encoding_read(uint16_t addr, void *p) @@ -711,7 +762,7 @@ static void ps2_mca_board_model_80_type2_init(int is486) mem_remap_top_256k(); ps2.split_addr = mem_size * 1024; - mca_init(24); + mca_init(8); ps2.planar_read = model_80_read; ps2.planar_write = model_80_write; @@ -721,42 +772,69 @@ static void ps2_mca_board_model_80_type2_init(int is486) io_sethandler(0x00e0, 0x0002, mem_encoding_read, NULL, NULL, mem_encoding_write, NULL, NULL, NULL); ps2.mem_regs[1] = 2; - + + /* Note by Kotori: I rewrote this because the original code was using + Model 80 Type 1-style 1 MB memory card settings, which are *NOT* + supported by Model 80 Type 2. */ switch (mem_size/1024) { case 1: - ps2.option[1] = 0x0c; + ps2.option[1] = 0x0e; /* 11 10 = 0 2 */ + ps2.mem_regs[1] = 0xd2; /* 01 = 1 (first) */ + ps2.mem_regs[0] = 0xf0; /* 11 = invalid */ break; case 2: - ps2.option[1] = 0x0e; + ps2.option[1] = 0x0e; /* 11 10 = 0 2 */ + ps2.mem_regs[1] = 0xc2; /* 00 = 2 */ + ps2.mem_regs[0] = 0xf0; /* 11 = invalid */ break; case 3: - ps2.option[1] = 0x02; + ps2.option[1] = 0x0a; /* 10 10 = 2 2 */ + ps2.mem_regs[1] = 0xc2; /* 00 = 2 */ + ps2.mem_regs[0] = 0xd0; /* 01 = 1 (first) */ break; case 4: default: - ps2.option[1] = 0x0a; + ps2.option[1] = 0x0a; /* 10 10 = 2 2 */ + ps2.mem_regs[1] = 0xc2; /* 00 = 2 */ + ps2.mem_regs[0] = 0xc0; /* 00 = 2 */ break; } + ps2.mem_regs[0] |= ((mem_size/1024) & 0x0f); + mem_mapping_add(&ps2.split_mapping, (mem_size+256) * 1024, - 256*1024, + 128*1024, ps2_read_split_ram, ps2_read_split_ramw, ps2_read_split_raml, ps2_write_split_ram, ps2_write_split_ramw, ps2_write_split_raml, - &ram[0xa0000], + &ram[0x80000], MEM_MAPPING_INTERNAL, NULL); mem_mapping_disable(&ps2.split_mapping); + mem_mapping_add(&ps2.split_mapping_2, + (mem_size+384) * 1024, + 256*1024, + ps2_read_split_2_ram, + ps2_read_split_2_ramw, + ps2_read_split_2_raml, + ps2_write_split_2_ram, + ps2_write_split_2_ramw, + ps2_write_split_2_raml, + &ram[0xa0000], + MEM_MAPPING_INTERNAL, + NULL); + mem_mapping_disable(&ps2.split_mapping_2); + if ((mem_size > 4096) && !is486) { /* Only 4 MB supported on planar, create a memory expansion card for the rest */ - mem_mapping_set_addr(&ram_high_mapping, 0x100000, 0x400000); + mem_mapping_set_addr(&ram_high_mapping, 0x100000, 0x300000); ps2.mem_pos_regs[0] = 0xff; ps2.mem_pos_regs[1] = 0xfc; @@ -764,31 +842,33 @@ static void ps2_mca_board_model_80_type2_init(int is486) switch (mem_size/1024) { case 5: - ps2.mem_pos_regs[4] = 0xfc; + ps2.mem_pos_regs[4] = 0xfc; /* 11 11 11 00 = 0 0 0 1 */ break; case 6: - ps2.mem_pos_regs[4] = 0xfe; + ps2.mem_pos_regs[4] = 0xfe; /* 11 11 11 10 = 0 0 0 2 */ break; case 7: - ps2.mem_pos_regs[4] = 0xf2; + ps2.mem_pos_regs[4] = 0xf2; /* 11 11 00 10 = 0 0 1 2 */ break; case 8: - ps2.mem_pos_regs[4] = 0xfa; + ps2.mem_pos_regs[4] = 0xfa; /* 11 11 10 10 = 0 0 2 2 */ break; case 9: - ps2.mem_pos_regs[4] = 0xca; + ps2.mem_pos_regs[4] = 0xca; /* 11 00 10 10 = 0 1 2 2 */ break; case 10: - ps2.mem_pos_regs[4] = 0xea; + ps2.mem_pos_regs[4] = 0xea; /* 11 10 10 10 = 0 2 2 2 */ break; case 11: - ps2.mem_pos_regs[4] = 0x2a; + ps2.mem_pos_regs[4] = 0x2a; /* 00 10 10 10 = 1 2 2 2 */ break; case 12: - ps2.mem_pos_regs[4] = 0xaa; + ps2.mem_pos_regs[4] = 0xaa; /* 10 10 10 10 = 2 2 2 2 */ break; } + pclog("ps2.mem_pos_regs[4] = %08X\n", ps2.mem_pos_regs[4]); + mca_add(ps2_mem_expansion_read, ps2_mem_expansion_write, NULL); mem_mapping_add(&ps2.expansion_mapping, 0x400000, @@ -821,6 +901,8 @@ machine_ps2_common_init(machine_t *model) pic2_init(); pit_ps2_init(); + + nmi_mask = 0x80; } diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index f0ae95c0a..5e0b14d8c 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -96,7 +96,7 @@ machine_t machines[] = { { "[486 ISA] AMI WinBIOS 486", ROM_WIN486, "win486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_ali1429_init, NULL, nvr_at_close }, { "[486 ISA] Award 486 clone", ROM_AWARD486_OPTI495, "award486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL, nvr_at_close }, { "[486 ISA] DTK PKM-0038S E-2", ROM_DTK486, "dtk486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 128, 1, 127, machine_at_dtk486_init, NULL, nvr_at_close }, - { "[486 ISA] IBM PS/1 machine 2133", ROM_IBMPS1_2133, "ibmps1_2133", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 1, 64, 1, 127, machine_ps1_m2133_init, NULL, nvr_at_close }, + { "[486 ISA] IBM PS/1 model 2133", ROM_IBMPS1_2133, "ibmps1_2133", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 1, 64, 1, 127, machine_ps1_m2133_init, NULL, nvr_at_close }, #ifdef WALTJE { "[486 MCA] IBM PS/2 model 80-486", ROM_IBMPS2_M80_486, "ibmps2_m80-486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 1, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC_PS2, 1, 32, 1, 63, machine_ps2_model_80_486_init, NULL, nvr_at_close }, diff --git a/src/mem.c b/src/mem.c index 376e748b7..22baf94f6 100644 --- a/src/mem.c +++ b/src/mem.c @@ -1358,17 +1358,17 @@ void mem_init(void) writelookup2 = malloc(1024 * 1024 * sizeof(uintptr_t)); rom = NULL; biosmask = 0xffff; - pages = malloc((((mem_size + 384) * 1024) >> 12) * sizeof(page_t)); + pages = malloc((1 << 20) * sizeof(page_t)); page_lookup = malloc((1 << 20) * sizeof(page_t *)); memset(ram, 0, mem_size * 1024); - memset(pages, 0, (((mem_size + 384) * 1024) >> 12) * sizeof(page_t)); + memset(pages, 0, (1 << 20) * sizeof(page_t)); memset(page_lookup, 0, (1 << 20) * sizeof(page_t *)); memset(ram_mapped_addr, 0, 64 * sizeof(uint32_t)); - for (c = 0; c < (((mem_size + 384) * 1024) >> 12); c++) + for (c = 0; c < (1 << 20); c++) { pages[c].mem = &ram[c << 12]; pages[c].write_b = mem_write_ramb_page; @@ -1461,10 +1461,8 @@ void mem_resize() ram = malloc(mem_size * 1024); memset(ram, 0, mem_size * 1024); - free(pages); - pages = malloc((((mem_size + 384) * 1024) >> 12) * sizeof(page_t)); - memset(pages, 0, (((mem_size + 384) * 1024) >> 12) * sizeof(page_t)); - for (c = 0; c < (((mem_size + 384) * 1024) >> 12); c++) + memset(pages, 0, (1 << 20) * sizeof(page_t)); + for (c = 0; c < (1 << 20); c++) { pages[c].mem = &ram[c << 12]; pages[c].write_b = mem_write_ramb_page; diff --git a/src/nvr_at.c b/src/nvr_at.c index 259e67a40..2f470b0f6 100644 --- a/src/nvr_at.c +++ b/src/nvr_at.c @@ -31,8 +31,10 @@ #include "io.h" #include "device.h" #include "machine/machine.h" +#include "mem.h" #include "nmi.h" #include "nvr.h" +#include "rom.h" static nvr_t *nvrp; @@ -45,7 +47,8 @@ nvr_write(uint16_t addr, uint8_t val, void *priv) if (! (addr & 1)) { nvr->addr = (val & nvr->mask); - nmi_mask = (~val & 0x80); + if (!(machines[machine].flags & MACHINE_MCA) && (romset != ROM_IBMPS1_2133)) + nmi_mask = (~val & 0x80); return; } diff --git a/src/scsi/scsi.c b/src/scsi/scsi.c index 21189f4a1..f70b117b4 100644 --- a/src/scsi/scsi.c +++ b/src/scsi/scsi.c @@ -34,6 +34,7 @@ #include "scsi_aha154x.h" #include "scsi_buslogic.h" #include "scsi_ncr5380.h" +#include "scsi_ncr53c810.h" #include "scsi_x54x.h" @@ -73,6 +74,7 @@ static SCSI_CARD scsi_cards[] = { { "[MCA] Adaptec AHA-1640", "aha1640", &aha1640_device, x54x_device_reset }, { "[MCA] BusLogic BT-640A", "bt640a", &buslogic_640a_device,BuslogicDeviceReset }, { "[PCI] BusLogic BT-958D", "bt958d", &buslogic_pci_device, BuslogicDeviceReset }, + { "[PCI] NCR 53C810", "ncr53c810", &ncr53c810_pci_device,NULL }, { "[VLB] BusLogic BT-445S", "bt445s", &buslogic_445s_device,BuslogicDeviceReset }, { "", "", NULL, NULL }, }; diff --git a/src/scsi/scsi_buslogic.c b/src/scsi/scsi_buslogic.c index eb25db920..145f6b7e3 100644 --- a/src/scsi/scsi_buslogic.c +++ b/src/scsi/scsi_buslogic.c @@ -11,7 +11,7 @@ * 1 - BT-545S ISA; * 2 - BT-958D PCI * - * Version: @(#)scsi_buslogic.c 1.0.30 2017/12/09 + * Version: @(#)scsi_buslogic.c 1.0.31 2017/12/10 * * Authors: TheCollector1995, * Miran Grca, @@ -1215,7 +1215,7 @@ BuslogicPCIWrite(int func, int addr, uint8_t val, void *p) } if (valxor & PCI_COMMAND_MEM) { x54x_mem_disable(dev); - if ((bl->MMIOBase != 0) & (val & PCI_COMMAND_MEM)) { + if ((bl->MMIOBase != 0) && (val & PCI_COMMAND_MEM)) { x54x_mem_set_addr(dev, bl->MMIOBase); } } diff --git a/src/scsi/scsi_disk.c b/src/scsi/scsi_disk.c index f489851f6..8f24b41e0 100644 --- a/src/scsi/scsi_disk.c +++ b/src/scsi/scsi_disk.c @@ -1927,11 +1927,18 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb) shdc[id].temp_buffer[2] = 0x02; /*SCSI-2 compliant*/ shdc[id].temp_buffer[3] = 0x02; shdc[id].temp_buffer[4] = 31; + shdc[id].temp_buffer[6] = 1; /* 16-bit transfers supported */ + shdc[id].temp_buffer[7] = 0x20; /* Wide bus supported */ ide_padstr8(shdc[id].temp_buffer + 8, 8, EMU_NAME); /* Vendor */ ide_padstr8(shdc[id].temp_buffer + 16, 16, device_identify); /* Product */ ide_padstr8(shdc[id].temp_buffer + 32, 4, EMU_VERSION); /* Revision */ idx = 36; + + if (max_len == 96) { + shdc[id].temp_buffer[4] = 91; + idx = 96; + } } atapi_out: diff --git a/src/sound/openal.c b/src/sound/openal.c index bdd86b3df..e0201f0dd 100644 --- a/src/sound/openal.c +++ b/src/sound/openal.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -205,6 +206,7 @@ void givealbuffer_common(void *buf, uint8_t src, int size, int freq) int processed; int state; ALuint buffer; + double gain; alGetSourcei(source[src], AL_SOURCE_STATE, &state); @@ -216,6 +218,10 @@ void givealbuffer_common(void *buf, uint8_t src, int size, int freq) if (processed>=1) { + gain = pow(10.0, (double)sound_gain[src] / 20.0); + + // alSourcef(source[src], AL_GAIN, gain); + alSourceUnqueueBuffers(source[src], 1, &buffer); if (sound_is_float) diff --git a/src/sound/sound.c b/src/sound/sound.c index 6ddf39723..c6b968f24 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -8,7 +8,7 @@ * * Sound emulation core. * - * Version: @(#)sound.c 1.0.9 2017/12/05 + * Version: @(#)sound.c 1.0.10 2017/12/09 * * Authors: Sarah Walker, * Miran Grca, @@ -52,6 +52,7 @@ typedef struct { int sound_card_current = 0; int sound_pos_global = 0; int soundon = 1; +int sound_gain[3] = { 0, 0, 0 }; static int sound_card_last = 0; diff --git a/src/sound/sound.h b/src/sound/sound.h index 5ae5f8c53..334a73a1d 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -8,7 +8,7 @@ * * Sound emulation core. * - * Version: @(#)sound.h 1.0.2 2017/10/04 + * Version: @(#)sound.h 1.0.3 2017/12/09 * * Authors: Sarah Walker, * Miran Grca, @@ -20,6 +20,8 @@ # define EMU_SOUND_H +extern int sound_gain[3]; + #define SOUNDBUFLEN (48000/50) #define CD_FREQ 44100 diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 50d00212f..2ae7d3597 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -8,7 +8,7 @@ # # Makefile for Win32 (MinGW32) environment. # -# Version: @(#)Makefile.mingw 1.0.82 2017/12/04 +# Version: @(#)Makefile.mingw 1.0.83 2017/12/06 # # Authors: Miran Grca, # Fred N. van Kempen, @@ -29,7 +29,7 @@ ifndef AUTODEP AUTODEP := n endif ifndef CRASHDUMP -CRASHCUMP := n +CRASHDUMP := n endif ifndef DEBUG DEBUG := n @@ -389,8 +389,8 @@ SCSIOBJ := scsi.o \ scsi_bus.o scsi_device.o \ scsi_disk.o \ scsi_x54x.o \ - scsi_buslogic.o scsi_aha154x.o \ - scsi_ncr5380.o + scsi_aha154x.o scsi_buslogic.o \ + scsi_ncr5380.o scsi_ncr53c810.o NETOBJ := network.o \ net_pcap.o \