diff --git a/src/ICONS/network.ico b/src/ICONS/network.ico new file mode 100644 index 000000000..b078387d3 Binary files /dev/null and b/src/ICONS/network.ico differ diff --git a/src/ICONS/other_peripherals.ico b/src/ICONS/other_peripherals.ico index b078387d3..111506318 100644 Binary files a/src/ICONS/other_peripherals.ico and b/src/ICONS/other_peripherals.ico differ diff --git a/src/cdrom-dosbox.cpp b/src/cdrom-dosbox.cpp index 86f09e8c8..6f966cf1b 100644 --- a/src/cdrom-dosbox.cpp +++ b/src/cdrom-dosbox.cpp @@ -205,6 +205,9 @@ bool CDROM_Interface_Image::IsMode2(unsigned long sector) bool CDROM_Interface_Image::LoadIsoFile(char* filename) { + int shift = 0; + int totalPregap = 0; + tracks.clear(); // data track @@ -216,6 +219,7 @@ bool CDROM_Interface_Image::LoadIsoFile(char* filename) return false; } track.number = 1; + track.track_number = 1;//IMPORTANT: This is needed. track.attr = DATA_TRACK;//data // try to detect iso type @@ -239,7 +243,7 @@ bool CDROM_Interface_Image::LoadIsoFile(char* filename) // leadout track track.number = 2; track.track_number = 0xAA; - track.attr = 0; + track.attr = 0x16; /* Was 0x00 but I believe 0x16 is appropriate. */ track.start = track.length; track.length = 0; track.file = NULL; @@ -389,7 +393,8 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile) // add leadout track track.number++; track.track_number = 0xAA; - track.attr = 0;//sync with load iso + // track.attr = 0;//sync with load iso + track.attr = 0x16; /* Was 0x00 but I believe 0x16 is appropriate. */ track.start = 0; track.length = 0; track.file = NULL; diff --git a/src/cdrom-image.cc b/src/cdrom-image.cc index 1959a8328..5ec185d65 100644 --- a/src/cdrom-image.cc +++ b/src/cdrom-image.cc @@ -228,7 +228,7 @@ static int image_get_last_block(uint8_t id, uint8_t starttrack, int msf, int max { uint32_t address; cdimg[id]->GetAudioTrackInfo(c+1, number, tmsf, attr); - address = MSFtoLBA(tmsf.min, tmsf.sec, tmsf.fr); + address = MSFtoLBA(tmsf.min, tmsf.sec, tmsf.fr) - 150; /* Do the - 150 here as well. */ if (address > lb) lb = address; } @@ -733,7 +733,7 @@ static void lba_to_msf(uint8_t *buf, int lba) lba += 150; buf[0] = (lba / 75) / 60; buf[1] = (lba / 75) % 60; - buf[2] = lba % 75; + buf[2] = lba % 75; } static uint32_t image_size(uint8_t id) @@ -747,64 +747,12 @@ static int image_readtoc(uint8_t id, unsigned char *b, unsigned char starttrack, int len=4; int c,d; uint32_t temp; - uint8_t *q; + int first_track; int last_track; int number; unsigned char attr; TMSF tmsf; - int lb; - - if (cdrom_image[id].image_is_iso) - { - if (starttrack > 1 && starttrack != 0xaa) - return -1; - q = b + 2; - *q++ = 1; /* first session */ - *q++ = 1; /* last session */ - if (starttrack <= 1) { - *q++ = 0; /* reserved */ - *q++ = 0x14; /* ADR, control */ - *q++ = 1; /* track number */ - *q++ = 0; /* reserved */ - if (msf) { - *q++ = 0; /* reserved */ - lba_to_msf(q, 0); - q += 3; - } else { - /* sector 0 */ - *q++ = 0; - *q++ = 0; - *q++ = 0; - *q++ = 0; - } - } - /* lead out track */ - *q++ = 0; /* reserved */ - *q++ = 0x16; /* ADR, control */ - *q++ = 0xaa; /* track number */ - *q++ = 0; /* reserved */ - lb = image_size(id) - 1; - if (msf) { - *q++ = 0; /* reserved */ - lba_to_msf(q, lb); - q += 3; - } else { - *q++ = lb >> 24; - *q++ = lb >> 16; - *q++ = lb >> 8; - *q++ = lb; - } - len = q - b; - if (len > maxlen) - { - len = maxlen; - } - b[0] = (uint8_t)(((len-2) >> 8) & 0xff); - b[1] = (uint8_t)((len-2) & 0xff); - return len; - } - cdimg[id]->GetAudioTracks(first_track, last_track, tmsf); b[2] = first_track; @@ -829,6 +777,7 @@ static int image_readtoc(uint8_t id, unsigned char *b, unsigned char starttrack, break; cdimg[id]->GetAudioTrackInfo(c+1, number, tmsf, attr); +// pclog("Len %i max %i Track %02X - %02X %02X %02i:%02i:%02i %08X\n",len,maxlen,toc[c].cdte_track,toc[c].cdte_adr,toc[c].cdte_ctrl,toc[c].cdte_addr.msf.minute, toc[c].cdte_addr.msf.second, toc[c].cdte_addr.msf.frame,MSFtoLBA(toc[c].cdte_addr.msf.minute, toc[c].cdte_addr.msf.second, toc[c].cdte_addr.msf.frame)); b[len++] = 0; /* reserved */ b[len++] = attr; b[len++] = number; /* track number */ @@ -843,7 +792,7 @@ static int image_readtoc(uint8_t id, unsigned char *b, unsigned char starttrack, } else { - temp = MSFtoLBA(tmsf.min, tmsf.sec, tmsf.fr); + temp = MSFtoLBA(tmsf.min, tmsf.sec, tmsf.fr) - 150; b[len++] = temp >> 24; b[len++] = temp >> 16; b[len++] = temp >> 8; @@ -852,50 +801,42 @@ static int image_readtoc(uint8_t id, unsigned char *b, unsigned char starttrack, if (single) break; } - - if (len > maxlen) - { - len = maxlen; - } - b[0] = (uint8_t)(((len-2) >> 8) & 0xff); b[1] = (uint8_t)((len-2) & 0xff); + /* + pclog("Table of Contents:\n"); + pclog("First track - %02X\n", first_track); + pclog("Last track - %02X\n", last_track); + for (c = 0; c <= last_track; c++) + { + cdimg[id]->GetAudioTrackInfo(c+1, number, tmsf, attr); + pclog("Track %02X - number %02X control %02X adr %02X address %02X %02X %02X %02X\n", c, number, attr, 0, 0, tmsf.min, tmsf.sec, tmsf.fr); + } + for (c = 0;c <= last_track; c++) { + cdimg[id]->GetAudioTrackInfo(c+1, number, tmsf, attr); + pclog("Track %02X - number %02X control %02X adr %02X address %06X\n", c, number, attr, 0, MSF_TO_FRAMES(tmsf.min, tmsf.sec, tmsf.fr)); + } + */ return len; } static int image_readtoc_session(uint8_t id, unsigned char *b, int msf, int maxlen) { - if (!cdimg[id]) return 0; int len = 4; + int number; TMSF tmsf; unsigned char attr; - uint8_t *q; - if (cdrom_image[id].image_is_iso) - { - q = b + 2; - *q++ = 1; /* first session */ - *q++ = 1; /* last session */ - - *q++ = 1; /* session number */ - *q++ = 0x14; /* data track */ - *q++ = 0; /* track number */ - *q++ = 0xa0; /* lead-in */ - *q++ = 0; /* min */ - *q++ = 0; /* sec */ - *q++ = 0; /* frame */ - *q++ = 0; - - if (maxlen < 12) - { - return maxlen; - } - return 12; - } + if (!cdimg[id]) return 0; cdimg[id]->GetAudioTrackInfo(1, number, tmsf, attr); + if (number == 0) + { + number = 1; + } + b[2] = 1; b[3] = 1; b[len++] = 0; /* reserved */ @@ -911,7 +852,7 @@ static int image_readtoc_session(uint8_t id, unsigned char *b, int msf, int maxl } else { - uint32_t temp = MSFtoLBA(tmsf.min, tmsf.sec, tmsf.fr); + uint32_t temp = MSFtoLBA(tmsf.min, tmsf.sec, tmsf.fr) - 150; /* Do the - 150. */ b[len++] = temp >> 24; b[len++] = temp >> 16; b[len++] = temp >> 8; @@ -928,8 +869,6 @@ static int image_readtoc_session(uint8_t id, unsigned char *b, int msf, int maxl static int image_readtoc_raw(uint8_t id, unsigned char *b, int msf, int maxlen) { - if (!cdimg[id]) return 0; - int track; int len = 4; @@ -938,93 +877,9 @@ static int image_readtoc_raw(uint8_t id, unsigned char *b, int msf, int maxlen) int number; unsigned char attr; TMSF tmsf; - uint8_t *q; int lb; - if (cdrom_image[id].image_is_iso) - { - q = b + 2; - *q++ = 1; /* first session */ - *q++ = 1; /* last session */ - - *q++ = 1; /* session number */ - *q++ = 0x14; /* data track */ - *q++ = 0; /* track number */ - *q++ = 0xa0; /* lead-in */ - *q++ = 0; /* min */ - *q++ = 0; /* sec */ - *q++ = 0; /* frame */ - *q++ = 0; - *q++ = 1; /* first track */ - *q++ = 0x00; /* disk type */ - *q++ = 0x00; - - *q++ = 1; /* session number */ - *q++ = 0x14; /* data track */ - *q++ = 0; /* track number */ - *q++ = 0xa1; - *q++ = 0; /* min */ - *q++ = 0; /* sec */ - *q++ = 0; /* frame */ - *q++ = 0; - *q++ = 1; /* last track */ - *q++ = 0x00; - *q++ = 0x00; - - *q++ = 1; /* session number */ - *q++ = 0x14; /* data track */ - *q++ = 0; /* track number */ - *q++ = 0xa2; /* lead-out */ - *q++ = 0; /* min */ - *q++ = 0; /* sec */ - *q++ = 0; /* frame */ - lb = image_size(id) >> 11; - /* this is raw, must be msf */ - if (msf) - { - *q++ = 0; /* reserved */ - lba_to_msf(q, lb); - q += 3; - } - else - { - *q++ = (lb >> 24) & 0xff; - *q++ = (lb >> 16) & 0xff; - *q++ = (lb >> 8) & 0xff; - *q++ = lb & 0xff; - } - - *q++ = 1; /* session number */ - *q++ = 0x14; /* ADR, control */ - *q++ = 0; /* track number */ - *q++ = 1; /* point */ - *q++ = 0; /* min */ - *q++ = 0; /* sec */ - *q++ = 0; /* frame */ - /* same here */ - if (msf) - { - *q++ = 0; /* reserved */ - lba_to_msf(q, 0); - q += 3; - } - else - { - *q++ = 0; - *q++ = 0; - *q++ = 0; - *q++ = 0; - } - - len = q - b; - if (len > maxlen) - { - len = maxlen; - } - b[0] = (uint8_t)(((len-2) >> 8) & 0xff); - b[1] = (uint8_t)((len-2) & 0xff); - return len; - } + if (!cdimg[id]) return 0; cdimg[id]->GetAudioTracks(first_track, last_track, tmsf); @@ -1048,21 +903,10 @@ static int image_readtoc_raw(uint8_t id, unsigned char *b, int msf, int maxlen) b[len++]=0; b[len++]=0; b[len++]=0; - if (msf) - { - b[len++]=0; - b[len++] = tmsf.min; - b[len++] = tmsf.sec; - b[len++] = tmsf.fr; - } - else - { - uint32_t temp = MSFtoLBA(tmsf.min, tmsf.sec, tmsf.fr); - b[len++] = temp >> 24; - b[len++] = temp >> 16; - b[len++] = temp >> 8; - b[len++] = temp; - } + b[len++]=0; + b[len++] = tmsf.min; + b[len++] = tmsf.sec; + b[len++] = tmsf.fr; } return len; } diff --git a/src/cdrom-image.h b/src/cdrom-image.h index 415956e56..4ea4cb78f 100644 --- a/src/cdrom-image.h +++ b/src/cdrom-image.h @@ -19,6 +19,8 @@ extern void image_close(uint8_t id); void update_status_bar_icon_state(int tag, int state); extern void cdrom_set_null_handler(uint8_t id); +void pclog(const char *format, ...); + #ifdef __cplusplus } #endif diff --git a/src/disc_86f.c b/src/disc_86f.c index eca278532..bfb8f6f50 100644 --- a/src/disc_86f.c +++ b/src/disc_86f.c @@ -1912,7 +1912,7 @@ void d86f_format_track(int drive, int side, int do_write) if (do_write) { d86f_write_direct(drive, side, d86f[drive].fill, 0); - d86f_handler[drive].write_data(drive, side, d86f[drive].datac++, d86f[drive].fill); + d86f_handler[drive].write_data(drive, side, d86f[drive].datac, d86f[drive].fill); } d86f_calccrc(drive, d86f[drive].fill); break; diff --git a/src/hdd_esdi.c b/src/hdd_esdi.c index 707e0d1b6..f40345933 100644 --- a/src/hdd_esdi.c +++ b/src/hdd_esdi.c @@ -796,7 +796,7 @@ static void esdi_mca_write(int port, uint8_t val, void *p) } } -static void loadhd(esdi_t *esdi, int d, const wchar_t *fn) +static void loadhd(esdi_t *esdi, int hdc_num, int d, const wchar_t *fn) { esdi_drive_t *drive = &esdi->drives[d]; @@ -829,15 +829,16 @@ static void loadhd(esdi_t *esdi, int d, const wchar_t *fn) } } - drive->spt = hdc[d].spt; - drive->hpc = hdc[d].hpc; - drive->tracks = hdc[d].tracks; - drive->sectors = hdc[d].spt * hdc[d].hpc * hdc[d].tracks; + drive->spt = hdc[hdc_num].spt; + drive->hpc = hdc[hdc_num].hpc; + drive->tracks = hdc[hdc_num].tracks; + drive->sectors = hdc[hdc_num].spt * hdc[hdc_num].hpc * hdc[hdc_num].tracks; } static void *esdi_init() { int i = 0; + int c = 0; esdi_t *esdi = malloc(sizeof(esdi_t)); memset(esdi, 0, sizeof(esdi_t)); @@ -847,7 +848,12 @@ static void *esdi_init() for (i = 0; i < HDC_NUM; i++) { - loadhd(esdi, hdc[i].mfm_channel, hdd_fn[i]); + if ((hdc[i].bus == 1) && (hdc[i].mfm_channel < MFM_NUM)) + { + loadhd(esdi, i, hdc[i].mfm_channel, hdd_fn[i]); + c++; + if (c >= MFM_NUM) break; + } } timer_add(esdi_callback, &esdi->callback, &esdi->callback, esdi); diff --git a/src/ide.c b/src/ide.c index f6c2c3454..afcb47778 100644 --- a/src/ide.c +++ b/src/ide.c @@ -354,27 +354,27 @@ static void ide_identify(IDE *ide) { uint32_t c, h, s; char device_identify[8] = { '8', '6', 'B', '_', 'H', 'D', '0', 0 }; - uint64_t full_size = (hdc[cur_ide[ide->board]].tracks * hdc[cur_ide[ide->board]].hpc * hdc[cur_ide[ide->board]].spt); + uint64_t full_size = (hdc[ide->hdc_num].tracks * hdc[ide->hdc_num].hpc * hdc[ide->hdc_num].spt); device_identify[6] = ide->channel + 0x30; ide_log("IDE Identify: %s\n", device_identify); memset(ide->buffer, 0, 512); - c = hdc[cur_ide[ide->board]].tracks; /* Cylinders */ - h = hdc[cur_ide[ide->board]].hpc; /* Heads */ - s = hdc[cur_ide[ide->board]].spt; /* Sectors */ + c = hdc[ide->hdc_num].tracks; /* Cylinders */ + h = hdc[ide->hdc_num].hpc; /* Heads */ + s = hdc[ide->hdc_num].spt; /* Sectors */ - if (hdc[cur_ide[ide->board]].tracks <= 16383) + if (hdc[ide->hdc_num].tracks <= 16383) { - ide->buffer[1] = hdc[cur_ide[ide->board]].tracks; /* Cylinders */ + ide->buffer[1] = hdc[ide->hdc_num].tracks; /* Cylinders */ } else { ide->buffer[1] = 16383; /* Cylinders */ } - ide->buffer[3] = hdc[cur_ide[ide->board]].hpc; /* Heads */ - ide->buffer[6] = hdc[cur_ide[ide->board]].spt; /* Sectors */ + ide->buffer[3] = hdc[ide->hdc_num].hpc; /* Heads */ + ide->buffer[6] = hdc[ide->hdc_num].spt; /* Sectors */ ide_padstr((char *) (ide->buffer + 10), "", 20); /* Serial Number */ ide_padstr((char *) (ide->buffer + 23), emulator_version, 8); /* Firmware */ ide_padstr((char *) (ide->buffer + 27), device_identify, 40); /* Model */ @@ -415,13 +415,18 @@ static void ide_identify(IDE *ide) ide->buffer[59] = ide->blocksize ? (ide->blocksize | 0x100) : 0; if (ide->buffer[49] & (1 << 9)) { - ide->buffer[60] = (hdc[cur_ide[ide->board]].tracks * hdc[cur_ide[ide->board]].hpc * hdc[cur_ide[ide->board]].spt) & 0xFFFF; /* Total addressable sectors (LBA) */ - ide->buffer[61] = ((hdc[cur_ide[ide->board]].tracks * hdc[cur_ide[ide->board]].hpc * hdc[cur_ide[ide->board]].spt) >> 16) & 0x0FFF; + ide->buffer[60] = (hdc[ide->hdc_num].tracks * hdc[ide->hdc_num].hpc * hdc[ide->hdc_num].spt) & 0xFFFF; /* Total addressable sectors (LBA) */ + ide->buffer[61] = ((hdc[ide->hdc_num].tracks * hdc[ide->hdc_num].hpc * hdc[ide->hdc_num].spt) >> 16) & 0x0FFF; } if (PCI && (ide->board < 2) && (hdc[ide->hdc_num].bus == 3)) { ide->buffer[52] = 2 << 8; /*DMA timing mode*/ + ide->buffer[63] = 7; + if (ide->mdma_mode != -1) + { + ide->buffer[63] = (ide->mdma_mode << 8); + } } ide->buffer[80] = 0xe; /*ATA-1 to ATA-3 supported*/ } @@ -661,78 +666,60 @@ int ide_cdrom_is_pio_only(IDE *ide) return 1; } -#if 0 -int ide_set_features(IDE *ide) +static int ide_set_features(IDE *ide) { - uint8_t cdrom_id = cur_ide[ide->board]; + uint8_t features, features_data; + uint8_t mode, submode; + + features = ide->cylprecomp; + features_data = ide->secount; - uint8_t features = 0; - - uint8_t sf_data = 0; - uint8_t val = 0; - - if (ide_drive_is_cdrom(ide)) - { - features = cdrom[cdrom_id].features; - sf_data = cdrom[cdrom_id].phase; - } - else - { - features = ide->cylprecomp; - sf_data = ide->secount; - } - - val = sf_data & 7; + pclog("Features code %02X\n", features); - if (ide->type == IDE_NONE) return 0; - switch(features) { - case 0x02: - case 0x82: - return 0; - case 0xcc: - case 0x66: - case 0xaa: - case 0x55: - case 0x05: - case 0x85: - case 0x69: - case 0x67: - case 0x96: - case 0x9a: - case 0x42: - case 0xc2: - return 1; - case 0x03: -#if 0 - if (ide->type == IDE_CDROM) + case 0x03: /* Set transfer mode. */ + pclog("Transfer mode %02X\n", features_data >> 3); + + mode = (features_data >> 3); + submode = features_data & 7; + + switch(mode) { - return 0; - } -#endif - switch(sf_data >> 3) - { - case 0: - ide->dma_identify_data[0] = 7; - break; - case 1: - /* We do not (yet) emulate flow control, so return with error if this is attempted. */ - return 0; - case 4: - if (ide_cdrom_is_pio_only(ide) || (ide->board >= 2)) + case 0x00: /* PIO default */ + if (submode != 0) { return 0; } - ide->dma_identify_data[0] = 7 | (1 << (val + 8)); + ide->mdma_mode = -1; break; + + case 0x01: /* PIO mode */ + if (submode > 2) + { + return 0; + } + ide->mdma_mode = -1; + break; + + case 0x04: /* Multiword DMA mode */ + if (!PCI || (hdc[ide->hdc_num].bus != 3) || (ide->board >= 2) || (submode > 2)) + { + return 0; + } + ide->mdma_mode = (1 << submode); + break; + default: return 0; } + + default: + return 0; } + return 1; } -#endif void ide_set_sector(IDE *ide, int64_t sector_num) { @@ -745,11 +732,11 @@ void ide_set_sector(IDE *ide, int64_t sector_num) } else { - cyl = sector_num / (hdc[cur_ide[ide->board]].hpc * hdc[cur_ide[ide->board]].spt); - r = sector_num % (hdc[cur_ide[ide->board]].hpc * hdc[cur_ide[ide->board]].spt); + cyl = sector_num / (hdc[ide->hdc_num].hpc * hdc[ide->hdc_num].spt); + r = sector_num % (hdc[ide->hdc_num].hpc * hdc[ide->hdc_num].spt); ide->cylinder = cyl; - ide->head = ((r / hdc[cur_ide[ide->board]].spt) & 0x0f); - ide->sector = (r % hdc[cur_ide[ide->board]].spt) + 1; + ide->head = ((r / hdc[ide->hdc_num].spt) & 0x0f); + ide->sector = (r % hdc[ide->hdc_num].spt) + 1; } } @@ -805,12 +792,10 @@ void resetide(void) ide_set_signature(&ide_drives[d]); -#if 0 - if (ide_drives[d].type != IDE_NONE) + if (ide_drives[d].type == IDE_HDD) { - ide_drives[d].dma_identify_data[0] = 7; + ide_drives[d].mdma_mode = 0; } -#endif ide_drives[d].error = 1; } @@ -920,7 +905,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val) switch (addr) { - case 0x1F0: /* Data */ + case 0x1F0: /* Data */ writeidew(ide_board, val | (val << 8)); return; @@ -939,7 +924,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val) ide_other->cylprecomp = val; return; - case 0x1F2: /* Sector count */ + case 0x1F2: /* Sector count */ if (ide_drive_is_cdrom(ide)) { ide_log("Sector count write: %i\n", val); @@ -955,14 +940,14 @@ void writeide(int ide_board, uint16_t addr, uint8_t val) ide_other->secount = val; return; - case 0x1F3: /* Sector */ + case 0x1F3: /* Sector */ ide->sector = val; ide->lba_addr = (ide->lba_addr & 0xFFFFF00) | val; ide_other->sector = val; ide_other->lba_addr = (ide_other->lba_addr & 0xFFFFF00) | val; return; - case 0x1F4: /* Cylinder low */ + case 0x1F4: /* Cylinder low */ if (ide_drive_is_cdrom(ide)) { cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].request_length &= 0xFF00; @@ -980,7 +965,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val) ide_other->lba_addr = (ide_other->lba_addr&0xFFF00FF) | (val << 8); return; - case 0x1F5: /* Cylinder high */ + case 0x1F5: /* Cylinder high */ if (ide_drive_is_cdrom(ide)) { cdrom[atapi_cdrom_drives[cur_ide[ide_board]]].request_length &= 0xFF; @@ -998,7 +983,7 @@ void writeide(int ide_board, uint16_t addr, uint8_t val) ide_other->lba_addr = (ide_other->lba_addr & 0xF00FFFF) | (val << 16); return; - case 0x1F6: /* Drive/Head */ + case 0x1F6: /* Drive/Head */ if (cur_ide[ide_board] != ((val>>4)&1)+(ide_board<<1)) { cur_ide[ide_board]=((val>>4)&1)+(ide_board<<1); @@ -1051,254 +1036,255 @@ void writeide(int ide_board, uint16_t addr, uint8_t val) ide_irq_update(ide); return; - case 0x1F7: /* Command register */ + case 0x1F7: /* Command register */ if (ide->type == IDE_NONE) { return; } - ide_irq_lower(ide); - ide->command=val; + ide_irq_lower(ide); + ide->command=val; - ide->error=0; - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].error = 0; - } - switch (val) - { - case WIN_SRST: /* ATAPI Device Reset */ - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; - } - else - { - ide->atastat = READY_STAT; - } - timer_process(); - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].callback = 100*IDE_TIME; - } - idecallback[ide_board]=100*IDE_TIME; - timer_update_outstanding(); - return; + ide->error=0; + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].error = 0; + } + switch (val) + { + case WIN_SRST: /* ATAPI Device Reset */ + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; + } + else + { + ide->atastat = READY_STAT; + } + timer_process(); + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].callback = 100*IDE_TIME; + } + idecallback[ide_board]=100*IDE_TIME; + timer_update_outstanding(); + return; - case WIN_RESTORE: - case WIN_SEEK: - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].status = READY_STAT; - } - else - { - ide->atastat = READY_STAT; - } - timer_process(); - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].callback = 100*IDE_TIME; - } - idecallback[ide_board]=100*IDE_TIME; - timer_update_outstanding(); - return; + case WIN_RESTORE: + case WIN_SEEK: + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].status = READY_STAT; + } + else + { + ide->atastat = READY_STAT; + } + timer_process(); + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].callback = 100*IDE_TIME; + } + idecallback[ide_board]=100*IDE_TIME; + timer_update_outstanding(); + return; - case WIN_READ_MULTIPLE: - /* Fatal removed in accordance with the official ATAPI reference: - If the Read Multiple command is attempted before the Set Multiple Mode - command has been executed or when Read Multiple commands are - disabled, the Read Multiple operation is rejected with an Aborted Com- - mand error. */ - ide->blockcount = 0; - - case WIN_READ: - case WIN_READ_NORETRY: - case WIN_READ_DMA: - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; - } - else - { - ide->atastat = BUSY_STAT; - } + case WIN_READ_MULTIPLE: + /* Fatal removed in accordance with the official ATAPI reference: + If the Read Multiple command is attempted before the Set Multiple Mode + command has been executed or when Read Multiple commands are + disabled, the Read Multiple operation is rejected with an Aborted Com- + mand error. */ + ide->blockcount = 0; + + case WIN_READ: + case WIN_READ_NORETRY: + case WIN_READ_DMA: + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; + } + else + { + ide->atastat = BUSY_STAT; + } + timer_process(); + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].callback = 200*IDE_TIME; + } + idecallback[ide_board]=200*IDE_TIME; + timer_update_outstanding(); + return; + + case WIN_WRITE_MULTIPLE: + if (!ide->blocksize && !ide_drive_is_cdrom(ide)) + { + fatal("Write_MULTIPLE - blocksize = 0\n"); + } + ide->blockcount = 0; + + case WIN_WRITE: + case WIN_WRITE_NORETRY: + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].status = DRQ_STAT | DSC_STAT | READY_STAT; + cdrom[atapi_cdrom_drives[ide->channel]].pos = 0; + } + else + { + ide->atastat = DRQ_STAT | DSC_STAT | READY_STAT; + ide->pos=0; + } + return; + + case WIN_WRITE_DMA: + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; + } + else + { + ide->atastat = BUSY_STAT; + } + timer_process(); + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].callback = 200*IDE_TIME; + } + idecallback[ide_board]=200*IDE_TIME; + timer_update_outstanding(); + return; + + case WIN_VERIFY: + case WIN_VERIFY_ONCE: + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; + } + else + { + ide->atastat = BUSY_STAT; + } + timer_process(); + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].callback = 200*IDE_TIME; + } + idecallback[ide_board]=200*IDE_TIME; + timer_update_outstanding(); + return; + + case WIN_FORMAT: + if (ide_drive_is_cdrom(ide)) + { + goto ide_bad_command; + } + else + { + ide->atastat = DRQ_STAT; + ide->pos=0; + } + return; + + case WIN_SPECIFY: /* Initialize Drive Parameters */ + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; + } + else + { + ide->atastat = BUSY_STAT; + } + timer_process(); + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].callback = 30*IDE_TIME; + } + idecallback[ide_board]=30*IDE_TIME; + timer_update_outstanding(); + return; + + case WIN_DRIVE_DIAGNOSTICS: /* Execute Drive Diagnostics */ + case WIN_PIDENTIFY: /* Identify Packet Device */ + case WIN_SET_MULTIPLE_MODE: /* Set Multiple Mode */ + case WIN_SET_FEATURES: /* Set Features */ + case WIN_NOP: + case WIN_STANDBYNOW1: + case WIN_IDLENOW1: + case WIN_SETIDLE1: /* Idle */ + case WIN_CHECKPOWERMODE1: + case WIN_SLEEP1: + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; + } + else + { + ide->atastat = BUSY_STAT; + } + timer_process(); + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].callback = 30*IDE_TIME; + } + idecallback[ide_board]=30*IDE_TIME; + timer_update_outstanding(); + return; + + case WIN_IDENTIFY: /* Identify Device */ + case WIN_READ_NATIVE_MAX: + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; + } + else + { + ide->atastat = BUSY_STAT; + } + timer_process(); + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].callback = 200*IDE_TIME; + } + idecallback[ide_board]=200*IDE_TIME; + timer_update_outstanding(); + return; + + case WIN_PACKETCMD: /* ATAPI Packet */ + /* Skip the command callback wait, and process immediately. */ + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].packet_status = CDROM_PHASE_IDLE; + cdrom[atapi_cdrom_drives[ide->channel]].pos=0; + cdrom[atapi_cdrom_drives[ide->channel]].phase = 1; + cdrom[atapi_cdrom_drives[ide->channel]].status = READY_STAT | DRQ_STAT | (cdrom[cur_ide[ide_board]].status & ERR_STAT); + } + else + { + ide->atastat = BUSY_STAT; timer_process(); - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].callback = 200*IDE_TIME; - } - idecallback[ide_board]=200*IDE_TIME; + idecallback[ide_board]=1; timer_update_outstanding(); - return; - - case WIN_WRITE_MULTIPLE: - if (!ide->blocksize && !ide_drive_is_cdrom(ide)) - { - fatal("Write_MULTIPLE - blocksize = 0\n"); - } - ide->blockcount = 0; - - case WIN_WRITE: - case WIN_WRITE_NORETRY: - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].status = DRQ_STAT | DSC_STAT | READY_STAT; - cdrom[atapi_cdrom_drives[ide->channel]].pos = 0; - } - else - { - ide->atastat = DRQ_STAT | DSC_STAT | READY_STAT; - ide->pos=0; - } - return; + ide->pos=0; + } + return; - case WIN_WRITE_DMA: - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; - } - else - { - ide->atastat = BUSY_STAT; - } - timer_process(); - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].callback = 200*IDE_TIME; - } - idecallback[ide_board]=200*IDE_TIME; - timer_update_outstanding(); - return; - - case WIN_VERIFY: - case WIN_VERIFY_ONCE: - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; - } - else - { - ide->atastat = BUSY_STAT; - } - timer_process(); - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].callback = 200*IDE_TIME; - } - idecallback[ide_board]=200*IDE_TIME; - timer_update_outstanding(); - return; - - case WIN_FORMAT: - if (ide_drive_is_cdrom(ide)) - { - goto ide_bad_command; - } - else - { - ide->atastat = DRQ_STAT; - ide->pos=0; - } - return; - - case WIN_SPECIFY: /* Initialize Drive Parameters */ - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; - } - else - { - ide->atastat = BUSY_STAT; - } - timer_process(); - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].callback = 30*IDE_TIME; - } - idecallback[ide_board]=30*IDE_TIME; - timer_update_outstanding(); - return; - - case WIN_DRIVE_DIAGNOSTICS: /* Execute Drive Diagnostics */ - case WIN_PIDENTIFY: /* Identify Packet Device */ - case WIN_SET_MULTIPLE_MODE: /*Set Multiple Mode*/ - case WIN_NOP: - case WIN_STANDBYNOW1: - case WIN_IDLENOW1: - case WIN_SETIDLE1: /* Idle */ - case WIN_CHECKPOWERMODE1: - case WIN_SLEEP1: - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; - } - else - { - ide->atastat = BUSY_STAT; - } - timer_process(); - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].callback = 30*IDE_TIME; - } - idecallback[ide_board]=30*IDE_TIME; - timer_update_outstanding(); - return; - - case WIN_IDENTIFY: /* Identify Device */ - case WIN_READ_NATIVE_MAX: - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].status = BUSY_STAT; - } - else - { - ide->atastat = BUSY_STAT; - } - timer_process(); - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].callback = 200*IDE_TIME; - } - idecallback[ide_board]=200*IDE_TIME; - timer_update_outstanding(); - return; - - case WIN_PACKETCMD: /* ATAPI Packet */ - /* Skip the command callback wait, and process immediately. */ - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].packet_status = CDROM_PHASE_IDLE; - cdrom[atapi_cdrom_drives[ide->channel]].pos=0; - cdrom[atapi_cdrom_drives[ide->channel]].phase = 1; - cdrom[atapi_cdrom_drives[ide->channel]].status = READY_STAT | DRQ_STAT | (cdrom[cur_ide[ide_board]].status & ERR_STAT); - } - else - { - ide->atastat = BUSY_STAT; - timer_process(); - idecallback[ide_board]=1; - timer_update_outstanding(); - ide->pos=0; - } - return; - - case 0xF0: - default: + case 0xF0: + default: ide_bad_command: - if (ide_drive_is_cdrom(ide)) - { - cdrom[atapi_cdrom_drives[ide->channel]].status = READY_STAT | ERR_STAT | DSC_STAT; - cdrom[atapi_cdrom_drives[ide->channel]].error = ABRT_ERR; - } - else - { - ide->atastat = READY_STAT | ERR_STAT | DSC_STAT; - ide->error = ABRT_ERR; - } - ide_irq_raise(ide); - return; + if (ide_drive_is_cdrom(ide)) + { + cdrom[atapi_cdrom_drives[ide->channel]].status = READY_STAT | ERR_STAT | DSC_STAT; + cdrom[atapi_cdrom_drives[ide->channel]].error = ABRT_ERR; + } + else + { + ide->atastat = READY_STAT | ERR_STAT | DSC_STAT; + ide->error = ABRT_ERR; + } + ide_irq_raise(ide); + return; } return; @@ -1439,7 +1425,7 @@ uint8_t readide(int ide_board, uint16_t addr) /* For ATAPI: Bits 7-4 = sense key, bit 3 = MCR (media change requested), Bit 2 = ABRT (aborted command), Bit 1 = EOM (end of media), - and Bit 0 = ILI (illegal length indication). */ + and Bit 0 = ILI (illegal length indication). */ case 0x1F1: /* Error */ if (ide->type == IDE_NONE) { @@ -1599,7 +1585,7 @@ void callbackide(int ide_board) ide = &ide_drives[cur_ide[ide_board]]; ide_other = &ide_drives[cur_ide[ide_board] ^ 1]; - full_size = (hdc[cur_ide[ide->board]].tracks * hdc[cur_ide[ide->board]].hpc * hdc[cur_ide[ide->board]].spt); + full_size = (hdc[ide->hdc_num].tracks * hdc[ide->hdc_num].hpc * hdc[ide->hdc_num].spt); ext_ide = ide; if (ide_drive_is_cdrom(ide)) @@ -1663,7 +1649,7 @@ void callbackide(int ide_board) { /* Initialize the Task File Registers as follows: Status = 00h, Error = 01h, Sector Count = 01h, Sector Number = 01h, Cylinder Low = 14h, Cylinder High =EBh and Drive/Head = 00h. */ - case WIN_SRST: /*ATAPI Device Reset */ + case WIN_SRST: /*ATAPI Device Reset */ ide->atastat = READY_STAT | DSC_STAT; ide->error=1; /*Device passed*/ ide->secount = ide->sector = 1; @@ -1683,8 +1669,8 @@ void callbackide(int ide_board) } return; - case WIN_RESTORE: - case WIN_SEEK: + case WIN_RESTORE: + case WIN_SEEK: if (ide_drive_is_cdrom(ide)) { goto abort_cmd; @@ -1716,8 +1702,8 @@ void callbackide(int ide_board) ide_irq_raise(ide); return; - case WIN_READ: - case WIN_READ_NORETRY: + case WIN_READ: + case WIN_READ_NORETRY: if (ide_drive_is_cdrom(ide)) { ide_set_signature(ide); @@ -1739,7 +1725,7 @@ void callbackide(int ide_board) update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 1); return; - case WIN_READ_DMA: + case WIN_READ_DMA: if (ide_drive_is_cdrom(ide) || (ide->board >= 2)) { goto abort_cmd; @@ -1782,7 +1768,7 @@ void callbackide(int ide_board) return; - case WIN_READ_MULTIPLE: + case WIN_READ_MULTIPLE: /* According to the official ATA reference: If the Read Multiple command is attempted before the Set Multiple Mode @@ -1816,8 +1802,8 @@ void callbackide(int ide_board) update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 1); return; - case WIN_WRITE: - case WIN_WRITE_NORETRY: + case WIN_WRITE: + case WIN_WRITE_NORETRY: if (ide_drive_is_cdrom(ide)) { goto abort_cmd; @@ -1846,7 +1832,7 @@ void callbackide(int ide_board) return; - case WIN_WRITE_DMA: + case WIN_WRITE_DMA: if (ide_drive_is_cdrom(ide) || (ide_board >= 2)) { goto abort_cmd; @@ -1889,7 +1875,7 @@ void callbackide(int ide_board) return; - case WIN_WRITE_MULTIPLE: + case WIN_WRITE_MULTIPLE: if (ide_drive_is_cdrom(ide)) { goto abort_cmd; @@ -1938,7 +1924,7 @@ void callbackide(int ide_board) update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 1); return; - case WIN_FORMAT: + case WIN_FORMAT: if (ide_drive_is_cdrom(ide)) { goto abort_cmd; @@ -1960,7 +1946,7 @@ void callbackide(int ide_board) /* update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 1); */ return; - case WIN_DRIVE_DIAGNOSTICS: + case WIN_DRIVE_DIAGNOSTICS: ide_set_signature(ide); ide->error=1; /*No error detected*/ @@ -1978,7 +1964,7 @@ void callbackide(int ide_board) } return; - case WIN_SPECIFY: /* Initialize Drive Parameters */ + case WIN_SPECIFY: /* Initialize Drive Parameters */ if (ide_drive_is_cdrom(ide)) { goto abort_cmd; @@ -1988,11 +1974,11 @@ void callbackide(int ide_board) ide->specify_success = 1; if (ide->hdi == 2) { - hdc[cur_ide[ide->board]].at_hpc = ide->head+1; - hdc[cur_ide[ide->board]].at_spt = ide->secount; + hdc[ide->hdc_num].at_hpc = ide->head+1; + hdc[ide->hdc_num].at_spt = ide->secount; fseeko64(ide->hdfile, 0x20, SEEK_SET); - fwrite(&(hdc[cur_ide[ide->board]].at_spt), 1, 4, ide->hdfile); - fwrite(&(hdc[cur_ide[ide->board]].at_hpc), 1, 4, ide->hdfile); + fwrite(&(hdc[ide->hdc_num].at_spt), 1, 4, ide->hdfile); + fwrite(&(hdc[ide->hdc_num].at_hpc), 1, 4, ide->hdfile); } ide->spt=ide->secount; ide->hpc=ide->head+1; @@ -2000,7 +1986,7 @@ void callbackide(int ide_board) ide_irq_raise(ide); return; - case WIN_PIDENTIFY: /* Identify Packet Device */ + case WIN_PIDENTIFY: /* Identify Packet Device */ if (ide_drive_is_cdrom(ide)) { ide_atapi_identify(ide); @@ -2013,8 +1999,8 @@ void callbackide(int ide_board) } goto abort_cmd; - case WIN_SET_MULTIPLE_MODE: - if (ide_drive_is_cdrom(ide)) + case WIN_SET_MULTIPLE_MODE: + if (ide_drive_is_cdrom(ide)) { goto abort_cmd; } @@ -2023,38 +2009,37 @@ void callbackide(int ide_board) ide_irq_raise(ide); return; -#if 0 case WIN_SET_FEATURES: - if (!(ide_set_features(ide))) + if ((ide->type == IDE_NONE) || ide_drive_is_cdrom(ide)) { goto abort_cmd; } - if (ide_drive_is_cdrom(ide)) + + if (!ide_set_features(ide)) { - cdrom[cdrom_id].status = READY_STAT | DSC_STAT; + goto abort_cmd; } else { ide->atastat = READY_STAT | DSC_STAT; + ide_irq_raise(ide); } - ide_irq_raise(ide); return; -#endif - + case WIN_READ_NATIVE_MAX: if ((ide->type != IDE_HDD) || ide_drive_is_cdrom(ide)) { goto abort_cmd; } - snum = hdc[cur_ide[ide->board]].spt; - snum *= hdc[cur_ide[ide->board]].hpc; - snum *= hdc[cur_ide[ide->board]].tracks; + snum = hdc[ide->hdc_num].spt; + snum *= hdc[ide->hdc_num].hpc; + snum *= hdc[ide->hdc_num].tracks; ide_set_sector(ide, snum - 1); ide->atastat = READY_STAT | DSC_STAT; ide_irq_raise(ide); return; - - case WIN_IDENTIFY: /* Identify Device */ + + case WIN_IDENTIFY: /* Identify Device */ if (ide->type == IDE_NONE) { ide_set_signature(ide); @@ -2076,7 +2061,7 @@ void callbackide(int ide_board) } return; - case WIN_PACKETCMD: /* ATAPI Packet */ + case WIN_PACKETCMD: /* ATAPI Packet */ if (!ide_drive_is_cdrom(ide)) { goto abort_cmd; @@ -2089,7 +2074,7 @@ void callbackide(int ide_board) case 0xFF: goto abort_cmd; - } + } abort_cmd: ide->command = 0; @@ -2107,6 +2092,7 @@ abort_cmd: } ide_irq_raise(ide); return; + id_not_found: ide->atastat = READY_STAT | ERR_STAT | DSC_STAT; ide->error = ABRT_ERR | 0x10; @@ -2140,161 +2126,159 @@ void ide_callback_qua() void ide_write_pri(uint16_t addr, uint8_t val, void *priv) { - writeide(0, addr, val); + writeide(0, addr, val); } void ide_write_pri_w(uint16_t addr, uint16_t val, void *priv) { - writeidew(0, val); + writeidew(0, val); } void ide_write_pri_l(uint16_t addr, uint32_t val, void *priv) { - writeidel(0, val); + writeidel(0, val); } uint8_t ide_read_pri(uint16_t addr, void *priv) { - return readide(0, addr); + return readide(0, addr); } uint16_t ide_read_pri_w(uint16_t addr, void *priv) { - return readidew(0); + return readidew(0); } uint32_t ide_read_pri_l(uint16_t addr, void *priv) { - return readidel(0); + return readidel(0); } void ide_write_sec(uint16_t addr, uint8_t val, void *priv) { - writeide(1, addr, val); + writeide(1, addr, val); } void ide_write_sec_w(uint16_t addr, uint16_t val, void *priv) { - writeidew(1, val); + writeidew(1, val); } void ide_write_sec_l(uint16_t addr, uint32_t val, void *priv) { - writeidel(1, val); + writeidel(1, val); } uint8_t ide_read_sec(uint16_t addr, void *priv) { - return readide(1, addr); + return readide(1, addr); } uint16_t ide_read_sec_w(uint16_t addr, void *priv) { - return readidew(1); + return readidew(1); } uint32_t ide_read_sec_l(uint16_t addr, void *priv) { - return readidel(1); + return readidel(1); } -/* *** REMOVE FROM CODE SUBMITTED TO MAINLINE - START *** */ void ide_write_ter(uint16_t addr, uint8_t val, void *priv) { - writeide(2, addr, val); + writeide(2, addr, val); } void ide_write_ter_w(uint16_t addr, uint16_t val, void *priv) { - writeidew(2, val); + writeidew(2, val); } void ide_write_ter_l(uint16_t addr, uint32_t val, void *priv) { - writeidel(2, val); + writeidel(2, val); } uint8_t ide_read_ter(uint16_t addr, void *priv) { - return readide(2, addr); + return readide(2, addr); } uint16_t ide_read_ter_w(uint16_t addr, void *priv) { - return readidew(2); + return readidew(2); } uint32_t ide_read_ter_l(uint16_t addr, void *priv) { - return readidel(2); + return readidel(2); } void ide_write_qua(uint16_t addr, uint8_t val, void *priv) { - writeide(3, addr, val); + writeide(3, addr, val); } void ide_write_qua_w(uint16_t addr, uint16_t val, void *priv) { - writeidew(3, val); + writeidew(3, val); } void ide_write_qua_l(uint16_t addr, uint32_t val, void *priv) { - writeidel(3, val); + writeidel(3, val); } uint8_t ide_read_qua(uint16_t addr, void *priv) { - return readide(3, addr); + return readide(3, addr); } uint16_t ide_read_qua_w(uint16_t addr, void *priv) { - return readidew(3); + return readidew(3); } uint32_t ide_read_qua_l(uint16_t addr, void *priv) { - return readidel(3); + return readidel(3); } -/* *** REMOVE FROM CODE SUBMITTED TO MAINLINE - END *** */ static uint16_t ide_base_main[2] = { 0x1f0, 0x170 }; static uint16_t ide_side_main[2] = { 0x3f6, 0x376 }; void ide_pri_enable() { - io_sethandler(0x01f0, 0x0008, ide_read_pri, ide_read_pri_w, ide_read_pri_l, ide_write_pri, ide_write_pri_w, ide_write_pri_l, NULL); - io_sethandler(0x03f6, 0x0001, ide_read_pri, NULL, NULL, ide_write_pri, NULL, NULL , NULL); - ide_base_main[0] = 0x1f0; - ide_side_main[0] = 0x3f6; + io_sethandler(0x01f0, 0x0008, ide_read_pri, ide_read_pri_w, ide_read_pri_l, ide_write_pri, ide_write_pri_w, ide_write_pri_l, NULL); + io_sethandler(0x03f6, 0x0001, ide_read_pri, NULL, NULL, ide_write_pri, NULL, NULL , NULL); + ide_base_main[0] = 0x1f0; + ide_side_main[0] = 0x3f6; } void ide_pri_enable_ex() { - if (ide_base_main[0] & 0x300) - { - pclog("Enabling primary base (%04X)...\n", ide_base_main[0]); - io_sethandler(ide_base_main[0], 0x0008, ide_read_pri, ide_read_pri_w, ide_read_pri_l, ide_write_pri, ide_write_pri_w, ide_write_pri_l, NULL); - } - if (ide_side_main[0] & 0x300) - { - pclog("Enabling primary side (%04X)...\n", ide_side_main[0]); - io_sethandler(ide_side_main[0], 0x0001, ide_read_pri, NULL, NULL, ide_write_pri, NULL, NULL , NULL); - } + if (ide_base_main[0] & 0x300) + { + pclog("Enabling primary base (%04X)...\n", ide_base_main[0]); + io_sethandler(ide_base_main[0], 0x0008, ide_read_pri, ide_read_pri_w, ide_read_pri_l, ide_write_pri, ide_write_pri_w, ide_write_pri_l, NULL); + } + if (ide_side_main[0] & 0x300) + { + pclog("Enabling primary side (%04X)...\n", ide_side_main[0]); + io_sethandler(ide_side_main[0], 0x0001, ide_read_pri, NULL, NULL, ide_write_pri, NULL, NULL , NULL); + } } void ide_pri_disable() { - io_removehandler(ide_base_main[0], 0x0008, ide_read_pri, ide_read_pri_w, ide_read_pri_l, ide_write_pri, ide_write_pri_w, ide_write_pri_l, NULL); - io_removehandler(ide_side_main[0], 0x0001, ide_read_pri, NULL, NULL, ide_write_pri, NULL, NULL , NULL); + io_removehandler(ide_base_main[0], 0x0008, ide_read_pri, ide_read_pri_w, ide_read_pri_l, ide_write_pri, ide_write_pri_w, ide_write_pri_l, NULL); + io_removehandler(ide_side_main[0], 0x0001, ide_read_pri, NULL, NULL, ide_write_pri, NULL, NULL , NULL); } void ide_sec_enable() { - io_sethandler(0x0170, 0x0008, ide_read_sec, ide_read_sec_w, ide_read_sec_l, ide_write_sec, ide_write_sec_w, ide_write_sec_l, NULL); - io_sethandler(0x0376, 0x0001, ide_read_sec, NULL, NULL, ide_write_sec, NULL, NULL , NULL); - ide_base_main[1] = 0x170; - ide_side_main[1] = 0x376; + io_sethandler(0x0170, 0x0008, ide_read_sec, ide_read_sec_w, ide_read_sec_l, ide_write_sec, ide_write_sec_w, ide_write_sec_l, NULL); + io_sethandler(0x0376, 0x0001, ide_read_sec, NULL, NULL, ide_write_sec, NULL, NULL , NULL); + ide_base_main[1] = 0x170; + ide_side_main[1] = 0x376; } void ide_sec_enable_ex() { - if (ide_base_main[1] & 0x300) - { - io_sethandler(ide_base_main[1], 0x0008, ide_read_sec, ide_read_sec_w, ide_read_sec_l, ide_write_sec, ide_write_sec_w, ide_write_sec_l, NULL); - } - if (ide_side_main[1] & 0x300) - { - io_sethandler(ide_side_main[1], 0x0001, ide_read_sec, NULL, NULL, ide_write_sec, NULL, NULL , NULL); - } + if (ide_base_main[1] & 0x300) + { + io_sethandler(ide_base_main[1], 0x0008, ide_read_sec, ide_read_sec_w, ide_read_sec_l, ide_write_sec, ide_write_sec_w, ide_write_sec_l, NULL); + } + if (ide_side_main[1] & 0x300) + { + io_sethandler(ide_side_main[1], 0x0001, ide_read_sec, NULL, NULL, ide_write_sec, NULL, NULL , NULL); + } } void ide_sec_disable() { - io_removehandler(ide_base_main[1], 0x0008, ide_read_sec, ide_read_sec_w, ide_read_sec_l, ide_write_sec, ide_write_sec_w, ide_write_sec_l, NULL); - io_removehandler(ide_side_main[1], 0x0001, ide_read_sec, NULL, NULL, ide_write_sec, NULL, NULL , NULL); + io_removehandler(ide_base_main[1], 0x0008, ide_read_sec, ide_read_sec_w, ide_read_sec_l, ide_write_sec, ide_write_sec_w, ide_write_sec_l, NULL); + io_removehandler(ide_side_main[1], 0x0001, ide_read_sec, NULL, NULL, ide_write_sec, NULL, NULL , NULL); } void ide_set_base(int controller, uint16_t port) @@ -2307,75 +2291,73 @@ void ide_set_side(int controller, uint16_t port) ide_side_main[controller] = port; } -/* *** REMOVE FROM CODE SUBMITTED TO MAINLINE - START *** */ void ide_ter_enable() { - io_sethandler(0x0168, 0x0008, ide_read_ter, ide_read_ter_w, ide_read_ter_l, ide_write_ter, ide_write_ter_w, ide_write_ter_l, NULL); - io_sethandler(0x036e, 0x0001, ide_read_ter, NULL, NULL, ide_write_ter, NULL, NULL , NULL); + io_sethandler(0x0168, 0x0008, ide_read_ter, ide_read_ter_w, ide_read_ter_l, ide_write_ter, ide_write_ter_w, ide_write_ter_l, NULL); + io_sethandler(0x036e, 0x0001, ide_read_ter, NULL, NULL, ide_write_ter, NULL, NULL , NULL); } void ide_ter_disable() { - io_removehandler(0x0168, 0x0008, ide_read_ter, ide_read_ter_w, ide_read_ter_l, ide_write_ter, ide_write_ter_w, ide_write_ter_l, NULL); - io_removehandler(0x036e, 0x0001, ide_read_ter, NULL, NULL, ide_write_ter, NULL, NULL , NULL); + io_removehandler(0x0168, 0x0008, ide_read_ter, ide_read_ter_w, ide_read_ter_l, ide_write_ter, ide_write_ter_w, ide_write_ter_l, NULL); + io_removehandler(0x036e, 0x0001, ide_read_ter, NULL, NULL, ide_write_ter, NULL, NULL , NULL); } void ide_ter_disable_cond() { - if ((ide_drives[4].type == IDE_NONE) && (ide_drives[5].type == IDE_NONE)) - { - ide_ter_disable(); - } + if ((ide_drives[4].type == IDE_NONE) && (ide_drives[5].type == IDE_NONE)) + { + ide_ter_disable(); + } } void ide_ter_init() { - ide_ter_enable(); + ide_ter_enable(); - timer_add(ide_callback_ter, &idecallback[2], &idecallback[2], NULL); + timer_add(ide_callback_ter, &idecallback[2], &idecallback[2], NULL); } void ide_qua_enable() { - io_sethandler(0x01e8, 0x0008, ide_read_qua, ide_read_qua_w, ide_read_qua_l, ide_write_qua, ide_write_qua_w, ide_write_qua_l, NULL); - io_sethandler(0x03ee, 0x0001, ide_read_qua, NULL, NULL, ide_write_qua, NULL, NULL , NULL); + io_sethandler(0x01e8, 0x0008, ide_read_qua, ide_read_qua_w, ide_read_qua_l, ide_write_qua, ide_write_qua_w, ide_write_qua_l, NULL); + io_sethandler(0x03ee, 0x0001, ide_read_qua, NULL, NULL, ide_write_qua, NULL, NULL , NULL); } void ide_qua_disable_cond() { - if ((ide_drives[6].type == IDE_NONE) && (ide_drives[7].type == IDE_NONE)) - { - ide_qua_disable(); - } + if ((ide_drives[6].type == IDE_NONE) && (ide_drives[7].type == IDE_NONE)) + { + ide_qua_disable(); + } } void ide_qua_disable() { - io_removehandler(0x01e8, 0x0008, ide_read_qua, ide_read_qua_w, ide_read_qua_l, ide_write_qua, ide_write_qua_w, ide_write_qua_l, NULL); - io_removehandler(0x03ee, 0x0001, ide_read_qua, NULL, NULL, ide_write_qua, NULL, NULL , NULL); + io_removehandler(0x01e8, 0x0008, ide_read_qua, ide_read_qua_w, ide_read_qua_l, ide_write_qua, ide_write_qua_w, ide_write_qua_l, NULL); + io_removehandler(0x03ee, 0x0001, ide_read_qua, NULL, NULL, ide_write_qua, NULL, NULL , NULL); } void ide_qua_init() { - ide_qua_enable(); + ide_qua_enable(); - timer_add(ide_callback_qua, &idecallback[3], &idecallback[3], NULL); + timer_add(ide_callback_qua, &idecallback[3], &idecallback[3], NULL); } -/* *** REMOVE FROM CODE SUBMITTED TO MAINLINE - END *** */ void ide_init() { - ide_pri_enable(); - ide_sec_enable(); - ide_bus_master_read = ide_bus_master_write = NULL; - - timer_add(ide_callback_pri, &idecallback[0], &idecallback[0], NULL); - timer_add(ide_callback_sec, &idecallback[1], &idecallback[1], NULL); + ide_pri_enable(); + ide_sec_enable(); + ide_bus_master_read = ide_bus_master_write = NULL; + + timer_add(ide_callback_pri, &idecallback[0], &idecallback[0], NULL); + timer_add(ide_callback_sec, &idecallback[1], &idecallback[1], NULL); } void ide_set_bus_master(int (*read)(int channel, uint8_t *data, int transfer_length), int (*write)(int channel, uint8_t *data, int transfer_length), void (*set_irq)(int channel)) { - ide_bus_master_read = read; - ide_bus_master_write = write; - ide_bus_master_set_irq = set_irq; + ide_bus_master_read = read; + ide_bus_master_write = write; + ide_bus_master_set_irq = set_irq; } diff --git a/src/ide.h b/src/ide.h index dedb41793..db8d52330 100644 --- a/src/ide.h +++ b/src/ide.h @@ -11,33 +11,34 @@ typedef struct IDE typedef struct __attribute__((__packed__)) IDE #endif { - int type; - int board; - uint8_t atastat; - uint8_t error; - int secount,sector,cylinder,head,drive,cylprecomp; - uint8_t command; - uint8_t fdisk; - int pos; - int packlen; - int spt,hpc; - int tracks; - int packetstatus; - uint8_t asc; - int reset; - FILE *hdfile; - uint16_t buffer[65536]; - int irqstat; - int service; - int lba; - int channel; - uint32_t lba_addr; - int skip512; - int blocksize, blockcount; - uint16_t dma_identify_data[3]; - int hdi,base; - int hdc_num; - uint8_t specify_success; + int type; + int board; + uint8_t atastat; + uint8_t error; + int secount,sector,cylinder,head,drive,cylprecomp; + uint8_t command; + uint8_t fdisk; + int pos; + int packlen; + int spt,hpc; + int tracks; + int packetstatus; + uint8_t asc; + int reset; + FILE *hdfile; + uint16_t buffer[65536]; + int irqstat; + int service; + int lba; + int channel; + uint32_t lba_addr; + int skip512; + int blocksize, blockcount; + uint16_t dma_identify_data[3]; + int hdi,base; + int hdc_num; + uint8_t specify_success; + int mdma_mode; } IDE; #ifdef __MSC__ # pragma pack(pop) diff --git a/src/mfm_xebec.c b/src/mfm_xebec.c index fde48c45d..fdbe7e7b3 100644 --- a/src/mfm_xebec.c +++ b/src/mfm_xebec.c @@ -763,7 +763,7 @@ static void xebec_callback(void *p) } } -static void loadhd(xebec_t *xebec, int d, const wchar_t *fn) +static void loadhd(xebec_t *xebec, int c, int d, const wchar_t *fn) { mfm_drive_t *drive = &xebec->drives[d]; @@ -796,9 +796,9 @@ static void loadhd(xebec_t *xebec, int d, const wchar_t *fn) } } - drive->spt = hdc[d].spt; - drive->hpc = hdc[d].hpc; - drive->tracks = hdc[d].tracks; + drive->spt = hdc[c].spt; + drive->hpc = hdc[c].hpc; + drive->tracks = hdc[c].tracks; } static struct @@ -844,15 +844,18 @@ static void xebec_set_switches(xebec_t *xebec) static void *xebec_init() { int i = 0; + int c = 0; xebec_t *xebec = malloc(sizeof(xebec_t)); memset(xebec, 0, sizeof(xebec_t)); for (i = 0; i < HDC_NUM; i++) { - if (hdc[i].bus == 1) + if ((hdc[i].bus == 1) && (hdc[i].mfm_channel < MFM_NUM)) { - loadhd(xebec, hdc[i].mfm_channel, hdd_fn[i]); + loadhd(xebec, i, hdc[i].mfm_channel, hdd_fn[i]); + c++; + if (c > MFM_NUM) break; } } @@ -904,15 +907,18 @@ device_t mfm_xebec_device = static void *dtc_5150x_init() { int i = 0; + int c = 0; xebec_t *xebec = malloc(sizeof(xebec_t)); memset(xebec, 0, sizeof(xebec_t)); for (i = 0; i < HDC_NUM; i++) { - if (hdc[i].bus == 1) + if ((hdc[i].bus == 1) && (hdc[i].mfm_channel < MFM_NUM)) { - loadhd(xebec, hdc[i].mfm_channel, hdd_fn[i]); + loadhd(xebec, i, hdc[i].mfm_channel, hdd_fn[i]); + c++; + if (c > MFM_NUM) break; } } diff --git a/src/scsi.c b/src/scsi.c index 733e2a0a7..c01458d44 100644 --- a/src/scsi.c +++ b/src/scsi.c @@ -35,6 +35,7 @@ static SCSI_CARD scsi_cards[] = { { "None", "none", NULL }, { "Adaptec AHA-1540B", "aha1540b", &aha1540b_device }, { "Adaptec AHA-1542CF", "aha1542cf", &aha1542cf_device }, + { "Adaptec AHA-1640", "aha1640", &aha1640_device }, { "BusLogic BT-542B", "bt542b", &buslogic_device }, { "BusLogic BT-958D PCI", "bt958d", &buslogic_pci_device }, { "", "", NULL } diff --git a/src/scsi_aha154x.c b/src/scsi_aha154x.c index 615bd8675..067b5dcea 100644 --- a/src/scsi_aha154x.c +++ b/src/scsi_aha154x.c @@ -25,7 +25,9 @@ #include #include "ibm.h" #include "io.h" +#include "mca.h" #include "mem.h" +#include "mca.h" #include "rom.h" #include "dma.h" #include "pic.h" @@ -176,7 +178,6 @@ static uint16_t aha_ports[] = { 0x0130, 0x0134, 0x0000, 0x0000 }; - /* * Write data to the BIOS space. * @@ -258,7 +259,7 @@ aha_patch(uint8_t *romptr, uint16_t ioaddr) /* Initialize AHA-154xNN-specific stuff. */ static void -aha154x_bios(uint16_t ioaddr, uint32_t memaddr, aha_info *aha) +aha154x_bios(uint16_t ioaddr, uint32_t memaddr, aha_info *aha, int irq, int dma) { uint32_t bios_size; uint32_t bios_addr; @@ -388,10 +389,11 @@ again: /* Initialize the on-board EEPROM. */ memset(aha_eep, 0x00, EEP_SIZE); aha_eep[0] = 7; /* SCSI ID 7 */ - aha_eep[1] = 15-9; /* IRQ15 */ - aha_eep[1] |= (6<<4); /* DMA6 */ - aha_eep[2] = (EE2_HABIOS | /* BIOS Space Reserved */ - EE2_SEEKRET); /* Immediate return on seek */ + aha_eep[0] |= (0x10 | 0x20 | 0x40); + aha_eep[1] = irq-9; /* IRQ15 */ + aha_eep[1] |= (dma<<4); /* DMA6 */ + aha_eep[2] = (EE2_DYNSCAN | /* BIOS Space Reserved */ + EE2_EXT1G | EE2_RMVOK); /* Immediate return on seek */ aha_eep[3] = SPEED_50; /* speed 5.0 MB/s */ aha_eep[6] = (EE6_TERM | /* host term enable */ EE6_RSTBUS); /* reset SCSI bus on boot */ @@ -843,6 +845,7 @@ typedef struct { mem_mapping_t mmio_mapping; aha_info aha; int chip; + uint8_t pos_regs[8]; } aha_t; #pragma pack(pop) @@ -855,7 +858,8 @@ static aha_t *ResetDev; enum { CHIP_AHA154XB, - CHIP_AHA154XCF + CHIP_AHA154XCF, + CHIP_AHA1640 }; @@ -2175,6 +2179,34 @@ aha_cmd_cb(void *priv) AHA_Callback += 50 * SCSI_TIME; } +uint8_t aha_mca_read(int port, void *p) +{ + aha_t *dev = (aha_t *)p; + + return dev->pos_regs[port & 7]; +} + +static uint16_t aha_mca_addr[6] = {0x130, 0x134, 0x230, 0x234, 0x330, 0x334}; + +void aha_mca_write(int port, uint8_t val, void *p) +{ + aha_t *dev = (aha_t *)p; + uint16_t addr; + + if (port < 0x102) + return; + + addr = aha_mca_addr[dev->pos_regs[4] & 6]; + io_removehandler(addr, 0x0004, aha_read, aha_readw, NULL, aha_write, aha_writew, NULL, dev); + + dev->pos_regs[port & 7] = val; + + if (dev->pos_regs[2] & 1) + { + io_sethandler(addr, 0x0004, aha_read, aha_readw, NULL, aha_write, aha_writew, NULL, dev); + } +} + static void * aha_init(int chip, int has_bios) @@ -2222,6 +2254,14 @@ aha_init(int chip, int has_bios) } } + if (dev->chip == CHIP_AHA1640) + { + pclog("Aha1640 initialized\n"); + mca_add(aha_mca_read, aha_mca_write, dev); + dev->pos_regs[0] = 0x1F; + dev->pos_regs[1] = 0x0F; + } + timer_add(aha_reset_poll, &ResetCB, &ResetCB, dev); timer_add(aha_cmd_cb, &AHA_Callback, &AHA_Callback, dev); @@ -2231,7 +2271,7 @@ aha_init(int chip, int has_bios) if (bios) { /* Perform AHA-154xNN-specific initialization. */ - aha154x_bios(dev->Base, bios_addr, &dev->aha); + aha154x_bios(dev->Base, bios_addr, &dev->aha, dev->Irq, dev->DmaChannel); } return(dev); @@ -2251,6 +2291,12 @@ aha_154xCF_init(void) return(aha_init(CHIP_AHA154XCF, 1)); } +static void * +aha_1640_init(void) +{ + return(aha_init(CHIP_AHA1640, 1)); +} + static void aha_close(void *priv) @@ -2359,6 +2405,77 @@ static device_config_t aha_154XCF_config[] = { } }; +static device_config_t aha_1640_config[] = { + { + "addr", "Address", CONFIG_SELECTION, "", 0x330, + { + { + "0x330", 0x330 + }, + { + "0x334", 0x334 + }, + { + "0x230", 0x230 + }, + { + "0x234", 0x234 + }, + { + "0x130", 0x130 + }, + { + "0x134", 0x134 + }, + { + "" + } + }, + }, + { + "irq", "IRQ", CONFIG_SELECTION, "", 10, + { + { + "IRQ 10", 10 + }, + { + "IRQ 11", 11 + }, + { + "IRQ 12", 12 + }, + { + "IRQ 14", 14 + }, + { + "IRQ 15", 15 + }, + { + "" + } + }, + }, + { + "dma", "DMA channel", CONFIG_SELECTION, "", 6, + { + { + "DMA 5", 5 + }, + { + "DMA 6", 6 + }, + { + "DMA 7", 7 + }, + { + "" + } + }, + }, + { + "", "", -1 + } +}; device_t aha1540b_device = { "Adaptec AHA-1540B", @@ -2383,3 +2500,15 @@ device_t aha1542cf_device = { NULL, aha_154XCF_config }; + +device_t aha1640_device = { + "Adaptec AHA-1640", + DEVICE_MCA, + aha_1640_init, + aha_close, + NULL, + NULL, + NULL, + NULL, + aha_1640_config +}; \ No newline at end of file diff --git a/src/scsi_aha154x.h b/src/scsi_aha154x.h index 67734e070..0e7db0d0d 100644 --- a/src/scsi_aha154x.h +++ b/src/scsi_aha154x.h @@ -12,6 +12,7 @@ typedef struct { extern device_t aha1540b_device; extern device_t aha1542cf_device; +extern device_t aha1640_device; #endif /*SCSI_AHA154X_H*/ diff --git a/src/win-language.c b/src/win-language.c index 333729302..a2820beb8 100644 --- a/src/win-language.c +++ b/src/win-language.c @@ -188,10 +188,10 @@ int file_dlg(HWND hwnd, WCHAR *f, char *fn, int save) int file_dlg_w_st(HWND hwnd, int i, WCHAR *fn, int save) { - file_dlg_w(hwnd, win_language_get_string_from_id(i), fn, save); + return file_dlg_w(hwnd, win_language_get_string_from_id(i), fn, save); } int file_dlg_st(HWND hwnd, int i, char *fn, int save) { - file_dlg(hwnd, win_language_get_string_from_id(i), fn, save); + return file_dlg(hwnd, win_language_get_string_from_id(i), fn, save); } diff --git a/src/win-settings.c b/src/win-settings.c index 3e48e898d..8567391d1 100644 --- a/src/win-settings.c +++ b/src/win-settings.c @@ -1192,6 +1192,7 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR int c = 0; int d = 0; LPTSTR lptsTemp; + device_t *scsi_dev; switch (message) { @@ -1210,21 +1211,26 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR break; } - settings_scsi_to_list[c] = d; - + settings_scsi_to_list[c] = d; + if (scsi_card_available(c)) { - if (c == 0) + scsi_dev = scsi_card_getdevice(c); + + if (!scsi_dev || (scsi_dev->flags & DEVICE_MCA) == (models[temp_model].flags & MODEL_MCA)) { - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(2152)); + if (c == 0) + { + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(2152)); + } + else + { + mbstowcs(lptsTemp, s, strlen(s) + 1); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); + } + settings_list_to_scsi[d] = c; + d++; } - else - { - mbstowcs(lptsTemp, s, strlen(s) + 1); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); - } - settings_list_to_scsi[d] = c; - d++; } c++; diff --git a/src/win.c b/src/win.c index 4d7bc0631..c3bc6a176 100644 --- a/src/win.c +++ b/src/win.c @@ -920,8 +920,14 @@ void update_status_bar_panes(HWND hwnds) c_ide_dma = count_hard_disks(3); c_scsi = count_hard_disks(4); + for (i = 0; i < sb_parts; i++) + { + SendMessage(hwnds, SB_SETICON, i, (LPARAM) NULL); + } + sb_parts = 0; - memset(sb_part_meanings, 0, 40); + memset(iStatusWidths, 0, 48); + memset(sb_part_meanings, 0, 48); for (i = 0; i < 4; i++) { if (fdd_get_type(i) != 0) @@ -950,14 +956,14 @@ void update_status_bar_panes(HWND hwnds) sb_part_meanings[sb_parts] = 0x20; sb_parts++; } - if (c_ide_pio && (models[model].flags & MODEL_HAS_IDE) || !memcmp(hdd_controller_name, "xtide", 5)) + if (c_ide_pio && ((models[model].flags & MODEL_HAS_IDE) || !memcmp(hdd_controller_name, "xtide", 5))) { edge += sb_icon_width; iStatusWidths[sb_parts] = edge; sb_part_meanings[sb_parts] = 0x21; sb_parts++; } - if (c_ide_dma && (models[model].flags & MODEL_HAS_IDE) || !memcmp(hdd_controller_name, "xtide", 5)) + if (c_ide_dma && ((models[model].flags & MODEL_HAS_IDE) || !memcmp(hdd_controller_name, "xtide", 5))) { edge += sb_icon_width; iStatusWidths[sb_parts] = edge; @@ -1605,11 +1611,8 @@ void win_cdrom_eject(uint8_t id) /* Signal disc change to the emulated machine. */ cdrom_insert(id); } - if (cdrom_drives[id].host_drive == 200) - { - CheckMenuItem(hmenu, IDM_CDROM_1_IMAGE + id, MF_UNCHECKED); - } - else + CheckMenuItem(hmenu, IDM_CDROM_1_IMAGE + id, MF_UNCHECKED); + if ((cdrom_drives[id].host_drive >= 65) && (cdrom_drives[id].host_drive <= 90)) { CheckMenuItem(hmenu, IDM_CDROM_1_REAL + id + (cdrom_drive << 2), MF_UNCHECKED); } @@ -1795,21 +1798,25 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM break; case IDM_VID_FULLSCREEN: - if (video_fullscreen_first) - { - video_fullscreen_first = 0; - msgbox_info(ghwnd, 2193); - } - startblit(); - video_wait_for_blit(); - mouse_close(); - vid_apis[0][vid_api].close(); - video_fullscreen = 1; - vid_apis[1][vid_api].init(ghwnd); - mouse_init(); - leave_fullscreen_flag = 0; - endblit(); - device_force_redraw(); + + if(video_fullscreen!=1){ + + if (video_fullscreen_first) + { + video_fullscreen_first = 0; + msgbox_info(ghwnd, 2193); + } + startblit(); + video_wait_for_blit(); + mouse_close(); + vid_apis[0][vid_api].close(); + video_fullscreen = 1; + vid_apis[1][vid_api].init(ghwnd); + mouse_init(); + leave_fullscreen_flag = 0; + endblit(); + device_force_redraw(); + } break; case IDM_VID_FS_FULL: @@ -2209,6 +2216,7 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR int cdrom_id = 0; int menu_sub_param = 0; int menu_super_param = 0; + int ret = 0; HMENU hmenu; @@ -2219,7 +2227,8 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR { case IDM_DISC_1: case IDM_DISC_1_WP: - if (!file_dlg_w_st(hwnd, 2173, discfns[0], 0)) + ret = file_dlg_w_st(hwnd, 2173, discfns[0], 0); + if (!ret) { disc_close(0); ui_writeprot[0] = (LOWORD(wParam) == IDM_DISC_1_WP) ? 1 : 0; @@ -2231,7 +2240,8 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR break; case IDM_DISC_2: case IDM_DISC_2_WP: - if (!file_dlg_w_st(hwnd, 2173, discfns[1], 0)) + ret = file_dlg_w_st(hwnd, 2173, discfns[1], 0); + if (!ret) { disc_close(1); ui_writeprot[1] = (LOWORD(wParam) == IDM_DISC_2_WP) ? 1 : 0; @@ -2243,7 +2253,8 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR break; case IDM_DISC_3: case IDM_DISC_3_WP: - if (!file_dlg_w_st(hwnd, 2173, discfns[2], 0)) + ret = file_dlg_w_st(hwnd, 2173, discfns[2], 0); + if (!ret) { disc_close(2); ui_writeprot[2] = (LOWORD(wParam) == IDM_DISC_3_WP) ? 1 : 0; @@ -2255,7 +2266,8 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR break; case IDM_DISC_4: case IDM_DISC_4_WP: - if (!file_dlg_w_st(hwnd, 2173, discfns[3], 0)) + ret = file_dlg_w_st(hwnd, 2173, discfns[3], 0); + if (!ret) { disc_close(3); ui_writeprot[3] = (LOWORD(wParam) == IDM_DISC_4_WP) ? 1 : 0; @@ -2394,6 +2406,7 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR return 0; case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: GetClientRect(hwnd, (LPRECT)& rc); pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);