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
170
171
172
173
174
175
176
177
|
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Patrick Mackinlay
/*
Apple "Ariel" video RAMDAC, part # 343S1045 (slow), 343S1069 (faster)
by R. Belmont, based on bt450.cpp by Patrick Mackinlay
This is Apple's first in-house DAC, and it's very Brooktree flavored.
Control bits are unknown except that bits 0-2 are color depth
and bit 3 is set to indicate the chip is a master and cleared to
tell it that it's a slave.
The key color register is never used by Mac OS, but it was intended for
a somewhat crude video overlay. You have two Ariel chips, one master
and one slave. The master gets pixels from main VRAM, the slave
gets pixels from a video input or whatever. You set bit 3 of the control
register to 1 on the master and 0 on the slave, and connect pin 19 of the
master and slave together with a small pull-up resistor.
When the master Ariel sees a color index matching the key, it will pull down
pin 19 and tri-state its own output for that pixel clock period. In response,
the slave will assert its own RGB output for that pixel clock period.
Because MAME RAMDACs almost never do the actual drawing for performance
reasons, we don't implement any of the scaffolding to support that feature.
*/
#include "emu.h"
#include "ariel.h"
#define LOG_REGISTERS (1U << 1)
#define VERBOSE (0)
#include "logmacro.h"
DEFINE_DEVICE_TYPE(ARIEL, ariel_device, "ariel", "Apple Ariel 256 Color RAMDAC")
ariel_device::ariel_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock)
: device_t(mconfig, ARIEL, tag, owner, clock)
, device_palette_interface(mconfig, *this)
, m_address(0)
, m_address_rgb(0)
, m_control(0)
, m_key_color(0)
, m_color_ram(nullptr)
{
}
void ariel_device::device_start()
{
m_color_ram = std::make_unique<std::array<u8, 3>[]>(palette_entries());
save_item(NAME(m_address));
save_item(NAME(m_address_rgb));
save_item(NAME(m_control));
save_item(NAME(m_key_color));
save_pointer(NAME(m_color_ram), palette_entries());
}
u8 ariel_device::read(offs_t offset)
{
switch (offset)
{
case 0: return address_r();
case 1: return palette_r();
case 2: return control_r();
case 3: return key_color_r();
}
return 0;
}
void ariel_device::write(offs_t offset, u8 data)
{
switch (offset)
{
case 0:
address_w(data);
break;
case 1:
palette_w(data);
break;
case 2:
control_w(data);
break;
case 3:
key_color_w(data);
break;
}
}
u8 ariel_device::address_r()
{
LOGMASKED(LOG_REGISTERS, "%s: read address @ 0x%02x (%s)\n", tag(), m_address, machine().describe_context());
if (!machine().side_effects_disabled())
{
m_address_rgb = 0;
}
return m_address;
}
void ariel_device::address_w(u8 data)
{
LOGMASKED(LOG_REGISTERS, "%s: 0x%02x to address (%s)\n", tag(), data, machine().describe_context());
m_address_rgb = 0;
m_address = data;
}
u8 ariel_device::palette_r()
{
u8 const data = (m_address < palette_entries()) ? m_color_ram[m_address][m_address_rgb] : 0xff;
LOGMASKED(LOG_REGISTERS, "%s: read palette @ 0x%02x (%s)\n", tag(), data, machine().describe_context());
if (!machine().side_effects_disabled())
{
m_address_rgb = (m_address_rgb + 1) % 3;
if (m_address_rgb == 0)
{
m_address++;
}
}
return data;
}
void ariel_device::palette_w(u8 data)
{
LOGMASKED(LOG_REGISTERS, "%s: write 0x%02x to palette (%s)\n", tag(), data, machine().describe_context());
if (m_address < palette_entries())
{
m_color_ram[m_address][m_address_rgb] = data;
// Sync the MAME palette so this can be used directly with ind16 screens if desired
if (m_address_rgb == 2)
set_pen_color(m_address, rgb_t(
m_color_ram[m_address][0],
m_color_ram[m_address][1],
m_color_ram[m_address][2]));
}
m_address_rgb = (m_address_rgb + 1) % 3;
if (m_address_rgb == 0)
{
m_address++;
}
}
u8 ariel_device::control_r()
{
return m_control;
}
void ariel_device::control_w(u8 data)
{
LOGMASKED(LOG_REGISTERS, "%s: write 0x%02x to control (%s)\n", tag(), data, machine().describe_context());
m_control = data;
}
u8 ariel_device::key_color_r()
{
return m_control;
}
void ariel_device::key_color_w(u8 data)
{
LOGMASKED(LOG_REGISTERS, "%s: write 0x%02x to key color (%s)\n", tag(), data, machine().describe_context());
m_control = data;
}
|