diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index b77ed1508d4..d499aabbef4 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -2432,3 +2432,19 @@ if (BUSES["NASBUS"]~=null) then MAME_DIR .. "src/emu/bus/nasbus/floppy.h", } end + +--------------------------------------------------- +-- +--@src/emu/bus/cgenie/expansion.h,BUSES += CGENIE_EXPANSION +--------------------------------------------------- + +if (BUSES["CGENIE_EXPANSION"]~=null) then + files { + MAME_DIR .. "src/emu/bus/cgenie/expansion.c", + MAME_DIR .. "src/emu/bus/cgenie/expansion.h", + MAME_DIR .. "src/emu/bus/cgenie/carts.c", + MAME_DIR .. "src/emu/bus/cgenie/carts.h", + MAME_DIR .. "src/emu/bus/cgenie/floppy.c", + MAME_DIR .. "src/emu/bus/cgenie/floppy.h", + } +end diff --git a/scripts/src/lib.lua b/scripts/src/lib.lua index 2b896997f29..d4738644375 100644 --- a/scripts/src/lib.lua +++ b/scripts/src/lib.lua @@ -176,6 +176,8 @@ project "formats" MAME_DIR .. "src/lib/formats/ccvf_dsk.h", MAME_DIR .. "src/lib/formats/cgen_cas.c", MAME_DIR .. "src/lib/formats/cgen_cas.h", + MAME_DIR .. "src/lib/formats/cgenie_dsk.c", + MAME_DIR .. "src/lib/formats/cgenie_dsk.h", MAME_DIR .. "src/lib/formats/coco_cas.c", MAME_DIR .. "src/lib/formats/coco_cas.h", MAME_DIR .. "src/lib/formats/coco_dsk.c", diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index b8fd7046336..867fb0fcdb1 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -579,6 +579,7 @@ BUSES["C64"] = true BUSES["CBM2"] = true BUSES["CBMIEC"] = true BUSES["CENTRONICS"] = true +BUSES["CGENIE_EXPANSION"] = true BUSES["CHANNELF"] = true BUSES["COCO"] = true BUSES["COLECO"] = true diff --git a/src/emu/bus/cgenie/carts.c b/src/emu/bus/cgenie/carts.c new file mode 100644 index 00000000000..f4b23a5cf9d --- /dev/null +++ b/src/emu/bus/cgenie/carts.c @@ -0,0 +1,13 @@ +// license:GPL-2.0+ +// copyright-holders:Dirk Best +/*************************************************************************** + + EACA Colour Genie Expansion Carts + +***************************************************************************/ + +#include "carts.h" + +SLOT_INTERFACE_START( expansion_slot_carts ) + SLOT_INTERFACE("floppy", CGENIE_FDC) +SLOT_INTERFACE_END diff --git a/src/emu/bus/cgenie/carts.h b/src/emu/bus/cgenie/carts.h new file mode 100644 index 00000000000..5dd3b67e172 --- /dev/null +++ b/src/emu/bus/cgenie/carts.h @@ -0,0 +1,20 @@ +// license:GPL-2.0+ +// copyright-holders:Dirk Best +/*************************************************************************** + + EACA Colour Genie Expansion Carts + +***************************************************************************/ + +#pragma once + +#ifndef __CGENIE_CARTS_H__ +#define __CGENIE_CARTS_H__ + +#include "emu.h" + +#include "floppy.h" + +SLOT_INTERFACE_EXTERN( expansion_slot_carts ); + +#endif // __CGENIE_CARTS_H__ diff --git a/src/emu/bus/cgenie/expansion.c b/src/emu/bus/cgenie/expansion.c new file mode 100644 index 00000000000..88a89a32cce --- /dev/null +++ b/src/emu/bus/cgenie/expansion.c @@ -0,0 +1,108 @@ +// license:GPL-2.0+ +// copyright-holders:Dirk Best +/*************************************************************************** + + EACA Colour Genie Expansion Slot + + 50-pin slot + +***************************************************************************/ + +#include "expansion.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type EXPANSION_SLOT = &device_creator; + + +//************************************************************************** +// SLOT DEVICE +//************************************************************************** + +//------------------------------------------------- +// expansion_slot_device - constructor +//------------------------------------------------- + +expansion_slot_device::expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, EXPANSION_SLOT, "Expansion Slot", tag, owner, clock, "expansion_slot", __FILE__), + device_slot_interface(mconfig, *this), + m_program(NULL), + m_io(NULL), + m_cart(NULL), + m_int_handler(*this), + m_nmi_handler(*this), + m_reset_handler(*this) +{ +} + +//------------------------------------------------- +// expansion_slot_device - destructor +//------------------------------------------------- + +expansion_slot_device::~expansion_slot_device() +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void expansion_slot_device::device_start() +{ + // resolve callbacks + m_int_handler.resolve_safe(); + m_nmi_handler.resolve_safe(); + m_reset_handler.resolve_safe(); +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void expansion_slot_device::device_reset() +{ +} + +//------------------------------------------------- +// set_program_space - set address space we are attached to +//------------------------------------------------- + +void expansion_slot_device::set_program_space(address_space *program) +{ + m_program = program; +} + +//------------------------------------------------- +// set_io_space - set address space we are attached to +//------------------------------------------------- + +void expansion_slot_device::set_io_space(address_space *io) +{ + m_io = io; +} + + +//************************************************************************** +// CARTRIDGE INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_expansion_interface - constructor +//------------------------------------------------- + +device_expansion_interface::device_expansion_interface(const machine_config &mconfig, device_t &device) : + device_slot_card_interface(mconfig, device) +{ + m_slot = dynamic_cast(device.owner()); +} + +//------------------------------------------------- +// ~device_expansion_interface - destructor +//------------------------------------------------- + +device_expansion_interface::~device_expansion_interface() +{ +} diff --git a/src/emu/bus/cgenie/expansion.h b/src/emu/bus/cgenie/expansion.h new file mode 100644 index 00000000000..79cbc1430b5 --- /dev/null +++ b/src/emu/bus/cgenie/expansion.h @@ -0,0 +1,128 @@ +// license:GPL-2.0+ +// copyright-holders:Dirk Best +/*************************************************************************** + + EACA Colour Genie Expansion Slot + + 50-pin slot + + 1 GND 26 /MREQ + 2 A8 27 /WR + 3 A7 28 /C4 + 4 A6 29 (not used) + 5 A9 30 /C1 + 6 A5 31 BD3 + 7 A4 32 /C3 + 8 A3 33 (not used) + 9 A10 34 /C2 + 10 A2 35 DB6 + 11 A11 36 /RD + 12 A1 37 BD4 + 13 A0 38 (not used) + 14 A12 39 BD7 + 15 A14 40 (not used) + 16 A13 41 BD5 + 17 /RFSH 42 (not useD) + 18 A15 43 BD0 + 19 /INT 44 (not used) + 20 /BUSRQ 45 BD2 + 21 /NMI 46 /RESET + 22 /WAIT 47 /M1 + 23 /HALT 48 /IORQ + 24 /BUSAK 49 BD1 + 25 /ROMDIS 50 +5V + +***************************************************************************/ + +#pragma once + +#ifndef __CGENIE_EXPANSION_H__ +#define __CGENIE_EXPANSION_H__ + +#include "emu.h" + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_EXPANSION_SLOT_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EXPANSION_SLOT, 0) \ + MCFG_DEVICE_SLOT_INTERFACE(expansion_slot_carts, NULL, false) + +#define MCFG_EXPANSION_SLOT_INT_HANDLER(_devcb) \ + devcb = &expansion_slot_device::set_int_handler(*device, DEVCB_##_devcb); + +#define MCFG_EXPANSION_SLOT_NMI_HANDLER(_devcb) \ + devcb = &expansion_slot_device::set_nmi_handler(*device, DEVCB_##_devcb); + +#define MCFG_EXPANSION_SLOT_RESET_HANDLER(_devcb) \ + devcb = &expansion_slot_device::set_reset_handler(*device, DEVCB_##_devcb); + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class device_expansion_interface; + +class expansion_slot_device : public device_t, public device_slot_interface +{ +public: + // construction/destruction + expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + virtual ~expansion_slot_device(); + + void set_program_space(address_space *program); + void set_io_space(address_space *io); + + // callbacks + template static devcb_base &set_int_handler(device_t &device, _Object object) + { return downcast(device).m_int_handler.set_callback(object); } + + template static devcb_base &set_nmi_handler(device_t &device, _Object object) + { return downcast(device).m_nmi_handler.set_callback(object); } + + template static devcb_base &set_reset_handler(device_t &device, _Object object) + { return downcast(device).m_reset_handler.set_callback(object); } + + // called from cart device + DECLARE_WRITE_LINE_MEMBER( int_w ) { m_int_handler(state); } + DECLARE_WRITE_LINE_MEMBER( nmi_w ) { m_nmi_handler(state); } + DECLARE_WRITE_LINE_MEMBER( reset_w ) { m_reset_handler(state); } + + address_space *m_program; + address_space *m_io; + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + device_expansion_interface *m_cart; + +private: + devcb_write_line m_int_handler; + devcb_write_line m_nmi_handler; + devcb_write_line m_reset_handler; +}; + +// class representing interface-specific live expansion device +class device_expansion_interface : public device_slot_card_interface +{ +public: + // construction/destruction + device_expansion_interface(const machine_config &mconfig, device_t &device); + virtual ~device_expansion_interface(); + +protected: + expansion_slot_device *m_slot; +}; + +// device type definition +extern const device_type EXPANSION_SLOT; + +// include here so drivers don't need to +#include "carts.h" + +#endif // __CGENIE_EXPANSION_H__ diff --git a/src/emu/bus/cgenie/floppy.c b/src/emu/bus/cgenie/floppy.c new file mode 100644 index 00000000000..efb53807774 --- /dev/null +++ b/src/emu/bus/cgenie/floppy.c @@ -0,0 +1,193 @@ +// license:GPL-2.0+ +// copyright-holders:Dirk Best +/*************************************************************************** + + EACA Colour Genie Floppy Disc Controller + + TODO: + - What's the exact FD1793 model? + - How does it turn off the motor? + - How does it switch between FM/MFM? + +***************************************************************************/ + +#include "floppy.h" +#include "formats/cgenie_dsk.h" +#include "bus/generic/carts.h" + + +//************************************************************************** +// CONSTANTS/MACROS +//************************************************************************** + +#define VERBOSE 0 + +// set to 1 to test fm disk formats +#define FM_MODE 0 + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type CGENIE_FDC = &device_creator; + +FLOPPY_FORMATS_MEMBER( cgenie_fdc_device::floppy_formats ) + FLOPPY_CGENIE_FORMAT +FLOPPY_FORMATS_END + +static SLOT_INTERFACE_START( cgenie_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 + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +ROM_START( cgenie_fdc ) + ROM_REGION(0x3000, "software", 0) + ROM_LOAD("cgdos.rom", 0x0000, 0x2000, CRC(2a96cf74) SHA1(6dcac110f87897e1ee7521aefbb3d77a14815893)) +ROM_END + +const rom_entry *cgenie_fdc_device::device_rom_region() const +{ + return ROM_NAME( cgenie_fdc ); +} + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +static MACHINE_CONFIG_FRAGMENT( cgenie_fdc ) + MCFG_FD1793x_ADD("fd1793", XTAL_16MHz / 4 / 4) + MCFG_WD_FDC_INTRQ_CALLBACK(WRITELINE(cgenie_fdc_device, intrq_w)) + + MCFG_FLOPPY_DRIVE_ADD("fd1793:0", cgenie_floppies, "ssdd", cgenie_fdc_device::floppy_formats) + MCFG_FLOPPY_DRIVE_ADD("fd1793:1", cgenie_floppies, "ssdd", cgenie_fdc_device::floppy_formats) + MCFG_FLOPPY_DRIVE_ADD("fd1793:2", cgenie_floppies, NULL, cgenie_fdc_device::floppy_formats) + MCFG_FLOPPY_DRIVE_ADD("fd1793:3", cgenie_floppies, NULL, cgenie_fdc_device::floppy_formats) + +// MCFG_SOFTWARE_LIST_ADD("floppy_list", "cgenie_flop") + + MCFG_GENERIC_SOCKET_ADD("socket", generic_plain_slot, "cgenie_socket") + MCFG_GENERIC_EXTENSIONS("bin,rom") + MCFG_GENERIC_LOAD(cgenie_fdc_device, socket_load) + + MCFG_SOFTWARE_LIST_ADD("cart_list", "cgenie_cart") +MACHINE_CONFIG_END + +machine_config_constructor cgenie_fdc_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( cgenie_fdc ); +} + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// cgenie_fdc_device - constructor +//------------------------------------------------- + +cgenie_fdc_device::cgenie_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, CGENIE_FDC, "Colour Genie Floppy Disc Controller", tag, owner, clock, "cgenie_fdc", __FILE__), + device_expansion_interface(mconfig, *this), + m_fdc(*this, "fd1793"), + m_floppy0(*this, "fd1793:0"), + m_floppy1(*this, "fd1793:1"), + m_floppy2(*this, "fd1793:2"), + m_floppy3(*this, "fd1793:3"), + m_socket(*this, "socket"), + m_floppy(NULL) +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void cgenie_fdc_device::device_start() +{ +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void cgenie_fdc_device::device_reset() +{ + // dos rom + m_slot->m_program->install_rom(0xc000, 0xdfff, memregion("software")->base()); + + // memory mapped i/o + m_slot->m_program->install_write_handler(0xffe0, 0xffe3, 0, 0x10, write8_delegate(FUNC(cgenie_fdc_device::select_w), this)); + m_slot->m_program->install_read_handler( 0xffec, 0xffef, 0, 0x10, read8_delegate(FUNC(fd1793_t::read), m_fdc.target())); + m_slot->m_program->install_write_handler(0xffec, 0xffef, 0, 0x10, write8_delegate(FUNC(fd1793_t::write), m_fdc.target())); + + // map extra socket + if (m_socket->exists()) + { + m_slot->m_program->install_read_handler(0xe000, 0xefff, read8_delegate(FUNC(generic_slot_device::read_rom), (generic_slot_device *) m_socket)); + } +} + + +//************************************************************************** +// IMPLEMENTATION +//************************************************************************** + +DEVICE_IMAGE_LOAD_MEMBER( cgenie_fdc_device, socket_load ) +{ + UINT32 size = m_socket->common_get_size("rom"); + + if (size > 0x1000) + { + image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported ROM size"); + return IMAGE_INIT_FAIL; + } + + m_socket->rom_alloc(0x1000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); + m_socket->common_load_rom(m_socket->get_rom_base(), size, "rom"); + + return IMAGE_INIT_PASS; +} + +WRITE_LINE_MEMBER( cgenie_fdc_device::intrq_w ) +{ + if (VERBOSE) + logerror("cgenie_fdc_device::intrq_w: %d\n", state); + + // forward to host + m_slot->int_w(state); +} + +WRITE8_MEMBER( cgenie_fdc_device::select_w ) +{ + if (VERBOSE) + logerror("cgenie_fdc_device::motor_w: 0x%02x\n", data); + + if (FM_MODE) + m_fdc->dden_w(1); + + m_floppy = NULL; + + if (BIT(data, 0)) m_floppy = m_floppy0->get_device(); + if (BIT(data, 1)) m_floppy = m_floppy1->get_device(); + if (BIT(data, 2)) m_floppy = m_floppy2->get_device(); + if (BIT(data, 3)) m_floppy = m_floppy3->get_device(); + + m_fdc->set_floppy(m_floppy); + + if (m_floppy) + { + m_floppy->ss_w(BIT(data, 4)); + m_floppy->mon_w(0); + } +} diff --git a/src/emu/bus/cgenie/floppy.h b/src/emu/bus/cgenie/floppy.h new file mode 100644 index 00000000000..6911358763d --- /dev/null +++ b/src/emu/bus/cgenie/floppy.h @@ -0,0 +1,59 @@ +// license:GPL-2.0+ +// copyright-holders:Dirk Best +/*************************************************************************** + + EACA Colour Genie Floppy Controller Cartridge + +***************************************************************************/ + +#pragma once + +#ifndef __CGENIE_EXPANSION_FLOPPY_H__ +#define __CGENIE_EXPANSION_FLOPPY_H__ + +#include "emu.h" +#include "expansion.h" +#include "machine/wd_fdc.h" +#include "bus/generic/slot.h" + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> floppy_controller_device + +class cgenie_fdc_device : public device_t, public device_expansion_interface +{ +public: + // construction/destruction + cgenie_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + DECLARE_WRITE_LINE_MEMBER(intrq_w); + DECLARE_WRITE8_MEMBER(select_w); + + DECLARE_FLOPPY_FORMATS(floppy_formats); + + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(socket_load); + +protected: + virtual const rom_entry *device_rom_region() const; + virtual machine_config_constructor device_mconfig_additions() const; + virtual void device_start(); + virtual void device_reset(); + +private: + required_device m_fdc; + required_device m_floppy0; + required_device m_floppy1; + required_device m_floppy2; + required_device m_floppy3; + required_device m_socket; + + floppy_image_device *m_floppy; +}; + +// device type definition +extern const device_type CGENIE_FDC; + +#endif // __CGENIE_EXPANSION_FLOPPY_H__ diff --git a/src/lib/formats/cgenie_dsk.c b/src/lib/formats/cgenie_dsk.c new file mode 100644 index 00000000000..895651acbe2 --- /dev/null +++ b/src/lib/formats/cgenie_dsk.c @@ -0,0 +1,69 @@ +// license:GPL-2.0+ +// copyright-holders:Dirk Best +/*************************************************************************** + + EACA Colour Genie + + Disk image format + +***************************************************************************/ + +#include "cgenie_dsk.h" + +cgenie_format::cgenie_format() : wd177x_format(formats) +{ +} + +const char *cgenie_format::name() const +{ + return "cgenie"; +} + +const char *cgenie_format::description() const +{ + return "Colour Genie disk image"; +} + +const char *cgenie_format::extensions() const +{ + return "dsk"; +} + +const cgenie_format::format cgenie_format::formats[] = +{ + { // 102k 5 1/4 inch single density single sided (Type A) + floppy_image::FF_525, floppy_image::SSSD, floppy_image::FM, + 4000, 10, 41, 1, 256, {}, 0, {}, 14, 11, 12 + }, + { // 184k 5 1/4 inch double density single sided (Type C) + floppy_image::FF_525, floppy_image::SSDD, floppy_image::MFM, + 2000, 18, 42, 1, 256, {}, 0, {}, 21, 22, 16 + }, + { // 204k 5 1/4 inch single density single sided (Type I) + floppy_image::FF_525, floppy_image::SSQD, floppy_image::FM, + 4000, 10, 81, 1, 256, {}, 0, {}, 14, 11, 12 + }, + { // 368k 5 1/4 inch double density single sided (Type K) + floppy_image::FF_525, floppy_image::SSQD, floppy_image::MFM, + 2000, 18, 82, 1, 256, {}, 0, {}, 21, 22, 16 + }, + { // 204k 5 1/4 inch single density double sided (Type B) + floppy_image::FF_525, floppy_image::DSSD, floppy_image::FM, + 4000, 10, 41, 2, 256, {}, 0, {}, 14, 11, 12 + }, + { // 368k 5 1/4 inch double density double sided (Type D) + floppy_image::FF_525, floppy_image::DSDD, floppy_image::MFM, + 2000, 18, 42, 2, 256, {}, 0, {}, 21, 22, 16 + }, + { // 408k 5 1/4 inch single density double sided (Type J) + floppy_image::FF_525, floppy_image::DSQD, floppy_image::FM, + 4000, 10, 81, 2, 256, {}, 0, {}, 14, 11, 12 + }, + { // 736k 5 1/4 inch double density double sided (Type L) + floppy_image::FF_525, floppy_image::DSQD, floppy_image::MFM, + 2000, 18, 82, 2, 256, {}, 0, {}, 21, 22, 16 + }, + {} +}; + +const floppy_format_type FLOPPY_CGENIE_FORMAT = &floppy_image_format_creator; diff --git a/src/lib/formats/cgenie_dsk.h b/src/lib/formats/cgenie_dsk.h new file mode 100644 index 00000000000..2c88860b9cc --- /dev/null +++ b/src/lib/formats/cgenie_dsk.h @@ -0,0 +1,33 @@ +// license:GPL-2.0+ +// copyright-holders:Dirk Best +/*************************************************************************** + + EACA Colour Genie + + Disk image format + +***************************************************************************/ + +#pragma once + +#ifndef __CGENIE_DSK_H__ +#define __CGENIE_DSK_H__ + +#include "wd177x_dsk.h" + +class cgenie_format : public wd177x_format +{ +public: + cgenie_format(); + + virtual const char *name() const; + virtual const char *description() const; + virtual const char *extensions() const; + +private: + static const format formats[]; +}; + +extern const floppy_format_type FLOPPY_CGENIE_FORMAT; + +#endif // __CGENIE_DSK_H__ diff --git a/src/mess/drivers/cgenie.c b/src/mess/drivers/cgenie.c index 168fdb15208..23f62221c77 100644 --- a/src/mess/drivers/cgenie.c +++ b/src/mess/drivers/cgenie.c @@ -38,28 +38,19 @@ NMI #include "sound/dac.h" #include "formats/cgen_cas.h" #include "machine/ram.h" +#include "bus/cgenie/expansion.h" -static ADDRESS_MAP_START (cgenie_mem, AS_PROGRAM, 8, cgenie_state ) +static ADDRESS_MAP_START( cgenie_mem, AS_PROGRAM, 8, cgenie_state ) + ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x0000, 0x3fff) AM_ROM // AM_RANGE(0x4000, 0xbfff) AM_RAM // set up in MACHINE_START -// AM_RANGE(0xc000, 0xdfff) AM_ROM // installed in cgenie_init_machine -// AM_RANGE(0xe000, 0xefff) AM_ROM // installed in cgenie_init_machine AM_RANGE(0xf000, 0xf3ff) AM_READWRITE(cgenie_colorram_r, cgenie_colorram_w ) AM_SHARE("colorram") AM_RANGE(0xf400, 0xf7ff) AM_READWRITE(cgenie_fontram_r, cgenie_fontram_w) AM_SHARE("fontram") AM_RANGE(0xf800, 0xf8ff) AM_READ(cgenie_keyboard_r ) - AM_RANGE(0xf900, 0xffdf) AM_NOP - AM_RANGE(0xffe0, 0xffe3) AM_READWRITE(cgenie_irq_status_r, cgenie_motor_w ) - AM_RANGE(0xffe4, 0xffeb) AM_NOP - AM_RANGE(0xffec, 0xffec) AM_READWRITE(cgenie_status_r, cgenie_command_w ) - AM_RANGE(0xffe4, 0xffeb) AM_NOP - AM_RANGE(0xffec, 0xffec) AM_WRITE(cgenie_command_w ) - AM_RANGE(0xffed, 0xffed) AM_READWRITE(cgenie_track_r, cgenie_track_w ) - AM_RANGE(0xffee, 0xffee) AM_READWRITE(cgenie_sector_r, cgenie_sector_w ) - AM_RANGE(0xffef, 0xffef) AM_READWRITE(cgenie_data_r, cgenie_data_w ) - AM_RANGE(0xfff0, 0xffff) AM_NOP + AM_RANGE(0xffe0, 0xffe3) AM_READ(cgenie_irq_status_r) ADDRESS_MAP_END -static ADDRESS_MAP_START (cgenie_io, AS_IO, 8, cgenie_state ) +static ADDRESS_MAP_START( cgenie_io, AS_IO, 8, cgenie_state ) ADDRESS_MAP_GLOBAL_MASK(0xff) AM_RANGE(0xf8, 0xf8) AM_READWRITE(cgenie_sh_control_port_r, cgenie_sh_control_port_w ) AM_RANGE(0xf9, 0xf9) AM_DEVREADWRITE("ay8910", ay8910_device, data_r, data_w) @@ -70,19 +61,10 @@ ADDRESS_MAP_END static INPUT_PORTS_START( cgenie ) PORT_START("DSW0") - PORT_DIPNAME( 0x80, 0x80, "Floppy Disc Drives") - PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x80, DEF_STR( On ) ) - PORT_DIPNAME( 0x40, 0x40, "CG-DOS ROM C000-DFFF") - PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x40, DEF_STR( On ) ) - PORT_DIPNAME( 0x20, 0x00, "Extension E000-EFFF") - PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x20, DEF_STR( On ) ) PORT_DIPNAME( 0x10, 0x10, "Video Display accuracy") PORT_CODE(KEYCODE_F5) PORT_TOGGLE PORT_DIPSETTING( 0x10, "TV set" ) PORT_DIPSETTING( 0x00, "RGB monitor" ) - PORT_BIT(0x0f, 0x0f, IPT_UNUSED) + PORT_BIT(0xef, 0xef, IPT_UNUSED) /************************************************************************** +-------------------------------+ +-------------------------------+ @@ -443,7 +425,7 @@ static const unsigned short cgenie_palette[] = 0, 41, 39, 38, /* TV set graphics colors: a bit brighter */ }; -/* Initialise the palette */ +/* Initialize the palette */ PALETTE_INIT_MEMBER(cgenie_state,cgenie) { UINT8 i, r, g, b; @@ -472,41 +454,6 @@ PALETTE_INIT_MEMBER(cgenie_state,cgenienz) palette.set_pen_indirect(i, cgenie_palette[i]); } -// This is currently broken -static LEGACY_FLOPPY_OPTIONS_START(cgenie ) - LEGACY_FLOPPY_OPTION( cgd, "cgd", "Colour Genie disk image", basicdsk_identify_default, basicdsk_construct_default, NULL, - HEADS([2]) - TRACKS([40]) - SECTORS([10]) - SECTOR_LENGTH([256]) - FIRST_SECTOR_ID([1])) -LEGACY_FLOPPY_OPTIONS_END - -static const floppy_interface cgenie_floppy_interface = -{ - FLOPPY_STANDARD_5_25_DSHD, - LEGACY_FLOPPY_OPTIONS_NAME(cgenie), - NULL -}; - - -// TODO: investigate this! I think it is some sort of expansion of the DOS cart... -DEVICE_IMAGE_LOAD_MEMBER( cgenie_state, cgenie_cart ) -{ - UINT32 size = m_cart->common_get_size("rom"); - - if (size > 0x1000) - { - image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); - return IMAGE_INIT_FAIL; - } - - m_cart->rom_alloc(0x1000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); - m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - - return IMAGE_INIT_PASS; -} - static MACHINE_CONFIG_START( cgenie_common, cgenie_state ) /* basic machine hardware */ @@ -549,22 +496,12 @@ static MACHINE_CONFIG_START( cgenie_common, cgenie_state ) MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_STOPPED) MCFG_CASSETTE_INTERFACE("cgenie_cass") - MCFG_DEVICE_ADD("wd179x", FD1793, 0) // TODO confirm type - MCFG_WD17XX_DEFAULT_DRIVE4_TAGS - MCFG_WD17XX_INTRQ_CALLBACK(WRITELINE(cgenie_state, cgenie_fdc_intrq_w)) - - MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(cgenie_floppy_interface) - - /* cartridge */ - MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "cgenie_cart") - MCFG_GENERIC_EXTENSIONS("bin,rom") - MCFG_GENERIC_LOAD(cgenie_state, cgenie_cart) - - /* software lists */ - MCFG_SOFTWARE_LIST_ADD("cart_list", "cgenie_cart") MCFG_SOFTWARE_LIST_ADD("cass_list", "cgenie_cass") - /* internal ram */ + MCFG_EXPANSION_SLOT_ADD("exp") + MCFG_EXPANSION_SLOT_INT_HANDLER(WRITELINE(cgenie_state, exp_intrq_w)) + + // internal ram MCFG_RAM_ADD(RAM_TAG) MCFG_RAM_DEFAULT_SIZE("16K") MCFG_RAM_EXTRA_OPTIONS("32K") @@ -586,173 +523,31 @@ MACHINE_CONFIG_END ***************************************************************************/ -ROM_START (cgenie) - ROM_REGION(0x13000,"maincpu",0) - ROM_LOAD ("cgenie.rom", 0x00000, 0x4000, CRC(d359ead7) SHA1(d8c2fc389ad38c45fba0ed556a7d91abac5463f4)) - ROM_LOAD ("cgdos.rom", 0x10000, 0x2000, CRC(2a96cf74) SHA1(6dcac110f87897e1ee7521aefbb3d77a14815893)) +ROM_START( cgenie ) + ROM_REGION(0x4000, "maincpu", 0) + ROM_LOAD("cgenie.rom", 0x0000, 0x4000, CRC(d359ead7) SHA1(d8c2fc389ad38c45fba0ed556a7d91abac5463f4)) - ROM_REGION(0x0c00,"gfx1",0) - ROM_LOAD ("cgenie1.fnt", 0x0000, 0x0800, CRC(4fed774a) SHA1(d53df8212b521892cc56be690db0bb474627d2ff)) + ROM_REGION(0x0c00, "gfx1", 0) + ROM_LOAD("cgenie1.fnt", 0x0000, 0x0800, CRC(4fed774a) SHA1(d53df8212b521892cc56be690db0bb474627d2ff)) /* Empty memory region for the character generator */ - ROM_REGION(0x0800,"gfx2",ROMREGION_ERASEFF) - + ROM_REGION(0x0800, "gfx2", ROMREGION_ERASEFF) ROM_END -ROM_START (cgenienz) - ROM_REGION(0x13000,"maincpu",0) +ROM_START( cgenienz ) + ROM_REGION(0x4000, "maincpu", 0) ROM_SYSTEM_BIOS(0, "old", "Old ROM") - ROMX_LOAD( "cg-basic-rom-v1-pal-en.rom", 0x0000, 0x4000, CRC(844aaedd) SHA1(b7f984bc5cd979c7ad11ff909e8134f694aea7aa), ROM_BIOS(1) ) + ROMX_LOAD("cg-basic-rom-v1-pal-en.rom", 0x0000, 0x4000, CRC(844aaedd) SHA1(b7f984bc5cd979c7ad11ff909e8134f694aea7aa), ROM_BIOS(1) ) ROM_SYSTEM_BIOS(1, "new", "New ROM") - ROMX_LOAD( "cgromv2.rom", 0x0000, 0x4000, CRC(cfb84e09) SHA1(e199e4429bab6f9fca2bb05e71324538928a693a), ROM_BIOS(2) ) - ROM_LOAD ("cgdos.rom", 0x10000, 0x2000, CRC(2a96cf74) SHA1(6dcac110f87897e1ee7521aefbb3d77a14815893)) + ROMX_LOAD("cgromv2.rom", 0x0000, 0x4000, CRC(cfb84e09) SHA1(e199e4429bab6f9fca2bb05e71324538928a693a), ROM_BIOS(2) ) - ROM_REGION(0x0c00,"gfx1",0) - ROM_LOAD ("cgenie1.fnt", 0x0000, 0x0800, CRC(4fed774a) SHA1(d53df8212b521892cc56be690db0bb474627d2ff)) + ROM_REGION(0x0c00, "gfx1", 0) + ROM_LOAD("cgenie1.fnt", 0x0000, 0x0800, CRC(4fed774a) SHA1(d53df8212b521892cc56be690db0bb474627d2ff)) /* Empty memory region for the character generator */ - ROM_REGION(0x0800,"gfx2",ROMREGION_ERASEFF) - + ROM_REGION(0x0800, "gfx2", ROMREGION_ERASEFF) ROM_END -// Code below is previous non-working implementation , just for reference -#if 0 - -#define CGENIE_DRIVE_INFO - - - -// -// abbreviations used: -// GPL Granules Per Lump -// GAT Granule Allocation Table -// GATL GAT Length -// GATM GAT Mask -// DDGA Disk Directory Granule Allocation -struct PDRIVE -{ - UINT8 DDSL; // Disk Directory Start Lump (lump number of GAT) - UINT8 GATL; // # of bytes used in the Granule Allocation Table sector - UINT8 STEPRATE; // step rate and somet SD/DD flag ... - UINT8 TRK; // number of tracks - UINT8 SPT; // sectors per track (both heads counted!) - UINT8 GATM; // number of used bits per byte in the GAT sector (GAT mask) - UINT8 P7; // ???? always zero - UINT8 FLAGS; // ???? some flags (SS/DS bit 6) - UINT8 GPL; // Sectors per granule (always 5 for the Colour Genie) - UINT8 DDGA; // Disk Directory Granule allocation (number of driectory granules) -}; - -static const PDRIVE pd_list[12] = { - {0x14, 0x28, 0x07, 0x28, 0x0A, 0x02, 0x00, 0x00, 0x05, 0x02}, // CMD"<0=A" 40 tracks, SS, SD - {0x14, 0x28, 0x07, 0x28, 0x14, 0x04, 0x00, 0x40, 0x05, 0x04}, // CMD"<0=B" 40 tracks, DS, SD - {0x18, 0x30, 0x53, 0x28, 0x12, 0x03, 0x00, 0x03, 0x05, 0x03}, // CMD"<0=C" 40 tracks, SS, DD - {0x18, 0x30, 0x53, 0x28, 0x24, 0x06, 0x00, 0x43, 0x05, 0x06}, // CMD"<0=D" 40 tracks, DS, DD - {0x14, 0x28, 0x07, 0x28, 0x0A, 0x02, 0x00, 0x04, 0x05, 0x02}, // CMD"<0=E" 40 tracks, SS, SD - {0x14, 0x28, 0x07, 0x28, 0x14, 0x04, 0x00, 0x44, 0x05, 0x04}, // CMD"<0=F" 40 tracks, DS, SD - {0x18, 0x30, 0x53, 0x28, 0x12, 0x03, 0x00, 0x07, 0x05, 0x03}, // CMD"<0=G" 40 tracks, SS, DD - {0x18, 0x30, 0x53, 0x28, 0x24, 0x06, 0x00, 0x47, 0x05, 0x06}, // CMD"<0=H" 40 tracks, DS, DD - {0x28, 0x50, 0x07, 0x50, 0x0A, 0x02, 0x00, 0x00, 0x05, 0x02}, // CMD"<0=I" 80 tracks, SS, SD - {0x28, 0x50, 0x07, 0x50, 0x14, 0x04, 0x00, 0x40, 0x05, 0x04}, // CMD"<0=J" 80 tracks, DS, SD - {0x30, 0x60, 0x53, 0x50, 0x12, 0x03, 0x00, 0x03, 0x05, 0x03}, // CMD"<0=K" 80 tracks, SS, DD - {0x30, 0x60, 0x53, 0x50, 0x24, 0x06, 0x00, 0x43, 0x05, 0x06}, // CMD"<0=L" 80 tracks, DS, DD -}; - -// basic-dsk is a disk image format which has the tracks and sectors -// stored in order, no information is stored which details the number -// of tracks, number of sides, number of sectors etc, so we need to -// set that up here -// -DEVICE_IMAGE_LOAD( cgenie_floppy ) -{ - int i, j, dir_offset; - UINT8 buff[16]; - UINT8 tracks = 0; - UINT8 heads = 0; - UINT8 spt = 0; - short dir_sector = 0; - short dir_length = 0; - - // A Floppy Isnt manditory, so return if none - if (device_load_basicdsk_floppy(image) != IMAGE_INIT_PASS) - return IMAGE_INIT_FAIL; - - // determine image geometry - image.fseek(0, SEEK_SET); - - // determine geometry from disk contents - for( i = 0; i < 12; i++ ) - { - image.fseek(pd_list[i].SPT * 256, SEEK_SET); - image.fread( buff, 16); - // find an entry with matching DDSL - if (buff[0] != 0x00 || buff[1] != 0xfe || buff[2] != pd_list[i].DDSL) - continue; - logerror("cgenie: checking format #%d\n", i); - - dir_sector = pd_list[i].DDSL * pd_list[i].GATM * pd_list[i].GPL + pd_list[i].SPT; - dir_length = pd_list[i].DDGA * pd_list[i].GPL; - - // scan directory for DIR/SYS or NCW1983/JHL files - // look into sector 2 and 3 first entry relative to DDSL - for( j = 16; j < 32; j += 8 ) - { - dir_offset = dir_sector * 256 + j * 32; - if( image.fseek(dir_offset, SEEK_SET) < 0 ) - break; - if( image.fread( buff, 16) != 16 ) - break; - if( !strncmp((char*)buff + 5, "DIR SYS", 11) || - !strncmp((char*)buff + 5, "NCW1983 JHL", 11) ) - { - tracks = pd_list[i].TRK; - heads = (pd_list[i].SPT > 18) ? 2 : 1; - spt = pd_list[i].SPT / heads; - dir_sector = pd_list[i].DDSL * pd_list[i].GATM * pd_list[i].GPL + pd_list[i].SPT; - dir_length = pd_list[i].DDGA * pd_list[i].GPL; - memcpy(memregion("maincpu")->base() + 0x5A71 + floppy_get_drive(image) * sizeof(PDRIVE), &pd_list[i], sizeof(PDRIVE)); - break; - } - } - - logerror("cgenie: geometry %d tracks, %d heads, %d sec/track\n", tracks, heads, spt); - // set geometry so disk image can be read - basicdsk_set_geometry(image, tracks, heads, spt, 256, 0, 0, FALSE); - - logerror("cgenie: directory sectors %d - %d (%d sectors)\n", dir_sector, dir_sector + dir_length - 1, dir_length); - // mark directory sectors with deleted data address mark - // assumption dir_sector is a sector offset - for (j = 0; j < dir_length; j++) - { - UINT8 track; - UINT8 side; - UINT8 sector_id; - UINT16 track_offset; - UINT16 sector_offset; - - // calc sector offset - sector_offset = dir_sector + j; - - // get track offset - track_offset = sector_offset / spt; - - // calc track - track = track_offset / heads; - - // calc side - side = track_offset % heads; - - // calc sector id - first sector id is 0! - sector_id = sector_offset % spt; - - // set deleted data address mark for sector specified - basicdsk_set_ddam(image, track, side, sector_id, 1); - } - - } - return IMAGE_INIT_PASS; -} -#endif /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */ COMP( 1982, cgenie, 0, 0, cgenie, cgenie, driver_device, 0, "EACA Computers Ltd", "Colour Genie EG2000" , 0) diff --git a/src/mess/includes/cgenie.h b/src/mess/includes/cgenie.h index 5d213808045..07c72e2b57e 100644 --- a/src/mess/includes/cgenie.h +++ b/src/mess/includes/cgenie.h @@ -9,12 +9,10 @@ #ifndef CGENIE_H_ #define CGENIE_H_ -#include "machine/wd17xx.h" #include "imagedev/cassette.h" #include "machine/ram.h" #include "sound/ay8910.h" -#include "bus/generic/slot.h" -#include "bus/generic/carts.h" +#include "bus/cgenie/expansion.h" // CRTC 6845 struct CRTC6845 @@ -50,12 +48,12 @@ public: m_fontram(*this, "fontram"), m_maincpu(*this, "maincpu"), m_cassette(*this, "cassette"), - m_cart(*this, "cartslot"), m_ram(*this, RAM_TAG), m_ay8910(*this, "ay8910"), m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette"), - m_screen(*this, "screen") + m_screen(*this, "screen"), + m_exp(*this, "exp") { } @@ -67,8 +65,6 @@ public: int m_font_offset[4]; int m_port_ff; UINT8 m_irq_status; - UINT8 m_motor_drive; - UINT8 m_head; UINT8 m_cass_level; UINT8 m_cass_bit; UINT8 m_psg_a_out; @@ -91,17 +87,19 @@ public: INTERRUPT_GEN_MEMBER(cgenie_timer_interrupt); INTERRUPT_GEN_MEMBER(cgenie_frame_interrupt); TIMER_CALLBACK_MEMBER(handle_cassette_input); - DECLARE_WRITE_LINE_MEMBER(cgenie_fdc_intrq_w); + + DECLARE_WRITE_LINE_MEMBER(exp_intrq_w); + DECLARE_READ8_MEMBER(cgenie_sh_control_port_r); DECLARE_WRITE8_MEMBER(cgenie_sh_control_port_w); required_device m_maincpu; required_device m_cassette; - required_device m_cart; required_device m_ram; required_device m_ay8910; required_device m_gfxdecode; required_device m_palette; required_device m_screen; + required_device m_exp; void cgenie_offset_xy(); int cgenie_get_register(int indx); @@ -125,20 +123,8 @@ public: DECLARE_WRITE8_MEMBER( cgenie_port_ff_w ); DECLARE_READ8_MEMBER( cgenie_port_ff_r ); - DECLARE_READ8_MEMBER( cgenie_status_r ); - DECLARE_READ8_MEMBER( cgenie_track_r ); - DECLARE_READ8_MEMBER( cgenie_sector_r ); - DECLARE_READ8_MEMBER( cgenie_data_r ); - - DECLARE_WRITE8_MEMBER( cgenie_command_w ); - DECLARE_WRITE8_MEMBER( cgenie_track_w ); - DECLARE_WRITE8_MEMBER( cgenie_sector_w ); - DECLARE_WRITE8_MEMBER( cgenie_data_w ); - DECLARE_READ8_MEMBER( cgenie_irq_status_r ); - DECLARE_WRITE8_MEMBER( cgenie_motor_w ); - DECLARE_READ8_MEMBER( cgenie_keyboard_r ); DECLARE_WRITE8_MEMBER( cgenie_videoram_w ); @@ -148,8 +134,6 @@ public: DECLARE_WRITE8_MEMBER( cgenie_index_w ); DECLARE_WRITE8_MEMBER( cgenie_register_w ); - - DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cgenie_cart); }; #endif /* CGENIE_H_ */ diff --git a/src/mess/machine/cgenie.c b/src/mess/machine/cgenie.c index a3f13bb3b7b..a71d5cbec00 100644 --- a/src/mess/machine/cgenie.c +++ b/src/mess/machine/cgenie.c @@ -12,10 +12,8 @@ #include "emu.h" #include "cpu/z80/z80.h" #include "includes/cgenie.h" -#include "machine/wd17xx.h" #include "imagedev/cassette.h" #include "sound/dac.h" -#include "imagedev/flopdrv.h" #include "machine/ram.h" #define AYWriteReg(chip,port,value) \ @@ -68,51 +66,6 @@ void cgenie_state::machine_reset() /* wipe out font RAM */ memset(&ROM[0x0f400], 0xff, 0x0400); - if( ioport("DSW0")->read() & 0x80 ) - { - logerror("cgenie floppy discs enabled\n"); - } - else - { - logerror("cgenie floppy discs disabled\n"); - } - - /* copy DOS ROM, if enabled or wipe out that memory area */ - if( ioport("DSW0")->read() & 0x40 ) - { - if ( ioport("DSW0")->read() & 0x80 ) - { - space.install_read_bank(0xc000, 0xdfff, "bank10"); - space.nop_write(0xc000, 0xdfff); - membank("bank10")->set_base(&ROM[0x0c000]); - logerror("cgenie DOS enabled\n"); - memcpy(&ROM[0x0c000],&ROM[0x10000], 0x2000); - } - else - { - space.nop_readwrite(0xc000, 0xdfff); - logerror("cgenie DOS disabled (no floppy image given)\n"); - } - } - else - { - space.nop_readwrite(0xc000, 0xdfff); - logerror("cgenie DOS disabled\n"); - memset(&memregion("maincpu")->base()[0x0c000], 0x00, 0x2000); - } - - /* copy EXT ROM, if enabled or wipe out that memory area */ - if (ioport("DSW0")->read() & 0x20 && m_cart->exists()) - { - m_maincpu->space(AS_PROGRAM).install_read_handler(0xe000, 0xefff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_cart)); - logerror("cgenie EXT enabled\n"); - } - else - { - space.nop_readwrite(0xe000, 0xefff); - logerror("cgenie EXT disabled\n"); - } - m_cass_level = 0; m_cass_bit = 1; } @@ -125,8 +78,6 @@ void cgenie_state::machine_start() /* initialize static variables */ m_irq_status = 0; - m_motor_drive = 0; - m_head = 0; m_tv_mode = -1; m_port_ff = 0xff; @@ -147,6 +98,10 @@ void cgenie_state::machine_start() m_videoram = m_ram->pointer(); membank("bank1")->set_base(m_ram->pointer()); machine().scheduler().timer_pulse(attotime::from_hz(11025), timer_expired_delegate(FUNC(cgenie_state::handle_cassette_input),this)); + + // setup expansion bus + m_exp->set_program_space(&m_maincpu->space(AS_PROGRAM)); + m_exp->set_io_space(&m_maincpu->space(AS_IO)); } /************************************* @@ -319,83 +274,11 @@ WRITE8_MEMBER( cgenie_state::cgenie_psg_port_b_w ) m_psg_b_out = data; } -READ8_MEMBER( cgenie_state::cgenie_status_r ) -{ - fd1793_device *fdc = machine().device("wd179x"); - /* If the floppy isn't emulated, return 0 */ - if( (ioport("DSW0")->read() & 0x80) == 0 ) - return 0; - return fdc->status_r(space, offset); -} - -READ8_MEMBER( cgenie_state::cgenie_track_r ) -{ - fd1793_device *fdc = machine().device("wd179x"); - /* If the floppy isn't emulated, return 0xff */ - if( (ioport("DSW0")->read() & 0x80) == 0 ) - return 0xff; - return fdc->track_r(space, offset); -} - -READ8_MEMBER( cgenie_state::cgenie_sector_r ) -{ - fd1793_device *fdc = machine().device("wd179x"); - /* If the floppy isn't emulated, return 0xff */ - if( (ioport("DSW0")->read() & 0x80) == 0 ) - return 0xff; - return fdc->sector_r(space, offset); -} - -READ8_MEMBER( cgenie_state::cgenie_data_r ) -{ - fd1793_device *fdc = machine().device("wd179x"); - /* If the floppy isn't emulated, return 0xff */ - if( (ioport("DSW0")->read() & 0x80) == 0 ) - return 0xff; - return fdc->data_r(space, offset); -} - -WRITE8_MEMBER( cgenie_state::cgenie_command_w ) -{ - fd1793_device *fdc = machine().device("wd179x"); - /* If the floppy isn't emulated, return immediately */ - if( (ioport("DSW0")->read() & 0x80) == 0 ) - return; - fdc->command_w(space, offset, data); -} - -WRITE8_MEMBER( cgenie_state::cgenie_track_w ) -{ - fd1793_device *fdc = machine().device("wd179x"); - /* If the floppy isn't emulated, ignore the write */ - if( (ioport("DSW0")->read() & 0x80) == 0 ) - return; - fdc->track_w(space, offset, data); -} - -WRITE8_MEMBER( cgenie_state::cgenie_sector_w ) -{ - fd1793_device *fdc = machine().device("wd179x"); - /* If the floppy isn't emulated, ignore the write */ - if( (ioport("DSW0")->read() & 0x80) == 0 ) - return; - fdc->sector_w(space, offset, data); -} - -WRITE8_MEMBER( cgenie_state::cgenie_data_w ) -{ - fd1793_device *fdc = machine().device("wd179x"); - /* If the floppy isn't emulated, ignore the write */ - if( (ioport("DSW0")->read() & 0x80) == 0 ) - return; - fdc->data_w(space, offset, data); -} - READ8_MEMBER( cgenie_state::cgenie_irq_status_r ) { int result = m_irq_status; - m_irq_status &= ~(IRQ_TIMER | IRQ_FDC); + m_irq_status &= ~(IRQ_TIMER); return result; } @@ -408,54 +291,17 @@ INTERRUPT_GEN_MEMBER(cgenie_state::cgenie_timer_interrupt) } } -WRITE_LINE_MEMBER(cgenie_state::cgenie_fdc_intrq_w) +WRITE_LINE_MEMBER( cgenie_state::exp_intrq_w ) { - /* if disc hardware is not enabled, do not cause an int */ - if (!( ioport("DSW0")->read() & 0x80 )) - return; + m_irq_status &= ~IRQ_FDC; + m_irq_status |= state << 6; - if (state) - { - if( (m_irq_status & IRQ_FDC) == 0 ) - { - m_irq_status |= IRQ_FDC; - m_maincpu->set_input_line(0, HOLD_LINE); - } - } + if (m_irq_status) + m_maincpu->set_input_line(INPUT_LINE_IRQ0, ASSERT_LINE); else - { - m_irq_status &= ~IRQ_FDC; - } + m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE); } -WRITE8_MEMBER( cgenie_state::cgenie_motor_w ) -{ - fd1793_device *fdc = machine().device("wd179x"); - UINT8 drive = 255; - - logerror("cgenie motor_w $%02X\n", data); - - if( data & 1 ) - drive = 0; - if( data & 2 ) - drive = 1; - if( data & 4 ) - drive = 2; - if( data & 8 ) - drive = 3; - - if( drive > 3 ) - return; - - /* mask head select bit */ - m_head = (data >> 4) & 1; - - /* currently selected drive */ - m_motor_drive = drive; - - fdc->set_drive(drive); - fdc->set_side(m_head); -} /************************************* * Keyboard *