summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/coco/coco_multi.h
blob: 7f5fc1d4ccbf170e966e5b551559347512e17e9b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// license:BSD-3-Clause
// copyright-holders:Nathan Woods
/***************************************************************************

    coco_multi.h

    Multi-Pak interface emulation

***************************************************************************/

#ifndef MAME_BUS_COCO_COCO_MULTI_H
#define MAME_BUS_COCO_COCO_MULTI_H

#pragma once

#include "cococart.h"



//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

// ======================> coco_multipak_device

class coco_multipak_device :
	public device_t,
	public device_cococart_interface
{
public:
	// construction/destruction
	coco_multipak_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	// optional information overrides
	virtual machine_config_constructor device_mconfig_additions() const override;

	virtual uint8_t* get_cart_base() override;

	// these are only public so they can be in a MACHINE_CONFIG_START
	// declaration; don't think about them as publically accessable
	DECLARE_WRITE_LINE_MEMBER(multi_slot1_cart_w);
	DECLARE_WRITE_LINE_MEMBER(multi_slot1_nmi_w);
	DECLARE_WRITE_LINE_MEMBER(multi_slot1_halt_w);
	DECLARE_WRITE_LINE_MEMBER(multi_slot2_cart_w);
	DECLARE_WRITE_LINE_MEMBER(multi_slot2_nmi_w);
	DECLARE_WRITE_LINE_MEMBER(multi_slot2_halt_w);
	DECLARE_WRITE_LINE_MEMBER(multi_slot3_cart_w);
	DECLARE_WRITE_LINE_MEMBER(multi_slot3_nmi_w);
	DECLARE_WRITE_LINE_MEMBER(multi_slot3_halt_w);
	DECLARE_WRITE_LINE_MEMBER(multi_slot4_cart_w);
	DECLARE_WRITE_LINE_MEMBER(multi_slot4_nmi_w);
	DECLARE_WRITE_LINE_MEMBER(multi_slot4_halt_w);

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;
	virtual DECLARE_READ8_MEMBER(read) override;
	virtual DECLARE_WRITE8_MEMBER(write) override;
	virtual void set_sound_enable(bool sound_enable) override;

private:
	// device references
	required_device_array<cococart_slot_device, 4> m_slots;

	// internal state
	uint8_t m_select;

	// internal accessors
	cococart_slot_device &owning_slot();
	int active_scs_slot_number() const;
	int active_cts_slot_number() const;
	cococart_slot_device &slot(int slot_number);
	cococart_slot_device &active_scs_slot();
	cococart_slot_device &active_cts_slot();

	// methods
	void set_select(uint8_t new_select);
	DECLARE_WRITE8_MEMBER(ff7f_write);
	void update_line(int slot_number, cococart_slot_device::line line);
};


// device type definition
DECLARE_DEVICE_TYPE(COCO_MULTIPAK, coco_multipak_device)

#endif  // MAME_BUS_COCO_COCO_MULTI_H