summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/a2bus/a2thunderclock.cpp
blob: 69870004f47e869d407c3d26c63a8e5bd272eff5 (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// license:BSD-3-Clause
// copyright-holders:R. Belmont
/*********************************************************************

    a2thunderclock.c

    Implemention of the Thunderware Thunderclock Plus.


    PCB Layout: (B1/B2 are batteries)
     _______________________________________________________________
    |                                                               |
    |    | | | |           uPD1990 CD4050 74LS174   74LS132         |
    |    | | | |              _      _     _     _     _            |
    |    | | | |             | |    | |   | |   | |   | |           |
    |    | | | |             |_|    |_|   |_|   |_|   |_|           |
    |    B1  B2                               74LS08                |
    |           74LS74  74LS109 74LS126        ____________  74LS27 |
    |               _      _     _            |            |    _   |
    |              | |    | |   | |           |   2716     |   | |  |
    |              |_|    |_|   |_|           |____________|   |_|  |
    |______________________________________                        _|
                                           |                      |
                                           |______________________|

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

#include "emu.h"
#include "a2thunderclock.h"

/***************************************************************************
    PARAMETERS
***************************************************************************/

//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

DEFINE_DEVICE_TYPE(A2BUS_THUNDERCLOCK, a2bus_thunderclock_device, "a2thunpl", "ThunderWare ThunderClock Plus")

#define THUNDERCLOCK_ROM_REGION  "thunclk_rom"
#define THUNDERCLOCK_UPD1990_TAG "thunclk_upd"

ROM_START( thunderclock )
	ROM_REGION(0x800, THUNDERCLOCK_ROM_REGION, 0)
	ROM_LOAD( "thunderclock plus rom.bin", 0x0000, 0x0800, CRC(1b99c4e3) SHA1(60f434f5325899d7ea257a6e56e6f53eae65146a) )
ROM_END

/***************************************************************************
    FUNCTION PROTOTYPES
***************************************************************************/

//-------------------------------------------------
//  device_add_mconfig - add device configuration
//-------------------------------------------------

MACHINE_CONFIG_START(a2bus_thunderclock_device::device_add_mconfig)
	MCFG_UPD1990A_ADD(THUNDERCLOCK_UPD1990_TAG, 1021800, DEVWRITELINE(DEVICE_SELF, a2bus_thunderclock_device, upd_dataout_w), NOOP)
MACHINE_CONFIG_END

//-------------------------------------------------
//  rom_region - device-specific ROM region
//-------------------------------------------------

const tiny_rom_entry *a2bus_thunderclock_device::device_rom_region() const
{
	return ROM_NAME( thunderclock );
}

//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

a2bus_thunderclock_device::a2bus_thunderclock_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, type, tag, owner, clock),
	device_a2bus_card_interface(mconfig, *this),
	m_upd1990ac(*this, THUNDERCLOCK_UPD1990_TAG), m_rom(nullptr), m_dataout(0)
{
}

a2bus_thunderclock_device::a2bus_thunderclock_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	a2bus_thunderclock_device(mconfig, A2BUS_THUNDERCLOCK, tag, owner, clock)
{
}

//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void a2bus_thunderclock_device::device_start()
{
	m_rom = device().machine().root_device().memregion(this->subtag(THUNDERCLOCK_ROM_REGION).c_str())->base();

	save_item(NAME(m_dataout));
}

void a2bus_thunderclock_device::device_reset()
{
	m_dataout = 0;
}


/*-------------------------------------------------
    read_c0nx - called for reads from this card's c0nx space
-------------------------------------------------*/

uint8_t a2bus_thunderclock_device::read_c0nx(uint8_t offset)
{
	return (m_dataout << 7);
}


/*-------------------------------------------------
    write_c0nx - called for writes to this card's c0nx space
-------------------------------------------------*/

void a2bus_thunderclock_device::write_c0nx(uint8_t offset, uint8_t data)
{
	// uPD1990AC hookup:
	// bit 0 = DATA IN?
	// bit 1 = CLK
	// bit 2 = STB
	// bit 3 = C0
	// bit 4 = C1
	// bit 5 = C2
	// bit 7 = data out
	if (offset == 0)
	{
		m_upd1990ac->cs_w(1);
		m_upd1990ac->oe_w(1);
		m_upd1990ac->data_in_w(data&0x01);
		m_upd1990ac->c0_w((data&0x08) >> 3);
		m_upd1990ac->c1_w((data&0x10) >> 4);
		m_upd1990ac->c2_w((data&0x20) >> 5);
		m_upd1990ac->stb_w((data&0x04) >> 2);
		m_upd1990ac->clk_w((data&0x02) >> 1);
	}
}

/*-------------------------------------------------
    read_cnxx - called for reads from this card's cnxx space
-------------------------------------------------*/

uint8_t a2bus_thunderclock_device::read_cnxx(uint8_t offset)
{
	// ROM is primarily a c800 image, but the first page is also the CnXX ROM
	return m_rom[offset];
}

/*-------------------------------------------------
    read_c800 - called for reads from this card's c800 space
-------------------------------------------------*/

uint8_t a2bus_thunderclock_device::read_c800(uint16_t offset)
{
	return m_rom[offset];
}

WRITE_LINE_MEMBER( a2bus_thunderclock_device::upd_dataout_w )
{
	if (state)
	{
		m_dataout = 1;
	}
	else
	{
		m_dataout = 0;
	}
}