1 // license:BSD-3-Clause
2 // copyright-holders:Nigel Barnes
3 /**********************************************************************
4 
5     BBC analogue port emulation
6 
7 **********************************************************************/
8 
9 #include "emu.h"
10 #include "analogue.h"
11 
12 
13 //**************************************************************************
14 //  DEVICE DEFINITIONS
15 //**************************************************************************
16 
17 DEFINE_DEVICE_TYPE(BBC_ANALOGUE_SLOT, bbc_analogue_slot_device, "bbc_analogue_slot", "BBC Micro Analogue port")
18 
19 
20 
21 //**************************************************************************
22 //  DEVICE BBC_ANALOGUE PORT INTERFACE
23 //**************************************************************************
24 
25 //-------------------------------------------------
26 //  device_bbc_analogue_interface - constructor
27 //-------------------------------------------------
28 
device_bbc_analogue_interface(const machine_config & mconfig,device_t & device)29 device_bbc_analogue_interface::device_bbc_analogue_interface(const machine_config &mconfig, device_t &device) :
30 	device_interface(device, "bbcanalogue")
31 {
32 	m_slot = dynamic_cast<bbc_analogue_slot_device *>(device.owner());
33 }
34 
35 
36 //**************************************************************************
37 //  LIVE DEVICE
38 //**************************************************************************
39 
40 //-------------------------------------------------
41 //  bbc_analogue_slot_device - constructor
42 //-------------------------------------------------
43 
bbc_analogue_slot_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)44 bbc_analogue_slot_device::bbc_analogue_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
45 	device_t(mconfig, BBC_ANALOGUE_SLOT, tag, owner, clock),
46 	device_single_card_slot_interface<device_bbc_analogue_interface>(mconfig, *this),
47 	m_card(nullptr),
48 	m_lpstb_handler(*this)
49 {
50 }
51 
52 
53 //-------------------------------------------------
54 //  device_start - device-specific startup
55 //-------------------------------------------------
56 
device_start()57 void bbc_analogue_slot_device::device_start()
58 {
59 	m_card = get_card_device();
60 
61 	// resolve callbacks
62 	m_lpstb_handler.resolve_safe();
63 }
64 
ch_r(int channel)65 uint8_t bbc_analogue_slot_device::ch_r(int channel)
66 {
67 	if (m_card)
68 		return m_card->ch_r(channel);
69 	else
70 		return 0x00;
71 }
72 
pb_r()73 uint8_t bbc_analogue_slot_device::pb_r()
74 {
75 	if (m_card)
76 		return m_card->pb_r();
77 	else
78 		return 0x30;
79 }
80 
81 
82 //-------------------------------------------------
83 //  SLOT_INTERFACE( bbc_analogue_devices )
84 //-------------------------------------------------
85 
86 
87 // slot devices
88 #include "joystick.h"
89 #include "bitstik.h"
90 //#include "lightpen.h"
91 //#include "micromike.h"
92 //#include "quinkey.h"
93 #include "cfa3000a.h"
94 
95 
bbc_analogue_devices(device_slot_interface & device)96 void bbc_analogue_devices(device_slot_interface &device)
97 {
98 	device.option_add("acornjoy",    BBC_ACORNJOY);         /* Acorn ANH01 Joysticks */
99 	device.option_add("bitstik1",    BBC_BITSTIK1);         /* Acorn ANF04 Bitstik */
100 	device.option_add("bitstik2",    BBC_BITSTIK2);         /* Robocom Bitstik 2 */
101 	//device.option_add("lightpen",    BBC_LIGHTPEN);         /* RH Electronics Lightpen */
102 	//device.option_add("micromike",   BBC_MICROMIKE);        /* Micro Mike */
103 	device.option_add("voltmace3b",  BBC_VOLTMACE3B);       /* Voltmace Delta 3b "Twin" Joysticks */
104 	//device.option_add("quinkey",     BBC_QUINKEY);          /* Microwriter Quinkey */
105 	device.option_add_internal("cfa3000a", CFA3000_ANLG);   /* Hanson CFA 3000 Analogue */
106 }
107