Modernized beta disk device. Still needs updating to modern fdc.(nw)

This commit is contained in:
Ivan Vangelista 2014-01-08 18:11:54 +00:00
parent 4548b75d5b
commit 233a37f1b2
5 changed files with 141 additions and 195 deletions

View File

@ -42,7 +42,7 @@ protected:
required_memory_bank m_bank2; required_memory_bank m_bank2;
required_memory_bank m_bank3; required_memory_bank m_bank3;
required_memory_bank m_bank4; required_memory_bank m_bank4;
required_device<device_t> m_beta; required_device<beta_disk_device> m_beta;
private: private:
UINT8 *m_p_ram; UINT8 *m_p_ram;
@ -54,12 +54,12 @@ DIRECT_UPDATE_MEMBER(atm_state::atm_direct)
{ {
UINT16 pc = m_maincpu->state_int(STATE_GENPCBASE); UINT16 pc = m_maincpu->state_int(STATE_GENPCBASE);
if (m_beta->started() && betadisk_is_active(m_beta)) if (m_beta->started() && m_beta->is_active())
{ {
if (pc >= 0x4000) if (pc >= 0x4000)
{ {
m_ROMSelection = BIT(m_port_7ffd_data, 4); m_ROMSelection = BIT(m_port_7ffd_data, 4);
betadisk_disable(m_beta); m_beta->disable();
m_bank1->set_base(&m_p_ram[0x10000 + (m_ROMSelection<<14)]); m_bank1->set_base(&m_p_ram[0x10000 + (m_ROMSelection<<14)]);
} }
} }
@ -67,7 +67,7 @@ DIRECT_UPDATE_MEMBER(atm_state::atm_direct)
{ {
m_ROMSelection = 3; m_ROMSelection = 3;
if (m_beta->started()) if (m_beta->started())
betadisk_enable(m_beta); m_beta->enable();
} }
if(address<=0x3fff) if(address<=0x3fff)
@ -95,7 +95,7 @@ void atm_state::atm_update_memory()
m_bank4->set_base(messram + ((m_port_7ffd_data & 0x07) * 0x4000)); m_bank4->set_base(messram + ((m_port_7ffd_data & 0x07) * 0x4000));
if (m_beta->started() && betadisk_is_active(m_beta) && !( m_port_7ffd_data & 0x10 ) ) if (m_beta->started() && m_beta->is_active() && !( m_port_7ffd_data & 0x10 ) )
m_ROMSelection = 3; m_ROMSelection = 3;
else else
/* ROM switching */ /* ROM switching */
@ -120,12 +120,12 @@ WRITE8_MEMBER(atm_state::atm_port_7ffd_w)
static ADDRESS_MAP_START (atm_io, AS_IO, 8, atm_state ) static ADDRESS_MAP_START (atm_io, AS_IO, 8, atm_state )
ADDRESS_MAP_UNMAP_HIGH ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x001f, 0x001f) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_status_r,betadisk_command_w) AM_MIRROR(0xff00) AM_RANGE(0x001f, 0x001f) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, status_r, command_w) AM_MIRROR(0xff00)
AM_RANGE(0x003f, 0x003f) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_track_r,betadisk_track_w) AM_MIRROR(0xff00) AM_RANGE(0x003f, 0x003f) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, track_r, track_w) AM_MIRROR(0xff00)
AM_RANGE(0x005f, 0x005f) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_sector_r,betadisk_sector_w) AM_MIRROR(0xff00) AM_RANGE(0x005f, 0x005f) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, sector_r, sector_w) AM_MIRROR(0xff00)
AM_RANGE(0x007f, 0x007f) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_data_r,betadisk_data_w) AM_MIRROR(0xff00) AM_RANGE(0x007f, 0x007f) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, data_r, data_w) AM_MIRROR(0xff00)
AM_RANGE(0x00fe, 0x00fe) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_RANGE(0x00fe, 0x00fe) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xff00) AM_MASK(0xffff)
AM_RANGE(0x00ff, 0x00ff) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_state_r, betadisk_param_w) AM_MIRROR(0xff00) AM_RANGE(0x00ff, 0x00ff) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, state_r, param_w) AM_MIRROR(0xff00)
AM_RANGE(0x4000, 0x4000) AM_WRITE(atm_port_7ffd_w) AM_MIRROR(0x3ffd) AM_RANGE(0x4000, 0x4000) AM_WRITE(atm_port_7ffd_w) AM_MIRROR(0x3ffd)
AM_RANGE(0x8000, 0x8000) AM_DEVWRITE("ay8912", ay8910_device, data_w) AM_MIRROR(0x3ffd) AM_RANGE(0x8000, 0x8000) AM_DEVWRITE("ay8912", ay8910_device, data_w) AM_MIRROR(0x3ffd)
AM_RANGE(0xc000, 0xc000) AM_DEVREADWRITE("ay8912", ay8910_device, data_r, address_w) AM_MIRROR(0x3ffd) AM_RANGE(0xc000, 0xc000) AM_DEVREADWRITE("ay8912", ay8910_device, data_r, address_w) AM_MIRROR(0x3ffd)
@ -142,8 +142,8 @@ MACHINE_RESET_MEMBER(atm_state,atm)
if (m_beta->started()) if (m_beta->started())
{ {
betadisk_enable(m_beta); m_beta->enable();
betadisk_clear_status(m_beta); m_beta->clear_status();
} }
space.set_direct_update_handler(direct_update_delegate(FUNC(atm_state::atm_direct), this)); space.set_direct_update_handler(direct_update_delegate(FUNC(atm_state::atm_direct), this));

