Skip to content

Commit 9e1cb61

Browse files
hhartepkoning2
authored andcommitted
AltairZ80: wd179x: Better support for 5.25-inch floppies.
1 parent 144bcf8 commit 9e1cb61

2 files changed

Lines changed: 35 additions & 9 deletions

File tree

AltairZ80/s100_64fdc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ extern t_stat set_iobase(UNIT *uptr, int32 val, CONST char *cptr, void *desc);
8282
extern t_stat show_iobase(FILE *st, UNIT *uptr, int32 val, CONST void *desc);
8383
extern uint32 sim_map_resource(uint32 baseaddr, uint32 size, uint32 resource_type,
8484
int32 (*routine)(const int32, const int32, const int32), const char* name, uint8 unmap);
85+
void wd179x_set_rpm(int rpm);
8586

8687
static t_stat cromfdc_svc (UNIT *uptr);
8788

@@ -1586,8 +1587,10 @@ static int32 cromfdc_control(const int32 port, const int32 io, const int32 data)
15861587
}
15871588
if(data & CROMFDC_CTRL_MAXI) {
15881589
wd179x_infop->drivetype = 8;
1590+
wd179x_set_rpm(360);
15891591
} else {
15901592
wd179x_infop->drivetype = 5;
1593+
wd179x_set_rpm(300);
15911594
}
15921595

15931596
if(data & CROMFDC_CTRL_MTRON) {
@@ -1611,6 +1614,7 @@ static int32 cromfdc_control(const int32 port, const int32 io, const int32 data)
16111614
}
16121615

16131616
sim_debug(DRIVE_MSG, &cromfdc_dev, "CROMFDC: " ADDRESS_FORMAT " WR CTRL: sel_drive=%d, drivetype=%d, motor=%d, dens=%d, aw=%d\n", PCX, wd179x_infop->sel_drive, wd179x_infop->drivetype, cromfdc_info->motor_on, wd179x_infop->ddens, cromfdc_info->autowait);
1617+
16141618
} else { /* I/O Read */
16151619
result = (crofdc_boot) ? 0 : CROMFDC_FLAG_BOOT;
16161620
result |= (wd179x_infop->intrq) ? CROMFDC_FLAG_EOJ : 0;

AltairZ80/wd179x.c

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@ typedef union {
9393
typedef struct {
9494
UNIT *uptr;
9595
DISK_INFO *imd;
96-
uint8 ntracks; /* number of tracks */
97-
uint8 nheads; /* number of heads */
98-
uint32 sectsize; /* sector size, not including pre/postamble */
99-
uint8 track; /* Current Track */
100-
uint8 ready; /* Is drive ready? */
96+
uint8 ntracks; /* number of tracks */
97+
uint8 nheads; /* number of heads */
98+
uint32 sectsize; /* sector size, not including pre/postamble */
99+
uint8 track; /* Current Track */
100+
uint8 ready; /* Is drive ready? */
101+
int rpm; /* Drive RPM */
101102
} WD179X_DRIVE_INFO;
102103

103104
typedef struct {
@@ -338,6 +339,14 @@ static t_stat wd179x_reset(DEVICE *dptr)
338339
return SCPE_OK;
339340
}
340341

342+
void wd179x_set_rpm(int rpm)
343+
{
344+
if (wd179x_info->sel_drive > WD179X_MAX_DRIVES) {
345+
return;
346+
}
347+
wd179x_info->drive[wd179x_info->sel_drive & 3].rpm = rpm;
348+
}
349+
341350
void wd179x_connect_external_fifo(uint16 fifo_len, uint8* storage)
342351
{
343352
wd179x_info->external_fifo_len = fifo_len;
@@ -1210,11 +1219,24 @@ static uint8 Do1793Command(uint8 cCommand)
12101219
if (cCommand & 0x04) {
12111220
wd179x_info->index_pulse_wait = TRUE;
12121221
if (wd179x_info->sel_drive < WD179X_MAX_DRIVES) {
1213-
if (pDrive->uptr->u3 == IMAGE_TYPE_IMD) {
1214-
sim_activate (wd179x_unit, ((wd179x_info->drive[wd179x_info->sel_drive].imd->ntracks % 77) == 0) ? CROMFDC_8IN_ROT : CROMFDC_5IN_ROT); /* Generate INDEX pulse */
1215-
} else {
1216-
sim_activate(wd179x_unit, CROMFDC_8IN_ROT); /* Generate INDEX pulse */
1222+
int rot = 0;
1223+
1224+
switch (pDrive->rpm) {
1225+
case 300:
1226+
rot = CROMFDC_5IN_ROT;
1227+
break;
1228+
case 360:
1229+
rot = CROMFDC_8IN_ROT;
1230+
break;
1231+
default: /* RPM not set, infer from the disk image, if possible. */
1232+
if (pDrive->uptr->u3 == IMAGE_TYPE_IMD) {
1233+
rot = ((wd179x_info->drive[wd179x_info->sel_drive].imd->ntracks % 77) == 0) ? CROMFDC_8IN_ROT : CROMFDC_5IN_ROT;
1234+
}
1235+
else {
1236+
rot = CROMFDC_8IN_ROT;
1237+
}
12171238
}
1239+
sim_activate(wd179x_unit, rot); /* Generate INDEX pulse */
12181240
}
12191241
} else {
12201242
wd179x_info->intrq = 1;

0 commit comments

Comments
 (0)