summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/swp20.cpp
blob: a9de3851fefad75f133c1f4d8327843c3d661e3c (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
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert

// Yamaha SWP20, rompler

#include "emu.h"
#include "swp20.h"

DEFINE_DEVICE_TYPE(SWP20, swp20_device, "swp20", "Yamaha SWP20 sound chip")

swp20_device::swp20_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, SWP20, tag, owner, clock),
	  device_sound_interface(mconfig, *this),
	  device_rom_interface(mconfig, *this)
{
}

void swp20_device::device_start()
{
}

void swp20_device::device_reset()
{
	m_p3c_port = 0x00;
	m_p3c_address = true;
}

void swp20_device::rom_bank_updated()
{
}

void swp20_device::map(address_map &map)
{
	map(0x00, 0x3f).rw(FUNC(swp20_device::snd_r), FUNC(swp20_device::snd_w));

	map(0x3c, 0x3c).w(FUNC(swp20_device::p3c_w));
}

// init mu80:
//  48394: <- 47aea
//   write 04.7f 00.14 01.90 to +3c
//   write 01.90 80-ff, 473ea++
//   write 01.94 80-ff, 4746a++
//   write 01.98 80-ff, 474ea++
//   write 01.9c 80-ff, 4756a++

//   write 01.a0
//   write 40-5f.data
// etc

void swp20_device::p3c_w(u8 data)
{
	if(m_p3c_address)
		m_p3c_port = data;
	else
		logerror("p3c %02x = %02x\n", m_p3c_port, data);

	m_p3c_address = !m_p3c_address;
}

u8 swp20_device::snd_r(offs_t offset)
{
	logerror("r %02x %s\n", offset, machine().describe_context());
	return 0;
}

void swp20_device::snd_w(offs_t offset, u8 data)
{
	logerror("w %02x, %02x %s\n", offset, data, machine().describe_context());
}

void swp20_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
	outputs[0].fill(0);
}
ss="mi">0; m_digitalvalue = 0; m_conversion_counter = 0; } /***************************************************************************** Implementation *****************************************************************************/ READ_LINE_MEMBER( upd7002_device::eoc_r ) { return BIT(m_status, 7); } void upd7002_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { switch (id) { case TIMER_CONVERSION_COMPLETE: { int counter_value = param; if (counter_value == m_conversion_counter) { // this really always does a 12 bit conversion m_data1 = m_digitalvalue >> 8; m_data0 = m_digitalvalue & 0xf0; // set the status register with top 2 MSB, not busy and conversion complete m_status = (m_status & 0x0f) | ((m_data1 & 0xc0) >> 2) | 0x40; // call the EOC function with EOC from status // eoc_r(0) this has just been set to 0 if (!m_eoc_cb.isnull()) m_eoc_cb(0); m_conversion_counter=0; } } break; default: throw emu_fatalerror("Unknown id in upd7002_device::device_timer"); } } uint8_t upd7002_device::read(offs_t offset) { switch (offset & 0x03) { case 0: return m_status; case 1: return m_data1; case 2: case 3: return m_data0; } return 0; } void upd7002_device::write(offs_t offset, uint8_t data) { /* logerror("write to uPD7002 $%02X = $%02X\n",offset,data); */ switch (offset & 0x03) { case 0: /* Data Latch/AD start D0 and D1 together define which one of the four input channels is selected D2 flag input, normally set to 0???? D3 defines whether an 8 (0) or 12 (1) bit resolution conversion should occur D4 to D7 not used. an 8 bit conversion typically takes 4ms an 12 bit conversion typically takes 10ms writing to this register will initiate a conversion. */ /* set D6=0 busy ,D7=1 conversion not complete */ m_status=(data & 0x0f) | 0x80; // call the EOC function with EOC from status // eoc_r(0) this has just been set to 1 if (!m_eoc_cb.isnull()) m_eoc_cb(1); /* the uPD7002 works by sampling the analogue value at the start of the conversion so it is read hear and stored until the end of the A to D conversion */ // this function should return a 16 bit value. m_digitalvalue = m_get_analogue_cb(m_status & 0x03); m_conversion_counter++; // call a timer to start the conversion if (m_status & 0x08) { // 12 bit conversion takes 10ms timer_set(attotime::from_msec(10), TIMER_CONVERSION_COMPLETE, m_conversion_counter); } else { // 8 bit conversion takes 4ms timer_set(attotime::from_msec(4), TIMER_CONVERSION_COMPLETE, m_conversion_counter); } break; case 1: case 2: /* Nothing */ break; case 3: /* Test Mode: Used for inspecting the device, The data input-output terminals assume an input state and are connected to the A/D counter. Therefore, the A/D conversion data read out after this is meaningless. */ break; } }