1 // license:LGPL-2.1+
2 // copyright-holders:Michael Zapf
3 /****************************************************************************
4 
5     Multi cartridge connector.
6 
7     We set the number of slots to 4, although we may have up to 16. From a
8     logical point of view we could have 256, but the operating system only checks
9     the first 16 banks.
10 *****************************************************************************/
11 
12 #ifndef MAME_BUS_TI99_GROMPORT_MULTICONN_H
13 #define MAME_BUS_TI99_GROMPORT_MULTICONN_H
14 
15 #pragma once
16 #include "cartridges.h"
17 
18 namespace bus { namespace ti99 { namespace gromport {
19 
20 class ti99_multi_cart_conn_device : public cartridge_connector_device
21 {
22 public:
23 	ti99_multi_cart_conn_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
24 
25 	void readz(offs_t offset, uint8_t *value) override;
26 	void write(offs_t offset, uint8_t data) override;
27 	void crureadz(offs_t offset, uint8_t *value) override;
28 	void cruwrite(offs_t offset, uint8_t data) override;
29 	DECLARE_WRITE_LINE_MEMBER(romgq_line) override;
30 	void set_gromlines(line_state mline, line_state moline, line_state gsq) override;
31 	DECLARE_WRITE_LINE_MEMBER(gclock_in) override;
32 
33 	void insert(int index, ti99_cartridge_device* cart) override;
34 	void remove(int index) override;
35 	DECLARE_INPUT_CHANGED_MEMBER( switch_changed );
36 
37 	bool is_grom_idle() override;
38 
39 protected:
40 	static constexpr unsigned NUMBER_OF_CARTRIDGE_SLOTS = 4;
41 
42 	virtual void device_start() override;
43 	virtual void device_reset() override;
44 	virtual void device_add_mconfig(machine_config &config) override;
45 	virtual ioport_constructor device_input_ports() const override;
46 
47 private:
48 	bool m_readrom;
49 	int     m_active_slot;
50 	int     m_fixed_slot;
51 	int     m_next_free_slot;
52 	ti99_cartridge_device*  m_cartridge[NUMBER_OF_CARTRIDGE_SLOTS];
53 
54 	void    set_slot(int slotnumber);
55 	int     get_active_slot(bool changebase, offs_t offset);
56 };
57 
58 } } } // end namespace bus::ti99::gromport
59 
60 DECLARE_DEVICE_TYPE_NS(TI99_GROMPORT_MULTI,  bus::ti99::gromport, ti99_multi_cart_conn_device)
61 
62 #endif // MAME_BUS_TI99_GROMPORT_MULTICONN_H
63 
64 
65 
66