Exemplo n.º 1
0
void legacy_floppy_image_device::device_start()
{
	floppy_drive *floppy = get_safe_token( this );
	floppy->config = (const floppy_interface*)static_config();
	floppy_drive_init(this);

	floppy->drive_id = floppy_get_drive(this);
	floppy->active = FALSE;

	/* resolve callbacks */
	floppy->out_idx_func.resolve(floppy->config->out_idx_func, *this);
	floppy->in_mon_func.resolve(floppy->config->in_mon_func, *this);
	floppy->out_tk00_func.resolve(floppy->config->out_tk00_func, *this);
	floppy->out_wpt_func.resolve(floppy->config->out_wpt_func, *this);
	floppy->out_rdy_func.resolve(floppy->config->out_rdy_func, *this);
//  floppy->out_dskchg_func.resolve(floppy->config->out_dskchg_func, *this);

	/* by default we are not write-protected */
	floppy->wpt = ASSERT_LINE;
	floppy->out_wpt_func(floppy->wpt);

	/* not at track 0 */
	floppy->tk00 = ASSERT_LINE;
	floppy->out_tk00_func(floppy->tk00);

	/* motor off */
	floppy->mon = ASSERT_LINE;

	/* disk changed */
	floppy->dskchg = CLEAR_LINE;
//  floppy->out_dskchg_func(floppy->dskchg);
}
Exemplo n.º 2
0
void legacy_floppy_image_device::device_start()
{
	floppy_drive_init();

	m_drive_id = floppy_get_drive(this);
	m_active = FALSE;

	/* resolve callbacks */
	m_out_idx_func.resolve_safe();
	//m_in_mon_func.resolve(m_config->in_mon_func, *this);
	//m_out_tk00_func.resolve(m_config->out_tk00_func, *this);
	//m_out_wpt_func.resolve(m_config->out_wpt_func, *this);
	//m_out_rdy_func.resolve(m_config->out_rdy_func, *this);
//  m_out_dskchg_func.resolve(m_config->out_dskchg_func, *this);

	/* by default we are not write-protected */
	m_wpt = ASSERT_LINE;
	//m_out_wpt_func(m_wpt);

	/* not at track 0 */
	m_tk00 = ASSERT_LINE;
	//m_out_tk00_func(m_tk00);

	/* motor off */
	m_mon = ASSERT_LINE;

	/* disk changed */
	m_dskchg = CLEAR_LINE;
//  m_out_dskchg_func(m_dskchg);
}
Exemplo n.º 3
0
int thomson_state::thmfc_floppy_find_sector( chrn_id* dst )
{
	legacy_floppy_image_device* img = thmfc_floppy_image();
	chrn_id id;
	int r = 0;

	/* scan track, try 4 revolutions */
	while ( r < 4 )
	{
		if ( img->floppy_drive_get_next_id( thmfc1->side, &id ) )
		{
			if ( id.C == thmfc1->track &&
					id.R == thmfc1->sector &&
					(128 << id.N) == thmfc1->sector_size
					/* check side ?  id.H == thmfc1->side */ )
			{
				if ( dst )
					memcpy( dst, &id, sizeof( chrn_id ) );
				thmfc1->stat0 = THMFC1_STAT0_BYTE_READY_POL;
				LOG (( "thmfc_floppy_find_sector: sector found C=%i H=%i R=%i N=%i\n", id.C, id.H, id.R, id.N ));
				return 1;
			}
		}

		if ( img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) )
			r++;
	}

	thmfc1->stat0 = THMFC1_STAT0_CRC_ERROR | THMFC1_STAT0_FINISHED;
	LOG (( "thmfc_floppy_find_sector: sector not found drive=%i track=%i sector=%i\n", floppy_get_drive(img), thmfc1->track, thmfc1->sector ));
	return 0;
}
Exemplo n.º 4
0
/***************************************************************************
    FLOPPY DRIVE
***************************************************************************/
static void vtech1_load_proc(device_image_interface &image)
{
    vtech1_state *vtech1 = image.device().machine().driver_data<vtech1_state>();
    int id = floppy_get_drive(&image.device());

    if (!image.is_readonly())
        vtech1->m_fdc_wrprot[id] = 0x00;
    else
        vtech1->m_fdc_wrprot[id] = 0x80;
}
Exemplo n.º 5
0
static void svi318_load_proc(device_image_interface &image)
{
	svi318_state *state = image.device().machine().driver_data<svi318_state>();
	int size;
	int id = floppy_get_drive(&image.device());

	size = image.length();
	switch (size)
	{
	case 172032:	/* SVI-328 SSDD */
		state->m_fdc.heads[id] = 1;
		break;
	case 346112:	/* SVI-328 DSDD */
		state->m_fdc.heads[id] = 2;
		break;
	case 348160:	/* SVI-728 DSDD CP/M */
		state->m_fdc.heads[id] = 2;
		break;
	}
}
Exemplo n.º 6
0
static void atari_load_proc(device_image_interface &image)
{
	atari_fdc_t *fdc = get_safe_token(image.device().owner());
	int id = floppy_get_drive(image);
	int size, i;
	const char *ext;

	fdc->drv[id].image = auto_alloc_array(image.device().machine(),UINT8,MAXSIZE);
	if (!fdc->drv[id].image)
		return;

	/* tell whether the image is writable */
	fdc->drv[id].mode = !image.is_readonly();
	/* set up image if it has been created */
	if (image.has_been_created())
	{
		int sector;
		char buff[256];
		memset(buff, 0, sizeof(buff));
		/* default to 720 sectors */
		for( sector = 0; sector < 720; sector++ )
			image.fwrite(buff, 256);
		image.fseek(0, SEEK_SET);
	}

	size = image.fread(fdc->drv[id].image, MAXSIZE);

	if( size <= 0 )
	{
		fdc->drv[id].image = NULL;
		return;
	}


	/* re allocate the buffer; we don't want to be too lazy ;) */
	//fdc->drv[id].image = (UINT8*)image.image_realloc(fdc->drv[id].image, size);

	ext = image.filetype();

	// hack alert, this means we can only load ATR via the softlist at the moment, image.filetype reutrns NULL :/
	if (image.software_entry() != NULL) ext="ATR";

	/* no extension: assume XFD format (no header) */
	if (!ext)
	{
		fdc->drv[id].type = FORMAT_XFD;
		fdc->drv[id].header_skip = 0;
	}
	else
	/* XFD extension */
	if( toupper(ext[0])=='X' && toupper(ext[1])=='F' && toupper(ext[2])=='D' )
	{
		fdc->drv[id].type = FORMAT_XFD;
		fdc->drv[id].header_skip = 0;
	}
	else
	/* ATR extension */
	if( toupper(ext[0])=='A' && toupper(ext[1])=='T' && toupper(ext[2])=='R' )
	{
		fdc->drv[id].type = FORMAT_ATR;
		fdc->drv[id].header_skip = 16;
	}
	else
	/* DSK extension */
	if( toupper(ext[0])=='D' && toupper(ext[1])=='S' && toupper(ext[2])=='K' )
	{
		fdc->drv[id].type = FORMAT_DSK;
		fdc->drv[id].header_skip = sizeof(dsk_format);
	}
	else
	{
		fdc->drv[id].type = FORMAT_XFD;
		fdc->drv[id].header_skip = 0;
	}

	if( fdc->drv[id].type == FORMAT_ATR &&
		(fdc->drv[id].image[0] != 0x96 || fdc->drv[id].image[1] != 0x02) )
	{
		fdc->drv[id].type = FORMAT_XFD;
		fdc->drv[id].header_skip = 0;
	}


	switch (fdc->drv[id].type)
	{
	/* XFD or unknown format: find a matching size from the table */
	case FORMAT_XFD:
		for( i = 0; xfd_formats[i].size; i++ )
		{
			if( size == xfd_formats[i].size )
			{
				fdc->drv[id].density = xfd_formats[i].dsk.density;
				fdc->drv[id].tracks = xfd_formats[i].dsk.tracks;
				fdc->drv[id].spt = xfd_formats[i].dsk.spt;
				fdc->drv[id].heads = (xfd_formats[i].dsk.doublesided) ? 2 : 1;
				fdc->drv[id].bseclen = 128;
				fdc->drv[id].seclen = 256 * xfd_formats[i].dsk.seclen_hi + xfd_formats[i].dsk.seclen_lo;
				fdc->drv[id].sectors = fdc->drv[id].tracks * fdc->drv[id].heads * fdc->drv[id].spt;
				break;
			}
		}
		break;
	/* ATR format: find a size including the 16 bytes header */
	case FORMAT_ATR:
		{
			int s;
			fdc->drv[id].bseclen = 128;
			/* get sectors from ATR header */
			s = (size - 16) / 128;
			/* 3 + odd number of sectors ? */
			if ( fdc->drv[id].image[4] == 128 || (s % 18) == 0 || (s % 26) == 0 || ((s - 3) % 1) != 0 )
			{
				fdc->drv[id].sectors = s;
				fdc->drv[id].seclen = 128;
				/* sector size 128 or count not evenly dividable by 26 ? */
				if( fdc->drv[id].seclen == 128 || (s % 26) != 0 )
				{
					/* yup! single density */
					fdc->drv[id].density = 0;
					fdc->drv[id].spt = 18;
					fdc->drv[id].heads = 1;
					fdc->drv[id].tracks = s / 18;
					if( s % 18 != 0 )
						fdc->drv[id].tracks += 1;
					if( fdc->drv[id].tracks % 2 == 0 && fdc->drv[id].tracks > 80 )
					{
						fdc->drv[id].heads = 2;
						fdc->drv[id].tracks /= 2;
					}
				}
				else
				{
					/* yes: medium density */
					fdc->drv[id].density = 0;
					fdc->drv[id].spt = 26;
					fdc->drv[id].heads = 1;
					fdc->drv[id].tracks = s / 26;
					if( s % 26 != 0 )
						fdc->drv[id].tracks += 1;
					if( fdc->drv[id].tracks % 2 == 0 && fdc->drv[id].tracks > 80 )
					{
						fdc->drv[id].heads = 2;
						fdc->drv[id].tracks /= 2;
					}
				}
			}
			else
			{
				/* it's double density */
				s = (s - 3) / 2 + 3;
				fdc->drv[id].sectors = s;
				fdc->drv[id].density = 2;
				fdc->drv[id].seclen = 256;
				fdc->drv[id].spt = 18;
				fdc->drv[id].heads = 1;
				fdc->drv[id].tracks = s / 18;
				if( s % 18 != 0 )
					fdc->drv[id].tracks += 1;
				if( fdc->drv[id].tracks % 2 == 0 && fdc->drv[id].tracks > 80 )
				{
					fdc->drv[id].heads = 2;
					fdc->drv[id].tracks /= 2;
				}
			}
		}
		break;
	/* DSK format: it's all in the header */
	case FORMAT_DSK:
		{
			dsk_format *dsk = (dsk_format *) fdc->drv[id].image;

			fdc->drv[id].tracks = dsk->tracks;
			fdc->drv[id].spt = dsk->spt;
			fdc->drv[id].heads = (dsk->doublesided) ? 2 : 1;
			fdc->drv[id].seclen = 256 * dsk->seclen_hi + dsk->seclen_lo;
			fdc->drv[id].bseclen = fdc->drv[id].seclen;
			fdc->drv[id].sectors = fdc->drv[id].tracks * fdc->drv[id].heads * fdc->drv[id].spt;
		}
		break;
	}
	logerror("atari opened floppy '%s', %d sectors (%d %s%s) %d bytes/sector\n",
			image.filename(),
			fdc->drv[id].sectors,
			fdc->drv[id].tracks,
			(fdc->drv[id].heads == 1) ? "SS" : "DS",
			(fdc->drv[id].density == 0) ? "SD" : (fdc->drv[id].density == 1) ? "MD" : "DD",
			fdc->drv[id].seclen);
	return;
}
Exemplo n.º 7
0
void atari_fdc_device::atari_load_proc(device_image_interface &image, bool is_created)
{
    int id = floppy_get_drive(image);
    int size, i;

    m_drv[id].image = std::make_unique<uint8_t[]>(MAXSIZE);
    if (!m_drv[id].image)
        return;

    /* tell whether the image is writable */
    m_drv[id].mode = !image.is_readonly();
    /* set up image if it has been created */
    if (is_created)
    {
        int sector;
        char buff[256];
        memset(buff, 0, sizeof(buff));
        /* default to 720 sectors */
        for( sector = 0; sector < 720; sector++ )
            image.fwrite(buff, 256);
        image.fseek(0, SEEK_SET);
    }

    size = image.fread(m_drv[id].image.get(), MAXSIZE);

    if( size <= 0 )
    {
        m_drv[id].image = nullptr;
        return;
    }


    /* re allocate the buffer; we don't want to be too lazy ;) */
    //m_drv[id].image = (uint8_t*)image.image_realloc(m_drv[id].image, size);

    // hack alert, this means we can only load ATR via the softlist at the moment, image.filetype returns "" :/
    bool is_softlist_entry = image.software_entry() != nullptr;

    /* no extension: assume XFD format (no header) */
    if (image.is_filetype("") && !is_softlist_entry)
    {
        m_drv[id].type = FORMAT_XFD;
        m_drv[id].header_skip = 0;
    }
    else
        /* XFD extension */
        if( image.is_filetype("xfd") )
        {
            m_drv[id].type = FORMAT_XFD;
            m_drv[id].header_skip = 0;
        }
        else
            /* ATR extension */
            if( image.is_filetype("atr") || is_softlist_entry)
            {
                m_drv[id].type = FORMAT_ATR;
                m_drv[id].header_skip = 16;
            }
            else
                /* DSK extension */
                if( image.is_filetype("dsk") )
                {
                    m_drv[id].type = FORMAT_DSK;
                    m_drv[id].header_skip = sizeof(atari_dsk_format);
                }
                else
                {
                    m_drv[id].type = FORMAT_XFD;
                    m_drv[id].header_skip = 0;
                }

    if( m_drv[id].type == FORMAT_ATR &&
            (m_drv[id].image[0] != 0x96 || m_drv[id].image[1] != 0x02) )
    {
        m_drv[id].type = FORMAT_XFD;
        m_drv[id].header_skip = 0;
    }


    switch (m_drv[id].type)
    {
    /* XFD or unknown format: find a matching size from the table */
    case FORMAT_XFD:
        for( i = 0; xfd_formats[i].size; i++ )
        {
            if( size == xfd_formats[i].size )
            {
                m_drv[id].density = xfd_formats[i].dsk.density;
                m_drv[id].tracks = xfd_formats[i].dsk.tracks;
                m_drv[id].spt = xfd_formats[i].dsk.spt;
                m_drv[id].heads = (xfd_formats[i].dsk.doublesided) ? 2 : 1;
                m_drv[id].bseclen = 128;
                m_drv[id].seclen = 256 * xfd_formats[i].dsk.seclen_hi + xfd_formats[i].dsk.seclen_lo;
                m_drv[id].sectors = m_drv[id].tracks * m_drv[id].heads * m_drv[id].spt;
                break;
            }
        }
        break;
    /* ATR format: find a size including the 16 bytes header */
    case FORMAT_ATR:
    {
        int s;
        m_drv[id].bseclen = 128;
        /* get sectors from ATR header */
        s = (size - 16) / 128;
        /* 3 + odd number of sectors ? */
        if ( m_drv[id].image[4] == 128 || (s % 18) == 0 || (s % 26) == 0 || ((s - 3) % 1) != 0 )
        {
            m_drv[id].sectors = s;
            m_drv[id].seclen = 128;
            /* sector size 128 or count not evenly dividable by 26 ? */
            if( m_drv[id].seclen == 128 || (s % 26) != 0 )
            {
                /* yup! single density */
                m_drv[id].density = 0;
                m_drv[id].spt = 18;
                m_drv[id].heads = 1;
                m_drv[id].tracks = s / 18;
                if( s % 18 != 0 )
                    m_drv[id].tracks += 1;
                if( m_drv[id].tracks % 2 == 0 && m_drv[id].tracks > 80 )
                {
                    m_drv[id].heads = 2;
                    m_drv[id].tracks /= 2;
                }
            }
            else
            {
                /* yes: medium density */
                m_drv[id].density = 0;
                m_drv[id].spt = 26;
                m_drv[id].heads = 1;
                m_drv[id].tracks = s / 26;
                if( s % 26 != 0 )
                    m_drv[id].tracks += 1;
                if( m_drv[id].tracks % 2 == 0 && m_drv[id].tracks > 80 )
                {
                    m_drv[id].heads = 2;
                    m_drv[id].tracks /= 2;
                }
            }
        }
        else
        {
            /* it's double density */
            s = (s - 3) / 2 + 3;
            m_drv[id].sectors = s;
            m_drv[id].density = 2;
            m_drv[id].seclen = 256;
            m_drv[id].spt = 18;
            m_drv[id].heads = 1;
            m_drv[id].tracks = s / 18;
            if( s % 18 != 0 )
                m_drv[id].tracks += 1;
            if( m_drv[id].tracks % 2 == 0 && m_drv[id].tracks > 80 )
            {
                m_drv[id].heads = 2;
                m_drv[id].tracks /= 2;
            }
        }
    }
    break;
    /* DSK format: it's all in the header */
    case FORMAT_DSK:
    {
        atari_dsk_format *dsk = (atari_dsk_format *) m_drv[id].image.get();

        m_drv[id].tracks = dsk->tracks;
        m_drv[id].spt = dsk->spt;
        m_drv[id].heads = (dsk->doublesided) ? 2 : 1;
        m_drv[id].seclen = 256 * dsk->seclen_hi + dsk->seclen_lo;
        m_drv[id].bseclen = m_drv[id].seclen;
        m_drv[id].sectors = m_drv[id].tracks * m_drv[id].heads * m_drv[id].spt;
    }
    break;
    }
    logerror("atari opened floppy '%s', %d sectors (%d %s%s) %d bytes/sector\n",
             image.filename(),
             m_drv[id].sectors,
             m_drv[id].tracks,
             (m_drv[id].heads == 1) ? "SS" : "DS",
             (m_drv[id].density == 0) ? "SD" : (m_drv[id].density == 1) ? "MD" : "DD",
             m_drv[id].seclen);
    return;
}
Exemplo n.º 8
0
static void fd800_unload_proc(device_image_interface &image)
{
	int unit = floppy_get_drive(&image.device());

	fd800.drv[unit].log_cylinder[0] = fd800.drv[unit].log_cylinder[1] = -1;
}