summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/bbc/exp/exp.h
blob: ef1a0174b1a2b95730dd45d0323f905f19d0ec11 (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
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************

    BBC Master Compact Expansion slot emulation

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

    Pin  Side A                   Side B

    1    SCREEN (0v)              SCREEN (0v)
    2    +5v                      +5v
    3    AT13                     A10
    4    NOT RST                  CD3
    5    AA15                     A11
    6    A8                       A9
    7    A13                      CD7
    8    A12                      CD6
    9    phi 2 OUT                CD5
    10   not connected            CD4
    11   not connected            LPTSTP
    12   B READ / NOT WRITE       BA7
    13   NOT NMI                  BA6
    14   NOT IRQ                  BA5
    15   NOT INFC                 BA4
    16   NOT INFD                 BA3
    17   AA14                     BA2
    18   NOT 8MHz                 BA1
    19   0v                       BA0
    20   PB7 (old user port)      CD0
    21   PB6 (old user port)      CD2
    22   PB5 (old user port)      CD1
    =========== POLARISATION SLOT ===========
    24   0v                       0v
    25   SCREEN (0v)              SCREEN (0v)

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

#ifndef MAME_BUS_BBC_EXP_EXP_H
#define MAME_BUS_BBC_EXP_EXP_H

#pragma once



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

// ======================> bbc_exp_slot_device

class device_bbc_exp_interface;

class bbc_exp_slot_device : public device_t, public device_slot_interface
{
public:
	// construction/destruction
	template <typename T>
	bbc_exp_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock, T &&slot_options, const char *default_option)
		: bbc_exp_slot_device(mconfig, tag, owner, clock)
	{
		option_reset();
		slot_options(*this);
		set_default_option(default_option);
		set_fixed(false);
	}

	bbc_exp_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	// callbacks
	auto irq_handler() { return m_irq_handler.bind(); }
	auto nmi_handler() { return m_nmi_handler.bind(); }

	// callbacks for mertec device (also connects to joyport)
	auto cb1_handler() { return m_cb1_handler.bind(); }
	auto cb2_handler() { return m_cb2_handler.bind(); }

	uint8_t fred_r(offs_t offset);
	void fred_w(offs_t offset, uint8_t data);
	uint8_t jim_r(offs_t offset);
	void jim_w(offs_t offset, uint8_t data);
	uint8_t sheila_r(offs_t offset);
	void sheila_w(offs_t offset, uint8_t data);

	DECLARE_WRITE_LINE_MEMBER( irq_w ) { m_irq_handler(state); }
	DECLARE_WRITE_LINE_MEMBER( nmi_w ) { m_nmi_handler(state); }

	// additional handlers for mertec device
	DECLARE_WRITE_LINE_MEMBER(cb1_w) { m_cb1_handler(state); }
	DECLARE_WRITE_LINE_MEMBER(cb2_w) { m_cb2_handler(state); }

	uint8_t pb_r();
	void pb_w(uint8_t data);

protected:
	// device-level overrides
	virtual void device_validity_check(validity_checker &valid) const override;
	virtual void device_start() override;
	virtual void device_reset() override;

	device_bbc_exp_interface *m_card;

private:
	devcb_write_line m_irq_handler;
	devcb_write_line m_nmi_handler;

	devcb_write_line m_cb1_handler;
	devcb_write_line m_cb2_handler;
};


// ======================> device_bbc_exp_interface

class device_bbc_exp_interface : public device_slot_card_interface
{
public:
	virtual uint8_t fred_r(offs_t offset) { return 0xff; }
	virtual void fred_w(offs_t offset, uint8_t data) { }
	virtual uint8_t jim_r(offs_t offset) { return 0xff; }
	virtual void jim_w(offs_t offset, uint8_t data) { }
	virtual uint8_t sheila_r(offs_t offset) { return 0xfe; }
	virtual void sheila_w(offs_t offset, uint8_t data) { }

	virtual uint8_t pb_r() { return 0xff; }
	virtual void pb_w(uint8_t data) { }

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

	bbc_exp_slot_device *m_slot;
};


// device type definition
DECLARE_DEVICE_TYPE(BBC_EXP_SLOT, bbc_exp_slot_device)

void bbc_exp_devices(device_slot_interface &device);


#endif // MAME_BUS_BBC_EXP_EXP_H