Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions AltairZ80/s100_64fdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ extern t_stat set_iobase(UNIT *uptr, int32 val, CONST char *cptr, void *desc);
extern t_stat show_iobase(FILE *st, UNIT *uptr, int32 val, CONST void *desc);
extern uint32 sim_map_resource(uint32 baseaddr, uint32 size, uint32 resource_type,
int32 (*routine)(const int32, const int32, const int32), const char* name, uint8 unmap);
void wd179x_set_rpm(int rpm);

static t_stat cromfdc_svc (UNIT *uptr);

Expand Down Expand Up @@ -1586,8 +1587,10 @@ static int32 cromfdc_control(const int32 port, const int32 io, const int32 data)
}
if(data & CROMFDC_CTRL_MAXI) {
wd179x_infop->drivetype = 8;
wd179x_set_rpm(360);
} else {
wd179x_infop->drivetype = 5;
wd179x_set_rpm(300);
}

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

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);

} else { /* I/O Read */
result = (crofdc_boot) ? 0 : CROMFDC_FLAG_BOOT;
result |= (wd179x_infop->intrq) ? CROMFDC_FLAG_EOJ : 0;
Expand Down
40 changes: 31 additions & 9 deletions AltairZ80/wd179x.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ typedef union {
typedef struct {
UNIT *uptr;
DISK_INFO *imd;
uint8 ntracks; /* number of tracks */
uint8 nheads; /* number of heads */
uint32 sectsize; /* sector size, not including pre/postamble */
uint8 track; /* Current Track */
uint8 ready; /* Is drive ready? */
uint8 ntracks; /* number of tracks */
uint8 nheads; /* number of heads */
uint32 sectsize; /* sector size, not including pre/postamble */
uint8 track; /* Current Track */
uint8 ready; /* Is drive ready? */
int rpm; /* Drive RPM */
} WD179X_DRIVE_INFO;

typedef struct {
Expand Down Expand Up @@ -338,6 +339,14 @@ static t_stat wd179x_reset(DEVICE *dptr)
return SCPE_OK;
}

void wd179x_set_rpm(int rpm)
{
if (wd179x_info->sel_drive > WD179X_MAX_DRIVES) {
return;
}
wd179x_info->drive[wd179x_info->sel_drive & 3].rpm = rpm;
}

void wd179x_connect_external_fifo(uint16 fifo_len, uint8* storage)
{
wd179x_info->external_fifo_len = fifo_len;
Expand Down Expand Up @@ -1210,11 +1219,24 @@ static uint8 Do1793Command(uint8 cCommand)
if (cCommand & 0x04) {
wd179x_info->index_pulse_wait = TRUE;
if (wd179x_info->sel_drive < WD179X_MAX_DRIVES) {
if (pDrive->uptr->u3 == IMAGE_TYPE_IMD) {
sim_activate (wd179x_unit, ((wd179x_info->drive[wd179x_info->sel_drive].imd->ntracks % 77) == 0) ? CROMFDC_8IN_ROT : CROMFDC_5IN_ROT); /* Generate INDEX pulse */
} else {
sim_activate(wd179x_unit, CROMFDC_8IN_ROT); /* Generate INDEX pulse */
int rot = 0;

switch (pDrive->rpm) {
case 300:
rot = CROMFDC_5IN_ROT;
break;
case 360:
rot = CROMFDC_8IN_ROT;
break;
default: /* RPM not set, infer from the disk image, if possible. */
if (pDrive->uptr->u3 == IMAGE_TYPE_IMD) {
rot = ((wd179x_info->drive[wd179x_info->sel_drive].imd->ntracks % 77) == 0) ? CROMFDC_8IN_ROT : CROMFDC_5IN_ROT;
}
else {
rot = CROMFDC_8IN_ROT;
}
}
sim_activate(wd179x_unit, rot); /* Generate INDEX pulse */
}
} else {
wd179x_info->intrq = 1;
Expand Down
Loading