View File

@ -30,7 +30,7 @@ protected:
required_memory_bank m_bank2; required_memory_bank m_bank2;
required_memory_bank m_bank3; required_memory_bank m_bank3;
required_memory_bank m_bank4; required_memory_bank m_bank4;
required_device<device_t> m_beta; required_device<beta_disk_device> m_beta;
private: private:
UINT8 *m_p_ram; UINT8 *m_p_ram;
void pentagon_update_memory(); void pentagon_update_memory();
@ -40,10 +40,10 @@ DIRECT_UPDATE_MEMBER(pentagon_state::pentagon_direct)
{ {
UINT16 pc = m_maincpu->pcbase(); UINT16 pc = m_maincpu->pcbase();
if (m_beta->started() && betadisk_is_active(m_beta) && (pc >= 0x4000)) if (m_beta->started() && m_beta->is_active() && (pc >= 0x4000))
{ {
m_ROMSelection = BIT(m_port_7ffd_data, 4); m_ROMSelection = BIT(m_port_7ffd_data, 4);
betadisk_disable(m_beta); m_beta->disable();
m_bank1->set_base(&m_p_ram[0x10000 + (m_ROMSelection<<14)]); m_bank1->set_base(&m_p_ram[0x10000 + (m_ROMSelection<<14)]);
} }
else else
@ -51,7 +51,7 @@ DIRECT_UPDATE_MEMBER(pentagon_state::pentagon_direct)
{ {
m_ROMSelection = 3; m_ROMSelection = 3;
if (m_beta->started()) if (m_beta->started())
betadisk_enable(m_beta); m_beta->enable();
} }
if (address<=0x3fff) if (address<=0x3fff)
@ -83,7 +83,7 @@ void pentagon_state::pentagon_update_memory()
m_bank4->set_base(messram + ((m_port_7ffd_data & 0x07) * 0x4000)); m_bank4->set_base(messram + ((m_port_7ffd_data & 0x07) * 0x4000));
if (m_beta->started() && betadisk_is_active(m_beta) && !( m_port_7ffd_data & 0x10 ) ) if (m_beta->started() && m_beta->is_active() && !( m_port_7ffd_data & 0x10 ) )
{ {
/* GLUK */ /* GLUK */
if (strcmp(machine().system().name, "pent1024")==0) if (strcmp(machine().system().name, "pent1024")==0)
@ -114,12 +114,12 @@ WRITE8_MEMBER(pentagon_state::pentagon_port_7ffd_w)
static ADDRESS_MAP_START (pentagon_io, AS_IO, 8, pentagon_state ) static ADDRESS_MAP_START (pentagon_io, AS_IO, 8, pentagon_state )
ADDRESS_MAP_UNMAP_HIGH ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x001f, 0x001f) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_status_r,betadisk_command_w) AM_MIRROR(0xff00) AM_RANGE(0x001f, 0x001f) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, status_r, command_w) AM_MIRROR(0xff00)
AM_RANGE(0x003f, 0x003f) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_track_r,betadisk_track_w) AM_MIRROR(0xff00) AM_RANGE(0x003f, 0x003f) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, track_r, track_w) AM_MIRROR(0xff00)
AM_RANGE(0x005f, 0x005f) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_sector_r,betadisk_sector_w) AM_MIRROR(0xff00) AM_RANGE(0x005f, 0x005f) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, sector_r, sector_w) AM_MIRROR(0xff00)
AM_RANGE(0x007f, 0x007f) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_data_r,betadisk_data_w) AM_MIRROR(0xff00) AM_RANGE(0x007f, 0x007f) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, data_r, data_w) AM_MIRROR(0xff00)
AM_RANGE(0x00fe, 0x00fe) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_RANGE(0x00fe, 0x00fe) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xff00) AM_MASK(0xffff)
AM_RANGE(0x00ff, 0x00ff) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_state_r, betadisk_param_w) AM_MIRROR(0xff00) AM_RANGE(0x00ff, 0x00ff) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, state_r, param_w) AM_MIRROR(0xff00)
AM_RANGE(0x4000, 0x4000) AM_WRITE(pentagon_port_7ffd_w) AM_MIRROR(0x3ffd) AM_RANGE(0x4000, 0x4000) AM_WRITE(pentagon_port_7ffd_w) AM_MIRROR(0x3ffd)
AM_RANGE(0x8000, 0x8000) AM_DEVWRITE("ay8912", ay8910_device, data_w) AM_MIRROR(0x3ffd) AM_RANGE(0x8000, 0x8000) AM_DEVWRITE("ay8912", ay8910_device, data_w) AM_MIRROR(0x3ffd)
AM_RANGE(0xc000, 0xc000) AM_DEVREADWRITE("ay8912", ay8910_device, data_r, address_w) AM_MIRROR(0x3ffd) AM_RANGE(0xc000, 0xc000) AM_DEVREADWRITE("ay8912", ay8910_device, data_r, address_w) AM_MIRROR(0x3ffd)
@ -136,8 +136,8 @@ MACHINE_RESET_MEMBER(pentagon_state,pentagon)
if (m_beta->started()) if (m_beta->started())
{ {
betadisk_enable(m_beta); m_beta->enable();
betadisk_clear_status(m_beta); m_beta->clear_status();
} }
space.set_direct_update_handler(direct_update_delegate(FUNC(pentagon_state::pentagon_direct), this)); space.set_direct_update_handler(direct_update_delegate(FUNC(pentagon_state::pentagon_direct), this));

