summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/bus/pet/exp.h
blob: a871a53c8a2ab85eb870d2527bcb59029a5355fe (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************

    Commodore PET Memory Expansion Port emulation

    Copyright MESS Team.
    Visit http://mamedev.org for licensing and usage restrictions.

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

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

#pragma once

#ifndef __PET_EXPANSION_SLOT__
#define __PET_EXPANSION_SLOT__

#include "emu.h"



//**************************************************************************
//  CONSTANTS
//**************************************************************************

#define PET_EXPANSION_SLOT_TAG     "exp"



//**************************************************************************
//  INTERFACE CONFIGURATION MACROS
//**************************************************************************

#define MCFG_PET_EXPANSION_SLOT_ADD(_tag, _clock, _slot_intf, _def_slot) \
	MCFG_DEVICE_ADD(_tag, PET_EXPANSION_SLOT, _clock) \
	MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)


#define MCFG_PET_EXPANSION_SLOT_DMA_CALLBACKS(_read, _write) \
	downcast<pet_expansion_slot_device *>(device)->set_callbacks(DEVCB2_##_read, DEVCB2_##_write);



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

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

class device_pet_expansion_card_interface;

class pet_expansion_slot_device : public device_t,
									public device_slot_interface
{
public:
	// construction/destruction
	pet_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	virtual ~pet_expansion_slot_device();

	template<class _read, class _write> void set_callbacks(_read rd, _write wr) {
		m_read_dma.set_callback(rd);
		m_write_dma.set_callback(wr);
	}

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

	// cartridge interface
	UINT8 dma_bd_r(offs_t offset);
	void dma_bd_w(offs_t offset, UINT8 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();
	virtual void device_reset();

	device_pet_expansion_card_interface *m_card;

	devcb2_read8  m_read_dma;
	devcb2_write8 m_write_dma;
};


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

class device_pet_expansion_card_interface : public device_slot_card_interface
{
	friend class pet_expansion_slot_device;

public:
	// construction/destruction
	device_pet_expansion_card_interface(const machine_config &mconfig, device_t &device);
	virtual ~device_pet_expansion_card_interface();

protected:
	// runtime
	virtual int pet_norom_r(address_space &space, offs_t offset, int sel) { return 1; }
	virtual UINT8 pet_bd_r(address_space &space, offs_t offset, UINT8 data, int &sel) { return data; };
	virtual void pet_bd_w(address_space &space, offs_t offset, UINT8 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
extern const device_type PET_EXPANSION_SLOT;


// slot devices
#include "64k.h"
#include "superpet.h"

SLOT_INTERFACE_EXTERN( pet_expansion_cards );



#endif