Previous 15994 Revisions Next

r4240 Monday 9th February, 2009 at 07:28:57 UTC by Curt Coder
[MSM6255] Cleaned up.
[src/mess/video]msm6255.c msm6255.h

src/mess/video/msm6255.c
r4239r4240
1010#include "driver.h"
1111#include "msm6255.h"
1212
13/***************************************************************************
14    PARAMETERS
15***************************************************************************/
16
1317#define MSM6255_MOR_GRAPHICS      0x01
1418#define MSM6255_MOR_4_BIT_PARALLEL   0x02
1519#define MSM6255_MOR_2_BIT_PARALLEL   0x04
r4239r4240
4650   MSM6255_REGISTER_CUR
4751};
4852
53/***************************************************************************
54    TYPE DEFINITIONS
55***************************************************************************/
56
4957typedef struct _msm6255_t msm6255_t;
5058struct _msm6255_t
5159{
5260   const msm6255_interface *intf;   /* interface */
61
5362   const device_config *screen;   /* screen */
5463
5564   UINT8 ir;                  /* instruction register */
r4239r4240
6776   int frame;                  /* frame counter */
6877};
6978
79/***************************************************************************
80    INLINE FUNCTIONS
81***************************************************************************/
82
7083INLINE msm6255_t *get_safe_token(const device_config *device)
7184{
7285   assert(device != NULL);
7386   assert(device->token != NULL);
74
7587   return (msm6255_t *)device->token;
7688}
7789
78/* Register Access */
90/***************************************************************************
91    IMPLEMENTATION
92***************************************************************************/
7993
94/*-------------------------------------------------
95    msm6255_register_r - register read
96-------------------------------------------------*/
97
8098READ8_DEVICE_HANDLER( msm6255_register_r )
8199{
82100   msm6255_t *msm6255 = get_safe_token(device);
r4239r4240
122140   }
123141}
124142
143/*-------------------------------------------------
144    msm6255_register_w - register write
145-------------------------------------------------*/
146
125147WRITE8_DEVICE_HANDLER( msm6255_register_w )
126148{
127149   msm6255_t *msm6255 = get_safe_token(device);
r4239r4240
173195   }
174196}
175197
176/* Screen Update */
198/*-------------------------------------------------
199    update_cursor - update cursor state
200-------------------------------------------------*/
177201
178static void msm6255_update_cursor(const device_config *device)
202static void update_cursor(const device_config *device)
179203{
180204   msm6255_t *msm6255 = get_safe_token(device);
181205
r4239r4240
219243   }
220244}
221245
222static void msm6255_draw_scanline(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int y, UINT16 ma, UINT8 ra)
246/*-------------------------------------------------
247    draw_scanline - draw one scanline
248-------------------------------------------------*/
249
250static void draw_scanline(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int y, UINT16 ma, UINT8 ra)
223251{
224252   msm6255_t *msm6255 = get_safe_token(device);
225253
r4239r4240
257285   }
258286}
259287
260static void msm6255_update_graphics(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
288/*-------------------------------------------------
289    update_graphics - draw graphics mode screen
290-------------------------------------------------*/
291
292static void update_graphics(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
261293{
262294   msm6255_t *msm6255 = get_safe_token(device);
263295
r4239r4240
272304
273305   for (y = 0; y < nx; y++)
274306   {
275      // draw upper half scanline
276
307      /* draw upper half scanline */
277308      UINT16 ma = sar + (y * hn);
309      draw_scanline(device, bitmap, cliprect, y, ma, 0);
278310
279      msm6255_draw_scanline(device, bitmap, cliprect, y, ma, 0);
280
281      // draw lower half scanline
282
311      /* draw lower half scanline */
283312      ma = sar + ((y + nx) * hn);
284
285      msm6255_draw_scanline(device, bitmap, cliprect, y + nx, ma, 0);
313      draw_scanline(device, bitmap, cliprect, y + nx, ma, 0);
286314   }
287315}
288316
289static void msm6255_update_text(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
317/*-------------------------------------------------
318    update_text - draw text mode screen
319-------------------------------------------------*/
320
321static void update_text(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
290322{
291323   msm6255_t *msm6255 = get_safe_token(device);
292324
r4239r4240
297329
298330   int sy, y;
299331
300   msm6255_update_cursor(device);
332   update_cursor(device);
301333
302334   for (sy = 0; sy < nx; sy++)
303335   {
304336      for (y = 0; y < vp; y++)
305337      {
306         // draw upper half scanline
307
338         /* draw upper half scanline */
308339         UINT16 ma = sar + ((sy * vp) + y) * hn;
340         draw_scanline(device, bitmap, cliprect, (sy * vp) + y, ma, y);
309341
310         msm6255_draw_scanline(device, bitmap, cliprect, (sy * vp) + y, ma, y);
311
312         // draw lower half scanline
313
342         /* draw lower half scanline */
314343         ma = sar + (((sy + nx) * vp) + y) * hn;
315
316         msm6255_draw_scanline(device, bitmap, cliprect, (sy * vp) + y, ma, y);
344         draw_scanline(device, bitmap, cliprect, (sy * vp) + y, ma, y);
317345      }
318346   }
319347}
320348
349/*-------------------------------------------------
350    update_text - draw screen
351-------------------------------------------------*/
352
321353void msm6255_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
322354{
323355   msm6255_t *msm6255 = get_safe_token(device);
r4239r4240
326358   {
327359      if (msm6255->mor & MSM6255_MOR_GRAPHICS)
328360      {
329         msm6255_update_graphics(device, bitmap, cliprect);
361         update_graphics(device, bitmap, cliprect);
330362      }
331363      else
332364      {
333         msm6255_update_text(device, bitmap, cliprect);
365         update_text(device, bitmap, cliprect);
334366      }
335367   }
336368   else
r4239r4240
339371   }
340372}
341373
342/* Device Interface */
374/*-------------------------------------------------
375    DEVICE_START( msm6255 )
376-------------------------------------------------*/
343377
344378static DEVICE_START( msm6255 )
345379{
346380   msm6255_t *msm6255 = get_safe_token(device);
347381
348   // validate arguments
382   /* resolve callbacks */
383   msm6255->intf = device->static_config;   
384   assert(msm6255->intf->char_ram_r != NULL);   
349385
350   assert(device != NULL);
351   assert(device->tag != NULL);
352   assert(device->static_config != NULL);
353
354   msm6255->intf = device->static_config;
355
356   assert(msm6255->intf->char_ram_r != NULL);
357
358   // get the screen device
359
386   /* get the screen */
360387   msm6255->screen = devtag_get_device(device->machine, VIDEO_SCREEN, msm6255->intf->screen_tag);
361388   assert(msm6255->screen != NULL);
362389
363   // register for state saving
390   /* register for state saving */
364391   state_save_register_device_item(device, 0, msm6255->ir);
365392   state_save_register_device_item(device, 0, msm6255->mor);
366393   state_save_register_device_item(device, 0, msm6255->pr);
r4239r4240
371398   state_save_register_device_item(device, 0, msm6255->sur);
372399   state_save_register_device_item(device, 0, msm6255->clr);
373400   state_save_register_device_item(device, 0, msm6255->cur);
374
375401   state_save_register_device_item(device, 0, msm6255->cursor);
376402   state_save_register_device_item(device, 0, msm6255->frame);
377403}
378404
405/*-------------------------------------------------
406    DEVICE_RESET( msm6255 )
407-------------------------------------------------*/
408
379409static DEVICE_RESET( msm6255 )
380410{
381411   msm6255_t *msm6255 = get_safe_token(device);
r4239r4240
383413   msm6255->frame = 0;
384414}
385415
416/*-------------------------------------------------
417    DEVICE_SET_INFO( msm6255 )
418-------------------------------------------------*/
419
386420static DEVICE_SET_INFO( msm6255 )
387421{
388422   switch (state)
r4239r4240
391425   }
392426}
393427
428/*-------------------------------------------------
429    DEVICE_GET_INFO( msm6255 )
430-------------------------------------------------*/
431
394432DEVICE_GET_INFO( msm6255 )
395433{
396434   switch (state)
397435   {
398436      /* --- the following bits of info are returned as 64-bit signed integers --- */
399      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(msm6255_t);            break;
400      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
401      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
437      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(msm6255_t);               break;
438      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                           break;
439      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;            break;
402440
403441      /* --- the following bits of info are returned as pointers to data or functions --- */
404442      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(msm6255); break;
405      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(msm6255);   break;
406      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
407      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(msm6255);   break;
443      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(msm6255);      break;
444      case DEVINFO_FCT_STOP:                     /* Nothing */                           break;
445      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(msm6255);      break;
408446
409447      /* --- the following bits of info are returned as NULL-terminated strings --- */
410      case DEVINFO_STR_NAME:                     strcpy(info->s, "OKI MSM6255");            break;
411      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "OKI MSM6255");            break;
412      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
413      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
414      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");      break;
448      case DEVINFO_STR_NAME:                     strcpy(info->s, "OKI MSM6255");               break;
449      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "OKI MSM6255");               break;
450      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                     break;
451      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                  break;
452      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");         break;
415453   }
416454}
src/mess/video/msm6255.h
r4239r4240
1010#ifndef __MSM6255_VIDEO__
1111#define __MSM6255_VIDEO__
1212
13typedef UINT8 (*msm6255_char_ram_read_func)(const device_config *device, UINT16 ma, UINT8 ra);
14#define MSM6255_CHAR_RAM_READ(name) UINT8 name(const device_config *device, UINT16 ma, UINT8 ra)
13/***************************************************************************
14    MACROS / CONSTANTS
15***************************************************************************/
1516
1617#define MSM6255      DEVICE_GET_INFO_NAME(msm6255)
1718
18#define MDRV_MSM6255_ADD(_tag, _intrf) \
19   MDRV_DEVICE_ADD(_tag, MSM6255, 0) \
20   MDRV_DEVICE_CONFIG(_intrf)
19#define MDRV_MSM6255_ADD(_tag, _clock, _config) \
20   MDRV_DEVICE_ADD(_tag, MSM6255, _clock) \
21   MDRV_DEVICE_CONFIG(_config)
2122
2223#define MDRV_MSM6255_REMOVE(_tag) \
2324   MDRV_DEVICE_REMOVE(_tag, MSM6255)
2425
25/* interface */
26#define MSM6255_INTERFACE(_name) \
27   const msm6255_interface (_name) =
28
29#define MSM6255_CHAR_RAM_READ(_name) \
30   UINT8 _name(const device_config *device, UINT16 ma, UINT8 ra)
31
32/***************************************************************************
33    TYPE DEFINITIONS
34***************************************************************************/
35
36typedef UINT8 (*msm6255_char_ram_read_func)(const device_config *device, UINT16 ma, UINT8 ra);
37
2638typedef struct _msm6255_interface msm6255_interface;
2739struct _msm6255_interface
2840{
2941   const char *screen_tag;      /* screen we are acting on */
30   int pixel_clock;         /* the pixel clock of the chip */
42   
3143   int character_clock;      /* the character clock of the chip */
3244
33   /* character memory read function */
45   /* ROM/RAM data read function */
3446   msm6255_char_ram_read_func      char_ram_r;
3547};
3648
49/***************************************************************************
50    PROTOTYPES
51***************************************************************************/
52
3753/* device interface */
3854DEVICE_GET_INFO( msm6255 );
3955

Previous 15994 Revisions Next


© 1998-2018 The MESS Team