trunk/src/emu/bus/a2bus/corvfdc01.c
r0 | r32442 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | corvfdc01.c |
| 4 | |
| 5 | Implemention of the Corvus Systems CORVUS01 floppy controller |
| 6 | |
| 7 | Boot PROM 0.8 fixes this at: 8", 500 blocks total, 128 bytes/block, |
| 8 | 26 sectors/track, 77 tracks. |
| 9 | |
| 10 | *********************************************************************/ |
| 11 | |
| 12 | #include "corvfdc01.h" |
| 13 | |
| 14 | /*************************************************************************** |
| 15 | PARAMETERS |
| 16 | ***************************************************************************/ |
| 17 | |
| 18 | //************************************************************************** |
| 19 | // GLOBAL VARIABLES |
| 20 | //************************************************************************** |
| 21 | |
| 22 | const device_type A2BUS_CORVFDC01 = &device_creator<a2bus_corvfdc01_device>; |
| 23 | |
| 24 | #define FDC01_ROM_REGION "fdc01_rom" |
| 25 | #define FDC01_FDC_TAG "fdc01_fdc" |
| 26 | |
| 27 | FLOPPY_FORMATS_MEMBER( a2bus_corvfdc01_device::corv_floppy_formats ) |
| 28 | FLOPPY_IMD_FORMAT |
| 29 | FLOPPY_FORMATS_END |
| 30 | |
| 31 | static SLOT_INTERFACE_START( corv_floppies ) |
| 32 | SLOT_INTERFACE( "8dssd", FLOPPY_8_DSSD ) |
| 33 | SLOT_INTERFACE_END |
| 34 | |
| 35 | MACHINE_CONFIG_FRAGMENT( fdc01 ) |
| 36 | MCFG_FD1793x_ADD(FDC01_FDC_TAG, XTAL_16MHz / 8) |
| 37 | MCFG_WD_FDC_INTRQ_CALLBACK(WRITELINE(a2bus_corvfdc01_device, intrq_w)) |
| 38 | MCFG_WD_FDC_DRQ_CALLBACK(WRITELINE(a2bus_corvfdc01_device, drq_w)) |
| 39 | MCFG_FLOPPY_DRIVE_ADD(FDC01_FDC_TAG":0", corv_floppies, "8dssd", a2bus_corvfdc01_device::corv_floppy_formats) |
| 40 | MCFG_FLOPPY_DRIVE_ADD(FDC01_FDC_TAG":1", corv_floppies, "8dssd", a2bus_corvfdc01_device::corv_floppy_formats) |
| 41 | MCFG_FLOPPY_DRIVE_ADD(FDC01_FDC_TAG":2", corv_floppies, "8dssd", a2bus_corvfdc01_device::corv_floppy_formats) |
| 42 | MCFG_FLOPPY_DRIVE_ADD(FDC01_FDC_TAG":3", corv_floppies, "8dssd", a2bus_corvfdc01_device::corv_floppy_formats) |
| 43 | MACHINE_CONFIG_END |
| 44 | |
| 45 | ROM_START( fdc01 ) |
| 46 | ROM_REGION(0x20, FDC01_ROM_REGION, 0) |
| 47 | ROM_LOAD( "ff01.bin", 0x000000, 0x000020, CRC(ad3c1136) SHA1(b1e1e8a10618588b1b44b3be5d88857497f30b33) ) |
| 48 | ROM_END |
| 49 | |
| 50 | enum |
| 51 | { |
| 52 | LS_DRQ_bit = 0, // DRQ |
| 53 | LS_INT_bit = 1, // INT |
| 54 | LS_SS_bit = 4, // 1 if single-sided (floppy or drive?) |
| 55 | LS_8IN_bit = 5, // 1 if 8" floppy drive? |
| 56 | LS_DSKCHG_bit = 6, // 0 if disk changed, 1 if not |
| 57 | LS_SD_bit = 7, // 1 if single density |
| 58 | |
| 59 | LS_DRQ_mask = (1 << LS_DRQ_bit), |
| 60 | LS_INT_mask = (1 << LS_INT_bit), |
| 61 | LS_SS_mask = (1 << LS_SS_bit), |
| 62 | LS_8IN_mask = (1 << LS_8IN_bit), |
| 63 | LS_DSKCHG_mask = (1 << LS_DSKCHG_bit), |
| 64 | LS_SD_mask = (1 << LS_SD_bit) |
| 65 | }; |
| 66 | |
| 67 | enum |
| 68 | { |
| 69 | LC_FLPSD1_bit = 0, // 0 if side 0 , 1 if side 1 |
| 70 | LC_DE0_bit = 1, // drive select bit 0 |
| 71 | LC_DE1_bit = 4, // drive select bit 1 |
| 72 | LC_MOTOROF_bit = 5, // 1 if motor to be turned off |
| 73 | LC_FLP8IN_bit = 6, // 1 to select 8", 0 for 5"1/4 (which I knew what it means) |
| 74 | LC_FMMFM_bit = 7, // 1 to select single density, 0 for double |
| 75 | |
| 76 | LC_FLPSD1_mask = (1 << LC_FLPSD1_bit), |
| 77 | LC_DE0_mask = (1 << LC_DE0_bit), |
| 78 | LC_DE1_mask = (1 << LC_DE1_bit), |
| 79 | LC_MOTOROF_mask = (1 << LC_MOTOROF_bit), |
| 80 | LC_FLP8IN_mask = (1 << LC_FLP8IN_bit), |
| 81 | LC_FMMFM_mask = (1 << LC_FMMFM_bit) |
| 82 | }; |
| 83 | |
| 84 | /*************************************************************************** |
| 85 | FUNCTION PROTOTYPES |
| 86 | ***************************************************************************/ |
| 87 | |
| 88 | //------------------------------------------------- |
| 89 | // machine_config_additions - device-specific |
| 90 | // machine configurations |
| 91 | //------------------------------------------------- |
| 92 | |
| 93 | machine_config_constructor a2bus_corvfdc01_device::device_mconfig_additions() const |
| 94 | { |
| 95 | return MACHINE_CONFIG_NAME( fdc01 ); |
| 96 | } |
| 97 | |
| 98 | //------------------------------------------------- |
| 99 | // rom_region - device-specific ROM region |
| 100 | //------------------------------------------------- |
| 101 | |
| 102 | const rom_entry *a2bus_corvfdc01_device::device_rom_region() const |
| 103 | { |
| 104 | return ROM_NAME( fdc01 ); |
| 105 | } |
| 106 | |
| 107 | //************************************************************************** |
| 108 | // LIVE DEVICE |
| 109 | //************************************************************************** |
| 110 | |
| 111 | a2bus_corvfdc01_device::a2bus_corvfdc01_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : |
| 112 | device_t(mconfig, type, name, tag, owner, clock, shortname, source), |
| 113 | device_a2bus_card_interface(mconfig, *this), |
| 114 | m_wdfdc(*this, FDC01_FDC_TAG), |
| 115 | m_con1(*this, FDC01_FDC_TAG":0"), |
| 116 | m_con2(*this, FDC01_FDC_TAG":1"), |
| 117 | m_con3(*this, FDC01_FDC_TAG":2"), |
| 118 | m_con4(*this, FDC01_FDC_TAG":3") |
| 119 | { |
| 120 | } |
| 121 | |
| 122 | a2bus_corvfdc01_device::a2bus_corvfdc01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 123 | device_t(mconfig, A2BUS_CORVFDC01, "Corvus Systems Floppy Controller", tag, owner, clock, "crvfdc01", __FILE__), |
| 124 | device_a2bus_card_interface(mconfig, *this), |
| 125 | m_wdfdc(*this, FDC01_FDC_TAG), |
| 126 | m_con1(*this, FDC01_FDC_TAG":0"), |
| 127 | m_con2(*this, FDC01_FDC_TAG":1"), |
| 128 | m_con3(*this, FDC01_FDC_TAG":2"), |
| 129 | m_con4(*this, FDC01_FDC_TAG":3") |
| 130 | { |
| 131 | } |
| 132 | |
| 133 | //------------------------------------------------- |
| 134 | // device_start - device-specific startup |
| 135 | //------------------------------------------------- |
| 136 | |
| 137 | void a2bus_corvfdc01_device::device_start() |
| 138 | { |
| 139 | // set_a2bus_device makes m_slot valid |
| 140 | set_a2bus_device(); |
| 141 | |
| 142 | astring tempstring; |
| 143 | m_rom = device().machine().root_device().memregion(this->subtag(tempstring, FDC01_ROM_REGION))->base(); |
| 144 | |
| 145 | save_item(NAME(m_fdc_local_status)); |
| 146 | save_item(NAME(m_fdc_local_command)); |
| 147 | } |
| 148 | |
| 149 | void a2bus_corvfdc01_device::device_reset() |
| 150 | { |
| 151 | m_fdc_local_status = 0; |
| 152 | m_fdc_local_command = 0; |
| 153 | m_curfloppy = NULL; |
| 154 | } |
| 155 | |
| 156 | /*------------------------------------------------- |
| 157 | read_c0nx - called for reads from this card's c0nx space |
| 158 | -------------------------------------------------*/ |
| 159 | |
| 160 | UINT8 a2bus_corvfdc01_device::read_c0nx(address_space &space, UINT8 offset) |
| 161 | { |
| 162 | switch (offset) |
| 163 | { |
| 164 | case 0: // local status |
| 165 | if (m_curfloppy) |
| 166 | { |
| 167 | m_fdc_local_status &= ~LS_DSKCHG_mask; |
| 168 | m_fdc_local_status |= m_curfloppy->dskchg_r() ? LS_DSKCHG_mask : 0; |
| 169 | } |
| 170 | return m_fdc_local_status; |
| 171 | |
| 172 | case 8: // WD1793 at 8-11 |
| 173 | return m_wdfdc->status_r(space, offset); |
| 174 | |
| 175 | case 9: |
| 176 | return m_wdfdc->track_r(space, offset); |
| 177 | |
| 178 | case 10: |
| 179 | return m_wdfdc->sector_r(space, offset); |
| 180 | |
| 181 | case 11: |
| 182 | return m_wdfdc->data_r(space, offset); |
| 183 | } |
| 184 | |
| 185 | return 0xff; |
| 186 | } |
| 187 | |
| 188 | |
| 189 | /*------------------------------------------------- |
| 190 | write_c0nx - called for writes to this card's c0nx space |
| 191 | -------------------------------------------------*/ |
| 192 | |
| 193 | void a2bus_corvfdc01_device::write_c0nx(address_space &space, UINT8 offset, UINT8 data) |
| 194 | { |
| 195 | int current_drive; |
| 196 | floppy_image_device *floppy; |
| 197 | |
| 198 | switch (offset) |
| 199 | { |
| 200 | case 0: // LOCAL COMMAND REG |
| 201 | m_fdc_local_command = data; |
| 202 | |
| 203 | current_drive = ((data >> LC_DE0_bit) & 1) | ((data >> (LC_DE1_bit-1)) & 2); |
| 204 | switch (current_drive) |
| 205 | { |
| 206 | case 0: |
| 207 | floppy = m_con1 ? m_con1->get_device() : 0; |
| 208 | break; |
| 209 | case 1: |
| 210 | floppy = m_con2 ? m_con2->get_device() : 0; |
| 211 | break; |
| 212 | case 2: |
| 213 | floppy = m_con3 ? m_con3->get_device() : 0; |
| 214 | break; |
| 215 | case 3: |
| 216 | floppy = m_con4 ? m_con4->get_device() : 0; |
| 217 | break; |
| 218 | } |
| 219 | |
| 220 | if (floppy != m_curfloppy) |
| 221 | { |
| 222 | m_wdfdc->set_floppy(floppy); |
| 223 | } |
| 224 | |
| 225 | if (m_curfloppy != NULL) |
| 226 | { |
| 227 | // side select |
| 228 | m_curfloppy->ss_w((data & LC_FLPSD1_mask) != 0); |
| 229 | |
| 230 | // motor control (active low) |
| 231 | m_curfloppy->mon_w((data & LC_MOTOROF_mask) ? 1 : 0); |
| 232 | } |
| 233 | |
| 234 | /*flp_8in = (data & LC_FLP8IN_mask) != 0;*/ |
| 235 | |
| 236 | m_wdfdc->dden_w(BIT(data, LC_FMMFM_bit)); |
| 237 | break; |
| 238 | |
| 239 | case 8: // FDC COMMAMD REG |
| 240 | m_wdfdc->cmd_w(space, offset, data); |
| 241 | break; |
| 242 | |
| 243 | case 9: // FDC TRACK REG |
| 244 | m_wdfdc->track_w(space, offset, data); |
| 245 | break; |
| 246 | |
| 247 | case 10: // FDC SECTOR REG |
| 248 | m_wdfdc->sector_w(space, offset, data); |
| 249 | break; |
| 250 | |
| 251 | case 11: // FDC DATA REG |
| 252 | m_wdfdc->data_w(space, offset, data); |
| 253 | break; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | /*------------------------------------------------- |
| 258 | read_cnxx - called for reads from this card's cnxx space |
| 259 | -------------------------------------------------*/ |
| 260 | |
| 261 | UINT8 a2bus_corvfdc01_device::read_cnxx(address_space &space, UINT8 offset) |
| 262 | { |
| 263 | return m_rom[offset & 0x1f]; |
| 264 | } |
| 265 | |
| 266 | WRITE_LINE_MEMBER(a2bus_corvfdc01_device::intrq_w) |
| 267 | { |
| 268 | if (state) |
| 269 | m_fdc_local_status |= LS_INT_mask; |
| 270 | else |
| 271 | m_fdc_local_status &= ~LS_INT_mask; |
| 272 | } |
| 273 | |
| 274 | WRITE_LINE_MEMBER(a2bus_corvfdc01_device::drq_w) |
| 275 | { |
| 276 | if (state) |
| 277 | m_fdc_local_status |= LS_DRQ_mask; |
| 278 | else |
| 279 | m_fdc_local_status &= ~LS_DRQ_mask; |
| 280 | } |
| 281 | |
trunk/src/emu/bus/a2bus/corvfdc01.h
r0 | r32442 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | corvfdc01.h |
| 4 | |
| 5 | Implemention of the Corvus Systems CORVUS01 floppy controller |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #ifndef __A2BUS_CORVFDC01__ |
| 10 | #define __A2BUS_CORVFDC01__ |
| 11 | |
| 12 | #include "emu.h" |
| 13 | #include "a2bus.h" |
| 14 | #include "machine/wd_fdc.h" |
| 15 | #include "formats/imd_dsk.h" |
| 16 | |
| 17 | //************************************************************************** |
| 18 | // TYPE DEFINITIONS |
| 19 | //************************************************************************** |
| 20 | |
| 21 | class a2bus_corvfdc01_device: |
| 22 | public device_t, |
| 23 | public device_a2bus_card_interface |
| 24 | { |
| 25 | public: |
| 26 | // construction/destruction |
| 27 | a2bus_corvfdc01_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); |
| 28 | a2bus_corvfdc01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 29 | |
| 30 | // optional information overrides |
| 31 | virtual machine_config_constructor device_mconfig_additions() const; |
| 32 | virtual const rom_entry *device_rom_region() const; |
| 33 | |
| 34 | DECLARE_WRITE_LINE_MEMBER(intrq_w); |
| 35 | DECLARE_WRITE_LINE_MEMBER(drq_w); |
| 36 | |
| 37 | DECLARE_FLOPPY_FORMATS(corv_floppy_formats); |
| 38 | |
| 39 | protected: |
| 40 | virtual void device_start(); |
| 41 | virtual void device_reset(); |
| 42 | |
| 43 | // overrides of standard a2bus slot functions |
| 44 | virtual UINT8 read_c0nx(address_space &space, UINT8 offset); |
| 45 | virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data); |
| 46 | virtual UINT8 read_cnxx(address_space &space, UINT8 offset); |
| 47 | |
| 48 | required_device<fd1793_t> m_wdfdc; |
| 49 | required_device<floppy_connector> m_con1; |
| 50 | required_device<floppy_connector> m_con2; |
| 51 | required_device<floppy_connector> m_con3; |
| 52 | required_device<floppy_connector> m_con4; |
| 53 | |
| 54 | private: |
| 55 | UINT8 *m_rom; |
| 56 | UINT8 m_fdc_local_status, m_fdc_local_command; |
| 57 | floppy_image_device *m_curfloppy; |
| 58 | }; |
| 59 | |
| 60 | // device type definition |
| 61 | extern const device_type A2BUS_CORVFDC01; |
| 62 | |
| 63 | #endif /* __A2BUS_CORVFDC01__ */ |
trunk/src/emu/bus/a2bus/corvfdc02.c
r0 | r32442 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | corvfdc02.c |
| 4 | |
| 5 | Implemention of the Corvus Systems CORVUS02 floppy controller |
| 6 | aka the "Buffered Floppy Controller" |
| 7 | |
| 8 | Boot PROM 0.8 says 8" DSDD or 5.25" DSDD |
| 9 | |
| 10 | *********************************************************************/ |
| 11 | |
| 12 | #include "corvfdc02.h" |
| 13 | |
| 14 | /*************************************************************************** |
| 15 | PARAMETERS |
| 16 | ***************************************************************************/ |
| 17 | |
| 18 | //************************************************************************** |
| 19 | // GLOBAL VARIABLES |
| 20 | //************************************************************************** |
| 21 | |
| 22 | const device_type A2BUS_CORVFDC02 = &device_creator<a2bus_corvfdc02_device>; |
| 23 | |
| 24 | #define FDC02_ROM_REGION "fdc02_rom" |
| 25 | #define FDC02_FDC_TAG "fdc02_fdc" |
| 26 | |
| 27 | FLOPPY_FORMATS_MEMBER( a2bus_corvfdc02_device::corv_floppy_formats ) |
| 28 | FLOPPY_IMD_FORMAT |
| 29 | FLOPPY_FORMATS_END |
| 30 | |
| 31 | static SLOT_INTERFACE_START( corv_floppies ) |
| 32 | SLOT_INTERFACE( "8dsdd", FLOPPY_8_DSDD ) |
| 33 | SLOT_INTERFACE( "525dsqd", FLOPPY_525_QD ) |
| 34 | SLOT_INTERFACE_END |
| 35 | |
| 36 | MACHINE_CONFIG_FRAGMENT( fdc02 ) |
| 37 | MCFG_UPD765A_ADD(FDC02_FDC_TAG, true, false) |
| 38 | MCFG_UPD765_INTRQ_CALLBACK(WRITELINE(a2bus_corvfdc02_device, intrq_w)) |
| 39 | MCFG_UPD765_DRQ_CALLBACK(WRITELINE(a2bus_corvfdc02_device, drq_w)) |
| 40 | MCFG_FLOPPY_DRIVE_ADD(FDC02_FDC_TAG":0", corv_floppies, "525dsqd", a2bus_corvfdc02_device::corv_floppy_formats) |
| 41 | MCFG_FLOPPY_DRIVE_ADD(FDC02_FDC_TAG":1", corv_floppies, "525dsqd", a2bus_corvfdc02_device::corv_floppy_formats) |
| 42 | MCFG_FLOPPY_DRIVE_ADD(FDC02_FDC_TAG":2", corv_floppies, "525dsqd", a2bus_corvfdc02_device::corv_floppy_formats) |
| 43 | MCFG_FLOPPY_DRIVE_ADD(FDC02_FDC_TAG":3", corv_floppies, "525dsqd", a2bus_corvfdc02_device::corv_floppy_formats) |
| 44 | MACHINE_CONFIG_END |
| 45 | |
| 46 | ROM_START( fdc02 ) |
| 47 | ROM_REGION(0x20, FDC02_ROM_REGION, 0) |
| 48 | ROM_LOAD( "bfc00.bin", 0x000000, 0x000020, CRC(98d1a765) SHA1(d27c3c6921e1bb3778a3f78decf106275bc0add1) ) |
| 49 | ROM_END |
| 50 | |
| 51 | /*************************************************************************** |
| 52 | FUNCTION PROTOTYPES |
| 53 | ***************************************************************************/ |
| 54 | |
| 55 | //------------------------------------------------- |
| 56 | // machine_config_additions - device-specific |
| 57 | // machine configurations |
| 58 | //------------------------------------------------- |
| 59 | |
| 60 | machine_config_constructor a2bus_corvfdc02_device::device_mconfig_additions() const |
| 61 | { |
| 62 | return MACHINE_CONFIG_NAME( fdc02 ); |
| 63 | } |
| 64 | |
| 65 | //------------------------------------------------- |
| 66 | // rom_region - device-specific ROM region |
| 67 | //------------------------------------------------- |
| 68 | |
| 69 | const rom_entry *a2bus_corvfdc02_device::device_rom_region() const |
| 70 | { |
| 71 | return ROM_NAME( fdc02 ); |
| 72 | } |
| 73 | |
| 74 | //************************************************************************** |
| 75 | // LIVE DEVICE |
| 76 | //************************************************************************** |
| 77 | |
| 78 | a2bus_corvfdc02_device::a2bus_corvfdc02_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : |
| 79 | device_t(mconfig, type, name, tag, owner, clock, shortname, source), |
| 80 | device_a2bus_card_interface(mconfig, *this), |
| 81 | m_fdc(*this, FDC02_FDC_TAG), |
| 82 | m_con1(*this, FDC02_FDC_TAG":0"), |
| 83 | m_con2(*this, FDC02_FDC_TAG":1"), |
| 84 | m_con3(*this, FDC02_FDC_TAG":2"), |
| 85 | m_con4(*this, FDC02_FDC_TAG":3") |
| 86 | { |
| 87 | |
| 88 | } |
| 89 | |
| 90 | a2bus_corvfdc02_device::a2bus_corvfdc02_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 91 | device_t(mconfig, A2BUS_CORVFDC02, "Corvus Systems Buffered Floppy Controller", tag, owner, clock, "crvfdc02", __FILE__), |
| 92 | device_a2bus_card_interface(mconfig, *this), |
| 93 | m_fdc(*this, FDC02_FDC_TAG), |
| 94 | m_con1(*this, FDC02_FDC_TAG":0"), |
| 95 | m_con2(*this, FDC02_FDC_TAG":1"), |
| 96 | m_con3(*this, FDC02_FDC_TAG":2"), |
| 97 | m_con4(*this, FDC02_FDC_TAG":3") |
| 98 | { |
| 99 | } |
| 100 | |
| 101 | //------------------------------------------------- |
| 102 | // device_start - device-specific startup |
| 103 | //------------------------------------------------- |
| 104 | |
| 105 | void a2bus_corvfdc02_device::device_start() |
| 106 | { |
| 107 | // set_a2bus_device makes m_slot valid |
| 108 | set_a2bus_device(); |
| 109 | |
| 110 | astring tempstring; |
| 111 | m_rom = device().machine().root_device().memregion(this->subtag(tempstring, FDC02_ROM_REGION))->base(); |
| 112 | |
| 113 | save_item(NAME(m_fdc_local_status)); |
| 114 | save_item(NAME(m_fdc_local_command)); |
| 115 | save_item(NAME(m_bufptr)); |
| 116 | save_item(NAME(m_buffer)); |
| 117 | } |
| 118 | |
| 119 | void a2bus_corvfdc02_device::device_reset() |
| 120 | { |
| 121 | m_fdc_local_status = 2; |
| 122 | m_fdc_local_command = 0; |
| 123 | m_curfloppy = NULL; |
| 124 | } |
| 125 | |
| 126 | /*------------------------------------------------- |
| 127 | read_c0nx - called for reads from this card's c0nx space |
| 128 | -------------------------------------------------*/ |
| 129 | |
| 130 | UINT8 a2bus_corvfdc02_device::read_c0nx(address_space &space, UINT8 offset) |
| 131 | { |
| 132 | switch (offset) |
| 133 | { |
| 134 | case 0: // 765 FIFO |
| 135 | return m_fdc->fifo_r(space, 0); |
| 136 | |
| 137 | case 1: // 765 MSR |
| 138 | return m_fdc->msr_r(space, 0); |
| 139 | |
| 140 | case 2: // buffer address |
| 141 | return (m_bufptr>>1) & 0xff; |
| 142 | |
| 143 | case 3: |
| 144 | // printf("Read buffer @ %x = %02x\n", m_bufptr, m_buffer[m_bufptr]); |
| 145 | return m_buffer[m_bufptr]; |
| 146 | |
| 147 | case 4: // local status |
| 148 | if (m_curfloppy) |
| 149 | { |
| 150 | m_fdc_local_status &= ~(1 | 0x40); |
| 151 | m_fdc_local_status |= m_curfloppy->dskchg_r() ? 1 : 0; |
| 152 | m_fdc_local_status |= m_curfloppy->ready_r() ? 0x40 : 0; |
| 153 | } |
| 154 | return m_fdc_local_status; |
| 155 | break; |
| 156 | } |
| 157 | |
| 158 | return 0xff; |
| 159 | } |
| 160 | |
| 161 | |
| 162 | /*------------------------------------------------- |
| 163 | write_c0nx - called for writes to this card's c0nx space |
| 164 | -------------------------------------------------*/ |
| 165 | |
| 166 | void a2bus_corvfdc02_device::write_c0nx(address_space &space, UINT8 offset, UINT8 data) |
| 167 | { |
| 168 | floppy_image_device *floppy = NULL; |
| 169 | |
| 170 | switch (offset) |
| 171 | { |
| 172 | case 0: // FDC FIFO write |
| 173 | m_fdc->fifo_w(space, offset, data); |
| 174 | break; |
| 175 | |
| 176 | case 1: // FDC ??? |
| 177 | break; |
| 178 | |
| 179 | case 2: // buffer address |
| 180 | m_bufptr = (data << 1) | (data & 1); |
| 181 | // printf("%02x to buffer address yields %x\n", data, m_bufptr); |
| 182 | break; |
| 183 | |
| 184 | case 3: // buffer write |
| 185 | // printf("%02x to buffer @ %x\n", data, m_bufptr); |
| 186 | m_buffer[m_bufptr--] = data; |
| 187 | break; |
| 188 | |
| 189 | case 4: // LOCAL COMMAND REG |
| 190 | m_fdc_local_command = data; |
| 191 | |
| 192 | // drive select enabled? |
| 193 | if (data & 4) |
| 194 | { |
| 195 | switch (data & 3) |
| 196 | { |
| 197 | case 0: |
| 198 | floppy = m_con1 ? m_con1->get_device() : 0; |
| 199 | break; |
| 200 | case 1: |
| 201 | floppy = m_con2 ? m_con2->get_device() : 0; |
| 202 | break; |
| 203 | case 2: |
| 204 | floppy = m_con3 ? m_con3->get_device() : 0; |
| 205 | break; |
| 206 | case 3: |
| 207 | floppy = m_con4 ? m_con4->get_device() : 0; |
| 208 | break; |
| 209 | } |
| 210 | |
| 211 | logerror("corvfdc02: selecting drive %d: %p\n", data & 3, floppy); |
| 212 | |
| 213 | if (floppy != m_curfloppy) |
| 214 | { |
| 215 | m_fdc->set_floppy(floppy); |
| 216 | m_curfloppy = floppy; |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | if (m_curfloppy != NULL) |
| 221 | { |
| 222 | // motor control (active low) |
| 223 | m_curfloppy->mon_w((data & 8) ? 1 : 0); |
| 224 | // printf("Cur drive %p motor %s\n", m_curfloppy, (data & 8) ? "OFF" : "ON"); |
| 225 | } |
| 226 | |
| 227 | if (data & 0x80) |
| 228 | { |
| 229 | // printf("Reset NEC765\n"); |
| 230 | m_fdc->reset(); |
| 231 | } |
| 232 | break; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | /*------------------------------------------------- |
| 237 | read_cnxx - called for reads from this card's cnxx space |
| 238 | -------------------------------------------------*/ |
| 239 | |
| 240 | UINT8 a2bus_corvfdc02_device::read_cnxx(address_space &space, UINT8 offset) |
| 241 | { |
| 242 | return m_rom[offset & 0x1f]; |
| 243 | } |
| 244 | |
| 245 | WRITE_LINE_MEMBER(a2bus_corvfdc02_device::intrq_w) |
| 246 | { |
| 247 | if (state) |
| 248 | { |
| 249 | m_fdc_local_status &= ~2; // indicate IRQ occured |
| 250 | if (m_fdc_local_command & 0x20) |
| 251 | { |
| 252 | raise_slot_irq(); |
| 253 | } |
| 254 | } |
| 255 | else |
| 256 | { |
| 257 | m_fdc_local_status |= 2; // clear IRQ |
| 258 | lower_slot_irq(); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | WRITE_LINE_MEMBER(a2bus_corvfdc02_device::drq_w) |
| 263 | { |
| 264 | // printf("DRQ: %d\n", state); |
| 265 | } |
| 266 | |
trunk/src/emu/bus/a2bus/corvfdc02.h
r0 | r32442 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | corvfdc02.h |
| 4 | |
| 5 | Implemention of the Corvus Systems CORVUS02 floppy controller |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #ifndef __A2BUS_CORVFDC02__ |
| 10 | #define __A2BUS_CORVFDC02__ |
| 11 | |
| 12 | #include "emu.h" |
| 13 | #include "a2bus.h" |
| 14 | #include "machine/upd765.h" |
| 15 | #include "formats/imd_dsk.h" |
| 16 | |
| 17 | //************************************************************************** |
| 18 | // TYPE DEFINITIONS |
| 19 | //************************************************************************** |
| 20 | |
| 21 | class a2bus_corvfdc02_device: |
| 22 | public device_t, |
| 23 | public device_a2bus_card_interface |
| 24 | { |
| 25 | public: |
| 26 | // construction/destruction |
| 27 | a2bus_corvfdc02_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); |
| 28 | a2bus_corvfdc02_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 29 | |
| 30 | // optional information overrides |
| 31 | virtual machine_config_constructor device_mconfig_additions() const; |
| 32 | virtual const rom_entry *device_rom_region() const; |
| 33 | |
| 34 | DECLARE_WRITE_LINE_MEMBER(intrq_w); |
| 35 | DECLARE_WRITE_LINE_MEMBER(drq_w); |
| 36 | |
| 37 | DECLARE_FLOPPY_FORMATS(corv_floppy_formats); |
| 38 | |
| 39 | protected: |
| 40 | virtual void device_start(); |
| 41 | virtual void device_reset(); |
| 42 | |
| 43 | // overrides of standard a2bus slot functions |
| 44 | virtual UINT8 read_c0nx(address_space &space, UINT8 offset); |
| 45 | virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data); |
| 46 | virtual UINT8 read_cnxx(address_space &space, UINT8 offset); |
| 47 | |
| 48 | required_device<upd765a_device> m_fdc; |
| 49 | required_device<floppy_connector> m_con1; |
| 50 | required_device<floppy_connector> m_con2; |
| 51 | required_device<floppy_connector> m_con3; |
| 52 | required_device<floppy_connector> m_con4; |
| 53 | |
| 54 | private: |
| 55 | UINT8 *m_rom; |
| 56 | UINT8 m_fdc_local_status, m_fdc_local_command; |
| 57 | UINT16 m_bufptr; |
| 58 | UINT8 m_buffer[2048]; // 1x6116 SRAM |
| 59 | floppy_image_device *m_curfloppy; |
| 60 | }; |
| 61 | |
| 62 | // device type definition |
| 63 | extern const device_type A2BUS_CORVFDC02; |
| 64 | |
| 65 | #endif /* __A2BUS_CORVFDC02__ */ |