1 // license:BSD-3-Clause
2 // copyright-holders:R. Belmont
3 /***************************************************************************
4
5 macpds.h - Mac 68000 PDS implementation (SE, Portable)
6
7 by R. Belmont
8
9 ***************************************************************************/
10
11 #ifndef MAME_BUS_MACPDS_MACPDS_H
12 #define MAME_BUS_MACPDS_MACPDS_H
13
14 #pragma once
15
16
17 //**************************************************************************
18 // TYPE DEFINITIONS
19 //**************************************************************************
20
21 class macpds_device;
22
23 class macpds_slot_device : public device_t, public device_slot_interface
24 {
25 public:
26 // construction/destruction
27 template <typename T>
macpds_slot_device(const machine_config & mconfig,const char * tag,device_t * owner,const char * nbtag,T && opts,const char * dflt)28 macpds_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, const char *nbtag, T &&opts, const char *dflt)
29 : macpds_slot_device(mconfig, tag, owner, (uint32_t)0)
30 {
31 option_reset();
32 opts(*this);
33 set_default_option(dflt);
34 set_macpds_slot(nbtag, tag);
35 }
36
37 macpds_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
38
39 // inline configuration
set_macpds_slot(const char * tag,const char * slottag)40 void set_macpds_slot(const char *tag, const char *slottag) { m_macpds_tag = tag; m_macpds_slottag = slottag; }
41
42 protected:
43 macpds_slot_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
44
45 // device-level overrides
46 virtual void device_start() override;
47
48 // configuration
49 const char *m_macpds_tag, *m_macpds_slottag;
50 };
51
52 // device type definition
DECLARE_DEVICE_TYPE(MACPDS_SLOT,macpds_slot_device)53 DECLARE_DEVICE_TYPE(MACPDS_SLOT, macpds_slot_device)
54
55
56 class device_macpds_card_interface;
57
58 // ======================> macpds_device
59 class macpds_device : public device_t
60 {
61 public:
62 // construction/destruction
63 macpds_device(const machine_config &mconfig, const char *tag, device_t *owner, const char *cputag)
64 : macpds_device(mconfig, tag, owner, (uint32_t)0)
65 {
66 set_cputag(cputag);
67 }
68
69 macpds_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
70
71 ~macpds_device() { m_device_list.detach_all(); }
72 // inline configuration
73 void set_cputag(const char *tag) { m_cputag = tag; }
74
75 void add_macpds_card(device_macpds_card_interface *card);
76 template<typename R, typename W> void install_device(offs_t start, offs_t end, R rhandler, W whandler, uint32_t mask=0xffffffff);
77 void install_bank(offs_t start, offs_t end, const char *tag, uint8_t *data);
78 void set_irq_line(int line, int state);
79
80 protected:
81 macpds_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
82
83 // device-level overrides
84 virtual void device_start() override;
85 virtual void device_reset() override;
86
87 // internal state
88 cpu_device *m_maincpu;
89
90 simple_list<device_macpds_card_interface> m_device_list;
91 const char *m_cputag;
92 };
93
94
95 // device type definition
DECLARE_DEVICE_TYPE(MACPDS,macpds_device)96 DECLARE_DEVICE_TYPE(MACPDS, macpds_device)
97
98 // ======================> device_macpds_card_interface
99
100 // class representing interface-specific live macpds card
101 class device_macpds_card_interface : public device_interface
102 {
103 friend class macpds_device;
104 template <class ElememtType> friend class simple_list;
105 public:
106 // construction/destruction
107 virtual ~device_macpds_card_interface();
108
109 device_macpds_card_interface *next() const { return m_next; }
110
111 void set_macpds_device();
112
113 // helper functions for card devices
114 void install_bank(offs_t start, offs_t end, const char *tag, uint8_t *data);
115 void install_rom(device_t *dev, const char *romregion, uint32_t addr);
116
117 // inline configuration
118 void set_macpds_tag(const char *tag, const char *slottag) { m_macpds_tag = tag; m_macpds_slottag = slottag; }
119
120 protected:
121 device_macpds_card_interface(const machine_config &mconfig, device_t &device);
122
123 macpds_device *m_macpds;
124 const char *m_macpds_tag, *m_macpds_slottag;
125
126 private:
127 device_macpds_card_interface *m_next;
128 };
129
130 #endif // MAME_BUS_MACPDS_MACPDS_H
131