1 // license:BSD-3-Clause
2 // copyright-holders:AJR
3 /****************************************************************************
4 
5     Skeleton device for Roland JX-8P and Super JX synthesizer boards.
6 
7 ****************************************************************************/
8 
9 #include "emu.h"
10 #include "jx8p_synth.h"
11 
12 DEFINE_DEVICE_TYPE(JX8P_SYNTH, jx8p_synth_device, "jx8p_synth", "Roland JX-8P Synthesizer Board")
13 DEFINE_DEVICE_TYPE(SUPERJX_SYNTH, superjx_synth_device, "superjx_synth", "Roland Super JX Synthesizer Board")
14 
15 
jx8p_synth_device(const machine_config & mconfig,device_type type,const char * tag,device_t * owner,u32 clock)16 jx8p_synth_device::jx8p_synth_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
17 	: device_t(mconfig, type, tag, owner, clock)
18 	, m_synthcpu(*this, "synthcpu")
19 	, m_ramio(*this, "ramio")
20 	, m_pit(*this, "pit%u", 1U)
21 {
22 }
23 
jx8p_synth_device(const machine_config & mconfig,const char * tag,device_t * owner,u32 clock)24 jx8p_synth_device::jx8p_synth_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
25 	: jx8p_synth_device(mconfig, JX8P_SYNTH, tag, owner, clock)
26 {
27 }
28 
superjx_synth_device(const machine_config & mconfig,const char * tag,device_t * owner,u32 clock)29 superjx_synth_device::superjx_synth_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
30 	: jx8p_synth_device(mconfig, SUPERJX_SYNTH, tag, owner, clock)
31 {
32 }
33 
device_start()34 void jx8p_synth_device::device_start()
35 {
36 }
37 
38 
prescale_w(u8 data)39 void jx8p_synth_device::prescale_w(u8 data)
40 {
41 	double clockin = clock() / (16.0 - (data & 0x0f));
42 	for (int n = 0; n < 2; n++)
43 	{
44 		m_pit[n]->set_clockin(0, clockin);
45 		m_pit[n]->set_clockin(1, clockin);
46 		m_pit[n]->set_clockin(2, clockin);
47 	}
48 
49 	u32 timerin = clock() / (16 - ((data & 0xf0) >> 4));
50 	m_ramio->set_unscaled_clock(timerin);
51 }
52 
adc_w(offs_t offset,u8 data)53 void jx8p_synth_device::adc_w(offs_t offset, u8 data)
54 {
55 }
56 
prog_map(address_map & map)57 void jx8p_synth_device::prog_map(address_map &map)
58 {
59 	map.global_mask(0x3fff);
60 	map(0x0000, 0x3fff).rom().region("program", 0);
61 }
62 
ext_map(address_map & map)63 void jx8p_synth_device::ext_map(address_map &map)
64 {
65 	map(0x0000, 0x00ff).mirror(0x3800).rw(m_ramio, FUNC(i8155_device::memory_r), FUNC(i8155_device::memory_w));
66 	map(0x0100, 0x0107).mirror(0x38f8).rw(m_ramio, FUNC(i8155_device::io_r), FUNC(i8155_device::io_w));
67 	map(0x0200, 0x0203).mirror(0x38fc).w(m_pit[0], FUNC(pit8253_device::write));
68 	map(0x0300, 0x0303).mirror(0x38fc).w(m_pit[1], FUNC(pit8253_device::write));
69 	map(0x0400, 0x0403).mirror(0x38fc).w(m_pit[2], FUNC(pit8253_device::write));
70 	map(0x0500, 0x0503).mirror(0x38fc).w(m_pit[3], FUNC(pit8253_device::write));
71 	map(0x0600, 0x0600).select(0xf0).mirror(0x380f).w(FUNC(jx8p_synth_device::adc_w));
72 }
73 
device_add_mconfig(machine_config & config)74 void jx8p_synth_device::device_add_mconfig(machine_config &config)
75 {
76 	I8031(config, m_synthcpu, 12_MHz_XTAL); // 8051-319 (EA tied to GND)
77 	m_synthcpu->set_addrmap(AS_PROGRAM, &jx8p_synth_device::prog_map);
78 	m_synthcpu->set_addrmap(AS_IO, &jx8p_synth_device::ext_map);
79 
80 	I8155(config, m_ramio, 0); // µPD8155HC
81 	m_ramio->out_pa_callback().set(FUNC(jx8p_synth_device::prescale_w));
82 
83 	for (auto &pit : m_pit)
84 		PIT8253(config, pit); // µPD8253C-2
85 }
86 
device_add_mconfig(machine_config & config)87 void superjx_synth_device::device_add_mconfig(machine_config &config)
88 {
89 	I8031(config, m_synthcpu, 12_MHz_XTAL); // MBL8031AH-P-G
90 	m_synthcpu->set_addrmap(AS_PROGRAM, &superjx_synth_device::prog_map);
91 	m_synthcpu->set_addrmap(AS_IO, &superjx_synth_device::ext_map);
92 
93 	I8155(config, m_ramio, 0); // µPD8155HC-2
94 	m_ramio->out_pa_callback().set(FUNC(superjx_synth_device::prescale_w));
95 
96 	for (auto &pit : m_pit)
97 		PIT8254(config, pit); // M5M82C54 P-6-D-1
98 }
99