|
9 | 9 | #include "emu.h" |
10 | 10 | #include "c2031.h" |
11 | 11 |
|
| 12 | +#include "cpu/m6502/m6502.h" |
| 13 | +#include "imagedev/floppy.h" |
| 14 | +#include "machine/64h156.h" |
| 15 | +#include "machine/6522via.h" |
| 16 | + |
12 | 17 | #include "formats/d64_dsk.h" |
13 | 18 | #include "formats/g64_dsk.h" |
14 | 19 |
|
15 | 20 |
|
| 21 | +namespace { |
| 22 | + |
16 | 23 | //************************************************************************** |
17 | 24 | // MACROS / CONSTANTS |
18 | 25 | //************************************************************************** |
19 | 26 |
|
20 | 27 | #define M6502_TAG "ucd5" |
21 | | -#define M6522_0_TAG "uab1" |
22 | | -#define M6522_1_TAG "ucd4" |
23 | 28 | #define C64H156_TAG "64h156" |
24 | 29 |
|
25 | 30 |
|
|
32 | 37 |
|
33 | 38 |
|
34 | 39 | //************************************************************************** |
35 | | -// DEVICE DEFINITIONS |
| 40 | +// TYPE DEFINITIONS |
36 | 41 | //************************************************************************** |
37 | 42 |
|
38 | | -DEFINE_DEVICE_TYPE(C2031, c2031_device, "c2031", "Commodore 2031") |
| 43 | +// ======================> c2031_device |
| 44 | + |
| 45 | +class c2031_device : public device_t, |
| 46 | + public device_ieee488_interface |
| 47 | +{ |
| 48 | +public: |
| 49 | + // construction/destruction |
| 50 | + c2031_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); |
| 51 | + |
| 52 | +protected: |
| 53 | + // device_t implementation |
| 54 | + virtual void device_start() override ATTR_COLD; |
| 55 | + virtual void device_reset() override ATTR_COLD; |
| 56 | + virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD; |
| 57 | + virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; |
| 58 | + virtual ioport_constructor device_input_ports() const override ATTR_COLD; |
| 59 | + |
| 60 | + // device_ieee488_interface implementation |
| 61 | + virtual void ieee488_atn(int state) override; |
| 62 | + virtual void ieee488_ifc(int state) override; |
| 63 | + |
| 64 | +private: |
| 65 | + inline int get_device_number(); |
| 66 | + |
| 67 | + void via0_irq_w(int state); |
| 68 | + uint8_t via0_pa_r(); |
| 69 | + void via0_pa_w(uint8_t data); |
| 70 | + uint8_t via0_pb_r(); |
| 71 | + void via0_pb_w(uint8_t data); |
| 72 | + void via1_irq_w(int state); |
| 73 | + uint8_t via1_pb_r(); |
| 74 | + void via1_pb_w(uint8_t data); |
| 75 | + void byte_w(int state); |
| 76 | + |
| 77 | + void c2031_mem(address_map &map) ATTR_COLD; |
| 78 | + |
| 79 | + static void floppy_formats(format_registration &fr); |
| 80 | + |
| 81 | + required_device<m6502_device> m_maincpu; |
| 82 | + required_device<via6522_device> m_via0; |
| 83 | + required_device<via6522_device> m_via1; |
| 84 | + required_device<c64h156_device> m_ga; |
| 85 | + required_device<floppy_image_device> m_floppy; |
| 86 | + required_ioport m_address; |
| 87 | + output_finder<2> m_leds; |
| 88 | + |
| 89 | + // IEEE-488 bus |
| 90 | + int m_nrfd_out; // not ready for data |
| 91 | + int m_ndac_out; // not data accepted |
| 92 | + int m_atna; // attention acknowledge |
| 93 | + int m_ifc; |
| 94 | + |
| 95 | + // interrupts |
| 96 | + int m_via0_irq; // VIA #0 interrupt request |
| 97 | + int m_via1_irq; // VIA #1 interrupt request |
| 98 | +}; |
39 | 99 |
|
40 | 100 |
|
41 | 101 | //------------------------------------------------- |
@@ -66,8 +126,8 @@ const tiny_rom_entry *c2031_device::device_rom_region() const |
66 | 126 | void c2031_device::c2031_mem(address_map &map) |
67 | 127 | { |
68 | 128 | map(0x0000, 0x07ff).mirror(0x6000).ram(); |
69 | | - map(0x1800, 0x180f).mirror(0x63f0).m(M6522_0_TAG, FUNC(via6522_device::map)); |
70 | | - map(0x1c00, 0x1c0f).mirror(0x63f0).m(M6522_1_TAG, FUNC(via6522_device::map)); |
| 129 | + map(0x1800, 0x180f).mirror(0x63f0).m(m_via0, FUNC(via6522_device::map)); |
| 130 | + map(0x1c00, 0x1c0f).mirror(0x63f0).m(m_via1, FUNC(via6522_device::map)); |
71 | 131 | map(0x8000, 0xbfff).mirror(0x4000).rom().region(M6502_TAG, 0); |
72 | 132 | } |
73 | 133 |
|
@@ -388,11 +448,11 @@ inline int c2031_device::get_device_number() |
388 | 448 | //------------------------------------------------- |
389 | 449 |
|
390 | 450 | c2031_device::c2031_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) |
391 | | - : device_t(mconfig, C2031, tag, owner, clock) |
| 451 | + : device_t(mconfig, GPIB_C2031, tag, owner, clock) |
392 | 452 | , device_ieee488_interface(mconfig, *this) |
393 | 453 | , m_maincpu(*this, M6502_TAG) |
394 | | - , m_via0(*this, M6522_0_TAG) |
395 | | - , m_via1(*this, M6522_1_TAG) |
| 454 | + , m_via0(*this, "uab1") |
| 455 | + , m_via1(*this, "ucd4") |
396 | 456 | , m_ga(*this, C64H156_TAG) |
397 | 457 | , m_floppy(*this, C64H156_TAG":0:525ssqd") |
398 | 458 | , m_address(*this, "ADDRESS") |
@@ -473,3 +533,12 @@ void c2031_device::ieee488_ifc(int state) |
473 | 533 |
|
474 | 534 | m_ifc = state; |
475 | 535 | } |
| 536 | + |
| 537 | +} // anonymous namespace |
| 538 | + |
| 539 | + |
| 540 | +//************************************************************************** |
| 541 | +// DEVICE DEFINITIONS |
| 542 | +//************************************************************************** |
| 543 | + |
| 544 | +DEFINE_DEVICE_TYPE_PRIVATE(GPIB_C2031, device_ieee488_interface, c2031_device, "c2031", "Commodore 2031 single disk drive") |
0 commit comments