1 // license:BSD-3-Clause
2 // copyright-holders:Barry Rodewald
3 /*
4  * cpcexp.h  --  Amstrad CPC Expansion port
5  *
6  *  Created on: 16/07/2011
7  *
8  *  Pinout from CPC6128 User's Manual
9  *    SOUND   1  2   GND
10  *      A15   3  4   A14
11  *      A13   5  6   A12
12  *      A11   7  8   A10
13  *       A9   9  10  A8
14  *       A7  11  12  A6
15  *       A5  13  14  A4
16  *       A3  15  16  A2
17  *       A1  17  18  A0
18  *       D7  19  20  D6
19  *       D5  21  22  D4
20  *       D3  23  24  D2
21  *       D1  25  26  D0
22  *      +5v  27  28  _MREQ
23  *      _M1  29  30  _RFSH
24  *    _IORQ  31  32  _RD
25  *      _WR  33  34  _HALT
26  *     _INT  35  36  _NMI
27  *   _BUSR2  37  38  _BUSAK
28  *    READY  39  40  _BUS RESET
29  *   _RESET  41  42  _ROMEN
30  *   ROMDIS  43  44  _RAMRD
31  *   RAMDIS  45  46  CURSOR
32  *    L.PEN  47  48  _EXP
33  *      GND  49  50  CLOCK
34  *
35  *  Aleste 520EX expansion port is 62-pin.  Same as the CPC above, except that pin 40 is not connected, plus the following:
36  *
37  *    MAP14  A26  B26  MAP15
38  *    MAP16  A27  B27  MAP17
39  *    MAP18  A28  B28  MAPBLK
40  *    _INTA  A29  B29  _DISP
41  *     Agnd  A30  B30  _CPU
42  *     Aucc  A31  B31  HIGH
43  *
44  */
45 
46 #ifndef MAME_BUS_CPC_CPCEXP_H
47 #define MAME_BUS_CPC_CPCEXP_H
48 
49 #pragma once
50 
51 
52 //**************************************************************************
53 //  TYPE DEFINITIONS
54 //**************************************************************************
55 
56 // ======================> device_cpc_expansion_card_interface
57 
58 // class representing interface-specific live cpc_expansion card
59 class device_cpc_expansion_card_interface : public device_interface
60 {
61 public:
62 	enum
63 	{
64 		MAP_LOWER = 0,  // special lower ROM handling
65 		MAP_UPPER,      // special upper ROM handling
66 		MAP_OTHER       // custom ROM handling (eg: Brunword MK4)
67 	};
68 
69 	// construction/destruction
70 	virtual ~device_cpc_expansion_card_interface();
71 
72 	// reset
cpc_reset_w()73 	virtual void cpc_reset_w() { }
WRITE_LINE_MEMBER(cursor_w)74 	virtual WRITE_LINE_MEMBER( cursor_w ) { }
WRITE_LINE_MEMBER(romen_w)75 	virtual WRITE_LINE_MEMBER( romen_w ) { }
76 
set_rom_bank(uint8_t sel)77 	void set_rom_bank(uint8_t sel) { m_rom_sel = sel; }  // tell device the currently selected ROM
get_rom_bank()78 	uint8_t get_rom_bank() { return m_rom_sel; }
set_mapping(uint8_t type)79 	virtual void set_mapping(uint8_t type) { }
80 
81 protected:
82 	device_cpc_expansion_card_interface(const machine_config &mconfig, device_t &device);
83 
84 private:
85 	uint8_t m_rom_sel;  // currently selected ROM
86 };
87 
88 
89 // ======================> cpc_expansion_slot_device
90 
91 class cpc_expansion_slot_device : public device_t, public device_single_card_slot_interface<device_cpc_expansion_card_interface>
92 {
93 public:
94 	// construction/destruction
95 	cpc_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
96 	template <typename T>
cpc_expansion_slot_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock,T && opts,const char * dflt)97 	cpc_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&opts, const char *dflt)
98 		: cpc_expansion_slot_device(mconfig, tag, owner, clock)
99 	{
100 		option_reset();
101 		opts(*this);
102 		set_default_option(dflt);
103 		set_fixed(false);
104 	}
105 	virtual ~cpc_expansion_slot_device();
106 
set_cpu_tag(Object && tag)107 	template <class Object> void set_cpu_tag(Object &&tag) { m_cpu.set_tag(std::forward<Object>(tag)); }
108 
irq_callback()109 	auto irq_callback() { return m_out_irq_cb.bind(); }
nmi_callback()110 	auto nmi_callback() { return m_out_nmi_cb.bind(); }
reset_callback()111 	auto reset_callback() { return m_out_reset_cb.bind(); }
romdis_callback()112 	auto romdis_callback() { return m_out_romdis_cb.bind(); }
rom_select_callback()113 	auto rom_select_callback() { return m_out_rom_select.bind(); }
114 
115 	DECLARE_WRITE_LINE_MEMBER( irq_w );
116 	DECLARE_WRITE_LINE_MEMBER( nmi_w );
117 	DECLARE_WRITE_LINE_MEMBER( reset_w );
118 	DECLARE_WRITE_LINE_MEMBER( romdis_w );
119 	void rom_select(uint8_t data);
120 
set_rom_bank(uint8_t sel)121 	void set_rom_bank(uint8_t sel) { if(m_card) m_card->set_rom_bank(sel); }  // tell device the currently selected ROM
set_mapping(uint8_t type)122 	void set_mapping(uint8_t type) { if(m_card) m_card->set_mapping(type); }  // tell device to enable any ROM or RAM mapping
DECLARE_WRITE_LINE_MEMBER(cursor_w)123 	DECLARE_WRITE_LINE_MEMBER( cursor_w ) { if(m_card) m_card->cursor_w(state); }  // pass on CRTC Cursor signal
DECLARE_WRITE_LINE_MEMBER(romen_w)124 	DECLARE_WRITE_LINE_MEMBER( romen_w ) { if(m_card) m_card->romen_w(state); }  // pass on /ROMEN signal
125 
cpu()126 	cpu_device &cpu() const { return *m_cpu; }
127 
128 protected:
129 	// device-level overrides
130 	virtual void device_config_complete() override;
131 	virtual void device_start() override;
132 
133 	required_device<cpu_device> m_cpu;
134 
135 	devcb_write_line    m_out_irq_cb;
136 	devcb_write_line    m_out_nmi_cb;
137 	devcb_write_line    m_out_reset_cb;
138 	devcb_write_line    m_out_romdis_cb;
139 	devcb_write8        m_out_rom_select;
140 
141 	device_cpc_expansion_card_interface *m_card;
142 
143 };
144 
145 
146 // device type definition
147 DECLARE_DEVICE_TYPE(CPC_EXPANSION_SLOT, cpc_expansion_slot_device)
148 
149 #endif // MAME_BUS_CPC_CPCEXP_H
150