Previous 15994 Revisions Next

r4833 Monday 25th May, 2009 at 20:02:59 UTC by Curt Coder
[PC8500] Added preliminary SED1330 LCD controller emulation.
[src/mess]mess.mak
[src/mess/drivers]pc8401a.c
[src/mess/includes]pc8401a.h
[src/mess/video]sed1330.c* sed1330.h*

src/mess/video/sed1330.c
r0r4833
1/**********************************************************************
2
3    SED1330 LCD Timing Controller emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10/*
11
12   TODO:
13
14   - everything
15
16*/
17
18#include "driver.h"
19#include "sed1330.h"
20
21/***************************************************************************
22    PARAMETERS
23***************************************************************************/
24
25#define LOG 1
26
27#define SED1330_INSTRUCTION_SYSTEM_SET      0x40
28#define SED1330_INSTRUCTION_SLEEP_IN      0x53
29#define SED1330_INSTRUCTION_DISP_ON         0x58
30#define SED1330_INSTRUCTION_DISP_OFF      0x59
31#define SED1330_INSTRUCTION_SCROLL         0x44
32#define SED1330_INSTRUCTION_CSRFORM         0x5d
33#define SED1330_INSTRUCTION_CGRAM_ADR      0x5c
34#define SED1330_INSTRUCTION_CSRDIR_RIGHT   0x4c
35#define SED1330_INSTRUCTION_CSRDIR_LEFT      0x4d
36#define SED1330_INSTRUCTION_CSRDIR_UP      0x4e
37#define SED1330_INSTRUCTION_CSRDIR_DOWN      0x4f
38#define SED1330_INSTRUCTION_HDOT_SCR      0x5a
39#define SED1330_INSTRUCTION_OVLAY         0x5b
40#define SED1330_INSTRUCTION_CSRW         0x46
41#define SED1330_INSTRUCTION_CSRR         0x47
42#define SED1330_INSTRUCTION_MWRITE         0x42
43#define SED1330_INSTRUCTION_MREAD         0x43
44
45#define SED1330_CSRDIR_RIGHT   0x00
46#define SED1330_CSRDIR_LEFT      0x01
47#define SED1330_CSRDIR_UP      0x10
48#define SED1330_CSRDIR_DOWN      0x11
49
50static const int SED1330_CYCLES[] = {
51   4, 4, 4, 4, 4, -1, -1, -1, 4, 4, 4, 4, 6, 6, 36, 36
52};
53
54#define SED1330_MODE_EXTERNAL_CG   0x01   /* not supported */
55#define SED1330_MODE_GRAPHIC      0x02   /* text mode not supported */
56#define SED1330_MODE_CURSOR         0x04   /* not supported */
57#define SED1330_MODE_BLINK         0x08   /* not supported */
58#define SED1330_MODE_MASTER         0x10   /* not supported */
59#define SED1330_MODE_DISPLAY_ON      0x20
60
61/***************************************************************************
62    TYPE DEFINITIONS
63***************************************************************************/
64
65typedef struct _sed1330_t sed1330_t;
66struct _sed1330_t
67{
68   devcb_resolved_read8      in_vd_func;
69   devcb_resolved_write8      out_vd_func;
70
71   int bf;                  /* busy flag */
72
73   UINT8 ir;               /* instruction register */
74
75   int m0;                  /*  */
76   int m1;                  /*  */
77   int m2;                  /*  */
78   int ws;                  /*  */
79   int iv;                  /*  */
80   int fx;                  /* horizontal character size */
81   int fy;                  /* vertical character size */
82   int wf;                  /* AC frame drive waveform period */
83   int cr;                  /* address range covered by 1 display line */
84   int tcr;               /* line length (including horizontal blanking) */
85   int lf;                  /* frame height in lines */
86   UINT16 ap;               /* horizontal address range of the virtual screen */
87
88   int hdotscr;            /* horizontal dot scroll */
89
90   UINT16 csr;               /* cursor address register */
91   int csrdir;               /* cursor direction */
92
93   int pbc;               /* parameter byte counter */
94
95   /* devices */
96   const device_config *screen;
97
98   /* timers */
99   emu_timer *busy_timer;
100};
101
102/***************************************************************************
103    INLINE FUNCTIONS
104***************************************************************************/
105
106INLINE sed1330_t *get_safe_token(const device_config *device)
107{
108   assert(device != NULL);
109   assert(device->token != NULL);
110   return (sed1330_t *)device->token;
111}
112
113INLINE const sed1330_interface *get_interface(const device_config *device)
114{
115   assert(device != NULL);
116   assert((device->type == SED1330));
117   return (const sed1330_interface *) device->static_config;
118}
119
120/***************************************************************************
121    IMPLEMENTATION
122***************************************************************************/
123
124/*-------------------------------------------------
125    TIMER_CALLBACK( busy_tick )
126-------------------------------------------------*/
127
128static TIMER_CALLBACK( busy_tick )
129{
130   const device_config *device = ptr;
131   sed1330_t *sed1330 = get_safe_token(device);
132
133   /* clear busy flag */
134   sed1330->bf = 0;
135}
136
137/*-------------------------------------------------
138    set_busy_flag - set busy flag and arm timer
139               to clear it later
140-------------------------------------------------*/
141#ifdef UNUSED_FUNCTION
142static void set_busy_flag(sed1330_t *sed1330, int period)
143{
144   /* set busy flag */
145   sed1330->bf = 1;
146
147   /* adjust busy timer */
148   timer_adjust_oneshot(sed1330->busy_timer, ATTOTIME_IN_USEC(period), 0);
149}
150#endif
151/*-------------------------------------------------
152    sed1330_status_r - status read
153-------------------------------------------------*/
154
155READ8_DEVICE_HANDLER( sed1330_status_r )
156{
157   sed1330_t *sed1330 = get_safe_token(device);
158
159   if (LOG) logerror("SED1330 '%s' Status Read: %s\n", device->tag, sed1330->bf ? "busy" : "ready");
160
161   return sed1330->bf << 6;
162}
163
164/*-------------------------------------------------
165    sed1330_control_w - control write
166-------------------------------------------------*/
167
168WRITE8_DEVICE_HANDLER( sed1330_command_w )
169{
170   sed1330_t *sed1330 = get_safe_token(device);
171
172   sed1330->ir = data;
173   sed1330->pbc = 0;
174}
175
176/*-------------------------------------------------
177    sed1330_data_r - data read
178-------------------------------------------------*/
179
180READ8_DEVICE_HANDLER( sed1330_data_r )
181{
182//   sed1330_t *sed1330 = get_safe_token(device);
183
184   return 0;
185}
186
187/*-------------------------------------------------
188    sed1330_data_w - data write
189-------------------------------------------------*/
190
191WRITE8_DEVICE_HANDLER( sed1330_data_w )
192{
193   sed1330_t *sed1330 = get_safe_token(device);
194
195   switch (sed1330->ir)
196   {
197   case SED1330_INSTRUCTION_SYSTEM_SET:
198      switch (sed1330->pbc)
199      {
200      case 0:
201         sed1330->m0 = BIT(data, 0);
202         sed1330->m1 = BIT(data, 1);
203         sed1330->m2 = BIT(data, 2);
204         sed1330->ws = BIT(data, 3);
205         sed1330->iv = BIT(data, 5);
206
207         if (LOG)
208         {
209            logerror("SED1330 '%s' %s CG ROM\n", device->tag, BIT(data, 0) ? "External" : "Internal");
210            logerror("SED1330 '%s' D6 Correction %s\n", device->tag, BIT(data, 1) ? "enabled" : "disabled");
211            logerror("SED1330 '%s' Character Height: %u\n", device->tag, BIT(data, 2) ? 16 : 8);
212            logerror("SED1330 '%s' %s Panel Drive\n", device->tag, BIT(data, 3) ? "Dual" : "Single");
213            logerror("SED1330 '%s' Screen Top-Line Correction: %s\n", device->tag, BIT(data, 5) ? "disabled" : "enabled");
214         }
215         break;
216
217      case 1:
218         sed1330->fx = (data & 0x07) + 1;
219         sed1330->wf = BIT(data, 7);
220
221         if (LOG)
222         {
223            logerror("SED1330 '%s' Horizontal Character Size: %u\n", device->tag, sed1330->fx);
224            logerror("SED1330 '%s' %s AC Drive\n", device->tag, BIT(data, 7) ? "2-frame" : "16-line");
225         }
226         break;
227
228      case 2:
229         sed1330->fy = (data & 0x0f) + 1;
230         if (LOG) logerror("SED1330 '%s' Vertical Character Size: %u\n", device->tag, sed1330->fy);
231         break;
232
233      case 3:
234         sed1330->cr = data + 1;
235         break;
236
237      case 4:
238         sed1330->tcr = data + 1;
239         break;
240
241      case 5:
242         sed1330->lf = data + 1;
243         break;
244
245      case 6:
246         sed1330->ap = (sed1330->ap & 0xff00) | data;
247         break;
248
249      case 7:
250         sed1330->ap = (data << 8) | (sed1330->ap & 0xff);
251         break;
252
253      default:
254         logerror("SED1330 '%s' Invalid parameter byte %02x\n", device->tag, data);
255      }
256      break;
257/*
258   case SED1330_INSTRUCTION_SLEEP_IN:
259      break;
260
261   case SED1330_INSTRUCTION_DISP_ON:
262      break;
263
264   case SED1330_INSTRUCTION_DISP_OFF:
265      break;
266
267   case SED1330_INSTRUCTION_SCROLL:
268      break;
269
270   case SED1330_INSTRUCTION_CSRFORM:
271      break;
272
273   case SED1330_INSTRUCTION_CGRAM_ADR:
274      break;
275*/
276   case SED1330_INSTRUCTION_CSRDIR_RIGHT:
277      sed1330->csrdir = data & 0x03;
278      if (LOG) logerror("SED1330 '%s' Cursor Direction: Right\n", device->tag);
279      break;
280/*
281   case SED1330_INSTRUCTION_CSRDIR_LEFT:
282      sed1330->csrdir = data & 0x03;
283      if (LOG) logerror("SED1330 '%s' Cursor Direction: Left\n", device->tag);
284      break;
285
286   case SED1330_INSTRUCTION_CSRDIR_UP:
287      sed1330->csrdir = data & 0x03;
288      if (LOG) logerror("SED1330 '%s' Cursor Direction: Up\n", device->tag);
289      break;
290
291   case SED1330_INSTRUCTION_CSRDIR_DOWN:
292      sed1330->csrdir = data & 0x03;
293      if (LOG) logerror("SED1330 '%s' Cursor Direction: Down\n", device->tag);
294      break;
295*/
296   case SED1330_INSTRUCTION_HDOT_SCR:
297      sed1330->hdotscr = data & 0x07;
298      if (LOG) logerror("SED1330 '%s' Horizontal Dot Scroll: %u\n", device->tag, sed1330->hdotscr);
299      break;
300/*
301   case SED1330_INSTRUCTION_OVLAY:
302      break;
303*/
304   case SED1330_INSTRUCTION_CSRW:
305      switch (sed1330->pbc)
306      {
307      case 0:
308         sed1330->csr = (sed1330->csr & 0xff00) | data;
309         if (LOG) logerror("SED1330 '%s' Cursor Address %04x\n", device->tag, sed1330->csr);
310         break;
311
312      case 1:     
313         sed1330->csr = (data << 8) | (sed1330->csr & 0xff);
314         if (LOG) logerror("SED1330 '%s' Cursor Address %04x\n", device->tag, sed1330->csr);
315         break;
316
317      default:
318         logerror("SED1330 '%s' Invalid parameter byte %02x\n", device->tag, data);
319      }
320      break;
321/*
322   case SED1330_INSTRUCTION_CSRR:
323      break;
324*/
325   case SED1330_INSTRUCTION_MWRITE:
326      devcb_call_write8(&sed1330->out_vd_func, sed1330->csr, data);
327
328      switch (sed1330->csrdir)
329      {
330      case SED1330_CSRDIR_RIGHT:
331         sed1330->csr++;
332         break;
333         
334      default:
335         logerror("SED1330 '%s' Unsupported cursor direction\n", device->tag);
336      }
337
338      break;
339/*
340   case SED1330_INSTRUCTION_MREAD:
341      break;
342*/
343   default:
344      logerror("SED1330 '%s' Unsupported instruction %02x\n", device->tag, sed1330->ir);
345   }
346
347   sed1330->pbc++;
348}
349#ifdef UNUSED_FUNCTION
350/*-------------------------------------------------
351    draw_scanline - draw one scanline
352-------------------------------------------------*/
353
354static void draw_scanline(sed1330_t *sed1330, bitmap_t *bitmap, const rectangle *cliprect, int y, UINT16 ra)
355{
356}
357
358/*-------------------------------------------------
359    update_graphics - draw graphics mode screen
360-------------------------------------------------*/
361
362static void update_graphics(sed1330_t *sed1330, bitmap_t *bitmap, const rectangle *cliprect)
363{
364}
365#endif
366/*-------------------------------------------------
367    sed1330_update - update screen
368-------------------------------------------------*/
369
370void sed1330_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
371{
372}
373
374/*-------------------------------------------------
375    DEVICE_START( sed1330 )
376-------------------------------------------------*/
377
378static DEVICE_START( sed1330 )
379{
380   sed1330_t *sed1330 = get_safe_token(device);
381   const sed1330_interface *intf = get_interface(device);
382
383   /* resolve callbacks */
384   devcb_resolve_read8(&sed1330->in_vd_func, &intf->in_vd_func, device);
385   devcb_resolve_write8(&sed1330->out_vd_func, &intf->out_vd_func, device);
386
387   /* get the screen device */
388   sed1330->screen = devtag_get_device(device->machine, intf->screen_tag);
389   assert(sed1330->screen != NULL);
390
391   /* create the busy timer */
392   sed1330->busy_timer = timer_alloc(device->machine, busy_tick, (void *)device);
393
394   /* register for state saving */
395//   state_save_register_device_item(device, 0, sed1330->);
396}
397
398/*-------------------------------------------------
399    DEVICE_RESET( sed1330 )
400-------------------------------------------------*/
401
402static DEVICE_RESET( sed1330 )
403{
404//   sed1330_t *sed1330 = get_safe_token(device);
405
406}
407
408/*-------------------------------------------------
409    DEVICE_GET_INFO( sed1330 )
410-------------------------------------------------*/
411
412DEVICE_GET_INFO( sed1330 )
413{
414   switch (state)
415   {
416      /* --- the following bits of info are returned as 64-bit signed integers --- */
417      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(sed1330_t);                  break;
418      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                              break;
419      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;               break;
420
421      /* --- the following bits of info are returned as pointers to data or functions --- */
422      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(sed1330);         break;
423      case DEVINFO_FCT_STOP:                     /* Nothing */                              break;
424      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(sed1330);         break;
425
426      /* --- the following bits of info are returned as NULL-terminated strings --- */
427      case DEVINFO_STR_NAME:                     strcpy(info->s, " SED1330");               break;
428      case DEVINFO_STR_FAMILY:                  strcpy(info->s, " SED1330");               break;
429      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                        break;
430      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                     break;
431      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");            break;
432   }
433}
src/mess/video/sed1330.h
r0r4833
1/**********************************************************************
2
3    SED1330 LCD Controller emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#ifndef __SED1330__
11#define __SED1330__
12
13#include "driver.h"
14#include "devcb.h"
15
16/***************************************************************************
17    MACROS / CONSTANTS
18***************************************************************************/
19
20#define SED1330 DEVICE_GET_INFO_NAME( sed1330 )
21
22#define MDRV_SED1330_ADD(_tag, _clock, _config) \
23   MDRV_DEVICE_ADD(_tag, SED1330, _clock) \
24   MDRV_DEVICE_CONFIG(_config)
25
26#define SED1330_INTERFACE(name) \
27   const sed1330_interface (name) =
28
29/***************************************************************************
30    TYPE DEFINITIONS
31***************************************************************************/
32
33typedef struct _sed1330_interface sed1330_interface;
34struct _sed1330_interface
35{
36   const char *screen_tag;      /* screen we are acting on */
37
38   devcb_read8            in_vd_func;
39   devcb_write8         out_vd_func;
40};
41
42/***************************************************************************
43    PROTOTYPES
44***************************************************************************/
45
46/* device interface */
47DEVICE_GET_INFO( sed1330 );
48
49/* register access */
50READ8_DEVICE_HANDLER( sed1330_status_r );
51WRITE8_DEVICE_HANDLER( sed1330_command_w );
52
53/* memory access */
54READ8_DEVICE_HANDLER( sed1330_data_r );
55WRITE8_DEVICE_HANDLER( sed1330_data_w );
56
57/* screen update */
58void sed1330_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect);
59
60#endif
src/mess/includes/pc8401a.h
r4832r4833
66#define PPI8255_TAG      "ppi8255"
77#define UPD1990A_TAG   "upd1990a"
88#define AY8910_TAG      "ay8910"
9#define SED1330_TAG      "sed1330"
910
1011#define PC8401A_VIDEORAM_SIZE   0x2000
1112#define PC8401A_VIDEORAM_MASK   0x1fff
r4832r4833
2627   UINT8 *video_ram;      /* video RAM */
2728
2829   const device_config *upd1990a;
30   const device_config *sed1330;
2931};
3032
3133#endif
src/mess/mess.mak
r4832r4833
758758   $(MESS_VIDEO)/pc_t1t.o   
759759
760760$(MESSOBJ)/pc8401a.a:      \
761   $(MESS_DRIVERS)/pc8401a.o
761   $(MESS_DRIVERS)/pc8401a.o \
762   $(MESS_VIDEO)/sed1330.o
762763
763764$(MESSOBJ)/at.a:      \
764765   $(MESS_MACHINE)/pc_ide.o   \
src/mess/drivers/pc8401a.c
r4832r4833
44#include "machine/8255ppi.h"
55#include "machine/upd1990a.h"
66#include "sound/ay8910.h"
7#include "video/sed1330.h"
78#include "cpu/z80/z80.h"
89
910/*
r4832r4833
383384   AM_RANGE(0x40, 0x40) AM_READWRITE(rtc_r, rtc_ctrl_w)
384385//   AM_RANGE(0x41, 0x41)
385386//   AM_RANGE(0x50, 0x51) USART?
386//   AM_RANGE(0x60, 0x61) LCD controller (60=data, 61=cmd)
387   AM_RANGE(0x60, 0x60) AM_DEVREADWRITE(SED1330_TAG, sed1330_data_r, sed1330_data_w)
388   AM_RANGE(0x61, 0x61) AM_DEVREADWRITE(SED1330_TAG, sed1330_status_r, sed1330_command_w)
387389//   AM_RANGE(0x70, 0x71)
388390//   AM_RANGE(0x80, 0x80) modem status, set to 0xff to boot
389391//   AM_RANGE(0x90, 0x93)
r4832r4833
555557{
556558   pc8401a_state *state = screen->machine->driver_data;
557559
558   int y, sx, x;
559   UINT16 addr = 0;
560   sed1330_update(state->sed1330, bitmap, cliprect);
560561
561   for (y = 0; y < 200; y++)
562   {
563      for (sx = 0; sx < 80; sx++)
564      {
565         UINT8 data = state->video_ram[addr & PC8500_VIDEORAM_MASK];
562   return 0;
563}
566564
567         for (x = 0; x < 6; x++)
568         {
569            *BITMAP_ADDR16(bitmap, y, (sx * 6) + x) = BIT(data, 0);
570            data >>= 1;
571         }
565static READ8_DEVICE_HANDLER( pc8500_sed1330_vd_r )
566{
567   pc8401a_state *state = device->machine->driver_data;
572568
573         addr++;
574      }
575   }
569   return state->video_ram[offset & PC8500_VIDEORAM_MASK];
570}
576571
577   return 0;
572static WRITE8_DEVICE_HANDLER( pc8500_sed1330_vd_w )
573{
574   pc8401a_state *state = device->machine->driver_data;
575
576   state->video_ram[offset & PC8500_VIDEORAM_MASK] = data;
578577}
579578
579static SED1330_INTERFACE( pc8500_sed1330_config )
580{
581   SCREEN_TAG,
582   DEVCB_DEVICE_HANDLER(SED1330_TAG, pc8500_sed1330_vd_r),
583   DEVCB_DEVICE_HANDLER(SED1330_TAG, pc8500_sed1330_vd_w)
584};
585
580586/* uPD1990A Interface */
581587
582588static WRITE_LINE_DEVICE_HANDLER( pc8401a_upd1990a_data_w )
r4832r4833
673679   MDRV_PALETTE_INIT(pc8401a)
674680   MDRV_VIDEO_UPDATE(pc8500)
675681
682   MDRV_SED1330_ADD(SED1330_TAG, 0, pc8500_sed1330_config)
683
676684   /* sound hardware */
677685   MDRV_SPEAKER_STANDARD_MONO("mono")
678686   MDRV_SOUND_ADD(AY8910_TAG, AY8910, 4000000)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team