1
/**********************************************************************
3
OKI MSM6255 Dot Matrix LCD Controller implementation
6
Visit http://mamedev.org for licensing and usage restrictions.
8
**********************************************************************/
12
#include "machine/devhelpr.h"
16
//**************************************************************************
18
//**************************************************************************
38
#define MOR_GRAPHICS 0x01
39
#define MOR_4_BIT_PARALLEL 0x02
40
#define MOR_2_BIT_PARALLEL 0x04
41
#define MOR_DISPLAY_ON 0x08
42
#define MOR_CURSOR_BLINK 0x10
43
#define MOR_CURSOR_ON 0x20
44
#define MOR_BLINK_TIME_16 0x40
52
#define PR_HP_MASK 0x07
53
#define PR_VP_MASK 0xf0
56
#define HNR_HN_MASK 0x7f
59
#define DVR_DN_MASK 0x7f
62
#define CPR_CPD_MASK 0x0f
63
#define CPR_CPU_MASK 0xf0
67
//**************************************************************************
69
//**************************************************************************
72
const device_type MSM6255 = msm6255_device_config::static_alloc_device_config;
76
//**************************************************************************
77
// DEVICE CONFIGURATION
78
//**************************************************************************
80
GENERIC_DEVICE_CONFIG_SETUP(msm6255, "MSM6255")
83
//-------------------------------------------------
84
// device_config_complete - perform any
85
// operations now that the configuration is
87
//-------------------------------------------------
89
void msm6255_device_config::device_config_complete()
91
// inherit a copy of the static data
92
const msm6255_interface *intf = reinterpret_cast<const msm6255_interface *>(static_config());
95
*static_cast<msm6255_interface *>(this) = *intf;
97
m_char_ram_r = intf->m_char_ram_r;
99
// or initialize to defaults if none provided
102
fatalerror("Interface not specified!");
108
//**************************************************************************
110
//**************************************************************************
112
//-------------------------------------------------
113
// read_video_data - read video ROM/RAM
114
//-------------------------------------------------
116
inline UINT8 msm6255_device::read_video_data(UINT16 ma, UINT8 ra)
118
return m_config.m_char_ram_r(this, ma, ra);
123
//**************************************************************************
125
//**************************************************************************
127
//-------------------------------------------------
128
// msm6255_device - constructor
129
//-------------------------------------------------
131
msm6255_device::msm6255_device(running_machine &_machine, const msm6255_device_config &config)
132
: device_t(_machine, config),
139
//-------------------------------------------------
140
// device_start - device-specific startup
141
//-------------------------------------------------
143
void msm6255_device::device_start()
146
m_screen = m_machine.device<screen_device>(m_config.m_screen_tag);
148
// register for state saving
149
save_item(NAME(m_ir));
150
save_item(NAME(m_mor));
151
save_item(NAME(m_pr));
152
save_item(NAME(m_hnr));
153
save_item(NAME(m_dvr));
154
save_item(NAME(m_cpr));
155
save_item(NAME(m_slr));
156
save_item(NAME(m_sur));
157
save_item(NAME(m_clr));
158
save_item(NAME(m_cur));
159
save_item(NAME(m_cursor));
160
save_item(NAME(m_frame));
164
//-------------------------------------------------
165
// device_reset - device-specific reset
166
//-------------------------------------------------
168
void msm6255_device::device_reset()
174
//-------------------------------------------------
175
// read - register read
176
//-------------------------------------------------
178
READ8_MEMBER( msm6255_device::read )
230
//-------------------------------------------------
231
// write - register write
232
//-------------------------------------------------
234
WRITE8_MEMBER( msm6255_device::write )
284
//-------------------------------------------------
286
//-------------------------------------------------
288
void msm6255_device::update_cursor()
290
if (m_mor & MOR_CURSOR_ON)
292
if (m_mor & MOR_CURSOR_BLINK)
294
if (m_mor & MOR_BLINK_TIME_16)
298
m_cursor = !m_cursor;
310
m_cursor = !m_cursor;
331
//-------------------------------------------------
333
//-------------------------------------------------
335
void msm6255_device::draw_scanline(bitmap_t *bitmap, const rectangle *cliprect, int y, UINT16 ma, UINT8 ra)
337
UINT8 hp = (m_pr & PR_HP_MASK) + 1;
338
UINT8 hn = (m_hnr & HNR_HN_MASK) + 1;
339
UINT8 cpu = m_cpr & CPR_CPU_MASK;
340
UINT8 cpd = m_cpr & CPR_CPD_MASK;
341
UINT16 car = (m_cur << 8) | m_clr;
345
for (sx = 0; sx < hn; sx++)
347
UINT8 data = read_video_data(ma, ra);
353
if (ra >= cpu && ra <= cpd)
360
for (x = 0; x < hp; x++)
362
*BITMAP_ADDR16(bitmap, y, (sx * hp) + x) = BIT(data, 7);
372
//-------------------------------------------------
374
//-------------------------------------------------
376
void msm6255_device::update_graphics(bitmap_t *bitmap, const rectangle *cliprect)
378
UINT8 hn = (m_hnr & HNR_HN_MASK) + 1;
379
UINT8 nx = (m_dvr & DVR_DN_MASK) + 1;
380
UINT16 sar = (m_sur << 8) | m_slr;
387
for (y = 0; y < nx; y++)
389
// draw upper half scanline
390
UINT16 ma = sar + (y * hn);
391
draw_scanline(bitmap, cliprect, y, ma, 0);
393
// draw lower half scanline
394
ma = sar + ((y + nx) * hn);
395
draw_scanline(bitmap, cliprect, y + nx, ma, 0);
400
//-------------------------------------------------
402
//-------------------------------------------------
404
void msm6255_device::update_text(bitmap_t *bitmap, const rectangle *cliprect)
406
UINT8 hn = (m_hnr & HNR_HN_MASK) + 1;
407
UINT8 vp = (m_pr & PR_VP_MASK) + 1;
408
UINT8 nx = (m_dvr & DVR_DN_MASK) + 1;
409
UINT16 sar = (m_sur << 8) | m_slr;
415
for (sy = 0; sy < nx; sy++)
417
for (y = 0; y < vp; y++)
419
// draw upper half scanline
420
UINT16 ma = sar + ((sy * vp) + y) * hn;
421
draw_scanline(bitmap, cliprect, (sy * vp) + y, ma, y);
423
// draw lower half scanline
424
ma = sar + (((sy + nx) * vp) + y) * hn;
425
draw_scanline(bitmap, cliprect, (sy * vp) + y, ma, y);
431
//-------------------------------------------------
432
// update_screen - update screen
433
//-------------------------------------------------
435
void msm6255_device::update_screen(bitmap_t *bitmap, const rectangle *cliprect)
437
if (m_mor & MOR_DISPLAY_ON)
439
if (m_mor & MOR_GRAPHICS)
441
update_graphics(bitmap, cliprect);
445
update_text(bitmap, cliprect);
450
bitmap_fill(bitmap, cliprect, get_black_pen(m_machine));