trunk/src/mess/machine/concept_exp.c
| r32271 | r32272 | |
| 1 | | /********************************************************************** |
| 2 | | |
| 3 | | Corvus Concept expansion port emulation |
| 4 | | |
| 5 | | Copyright MESS Team. |
| 6 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | | |
| 8 | | |
| 9 | | FIXME: Concept expansion ports should just use the Apple II Bus device! |
| 10 | | The code below is outdated and inaccurate! |
| 11 | | |
| 12 | | **********************************************************************/ |
| 13 | | |
| 14 | | #include "machine/concept_exp.h" |
| 15 | | |
| 16 | | // FDC controller |
| 17 | | #include "imagedev/flopdrv.h" |
| 18 | | #include "formats/basicdsk.h" |
| 19 | | |
| 20 | | // HDC controller |
| 21 | | #include "imagedev/harddriv.h" |
| 22 | | |
| 23 | | //************************************************************************** |
| 24 | | // DEVICE DEFINITIONS |
| 25 | | //************************************************************************** |
| 26 | | |
| 27 | | // device type definition |
| 28 | | const device_type CONCEPT_EXP_PORT = &device_creator<concept_exp_port_device>; |
| 29 | | |
| 30 | | |
| 31 | | //************************************************************************** |
| 32 | | // LIVE DEVICE |
| 33 | | //************************************************************************** |
| 34 | | |
| 35 | | //------------------------------------------------- |
| 36 | | // concept_exp_port_device - constructor |
| 37 | | //------------------------------------------------- |
| 38 | | |
| 39 | | concept_exp_port_device::concept_exp_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 40 | | device_t(mconfig, CONCEPT_EXP_PORT, "Corvus Concept expansion port", tag, owner, clock, "concept_exp_port", __FILE__), |
| 41 | | device_slot_interface(mconfig, *this) |
| 42 | | { |
| 43 | | } |
| 44 | | |
| 45 | | |
| 46 | | //------------------------------------------------- |
| 47 | | // device_start - device-specific startup |
| 48 | | //------------------------------------------------- |
| 49 | | |
| 50 | | void concept_exp_port_device::device_start() |
| 51 | | { |
| 52 | | m_card = dynamic_cast<concept_exp_card_device *>(get_card_device()); |
| 53 | | } |
| 54 | | |
| 55 | | |
| 56 | | //------------------------------------------------- |
| 57 | | // device_reset - device-specific reset |
| 58 | | //------------------------------------------------- |
| 59 | | |
| 60 | | void concept_exp_port_device::device_reset() |
| 61 | | { |
| 62 | | } |
| 63 | | |
| 64 | | |
| 65 | | READ8_MEMBER( concept_exp_port_device::reg_r ) |
| 66 | | { |
| 67 | | if (m_card) |
| 68 | | return m_card->reg_r(space, offset); |
| 69 | | |
| 70 | | return 0; |
| 71 | | } |
| 72 | | |
| 73 | | WRITE8_MEMBER( concept_exp_port_device::reg_w ) |
| 74 | | { |
| 75 | | if (m_card != NULL) |
| 76 | | m_card->reg_w(space, offset, data); |
| 77 | | } |
| 78 | | |
| 79 | | READ8_MEMBER( concept_exp_port_device::rom_r ) |
| 80 | | { |
| 81 | | if (m_card) |
| 82 | | return m_card->reg_r(space, offset); |
| 83 | | |
| 84 | | return 0; |
| 85 | | } |
| 86 | | |
| 87 | | WRITE8_MEMBER( concept_exp_port_device::rom_w ) |
| 88 | | { |
| 89 | | if (m_card != NULL) |
| 90 | | m_card->reg_w(space, offset, data); |
| 91 | | } |
| 92 | | |
| 93 | | |
| 94 | | //************************************************************************** |
| 95 | | // CARD INTERFACE |
| 96 | | //************************************************************************** |
| 97 | | |
| 98 | | //------------------------------------------------- |
| 99 | | // concept_exp_card_device - constructor |
| 100 | | //------------------------------------------------- |
| 101 | | |
| 102 | | concept_exp_card_device::concept_exp_card_device(const machine_config &mconfig, device_t &device) |
| 103 | | : device_slot_card_interface(mconfig, device) |
| 104 | | { |
| 105 | | } |
| 106 | | |
| 107 | | |
| 108 | | //************************************************************************** |
| 109 | | // STUB EMULATION OF CARD DEVICES |
| 110 | | //************************************************************************** |
| 111 | | |
| 112 | | // FIXME: clean these up and move them in separate sources if suitable... |
| 113 | | |
| 114 | | const device_type CONCEPT_FDC = &device_creator<concept_fdc_device>; |
| 115 | | const device_type CONCEPT_HDC = &device_creator<concept_hdc_device>; |
| 116 | | |
| 117 | | concept_fdc_device::concept_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 118 | | : device_t(mconfig, CONCEPT_FDC, "Corvus Concept FDC controller", tag, owner, clock, "concept_fdc", __FILE__), |
| 119 | | concept_exp_card_device( mconfig, *this ) |
| 120 | | { |
| 121 | | } |
| 122 | | |
| 123 | | concept_hdc_device::concept_hdc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 124 | | : device_t(mconfig, CONCEPT_HDC, "Corvus Concept HDC controller", tag, owner, clock, "concept_hdc", __FILE__), |
| 125 | | concept_exp_card_device( mconfig, *this ), |
| 126 | | m_hdc(*this, "hdc") |
| 127 | | { |
| 128 | | } |
| 129 | | |
| 130 | | |
| 131 | | // FDC Controller |
| 132 | | |
| 133 | | enum |
| 134 | | { |
| 135 | | LS_DRQ_bit = 0, // DRQ |
| 136 | | LS_INT_bit = 1, // INT |
| 137 | | LS_SS_bit = 4, // 1 if single-sided (floppy or drive?) |
| 138 | | LS_8IN_bit = 5, // 1 if 8" floppy drive? |
| 139 | | LS_DSKCHG_bit = 6, // 0 if disk changed, 1 if not |
| 140 | | LS_SD_bit = 7, // 1 if single density |
| 141 | | |
| 142 | | LS_DRQ_mask = (1 << LS_DRQ_bit), |
| 143 | | LS_INT_mask = (1 << LS_INT_bit), |
| 144 | | LS_SS_mask = (1 << LS_SS_bit), |
| 145 | | LS_8IN_mask = (1 << LS_8IN_bit), |
| 146 | | LS_DSKCHG_mask = (1 << LS_DSKCHG_bit), |
| 147 | | LS_SD_mask = (1 << LS_SD_bit) |
| 148 | | }; |
| 149 | | |
| 150 | | enum |
| 151 | | { |
| 152 | | LC_FLPSD1_bit = 0, // 0 if side 0 , 1 if side 1 |
| 153 | | LC_DE0_bit = 1, // drive select bit 0 |
| 154 | | LC_DE1_bit = 4, // drive select bit 1 |
| 155 | | LC_MOTOROF_bit = 5, // 1 if motor to be turned off |
| 156 | | LC_FLP8IN_bit = 6, // 1 to select 8", 0 for 5"1/4 (which I knew what it means) |
| 157 | | LC_FMMFM_bit = 7, // 1 to select single density, 0 for double |
| 158 | | |
| 159 | | LC_FLPSD1_mask = (1 << LC_FLPSD1_bit), |
| 160 | | LC_DE0_mask = (1 << LC_DE0_bit), |
| 161 | | LC_DE1_mask = (1 << LC_DE1_bit), |
| 162 | | LC_MOTOROF_mask = (1 << LC_MOTOROF_bit), |
| 163 | | LC_FLP8IN_mask = (1 << LC_FLP8IN_bit), |
| 164 | | LC_FMMFM_mask = (1 << LC_FMMFM_bit) |
| 165 | | }; |
| 166 | | |
| 167 | | void concept_fdc_device::device_start() |
| 168 | | { |
| 169 | | m_wd179x = subdevice<fd1793_device>("wd179x"); |
| 170 | | |
| 171 | | save_item(NAME(m_fdc_local_status)); |
| 172 | | save_item(NAME(m_fdc_local_command)); |
| 173 | | } |
| 174 | | |
| 175 | | |
| 176 | | void concept_fdc_device::device_reset() |
| 177 | | { |
| 178 | | m_fdc_local_status = 0; |
| 179 | | m_fdc_local_command = 0; |
| 180 | | } |
| 181 | | |
| 182 | | |
| 183 | | WRITE_LINE_MEMBER(concept_fdc_device::intrq_w) |
| 184 | | { |
| 185 | | if (state) |
| 186 | | m_fdc_local_status |= LS_INT_mask; |
| 187 | | else |
| 188 | | m_fdc_local_status &= ~LS_INT_mask; |
| 189 | | } |
| 190 | | |
| 191 | | WRITE_LINE_MEMBER(concept_fdc_device::drq_w) |
| 192 | | { |
| 193 | | if (state) |
| 194 | | m_fdc_local_status |= LS_DRQ_mask; |
| 195 | | else |
| 196 | | m_fdc_local_status &= ~LS_DRQ_mask; |
| 197 | | } |
| 198 | | |
| 199 | | READ8_MEMBER(concept_fdc_device::reg_r) |
| 200 | | { |
| 201 | | switch (offset) |
| 202 | | { |
| 203 | | case 0: // LOCAL STATUS REG |
| 204 | | return m_fdc_local_status; |
| 205 | | |
| 206 | | case 8: // FDC STATUS REG |
| 207 | | return m_wd179x->status_r(space, offset); |
| 208 | | |
| 209 | | case 9: // FDC TRACK REG |
| 210 | | return m_wd179x->track_r(space, offset); |
| 211 | | |
| 212 | | case 10: // FDC SECTOR REG |
| 213 | | return m_wd179x->sector_r(space, offset); |
| 214 | | |
| 215 | | case 11: // FDC DATA REG |
| 216 | | return m_wd179x->data_r(space, offset); |
| 217 | | } |
| 218 | | |
| 219 | | return 0; |
| 220 | | } |
| 221 | | |
| 222 | | WRITE8_MEMBER(concept_fdc_device::reg_w) |
| 223 | | { |
| 224 | | int current_drive; |
| 225 | | |
| 226 | | switch (offset) |
| 227 | | { |
| 228 | | case 0: // LOCAL COMMAND REG |
| 229 | | m_fdc_local_command = data; |
| 230 | | |
| 231 | | m_wd179x->set_side((data & LC_FLPSD1_mask) != 0); |
| 232 | | current_drive = ((data >> LC_DE0_bit) & 1) | ((data >> (LC_DE1_bit-1)) & 2); |
| 233 | | m_wd179x->set_drive(current_drive); |
| 234 | | /*motor_on = (data & LC_MOTOROF_mask) == 0;*/ |
| 235 | | // floppy_drive_set_motor_state(floppy_get_device(machine(), current_drive), (data & LC_MOTOROF_mask) == 0 ? 1 : 0); |
| 236 | | /*flp_8in = (data & LC_FLP8IN_mask) != 0;*/ |
| 237 | | m_wd179x->dden_w(BIT(data, 7)); |
| 238 | | floppy_get_device(machine(), current_drive)->floppy_drive_set_ready_state(1, 0); |
| 239 | | break; |
| 240 | | |
| 241 | | case 8: // FDC COMMAMD REG |
| 242 | | m_wd179x->command_w(space, offset, data); |
| 243 | | break; |
| 244 | | |
| 245 | | case 9: // FDC TRACK REG |
| 246 | | m_wd179x->track_w(space, offset, data); |
| 247 | | break; |
| 248 | | |
| 249 | | case 10: // FDC SECTOR REG |
| 250 | | m_wd179x->sector_w(space, offset, data); |
| 251 | | break; |
| 252 | | |
| 253 | | case 11: // FDC DATA REG |
| 254 | | m_wd179x->data_w(space, offset, data); |
| 255 | | break; |
| 256 | | } |
| 257 | | } |
| 258 | | |
| 259 | | READ8_MEMBER(concept_fdc_device::rom_r) |
| 260 | | { |
| 261 | | static const UINT8 data[] = "CORVUS01"; |
| 262 | | return (offset < 8) ? data[offset] : 0; |
| 263 | | } |
| 264 | | |
| 265 | | |
| 266 | | static LEGACY_FLOPPY_OPTIONS_START(concept) |
| 267 | | #if 1 |
| 268 | | /* SSSD 8" */ |
| 269 | | LEGACY_FLOPPY_OPTION(concept, "img", "Corvus Concept 8\" SSSD disk image", basicdsk_identify_default, basicdsk_construct_default, NULL, |
| 270 | | HEADS([1]) |
| 271 | | TRACKS([77]) |
| 272 | | SECTORS([26]) |
| 273 | | SECTOR_LENGTH([128]) |
| 274 | | FIRST_SECTOR_ID([1])) |
| 275 | | #elif 0 |
| 276 | | /* SSDD 8" (according to ROMs) */ |
| 277 | | LEGACY_FLOPPY_OPTION(concept, "img", "Corvus Concept 8\" SSDD disk image", basicdsk_identify_default, basicdsk_construct_default, NULL, |
| 278 | | HEADS([1]) |
| 279 | | TRACKS([77]) |
| 280 | | SECTORS([26]) |
| 281 | | SECTOR_LENGTH([256]) |
| 282 | | FIRST_SECTOR_ID([1])) |
| 283 | | #elif 0 |
| 284 | | /* Apple II DSDD 5"1/4 (according to ROMs) */ |
| 285 | | LEGACY_FLOPPY_OPTION(concept, "img", "Corvus Concept Apple II 5\"1/4 DSDD disk image", basicdsk_identify_default, basicdsk_construct_default, NULL, |
| 286 | | HEADS([2]) |
| 287 | | TRACKS([35]) |
| 288 | | SECTORS([16]) |
| 289 | | SECTOR_LENGTH([256]) |
| 290 | | FIRST_SECTOR_ID([1])) |
| 291 | | #elif 0 |
| 292 | | /* actual formats found */ |
| 293 | | LEGACY_FLOPPY_OPTION(concept, "img", "Corvus Concept 5\"1/4 DSDD disk image (256-byte sectors)", basicdsk_identify_default, basicdsk_construct_default, NULL, |
| 294 | | HEADS([2]) |
| 295 | | TRACKS([80]) |
| 296 | | SECTORS([16]) |
| 297 | | SECTOR_LENGTH([256]) |
| 298 | | FIRST_SECTOR_ID([1])) |
| 299 | | #else |
| 300 | | LEGACY_FLOPPY_OPTION(concept, "img", "Corvus Concept 5\"1/4 DSDD disk image (512-byte sectors)", basicdsk_identify_default, basicdsk_construct_default, NULL, |
| 301 | | HEADS([2]) |
| 302 | | TRACKS([80]) |
| 303 | | SECTORS([9]) |
| 304 | | SECTOR_LENGTH([512]) |
| 305 | | FIRST_SECTOR_ID([1])) |
| 306 | | #endif |
| 307 | | LEGACY_FLOPPY_OPTIONS_END |
| 308 | | |
| 309 | | static const floppy_interface concept_floppy_interface = |
| 310 | | { |
| 311 | | FLOPPY_STANDARD_5_25_DSHD, |
| 312 | | LEGACY_FLOPPY_OPTIONS_NAME(concept), |
| 313 | | NULL |
| 314 | | }; |
| 315 | | |
| 316 | | |
| 317 | | static MACHINE_CONFIG_FRAGMENT( fdc ) |
| 318 | | MCFG_DEVICE_ADD("wd179x", FD1793, 0) |
| 319 | | MCFG_WD17XX_DEFAULT_DRIVE4_TAGS |
| 320 | | MCFG_WD17XX_INTRQ_CALLBACK(WRITELINE(concept_fdc_device, intrq_w)) |
| 321 | | MCFG_WD17XX_DRQ_CALLBACK(WRITELINE(concept_fdc_device, drq_w)) |
| 322 | | |
| 323 | | MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(concept_floppy_interface) |
| 324 | | MACHINE_CONFIG_END |
| 325 | | |
| 326 | | machine_config_constructor concept_fdc_device::device_mconfig_additions() const |
| 327 | | { |
| 328 | | return MACHINE_CONFIG_NAME(fdc); |
| 329 | | } |
| 330 | | |
| 331 | | |
| 332 | | // HDC Controller |
| 333 | | |
| 334 | | void concept_hdc_device::device_start() |
| 335 | | { |
| 336 | | } |
| 337 | | |
| 338 | | |
| 339 | | void concept_hdc_device::device_reset() |
| 340 | | { |
| 341 | | } |
| 342 | | |
| 343 | | |
| 344 | | // Handle reads against the Hard Disk Controller's onboard registers |
| 345 | | READ8_MEMBER(concept_hdc_device::reg_r) |
| 346 | | { |
| 347 | | switch (offset) |
| 348 | | { |
| 349 | | case 0: // HDC Data Register |
| 350 | | return m_hdc->read(space, offset); |
| 351 | | |
| 352 | | case 1: // HDC Status Register |
| 353 | | return m_hdc->status_r(space, offset); |
| 354 | | } |
| 355 | | |
| 356 | | return 0; |
| 357 | | } |
| 358 | | |
| 359 | | // Handle writes against the Hard Disk Controller's onboard registers |
| 360 | | WRITE8_MEMBER(concept_hdc_device::reg_w) |
| 361 | | { |
| 362 | | switch (offset) |
| 363 | | { |
| 364 | | case 0: // HDC Data Register |
| 365 | | m_hdc->write(space, offset, data); |
| 366 | | break; |
| 367 | | } |
| 368 | | } |
| 369 | | |
| 370 | | // Handle reads agsint the Hard Disk Controller's onboard ROM |
| 371 | | READ8_MEMBER(concept_hdc_device::rom_r) |
| 372 | | { |
| 373 | | static const UINT8 data[8] = { 0xa9, 0x20, 0xa9, 0x00, 0xa9, 0x03, 0xa9, 0x3c }; /* Same as Apple II */ |
| 374 | | return (offset < 8) ? data[offset] : 0; |
| 375 | | } |
| 376 | | |
| 377 | | |
| 378 | | |
| 379 | | static MACHINE_CONFIG_FRAGMENT( hdc ) |
| 380 | | MCFG_DEVICE_ADD("hdc", CORVUS_HDC, 0) |
| 381 | | MCFG_HARDDISK_ADD( "harddisk1" ) |
| 382 | | MACHINE_CONFIG_END |
| 383 | | |
| 384 | | machine_config_constructor concept_hdc_device::device_mconfig_additions() const |
| 385 | | { |
| 386 | | return MACHINE_CONFIG_NAME(hdc); |
| 387 | | } |
trunk/src/mess/machine/concept_exp.h
| r32271 | r32272 | |
| 1 | | #ifndef __CONCEPT_EXP__ |
| 2 | | #define __CONCEPT_EXP__ |
| 3 | | |
| 4 | | #include "emu.h" |
| 5 | | #include "machine/wd17xx.h" |
| 6 | | #include "machine/corvushd.h" |
| 7 | | |
| 8 | | // FIXME: Concept expansion ports should just use the Apple II Bus device! |
| 9 | | // The code below is outdated and inaccurate! |
| 10 | | |
| 11 | | class concept_exp_card_device; |
| 12 | | |
| 13 | | |
| 14 | | class concept_exp_port_device : public device_t, |
| 15 | | public device_slot_interface |
| 16 | | { |
| 17 | | public: |
| 18 | | // construction/destruction |
| 19 | | concept_exp_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 20 | | |
| 21 | | DECLARE_READ8_MEMBER( reg_r ); |
| 22 | | DECLARE_READ8_MEMBER( rom_r ); |
| 23 | | DECLARE_WRITE8_MEMBER( reg_w ); |
| 24 | | DECLARE_WRITE8_MEMBER( rom_w ); |
| 25 | | |
| 26 | | protected: |
| 27 | | // device-level overrides |
| 28 | | virtual void device_start(); |
| 29 | | virtual void device_reset(); |
| 30 | | |
| 31 | | concept_exp_card_device *m_card; |
| 32 | | }; |
| 33 | | |
| 34 | | |
| 35 | | // device type definition |
| 36 | | extern const ATTR_DEPRECATED device_type CONCEPT_EXP_PORT; |
| 37 | | |
| 38 | | |
| 39 | | //************************************************************************** |
| 40 | | // INTERFACE CONFIGURATION MACROS |
| 41 | | //************************************************************************** |
| 42 | | |
| 43 | | #define MCFG_CONCEPT_EXP_PORT_ADD(_tag, _slot_intf, _def_slot) \ |
| 44 | | MCFG_DEVICE_ADD(_tag, CONCEPT_EXP_PORT, 0) \ |
| 45 | | MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) |
| 46 | | |
| 47 | | |
| 48 | | |
| 49 | | |
| 50 | | |
| 51 | | //************************************************************************** |
| 52 | | // CARD INTERFACE |
| 53 | | //************************************************************************** |
| 54 | | |
| 55 | | |
| 56 | | class concept_exp_card_device : public device_slot_card_interface |
| 57 | | { |
| 58 | | public: |
| 59 | | // construction/destruction |
| 60 | | concept_exp_card_device(const machine_config &mconfig, device_t &device); |
| 61 | | |
| 62 | | DECLARE_READ8_MEMBER( reg_r ) { return 0xff; } |
| 63 | | DECLARE_READ8_MEMBER( rom_r ) { return 0xff; } |
| 64 | | DECLARE_WRITE8_MEMBER( reg_w ) {} |
| 65 | | DECLARE_WRITE8_MEMBER( rom_w ) {} |
| 66 | | |
| 67 | | protected: |
| 68 | | }; |
| 69 | | |
| 70 | | |
| 71 | | class concept_fdc_device : public device_t, |
| 72 | | public concept_exp_card_device |
| 73 | | { |
| 74 | | public: |
| 75 | | // construction/destruction |
| 76 | | concept_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 77 | | |
| 78 | | DECLARE_READ8_MEMBER(reg_r); |
| 79 | | DECLARE_READ8_MEMBER(rom_r); |
| 80 | | DECLARE_WRITE8_MEMBER(reg_w); |
| 81 | | |
| 82 | | DECLARE_WRITE_LINE_MEMBER(intrq_w); |
| 83 | | DECLARE_WRITE_LINE_MEMBER(drq_w); |
| 84 | | |
| 85 | | // device-level overrides |
| 86 | | virtual void device_start(); |
| 87 | | virtual void device_reset(); |
| 88 | | virtual machine_config_constructor device_mconfig_additions() const; |
| 89 | | |
| 90 | | protected: |
| 91 | | fd1793_device *m_wd179x; |
| 92 | | |
| 93 | | UINT8 m_fdc_local_status; |
| 94 | | UINT8 m_fdc_local_command; |
| 95 | | }; |
| 96 | | |
| 97 | | class concept_hdc_device : public device_t, |
| 98 | | public concept_exp_card_device |
| 99 | | { |
| 100 | | public: |
| 101 | | // construction/destruction |
| 102 | | concept_hdc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 103 | | |
| 104 | | DECLARE_READ8_MEMBER( reg_r ); |
| 105 | | DECLARE_READ8_MEMBER( rom_r ); |
| 106 | | DECLARE_WRITE8_MEMBER( reg_w ); |
| 107 | | |
| 108 | | // device-level overrides |
| 109 | | virtual void device_start(); |
| 110 | | virtual void device_reset(); |
| 111 | | virtual machine_config_constructor device_mconfig_additions() const; |
| 112 | | |
| 113 | | protected: |
| 114 | | required_device<corvus_hdc_t> m_hdc; |
| 115 | | }; |
| 116 | | |
| 117 | | |
| 118 | | extern const ATTR_DEPRECATED device_type CONCEPT_FDC; |
| 119 | | extern const ATTR_DEPRECATED device_type CONCEPT_HDC; |
| 120 | | |
| 121 | | #endif |