Previous 15994 Revisions Next

r4448 Monday 30th March, 2009 at 13:28:43 UTC by Curt Coder
[MIKROMIKKO] Added uPD7220 stuff.
[src/mess/drivers]mikromik.c
[src/mess/video]upd7220.c upd7220.h

src/mess/video/upd7220.c
r4447r4448
22#include "upd7220.h"
33 
44/***************************************************************************
5    PARAMETERS
6***************************************************************************/
7 
8#define UPD7220_COMMAND_RESET   0x00
9#define UPD7220_COMMAND_SYNC   0x0e // & 0xfe
10#define UPD7220_COMMAND_VSYNC   0x6e // & 0xfe
11#define UPD7220_COMMAND_CCHAR   0x4b
12#define UPD7220_COMMAND_START   0x6b
13#define UPD7220_COMMAND_BCTRL   0x0c // & 0xfe
14#define UPD7220_COMMAND_ZOOM   0x46
15#define UPD7220_COMMAND_CURS   0x49
16#define UPD7220_COMMAND_PRAM   0x70 // & 0xf0
17#define UPD7220_COMMAND_PITCH   0x47
18#define UPD7220_COMMAND_WDAT   0x20 // & 0xe4
19#define UPD7220_COMMAND_MASK   0x4a
20#define UPD7220_COMMAND_FIGS   0x4c
21#define UPD7220_COMMAND_FIGD   0x6c
22#define UPD7220_COMMAND_GCHRD   0x68
23#define UPD7220_COMMAND_RDAT   0xa0 // & 0xe4
24#define UPD7220_COMMAND_CURD   0xe0
25#define UPD7220_COMMAND_LPRD   0xc0
26#define UPD7220_COMMAND_DMAR   0xa4 // & 0xe4
27#define UPD7220_COMMAND_DMAW   0x24 // & 0xe4
28 
29#define UPD7220_SR_DATA_READY         0x01
30#define UPD7220_SR_FIFO_FULL         0x02
31#define UPD7220_SR_FIFO_EMPTY         0x04
32#define UPD7220_SR_DRAWING_IN_PROGRESS   0x08
33#define UPD7220_SR_DMA_EXECUTE         0x10
34#define UPD7220_SR_VSYNC_ACTIVE         0x20
35#define UPD7220_SR_HBLANK_ACTIVE      0x40
36#define UPD7220_SR_LIGHT_PEN_DETECT      0x80
37 
38/***************************************************************************
539    TYPE DEFINITIONS
640***************************************************************************/
741 
842typedef struct _upd7220_t upd7220_t;
943struct _upd7220_t
1044{
45   devcb_resolved_read8      in_data_func;
46   devcb_resolved_write8      out_data_func;
1147   devcb_resolved_write_line   out_drq_func;
1248   devcb_resolved_write_line   out_hsync_func;
1349   devcb_resolved_write_line   out_vsync_func;
50   devcb_resolved_write_line   out_blank_func;
1451 
52   int clock;                   
53 
54   UINT8 ra[16];               /* parameter RAM */
55 
56   UINT8 sr;                  /* status register */
57   UINT8 mode;                  /* mode of operation */
58 
59   int de;                     /* display enabled */
60   int aw;                     /* active display words per line - 2 (must be even number with bit 0 = 0) */
61   int al;                     /* active display lines per video field */
62   int vs;                     /* vertical sync width - 1 */
63   int vfp;                  /* vertical front porch width - 1 */
64   int vbp;                  /* vertical back porch width - 1 */
65   int hs;                     /* horizontal sync width - 1 */
66   int hfp;                  /* horizontal front porch width - 1 */
67   int hbp;                  /* horizontal back porch width - 1 */
68   int m;                     /* 0 = accept external vertical sync (slave mode) / 1 = generate & output vertical sync (master mode) */
69 
70   int dc;                     /* display cursor */
71   int sc;                     /* 0 = blinking cursor / 1 = steady cursor */
72   int br;                     /* blink rate */
73   int lr;                     /* lines per character row - 1 */
74   int ctop;                  /* cursor top line number in the row */
75   int cbot;                  /* cursor bottom line number in the row (CBOT < LR) */
76   UINT32 ead;                  /* execute word address */
77   UINT16 dad;                  /* dot address within the word */
78   UINT32 lad;                  /* light pen address */
79   
80   int disp;                  /* display zoom factor */
81   int gchr;                  /* zoom factor for graphics character writing and area filling */
82   UINT16 mask;               /* mask register */
83   UINT8 pitch;               /* number of word addresses in display memory in the horizontal direction */
84 
85   /* timers */
86   emu_timer *vsync_timer;         /* vertical sync timer */
87   emu_timer *hsync_timer;         /* horizontal sync timer */
88   emu_timer *blank_timer;         /* CRT blanking timer */
89 
1590   const device_config *screen;   /* screen */
1691};
1792 
r4447r4448
2398{
2499   assert(device != NULL);
25100   assert(device->token != NULL);
26 
27101   return (upd7220_t *)device->token;
28102}
29103 
r4447r4448
34108   return (const upd7220_interface *) device->static_config;
35109}
36110 
111INLINE void queue(upd7220_t *upd7220, UINT8 data, int command)
112{
113}
114 
115INLINE UINT16 dequeue(upd7220_t *upd7220)
116{
117   return 0;
118}
119 
37120/***************************************************************************
38121    IMPLEMENTATION
39122***************************************************************************/
40123 
41124/*-------------------------------------------------
125    recompute_parameters - 
126-------------------------------------------------*/
127#ifdef UNUSED_FUNCTION
128static void recompute_parameters(upd7220_t *upd7220)
129{
130   rectangle visarea;
131 
132   int horiz_pix_total;
133   int vert_pix_total;
134 
135   attoseconds_t refresh = HZ_TO_ATTOSECONDS(upd7220->clock) * (upd7220->aw + 2) * upd7220->al;
136 
137   visarea.min_x = upd7220->hs + upd7220->hbp + 1;
138   visarea.min_y = upd7220->vs + upd7220->vbp + 1;
139   visarea.max_x = 0;
140   visarea.max_y = upd7220->al + 2 - upd7220->vfp;
141 
142   video_screen_configure(upd7220->screen, horiz_pix_total, vert_pix_total, &visarea, refresh);
143}
144#endif
145/*-------------------------------------------------
146    update_vsync_timer - 
147-------------------------------------------------*/
148 
149static void update_vsync_timer(upd7220_t *upd7220, int state)
150{
151   int next_y = state ? (upd7220->vs + 1) : 0;
152 
153   attotime duration = video_screen_get_time_until_pos(upd7220->screen, next_y, 0);
154 
155   timer_adjust_oneshot(upd7220->vsync_timer, duration, !state);
156}
157 
158/*-------------------------------------------------
159    TIMER_CALLBACK( vsync_tick )
160-------------------------------------------------*/
161 
162static TIMER_CALLBACK( vsync_tick )
163{
164   const device_config *device = ptr;
165   upd7220_t *upd7220 = get_safe_token(device);
166 
167   devcb_call_write_line(&upd7220->out_vsync_func, param);
168 
169   update_vsync_timer(upd7220, param);
170}
171 
172/*-------------------------------------------------
173    update_hsync_timer - 
174-------------------------------------------------*/
175 
176static void update_hsync_timer(upd7220_t *upd7220, int state)
177{
178   int y = video_screen_get_vpos(upd7220->screen);
179 
180   int next_x = state ? upd7220->hs : 0;
181   int next_y = state ? y : ((y + 1) % upd7220->al);
182 
183   attotime duration = video_screen_get_time_until_pos(upd7220->screen, next_y, next_x);
184 
185   timer_adjust_oneshot(upd7220->hsync_timer, duration, !state);
186}
187 
188/*-------------------------------------------------
189    TIMER_CALLBACK( hsync_tick )
190-------------------------------------------------*/
191 
192static TIMER_CALLBACK( hsync_tick )
193{
194   const device_config *device = ptr;
195   upd7220_t *upd7220 = get_safe_token(device);
196 
197   devcb_call_write_line(&upd7220->out_hsync_func, param);
198 
199   update_hsync_timer(upd7220, param);
200}
201 
202/*-------------------------------------------------
203    update_blank_timer - 
204-------------------------------------------------*/
205 
206static void update_blank_timer(upd7220_t *upd7220, int state)
207{
208   int y = video_screen_get_vpos(upd7220->screen);
209 
210   int next_x = state ? (upd7220->hs + upd7220->hbp + 1) : 0;
211   int next_y = state ? y : ((y + 1) % upd7220->al);
212 
213   attotime duration = video_screen_get_time_until_pos(upd7220->screen, next_y, next_x);
214 
215   timer_adjust_oneshot(upd7220->hsync_timer, duration, !state);
216}
217 
218/*-------------------------------------------------
219    TIMER_CALLBACK( blank_tick )
220-------------------------------------------------*/
221 
222static TIMER_CALLBACK( blank_tick )
223{
224   const device_config *device = ptr;
225   upd7220_t *upd7220 = get_safe_token(device);
226 
227   devcb_call_write_line(&upd7220->out_blank_func, param);
228 
229   update_blank_timer(upd7220, param);
230}
231 
232/*-------------------------------------------------
233    process_command - process command
234-------------------------------------------------*/
235 
236#ifdef UNUSED_CODE
237static void process_command(upd7220_t *upd7220, UINT8 data)
238{
239   switch (data)
240   {
241   case UPD7220_COMMAND_RESET:
242      break;
243   case UPD7220_COMMAND_CCHAR:
244      break;
245   case UPD7220_COMMAND_START:
246      break;
247   case UPD7220_COMMAND_ZOOM:
248      break;
249   case UPD7220_COMMAND_CURS:
250      break;
251   case UPD7220_COMMAND_PITCH:
252      break;
253   case UPD7220_COMMAND_MASK:
254      break;
255   case UPD7220_COMMAND_FIGS:
256      break;
257   case UPD7220_COMMAND_FIGD:
258      break;
259   case UPD7220_COMMAND_CURD:
260      break;
261   case UPD7220_COMMAND_LPRD:
262      break;
263   default:
264      switch (data & 0xfe)
265      {
266      case UPD7220_COMMAND_SYNC:
267         break;
268      case UPD7220_COMMAND_VSYNC:
269         break;
270      case UPD7220_COMMAND_BCTRL:
271         break;
272      default:
273         switch (data & 0xf0)
274         {
275         case UPD7220_COMMAND_PRAM:
276         default:
277            switch (data & 0xe4)
278            {
279            case UPD7220_COMMAND_WDAT:
280               break;
281            case UPD7220_COMMAND_RDAT:
282               break;
283            case UPD7220_COMMAND_DMAR:
284               break;
285            case UPD7220_COMMAND_DMAW:
286               break;
287            default:
288               logerror("Invalid command %02x\n", data);
289            }
290         }
291      }
292   }
293}
294#endif
295 
296/*-------------------------------------------------
42297    upd7220_r - register read
43298-------------------------------------------------*/
44299 
45300READ8_DEVICE_HANDLER( upd7220_r )
46301{
47   return 0;
302   upd7220_t *upd7220 = get_safe_token(device);
303 
304   UINT8 data;
305 
306   if (offset & 1)
307   {
308      /* FIFO read */
309      data = dequeue(upd7220);
310   }
311   else
312   {
313      /* status register */
314      data = upd7220->sr;
315   }
316 
317   return data;
48318}
49319 
50320/*-------------------------------------------------
r4447r4448
53323 
54324WRITE8_DEVICE_HANDLER( upd7220_w )
55325{
326   upd7220_t *upd7220 = get_safe_token(device);
327 
328   if (offset & 1)
329   {
330      /* command into FIFO */
331      queue(upd7220, data, 1);
332   }
333   else
334   {
335      /* parameter into FIFO */
336      queue(upd7220, data, 0);
337   }
56338}
57339 
58340/*-------------------------------------------------
r4447r4448
64346}
65347 
66348/*-------------------------------------------------
349    upd7220_lpen_w - light pen strobe
350-------------------------------------------------*/
351 
352void upd7220_lpen_w(const device_config *device, int state)
353{
354}
355 
356/*-------------------------------------------------
357    ROM( upd7220 )
358-------------------------------------------------*/
359 
360ROM_START( upd7220 )
361   ROM_REGION( 0x100, "upd7220", ROMREGION_LOADBYNAME )
362   ROM_LOAD( "upd7220.bin", 0x000, 0x100, NO_DUMP ) /* internal 128x14 control ROM */
363ROM_END
364 
365/*-------------------------------------------------
67366    DEVICE_START( upd7220 )
68367-------------------------------------------------*/
69368 
r4447r4448
73372   const upd7220_interface *intf = get_interface(device);
74373 
75374   /* resolve callbacks */
375   devcb_resolve_read8(&upd7220->in_data_func, &intf->in_data_func, device);
376   devcb_resolve_write8(&upd7220->out_data_func, &intf->out_data_func, device);
76377   devcb_resolve_write_line(&upd7220->out_drq_func, &intf->out_drq_func, device);
77378   devcb_resolve_write_line(&upd7220->out_hsync_func, &intf->out_hsync_func, device);
78379   devcb_resolve_write_line(&upd7220->out_vsync_func, &intf->out_vsync_func, device);
r4447r4448
80381   /* get the screen device */
81382   upd7220->screen = devtag_get_device(device->machine, intf->screen_tag);
82383   assert(upd7220->screen != NULL);
384 
385   /* create the timers */
386   upd7220->vsync_timer = timer_alloc(device->machine, vsync_tick, (void *)device);
387   upd7220->hsync_timer = timer_alloc(device->machine, hsync_tick, (void *)device);
388   upd7220->blank_timer = timer_alloc(device->machine, blank_tick, (void *)device);
389 
390   /* register for state saving */
391   state_save_register_device_item_array(device, 0, upd7220->ra);
392   state_save_register_device_item(device, 0, upd7220->sr);
393   state_save_register_device_item(device, 0, upd7220->mode);
394   state_save_register_device_item(device, 0, upd7220->de);
395   state_save_register_device_item(device, 0, upd7220->aw);
396   state_save_register_device_item(device, 0, upd7220->al);
397   state_save_register_device_item(device, 0, upd7220->vs);
398   state_save_register_device_item(device, 0, upd7220->vfp);
399   state_save_register_device_item(device, 0, upd7220->vbp);
400   state_save_register_device_item(device, 0, upd7220->hs);
401   state_save_register_device_item(device, 0, upd7220->hfp);
402   state_save_register_device_item(device, 0, upd7220->hbp);
403   state_save_register_device_item(device, 0, upd7220->m);
404   state_save_register_device_item(device, 0, upd7220->dc);
405   state_save_register_device_item(device, 0, upd7220->sc);
406   state_save_register_device_item(device, 0, upd7220->br);
407   state_save_register_device_item(device, 0, upd7220->lr);
408   state_save_register_device_item(device, 0, upd7220->ctop);
409   state_save_register_device_item(device, 0, upd7220->cbot);
410   state_save_register_device_item(device, 0, upd7220->ead);
411   state_save_register_device_item(device, 0, upd7220->dad);
412   state_save_register_device_item(device, 0, upd7220->lad);
413   state_save_register_device_item(device, 0, upd7220->disp);
414   state_save_register_device_item(device, 0, upd7220->gchr);
415   state_save_register_device_item(device, 0, upd7220->mask);
416   state_save_register_device_item(device, 0, upd7220->pitch);
83417}
84418 
85419/*-------------------------------------------------
r4447r4448
118452      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                              break;
119453      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;               break;
120454 
455      /* --- the following bits of info are returned as pointers --- */
456      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(upd7220);            break;
457 
121458      /* --- the following bits of info are returned as pointers to data or functions --- */
122459      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(upd7220);      break;
123460      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(upd7220);         break;
src/mess/video/upd7220.h
r4447r4448
1919    TYPE DEFINITIONS
2020***************************************************************************/
2121 
22typedef void (*upd7220_display_pixels_func)(const device_config *device, int y, int x, UINT16 ad, UINT8 lc, int atblink, int csr, int csr_image);
23#define UPD7220_DISPLAY_PIXELS(name) void name(const device_config *device, int y, int x, UINT16 ad, UINT8 lc, int atblink, int csr, int csr_image)
24 
2225typedef struct _upd7220_interface upd7220_interface;
2326struct _upd7220_interface
2427{
2528   const char *screen_tag;      /* screen we are acting on */
2629 
30   int                  hpixels_per_column;
31 
32   upd7220_display_pixels_func   display;
33 
34   /* this gets called for every video memory read */
35   devcb_read8            in_data_func;
36 
37   /* this gets called for every video memory write */
38   devcb_write8         out_data_func;
39 
2740   /* this gets called for every change of the DRQ pin (pin 7) */
2841   devcb_write_line      out_drq_func;
2942 
r4447r4448
3245 
3346   /* this gets called for every change of the VSYNC pin (pin 4) */
3447   devcb_write_line      out_vsync_func;
48 
49   /* this gets called for every change of the BLANK pin (pin 5) */
50   devcb_write_line      out_blank_func;
3551};
3652 
3753/***************************************************************************
r4447r4448
5066/* dma acknowledge with write */
5167WRITE8_DEVICE_HANDLER( upd7220_dack_w );
5268 
69/* light pen strobe */
70void upd7220_lpen_w(const device_config *device, int state);
71 
5372/* screen update */
5473void upd7220_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect);
5574 
src/mess/drivers/mikromik.c
r4447r4448
5353   crtc_display_pixels
5454};
5555
56static UPD7220_DISPLAY_PIXELS( hgdc_display_pixels )
57{
58}
59
5660static WRITE_LINE_DEVICE_HANDLER( hgdc_drq_w )
5761{
5862   mm1_state *driver_state = device->machine->driver_data;
r4447r4448
6367static UPD7220_INTERFACE( mm1_upd7220_intf )
6468{
6569   SCREEN_TAG,
70   8,
71   hgdc_display_pixels,
72   DEVCB_NULL,
73   DEVCB_NULL,
6674   DEVCB_LINE(hgdc_drq_w),
6775   DEVCB_NULL,
76   DEVCB_NULL,
6877   DEVCB_NULL
6978};
7079

Previous 15994 Revisions Next


© 1998-2018 The MESS Team