View File

@ -179,7 +179,7 @@ protected:
required_memory_bank m_bank2; required_memory_bank m_bank2;
required_memory_bank m_bank3; required_memory_bank m_bank3;
required_memory_bank m_bank4; required_memory_bank m_bank4;
required_device<device_t> m_beta; required_device<beta_disk_device> m_beta;
private: private:
UINT8 *m_p_ram; UINT8 *m_p_ram;
void scorpion_update_memory(); void scorpion_update_memory();
@ -257,10 +257,10 @@ DIRECT_UPDATE_MEMBER(scorpion_state::scorpion_direct)
UINT16 pc = m_maincpu->device_t::safe_pcbase(); // works, but... UINT16 pc = m_maincpu->device_t::safe_pcbase(); // works, but...
m_ram_disabled_by_beta = 0; m_ram_disabled_by_beta = 0;
if (betadisk_is_active(m_beta) && (pc >= 0x4000)) if (m_beta->is_active() && (pc >= 0x4000))
{ {
m_ROMSelection = BIT(m_port_7ffd_data, 4); m_ROMSelection = BIT(m_port_7ffd_data, 4);
betadisk_disable(m_beta); m_beta->disable();
m_ram_disabled_by_beta = 1; m_ram_disabled_by_beta = 1;
m_bank1->set_base(&m_p_ram[0x10000 + (m_ROMSelection<<14)]); m_bank1->set_base(&m_p_ram[0x10000 + (m_ROMSelection<<14)]);
} }
@ -268,7 +268,7 @@ DIRECT_UPDATE_MEMBER(scorpion_state::scorpion_direct)
if (((pc & 0xff00) == 0x3d00) && (m_ROMSelection==1)) if (((pc & 0xff00) == 0x3d00) && (m_ROMSelection==1))
{ {
m_ROMSelection = 3; m_ROMSelection = 3;
betadisk_enable(m_beta); m_beta->enable();
} }
if(address<=0x3fff) if(address<=0x3fff)
@ -313,12 +313,12 @@ WRITE8_MEMBER(scorpion_state::scorpion_port_1ffd_w)
static ADDRESS_MAP_START (scorpion_io, AS_IO, 8, scorpion_state ) static ADDRESS_MAP_START (scorpion_io, AS_IO, 8, scorpion_state )
ADDRESS_MAP_UNMAP_HIGH ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x001f, 0x001f) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_status_r,betadisk_command_w) AM_MIRROR(0xff00) AM_RANGE(0x001f, 0x001f) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, status_r, command_w) AM_MIRROR(0xff00)
AM_RANGE(0x003f, 0x003f) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_track_r,betadisk_track_w) AM_MIRROR(0xff00) AM_RANGE(0x003f, 0x003f) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, track_r, track_w) AM_MIRROR(0xff00)
AM_RANGE(0x005f, 0x005f) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_sector_r,betadisk_sector_w) AM_MIRROR(0xff00) AM_RANGE(0x005f, 0x005f) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, sector_r, sector_w) AM_MIRROR(0xff00)
AM_RANGE(0x007f, 0x007f) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_data_r,betadisk_data_w) AM_MIRROR(0xff00) AM_RANGE(0x007f, 0x007f) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, data_r, data_w) AM_MIRROR(0xff00)
AM_RANGE(0x00fe, 0x00fe) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_RANGE(0x00fe, 0x00fe) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xff00) AM_MASK(0xffff)
AM_RANGE(0x00ff, 0x00ff) AM_DEVREADWRITE_LEGACY(BETA_DISK_TAG, betadisk_state_r, betadisk_param_w) AM_MIRROR(0xff00) AM_RANGE(0x00ff, 0x00ff) AM_DEVREADWRITE(BETA_DISK_TAG, beta_disk_device, state_r, param_w) AM_MIRROR(0xff00)
AM_RANGE(0x4000, 0x4000) AM_WRITE(scorpion_port_7ffd_w) AM_MIRROR(0x3ffd) AM_RANGE(0x4000, 0x4000) AM_WRITE(scorpion_port_7ffd_w) AM_MIRROR(0x3ffd)
AM_RANGE(0x8000, 0x8000) AM_DEVWRITE("ay8912", ay8910_device, data_w) AM_MIRROR(0x3ffd) AM_RANGE(0x8000, 0x8000) AM_DEVWRITE("ay8912", ay8910_device, data_w) AM_MIRROR(0x3ffd)
AM_RANGE(0xc000, 0xc000) AM_DEVREADWRITE("ay8912", ay8910_device, data_r, address_w) AM_MIRROR(0x3ffd) AM_RANGE(0xc000, 0xc000) AM_DEVREADWRITE("ay8912", ay8910_device, data_r, address_w) AM_MIRROR(0x3ffd)
@ -336,8 +336,8 @@ MACHINE_RESET_MEMBER(scorpion_state,scorpion)
space.install_read_bank(0x0000, 0x3fff, "bank1"); space.install_read_bank(0x0000, 0x3fff, "bank1");
space.install_write_handler(0x0000, 0x3fff, write8_delegate(FUNC(scorpion_state::scorpion_0000_w),this)); space.install_write_handler(0x0000, 0x3fff, write8_delegate(FUNC(scorpion_state::scorpion_0000_w),this));
betadisk_disable(m_beta); m_beta->disable();
betadisk_clear_status(m_beta); m_beta->clear_status();
space.set_direct_update_handler(direct_update_delegate(FUNC(scorpion_state::scorpion_direct), this)); space.set_direct_update_handler(direct_update_delegate(FUNC(scorpion_state::scorpion_direct), this));
memset(messram,0,256*1024); memset(messram,0,256*1024);

