trunk/src/lib/formats/trd_dsk.c
| r243405 | r243406 | |
| 6 | 6 | |
| 7 | 7 | *********************************************************************/ |
| 8 | 8 | |
| 9 | | #include <string.h> |
| 9 | #include "emu.h" |
| 10 | #include "formats/trd_dsk.h" |
| 10 | 11 | |
| 11 | | #include "trd_dsk.h" |
| 12 | | #include "basicdsk.h" |
| 12 | trd_format::trd_format() : wd177x_format(formats) |
| 13 | { |
| 14 | } |
| 13 | 15 | |
| 14 | | |
| 15 | | static FLOPPY_IDENTIFY(trd_dsk_identify) |
| 16 | const char *trd_format::name() const |
| 16 | 17 | { |
| 17 | | *vote = 100; |
| 18 | | return FLOPPY_ERROR_SUCCESS; |
| 18 | return "trd"; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | | static FLOPPY_CONSTRUCT(trd_dsk_construct) |
| 21 | const char *trd_format::description() const |
| 22 | 22 | { |
| 23 | | struct basicdsk_geometry geometry; |
| 24 | | UINT8 data[1]; |
| 25 | | int heads; |
| 26 | | int cylinders; |
| 23 | return "TRD floppy disk image"; |
| 24 | } |
| 27 | 25 | |
| 28 | | floppy_image_read( floppy, data, 0x8e3 , 1 ); |
| 29 | | |
| 30 | | /* guess geometry of disk */ |
| 31 | | heads = data[0] & 0x08 ? 1 : 2; |
| 32 | | cylinders = data[0] & 0x01 ? 40 : 80; |
| 33 | | |
| 34 | | memset(&geometry, 0, sizeof(geometry)); |
| 35 | | geometry.heads = heads; |
| 36 | | geometry.first_sector_id = 1; |
| 37 | | geometry.sector_length = 256; |
| 38 | | geometry.tracks = cylinders; |
| 39 | | geometry.sectors = 16; |
| 40 | | return basicdsk_construct(floppy, &geometry); |
| 26 | const char *trd_format::extensions() const |
| 27 | { |
| 28 | return "trd"; |
| 41 | 29 | } |
| 42 | 30 | |
| 31 | const trd_format::format trd_format::formats[] = { |
| 32 | { // 5"25 640K double density |
| 33 | floppy_image::FF_525, floppy_image::DSQD, floppy_image::MFM, |
| 34 | // GAP4A - 0(!) bytes, GAP1 - 10 bytes, GAP2 - 22 bytes, GAP3 - 60 bytes, GAP4B - upto track end |
| 35 | 2000, 16, 80, 2, 256, {}, 1, {}, 10, 22, 60 |
| 36 | }, |
| 37 | {} |
| 38 | }; |
| 43 | 39 | |
| 44 | | |
| 45 | | /* ----------------------------------------------------------------------- */ |
| 46 | | |
| 47 | | LEGACY_FLOPPY_OPTIONS_START( trd ) |
| 48 | | LEGACY_FLOPPY_OPTION( trd_dsk, "trd", "TRD floppy disk image", trd_dsk_identify, trd_dsk_construct, NULL, NULL) |
| 49 | | LEGACY_FLOPPY_OPTIONS_END |
| 40 | const floppy_format_type FLOPPY_TRD_FORMAT = &floppy_image_format_creator<trd_format>; |
trunk/src/mess/machine/beta.c
| r243405 | r243406 | |
| 14 | 14 | |
| 15 | 15 | */ |
| 16 | 16 | #include "emu.h" |
| 17 | | #include "imagedev/flopdrv.h" |
| 18 | 17 | #include "formats/trd_dsk.h" |
| 19 | 18 | #include "machine/beta.h" |
| 20 | 19 | |
| r243405 | r243406 | |
| 27 | 26 | const device_type BETA_DISK = &device_creator<beta_disk_device>; |
| 28 | 27 | |
| 29 | 28 | beta_disk_device::beta_disk_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 30 | | : device_t(mconfig, BETA_DISK, "Beta Disk Interface", tag, owner, clock, "betadisk", __FILE__), |
| 31 | | m_betadisk_status(0), |
| 32 | | m_betadisk_active(0) |
| 29 | : device_t(mconfig, BETA_DISK, "Beta Disk Interface", tag, owner, clock, "betadisk", __FILE__) |
| 30 | , m_betadisk_active(0) |
| 31 | , m_wd179x(*this, "wd179x") |
| 32 | , m_floppy0(*this, "wd179x:0") |
| 33 | , m_floppy1(*this, "wd179x:1") |
| 34 | , m_floppy2(*this, "wd179x:2") |
| 35 | , m_floppy3(*this, "wd179x:3") |
| 33 | 36 | { |
| 34 | 37 | } |
| 35 | 38 | |
| r243405 | r243406 | |
| 39 | 42 | |
| 40 | 43 | void beta_disk_device::device_start() |
| 41 | 44 | { |
| 42 | | astring tempstring; |
| 43 | | |
| 44 | | /* validate arguments */ |
| 45 | | assert(tag() != NULL); |
| 46 | | |
| 47 | | /* find our WD179x */ |
| 48 | | tempstring.printf("%s:%s", tag(), "wd179x"); |
| 49 | | m_wd179x = machine().device<wd2793_device>(tempstring); |
| 50 | 45 | } |
| 51 | 46 | |
| 52 | 47 | //------------------------------------------------- |
| r243405 | r243406 | |
| 72 | 67 | m_betadisk_active = 0; |
| 73 | 68 | } |
| 74 | 69 | |
| 75 | | void beta_disk_device::clear_status() |
| 76 | | { |
| 77 | | m_betadisk_status = 0; |
| 78 | | } |
| 79 | | |
| 80 | | WRITE_LINE_MEMBER(beta_disk_device::wd179x_intrq_w) |
| 81 | | { |
| 82 | | if (state) |
| 83 | | m_betadisk_status |= (1<<7); |
| 84 | | else |
| 85 | | m_betadisk_status &=~(1<<7); |
| 86 | | } |
| 87 | | |
| 88 | | WRITE_LINE_MEMBER(beta_disk_device::wd179x_drq_w) |
| 89 | | { |
| 90 | | if (state) |
| 91 | | m_betadisk_status |= (1<<6); |
| 92 | | else |
| 93 | | m_betadisk_status &=~(1<<6); |
| 94 | | } |
| 95 | | |
| 96 | 70 | READ8_MEMBER(beta_disk_device::status_r) |
| 97 | 71 | { |
| 98 | 72 | if (m_betadisk_active==1) { |
| 99 | | return m_wd179x->status_r(space, offset); |
| 73 | return m_wd179x->status_r(space, 0); |
| 100 | 74 | } else { |
| 101 | 75 | return 0xff; |
| 102 | 76 | } |
| r243405 | r243406 | |
| 105 | 79 | READ8_MEMBER(beta_disk_device::track_r) |
| 106 | 80 | { |
| 107 | 81 | if (m_betadisk_active==1) { |
| 108 | | return m_wd179x->track_r(space, offset); |
| 82 | return m_wd179x->track_r(space, 0); |
| 109 | 83 | } else { |
| 110 | 84 | return 0xff; |
| 111 | 85 | } |
| r243405 | r243406 | |
| 114 | 88 | READ8_MEMBER(beta_disk_device::sector_r) |
| 115 | 89 | { |
| 116 | 90 | if (m_betadisk_active==1) { |
| 117 | | return m_wd179x->sector_r(space, offset); |
| 91 | return m_wd179x->sector_r(space, 0); |
| 118 | 92 | } else { |
| 119 | 93 | return 0xff; |
| 120 | 94 | } |
| r243405 | r243406 | |
| 123 | 97 | READ8_MEMBER(beta_disk_device::data_r) |
| 124 | 98 | { |
| 125 | 99 | if (m_betadisk_active==1) { |
| 126 | | return m_wd179x->data_r(space, offset); |
| 100 | return m_wd179x->data_r(space, 0); |
| 127 | 101 | } else { |
| 128 | 102 | return 0xff; |
| 129 | 103 | } |
| r243405 | r243406 | |
| 132 | 106 | READ8_MEMBER(beta_disk_device::state_r) |
| 133 | 107 | { |
| 134 | 108 | if (m_betadisk_active==1) { |
| 135 | | return m_betadisk_status; |
| 109 | UINT8 result = 0x3F; // actually open bus |
| 110 | result |= m_wd179x->drq_r() ? 0x40 : 0; |
| 111 | result |= m_wd179x->intrq_r() ? 0x80 : 0; |
| 112 | return result; |
| 136 | 113 | } else { |
| 137 | 114 | return 0xff; |
| 138 | 115 | } |
| r243405 | r243406 | |
| 140 | 117 | |
| 141 | 118 | WRITE8_MEMBER(beta_disk_device::param_w) |
| 142 | 119 | { |
| 143 | | const char *floppy_tags[4] = { FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3 }; |
| 144 | | |
| 145 | 120 | if (m_betadisk_active == 1) |
| 146 | 121 | { |
| 147 | | m_wd179x->set_drive(data & 3); |
| 148 | | m_wd179x->set_side ((data & 0x10) ? 0 : 1 ); |
| 149 | | m_wd179x->dden_w(!BIT(data, 6)); |
| 150 | | if ((data & 0x04) == 0) // reset |
| 151 | | m_wd179x->reset(); |
| 122 | floppy_connector* connectors[] = { m_floppy0, m_floppy1, m_floppy2, m_floppy3 }; |
| 152 | 123 | |
| 153 | | // bit 3 connected to pin 23 "HRDY" of FDC |
| 154 | | // TEMP HACK, FDD motor and RDY FDC pin controlled by HLD pin of FDC |
| 155 | | legacy_floppy_image_device *flop = subdevice<legacy_floppy_image_device>(floppy_tags[data & 3]); |
| 156 | | flop->floppy_mon_w(CLEAR_LINE); |
| 157 | | flop->floppy_drive_set_ready_state(1, 0); |
| 124 | floppy_image_device* floppy = connectors[data & 3]->get_device(); |
| 125 | |
| 126 | m_wd179x->set_floppy(floppy); |
| 127 | floppy->ss_w(BIT(data, 4) ? 0 : 1); |
| 128 | m_wd179x->dden_w(BIT(data, 6)); |
| 129 | |
| 130 | // bit 3 connected to pin 23 "HLT" of FDC and via diode to INDEX |
| 131 | //m_wd179x->hlt_w(BIT(data, 3)); // not handled in current wd_fdc |
| 132 | |
| 133 | if (BIT(data, 2) == 0) // reset |
| 134 | { |
| 135 | m_wd179x->reset(); |
| 136 | floppy->mon_w(ASSERT_LINE); |
| 137 | } else { |
| 138 | // HACK, FDD motor and RDY FDC pin controlled by HLD pin of FDC |
| 139 | floppy->mon_w(CLEAR_LINE); |
| 140 | } |
| 158 | 141 | } |
| 159 | 142 | } |
| 160 | 143 | |
| 161 | 144 | WRITE8_MEMBER(beta_disk_device::command_w) |
| 162 | 145 | { |
| 163 | 146 | if (m_betadisk_active==1) { |
| 164 | | m_wd179x->command_w(space, offset, data); |
| 147 | m_wd179x->cmd_w(space, 0, data); |
| 165 | 148 | } |
| 166 | 149 | } |
| 167 | 150 | |
| 168 | 151 | WRITE8_MEMBER(beta_disk_device::track_w) |
| 169 | 152 | { |
| 170 | 153 | if (m_betadisk_active==1) { |
| 171 | | m_wd179x->track_w(space, offset, data); |
| 154 | m_wd179x->track_w(space, 0, data); |
| 172 | 155 | } |
| 173 | 156 | } |
| 174 | 157 | |
| 175 | 158 | WRITE8_MEMBER(beta_disk_device::sector_w) |
| 176 | 159 | { |
| 177 | 160 | if (m_betadisk_active==1) { |
| 178 | | m_wd179x->sector_w(space, offset, data); |
| 161 | m_wd179x->sector_w(space, 0, data); |
| 179 | 162 | } |
| 180 | 163 | } |
| 181 | 164 | |
| 182 | 165 | WRITE8_MEMBER(beta_disk_device::data_w) |
| 183 | 166 | { |
| 184 | 167 | if (m_betadisk_active==1) { |
| 185 | | m_wd179x->data_w(space, offset, data); |
| 168 | m_wd179x->data_w(space, 0, data); |
| 186 | 169 | } |
| 187 | 170 | } |
| 188 | 171 | |
| 189 | | static const floppy_interface beta_floppy_interface = |
| 190 | | { |
| 191 | | FLOPPY_STANDARD_5_25_DSDD, |
| 192 | | LEGACY_FLOPPY_OPTIONS_NAME(trd), |
| 193 | | NULL |
| 194 | | }; |
| 172 | FLOPPY_FORMATS_MEMBER(beta_disk_device::floppy_formats) |
| 173 | FLOPPY_TRD_FORMAT |
| 174 | FLOPPY_FORMATS_END |
| 195 | 175 | |
| 196 | | static MACHINE_CONFIG_FRAGMENT( beta_disk ) |
| 197 | | MCFG_DEVICE_ADD("wd179x", WD2793, 0) // KR1818VG93 clone of WD1793 |
| 198 | | MCFG_WD17XX_DEFAULT_DRIVE4_TAGS |
| 199 | | MCFG_WD17XX_INTRQ_CALLBACK(WRITELINE(beta_disk_device, wd179x_intrq_w)) |
| 200 | | MCFG_WD17XX_DRQ_CALLBACK(WRITELINE(beta_disk_device, wd179x_drq_w)) |
| 176 | static SLOT_INTERFACE_START( beta_disk_floppies ) |
| 177 | SLOT_INTERFACE( "drive0", FLOPPY_525_QD ) |
| 178 | SLOT_INTERFACE( "drive1", FLOPPY_525_QD ) |
| 179 | SLOT_INTERFACE( "drive2", FLOPPY_525_QD ) |
| 180 | SLOT_INTERFACE( "drive3", FLOPPY_525_QD ) |
| 181 | SLOT_INTERFACE_END |
| 201 | 182 | |
| 202 | | MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(beta_floppy_interface) |
| 183 | static MACHINE_CONFIG_FRAGMENT( beta_disk ) |
| 184 | MCFG_WD2793x_ADD("wd179x", XTAL_8MHz / 8) // KR1818VG93 clone of WD1793 |
| 185 | MCFG_FLOPPY_DRIVE_ADD("wd179x:0", beta_disk_floppies, "drive0", beta_disk_device::floppy_formats) |
| 186 | MCFG_FLOPPY_DRIVE_ADD("wd179x:1", beta_disk_floppies, "drive1", beta_disk_device::floppy_formats) |
| 187 | MCFG_FLOPPY_DRIVE_ADD("wd179x:2", beta_disk_floppies, "drive2", beta_disk_device::floppy_formats) |
| 188 | MCFG_FLOPPY_DRIVE_ADD("wd179x:3", beta_disk_floppies, "drive3", beta_disk_device::floppy_formats) |
| 203 | 189 | MACHINE_CONFIG_END |
| 204 | 190 | |
| 205 | 191 | ROM_START( beta_disk ) |