Previous 15994 Revisions Next

r15034 Wednesday 25th April, 2012 at 20:56:30 UTC by Sandro Ronco
KC: Added emulation of GIDE interface. [Sandro Ronco]
[src/mess/drivers]kc.c
[src/mess/machine]kc_d004.c kc_d004.h

src/mess/machine/kc_d004.c
r15033r15034
1212#define Z80_TAG         "disk"
1313#define Z80CTC_TAG      "z80ctc"
1414#define UPD765_TAG      "upd765"
15#define IDE_TAG         "ide"
1516
1617/***************************************************************************
1718    IMPLEMENTATION
1819***************************************************************************/
1920
2021static 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")
2224ADDRESS_MAP_END
2325
2426static ADDRESS_MAP_START(kc_d004_io, AS_IO, 8, kc_d004_device)
r15033r15034
3335   AM_RANGE(0xfc, 0xff) AM_DEVREADWRITE_LEGACY(Z80CTC_TAG, z80ctc_r, z80ctc_w)
3436ADDRESS_MAP_END
3537
38static 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)
48ADDRESS_MAP_END
49
3650static LEGACY_FLOPPY_OPTIONS_START(kc_d004)
3751   LEGACY_FLOPPY_OPTION(kc85, "img", "KC85 disk image 800KB", basicdsk_identify_default, basicdsk_construct_default, NULL,
3852      HEADS([2])
r15033r15034
109123   MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(kc_d004_floppy_interface)
110124MACHINE_CONFIG_END
111125
126
127static 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")
134MACHINE_CONFIG_END
135
136
112137ROM_START( kc_d004 )
113138   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))
115140ROM_END
116141
142ROM_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
149ROM_END
150
151
117152//**************************************************************************
118153//  GLOBAL VARIABLES
119154//**************************************************************************
120155
121156const device_type KC_D004 = &device_creator<kc_d004_device>;
157const device_type KC_D004_GIDE = &device_creator<kc_d004_gide_device>;
122158
123159//**************************************************************************
124160//  LIVE DEVICE
r15033r15034
132168      : device_t(mconfig, KC_D004, "D004 Floppy Disk Interface", tag, owner, clock),
133169      device_kcexp_interface( mconfig, *this ),
134170      m_cpu(*this, Z80_TAG),
135      m_fdc(*this, UPD765_TAG)
171      m_fdc(*this, UPD765_TAG),
172      m_koppel_ram(*this, "koppelram")
136173{
137174}
138175
176kc_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
139185//-------------------------------------------------
140186//  device_start - device-specific startup
141187//-------------------------------------------------
r15033r15034
241287         case 0xf1:
242288         case 0xf2:
243289         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)];
245291            break;
246292         }
247293      }
r15033r15034
271317         case 0xf1:
272318         case 0xf2:
273319         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;
275321            break;
276322         case 0xf4:
277323            if (data & 0x01)
r15033r15034
360406   else
361407      m_hw_input_gate |= 0x80;
362408}
409
410
411
412//**************************************************************************
413//  D004 Floppy Disk + GIDE Interface
414//**************************************************************************
415
416//-------------------------------------------------
417//  kc_d004_gide_device - constructor
418//-------------------------------------------------
419
420kc_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
430machine_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
440const 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
449void 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
461READ8_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
501WRITE8_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
r15033r15034
88#include "machine/z80ctc.h"
99#include "cpu/z80/z80.h"
1010#include "machine/upd765.h"
11#include "machine/idectrl.h"
1112#include "formats/basicdsk.h"
1213#include "imagedev/flopdrv.h"
14#include "imagedev/harddriv.h"
1315
1416
1517//**************************************************************************
r15033r15034
2527public:
2628   // construction/destruction
2729   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);
2831
2932   // optional information overrides
3033   virtual machine_config_constructor device_mconfig_additions() const;
r15033r15034
5861
5962   required_device<cpu_device> m_cpu;
6063   required_device<device_t>   m_fdc;
64   required_shared_ptr<UINT8>   m_koppel_ram;
6165
6266   // internal state
6367   emu_timer *         m_reset_timer;
r15033r15034
7377};
7478
7579
80// ======================> kc_d004_gide_device
81
82class kc_d004_gide_device :
83      public kc_d004_device
84{
85public:
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
93protected:
94   // device-level overrides
95   virtual void device_reset();
96   virtual void device_config_complete() { m_shortname = "kc_d004gide"; }
97
98public:
99   DECLARE_READ8_MEMBER(gide_r);
100   DECLARE_WRITE8_MEMBER(gide_w);
101
102private:
103   required_device<device_t> m_ide;
104
105   UINT16            m_ide_data;
106   int             m_lh;
107};
108
76109// device type definition
77110extern const device_type KC_D004;
111extern const device_type KC_D004_GIDE;
78112
79113#endif  /* __KC_D004_H__ */
src/mess/drivers/kc.c
r15033r15034
8888extern SLOT_INTERFACE_START(kc85_exp)
8989   SLOT_INTERFACE("d002", KC_D002)         // D002 Bus Driver
9090   SLOT_INTERFACE("d004", KC_D004)         // D004 Floppy Disk Interface
91   SLOT_INTERFACE("d004gide", KC_D004_GIDE) // D004 Floppy Disk + GIDE Interface
9192SLOT_INTERFACE_END
9293
9394

Previous 15994 Revisions Next


© 1998-2018 The MESS Team