mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
dgnalpha: updated to use the new wd fdc
This commit is contained in:
parent
51709eef04
commit
0afa682456
@ -373,6 +373,8 @@ project "formats"
|
||||
MAME_DIR .. "src/lib/formats/uef_cas.h",
|
||||
MAME_DIR .. "src/lib/formats/upd765_dsk.c",
|
||||
MAME_DIR .. "src/lib/formats/upd765_dsk.h",
|
||||
MAME_DIR .. "src/lib/formats/vdk_dsk.c",
|
||||
MAME_DIR .. "src/lib/formats/vdk_dsk.h",
|
||||
MAME_DIR .. "src/lib/formats/victor9k_dsk.c",
|
||||
MAME_DIR .. "src/lib/formats/victor9k_dsk.h",
|
||||
MAME_DIR .. "src/lib/formats/vg5k_cas.c",
|
||||
|
158
src/lib/formats/vdk_dsk.c
Normal file
158
src/lib/formats/vdk_dsk.c
Normal file
@ -0,0 +1,158 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Dirk Best
|
||||
/***************************************************************************
|
||||
|
||||
VDK
|
||||
|
||||
Disk image format
|
||||
|
||||
Used by Paul Burgin's PC-Dragon emulator
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "vdk_dsk.h"
|
||||
|
||||
vdk_format::vdk_format() : wd177x_format(NULL)
|
||||
{
|
||||
m_format.form_factor = floppy_image::FF_525;
|
||||
m_format.encoding = floppy_image::MFM;
|
||||
m_format.cell_size = 2000;
|
||||
m_format.sector_count = 18;
|
||||
// m_format.track_count = 40/80
|
||||
// m_format.head_count = 1/2
|
||||
m_format.sector_base_size = 256;
|
||||
m_format.sector_base_id = 1;
|
||||
m_format.gap_1 = 32;
|
||||
m_format.gap_2 = 24;
|
||||
m_format.gap_3 = 22;
|
||||
}
|
||||
|
||||
const char *vdk_format::name() const
|
||||
{
|
||||
return "vdk";
|
||||
}
|
||||
|
||||
const char *vdk_format::description() const
|
||||
{
|
||||
return "VDK disk image";
|
||||
}
|
||||
|
||||
const char *vdk_format::extensions() const
|
||||
{
|
||||
return "vdk";
|
||||
}
|
||||
|
||||
int vdk_format::identify(io_generic *io, UINT32 form_factor)
|
||||
{
|
||||
UINT8 id[2];
|
||||
io_generic_read(io, id, 0, 2);
|
||||
|
||||
if (id[0] == 'd' && id[1] == 'k')
|
||||
return 50;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool vdk_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
|
||||
{
|
||||
UINT8 header[0x100];
|
||||
io_generic_read(io, header, 0, 100);
|
||||
int header_size = header[3] * 0x100 + header[2];
|
||||
|
||||
m_format.track_count = header[8];
|
||||
m_format.head_count = header[9];
|
||||
|
||||
switch (m_format.head_count)
|
||||
{
|
||||
case 1: m_format.variant = floppy_image::SSDD; break;
|
||||
case 2: m_format.variant = floppy_image::DSDD; break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
floppy_image_format_t::desc_e *desc;
|
||||
int current_size;
|
||||
int end_gap_index;
|
||||
|
||||
desc = get_desc_mfm(m_format, current_size, end_gap_index);
|
||||
|
||||
int total_size = 200000000 / m_format.cell_size;
|
||||
int remaining_size = total_size - current_size;
|
||||
if (remaining_size < 0)
|
||||
throw emu_fatalerror("vdk_format: Incorrect track layout, max_size=%d, current_size=%d", total_size, current_size);
|
||||
|
||||
// fixup the end gap
|
||||
desc[end_gap_index].p2 = remaining_size / 16;
|
||||
desc[end_gap_index + 1].p2 = remaining_size & 15;
|
||||
desc[end_gap_index + 1].p1 >>= 16 - (remaining_size & 15);
|
||||
|
||||
int track_size = compute_track_size(m_format);
|
||||
|
||||
UINT8 sectdata[40*512];
|
||||
desc_s sectors[40];
|
||||
build_sector_description(m_format, sectdata, sectors);
|
||||
|
||||
for(int track=0; track < m_format.track_count; track++)
|
||||
for(int head=0; head < m_format.head_count; head++) {
|
||||
io_generic_read(io, sectdata, header_size + get_image_offset(m_format, head, track), track_size);
|
||||
generate_track(desc, track, head, sectors, m_format.sector_count, total_size, image);
|
||||
}
|
||||
|
||||
image->set_variant(m_format.variant);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool vdk_format::save(io_generic *io, floppy_image *image)
|
||||
{
|
||||
int tracks, heads;
|
||||
image->get_actual_geometry(tracks, heads);
|
||||
|
||||
m_format.track_count = tracks;
|
||||
m_format.head_count = heads;
|
||||
|
||||
switch (m_format.head_count)
|
||||
{
|
||||
case 1: m_format.variant = floppy_image::SSDD; break;
|
||||
case 2: m_format.variant = floppy_image::DSDD; break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
// write header
|
||||
UINT8 header[12];
|
||||
|
||||
header[0] = 'd';
|
||||
header[1] = 'k';
|
||||
header[2] = sizeof(header) % 0x100;
|
||||
header[3] = sizeof(header) / 0x100;
|
||||
header[4] = 0x10;
|
||||
header[5] = 0x10;
|
||||
header[6] = 'M';
|
||||
header[7] = 0x01;
|
||||
header[8] = tracks;
|
||||
header[9] = heads;
|
||||
header[10] = 0;
|
||||
header[11] = 0;
|
||||
|
||||
io_generic_write(io, header, 0, sizeof(header));
|
||||
|
||||
// write disk data
|
||||
int track_size = compute_track_size(m_format);
|
||||
|
||||
UINT8 sectdata[40*512];
|
||||
desc_s sectors[40];
|
||||
build_sector_description(m_format, sectdata, sectors);
|
||||
|
||||
for (int track = 0; track < m_format.track_count; track++)
|
||||
{
|
||||
for (int head = 0; head < m_format.head_count; head++)
|
||||
{
|
||||
extract_sectors(image, m_format, sectors, track, head);
|
||||
io_generic_write(io, sectdata, sizeof(header) + get_image_offset(m_format, head, track), track_size);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const floppy_format_type FLOPPY_VDK_FORMAT = &floppy_image_format_creator<vdk_format>;
|
39
src/lib/formats/vdk_dsk.h
Normal file
39
src/lib/formats/vdk_dsk.h
Normal file
@ -0,0 +1,39 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Dirk Best
|
||||
/***************************************************************************
|
||||
|
||||
VDK
|
||||
|
||||
Disk image format
|
||||
|
||||
Used by Paul Burgin's PC-Dragon emulator
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __VDK_DSK_H__
|
||||
#define __VDK_DSK_H__
|
||||
|
||||
#include "wd177x_dsk.h"
|
||||
|
||||
class vdk_format : public wd177x_format
|
||||
{
|
||||
public:
|
||||
vdk_format();
|
||||
|
||||
virtual const char *name() const;
|
||||
virtual const char *description() const;
|
||||
virtual const char *extensions() const;
|
||||
|
||||
virtual int identify(io_generic *io, UINT32 form_factor);
|
||||
virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
|
||||
virtual bool save(io_generic *io, floppy_image *image);
|
||||
|
||||
private:
|
||||
format m_format;
|
||||
};
|
||||
|
||||
extern const floppy_format_type FLOPPY_VDK_FORMAT;
|
||||
|
||||
#endif // __VDK_DSK_H__
|
@ -18,7 +18,8 @@
|
||||
#include "bus/coco/coco_pak.h"
|
||||
#include "bus/coco/coco_fdc.h"
|
||||
#include "bus/coco/coco_multi.h"
|
||||
#include "formats/coco_dsk.h"
|
||||
#include "formats/vdk_dsk.h"
|
||||
#include "formats/dmk_dsk.h"
|
||||
#include "imagedev/flopdrv.h"
|
||||
|
||||
|
||||
@ -125,12 +126,19 @@ static SLOT_INTERFACE_START(dragon_cart)
|
||||
SLOT_INTERFACE("pak", COCO_PAK)
|
||||
SLOT_INTERFACE_END
|
||||
|
||||
static const floppy_interface coco_floppy_interface =
|
||||
{
|
||||
FLOPPY_STANDARD_5_25_DSHD,
|
||||
LEGACY_FLOPPY_OPTIONS_NAME(coco),
|
||||
NULL
|
||||
};
|
||||
FLOPPY_FORMATS_MEMBER( dragon_alpha_state::dragon_formats )
|
||||
FLOPPY_VDK_FORMAT,
|
||||
FLOPPY_DMK_FORMAT
|
||||
FLOPPY_FORMATS_END
|
||||
|
||||
static SLOT_INTERFACE_START( dragon_floppies )
|
||||
SLOT_INTERFACE("sssd", FLOPPY_525_SSSD)
|
||||
SLOT_INTERFACE("sd", FLOPPY_525_SD)
|
||||
SLOT_INTERFACE("ssdd", FLOPPY_525_SSDD)
|
||||
SLOT_INTERFACE("dd", FLOPPY_525_DD)
|
||||
SLOT_INTERFACE("ssqd", FLOPPY_525_SSQD)
|
||||
SLOT_INTERFACE("qd", FLOPPY_525_QD)
|
||||
SLOT_INTERFACE_END
|
||||
|
||||
static MACHINE_CONFIG_START( dragon_base, dragon_state )
|
||||
// basic machine hardware
|
||||
@ -237,12 +245,14 @@ static MACHINE_CONFIG_DERIVED_CLASS( dgnalpha, dragon_base, dragon_alpha_state )
|
||||
MCFG_MOS6551_XTAL(XTAL_1_8432MHz)
|
||||
|
||||
// floppy
|
||||
MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(coco_floppy_interface)
|
||||
MCFG_WD2797x_ADD(WD2797_TAG, XTAL_1MHz)
|
||||
MCFG_WD_FDC_INTRQ_CALLBACK(WRITELINE(dragon_alpha_state, fdc_intrq_w))
|
||||
MCFG_WD_FDC_DRQ_CALLBACK(WRITELINE(dragon_alpha_state, fdc_drq_w))
|
||||
|
||||
MCFG_DEVICE_ADD(WD2797_TAG, WD2797, 0)
|
||||
MCFG_WD17XX_DEFAULT_DRIVE4_TAGS
|
||||
MCFG_WD17XX_INTRQ_CALLBACK(WRITELINE(dragon_alpha_state, fdc_intrq_w))
|
||||
MCFG_WD17XX_DRQ_CALLBACK(WRITELINE(dragon_alpha_state, fdc_drq_w))
|
||||
MCFG_FLOPPY_DRIVE_ADD(WD2797_TAG ":0", dragon_floppies, "qd", dragon_alpha_state::dragon_formats)
|
||||
MCFG_FLOPPY_DRIVE_ADD(WD2797_TAG ":1", dragon_floppies, "qd", dragon_alpha_state::dragon_formats)
|
||||
MCFG_FLOPPY_DRIVE_ADD(WD2797_TAG ":2", dragon_floppies, "qd", dragon_alpha_state::dragon_formats)
|
||||
MCFG_FLOPPY_DRIVE_ADD(WD2797_TAG ":3", dragon_floppies, "qd", dragon_alpha_state::dragon_formats)
|
||||
|
||||
// sound hardware
|
||||
MCFG_SOUND_ADD(AY8912_TAG, AY8912, 1000000)
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include "includes/dragon.h"
|
||||
#include "sound/ay8910.h"
|
||||
#include "machine/wd17xx.h"
|
||||
#include "machine/wd_fdc.h"
|
||||
|
||||
|
||||
|
||||
@ -42,13 +42,24 @@ public:
|
||||
: dragon64_state(mconfig, type, tag),
|
||||
m_pia_2(*this, PIA2_TAG),
|
||||
m_ay8912(*this, AY8912_TAG),
|
||||
m_fdc(*this, WD2797_TAG)
|
||||
m_fdc(*this, WD2797_TAG),
|
||||
m_floppy0(*this, WD2797_TAG ":0"),
|
||||
m_floppy1(*this, WD2797_TAG ":1"),
|
||||
m_floppy2(*this, WD2797_TAG ":2"),
|
||||
m_floppy3(*this, WD2797_TAG ":3")
|
||||
{
|
||||
}
|
||||
|
||||
DECLARE_FLOPPY_FORMATS(dragon_formats);
|
||||
|
||||
required_device<pia6821_device> m_pia_2;
|
||||
required_device<ay8912_device> m_ay8912;
|
||||
required_device<wd2797_device> m_fdc;
|
||||
required_device<wd2797_t> m_fdc;
|
||||
required_device<floppy_connector> m_floppy0;
|
||||
required_device<floppy_connector> m_floppy1;
|
||||
required_device<floppy_connector> m_floppy2;
|
||||
required_device<floppy_connector> m_floppy3;
|
||||
|
||||
|
||||
/* pia2 */
|
||||
DECLARE_WRITE8_MEMBER( pia2_pa_w );
|
||||
|
@ -161,6 +161,7 @@ READ8_MEMBER( dragon_alpha_state::ff20_read )
|
||||
result = m_fdc->status_r(space, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -196,10 +197,7 @@ WRITE8_MEMBER( dragon_alpha_state::ff20_write )
|
||||
m_fdc->track_w(space, 0, data);
|
||||
break;
|
||||
case 15:
|
||||
m_fdc->command_w(space, 0, data);
|
||||
|
||||
/* disk head is encoded in the command byte */
|
||||
m_fdc->set_side((data & 0x02) ? 1 : 0);
|
||||
m_fdc->cmd_w(space, 0, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -316,21 +314,24 @@ WRITE8_MEMBER( dragon_alpha_state::psg_porta_write )
|
||||
/* Bits 0..3 are the drive select lines for the internal floppy interface */
|
||||
/* Bit 4 is the motor on, in the real hardware these are inverted on their way to the drive */
|
||||
/* Bits 5,6,7 are connected to /DDEN, ENP and 5/8 on the WD2797 */
|
||||
switch (data & 0xF)
|
||||
{
|
||||
case(0x01) :
|
||||
m_fdc->set_drive(0);
|
||||
break;
|
||||
case(0x02) :
|
||||
m_fdc->set_drive(1);
|
||||
break;
|
||||
case(0x04) :
|
||||
m_fdc->set_drive(2);
|
||||
break;
|
||||
case(0x08) :
|
||||
m_fdc->set_drive(3);
|
||||
break;
|
||||
}
|
||||
|
||||
floppy_image_device *floppy = NULL;
|
||||
|
||||
if (BIT(data, 0)) floppy = m_floppy0->get_device();
|
||||
if (BIT(data, 1)) floppy = m_floppy1->get_device();
|
||||
if (BIT(data, 2)) floppy = m_floppy2->get_device();
|
||||
if (BIT(data, 3)) floppy = m_floppy3->get_device();
|
||||
|
||||
m_fdc->set_floppy(floppy);
|
||||
|
||||
// todo: turning the motor on with bit 4 isn't giving the drive enough
|
||||
// time to spin up, how does it work in hardware?
|
||||
if (m_floppy0->get_device()) m_floppy0->get_device()->mon_w(0);
|
||||
if (m_floppy1->get_device()) m_floppy1->get_device()->mon_w(0);
|
||||
if (m_floppy2->get_device()) m_floppy2->get_device()->mon_w(0);
|
||||
if (m_floppy3->get_device()) m_floppy3->get_device()->mon_w(0);
|
||||
|
||||
m_fdc->dden_w(BIT(data, 5));
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user