src/mess/machine/kc_d004.c
| r15033 | r15034 | |
| 12 | 12 | #define Z80_TAG "disk" |
| 13 | 13 | #define Z80CTC_TAG "z80ctc" |
| 14 | 14 | #define UPD765_TAG "upd765" |
| 15 | #define IDE_TAG "ide" |
| 15 | 16 | |
| 16 | 17 | /*************************************************************************** |
| 17 | 18 | IMPLEMENTATION |
| 18 | 19 | ***************************************************************************/ |
| 19 | 20 | |
| 20 | 21 | static ADDRESS_MAP_START(kc_d004_mem, AS_PROGRAM, 8, kc_d004_device) |
| 21 | | AM_RANGE(0x0000, 0xffff) AM_RAM // 64kb RAM |
| 22 | AM_RANGE(0x0000, 0xfbff) AM_RAM |
| 23 | AM_RANGE(0xfc00, 0xffff) AM_RAM AM_SHARE("koppelram") |
| 22 | 24 | ADDRESS_MAP_END |
| 23 | 25 | |
| 24 | 26 | static ADDRESS_MAP_START(kc_d004_io, AS_IO, 8, kc_d004_device) |
| r15033 | r15034 | |
| 33 | 35 | AM_RANGE(0xfc, 0xff) AM_DEVREADWRITE_LEGACY(Z80CTC_TAG, z80ctc_r, z80ctc_w) |
| 34 | 36 | ADDRESS_MAP_END |
| 35 | 37 | |
| 38 | static ADDRESS_MAP_START(kc_d004_gide_io, AS_IO, 8, kc_d004_gide_device) |
| 39 | ADDRESS_MAP_UNMAP_HIGH |
| 40 | AM_RANGE(0x00f0, 0x00f0) AM_MIRROR(0xff00) AM_DEVREAD_LEGACY(UPD765_TAG, upd765_status_r) |
| 41 | AM_RANGE(0x00f1, 0x00f1) AM_MIRROR(0xff00) AM_DEVREADWRITE_LEGACY(UPD765_TAG, upd765_data_r, upd765_data_w) |
| 42 | AM_RANGE(0x00f2, 0x00f3) AM_MIRROR(0xff00) AM_DEVREADWRITE_LEGACY(UPD765_TAG, upd765_dack_r, upd765_dack_w) |
| 43 | AM_RANGE(0x00f4, 0x00f4) AM_MIRROR(0xff00) AM_READ(hw_input_gate_r) |
| 44 | AM_RANGE(0x00f6, 0x00f7) AM_MIRROR(0xff00) AM_WRITE(fdd_select_w) |
| 45 | AM_RANGE(0x00f8, 0x00f9) AM_MIRROR(0xff00) AM_WRITE(hw_terminal_count_w) |
| 46 | AM_RANGE(0x00fc, 0x00ff) AM_MIRROR(0xff00) AM_DEVREADWRITE_LEGACY(Z80CTC_TAG, z80ctc_r, z80ctc_w) |
| 47 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(gide_r, gide_w) |
| 48 | ADDRESS_MAP_END |
| 49 | |
| 36 | 50 | static LEGACY_FLOPPY_OPTIONS_START(kc_d004) |
| 37 | 51 | LEGACY_FLOPPY_OPTION(kc85, "img", "KC85 disk image 800KB", basicdsk_identify_default, basicdsk_construct_default, NULL, |
| 38 | 52 | HEADS([2]) |
| r15033 | r15034 | |
| 109 | 123 | MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(kc_d004_floppy_interface) |
| 110 | 124 | MACHINE_CONFIG_END |
| 111 | 125 | |
| 126 | |
| 127 | static MACHINE_CONFIG_FRAGMENT(kc_d004_gide) |
| 128 | MCFG_FRAGMENT_ADD(kc_d004) |
| 129 | |
| 130 | MCFG_CPU_MODIFY(Z80_TAG) |
| 131 | MCFG_CPU_IO_MAP(kc_d004_gide_io) |
| 132 | |
| 133 | MCFG_IDE_CONTROLLER_ADD(IDE_TAG, NULL, ide_image_devices, "hdd", "hdd") |
| 134 | MACHINE_CONFIG_END |
| 135 | |
| 136 | |
| 112 | 137 | ROM_START( kc_d004 ) |
| 113 | 138 | ROM_REGION(0x2000, Z80_TAG, 0) |
| 114 | | ROM_LOAD_OPTIONAL( "d004v20.bin", 0x0000, 0x2000, CRC(4f3494f1) SHA1(66f476de78fb474d9ac61c6eaffce3354fd66776)) |
| 139 | ROM_LOAD_OPTIONAL("d004v20.bin", 0x0000, 0x2000, CRC(4f3494f1) SHA1(66f476de78fb474d9ac61c6eaffce3354fd66776)) |
| 115 | 140 | ROM_END |
| 116 | 141 | |
| 142 | ROM_START( kc_d004_gide ) |
| 143 | ROM_REGION(0x2000, Z80_TAG, 0) |
| 144 | ROM_LOAD_OPTIONAL("d004v33_3.bin", 0x0000, 0x2000, CRC(945f3e4b) SHA1(cce5d9eea82582270660c8275336b15bf9906253)) // KC85/3 |
| 145 | ROM_LOAD_OPTIONAL("d004v33_4.bin", 0x0000, 0x2000, CRC(1451efd7) SHA1(9db201af408adb02254094dc7aa7185bf5a7b9b1)) // KC85/4-5 |
| 146 | ROM_LOAD_OPTIONAL("d004v30.bin", 0x0000, 0x2000, CRC(6fe0a283) SHA1(5582b2541a34a90c7a9516a6a222d4961fc54fcf)) // KC85/4-5 |
| 147 | ROM_LOAD_OPTIONAL("d004v31.bin", 0x0000, 0x2000, CRC(712547de) SHA1(38b3164dce23573375fc0237f348d9a699fc6f9f)) // KC85/4-5 |
| 148 | ROM_LOAD_OPTIONAL("d004v32.bin", 0x0000, 0x2000, CRC(9a3d3511) SHA1(8232adb5e5f0b25b52f9873cff14831da3a0398a)) // KC85/4-5 |
| 149 | ROM_END |
| 150 | |
| 151 | |
| 117 | 152 | //************************************************************************** |
| 118 | 153 | // GLOBAL VARIABLES |
| 119 | 154 | //************************************************************************** |
| 120 | 155 | |
| 121 | 156 | const device_type KC_D004 = &device_creator<kc_d004_device>; |
| 157 | const device_type KC_D004_GIDE = &device_creator<kc_d004_gide_device>; |
| 122 | 158 | |
| 123 | 159 | //************************************************************************** |
| 124 | 160 | // LIVE DEVICE |
| r15033 | r15034 | |
| 132 | 168 | : device_t(mconfig, KC_D004, "D004 Floppy Disk Interface", tag, owner, clock), |
| 133 | 169 | device_kcexp_interface( mconfig, *this ), |
| 134 | 170 | m_cpu(*this, Z80_TAG), |
| 135 | | m_fdc(*this, UPD765_TAG) |
| 171 | m_fdc(*this, UPD765_TAG), |
| 172 | m_koppel_ram(*this, "koppelram") |
| 136 | 173 | { |
| 137 | 174 | } |
| 138 | 175 | |
| 176 | kc_d004_device::kc_d004_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) |
| 177 | : device_t(mconfig, type, name, tag, owner, clock), |
| 178 | device_kcexp_interface( mconfig, *this ), |
| 179 | m_cpu(*this, Z80_TAG), |
| 180 | m_fdc(*this, UPD765_TAG), |
| 181 | m_koppel_ram(*this, "koppelram") |
| 182 | { |
| 183 | } |
| 184 | |
| 139 | 185 | //------------------------------------------------- |
| 140 | 186 | // device_start - device-specific startup |
| 141 | 187 | //------------------------------------------------- |
| r15033 | r15034 | |
| 241 | 287 | case 0xf1: |
| 242 | 288 | case 0xf2: |
| 243 | 289 | case 0xf3: |
| 244 | | data = m_cpu->memory().space(AS_PROGRAM)->read_byte(0xfc00 | ((offset & 0x03)<<8) | ((offset>>8) & 0xff)); |
| 290 | data = m_koppel_ram[((offset & 0x03)<<8) | ((offset>>8) & 0xff)]; |
| 245 | 291 | break; |
| 246 | 292 | } |
| 247 | 293 | } |
| r15033 | r15034 | |
| 271 | 317 | case 0xf1: |
| 272 | 318 | case 0xf2: |
| 273 | 319 | case 0xf3: |
| 274 | | m_cpu->memory().space(AS_PROGRAM)->write_byte(0xfc00 | ((offset & 0x03)<<8) | ((offset>>8) & 0xff), data); |
| 320 | m_koppel_ram[((offset & 0x03)<<8) | ((offset>>8) & 0xff)] = data; |
| 275 | 321 | break; |
| 276 | 322 | case 0xf4: |
| 277 | 323 | if (data & 0x01) |
| r15033 | r15034 | |
| 360 | 406 | else |
| 361 | 407 | m_hw_input_gate |= 0x80; |
| 362 | 408 | } |
| 409 | |
| 410 | |
| 411 | |
| 412 | //************************************************************************** |
| 413 | // D004 Floppy Disk + GIDE Interface |
| 414 | //************************************************************************** |
| 415 | |
| 416 | //------------------------------------------------- |
| 417 | // kc_d004_gide_device - constructor |
| 418 | //------------------------------------------------- |
| 419 | |
| 420 | kc_d004_gide_device::kc_d004_gide_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 421 | : kc_d004_device(mconfig, KC_D004, "D004 Floppy Disk + GIDE Interface", tag, owner, clock), |
| 422 | m_ide(*this, IDE_TAG) |
| 423 | { |
| 424 | } |
| 425 | |
| 426 | //------------------------------------------------- |
| 427 | // device_mconfig_additions |
| 428 | //------------------------------------------------- |
| 429 | |
| 430 | machine_config_constructor kc_d004_gide_device::device_mconfig_additions() const |
| 431 | { |
| 432 | return MACHINE_CONFIG_NAME( kc_d004_gide ); |
| 433 | } |
| 434 | |
| 435 | |
| 436 | //------------------------------------------------- |
| 437 | // device_rom_region |
| 438 | //------------------------------------------------- |
| 439 | |
| 440 | const rom_entry *kc_d004_gide_device::device_rom_region() const |
| 441 | { |
| 442 | return ROM_NAME( kc_d004_gide ); |
| 443 | } |
| 444 | |
| 445 | //------------------------------------------------- |
| 446 | // device_reset - device-specific reset |
| 447 | //------------------------------------------------- |
| 448 | |
| 449 | void kc_d004_gide_device::device_reset() |
| 450 | { |
| 451 | kc_d004_device::device_reset(); |
| 452 | |
| 453 | m_ide_data = 0; |
| 454 | m_lh = 0; |
| 455 | } |
| 456 | |
| 457 | //------------------------------------------------- |
| 458 | // GIDE read |
| 459 | //------------------------------------------------- |
| 460 | |
| 461 | READ8_MEMBER(kc_d004_gide_device::gide_r) |
| 462 | { |
| 463 | UINT8 data = 0xff; |
| 464 | UINT8 io_addr = offset & 0x0f; |
| 465 | |
| 466 | if (io_addr == 0x05) |
| 467 | { |
| 468 | UINT8 rtc_addr = (offset >> 8) & 0x0f; |
| 469 | |
| 470 | // TODO RTC-72421 |
| 471 | logerror("GIDE %s read RTC 0x%02x\n", tag(), rtc_addr); |
| 472 | data = 0; |
| 473 | } |
| 474 | else |
| 475 | { |
| 476 | int ide_cs = (io_addr & 0x08) ? 0 : ((io_addr == 0x06 || io_addr == 0x07) ? 1 : -1); |
| 477 | |
| 478 | if (ide_cs != -1) |
| 479 | { |
| 480 | int data_shift = 0; |
| 481 | |
| 482 | if (io_addr == 0x08 && m_lh) |
| 483 | data_shift = 8; |
| 484 | |
| 485 | if (io_addr == 0x06 || io_addr == 0x07 || io_addr > 0x08 || (io_addr == 0x08 && !m_lh)) |
| 486 | m_ide_data = ide_bus_r(m_ide, ide_cs, io_addr & 0x07); |
| 487 | |
| 488 | data = (m_ide_data >> data_shift) & 0xff; |
| 489 | } |
| 490 | |
| 491 | m_lh = (io_addr == 0x08) ? !m_lh : ((io_addr > 0x08) ? 0 : m_lh); |
| 492 | } |
| 493 | |
| 494 | return data; |
| 495 | } |
| 496 | |
| 497 | //------------------------------------------------- |
| 498 | // GIDE write |
| 499 | //------------------------------------------------- |
| 500 | |
| 501 | WRITE8_MEMBER(kc_d004_gide_device::gide_w) |
| 502 | { |
| 503 | UINT8 io_addr = offset & 0x0f; |
| 504 | |
| 505 | if (io_addr == 0x05) |
| 506 | { |
| 507 | UINT8 rtc_addr = (offset >> 8) & 0x0f; |
| 508 | |
| 509 | // TODO RTC-72421 |
| 510 | logerror("GIDE %s wrire RTC 0x%02x 0x%02x\n", tag(), rtc_addr, data); |
| 511 | } |
| 512 | else |
| 513 | { |
| 514 | int ide_cs = (io_addr & 0x08) ? 0 : ((io_addr == 0x06 || io_addr == 0x07) ? 1 : -1); |
| 515 | |
| 516 | if (ide_cs != -1) |
| 517 | { |
| 518 | int data_shift = 0; |
| 519 | |
| 520 | if (io_addr == 0x08 && m_lh) |
| 521 | data_shift = 8; |
| 522 | |
| 523 | m_ide_data = (data << data_shift) | (m_ide_data & (0xff00 >> data_shift)); |
| 524 | |
| 525 | if (io_addr == 0x06 || io_addr == 0x07 || io_addr > 0x08 || (io_addr == 0x08 && m_lh)) |
| 526 | ide_bus_w(m_ide, ide_cs, io_addr & 0x07, m_ide_data); |
| 527 | } |
| 528 | |
| 529 | m_lh = (io_addr == 0x08) ? !m_lh : ((io_addr > 0x08) ? 0 : m_lh); |
| 530 | } |
| 531 | } |
src/mess/machine/kc_d004.h
| r15033 | r15034 | |
| 8 | 8 | #include "machine/z80ctc.h" |
| 9 | 9 | #include "cpu/z80/z80.h" |
| 10 | 10 | #include "machine/upd765.h" |
| 11 | #include "machine/idectrl.h" |
| 11 | 12 | #include "formats/basicdsk.h" |
| 12 | 13 | #include "imagedev/flopdrv.h" |
| 14 | #include "imagedev/harddriv.h" |
| 13 | 15 | |
| 14 | 16 | |
| 15 | 17 | //************************************************************************** |
| r15033 | r15034 | |
| 25 | 27 | public: |
| 26 | 28 | // construction/destruction |
| 27 | 29 | kc_d004_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 30 | kc_d004_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); |
| 28 | 31 | |
| 29 | 32 | // optional information overrides |
| 30 | 33 | virtual machine_config_constructor device_mconfig_additions() const; |
| r15033 | r15034 | |
| 58 | 61 | |
| 59 | 62 | required_device<cpu_device> m_cpu; |
| 60 | 63 | required_device<device_t> m_fdc; |
| 64 | required_shared_ptr<UINT8> m_koppel_ram; |
| 61 | 65 | |
| 62 | 66 | // internal state |
| 63 | 67 | emu_timer * m_reset_timer; |
| r15033 | r15034 | |
| 73 | 77 | }; |
| 74 | 78 | |
| 75 | 79 | |
| 80 | // ======================> kc_d004_gide_device |
| 81 | |
| 82 | class kc_d004_gide_device : |
| 83 | public kc_d004_device |
| 84 | { |
| 85 | public: |
| 86 | // construction/destruction |
| 87 | kc_d004_gide_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 88 | |
| 89 | // optional information overrides |
| 90 | virtual machine_config_constructor device_mconfig_additions() const; |
| 91 | virtual const rom_entry *device_rom_region() const; |
| 92 | |
| 93 | protected: |
| 94 | // device-level overrides |
| 95 | virtual void device_reset(); |
| 96 | virtual void device_config_complete() { m_shortname = "kc_d004gide"; } |
| 97 | |
| 98 | public: |
| 99 | DECLARE_READ8_MEMBER(gide_r); |
| 100 | DECLARE_WRITE8_MEMBER(gide_w); |
| 101 | |
| 102 | private: |
| 103 | required_device<device_t> m_ide; |
| 104 | |
| 105 | UINT16 m_ide_data; |
| 106 | int m_lh; |
| 107 | }; |
| 108 | |
| 76 | 109 | // device type definition |
| 77 | 110 | extern const device_type KC_D004; |
| 111 | extern const device_type KC_D004_GIDE; |
| 78 | 112 | |
| 79 | 113 | #endif /* __KC_D004_H__ */ |