Several rounds of code cleanups.
Fixed the heap-trashing bug. Applied some more upstream patches.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Generic interface for CD-ROM/DVD/BD implementations.
|
||||
*
|
||||
* Version: @(#)cdrom.c 1.0.25 2018/10/21
|
||||
* Version: @(#)cdrom.c 1.0.26 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -168,7 +168,7 @@ cdrom_global_init(void)
|
||||
static void
|
||||
cdrom_drive_reset(cdrom_t *dev)
|
||||
{
|
||||
dev->p = NULL;
|
||||
dev->priv = NULL;
|
||||
dev->insert = NULL;
|
||||
dev->close = NULL;
|
||||
dev->get_volume = NULL;
|
||||
@@ -228,7 +228,8 @@ cdrom_close(void)
|
||||
dev->ops = NULL;
|
||||
|
||||
if (dev->close)
|
||||
dev->close(dev->p);
|
||||
dev->close(dev->priv);
|
||||
dev->priv = NULL;
|
||||
|
||||
cdrom_drive_reset(dev);
|
||||
}
|
||||
@@ -243,7 +244,7 @@ cdrom_insert(uint8_t id)
|
||||
|
||||
if (dev->bus_type) {
|
||||
if (dev->insert)
|
||||
dev->insert(dev->p);
|
||||
dev->insert(dev->priv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Definitions for the CDROM module..
|
||||
*
|
||||
* Version: @(#)cdrom.h 1.0.15 2018/10/18
|
||||
* Version: @(#)cdrom.h 1.0.16 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -154,11 +154,11 @@ typedef struct cdrom {
|
||||
|
||||
void (*reset)(struct cdrom *);
|
||||
|
||||
void *p;
|
||||
void (*insert)(void *p);
|
||||
void (*close)(void *p);
|
||||
uint32_t (*get_volume)(void *p, int channel);
|
||||
uint32_t (*get_channel)(void *p, int channel);
|
||||
void *priv;
|
||||
void (*insert)(void *priv);
|
||||
void (*close)(void *priv);
|
||||
uint32_t (*get_volume)(void *priv, int channel);
|
||||
uint32_t (*get_channel)(void *priv, int channel);
|
||||
|
||||
wchar_t image_path[1024],
|
||||
*prev_image_path;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* Devices currently implemented are hard disk, CD-ROM and
|
||||
* ZIP IDE/ATAPI devices.
|
||||
*
|
||||
* Version: @(#)hdc_ide_ata.c 1.0.26 2018/10/19
|
||||
* Version: @(#)hdc_ide_ata.c 1.0.27 2018/10/25
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
@@ -133,7 +133,7 @@
|
||||
#define FEATURE_DISABLE_IRQ_OVERLAPPED 0xdd
|
||||
#define FEATURE_DISABLE_IRQ_SERVICE 0xde
|
||||
|
||||
#define IDE_PCI (PCI && pio_override)
|
||||
#define IDE_PCI (PCI && pio_override && (ide->board < 2))
|
||||
|
||||
|
||||
typedef struct {
|
||||
@@ -383,34 +383,35 @@ static int
|
||||
ide_get_max(ide_t *ide, int type)
|
||||
{
|
||||
if (ide_drive_is_atapi(ide))
|
||||
return ide->get_max(!IDE_PCI || (ide->board >= 2), type);
|
||||
return ide->get_max(!IDE_PCI, type);
|
||||
|
||||
switch(type) {
|
||||
case TYPE_PIO: /* PIO */
|
||||
if (!IDE_PCI || (ide->board >= 2))
|
||||
if (! IDE_PCI)
|
||||
return 0; /* Maximum PIO 0 for legacy PIO-only drive. */
|
||||
else
|
||||
return 4;
|
||||
break;
|
||||
return 4;
|
||||
|
||||
case TYPE_SDMA: /* SDMA */
|
||||
if (!IDE_PCI || (ide->board >= 2))
|
||||
if (! IDE_PCI)
|
||||
return -1;
|
||||
else
|
||||
return 2;
|
||||
return 2;
|
||||
|
||||
case TYPE_MDMA: /* MDMA */
|
||||
if (!IDE_PCI || (ide->board >= 2))
|
||||
if (! IDE_PCI)
|
||||
return -1;
|
||||
else
|
||||
return 2;
|
||||
return 2;
|
||||
|
||||
case TYPE_UDMA: /* UDMA */
|
||||
if (!IDE_PCI || (ide->board >= 2))
|
||||
if (! IDE_PCI)
|
||||
return -1;
|
||||
else
|
||||
return 2;
|
||||
return 2;
|
||||
|
||||
default:
|
||||
fatal("Unknown transfer type: %i\n", type);
|
||||
return -1;
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -422,24 +423,24 @@ ide_get_timings(ide_t *ide, int type)
|
||||
|
||||
switch(type) {
|
||||
case TIMINGS_DMA:
|
||||
if (!IDE_PCI || (ide->board >= 2))
|
||||
if (! IDE_PCI)
|
||||
return 0;
|
||||
else
|
||||
return 120;
|
||||
break;
|
||||
return 120;
|
||||
|
||||
case TIMINGS_PIO:
|
||||
if (!IDE_PCI || (ide->board >= 2))
|
||||
if (! IDE_PCI)
|
||||
return 0;
|
||||
else
|
||||
return 120;
|
||||
break;
|
||||
return 120;
|
||||
|
||||
case TIMINGS_PIO_FC:
|
||||
return 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
fatal("Unknown transfer type: %i\n", type);
|
||||
return 0;
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -527,7 +528,7 @@ ide_hd_identify(ide_t *ide)
|
||||
DEBUG("Current CHS translation: %i, %i, %i\n", ide->buffer[54], ide->buffer[55], ide->buffer[56]);
|
||||
}
|
||||
|
||||
if (IDE_PCI && (ide->board < 2)) {
|
||||
if (IDE_PCI) {
|
||||
ide->buffer[47] = 32 | 0x8000; /*Max sectors on multiple transfer command*/
|
||||
ide->buffer[80] = 0x1e; /*ATA-1 to ATA-4 supported*/
|
||||
ide->buffer[81] = 0x18; /*ATA-4 revision 18 supported*/
|
||||
@@ -548,7 +549,7 @@ ide_identify(ide_t *ide)
|
||||
memset(ide->buffer, 0, 512);
|
||||
|
||||
if (ide_drive_is_atapi(ide))
|
||||
ide->identify(ide, IDE_PCI && (ide->board < 2));
|
||||
ide->identify(ide, IDE_PCI);
|
||||
else if (ide->type != IDE_NONE)
|
||||
ide_hd_identify(ide);
|
||||
else {
|
||||
@@ -564,7 +565,7 @@ ide_identify(ide_t *ide)
|
||||
if (ide_boards[ide->board]->bit32)
|
||||
ide->buffer[48] |= 1; /*Dword transfers supported*/
|
||||
ide->buffer[51] = ide_get_timings(ide, TIMINGS_PIO);
|
||||
ide->buffer[53] &= 0x0006;
|
||||
ide->buffer[53] &= 0xfff9;
|
||||
ide->buffer[52] = ide->buffer[62] = ide->buffer[63] = ide->buffer[64] = 0x0000;
|
||||
ide->buffer[65] = ide->buffer[66] = ide->buffer[67] = ide->buffer[68] = 0x0000;
|
||||
ide->buffer[88] = 0x0000;
|
||||
@@ -864,17 +865,17 @@ ide_allocate_buffer(ide_t *dev)
|
||||
|
||||
|
||||
void
|
||||
ide_atapi_attach(ide_t *dev)
|
||||
ide_atapi_attach(ide_t *ide)
|
||||
{
|
||||
if (dev->type != IDE_NONE)
|
||||
if (ide->type != IDE_NONE)
|
||||
return;
|
||||
|
||||
dev->type = IDE_ATAPI;
|
||||
ide_allocate_buffer(dev);
|
||||
ide_set_signature(dev);
|
||||
dev->mdma_mode = (1 << dev->get_max(!IDE_PCI || (dev->board >= 2), TYPE_PIO));
|
||||
dev->error = 1;
|
||||
dev->cfg_spt = dev->cfg_hpc = 0;
|
||||
ide->type = IDE_ATAPI;
|
||||
ide_allocate_buffer(ide);
|
||||
ide_set_signature(ide);
|
||||
ide->mdma_mode = (1 << ide->get_max(!IDE_PCI, TYPE_PIO));
|
||||
ide->error = 1;
|
||||
ide->cfg_spt = ide->cfg_hpc = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1863,7 +1864,7 @@ ide_callback(void *priv)
|
||||
|
||||
case WIN_READ_DMA:
|
||||
case WIN_READ_DMA_ALT:
|
||||
if (ide_drive_is_atapi(ide) || !IDE_PCI || (ide->board >= 2)) {
|
||||
if (ide_drive_is_atapi(ide) || !IDE_PCI) {
|
||||
DEBUG("IDE %i: DMA read aborted (bad device or board)\n", ide->channel);
|
||||
goto abort_cmd;
|
||||
}
|
||||
@@ -1966,7 +1967,7 @@ ide_callback(void *priv)
|
||||
|
||||
case WIN_WRITE_DMA:
|
||||
case WIN_WRITE_DMA_ALT:
|
||||
if (ide_drive_is_atapi(ide) || !IDE_PCI || (ide->board >= 2)) {
|
||||
if (ide_drive_is_atapi(ide) || !IDE_PCI) {
|
||||
DEBUG("IDE %i: DMA write aborted (bad device type or board)\n", ide->channel);
|
||||
goto abort_cmd;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Definitions for the hard disk image handler.
|
||||
*
|
||||
* Version: @(#)hdd.h 1.0.11 2018/10/15
|
||||
* Version: @(#)hdd.h 1.0.13 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -114,6 +114,8 @@ typedef struct {
|
||||
uint32_t at_spt, /* [Translation] parameters */
|
||||
at_hpc;
|
||||
|
||||
void *priv;
|
||||
|
||||
FILE *f; /* current file handle to image */
|
||||
|
||||
wchar_t fn[260]; /* name of current image file */
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Implementation of the Iomega ZIP drive with SCSI(-like)
|
||||
* commands, for both ATAPI and SCSI usage.
|
||||
*
|
||||
* Version: @(#)zip.c 1.0.22 2018/10/25
|
||||
* Version: @(#)zip.c 1.0.23 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -68,13 +68,10 @@
|
||||
#define ABRT_ERR 0x04 /* Command aborted */
|
||||
#define MCR_ERR 0x08 /* Media change request */
|
||||
|
||||
#define zipbufferb dev->buffer
|
||||
|
||||
|
||||
#ifdef ENABLE_ZIP_LOG
|
||||
int zip_do_log = ENABLE_ZIP_LOG;
|
||||
#endif
|
||||
zip_t *zip[ZIP_NUM] = { NULL, NULL, NULL, NULL };
|
||||
zip_drive_t zip_drives[ZIP_NUM];
|
||||
|
||||
|
||||
@@ -587,6 +584,7 @@ zip_disk_reload(zip_t *dev)
|
||||
void
|
||||
zip_disk_close(zip_t *dev)
|
||||
{
|
||||
ERRLOG("ZIP: disk_close: dev=%08lx drv=%08lx\n", dev, dev->drv);
|
||||
if (dev->drv->f) {
|
||||
fclose(dev->drv->f);
|
||||
dev->drv->f = NULL;
|
||||
@@ -619,30 +617,6 @@ zip_set_signature(void *p)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
zip_init(zip_t *dev)
|
||||
{
|
||||
if (dev->id >= ZIP_NUM)
|
||||
return;
|
||||
|
||||
dev->requested_blocks = 1;
|
||||
dev->sense[0] = 0xf0;
|
||||
dev->sense[7] = 10;
|
||||
dev->drv->bus_mode = 0;
|
||||
if (dev->drv->bus_type >= ZIP_BUS_ATAPI)
|
||||
dev->drv->bus_mode |= 2;
|
||||
if (dev->drv->bus_type < ZIP_BUS_SCSI)
|
||||
dev->drv->bus_mode |= 1;
|
||||
DEBUG("ZIP %i: Bus type %i, bus mode %i\n", dev->id, dev->drv->bus_type, dev->drv->bus_mode);
|
||||
if (dev->drv->bus_type < ZIP_BUS_SCSI)
|
||||
zip_set_signature(dev);
|
||||
dev->status = READY_STAT | DSC_STAT;
|
||||
dev->pos = 0;
|
||||
dev->packet_status = 0xff;
|
||||
zip_sense_key = zip_asc = zip_ascq = dev->unit_attention = 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
zip_supports_pio(zip_t *dev)
|
||||
{
|
||||
@@ -1232,9 +1206,9 @@ zip_blocks(zip_t *dev, int32_t *len, int first_batch, int out)
|
||||
|
||||
fseek(dev->drv->f, dev->drv->base + (dev->sector_pos << 9), SEEK_SET);
|
||||
if (out)
|
||||
fwrite(zipbufferb, 1, *len, dev->drv->f);
|
||||
fwrite(dev->buffer, 1, *len, dev->drv->f);
|
||||
else
|
||||
fread(zipbufferb, 1, *len, dev->drv->f);
|
||||
fread(dev->buffer, 1, *len, dev->drv->f);
|
||||
|
||||
DEBUG("%s %i bytes of blocks...\n", out ? "Written" : "Read", *len);
|
||||
|
||||
@@ -1446,17 +1420,17 @@ static void
|
||||
zip_buf_alloc(zip_t *dev, uint32_t len)
|
||||
{
|
||||
DEBUG("ZIP %i: Allocated buffer length: %i\n", dev->id, len);
|
||||
zipbufferb = (uint8_t *) malloc(len);
|
||||
dev->buffer = (uint8_t *) malloc(len);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
zip_buf_free(zip_t *dev)
|
||||
{
|
||||
if (zipbufferb) {
|
||||
if (dev->buffer) {
|
||||
DEBUG("ZIP %i: Freeing buffer...\n", dev->id);
|
||||
free(zipbufferb);
|
||||
zipbufferb = NULL;
|
||||
free(dev->buffer);
|
||||
dev->buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1534,24 +1508,24 @@ zip_command(void *p, uint8_t *cdb)
|
||||
max_len = cdb[4];
|
||||
zip_buf_alloc(dev, 256);
|
||||
zip_set_buf_len(dev, BufLen, &max_len);
|
||||
memset(zipbufferb, 0, 256);
|
||||
memset(dev->buffer, 0, 256);
|
||||
if (cdb[2] == 1) {
|
||||
/* This page is related to disk health status - setting
|
||||
this page to 0 makes disk health read as "marginal". */
|
||||
zipbufferb[0] = 0x58;
|
||||
zipbufferb[1] = 0x00;
|
||||
dev->buffer[0] = 0x58;
|
||||
dev->buffer[1] = 0x00;
|
||||
for (i = 0x00; i < 0x58; i++)
|
||||
zipbufferb[i + 0x02] = 0xff;
|
||||
dev->buffer[i + 0x02] = 0xff;
|
||||
} else if (cdb[2] == 2) {
|
||||
zipbufferb[0] = 0x3d;
|
||||
zipbufferb[1] = 0x00;
|
||||
dev->buffer[0] = 0x3d;
|
||||
dev->buffer[1] = 0x00;
|
||||
for (i = 0x00; i < 0x13; i++)
|
||||
zipbufferb[i + 0x02] = 0x00;
|
||||
zipbufferb[0x15] = 0x00;
|
||||
dev->buffer[i + 0x02] = 0x00;
|
||||
dev->buffer[0x15] = 0x00;
|
||||
if (dev->drv->read_only)
|
||||
zipbufferb[0x15] |= 0x02;
|
||||
dev->buffer[0x15] |= 0x02;
|
||||
for (i = 0x00; i < 0x27; i++)
|
||||
zipbufferb[i + 0x16] = 0x00;
|
||||
dev->buffer[i + 0x16] = 0x00;
|
||||
} else {
|
||||
zip_invalid_field(dev);
|
||||
zip_buf_free(dev);
|
||||
@@ -1583,7 +1557,7 @@ zip_command(void *p, uint8_t *cdb)
|
||||
zip_buf_alloc(dev, 256);
|
||||
zip_set_buf_len(dev, BufLen, &max_len);
|
||||
len = (cdb[1] & 1) ? 8 : 18;
|
||||
zip_request_sense(dev, zipbufferb, max_len, cdb[1] & 1);
|
||||
zip_request_sense(dev, dev->buffer, max_len, cdb[1] & 1);
|
||||
zip_data_command_finish(dev, len, len, cdb[4], 0);
|
||||
break;
|
||||
|
||||
@@ -1595,8 +1569,8 @@ zip_command(void *p, uint8_t *cdb)
|
||||
|
||||
zip_set_buf_len(dev, BufLen, &len);
|
||||
|
||||
memset(zipbufferb, 0, 8);
|
||||
zipbufferb[5] = 1;
|
||||
memset(dev->buffer, 0, 8);
|
||||
dev->buffer[5] = 1;
|
||||
|
||||
zip_data_command_finish(dev, 8, 8, len, 0);
|
||||
break;
|
||||
@@ -1830,25 +1804,25 @@ zip_command(void *p, uint8_t *cdb)
|
||||
return;
|
||||
}
|
||||
|
||||
memset(zipbufferb, 0, len);
|
||||
memset(dev->buffer, 0, len);
|
||||
alloc_length = len;
|
||||
|
||||
if (cdb[0] == GPCMD_MODE_SENSE_6) {
|
||||
len = zip_mode_sense(dev, zipbufferb, 4, cdb[2], block_desc);
|
||||
len = zip_mode_sense(dev, dev->buffer, 4, cdb[2], block_desc);
|
||||
len = MIN(len, alloc_length);
|
||||
zipbufferb[0] = len - 1;
|
||||
zipbufferb[1] = 0;
|
||||
dev->buffer[0] = len - 1;
|
||||
dev->buffer[1] = 0;
|
||||
if (block_desc)
|
||||
zipbufferb[3] = 8;
|
||||
dev->buffer[3] = 8;
|
||||
} else {
|
||||
len = zip_mode_sense(dev, zipbufferb, 8, cdb[2], block_desc);
|
||||
len = zip_mode_sense(dev, dev->buffer, 8, cdb[2], block_desc);
|
||||
len = MIN(len, alloc_length);
|
||||
zipbufferb[0]=(len - 2) >> 8;
|
||||
zipbufferb[1]=(len - 2) & 255;
|
||||
zipbufferb[2] = 0;
|
||||
dev->buffer[0]=(len - 2) >> 8;
|
||||
dev->buffer[1]=(len - 2) & 255;
|
||||
dev->buffer[2] = 0;
|
||||
if (block_desc) {
|
||||
zipbufferb[6] = 0;
|
||||
zipbufferb[7] = 8;
|
||||
dev->buffer[6] = 0;
|
||||
dev->buffer[7] = 8;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1912,16 +1886,16 @@ zip_command(void *p, uint8_t *cdb)
|
||||
preamble_len = 4;
|
||||
size_idx = 3;
|
||||
|
||||
zipbufferb[idx++] = 05;
|
||||
zipbufferb[idx++] = cdb[2];
|
||||
zipbufferb[idx++] = 0;
|
||||
dev->buffer[idx++] = 05;
|
||||
dev->buffer[idx++] = cdb[2];
|
||||
dev->buffer[idx++] = 0;
|
||||
|
||||
idx++;
|
||||
|
||||
switch (cdb[2]) {
|
||||
case 0x00:
|
||||
zipbufferb[idx++] = 0x00;
|
||||
zipbufferb[idx++] = 0x83;
|
||||
dev->buffer[idx++] = 0x00;
|
||||
dev->buffer[idx++] = 0x83;
|
||||
break;
|
||||
case 0x83:
|
||||
if (idx + 24 > max_len) {
|
||||
@@ -1930,27 +1904,27 @@ zip_command(void *p, uint8_t *cdb)
|
||||
return;
|
||||
}
|
||||
|
||||
zipbufferb[idx++] = 0x02;
|
||||
zipbufferb[idx++] = 0x00;
|
||||
zipbufferb[idx++] = 0x00;
|
||||
zipbufferb[idx++] = 20;
|
||||
ide_padstr8(zipbufferb + idx, 20, "53R141"); /* Serial */
|
||||
dev->buffer[idx++] = 0x02;
|
||||
dev->buffer[idx++] = 0x00;
|
||||
dev->buffer[idx++] = 0x00;
|
||||
dev->buffer[idx++] = 20;
|
||||
ide_padstr8(dev->buffer + idx, 20, "53R141"); /* Serial */
|
||||
idx += 20;
|
||||
|
||||
if (idx + 72 > cdb[4])
|
||||
goto atapi_out;
|
||||
zipbufferb[idx++] = 0x02;
|
||||
zipbufferb[idx++] = 0x01;
|
||||
zipbufferb[idx++] = 0x00;
|
||||
zipbufferb[idx++] = 68;
|
||||
ide_padstr8(zipbufferb + idx, 8, "IOMEGA "); /* Vendor */
|
||||
dev->buffer[idx++] = 0x02;
|
||||
dev->buffer[idx++] = 0x01;
|
||||
dev->buffer[idx++] = 0x00;
|
||||
dev->buffer[idx++] = 68;
|
||||
ide_padstr8(dev->buffer + idx, 8, "IOMEGA "); /* Vendor */
|
||||
idx += 8;
|
||||
if (dev->drv->is_250)
|
||||
ide_padstr8(zipbufferb + idx, 40, "ZIP 250 "); /* Product */
|
||||
ide_padstr8(dev->buffer + idx, 40, "ZIP 250 "); /* Product */
|
||||
else
|
||||
ide_padstr8(zipbufferb + idx, 40, "ZIP 100 "); /* Product */
|
||||
ide_padstr8(dev->buffer + idx, 40, "ZIP 100 "); /* Product */
|
||||
idx += 40;
|
||||
ide_padstr8(zipbufferb + idx, 20, "53R141"); /* Product */
|
||||
ide_padstr8(dev->buffer + idx, 20, "53R141"); /* Product */
|
||||
idx += 20;
|
||||
break;
|
||||
default:
|
||||
@@ -1963,45 +1937,45 @@ zip_command(void *p, uint8_t *cdb)
|
||||
preamble_len = 5;
|
||||
size_idx = 4;
|
||||
|
||||
memset(zipbufferb, 0, 8);
|
||||
memset(dev->buffer, 0, 8);
|
||||
if (cdb[1] & 0xe0)
|
||||
zipbufferb[0] = 0x60; /*No physical device on this LUN*/
|
||||
dev->buffer[0] = 0x60; /*No physical device on this LUN*/
|
||||
else
|
||||
zipbufferb[0] = 0x00; /*Hard disk*/
|
||||
zipbufferb[1] = 0x80; /*Removable*/
|
||||
zipbufferb[2] = (dev->drv->bus_type == ZIP_BUS_SCSI) ? 0x02 : 0x00; /*SCSI-2 compliant*/
|
||||
zipbufferb[3] = (dev->drv->bus_type == ZIP_BUS_SCSI) ? 0x02 : 0x21;
|
||||
zipbufferb[4] = 31;
|
||||
dev->buffer[0] = 0x00; /*Hard disk*/
|
||||
dev->buffer[1] = 0x80; /*Removable*/
|
||||
dev->buffer[2] = (dev->drv->bus_type == ZIP_BUS_SCSI) ? 0x02 : 0x00; /*SCSI-2 compliant*/
|
||||
dev->buffer[3] = (dev->drv->bus_type == ZIP_BUS_SCSI) ? 0x02 : 0x21;
|
||||
dev->buffer[4] = 31;
|
||||
if (dev->drv->bus_type == ZIP_BUS_SCSI) {
|
||||
zipbufferb[6] = 1; /* 16-bit transfers supported */
|
||||
zipbufferb[7] = 0x20; /* Wide bus supported */
|
||||
dev->buffer[6] = 1; /* 16-bit transfers supported */
|
||||
dev->buffer[7] = 0x20; /* Wide bus supported */
|
||||
}
|
||||
|
||||
ide_padstr8(zipbufferb + 8, 8, "IOMEGA "); /* Vendor */
|
||||
ide_padstr8(dev->buffer + 8, 8, "IOMEGA "); /* Vendor */
|
||||
if (dev->drv->is_250) {
|
||||
ide_padstr8(zipbufferb + 16, 16, "ZIP 250 "); /* Product */
|
||||
ide_padstr8(zipbufferb + 32, 4, "42.S"); /* Revision */
|
||||
ide_padstr8(dev->buffer + 16, 16, "ZIP 250 "); /* Product */
|
||||
ide_padstr8(dev->buffer + 32, 4, "42.S"); /* Revision */
|
||||
if (max_len >= 44)
|
||||
ide_padstr8(zipbufferb + 36, 8, "08/08/01"); /* Date? */
|
||||
ide_padstr8(dev->buffer + 36, 8, "08/08/01"); /* Date? */
|
||||
if (max_len >= 122)
|
||||
ide_padstr8(zipbufferb + 96, 26, "(c) Copyright IOMEGA 2000 "); /* Copyright string */
|
||||
ide_padstr8(dev->buffer + 96, 26, "(c) Copyright IOMEGA 2000 "); /* Copyright string */
|
||||
} else {
|
||||
ide_padstr8(zipbufferb + 16, 16, "ZIP 100 "); /* Product */
|
||||
ide_padstr8(zipbufferb + 32, 4, "E.08"); /* Revision */
|
||||
ide_padstr8(dev->buffer + 16, 16, "ZIP 100 "); /* Product */
|
||||
ide_padstr8(dev->buffer + 32, 4, "E.08"); /* Revision */
|
||||
}
|
||||
idx = 36;
|
||||
|
||||
if (max_len == 96) {
|
||||
zipbufferb[4] = 91;
|
||||
dev->buffer[4] = 91;
|
||||
idx = 96;
|
||||
} else if (max_len == 128) {
|
||||
zipbufferb[4] = 0x75;
|
||||
dev->buffer[4] = 0x75;
|
||||
idx = 128;
|
||||
}
|
||||
}
|
||||
|
||||
atapi_out:
|
||||
zipbufferb[size_idx] = idx - preamble_len;
|
||||
dev->buffer[size_idx] = idx - preamble_len;
|
||||
len=idx;
|
||||
|
||||
len = MIN(len, max_len);
|
||||
@@ -2036,7 +2010,7 @@ atapi_out:
|
||||
|
||||
zip_buf_alloc(dev, 8);
|
||||
|
||||
if (zip_read_capacity(dev, dev->current_cdb, zipbufferb, (uint32_t *) &len) == 0) {
|
||||
if (zip_read_capacity(dev, dev->current_cdb, dev->buffer, (uint32_t *) &len) == 0) {
|
||||
zip_buf_free(dev);
|
||||
return;
|
||||
}
|
||||
@@ -2056,59 +2030,59 @@ atapi_out:
|
||||
len = (cdb[7] << 8) | cdb[8];
|
||||
|
||||
zip_buf_alloc(dev, len);
|
||||
memset(zipbufferb, 0, len);
|
||||
memset(dev->buffer, 0, len);
|
||||
|
||||
pos = 0;
|
||||
|
||||
/* List header */
|
||||
zipbufferb[pos++] = 0;
|
||||
zipbufferb[pos++] = 0;
|
||||
zipbufferb[pos++] = 0;
|
||||
dev->buffer[pos++] = 0;
|
||||
dev->buffer[pos++] = 0;
|
||||
dev->buffer[pos++] = 0;
|
||||
if (dev->drv->f != NULL)
|
||||
zipbufferb[pos++] = 16;
|
||||
dev->buffer[pos++] = 16;
|
||||
else
|
||||
zipbufferb[pos++] = 8;
|
||||
dev->buffer[pos++] = 8;
|
||||
|
||||
/* Current/Maximum capacity header */
|
||||
if (dev->drv->is_250) {
|
||||
if (dev->drv->f != NULL) {
|
||||
zipbufferb[pos++] = (dev->drv->medium_size >> 24) & 0xff;
|
||||
zipbufferb[pos++] = (dev->drv->medium_size >> 16) & 0xff;
|
||||
zipbufferb[pos++] = (dev->drv->medium_size >> 8) & 0xff;
|
||||
zipbufferb[pos++] = dev->drv->medium_size & 0xff;
|
||||
zipbufferb[pos++] = 2; /* Current medium capacity */
|
||||
dev->buffer[pos++] = (dev->drv->medium_size >> 24) & 0xff;
|
||||
dev->buffer[pos++] = (dev->drv->medium_size >> 16) & 0xff;
|
||||
dev->buffer[pos++] = (dev->drv->medium_size >> 8) & 0xff;
|
||||
dev->buffer[pos++] = dev->drv->medium_size & 0xff;
|
||||
dev->buffer[pos++] = 2; /* Current medium capacity */
|
||||
} else {
|
||||
zipbufferb[pos++] = (ZIP_250_SECTORS >> 24) & 0xff;
|
||||
zipbufferb[pos++] = (ZIP_250_SECTORS >> 16) & 0xff;
|
||||
zipbufferb[pos++] = (ZIP_250_SECTORS >> 8) & 0xff;
|
||||
zipbufferb[pos++] = ZIP_250_SECTORS & 0xff;
|
||||
zipbufferb[pos++] = 3; /* Maximum medium capacity */
|
||||
dev->buffer[pos++] = (ZIP_250_SECTORS >> 24) & 0xff;
|
||||
dev->buffer[pos++] = (ZIP_250_SECTORS >> 16) & 0xff;
|
||||
dev->buffer[pos++] = (ZIP_250_SECTORS >> 8) & 0xff;
|
||||
dev->buffer[pos++] = ZIP_250_SECTORS & 0xff;
|
||||
dev->buffer[pos++] = 3; /* Maximum medium capacity */
|
||||
}
|
||||
} else {
|
||||
zipbufferb[pos++] = (ZIP_SECTORS >> 24) & 0xff;
|
||||
zipbufferb[pos++] = (ZIP_SECTORS >> 16) & 0xff;
|
||||
zipbufferb[pos++] = (ZIP_SECTORS >> 8) & 0xff;
|
||||
zipbufferb[pos++] = ZIP_SECTORS & 0xff;
|
||||
dev->buffer[pos++] = (ZIP_SECTORS >> 24) & 0xff;
|
||||
dev->buffer[pos++] = (ZIP_SECTORS >> 16) & 0xff;
|
||||
dev->buffer[pos++] = (ZIP_SECTORS >> 8) & 0xff;
|
||||
dev->buffer[pos++] = ZIP_SECTORS & 0xff;
|
||||
if (dev->drv->f != NULL)
|
||||
zipbufferb[pos++] = 2;
|
||||
dev->buffer[pos++] = 2;
|
||||
else
|
||||
zipbufferb[pos++] = 3;
|
||||
dev->buffer[pos++] = 3;
|
||||
}
|
||||
|
||||
zipbufferb[pos++] = 512 >> 16;
|
||||
zipbufferb[pos++] = 512 >> 8;
|
||||
zipbufferb[pos++] = 512 & 0xff;
|
||||
dev->buffer[pos++] = 512 >> 16;
|
||||
dev->buffer[pos++] = 512 >> 8;
|
||||
dev->buffer[pos++] = 512 & 0xff;
|
||||
|
||||
if (dev->drv->f != NULL) {
|
||||
/* Formattable capacity descriptor */
|
||||
zipbufferb[pos++] = (dev->drv->medium_size >> 24) & 0xff;
|
||||
zipbufferb[pos++] = (dev->drv->medium_size >> 16) & 0xff;
|
||||
zipbufferb[pos++] = (dev->drv->medium_size >> 8) & 0xff;
|
||||
zipbufferb[pos++] = dev->drv->medium_size & 0xff;
|
||||
zipbufferb[pos++] = 0;
|
||||
zipbufferb[pos++] = 512 >> 16;
|
||||
zipbufferb[pos++] = 512 >> 8;
|
||||
zipbufferb[pos++] = 512 & 0xff;
|
||||
dev->buffer[pos++] = (dev->drv->medium_size >> 24) & 0xff;
|
||||
dev->buffer[pos++] = (dev->drv->medium_size >> 16) & 0xff;
|
||||
dev->buffer[pos++] = (dev->drv->medium_size >> 8) & 0xff;
|
||||
dev->buffer[pos++] = dev->drv->medium_size & 0xff;
|
||||
dev->buffer[pos++] = 0;
|
||||
dev->buffer[pos++] = 512 >> 16;
|
||||
dev->buffer[pos++] = 512 >> 8;
|
||||
dev->buffer[pos++] = 512 & 0xff;
|
||||
}
|
||||
|
||||
zip_set_buf_len(dev, BufLen, &len);
|
||||
@@ -2171,26 +2145,26 @@ zip_phase_data_out(zip_t *dev)
|
||||
|
||||
for (i = dev->sector_pos; i <= last_to_write; i++) {
|
||||
if (dev->current_cdb[1] & 2) {
|
||||
zipbufferb[0] = (i >> 24) & 0xff;
|
||||
zipbufferb[1] = (i >> 16) & 0xff;
|
||||
zipbufferb[2] = (i >> 8) & 0xff;
|
||||
zipbufferb[3] = i & 0xff;
|
||||
dev->buffer[0] = (i >> 24) & 0xff;
|
||||
dev->buffer[1] = (i >> 16) & 0xff;
|
||||
dev->buffer[2] = (i >> 8) & 0xff;
|
||||
dev->buffer[3] = i & 0xff;
|
||||
} else if (dev->current_cdb[1] & 4) {
|
||||
/* CHS are 96,1,2048 (ZIP 100) and 239,1,2048 (ZIP 250) */
|
||||
s = (i % 2048);
|
||||
h = ((i - s) / 2048) % 1;
|
||||
c = ((i - s) / 2048) / 1;
|
||||
zipbufferb[0] = (c >> 16) & 0xff;
|
||||
zipbufferb[1] = (c >> 8) & 0xff;
|
||||
zipbufferb[2] = c & 0xff;
|
||||
zipbufferb[3] = h & 0xff;
|
||||
zipbufferb[4] = (s >> 24) & 0xff;
|
||||
zipbufferb[5] = (s >> 16) & 0xff;
|
||||
zipbufferb[6] = (s >> 8) & 0xff;
|
||||
zipbufferb[7] = s & 0xff;
|
||||
dev->buffer[0] = (c >> 16) & 0xff;
|
||||
dev->buffer[1] = (c >> 8) & 0xff;
|
||||
dev->buffer[2] = c & 0xff;
|
||||
dev->buffer[3] = h & 0xff;
|
||||
dev->buffer[4] = (s >> 24) & 0xff;
|
||||
dev->buffer[5] = (s >> 16) & 0xff;
|
||||
dev->buffer[6] = (s >> 8) & 0xff;
|
||||
dev->buffer[7] = s & 0xff;
|
||||
}
|
||||
fseek(dev->drv->f, dev->drv->base + (i << 9), SEEK_SET);
|
||||
fwrite(zipbufferb, 1, 512, dev->drv->f);
|
||||
fwrite(dev->buffer, 1, 512, dev->drv->f);
|
||||
}
|
||||
break;
|
||||
case GPCMD_MODE_SELECT_6:
|
||||
@@ -2202,13 +2176,13 @@ zip_phase_data_out(zip_t *dev)
|
||||
|
||||
if (dev->drv->bus_type == ZIP_BUS_SCSI) {
|
||||
if (dev->current_cdb[0] == GPCMD_MODE_SELECT_6) {
|
||||
block_desc_len = zipbufferb[2];
|
||||
block_desc_len = dev->buffer[2];
|
||||
block_desc_len <<= 8;
|
||||
block_desc_len |= zipbufferb[3];
|
||||
block_desc_len |= dev->buffer[3];
|
||||
} else {
|
||||
block_desc_len = zipbufferb[6];
|
||||
block_desc_len = dev->buffer[6];
|
||||
block_desc_len <<= 8;
|
||||
block_desc_len |= zipbufferb[7];
|
||||
block_desc_len |= dev->buffer[7];
|
||||
}
|
||||
} else
|
||||
block_desc_len = 0;
|
||||
@@ -2216,8 +2190,8 @@ zip_phase_data_out(zip_t *dev)
|
||||
pos = hdr_len + block_desc_len;
|
||||
|
||||
while(1) {
|
||||
page = zipbufferb[pos] & 0x3F;
|
||||
page_len = zipbufferb[pos + 1];
|
||||
page = dev->buffer[pos] & 0x3F;
|
||||
page_len = dev->buffer[pos + 1];
|
||||
|
||||
pos += 2;
|
||||
|
||||
@@ -2226,7 +2200,7 @@ zip_phase_data_out(zip_t *dev)
|
||||
else {
|
||||
for (i = 0; i < page_len; i++) {
|
||||
ch = zip_mode_sense_pages_changeable.pages[page][i + 2];
|
||||
val = zipbufferb[pos + i];
|
||||
val = dev->buffer[pos + i];
|
||||
old_val = dev->ms_pages_saved.pages[page][i + 2];
|
||||
if (val != old_val) {
|
||||
if (ch)
|
||||
@@ -2322,7 +2296,7 @@ zip_read_from_ide_dma(zip_t *dev)
|
||||
|
||||
if (ide_bus_master_write) {
|
||||
ret = ide_bus_master_write(dev->drv->bus_id.ide_channel >> 1,
|
||||
zipbufferb, dev->packet_len,
|
||||
dev->buffer, dev->packet_len,
|
||||
ide_bus_master_priv[dev->drv->bus_id.ide_channel >> 1]);
|
||||
if (ret == 2) /* DMA not enabled, wait for it to be enabled. */
|
||||
return 2;
|
||||
@@ -2346,7 +2320,7 @@ zip_read_from_scsi_dma(scsi_device_t *sd, UNUSED(uint8_t scsi_id))
|
||||
return 0;
|
||||
|
||||
DEBUG("Reading from SCSI DMA: SCSI ID %02X, init length %i\n", scsi_id, *BufLen);
|
||||
memcpy(zipbufferb, sd->cmd_buffer, *BufLen);
|
||||
memcpy(dev->buffer, sd->cmd_buffer, *BufLen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2400,7 +2374,7 @@ zip_write_to_ide_dma(zip_t *dev)
|
||||
|
||||
if (ide_bus_master_read) {
|
||||
ret = ide_bus_master_read(dev->drv->bus_id.ide_channel >> 1,
|
||||
zipbufferb, dev->packet_len,
|
||||
dev->buffer, dev->packet_len,
|
||||
ide_bus_master_priv[dev->drv->bus_id.ide_channel >> 1]);
|
||||
if (ret == 2) /* DMA not enabled, wait for it to be enabled. */
|
||||
return 2;
|
||||
@@ -2424,10 +2398,10 @@ zip_write_to_scsi_dma(scsi_device_t *sd, UNUSED(uint8_t scsi_id))
|
||||
return 0;
|
||||
|
||||
DEBUG("Writing to SCSI DMA: SCSI ID %02X, init length %i\n", scsi_id, BufLen);
|
||||
memcpy(sd->cmd_buffer, zipbufferb, BufLen);
|
||||
memcpy(sd->cmd_buffer, dev->buffer, BufLen);
|
||||
DEBUG("ZIP %i: Data from CD buffer: %02X %02X %02X %02X %02X %02X %02X %02X\n", dev->id,
|
||||
zipbufferb[0], zipbufferb[1], zipbufferb[2], zipbufferb[3], zipbufferb[4], zipbufferb[5],
|
||||
zipbufferb[6], zipbufferb[7]);
|
||||
dev->buffer[0], dev->buffer[1], dev->buffer[2], dev->buffer[3], dev->buffer[4], dev->buffer[5],
|
||||
dev->buffer[6], dev->buffer[7]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2472,7 +2446,7 @@ zip_callback(void *p)
|
||||
case PHASE_COMMAND:
|
||||
DEBUG("ZIP %i: PHASE_COMMAND\n", dev->id);
|
||||
dev->status = BUSY_STAT | (dev->status & ERR_STAT);
|
||||
memcpy(dev->atapi_cdb, zipbufferb, 12);
|
||||
memcpy(dev->atapi_cdb, dev->buffer, 12);
|
||||
zip_command(dev, dev->atapi_cdb);
|
||||
return;
|
||||
case PHASE_COMPLETE:
|
||||
@@ -2552,10 +2526,10 @@ zip_packet_read(void *p, int length)
|
||||
if (!dev)
|
||||
return 0;
|
||||
|
||||
zipbufferw = (uint16_t *) zipbufferb;
|
||||
zipbufferl = (uint32_t *) zipbufferb;
|
||||
zipbufferw = (uint16_t *) dev->buffer;
|
||||
zipbufferl = (uint32_t *) dev->buffer;
|
||||
|
||||
if (!zipbufferb)
|
||||
if (!dev->buffer)
|
||||
return 0;
|
||||
|
||||
/* Make sure we return a 0 and don't attempt to read from the buffer if we're transferring bytes beyond it,
|
||||
@@ -2563,7 +2537,7 @@ zip_packet_read(void *p, int length)
|
||||
(which is 1 sector = 512 bytes). */
|
||||
switch(length) {
|
||||
case 1:
|
||||
temp = (dev->pos < dev->packet_len) ? zipbufferb[dev->pos] : 0;
|
||||
temp = (dev->pos < dev->packet_len) ? dev->buffer[dev->pos] : 0;
|
||||
dev->pos++;
|
||||
dev->request_pos++;
|
||||
break;
|
||||
@@ -2604,19 +2578,19 @@ zip_packet_write(void *p, uint32_t val, int length)
|
||||
return;
|
||||
|
||||
if (dev->packet_status == PHASE_IDLE) {
|
||||
if (!zipbufferb)
|
||||
if (!dev->buffer)
|
||||
zip_buf_alloc(dev, 12);
|
||||
}
|
||||
|
||||
zipbufferw = (uint16_t *) zipbufferb;
|
||||
zipbufferl = (uint32_t *) zipbufferb;
|
||||
zipbufferw = (uint16_t *) dev->buffer;
|
||||
zipbufferl = (uint32_t *) dev->buffer;
|
||||
|
||||
if (!zipbufferb)
|
||||
if (!dev->buffer)
|
||||
return;
|
||||
|
||||
switch(length) {
|
||||
case 1:
|
||||
zipbufferb[dev->pos] = val & 0xff;
|
||||
dev->buffer[dev->pos] = val & 0xff;
|
||||
dev->pos++;
|
||||
dev->request_pos++;
|
||||
break;
|
||||
@@ -2659,7 +2633,6 @@ void
|
||||
zip_global_init(void)
|
||||
{
|
||||
/* Clear the global data. */
|
||||
memset(zip, 0x00, sizeof(zip));
|
||||
memset(zip_drives, 0x00, sizeof(zip_drives));
|
||||
}
|
||||
|
||||
@@ -2688,22 +2661,24 @@ zip_250_identify(ide_t *ide, int ide_has_dma)
|
||||
static int
|
||||
zip_get_max(int ide_has_dma, int type)
|
||||
{
|
||||
int ret;
|
||||
int ret = -1;
|
||||
|
||||
switch(type) {
|
||||
case TYPE_PIO:
|
||||
ret = ide_has_dma ? 3 : 0;
|
||||
break;
|
||||
case TYPE_SDMA:
|
||||
default:
|
||||
ret = -1;
|
||||
break;
|
||||
|
||||
case TYPE_MDMA:
|
||||
ret = ide_has_dma ? -1 : 1;
|
||||
break;
|
||||
|
||||
case TYPE_UDMA:
|
||||
ret = ide_has_dma ? -1 : 2;
|
||||
break;
|
||||
|
||||
case TYPE_SDMA:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -2713,20 +2688,22 @@ zip_get_max(int ide_has_dma, int type)
|
||||
static int
|
||||
zip_get_timings(int ide_has_dma, int type)
|
||||
{
|
||||
int ret;
|
||||
int ret = 0;
|
||||
|
||||
switch(type) {
|
||||
case TIMINGS_DMA:
|
||||
ret = ide_has_dma ? 0x96 : 0;
|
||||
break;
|
||||
|
||||
case TIMINGS_PIO:
|
||||
ret = ide_has_dma ? 0xb4 : 0;
|
||||
break;
|
||||
|
||||
case TIMINGS_PIO_FC:
|
||||
ret = ide_has_dma ? 0xb4 : 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2737,10 +2714,8 @@ zip_get_timings(int ide_has_dma, int type)
|
||||
static void
|
||||
zip_identify(void *p, int ide_has_dma)
|
||||
{
|
||||
ide_t *ide = (ide_t *) p;
|
||||
zip_t *zip;
|
||||
|
||||
zip = (zip_t *) ide->p;
|
||||
ide_t *ide = (ide_t *)p;
|
||||
zip_t *zip = (zip_t *)ide->p;
|
||||
|
||||
/* Using (2<<5) below makes the ASUS P/I-P54TP4XE misdentify the ZIP drive
|
||||
as a LS-120. */
|
||||
@@ -2756,24 +2731,49 @@ zip_identify(void *p, int ide_has_dma)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
zip_init(zip_t *dev)
|
||||
{
|
||||
dev->requested_blocks = 1;
|
||||
dev->sense[0] = 0xf0;
|
||||
dev->sense[7] = 10;
|
||||
|
||||
dev->drv->bus_mode = 0;
|
||||
if (dev->drv->bus_type >= ZIP_BUS_ATAPI)
|
||||
dev->drv->bus_mode |= 2;
|
||||
if (dev->drv->bus_type < ZIP_BUS_SCSI)
|
||||
dev->drv->bus_mode |= 1;
|
||||
DEBUG("ZIP %i: Bus type %i, bus mode %i\n", dev->id, dev->drv->bus_type, dev->drv->bus_mode);
|
||||
if (dev->drv->bus_type < ZIP_BUS_SCSI)
|
||||
zip_set_signature(dev);
|
||||
dev->status = READY_STAT | DSC_STAT;
|
||||
dev->pos = 0;
|
||||
dev->packet_status = 0xff;
|
||||
zip_sense_key = zip_asc = zip_ascq = dev->unit_attention = 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
zip_drive_reset(int c)
|
||||
{
|
||||
scsi_device_t *sd;
|
||||
zip_t *dev;
|
||||
ide_t *id;
|
||||
|
||||
if (!zip[c]) {
|
||||
zip[c] = (zip_t *)mem_alloc(sizeof(zip_t));
|
||||
memset(zip[c], 0x00, sizeof(zip_t));
|
||||
dev = (zip_t *)zip_drives[c].priv;
|
||||
if (dev == NULL) {
|
||||
dev = (zip_t *)mem_alloc(sizeof(zip_t));
|
||||
memset(dev, 0x00, sizeof(zip_t));
|
||||
zip_drives[c].priv = dev;
|
||||
}
|
||||
|
||||
zip[c]->id = c;
|
||||
dev->id = c;
|
||||
dev->drv = &zip_drives[c];
|
||||
|
||||
if (zip_drives[c].bus_type == ZIP_BUS_SCSI) {
|
||||
/* SCSI ZIP, attach to the SCSI bus. */
|
||||
sd = &scsi_devices[zip_drives[c].bus_id.scsi.id][zip_drives[c].bus_id.scsi.lun];
|
||||
|
||||
sd->p = zip[c];
|
||||
sd->p = dev;
|
||||
sd->command = zip_command;
|
||||
sd->callback = zip_callback;
|
||||
sd->err_stat_to_scsi = zip_err_stat_to_scsi;
|
||||
@@ -2781,14 +2781,17 @@ zip_drive_reset(int c)
|
||||
sd->reset = zip_reset;
|
||||
sd->read_capacity = zip_read_capacity;
|
||||
sd->type = SCSI_REMOVABLE_DISK;
|
||||
|
||||
DEBUG("SCSI ZIP drive %i attached to SCSI ID %i\n",
|
||||
c, dev->drv->bus_id.scsi.id);
|
||||
} else if (zip_drives[c].bus_type == ZIP_BUS_ATAPI) {
|
||||
/* ATAPI CD-ROM, attach to the IDE bus. */
|
||||
id = ide_drives[zip_drives[c].bus_id.ide_channel];
|
||||
/* If the IDE channel is initialized, we attach to it,
|
||||
otherwise, we do nothing - it's going to be a drive
|
||||
that's not attached to anything. */
|
||||
if (id) {
|
||||
id->p = zip[c];
|
||||
if (id != NULL) {
|
||||
id->p = dev;
|
||||
id->get_max = zip_get_max;
|
||||
id->get_timings = zip_get_timings;
|
||||
id->identify = zip_identify;
|
||||
@@ -2801,6 +2804,9 @@ zip_drive_reset(int c)
|
||||
id->interrupt_drq = 1;
|
||||
|
||||
ide_atapi_attach(id);
|
||||
|
||||
DEBUG("ATAPI ZIP drive %i attached to IDE channel %i\n",
|
||||
c, dev->drv->bus_id.ide_channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2809,6 +2815,7 @@ zip_drive_reset(int c)
|
||||
void
|
||||
zip_hard_reset(void)
|
||||
{
|
||||
zip_t *dev;
|
||||
int c;
|
||||
|
||||
for (c = 0; c < ZIP_NUM; c++) {
|
||||
@@ -2825,20 +2832,14 @@ zip_hard_reset(void)
|
||||
|
||||
zip_drive_reset(c);
|
||||
|
||||
zip[c]->id = c;
|
||||
zip[c]->drv = &zip_drives[c];
|
||||
dev = (zip_t *)zip_drives[c].priv;
|
||||
|
||||
zip_init(zip[c]);
|
||||
zip_init(dev);
|
||||
|
||||
if (wcslen(zip_drives[c].image_path))
|
||||
zip_load(zip[c], zip_drives[c].image_path);
|
||||
if (wcslen(dev->drv->image_path))
|
||||
zip_load(dev, dev->drv->image_path);
|
||||
|
||||
zip_mode_sense_load(zip[c]);
|
||||
|
||||
if (zip_drives[c].bus_type == ZIP_BUS_SCSI)
|
||||
DEBUG("SCSI ZIP drive %i attached to SCSI ID %i\n", c, zip_drives[c].bus_id.scsi.id);
|
||||
else if (zip_drives[c].bus_type == ZIP_BUS_ATAPI)
|
||||
DEBUG("ATAPI ZIP drive %i attached to IDE channel %i\n", c, zip_drives[c].bus_id.ide_channel);
|
||||
zip_mode_sense_load(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2851,13 +2852,14 @@ zip_close(void)
|
||||
int c;
|
||||
|
||||
for (c = 0; c < ZIP_NUM; c++) {
|
||||
dev = zip[c];
|
||||
dev = (zip_t *)zip_drives[c].priv;
|
||||
|
||||
if (dev) {
|
||||
if (dev != NULL) {
|
||||
zip_disk_close(dev);
|
||||
|
||||
free(zip[c]);
|
||||
zip[c] = NULL;
|
||||
free(dev);
|
||||
|
||||
zip_drives[c].priv = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2869,8 +2871,8 @@ zip_reset_bus(int bus)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ZIP_NUM; i++) {
|
||||
if (zip_drives[i].bus_type == ZIP_BUS_ATAPI)
|
||||
zip_reset(zip[i]);
|
||||
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && zip_drives[i].priv)
|
||||
zip_reset(zip_drives[i].priv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Implementation of the Iomega ZIP drive with SCSI(-like)
|
||||
* commands, for both ATAPI and SCSI usage.
|
||||
*
|
||||
* Version: @(#)zip.h 1.0.9 2018/10/17
|
||||
* Version: @(#)zip.h 1.0.10 2018/10/25
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
@@ -72,12 +72,15 @@ typedef struct {
|
||||
} scsi;
|
||||
} bus_id;
|
||||
|
||||
wchar_t image_path[1024],
|
||||
prev_image_path[1024];
|
||||
|
||||
uint32_t medium_size,
|
||||
base;
|
||||
|
||||
void *priv;
|
||||
|
||||
FILE *f;
|
||||
|
||||
wchar_t image_path[1024],
|
||||
prev_image_path[1024];
|
||||
} zip_drive_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -113,7 +116,6 @@ typedef struct {
|
||||
} zip_t;
|
||||
|
||||
|
||||
extern zip_t *zip[ZIP_NUM];
|
||||
extern zip_drive_t zip_drives[ZIP_NUM];
|
||||
extern uint8_t atapi_zip_drives[8];
|
||||
extern uint8_t scsi_zip_drives[16][8];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Emulation of SCSI fixed disks.
|
||||
*
|
||||
* Version: @(#)scsi_disk.c 1.0.18 2018/10/20
|
||||
* Version: @(#)scsi_disk.c 1.0.19 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -76,10 +76,6 @@
|
||||
#define scsi_disk_ascq dev->sense[13]
|
||||
|
||||
|
||||
scsi_disk_t *scsi_disk[HDD_NUM] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
|
||||
|
||||
|
||||
/* Table of all SCSI commands and their flags, needed for the new disc change / not ready handler. */
|
||||
const uint8_t scsi_disk_command_flags[0x100] = {
|
||||
IMPLEMENTED | CHECK_READY | NONDATA, /* 0x00 */
|
||||
@@ -1278,63 +1274,56 @@ scsi_disk_callback(void *p)
|
||||
}
|
||||
|
||||
|
||||
/* Peform a master init on the entire module. */
|
||||
void
|
||||
scsi_disk_global_init(void)
|
||||
{
|
||||
/* Clear the global data. */
|
||||
memset(scsi_disk, 0x00, sizeof(scsi_disk));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
scsi_disk_hard_reset(void)
|
||||
{
|
||||
int c;
|
||||
scsi_device_t *sd;
|
||||
scsi_disk_t *dev;
|
||||
int c;
|
||||
|
||||
for (c = 0; c < HDD_NUM; c++) {
|
||||
if (hdd[c].bus == HDD_BUS_SCSI) {
|
||||
DEBUG("SCSI disk hard_reset drive=%d\n", c);
|
||||
if (hdd[c].bus != HDD_BUS_SCSI) continue;
|
||||
|
||||
/* Make sure to ignore any SCSI disk that has an out of range ID. */
|
||||
if (hdd[c].bus_id.scsi.id > SCSI_ID_MAX)
|
||||
continue;
|
||||
if (hdd[c].bus_id.scsi.lun > SCSI_LUN_MAX)
|
||||
continue;
|
||||
DEBUG("SCSI disk hard_reset drive=%d\n", c);
|
||||
|
||||
/* Make sure to ignore any SCSI disk whose image file name is empty. */
|
||||
if (wcslen(hdd[c].fn) == 0)
|
||||
continue;
|
||||
/* Make sure to ignore any SCSI disk that has an out of range ID. */
|
||||
if (hdd[c].bus_id.scsi.id > SCSI_ID_MAX)
|
||||
continue;
|
||||
if (hdd[c].bus_id.scsi.lun > SCSI_LUN_MAX)
|
||||
continue;
|
||||
|
||||
/* Make sure to ignore any SCSI disk whose image fails to load. */
|
||||
if (! hdd_image_load(c))
|
||||
continue;
|
||||
/* Make sure to ignore any SCSI disk whose image file name is empty. */
|
||||
if (wcslen(hdd[c].fn) == 0)
|
||||
continue;
|
||||
|
||||
if (! scsi_disk[c]) {
|
||||
scsi_disk[c] = (scsi_disk_t *)mem_alloc(sizeof(scsi_disk_t));
|
||||
memset(scsi_disk[c], 0, sizeof(scsi_disk_t));
|
||||
}
|
||||
/* Make sure to ignore any SCSI disk whose image fails to load. */
|
||||
if (! hdd_image_load(c))
|
||||
continue;
|
||||
|
||||
/* SCSI disk, attach to the SCSI bus. */
|
||||
sd = &scsi_devices[hdd[c].bus_id.scsi.id][hdd[c].bus_id.scsi.lun];
|
||||
|
||||
sd->p = scsi_disk[c];
|
||||
sd->command = scsi_disk_command;
|
||||
sd->callback = scsi_disk_callback;
|
||||
sd->err_stat_to_scsi = scsi_disk_err_stat_to_scsi;
|
||||
sd->request_sense = scsi_disk_request_sense_for_scsi;
|
||||
sd->reset = scsi_disk_reset;
|
||||
sd->read_capacity = scsi_disk_read_capacity;
|
||||
sd->type = SCSI_FIXED_DISK;
|
||||
|
||||
scsi_disk[c]->id = c;
|
||||
scsi_disk[c]->drv = &hdd[c];
|
||||
|
||||
scsi_disk_mode_sense_load(scsi_disk[c]);
|
||||
|
||||
DEBUG("SCSI disk %i attached to ID %i LUN %i\n", c, hdd[c].bus_id.scsi.id, hdd[c].bus_id.scsi.lun);
|
||||
dev = (scsi_disk_t *)hdd[c].priv;
|
||||
if (dev == NULL) {
|
||||
dev = (scsi_disk_t *)mem_alloc(sizeof(scsi_disk_t));
|
||||
memset(dev, 0x00, sizeof(scsi_disk_t));
|
||||
}
|
||||
dev->id = c;
|
||||
dev->drv = &hdd[c];
|
||||
|
||||
/* SCSI disk, attach to the SCSI bus. */
|
||||
sd = &scsi_devices[hdd[c].bus_id.scsi.id][hdd[c].bus_id.scsi.lun];
|
||||
|
||||
sd->p = dev;
|
||||
sd->command = scsi_disk_command;
|
||||
sd->callback = scsi_disk_callback;
|
||||
sd->err_stat_to_scsi = scsi_disk_err_stat_to_scsi;
|
||||
sd->request_sense = scsi_disk_request_sense_for_scsi;
|
||||
sd->reset = scsi_disk_reset;
|
||||
sd->read_capacity = scsi_disk_read_capacity;
|
||||
sd->type = SCSI_FIXED_DISK;
|
||||
|
||||
scsi_disk_mode_sense_load(dev);
|
||||
|
||||
DEBUG("SCSI disk %i attached to ID %i LUN %i\n",
|
||||
c, hdd[c].bus_id.scsi.id, hdd[c].bus_id.scsi.lun);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1346,13 +1335,14 @@ scsi_disk_close(void)
|
||||
int c;
|
||||
|
||||
for (c = 0; c < HDD_NUM; c++) {
|
||||
dev = scsi_disk[c];
|
||||
dev = (scsi_disk_t *)hdd[c].priv;
|
||||
|
||||
if (dev) {
|
||||
if (dev != NULL) {
|
||||
hdd_image_close(c);
|
||||
|
||||
free(scsi_disk[c]);
|
||||
scsi_disk[c] = NULL;
|
||||
free(dev);
|
||||
|
||||
hdd[c].priv = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Emulation of SCSI fixed and removable disks.
|
||||
*
|
||||
* Version: @(#)scsi_disk.h 1.0.5 2018/10/19
|
||||
* Version: @(#)scsi_disk.h 1.0.6 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -67,16 +67,12 @@ typedef struct {
|
||||
} scsi_disk_t;
|
||||
|
||||
|
||||
extern scsi_disk_t *scsi_disk[HDD_NUM];
|
||||
|
||||
|
||||
#ifdef USE_REMOVABLE_DISK
|
||||
extern void scsi_disk_insert(int id);
|
||||
extern void scsi_reloadhd(int id);
|
||||
extern void scsi_unloadhd(int scsi_id, int scsi_lun, int id);
|
||||
#endif
|
||||
|
||||
extern void scsi_disk_global_init(void);
|
||||
extern void scsi_disk_hard_reset(void);
|
||||
extern void scsi_disk_close(void);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* website (for 32bit and 64bit Windows) are working, and
|
||||
* need no additional support files other than sound fonts.
|
||||
*
|
||||
* Version: @(#)midi_fluidsynth.c 1.0.13 2018/10/14
|
||||
* Version: @(#)midi_fluidsynth.c 1.0.14 2018/10/25
|
||||
*
|
||||
* Code borrowed from scummvm.
|
||||
*
|
||||
@@ -185,8 +185,7 @@ fluidsynth_thread(void *param)
|
||||
f_fluid_synth_write_float(data->synth, buf_size/(2 * sizeof(float)), buf, 0, 2, buf, 1, 2);
|
||||
buf_pos += buf_size;
|
||||
if (buf_pos >= data->buf_size) {
|
||||
if (soundon)
|
||||
openal_buffer_midi(data->buffer, data->buf_size / sizeof(float));
|
||||
openal_buffer_midi(data->buffer, data->buf_size / sizeof(float));
|
||||
buf_pos = 0;
|
||||
}
|
||||
} else {
|
||||
@@ -196,27 +195,10 @@ fluidsynth_thread(void *param)
|
||||
f_fluid_synth_write_s16(data->synth, buf_size/(2 * sizeof(int16_t)), buf, 0, 2, buf, 1, 2);
|
||||
buf_pos += buf_size;
|
||||
if (buf_pos >= data->buf_size) {
|
||||
if (soundon)
|
||||
openal_buffer_midi(data->buffer_int16, data->buf_size / sizeof(int16_t));
|
||||
openal_buffer_midi(data->buffer_int16, data->buf_size / sizeof(int16_t));
|
||||
buf_pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (sound_is_float) {
|
||||
memset(data->buffer, 0, data->buf_size * sizeof(float));
|
||||
if (data->synth)
|
||||
f_fluid_synth_write_float(data->synth, data->buf_size/2, data->buffer, 0, 2, data->buffer, 1, 2);
|
||||
if (soundon)
|
||||
openal_buffer_midi(data->buffer, data->buf_size);
|
||||
} else {
|
||||
memset(data->buffer, 0, data->buf_size * sizeof(int16_t));
|
||||
if (data->synth)
|
||||
f_fluid_synth_write_s16(data->synth, data->buf_size/2, data->buffer_int16, 0, 2, data->buffer_int16, 1, 2);
|
||||
if (soundon)
|
||||
openal_buffer_midi(data->buffer_int16, data->buf_size);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Interface to the MuNT32 MIDI synthesizer.
|
||||
*
|
||||
* Version: @(#)midi_mt32.c 1.0.6 2018/10/14
|
||||
* Version: @(#)midi_mt32.c 1.0.7 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -100,25 +100,21 @@ static const mt32emu_report_handler_i_v0 handler_v0 = {
|
||||
#define BUFFER_SEGMENTS 10
|
||||
|
||||
|
||||
static thread_t *thread_h = NULL;
|
||||
static event_t *event = NULL;
|
||||
static event_t *start_event = NULL;
|
||||
static volatile int mt32_on = 0;
|
||||
static uint32_t samplerate = 44100;
|
||||
static int buf_size = 0;
|
||||
static float* buffer = NULL;
|
||||
static int16_t* buffer_int16 = NULL;
|
||||
static int midi_pos = 0;
|
||||
static thread_t *thread_h = NULL;
|
||||
static event_t *event = NULL;
|
||||
static event_t *start_event = NULL;
|
||||
static volatile int mt32_on = 0;
|
||||
static uint32_t samplerate = 44100;
|
||||
static int buf_size = 0;
|
||||
static float *buffer = NULL;
|
||||
static int16_t *buffer_int16 = NULL;
|
||||
static int midi_pos = 0;
|
||||
static const mt32emu_report_handler_i handler = { &handler_v0 };
|
||||
static mt32emu_context context = NULL;
|
||||
static int mtroms_present[2] = {-1, -1};
|
||||
static mt32emu_context context = NULL;
|
||||
static int mtroms_present[2] = {-1, -1};
|
||||
|
||||
|
||||
#if 1
|
||||
int
|
||||
#else
|
||||
mt32emu_return_code
|
||||
#endif
|
||||
int /*mt32emu_return_code*/
|
||||
mt32_check(const char *func, mt32emu_return_code ret, mt32emu_return_code expected)
|
||||
{
|
||||
if (ret != expected) {
|
||||
@@ -195,8 +191,7 @@ mt32_thread(void *param)
|
||||
mt32_stream(buf, bsize / (2 * sizeof(float)));
|
||||
buf_pos += bsize;
|
||||
if (buf_pos >= buf_size) {
|
||||
if (soundon)
|
||||
openal_buffer_midi(buffer, buf_size / sizeof(float));
|
||||
openal_buffer_midi(buffer, buf_size / sizeof(float));
|
||||
buf_pos = 0;
|
||||
}
|
||||
} else {
|
||||
@@ -206,8 +201,7 @@ mt32_thread(void *param)
|
||||
mt32_stream_int16(buf16, bsize / (2 * sizeof(int16_t)));
|
||||
buf_pos += bsize;
|
||||
if (buf_pos >= buf_size) {
|
||||
if (soundon)
|
||||
openal_buffer_midi(buffer_int16, buf_size / sizeof(int16_t));
|
||||
openal_buffer_midi(buffer_int16, buf_size / sizeof(int16_t));
|
||||
buf_pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
* NOTE: See MSC_ macros for allocation on stack. --FvK
|
||||
*
|
||||
* Version: @(#)snd_dbopl.cpp 1.0.7 2018/09/22
|
||||
* Version: @(#)snd_dbopl.cpp 1.0.8 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -210,7 +210,7 @@ void opl2_update(int nr, int16_t *buffer, int samples)
|
||||
buffer_32 = (Bit32s *)mem_alloc(buffer_sz);
|
||||
}
|
||||
#else
|
||||
Bit32s buffer_32[SOUNDBUFLEN];
|
||||
Bit32s buffer_32[SOUNDBUFLEN * 2];
|
||||
#endif
|
||||
int c;
|
||||
|
||||
@@ -244,7 +244,7 @@ void opl3_update(int nr, int16_t *buffer, int samples)
|
||||
buffer_32 = (Bit32s *)mem_alloc(buffer_sz);
|
||||
}
|
||||
#else
|
||||
Bit32s buffer_32[SOUNDBUFLEN];
|
||||
Bit32s buffer_32[SOUNDBUFLEN * 2];
|
||||
#endif
|
||||
int c;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Sound Blaster emulation.
|
||||
*
|
||||
* Version: @(#)snd_sb.c 1.0.8 2018/10/16
|
||||
* Version: @(#)snd_sb.c 1.0.9 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -71,7 +71,7 @@ FILE* soundfsbin = 0/*NULL*/;
|
||||
|
||||
|
||||
/* SB 2.0 CD version */
|
||||
typedef struct sb_ct1335_mixer_t
|
||||
typedef struct
|
||||
{
|
||||
int32_t master;
|
||||
int32_t voice;
|
||||
@@ -81,8 +81,9 @@ typedef struct sb_ct1335_mixer_t
|
||||
uint8_t index;
|
||||
uint8_t regs[256];
|
||||
} sb_ct1335_mixer_t;
|
||||
|
||||
/* SB PRO */
|
||||
typedef struct sb_ct1345_mixer_t
|
||||
typedef struct
|
||||
{
|
||||
int32_t master_l, master_r;
|
||||
int32_t voice_l, voice_r;
|
||||
@@ -104,8 +105,9 @@ typedef struct sb_ct1345_mixer_t
|
||||
uint8_t regs[256];
|
||||
|
||||
} sb_ct1345_mixer_t;
|
||||
|
||||
/* SB16 and AWE32 */
|
||||
typedef struct sb_ct1745_mixer_t
|
||||
typedef struct
|
||||
{
|
||||
int32_t master_l, master_r;
|
||||
int32_t voice_l, voice_r;
|
||||
@@ -146,7 +148,7 @@ typedef struct sb_ct1745_mixer_t
|
||||
uint8_t regs[256];
|
||||
} sb_ct1745_mixer_t;
|
||||
|
||||
typedef struct sb_t
|
||||
typedef struct
|
||||
{
|
||||
uint8_t opl_enabled;
|
||||
opl_t opl;
|
||||
@@ -158,9 +160,6 @@ typedef struct sb_t
|
||||
};
|
||||
mpu_t *mpu;
|
||||
emu8k_t emu8k;
|
||||
#if 0
|
||||
sb_ct1745_mixer_t temp_mixer_sb16;
|
||||
#endif
|
||||
|
||||
int pos;
|
||||
|
||||
@@ -168,6 +167,8 @@ typedef struct sb_t
|
||||
|
||||
int opl_emu;
|
||||
} sb_t;
|
||||
|
||||
|
||||
/* 0 to 7 -> -14dB to 0dB i 2dB steps. 8 to 15 -> 0 to +14dB in 2dB steps.
|
||||
Note that for positive dB values, this is not amplitude, it is amplitude-1. */
|
||||
const float sb_bass_treble_4bits[]= {
|
||||
@@ -300,44 +301,6 @@ static void sb_get_buffer_sbpro(int32_t *buffer, int len, void *p)
|
||||
sb->dsp.pos = 0;
|
||||
}
|
||||
|
||||
// FIXME: See why this causes weird audio glitches in some situations.
|
||||
#if 0
|
||||
static void sb_process_buffer_sb16(int32_t *buffer, int len, void *p)
|
||||
{
|
||||
sb_t *sb = (sb_t *)p;
|
||||
sb_ct1745_mixer_t *mixer = &sb->temp_mixer_sb16;
|
||||
|
||||
int c;
|
||||
|
||||
for (c = 0; c < len * 2; c += 2)
|
||||
{
|
||||
int32_t out_l = 0, out_r = 0;
|
||||
|
||||
out_l = ((int32_t)(low_fir_sb16(0, (float)buffer[c]) * mixer->cd_l) / 3) >> 15;
|
||||
out_r = ((int32_t)(low_fir_sb16(1, (float)buffer[c + 1]) * mixer->cd_r) / 3) >> 15;
|
||||
|
||||
out_l = (out_l * mixer->master_l) >> 15;
|
||||
out_r = (out_r * mixer->master_r) >> 15;
|
||||
|
||||
if (mixer->bass_l != 8 || mixer->bass_r != 8 || mixer->treble_l != 8 || mixer->treble_r != 8)
|
||||
{
|
||||
/* This is not exactly how one does bass/treble controls, but the end result is like it. A better implementation would reduce the cpu usage */
|
||||
if (mixer->bass_l>8) out_l += (int32_t)(low_iir(0, (float)out_l)*sb_bass_treble_4bits[mixer->bass_l]);
|
||||
if (mixer->bass_r>8) out_r += (int32_t)(low_iir(1, (float)out_r)*sb_bass_treble_4bits[mixer->bass_r]);
|
||||
if (mixer->treble_l>8) out_l += (int32_t)(high_iir(0, (float)out_l)*sb_bass_treble_4bits[mixer->treble_l]);
|
||||
if (mixer->treble_r>8) out_r += (int32_t)(high_iir(1, (float)out_r)*sb_bass_treble_4bits[mixer->treble_r]);
|
||||
if (mixer->bass_l<8) out_l = (int32_t)((out_l )*sb_bass_treble_4bits[mixer->bass_l] + low_cut_iir(0, (float)out_l)*(1.f-sb_bass_treble_4bits[mixer->bass_l]));
|
||||
if (mixer->bass_r<8) out_r = (int32_t)((out_r )*sb_bass_treble_4bits[mixer->bass_r] + low_cut_iir(1, (float)out_r)*(1.f-sb_bass_treble_4bits[mixer->bass_r]));
|
||||
if (mixer->treble_l<8) out_l = (int32_t)((out_l )*sb_bass_treble_4bits[mixer->treble_l] + high_cut_iir(0, (float)out_l)*(1.f-sb_bass_treble_4bits[mixer->treble_l]));
|
||||
if (mixer->treble_r<8) out_r = (int32_t)((out_r )*sb_bass_treble_4bits[mixer->treble_r] + high_cut_iir(1, (float)out_r)*(1.f-sb_bass_treble_4bits[mixer->treble_r]));
|
||||
}
|
||||
|
||||
buffer[c] = (out_l << mixer->output_gain_L);
|
||||
buffer[c + 1] = (out_r << mixer->output_gain_R);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void sb_get_buffer_sb16(int32_t *buffer, int len, void *p)
|
||||
{
|
||||
sb_t *sb = (sb_t *)p;
|
||||
@@ -409,15 +372,16 @@ static void sb_get_buffer_sb16(int32_t *buffer, int len, void *p)
|
||||
sb->pos = 0;
|
||||
sb->opl.pos = 0;
|
||||
sb->dsp.pos = 0;
|
||||
#if 0
|
||||
memcpy(&sb->temp_mixer_sb16, &sb->mixer_sb16, sizeof(sb_ct1745_mixer_t));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef SB_DSP_RECORD_DEBUG
|
||||
int old_dsp_rec_pos=0;
|
||||
int buf_written=0;
|
||||
int last_crecord=0;
|
||||
#endif
|
||||
|
||||
|
||||
static void sb_get_buffer_emu8k(int32_t *buffer, int len, void *p)
|
||||
{
|
||||
sb_t *sb = (sb_t *)p;
|
||||
@@ -522,9 +486,6 @@ static void sb_get_buffer_emu8k(int32_t *buffer, int len, void *p)
|
||||
sb->opl.pos = 0;
|
||||
sb->dsp.pos = 0;
|
||||
sb->emu8k.pos = 0;
|
||||
#if 0
|
||||
memcpy(&sb->temp_mixer_sb16, &sb->mixer_sb16, sizeof(sb_ct1745_mixer_t));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1296,9 +1257,6 @@ void *sb_16_init(const device_t *info)
|
||||
}
|
||||
io_sethandler(addr+4, 0x0002, sb_ct1745_mixer_read, NULL, NULL, sb_ct1745_mixer_write, NULL, NULL, sb);
|
||||
sound_add_handler(sb_get_buffer_sb16, sb);
|
||||
#if 0
|
||||
sound_add_process_handler(sb_process_buffer_sb16, sb);
|
||||
#endif
|
||||
if (mpu_addr) {
|
||||
sb->mpu = (mpu_t *)mem_alloc(sizeof(mpu_t));
|
||||
memset(sb->mpu, 0, sizeof(mpu_t));
|
||||
@@ -1306,14 +1264,11 @@ void *sb_16_init(const device_t *info)
|
||||
sb_dsp_set_mpu(sb->mpu);
|
||||
} else
|
||||
sb->mpu = NULL;
|
||||
#if 0
|
||||
memcpy(&sb->temp_mixer_sb16, &sb->mixer_sb16, sizeof(sb_ct1745_mixer_t));
|
||||
#endif
|
||||
|
||||
return sb;
|
||||
}
|
||||
|
||||
int sb_awe32_available()
|
||||
int sb_awe32_available(void)
|
||||
{
|
||||
return rom_present(ROM_PATH_AWE32);
|
||||
}
|
||||
@@ -1345,9 +1300,6 @@ void *sb_awe32_init(const device_t *info)
|
||||
}
|
||||
io_sethandler(addr+4, 0x0002, sb_ct1745_mixer_read, NULL, NULL, sb_ct1745_mixer_write, NULL, NULL, sb);
|
||||
sound_add_handler(sb_get_buffer_emu8k, sb);
|
||||
#if 0
|
||||
sound_add_process_handler(sb_process_buffer_sb16, sb);
|
||||
#endif
|
||||
if (mpu_addr) {
|
||||
sb->mpu = (mpu_t *)mem_alloc(sizeof(mpu_t));
|
||||
memset(sb->mpu, 0, sizeof(mpu_t));
|
||||
@@ -1356,9 +1308,6 @@ void *sb_awe32_init(const device_t *info)
|
||||
} else
|
||||
sb->mpu = NULL;
|
||||
emu8k_init(&sb->emu8k, ROM_PATH_AWE32, emu_addr, onboard_ram);
|
||||
#if 0
|
||||
memcpy(&sb->temp_mixer_sb16, &sb->mixer_sb16, sizeof(sb_ct1745_mixer_t));
|
||||
#endif
|
||||
|
||||
return sb;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Sound emulation core.
|
||||
*
|
||||
* Version: @(#)sound.c 1.0.15 2018/10/20
|
||||
* Version: @(#)sound.c 1.0.16 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -73,7 +73,6 @@ typedef struct {
|
||||
int sound_do_log = ENABLE_SOUND_LOG;
|
||||
#endif
|
||||
int sound_pos_global = 0;
|
||||
volatile int soundon = 1;
|
||||
|
||||
|
||||
static sndhnd_t handlers[8];
|
||||
@@ -113,7 +112,7 @@ cd_thread(void *param)
|
||||
thread_wait_event(cd_event, -1);
|
||||
thread_reset_event(cd_event);
|
||||
|
||||
if (!soundon || !cd_audioon) return;
|
||||
if (! cd_audioon) return;
|
||||
|
||||
for (c = 0; c < CD_BUFLEN*2; c += 2) {
|
||||
if (sound_is_float) {
|
||||
@@ -136,18 +135,18 @@ cd_thread(void *param)
|
||||
} else
|
||||
continue;
|
||||
|
||||
if (soundon && has_audio) {
|
||||
if (has_audio) {
|
||||
if (cdrom[i].get_volume) {
|
||||
audio_vol_l = cdrom[i].get_volume(cdrom[i].p, 0);
|
||||
audio_vol_r = cdrom[i].get_volume(cdrom[i].p, 1);
|
||||
audio_vol_l = cdrom[i].get_volume(cdrom[i].priv, 0);
|
||||
audio_vol_r = cdrom[i].get_volume(cdrom[i].priv, 1);
|
||||
} else {
|
||||
audio_vol_l = 255;
|
||||
audio_vol_r = 255;
|
||||
}
|
||||
|
||||
if (cdrom[i].get_channel) {
|
||||
ch_sel[0] = cdrom[i].get_channel(cdrom[i].p, 0);
|
||||
ch_sel[1] = cdrom[i].get_channel(cdrom[i].p, 1);
|
||||
ch_sel[0] = cdrom[i].get_channel(cdrom[i].priv, 0);
|
||||
ch_sel[1] = cdrom[i].get_channel(cdrom[i].priv, 1);
|
||||
} else {
|
||||
ch_sel[0] = 1;
|
||||
ch_sel[1] = 2;
|
||||
@@ -253,14 +252,14 @@ cd_thread_end(void)
|
||||
static void
|
||||
sound_poll(void *priv)
|
||||
{
|
||||
int c;
|
||||
|
||||
poll_time += poll_latch;
|
||||
|
||||
midi_poll();
|
||||
|
||||
sound_pos_global++;
|
||||
if (sound_pos_global == SOUNDBUFLEN) {
|
||||
int c;
|
||||
|
||||
memset(outbuffer, 0, SOUNDBUFLEN * 2 * sizeof(int32_t));
|
||||
|
||||
for (c = 0; c < handlers_num; c++)
|
||||
@@ -279,12 +278,10 @@ sound_poll(void *priv)
|
||||
}
|
||||
}
|
||||
|
||||
if (soundon) {
|
||||
if (sound_is_float)
|
||||
openal_buffer(outbuffer_ex);
|
||||
else
|
||||
openal_buffer(outbuffer_ex_int16);
|
||||
}
|
||||
if (sound_is_float)
|
||||
openal_buffer(outbuffer_ex);
|
||||
else
|
||||
openal_buffer(outbuffer_ex_int16);
|
||||
|
||||
if (cd_thread_enable) {
|
||||
cd_buf_update--;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Definitions for the Sound Emulation core.
|
||||
*
|
||||
* Version: @(#)sound.h 1.0.10 2018/10/16
|
||||
* Version: @(#)sound.h 1.0.11 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -54,7 +54,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
extern int sound_pos_global;
|
||||
extern volatile int soundon;
|
||||
|
||||
|
||||
extern void sound_log(int level, const char *fmt, ...);
|
||||
|
||||
3
src/pc.c
3
src/pc.c
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Main emulator module where most things are controlled.
|
||||
*
|
||||
* Version: @(#)pc.c 1.0.59 2018/10/24
|
||||
* Version: @(#)pc.c 1.0.60 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -718,7 +718,6 @@ usage:
|
||||
hdd_init();
|
||||
cdrom_global_init();
|
||||
zip_global_init();
|
||||
scsi_disk_global_init();
|
||||
|
||||
network_init();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handle the UI part of CD-ROM/ZIP/DISK media changes.
|
||||
*
|
||||
* Version: @(#)ui_cdrom.c 1.0.5 2018/10/24
|
||||
* Version: @(#)ui_cdrom.c 1.0.6 2018/10/25
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -135,23 +135,24 @@ ui_cdrom_reload(uint8_t id)
|
||||
|
||||
|
||||
void
|
||||
ui_zip_mount(uint8_t drive, int part, int8_t wp, const wchar_t *fn)
|
||||
ui_zip_mount(uint8_t id, int part, int8_t wp, const wchar_t *fn)
|
||||
{
|
||||
zip_t *dev = (zip_t *)zip_drives[id].priv;
|
||||
int len;
|
||||
|
||||
zip_disk_close(zip[drive]);
|
||||
zip_disk_close(dev);
|
||||
|
||||
zip_drives[drive].ui_writeprot = wp;
|
||||
zip_load(zip[drive], fn);
|
||||
zip_insert(zip[drive]);
|
||||
zip_drives[id].ui_writeprot = wp;
|
||||
zip_load(dev, fn);
|
||||
zip_insert(dev);
|
||||
|
||||
len = (int)wcslen(zip_drives[drive].image_path);
|
||||
ui_sb_icon_state(SB_ZIP | drive, len ? 0 : 1);
|
||||
len = (int)wcslen(zip_drives[id].image_path);
|
||||
ui_sb_icon_state(SB_ZIP | id, len ? 0 : 1);
|
||||
|
||||
sb_menu_enable_item(part, IDM_ZIP_EJECT | drive, len ? 1 : 0);
|
||||
sb_menu_enable_item(part, IDM_ZIP_RELOAD | drive, len ? 0 : 1);
|
||||
sb_menu_enable_item(part, IDM_ZIP_EJECT | id, len ? 1 : 0);
|
||||
sb_menu_enable_item(part, IDM_ZIP_RELOAD | id, len ? 0 : 1);
|
||||
|
||||
ui_sb_tip_update(SB_ZIP | drive);
|
||||
ui_sb_tip_update(SB_ZIP | id);
|
||||
|
||||
config_save();
|
||||
}
|
||||
@@ -160,11 +161,13 @@ ui_zip_mount(uint8_t drive, int part, int8_t wp, const wchar_t *fn)
|
||||
void
|
||||
ui_zip_eject(uint8_t id)
|
||||
{
|
||||
zip_disk_close(zip[id]);
|
||||
zip_t *dev = (zip_t *)zip_drives[id].priv;
|
||||
|
||||
zip_disk_close(dev);
|
||||
|
||||
if (zip_drives[id].bus_type) {
|
||||
/* Signal disk change to the emulated machine. */
|
||||
zip_insert(zip[id]);
|
||||
zip_insert(dev);
|
||||
}
|
||||
|
||||
ui_sb_icon_state(SB_ZIP | id, 1);
|
||||
@@ -179,7 +182,9 @@ ui_zip_eject(uint8_t id)
|
||||
void
|
||||
ui_zip_reload(uint8_t id)
|
||||
{
|
||||
zip_disk_reload(zip[id]);
|
||||
zip_t *dev = (zip_t *)zip_drives[id].priv;
|
||||
|
||||
zip_disk_reload(dev);
|
||||
|
||||
if (wcslen(zip_drives[id].image_path) == 0) {
|
||||
ui_sb_menu_enable_item(SB_ZIP|id, IDM_ZIP_EJECT | id, 0);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Common UI support functions for the Status Bar module.
|
||||
*
|
||||
* Version: @(#)ui_stbar.c 1.0.15 2018/10/19
|
||||
* Version: @(#)ui_stbar.c 1.0.16 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*
|
||||
* FIXME: Not yet fully working! Getting there, though ;-)
|
||||
*
|
||||
* Version: @(#)win_cdrom.c 1.0.15 2018/10/24
|
||||
* Version: @(#)win_cdrom.c 1.0.16 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -285,7 +285,7 @@ ioctl_ready(cdrom_t *dev)
|
||||
|
||||
/* Notify the drive. */
|
||||
if (dev->insert)
|
||||
dev->insert(dev->p);
|
||||
dev->insert(dev->priv);
|
||||
}
|
||||
|
||||
/* OK, we handled it. */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Implementation of the Settings dialog.
|
||||
*
|
||||
* Version: @(#)win_settings_sound.h 1.0.13 2018/10/24
|
||||
* Version: @(#)win_settings_sound.h 1.0.14 2018/10/25
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -46,8 +46,10 @@
|
||||
#define NUM_MIDI 16
|
||||
|
||||
|
||||
static int sound_to_list[NUM_SOUND], list_to_sound[NUM_SOUND];
|
||||
static int midi_to_list[NUM_MIDI], list_to_midi[NUM_MIDI];
|
||||
static int sound_to_list[NUM_SOUND],
|
||||
list_to_sound[NUM_SOUND];
|
||||
static int midi_to_list[NUM_MIDI],
|
||||
list_to_midi[NUM_MIDI];
|
||||
|
||||
|
||||
static int
|
||||
@@ -86,44 +88,44 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
case WM_INITDIALOG:
|
||||
h = GetDlgItem(hdlg, IDC_COMBO_SOUND);
|
||||
c = d = 0;
|
||||
while (1) {
|
||||
for (;;) {
|
||||
stransi = sound_card_get_internal_name(c);
|
||||
if (stransi == NULL)
|
||||
break;
|
||||
|
||||
sound_to_list[c] = d;
|
||||
if (stransi == NULL) break;
|
||||
|
||||
dev = sound_card_getdevice(c);
|
||||
|
||||
if (sound_card_available(c) &&
|
||||
device_is_valid(dev, machines[temp_machine].flags)) {
|
||||
if (c == 0) {
|
||||
/* Translate "None". */
|
||||
SendMessage(h, CB_ADDSTRING, 0,
|
||||
win_string(IDS_NONE));
|
||||
} else if (c == 1) {
|
||||
if (! (machines[temp_machine].flags&MACHINE_SOUND)) {
|
||||
c++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Translate "Internal". */
|
||||
SendMessage(h, CB_ADDSTRING, 0,
|
||||
win_string(IDS_INTERNAL));
|
||||
} else {
|
||||
sprintf(tempA, "[%s] %s",
|
||||
device_get_bus_name(dev),
|
||||
sound_card_getname(c));
|
||||
mbstowcs(temp, tempA, sizeof_w(temp));
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp);
|
||||
}
|
||||
|
||||
list_to_sound[d] = c;
|
||||
d++;
|
||||
if (!sound_card_available(c) ||
|
||||
!device_is_valid(dev, machines[temp_machine].flags)) {
|
||||
c++;
|
||||
continue;
|
||||
}
|
||||
|
||||
c++;
|
||||
if (c == 0) {
|
||||
/* Translate "None". */
|
||||
SendMessage(h, CB_ADDSTRING, 0,
|
||||
win_string(IDS_NONE));
|
||||
} else if (c == 1) {
|
||||
if (! (machines[temp_machine].flags&MACHINE_SOUND)) {
|
||||
c++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Translate "Internal". */
|
||||
SendMessage(h, CB_ADDSTRING, 0,
|
||||
win_string(IDS_INTERNAL));
|
||||
} else {
|
||||
sprintf(tempA, "[%s] %s",
|
||||
device_get_bus_name(dev),
|
||||
sound_card_getname(c));
|
||||
mbstowcs(temp, tempA, sizeof_w(temp));
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp);
|
||||
}
|
||||
|
||||
sound_to_list[c] = d;
|
||||
list_to_sound[d] = c;
|
||||
d++; c++;
|
||||
}
|
||||
|
||||
SendMessage(h, CB_SETCURSEL, sound_to_list[temp_sound_card], 0);
|
||||
|
||||
EnableWindow(h, d ? TRUE : FALSE);
|
||||
|
||||
Reference in New Issue
Block a user