From 17e2cd6776e1a11aa33ef2f6234470a3cf50a98e Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 28 Dec 2016 23:34:00 +0100 Subject: [PATCH] Added a quaternary IDE controller on ports 1E8-1EF/3EE; The tertiary and quaternary IDE controllers are now fully configurable; The IRQ of the RTL8029AS network card is now configurable; CopyQM floppy images are now supported. --- src/disc.c | 12 + src/disc_img.c | 186 ++++++-- src/ibm.h | 8 +- src/ide.c | 97 +++- src/ide.h | 10 +- src/model.c | 15 - src/ne2000.c | 37 +- src/pc.c | 43 ++ src/pc.rc | 217 +++++---- src/pic.c | 30 +- src/resources.h | 241 +++++----- src/win-hdconf.c | 1098 +++++++++------------------------------------- src/win.c | 288 +++++++++--- 13 files changed, 1072 insertions(+), 1210 deletions(-) diff --git a/src/disc.c b/src/disc.c index badbb81cc..ee4a4ccc3 100644 --- a/src/disc.c +++ b/src/disc.c @@ -63,12 +63,24 @@ static struct } loaders[]= { + {"001", img_load, img_close, -1}, + {"002", img_load, img_close, -1}, + {"003", img_load, img_close, -1}, + {"004", img_load, img_close, -1}, + {"005", img_load, img_close, -1}, + {"006", img_load, img_close, -1}, + {"007", img_load, img_close, -1}, + {"008", img_load, img_close, -1}, + {"009", img_load, img_close, -1}, + {"010", img_load, img_close, -1}, {"12", img_load, img_close, -1}, {"144", img_load, img_close, -1}, {"360", img_load, img_close, -1}, {"720", img_load, img_close, -1}, {"86F", d86f_load, d86f_close, -1}, {"BIN", img_load, img_close, -1}, + {"CQ", img_load, img_close, -1}, + {"CQM", img_load, img_close, -1}, {"DSK", img_load, img_close, -1}, {"FDI", fdi_load, fdi_close, -1}, {"FLP", img_load, img_close, -1}, diff --git a/src/disc_img.c b/src/disc_img.c index fa8641611..f4b531ef1 100644 --- a/src/disc_img.c +++ b/src/disc_img.c @@ -1,6 +1,8 @@ /* Copyright holders: Sarah Walker, Tenshi see COPYING for more details */ +#include + #include "ibm.h" #include "disc.h" #include "disc_img.h" @@ -27,6 +29,10 @@ static struct uint16_t sector_pos[2][256]; uint8_t current_sector_pos_side; uint16_t current_sector_pos; + uint8_t *cqm_data; + uint8_t is_cqm; + uint8_t interleave; + uint8_t skew; } img[FDD_NUM]; uint8_t dmf_r[21] = { 12, 2, 13, 3, 14, 4, 15, 5, 16, 6, 17, 7, 18, 8, 19, 9, 20, 10, 21, 11, 1 }; @@ -232,9 +238,13 @@ void img_load(int drive, char *fn) uint8_t max_spt; /* Used for XDF detection. */ int temp_rate; char ext[4]; - int fdi; + int fdi, cqm; int i; - uint8_t first_byte; + uint8_t first_byte, second_byte; + uint16_t comment_len = 0; + int16_t block_len = 0; + uint32_t cur_pos = 0; + uint8_t rep_byte = 0; ext[0] = fn[strlen(fn) - 3] | 0x60; ext[1] = fn[strlen(fn) - 2] | 0x60; @@ -258,6 +268,10 @@ void img_load(int drive, char *fn) } fwriteprot[drive] = writeprot[drive]; + fdi = cqm = 0; + + img[drive].interleave = img[drive].skew = 0; + if (strcmp(ext, "fdi") == 0) { /* This is a Japanese FDI image, so let's read the header */ @@ -278,23 +292,94 @@ void img_load(int drive, char *fn) bpb_sides = fgetc(img[drive].f); fdi = 1; + cqm = 0; } else { - /* Read the BPB */ - pclog("img_load(): File is a raw image...\n"); + /* Read the first type bytes. */ fseek(img[drive].f, 0x00, SEEK_SET); first_byte = fgetc(img[drive].f); - fseek(img[drive].f, 0x0B, SEEK_SET); - fread(&bpb_bps, 1, 2, img[drive].f); - fseek(img[drive].f, 0x13, SEEK_SET); - fread(&bpb_total, 1, 2, img[drive].f); - fseek(img[drive].f, 0x15, SEEK_SET); - bpb_mid = fgetc(img[drive].f); - fseek(img[drive].f, 0x18, SEEK_SET); - bpb_sectors = fgetc(img[drive].f); - fseek(img[drive].f, 0x1A, SEEK_SET); - bpb_sides = fgetc(img[drive].f); + fseek(img[drive].f, 0x01, SEEK_SET); + second_byte = fgetc(img[drive].f); + + if (((first_byte == 'C') && (second_byte == 'Q')) || ((first_byte == 'c') && (second_byte == 'q'))) + { + pclog("img_load(): File is a CopyQM image...\n"); + + fwriteprot[drive] = writeprot[drive] = 1; + + fseek(img[drive].f, 0x03, SEEK_SET); + fread(&bpb_bps, 1, 2, img[drive].f); + /* fseek(img[drive].f, 0x0B, SEEK_SET); + fread(&bpb_total, 1, 2, img[drive].f); */ + fseek(img[drive].f, 0x10, SEEK_SET); + bpb_sectors = fgetc(img[drive].f); + fseek(img[drive].f, 0x12, SEEK_SET); + bpb_sides = fgetc(img[drive].f); + fseek(img[drive].f, 0x5B, SEEK_SET); + img[drive].tracks = fgetc(img[drive].f); + + bpb_total = ((uint16_t) bpb_sectors) * ((uint16_t) bpb_sides) * img[drive].tracks; + + fseek(img[drive].f, 0x74, SEEK_SET); + img[drive].interleave = fgetc(img[drive].f); + fseek(img[drive].f, 0x75, SEEK_SET); + img[drive].skew = fgetc(img[drive].f); + + img[drive].cqm_data = (uint8_t *) malloc(((uint32_t) bpb_total) * ((uint32_t) bpb_bps)); + memset(img[drive].cqm_data, 0xf6, ((uint32_t) bpb_total) * ((uint32_t) bpb_bps)); + + fseek(img[drive].f, 0x6F, SEEK_SET); + fread(&comment_len, 1, 2, img[drive].f); + + fseek(img[drive].f, -1, SEEK_END); + size = ftell(img[drive].f) + 1; + + fseek(img[drive].f, 133 + comment_len, SEEK_SET); + + cur_pos = 0; + + while(!feof(img[drive].f)) + { + fread(&block_len, 1, 2, img[drive].f); + + if (!feof(img[drive].f)) + { + if (block_len < 0) + { + rep_byte = fgetc(img[drive].f); + block_len = -block_len; + memset(img[drive].cqm_data + cur_pos, rep_byte, block_len); + cur_pos += block_len; + } + else if (block_len > 0) + { + fread(img[drive].cqm_data + cur_pos, 1, block_len, img[drive].f); + cur_pos += block_len; + } + } + } + printf("Finished reading CopyQM image data\n"); + + cqm = 1; + } + else + { + /* Read the BPB */ + pclog("img_load(): File is a raw image...\n"); + fseek(img[drive].f, 0x0B, SEEK_SET); + fread(&bpb_bps, 1, 2, img[drive].f); + fseek(img[drive].f, 0x13, SEEK_SET); + fread(&bpb_total, 1, 2, img[drive].f); + fseek(img[drive].f, 0x15, SEEK_SET); + bpb_mid = fgetc(img[drive].f); + fseek(img[drive].f, 0x18, SEEK_SET); + bpb_sectors = fgetc(img[drive].f); + fseek(img[drive].f, 0x1A, SEEK_SET); + bpb_sides = fgetc(img[drive].f); + + cqm = 0; + } img[drive].base = 0; fdi = 0; @@ -308,9 +393,9 @@ void img_load(int drive, char *fn) img[drive].hole = 0; - pclog("BPB reports %i sides and %i bytes per sector\n", bpb_sides, bpb_bps); + pclog("BPB reports %i sides and %i bytes per sector (%i sectors total)\n", bpb_sides, bpb_bps, bpb_total); - if (((bpb_sides < 1) || (bpb_sides > 2) || !bps_is_valid(bpb_bps) || !first_byte_is_valid(first_byte)) && !fdi) + if (((bpb_sides < 1) || (bpb_sides > 2) || !bps_is_valid(bpb_bps) || !first_byte_is_valid(first_byte)) && !fdi && !cqm) { /* The BPB is giving us a wacky number of sides and/or bytes per sector, therefore it is most probably not a BPB at all, so we have to guess the parameters from file size. */ @@ -364,8 +449,11 @@ void img_load(int drive, char *fn) } else { - /* Number of tracks = number of total sectors divided by sides times sectors per track. */ - img[drive].tracks = ((uint32_t) bpb_total) / (((uint32_t) bpb_sides) * ((uint32_t) bpb_sectors)); + if (!cqm) + { + /* Number of tracks = number of total sectors divided by sides times sectors per track. */ + img[drive].tracks = ((uint32_t) bpb_total) / (((uint32_t) bpb_sides) * ((uint32_t) bpb_sectors)); + } } /* The rest we just set directly from the BPB. */ img[drive].sectors = bpb_sectors; @@ -430,6 +518,8 @@ void img_load(int drive, char *fn) img[drive].track_flags |= temp_rate & 3; /* Data rate. */ if (temp_rate & 4) img[drive].track_flags |= 0x20; /* RPM. */ + img[drive].is_cqm = cqm; + pclog("Disk flags: %i, track flags: %i\n", img[drive].disk_flags, img[drive].track_flags); d86f_register_img(drive); @@ -444,6 +534,8 @@ void img_close(int drive) d86f_unregister(drive); if (img[drive].f) fclose(img[drive].f); + if (img[drive].cqm_data) + free(img[drive].cqm_data); img[drive].f = NULL; } @@ -478,6 +570,7 @@ void img_seek(int drive, int track) int is_t0, sector, current_pos, img_pos, sr, sside, total, array_sector, buf_side, buf_pos; int ssize = 128 << ((int) img[drive].sector_size); + uint32_t cur_pos = 0; if (!img[drive].f) return; @@ -489,16 +582,30 @@ void img_seek(int drive, int track) is_t0 = (track == 0) ? 1 : 0; - fseek(img[drive].f, img[drive].base + (track * img[drive].sectors * ssize * img[drive].sides), SEEK_SET); + if (!img[drive].is_cqm) + { + fseek(img[drive].f, img[drive].base + (track * img[drive].sectors * ssize * img[drive].sides), SEEK_SET); + } + for (side = 0; side < img[drive].sides; side++) { - fread(img[drive].track_data[side], img[drive].sectors * ssize, 1, img[drive].f); + if (img[drive].is_cqm) + { + cur_pos = (track * img[drive].sectors * ssize * img[drive].sides) + (side * img[drive].sectors * ssize); + // pclog("Current position: %i... ", cur_pos); + memcpy(img[drive].track_data[side], img[drive].cqm_data + cur_pos, img[drive].sectors * ssize); + // pclog("done!\n"); + } + else + { + fread(img[drive].track_data[side], img[drive].sectors * ssize, 1, img[drive].f); + } } d86f_reset_index_hole_pos(drive, 0); d86f_reset_index_hole_pos(drive, 1); - if (!img[drive].xdf_type) + if (!img[drive].xdf_type || img[drive].is_cqm) { for (side = 0; side < img[drive].sides; side++) { @@ -507,13 +614,32 @@ void img_seek(int drive, int track) for (sector = 0; sector < img[drive].sectors; sector++) { // sr = img[drive].dmf ? (dmf_r[sector]) : (sector + 1); - if (img[drive].gap3_size < 68) + if (img[drive].is_cqm) { - sr = interleave(sector, 1, img[drive].sectors); + if (img[drive].interleave) + { + sr = interleave(sector, img[drive].skew, img[drive].sectors); + } + else + { + sr = sector + 1; + sr += img[drive].skew; + if (sr > img[drive].sectors) + { + sr -= img[drive].sectors; + } + } } else { - sr = img[drive].dmf ? (dmf_r[sector]) : (sector + 1); + if (img[drive].gap3_size < 68) + { + sr = interleave(sector, 1, img[drive].sectors); + } + else + { + sr = img[drive].dmf ? (dmf_r[sector]) : (sector + 1); + } } id[0] = track; id[1] = side; @@ -522,7 +648,14 @@ void img_seek(int drive, int track) img[drive].sector_pos_side[side][sr] = side; img[drive].sector_pos[side][sr] = (sr - 1) * ssize; // pclog("Seek: %i %i %i %i | %i %04X\n", id[0], id[1], id[2], id[3], side, (sr - 1) * ssize); - current_pos = d86f_prepare_sector(drive, side, current_pos, id, &img[drive].track_data[side][(sr - 1) * ssize], ssize, img[drive].gap2_size, img[drive].gap3_size, 0, 0); + if (img[drive].is_cqm) + { + current_pos = d86f_prepare_sector(drive, side, current_pos, id, &img[drive].track_data[side][sector * ssize], ssize, img[drive].gap2_size, img[drive].gap3_size, 0, 0); + } + else + { + current_pos = d86f_prepare_sector(drive, side, current_pos, id, &img[drive].track_data[side][(sr - 1) * ssize], ssize, img[drive].gap2_size, img[drive].gap3_size, 0, 0); + } } } } @@ -602,6 +735,9 @@ void img_writeback(int drive) if (!img[drive].f) return; + + if (img[drive].is_cqm) + return; fseek(img[drive].f, img[drive].base + (img[drive].track * img[drive].sectors * ssize * img[drive].sides), SEEK_SET); for (side = 0; side < img[drive].sides; side++) diff --git a/src/ibm.h b/src/ibm.h index 6d4236ff0..5e5bd9324 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -522,7 +522,9 @@ typedef struct uint32_t base; } hard_disk_t; -hard_disk_t hdc[6]; +#define IDE_NUM 8 + +hard_disk_t hdc[IDE_NUM]; uint64_t hdt[128][3]; @@ -535,7 +537,7 @@ int keybsenddelay; /*CD-ROM*/ extern int cdrom_drive; extern int old_cdrom_drive; -extern int idecallback[3]; +extern int idecallback[4]; extern int cdrom_enabled; extern int scsi_cdrom_enabled; @@ -548,8 +550,6 @@ extern int scsi_cdrom_enabled; extern uint32_t SCSIGetCDVolume(int channel); extern uint32_t SCSIGetCDChannel(int channel); -extern int ide_ter_enabled; - #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define ELEMENTS(Array) (sizeof(Array) / sizeof((Array)[0])) diff --git a/src/ide.c b/src/ide.c index 59101c781..0cd093255 100644 --- a/src/ide.c +++ b/src/ide.c @@ -140,11 +140,11 @@ typedef struct IDE int hdc_num; } IDE; -IDE ide_drives[6]; +IDE ide_drives[IDE_NUM]; IDE *ext_ide; -char ide_fn[6][512]; +char ide_fn[IDE_NUM][512]; int (*ide_bus_master_read_sector)(int channel, uint8_t *data); int (*ide_bus_master_write_sector)(int channel, uint8_t *data); @@ -154,16 +154,14 @@ static void callnonreadcd(IDE *ide); static void callreadcd(IDE *ide); static void atapicommand(int ide_board); -int idecallback[3] = {0, 0, 0}; +int idecallback[4] = {0, 0, 0, 0}; -int cur_ide[3]; +int cur_ide[4]; int atapi_command = 0; int atapi_cdrom_channel = 2; -int ide_ter_enabled = 0; - uint8_t getstat(IDE *ide) { return ide->atastat; } int image_is_hdi(const char *s) @@ -190,6 +188,9 @@ int image_is_hdi(const char *s) } } +int ide34_enable[2] = { 0, 0 }; +int ide34_irq[2] = { 10, 11 }; + static inline void ide_irq_raise(IDE *ide) { // pclog("IDE_IRQ_RAISE\n"); @@ -211,7 +212,10 @@ static inline void ide_irq_raise(IDE *ide) picint(1 << 15); break; case 2: - picint(1 << 10); + picint(1 << ide34_irq[0]); + break; + case 3: + picint(1 << ide34_irq[1]); break; } #endif @@ -247,7 +251,10 @@ static inline void ide_irq_lower(IDE *ide) picintc(1 << 15); break; case 2: - picintc(1 << 10); + picintc(1 << ide34_irq[0]); + break; + case 3: + picintc(1 << ide34_irq[1]); break; } #endif @@ -261,14 +268,16 @@ int get_irq(uint8_t board) { if (board == 0) return 1 << 14; else if (board == 1) return 1 << 15; - else if (board == 2) return 1 << 10; + else if (board == 2) return 1 << ide34_irq[0]; + else if (board == 3) return 1 << ide34_irq[1]; } int get_pic_mask(uint8_t board) { if (board == 0) return 1 << 6; else if (board == 1) return 1 << 7; - else if (board == 2) return 1 << 2; + else if (board == 2) return 1 << (ide34_irq[0] & 7); + else if (board == 3) return 1 << (ide34_irq[1] & 7); } void ide_irq_update(IDE *ide) @@ -620,7 +629,7 @@ void resetide(void) int d; /* Close hard disk image files (if previously open) */ - for (d = 0; d < 4; d++) { + for (d = 0; d < IDE_NUM; d++) { ide_drives[d].type = IDE_NONE; if (ide_drives[d].hdfile != NULL) { fclose(ide_drives[d].hdfile); @@ -631,23 +640,16 @@ void resetide(void) ide_drives[d].board = (d & 2) ? 1 : 0; } - for (d = 4; d < 6; d++) - { - ide_drives[d].type = IDE_NONE; - ide_drives[d].atastat = READY_STAT | DSC_STAT; - ide_drives[d].service = 0; - ide_drives[d].board = 2; - } - page_flags[GPMODE_CDROM_AUDIO_PAGE] &= 0xFD; /* Clear changed flag for CDROM AUDIO mode page. */ memset(mode_pages_in[GPMODE_CDROM_AUDIO_PAGE], 0, 256); /* Clear the page itself. */ idecallback[0]=idecallback[1]=0; + idecallback[2]=idecallback[3]=0; #ifdef MAINLINE #define IDE_DRIVES 4 #else -#define IDE_DRIVES 6 +#define IDE_DRIVES IDE_NUM #endif for (d = 0; d < IDE_DRIVES; d++) @@ -679,6 +681,7 @@ void resetide(void) cur_ide[1] = 2; cur_ide[2] = 4; + cur_ide[3] = 8; // ide_drives[1].type = IDE_CDROM; @@ -1800,6 +1803,12 @@ void ide_callback_ter() callbackide(2); } +void ide_callback_qua() +{ + idecallback[3] = 0; + callbackide(3); +} + /*ATAPI CD-ROM emulation*/ void atapi_cmd_error(IDE *ide, uint8_t sensekey, uint8_t asc, uint8_t ascq) { @@ -3078,6 +3087,31 @@ uint32_t ide_read_ter_l(uint16_t addr, void *priv) { return readidel(2); } + +void ide_write_qua(uint16_t addr, uint8_t val, void *priv) +{ + writeide(3, addr, val); +} +void ide_write_qua_w(uint16_t addr, uint16_t val, void *priv) +{ + writeidew(3, val); +} +void ide_write_qua_l(uint16_t addr, uint32_t val, void *priv) +{ + writeidel(3, val); +} +uint8_t ide_read_qua(uint16_t addr, void *priv) +{ + return readide(3, addr); +} +uint16_t ide_read_qua_w(uint16_t addr, void *priv) +{ + return readidew(3); +} +uint32_t ide_read_qua_l(uint16_t addr, void *priv) +{ + return readidel(3); +} /* *** REMOVE FROM CODE SUBMITTED TO MAINLINE - END *** */ void ide_pri_enable() @@ -3109,16 +3143,12 @@ 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); - - ide_ter_enabled = 1; } 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); - - ide_ter_enabled = 0; } void ide_ter_init() @@ -3127,6 +3157,25 @@ void ide_ter_init() 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); +} + +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); +} + +void ide_qua_init() +{ + ide_qua_enable(); + + timer_add(ide_callback_qua, &idecallback[3], &idecallback[3], NULL); +} /* *** REMOVE FROM CODE SUBMITTED TO MAINLINE - END *** */ void ide_init() diff --git a/src/ide.h b/src/ide.h index bae43ae64..b61b4b0df 100644 --- a/src/ide.h +++ b/src/ide.h @@ -14,19 +14,25 @@ extern void callbackide(int ide_board); extern void resetide(void); extern void ide_init(); extern void ide_ter_init(); +extern void ide_qua_init(); extern void ide_pri_enable(); extern void ide_sec_enable(); extern void ide_ter_enable(); +extern void ide_qua_enable(); extern void ide_pri_disable(); extern void ide_sec_disable(); extern void ide_ter_disable(); +extern void ide_qua_disable(); extern void ide_set_bus_master(int (*read_sector)(int channel, uint8_t *data), int (*write_sector)(int channel, uint8_t *data), void (*set_irq)(int channel)); extern int ideboard; -extern int idecallback[3]; +extern int ide34_enable[2]; +extern int ide34_irq[2]; -extern char ide_fn[6][512]; +extern int idecallback[4]; + +extern char ide_fn[IDE_NUM][512]; extern int atapi_cdrom_channel; diff --git a/src/model.c b/src/model.c index db7607cef..fb17fa28d 100644 --- a/src/model.c +++ b/src/model.c @@ -431,7 +431,6 @@ void at_sis496_init() memregs_init(); pci_init(PCI_CONFIG_TYPE_1, 0, 31); device_add(&sis496_device); - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_r418_init() @@ -449,7 +448,6 @@ void at_premiere_common_init() fdc37c665_init(); intel_batman_init(); device_add(&intel_flash_bxt_ami_device); - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_batman_init() @@ -483,7 +481,6 @@ void at_advanced_common_init() i430fx_init(); piix_init(7); pc87306_init(); - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_endeavor_init() @@ -508,7 +505,6 @@ void at_mb500n_init() piix_init(7); fdc37c665_init(); device_add(&intel_flash_bxt_device); - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } #if 0 @@ -522,7 +518,6 @@ void at_powermate_v_init() fdc37c665_init(); acerm3a_io_init(); device_add(&intel_flash_bxt_device); - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } #endif @@ -535,7 +530,6 @@ void at_p54tp4xe_init() piix_init(7); fdc37c665_init(); device_add(&intel_flash_bxt_device); - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_acerm3a_init() @@ -548,7 +542,6 @@ void at_acerm3a_init() fdc37c932fr_init(); acerm3a_io_init(); device_add(&intel_flash_bxb_device); - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_acerv35n_init() @@ -561,7 +554,6 @@ void at_acerv35n_init() fdc37c932fr_init(); acerm3a_io_init(); device_add(&intel_flash_bxb_device); - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_p55t2p4_init() @@ -573,7 +565,6 @@ void at_p55t2p4_init() piix3_init(7); w83877f_init(); device_add(&intel_flash_bxt_device); - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_i430vx_init() @@ -585,7 +576,6 @@ void at_i430vx_init() piix3_init(7); um8669f_init(); device_add(&intel_flash_bxt_device); - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_p55tvp4_init() @@ -597,8 +587,6 @@ void at_p55tvp4_init() piix3_init(7); w83877f_init(); device_add(&intel_flash_bxt_device); - - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_p55va_init() @@ -610,7 +598,6 @@ void at_p55va_init() piix3_init(7); fdc37c932fr_init(); device_add(&intel_flash_bxt_device); - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void at_i440fx_init() @@ -622,7 +609,6 @@ void at_i440fx_init() piix3_init(7); fdc37c665_init(); device_add(&intel_flash_bxt_device); - if ((atapi_cdrom_channel >= 4) && (atapi_cdrom_channel <= 5) && cdrom_enabled && !scsi_cdrom_enabled) ide_ter_init(); } void model_init() @@ -632,7 +618,6 @@ void model_init() io_init(); fdc_update_is_nsc(0); - ide_ter_enabled = 0; models[model].init(); if (models[model].device) device_add(models[model].device); diff --git a/src/ne2000.c b/src/ne2000.c index 3eb2df438..b8121e9c6 100644 --- a/src/ne2000.c +++ b/src/ne2000.c @@ -1928,7 +1928,7 @@ void *rtl8029as_init() memset(ne2000, 0, sizeof(ne2000_t)); disable_netbios = device_get_config_int("disable_netbios"); - ne2000_setirq(ne2000, (ide_ter_enabled ? 11 : 10)); + ne2000_setirq(ne2000, device_get_config_int("irq")); //net_type //0 pcap @@ -1981,7 +1981,8 @@ void *rtl8029as_init() bios_addr = 0xD0000; } - ne2000_pci_regs[0x3C] = ide_ter_enabled ? 11 : 10; + // ne2000_pci_regs[0x3C] = ide_ter_enabled ? 11 : 10; + ne2000_pci_regs[0x3C] = device_get_config_int("irq"); ne2000_pci_regs[0x3D] = 1; memset(rtl8029as_eeprom, 0, 128); @@ -2274,6 +2275,38 @@ static device_config_t ne2000_config[] = static device_config_t rtl8029as_config[] = { + { + .name = "irq", + .description = "IRQ", + .type = CONFIG_SELECTION, + .selection = + { + { + .description = "IRQ 3", + .value = 3 + }, + { + .description = "IRQ 5", + .value = 5 + }, + { + .description = "IRQ 7", + .value = 7 + }, + { + .description = "IRQ 10", + .value = 10 + }, + { + .description = "IRQ 11", + .value = 11 + }, + { + .description = "" + } + }, + .default_int = 10 + }, { .name = "net_type", .description = "Network type", diff --git a/src/pc.c b/src/pc.c index bc438c4df..3477f95aa 100644 --- a/src/pc.c +++ b/src/pc.c @@ -403,6 +403,19 @@ void resetpchard() video_init(); speaker_init(); + ide_ter_disable(); + ide_qua_disable(); + + if (ide34_enable[0]) + { + ide_ter_init(); + } + + if (ide34_enable[1]) + { + ide_qua_init(); + } + vlan_reset(); //NETWORK network_card_init(network_card_current); @@ -735,6 +748,23 @@ void loadconfig(char *fn) p = (char *)config_get_string(NULL, "hdh_fn", ""); if (p) strcpy(ide_fn[5], p); else strcpy(ide_fn[5], ""); + hdc[6].spt = config_get_int(NULL, "hdi_sectors", 0); + hdc[6].hpc = config_get_int(NULL, "hdi_heads", 0); + hdc[6].tracks = config_get_int(NULL, "hdi_cylinders", 0); + p = (char *)config_get_string(NULL, "hdi_fn", ""); + if (p) strcpy(ide_fn[6], p); + else strcpy(ide_fn[6], ""); + hdc[7].spt = config_get_int(NULL, "hdj_sectors", 0); + hdc[7].hpc = config_get_int(NULL, "hdj_heads", 0); + hdc[7].tracks = config_get_int(NULL, "hdj_cylinders", 0); + p = (char *)config_get_string(NULL, "hdj_fn", ""); + if (p) strcpy(ide_fn[7], p); + else strcpy(ide_fn[7], ""); + + ide34_enable[0] = config_get_int(NULL, "ide_ter_enable", 0); + ide34_irq[0] = config_get_int(NULL, "ide_ter_irq", 10); + ide34_enable[1] = config_get_int(NULL, "ide_qua_enable", 0); + ide34_irq[1] = config_get_int(NULL, "ide_qua_irq", 11); fdd_set_type(0, config_get_int(NULL, "drive_a_type", 1)); fdd_set_type(1, config_get_int(NULL, "drive_b_type", 1)); @@ -881,6 +911,19 @@ void saveconfig() config_set_int(NULL, "hdh_heads", hdc[5].hpc); config_set_int(NULL, "hdh_cylinders", hdc[5].tracks); config_set_string(NULL, "hdh_fn", ide_fn[5]); + config_set_int(NULL, "hdi_sectors", hdc[6].spt); + config_set_int(NULL, "hdi_heads", hdc[6].hpc); + config_set_int(NULL, "hdi_cylinders", hdc[6].tracks); + config_set_string(NULL, "hdi_fn", ide_fn[6]); + config_set_int(NULL, "hdj_sectors", hdc[7].spt); + config_set_int(NULL, "hdj_heads", hdc[7].hpc); + config_set_int(NULL, "hdj_cylinders", hdc[7].tracks); + config_set_string(NULL, "hdj_fn", ide_fn[7]); + + config_set_int(NULL, "ide_ter_enable", ide34_enable[0]); + config_set_int(NULL, "ide_ter_irq", ide34_irq[0]); + config_set_int(NULL, "ide_qua_enable", ide34_enable[1]); + config_set_int(NULL, "ide_qua_irq", ide34_irq[1]); config_set_int(NULL, "drive_a_type", fdd_get_type(0)); config_set_int(NULL, "drive_b_type", fdd_get_type(1)); diff --git a/src/pc.rc b/src/pc.rc index 1fa343d29..0c98dd3b1 100644 --- a/src/pc.rc +++ b/src/pc.rc @@ -43,6 +43,31 @@ BEGIN MENUITEM "&Empty",IDM_CDROM_EMPTY MENUITEM "&ISO...",IDM_CDROM_ISO END + POPUP "E&xtra IDE controllers" + BEGIN + POPUP "&Tertiary IDE controller" + BEGIN + MENUITEM "&Enabled",IDM_IDE_TER_ENABLED + MENUITEM SEPARATOR + MENUITEM "&9",IDM_IDE_TER_IRQ9 + MENUITEM "1&0",IDM_IDE_TER_IRQ10 + MENUITEM "1&1",IDM_IDE_TER_IRQ11 + MENUITEM "1&2",IDM_IDE_TER_IRQ12 + MENUITEM "1&4",IDM_IDE_TER_IRQ14 + MENUITEM "1&5",IDM_IDE_TER_IRQ15 + END + POPUP "&Quaternary IDE controller" + BEGIN + MENUITEM "&Enabled",IDM_IDE_QUA_ENABLED + MENUITEM SEPARATOR + MENUITEM "&9",IDM_IDE_QUA_IRQ9 + MENUITEM "1&0",IDM_IDE_QUA_IRQ10 + MENUITEM "1&1",IDM_IDE_QUA_IRQ11 + MENUITEM "1&2",IDM_IDE_QUA_IRQ12 + MENUITEM "1&4",IDM_IDE_QUA_IRQ14 + MENUITEM "1&5",IDM_IDE_QUA_IRQ15 + END + END POPUP "&SCSI controller" BEGIN MENUITEM "&Enabled",IDM_SCSI_ENABLED @@ -173,7 +198,7 @@ BEGIN COMBOBOX IDC_COMBODR4,162,176,57,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END -HdConfDlg DIALOGEX 0, 0, 210, DLG_HEIGHT +HdConfDlg DIALOGEX 0, 0, 270, DLG_HEIGHT STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Configure Hard Discs" FONT 9, "Segoe UI" @@ -182,100 +207,124 @@ HdConfDlg DIALOGEX 0, 0, 210, DLG_HEIGHT PUSHBUTTON "Cancel",IDCANCEL,101+12,CMD_BASE,50,14 LTEXT "C:",IDC_STATIC,7,C_BASE+2,27,10 - RADIOBUTTON "Hard drive", IDC_CHDD, 7+64, C_BASE, 53, 12 , WS_TABSTOP - RADIOBUTTON "CD-ROM", IDC_CCDROM, 7+128, C_BASE, 53, 12 , WS_TABSTOP - EDITTEXT IDC_EDIT_C_FN, 7, C_BASE+16, 136, 12, WS_DISABLED - PUSHBUTTON "...",IDC_CFILE,7 + 136, C_BASE+16, 16, 14 - PUSHBUTTON "New",IDC_CNEW,7 + 136 + 16, C_BASE+16, 24, 14 - PUSHBUTTON "Eject", IDC_EJECTC, 7 + 136 + 16 + 24, C_BASE+16, 24, 14 - - EDITTEXT IDC_EDIT_C_SPT,15,C_BASE+32,16,12, WS_DISABLED - EDITTEXT IDC_EDIT_C_HPC,48,C_BASE+32,16,12, WS_DISABLED - EDITTEXT IDC_EDIT_C_CYL,81,C_BASE+32,28,12, WS_DISABLED - LTEXT "S:",IDC_STATIC,7,C_BASE+34,8,12 - LTEXT "H:",IDC_STATIC,40,C_BASE+34,8,12 - LTEXT "C:",IDC_STATIC,73,C_BASE+34,8,12 - LTEXT "", IDC_TEXT_C_SIZE, 118, C_BASE+34, 89, 12 + EDITTEXT IDC_EDIT_C_FN, 7+16, C_BASE, 120, 12, WS_DISABLED + PUSHBUTTON "...",IDC_CFILE,7 + 136, C_BASE, 16, 14 + PUSHBUTTON "New",IDC_CNEW,7 + 152, C_BASE, 24, 14 + PUSHBUTTON "Eject", IDC_EJECTC, 7 + 176, C_BASE, 24, 14 + RADIOBUTTON "Hard drive", IDC_CHDD, 7+207, C_BASE, 53, 12 , WS_TABSTOP + RADIOBUTTON "CD-ROM", IDC_CCDROM, 7+207, C_BASE+16, 53, 12 , WS_TABSTOP + EDITTEXT IDC_EDIT_C_SPT,15,C_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_C_HPC,48,C_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_C_CYL,81,C_BASE+16,28,12, WS_DISABLED + LTEXT "S:",IDC_STATIC,7,C_BASE+18,8,12 + LTEXT "H:",IDC_STATIC,40,C_BASE+18,8,12 + LTEXT "C:",IDC_STATIC,73,C_BASE+18,8,12 + LTEXT "", IDC_TEXT_C_SIZE, 118, C_BASE+18, 89, 12 LTEXT "D:",IDC_STATIC,7,D_BASE+2,27,10 - RADIOBUTTON "Hard drive", IDC_DHDD, 7+64, D_BASE, 53, 12 , WS_TABSTOP - RADIOBUTTON "CD-ROM", IDC_DCDROM, 7+128, D_BASE, 53, 12 , WS_TABSTOP - EDITTEXT IDC_EDIT_D_FN, 7, D_BASE+16, 136, 12, WS_DISABLED - PUSHBUTTON "...",IDC_DFILE,7 + 136, D_BASE+16, 16, 14 - PUSHBUTTON "New",IDC_DNEW,7 + 136 + 16, D_BASE+16, 24, 14 - PUSHBUTTON "Eject", IDC_EJECTD, 7 + 136 + 16 + 24, D_BASE+16, 24, 14 - - EDITTEXT IDC_EDIT_D_SPT,15,D_BASE+32,16,12, WS_DISABLED - EDITTEXT IDC_EDIT_D_HPC,48,D_BASE+32,16,12, WS_DISABLED - EDITTEXT IDC_EDIT_D_CYL,81,D_BASE+32,28,12, WS_DISABLED - LTEXT "S:",IDC_STATIC,7,D_BASE+34,8,12 - LTEXT "H:",IDC_STATIC,40,D_BASE+34,8,12 - LTEXT "C:",IDC_STATIC,73,D_BASE+34,8,12 - LTEXT "", IDC_TEXT_D_SIZE, 118, D_BASE+34, 89, 12 + EDITTEXT IDC_EDIT_D_FN, 7+16, D_BASE, 120, 12, WS_DISABLED + PUSHBUTTON "...",IDC_DFILE,7 + 136, D_BASE, 16, 14 + PUSHBUTTON "New",IDC_DNEW,7 + 152, D_BASE, 24, 14 + PUSHBUTTON "Eject", IDC_EJECTD, 7 + 176, D_BASE, 24, 14 + RADIOBUTTON "Hard drive", IDC_DHDD, 7+207, D_BASE, 53, 12 , WS_TABSTOP + RADIOBUTTON "CD-ROM", IDC_DCDROM, 7+207, D_BASE+16, 53, 12 , WS_TABSTOP + EDITTEXT IDC_EDIT_D_SPT,15,D_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_D_HPC,48,D_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_D_CYL,81,D_BASE+16,28,12, WS_DISABLED + LTEXT "S:",IDC_STATIC,7,D_BASE+18,8,12 + LTEXT "H:",IDC_STATIC,40,D_BASE+18,8,12 + LTEXT "C:",IDC_STATIC,73,D_BASE+18,8,12 + LTEXT "", IDC_TEXT_D_SIZE, 118, D_BASE+18, 89, 12 LTEXT "E:",IDC_STATIC,7,E_BASE+2,27,10 - RADIOBUTTON "Hard drive", IDC_EHDD, 7+64, E_BASE, 53, 12 , WS_TABSTOP - RADIOBUTTON "CD-ROM", IDC_ECDROM, 7+128, E_BASE, 53, 12 , WS_TABSTOP - EDITTEXT IDC_EDIT_E_FN, 7, E_BASE+16, 136, 12, WS_DISABLED - PUSHBUTTON "...",IDC_EFILE,7 + 136, E_BASE+16, 16, 14 - PUSHBUTTON "New",IDC_ENEW,7 + 136 + 16, E_BASE+16, 24, 14 - PUSHBUTTON "Eject", IDC_EJECTE, 7 + 136 + 16 + 24, E_BASE+16, 24, 14 - - EDITTEXT IDC_EDIT_E_SPT,15,E_BASE+32,16,12, WS_DISABLED - EDITTEXT IDC_EDIT_E_HPC,48,E_BASE+32,16,12, WS_DISABLED - EDITTEXT IDC_EDIT_E_CYL,81,E_BASE+32,28,12, WS_DISABLED - LTEXT "S:",IDC_STATIC,7,E_BASE+34,8,12 - LTEXT "H:",IDC_STATIC,40,E_BASE+34,8,12 - LTEXT "C:",IDC_STATIC,73,E_BASE+34,8,12 - LTEXT "", IDC_TEXT_E_SIZE, 118, E_BASE+34, 89, 12 + EDITTEXT IDC_EDIT_E_FN, 7+16, E_BASE, 120, 12, WS_DISABLED + PUSHBUTTON "...",IDC_EFILE,7 + 136, E_BASE, 16, 14 + PUSHBUTTON "New",IDC_ENEW,7 + 152, E_BASE, 24, 14 + PUSHBUTTON "Eject", IDC_EJECTE, 7 + 176, E_BASE, 24, 14 + RADIOBUTTON "Hard drive", IDC_EHDD, 7+207, E_BASE, 53, 12 , WS_TABSTOP + RADIOBUTTON "CD-ROM", IDC_ECDROM, 7+207, E_BASE+16, 53, 12 , WS_TABSTOP + EDITTEXT IDC_EDIT_E_SPT,15,E_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_E_HPC,48,E_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_E_CYL,81,E_BASE+16,28,12, WS_DISABLED + LTEXT "S:",IDC_STATIC,7,E_BASE+18,8,12 + LTEXT "H:",IDC_STATIC,40,E_BASE+18,8,12 + LTEXT "C:",IDC_STATIC,73,E_BASE+18,8,12 + LTEXT "", IDC_TEXT_E_SIZE, 118, E_BASE+18, 89, 12 LTEXT "F:",IDC_STATIC,7,F_BASE+2,27,10 - RADIOBUTTON "Hard drive", IDC_FHDD, 7+64, F_BASE, 53, 12 , WS_TABSTOP - RADIOBUTTON "CD-ROM", IDC_FCDROM, 7+128, F_BASE, 53, 12 , WS_TABSTOP - EDITTEXT IDC_EDIT_F_FN, 7, F_BASE+16, 136, 12, WS_DISABLED - PUSHBUTTON "...",IDC_FFILE,7 + 136, F_BASE+16, 16, 14 - PUSHBUTTON "New",IDC_FNEW,7 + 136 + 16, F_BASE+16, 24, 14 - PUSHBUTTON "Eject", IDC_EJECTF, 7 + 136 + 16 + 24, F_BASE+16, 24, 14 - - EDITTEXT IDC_EDIT_F_SPT,15,F_BASE+32,16,12, WS_DISABLED - EDITTEXT IDC_EDIT_F_HPC,48,F_BASE+32,16,12, WS_DISABLED - EDITTEXT IDC_EDIT_F_CYL,81,F_BASE+32,28,12, WS_DISABLED - LTEXT "S:",IDC_STATIC,7,F_BASE+34,8,12 - LTEXT "H:",IDC_STATIC,40,F_BASE+34,8,12 - LTEXT "C:",IDC_STATIC,73,F_BASE+34,8,12 - LTEXT "", IDC_TEXT_F_SIZE, 118, F_BASE+34, 89, 12 + EDITTEXT IDC_EDIT_F_FN, 7+16, F_BASE, 120, 12, WS_DISABLED + PUSHBUTTON "...",IDC_FFILE,7 + 136, F_BASE, 16, 14 + PUSHBUTTON "New",IDC_FNEW,7 + 152, F_BASE, 24, 14 + PUSHBUTTON "Eject", IDC_EJECTF, 7 + 176, F_BASE, 24, 14 + RADIOBUTTON "Hard drive", IDC_FHDD, 7+207, F_BASE, 53, 12 , WS_TABSTOP + RADIOBUTTON "CD-ROM", IDC_FCDROM, 7+207, F_BASE+16, 53, 12 , WS_TABSTOP + EDITTEXT IDC_EDIT_F_SPT,15,F_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_F_HPC,48,F_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_F_CYL,81,F_BASE+16,28,12, WS_DISABLED + LTEXT "S:",IDC_STATIC,7,F_BASE+18,8,12 + LTEXT "H:",IDC_STATIC,40,F_BASE+18,8,12 + LTEXT "C:",IDC_STATIC,73,F_BASE+18,8,12 + LTEXT "", IDC_TEXT_F_SIZE, 118, F_BASE+18, 89, 12 LTEXT "G:",IDC_STATIC,7,G_BASE+2,27,10 - RADIOBUTTON "Hard drive", IDC_GHDD, 7+64, G_BASE, 53, 12 , WS_TABSTOP - RADIOBUTTON "CD-ROM", IDC_GCDROM, 7+128, G_BASE, 53, 12 , WS_TABSTOP - EDITTEXT IDC_EDIT_G_FN, 7, G_BASE+16, 136, 12, WS_DISABLED - PUSHBUTTON "...",IDC_GFILE,7 + 136, G_BASE+16, 16, 14 - PUSHBUTTON "New",IDC_GNEW,7 + 136 + 16, G_BASE+16, 24, 14 - PUSHBUTTON "Eject", IDC_EJECTG, 7 + 136 + 16 + 24, G_BASE+16, 24, 14 - - EDITTEXT IDC_EDIT_G_SPT,15,G_BASE+32,16,12, WS_DISABLED - EDITTEXT IDC_EDIT_G_HPC,48,G_BASE+32,16,12, WS_DISABLED - EDITTEXT IDC_EDIT_G_CYL,81,G_BASE+32,28,12, WS_DISABLED - LTEXT "S:",IDC_STATIC,7,G_BASE+34,8,12 - LTEXT "H:",IDC_STATIC,40,G_BASE+34,8,12 - LTEXT "C:",IDC_STATIC,73,G_BASE+34,8,12 - LTEXT "", IDC_TEXT_G_SIZE, 118, G_BASE+34, 89, 12 + EDITTEXT IDC_EDIT_G_FN, 7+16, G_BASE, 120, 12, WS_DISABLED + PUSHBUTTON "...",IDC_GFILE,7 + 136, G_BASE, 16, 14 + PUSHBUTTON "New",IDC_GNEW,7 + 152, G_BASE, 24, 14 + PUSHBUTTON "Eject", IDC_EJECTG, 7 + 176, G_BASE, 24, 14 + RADIOBUTTON "Hard drive", IDC_GHDD, 7+207, G_BASE, 53, 12 , WS_TABSTOP + RADIOBUTTON "CD-ROM", IDC_GCDROM, 7+207, G_BASE+16, 53, 12 , WS_TABSTOP + EDITTEXT IDC_EDIT_G_SPT,15,G_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_G_HPC,48,G_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_G_CYL,81,G_BASE+16,28,12, WS_DISABLED + LTEXT "S:",IDC_STATIC,7,G_BASE+18,8,12 + LTEXT "H:",IDC_STATIC,40,G_BASE+18,8,12 + LTEXT "C:",IDC_STATIC,73,G_BASE+18,8,12 + LTEXT "", IDC_TEXT_G_SIZE, 118, G_BASE+18, 89, 12 LTEXT "H:",IDC_STATIC,7,H_BASE+2,27,10 - RADIOBUTTON "Hard drive", IDC_HHDD, 7+64, H_BASE, 53, 12 , WS_TABSTOP - RADIOBUTTON "CD-ROM", IDC_HCDROM, 7+128, H_BASE, 53, 12 , WS_TABSTOP - EDITTEXT IDC_EDIT_H_FN, 7, H_BASE+16, 136, 12, WS_DISABLED - PUSHBUTTON "...",IDC_HFILE,7 + 136, H_BASE+16, 16, 14 - PUSHBUTTON "New",IDC_HNEW,7 + 136 + 16, H_BASE+16, 24, 14 - PUSHBUTTON "Eject", IDC_EJECTH, 7 + 136 + 16 + 24, H_BASE+16, 24, 14 + EDITTEXT IDC_EDIT_H_FN, 7+16, H_BASE, 120, 12, WS_DISABLED + PUSHBUTTON "...",IDC_HFILE,7 + 136, H_BASE, 16, 14 + PUSHBUTTON "New",IDC_HNEW,7 + 152, H_BASE, 24, 14 + PUSHBUTTON "Eject", IDC_EJECTH, 7 + 176, H_BASE, 24, 14 + RADIOBUTTON "Hard drive", IDC_HHDD, 7+207, H_BASE, 53, 12 , WS_TABSTOP + RADIOBUTTON "CD-ROM", IDC_HCDROM, 7+207, H_BASE+16, 53, 12 , WS_TABSTOP + EDITTEXT IDC_EDIT_H_SPT,15,H_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_H_HPC,48,H_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_H_CYL,81,H_BASE+16,28,12, WS_DISABLED + LTEXT "S:",IDC_STATIC,7,H_BASE+18,8,12 + LTEXT "H:",IDC_STATIC,40,H_BASE+18,8,12 + LTEXT "C:",IDC_STATIC,73,H_BASE+18,8,12 + LTEXT "", IDC_TEXT_H_SIZE, 118, H_BASE+18, 89, 12 - EDITTEXT IDC_EDIT_H_SPT,15,H_BASE+32,16,12, WS_DISABLED - EDITTEXT IDC_EDIT_H_HPC,48,H_BASE+32,16,12, WS_DISABLED - EDITTEXT IDC_EDIT_H_CYL,81,H_BASE+32,28,12, WS_DISABLED - LTEXT "S:",IDC_STATIC,7,H_BASE+34,8,12 - LTEXT "H:",IDC_STATIC,40,H_BASE+34,8,12 - LTEXT "C:",IDC_STATIC,73,H_BASE+34,8,12 - LTEXT "", IDC_TEXT_H_SIZE, 118, H_BASE+34, 89, 12 + LTEXT "I:",IDC_STATIC,7,I_BASE+2,27,10 + EDITTEXT IDC_EDIT_I_FN, 7+16, I_BASE, 120, 12, WS_DISABLED + PUSHBUTTON "...",IDC_IFILE,7 + 136, I_BASE, 16, 14 + PUSHBUTTON "New",IDC_INEW,7 + 152, I_BASE, 24, 14 + PUSHBUTTON "Eject", IDC_EJECTI, 7 + 176, I_BASE, 24, 14 + RADIOBUTTON "Hard drive", IDC_IHDD, 7+207, I_BASE, 53, 12 , WS_TABSTOP + RADIOBUTTON "CD-ROM", IDC_ICDROM, 7+207, I_BASE+16, 53, 12 , WS_TABSTOP + EDITTEXT IDC_EDIT_I_SPT,15,I_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_I_HPC,48,I_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_I_CYL,81,I_BASE+16,28,12, WS_DISABLED + LTEXT "S:",IDC_STATIC,7,I_BASE+18,8,12 + LTEXT "H:",IDC_STATIC,40,I_BASE+18,8,12 + LTEXT "C:",IDC_STATIC,73,I_BASE+18,8,12 + LTEXT "", IDC_TEXT_I_SIZE, 118, I_BASE+18, 89, 12 + + LTEXT "J:",IDC_STATIC,7,J_BASE+2,27,10 + EDITTEXT IDC_EDIT_J_FN, 7+16, J_BASE, 120, 12, WS_DISABLED + PUSHBUTTON "...",IDC_JFILE,7 + 136, J_BASE, 16, 14 + PUSHBUTTON "New",IDC_JNEW,7 + 152, J_BASE, 24, 14 + PUSHBUTTON "Eject", IDC_EJECTJ, 7 + 176, J_BASE, 24, 14 + RADIOBUTTON "Hard drive", IDC_JHDD, 7+207, J_BASE, 53, 12 , WS_TABSTOP + RADIOBUTTON "CD-ROM", IDC_JCDROM, 7+207, J_BASE+16, 53, 12 , WS_TABSTOP + EDITTEXT IDC_EDIT_J_SPT,15,J_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_J_HPC,48,J_BASE+16,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_J_CYL,81,J_BASE+16,28,12, WS_DISABLED + LTEXT "S:",IDC_STATIC,7,J_BASE+18,8,12 + LTEXT "H:",IDC_STATIC,40,J_BASE+18,8,12 + LTEXT "C:",IDC_STATIC,73,J_BASE+18,8,12 + LTEXT "", IDC_TEXT_J_SIZE, 118, J_BASE+18, 89, 12 END diff --git a/src/pic.c b/src/pic.c index fddd96b4c..96cca37ac 100644 --- a/src/pic.c +++ b/src/pic.c @@ -73,8 +73,11 @@ static void pic_autoeoi() pic.ins&=~(1<0xFF) { + if (!AT) + { + return; + } + pic2.pend|=(num>>8); if ((pic2.pend&~pic2.mask)&~pic2.mask2) pic.pend |= (1 << 2); @@ -335,7 +343,7 @@ void picintlevel(uint16_t num) { int c = 0; while (!(num & (1 << c))) c++; - if (AT && c == 2) + if (AT && (c == 2)) { c = 9; num = 1 << 9; @@ -346,6 +354,11 @@ void picintlevel(uint16_t num) pic_current[c]=1; if (num>0xFF) { + if (!AT) + { + return; + } + pic2.pend|=(num>>8); } else @@ -361,7 +374,7 @@ void picintc(uint16_t num) if (!num) return; while (!(num & (1 << c))) c++; - if (AT && c == 2) + if (AT && (c == 2)) { c = 9; num = 1 << 9; @@ -371,6 +384,11 @@ void picintc(uint16_t num) if (num > 0xff) { + if (!AT) + { + return; + } + pic2.pend &= ~(num >> 8); if (!((pic2.pend&~pic2.mask)&~pic2.mask2)) pic.pend &= ~(1 << 2); @@ -427,7 +445,7 @@ uint8_t picinterrupt() pic2.ins |= (1 << c); pic_update_mask(&pic2.mask2, pic2.ins); - pic.pend &= ~(1 << c); + // pic.pend &= ~(1 << c); pic.ins |= (1 << 2); /*Cascade IRQ*/ pic_update_mask(&pic.mask2, pic.ins); diff --git a/src/resources.h b/src/resources.h index 3c6f26096..26a26020f 100644 --- a/src/resources.h +++ b/src/resources.h @@ -40,22 +40,36 @@ #define IDM_CDROM_REAL 40200 #define IDM_CDROM_ENABLED 40300 #define IDM_CDROM_SCSI 40400 -#define IDM_SCSI_ENABLED 40500 -#define IDM_SCSI_BASE130 40501 -#define IDM_SCSI_BASE134 40502 -#define IDM_SCSI_BASE230 40503 -#define IDM_SCSI_BASE234 40504 -#define IDM_SCSI_BASE330 40505 -#define IDM_SCSI_BASE334 40506 -#define IDM_SCSI_IRQ9 40507 -#define IDM_SCSI_IRQ10 40508 -#define IDM_SCSI_IRQ11 40509 -#define IDM_SCSI_IRQ12 40510 -#define IDM_SCSI_IRQ14 40511 -#define IDM_SCSI_IRQ15 40512 -#define IDM_SCSI_DMA5 40513 -#define IDM_SCSI_DMA6 40514 -#define IDM_SCSI_DMA7 40515 +#define IDM_IDE_TER_ENABLED 40500 +#define IDM_IDE_TER_IRQ9 40501 +#define IDM_IDE_TER_IRQ10 40502 +#define IDM_IDE_TER_IRQ11 40503 +#define IDM_IDE_TER_IRQ12 40504 +#define IDM_IDE_TER_IRQ14 40505 +#define IDM_IDE_TER_IRQ15 40506 +#define IDM_IDE_QUA_ENABLED 40507 +#define IDM_IDE_QUA_IRQ9 40508 +#define IDM_IDE_QUA_IRQ10 40509 +#define IDM_IDE_QUA_IRQ11 40510 +#define IDM_IDE_QUA_IRQ12 40511 +#define IDM_IDE_QUA_IRQ14 40512 +#define IDM_IDE_QUA_IRQ15 40513 +#define IDM_SCSI_ENABLED 40600 +#define IDM_SCSI_BASE130 40601 +#define IDM_SCSI_BASE134 40602 +#define IDM_SCSI_BASE230 40603 +#define IDM_SCSI_BASE234 40604 +#define IDM_SCSI_BASE330 40605 +#define IDM_SCSI_BASE334 40606 +#define IDM_SCSI_IRQ9 40607 +#define IDM_SCSI_IRQ10 40608 +#define IDM_SCSI_IRQ11 40609 +#define IDM_SCSI_IRQ12 40610 +#define IDM_SCSI_IRQ14 40611 +#define IDM_SCSI_IRQ15 40612 +#define IDM_SCSI_DMA5 40613 +#define IDM_SCSI_DMA6 40614 +#define IDM_SCSI_DMA7 40615 #define IDC_COMBO1 1000 #define IDC_COMBOVID 1001 @@ -91,87 +105,117 @@ #define IDC_EDIT5 1034 #define IDC_EDIT6 1035 #define IDC_COMBOHDT 1036 -#define IDC_TEXT1 1040 -#define IDC_TEXT2 1041 -#define IDC_EDITC 1050 -#define IDC_CFILE 1051 -#define IDC_CNEW 1052 -#define IDC_EDITD 1053 -#define IDC_DFILE 1054 -#define IDC_DNEW 1055 -#define IDC_EJECTC 1056 -#define IDC_EJECTD 1057 -#define IDC_EDITE 1058 -#define IDC_EFILE 1059 -#define IDC_ENEW 1060 -#define IDC_EDITF 1061 -#define IDC_FFILE 1062 -#define IDC_FNEW 1063 -#define IDC_EJECTE 1064 -#define IDC_EJECTF 1065 -#define IDC_EDITG 1066 -#define IDC_GFILE 1067 -#define IDC_GNEW 1068 -#define IDC_EDITH 1069 -#define IDC_HFILE 1070 -#define IDC_HNEW 1071 -#define IDC_EJECTG 1072 -#define IDC_EJECTH 1073 -#define IDC_MEMSPIN 1070 -#define IDC_MEMTEXT 1071 -#define IDC_CHDD 1080 -#define IDC_CCDROM 1081 -#define IDC_DHDD 1082 -#define IDC_DCDROM 1083 -#define IDC_EHDD 1084 -#define IDC_ECDROM 1085 -#define IDC_FHDD 1086 -#define IDC_FCDROM 1087 -#define IDC_GHDD 1088 -#define IDC_GCDROM 1089 -#define IDC_HHDD 1090 -#define IDC_HCDROM 1091 -#define IDC_STEXT1 1100 -#define IDC_STEXT2 1101 -#define IDC_STEXT3 1102 -#define IDC_STEXT4 1103 -#define IDC_STEXT5 1104 -#define IDC_STEXT6 1105 -#define IDC_STEXT7 1106 -#define IDC_STEXT8 1107 -#define IDC_STEXT_DEVICE 1108 -#define IDC_TEXT_MB 1120 +#define IDC_EJECTC 1040 +#define IDC_EDITC 1050 +#define IDC_CFILE 1060 +#define IDC_CNEW 1070 +#define IDC_CHDD 1080 +#define IDC_CCDROM 1090 #define IDC_EDIT_C_SPT 1200 -#define IDC_EDIT_C_HPC 1201 -#define IDC_EDIT_C_CYL 1202 -#define IDC_EDIT_D_SPT 1203 -#define IDC_EDIT_D_HPC 1204 -#define IDC_EDIT_D_CYL 1205 -#define IDC_EDIT_E_SPT 1206 -#define IDC_EDIT_E_HPC 1207 -#define IDC_EDIT_E_CYL 1208 -#define IDC_EDIT_F_SPT 1209 -#define IDC_EDIT_F_HPC 1210 -#define IDC_EDIT_F_CYL 1211 -#define IDC_EDIT_G_SPT 1212 -#define IDC_EDIT_G_HPC 1213 -#define IDC_EDIT_G_CYL 1214 -#define IDC_EDIT_H_SPT 1215 -#define IDC_EDIT_H_HPC 1216 -#define IDC_EDIT_H_CYL 1217 -#define IDC_TEXT_C_SIZE 1220 -#define IDC_TEXT_D_SIZE 1221 -#define IDC_TEXT_E_SIZE 1222 -#define IDC_TEXT_F_SIZE 1223 -#define IDC_TEXT_G_SIZE 1224 -#define IDC_TEXT_H_SIZE 1225 +#define IDC_EDIT_C_HPC 1210 +#define IDC_EDIT_C_CYL 1220 #define IDC_EDIT_C_FN 1230 +#define IDC_TEXT_C_SIZE 1240 + +#define IDC_EJECTD 1041 +#define IDC_EDITD 1051 +#define IDC_DFILE 1061 +#define IDC_DNEW 1071 +#define IDC_DHDD 1081 +#define IDC_DCDROM 1091 +#define IDC_EDIT_D_SPT 1201 +#define IDC_EDIT_D_HPC 1211 +#define IDC_EDIT_D_CYL 1221 #define IDC_EDIT_D_FN 1231 +#define IDC_TEXT_D_SIZE 1241 + +#define IDC_EJECTE 1042 +#define IDC_EDITE 1052 +#define IDC_EFILE 1062 +#define IDC_ENEW 1072 +#define IDC_EHDD 1082 +#define IDC_ECDROM 1092 +#define IDC_EDIT_E_SPT 1202 +#define IDC_EDIT_E_HPC 1212 +#define IDC_EDIT_E_CYL 1222 #define IDC_EDIT_E_FN 1232 +#define IDC_TEXT_E_SIZE 1242 + +#define IDC_EJECTF 1043 +#define IDC_EDITF 1053 +#define IDC_FFILE 1063 +#define IDC_FNEW 1073 +#define IDC_FHDD 1083 +#define IDC_FCDROM 1093 +#define IDC_EDIT_F_SPT 1203 +#define IDC_EDIT_F_HPC 1213 +#define IDC_EDIT_F_CYL 1223 #define IDC_EDIT_F_FN 1233 +#define IDC_TEXT_F_SIZE 1243 + +#define IDC_EJECTG 1044 +#define IDC_EDITG 1054 +#define IDC_GFILE 1064 +#define IDC_GNEW 1074 +#define IDC_GHDD 1084 +#define IDC_GCDROM 1094 +#define IDC_EDIT_G_SPT 1204 +#define IDC_EDIT_G_HPC 1214 +#define IDC_EDIT_G_CYL 1224 #define IDC_EDIT_G_FN 1234 +#define IDC_TEXT_G_SIZE 1244 + +#define IDC_EJECTH 1045 +#define IDC_EDITH 1055 +#define IDC_HFILE 1065 +#define IDC_HNEW 1075 +#define IDC_HHDD 1085 +#define IDC_HCDROM 1095 +#define IDC_EDIT_H_SPT 1205 +#define IDC_EDIT_H_HPC 1215 +#define IDC_EDIT_H_CYL 1225 #define IDC_EDIT_H_FN 1235 +#define IDC_TEXT_H_SIZE 1245 + +#define IDC_EJECTI 1046 +#define IDC_EDITI 1056 +#define IDC_IFILE 1066 +#define IDC_INEW 1076 +#define IDC_IHDD 1086 +#define IDC_ICDROM 1096 +#define IDC_EDIT_I_SPT 1206 +#define IDC_EDIT_I_HPC 1216 +#define IDC_EDIT_I_CYL 1226 +#define IDC_EDIT_I_FN 1236 +#define IDC_TEXT_I_SIZE 1246 + +#define IDC_EJECTJ 1047 +#define IDC_EDITJ 1057 +#define IDC_JFILE 1067 +#define IDC_JNEW 1077 +#define IDC_JHDD 1087 +#define IDC_JCDROM 1097 +#define IDC_EDIT_J_SPT 1207 +#define IDC_EDIT_J_HPC 1217 +#define IDC_EDIT_J_CYL 1227 +#define IDC_EDIT_J_FN 1237 +#define IDC_TEXT_J_SIZE 1247 + +#define IDC_MEMSPIN 1100 +#define IDC_MEMTEXT 1101 +#define IDC_STEXT1 1102 +#define IDC_STEXT2 1103 +#define IDC_STEXT3 1104 +#define IDC_STEXT4 1105 +#define IDC_STEXT5 1106 +#define IDC_STEXT6 1107 +#define IDC_STEXT7 1108 +#define IDC_STEXT8 1109 +#define IDC_STEXT_DEVICE 1110 +#define IDC_TEXT_MB 1111 +#define IDC_TEXT1 1115 +#define IDC_TEXT2 1116 #define IDC_CONFIGUREVID 1200 #define IDC_CONFIGURESND 1201 @@ -188,12 +232,13 @@ #define WM_RESETD3D WM_USER #define WM_LEAVEFULLSCREEN WM_USER + 1 -#define C_BASE 6 /* End at 38. */ -#define D_BASE 60 /* End at 92. */ -#define E_BASE 114 /* End at 146. */ -#define F_BASE 168 /* End at 200. */ -#define G_BASE 222 /* End at 254. */ -#define H_BASE 276 /* End at 308. */ -#define CMD_BASE 334 -#define DLG_HEIGHT 366 - +#define C_BASE 6 +#define D_BASE 44 +#define E_BASE 82 +#define F_BASE 120 +#define G_BASE 158 +#define H_BASE 196 +#define I_BASE 234 +#define J_BASE 272 +#define CMD_BASE 314 +#define DLG_HEIGHT 346 diff --git a/src/win-hdconf.c b/src/win-hdconf.c index bf762a552..cc09df282 100644 --- a/src/win-hdconf.c +++ b/src/win-hdconf.c @@ -22,31 +22,15 @@ static int new_cdrom_channel; static void update_hdd_cdrom(HWND hdlg) { HWND h; + int drive_num = 0; - h = GetDlgItem(hdlg, IDC_CHDD); - SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 0) ? 0 : 1, 0); - h = GetDlgItem(hdlg, IDC_CCDROM); - SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 0) ? 1 : 0, 0); - h = GetDlgItem(hdlg, IDC_DHDD); - SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 1) ? 0 : 1, 0); - h = GetDlgItem(hdlg, IDC_DCDROM); - SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 1) ? 1 : 0, 0); - h = GetDlgItem(hdlg, IDC_EHDD); - SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 2) ? 0 : 1, 0); - h = GetDlgItem(hdlg, IDC_ECDROM); - SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 2) ? 1 : 0, 0); - h = GetDlgItem(hdlg, IDC_FHDD); - SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 3) ? 0 : 1, 0); - h = GetDlgItem(hdlg, IDC_FCDROM); - SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 3) ? 1 : 0, 0); - h = GetDlgItem(hdlg, IDC_GHDD); - SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 4) ? 0 : 1, 0); - h = GetDlgItem(hdlg, IDC_GCDROM); - SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 4) ? 1 : 0, 0); - h = GetDlgItem(hdlg, IDC_HHDD); - SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 5) ? 0 : 1, 0); - h = GetDlgItem(hdlg, IDC_HCDROM); - SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 5) ? 1 : 0, 0); + for (drive_num = 0; drive_num < IDE_NUM; drive_num++) + { + h = GetDlgItem(hdlg, IDC_CHDD + drive_num); + SendMessage(h, BM_SETCHECK, (new_cdrom_channel == drive_num) ? 0 : 1, 0); + h = GetDlgItem(hdlg, IDC_CCDROM + drive_num); + SendMessage(h, BM_SETCHECK, (new_cdrom_channel == drive_num) ? 1 : 0, 0); + } } int hdnew_no_update = 0; @@ -409,122 +393,168 @@ BOOL CALLBACK hdsize_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPar return hdconf_common_dlgproc(hdlg, message, wParam, lParam, 1, &hdsize_temp_hd, &hdsize_no_update, hd_new_spt, hd_new_hpc, hd_new_cyl); } +static void hdconf_eject(HWND hdlg, int drive_num, hard_disk_t *hd) +{ + hd->spt = 0; + hd->hpc = 0; + hd->tracks = 0; + ide_fn[drive_num][0] = 0; + SetDlgItemText(hdlg, IDC_EDIT_C_SPT + drive_num, "0"); + SetDlgItemText(hdlg, IDC_EDIT_C_HPC + drive_num, "0"); + SetDlgItemText(hdlg, IDC_EDIT_C_CYL + drive_num, "0"); + SetDlgItemText(hdlg, IDC_EDIT_C_FN + drive_num, ""); + hd_changed = 1; + return; +} + +static void hdconf_new(HWND hdlg, int drive_num) +{ + HWND h; + + if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, hdnew_dlgproc) == 1) + { + h = GetDlgItem(hdlg, IDC_EDIT_C_SPT + drive_num); + sprintf(s, "%" PRIu64, hd_new_spt); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + h = GetDlgItem(hdlg, IDC_EDIT_C_HPC + drive_num); + sprintf(s, "%" PRIu64, hd_new_hpc); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + h = GetDlgItem(hdlg, IDC_EDIT_C_CYL + drive_num); + sprintf(s, "%" PRIu64, hd_new_cyl); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + h = GetDlgItem(hdlg, IDC_EDIT_C_FN + drive_num); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name); + + h= GetDlgItem(hdlg, IDC_TEXT_C_SIZE + drive_num); + sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + + hd_changed = 1; + } + return; +} + +static void hdconf_file(HWND hdlg, int drive_num) +{ + HWND h; + FILE *f; + off64_t sz; + uint32_t sector_size = 512; + uint32_t base = 0x1000; + int ret; + + if (!getfile(hdlg, "Hard disc image (*.HDI;*.IMA;*.IMG;*.VHD)\0*.HDI;*.IMA;*.IMG;*.VHD\0All files (*.*)\0*.*\0", "")) + { + f = fopen64(openfilestring, "rb"); + if (!f) + { + MessageBox(ghwnd,"Can't open file for read","86Box error",MB_OK); + return; + } + + if (image_is_hdi(openfilestring)) + { + fseeko64(f, 0x10, SEEK_END); + fread(§or_size, 1, 4, f); + if (sector_size != 512) + { + MessageBox(ghwnd,"HDI image with a sector size that is not 512","86Box error",MB_OK); + fclose(f); + return; + } + fread(&hd_new_spt, 1, 4, f); + fread(&hd_new_hpc, 1, 4, f); + fread(&hd_new_cyl, 1, 4, f); + + ret = 1; + } + else + { + fseeko64(f, -1, SEEK_END); + sz = ftello64(f) + 1; + fclose(f); + hd_new_spt = 63; + hd_new_hpc = 16; + hd_new_cyl = ((sz / 512) / 16) / 63; + + ret = DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc); + } + if (ret == 1) + { + h = GetDlgItem(hdlg, IDC_EDIT_C_SPT + drive_num); + sprintf(s, "%" PRIu64, hd_new_spt); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + h = GetDlgItem(hdlg, IDC_EDIT_C_HPC + drive_num); + sprintf(s, "%" PRIu64, hd_new_hpc); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + h = GetDlgItem(hdlg, IDC_EDIT_C_CYL + drive_num); + sprintf(s, "%" PRIu64, hd_new_cyl); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + h = GetDlgItem(hdlg, IDC_EDIT_C_FN + drive_num); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring); + + h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE + drive_num); + sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + + hd_changed = 1; + } + } + return; +} + +static void hdconf_edit_boxes(HWND hdlg, int drive_num, hard_disk_t *hd) +{ + HWND h; + + h = GetDlgItem(hdlg, IDC_EDIT_C_SPT + drive_num); + SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); + sscanf(s, "%" PRIu64, &(hd->spt)); + h = GetDlgItem(hdlg, IDC_EDIT_C_HPC + drive_num); + SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); + sscanf(s, "%" PRIu64, &(hd->hpc)); + h = GetDlgItem(hdlg, IDC_EDIT_C_CYL + drive_num); + SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); + sscanf(s, "%" PRIu64, &(hd->tracks)); + + h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE + drive_num); + sprintf(s, "Size: %" PRIu64 " MB", (hd->tracks*hd->hpc*hd->spt) >> 11); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + return; +} + static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND h; - hard_disk_t hd[6]; - FILE *f; - off64_t sz; - int ret; - uint32_t sector_size = 512; - uint32_t base = 0x1000; + hard_disk_t hd[IDE_NUM]; + int drive_num = 0; switch (message) { case WM_INITDIALOG: pause = 1; - hd[0] = hdc[0]; - hd[1] = hdc[1]; - hd[2] = hdc[2]; - hd[3] = hdc[3]; - hd[4] = hdc[4]; - hd[5] = hdc[5]; + + for (drive_num = 0; drive_num < IDE_NUM; drive_num++) + { + hd[drive_num] = hdc[drive_num]; + + h = GetDlgItem(hdlg, IDC_EDIT_C_SPT + drive_num); + sprintf(s, "%" PRIu64, hdc[drive_num].spt); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + h = GetDlgItem(hdlg, IDC_EDIT_C_HPC + drive_num); + sprintf(s, "%" PRIu64, hdc[drive_num].hpc); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + h = GetDlgItem(hdlg, IDC_EDIT_C_CYL + drive_num); + sprintf(s, "%" PRIu64, hdc[drive_num].tracks); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + h = GetDlgItem(hdlg, IDC_EDIT_C_FN + drive_num); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)ide_fn[drive_num]); + + h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE + drive_num); + sprintf(s, "Size: %" PRIu64 " MB", (hd[drive_num].tracks*hd[drive_num].hpc*hd[drive_num].spt) >> 11); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); + } + hd_changed = 0; - - h = GetDlgItem(hdlg, IDC_EDIT_C_SPT); - sprintf(s, "%" PRIu64, hdc[0].spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_C_HPC); - sprintf(s, "%" PRIu64, hdc[0].hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_C_CYL); - sprintf(s, "%" PRIu64, hdc[0].tracks); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_C_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)ide_fn[0]); - - h = GetDlgItem(hdlg, IDC_EDIT_D_SPT); - sprintf(s, "%" PRIu64, hdc[1].spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_D_HPC); - sprintf(s, "%" PRIu64, hdc[1].hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_D_CYL); - sprintf(s, "%" PRIu64, hdc[1].tracks); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h= GetDlgItem(hdlg, IDC_EDIT_D_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)ide_fn[1]); - - h = GetDlgItem(hdlg, IDC_EDIT_E_SPT); - sprintf(s, "%" PRIu64, hdc[2].spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_E_HPC); - sprintf(s, "%" PRIu64, hdc[2].hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_E_CYL); - sprintf(s, "%" PRIu64, hdc[2].tracks); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h= GetDlgItem(hdlg, IDC_EDIT_E_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)ide_fn[2]); - - h = GetDlgItem(hdlg, IDC_EDIT_F_SPT); - sprintf(s, "%" PRIu64, hdc[3].spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_F_HPC); - sprintf(s, "%" PRIu64, hdc[3].hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_F_CYL); - sprintf(s, "%" PRIu64, hdc[3].tracks); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h= GetDlgItem(hdlg, IDC_EDIT_F_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)ide_fn[3]); - - h = GetDlgItem(hdlg, IDC_EDIT_G_SPT); - sprintf(s, "%" PRIu64, hdc[4].spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_G_HPC); - sprintf(s, "%" PRIu64, hdc[4].hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_G_CYL); - sprintf(s, "%" PRIu64, hdc[4].tracks); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h= GetDlgItem(hdlg, IDC_EDIT_G_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)ide_fn[4]); - - h = GetDlgItem(hdlg, IDC_EDIT_H_SPT); - sprintf(s, "%" PRIu64, hdc[5].spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_H_HPC); - sprintf(s, "%" PRIu64, hdc[5].hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_H_CYL); - sprintf(s, "%" PRIu64, hdc[5].tracks); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h= GetDlgItem(hdlg, IDC_EDIT_H_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)ide_fn[5]); - - h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd[0].tracks*hd[0].hpc*hd[0].spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - h = GetDlgItem(hdlg, IDC_TEXT_D_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd[1].tracks*hd[1].hpc*hd[1].spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - h = GetDlgItem(hdlg, IDC_TEXT_E_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd[2].tracks*hd[2].hpc*hd[2].spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - h = GetDlgItem(hdlg, IDC_TEXT_F_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd[3].tracks*hd[3].hpc*hd[3].spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - h = GetDlgItem(hdlg, IDC_TEXT_G_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd[4].tracks*hd[4].hpc*hd[4].spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - h = GetDlgItem(hdlg, IDC_TEXT_H_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd[5].tracks*hd[5].hpc*hd[5].spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); new_cdrom_channel = atapi_cdrom_channel; @@ -539,84 +569,22 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR { if (MessageBox(NULL, "This will reset 86Box!\nOkay to continue?", "86Box", MB_OKCANCEL) == IDOK) { - h = GetDlgItem(hdlg, IDC_EDIT_C_SPT); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[0].spt); - h = GetDlgItem(hdlg, IDC_EDIT_C_HPC); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[0].hpc); - h = GetDlgItem(hdlg, IDC_EDIT_C_CYL); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[0].tracks); - h = GetDlgItem(hdlg, IDC_EDIT_C_FN); - SendMessage(h, WM_GETTEXT, 511, (LPARAM)ide_fn[0]); - - h = GetDlgItem(hdlg, IDC_EDIT_D_SPT); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[1].spt); - h = GetDlgItem(hdlg, IDC_EDIT_D_HPC); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[1].hpc); - h = GetDlgItem(hdlg, IDC_EDIT_D_CYL); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[1].tracks); - h = GetDlgItem(hdlg, IDC_EDIT_D_FN); - SendMessage(h, WM_GETTEXT, 511, (LPARAM)ide_fn[1]); + for (drive_num = 0; drive_num < IDE_NUM; drive_num++) + { + h = GetDlgItem(hdlg, IDC_EDIT_C_SPT + drive_num); + SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); + sscanf(s, "%" PRIu64, &hd[drive_num].spt); + h = GetDlgItem(hdlg, IDC_EDIT_C_HPC + drive_num); + SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); + sscanf(s, "%" PRIu64, &hd[drive_num].hpc); + h = GetDlgItem(hdlg, IDC_EDIT_C_CYL + drive_num); + SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); + sscanf(s, "%" PRIu64, &hd[drive_num].tracks); + h = GetDlgItem(hdlg, IDC_EDIT_C_FN + drive_num); + SendMessage(h, WM_GETTEXT, 511, (LPARAM)ide_fn[drive_num]); - h = GetDlgItem(hdlg, IDC_EDIT_E_SPT); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[2].spt); - h = GetDlgItem(hdlg, IDC_EDIT_E_HPC); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[2].hpc); - h = GetDlgItem(hdlg, IDC_EDIT_E_CYL); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[2].tracks); - h = GetDlgItem(hdlg, IDC_EDIT_E_FN); - SendMessage(h, WM_GETTEXT, 511, (LPARAM)ide_fn[2]); - - h = GetDlgItem(hdlg, IDC_EDIT_F_SPT); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[3].spt); - h = GetDlgItem(hdlg, IDC_EDIT_F_HPC); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[3].hpc); - h = GetDlgItem(hdlg, IDC_EDIT_F_CYL); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[3].tracks); - h = GetDlgItem(hdlg, IDC_EDIT_F_FN); - SendMessage(h, WM_GETTEXT, 511, (LPARAM)ide_fn[3]); - - h = GetDlgItem(hdlg, IDC_EDIT_G_SPT); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[4].spt); - h = GetDlgItem(hdlg, IDC_EDIT_G_HPC); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[4].hpc); - h = GetDlgItem(hdlg, IDC_EDIT_G_CYL); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[4].tracks); - h = GetDlgItem(hdlg, IDC_EDIT_G_FN); - SendMessage(h, WM_GETTEXT, 511, (LPARAM)ide_fn[4]); - - h = GetDlgItem(hdlg, IDC_EDIT_H_SPT); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[5].spt); - h = GetDlgItem(hdlg, IDC_EDIT_H_HPC); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[5].hpc); - h = GetDlgItem(hdlg, IDC_EDIT_H_CYL); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[5].tracks); - h = GetDlgItem(hdlg, IDC_EDIT_H_FN); - SendMessage(h, WM_GETTEXT, 511, (LPARAM)ide_fn[5]); - - hdc[0] = hd[0]; - hdc[1] = hd[1]; - hdc[2] = hd[2]; - hdc[3] = hd[3]; - hdc[4] = hd[4]; - hdc[5] = hd[5]; + hdc[drive_num] = hd[drive_num]; + } atapi_cdrom_channel = new_cdrom_channel; @@ -631,721 +599,77 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR return TRUE; case IDC_EJECTC: - hd[0].spt = 0; - hd[0].hpc = 0; - hd[0].tracks = 0; - ide_fn[0][0] = 0; - SetDlgItemText(hdlg, IDC_EDIT_C_SPT, "0"); - SetDlgItemText(hdlg, IDC_EDIT_C_HPC, "0"); - SetDlgItemText(hdlg, IDC_EDIT_C_CYL, "0"); - SetDlgItemText(hdlg, IDC_EDIT_C_FN, ""); - hd_changed = 1; - return TRUE; case IDC_EJECTD: - hd[1].spt = 0; - hd[1].hpc = 0; - hd[1].tracks = 0; - ide_fn[1][0] = 0; - SetDlgItemText(hdlg, IDC_EDIT_D_SPT, "0"); - SetDlgItemText(hdlg, IDC_EDIT_D_HPC, "0"); - SetDlgItemText(hdlg, IDC_EDIT_D_CYL, "0"); - SetDlgItemText(hdlg, IDC_EDIT_D_FN, ""); - hd_changed = 1; - return TRUE; case IDC_EJECTE: - hd[2].spt = 0; - hd[2].hpc = 0; - hd[2].tracks = 0; - ide_fn[2][0] = 0; - SetDlgItemText(hdlg, IDC_EDIT_E_SPT, "0"); - SetDlgItemText(hdlg, IDC_EDIT_E_HPC, "0"); - SetDlgItemText(hdlg, IDC_EDIT_E_CYL, "0"); - SetDlgItemText(hdlg, IDC_EDIT_E_FN, ""); - hd_changed = 1; - return TRUE; case IDC_EJECTF: - hd[3].spt = 0; - hd[3].hpc = 0; - hd[3].tracks = 0; - ide_fn[3][0] = 0; - SetDlgItemText(hdlg, IDC_EDIT_F_SPT, "0"); - SetDlgItemText(hdlg, IDC_EDIT_F_HPC, "0"); - SetDlgItemText(hdlg, IDC_EDIT_F_CYL, "0"); - SetDlgItemText(hdlg, IDC_EDIT_F_FN, ""); - hd_changed = 1; - return TRUE; case IDC_EJECTG: - hd[4].spt = 0; - hd[4].hpc = 0; - hd[4].tracks = 0; - ide_fn[4][0] = 0; - SetDlgItemText(hdlg, IDC_EDIT_G_SPT, "0"); - SetDlgItemText(hdlg, IDC_EDIT_G_HPC, "0"); - SetDlgItemText(hdlg, IDC_EDIT_G_CYL, "0"); - SetDlgItemText(hdlg, IDC_EDIT_G_FN, ""); - hd_changed = 1; - return TRUE; case IDC_EJECTH: - hd[5].spt = 0; - hd[5].hpc = 0; - hd[5].tracks = 0; - ide_fn[5][0] = 0; - SetDlgItemText(hdlg, IDC_EDIT_H_SPT, "0"); - SetDlgItemText(hdlg, IDC_EDIT_H_HPC, "0"); - SetDlgItemText(hdlg, IDC_EDIT_H_CYL, "0"); - SetDlgItemText(hdlg, IDC_EDIT_H_FN, ""); - hd_changed = 1; - return TRUE; + case IDC_EJECTI: + case IDC_EJECTJ: + drive_num = LOWORD(wParam) % 10; + hdconf_eject(hdlg, drive_num, &(hd[drive_num])); + return TRUE; case IDC_CNEW: - if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, hdnew_dlgproc) == 1) - { - h = GetDlgItem(hdlg, IDC_EDIT_C_SPT); - sprintf(s, "%" PRIu64, hd_new_spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_C_HPC); - sprintf(s, "%" PRIu64, hd_new_hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_C_CYL); - sprintf(s, "%" PRIu64, hd_new_cyl); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_C_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name); - - h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - hd_changed = 1; - } - return TRUE; + case IDC_DNEW: + case IDC_ENEW: + case IDC_FNEW: + case IDC_GNEW: + case IDC_HNEW: + case IDC_INEW: + case IDC_JNEW: + drive_num = LOWORD(wParam) % 10; + hdconf_new(hdlg, drive_num); + return TRUE; case IDC_CFILE: - if (!getfile(hdlg, "Hard disc image (*.HDI;*.IMA;*.IMG;*.VHD)\0*.HDI;*.IMA;*.IMG;*.VHD\0All files (*.*)\0*.*\0", "")) - { - f = fopen64(openfilestring, "rb"); - if (!f) - { - MessageBox(ghwnd,"Can't open file for read","86Box error",MB_OK); - return TRUE; - } - - if (image_is_hdi(openfilestring)) - { - fseeko64(f, 0x10, SEEK_END); - fread(§or_size, 1, 4, f); - if (sector_size != 512) - { - MessageBox(ghwnd,"HDI image with a sector size that is not 512","86Box error",MB_OK); - fclose(f); - return TRUE; - } - fread(&hd_new_spt, 1, 4, f); - fread(&hd_new_hpc, 1, 4, f); - fread(&hd_new_cyl, 1, 4, f); - - ret = 1; - } - else - { - fseeko64(f, -1, SEEK_END); - sz = ftello64(f) + 1; - fclose(f); - hd_new_spt = 63; - hd_new_hpc = 16; - hd_new_cyl = ((sz / 512) / 16) / 63; - - ret = DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc); - } - if (ret == 1) - { - h = GetDlgItem(hdlg, IDC_EDIT_C_SPT); - sprintf(s, "%" PRIu64, hd_new_spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_C_HPC); - sprintf(s, "%" PRIu64, hd_new_hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_C_CYL); - sprintf(s, "%" PRIu64, hd_new_cyl); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_C_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring); - - h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - hd_changed = 1; - } - } - return TRUE; - - case IDC_DNEW: - if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, hdnew_dlgproc) == 1) - { - h = GetDlgItem(hdlg, IDC_EDIT_D_SPT); - sprintf(s, "%" PRIu64, hd_new_spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_D_HPC); - sprintf(s, "%" PRIu64, hd_new_hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_D_CYL); - sprintf(s, "%" PRIu64, hd_new_cyl); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_D_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name); - - h= GetDlgItem(hdlg, IDC_TEXT_D_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - hd_changed = 1; - } - return TRUE; - case IDC_DFILE: - if (!getfile(hdlg, "Hard disc image (*.HDI;*.IMA;*.IMG;*.VHD)\0*.HDI;*.IMA;*.IMG;*.VHD\0All files (*.*)\0*.*\0", "")) - { - f = fopen64(openfilestring, "rb"); - if (!f) - { - MessageBox(ghwnd,"Can't open file for read","86Box error",MB_OK); - return TRUE; - } - - if (image_is_hdi(openfilestring)) - { - fseeko64(f, 0x10, SEEK_END); - fread(§or_size, 1, 4, f); - if (sector_size != 512) - { - MessageBox(ghwnd,"HDI image with a sector size that is not 512","86Box error",MB_OK); - fclose(f); - return TRUE; - } - fread(&hd_new_spt, 1, 4, f); - fread(&hd_new_hpc, 1, 4, f); - fread(&hd_new_cyl, 1, 4, f); - - ret = 1; - } - else - { - fseeko64(f, -1, SEEK_END); - sz = ftello64(f) + 1; - fclose(f); - hd_new_spt = 63; - hd_new_hpc = 16; - hd_new_cyl = ((sz / 512) / 16) / 63; - - ret = DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc); - } - if (ret == 1) - { - h = GetDlgItem(hdlg, IDC_EDIT_D_SPT); - sprintf(s, "%" PRIu64, hd_new_spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_D_HPC); - sprintf(s, "%" PRIu64, hd_new_hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_D_CYL); - sprintf(s, "%" PRIu64, hd_new_cyl); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_D_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring); - - h = GetDlgItem(hdlg, IDC_TEXT_D_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - hd_changed = 1; - } - } - return TRUE; - - case IDC_ENEW: - if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, hdnew_dlgproc) == 1) - { - h = GetDlgItem(hdlg, IDC_EDIT_E_SPT); - sprintf(s, "%" PRIu64, hd_new_spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_E_HPC); - sprintf(s, "%" PRIu64, hd_new_hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_E_CYL); - sprintf(s, "%" PRIu64, hd_new_cyl); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_E_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name); - - h= GetDlgItem(hdlg, IDC_TEXT_E_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - hd_changed = 1; - } - return TRUE; - case IDC_EFILE: - if (!getfile(hdlg, "Hard disc image (*.HDI;*.IMA;*.IMG;*.VHD)\0*.HDI;*.IMA;*.IMG;*.VHD\0All files (*.*)\0*.*\0", "")) - { - f = fopen64(openfilestring, "rb"); - if (!f) - { - MessageBox(ghwnd,"Can't open file for read","86Box error",MB_OK); - return TRUE; - } - - if (image_is_hdi(openfilestring)) - { - fseeko64(f, 0x10, SEEK_END); - fread(§or_size, 1, 4, f); - if (sector_size != 512) - { - MessageBox(ghwnd,"HDI image with a sector size that is not 512","86Box error",MB_OK); - fclose(f); - return TRUE; - } - fread(&hd_new_spt, 1, 4, f); - fread(&hd_new_hpc, 1, 4, f); - fread(&hd_new_cyl, 1, 4, f); - - ret = 1; - } - else - { - fseeko64(f, -1, SEEK_END); - sz = ftello64(f) + 1; - fclose(f); - hd_new_spt = 63; - hd_new_hpc = 16; - hd_new_cyl = ((sz / 512) / 16) / 63; - - ret = DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc); - } - if (ret == 1) - { - h = GetDlgItem(hdlg, IDC_EDIT_E_SPT); - sprintf(s, "%" PRIu64, hd_new_spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_E_HPC); - sprintf(s, "%" PRIu64, hd_new_hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_E_CYL); - sprintf(s, "%" PRIu64, hd_new_cyl); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_E_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring); - - h = GetDlgItem(hdlg, IDC_TEXT_E_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - hd_changed = 1; - } - } - return TRUE; - - case IDC_FNEW: - if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, hdnew_dlgproc) == 1) - { - h = GetDlgItem(hdlg, IDC_EDIT_F_SPT); - sprintf(s, "%" PRIu64, hd_new_spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_F_HPC); - sprintf(s, "%" PRIu64, hd_new_hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_F_CYL); - sprintf(s, "%" PRIu64, hd_new_cyl); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_F_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name); - - h= GetDlgItem(hdlg, IDC_TEXT_F_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - hd_changed = 1; - } - return TRUE; - case IDC_FFILE: - if (!getfile(hdlg, "Hard disc image (*.HDI;*.IMA;*.IMG;*.VHD)\0*.HDI;*.IMA;*.IMG;*.VHD\0All files (*.*)\0*.*\0", "")) - { - f = fopen64(openfilestring, "rb"); - if (!f) - { - MessageBox(ghwnd,"Can't open file for read","86Box error",MB_OK); - return TRUE; - } - - if (image_is_hdi(openfilestring)) - { - fseeko64(f, 0x10, SEEK_END); - fread(§or_size, 1, 4, f); - if (sector_size != 512) - { - MessageBox(ghwnd,"HDI image with a sector size that is not 512","86Box error",MB_OK); - fclose(f); - return TRUE; - } - fread(&hd_new_spt, 1, 4, f); - fread(&hd_new_hpc, 1, 4, f); - fread(&hd_new_cyl, 1, 4, f); - - ret = 1; - } - else - { - fseeko64(f, -1, SEEK_END); - sz = ftello64(f) + 1; - fclose(f); - hd_new_spt = 63; - hd_new_hpc = 16; - hd_new_cyl = ((sz / 512) / 16) / 63; - - ret = DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc); - } - if (ret == 1) - { - h = GetDlgItem(hdlg, IDC_EDIT_F_SPT); - sprintf(s, "%" PRIu64, hd_new_spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_F_HPC); - sprintf(s, "%" PRIu64, hd_new_hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_F_CYL); - sprintf(s, "%" PRIu64, hd_new_cyl); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_F_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring); - - h = GetDlgItem(hdlg, IDC_TEXT_F_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - hd_changed = 1; - } - } - return TRUE; - - case IDC_GNEW: - if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, hdnew_dlgproc) == 1) - { - h = GetDlgItem(hdlg, IDC_EDIT_G_SPT); - sprintf(s, "%" PRIu64, hd_new_spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_G_HPC); - sprintf(s, "%" PRIu64, hd_new_hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_G_CYL); - sprintf(s, "%" PRIu64, hd_new_cyl); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_G_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name); - - h= GetDlgItem(hdlg, IDC_TEXT_G_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - hd_changed = 1; - } - return TRUE; - case IDC_GFILE: - if (!getfile(hdlg, "Hard disc image (*.HDI;*.IMA;*.IMG;*.VHD)\0*.HDI;*.IMA;*.IMG;*.VHD\0All files (*.*)\0*.*\0", "")) - { - f = fopen64(openfilestring, "rb"); - if (!f) - { - MessageBox(ghwnd,"Can't open file for read","86Box error",MB_OK); - return TRUE; - } - - if (image_is_hdi(openfilestring)) - { - fseeko64(f, 0x10, SEEK_END); - fread(§or_size, 1, 4, f); - if (sector_size != 512) - { - MessageBox(ghwnd,"HDI image with a sector size that is not 512","86Box error",MB_OK); - fclose(f); - return TRUE; - } - fread(&hd_new_spt, 1, 4, f); - fread(&hd_new_hpc, 1, 4, f); - fread(&hd_new_cyl, 1, 4, f); - - ret = 1; - } - else - { - fseeko64(f, -1, SEEK_END); - sz = ftello64(f) + 1; - fclose(f); - hd_new_spt = 63; - hd_new_hpc = 16; - hd_new_cyl = ((sz / 512) / 16) / 63; - - ret = DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc); - } - if (ret == 1) - { - h = GetDlgItem(hdlg, IDC_EDIT_G_SPT); - sprintf(s, "%" PRIu64, hd_new_spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_G_HPC); - sprintf(s, "%" PRIu64, hd_new_hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_G_CYL); - sprintf(s, "%" PRIu64, hd_new_cyl); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_G_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring); - - h = GetDlgItem(hdlg, IDC_TEXT_G_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - hd_changed = 1; - } - } - return TRUE; - - case IDC_HNEW: - if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, hdnew_dlgproc) == 1) - { - h = GetDlgItem(hdlg, IDC_EDIT_H_SPT); - sprintf(s, "%" PRIu64, hd_new_spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_H_HPC); - sprintf(s, "%" PRIu64, hd_new_hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_H_CYL); - sprintf(s, "%" PRIu64, hd_new_cyl); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_H_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name); - - h= GetDlgItem(hdlg, IDC_TEXT_H_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - hd_changed = 1; - } - return TRUE; - case IDC_HFILE: - if (!getfile(hdlg, "Hard disc image (*.HDI;*.IMA;*.IMG;*.VHD)\0*.HDI;*.IMA;*.IMG;*.VHD\0All files (*.*)\0*.*\0", "")) - { - f = fopen64(openfilestring, "rb"); - if (!f) - { - MessageBox(ghwnd,"Can't open file for read","86Box error",MB_OK); - return TRUE; - } - - if (image_is_hdi(openfilestring)) - { - fseeko64(f, 0x10, SEEK_END); - fread(§or_size, 1, 4, f); - if (sector_size != 512) - { - MessageBox(ghwnd,"HDI image with a sector size that is not 512","86Box error",MB_OK); - fclose(f); - return TRUE; - } - fread(&hd_new_spt, 1, 4, f); - fread(&hd_new_hpc, 1, 4, f); - fread(&hd_new_cyl, 1, 4, f); - - ret = 1; - } - else - { - fseeko64(f, -1, SEEK_END); - sz = ftello64(f) + 1; - fclose(f); - hd_new_spt = 63; - hd_new_hpc = 16; - hd_new_cyl = ((sz / 512) / 16) / 63; - - ret = DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc); - } - if (ret == 1) - { - h = GetDlgItem(hdlg, IDC_EDIT_H_SPT); - sprintf(s, "%" PRIu64, hd_new_spt); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_H_HPC); - sprintf(s, "%" PRIu64, hd_new_hpc); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_H_CYL); - sprintf(s, "%" PRIu64, hd_new_cyl); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - h = GetDlgItem(hdlg, IDC_EDIT_H_FN); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring); - - h = GetDlgItem(hdlg, IDC_TEXT_H_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd_new_cyl*hd_new_hpc*hd_new_spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - - hd_changed = 1; - } - } - return TRUE; + case IDC_IFILE: + case IDC_JFILE: + drive_num = LOWORD(wParam) % 10; + hdconf_file(hdlg, drive_num); + return TRUE; case IDC_EDIT_C_SPT: case IDC_EDIT_C_HPC: case IDC_EDIT_C_CYL: - h = GetDlgItem(hdlg, IDC_EDIT_C_SPT); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[0].spt); - h = GetDlgItem(hdlg, IDC_EDIT_C_HPC); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[0].hpc); - h = GetDlgItem(hdlg, IDC_EDIT_C_CYL); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[0].tracks); - - h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd[0].tracks*hd[0].hpc*hd[0].spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - return TRUE; - case IDC_EDIT_D_SPT: case IDC_EDIT_D_HPC: case IDC_EDIT_D_CYL: - h = GetDlgItem(hdlg, IDC_EDIT_D_SPT); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[1].spt); - h = GetDlgItem(hdlg, IDC_EDIT_D_HPC); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[1].hpc); - h = GetDlgItem(hdlg, IDC_EDIT_D_CYL); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[1].tracks); - - h = GetDlgItem(hdlg, IDC_TEXT_D_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd[1].tracks*hd[1].hpc*hd[1].spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - return TRUE; - case IDC_EDIT_E_SPT: case IDC_EDIT_E_HPC: case IDC_EDIT_E_CYL: - h = GetDlgItem(hdlg, IDC_EDIT_E_SPT); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[2].spt); - h = GetDlgItem(hdlg, IDC_EDIT_E_HPC); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[2].hpc); - h = GetDlgItem(hdlg, IDC_EDIT_E_CYL); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[2].tracks); - - h = GetDlgItem(hdlg, IDC_TEXT_E_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd[2].tracks*hd[2].hpc*hd[2].spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - return TRUE; - case IDC_EDIT_F_SPT: case IDC_EDIT_F_HPC: case IDC_EDIT_F_CYL: - h = GetDlgItem(hdlg, IDC_EDIT_F_SPT); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[3].spt); - h = GetDlgItem(hdlg, IDC_EDIT_F_HPC); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[3].hpc); - h = GetDlgItem(hdlg, IDC_EDIT_F_CYL); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[3].tracks); - - h = GetDlgItem(hdlg, IDC_TEXT_F_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd[3].tracks*hd[3].hpc*hd[3].spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - return TRUE; - case IDC_EDIT_G_SPT: case IDC_EDIT_G_HPC: case IDC_EDIT_G_CYL: - h = GetDlgItem(hdlg, IDC_EDIT_G_SPT); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[4].spt); - h = GetDlgItem(hdlg, IDC_EDIT_G_HPC); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[4].hpc); - h = GetDlgItem(hdlg, IDC_EDIT_G_CYL); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[4].tracks); - - h = GetDlgItem(hdlg, IDC_TEXT_G_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd[4].tracks*hd[4].hpc*hd[4].spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - return TRUE; - case IDC_EDIT_H_SPT: case IDC_EDIT_H_HPC: case IDC_EDIT_H_CYL: - h = GetDlgItem(hdlg, IDC_EDIT_H_SPT); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[5].spt); - h = GetDlgItem(hdlg, IDC_EDIT_H_HPC); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[5].hpc); - h = GetDlgItem(hdlg, IDC_EDIT_H_CYL); - SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); - sscanf(s, "%" PRIu64, &hd[5].tracks); - - h = GetDlgItem(hdlg, IDC_TEXT_H_SIZE); - sprintf(s, "Size: %" PRIu64 " MB", (hd[5].tracks*hd[5].hpc*hd[5].spt) >> 11); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)s); - return TRUE; + case IDC_EDIT_I_SPT: case IDC_EDIT_I_HPC: case IDC_EDIT_I_CYL: + case IDC_EDIT_J_SPT: case IDC_EDIT_J_HPC: case IDC_EDIT_J_CYL: + drive_num = LOWORD(wParam) % 10; + hdconf_edit_boxes(hdlg, drive_num, &(hd[drive_num])); + return TRUE; case IDC_CHDD: - if (new_cdrom_channel == 0) - new_cdrom_channel = -1; - update_hdd_cdrom(hdlg); - return TRUE; case IDC_DHDD: - if (new_cdrom_channel == 1) - new_cdrom_channel = -1; - update_hdd_cdrom(hdlg); - return TRUE; case IDC_EHDD: - if (new_cdrom_channel == 2) - new_cdrom_channel = -1; - update_hdd_cdrom(hdlg); - return TRUE; case IDC_FHDD: - if (new_cdrom_channel == 3) - new_cdrom_channel = -1; - update_hdd_cdrom(hdlg); - return TRUE; case IDC_GHDD: - if (new_cdrom_channel == 4) - new_cdrom_channel = -1; - update_hdd_cdrom(hdlg); - return TRUE; case IDC_HHDD: - if (new_cdrom_channel == 5) + case IDC_IHDD: + case IDC_JHDD: + if (new_cdrom_channel == (LOWORD(wParam) - IDC_CCDROM)) new_cdrom_channel = -1; update_hdd_cdrom(hdlg); return TRUE; case IDC_CCDROM: - new_cdrom_channel = 0; - update_hdd_cdrom(hdlg); - return TRUE; case IDC_DCDROM: - new_cdrom_channel = 1; - update_hdd_cdrom(hdlg); - return TRUE; case IDC_ECDROM: - new_cdrom_channel = 2; + case IDC_FCDROM: + case IDC_GCDROM: + case IDC_HCDROM: + case IDC_ICDROM: + case IDC_JCDROM: + new_cdrom_channel = LOWORD(wParam) - IDC_CCDROM; update_hdd_cdrom(hdlg); return TRUE; - case IDC_FCDROM: - new_cdrom_channel = 3; - update_hdd_cdrom(hdlg); - return TRUE; - case IDC_GCDROM: - new_cdrom_channel = 4; - update_hdd_cdrom(hdlg); - return TRUE; - case IDC_HCDROM: - new_cdrom_channel = 5; - update_hdd_cdrom(hdlg); - return TRUE; } break; diff --git a/src/win.c b/src/win.c index 48d8a1704..0d2ee69cf 100644 --- a/src/win.c +++ b/src/win.c @@ -18,6 +18,7 @@ #include #include "86box.h" #include "ibm.h" +#include "ide.h" #include "cdrom-null.h" #include "cdrom-ioctl.h" #include "cdrom-iso.h" @@ -626,6 +627,84 @@ int WINAPI WinMain (HINSTANCE hThisInstance, if (scsi_cdrom_enabled) CheckMenuItem(menu, IDM_CDROM_SCSI, MF_CHECKED); + if (ide34_enable[0]) + CheckMenuItem(menu, IDM_IDE_TER_ENABLED, MF_CHECKED); + + CheckMenuItem(menu, IDM_IDE_TER_IRQ9, MF_UNCHECKED); + CheckMenuItem(menu, IDM_IDE_TER_IRQ10, MF_UNCHECKED); + CheckMenuItem(menu, IDM_IDE_TER_IRQ11, MF_UNCHECKED); + CheckMenuItem(menu, IDM_IDE_TER_IRQ12, MF_UNCHECKED); + CheckMenuItem(menu, IDM_IDE_TER_IRQ14, MF_UNCHECKED); + CheckMenuItem(menu, IDM_IDE_TER_IRQ15, MF_UNCHECKED); + + if (ide34_irq[0] == 9) + { + CheckMenuItem(menu, IDM_IDE_TER_IRQ9, MF_CHECKED); + } + else if (ide34_irq[0] == 10) + { + CheckMenuItem(menu, IDM_IDE_TER_IRQ10, MF_CHECKED); + } + else if (ide34_irq[0] == 11) + { + CheckMenuItem(menu, IDM_IDE_TER_IRQ11, MF_CHECKED); + } + else if (ide34_irq[0] == 12) + { + CheckMenuItem(menu, IDM_IDE_TER_IRQ12, MF_CHECKED); + } + else if (ide34_irq[0] == 14) + { + CheckMenuItem(menu, IDM_IDE_TER_IRQ14, MF_CHECKED); + } + else if (ide34_irq[0] == 15) + { + CheckMenuItem(menu, IDM_IDE_TER_IRQ15, MF_CHECKED); + } + else + { + fatal("Unrecognized tertiary IDE controller IRQ\n"); + } + + if (ide34_enable[1]) + CheckMenuItem(menu, IDM_IDE_QUA_ENABLED, MF_CHECKED); + + CheckMenuItem(menu, IDM_IDE_QUA_IRQ9, MF_UNCHECKED); + CheckMenuItem(menu, IDM_IDE_QUA_IRQ10, MF_UNCHECKED); + CheckMenuItem(menu, IDM_IDE_QUA_IRQ11, MF_UNCHECKED); + CheckMenuItem(menu, IDM_IDE_QUA_IRQ12, MF_UNCHECKED); + CheckMenuItem(menu, IDM_IDE_QUA_IRQ14, MF_UNCHECKED); + CheckMenuItem(menu, IDM_IDE_QUA_IRQ15, MF_UNCHECKED); + + if (ide34_irq[1] == 9) + { + CheckMenuItem(menu, IDM_IDE_QUA_IRQ9, MF_CHECKED); + } + else if (ide34_irq[1] == 10) + { + CheckMenuItem(menu, IDM_IDE_QUA_IRQ10, MF_CHECKED); + } + else if (ide34_irq[1] == 11) + { + CheckMenuItem(menu, IDM_IDE_QUA_IRQ11, MF_CHECKED); + } + else if (ide34_irq[1] == 12) + { + CheckMenuItem(menu, IDM_IDE_QUA_IRQ12, MF_CHECKED); + } + else if (ide34_irq[1] == 14) + { + CheckMenuItem(menu, IDM_IDE_QUA_IRQ14, MF_CHECKED); + } + else if (ide34_irq[1] == 15) + { + CheckMenuItem(menu, IDM_IDE_QUA_IRQ15, MF_CHECKED); + } + else + { + fatal("Unrecognized quaternary IDE controller IRQ\n"); + } + if (buslogic_enabled) CheckMenuItem(menu, IDM_SCSI_ENABLED, MF_CHECKED); @@ -1059,7 +1138,59 @@ void cdrom_close(void) } } -char *floppy_image_extensions = "All floppy images (*.12;*.144;*.360;*.720;*.86F;*.BIN;*.DSK;*.FDI;*.FLP;*.HDM;*.IMA;*.IMD;*.IMG;*.TD0;*.VFD;*.XDF)\0*.12;*.144;*.360;*.720;*.86F;*.BIN;*.DSK;*.FDI;*.FLP;*.HDM;*.IMA;*.IMD;*.IMG;*.TD0;*.VFD;*.XDF\0Advanced sector-based images (*.IMD;*.TD0)\0*.IMD;*.TD0\0Basic sector-based images (*.12;*.144;*.360;*.720;*.BIN;*.DSK;*.FDI;*.FLP;*.HDM;*.IMA;*.IMG;*.VFD;*.XDF)\0*.12;*.144;*.360;*.720;*.BIN;*.DSK;*.FDI;*.FLP;*.HDM;*.IMA;*.IMG;*.VFD;*.XDF\0Flux images (*.FDI)\0*.FDI\0Surface-based images (*.86F)\0*.86F\0All files (*.*)\0*.*\0"; +char *floppy_image_extensions = "All floppy images (*.001;*.002;*.003;*.004;*.005;*.006;*.007;*.008;*.009;*.010;*.12;*.144;*.360;*.720;*.86F;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FLP;*.HDM;*.IMA;*.IMD;*.IMG;*.TD0;*.VFD;*.XDF)\0*.001;*.002;*.003;*.004;*.005;*.006;*.007;*.008;*.009;*.010;*.12;*.144;*.360;*.720;*.86F;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FLP;*.HDM;*.IMA;*.IMD;*.IMG;*.TD0;*.VFD;*.XDF\0Advanced sector-based images (*.IMD;*.TD0)\0*.IMD;*.TD0\0Basic sector-based images (*.001;*.002;*.003;*.004;*.005;*.006;*.007;*.008;*.009;*.010;*.12;*.144;*.360;*.720;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FLP;*.HDM;*.IMA;*.IMG;*.VFD;*.XDF)\0*.001;*.002;*.003;*.004;*.005;*.006;*.007;*.008;*.009;*.010;*.12;*.144;*.360;*.720;*.BIN;*.CQ;*.CQM;*.DSK;*.FDI;*.FLP;*.HDM;*.IMA;*.IMG;*.VFD;*.XDF\0Flux images (*.FDI)\0*.FDI\0Surface-based images (*.86F)\0*.86F\0All files (*.*)\0*.*\0"; + +int ide_ter_set_irq(HMENU hmenu, int irq, int id) +{ + if (ide34_irq[0] == irq) + { + return 0; + } + if (MessageBox(NULL,"This will reset 86Box!\nOkay to continue?","86Box",MB_OKCANCEL) != IDOK) + { + return 0; + } + pause = 1; + Sleep(100); + ide34_irq[0] = irq; + CheckMenuItem(hmenu, IDM_IDE_TER_IRQ9, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_IDE_TER_IRQ10, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_IDE_TER_IRQ11, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_IDE_TER_IRQ12, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_IDE_TER_IRQ14, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_IDE_TER_IRQ15, MF_UNCHECKED); + CheckMenuItem(hmenu, id, MF_CHECKED); + saveconfig(); + resetpchard(); + pause = 0; + return 1; +} + +int ide_qua_set_irq(HMENU hmenu, int irq, int id) +{ + if (ide34_irq[1] == irq) + { + return 0; + } + if (MessageBox(NULL,"This will reset 86Box!\nOkay to continue?","86Box",MB_OKCANCEL) != IDOK) + { + return 0; + } + pause = 1; + Sleep(100); + ide34_irq[1] = irq; + CheckMenuItem(hmenu, IDM_IDE_QUA_IRQ9, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_IDE_QUA_IRQ10, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_IDE_QUA_IRQ11, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_IDE_QUA_IRQ12, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_IDE_QUA_IRQ14, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_IDE_QUA_IRQ15, MF_UNCHECKED); + CheckMenuItem(hmenu, id, MF_CHECKED); + saveconfig(); + resetpchard(); + pause = 0; + return 1; +} int scsi_set_base(HMENU hmenu, int base, int id) { @@ -1415,13 +1546,89 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM } pause = 1; Sleep(100); - scsi_cdrom_enabled ^= 1; + scsi_cdrom_enabled ^= 1; CheckMenuItem(hmenu, IDM_CDROM_SCSI, scsi_cdrom_enabled ? MF_CHECKED : MF_UNCHECKED); saveconfig(); resetpchard(); pause = 0; break; + case IDM_IDE_TER_ENABLED: + if (MessageBox(NULL,"This will reset 86Box!\nOkay to continue?","86Box",MB_OKCANCEL) != IDOK) + { + break; + } + pause = 1; + Sleep(100); + ide34_enable[0] ^= 1; + CheckMenuItem(hmenu, IDM_SCSI_ENABLED, ide34_enable[0] ? MF_CHECKED : MF_UNCHECKED); + saveconfig(); + resetpchard(); + pause = 0; + break; + + case IDM_IDE_TER_IRQ9: + ide_ter_set_irq(hmenu, 9, IDM_SCSI_IRQ9); + break; + + case IDM_IDE_TER_IRQ10: + ide_ter_set_irq(hmenu, 10, IDM_SCSI_IRQ10); + break; + + case IDM_IDE_TER_IRQ11: + ide_ter_set_irq(hmenu, 11, IDM_SCSI_IRQ11); + break; + + case IDM_IDE_TER_IRQ12: + ide_ter_set_irq(hmenu, 12, IDM_SCSI_IRQ12); + break; + + case IDM_IDE_TER_IRQ14: + ide_ter_set_irq(hmenu, 14, IDM_SCSI_IRQ14); + break; + + case IDM_IDE_TER_IRQ15: + ide_ter_set_irq(hmenu, 15, IDM_SCSI_IRQ15); + break; + + case IDM_IDE_QUA_ENABLED: + if (MessageBox(NULL,"This will reset 86Box!\nOkay to continue?","86Box",MB_OKCANCEL) != IDOK) + { + break; + } + pause = 1; + Sleep(100); + ide34_enable[1] ^= 1; + CheckMenuItem(hmenu, IDM_SCSI_ENABLED, ide34_enable[1] ? MF_CHECKED : MF_UNCHECKED); + saveconfig(); + resetpchard(); + pause = 0; + break; + + case IDM_IDE_QUA_IRQ9: + ide_qua_set_irq(hmenu, 9, IDM_SCSI_IRQ9); + break; + + case IDM_IDE_QUA_IRQ10: + ide_qua_set_irq(hmenu, 10, IDM_SCSI_IRQ10); + break; + + case IDM_IDE_QUA_IRQ11: + ide_qua_set_irq(hmenu, 11, IDM_SCSI_IRQ11); + break; + + case IDM_IDE_QUA_IRQ12: + ide_qua_set_irq(hmenu, 12, IDM_SCSI_IRQ12); + break; + + case IDM_IDE_QUA_IRQ14: + ide_qua_set_irq(hmenu, 14, IDM_SCSI_IRQ14); + break; + + case IDM_IDE_QUA_IRQ15: + ide_qua_set_irq(hmenu, 15, IDM_SCSI_IRQ15); + break; + case IDM_SCSI_ENABLED: if (MessageBox(NULL,"This will reset 86Box!\nOkay to continue?","86Box",MB_OKCANCEL) != IDOK) { @@ -1429,7 +1636,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM } pause = 1; Sleep(100); - buslogic_enabled ^= 1; + buslogic_enabled ^= 1; CheckMenuItem(hmenu, IDM_SCSI_ENABLED, buslogic_enabled ? MF_CHECKED : MF_UNCHECKED); saveconfig(); resetpchard(); @@ -1437,108 +1644,63 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM break; case IDM_SCSI_BASE130: - if (scsi_set_base(hmenu, 0x130, IDM_SCSI_BASE130) == 0) - { - break; - } + scsi_set_base(hmenu, 0x130, IDM_SCSI_BASE130); break; case IDM_SCSI_BASE134: - if (scsi_set_base(hmenu, 0x134, IDM_SCSI_BASE134) == 0) - { - break; - } + scsi_set_base(hmenu, 0x134, IDM_SCSI_BASE134); break; case IDM_SCSI_BASE230: - if (scsi_set_base(hmenu, 0x230, IDM_SCSI_BASE230) == 0) - { - break; - } + scsi_set_base(hmenu, 0x230, IDM_SCSI_BASE230); break; case IDM_SCSI_BASE234: - if (scsi_set_base(hmenu, 0x234, IDM_SCSI_BASE234) == 0) - { - break; - } + scsi_set_base(hmenu, 0x234, IDM_SCSI_BASE234); break; case IDM_SCSI_BASE330: - if (scsi_set_base(hmenu, 0x330, IDM_SCSI_BASE330) == 0) - { - break; - } + scsi_set_base(hmenu, 0x330, IDM_SCSI_BASE330); break; case IDM_SCSI_BASE334: - if (scsi_set_base(hmenu, 0x334, IDM_SCSI_BASE334) == 0) - { - break; - } + scsi_set_base(hmenu, 0x334, IDM_SCSI_BASE334); break; case IDM_SCSI_IRQ9: - if (scsi_set_irq(hmenu, 9, IDM_SCSI_IRQ9) == 0) - { - break; - } + scsi_set_irq(hmenu, 9, IDM_SCSI_IRQ9); break; case IDM_SCSI_IRQ10: - if (scsi_set_irq(hmenu, 10, IDM_SCSI_IRQ10) == 0) - { - break; - } + scsi_set_irq(hmenu, 10, IDM_SCSI_IRQ10); break; case IDM_SCSI_IRQ11: - if (scsi_set_irq(hmenu, 11, IDM_SCSI_IRQ11) == 0) - { - break; - } + scsi_set_irq(hmenu, 11, IDM_SCSI_IRQ11); break; case IDM_SCSI_IRQ12: - if (scsi_set_irq(hmenu, 12, IDM_SCSI_IRQ12) == 0) - { - break; - } + scsi_set_irq(hmenu, 12, IDM_SCSI_IRQ12); break; case IDM_SCSI_IRQ14: - if (scsi_set_irq(hmenu, 14, IDM_SCSI_IRQ14) == 0) - { - break; - } + scsi_set_irq(hmenu, 14, IDM_SCSI_IRQ14); break; case IDM_SCSI_IRQ15: - if (scsi_set_irq(hmenu, 15, IDM_SCSI_IRQ15) == 0) - { - break; - } + scsi_set_irq(hmenu, 15, IDM_SCSI_IRQ15); break; case IDM_SCSI_DMA5: - if (scsi_set_dma(hmenu, 5, IDM_SCSI_DMA5) == 0) - { - break; - } + scsi_set_dma(hmenu, 5, IDM_SCSI_DMA5); break; case IDM_SCSI_DMA6: - if (scsi_set_dma(hmenu, 6, IDM_SCSI_DMA6) == 0) - { - break; - } + scsi_set_dma(hmenu, 6, IDM_SCSI_DMA6); break; case IDM_SCSI_DMA7: - if (scsi_set_dma(hmenu, 7, IDM_SCSI_DMA7) == 0) - { - break; - } + scsi_set_dma(hmenu, 7, IDM_SCSI_DMA7); break; case IDM_CDROM_EMPTY: