summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/pet/exp.h
blob: e8018bdd732fc721ed7f49715077b009b523d907 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************

    Commodore PET Memory Expansion Port emulation

**********************************************************************

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

#ifndef MAME_BUS_PET_EXP_H
#define MAME_BUS_PET_EXP_H

#pragma once




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

// ======================> pet_expansion_slot_device

class device_pet_expansion_card_interface;

class pet_expansion_slot_device : public device_t,
									public device_single_card_slot_interface<device_pet_expansion_card_interface>
{
public:
	template <typename T>
	pet_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&opts, const char *dflt)
		: pet_expansion_slot_device(mconfig, tag, owner, clock)
	{
		option_reset();
		opts(*this);
		set_default_option(dflt);
		set_fixed(false);
	}

	pet_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
	virtual ~pet_expansion_slot_device();

	auto dma_read_callback() { return m_read_dma.bind(); }
	auto dma_write_callback() { return m_write_dma.bind(); }

	// computer interface
	int norom_r(offs_t offset, int sel);
	uint8_t read(offs_t offset, uint8_t data, int &sel);
	void write(offs_t offset, uint8_t data, int &sel);
	DECLARE_READ_LINE_MEMBER( diag_r );
	DECLARE_WRITE_LINE_MEMBER( irq_w );

	// cartridge interface
	uint8_t dma_bd_r(offs_t offset);
	void dma_bd_w(offs_t offset, uint8_t data);
	int phi2();

	enum
	{
		SEL_NONE = -1,
		SEL0 = 0,
		SEL1,
		SEL2,
		SEL3,
		SEL4,
		SEL5,
		SEL6,
		SEL7,
		SEL8,
		SEL9,
		SELA,
		SELB,
		SELC,
		SELD,
		SELE,
		SELF
	};

protected:
	// device-level overrides
	virtual void device_start() override;

	device_pet_expansion_card_interface *m_card;

	devcb_read8  m_read_dma;
	devcb_write8 m_write_dma;
};


// ======================> device_pet_expansion_card_interface

class device_pet_expansion_card_interface : public device_interface
{
	friend class pet_expansion_slot_device;

public:
	// construction/destruction
	virtual ~device_pet_expansion_card_interface();

protected:
	device_pet_expansion_card_interface(const machine_config &mconfig, device_t &device);

	// runtime
	virtual int pet_norom_r(offs_t offset, int sel) { return 1; }
	virtual uint8_t pet_bd_r(offs_t offset, uint8_t data, int &sel) { return data; }
	virtual void pet_bd_w(offs_t offset, uint8_t data, int &sel) { }
	virtual int pet_diag_r() { return 1; }
	virtual void pet_irq_w(int state) { }

	pet_expansion_slot_device *m_slot;
};


// device type definition
DECLARE_DEVICE_TYPE(PET_EXPANSION_SLOT, pet_expansion_slot_device)


void pet_expansion_cards(device_slot_interface &device);

#endif // MAME_BUS_PET_EXP_H