View File

@ -12,193 +12,178 @@
#include "formats/trd_dsk.h" #include "formats/trd_dsk.h"
#include "machine/wd17xx.h" #include "machine/wd17xx.h"
#include "machine/beta.h" #include "machine/beta.h"
#include "devlegcy.h"
/*************************************************************************** /***************************************************************************
TYPE DEFINITIONS TYPE DEFINITIONS
***************************************************************************/ ***************************************************************************/
struct beta_disk_state
const device_type BETA_DISK = &device_creator<beta_disk_device>;
beta_disk_device::beta_disk_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, BETA_DISK, "Beta Disk Interface", tag, owner, clock, "betadisk", __FILE__),
m_betadisk_status(0),
m_betadisk_active(0)
{ {
UINT8 betadisk_status;
UINT8 betadisk_active;
device_t *wd179x;
};
/*****************************************************************************
INLINE FUNCTIONS
*****************************************************************************/
INLINE beta_disk_state *get_safe_token(device_t *device)
{
assert(device != NULL);
assert(device->type() == BETA_DISK);
return (beta_disk_state *)downcast<beta_disk_device *>(device)->token();
} }
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
int betadisk_is_active(device_t *device) void beta_disk_device::device_start()
{ {
beta_disk_state *beta = get_safe_token(device); astring tempstring;
return beta->betadisk_active; /* validate arguments */
assert(tag() != NULL);
/* find our WD179x */
tempstring.printf("%s:%s", tag(), "wd179x");
m_wd179x = machine().device(tempstring);
} }
void betadisk_enable(device_t *device) //-------------------------------------------------
{ // device_reset - device-specific reset
beta_disk_state *beta = get_safe_token(device); //-------------------------------------------------
beta->betadisk_active = 1; void beta_disk_device::device_reset()
{
} }
void betadisk_disable(device_t *device) int beta_disk_device::is_active()
{ {
beta_disk_state *beta = get_safe_token(device); return m_betadisk_active;
beta->betadisk_active = 0;
} }
void betadisk_clear_status(device_t *device) void beta_disk_device::enable()
{ {
beta_disk_state *beta = get_safe_token(device); m_betadisk_active = 1;
beta->betadisk_status = 0;
} }
static WRITE_LINE_DEVICE_HANDLER( betadisk_wd179x_intrq_w ) void beta_disk_device::disable()
{ {
beta_disk_state *beta = get_safe_token(device->owner()); m_betadisk_active = 0;
}
void beta_disk_device::clear_status()
{
m_betadisk_status = 0;
}
static WRITE_LINE_DEVICE_HANDLER(wd179x_intrq_w)
{
beta_disk_device *beta = dynamic_cast<beta_disk_device *>(device->owner());
if (state) if (state)
beta->betadisk_status |= (1<<7); beta->m_betadisk_status |= (1<<7);
else else
beta->betadisk_status &=~(1<<7); beta->m_betadisk_status &=~(1<<7);
} }
static WRITE_LINE_DEVICE_HANDLER( betadisk_wd179x_drq_w ) static WRITE_LINE_DEVICE_HANDLER(wd179x_drq_w)
{ {
beta_disk_state *beta = get_safe_token(device->owner()); beta_disk_device *beta = dynamic_cast<beta_disk_device *>(device->owner());
if (state) if (state)
beta->betadisk_status |= (1<<6); beta->m_betadisk_status |= (1<<6);
else else
beta->betadisk_status &=~(1<<6); beta->m_betadisk_status &=~(1<<6);
} }
static const wd17xx_interface beta_wd17xx_interface = static const wd17xx_interface beta_wd17xx_interface =
{ {
DEVCB_NULL, DEVCB_NULL,
DEVCB_LINE(betadisk_wd179x_intrq_w), DEVCB_LINE(wd179x_intrq_w),
DEVCB_LINE(betadisk_wd179x_drq_w), DEVCB_LINE(wd179x_drq_w),
{FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3} {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
}; };
READ8_DEVICE_HANDLER(betadisk_status_r) READ8_MEMBER(beta_disk_device::status_r)
{ {
beta_disk_state *beta = get_safe_token(device); if (m_betadisk_active==1) {
return wd17xx_status_r(m_wd179x, space, offset);
if (beta->betadisk_active==1) {
return wd17xx_status_r(beta->wd179x, space, offset);
} else { } else {
return 0xff; return 0xff;
} }
} }
READ8_DEVICE_HANDLER(betadisk_track_r) READ8_MEMBER(beta_disk_device::track_r)
{ {
beta_disk_state *beta = get_safe_token(device); if (m_betadisk_active==1) {
return wd17xx_track_r(m_wd179x, space, offset);
if (beta->betadisk_active==1) {
return wd17xx_track_r(beta->wd179x, space, offset);
} else { } else {
return 0xff; return 0xff;
} }
} }
READ8_DEVICE_HANDLER(betadisk_sector_r) READ8_MEMBER(beta_disk_device::sector_r)
{ {
beta_disk_state *beta = get_safe_token(device); if (m_betadisk_active==1) {
return wd17xx_sector_r(m_wd179x, space, offset);
if (beta->betadisk_active==1) {
return wd17xx_sector_r(beta->wd179x, space, offset);
} else { } else {
return 0xff; return 0xff;
} }
} }
READ8_DEVICE_HANDLER(betadisk_data_r) READ8_MEMBER(beta_disk_device::data_r)
{ {
beta_disk_state *beta = get_safe_token(device); if (m_betadisk_active==1) {
return wd17xx_data_r(m_wd179x, space, offset);
if (beta->betadisk_active==1) {
return wd17xx_data_r(beta->wd179x, space, offset);
} else { } else {
return 0xff; return 0xff;
} }
} }
READ8_DEVICE_HANDLER(betadisk_state_r) READ8_MEMBER(beta_disk_device::state_r)
{ {
beta_disk_state *beta = get_safe_token(device); if (m_betadisk_active==1) {
return m_betadisk_status;
if (beta->betadisk_active==1) {
return beta->betadisk_status;
} else { } else {
return 0xff; return 0xff;
} }
} }
WRITE8_DEVICE_HANDLER(betadisk_param_w) WRITE8_MEMBER(beta_disk_device::param_w)
{ {
beta_disk_state *beta = get_safe_token(device); if (m_betadisk_active==1) {
wd17xx_set_drive(m_wd179x, data & 3);
if (beta->betadisk_active==1) { wd17xx_set_side (m_wd179x,(data & 0x10) ? 0 : 1 );
wd17xx_set_drive(beta->wd179x, data & 3); wd17xx_dden_w(m_wd179x, !BIT(data, 5));
wd17xx_set_side (beta->wd179x,(data & 0x10) ? 0 : 1 );
wd17xx_dden_w(beta->wd179x, !BIT(data, 5));
if ((data & 0x04) == 0) // reset if ((data & 0x04) == 0) // reset
{ {
wd17xx_reset(beta->wd179x); wd17xx_reset(m_wd179x);
} }
beta->betadisk_status = (data & 0x3f) | beta->betadisk_status; m_betadisk_status = (data & 0x3f) | m_betadisk_status;
} }
} }
WRITE8_DEVICE_HANDLER(betadisk_command_w) WRITE8_MEMBER(beta_disk_device::command_w)
{ {
beta_disk_state *beta = get_safe_token(device); if (m_betadisk_active==1) {
wd17xx_command_w(m_wd179x, space, offset, data);
if (beta->betadisk_active==1) {
wd17xx_command_w(beta->wd179x, space, offset, data);
} }
} }
WRITE8_DEVICE_HANDLER(betadisk_track_w) WRITE8_MEMBER(beta_disk_device::track_w)
{ {
beta_disk_state *beta = get_safe_token(device); if (m_betadisk_active==1) {
wd17xx_track_w(m_wd179x, space, offset, data);
if (beta->betadisk_active==1) {
wd17xx_track_w(beta->wd179x, space, offset, data);
} }
} }
WRITE8_DEVICE_HANDLER(betadisk_sector_w) WRITE8_MEMBER(beta_disk_device::sector_w)
{ {
beta_disk_state *beta = get_safe_token(device); if (m_betadisk_active==1) {
wd17xx_sector_w(m_wd179x, space, offset, data);
if (beta->betadisk_active==1) {
wd17xx_sector_w(beta->wd179x, space, offset, data);
} }
} }
WRITE8_DEVICE_HANDLER(betadisk_data_w) WRITE8_MEMBER(beta_disk_device::data_w)
{ {
beta_disk_state *beta = get_safe_token(device); if (m_betadisk_active==1) {
wd17xx_data_w(m_wd179x, space, offset, data);
if (beta->betadisk_active==1) {
wd17xx_data_w(beta->wd179x, space, offset, data);
} }
} }
@ -302,48 +287,6 @@ ROM_START( beta_disk )
ROM_END ROM_END
/*-------------------------------------------------
DEVICE_START( beta_disk )
-------------------------------------------------*/
static DEVICE_START( beta_disk )
{
beta_disk_state *beta = get_safe_token(device);
astring tempstring;
/* validate arguments */
assert(device->tag() != NULL);
/* find our WD179x */
tempstring.printf("%s:%s", device->tag(), "wd179x");
beta->wd179x = device->machine().device(tempstring);
}
const device_type BETA_DISK = &device_creator<beta_disk_device>;
beta_disk_device::beta_disk_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, BETA_DISK, "Beta Disk Interface", tag, owner, clock, "betadisk", __FILE__)
{
m_token = global_alloc_clear(beta_disk_state);
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void beta_disk_device::device_start()
{
DEVICE_START_NAME( beta_disk )(this);
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void beta_disk_device::device_reset()
{
}
//------------------------------------------------- //-------------------------------------------------
// device_mconfig_additions - return a pointer to // device_mconfig_additions - return a pointer to
// the device's machine fragment // the device's machine fragment

View File

@ -11,30 +11,44 @@
#define __BETA_H__ #define __BETA_H__
int betadisk_is_active(device_t *device);
void betadisk_enable(device_t *device);
void betadisk_disable(device_t *device);
void betadisk_clear_status(device_t *device);
#define BETA_DISK_TAG "beta" #define BETA_DISK_TAG "beta"
class beta_disk_device : public device_t class beta_disk_device : public device_t
{ {
public: public:
beta_disk_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); beta_disk_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~beta_disk_device() { global_free(m_token); } ~beta_disk_device() {}
DECLARE_READ8_MEMBER(status_r);
DECLARE_READ8_MEMBER(track_r);
DECLARE_READ8_MEMBER(sector_r);
DECLARE_READ8_MEMBER(data_r);
DECLARE_READ8_MEMBER(state_r);
DECLARE_WRITE8_MEMBER(param_w);
DECLARE_WRITE8_MEMBER(command_w);
DECLARE_WRITE8_MEMBER(track_w);
DECLARE_WRITE8_MEMBER(sector_w);
DECLARE_WRITE8_MEMBER(data_w);
int is_active();
void enable();
void disable();
void clear_status();
UINT8 m_betadisk_status;
UINT8 m_betadisk_active;
// access to legacy token
void *token() const { assert(m_token != NULL); return m_token; }
protected: protected:
// device-level overrides // device-level overrides
virtual void device_start(); virtual void device_start();
virtual void device_reset(); virtual void device_reset();
virtual const rom_entry *device_rom_region() const; virtual const rom_entry *device_rom_region() const;
virtual machine_config_constructor device_mconfig_additions() const; virtual machine_config_constructor device_mconfig_additions() const;
private: private:
// internal state // internal state
void *m_token; device_t *m_wd179x;
}; };
extern const device_type BETA_DISK; extern const device_type BETA_DISK;
@ -46,15 +60,4 @@ extern const device_type BETA_DISK;
#define MCFG_BETA_DISK_REMOVE(_tag) \ #define MCFG_BETA_DISK_REMOVE(_tag) \
MCFG_DEVICE_REMOVE(_tag) MCFG_DEVICE_REMOVE(_tag)
DECLARE_READ8_DEVICE_HANDLER(betadisk_status_r);
DECLARE_READ8_DEVICE_HANDLER(betadisk_track_r);
DECLARE_READ8_DEVICE_HANDLER(betadisk_sector_r);
DECLARE_READ8_DEVICE_HANDLER(betadisk_data_r);
DECLARE_READ8_DEVICE_HANDLER(betadisk_state_r);
DECLARE_WRITE8_DEVICE_HANDLER(betadisk_param_w);
DECLARE_WRITE8_DEVICE_HANDLER(betadisk_command_w);
DECLARE_WRITE8_DEVICE_HANDLER(betadisk_track_w);
DECLARE_WRITE8_DEVICE_HANDLER(betadisk_sector_w);
DECLARE_WRITE8_DEVICE_HANDLER(betadisk_data_w);
#endif /* __BETA_H__ */ #endif /* __BETA_H__ */