trunk/src/mess/drivers/excali64.c
| r242576 | r242577 | |
| 19 | 19 | |
| 20 | 20 | ToDo: |
| 21 | 21 | - Colours are approximate. |
| 22 | | - Disk controller, works with old wd17xx but crashes on new wd. |
| 22 | - Disk controller, using the old wd17xx because new wd crashes on loading a disk. |
| 23 | 23 | - Hardware supports 20cm and 13cm floppies, but we only support 13cm as this |
| 24 | 24 | is the only software that exists. |
| 25 | 25 | - The schematic shows the audio counter connected to 2MHz, but this produces |
| r242576 | r242577 | |
| 29 | 29 | |
| 30 | 30 | ****************************************************************************/ |
| 31 | 31 | |
| 32 | | #define NEWFDC 0 |
| 33 | | |
| 34 | | |
| 35 | 32 | #include "emu.h" |
| 36 | 33 | #include "cpu/z80/z80.h" |
| 37 | 34 | #include "video/mc6845.h" |
| 38 | 35 | #include "machine/i8251.h" |
| 39 | 36 | #include "bus/rs232/rs232.h" |
| 40 | | //#include "machine/clock.h" |
| 41 | 37 | #include "machine/pit8253.h" |
| 42 | 38 | #include "machine/i8255.h" |
| 43 | 39 | #include "bus/centronics/ctronics.h" |
| r242576 | r242577 | |
| 47 | 43 | #include "machine/z80dma.h" |
| 48 | 44 | #include "machine/rescap.h" |
| 49 | 45 | #include "machine/74123.h" |
| 50 | | #if NEWFDC |
| 51 | | #include "machine/wd_fdc.h" |
| 52 | | #include "formats/excali64_dsk.h" |
| 53 | | #else |
| 54 | 46 | #include "machine/wd17xx.h" |
| 55 | 47 | #include "imagedev/flopdrv.h" |
| 56 | 48 | #include "formats/basicdsk.h" |
| 57 | | #endif |
| 58 | 49 | |
| 59 | 50 | class excali64_state : public driver_device |
| 60 | 51 | { |
| r242576 | r242577 | |
| 70 | 61 | , m_u12(*this, "u12") |
| 71 | 62 | , m_centronics(*this, "centronics") |
| 72 | 63 | , m_fdc(*this, "fdc") |
| 73 | | #if NEWFDC |
| 74 | | , m_floppy0(*this, "fdc:0") |
| 75 | | , m_floppy1(*this, "fdc:1") |
| 76 | | #endif |
| 77 | 64 | { } |
| 78 | 65 | |
| 79 | 66 | DECLARE_PALETTE_INIT(excali64); |
| r242576 | r242577 | |
| 86 | 73 | DECLARE_WRITE8_MEMBER(porte4_w); |
| 87 | 74 | DECLARE_READ8_MEMBER(porte8_r); |
| 88 | 75 | DECLARE_WRITE8_MEMBER(portec_w); |
| 89 | | #if NEWFDC |
| 90 | | DECLARE_FLOPPY_FORMATS(floppy_formats); |
| 91 | | #endif |
| 92 | 76 | DECLARE_WRITE_LINE_MEMBER(cent_busy_w); |
| 93 | 77 | DECLARE_WRITE_LINE_MEMBER(busreq_w); |
| 94 | 78 | DECLARE_READ8_MEMBER(memory_read_byte); |
| r242576 | r242577 | |
| 119 | 103 | required_device<z80dma_device> m_dma; |
| 120 | 104 | required_device<ttl74123_device> m_u12; |
| 121 | 105 | required_device<centronics_device> m_centronics; |
| 122 | | #if NEWFDC |
| 123 | | required_device<wd2793_t> m_fdc; |
| 124 | | required_device<floppy_connector> m_floppy0; |
| 125 | | required_device<floppy_connector> m_floppy1; |
| 126 | | #else |
| 127 | 106 | required_device<wd2793_device> m_fdc; |
| 128 | | #endif |
| 129 | 107 | }; |
| 130 | 108 | |
| 131 | 109 | static ADDRESS_MAP_START(excali64_mem, AS_PROGRAM, 8, excali64_state) |
| r242576 | r242577 | |
| 151 | 129 | AM_RANGE(0xe4, 0xe7) AM_WRITE(porte4_w) |
| 152 | 130 | AM_RANGE(0xe8, 0xeb) AM_READ(porte8_r) |
| 153 | 131 | AM_RANGE(0xec, 0xef) AM_WRITE(portec_w) |
| 154 | | #if NEWFDC |
| 155 | | AM_RANGE(0xf0, 0xf3) AM_DEVREADWRITE("fdc", wd2793_t, read, write) |
| 156 | | #else |
| 157 | 132 | AM_RANGE(0xf0, 0xf3) AM_DEVREADWRITE("fdc", wd2793_device, read, write) |
| 158 | | #endif |
| 159 | 133 | ADDRESS_MAP_END |
| 160 | 134 | |
| 161 | 135 | |
| r242576 | r242577 | |
| 246 | 220 | m_centronics_busy = state; |
| 247 | 221 | } |
| 248 | 222 | |
| 249 | | #if NEWFDC |
| 250 | | FLOPPY_FORMATS_MEMBER( excali64_state::floppy_formats ) |
| 251 | | FLOPPY_EXCALI64_FORMAT |
| 252 | | FLOPPY_FORMATS_END |
| 253 | | |
| 254 | | static SLOT_INTERFACE_START( excali64_floppies ) |
| 255 | | SLOT_INTERFACE( "525dd", FLOPPY_525_DD ) |
| 256 | | SLOT_INTERFACE_END |
| 257 | | #else |
| 258 | 223 | static LEGACY_FLOPPY_OPTIONS_START(excali64) |
| 259 | 224 | LEGACY_FLOPPY_OPTION(excali64_ds, "raw", "Excalibur 64 DS disk image", basicdsk_identify_default, basicdsk_construct_default, NULL, |
| 260 | 225 | HEADS([2]) |
| r242576 | r242577 | |
| 270 | 235 | LEGACY_FLOPPY_OPTIONS_NAME(excali64), |
| 271 | 236 | NULL |
| 272 | 237 | }; |
| 273 | | #endif |
| 274 | 238 | |
| 275 | 239 | // pulses from port E4 bit 5 restart the 74123. After 3.6 secs without a pulse, the motor gets turned off. |
| 276 | 240 | WRITE8_MEMBER( excali64_state::motor_w ) |
| 277 | 241 | { |
| 278 | 242 | m_motor = BIT(data, 0); |
| 279 | | #if NEWFDC |
| 280 | | m_floppy1->get_device()->mon_w(!m_motor); |
| 281 | | m_floppy0->get_device()->mon_w(!m_motor); |
| 282 | | #else |
| 283 | 243 | legacy_floppy_image_device *flop = subdevice<legacy_floppy_image_device>(FLOPPY_0); |
| 284 | 244 | flop->floppy_mon_w(!m_motor); // motor on |
| 285 | 245 | flop = subdevice<legacy_floppy_image_device>(FLOPPY_1); |
| 286 | 246 | flop->floppy_mon_w(!m_motor); // motor on |
| 287 | | #endif |
| 288 | 247 | } |
| 289 | 248 | |
| 290 | 249 | READ8_MEMBER( excali64_state::porte8_r ) |
| r242576 | r242577 | |
| 294 | 253 | |
| 295 | 254 | WRITE8_MEMBER( excali64_state::porte4_w ) |
| 296 | 255 | { |
| 297 | | #if NEWFDC |
| 298 | | floppy_image_device *floppy = NULL; |
| 299 | | if (BIT(data, 0)) |
| 300 | | floppy = m_floppy0->get_device(); |
| 301 | | |
| 302 | | if (BIT(data, 1)) |
| 303 | | floppy = m_floppy1->get_device(); |
| 304 | | |
| 305 | | if (floppy) |
| 306 | | { |
| 307 | | m_fdc->set_floppy(floppy); |
| 308 | | floppy->ss_w(BIT(data, 4)); |
| 309 | | } |
| 310 | | #else |
| 311 | 256 | if BIT(data, 0) |
| 312 | 257 | m_fdc->set_drive(0); |
| 313 | 258 | |
| r242576 | r242577 | |
| 315 | 260 | m_fdc->set_drive(1); |
| 316 | 261 | |
| 317 | 262 | m_fdc->set_side(BIT(data, 4)); |
| 318 | | #endif |
| 319 | 263 | |
| 320 | 264 | m_u12->b_w(space,offset, BIT(data, 5)); // motor pulse |
| 321 | 265 | } |
| r242576 | r242577 | |
| 327 | 271 | */ |
| 328 | 272 | WRITE8_MEMBER( excali64_state::portec_w ) |
| 329 | 273 | { |
| 330 | | #if NEWFDC |
| 331 | | m_fdc->dden_w(BIT(data, 2)); |
| 332 | | #else |
| 333 | 274 | m_fdc->dden_w(!BIT(data, 2)); |
| 334 | | #endif |
| 335 | 275 | } |
| 336 | 276 | |
| 337 | 277 | WRITE_LINE_MEMBER( excali64_state::busreq_w ) |
| r242576 | r242577 | |
| 652 | 592 | |
| 653 | 593 | /* Devices */ |
| 654 | 594 | MCFG_CASSETTE_ADD( "cassette" ) |
| 655 | | #if NEWFDC |
| 656 | | MCFG_WD2793x_ADD("fdc", XTAL_16MHz / 16) |
| 657 | | MCFG_WD_FDC_FORCE_READY |
| 658 | | MCFG_WD_FDC_DRQ_CALLBACK(DEVWRITELINE("dma", z80dma_device, rdy_w)) |
| 659 | | MCFG_FLOPPY_DRIVE_ADD("fdc:0", excali64_floppies, "525dd", floppy_image_device::default_floppy_formats)// excali64_state::floppy_formats) |
| 660 | | MCFG_FLOPPY_DRIVE_ADD("fdc:1", excali64_floppies, "525dd", floppy_image_device::default_floppy_formats) |
| 661 | | #else |
| 662 | 595 | MCFG_DEVICE_ADD("fdc", WD2793, 0) |
| 663 | 596 | MCFG_WD17XX_DEFAULT_DRIVE2_TAGS |
| 664 | 597 | MCFG_WD17XX_DRQ_CALLBACK(DEVWRITELINE("dma", z80dma_device, rdy_w)) |
| 665 | 598 | MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(excali64_floppy_interface) |
| 666 | | #endif |
| 599 | |
| 667 | 600 | MCFG_DEVICE_ADD("dma", Z80DMA, XTAL_16MHz/4) |
| 668 | 601 | MCFG_Z80DMA_OUT_BUSREQ_CB(WRITELINE(excali64_state, busreq_w)) |
| 669 | 602 | MCFG_Z80DMA_IN_MREQ_CB(READ8(excali64_state, memory_read_byte)) |