summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/ti99/peb/sidmaster.cpp
blob: 9b6eb0af1292508c254b48626625e3f1288243d2 (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
// license:LGPL-2.1+
// copyright-holders:Michael Zapf
/****************************************************************************

    SID Master 99
    Original circuit copyright 2010 by Marc Hull
    Board layout and board artwork copyright 2010 by Jim Fetzner

    This expansion card adds a SID sound generator chip to the TI system.

    The circuitry has an unconventional selection mechanism: It assumes to be
    active at all times, unless a CRU address 1xxx and higher appears on the
    bus. This requires that the 9901 addresses be visible on the bus. Also, it
    has to be verified whether the real Geneve works with the SID Master.

    The SID is mapped to addresses 5800-5836 (even addresses only), incompletely
    decoded (5800-5FFF).

    Michael Zapf
    September 2020

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

#include "emu.h"
#include "sidmaster.h"

#define LOG_WARN       (1U<<1)
#define LOG_WRITE      (1U<<2)

#define VERBOSE ( LOG_GENERAL | LOG_WARN )

#include "logmacro.h"

DEFINE_DEVICE_TYPE(TI99_SIDMASTER, bus::ti99::peb::sidmaster_device, "ti99_sidmaster", "SID Master 99")

namespace bus::ti99::peb {

sidmaster_device::sidmaster_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, TI99_SIDMASTER, tag, owner, clock),
	device_ti99_peribox_card_interface(mconfig, *this),
	m_sid(*this, "sid")
{
}

void sidmaster_device::write(offs_t offset, uint8_t data)
{
	if (m_selected && ((offset & 0xf800)==0x5800))
	{
		LOGMASKED(LOG_WRITE, "%04x <- %02x\n", offset, data);
		m_sid->write((offset >> 1)& 0x1f, data);
	}
}

/*
    CRU read access
    There is actually no CRU access; the card is deselected when CRU devices
    0x1000 and higher are accessed.
*/
void sidmaster_device::crureadz(offs_t offset, uint8_t *value)
{
	bool prevsel = m_selected;
	m_selected = ((offset & 0xf000) == 0x0000);
	if (prevsel && !m_selected)
		m_sid->reset();
}

/*
    CRU write access
    There is actually no CRU access; the card is deselected when CRU devices
    0x1000 and higher are accessed.
*/
void sidmaster_device::cruwrite(offs_t offset, uint8_t data)
{
	bool prevsel = m_selected;
	m_selected = ((offset & 0xf000) == 0x0000);
	if (prevsel && !m_selected)
		m_sid->reset();
}

void sidmaster_device::device_add_mconfig(machine_config &config)
{
	// sound hardware
	SPEAKER(config, "mono").front_center();
	MOS6581(config, m_sid, XTAL(17'734'472)/18);
	m_sid->add_route(ALL_OUTPUTS, "mono", 1.00);
}

void sidmaster_device::device_start()
{
}

void sidmaster_device::device_reset()
{
	m_sid->reset();
}


} // end namespace bus::ti99::peb