Previous 15994 Revisions Next

r10972 Tuesday 29th March, 2011 at 07:18:10 UTC by Curt Coder
Converted MSM6255 to C++ device and moved to emu folder.
[src/emu]emu.mak
[src/emu/video]msm6255.c* msm6255.h*
[src/mess]mess.mak
[src/mess/drivers]bw2.c
[src/mess/includes]bw2.h
[src/mess/video]msm6255.c msm6255.h

src/emu/video/msm6255.c
r0r10972
1/**********************************************************************
2
3    OKI MSM6255 Dot Matrix LCD Controller implementation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "emu.h"
11#include "msm6255.h"
12#include "machine/devhelpr.h"
13
14
15
16//**************************************************************************
17//  MACROS / CONSTANTS
18//**************************************************************************
19
20#define LOG 0
21
22
23// registers
24enum
25{
26   REGISTER_MOR = 0,
27   REGISTER_PR,
28   REGISTER_HNR,
29   REGISTER_DVR,
30   REGISTER_CPR,
31   REGISTER_SLR,
32   REGISTER_SUR,
33   REGISTER_CLR,
34   REGISTER_CUR
35};
36
37
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
45
46
47#define PR_HP_4            0x03
48#define PR_HP_5            0x04
49#define PR_HP_6            0x05
50#define PR_HP_7            0x06
51#define PR_HP_8            0x07
52#define PR_HP_MASK         0x07
53#define PR_VP_MASK         0xf0
54
55
56#define HNR_HN_MASK         0x7f
57
58
59#define DVR_DN_MASK         0x7f
60
61
62#define CPR_CPD_MASK      0x0f
63#define CPR_CPU_MASK      0xf0
64
65
66
67//**************************************************************************
68//  GLOBAL VARIABLES
69//**************************************************************************
70
71// devices
72const device_type MSM6255 = msm6255_device_config::static_alloc_device_config;
73
74
75
76//**************************************************************************
77//  DEVICE CONFIGURATION
78//**************************************************************************
79
80GENERIC_DEVICE_CONFIG_SETUP(msm6255, "MSM6255")
81
82
83//-------------------------------------------------
84//  device_config_complete - perform any
85//  operations now that the configuration is
86//  complete
87//-------------------------------------------------
88
89void msm6255_device_config::device_config_complete()
90{
91   // inherit a copy of the static data
92   const msm6255_interface *intf = reinterpret_cast<const msm6255_interface *>(static_config());
93   if (intf != NULL)
94   {
95      *static_cast<msm6255_interface *>(this) = *intf;
96     
97      m_char_ram_r = intf->m_char_ram_r;
98   }
99   // or initialize to defaults if none provided
100   else
101   {
102      fatalerror("Interface not specified!");
103   }
104}
105
106
107
108//**************************************************************************
109//  INLINE HELPERS
110//**************************************************************************
111
112//-------------------------------------------------
113//  read_video_data - read video ROM/RAM
114//-------------------------------------------------
115
116inline UINT8 msm6255_device::read_video_data(UINT16 ma, UINT8 ra)
117{
118   return m_config.m_char_ram_r(this, ma, ra);
119}
120
121
122
123//**************************************************************************
124//  LIVE DEVICE
125//**************************************************************************
126
127//-------------------------------------------------
128//  msm6255_device - constructor
129//-------------------------------------------------
130
131msm6255_device::msm6255_device(running_machine &_machine, const msm6255_device_config &config)
132    : device_t(_machine, config),
133     m_cursor(0),
134      m_config(config)
135{
136}
137
138
139//-------------------------------------------------
140//  device_start - device-specific startup
141//-------------------------------------------------
142
143void msm6255_device::device_start()
144{
145   // find screen
146   m_screen = machine->device<screen_device>(m_config.m_screen_tag);
147
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));
161}
162
163
164//-------------------------------------------------
165//  device_reset - device-specific reset
166//-------------------------------------------------
167
168void msm6255_device::device_reset()
169{
170   m_frame = 0;
171}
172
173
174//-------------------------------------------------
175//  read - register read
176//-------------------------------------------------
177
178READ8_MEMBER( msm6255_device::read )
179{
180   UINT8 data = 0;
181   
182   if (offset & 0x01)
183   {
184      return m_ir;
185   }
186   else
187   {
188      switch (m_ir)
189      {
190      case REGISTER_MOR:
191         break; // write-only
192
193      case REGISTER_PR:
194         data = m_pr;
195         break;
196
197      case REGISTER_HNR:
198         data = m_hnr;
199         break;
200
201      case REGISTER_DVR:
202         break; // write-only
203
204      case REGISTER_CPR:
205         data = m_cpr;
206         break;
207
208      case REGISTER_SLR:
209         data = m_slr;
210         break;
211
212      case REGISTER_SUR:
213         data = m_sur;
214         break;
215
216      case REGISTER_CLR:
217         data = m_clr;
218         break;
219
220      case REGISTER_CUR:
221         data = m_cur;
222         break;
223      }
224   }
225   
226   return data;
227}
228
229
230//-------------------------------------------------
231//  write - register write
232//-------------------------------------------------
233
234WRITE8_MEMBER( msm6255_device::write )
235{
236   if (offset & 0x01)
237   {
238      m_ir = data & 0x0f;
239   }
240   else
241   {
242      switch (m_ir)
243      {
244      case REGISTER_MOR:
245         m_mor = data & 0x7f;
246         break;
247
248      case REGISTER_PR:
249         m_pr = data & 0xf7;
250         break;
251
252      case REGISTER_HNR:
253         m_hnr = data & 0x7f;
254         break;
255
256      case REGISTER_DVR:
257         m_dvr = data;
258         break;
259
260      case REGISTER_CPR:
261         m_cpr = data;
262         break;
263
264      case REGISTER_SLR:
265         m_slr = data;
266         break;
267
268      case REGISTER_SUR:
269         m_sur = data;
270         break;
271
272      case REGISTER_CLR:
273         m_clr = data;
274         break;
275
276      case REGISTER_CUR:
277         m_cur = data;
278         break;
279      }
280   }
281}
282
283
284//-------------------------------------------------
285//  update_cursor -
286//-------------------------------------------------
287
288void msm6255_device::update_cursor()
289{
290   if (m_mor & MOR_CURSOR_ON)
291   {
292      if (m_mor & MOR_CURSOR_BLINK)
293      {
294         if (m_mor & MOR_BLINK_TIME_16)
295         {
296            if (m_frame == 16)
297            {
298               m_cursor = !m_cursor;
299               m_frame = 0;
300            }
301            else
302            {
303               m_frame++;
304            }
305         }
306         else
307         {
308            if (m_frame == 32)
309            {
310               m_cursor = !m_cursor;
311               m_frame = 0;
312            }
313            else
314            {
315               m_frame++;
316            }
317         }
318      }
319      else
320      {
321         m_cursor = 1;
322      }
323   }
324   else
325   {
326      m_cursor = 0;
327   }
328}
329
330
331//-------------------------------------------------
332//  draw_scanline -
333//-------------------------------------------------
334
335void msm6255_device::draw_scanline(bitmap_t *bitmap, const rectangle *cliprect, int y, UINT16 ma, UINT8 ra)
336{
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;
342
343   int sx, x;
344
345   for (sx = 0; sx < hn; sx++)
346   {
347      UINT8 data = read_video_data(ma, ra);
348
349      if (m_cursor)
350      {
351         if (ma == car)
352         {
353            if (ra >= cpu && ra <= cpd)
354            {
355               data ^= 0xff;
356            }
357         }
358      }
359
360      for (x = 0; x < hp; x++)
361      {
362         *BITMAP_ADDR16(bitmap, y, (sx * hp) + x) = BIT(data, 7);
363
364         data <<= 1;
365      }
366
367      ma++;
368   }
369}
370
371
372//-------------------------------------------------
373//  update_graphics -
374//-------------------------------------------------
375
376void msm6255_device::update_graphics(bitmap_t *bitmap, const rectangle *cliprect)
377{
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;
381
382   int y;
383
384   m_cursor = 0;
385   m_frame = 0;
386
387   for (y = 0; y < nx; y++)
388   {
389      // draw upper half scanline
390      UINT16 ma = sar + (y * hn);
391      draw_scanline(bitmap, cliprect, y, ma, 0);
392
393      // draw lower half scanline
394      ma = sar + ((y + nx) * hn);
395      draw_scanline(bitmap, cliprect, y + nx, ma, 0);
396   }
397}
398
399
400//-------------------------------------------------
401//  update_text -
402//-------------------------------------------------
403
404void msm6255_device::update_text(bitmap_t *bitmap, const rectangle *cliprect)
405{
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;
410
411   int sy, y;
412
413   update_cursor();
414
415   for (sy = 0; sy < nx; sy++)
416   {
417      for (y = 0; y < vp; y++)
418      {
419         // draw upper half scanline
420         UINT16 ma = sar + ((sy * vp) + y) * hn;
421         draw_scanline(bitmap, cliprect, (sy * vp) + y, ma, y);
422
423         // draw lower half scanline
424         ma = sar + (((sy + nx) * vp) + y) * hn;
425         draw_scanline(bitmap, cliprect, (sy * vp) + y, ma, y);
426      }
427   }
428}
429
430
431//-------------------------------------------------
432//  update_screen - update screen
433//-------------------------------------------------
434
435void msm6255_device::update_screen(bitmap_t *bitmap, const rectangle *cliprect)
436{
437   if (m_mor & MOR_DISPLAY_ON)
438   {
439      if (m_mor & MOR_GRAPHICS)
440      {
441         update_graphics(bitmap, cliprect);
442      }
443      else
444      {
445         update_text(bitmap, cliprect);
446      }
447   }
448   else
449   {
450      bitmap_fill(bitmap, cliprect, get_black_pen(machine));
451   }
452}
src/emu/video/msm6255.h
r0r10972
1/**********************************************************************
2
3    OKI MSM6255 Dot Matrix LCD Controller implementation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __MSM6255__
13#define __MSM6255__
14
15#include "emu.h"
16
17
18
19///*************************************************************************
20//  INTERFACE CONFIGURATION MACROS
21///*************************************************************************
22
23#define MCFG_MSM6255_ADD(_tag, _clock, _config) \
24   MCFG_DEVICE_ADD(_tag, MSM6255, _clock) \
25   MCFG_DEVICE_CONFIG(_config)
26
27
28#define MSM6255_INTERFACE(name) \
29   const msm6255_interface (name) =
30
31   
32#define MSM6255_CHAR_RAM_READ(_name) \
33   UINT8 _name(device_t *device, UINT16 ma, UINT8 ra)
34
35   
36
37///*************************************************************************
38//  TYPE DEFINITIONS
39///*************************************************************************
40
41// ======================> msm6255_char_ram_read_func
42
43typedef UINT8 (*msm6255_char_ram_read_func)(device_t *device, UINT16 ma, UINT8 ra);
44
45
46// ======================> msm6255_interface
47
48struct msm6255_interface
49{
50   const char *m_screen_tag;
51
52   int m_character_clock;
53
54   // ROM/RAM data read function
55   msm6255_char_ram_read_func      m_char_ram_r;
56};
57
58
59// ======================> msm6255_device_config
60
61class msm6255_device_config :   public device_config,
62                                public msm6255_interface
63{
64    friend class msm6255_device;
65
66    // construction/destruction
67    msm6255_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
68
69public:
70    // allocators
71    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
72    virtual device_t *alloc_device(running_machine &machine) const;
73
74protected:
75   // device_config overrides
76   virtual void device_config_complete();
77
78   msm6255_char_ram_read_func      m_char_ram_r;
79};
80
81
82// ======================> msm6255_device
83
84class msm6255_device :   public device_t
85{
86    friend class msm6255_device_config;
87
88    // construction/destruction
89    msm6255_device(running_machine &_machine, const msm6255_device_config &_config);
90
91public:
92    DECLARE_READ8_MEMBER( read );
93    DECLARE_WRITE8_MEMBER( write );
94
95   void update_screen(bitmap_t *bitmap, const rectangle *cliprect);
96
97protected:
98    // device-level overrides
99    virtual void device_start();
100    virtual void device_reset();
101
102private:
103   inline UINT8 read_video_data(UINT16 ma, UINT8 ra);
104   void update_cursor();
105   void draw_scanline(bitmap_t *bitmap, const rectangle *cliprect, int y, UINT16 ma, UINT8 ra);
106   void update_graphics(bitmap_t *bitmap, const rectangle *cliprect);
107   void update_text(bitmap_t *bitmap, const rectangle *cliprect);
108   
109   screen_device *m_screen;
110   
111   UINT8 m_ir;                  // instruction register
112   UINT8 m_mor;               // mode control register
113   UINT8 m_pr;                  // character pitch register
114   UINT8 m_hnr;               // horizontal character number register
115   UINT8 m_dvr;               // duty number register
116   UINT8 m_cpr;               // cursor form register
117   UINT8 m_slr;               // start address (lower) register
118   UINT8 m_sur;               // start address (upper) register
119   UINT8 m_clr;               // cursor address (lower) register
120   UINT8 m_cur;               // cursor address (upper) register
121
122   int m_cursor;               // is cursor displayed
123   int m_frame;               // frame counter
124
125   const msm6255_device_config &m_config;
126};
127
128
129// device type definition
130extern const device_type MSM6255;
131
132
133
134#endif
src/emu/emu.mak
r10971r10972
234234   $(EMUVIDEO)/hd61830.o      \
235235   $(EMUVIDEO)/hd63484.o      \
236236   $(EMUVIDEO)/mc6845.o      \
237   $(EMUVIDEO)/msm6255.o      \
237238   $(EMUVIDEO)/pc_vga.o      \
238239   $(EMUVIDEO)/pc_video.o      \
239240   $(EMUVIDEO)/poly.o         \
src/mess/video/msm6255.c
r10971r10972
1/***************************************************************************
2
3    OKI MSM6255 Dot Matrix LCD Controller implementation
4
5    Copyright MESS team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8***************************************************************************/
9
10#include "emu.h"
11#include "msm6255.h"
12
13/***************************************************************************
14    PARAMETERS
15***************************************************************************/
16
17#define MSM6255_MOR_GRAPHICS      0x01
18#define MSM6255_MOR_4_BIT_PARALLEL   0x02
19#define MSM6255_MOR_2_BIT_PARALLEL   0x04
20#define MSM6255_MOR_DISPLAY_ON      0x08
21#define MSM6255_MOR_CURSOR_BLINK   0x10
22#define MSM6255_MOR_CURSOR_ON      0x20
23#define MSM6255_MOR_BLINK_TIME_16   0x40
24
25#define MSM6255_PR_HP_4            0x03
26#define MSM6255_PR_HP_5            0x04
27#define MSM6255_PR_HP_6            0x05
28#define MSM6255_PR_HP_7            0x06
29#define MSM6255_PR_HP_8            0x07
30#define MSM6255_PR_HP_MASK         0x07
31#define MSM6255_PR_VP_MASK         0xf0
32
33#define MSM6255_HNR_HN_MASK         0x7f
34
35#define MSM6255_DVR_DN_MASK         0x7f
36
37#define MSM6255_CPR_CPD_MASK      0x0f
38#define MSM6255_CPR_CPU_MASK      0xf0
39
40enum
41{
42   MSM6255_REGISTER_MOR = 0,
43   MSM6255_REGISTER_PR,
44   MSM6255_REGISTER_HNR,
45   MSM6255_REGISTER_DVR,
46   MSM6255_REGISTER_CPR,
47   MSM6255_REGISTER_SLR,
48   MSM6255_REGISTER_SUR,
49   MSM6255_REGISTER_CLR,
50   MSM6255_REGISTER_CUR
51};
52
53/***************************************************************************
54    TYPE DEFINITIONS
55***************************************************************************/
56
57typedef struct _msm6255_t msm6255_t;
58struct _msm6255_t
59{
60   const msm6255_interface *intf;   /* interface */
61
62   screen_device *screen;   /* screen */
63
64   UINT8 ir;                  /* instruction register */
65   UINT8 mor;                  /* mode control register */
66   UINT8 pr;                  /* character pitch register */
67   UINT8 hnr;                  /* horizontal character number register */
68   UINT8 dvr;                  /* duty number register */
69   UINT8 cpr;                  /* cursor form register */
70   UINT8 slr;                  /* start address (lower) register */
71   UINT8 sur;                  /* start address (upper) register */
72   UINT8 clr;                  /* cursor address (lower) register */
73   UINT8 cur;                  /* cursor address (upper) register */
74
75   int cursor;                  /* is cursor displayed */
76   int frame;                  /* frame counter */
77};
78
79/***************************************************************************
80    INLINE FUNCTIONS
81***************************************************************************/
82
83INLINE msm6255_t *get_safe_token(device_t *device)
84{
85   assert(device != NULL);
86   assert(device->type() == MSM6255);
87
88   return (msm6255_t *)downcast<legacy_device_base *>(device)->token();
89}
90
91/***************************************************************************
92    IMPLEMENTATION
93***************************************************************************/
94
95/*-------------------------------------------------
96    msm6255_register_r - register read
97-------------------------------------------------*/
98
99READ8_DEVICE_HANDLER( msm6255_register_r )
100{
101   msm6255_t *msm6255 = get_safe_token(device);
102
103   if (offset & 0x01)
104   {
105      return msm6255->ir;
106   }
107   else
108   {
109      switch (msm6255->ir)
110      {
111      case MSM6255_REGISTER_MOR:
112         return 0x00; // write-only
113
114      case MSM6255_REGISTER_PR:
115         return msm6255->pr;
116
117      case MSM6255_REGISTER_HNR:
118         return msm6255->hnr;
119
120      case MSM6255_REGISTER_DVR:
121         return 0x00; // write-only
122
123      case MSM6255_REGISTER_CPR:
124         return msm6255->cpr;
125
126      case MSM6255_REGISTER_SLR:
127         return msm6255->slr;
128
129      case MSM6255_REGISTER_SUR:
130         return msm6255->sur;
131
132      case MSM6255_REGISTER_CLR:
133         return msm6255->clr;
134
135      case MSM6255_REGISTER_CUR:
136         return msm6255->cur;
137
138      default:
139         return 0;
140      }
141   }
142}
143
144/*-------------------------------------------------
145    msm6255_register_w - register write
146-------------------------------------------------*/
147
148WRITE8_DEVICE_HANDLER( msm6255_register_w )
149{
150   msm6255_t *msm6255 = get_safe_token(device);
151
152   if (offset & 0x01)
153   {
154      msm6255->ir = data & 0x0f;
155   }
156   else
157   {
158      switch (msm6255->ir)
159      {
160      case MSM6255_REGISTER_MOR:
161         msm6255->mor = data & 0x7f;
162         break;
163
164      case MSM6255_REGISTER_PR:
165         msm6255->pr = data & 0xf7;
166         break;
167
168      case MSM6255_REGISTER_HNR:
169         msm6255->hnr = data & 0x7f;
170         break;
171
172      case MSM6255_REGISTER_DVR:
173         msm6255->dvr = data;
174         break;
175
176      case MSM6255_REGISTER_CPR:
177         msm6255->cpr = data;
178         break;
179
180      case MSM6255_REGISTER_SLR:
181         msm6255->slr = data;
182         break;
183
184      case MSM6255_REGISTER_SUR:
185         msm6255->sur = data;
186         break;
187
188      case MSM6255_REGISTER_CLR:
189         msm6255->clr = data;
190         break;
191
192      case MSM6255_REGISTER_CUR:
193         msm6255->cur = data;
194         break;
195      }
196   }
197}
198
199/*-------------------------------------------------
200    update_cursor - update cursor state
201-------------------------------------------------*/
202
203static void update_cursor(device_t *device)
204{
205   msm6255_t *msm6255 = get_safe_token(device);
206
207   if (msm6255->mor & MSM6255_MOR_CURSOR_ON)
208   {
209      if (msm6255->mor & MSM6255_MOR_CURSOR_BLINK)
210      {
211         if (msm6255->mor & MSM6255_MOR_BLINK_TIME_16)
212         {
213            if (msm6255->frame == 16)
214            {
215               msm6255->cursor = !msm6255->cursor;
216               msm6255->frame = 0;
217            }
218            else
219            {
220               msm6255->frame++;
221            }
222         }
223         else
224         {
225            if (msm6255->frame == 32)
226            {
227               msm6255->cursor = !msm6255->cursor;
228               msm6255->frame = 0;
229            }
230            else
231            {
232               msm6255->frame++;
233            }
234         }
235      }
236      else
237      {
238         msm6255->cursor = 1;
239      }
240   }
241   else
242   {
243      msm6255->cursor = 0;
244   }
245}
246
247/*-------------------------------------------------
248    draw_scanline - draw one scanline
249-------------------------------------------------*/
250
251static void draw_scanline(device_t *device, bitmap_t *bitmap, const rectangle *cliprect, int y, UINT16 ma, UINT8 ra)
252{
253   msm6255_t *msm6255 = get_safe_token(device);
254
255   UINT8 hp = (msm6255->pr & MSM6255_PR_HP_MASK) + 1;
256   UINT8 hn = (msm6255->hnr & MSM6255_HNR_HN_MASK) + 1;
257   UINT8 cpu = msm6255->cpr & MSM6255_CPR_CPU_MASK;
258   UINT8 cpd = msm6255->cpr & MSM6255_CPR_CPD_MASK;
259   UINT16 car = (msm6255->cur << 8) | msm6255->clr;
260
261   int sx, x;
262
263   for (sx = 0; sx < hn; sx++)
264   {
265      UINT8 data = msm6255->intf->char_ram_r(device, ma, ra);
266
267      if (msm6255->cursor)
268      {
269         if (ma == car)
270         {
271            if (ra >= cpu && ra <= cpd)
272            {
273               data ^= 0xff;
274            }
275         }
276      }
277
278      for (x = 0; x < hp; x++)
279      {
280         *BITMAP_ADDR16(bitmap, y, (sx * hp) + x) = BIT(data, 7);
281
282         data <<= 1;
283      }
284
285      ma++;
286   }
287}
288
289/*-------------------------------------------------
290    update_graphics - draw graphics mode screen
291-------------------------------------------------*/
292
293static void update_graphics(device_t *device, bitmap_t *bitmap, const rectangle *cliprect)
294{
295   msm6255_t *msm6255 = get_safe_token(device);
296
297   UINT8 hn = (msm6255->hnr & MSM6255_HNR_HN_MASK) + 1;
298   UINT8 nx = (msm6255->dvr & MSM6255_DVR_DN_MASK) + 1;
299   UINT16 sar = (msm6255->sur << 8) | msm6255->slr;
300
301   int y;
302
303   msm6255->cursor = 0;
304   msm6255->frame = 0;
305
306   for (y = 0; y < nx; y++)
307   {
308      /* draw upper half scanline */
309      UINT16 ma = sar + (y * hn);
310      draw_scanline(device, bitmap, cliprect, y, ma, 0);
311
312      /* draw lower half scanline */
313      ma = sar + ((y + nx) * hn);
314      draw_scanline(device, bitmap, cliprect, y + nx, ma, 0);
315   }
316}
317
318/*-------------------------------------------------
319    update_text - draw text mode screen
320-------------------------------------------------*/
321
322static void update_text(device_t *device, bitmap_t *bitmap, const rectangle *cliprect)
323{
324   msm6255_t *msm6255 = get_safe_token(device);
325
326   UINT8 hn = (msm6255->hnr & MSM6255_HNR_HN_MASK) + 1;
327   UINT8 vp = (msm6255->pr & MSM6255_PR_VP_MASK) + 1;
328   UINT8 nx = (msm6255->dvr & MSM6255_DVR_DN_MASK) + 1;
329   UINT16 sar = (msm6255->sur << 8) | msm6255->slr;
330
331   int sy, y;
332
333   update_cursor(device);
334
335   for (sy = 0; sy < nx; sy++)
336   {
337      for (y = 0; y < vp; y++)
338      {
339         /* draw upper half scanline */
340         UINT16 ma = sar + ((sy * vp) + y) * hn;
341         draw_scanline(device, bitmap, cliprect, (sy * vp) + y, ma, y);
342
343         /* draw lower half scanline */
344         ma = sar + (((sy + nx) * vp) + y) * hn;
345         draw_scanline(device, bitmap, cliprect, (sy * vp) + y, ma, y);
346      }
347   }
348}
349
350/*-------------------------------------------------
351    update_text - draw screen
352-------------------------------------------------*/
353
354void msm6255_update(device_t *device, bitmap_t *bitmap, const rectangle *cliprect)
355{
356   msm6255_t *msm6255 = get_safe_token(device);
357
358   if (msm6255->mor & MSM6255_MOR_DISPLAY_ON)
359   {
360      if (msm6255->mor & MSM6255_MOR_GRAPHICS)
361      {
362         update_graphics(device, bitmap, cliprect);
363      }
364      else
365      {
366         update_text(device, bitmap, cliprect);
367      }
368   }
369   else
370   {
371      bitmap_fill(bitmap, cliprect, get_black_pen(device->machine));
372   }
373}
374
375/*-------------------------------------------------
376    DEVICE_START( msm6255 )
377-------------------------------------------------*/
378
379static DEVICE_START( msm6255 )
380{
381   msm6255_t *msm6255 = get_safe_token(device);
382
383   /* resolve callbacks */
384   msm6255->intf = (const msm6255_interface*)device->baseconfig().static_config();
385   assert(msm6255->intf->char_ram_r != NULL);
386
387   /* get the screen */
388   msm6255->screen = device->machine->device<screen_device>(msm6255->intf->screen_tag);
389   assert(msm6255->screen != NULL);
390
391   /* register for state saving */
392   device->save_item(NAME(msm6255->ir));
393   device->save_item(NAME(msm6255->mor));
394   device->save_item(NAME(msm6255->pr));
395   device->save_item(NAME(msm6255->hnr));
396   device->save_item(NAME(msm6255->dvr));
397   device->save_item(NAME(msm6255->cpr));
398   device->save_item(NAME(msm6255->slr));
399   device->save_item(NAME(msm6255->sur));
400   device->save_item(NAME(msm6255->clr));
401   device->save_item(NAME(msm6255->cur));
402   device->save_item(NAME(msm6255->cursor));
403   device->save_item(NAME(msm6255->frame));
404}
405
406/*-------------------------------------------------
407    DEVICE_RESET( msm6255 )
408-------------------------------------------------*/
409
410static DEVICE_RESET( msm6255 )
411{
412   msm6255_t *msm6255 = get_safe_token(device);
413
414   msm6255->frame = 0;
415}
416
417/*-------------------------------------------------
418    DEVICE_GET_INFO( msm6255 )
419-------------------------------------------------*/
420
421DEVICE_GET_INFO( msm6255 )
422{
423   switch (state)
424   {
425      /* --- the following bits of info are returned as 64-bit signed integers --- */
426      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(msm6255_t);               break;
427      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                           break;
428
429      /* --- the following bits of info are returned as pointers to data or functions --- */
430      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(msm6255);      break;
431      case DEVINFO_FCT_STOP:                     /* Nothing */                           break;
432      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(msm6255);      break;
433
434      /* --- the following bits of info are returned as NULL-terminated strings --- */
435      case DEVINFO_STR_NAME:                     strcpy(info->s, "OKI MSM6255");               break;
436      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "OKI MSM6255");               break;
437      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                     break;
438      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                  break;
439      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");         break;
440   }
441}
442
443DEFINE_LEGACY_DEVICE(MSM6255, msm6255);
src/mess/video/msm6255.h
r10971r10972
1/***************************************************************************
2
3    OKI MSM6255 Dot Matrix LCD Controller implementation
4
5    Copyright MESS team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8***************************************************************************/
9
10#ifndef __MSM6255_VIDEO__
11#define __MSM6255_VIDEO__
12
13/***************************************************************************
14    MACROS / CONSTANTS
15***************************************************************************/
16
17DECLARE_LEGACY_DEVICE(MSM6255, msm6255);
18
19#define MCFG_MSM6255_ADD(_tag, _clock, _config) \
20   MCFG_DEVICE_ADD(_tag, MSM6255, _clock) \
21   MCFG_DEVICE_CONFIG(_config)
22
23#define MCFG_MSM6255_REMOVE(_tag) \
24   MCFG_DEVICE_REMOVE(_tag)
25
26#define MSM6255_INTERFACE(_name) \
27   const msm6255_interface (_name) =
28
29#define MSM6255_CHAR_RAM_READ(_name) \
30   UINT8 _name(device_t *device, UINT16 ma, UINT8 ra)
31
32/***************************************************************************
33    TYPE DEFINITIONS
34***************************************************************************/
35
36typedef UINT8 (*msm6255_char_ram_read_func)(device_t *device, UINT16 ma, UINT8 ra);
37
38typedef struct _msm6255_interface msm6255_interface;
39struct _msm6255_interface
40{
41   const char *screen_tag;      /* screen we are acting on */
42
43   int character_clock;      /* the character clock of the chip */
44
45   /* ROM/RAM data read function */
46   msm6255_char_ram_read_func      char_ram_r;
47};
48
49/***************************************************************************
50    PROTOTYPES
51***************************************************************************/
52
53/* character memory access */
54READ8_DEVICE_HANDLER ( msm6255_register_r );
55WRITE8_DEVICE_HANDLER ( msm6255_register_w );
56
57/* updates the screen */
58void msm6255_update(device_t *device, bitmap_t *bitmap, const rectangle *cliprect);
59
60#endif
src/mess/includes/bw2.h
r10971r10972
11#ifndef __BW2__
22#define __BW2__
33
4#define ADDRESS_MAP_MODERN
5
6#include "emu.h"
7#include "cpu/z80/z80.h"
8#include "imagedev/flopdrv.h"
9#include "formats/basicdsk.h"
10#include "machine/i8255a.h"
11#include "machine/ctronics.h"
12#include "machine/msm8251.h"
13#include "machine/pit8253.h"
414#include "machine/ram.h"
15#include "machine/wd17xx.h"
16#include "video/msm6255.h"
17#include "rendlay.h"
518
19
620#define SCREEN_TAG      "screen"
721#define Z80_TAG         "ic1"
822#define I8255A_TAG      "ic4"
r10971r10972
4458   required_device<cpu_device> m_maincpu;
4559   required_device<device_t> m_uart;
4660   required_device<device_t> m_fdc;
47   required_device<device_t> m_lcdc;
61   required_device<msm6255_device> m_lcdc;
4862   required_device<device_t> m_centronics;
4963   required_device<device_t> m_ram;
5064   required_device<device_t> m_floppy0;
src/mess/mess.mak
r10971r10972
569569   $(MESS_VIDEO)/i8275.o      \
570570   $(MESS_VIDEO)/m6845.o      \
571571   $(MESS_VIDEO)/m6847.o      \
572   $(MESS_VIDEO)/msm6255.o      \
573572   $(MESS_VIDEO)/saa505x.o      \
574573   $(MESS_VIDEO)/sed1330.o      \
575574   $(MESS_VIDEO)/tms3556.o      \
src/mess/drivers/bw2.c
r10971r10972
2727
2828***************************************************************************/
2929
30#define ADDRESS_MAP_MODERN
31
32#include "emu.h"
33#include "cpu/z80/z80.h"
34#include "imagedev/flopdrv.h"
35#include "machine/ram.h"
36#include "formats/basicdsk.h"
37#include "machine/i8255a.h"
38#include "machine/ctronics.h"
39#include "machine/msm8251.h"
40#include "machine/wd17xx.h"
41#include "machine/pit8253.h"
42#include "video/msm6255.h"
4330#include "includes/bw2.h"
44#include "rendlay.h"
4531
4632int bw2_state::get_ramdisk_size()
4733{
r10971r10972
258244static ADDRESS_MAP_START( bw2_io, AS_IO, 8, bw2_state )
259245   ADDRESS_MAP_UNMAP_HIGH
260246   ADDRESS_MAP_GLOBAL_MASK(0xff)
261   AM_RANGE( 0x00, 0x03 ) AM_DEVREADWRITE_LEGACY(I8255A_TAG, i8255a_r, i8255a_w )
262   AM_RANGE( 0x10, 0x13 ) AM_DEVREADWRITE_LEGACY(PIT8253_TAG, pit8253_r, pit8253_w )
263   AM_RANGE( 0x20, 0x21 ) AM_DEVREADWRITE_LEGACY(MSM6255_TAG, msm6255_register_r, msm6255_register_w )
247   AM_RANGE( 0x00, 0x03 ) AM_DEVREADWRITE_LEGACY(I8255A_TAG, i8255a_r, i8255a_w)
248   AM_RANGE( 0x10, 0x13 ) AM_DEVREADWRITE_LEGACY(PIT8253_TAG, pit8253_r, pit8253_w)
249   AM_RANGE( 0x20, 0x21 ) AM_DEVREADWRITE(MSM6255_TAG, msm6255_device, read, write)
264250//  AM_RANGE( 0x30, 0x3f ) SLOT
265251   AM_RANGE( 0x40, 0x40 ) AM_DEVREADWRITE_LEGACY(MSM8251_TAG, msm8251_data_r, msm8251_data_w)
266252   AM_RANGE( 0x41, 0x41 ) AM_DEVREADWRITE_LEGACY(MSM8251_TAG, msm8251_status_r, msm8251_control_w)
r10971r10972
579565
580566bool bw2_state::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
581567{
582   msm6255_update(m_lcdc, &bitmap, &cliprect);
568   m_lcdc->update_screen(&bitmap, &cliprect);
583569
584570   return 0;
585571}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team