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
|
// license:BSD-3-Clause
// copyright-holders:Barry Rodewald
/*
* Data East Pinball Dot Matrix Display
*
* Type 2: 128x32
* 68B09E @ 2MHz
* 68B45 CRTC
*/
#include "emu.h"
#include "decodmd2.h"
#include "screen.h"
DEFINE_DEVICE_TYPE(DECODMD2, decodmd_type2_device, "decodmd2", "Data East Pinball Dot Matrix Display Type 2")
void decodmd_type2_device::bank_w(uint8_t data)
{
m_rombank1->set_entry(data & 0x1f);
}
void decodmd_type2_device::crtc_address_w(uint8_t data)
{
m_mc6845->address_w(data);
m_crtc_index = data;
}
uint8_t decodmd_type2_device::crtc_status_r()
{
return m_mc6845->register_r();
}
void decodmd_type2_device::crtc_register_w(uint8_t data)
{
m_mc6845->register_w(data);
m_crtc_reg[m_crtc_index] = data;
}
uint8_t decodmd_type2_device::latch_r()
{
// clear IRQ?
m_cpu->set_input_line(M6809_IRQ_LINE,CLEAR_LINE);
m_busy = false;
return m_command;
}
void decodmd_type2_device::data_w(uint8_t data)
{
// set IRQ?
m_latch = data;
}
uint8_t decodmd_type2_device::busy_r()
{
uint8_t ret = 0x00;
ret = (m_status & 0x0f) << 3;
if(m_busy)
return 0x80 | ret;
else
return 0x00 | ret;
}
void decodmd_type2_device::ctrl_w(uint8_t data)
{
if(!(m_ctrl & 0x01) && (data & 0x01))
{
m_cpu->set_input_line(M6809_IRQ_LINE,ASSERT_LINE);
m_busy = true;
m_command = m_latch;
}
if((m_ctrl & 0x02) && !(data & 0x02))
{
m_cpu->pulse_input_line(INPUT_LINE_RESET, attotime::zero);
m_rombank1->set_entry(0);
logerror("DMD2: Reset\n");
}
m_ctrl = data;
}
uint8_t decodmd_type2_device::ctrl_r()
{
return m_ctrl;
}
uint8_t decodmd_type2_device::status_r()
{
return m_status;
}
void decodmd_type2_device::status_w(uint8_t data)
{
m_status = data & 0x0f;
}
TIMER_DEVICE_CALLBACK_MEMBER(decodmd_type2_device::dmd_firq)
{
m_cpu->set_input_line(M6809_FIRQ_LINE, HOLD_LINE);
}
MC6845_UPDATE_ROW( decodmd_type2_device::crtc_update_row )
{
uint16_t addr = (ma & 0xfc00) + ((ma & 0x100)<<2) + (ra << 4);
for (int x = 0; x < 128; x += 8)
{
for (int dot = 0; dot < 8; dot++)
{
uint8_t intensity = ((m_ram[addr] >> (7-dot) & 0x01) << 1) | (m_ram[addr + 0x200] >> (7-dot) & 0x01);
bitmap.pix(y, x + dot) = rgb_t(0x3f * intensity, 0x2a * intensity, 0x00);
}
addr++;
}
}
void decodmd_type2_device::decodmd2_map(address_map &map)
{
map(0x0000, 0x2fff).ram().share("dmdram");
map(0x3000, 0x3000).rw(FUNC(decodmd_type2_device::crtc_status_r), FUNC(decodmd_type2_device::crtc_address_w));
map(0x3001, 0x3001).w(FUNC(decodmd_type2_device::crtc_register_w));
map(0x3002, 0x3002).w(FUNC(decodmd_type2_device::bank_w));
map(0x3003, 0x3003).r(FUNC(decodmd_type2_device::latch_r));
map(0x4000, 0x7fff).bankr("dmdbank1").w(FUNC(decodmd_type2_device::status_w));
map(0x8000, 0xffff).bankr("dmdbank2"); // last 32k of ROM
}
void decodmd_type2_device::device_add_mconfig(machine_config &config)
{
/* basic machine hardware */
MC6809E(config, m_cpu, XTAL(8'000'000) / 4);
m_cpu->set_addrmap(AS_PROGRAM, &decodmd_type2_device::decodmd2_map);
config.set_maximum_quantum(attotime::from_hz(60));
TIMER(config, "firq_timer", 0).configure_periodic(FUNC(decodmd_type2_device::dmd_firq), attotime::from_hz(80));
MC6845(config, m_mc6845, XTAL(8'000'000) / 8); // TODO: confirm clock speed
m_mc6845->set_screen(nullptr);
m_mc6845->set_show_border_area(false);
m_mc6845->set_char_width(8);
m_mc6845->set_update_row_callback(FUNC(decodmd_type2_device::crtc_update_row));
screen_device &screen(SCREEN(config, "dmd", SCREEN_TYPE_RASTER));
screen.set_native_aspect();
screen.set_size(128, 32);
screen.set_visarea(0, 128-1, 0, 32-1);
screen.set_screen_update("dmd6845", FUNC(mc6845_device::screen_update));
screen.set_refresh_hz(60);
}
decodmd_type2_device::decodmd_type2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, DECODMD2, tag, owner, clock)
, m_cpu(*this, "dmdcpu")
, m_mc6845(*this, "dmd6845")
, m_rombank1(*this, "dmdbank1")
, m_rombank2(*this, "dmdbank2")
, m_ram(*this, "dmdram")
, m_rom(*this, finder_base::DUMMY_TAG)
{
}
void decodmd_type2_device::device_start()
{
}
void decodmd_type2_device::device_reset()
{
m_rombank1->configure_entries(0, 32, &m_rom[0x0000], 0x4000);
m_rombank2->configure_entry(0, &m_rom[0x78000]);
m_rombank1->set_entry(0);
m_rombank2->set_entry(0);
m_busy = false;
}
|