Hard disk parameters dialog boxes now allow you to specify size in MB or select a predefined type from a combo box;
Japanese HDI hard disk images are now supproted; FDC FORMAT command now CRC's the correct data, fixes formatting inserted IMG's; FDC SEEK command now no longer incorrectly reports invalid status when HDSEL (head select) is 1, fixes booting from inserted floppies of any format on boards other than ASUS P/I-P55TVP4.
This commit is contained in:
@@ -30,8 +30,7 @@ LIBS = -mwindows -lwinmm -lopenal.dll -lopenal -lddraw -ldinput8 -ldxguid -ld3d9
|
||||
|
||||
86Box.exe: $(OBJ) $(DBOBJ) $(SIDOBJ) $(SLIRPOBJ)
|
||||
$(CC) $(OBJ) $(DBOBJ) $(SIDOBJ) $(SLIRPOBJ) -o "86Box.exe" $(LIBS)
|
||||
|
||||
a.exe: strip "86Box.exe"
|
||||
strip "86Box.exe"
|
||||
|
||||
all : 86Box.exe
|
||||
|
||||
|
||||
@@ -1465,7 +1465,7 @@ int d86f_poll_check_notfound(int drive)
|
||||
/* The index hole has been hit twice and we're still in a find state.
|
||||
This means sector finding has failed for whatever reason.
|
||||
Abort with sector not found and set state to idle. */
|
||||
// pclog("d86f_poll(): Sector not found (%i %i %i %i) (%i, %i)\n", d86f[drive].req_sector.id.c, d86f[drive].req_sector.id.h, d86f[drive].req_sector.id.r, d86f[drive].req_sector.id.n, fdc_get_bitcell_period(), d86f_get_bitcell_period(drive));
|
||||
pclog("d86f_poll(): Sector not found (%i %i %i %i) (%i, %i)\n", d86f[drive].req_sector.id.c, d86f[drive].req_sector.id.h, d86f[drive].req_sector.id.r, d86f[drive].req_sector.id.n, fdc_get_bitcell_period(), d86f_get_bitcell_period(drive));
|
||||
fdc_notfound();
|
||||
d86f[drive].state = STATE_IDLE;
|
||||
d86f[drive].index_count = 0;
|
||||
@@ -1932,7 +1932,7 @@ void d86f_poll_format(int drive, int side)
|
||||
{
|
||||
d86f_handler[drive].write_data(drive, side, d86f[drive].id_pos, d86f[drive].fill);
|
||||
}
|
||||
d86f_calccrc(drive, d86f[drive].track_data_byte);
|
||||
d86f_calccrc(drive, d86f[drive].fill);
|
||||
break;
|
||||
case BYTE_ID_CRC:
|
||||
case BYTE_DATA_CRC:
|
||||
|
||||
@@ -360,7 +360,7 @@ void img_load(int drive, char *fn)
|
||||
img[drive].dmf = 0;
|
||||
}
|
||||
|
||||
pclog("Image parameters: bit rate 300: %f, temporary rate: %i, hole: %i, XDF type: %i\n", bit_rate_300, temp_rate, img[drive].disk_flags >> 1, img[drive].xdf_type);
|
||||
pclog("Image parameters: bit rate 300: %f, temporary rate: %i, hole: %i, DMF: %i, XDF type: %i\n", bit_rate_300, temp_rate, img[drive].disk_flags >> 1, img[drive].dmf, img[drive].xdf_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
30
src/fdc.c
30
src/fdc.c
@@ -489,6 +489,7 @@ void fdc_write(uint16_t addr, uint8_t val, void *priv)
|
||||
{
|
||||
// pclog("Write FDC %04X %02X %04X:%04X %i %02X %i rate=%i %i\n",addr,val,cs>>4,pc,ins,fdc.st0,ins,fdc.rate, fdc.data_ready);
|
||||
int drive;
|
||||
int seek_time;
|
||||
|
||||
switch (addr&7)
|
||||
{
|
||||
@@ -853,11 +854,6 @@ bad_command:
|
||||
fdc_seek(fdc.drive, -fdc.max_track);
|
||||
}
|
||||
disctime = fdc.max_track * 10 * TIMER_USEC;
|
||||
fdc.st0 &= 0x30;
|
||||
if (!fdd_track0(fdc.drive))
|
||||
{
|
||||
fdc.st0 |= 0x30;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x0d: /*Format*/
|
||||
@@ -881,6 +877,10 @@ bad_command:
|
||||
disctime = 0;
|
||||
if (fdc.command & 0x80)
|
||||
{
|
||||
if (!fdc.params[1])
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (fdc.command & 0x40)
|
||||
{
|
||||
/* Relative seek inwards. */
|
||||
@@ -895,10 +895,15 @@ bad_command:
|
||||
}
|
||||
else
|
||||
{
|
||||
seek_time = ((int) (fdc.params[1] - fdc.track[fdc.drive])) * 10 * TIMER_USEC;
|
||||
if (!seek_time)
|
||||
{
|
||||
break;
|
||||
}
|
||||
fdc_seek(fdc.drive, fdc.params[1] - fdc.track[fdc.drive]);
|
||||
disctime = ((int) (fdc.params[1] - fdc.track[fdc.drive])) * 10 * TIMER_USEC;
|
||||
if (seek_time < 0) seek_time = -seek_time;
|
||||
disctime = seek_time;
|
||||
}
|
||||
fdc.st0 &= 0x30;
|
||||
break;
|
||||
|
||||
case 10: /*Read sector ID*/
|
||||
@@ -1120,6 +1125,7 @@ void fdc_callback()
|
||||
paramstogo = 1;
|
||||
discint = 0;
|
||||
disctime = 0;
|
||||
pclog("Sense drive status: %02X\n", fdc.res[10]);
|
||||
return;
|
||||
case 5: /*Write data*/
|
||||
case 6: /*Read data*/
|
||||
@@ -1176,10 +1182,14 @@ void fdc_callback()
|
||||
case 7: /*Recalibrate*/
|
||||
fdc.track[fdc.drive]=0;
|
||||
// if (!driveempty[fdc.dor & 1]) discchanged[fdc.dor & 1] = 0;
|
||||
if (fdc.params[0] <= 1)
|
||||
if ((fdc.params[0] & 3) <= 1)
|
||||
fdc.st0 = 0x20 | (fdc.params[0] & 3) | (fdd_get_head(fdc.drive ^ fdd_swap)?4:0);
|
||||
else
|
||||
fdc.st0 = 0x68 | (fdc.params[0] & 3) | (fdd_get_head(fdc.drive ^ fdd_swap)?4:0);
|
||||
if (!fdd_track0(fdc.drive ^ fdd_swap))
|
||||
{
|
||||
fdc.st0 |= 0x30;
|
||||
}
|
||||
discint=-3;
|
||||
timer_process();
|
||||
disctime = 2048 * (1 << TIMER_SHIFT);
|
||||
@@ -1247,10 +1257,10 @@ void fdc_callback()
|
||||
return;
|
||||
|
||||
case 15: /*Seek*/
|
||||
fdc.track[fdc.drive]=fdc.params[1];
|
||||
fdc.track[fdc.params[0] & 3]=fdc.params[1];
|
||||
// if (!driveempty[fdc.dor & 1]) discchanged[fdc.dor & 1] = 0;
|
||||
// printf("Seeked to track %i %i\n",fdc.track[fdc.drive], fdc.drive);
|
||||
if (fdc.params[0] <= 1)
|
||||
if ((fdc.params[0] & 3) <= 1)
|
||||
fdc.st0 = 0x20 | (fdc.params[0] & 3) | (fdd_get_head(fdc.drive ^ fdd_swap)?4:0);
|
||||
else
|
||||
fdc.st0 = 0x68 | (fdc.params[0] & 3) | (fdd_get_head(fdc.drive ^ fdd_swap)?4:0);
|
||||
|
||||
@@ -91,6 +91,8 @@ void fdd_seek(int drive, int track_diff)
|
||||
}
|
||||
|
||||
fdd[drive].track += track_diff;
|
||||
|
||||
// pclog("Seeking %i tracks...\n", track_diff);
|
||||
|
||||
if (fdd[drive].track < 0)
|
||||
fdd[drive].track = 0;
|
||||
|
||||
10
src/ibm.h
10
src/ibm.h
@@ -550,12 +550,18 @@ char pcempath[512];
|
||||
typedef struct
|
||||
{
|
||||
FILE *f;
|
||||
int spt,hpc; /*Sectors per track, heads per cylinder*/
|
||||
int tracks;
|
||||
uint64_t spt,hpc; /*Sectors per track, heads per cylinder*/
|
||||
uint64_t tracks;
|
||||
int is_hdi;
|
||||
uint32_t base;
|
||||
} hard_disk_t;
|
||||
|
||||
hard_disk_t hdc[4];
|
||||
|
||||
uint64_t hdt[128][3];
|
||||
|
||||
int image_is_hdi(char *s);
|
||||
|
||||
/*Keyboard*/
|
||||
int64_t keybsenddelay;
|
||||
|
||||
|
||||
188
src/ide.c
188
src/ide.c
@@ -295,6 +295,23 @@ enum
|
||||
IDE_CDROM
|
||||
};
|
||||
|
||||
uint64_t hdt[128][3] = { { 306, 4, 17 }, { 615, 2, 17 }, { 306, 4, 26 }, { 1024, 2, 17 }, { 697, 3, 17 }, { 306, 8, 17 }, { 614, 4, 17 }, { 615, 4, 17 }, /* 000-007 */
|
||||
{ 670, 4, 17 }, { 697, 4, 17 }, { 987, 3, 17 }, { 820, 4, 17 }, { 670, 5, 17 }, { 697, 5, 17 }, { 733, 5, 17 }, { 615, 6, 17 }, /* 008-015 */
|
||||
{ 462, 8, 17 }, { 306, 8, 26 }, { 615, 4, 26 }, { 1024, 4, 17 }, { 855, 5, 17 }, { 925, 5, 17 }, { 932, 5, 17 }, { 1024, 2, 40 }, /* 016-023 */
|
||||
{ 809, 6, 17 }, { 976, 5, 17 }, { 977, 5, 17 }, { 698, 7, 17 }, { 699, 7, 17 }, { 981, 5, 17 }, { 615, 8, 17 }, { 989, 5, 17 }, /* 024-031 */
|
||||
{ 820, 4, 26 }, { 1024, 5, 17 }, { 733, 7, 17 }, { 754, 7, 17 }, { 733, 5, 26 }, { 940, 6, 17 }, { 615, 6, 26 }, { 462, 8, 26 }, /* 032-039 */
|
||||
{ 830, 7, 17 }, { 855, 7, 17 }, { 751, 8, 17 }, { 1024, 4, 26 }, { 918, 7, 17 }, { 925, 7, 17 }, { 855, 5, 26 }, { 977, 7, 17 }, /* 040-047 */
|
||||
{ 987, 7, 17 }, { 1024, 7, 17 }, { 823, 4, 38 }, { 925, 8, 17 }, { 809, 6, 26 }, { 976, 5, 26 }, { 977, 5, 26 }, { 698, 7, 26 }, /* 048-055 */
|
||||
{ 699, 7, 26 }, { 940, 8, 17 }, { 615, 8, 26 }, { 1024, 5, 26 }, { 733, 7, 26 }, { 1024, 8, 17 }, { 823, 10, 17 }, { 754, 11, 17 }, /* 056-063 */
|
||||
{ 830, 10, 17 }, { 925, 9, 17 }, { 1224, 7, 17 }, { 940, 6, 26 }, { 855, 7, 26 }, { 751, 8, 26 }, { 1024, 9, 17 }, { 965, 10, 17 }, /* 064-071 */
|
||||
{ 969, 5, 34 }, { 980, 10, 17 }, { 960, 5, 35 }, { 918, 11, 17 }, { 1024, 10, 17 }, { 977, 7, 26 }, { 1024, 7, 26 }, { 1024, 11, 17 }, /* 072-079 */
|
||||
{ 940, 8, 26 }, { 776, 8, 33 }, { 755, 16, 17 }, { 1024, 12, 17 }, { 1024, 8, 26 }, { 823, 10, 26 }, { 830, 10, 26 }, { 925, 9, 26 }, /* 080-087 */
|
||||
{ 960, 9, 26 }, { 1024, 13, 17 }, { 1224, 11, 17 }, { 900, 15, 17 }, { 969, 7, 34 }, { 917, 15, 17 }, { 918, 15, 17 }, { 1524, 4, 39 }, /* 088-095 */
|
||||
{ 1024, 9, 26 }, { 1024, 14, 17 }, { 965, 10, 26 }, { 980, 10, 26 }, { 1020, 15, 17 }, { 1023, 15, 17 }, { 1024, 15, 17 }, { 1024, 16, 17 }, /* 096-103 */
|
||||
{ 1224, 15, 17 }, { 755, 16, 26 }, { 903, 8, 46 }, { 984, 10, 34 }, { 900, 15, 26 }, { 917, 15, 26 }, { 1023, 15, 26 }, { 684, 16, 38 }, /* 104-111 */
|
||||
{ 1930, 4, 62 }, { 967, 16, 31 }, { 1013, 10, 63 }, { 1218, 15, 36 }, { 654, 16, 63 }, { 659, 16, 63 }, { 702, 16, 63 }, { 1002, 13, 63 }, /* 112-119 */
|
||||
{ 854, 16, 63 }, { 987, 16, 63 }, { 995, 16, 63 }, { 1024, 16, 63 }, { 1036, 16, 63 }, { 1120, 16, 59 }, { 1054, 16, 63 }, { 0, 0, 0 } }; /* 119-127 */
|
||||
|
||||
typedef struct IDE
|
||||
{
|
||||
int type;
|
||||
@@ -321,6 +338,8 @@ typedef struct IDE
|
||||
int skip512;
|
||||
int blocksize, blockcount;
|
||||
uint16_t dma_identify_data[3];
|
||||
int hdi,base;
|
||||
int hdc_num;
|
||||
} IDE;
|
||||
|
||||
IDE ide_drives[6];
|
||||
@@ -343,6 +362,28 @@ int cur_ide[3];
|
||||
|
||||
uint8_t getstat(IDE *ide) { return ide->atastat; }
|
||||
|
||||
int image_is_hdi(char *s)
|
||||
{
|
||||
int len;
|
||||
char ext[5] = { 0, 0, 0, 0, 0 };
|
||||
len = strlen(s);
|
||||
ext[0] = s[len - 4];
|
||||
ext[1] = s[len - 3];
|
||||
if ((ext[1] >= 0x61) && (ext[1] <= 0x7a)) ext[1] &= ~0x20;
|
||||
ext[2] = s[len - 2];
|
||||
if ((ext[2] >= 0x61) && (ext[2] <= 0x7a)) ext[2] &= ~0x20;
|
||||
ext[3] = s[len - 1];
|
||||
if ((ext[3] >= 0x61) && (ext[3] <= 0x7a)) ext[3] &= ~0x20;
|
||||
if (strcmp(ext, ".HDI") == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void ide_irq_raise(IDE *ide)
|
||||
{
|
||||
// pclog("IDE_IRQ_RAISE\n");
|
||||
@@ -704,63 +745,16 @@ static void ide_next_sector(IDE *ide)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RPCEMU_IDE
|
||||
static void loadhd(IDE *ide, int d, const char *fn)
|
||||
{
|
||||
char pathname[512];
|
||||
|
||||
append_filename(pathname, rpcemu_get_datadir(), fn, 512);
|
||||
|
||||
rpclog("Loading %s\n",pathname);
|
||||
if (ide->hdfile == NULL) {
|
||||
/* Try to open existing hard disk image */
|
||||
ide->hdfile = fopen64(pathname, "rb+");
|
||||
if (ide->hdfile == NULL) {
|
||||
/* Failed to open existing hard disk image */
|
||||
if (errno == ENOENT) {
|
||||
/* Failed because it does not exist,
|
||||
so try to create new file */
|
||||
ide->hdfile = fopen64(pathname, "wb+");
|
||||
if (ide->hdfile == NULL) {
|
||||
fatal("Cannot create file '%s': %s",
|
||||
pathname, strerror(errno));
|
||||
}
|
||||
} else {
|
||||
/* Failed for another reason */
|
||||
fatal("Cannot open file '%s': %s",
|
||||
pathname, strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fseek(ide->hdfile, 0xfc1, SEEK_SET);
|
||||
ide->spt = getc(ide->hdfile);
|
||||
ide->hpc = getc(ide->hdfile);
|
||||
ide->skip512 = 1;
|
||||
// rpclog("First check - spt %i hpc %i\n",ide.spt[0],ide.hpc[0]);
|
||||
if (!ide->spt || !ide->hpc)
|
||||
{
|
||||
fseek(ide->hdfile, 0xdc1, SEEK_SET);
|
||||
ide->spt = getc(ide->hdfile);
|
||||
ide->hpc = getc(ide->hdfile);
|
||||
// rpclog("Second check - spt %i hpc %i\n",ide.spt[0],ide.hpc[0]);
|
||||
ide->skip512 = 0;
|
||||
if (!ide->spt || !ide->hpc)
|
||||
{
|
||||
ide->spt=63;
|
||||
ide->hpc=16;
|
||||
ide->skip512 = 1;
|
||||
// rpclog("Final check - spt %i hpc %i\n",ide.spt[0],ide.hpc[0]);
|
||||
}
|
||||
}
|
||||
|
||||
ide->type = IDE_HDD;
|
||||
|
||||
rpclog("%i %i %i\n",ide->spt,ide->hpc,ide->skip512);
|
||||
}
|
||||
#else
|
||||
static void loadhd(IDE *ide, int d, const char *fn)
|
||||
{
|
||||
uint32_t sector_size = 512;
|
||||
uint32_t zero = 0;
|
||||
uint32_t full_size = 0;
|
||||
uint32_t transl_spt = 0;
|
||||
uint32_t transl_hpc = 0;
|
||||
int c;
|
||||
ide->base = 0;
|
||||
ide->hdi = 0;
|
||||
if (ide->hdfile == NULL) {
|
||||
/* Try to open existing hard disk image */
|
||||
ide->hdfile = fopen64(fn, "rb+");
|
||||
@@ -776,6 +770,28 @@ static void loadhd(IDE *ide, int d, const char *fn)
|
||||
fn, strerror(errno));*/
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (image_is_hdi(fn))
|
||||
{
|
||||
full_size = hdc[d].spt * hdc[d].hpc * hdc[d].tracks * 512;
|
||||
ide->base = 0x1000;
|
||||
ide->hdi = 1;
|
||||
fwrite(&zero, 1, 4, ide->hdfile);
|
||||
fwrite(&zero, 1, 4, ide->hdfile);
|
||||
fwrite(&(ide->base), 1, 4, ide->hdfile);
|
||||
fwrite(&full_size, 1, 4, ide->hdfile);
|
||||
fwrite(§or_size, 1, 4, ide->hdfile);
|
||||
fwrite(&(hdc[d].spt), 1, 4, ide->hdfile);
|
||||
fwrite(&(hdc[d].hpc), 1, 4, ide->hdfile);
|
||||
fwrite(&(hdc[d].tracks), 1, 4, ide->hdfile);
|
||||
for (c = 0; c < 0x3f8; c++)
|
||||
{
|
||||
fwrite(&zero, 1, 4, ide->hdfile);
|
||||
}
|
||||
}
|
||||
ide->hdc_num = d;
|
||||
}
|
||||
} else {
|
||||
/* Failed for another reason */
|
||||
ide->type = IDE_NONE;
|
||||
@@ -785,13 +801,34 @@ static void loadhd(IDE *ide, int d, const char *fn)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (image_is_hdi(fn))
|
||||
{
|
||||
fseek(ide->hdfile, 0x8, SEEK_SET);
|
||||
fread(&(ide->base), 1, 4, ide->hdfile);
|
||||
fseek(ide->hdfile, 0x10, SEEK_SET);
|
||||
fread(§or_size, 1, 4, ide->hdfile);
|
||||
if (sector_size != 512)
|
||||
{
|
||||
/* Sector size is not 512 */
|
||||
fclose(ide->hdfile);
|
||||
ide->type = IDE_NONE;
|
||||
return;
|
||||
}
|
||||
fread(&(hdc[d].spt), 1, 4, ide->hdfile);
|
||||
fread(&(hdc[d].hpc), 1, 4, ide->hdfile);
|
||||
fread(&(hdc[d].tracks), 1, 4, ide->hdfile);
|
||||
ide->hdi = 1;
|
||||
}
|
||||
}
|
||||
|
||||
ide->spt = hdc[d].spt;
|
||||
ide->hpc = hdc[d].hpc;
|
||||
ide->tracks = hdc[d].tracks;
|
||||
ide->type = IDE_HDD;
|
||||
ide->hdc_num = d;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ide_set_signature(IDE *ide)
|
||||
{
|
||||
@@ -1524,6 +1561,7 @@ void callbackide(int ide_board)
|
||||
IDE *ide = &ide_drives[cur_ide[ide_board]];
|
||||
IDE *ide_other = &ide_drives[cur_ide[ide_board] ^ 1];
|
||||
off64_t addr;
|
||||
uint64_t faddr;
|
||||
int c;
|
||||
ext_ide = ide;
|
||||
int64_t snum;
|
||||
@@ -1613,7 +1651,7 @@ void callbackide(int ide_board)
|
||||
{
|
||||
fatal("Read from other cylinder/head");
|
||||
}*/
|
||||
fseeko64(ide->hdfile, addr, SEEK_SET);
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
fread(ide->buffer, 512, 1, ide->hdfile);
|
||||
ide->pos=0;
|
||||
ide->atastat = DRQ_STAT | READY_STAT | DSC_STAT;
|
||||
@@ -1633,7 +1671,7 @@ void callbackide(int ide_board)
|
||||
else
|
||||
{
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
fseeko64(ide->hdfile, addr, SEEK_SET);
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
fread(ide->buffer, 512, 1, ide->hdfile);
|
||||
ide->pos=0;
|
||||
}
|
||||
@@ -1678,7 +1716,7 @@ void callbackide(int ide_board)
|
||||
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
// pclog("Read multiple from %08X %i (%i) %i\n", addr, ide->blockcount, ide->blocksize, ide->secount);
|
||||
fseeko64(ide->hdfile, addr, SEEK_SET);
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
fread(ide->buffer, 512, 1, ide->hdfile);
|
||||
ide->pos=0;
|
||||
ide->atastat = DRQ_STAT | READY_STAT | DSC_STAT;
|
||||
@@ -1702,7 +1740,7 @@ void callbackide(int ide_board)
|
||||
}
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
// pclog("Write sector callback %i %i %i offset %08X %i left %i\n",ide.sector,ide.cylinder,ide.head,addr,ide.secount,ide.spt);
|
||||
fseeko64(ide->hdfile, addr, SEEK_SET);
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
fwrite(ide->buffer, 512, 1, ide->hdfile);
|
||||
ide_irq_raise(ide);
|
||||
ide->secount = (ide->secount - 1) & 0xff;
|
||||
@@ -1737,7 +1775,7 @@ void callbackide(int ide_board)
|
||||
else
|
||||
{*/
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
fseeko64(ide->hdfile, addr, SEEK_SET);
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
fwrite(ide->buffer, 512, 1, ide->hdfile);
|
||||
//}
|
||||
|
||||
@@ -1767,7 +1805,7 @@ void callbackide(int ide_board)
|
||||
}
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
// pclog("Write sector callback %i %i %i offset %08X %i left %i\n",ide.sector,ide.cylinder,ide.head,addr,ide.secount,ide.spt);
|
||||
fseeko64(ide->hdfile, addr, SEEK_SET);
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
fwrite(ide->buffer, 512, 1, ide->hdfile);
|
||||
ide->blockcount++;
|
||||
if (ide->blockcount >= ide->blocksize || ide->secount == 1)
|
||||
@@ -1809,7 +1847,7 @@ void callbackide(int ide_board)
|
||||
}
|
||||
addr = ide_get_sector(ide) * 512;
|
||||
// pclog("Format cyl %i head %i offset %08X %08X %08X secount %i\n",ide.cylinder,ide.head,addr,addr>>32,addr,ide.secount);
|
||||
fseeko64(ide->hdfile, addr, SEEK_SET);
|
||||
fseeko64(ide->hdfile, ide->base + addr, SEEK_SET);
|
||||
memset(ide->buffer, 0, 512);
|
||||
for (c=0;c<ide->secount;c++)
|
||||
{
|
||||
@@ -1845,6 +1883,28 @@ void callbackide(int ide_board)
|
||||
}
|
||||
ide->spt=ide->secount;
|
||||
ide->hpc=ide->head+1;
|
||||
#if 0
|
||||
if (ide->hdi)
|
||||
{
|
||||
faddr = ftello64(ide->hdfile);
|
||||
if (hdc[ide->hdc_num].spt != ide->spt)
|
||||
{
|
||||
fseeko64(ide->hdfile, 0x34, SEEK_SET);
|
||||
fwrite(&(ide->spt), 1, 4, ide->hdfile);
|
||||
}
|
||||
if (hdc[ide->hdc_num].hpc != ide->hpc)
|
||||
{
|
||||
fseeko64(ide->hdfile, 0x38, SEEK_SET);
|
||||
fwrite(&(ide->hpc), 1, 4, ide->hdfile);
|
||||
}
|
||||
fseeko64(ide->hdfile, faddr, SEEK_SET);
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
/* Make sure other parts of the emulator are aware the sectors and heads have changed. */
|
||||
hdc[ide->hdc_num].spt = ide->spt;
|
||||
hdc[ide->hdc_num].hpc = ide->hpc;
|
||||
#endif
|
||||
ide->atastat = READY_STAT | DSC_STAT;
|
||||
#ifndef RPCEMU_IDE
|
||||
// pclog("SPECIFY - %i sectors per track, %i heads per cylinder %i %i\n",ide->spt,ide->hpc,cur_ide[ide_board],ide_board);
|
||||
|
||||
34
src/pc.rc
34
src/pc.rc
@@ -208,7 +208,7 @@ HdConfDlg DIALOGEX 0, 0, 210, 286+4*16
|
||||
|
||||
END
|
||||
|
||||
HdNewDlg DIALOGEX 0, 0, 186, 86
|
||||
HdNewDlg DIALOGEX 0, 0, 216, 86
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "New Hard Disc"
|
||||
FONT 9, "Segoe UI"
|
||||
@@ -216,19 +216,23 @@ BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,31,66,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,101,66,50,14
|
||||
|
||||
EDITTEXT IDC_EDITC, 7, 6, 136, 12
|
||||
PUSHBUTTON "...",IDC_CFILE,7 + 136, 6, 16, 14
|
||||
EDITTEXT IDC_EDITC, 7, 6, 187, 12
|
||||
PUSHBUTTON "...",IDC_CFILE,7 + 187, 6, 16, 14
|
||||
|
||||
EDITTEXT IDC_EDIT1,36,22,16,12
|
||||
EDITTEXT IDC_EDIT2,94,22,16,12
|
||||
EDITTEXT IDC_EDIT3,152,22,28,12
|
||||
LTEXT "Sectors:",IDC_STATIC,7,22,27,10
|
||||
LTEXT "Heads:",IDC_STATIC,63,22,29,8
|
||||
LTEXT "Cylinders:",IDC_STATIC,120,22,32,12
|
||||
LTEXT "", IDC_TEXT1, 7, 38, 136, 12
|
||||
EDITTEXT IDC_EDIT4,36,38,28,12
|
||||
COMBOBOX IDC_COMBOHDT,117,38,93,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Sectors:",IDC_STATIC,7,23,27,10
|
||||
LTEXT "Heads:",IDC_STATIC,63,23,29,8
|
||||
LTEXT "Cylinders:",IDC_STATIC,120,23,32,12
|
||||
LTEXT "Size:",IDC_STATIC,7,39,17,8
|
||||
LTEXT "MB",IDC_STATIC,68,39,10,8
|
||||
LTEXT "Type:",IDC_STATIC,94,39,17,8
|
||||
END
|
||||
|
||||
HdSizeDlg DIALOGEX 0, 0, 186, 86
|
||||
HdSizeDlg DIALOGEX 0, 0, 216, 86
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Hard disc parameters"
|
||||
FONT 9, "Segoe UI"
|
||||
@@ -236,15 +240,19 @@ BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,31,66,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,101,66,50,14
|
||||
|
||||
LTEXT "Initial settings are based on file size",IDC_STATIC,7,6,170,10
|
||||
LTEXT "Initial settings are based on file size (header if HDI)",IDC_STATIC,7,6,200,10
|
||||
|
||||
EDITTEXT IDC_EDIT1,36,22,16,12
|
||||
EDITTEXT IDC_EDIT2,94,22,16,12
|
||||
EDITTEXT IDC_EDIT3,152,22,28,12
|
||||
LTEXT "Sectors:",IDC_STATIC,7,22,27,10
|
||||
LTEXT "Heads:",IDC_STATIC,63,22,29,8
|
||||
LTEXT "Cylinders:",IDC_STATIC,120,22,32,12
|
||||
LTEXT "", IDC_TEXT1, 7, 38, 136, 12
|
||||
EDITTEXT IDC_EDIT4,36,38,28,12
|
||||
COMBOBOX IDC_COMBOHDT,117,38,93,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Sectors:",IDC_STATIC,7,23,27,10
|
||||
LTEXT "Heads:",IDC_STATIC,63,23,29,8
|
||||
LTEXT "Cylinders:",IDC_STATIC,120,23,32,12
|
||||
LTEXT "Size:",IDC_STATIC,7,39,17,8
|
||||
LTEXT "MB",IDC_STATIC,68,39,10,8
|
||||
LTEXT "Type:",IDC_STATIC,94,39,17,8
|
||||
END
|
||||
|
||||
StatusDlg DIALOGEX 0,0,186,186+20+180
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#define IDC_EDIT4 1033
|
||||
#define IDC_EDIT5 1034
|
||||
#define IDC_EDIT6 1035
|
||||
#define IDC_COMBOHDT 1036
|
||||
#define IDC_TEXT1 1040
|
||||
#define IDC_TEXT2 1041
|
||||
#define IDC_EDITC 1050
|
||||
|
||||
657
src/win-hdconf.c
657
src/win-hdconf.c
@@ -1,6 +1,7 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
@@ -14,7 +15,8 @@
|
||||
static int hd_changed = 0;
|
||||
|
||||
static char hd_new_name[512];
|
||||
static int hd_new_spt, hd_new_hpc, hd_new_cyl;
|
||||
static uint64_t hd_new_spt, hd_new_hpc, hd_new_cyl;
|
||||
static int hd_new_hdi;
|
||||
static int new_cdrom_channel;
|
||||
|
||||
static void update_hdd_cdrom(HWND hdlg)
|
||||
@@ -43,114 +45,349 @@ static void update_hdd_cdrom(HWND hdlg)
|
||||
SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 5) ? 1 : 0, 0);
|
||||
}
|
||||
|
||||
static BOOL CALLBACK hdnew_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
int hdnew_no_update = 0;
|
||||
|
||||
hard_disk_t hdnew_temp_hd;
|
||||
|
||||
int hdsize_no_update = 0;
|
||||
|
||||
hard_disk_t hdsize_temp_hd;
|
||||
|
||||
char s[260];
|
||||
|
||||
static int hdconf_initialize_hdt_combo(HWND hdlg, hard_disk_t *internal_hd)
|
||||
{
|
||||
char s[260];
|
||||
HWND h;
|
||||
int c;
|
||||
hard_disk_t hd[4];
|
||||
int i = 0;
|
||||
uint64_t size = 0;
|
||||
uint64_t size_mb = 0;
|
||||
uint64_t size_shift = 11;
|
||||
int selection = 127;
|
||||
|
||||
h = GetDlgItem(hdlg, IDC_COMBOHDT);
|
||||
for (i = 0; i < 127; i++)
|
||||
{
|
||||
size = hdt[i][0] * hdt[i][1] * hdt[i][2];
|
||||
size_mb = size >> size_shift;
|
||||
sprintf(s, "%" PRIu64 " MB (CHS: %" PRIu64 ", %" PRIu64 ", %" PRIu64 ")", size_mb, hdt[i][0], hdt[i][1], hdt[i][2]);
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)s);
|
||||
if ((internal_hd->tracks == hdt[i][0]) && (internal_hd->hpc == hdt[i][1]) && (internal_hd->spt == hdt[i][2]))
|
||||
{
|
||||
selection = i;
|
||||
}
|
||||
}
|
||||
sprintf(s, "Custom...");
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)s);
|
||||
SendMessage(h, CB_SETCURSEL, selection, 0);
|
||||
return selection;
|
||||
}
|
||||
|
||||
static void hdconf_update_text_boxes(HWND hdlg, BOOL enable)
|
||||
{
|
||||
HWND h;
|
||||
|
||||
h=GetDlgItem(hdlg, IDC_EDIT1);
|
||||
EnableWindow(h, enable);
|
||||
h=GetDlgItem(hdlg, IDC_EDIT2);
|
||||
EnableWindow(h, enable);
|
||||
h=GetDlgItem(hdlg, IDC_EDIT3);
|
||||
EnableWindow(h, enable);
|
||||
h=GetDlgItem(hdlg, IDC_EDIT4);
|
||||
EnableWindow(h, enable);
|
||||
}
|
||||
|
||||
void hdconf_set_text_boxes(HWND hdlg, hard_disk_t *internal_hd)
|
||||
{
|
||||
HWND h;
|
||||
|
||||
uint64_t size_shift = 11;
|
||||
|
||||
h = GetDlgItem(hdlg, IDC_EDIT1);
|
||||
sprintf(s, "%" PRIu64, internal_hd->spt);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT2);
|
||||
sprintf(s, "%" PRIu64, internal_hd->hpc);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT3);
|
||||
sprintf(s, "%" PRIu64, internal_hd->tracks);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
|
||||
h = GetDlgItem(hdlg, IDC_EDIT4);
|
||||
sprintf(s, "%" PRIu64, (internal_hd->spt * internal_hd->hpc * internal_hd->tracks) >> size_shift);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
}
|
||||
|
||||
BOOL hdconf_initdialog_common(HWND hdlg, hard_disk_t *internal_hd, int *no_update, uint64_t spt, uint64_t hpc, uint64_t tracks)
|
||||
{
|
||||
HWND h;
|
||||
int selection = 127;
|
||||
|
||||
internal_hd->spt = spt;
|
||||
internal_hd->hpc = hpc;
|
||||
internal_hd->tracks = tracks;
|
||||
*no_update = 1;
|
||||
|
||||
hdconf_set_text_boxes(hdlg, internal_hd);
|
||||
|
||||
selection = hdconf_initialize_hdt_combo(hdlg, internal_hd);
|
||||
|
||||
if (selection < 127)
|
||||
{
|
||||
hdconf_update_text_boxes(hdlg, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
hdconf_update_text_boxes(hdlg, TRUE);
|
||||
}
|
||||
|
||||
*no_update = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int hdconf_idok_common(HWND hdlg)
|
||||
{
|
||||
HWND h;
|
||||
|
||||
h = GetDlgItem(hdlg, IDC_EDIT1);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%" PRIu64, &hd_new_spt);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT2);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%" PRIu64, &hd_new_hpc);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT3);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%" PRIu64, &hd_new_cyl);
|
||||
|
||||
if (hd_new_spt > 63)
|
||||
{
|
||||
MessageBox(ghwnd, "Drive has too many sectors (maximum is 63)", "86Box error", MB_OK);
|
||||
return 1;
|
||||
}
|
||||
if (hd_new_hpc > 16)
|
||||
{
|
||||
MessageBox(ghwnd, "Drive has too many heads (maximum is 16)", "86Box error", MB_OK);
|
||||
return 1;
|
||||
}
|
||||
if (hd_new_cyl > 16383)
|
||||
{
|
||||
MessageBox(ghwnd, "Drive has too many cylinders (maximum is 16383)", "86Box error", MB_OK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL hdconf_process_edit_boxes(HWND hdlg, WORD control, uint64_t *var, hard_disk_t *internal_hd, int *no_update)
|
||||
{
|
||||
HWND h;
|
||||
uint64_t size_shift = 11;
|
||||
|
||||
if (*no_update)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
h = GetDlgItem(hdlg, control);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%" PRIu64, var);
|
||||
|
||||
*no_update = 1;
|
||||
if(!(*var))
|
||||
{
|
||||
*var = 1;
|
||||
sprintf(s, "%" PRIu64, *var);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
}
|
||||
|
||||
if (control == IDC_EDIT4)
|
||||
{
|
||||
*var <<= 11; /* Convert to sectors */
|
||||
*var /= internal_hd->hpc;
|
||||
*var /= internal_hd->spt;
|
||||
internal_hd->tracks = *var;
|
||||
|
||||
h = GetDlgItem(hdlg, IDC_EDIT3);
|
||||
sprintf(s, "%" PRIu64, internal_hd->tracks);
|
||||
SendMessage(h, WM_SETTEXT, 1, (LPARAM)s);
|
||||
}
|
||||
else if ((control >= IDC_EDIT1) && (control <= IDC_EDIT3))
|
||||
{
|
||||
h = GetDlgItem(hdlg, IDC_EDIT4);
|
||||
sprintf(s, "%" PRIu64, (internal_hd->spt * internal_hd->hpc * internal_hd->tracks) >> size_shift);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
}
|
||||
|
||||
*no_update = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL hdconf_process_hdt_combo(HWND hdlg, hard_disk_t *internal_hd, int *no_update, WPARAM wParam)
|
||||
{
|
||||
HWND h;
|
||||
int selection = 127;
|
||||
|
||||
if (*no_update)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (HIWORD(wParam) == CBN_SELCHANGE)
|
||||
{
|
||||
*no_update = 1;
|
||||
|
||||
h = GetDlgItem(hdlg,IDC_COMBOHDT);
|
||||
selection = SendMessage(h,CB_GETCURSEL,0,0);
|
||||
|
||||
if (selection < 127)
|
||||
{
|
||||
hdconf_update_text_boxes(hdlg, FALSE);
|
||||
|
||||
internal_hd->tracks = hdt[selection][0];
|
||||
internal_hd->hpc = hdt[selection][1];
|
||||
internal_hd->spt = hdt[selection][2];
|
||||
|
||||
hdconf_set_text_boxes(hdlg, internal_hd);
|
||||
}
|
||||
else
|
||||
{
|
||||
hdconf_update_text_boxes(hdlg, TRUE);
|
||||
}
|
||||
|
||||
*no_update = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK hdconf_common_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam, int type, hard_disk_t *internal_hd, int *no_update, uint64_t spt, uint64_t hpc, uint64_t tracks)
|
||||
{
|
||||
HWND h;
|
||||
uint64_t c;
|
||||
FILE *f;
|
||||
uint8_t buf[512];
|
||||
int is_hdi;
|
||||
uint64_t size;
|
||||
uint32_t zero = 0;
|
||||
uint32_t sector_size = 512;
|
||||
uint32_t base = 0x1000;
|
||||
uint64_t full_size = 0;
|
||||
uint64_t full_size_bytes = 0;
|
||||
uint64_t size_shift = 11;
|
||||
int selection = 127;
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
h = GetDlgItem(hdlg, IDC_EDIT1);
|
||||
sprintf(s, "%i", 63);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT2);
|
||||
sprintf(s, "%i", 16);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT3);
|
||||
sprintf(s, "%i", 511);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
if (!type)
|
||||
{
|
||||
h = GetDlgItem(hdlg, IDC_EDITC);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)"");
|
||||
}
|
||||
return hdconf_initdialog_common(hdlg, internal_hd, no_update, spt, hpc, tracks);
|
||||
|
||||
h = GetDlgItem(hdlg, IDC_EDITC);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)"");
|
||||
|
||||
h = GetDlgItem(hdlg, IDC_TEXT1);
|
||||
sprintf(s, "Size : %imb", (((511*16*63)*512)/1024)/1024);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
h = GetDlgItem(hdlg, IDC_EDITC);
|
||||
SendMessage(h, WM_GETTEXT, 511, (LPARAM)hd_new_name);
|
||||
if (!hd_new_name[0])
|
||||
{
|
||||
MessageBox(ghwnd,"Please enter a valid filename","86Box error",MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
h = GetDlgItem(hdlg, IDC_EDIT1);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%i", &hd_new_spt);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT2);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%i", &hd_new_hpc);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT3);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%i", &hd_new_cyl);
|
||||
if (!type)
|
||||
{
|
||||
h = GetDlgItem(hdlg, IDC_EDITC);
|
||||
SendMessage(h, WM_GETTEXT, 511, (LPARAM)hd_new_name);
|
||||
if (!hd_new_name[0])
|
||||
{
|
||||
MessageBox(ghwnd,"Please enter a valid filename","86Box error",MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (hdconf_idok_common(hdlg))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!type)
|
||||
{
|
||||
f = fopen64(hd_new_name, "wb");
|
||||
if (!f)
|
||||
{
|
||||
MessageBox(ghwnd, "Can't open file for write", "86Box error", MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
full_size = (hd_new_cyl * hd_new_hpc * hd_new_spt);
|
||||
full_size_bytes = full_size * 512;
|
||||
if (image_is_hdi(hd_new_name))
|
||||
{
|
||||
if (full_size_bytes >= 0x100000000)
|
||||
{
|
||||
MessageBox(ghwnd, "Drive is HDI and 4 GB or bigger (size filed in HDI header is 32-bit)", "86Box error", MB_OK);
|
||||
fclose(f);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
hd_new_hdi = 1;
|
||||
|
||||
fwrite(&zero, 1, 4, f); /* 00000000: Zero/unknown */
|
||||
fwrite(&zero, 1, 4, f); /* 00000004: Zero/unknown */
|
||||
fwrite(&base, 1, 4, f); /* 00000008: Offset at which data starts */
|
||||
fwrite(&full_size_bytes, 1, 4, f); /* 0000000C: Full size of the data (32-bit) */
|
||||
fwrite(§or_size, 1, 4, f); /* 00000010: Sector size in bytes */
|
||||
fwrite(&hd_new_spt, 1, 4, f); /* 00000014: Sectors per cylinder */
|
||||
fwrite(&hd_new_hpc, 1, 4, f); /* 00000018: Heads per cylinder */
|
||||
fwrite(&hd_new_cyl, 1, 4, f); /* 0000001C: Cylinders */
|
||||
|
||||
for (c = 0; c < 0x3f8; c++)
|
||||
{
|
||||
fwrite(&zero, 1, 4, f);
|
||||
}
|
||||
}
|
||||
memset(buf, 0, 512);
|
||||
for (c = 0; c < full_size; c++)
|
||||
fwrite(buf, 512, 1, f);
|
||||
fclose(f);
|
||||
|
||||
if (hd_new_spt > 63)
|
||||
{
|
||||
MessageBox(ghwnd, "Drive has too many sectors (maximum is 63)", "86Box error", MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
if (hd_new_hpc > 16)
|
||||
{
|
||||
MessageBox(ghwnd, "Drive has too many heads (maximum is 16)", "86Box error", MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
if (hd_new_cyl > 16383)
|
||||
{
|
||||
MessageBox(ghwnd, "Drive has too many cylinders (maximum is 16383)", "86Box error", MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
MessageBox(ghwnd, "Remember to partition and format the new drive", "86Box", MB_OK);
|
||||
}
|
||||
|
||||
f = fopen64(hd_new_name, "wb");
|
||||
if (!f)
|
||||
{
|
||||
MessageBox(ghwnd, "Can't open file for write", "86Box error", MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
memset(buf, 0, 512);
|
||||
for (c = 0; c < (hd_new_cyl * hd_new_hpc * hd_new_spt); c++)
|
||||
fwrite(buf, 512, 1, f);
|
||||
fclose(f);
|
||||
|
||||
MessageBox(ghwnd, "Remember to partition and format the new drive", "86Box", MB_OK);
|
||||
|
||||
EndDialog(hdlg, 1);
|
||||
EndDialog(hdlg,1);
|
||||
return TRUE;
|
||||
|
||||
case IDCANCEL:
|
||||
EndDialog(hdlg, 0);
|
||||
return TRUE;
|
||||
|
||||
case IDC_CFILE:
|
||||
if (!getsfile(hdlg, "Hard disc image (*.IMA;*.IMG;*.VHD)\0*.IMA;*.IMG;*.VHD\0All files (*.*)\0*.*\0", ""))
|
||||
{
|
||||
h = GetDlgItem(hdlg, IDC_EDITC);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case IDC_EDIT1: case IDC_EDIT2: case IDC_EDIT3:
|
||||
h = GetDlgItem(hdlg, IDC_EDIT1);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%i", &hd[0].spt);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT2);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%i", &hd[0].hpc);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT3);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%i", &hd[0].tracks);
|
||||
if (!type)
|
||||
{
|
||||
if (!getsfile(hdlg, "Hard disc image (*.HDI;*.IMA;*.IMG)\0*.HDI;*.IMA;*.IMG\0All files (*.*)\0*.*\0", ""))
|
||||
{
|
||||
h = GetDlgItem(hdlg, IDC_EDITC);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
h = GetDlgItem(hdlg, IDC_TEXT1);
|
||||
sprintf(s, "Size : %imb", (((((uint64_t)hd[0].tracks*(uint64_t)hd[0].hpc)*(uint64_t)hd[0].spt)*512)/1024)/1024);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
return TRUE;
|
||||
case IDC_EDIT1:
|
||||
return hdconf_process_edit_boxes(hdlg, IDC_EDIT1, &(internal_hd->spt), internal_hd, no_update);
|
||||
|
||||
case IDC_EDIT2:
|
||||
return hdconf_process_edit_boxes(hdlg, IDC_EDIT2, &(internal_hd->hpc), internal_hd, no_update);
|
||||
|
||||
case IDC_EDIT3:
|
||||
return hdconf_process_edit_boxes(hdlg, IDC_EDIT3, &(internal_hd->tracks), internal_hd, no_update);
|
||||
|
||||
case IDC_EDIT4:
|
||||
return hdconf_process_edit_boxes(hdlg, IDC_EDIT4, &size, internal_hd, no_update);
|
||||
|
||||
case IDC_COMBOHDT:
|
||||
return hdconf_process_hdt_combo(hdlg, internal_hd, no_update, wParam);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -158,93 +395,25 @@ static BOOL CALLBACK hdnew_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARA
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK hdnew_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return hdconf_common_dlgproc(hdlg, message, wParam, lParam, 0, &hdnew_temp_hd, &hdnew_no_update, 63, 16, 511);
|
||||
}
|
||||
|
||||
BOOL CALLBACK hdsize_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
char s[260];
|
||||
HWND h;
|
||||
hard_disk_t hd[2];
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
h = GetDlgItem(hdlg, IDC_EDIT1);
|
||||
sprintf(s, "%i", hd_new_spt);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT2);
|
||||
sprintf(s, "%i", hd_new_hpc);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT3);
|
||||
sprintf(s, "%i", hd_new_cyl);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
|
||||
h = GetDlgItem(hdlg, IDC_TEXT1);
|
||||
sprintf(s, "Size : %imb", ((((uint64_t)hd_new_spt*(uint64_t)hd_new_hpc*(uint64_t)hd_new_cyl)*512)/1024)/1024);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
h = GetDlgItem(hdlg, IDC_EDIT1);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%i", &hd_new_spt);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT2);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%i", &hd_new_hpc);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT3);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%i", &hd_new_cyl);
|
||||
|
||||
if (hd_new_spt > 63)
|
||||
{
|
||||
MessageBox(ghwnd,"Drive has too many sectors (maximum is 63)","86Box error",MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
if (hd_new_hpc > 16)
|
||||
{
|
||||
MessageBox(ghwnd,"Drive has too many heads (maximum is 16)","86Box error",MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
if (hd_new_cyl > 16383)
|
||||
{
|
||||
MessageBox(ghwnd,"Drive has too many cylinders (maximum is 16383)","86Box error",MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
EndDialog(hdlg,1);
|
||||
return TRUE;
|
||||
case IDCANCEL:
|
||||
EndDialog(hdlg,0);
|
||||
return TRUE;
|
||||
|
||||
case IDC_EDIT1: case IDC_EDIT2: case IDC_EDIT3:
|
||||
h = GetDlgItem(hdlg, IDC_EDIT1);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%i", &hd[0].spt);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT2);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%i", &hd[0].hpc);
|
||||
h = GetDlgItem(hdlg, IDC_EDIT3);
|
||||
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
|
||||
sscanf(s, "%i", &hd[0].tracks);
|
||||
|
||||
h = GetDlgItem(hdlg, IDC_TEXT1);
|
||||
sprintf(s, "Size : %imb", (((((uint64_t)hd[0].tracks*(uint64_t)hd[0].hpc)*(uint64_t)hd[0].spt)*512)/1024)/1024);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return FALSE;
|
||||
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 BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
char s[260];
|
||||
HWND h;
|
||||
hard_disk_t hd[4];
|
||||
FILE *f;
|
||||
off64_t sz;
|
||||
int ret;
|
||||
uint32_t sector_size = 512;
|
||||
uint32_t base = 0x1000;
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
@@ -466,7 +635,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR
|
||||
return TRUE;
|
||||
|
||||
case IDC_CFILE:
|
||||
if (!getfile(hdlg, "Hard disc image (*.IMA;*.IMG;*.VHD)\0*.IMA;*.IMG;*.VHD\0All files (*.*)\0*.*\0", ""))
|
||||
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)
|
||||
@@ -474,14 +643,35 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR
|
||||
MessageBox(ghwnd,"Can't open file for read","86Box error",MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
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;
|
||||
|
||||
if (DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc) == 1)
|
||||
|
||||
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, "%i", hd_new_spt);
|
||||
@@ -495,7 +685,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR
|
||||
h = GetDlgItem(hdlg, IDC_EDIT_C_FN);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring);
|
||||
|
||||
h= GetDlgItem(hdlg, IDC_TEXT_C_SIZE);
|
||||
h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE);
|
||||
sprintf(s, "Size : %imb", (((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||
|
||||
@@ -528,7 +718,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR
|
||||
return TRUE;
|
||||
|
||||
case IDC_DFILE:
|
||||
if (!getfile(hdlg, "Hard disc image (*.IMA;*.IMG;*.VHD)\0*.IMA;*.IMG;*.VHD\0All files (*.*)\0*.*\0", ""))
|
||||
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)
|
||||
@@ -536,14 +726,35 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR
|
||||
MessageBox(ghwnd,"Can't open file for read","86Box error",MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
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;
|
||||
|
||||
if (DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc) == 1)
|
||||
|
||||
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, "%i", hd_new_spt);
|
||||
@@ -590,7 +801,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR
|
||||
return TRUE;
|
||||
|
||||
case IDC_EFILE:
|
||||
if (!getfile(hdlg, "Hard disc image (*.IMA;*.IMG;*.VHD)\0*.IMA;*.IMG;*.VHD\0All files (*.*)\0*.*\0", ""))
|
||||
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)
|
||||
@@ -598,14 +809,35 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR
|
||||
MessageBox(ghwnd,"Can't open file for read","86Box error",MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
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;
|
||||
|
||||
if (DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc) == 1)
|
||||
|
||||
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, "%i", hd_new_spt);
|
||||
@@ -652,7 +884,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR
|
||||
return TRUE;
|
||||
|
||||
case IDC_FFILE:
|
||||
if (!getfile(hdlg, "Hard disc image (*.IMA;*.IMG;*.VHD)\0*.IMA;*.IMG;*.VHD\0All files (*.*)\0*.*\0", ""))
|
||||
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)
|
||||
@@ -660,14 +892,35 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR
|
||||
MessageBox(ghwnd,"Can't open file for read","86Box error",MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
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;
|
||||
|
||||
if (DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, hdsize_dlgproc) == 1)
|
||||
|
||||
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, "%i", hd_new_spt);
|
||||
|
||||
Reference in New Issue
Block a user